diff options
author | Terry Chia <terrycwk1994@gmail.com> | 2016-09-03 07:57:45 +0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-09-02 19:57:45 -0400 |
commit | a2d0da9bcd7b5660b5038c79b7168d6fb645971f (patch) | |
tree | fc281bf52c97116c9fc8bce7c43e06b25ef71538 /tests | |
parent | 8bd420513e3a1f8594079889a5ca8f5d12fd00a6 (diff) | |
download | cryptography-a2d0da9bcd7b5660b5038c79b7168d6fb645971f.tar.gz cryptography-a2d0da9bcd7b5660b5038c79b7168d6fb645971f.tar.bz2 cryptography-a2d0da9bcd7b5660b5038c79b7168d6fb645971f.zip |
Add bounds checking for Scrypt parameters. (#3130)
* Add bounds checking for Scrypt parameters.
* Pep8.
* More PEP8.
* Change wording.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hazmat/primitives/test_scrypt.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_scrypt.py b/tests/hazmat/primitives/test_scrypt.py index de4100e3..49b304e0 100644 --- a/tests/hazmat/primitives/test_scrypt.py +++ b/tests/hazmat/primitives/test_scrypt.py @@ -117,3 +117,20 @@ class TestScrypt(object): scrypt.derive(password) with pytest.raises(AlreadyFinalized): scrypt.derive(password) + + def test_invalid_n(self, backend): + # n is less than 2 + with pytest.raises(ValueError): + Scrypt(b"NaCl", 64, 1, 8, 16, backend) + + # n is not a power of 2 + with pytest.raises(ValueError): + Scrypt(b"NaCl", 64, 3, 8, 16, backend) + + def test_invalid_r(self, backend): + with pytest.raises(ValueError): + Scrypt(b"NaCl", 64, 2, 0, 16, backend) + + def test_invalid_p(self, backend): + with pytest.raises(ValueError): + Scrypt(b"NaCl", 64, 2, 8, 0, backend) |