Exemplo n.º 1
0
    def compute_client_values(self, byte_size=DEFAULT_SECRETSIZE):
        '''
		Computes client's private and public values:
		a = random()
		A = g^a % N  
		'''
        self.a = obj_to_int(get_randombytes(byte_size))
        self.A = pow(self.g, self.a, self.N)
        return self.A
Exemplo n.º 2
0
    def compute_server_values(self,
                              username,
                              verifier,
                              byte_size=DEFAULT_SECRETSIZE):
        '''Calculates server values'''
        l = self.N.bit_length()

        self.b = obj_to_int(get_randombytes(byte_size))
        k = obj_to_int(compute_hash(self.N, compute_padding(self.g, l)))

        self.B = (k * verifier + pow(self.g, self.b, self.N)) % self.N
        return self.B
Exemplo n.º 3
0
 def compute_verifier(self,
                      username,
                      password,
                      gn=DEFAULT_GROUP_PARAMETERS,
                      byte_size=DEFAULT_SALT_SIZE):
     '''Creates the SRP verifier according to the RFC formula'''
     self.username = username
     self.password = password
     salt = get_randombytes(byte_size)
     x = self._compute_x(salt, username, password)
     verifier = pow(self.g, x, self.N)
     return salt, verifier