コード例 #1
0
    def derive(self, key_material: bytes) -> bytes:
        if self._used:
            raise AlreadyFinalized("PBKDF2 instances can only be used once.")
        self._used = True

        utils._check_byteslike("key_material", key_material)
        from cryptography.hazmat.backends.openssl.backend import backend

        return backend.derive_pbkdf2_hmac(
            self._algorithm,
            self._length,
            self._salt,
            self._iterations,
            key_material,
        )
コード例 #2
0
 def test_derive_pbkdf2_raises_unsupported_on_old_openssl(self):
     if backend.pbkdf2_hmac_supported(hashes.SHA256()):
         pytest.skip("Requires an older OpenSSL")
     with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_HASH):
         backend.derive_pbkdf2_hmac(hashes.SHA256(), 10, b"", 1000, b"")
コード例 #3
0
 def test_derive_pbkdf2_raises_unsupported_on_old_openssl(self):
     if backend.pbkdf2_hmac_supported(hashes.SHA256()):
         pytest.skip("Requires an older OpenSSL")
     with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_HASH):
         backend.derive_pbkdf2_hmac(hashes.SHA256(), 10, b"", 1000, b"")
コード例 #4
0
 def test_derive_pbkdf2_raises_unsupported_on_old_openssl(self):
     if backend.pbkdf2_hmac_supported(hashes.SHA256()):
         pytest.skip("Requires an older OpenSSL")
     with pytest.raises(UnsupportedHash):
         backend.derive_pbkdf2_hmac(hashes.SHA256(), 10, b"", 1000, b"")
コード例 #5
0
 def test_derive_pbkdf2_raises_unsupported_on_old_openssl(self):
     if backend.pbkdf2_hmac_supported(hashes.SHA256()):
         pytest.skip("Requires an older OpenSSL")
     with pytest.raises(UnsupportedAlgorithm):
         backend.derive_pbkdf2_hmac(hashes.SHA256(), 10, b"", 1000, b"")