gpg: 1st try for RSA primary key support

This commit is contained in:
Roman Zeyde
2016-04-30 11:40:02 +03:00
parent 9ed9781496
commit f35b5be3ac
2 changed files with 8 additions and 6 deletions

View File

@@ -94,7 +94,7 @@ def _parse_rsa_sig(sig):
return (util.bytes2num(sig_s),)
def sign(sock, keygrip, digest, algo='ecdsa'):
def sign(sock, keygrip, digest, algo='rsa'):
"""Sign a digest using specified key using GPG agent."""
hash_algo = 8 # SHA256
assert len(digest) == 32

View File

@@ -146,8 +146,8 @@ class AgentSigner(object):
def sign(self, digest):
"""Sign the digest and return an ECDSA signature."""
r, s = agent.sign(sock=self.sock, keygrip=self.keygrip, digest=digest)
return mpi(r) + mpi(s)
s, = agent.sign(sock=self.sock, keygrip=self.keygrip, digest=digest)
return mpi(s)
def close(self):
"""Close the connection to gpg-agent."""
@@ -286,7 +286,8 @@ class Signer(object):
data_to_sign=data_to_sign,
sig_type=0x18,
hashed_subpackets=hashed_subpackets,
unhashed_subpackets=unhashed_subpackets)
unhashed_subpackets=unhashed_subpackets,
public_algo=1)
sign_packet = packet(tag=2, blob=signature)
return subkey_packet + sign_packet
@@ -310,12 +311,13 @@ class Signer(object):
def _make_signature(conn, data_to_sign,
hashed_subpackets, unhashed_subpackets, sig_type=0):
hashed_subpackets, unhashed_subpackets, sig_type=0,
public_algo=None):
curve_info = SUPPORTED_CURVES[conn.curve_name]
header = struct.pack('>BBBB',
4, # version
sig_type, # rfc4880 (section-5.2.1)
curve_info['algo_id'],
public_algo or curve_info['algo_id'],
8) # hash_alg (SHA256)
hashed = subpackets(*hashed_subpackets)
unhashed = subpackets(*unhashed_subpackets)