From df6ddab2cf4b89f94f9cfaf552626cd4487db1bf Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Tue, 10 Oct 2017 09:05:43 +0300 Subject: [PATCH] gpg: add compression and stronger digests --- libagent/gpg/encode.py | 4 ++-- libagent/gpg/protocol.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libagent/gpg/encode.py b/libagent/gpg/encode.py index d556ed6..516b16e 100644 --- a/libagent/gpg/encode.py +++ b/libagent/gpg/encode.py @@ -23,9 +23,9 @@ def create_primary(user_id, pubkey, signer_func, secret_bytes=b''): # https://tools.ietf.org/html/rfc4880#section-5.2.3.4 protocol.subpacket_byte(0x1B, 1 | 2), # key flags (certify & sign) # https://tools.ietf.org/html/rfc4880#section-5.2.3.21 - protocol.subpacket_byte(0x15, 8), # preferred hash (SHA256) + protocol.subpacket_bytes(0x15, [8, 9, 10]), # preferred hash # https://tools.ietf.org/html/rfc4880#section-5.2.3.8 - protocol.subpacket_byte(0x16, 0), # preferred compression (none) + protocol.subpacket_bytes(0x16, [2, 3, 1]), # preferred compression # https://tools.ietf.org/html/rfc4880#section-5.2.3.9 protocol.subpacket_byte(0x17, 0x80) # key server prefs (no-modify) # https://tools.ietf.org/html/rfc4880#section-5.2.3.17 diff --git a/libagent/gpg/protocol.py b/libagent/gpg/protocol.py index f9ca4b4..68bb7f8 100644 --- a/libagent/gpg/protocol.py +++ b/libagent/gpg/protocol.py @@ -47,6 +47,11 @@ def subpacket_byte(subpacket_type, value): return subpacket(subpacket_type, '>B', value) +def subpacket_bytes(subpacket_type, values): + """Create GPG subpacket with 8-bit unsigned integers.""" + return subpacket(subpacket_type, '>' + 'B'*len(values), *values) + + def subpacket_prefix_len(item): """Prefix subpacket length according to RFC 4880 section-5.2.3.1.""" n = len(item)