Commit graph

17 commits

Author SHA1 Message Date
Legrandin
c2b27a3cd9 Update link to latest scrypt RFC draft 2015-08-04 20:32:17 +00:00
Legrandin
f9c9e92b01 Stream ciphers use raw interface 2015-01-24 21:07:17 +01:00
Legrandin
e9adec93c7 Every cipher instance is a mode-specific type 2014-12-10 21:40:49 +01:00
Legrandin
6e19820cc2 Optimize speed of PBKDF2 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
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
Dwayne Litzenberger
acbd4dedc8 More ValueError -> TypeError 2013-10-20 13:30:22 -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
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
Legrandin
6f31263720 Fix documentation for PKCS#1 modules.
Objects used by PKCS#1 modules were treated as private,
and therefore ignored by epydoc.

Replaced SHA module with None as PBKDF1 default parameter value, because it was
not displayed nicely by epydoc. Default value is assigned in the body.
2012-04-19 22:40:39 +02:00
Legrandin
bec515ac75 Fixed short digest exception message in PBKDF1. 2012-01-17 23:23:17 +01: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
8a69efb465 Add new module Crypto.Protocol.KDF with two PKCS#5 key derivation algorithms. 2011-09-22 20:51:46 +02:00