aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives
diff options
context:
space:
mode:
authorTux <tuxxy@users.noreply.github.com>2018-12-08 18:15:51 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2018-12-08 20:15:51 -0500
commitfbbd54fe017717706ffe48b168ff0639e88f4b43 (patch)
tree8c0166b2d68bcd79c2d63dec4165b6f28d62fe73 /tests/hazmat/primitives
parentc3d38b5d80a955aee4b160bb97464a20c4992da7 (diff)
downloadcryptography-fbbd54fe017717706ffe48b168ff0639e88f4b43.tar.gz
cryptography-fbbd54fe017717706ffe48b168ff0639e88f4b43.tar.bz2
cryptography-fbbd54fe017717706ffe48b168ff0639e88f4b43.zip
Raise MemoryError when backend.derive_scrypt can't malloc enough (#4592)
* Raise MemoryError when backend.derive_scrypt can't malloc enough * Expose ERR_R_MALLOC_FAILURE and use the reason_match pattern to catch it * Add test_scrypt_malloc_failure in test_scrypt * let's see if this passes * add comment to filippo's blog post about scrypt's params
Diffstat (limited to 'tests/hazmat/primitives')
-rw-r--r--tests/hazmat/primitives/test_scrypt.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_scrypt.py b/tests/hazmat/primitives/test_scrypt.py
index 64abfe79..25d2c615 100644
--- a/tests/hazmat/primitives/test_scrypt.py
+++ b/tests/hazmat/primitives/test_scrypt.py
@@ -80,6 +80,20 @@ class TestScrypt(object):
Scrypt(salt, length, work_factor, block_size,
parallelization_factor, backend)
+ def test_scrypt_malloc_failure(self, backend):
+ password = b"NaCl"
+ work_factor = 1024 ** 3
+ block_size = 589824
+ parallelization_factor = 16
+ length = 64
+ salt = b"NaCl"
+
+ scrypt = Scrypt(salt, length, work_factor, block_size,
+ parallelization_factor, backend)
+
+ with pytest.raises(MemoryError):
+ scrypt.derive(password)
+
def test_password_not_bytes(self, backend):
password = 1
work_factor = 1024