Module pkcs1_15
Module to create PKCS#1 v1.5 RSA signatures
See RFC3447 or the original RSA Labs specification.
This scheme is more properly called RSASSA-PKCS1-v1_5.
For example, a sender can create the signature of a message using
its private RSA key:
>>> from Cryptodome.Signature import pkcs1_15
>>> from Cryptodome.Hash import SHA256
>>> from Cryptodome.PublicKey import RSA
>>>
>>> message = 'To be signed'
>>> key = RSA.importKey(open('private_key.der').read())
>>> h = SHA256.new(message)
>>> signature = pkcs1_15.new(key).sign(h)
At the other side, the receiver can verify the signature (and therefore
the authenticity of the message) using the public RSA key:
>>> key = RSA.importKey(open('public_key.der').read())
>>> h = SHA.new(message)
>>> try:
>>> pkcs1_15.new(key).verify(h, signature):
>>> print "The signature is valid."
>>> except (ValueError, TypeError):
>>> print "The signature is not valid."
|
PKCS115_SigScheme
An instance of the PKCS#1 v1.5 signature scheme for a specific RSA key.
|
|
new(rsa_key)
Return a signature scheme object PKCS115_SigScheme that
can create or verify PKCS#1 v1.5 signatures. |
|
|
Return a signature scheme object PKCS115_SigScheme that
can create or verify PKCS#1 v1.5 signatures.
- Parameters:
rsa_key (RSA key object) - The RSA key to use to sign or verify the message.
This is a Cryptodome.PublicKey.RSA object.
Signing is only possible if rsa_key is a private RSA key.
|