diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-03-15 15:15:30 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-03-15 15:15:30 -0700 |
commit | 106cc54b4344cc97af54eccb4d873434efe4203a (patch) | |
tree | f1253ea7cbd411c5f97e25558defc5de6eb95cd1 /tests/hazmat/primitives/test_rsa.py | |
parent | 7b9d92416ece98fdb12b2c220b81d5180bc87945 (diff) | |
parent | a0fdedef7328615fad7f174d52d6dc36346c7e2f (diff) | |
download | cryptography-106cc54b4344cc97af54eccb4d873434efe4203a.tar.gz cryptography-106cc54b4344cc97af54eccb4d873434efe4203a.tar.bz2 cryptography-106cc54b4344cc97af54eccb4d873434efe4203a.zip |
Merge pull request #775 from reaperhulk/rsa-mgf1-class
add MGF1 class, docs, tests
Diffstat (limited to 'tests/hazmat/primitives/test_rsa.py')
-rw-r--r-- | tests/hazmat/primitives/test_rsa.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index 79323265..114dc415 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -558,3 +558,30 @@ class TestRSAVerification(object): public_key = private_key.public_key() with pytest.raises(TypeError): public_key.verifier(b"sig", "notpadding", hashes.SHA1(), backend) + + +class TestMGF1(object): + def test_invalid_hash_algorithm(self): + with pytest.raises(TypeError): + padding.MGF1(b"not_a_hash", 0) + + def test_invalid_salt_length_not_integer(self): + with pytest.raises(TypeError): + padding.MGF1(hashes.SHA1(), b"not_a_length") + + def test_invalid_salt_length_negative_integer(self): + with pytest.raises(ValueError): + padding.MGF1(hashes.SHA1(), -1) + + def test_valid_mgf1_parameters(self): + algorithm = hashes.SHA1() + salt_length = algorithm.digest_size + mgf = padding.MGF1(algorithm, salt_length) + assert mgf._algorithm == algorithm + assert mgf._salt_length == salt_length + + def test_valid_mgf1_parameters_maximum(self): + algorithm = hashes.SHA1() + mgf = padding.MGF1(algorithm, padding.MGF1.MAX_LENGTH) + assert mgf._algorithm == algorithm + assert mgf._salt_length == padding.MGF1.MAX_LENGTH |