From 8108e5400d842a6894cb1e14deabfc1a2ad8a2ac Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Sat, 11 Jun 2016 13:47:56 +0300 Subject: [PATCH] gpg: support TREZOR-based primary key --- trezor_agent/gpg/decode.py | 1 + trezor_agent/gpg/encode.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/trezor_agent/gpg/decode.py b/trezor_agent/gpg/decode.py index 127f112..8cbb454 100644 --- a/trezor_agent/gpg/decode.py +++ b/trezor_agent/gpg/decode.py @@ -295,6 +295,7 @@ def load_public_key(pubkey_bytes, use_custom=False): packets = packets[2:] packet['user_id'] = userid['value'] + packet['_is_custom'] = signature['_is_custom'] return packet diff --git a/trezor_agent/gpg/encode.py b/trezor_agent/gpg/encode.py index 97c5b1d..9b5345f 100644 --- a/trezor_agent/gpg/encode.py +++ b/trezor_agent/gpg/encode.py @@ -135,7 +135,7 @@ def create_subkey(primary_bytes, pubkey, signer_func, ecdh=False): proto.subpacket_time(pubkey.created)] # signature time unhashed_subpackets = [ proto.subpacket(16, pubkey.key_id())] # issuer key id - log.info('confirm signing subkey with hardware device') + log.info('confirm signing with new subkey') embedded_sig = proto.make_signature( signer_func=signer_func, data_to_sign=data_to_sign, @@ -160,11 +160,12 @@ def create_subkey(primary_bytes, pubkey, signer_func, ecdh=False): unhashed_subpackets.append(proto.subpacket(32, embedded_sig)) unhashed_subpackets.append(proto.CUSTOM_SUBPACKET) - log.info('confirm signing subkey with gpg-agent') - # TODO: support TREZOR-based primary key - gpg_agent = AgentSigner(primary['user_id']) + log.info('confirm signing with primary key') + if not primary['_is_custom']: + signer_func = AgentSigner(primary['user_id']).sign + signature = proto.make_signature( - signer_func=gpg_agent.sign, + signer_func=signer_func, data_to_sign=data_to_sign, public_algo=primary['algo'], sig_type=0x18,