Commit graph

98 commits

Author SHA1 Message Date
Legrandin
7073325ff7 Update to documentation 2015-07-19 19:12:47 +00:00
Legrandin
29302e0686 Fix missing module problem on Windows 2015-07-11 20:37:33 +00:00
Legrandin
f45c561328 Add Crypto.Signature.pkcs1_pss with NIST test vectors
Crypto.Signature.PKCS1_PSS is reverted to the old behavior it had
in PyCrypto: verify() returns True/False and does not raise an
exception with wrong signature.
2015-07-11 20:26:17 +00:00
Legrandin
469714c1ab Formatting 2015-06-05 21:35:04 +02:00
Legrandin
734f329c35 [OCB] Avoid slicing of (large) inputs when possible 2015-05-31 07:17:42 -04:00
Legrandin
bf7e048e74 Added example and clarifications on use of last encrypt/decrypt 2015-05-30 15:24:41 -04:00
Legrandin
f11a960bbc Fix incorrect handling of misaligned associated data 2015-05-30 15:13:20 -04:00
Legrandin
03b14b6a0c Simplify C code by moving caches under Python 2015-05-29 09:06:49 -04:00
Legrandin
a24f0fb534 First draft of OCB
[skip ci]
2015-05-24 15:29:26 -04:00
Legrandin
6257fa5114 Add support for ChaCha20. 2015-04-30 11:44:34 -04:00
Legrandin
d0311fb416 MAC checks are all performed with BLAKE2s 2015-04-16 14:11:50 +02:00
Legrandin
1f3c1b4fcc Remove Crypto.PublicKey.RSA.RSAImplementation
In the process, we add a "randfunc" parameter to
- Crypto.Cipher.PKCS1_OAEP.new()
- Crypto.Cipher.PKCS1_v1_5.new()
- Crypto.Signature.PKCS1_PSS.new()
to set the PRNG used by each algorithm.
Previously, the PRNG was taken from the RSA key itself.
2015-03-11 11:30:33 -04:00
Legrandin
72aff29a65 Update to API documentation. 2015-03-11 11:30:16 -04:00
Legrandin
0b76cd2168 Ensure that all data passed to C backend is byte strings 2015-02-10 22:29:40 +01:00
Legrandin
11a6d1dfa4 Flag explicitly certain arguments as of size_t type 2015-02-10 16:45:25 +01:00
Legrandin
5d5a709811 Make modules to compile again with MSVC 2015-02-02 21:40:34 +01:00
Legrandin
0e3320ed43 Galois module uses raw interface 2015-01-25 18:01:45 +01:00
Legrandin
f9c9e92b01 Stream ciphers use raw interface 2015-01-24 21:07:17 +01:00
Legrandin
c36fdefd24 cpuid uses the raw interface too 2015-01-23 15:24:21 +00:00
Legrandin
e934e4135d Symmetric ciphers use cffi too (when available). 2015-01-22 09:35:44 +01:00
Legrandin
cb844d8292 More reliable way to infer module extension 2015-01-05 23:06:22 +01:00
Legrandin
e042da71d5 Update ARC2 2015-01-05 23:06:22 +01:00
Legrandin
f910d9b16d Update to Blowfish 2015-01-05 23:06:22 +01:00
Legrandin
e16d19daaf Update CAST 2015-01-05 23:06:22 +01:00
Legrandin
32b0c53ac6 Update DES and DES3 2015-01-05 23:06:21 +01:00
Legrandin
08baea4cb4 Break up block_template.c (AES only) 2015-01-05 23:06:21 +01:00
Legrandin
e9adec93c7 Every cipher instance is a mode-specific type 2014-12-10 21:40:49 +01:00
Legrandin
546912f61d Factor out GCM code into separate module 2014-12-09 21:33:41 +01:00
Legrandin
350935d855 Factor out EAX mode into separate module 2014-12-08 22:15:50 +01:00
Legrandin
774d28d441 Factor out OpenPGP cipher mode in separate module 2014-12-08 21:53:14 +01:00
Legrandin
aaeea1f33b Factor out CCM mode in a separate module 2014-12-08 21:07:14 +01:00
Legrandin
9e4d71df58 Factor out SIV cipher mode into a separate module 2014-12-08 11:49:38 +01:00
Legrandin
0700393bbb blockalgo.py must be included in the documentation 2014-06-26 22:54:48 +02:00
Legrandin
522d71917f Removed Crypto.Cipher.XOR module 2014-06-22 09:32:33 +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
251fbd8e8c Hide private modules from documentation 2014-06-16 20:38:26 +02:00
Legrandin
465d0391ac ECB is not the default mode for a new cipher.
The expression AES.new(key) used to be equivalent
to AES.new(key, AES.MODE_ECB). The same applies to
any other algorithm beside AES.

