def PillowTalkActivator(client):
    client.link.name = client.keyfile['user']['login_name']
    while not (client.commGeneric.closed or client.link.authenticated):
        client.link.begin_auth(client.link.name)
        cmd, msg, sig = client.link.recieve()
        if cmd != 'sign_auth': continue
        client.link.sign_auth(msg)
        cmd, msg, sig = client.link.recieve()
        if cmd != 'verification_result': continue
        msg = qcrypt.denormalize(msg)
        msg_vr = auth.verify_signature(client.link.secret, client.link.salt, msg, sig)
        vr = bool(int(msg[0]))
        if not msg_vr: continue
        if vr: print 'server verified client'
        else: 
            client.link.comm.close()
            sys.exit()
        
        client.link.request_auth()
        cmd, msg, sig = client.link.recieve()
        if cmd != 'verify_auth': continue
        vr = client.link.verify_auth(msg)
        if not vr:
            client.link.comm.close()
            sys.exit()
        print 'client verified server'
Exemplo n.º 2
0
 def verification_result(msg, sig):
     msg = qcrypt.denormalize(msg)
     msg_vr = auth.verify_signature(self.link.secret, self.link.salt, msg, sig)
     vr = bool(int(msg[0]))
     if not msg_vr: return
     if vr: print 'client verified server'
     else: self.link.comm.close()
Exemplo n.º 3
0
 def set_pub_key(self, msg, signature):
     vr = auth.verify_signature(self.secret, self.salt, msg, signature)
     if vr:
         k_dict = nDDB.decode(qcrypt.denormalize(msg))
         k = RSA.generate(1, os.urandom)
         k.__setstate__(keyfile.proc_key_dict(k_dict))
         print 'public key recieved and verified'
     else:
         print 'incorrect message signature'
         k = None
     self.pub_key = k
Exemplo n.º 4
0
 def confirm_aes_key_set(self, msg, signature):
     vr = auth.verify_signature(self.secret, self.salt, msg, signature)
     if vr:
         msg_d = qcrypt.aes_decrypt(msg, self.aes_key)
         if msg_d == AES_SET_MSG: 
             self.key_agreement = True
             print 'aes key exchanged confirmed. key agreement reached'
         else: 
             self.key_agreement = False
             self.aes_key = None
     else:
         self.key_agreement = False
         print 'incorrect message signature'
     return self.key_agreement
Exemplo n.º 5
0
 def set_aes_key(self, msg_e, signature):
     vr = auth.verify_signature(self.secret, self.salt, msg_e, signature)
     if vr:
         k = qcrypt.pub_decrypt(msg_e, self.pri_key)
         self.aes_key = k
         self.key_agreement = True
         msg = qcrypt.aes_encrypt(AES_SET_MSG, self.aes_key)
         signature = auth.sign_msg(self.partner_secret_hash, msg)
         self.send('confirm_aeskey', msg, signature)
         print 'set aes key. key agreement reached'
     else:
         k = None
         self.send('bad_aeskey', None)
         self.key_agreement = False
         print 'incorrect message signature'
     self.aes_key = k
     return k