Commit graph

9 commits

Author SHA1 Message Date
Legrandin
c85dfa7953 Add Crypto.Signature.pkcs1_v1_5 module with NIST test vectors
Crypto.Signature.PKCS1_v1_5 is reverted to old behavior it
had in PyCrypto (verify raises no exception; it only returns
True or False).
2015-07-10 19:19:13 +00:00
Legrandin
2e969dbaec Adjust DSS example 2015-03-13 20:43:59 +01:00
Legrandin
8675e6f03f Start licensing under BSD 2-Clause 2014-06-23 22:23:38 +02:00
Legrandin
1c3c049a4c Clean up Crypto.PublicKey module
This patch does a few things to simplify the public key classes
(RSA, DSA and ElGamal):

* It removes the Crypto.PublicKey.pubkey module. The 3 classes
  do not have an ancestor anymore.
* Methods sign(), verify(), encrypt(), and decrypt() are removed.
* Methods blind() and unblind() are removed.
* Methods can_sign() and can_encrypt() are removed.
* The 3 classes cannot be pickled anymore.
2014-06-16 22:00:03 +02:00
Legrandin
e61cb26e1e Failed signature verifications raise an exception.
Until now, the verify() method of a Crypto.Signature object returns
False if a signature is not authentic.

With this change set, verify() now raises a ValueError exception.
The return value of verify() must not be checked anymore.

NOTE: this change sets breaks compatibility with PyCrypto
2014-06-16 20:38:26 +02:00
Legrandin
d83380a048 Removed support for Python<2.4 2014-06-16 20:36:35 +02:00
Legrandin
cd186a4d8e IETF draft has become RFC6979 2014-03-04 22:34:30 +01:00
Legrandin
7d4cfcad64 Add support for deterministic DSA.
This patch implements the variant of DSA
described in http://tools.ietf.org/html/draft-pornin-deterministic-dsa-02.

The nonce k is not taken from the RNG: instead, it is derived from
the message and the key.

DSA is still secure even on platforms where the RNG is not reliable
(e.g. in VMs).
2014-03-04 22:34:29 +01:00
Legrandin
727780b7da 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)
2014-03-04 22:34:29 +01:00