File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 66import argparse
77import os
88import struct
9- from hashlib import sha256
9+ from hashlib import sha256 , sha512
1010
1111from cryptography .hazmat .primitives import serialization
1212from cryptography .hazmat .primitives .asymmetric import ec , ed25519
@@ -174,7 +174,11 @@ def get_hashes(public_key_files, verify_hashes):
174174 hashes = list ()
175175 for fn in public_key_files :
176176 with open (fn , 'rb' ) as f :
177- digest = sha256 (public_key_to_string (load_pem_public_key (f .read ()))).digest ()[:16 ]
177+ key_data = load_pem_public_key (f .read ())
178+ if isinstance (key_data , ed25519 .Ed25519PublicKey ):
179+ digest = sha512 (public_key_to_string (key_data )).digest ()[:16 ]
180+ else :
181+ digest = sha256 (public_key_to_string (key_data )).digest ()[:16 ]
178182 if verify_hashes and any ([digest [n :n + 2 ] == b'\xff \xff ' for n in range (0 , len (digest ), 2 )]):
179183 raise RuntimeError (f"Hash of key in '{ os .path .abspath (f .name )} ' contains 0xffff. Please regenerate the key." )
180184 hashes .append (digest )
You can’t perform that action at this time.
0 commit comments