diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-12-18 11:26:09 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-12-18 11:26:09 -0800 |
commit | eb3e117d29aa2e16b6ca0ff206062d36474f8bfd (patch) | |
tree | 85159799cfb227c48bda8be9d1a9658c1dad4fe4 /paramiko/dsskey.py | |
parent | b3884d2c44233f16cd334c4abcfddcf5e8bf8ef6 (diff) | |
download | paramiko-eb3e117d29aa2e16b6ca0ff206062d36474f8bfd.tar.gz |
A bunch of cleanup
Diffstat (limited to 'paramiko/dsskey.py')
-rw-r--r-- | paramiko/dsskey.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/paramiko/dsskey.py b/paramiko/dsskey.py index 6ea29d9c..2c90694f 100644 --- a/paramiko/dsskey.py +++ b/paramiko/dsskey.py @@ -24,9 +24,9 @@ from cryptography.exceptions import InvalidSignature from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import dsa - -from pyasn1.codec.der import encoder, decoder -from pyasn1.type import namedtype, univ +from cryptography.hazmat.primitives.asymmetric.utils import ( + decode_rfc6979_signature, encode_rfc6979_signature +) from paramiko import util from paramiko.common import zero_byte @@ -36,13 +36,6 @@ from paramiko.ber import BER, BERException from paramiko.pkey import PKey -class _DSSSigValue(univ.Sequence): - componentType = namedtype.NamedTypes( - namedtype.NamedType('r', univ.Integer()), - namedtype.NamedType('s', univ.Integer()) - ) - - class DSSKey(PKey): """ Representation of a DSS key which can be used to sign an verify SSH2 @@ -120,8 +113,7 @@ class DSSKey(PKey): ).private_key(backend=default_backend()) signer = key.signer(hashes.SHA1()) signer.update(data) - signature = signer.finalize() - (r, s), _ = decoder.decode(signature) + r, s = decode_rfc6979_signature(signer.finalize()) m = Message() m.add_string('ssh-dss') @@ -149,10 +141,7 @@ class DSSKey(PKey): sigR = util.inflate_long(sig[:20], 1) sigS = util.inflate_long(sig[20:], 1) - sig_asn1 = _DSSSigValue() - sig_asn1.setComponentByName('r', sigR) - sig_asn1.setComponentByName('s', sigS) - signature = encoder.encode(sig_asn1) + signature = encode_rfc6979_signature(sigR, sigS) key = dsa.DSAPublicNumbers( y=self.y, |