Beispiel #1
0
def test_determine_bcrypt_cost():
    bcrypt = _import_bcrypt()
    if bcrypt is None:
        with pytest.raises(RuntimeError):
            determine_bcrypt_cost(8, 0.1)
    else:
        assert determine_bcrypt_cost(8, 0.1) > 0
Beispiel #2
0
"""
import os
import hmac
import inspect
import hashlib
import warnings
from binascii import hexlify, unhexlify
from collections import OrderedDict

from pwhash.algorithms import pbkdf2
from pwhash.utils import (
    constant_time_equal, classproperty, _import_bcrypt, get_root_path,
    text_type, native_to_bytes, bytes_to_native, int_to_bytes
)

bcrypt = _import_bcrypt()


DIGEST_SIZES = {
    "hmac-sha1": 20,
    "hmac-sha224": 28,
    "hmac-sha256": 32,
    "hmac-sha384": 48,
    "hmac-sha512": 64
}

#: The recommended minimum salt length as specified in the `NIST Special
#: Publication 800-132`_, published in December of 2010.
#:
#: .. _NIST Special Publication 800-132: http://csrc.nist.gov/publications/nistpubs/800-132/nist-sp800-132.pdf
RECOMMENDED_MIN_SALT_LENGTH = 16 # 128 bit