Commit graph

32 commits

Author SHA1 Message Date
Helder Eijs
eda4f65718 Move test vectors in a separate package 2021-01-03 23:49:50 +01:00
Helder Eijs
0374c47c5d Add Wycheproof tests for HKDF 2019-12-15 23:29:52 +01:00
Helder Eijs
dc263c1cc1 Fix docs and catches zero bytes in password 2019-08-16 22:17:19 +02:00
Helder Eijs
5ce770106c Add negative tests 2019-08-16 22:17:19 +02:00
Helder Eijs
f63446d27c Add more bcrypt tests 2019-08-16 22:17:19 +02:00
Helder Eijs
ca975e96ad First version of bcrypt 2019-08-16 22:17:19 +02:00
Helder Eijs
cd7f0128b6 Make code base suitable for Python 2 and 3 - stop using 2to3 2018-11-04 15:04:23 +01:00
Helder Eijs
4242e82e9e Modern syntax for except statement 2018-06-12 14:15:39 +02:00
Helder Eijs
45ddf281d8 The salt for PBKDF2 can be bytes or a string 2018-02-25 12:44:19 +01:00
Helder Eijs
b6350bf453 Update to Changelog and cleanup 2018-02-24 21:37:54 +01:00
Helder Eijs
f29343c6f1 Extend optimization to MD5, SHA1, SHA224, SHA384 and SHA512 2018-02-24 17:44:35 +01:00
Helder Eijs
1334dd5693 Improve efficiency of PBKDF2 for HMAC-based PRFs 2018-02-21 12:05:20 +01:00
Helder Eijs
97423dcb22 Optionally skip slow tests for KDFs 2018-01-25 21:46:49 +01:00
Helder Eijs
5d712a784e Don't fail hard with scrypt test using 1GB of RAM 2018-01-08 12:16:12 +01:00
Helder Eijs
ce14d08bdf Remove tests for internal scrypt functions 2017-01-30 21:40:48 +01:00
Helder Eijs
2870726a95 Moving more to C
[skip ci]
2017-01-30 21:37:32 +01:00
Helder Eijs
e5fb79f3f0 First round of optimization 2017-01-29 16:29:49 +01:00
Legrandin
abf4a007a7 DES3 does not accept weak (Single DES) keys 2015-12-25 09:08:22 +01:00
Legrandin
d83380a048 Removed support for Python<2.4 2014-06-16 20:36:35 +02:00
Legrandin
3755ff63fe Merge branch 'scrypt' of https://github.com/Legrandin/pycrypto
Conflicts:
	lib/Crypto/Protocol/KDF.py
	lib/Crypto/SelfTest/Cipher/common.py
	lib/Crypto/SelfTest/Hash/test_HMAC.py
	lib/Crypto/SelfTest/Protocol/test_KDF.py
	src/hash_template.c
2014-05-11 15:42:33 +02:00
Legrandin
02a41cb9e5 Add support for HKDF (RFC5869) 2014-03-04 22:31:19 +01:00
Legrandin
aa32e3d662 Optimize scrypt (~50%) and support for Python 2.1 2013-12-24 23:00:35 +01:00
Legrandin
102cd21c8d Add support for scrypt
scrypt is a robust password-based key derivation function.
These set of changes implements it according to the RFC draft:

http://tools.ietf.org/html/draft-josefsson-scrypt-kdf-01

scrypt is also added to the algorithms understood by PKCS#8
(so that one can protect private keys at rest with it).

Additionally, this patch adds tests cases for PBES functions.
2013-12-24 22:56:21 +01:00
Dwayne Litzenberger
7bb217aedd Rename S2V -> _S2V until we come up with a real PRF API 2013-10-20 17:48:54 -07:00
Legrandin
199a9741a1 Add support for SIV (Synthetic IV) mode
This patch add supports for SIV, an AEAD block cipher
mode defined in RFC5297. SIV is only valid for AES.

The PRF of SIV (S2V) is factored out in the Protocol.KDF module.

See the following example to get a feeling of the API (slightly
different than other AEAD mode, during decryption).

