Commit Graph
1249 Commits
Author SHA1 Message Date
Martin Willi 23947b2a4f aesni: Fix doxygen groups 2015-04-15 17:29:56 +02:00
Martin Willi 13a5a906e9 gcrypt: Explicitly initialize RNG backend to allocate static data
The libgcrypt RNG implementation uses static buffer allocation which it does
not free. There is no symbol we can catch in leak-detective, hence we explicitly
initialize the RNG during the whitelisted gcrypt_plugin_create() function.
2015-04-15 14:38:42 +02:00
Martin Willi 41421b85a9 gcrypt: Support setting private value and testing of DH backend 2015-04-15 14:38:42 +02:00
Martin Willi 0778c027a7 openssl: Support setting ECDH private values 2015-04-15 14:38:42 +02:00
Martin Willi e77ca5c79d openssl: Support setting private Diffie-Hellman values 2015-04-15 14:38:42 +02:00
Martin Willi 1a522d327e gmp: Support setting Diffie-Hellman private values 2015-04-15 14:38:41 +02:00
Martin Willi b8f576a803 test-vectors: Add DH vectors for Brainpool groups 2015-04-15 14:38:41 +02:00
Martin Willi 8b070b1b36 test-vectors: Add DH vectors for ECDH groups 2015-04-15 14:38:41 +02:00
Martin Willi 57f1ef220c test-vectors: Add DH vectors for subgroup MODP groups 2015-04-15 14:38:41 +02:00
Martin Willi e62906524c test-vectors: Add DH vectors for normal MODP groups 2015-04-15 14:38:39 +02:00
Martin Willi 79955b2b99 test-vectors: Support testing DH groups 2015-04-15 14:37:38 +02:00
Martin Willi 37794878cc aesni: Avoid loading AES/GHASH round keys into local variables
The performance impact is not measurable, as the compiler loads these variables
in xmm registers in unrolled loops anyway.

