Пример #1
0
 def to_string(self, withchk=True):
     salt = ab64_encode(self.salt).decode("ascii")
     if withchk and self.checksum:
         chk = ab64_encode(self.checksum).decode("ascii")
     else:
         chk = None
     return uh.render_mc3(self.ident, self.rounds, salt, chk)
Пример #2
0
 def to_string(self, withchk=True):
     salt = ab64_encode(self.salt).decode("ascii")
     if withchk and self.checksum:
         chk = ab64_encode(self.checksum).decode("ascii")
     else:
         chk = None
     return uh.render_mc3(self.ident, self.rounds, salt, chk)
Пример #3
0
 def to_string(self, withchk=True):
     salt = bascii_to_str(ab64_encode(self.salt))
     chkmap = self.checksum
     if withchk and chkmap:
         chk_str = ",".join("%s=%s" % (alg, bascii_to_str(ab64_encode(chkmap[alg]))) for alg in self.algs)
     else:
         chk_str = ",".join(self.algs)
     return "$scram$%d$%s$%s" % (self.rounds, salt, chk_str)
Пример #4
0
 def to_string(self, withchk=True):
     salt = bascii_to_str(ab64_encode(self.salt))
     chkmap = self.checksum
     if withchk and chkmap:
         chk_str = ",".join("%s=%s" %
                            (alg, bascii_to_str(ab64_encode(chkmap[alg])))
                            for alg in self.algs)
     else:
         chk_str = ",".join(self.algs)
     return '$scram$%d$%s$%s' % (self.rounds, salt, chk_str)
Пример #5
0
	def _compute_ersatz_salt(self, password, ersatz_password):
		'''
			Creates a ersatz salt
			Inputs
				password - True user password
				ersatz_pw- Fake user password
			todo: remove the array cut 
		'''
		return ab64_encode(self._sxor(self._hdf(self._formatPassword(password)),\
						 ersatz_password))
Пример #6
0
def generate_key( passphrase, salt ):
	assert len(passphrase) > 0
	
	# add salt to passphrase and to sha512_crypt's salt
	crypt_salt = ab64_encode(sha512(salt).digest())[:16]
	passphrase += salt
	
	assert len(crypt_salt) == 16	
	key = sha512_crypt.encrypt(passphrase, rounds = PASSPHRASE_ROUNDS, salt = crypt_salt)
	assert len(key) > 86
	
	# get just the hash back
	key = ab64_decode(key[-86:])
	
	assert len(key) == 64	
	return key
Пример #7
0
def generate_key(passphrase, salt):
    assert len(passphrase) > 0

    # add salt to passphrase and to sha512_crypt's salt
    crypt_salt = ab64_encode(sha512(salt).digest())[:16]
    passphrase += salt

    assert len(crypt_salt) == 16
    key = sha512_crypt.encrypt(passphrase,
                               rounds=PASSPHRASE_ROUNDS,
                               salt=crypt_salt)
    assert len(key) > 86

    # get just the hash back
    key = ab64_decode(key[-86:])

    assert len(key) == 64
    return key
Пример #8
0
 def _calc_checksum(self, secret):
     if isinstance(secret, unicode):
         secret = secret.encode("utf-8")
     salt = str_to_bascii(self.to_string(withchk=False))
     result = pbkdf2(secret, salt, self.rounds, 24, "hmac-sha1")
     return ab64_encode(result).decode("ascii")
Пример #9
0
 def _calc_checksum(self, secret):
     if isinstance(secret, unicode):
         secret = secret.encode("utf-8")
     salt = str_to_bascii(self.to_string(withchk=False))
     result = pbkdf2(secret, salt, self.rounds, 24, "hmac-sha1")
     return ab64_encode(result).decode("ascii")