Пример #1
0
def do_verify(message, signature, keyname='pub.der'):
	key = RSA.importKey(open(keyname).read())
	h = SHA.new()
	h.update(message)
	print "digest: %s" % binascii.hexlify(h.digest())
	if PKCS1_v1_5.verify(h, key, signature):
		return True
	else:
		return False
Пример #2
0
    def verify(self, msg, crypto, key):
        """
        Verifies a message using RSA cryptographic signature and key.

        ``crypto`` is the cryptographic signature
        ``key`` is the verifying key. Can be a real key object or a string.
        """
        import Crypto.Signature.PKCS1_v1_5 as PKCS
        import Crypto.Hash.SHA256 as SHA256
        import Crypto.PublicKey.RSA as RSA

        hashm = SHA256.new()
        hashm.update(msg)
        private_key = key
        if not isinstance(key, RSA._RSAobj):
            private_key = RSA.importKey(key)
        if not PKCS.verify(hashm, private_key, crypto):
            raise SignatureError("Could not validate signature")
        return True
Пример #3
0
def do_verify_hash(h, signature, keyname='pub.der'):
	key = RSA.importKey(open(keyname).read())
	if PKCS1_v1_5.verify(h, key, signature):
		return True
	else:
		return False