You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
820 B

10 years ago
10 years ago
10 years ago
  1. #!/usr/bin/env python3
  2. import rsa
  3. import json
  4. from binascii import hexlify
  5. try:
  6. input = raw_input
  7. except NameError:
  8. pass
  9. versions_info = json.load(open('update/versions.json'))
  10. if 'signature' in versions_info:
  11. del versions_info['signature']
  12. print('Enter the PKCS1 private key, followed by a blank line:')
  13. privkey = b''
  14. while True:
  15. try:
  16. line = input()
  17. except EOFError:
  18. break
  19. if line == '':
  20. break
  21. privkey += line.encode('ascii') + b'\n'
  22. privkey = rsa.PrivateKey.load_pkcs1(privkey)
  23. signature = hexlify(rsa.pkcs1.sign(json.dumps(versions_info, sort_keys=True).encode('utf-8'), privkey, 'SHA-256')).decode()
  24. print('signature: ' + signature)
  25. versions_info['signature'] = signature
  26. json.dump(versions_info, open('update/versions.json', 'w'), indent=4, sort_keys=True)