Пример #1
0
def stretchkey(passwd, salt, count):
    """Streach a key. H(pass+salt)

	"""
    assert count > 0
    # Hash once with both
    inithsh = sha256_func()
    inithsh.update(passwd)
    inithsh.update(salt)
    # Expecting it in binary form; NOT HEX FORM
    hsh = inithsh.digest()
    # Rehash
    for i in xrange(count):
        t = sha256_func()
        t.update(hsh)
        hsh = t.digest()
    return hsh
Пример #2
0
def stretchkey(passwd, salt, count):
    """Streach a key. H(pass+salt)

	"""
    assert count > 0
    # Hash once with both
    inithsh = sha256_func()
    inithsh.update(passwd)
    inithsh.update(salt)
    # Expecting it in binary form; NOT HEX FORM
    hsh = inithsh.digest()
    # Rehash
    for i in xrange(count):
        t = sha256_func()
        t.update(hsh)
        hsh = t.digest()
    return hsh
Пример #3
0
 def _regen_hpprime(self):
     """Regenerate H(P')
     Save the SHA256 of self.pprime.
     """
     hsh = sha256_func()
     hsh.update(self.pprime)
     self.hpprime = hsh.digest()
     log.debug("Set H(P') to % s" % repr(self.hpprime))
     assert self.check_password()
Пример #4
0
 def _regen_hpprime(self):
     """Regenerate H(P')
     Save the SHA256 of self.pprime. 
     """
     hsh = sha256_func()
     hsh.update(self.pprime)
     self.hpprime = hsh.digest()
     log.debug("Set H(P') to %s" % repr(self.hpprime))
     assert self.check_password()
Пример #5
0
def stretchkey(passwd, salt, count):
    """
    Stretch a key. H(pass+salt)
    @param passwd: The password being stretched
    @type passwd: string
    @param salt: Salt for the password. Should pre-provided random data.
    @type salt: string
    @param count: The number of times to repeat the stretch function
    @type count: int
    """
    assert count > 0
    # Hash once with both
    inithsh = sha256_func()
    inithsh.update(passwd)
    inithsh.update(salt)
    # Expecting it in binary form; NOT HEX FORM
    hsh = inithsh.digest()
    # Rehash
    for i in range(count):
        t = sha256_func()
        t.update(hsh)
        hsh = t.digest()
    return hsh
Пример #6
0
def stretchkey(passwd, salt, count):
    """
    Stretch a key. H(pass+salt)
    @param passwd: The password being stretched
    @type passwd: string
    @param salt: Salt for the password. Should pre-provided random data.
    @type salt: string
    @param count: The number of times to repeat the stretch function
    @type count: int
    """
    assert count > 0
    # Hash once with both
    inithsh = sha256_func()
    inithsh.update(passwd)
    inithsh.update(salt)
    # Expecting it in binary form; NOT HEX FORM
    hsh = inithsh.digest()
    # Rehash
    for i in xrange(count):
        t = sha256_func()
        t.update(hsh)
        hsh = t.digest()
    return hsh
Пример #7
0
 def check_password(self):
     """Check that the hash in self.pprime matches what's in the password safe. True if password matches hash in hpprime. False otherwise"""
     hsh = sha256_func()
     hsh.update(self.pprime)
     return hsh.digest() == self.hpprime
Пример #8
0
 def check_password(self):
     """Check that the hash in self.pprime matches whats in the password safe. True if password matches hash in hpprime. False otherwise"""
     hsh = sha256_func()
     hsh.update(self.pprime)
     return hsh.digest() == self.hpprime