Exemplo n.º 1
0
 def set_password(self, s, password):
     socket = self.socket[s]
     salt, v = SRP.new_passwd(self.co.user, password)
     cypherv = crypt(long_to_string(v), socket['key'])[0]
     self._send_msg(s, {'op': 'set password', 's': salt, 'v': cypherv})
     socket['state'] = 5
     self.rs.listen_forever(self.nh)
     self.rs.doneflag.clear()
Exemplo n.º 2
0
 def set_password(self, s, password):
     socket = self.socket[s]
     salt, v = SRP.new_passwd(self.co.user, password)
     cypherv = crypt(long_to_string(v), socket['key'])[0]
     self._send_msg(s, {'op': 'set password', 's': salt, 'v': cypherv})
     socket['state'] = 5
     self.rs.listen_forever(self.nh)
     self.rs.doneflag.clear()
Exemplo n.º 3
0
def crypt(text, key, counter=0L):
    keylen, length = len(key), len(text)
    pos, cyphertext = 0, []
    while pos < length:
        scounter = long_to_string(counter, keylen)
        hash = sha.new("ctr mode crypt" + key + scounter).digest()
        for i in xrange(min(length-pos, len(hash))):
            cyphertext.append(chr(ord(hash[i]) ^ ord(text[pos])))
            pos += 1
        counter += 1
    return (''.join(cyphertext), counter)
Exemplo n.º 4
0
def hash(s):
    """Hash a value with some hashing algorithm."""
    if type(s) != type(''):
	s = long_to_string(s)

    return sha.new(s).digest()
Exemplo n.º 5
0
def host_authenticator(K, A, m):
    A = long_to_string(A, 128)
    return hmac.new(K, A + m, sha)
Exemplo n.º 6
0
def _client_authenticator(K, n, g, user, s, A, B, u):
    A = long_to_string(A, 128)
    B = long_to_string(B, 128)
    u = long_to_string(u, 128)
    return hmac.new(K, hash(n) + hash(g) + hash(user) + s + A + B + u, sha)
Exemplo n.º 7
0
def hash(s):
    """Hash a value with some hashing algorithm."""
    if type(s) != type(''):
        s = long_to_string(s)

    return sha.new(s).digest()
Exemplo n.º 8
0
def host_authenticator(K, A, m):
    A = long_to_string(A, 128)
    return hmac.new(K, A + m, sha)
Exemplo n.º 9
0
def _client_authenticator(K, n, g, user, s, A, B, u):
    A = long_to_string(A, 128)
    B = long_to_string(B, 128)
    u = long_to_string(u, 128)
    return hmac.new(K, hash(n) + hash(g) + hash(user) + s + A + B + u, sha)