def isValid(self, keyMessage): """ Verify the self signature. """ key = keyMessage.packets.get(PublicKeyPacket.TAG) if key is None: key = keyMessage.packets.get(SecretKeyPacket.TAG) if key is None: raise Exception('no key in message') em = crypto.i2b(crypto.rsaEncrypt(self.signature.value, key.e.value, key.n.value)) return encoding.pssVerify(self.hashdata(), em, crypto.HASH_SIZE[crypto.HASH_SHA256] / 8, key.n.bits() - 1, crypto.HASH_SHA256)
def send(self, address, message): # Send the message to the specified address #print "SEND<", address, ">:", self.stringToHex(message) message = crypto.rsaEncrypt(message) self.SOCK.sendto(message, (address, DEFAULT_PORT))