diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-06-27 09:15:07 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-06-27 09:15:07 -0600 |
commit | dacb5f9951064d19ac69c1198985af136f71a6db (patch) | |
tree | f40e491487856a46a2fd93167ab24fdaf07412c8 /tests | |
parent | a44338b355a628ba7d732063551650cd9f8b2cb8 (diff) | |
download | cryptography-dacb5f9951064d19ac69c1198985af136f71a6db.tar.gz cryptography-dacb5f9951064d19ac69c1198985af136f71a6db.tar.bz2 cryptography-dacb5f9951064d19ac69c1198985af136f71a6db.zip |
add generate_private_key to DSAParameters + add a new function to dsa
dsa.generate_private_key(key_size, backend) will allow you to generate a
new DSA key and implicitly generate new parameters. This streamlines the
common case and will be an avenue to support future backends that don't
allow independent generation of DSAParameters (e.g. CommonCrypto)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hazmat/primitives/test_dsa.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/hazmat/primitives/test_dsa.py b/tests/hazmat/primitives/test_dsa.py index 76436f79..531b448f 100644 --- a/tests/hazmat/primitives/test_dsa.py +++ b/tests/hazmat/primitives/test_dsa.py @@ -77,7 +77,6 @@ class TestDSA(object): def test_generate_dsa_parameters(self, backend): parameters = dsa.generate_parameters(1024, backend) assert isinstance(parameters, interfaces.DSAParameters) - # TODO: withnumbers check like RSA def test_generate_invalid_dsa_parameters(self, backend): with pytest.raises(ValueError): @@ -97,7 +96,7 @@ class TestDSA(object): q=vector['q'], g=vector['g'] ).parameters(backend) - skey = dsa.generate_private_key(parameters) + skey = parameters.generate_private_key() if isinstance(skey, interfaces.DSAPrivateKeyWithNumbers): numbers = skey.private_numbers() skey_parameters = numbers.public_numbers.parameter_numbers @@ -118,6 +117,16 @@ class TestDSA(object): skey_parameters.g, numbers.x, skey_parameters.p ) + def test_generate_dsa_private_key_and_parameters(self, backend): + skey = dsa.generate_private_key(1024, backend) + assert skey + if isinstance(skey, interfaces.DSAPrivateKeyWithNumbers): + numbers = skey.private_numbers() + skey_parameters = numbers.public_numbers.parameter_numbers + assert numbers.public_numbers.y == pow( + skey_parameters.g, numbers.x, skey_parameters.p + ) + def test_invalid_parameters_argument_types(self): with pytest.raises(TypeError): dsa.DSAParameters(None, None, None) |