Example #1
0
def test_pbkd2_issue81():
    """Test for Regression on Incorrect behavior of bytes_() under Python3.4

    https://github.com/bbangert/beaker/issues/81
    """
    result = pbkdf2("MASTER_KEY", b"SALT", 1)
    expected = pbkdf2("MASTER_KEY", "SALT", 1)
    assert result == expected, (result, expected)
Example #2
0
def test_pbkd2_issue81():
    """Test for Regression on Incorrect behavior of bytes_() under Python3.4

    https://github.com/bbangert/beaker/issues/81
    """
    result = pbkdf2("MASTER_KEY", b"SALT", 1)
    expected = pbkdf2("MASTER_KEY", "SALT", 1)
    assert result == expected, (result, expected)
Example #3
0
 def hexread(self, octets):
     return b2a_hex(
         pbkdf2(self.passphrase, self.salt, self.iterations, octets))
Example #4
0
 def hexread(self, octets):
     return b2a_hex(pbkdf2(self.passphrase, self.salt, self.iterations, octets))
Example #5
0
def test_pbkdf2_test1():
    result = pbkdf2("password", "ATHENA.MIT.EDUraeburn", 1, dklen=16)
    expected = a2b_hex(b"cdedb5281bb2f801565a1122b2563515")
    assert result == expected, (result, expected)
Example #6
0
def test_pbkdf2_test4():
    result = b2a_hex(pbkdf2("X"*65, "pass phrase exceeds block size", 1200, dklen=32))
    expected = b"9ccad6d468770cd51b10e6a68721be611a8b4d282601db3b36be9246915ec82a"
    assert result == expected, (result, expected)
Example #7
0
def test_pbkdf2_test3():
    result = b2a_hex(pbkdf2("X"*64, "pass phrase equals block size", 1200, dklen=32))
    expected = b"139c30c0966bc32ba55fdbf212530ac9c5ec59f1a452f5cc9ad940fea0598ed1"
    assert result == expected, (result, expected)
Example #8
0
def test_pbkdf2_test2():
    result = b2a_hex(pbkdf2("password", "ATHENA.MIT.EDUraeburn", 1200, dklen=32))
    expected = b"5c08eb61fdf71e4e4ec3cf6ba1f5512ba7e52ddbc5e5142f708a31e2e62b1e13"
    assert result == expected, (result, expected)
Example #9
0
def generateCryptoKeys(master_key, salt, iterations, keylen):
    # NB: We XOR parts of the keystream into the randomly-generated parts, just
    # in case os.urandom() isn't as random as it should be.  Note that if
    # os.urandom() returns truly random data, this will have no effect on the
    # overall security.
    return pbkdf2(master_key, salt, iterations=iterations, dklen=keylen)
Example #10
0
def generateCryptoKeys(master_key, salt, iterations, keylen):
    # NB: We XOR parts of the keystream into the randomly-generated parts, just
    # in case os.urandom() isn't as random as it should be.  Note that if
    # os.urandom() returns truly random data, this will have no effect on the
    # overall security.
    return pbkdf2(master_key, salt, iterations=iterations, dklen=keylen)
Example #11
0
def test_pbkdf2_test1():
    result = pbkdf2("password", "ATHENA.MIT.EDUraeburn", 1, dklen=16)
    expected = a2b_hex(b"cdedb5281bb2f801565a1122b2563515")
    assert result == expected, (result, expected)
Example #12
0
def test_pbkdf2_test4():
    result = b2a_hex(pbkdf2("X" * 65, "pass phrase exceeds block size", 1200, dklen=32))
    expected = b"9ccad6d468770cd51b10e6a68721be611a8b4d282601db3b36be9246915ec82a"
    assert result == expected, (result, expected)
Example #13
0
def test_pbkdf2_test3():
    result = b2a_hex(pbkdf2("X" * 64, "pass phrase equals block size", 1200, dklen=32))
    expected = b"139c30c0966bc32ba55fdbf212530ac9c5ec59f1a452f5cc9ad940fea0598ed1"
    assert result == expected, (result, expected)
Example #14
0
def test_pbkdf2_test2():
    result = b2a_hex(pbkdf2("password", "ATHENA.MIT.EDUraeburn", 1200, dklen=32))
    expected = b"5c08eb61fdf71e4e4ec3cf6ba1f5512ba7e52ddbc5e5142f708a31e2e62b1e13"
    assert result == expected, (result, expected)