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)
def make_call(self, callee, caller, pseudonym, filename): plaintext = [callee, caller, pseudonym, filename] ciphertext = asym_encrypt(plaintext, constants.P.public_key) packet = [constants.Header.INITCALL, ciphertext] self.sendLine(serialize(packet)) self.p_deferred = defer.Deferred() self.p_deferred.addCallback(self.connect_to_n, filename)
def pseudonym_update(self, pseudonym, identifier, secret): """ Update pseudonym at Pseudonym Provider with asymmetric encryption (ECIES) """ plaintext = [pseudonym, identifier, secret] ciphertext = asym_encrypt(plaintext, constants.P.public_key) packet = [constants.Header.PSEUDONYMUPDATE, ciphertext] self.sendLine(serialize(packet))
def send_msg(self, callee, caller, msg): msg = make_msg(msg) plaintext = [callee, caller, msg] ciphertext = asym_encrypt(plaintext, constants.P.public_key) packet = [constants.Header.MSG, ciphertext] self.sendLine(serialize(packet))
def location_update(self, pseudonym, location, seed): """ Update location at Location Provider with asymmetric encryption (ECIES) """ plaintext = [pseudonym, location, seed] ciphertext = asym_encrypt(plaintext, constants.L.public_key) packet = [constants.Header.LOCATIONUPDATE, ciphertext] self.sendLine(serialize(packet))