Commit graph

37 commits

Author SHA1 Message Date
AlexanderUp
16678f925d Moved back to Crypto module 2022-12-14 08:36:15 +01:00
AlexanderUp
97c870823f Speedtest moved back to Crypto module 2022-12-14 08:36:15 +01:00
Alexander
fbcc5b3a44 Compatibility with python 3 improved.
Issues while Python3 run fixed:
1) Using Cryptodome library instead Crypto library.
2) Using time.perf_counter() instead time.time().
3) Using range() instead xrange().
4) Removing of big integer L literal.
5) Fixed encryption speed test with mode 'MODE_SIV'.
2022-12-14 08:36:15 +01:00
Hugo
494d23d003 Drop support for EOL Python 2.4 2018-09-24 08:51:20 +03:00
Legrandin
5f1dae51ed EAX performance test was running GCM 2015-06-05 21:30:01 +02:00
Legrandin
a0aa406ad6 Add OCB to benchmarks 2015-05-29 09:06:49 -04:00
Legrandin
c2ae9d1cc2 Add ChaCha20 benchmark 2015-04-30 11:44:35 -04:00
Legrandin
a64aead56d Update benchmark with BLAKE2b and BLAKE2s 2015-04-16 14:11:50 +02:00
Legrandin
db6c6f8e5e Add support or BLAKE2s and BLAKE2b 2015-04-16 14:11:50 +02:00
Legrandin
af28deab82 Make benchmark script work again 2015-01-10 21:47:35 +01:00
Legrandin
7cbec3b127 Add SHA-3 to benchmarks 2014-05-11 12:45:37 +02:00
Legrandin
87e8b9e67d Add Salsa20 benchmark
In the process, we clean up a bit the code.
2014-05-05 21:15:35 +02:00
Richard Mitchell
e442ffa2b0 Fix speedtest run for ECB modes. 2014-04-28 16:58:27 +01:00
Legrandin
35be87837d Add key setup speed benchmark for all AEAD modes. 2013-10-20 13:30:21 -07:00
Legrandin
5d7ab24c51 Add support for GCM mode (AES only).
The main change done by this commit is adding support
for MODE_GCM (NIST SP 800 38D). Test vectors are included.

The mode uses a C extension (Crypto.Util.galois._ghash)
to compute the GHASH step. The C implementation is the most
basic one and it is still significantly (5x times) slower than CTR.
Optimizations can be introduced using tables (CPU/memory trade-off)
or even AES NI instructions on newer x86 CPUs.

This patch also simplifies Crypto.Cipher.blockalgo.py by:
 * removing duplicated code previously shared by digest() and verify().
 * removing duplicated code previously shared by Crypto.Hash.CMAC
   and Crypto.Cipher.block_algo (management of internal buffers
   for MACs that can only operate on block aligned data, like
   CMAC, CBCMAC, and now also GHASH).

