| 1 |
:mod:`Crypto.Signature` package |
| 2 |
=============================== |
| 3 |
|
| 4 |
The :mod:`Crypto.Signature` package contains algorithms for performing digital |
| 5 |
signatures, used to guarantee integrity and non-repudiation. |
| 6 |
|
| 7 |
Digital signatures are based on public key cryptography: the party that signs a |
| 8 |
message holds the *private key*, the one that verifies the signature holds the |
| 9 |
*public key*. |
| 10 |
|
| 11 |
Signing a message |
| 12 |
----------------- |
| 13 |
|
| 14 |
1. Instantiate a new signer object for the desired algorithm, |
| 15 |
for instance with :func:`Crypto.Signature.pkcs1_15.new`. |
| 16 |
The first parameter is the key object (*private* key) |
| 17 |
obtained via the :mod:`Crypto.PublicKey` module. |
| 18 |
|
| 19 |
2. Instantiate a cryptographic hash object, for instance with :func:`Crypto.Hash.SHA384.new`. |
| 20 |
Then, process the message with its :func:`update` method. |
| 21 |
|
| 22 |
3. Invoke the :func:`sign` method on the signer with the hash object as parameter. |
| 23 |
The output is the signature of the message (a byte string). |
| 24 |
|
| 25 |
Verifying a signature |
| 26 |
--------------------- |
| 27 |
|
| 28 |
1. Instantiate a new verifier object for the desired algorithm, |
| 29 |
for instance with :func:`Crypto.Signature.pkcs1_15.new`. |
| 30 |
The first parameter is the key object (*public* key) |
| 31 |
obtained via the :mod:`Crypto.PublicKey` module. |
| 32 |
|
| 33 |
2. Instantiate a cryptographic hash object, for instance with :func:`Crypto.Hash.SHA384.new`. |
| 34 |
Then, process the message with its :func:`update` method. |
| 35 |
|
| 36 |
3. Invoke the :func:`verify` method on the verifier, with the hash object and the incoming signature as parameters. |
| 37 |
If the message is not authentic, an :py:exc:`ValueError` is raised. |
| 38 |
|
| 39 |
Available mechanisms |
| 40 |
-------------------- |
| 41 |
|
| 42 |
* :doc:`pkcs1_v1_5` |
| 43 |
|
| 44 |
* :doc:`pkcs1_pss` |
| 45 |
|
| 46 |
* :doc:`eddsa` |
| 47 |
|
| 48 |
* :doc:`dsa` |
| 49 |
|