Package Crypto :: Package Signature :: Module PKCS1_v1_5
[frames] | no frames]

Module PKCS1_v1_5

RSA digital signature protocol according to PKCS#1 v1.5

See RFC3447 or the original RSA Labs specification.

This scheme is more properly called RSASSA-PKCS1-v1_5.

For example, a sender may authenticate a message using SHA-1 like this:

>>> from Crypto.Signature import PKCS1_v1_5
>>> from Crypto.Hash import SHA
>>> from Crypto.PublicKey import RSA
>>>
>>> message = 'To be signed'
>>> key = RSA.importKey(open('privkey.der').read())
>>> h = SHA.new(message)
>>> signer = PKCS1_v1_5.new(key)
>>> signature = signer.sign(h)

At the receiver side, verification can be done using the public part of the RSA key:

>>> key = RSA.importKey(open('pubkey.der').read())
>>> h = SHA.new(message)
>>> verifier = PKCS1_v1_5.new(key)
>>> if verifier.verify(h, signature):
>>>    print "The signature is authentic."
>>> else:
>>>    print "The signature is not authentic."
Classes
  PKCS115_SigScheme
This signature scheme can perform PKCS#1 v1.5 RSA signature or verification.
Functions
 
new(key)
Return a signature scheme object PKCS115_SigScheme that can be used to perform PKCS#1 v1.5 signature or verification.
Function Details

new(key)

 
Return a signature scheme object PKCS115_SigScheme that can be used to perform PKCS#1 v1.5 signature or verification.
Parameters:
  • key (RSA key object) - The key to use to sign or verify the message. This is a Crypto.PublicKey.RSA object. Signing is only possible if key is a private RSA key.