Package Cryptodome :: Package Signature :: Module DSS :: Class DssSigScheme

Class DssSigScheme

object --+
         |
        DssSigScheme
Known Subclasses:

This signature scheme can perform DSS signature or verification.
Instance Methods
 
can_sign(self)
Return True if this signature object can be used for signing messages.
 
sign(self, msg_hash)
Produce the DSS signature of a message.
 
verify(self, msg_hash, signature)
Verify that a certain DSS signature is authentic.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

sign(self, msg_hash)

 
Produce the DSS signature of a message.
Parameters:
  • msg_hash (hash object) - The hash that was carried out over the message. The object belongs to the Cryptodome.Hash package.

    Under mode 'fips-186-3', the hash must be a FIPS approved secure hash (SHA-1 or a member of the SHA-2 family), of cryptographic strength appropriate for the DSA key. For instance, a 3072/256 DSA key can only be used in combination with SHA-512.

Returns:
The signature encoded as a byte string.
Raises:
  • ValueError - If the hash algorithm is incompatible to the DSA key.
  • TypeError - If the DSA key has no private half.

verify(self, msg_hash, signature)

 

Verify that a certain DSS signature is authentic.

This function checks if the party holding the private half of the key really signed the message.

Parameters:
  • msg_hash (hash object) - The hash that was carried out over the message. This is an object belonging to the Cryptodome.Hash module.

    Under mode 'fips-186-3', the hash must be a FIPS approved secure hash (SHA-1 or a member of the SHA-2 family), of cryptographic strength appropriate for the DSA key. For instance, a 3072/256 DSA key can only be used in combination with SHA-512.

  • signature (byte string) - The signature that needs to be validated.
Raises:
  • ValueError - If the signature is not authentic.