mirror of
https://github.com/romanz/amodem.git
synced 2026-04-18 20:25:59 +08:00
gpg: refactor pubkeys' parsing code
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import logging
|
||||
import time
|
||||
|
||||
from . import keyring, proto
|
||||
from . import decode, keyring, proto
|
||||
from .. import client, factory, formats, util
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -136,10 +136,10 @@ class Factory(object):
|
||||
sign_packet = proto.packet(tag=2, blob=signature)
|
||||
return pubkey_packet + user_id_packet + sign_packet
|
||||
|
||||
def create_subkey(self):
|
||||
def create_subkey(self, primary_bytes):
|
||||
"""Export new subkey to `self.user_id` GPG primary key."""
|
||||
subkey_packet = proto.packet(tag=14, blob=self.pubkey.data())
|
||||
primary = keyring.get_public_key(self.user_id)
|
||||
primary = decode.load_public_key(primary_bytes)
|
||||
log.info('adding subkey to primary GPG key "%s" (%s)',
|
||||
self.user_id, util.hexlify(primary['key_id']))
|
||||
data_to_sign = primary['_to_hash'] + self.pubkey.data_to_hash()
|
||||
@@ -176,7 +176,7 @@ class Factory(object):
|
||||
hashed_subpackets=hashed_subpackets,
|
||||
unhashed_subpackets=unhashed_subpackets)
|
||||
sign_packet = proto.packet(tag=2, blob=signature)
|
||||
return subkey_packet + sign_packet
|
||||
return primary_bytes + subkey_packet + sign_packet
|
||||
|
||||
def sign_message(self, msg, sign_time=None):
|
||||
"""Sign GPG message at specified time."""
|
||||
|
||||
Reference in New Issue
Block a user