aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/primitives/kdf
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-01-05 14:11:17 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2017-01-05 14:11:17 -0500
commitd74ba3298ddd4d3558224af85768e28f4c7f8d0d (patch)
tree82dcb0f34338310fa70163b5290f2ca1c775c5c2 /src/cryptography/hazmat/primitives/kdf
parent1c2458e0ceb1685b80dfe115a796926d3f1f4d86 (diff)
downloadcryptography-d74ba3298ddd4d3558224af85768e28f4c7f8d0d.tar.gz
cryptography-d74ba3298ddd4d3558224af85768e28f4c7f8d0d.tar.bz2
cryptography-d74ba3298ddd4d3558224af85768e28f4c7f8d0d.zip
add memory limit check for scrypt (#3328)
* add memory limit check for scrypt fixes #3323 * test a pass * move _MEM_LIMIT to the scrypt module
Diffstat (limited to 'src/cryptography/hazmat/primitives/kdf')
-rw-r--r--src/cryptography/hazmat/primitives/kdf/scrypt.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/primitives/kdf/scrypt.py b/src/cryptography/hazmat/primitives/kdf/scrypt.py
index 20935409..77dcf9ab 100644
--- a/src/cryptography/hazmat/primitives/kdf/scrypt.py
+++ b/src/cryptography/hazmat/primitives/kdf/scrypt.py
@@ -4,6 +4,8 @@
from __future__ import absolute_import, division, print_function
+import sys
+
from cryptography import utils
from cryptography.exceptions import (
AlreadyFinalized, InvalidKey, UnsupportedAlgorithm, _Reasons
@@ -13,6 +15,11 @@ from cryptography.hazmat.primitives import constant_time
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
+# This is used by the scrypt tests to skip tests that require more memory
+# than the MEM_LIMIT
+_MEM_LIMIT = sys.maxsize // 2
+
+
@utils.register_interface(KeyDerivationFunction)
class Scrypt(object):
def __init__(self, salt, length, n, r, p, backend):