Since the ECB mode is not a secure default,
the expression AES.new(key) will now raise an exception.

NOTE: this change sets breaks compatibility with PyCrypto
2014-06-16 20:36:36 +02:00
Legrandin
d83380a048 Removed support for Python<2.4 2014-06-16 20:36:35 +02:00
Legrandin
e4da72373d Added example to Salsa20 module 2014-05-11 15:24:07 +02:00
Legrandin
851246faeb Salsa20 uses a nonce, not an IV. 2014-05-05 21:15:35 +02:00
Legrandin
31b22bac13 Merge branch 'salsa20' of https://github.com/bluviolin/pycrypto 2014-05-05 14:26:14 +02:00
Legrandin
d66d1f6277 Make Cipher.galois module private 2014-04-26 09:10:19 +02:00
Legrandin
0d4b274894 Make GHASH more robust against timing attacks.
In order to speed up as much as possible the GHASH,
the current implementation expands the 16 byte hash key
(H) into a table of 64 KBytes. However, that is sensitive
to cache-based timing attacks.

If we assume that access to data inside the same cache line
is constant-time (likely), fitting a table item into a cache
line may help against the attacks.

This patch reduce the pre-computed table from 64K to 4K
and aligns every item to a 32 byte boundary (since most modern
CPUs have cache line of that size or larger).

This patch will reduce the overall performance.

This patch also reverts commit 965871a727 ("GCM mode:
Optimize key setup for GCM mode") since I actually
got conflicting benchmark results.
2014-04-14 07:59:40 +02:00
Legrandin
7c5a1ebb99 Fixed sentence in CCM example 2014-02-21 23:59:53 -08:00
Dwayne Litzenberger
7bb217aedd Rename S2V -> _S2V until we come up with a real PRF API 2013-10-20 17:48:54 -07:00
Dwayne Litzenberger
ff9009abb8 Make MODE_OPENPGP accept uppercase 'IV' parameter.
This is for consistency with the rest of PyCrypto.

Closes: https://bugs.launchpad.net/pycrypto/+bug/1132550
2013-10-20 13:30:22 -07:00
Dwayne Litzenberger
acbd4dedc8 More ValueError -> TypeError 2013-10-20 13:30:22 -07:00
Dwayne Litzenberger
3e706bfc6a _CBCMAC: Rename ignite() -> _ignite()
I don't want to make this a public API just yet.
2013-10-20 13:30:22 -07:00
Legrandin
2062e5f843 Add encrypt_and_digest() and decrypt_and_verify()
This patch adds encrypt_and_digest() and decrypt_and_verify()
methods to a cipher object.

In most cases they are just shortcuts to the existing functions.
For SIV mode, decrypt_and_verify() replaces decrypt().

[dlitz@dlitz.net: Squashed with bugfix commit:]

Bug in encrypt_and_digest() (all AEAD modes)

decrypt() was being called instead of encrypt().
Added also a unit test to validate that composition
of encrypt_and_digest() and decrypt_and_verify()
is the identity function.

[dlitz@dlitz.net: Included changes from the following commit from the author's pull request:]
- [9c13f9c] Rename 'IV' parameter to 'nonce' for AEAD modes.
[dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"]
[dlitz@dlitz.net: Replaced MacMismatchError with ValueError]
[dlitz@dlitz.net: Replaced ApiUsageError with TypeError]
2013-10-20 13:30:22 -07:00
Legrandin
965871a727 GCM mode: Optimize key setup for GCM mode.
GCM mode requires GHASH for 2 different operations: one for
the data (AD + ciphertext) and one for the IV.

Construction of tables to speed-up GHASH is very expensive
and it is worth doing only for the data, not for the IV.

This patch ensures that the GHASH for the IV does not
use tables, with a ~40% faster key setup.

[dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"]
2013-10-20 13:30:22 -07:00