0 ; ˆl–ßi~”jj"T%õÆY¸Ð”Å£Æ „Ž4çÅa–ß=¿JJj"Tâ�nã!¸TÅ£Ä?÷ """tests for passlib.utils.scrypt""" #============================================================================= # imports #============================================================================= # core from binascii import hexlify import hashlib import logging; log = logging.getLogger(__name__) import struct import warnings warnings.filterwarnings("ignore", ".*using builtin scrypt backend.*") # site # pkg from passlib import exc from passlib.utils import getrandbytes from passlib.utils.compat import PYPY, u, bascii_to_str from passlib.utils.decor import classproperty from passlib.tests.utils import TestCase, skipUnless, TEST_MODE, hb # subject from passlib.crypto import scrypt as scrypt_mod # local __all__ = [ "ScryptEngineTest", "BuiltinScryptTest", "FastScryptTest", ] #============================================================================= # support functions #============================================================================= def hexstr(data): """return bytes as hex str""" return bascii_to_str(hexlify(data)) def unpack_uint32_list(data, check_count=None): """unpack bytes as list of uint32 values""" count = len(data) // 4 assert check_count is None or check_count == count return struct.unpack("<%dI" % count, data) def seed_bytes(seed, count): """ generate random reference bytes from specified seed. used to generate some predictable test vectors. """ if hasattr(seed, "encode"): seed = seed.encode("ascii") buf = b'' i = 0 while len(buf) < count: buf += hashlib.sha256(seed + struct.pack("