Package Cryptodome :: Package Signature :: Module pkcs1_15 :: Class PKCS115_SigScheme

Class PKCS115_SigScheme

An instance of the PKCS#1 v1.5 signature scheme for a specific RSA key.
Instance Methods
 
__init__(self, rsa_key)
Initialize this PKCS#1 v1.5 signature scheme object.
 
can_sign(self)
Return True if this object can be used to sign messages.
 
sign(self, msg_hash)
Produce the PKCS#1 v1.5 signature of a message.
 
verify(self, msg_hash, signature)
Verify that a certain PKCS#1 v1.5 signature is valid.
Method Details

__init__(self, rsa_key)
(Constructor)

 
Initialize this PKCS#1 v1.5 signature scheme object.
Parameters:
  • rsa_key (an RSA key object) - Creation of signatures is only possible if this is a private RSA key. Verification of signatures is always possible.

sign(self, msg_hash)

 

Produce the PKCS#1 v1.5 signature of a message.

This function is named RSASSA-PKCS1-V1_5-SIGN; it is specified in section 8.2.1 of RFC3447.

Parameters:
  • msg_hash (hash object) - This is an object created with to the Cryptodome.Hash module. It was used used to hash the message to sign.
Returns:
The signature encoded as a byte string.
Raises:
  • ValueError - If the RSA key is not long enough when combined with the given hash algorithm.
  • TypeError - If the RSA key has no private half.

verify(self, msg_hash, signature)

 

Verify that a certain PKCS#1 v1.5 signature is valid.

This method checks if the message really originates from someone that holds the RSA private key. really signed the message.

This function is named RSASSA-PKCS1-V1_5-VERIFY; it is specified in section 8.2.2 of RFC3447.

Parameters:
  • msg_hash (hash object) - The hash that was carried out over the message. This is an object belonging to the Cryptodome.Hash module.
  • signature (byte string) - The signature that needs to be validated.
Raises:
  • ValueError - if the signature is not valid.