Пример #1
0
def chicken_hash(data: bytes):
    """Hash some data with the chicken algorithm chain

    Args:
        data (bytes)
            The bytes-like data to be hashed
    
    Returns:
        A :class:`Keccak_Hash` hash object
    """
    a = BLAKE2b.new(data=data, digest_bits=256).digest()
    b = keccak.new(data=a, digest_bits=256).digest()
    c = Groestl().new(b).digest()
    return keccak.new(data=c, digest_bits=256)
Пример #2
0
    def runTest(self):

        key = RSA.generate(1280)
        signer = pss.new(key)
        hash_names = ("MD2", "MD4", "MD5", "RIPEMD160", "SHA1", "SHA224",
                      "SHA256", "SHA384", "SHA512", "SHA3_224", "SHA3_256",
                      "SHA3_384", "SHA3_512")

        for name in hash_names:
            hashed = load_hash_by_name(name).new(b("Test"))
            signer.sign(hashed)

        from Cryptodome.Hash import BLAKE2b, BLAKE2s
        for hash_size in (20, 32, 48, 64):
            hashed_b = BLAKE2b.new(digest_bytes=hash_size, data=b("Test"))
            signer.sign(hashed_b)
        for hash_size in (16, 20, 28, 32):
            hashed_s = BLAKE2s.new(digest_bytes=hash_size, data=b("Test"))
            signer.sign(hashed_s)
Пример #3
0
    def runTest(self):

        key = RSA.generate(1280)
        signer = pss.new(key)
        hash_names = ("MD2", "MD4", "MD5", "RIPEMD160", "SHA1",
                      "SHA224", "SHA256", "SHA384", "SHA512",
                      "SHA3_224", "SHA3_256", "SHA3_384", "SHA3_512")

        for name in hash_names:
            hashed = load_hash_by_name(name).new(b("Test"))
            signer.sign(hashed)

        from Cryptodome.Hash import BLAKE2b, BLAKE2s
        for hash_size in (20, 32, 48, 64):
            hashed_b = BLAKE2b.new(digest_bytes=hash_size, data=b("Test"))
            signer.sign(hashed_b)
        for hash_size in (16, 20, 28, 32):
            hashed_s = BLAKE2s.new(digest_bytes=hash_size, data=b("Test"))
            signer.sign(hashed_s)
# Released to the public domain.

# Designed for answering security questions deterministically, while
# guaranteeing a minimum security margin to prevent anyone who knows the actual
# answer from compromising an account.

# BLAKE2 is based on ChaCha and uses the HAIFA construction
# SHAKE256 is a SHA-3 XOF based on Keccak which uses the sponge construction
# scrypt is a KDF based on PBKDF2-HMAC-SHA256, which uses the Merkle-Damgard construction

from Cryptodome.Hash import BLAKE2b
from Cryptodome.Hash import SHAKE256
from Cryptodome.Protocol.KDF import scrypt

print("Answers are case-sensitive.")
site = raw_input("What site is this for? Root domain and TLD only (E.G.: example.com) ")
key = raw_input("What is a secret key with at least 128-bits entropy only you know? ")
answer = raw_input("What is the answer to the security question? ")

shake = SHAKE256.new()
secret = shake.update(bytes(key)).read(64)
salt = BLAKE2b.new(digest_bits=512, key=secret)
salt.update(bytes(site))

# A cost of 32 MiB of RAM and 5+ seconds computation
crypt = scrypt(bytes(answer), salt.digest(), 16, 2**15, 8, 1)

print("")
print("Enter this into your security question form: {}".format(crypt.encode('hex')))