1 diff --git a/test/soft_u2f_v2.py b/test/soft_u2f_v2.py
2 index d011b1f..9a24bb9 100644
3 --- a/test/soft_u2f_v2.py
4 +++ b/test/soft_u2f_v2.py
5 @@ -112,9 +112,7 @@ class SoftU2FDevice(object):
6 CERT_PRIV, password=None, backend=default_backend())
8 data = b'\x00' + app_param + client_param + key_handle + pub_key
9 - signer = cert_priv.signer(ec.ECDSA(hashes.SHA256()))
11 - signature = signer.finalize()
12 + signature = cert_priv.sign(data, ec.ECDSA(hashes.SHA256()))
14 raw_response = (b'\x05' + pub_key + six.int2byte(len(key_handle)) +
15 key_handle + cert + signature)
16 @@ -163,9 +161,7 @@ class SoftU2FDevice(object):
17 counter = struct.pack('>I', self.counter)
19 data = app_param + touch + counter + client_param
20 - signer = priv_key.signer(ec.ECDSA(hashes.SHA256()))
22 - signature = signer.finalize()
23 + signature = priv_key.sign(data, ec.ECDSA(hashes.SHA256()))
24 raw_response = touch + counter + signature
27 diff --git a/u2flib_server/attestation/resolvers.py b/u2flib_server/attestation/resolvers.py
28 index 034549f..cd59b10 100644
29 --- a/u2flib_server/attestation/resolvers.py
30 +++ b/u2flib_server/attestation/resolvers.py
31 @@ -86,27 +86,29 @@ class MetadataResolver(object):
32 cert_bytes = cert.tbs_certificate_bytes
34 if isinstance(pubkey, rsa.RSAPublicKey):
35 - verifier = pubkey.verifier(
38 - cert.signature_hash_algorithm
45 + cert.signature_hash_algorithm
48 + except InvalidSignature:
50 elif isinstance(pubkey, ec.EllipticCurvePublicKey):
51 - verifier = pubkey.verifier(
53 - ec.ECDSA(cert.signature_hash_algorithm)
59 + ec.ECDSA(cert.signature_hash_algorithm)
62 + except InvalidSignature:
65 raise ValueError("Unsupported public key value")
67 - verifier.update(cert_bytes)
72 - except InvalidSignature:
75 def resolve(self, cert):
76 if isinstance(cert, bytes):
77 cert = x509.load_der_x509_certificate(cert, default_backend())
78 diff --git a/u2flib_server/model.py b/u2flib_server/model.py
79 index 481be51..6ec01bb 100644
80 --- a/u2flib_server/model.py
81 +++ b/u2flib_server/model.py
82 @@ -175,12 +175,9 @@ class RegistrationData(object):
83 cert = x509.load_der_x509_certificate(self.certificate,
85 pubkey = cert.public_key()
86 - verifier = pubkey.verifier(self.signature, ec.ECDSA(hashes.SHA256()))
88 - verifier.update(b'\0' + app_param + chal_param + self.key_handle +
90 + msg = (b'\0' + app_param + chal_param + self.key_handle + self.pub_key)
93 + pubkey.verify(self.signature, msg, ec.ECDSA(hashes.SHA256()))
94 except InvalidSignature:
95 raise ValueError('Attestation signature is invalid')
97 @@ -207,13 +204,9 @@ class SignatureData(object):
98 def verify(self, app_param, chal_param, der_pubkey):
99 pubkey = load_der_public_key(PUB_KEY_DER_PREFIX + der_pubkey,
101 - verifier = pubkey.verifier(self.signature, ec.ECDSA(hashes.SHA256()))
102 - verifier.update(app_param +
103 - six.int2byte(self.user_presence) +
104 - struct.pack('>I', self.counter) +
106 + msg = app_param + six.int2byte(self.user_presence) + struct.pack('>I', self.counter) + chal_param
109 + pubkey.verify(self.signature, msg, ec.ECDSA(hashes.SHA256()))
110 except InvalidSignature:
111 raise ValueError('U2F signature is invalid')