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