diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2014-06-14 09:53:35 +0100 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2014-06-14 09:53:35 +0100 |
commit | c6d202ed4becfcad6c1aacc3e274e00f83352a40 (patch) | |
tree | 995647cafcf1e96f264bc6afe6710f039a252bce /tests/hazmat/primitives/utils.py | |
parent | fcef4976e326d310d0cf77a6a7b929313583e4ad (diff) | |
parent | 626855ab04929de40992fa30f47d2975f32a31d1 (diff) | |
download | cryptography-c6d202ed4becfcad6c1aacc3e274e00f83352a40.tar.gz cryptography-c6d202ed4becfcad6c1aacc3e274e00f83352a40.tar.bz2 cryptography-c6d202ed4becfcad6c1aacc3e274e00f83352a40.zip |
Merge pull request #1116 from reaperhulk/rsa-numbers-backend-specific
Provide Backend Specific RSA Keys
Diffstat (limited to 'tests/hazmat/primitives/utils.py')
-rw-r--r-- | tests/hazmat/primitives/utils.py | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py index a496459b..54659aa9 100644 --- a/tests/hazmat/primitives/utils.py +++ b/tests/hazmat/primitives/utils.py @@ -28,6 +28,9 @@ from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.hazmat.primitives.kdf.hkdf import HKDF, HKDFExpand from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC +from cryptography.hazmat.primitives.serialization import ( + load_rsa_public_numbers +) from ...utils import load_vectors_from_file @@ -388,16 +391,16 @@ def generate_rsa_verification_test(param_loader, path, file_names, hash_alg, def rsa_verification_test(backend, params, hash_alg, pad_factory): - public_key = rsa.RSAPublicKey( - public_exponent=params["public_exponent"], - modulus=params["modulus"] + public_numbers = rsa.RSAPublicNumbers( + e=params["public_exponent"], + n=params["modulus"] ) + public_key = load_rsa_public_numbers(public_numbers, backend) pad = pad_factory(params, hash_alg) verifier = public_key.verifier( binascii.unhexlify(params["s"]), pad, - hash_alg, - backend + hash_alg ) verifier.update(binascii.unhexlify(params["msg"])) if params["fail"]: @@ -407,19 +410,14 @@ def rsa_verification_test(backend, params, hash_alg, pad_factory): verifier.verify() -def _check_rsa_private_key(skey): +def _check_rsa_private_numbers(skey): assert skey - assert skey.modulus - assert skey.public_exponent - assert skey.private_exponent - assert skey.p * skey.q == skey.modulus - assert skey.key_size + pkey = skey.public_numbers + assert pkey + assert pkey.e + assert pkey.n + assert skey.d + assert skey.p * skey.q == pkey.n assert skey.dmp1 == rsa.rsa_crt_dmp1(skey.d, skey.p) assert skey.dmq1 == rsa.rsa_crt_dmq1(skey.d, skey.q) assert skey.iqmp == rsa.rsa_crt_iqmp(skey.p, skey.q) - - pkey = skey.public_key() - assert pkey - assert skey.modulus == pkey.modulus - assert skey.public_exponent == pkey.public_exponent - assert skey.key_size == pkey.key_size |