Encryption (Python 2):

	>>> from Crypto.Cipher import AES
	>>> key = b'0'*32
	>>> siv = AES.new(key, AES.MODE_SIV)
	>>> ct  = siv.encrypt(b'Message')
	>>> mac = siv.digest()

Decryption (Python 2):

	>>> from Crypto.Cipher import AES, MacMismatchError
	>>> key = b'0'*32
	>>> siv = AES.new(key, AES.MODE_SIV)
	>>> pt  = siv.decrypt(ct + mac)
	>>> try:
	>>>	siv.verify(mac)
	>>>	print "Plaintext", pt
	>>> except MacMismatchError:
	>>>     print "Error"

This change also fixes the description/design of AEAD API.

With SIV (RFC5297), decryption can only start when the MAC is known.
The original AEAD API did not support that.

For SIV the MAC is now exceptionally passed together with the ciphertext
to the decrypt() method.

[dlitz@dlitz.net: Included changes from the following commits from the author's pull request:]
- [9c13f9c] Rename 'IV' parameter to 'nonce' for AEAD modes.
- [d7727fb] Fix description/design of AEAD API.
- [fb62fae] ApiUsageError becomes TypeError [whitespace]
- [4ec64d8] Removed last references to ApiUsageError [whitespace]
- [ee46922] Removed most 'import *' statements
- [ca460a7] Made blockalgo.py more PEP-8 compliant;
            The second parameter of the _GHASH constructor
            is now the length of the block (block_size)
            and not the full module.
[dlitz@dlitz.net: A conflict that was not resolved in the previous
                  commit was originally resolved here.  Moved the
                  resolution to the previous commit.]
[dlitz@dlitz.net: Replaced MacMismatchError with ValueError]
[dlitz@dlitz.net: Replaced ApiUsageError with TypeError]
[dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"]
2013-10-20 13:30:21 -07:00
Legrandin
7214ce9929 Removed most 'import *' statements
[dlitz@dlitz.net: Re-ordered commits; so don't import S2V yet]
[dlitz@dlitz.net: Included an additional 'import *' change from the following commit:]
    commit 4ec64d8eaaa4965889eb8e3b801fc77aa84e0a4e
    Author: Legrandin <helderijs@gmail.com>
    Date:   Tue Sep 10 07:28:08 2013 +0200

        Removed last references to ApiUsageError

[dlitz@dlitz.net: Removed unrelated whitespace changes]
2013-10-20 13:30:21 -07:00
Legrandin
8766da37a2 whitespace changes (pre-AEAD)
[dlitz@dlitz.net: Whitespace changes extracted from the author's pull request:]
- [9c13f9c] Rename 'IV' parameter to 'nonce' for AEAD modes.
- [4ec64d8] Removed last references to ApiUsageError
- [ee46922] Removed most 'import *' statements
2013-10-20 13:30:21 -07:00
Dwayne Litzenberger
755375bb7d Hash: Rename SHA->SHA1 and RIPEMD->RIPEMD160 (1/2)
These algorithm names were confusing, because there are actually
algorithms called "SHA" (a.k.a. SHA-0) and "RIPEMD" (the original
version).

This commit just renames the modules, with no backward-compatibility
support.
2013-02-16 16:20:23 -08:00
Dwayne C. Litzenberger
7c3c710995 Re-enable (accidentally?) disabled PBKDF2 tests
These were disabled in commit 897b75983c
2012-01-13 10:01:17 -05:00
Legrandin
c22fa18c0d Merged from upstream (py3k support) and modified so that all unit tests pass. 2011-10-18 23:20:26 +02:00
Legrandin
897b75983c Added Lorenz Quack's native C implementation of all SHA-2 algorithm
(as submitted here https://bugs.launchpad.net/pycrypto/+bug/544792)
so that they are available also in Python 2.1, 2.2, 2.3 and 2.4.

Regardless where the implementation comes from (Python standard
library or our native modules, depending on the Python version),
all Crypto.Hash objects are always used as front-ends.
2011-10-16 22:41:21 +02:00
Legrandin
8a69efb465 Add new module Crypto.Protocol.KDF with two PKCS#5 key derivation algorithms. 2011-09-22 20:51:46 +02:00