Commit Graph
11143 Commits
Author SHA1 Message Date
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 1ef6c0ef06 utils: Provide an INIT_EXTRA() macro, that allocates extra data to INIT() 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 f17861dca9 vici: Relicense libvici.h under MIT
libvici currently relies on libstrongswan, and therefore is bound to the GPLv2.
But to allow alternatively licensed reimplementations without copyleft based
on the same interface, we liberate the header.
2015-04-14 17:42:53 +02:00
Martin Willi 3ba3be97d6 utils: Define MAX_(U)INT_TYPE to the maximum size integer type available 2015-04-14 12:03:57 +02:00
Martin Willi 051064ac60 utils: Typedef int128_t and u_int128_t types if supported 2015-04-14 12:03:46 +02:00
Martin Willi 161a015782 utils: Use chunk_equals_const() for all cryptographic purposes 2015-04-14 12:02:51 +02:00
Martin Willi 9d6e952201 utils: Add a constant time chunk_equals() variant for cryptographic purposes 2015-04-14 12:02:48 +02:00
Martin Willi 71afe0a556 utils: Use memeq_const() for all cryptographic purposes 2015-04-14 11:53:31 +02:00
Martin Willi b833963270 utils: Add a constant time memeq() variant for cryptographic purposes 2015-04-14 11:51:54 +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 793851856b cpu-feature: Support Via Padlock security features 2015-04-13 15:31:58 +02:00
Martin Willi f155880eda cpu-feature: Add a common class to query available CPU features
Currently supported is x86/x64 via cpuid() for some common 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 d20be3fa28 vici: Defer read/write error reporting after connection entry has been released
If a vici client registered for (control-)log events, but a vici read/write
operation fails, this may result in a deadlock. The attempt to write to the
bus results in a vici log message, which in turn tries to acquire the lock
for the entry currently held.

While a recursive lock could help as well for a single thread, there is still
a risk of inter-thread races if there is more than one thread listening for
events and/or having read/write errors.

We instead log to a local buffer, and write to the bus not before the connection
entry has been released. Additionally, we mark the connection entry as unusable
to avoid writing to the failed socket again, potentially triggering an error
loop.
2015-04-13 15:08:10 +02:00
Martin Willi 3c81cb6fc3 aead: Create AEAD using traditional transforms with an explicit IV generator
Real AEADs directly provide a suitable IV generator, but traditional crypters
do not. For some (stream) ciphers, we should use sequential IVs, for which
we pass an appropriate generator to the AEAD wrapper.
2015-04-13 15:06:15 +02:00
Martin Willi a4549e5525 iv-gen: Add a generic constructor to create an IV gen from an algorithm 2015-04-13 15:06:15 +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 7394ad92ae thread: Remove unneeded thread startup synchronization
sem_init() is deprecated on OS X, and it actually fails with ENOSYS. Using our
wrapped semaphore object is not an option, as it relies on the thread cleanup
that we can't rely on at this stage.

It is unclear why startup synchronization is required, as we can allocate the
thread ID just before creating the pthread. There is a chance that we allocate
a thread ID for a thread that fails to create, but the risk and consequences
are negligible.
2015-04-13 14:50:45 +02:00
Martin Willi 101d67440f libsimaka: Link against Winsock2 on Windows
The library makes use of htons/ntohs().
2015-04-13 09:31:28 +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
Martin Willi dad99b5eea kernel-netlink: Fix GCC error about uninitialized variable use
get_replay_state() always returns a replay_state_len when returning a
replay state, but GCC doesn't know about that.
2015-04-08 11:13:04 +02:00
Martin Willi 12def59617 asn1: Undefine TIME_UTC, which is used by C11
When building with C11 support, TIME_UTC is used for timespec_get() and
defined in <time.h>. Undefine TIME_UTC for our own internal use in asn1.c.
2015-04-08 08:47:31 +02:00
Andreas Steffen ff96400d13 Wipe auxiliary key store 2015-03-28 10:44:23 +01:00
Martin Willi 9310d4250a crypto-tester: Explicitly exclude FIPS-PRF from append mode tests
This was implicitly done by the seed length check before 58dda5d6, but we
now require an explicit check to avoid that unsupported use.
2015-03-28 08:38:52 +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
Andreas Steffen 883c11caa0 Added tnc/tnccs-20-fail-init and tnc/tnccs-20-fail-resp scenarios 2015-03-27 20:56:44 +01:00
Andreas Steffen 619e0b4235 Fixed PB-TNC error handling 2015-03-27 20:56:44 +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
Martin Willi 58dda5d6ab crypto-tester: Test set_key() after a doing a partial append on prf/signers
While that use is uncommon in real-world use, nonetheless should HMAC set a
correct key and reset any underlying hasher.
2015-03-27 15:53:47 +01:00
Tobias Brunner c063b9cfe9 stroke: Properly parse bliss key strength in public key constraint 2015-03-25 13:27:15 +01:00