Commit ffa4ddae authored by Simo Sorce's avatar Simo Sorce Committed by Christian Heimes

Cyrptography deprecated signer and verifier

Use sign() and verify() directly instead.
Signed-off-by: 's avatarSimo Sorce <simo@redhat.com>
parent f38ff2c3
...@@ -122,15 +122,11 @@ class _RawRSA(_RawJWS): ...@@ -122,15 +122,11 @@ class _RawRSA(_RawJWS):
def sign(self, key, payload): def sign(self, key, payload):
skey = key.get_op_key('sign') skey = key.get_op_key('sign')
signer = skey.signer(self.padfn, self.hashfn) return skey.sign(payload, self.padfn, self.hashfn)
signer.update(payload)
return signer.finalize()
def verify(self, key, payload, signature): def verify(self, key, payload, signature):
pkey = key.get_op_key('verify') pkey = key.get_op_key('verify')
verifier = pkey.verifier(signature, self.padfn, self.hashfn) pkey.verify(signature, payload, self.padfn, self.hashfn)
verifier.update(payload)
verifier.verify()
class _RawEC(_RawJWS): class _RawEC(_RawJWS):
...@@ -144,9 +140,7 @@ class _RawEC(_RawJWS): ...@@ -144,9 +140,7 @@ class _RawEC(_RawJWS):
def sign(self, key, payload): def sign(self, key, payload):
skey = key.get_op_key('sign', self._curve) skey = key.get_op_key('sign', self._curve)
signer = skey.signer(ec.ECDSA(self.hashfn)) signature = skey.sign(payload, ec.ECDSA(self.hashfn))
signer.update(payload)
signature = signer.finalize()
r, s = ec_utils.decode_rfc6979_signature(signature) r, s = ec_utils.decode_rfc6979_signature(signature)
l = key.get_curve(self._curve).key_size l = key.get_curve(self._curve).key_size
return _encode_int(r, l) + _encode_int(s, l) return _encode_int(r, l) + _encode_int(s, l)
...@@ -157,9 +151,7 @@ class _RawEC(_RawJWS): ...@@ -157,9 +151,7 @@ class _RawEC(_RawJWS):
s = signature[len(signature) // 2:] s = signature[len(signature) // 2:]
enc_signature = ec_utils.encode_rfc6979_signature( enc_signature = ec_utils.encode_rfc6979_signature(
int(hexlify(r), 16), int(hexlify(s), 16)) int(hexlify(r), 16), int(hexlify(s), 16))
verifier = pkey.verifier(enc_signature, ec.ECDSA(self.hashfn)) pkey.verify(enc_signature, payload, ec.ECDSA(self.hashfn))
verifier.update(payload)
verifier.verify()
class _RawNone(_RawJWS): class _RawNone(_RawJWS):
......
...@@ -23,7 +23,7 @@ setup( ...@@ -23,7 +23,7 @@ setup(
], ],
data_files = [('share/doc/jwcrypto', ['LICENSE', 'README.md'])], data_files = [('share/doc/jwcrypto', ['LICENSE', 'README.md'])],
install_requires = [ install_requires = [
'cryptography >= 0.7.2', 'cryptography >= 1.5',
], ],
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment