Example #1
0
 def test_asym_encryption(self):
     identifier = helpers.pick_random()
     ciphertext = helpers.asym_encrypt(identifier, constants.P.public_key)
     s = helpers.serialize([0, ciphertext])
     [op, d] = helpers.deserialize(s)
     plaintext = helpers.asym_decrypt(d, constants.P.private_key)
     self.assertEqual(identifier, plaintext)
Example #2
0
 def lineReceived(self, line):
     print "Received %s from Network Operator" % line
     packet = deserialize(line)
     if packet[0] == constants.Header.LOCATIONUPDATE:
         plaintext = asym_decrypt(packet[1], constants.L.private_key)
         self.factory.server.store(plaintext[0], plaintext[1], plaintext[2])  # pseudo, loc, seed
     else:
         print "Unknown operator %d" % packet[0]
Example #3
0
 def lineReceived(self, line):
     print "received " + str(line)
     data = deserialize(line)
     op = data[0]
     if op == constants.Header.INITCALL:
         # if len(data) == 3:
         #     callee = data[1]
         #     caller = data[2]
         # el
         if len(data) == 2:
             callee, caller, pseudonym, msg = asym_decrypt(data[1], constants.P.private_key)
         else:
             print "Wrong amount of arguments"
             print data
         self.factory.P.init_call(callee, caller, pseudonym, self)
     elif op == constants.Header.MSG:
         callee, caller, msg = asym_decrypt(data[1], constants.P.private_key)
         self.factory.P.send_msg(callee, caller, msg)
     else:
         print "Type %d unknown" % op
Example #4
0
 def lineReceived(self, line):
     print "received " + line
     packet = deserialize(line)
     if packet[0] == constants.Header.ANSWERCALL:
         cid = packet[1]
         self.factory.P.spawn_proxy(cid)
     elif packet[0] == constants.Header.PSEUDONYMUPDATE:
         plaintext = asym_decrypt(packet[1], constants.P.private_key)
         self.factory.P.pseudonym_update(plaintext[0], plaintext[1], plaintext[2])  # pseudonym, identifier, secret
     else:
         print "Type %d unknown" % packet[0]