Ejemplo n.º 1
0
        def test_challenges_native_to_py(self):
            for authkey in authkeys:
                generated_challenge = cube2crypto.genchallenge(
                    authkey['public'], repr(Random.get_random_bytes(24)))
                answer = answer_challenge(authkey['private'],
                                          generated_challenge[0])

                self.assertEqual(generated_challenge[1], str(answer))
 def request_authentication(self, client, authid, email):
     
     user = User.by_email(email)
     
     if user is None:
         self.deny(authid)
         return
     
     pubkey = user.pubkey
     
     challenge, answer = cube2crypto.genchallenge(pubkey, format(random.getrandbits(128), 'X'))
     
     self.pending_auths[(client, authid)] = {'user': user, 'answer': answer}
     
     self.challenge.emit(client, authid, challenge)
Ejemplo n.º 3
0
 def register_server(self, client, server_domain, port):
     "Attempt to register a newly connected server_domain."
     
     if client in self.servers.keys():
         self.servers[client]['time'] = time.time()
         return
     
     server_domain = ServerDomain.by_domain(server_domain)
     
     if server_domain is None:
         self.deny.emit(client)
         return
     
     pubkey = server_domain.pubkey
     
     challenge, answer = cube2crypto.genchallenge(pubkey, format(random.getrandbits(128), 'X'))
     
     self.servers_pending[client] = {'port': port, 'time': time.time(), 'server_domain': server_domain, 'answer': answer}
     
     self.challenge.emit(client, challenge)
Ejemplo n.º 4
0
 def request_authentication(self, client, authid, member_name):
     
     if "@" in member_name:
         member = Member.by_member_email(member_name)
     else:
         member = Member.by_member_name(member_name)
     
     if member is None:
         print "Could not fetch member. Failing authentication."
         self.deny.emit(client, authid)
         return
     
     pubkey = member.public_auth_key
     
     if pubkey is None:
         print "Could not fetch pubkey. Failing authentication."
         self.deny.emit(client, authid)
         return
     
     challenge, answer = cube2crypto.genchallenge(pubkey, format(random.getrandbits(128), 'X'))
     
     self.pending_auths[(client, authid)] = {'member': member, 'answer': answer}
     
     self.challenge.emit(client, authid, challenge)
Ejemplo n.º 5
0
 def test_challenges(self):
     for authkey in authkeys:
         generated_challenge = cube2crypto.genchallenge(authkey['public'], authkey['pwd'])
         answer = cube2crypto.answerchallenge(authkey['private'], generated_challenge[0])
         
         self.assertEqual(generated_challenge[1], answer)
Ejemplo n.º 6
0
 def test_challenges_native_to_py(self):
     for authkey in authkeys:
         generated_challenge = cube2crypto.genchallenge(authkey['public'], repr(Random.get_random_bytes(24)))
         answer = answer_challenge(authkey['private'], generated_challenge[0])
         
         self.assertEqual(generated_challenge[1], answer)