def data_unsigned_decrypted(self,data, keyPublic,keyPrivate): ##################################################################################### #INPUT #-object serialized and crypted under keYPublic #-public key #-private key #FUNCTION #-decryption under keyPublic #-signature verification #-unserialization data #-decryption under private key #OUTPUT #D_privateKey((serialized)((serialized)data,signature_privateKey((serialized)data))) #if some problem appens it returns false ##################################################################################### logging.debug("Inside data_unsigned_decrypted") logging.debug("Try to decrypt data") pkt_un=crypto.decrypt(keyPrivate, data) logging.debug("Try to unserialize data and sig") #print pkt_un t = pickle.loads(pkt_un) (data_p,signature) = t logging.debug("Try to verify sig") if not (crypto.verify_sign(keyPublic,data_p, signature)): logging.error("Signature not verified")# check this!!!!! return False#check this!!!! logging.debug("Try to unserialize data") data=pickle.loads(data_p) logging.debug("Return data") return data
def checkCertificate(cert,keyPublic=crypto.loadPublicKey("TIS")): if cert.__len__()!=3: logging.error("Invalid certificate, (Data,PublicKey,Signature)") return False if not (crypto.verify_sign(keyPublic,(cert[0]+cert[1]),cert[2])): logging.error("Signature into certificate not verified")# check this!!!!! return False#check this!!!! return True