[dlitz@dlitz.net: Included changes from the following commits from the author's pull request:]
- [9c13f9c] Rename 'IV' parameter to 'nonce' for AEAD modes.
- [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: Replaced MacMismatchError with ValueError]
[dlitz@dlitz.net: Replaced ApiUsageError with TypeError]
[dlitz@dlitz.net: Replaced renamed variable `ht` with original `h`]
[dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"]
2013-10-20 13:30:21 -07:00
Legrandin
8bdbdb8168 Add EAX authenticated encryption mode
[dlitz@dlitz.net: Included changes from the following commits from the author's pull request:]
- [9c13f9c] Rename 'IV' parameter to 'nonce' for AEAD modes.
- [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: Fixed unresolved conflict in lib/Crypto/Cipher/blockalgo.py]
2013-10-20 13:30:21 -07:00
Legrandin
57104488fa Add support for CCM mode (AES only).
[dlitz@dlitz.net: Included changes from the following commits from the author's pull request:]
- [5306cf3] Added support for CCM mode (AES cipher only)
- [9abe301] Added CCM tests
- [f0c1395] Add MacMismatchError and ApiUsageError
- [fb62fae] ApiUsageError becomes TypeError
- [9c13f9c] Rename 'IV' parameter to 'nonce' for AEAD modes.
- [4ec64d8] Removed last references to ApiUsageError
- [80bfd35] Corrected AES-CCM examples
[dlitz@dlitz.net: Removed unrelated documentation change]
[dlitz@dlitz.net: Renamed 'targs' back to 'args']
[dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"]
2013-10-20 13:30:21 -07:00
Legrandin
da79b781af Add support for CMAC
This patch adds support for CMAC (RFC4493, NIST SP800-38B).

[dlitz@dlitz.net: Replaced MacMismatchError with ValueError]
[dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"]
2013-10-20 13:30:21 -07:00
Legrandin
92fea1b606 Add CTR mode benchmark 2013-10-20 13:30:21 -07:00
Dwayne Litzenberger
f54fb9c654 pct-speedtest.py: Add CTR-mode tests 2013-07-14 01:04:21 -07:00
Dwayne Litzenberger
b58ac57d42 pct-speedtest.py: Test the random module 2013-04-21 23:51:33 -07:00
Dwayne Litzenberger
e85ae486ab pct-speedtest.py: Add PKCS#1 signing and verification 2013-02-17 10:18:57 -08:00
Dwayne Litzenberger
3e0afc7ae3 Hash: Rename SHA->SHA1 and RIPEMD->RIPEMD160 (pct-speedtest.py)
Oops, I missed this one.
2013-02-17 09:44:54 -08: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 Litzenberger
aa7d69400b pct-speedtest.py: Test HMAC modules 2013-02-16 09:44:35 -08:00
Dwayne Litzenberger
7ba49c5cbc pct-speedtest.py: Add some comments 2013-02-16 09:44:35 -08:00
Dwayne Litzenberger
3eb6e1489a pct-speedtest.py: Also test the standard hashlib modules, if possible
On my machine, hashlib is about 5x faster than PyCrypto for single-block
inputs. :(  (It's about the same for long inputs.)
2013-02-16 09:44:35 -08:00
Dwayne Litzenberger
40184dc344 pct-speedtest.py: Add tests for SHA224/SHA384/SHA512 2013-02-16 09:44:35 -08:00
Dwayne Litzenberger
3ba082f25a pct-speedtest.py: Python 3 compatibility 2013-02-16 09:44:35 -08:00
Dwayne Litzenberger
109aae13b3 pct-speedtest.py: Python 2.1-2.3 compatibility
They don't have os.urandom, so use Crypto.Random.get_random_bytes
2013-02-16 09:44:19 -08:00
Legrandin
8459bc3d15 Performance test: display CFB-8 as CFB mode being test 2012-05-18 13:48:36 +02:00
Legrandin
30a374dd40 Added OPENPGP speed test 2012-05-17 22:46:14 +02:00
Legrandin
67d8cd1aaf Removed PGP mode from block ciphers 2012-05-14 19:52:30 +02:00
windwiny
5feb3e1c46 add MODE_ECB test 2012-01-13 11:56:02 -05:00
Lorenz Quack
c575de4f18 getStrongPrime() implementation
From http://lists.dlitz.net/pipermail/pycrypto/2009q4/000167.html, with the
following explanation included in the email:

=== snip ===
Hi there!

Here comes my monster patch.
It includes a python and C version of getStrongPrime, rabinMillerTest and isPrime.
there are also two small unit tests and some helper functions.
They all take a randfunc and propagate them (or so I hope).
The Rabin-Miller-Test uses random bases (non-deterministic).
getStrongPrime and isPrime take an optional parameter "false_positive_prob"
where one can specify the maximum probability that the prime is actually
composite. Internally the functions calculate the Rabin-Miller rounds from
this. It defaults to 1e-6 (1:1000000) which results in 10 rounds of Rabin-Miller
testing.

Please review this carefully. Even though I tried hard to get things right some
bugs always slip through.
maybe you could also review the way I acquire and release the GIL. It felt kind
of ugly the way I did it but I don't see a better way just now.

Concerning the public exponent e:
I now know why it needs to be coprime to p-1 and q-1. The private exponent d is
the inverse of e mod ((p-1)(q-1)).
If e is not coprime to ((p-1)(q-1)) then the inverse does not exist [1].

The getStrongPrime take an optional argument e. if provided the function will
make sure p-1 and e are coprime. if e is even (p-1)/2 will be coprime.
if e is even then there is a additional constraint: p =/= q mod 8.
I can't check for that in getStrongPrime of course but since we hardcoded e to
be odd in _RSA.py this should pose no problem.

The Baillie-PSW-Test is not included.

I tried hard not to use any functionality new than 2.1 but if you find anything
feel free to criticize. Also if I didn't get the coding style right either tell
me or feel free to correct it yourself.

have fun.
//Lorenz

[1] http://mathworld.wolfram.com/ModularInverse.html
=== snip ===
2010-06-10 21:02:07 -04:00
Dwayne C. Litzenberger
9615fb8516 Add support for the XOR cipher to pct-speedtest.py 2009-08-02 14:06:40 -04:00
Dwayne C. Litzenberger
896da968f8 Add pct-speedtest.py 2009-03-11 00:10:25 -04:00