Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libagent/gpg/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def create_subkey(primary_bytes, subkey, signer_func, secret_bytes=b''):
unhashed_subpackets.append(protocol.subpacket(32, embedded_sig))
unhashed_subpackets.append(protocol.CUSTOM_SUBPACKET)

if not decode.has_custom_subpacket(signature):
signer_func = keyring.create_agent_signer(user_id['value'])
# Allow signing with existing GnuPG keyring (for adding TREZOR-based subkeys)
signer_func = keyring.create_agent_signer(user_id['value'])

signature = protocol.make_signature(
signer_func=signer_func,
Expand Down
4 changes: 0 additions & 4 deletions libagent/gpg/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ def keygrip_curve25519(vk):

ECDH_ALGO_ID = 18

CUSTOM_KEY_LABEL = b'TREZOR-GPG' # marks "our" pubkey
CUSTOM_SUBPACKET_ID = 26 # use "policy URL" subpacket
CUSTOM_SUBPACKET = subpacket(CUSTOM_SUBPACKET_ID, CUSTOM_KEY_LABEL)


def get_curve_name_by_oid(oid):
"""Return curve name matching specified OID, or raise KeyError."""
Expand Down
13 changes: 0 additions & 13 deletions libagent/gpg/tests/test_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,6 @@ def test_gpg_files(public_key_path): # pylint: disable=redefined-outer-name
assert list(decode.parse_packets(f))


def test_has_custom_subpacket():
sig = {'unhashed_subpackets': []}
assert not decode.has_custom_subpacket(sig)

custom_markers = [
protocol.CUSTOM_SUBPACKET,
protocol.subpacket(10, protocol.CUSTOM_KEY_LABEL),
]
for marker in custom_markers:
sig = {'unhashed_subpackets': [marker]}
assert decode.has_custom_subpacket(sig)


def test_load_by_keygrip_missing():
with pytest.raises(KeyError):
decode.load_by_keygrip(pubkey_bytes=b'', keygrip=b'')