diff options
author | Niels Möller <nisse@lysator.liu.se> | 2012-03-30 22:05:49 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2012-03-30 22:05:49 +0200 |
commit | 60f3e6778c6b690ca627012f92df27b0eb0f32f3 (patch) | |
tree | 93499aac2f2183104e388abf803c026711667c10 /nettle-internal.c | |
parent | 4403177a7d529dd73c8e5a10ad8df77b112d45cb (diff) | |
download | nettle-60f3e6778c6b690ca627012f92df27b0eb0f32f3.tar.gz |
Support salsa20 in nettle-benchmark.
Diffstat (limited to 'nettle-internal.c')
-rw-r--r-- | nettle-internal.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/nettle-internal.c b/nettle-internal.c index b789a572..93199a98 100644 --- a/nettle-internal.c +++ b/nettle-internal.c @@ -35,9 +35,10 @@ #include "blowfish.h" #include "des.h" #include "gcm.h" +#include "salsa20.h" /* DES uses a different signature for the key set function. We ignore - the return value incicating weak keys. */ + the return value indicating weak keys. */ static void des_set_key_hack(void *ctx, unsigned length, const uint8_t *key) { @@ -77,6 +78,25 @@ nettle_des3 = { const struct nettle_cipher nettle_blowfish128 = _NETTLE_CIPHER(blowfish, BLOWFISH, 128); +/* Sets a fix zero iv. For benchmarking only. */ +static void +salsa20_set_key_hack(void *ctx, unsigned length, const uint8_t *key) +{ + static const uint8_t iv[SALSA20_IV_SIZE]; + salsa20_set_key (ctx, length, key); + salsa20_set_iv (ctx, SALSA20_IV_SIZE, iv); +} + +/* Claim zero block size, to classify as a stream cipher. */ +const struct nettle_cipher +nettle_salsa20 = { + "salsa20", sizeof(struct salsa20_ctx), + 0, SALSA20_KEY_SIZE, + salsa20_set_key_hack, salsa20_set_key_hack, + (nettle_crypt_func *) salsa20_crypt, + (nettle_crypt_func *) salsa20_crypt +}; + const struct nettle_aead nettle_gcm_aes128 = _NETTLE_AEAD(gcm, GCM, aes, 128); const struct nettle_aead |