However, we avoid loading these sensitive keys onto the stack. This happens for
larger key schedules, where the register count is insufficient. If that key
material is not on the stack, we can avoid to wipe it explicitly after
crypto operations.
2015-04-15 13:44:40 +02:00
Martin Willi 93f0080265 aesni: Align all class instances to 16 byte boundaries
While the required members are aligned in the struct as required, on 32-bit
platforms the allocator aligns the structures itself to 8 bytes only. This
results in non-aligned struct members, and invalid memory accesses.
2015-04-15 13:44:40 +02:00
Martin Willi edab6c658c aesni: Calculate GHASH for 4 blocks of associated data in parallel
While associated data is usually not that large, in some specific cases
this can bring a significant performance boost.
2015-04-15 11:35:28 +02:00
Martin Willi 0eb593b0bb aesni: Calculate GHASH for 4 blocks of encryption data in parallel
Increases performance by another ~30%.
2015-04-15 11:35:28 +02:00
Martin Willi 58c44cdd00 aesni: Use 4-way parallel en/decryption in GCM
Increases overall performance by ~25%.
2015-04-15 11:35:28 +02:00
Martin Willi 677649cfb5 aesni: Use dedicated key size specific en-/decryption functions in GCM
This gives not much more than ~5% increase in performance, but allows us to
improve further.
2015-04-15 11:35:28 +02:00
Martin Willi 313811b72d aesni: Add a GCM AEAD based on the AES-NI key schedule 2015-04-15 11:35:28 +02:00
Martin Willi 4284660677 aesni: Implement CMAC mode to provide a signer/prf
Compared to the cmac plugin using AESNI-CBC as backend, this improves
performance of AES-CMAC by ~45%.
2015-04-15 11:35:28 +02:00
Martin Willi 9d187f8711 aesni: Implement XCBC mode to provide a signer/prf
Compared to the xcbc plugin using AESNI-CBC as backend, this improves
performance of AES-XCBC by ~45%.
2015-04-15 11:35:28 +02:00
Martin Willi d48642b7eb aesni: Partially use separate code paths for different key sizes in CCM
Due to the serial nature of the CBC mac, this brings only a marginal speedup.
2015-04-15 11:35:28 +02:00
Martin Willi 1ae46dfba2 aesni: Add a CCM AEAD reusing the key schedule 2015-04-15 11:35:27 +02:00
Martin Willi 8488dea2f9 aesni: Use 4-way parallel AES-NI instructions for CTR en/decryption
CTR can be parallelized, and we do so by queueing instructions to the processor
pipeline. While we have enough registers for 128-bit decryption, the register
count is insufficient to hold all variables with larger key sizes. Nonetheless
is 4-way parallelism faster, depending on key size between ~10% and ~25%.
2015-04-15 11:35:27 +02:00
Martin Willi 9e47c1fe77 aesni: Use dedicated round count specific encryption functions in CTR mode
This allows us to unroll loops and hold the key schedule in local (register)
variables. This brings an impressive speedup of ~45%.
2015-04-15 11:35:27 +02:00
Martin Willi 74d43cbde9 aesni: Implement a AES-NI based CTR crypter using the key schedule 2015-04-15 11:35:27 +02:00
Martin Willi a3cb72e850 aesni: Use 4-way parallel AES-NI instructions for CBC decryption
CBC decryption can be parallelized, and we do so by queueing instructions
to the processor pipeline. While we have enough registers for 128-bit
decryption, the register count is insufficient to hold all variables with
larger key sizes. Nonetheless is 4-way parallelism faster, roughly by ~8%.
2015-04-15 11:35:27 +02:00
Martin Willi 95ef361415 aesni: Use separate en-/decryption CBC code paths for different key sizes
This allows us to unroll loops, and use local (register) variables for the
key schedule. This improves performance slightly for encryption, but a lot
for reorderable decryption (>30%).
2015-04-15 11:35:27 +02:00
Martin Willi 8f1fab93e9 aesni: Implement a AES-NI based CBC crypter using the key schedule 2015-04-15 11:35:27 +02:00
Martin Willi b2d96bfe25 aesni: Implement 256-bit key schedule 2015-04-15 11:35:27 +02:00
Martin Willi d7811415ff aesni: Implement 192-bit key schedule 2015-04-15 11:35:26 +02:00
Martin Willi 6d7671eb1c aesni: Implement 128-bit key schedule 2015-04-15 11:35:26 +02:00
Martin Willi 431f452ed4 aesni: Add a common key schedule class for AES 2015-04-15 11:35:26 +02:00
Martin Willi 78c04b5d4d aesni: Provide a plugin stub for AES-NI instruction based crypto primitives 2015-04-15 11:35:26 +02:00
Martin Willi ed6295944b test-vectors: Add some self-made additional AES-GCM test vectors
We missed test vectors for 192/256-bit key vectors for ICV8/12, and should
also have some for larger associated data chunk.
2015-04-15 11:35:26 +02:00
Martin Willi 5c419b2974 test-vectors: Define some additional CCM test vectors
We don't have any where plain or associated data is not a multiple of the block
size, but it is likely to find bugs here. Also, we miss some ICV12 test vectors
using 128- and 192-bit key sizes.
2015-04-15 11:35:26 +02:00
Martin Willi 3a5106caea crypto-tester: Use the plugin feature key size to benchmark crypters/aeads
We previously didn't pass the key size during algorithm registration, but this
resulted in benchmarking with the "default" key size the crypter uses when
passing 0 as key size.
2015-04-15 11:35:26 +02:00
Martin Willi 161a015782 utils: Use chunk_equals_const() for all cryptographic purposes 2015-04-14 12:02:51 +02:00
Martin Willi 71afe0a556 utils: Use memeq_const() for all cryptographic purposes 2015-04-14 11:53:31 +02:00
Martin Willi 63d1e5b930 rdrand: Reuse CPU feature detection to check for RDRAND instructions 2015-04-13 15:31:58 +02:00
Martin Willi 137079b56f padlock: Reuse common CPU feature detection to check for Padlock features 2015-04-13 15:31:58 +02:00
Martin Willi 6a84a4049d sqlite: Use our locking mechanism also when sqlite3_threadsafe() returns 0
We previously checked for older library versions without locking support at
all. But newer libraries can be built in single-threading mode as well, where
we have to care about the locking.
2015-04-13 15:31:58 +02:00
Martin Willi 4e621ada96 sqlite: Show SQLite library version and thread safety flag during startup 2015-04-13 15:31:58 +02:00
Martin Willi c2906c8f21 openssl: Don't pre-initialize OpenSSL HMAC with an empty key
With OpenSSL commit 929b0d70c19f60227f89fac63f22a21f21950823 setting an empty
key fails if no previous key has been set on that HMAC.

In 9138f49e we explicitly added the check we remove now, as HMAC_Update()
might crash if HMAC_Init_ex() has not been called yet. To avoid that, we
set and check a flag locally to let any get_mac() call fail if set_key() has
not yet been called.
2015-04-13 14:52:30 +02:00
Martin Willi 280f752c56 fips-prf: Remove superfluous <arpa/inet.h> include
As we make no use of htonl() and friends, this is unneeded, but actually
prevents a Windows build.
2015-04-13 09:31:28 +02:00
Andreas Steffen ff96400d13 Wipe auxiliary key store 2015-03-28 10:44:23 +01:00
Martin Willi b234fdfce8 fips-prf: Fail when trying to use append mode on FIPS-PRF
Append mode hardly makes sense for the special stateful FIPS-PRF, which is
different to other PRFs.
2015-03-28 08:36:35 +01:00
Martin Willi bc1876bc9a cmac: Reset state before doing set_key() 2015-03-27 16:07:53 +01:00
Martin Willi 4075e9d7a4 af-alg: Reset hmac/xcbc state before doing set_key() 2015-03-27 16:06:21 +01:00
Martin Willi eedd92b53b xcbc: Reset XCBC state in set_key()
If some partial data has been appended, a truncated key gets invalid if it
is calculated from the pending state.
2015-03-27 15:53:52 +01:00
Martin Willi bfb029c82a hmac: Reset the underlying hasher before doing set_key() with longer keys
The user might have done a non-complete append, having some state in the
hasher.

Fixes #909.
2015-03-27 15:53:50 +01:00