Exemplo n.º 1
0
 def send_new_aes_key(self):
     self.aes_key = qcrypt.create_aes_key()
     k = qcrypt.pub_encrypt(self.aes_key, self.pub_key)
     signature = auth.sign_msg(self.partner_secret_hash, k)
     self.send('set_aes_key', k, signature)
     self.key_agreement = False
     print 'sending new aes session key'
     return self.aes_key
Exemplo n.º 2
0
 def verify_auth(self, new_auth_msg):
     vr = auth.verify_auth(self.secret, self.salt, self.auth_msg, new_auth_msg)
     msg = str(int(vr))+os.urandom(7)
     sig = auth.sign_msg(self.partner_secret_hash, msg)
     msg = qcrypt.normalize(msg)
     self.send('verification_result', msg, sig)
     self.authenticated = vr
     return vr
Exemplo n.º 3
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
Exemplo n.º 4
0
 def request_pub_key(self):
     k = self.pri_key.publickey().__getstate__()
     msg = qcrypt.normalize(nDDB.encode(k))
     signature = auth.sign_msg(self.partner_secret_hash, msg)
     self.send('set_pub_key', msg, signature)
     print 'sent signed public key'