aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/backends
diff options
context:
space:
mode:
authorTerry Chia <terrycwk1994@gmail.com>2016-09-01 23:39:57 +0800
committerPaul Kehrer <paul.l.kehrer@gmail.com>2016-09-01 10:39:57 -0500
commitd8a27df32b1ae35f165b00a644bd2432f6e44280 (patch)
treef0aaab250003ac9cbfb5f458df9ab32ec74a8bce /tests/hazmat/backends
parentc7b29b86cd20fe62fa199eb8fb2c87f88133a5ab (diff)
downloadcryptography-d8a27df32b1ae35f165b00a644bd2432f6e44280.tar.gz
cryptography-d8a27df32b1ae35f165b00a644bd2432f6e44280.tar.bz2
cryptography-d8a27df32b1ae35f165b00a644bd2432f6e44280.zip
Scrypt Implementation (#3117)
* Scrypt implementation. * Docs stuff. * Make example just an example and not a doctest. * Add changelog entry. * Docs cleanup. * Add more tests. * Add multibackend tests. * PEP8. * Add docs about Scrypt parameters. * Docs cleanup. * Add AlreadyFinalized.
Diffstat (limited to 'tests/hazmat/backends')
-rw-r--r--tests/hazmat/backends/test_multibackend.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py
index bf54d5ce..1cd87336 100644
--- a/tests/hazmat/backends/test_multibackend.py
+++ b/tests/hazmat/backends/test_multibackend.py
@@ -13,7 +13,7 @@ from cryptography.exceptions import (
from cryptography.hazmat.backends.interfaces import (
CMACBackend, CipherBackend, DERSerializationBackend, DSABackend,
EllipticCurveBackend, HMACBackend, HashBackend, PBKDF2HMACBackend,
- PEMSerializationBackend, RSABackend, X509Backend
+ PEMSerializationBackend, RSABackend, ScryptBackend, X509Backend
)
from cryptography.hazmat.backends.multibackend import MultiBackend
from cryptography.hazmat.primitives import cmac, hashes, hmac
@@ -231,6 +231,12 @@ class DummyX509Backend(object):
pass
+@utils.register_interface(ScryptBackend)
+class DummyScryptBackend(object):
+ def derive_scrypt(self, key_material, salt, length, n, r, p):
+ pass
+
+
class TestMultiBackend(object):
def test_raises_error_with_empty_list(self):
with pytest.raises(ValueError):
@@ -558,3 +564,11 @@ class TestMultiBackend(object):
)
with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_X509):
backend.create_x509_revoked_certificate(object())
+
+ def test_scrypt(self):
+ backend = MultiBackend([DummyScryptBackend()])
+ backend.derive_scrypt(b"key", b"salt", 1, 1, 1, 1)
+
+ backend = MultiBackend([DummyBackend])
+ with pytest.raises(UnsupportedAlgorithm):
+ backend.derive_scrypt(b"key", b"salt", 1, 1, 1, 1)