mirror of
https://github.com/romanz/amodem.git
synced 2026-03-25 11:51:02 +08:00
gpg: support more digests (with larger output than 256 bits)
NIST256 signs the prefix of a longer digest. Ed25519 signs the whole one.
This commit is contained in:
@@ -65,8 +65,7 @@ def open_connection(keygrip_bytes):
|
||||
|
||||
def pksign(keygrip, digest, algo):
|
||||
"""Sign a message digest using a private EC key."""
|
||||
assert algo == b'8', 'Unsupported hash algorithm ID {}'.format(algo)
|
||||
assert len(digest) == 64 # SHA-256 bits (in hex digits)
|
||||
log.debug('signing %r digest (algo #%s)', digest, algo)
|
||||
keygrip_bytes = binascii.unhexlify(keygrip)
|
||||
with open_connection(keygrip_bytes) as conn:
|
||||
r, s = conn.sign(binascii.unhexlify(digest))
|
||||
|
||||
@@ -37,6 +37,9 @@ class HardwareSigner(object):
|
||||
"""Sign the digest and return a serialized signature."""
|
||||
log.info('please confirm GPG signature on %s for "%s"...',
|
||||
self.client_wrapper.device_name, self.user_id)
|
||||
if self.curve_name == formats.CURVE_NIST256:
|
||||
digest = digest[:32] # sign the first 256 bits
|
||||
log.debug('signing digest: %s', util.hexlify(digest))
|
||||
result = self.client_wrapper.connection.sign_identity(
|
||||
identity=self.identity,
|
||||
challenge_hidden=digest,
|
||||
|
||||
Reference in New Issue
Block a user