]>
Commit | Line | Data |
---|---|---|
51719893 | 1 | #!/usr/bin/env python3 |
dcddc10a | 2 | from __future__ import unicode_literals, with_statement |
067f6a35 FV |
3 | |
4 | import rsa | |
5 | import json | |
6 | from binascii import hexlify | |
7 | ||
1841f65e PH |
8 | try: |
9 | input = raw_input | |
10 | except NameError: | |
11 | pass | |
12 | ||
067f6a35 FV |
13 | versions_info = json.load(open('update/versions.json')) |
14 | if 'signature' in versions_info: | |
5f6a1245 | 15 | del versions_info['signature'] |
067f6a35 | 16 | |
067f6a35 | 17 | print('Enter the PKCS1 private key, followed by a blank line:') |
1841f65e | 18 | privkey = b'' |
067f6a35 | 19 | while True: |
5f6a1245 JW |
20 | try: |
21 | line = input() | |
22 | except EOFError: | |
23 | break | |
24 | if line == '': | |
25 | break | |
26 | privkey += line.encode('ascii') + b'\n' | |
067f6a35 FV |
27 | privkey = rsa.PrivateKey.load_pkcs1(privkey) |
28 | ||
29 | signature = hexlify(rsa.pkcs1.sign(json.dumps(versions_info, sort_keys=True).encode('utf-8'), privkey, 'SHA-256')).decode() | |
30 | print('signature: ' + signature) | |
31 | ||
32 | versions_info['signature'] = signature | |
dcddc10a PH |
33 | with open('update/versions.json', 'w') as versionsf: |
34 | json.dump(versions_info, versionsf, indent=4, sort_keys=True) |