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.

26 lines
638 B

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