dlitz/pycrypto — pull request #53 by Legrandin (2013-07-15 22:07:47+00:00)
Title: Implement a robust DSA API.

This patch introduces a new module (Crypto.Signature.DSS)
with a less error prone API for performing DSA signatures.

Similarly to Crypto.Signature.PKCS1_PSS, the module
creates a signer object that only works with hash objects,
not directly with messages.

Additionally, the caller does not need to provide any RNG.
The module will use the default one and will correctly pick
the critical nonce K.

Example of API usage:

>>> from Crypto.Signature.DSS
>>> from Crypto.Hash import SHA256
>>> from Crypto.PublicKey import DSA
>>>
>>> message = b'I give my permission to order #4355'
>>> key = DSA.importKey(open('privkey.der').read())
>>> h = SHA256.new(message)
>>> signer = DSS.new(key)
>>> signature = signer.sign(h)