예제 #1
0
파일: digest.py 프로젝트: javierrami/GAM
 def _pbkdf2_looper(keyed_hmac, digest, rounds):
     hexlify = _hexlify
     accum = int(hexlify(digest), 16)
     for _ in irange(rounds - 1):
         digest = keyed_hmac(digest)
         accum ^= int(hexlify(digest), 16)
     return int_to_bytes(accum, len(digest))
예제 #2
0
 def _pbkdf2_looper(keyed_hmac, digest, rounds):
     hexlify = _hexlify
     accum = int(hexlify(digest), 16)
     for _ in irange(rounds - 1):
         digest = keyed_hmac(digest)
         accum ^= int(hexlify(digest), 16)
     return int_to_bytes(accum, len(digest))
예제 #3
0
파일: pbkdf2.py 프로젝트: Glottotopia/aagd
 def gen():
     for i in irange(block_count):
         digest = prf_func(secret, salt + pack(">L", i+1))
         accum = bytes_to_int(digest)
         for _ in irange(rounds-1):
             digest = prf_func(secret, digest)
             accum ^= bytes_to_int(digest)
         yield int_to_bytes(accum, digest_size)
예제 #4
0
 def gen():
     for i in irange(block_count):
         digest = prf_func(secret, salt + pack(">L", i+1))
         accum = bytes_to_int(digest)
         for _ in irange(rounds-1):
             digest = prf_func(secret, digest)
             accum ^= bytes_to_int(digest)
         yield int_to_bytes(accum, digest_size)
예제 #5
0
 def gen():
     for i in irange(block_count):
         digest = keyed_prf(salt + pack(">L", i + 1))
         accum = bytes_to_int(digest)
         # speed-critical loop of pbkdf2
         # NOTE: currently converting digests to integers since that XORs faster.
         for _ in irange(rounds - 1):
             digest = keyed_prf(digest)
             accum ^= bytes_to_int(digest)
         yield int_to_bytes(accum, digest_size)
예제 #6
0
파일: pbkdf2.py 프로젝트: cutso/passlib
 def gen():
     for i in irange(block_count):
         digest = keyed_prf(salt + pack(">L", i+1))
         accum = bytes_to_int(digest)
         # speed-critical loop of pbkdf2
         # NOTE: currently converting digests to integers since that XORs faster.
         for _ in irange(rounds-1):
             digest = keyed_prf(digest)
             accum ^= bytes_to_int(digest)
         yield int_to_bytes(accum, digest_size)
예제 #7
0
def des_encrypt_block(key, input):
    """do traditional encryption of a single DES block

    :arg key: 8 byte des key
    :arg input: 8 byte plaintext
    :returns: 8 byte ciphertext

    all values must be :class:`bytes`
    """
    if not isinstance(key, bytes):
        raise TypeError("key must be bytes, not %s" % (type(key),))
    if len(key) == 7:
        key = expand_des_key(key)
    assert len(key) == 8
    if not isinstance(input, bytes):
        raise TypeError("input must be bytes, not %s" % (type(input),))
    assert len(input) == 8
    input = bytes_to_int(input)
    key = bytes_to_int(key)
    out = mdes_encrypt_int_block(key, input, 0, 1)
    return int_to_bytes(out, 8)