diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2018-06-19 18:34:33 +0300 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2018-06-19 19:29:25 +0300 |
commit | ca21a24808efa5d562ac91f683504ae0d6dfa69f (patch) | |
tree | b0088b2bfbe08948d4275e9036e7fdce9adbb8e4 /cipher/camellia-glue.c | |
parent | b6e6ace324440f564df664e27f8276ef01f76795 (diff) | |
download | libgcrypt-ca21a24808efa5d562ac91f683504ae0d6dfa69f.tar.gz |
Pass cipher object pointer to setkey functions
* cipher/cipher.c (cipher_setkey): Pass cipher object pointer to
cipher's setkey function.
* cipher/arcfour.c: Add gcry_cipher_hd_t parameter for setkey
functions and update selftests to pass NULL pointer.
* cipher/blowfish.c: Ditto.
* cipher/camellia-glue.c: Ditto.
* cipher/cast5.c: Ditto.
* cipher/chacha20.c: Ditto.
* cipher/cipher-selftest.c: Ditto.
* cipher/des.c: Ditto.
* cipher/gost28147.c: Ditto.
* cipher/idea.c: Ditto.
* cipher/rfc2268.c: Ditto.
* cipher/rijndael.c: Ditto.
* cipher/salsa20.c: Ditto.
* cipher/seed.c: Ditto.
* cipher/serpent.c: Ditto.
* cipher/twofish.c: Ditto.
* src/cipher-proto.h: Ditto.
--
This allows setkey function to replace bulk cipher operations
with faster alternative.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/camellia-glue.c')
-rw-r--r-- | cipher/camellia-glue.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/cipher/camellia-glue.c b/cipher/camellia-glue.c index 76870944..22df2146 100644 --- a/cipher/camellia-glue.c +++ b/cipher/camellia-glue.c @@ -204,7 +204,8 @@ extern void _gcry_camellia_aesni_avx2_ocb_auth(CAMELLIA_context *ctx, static const char *selftest(void); static gcry_err_code_t -camellia_setkey(void *c, const byte *key, unsigned keylen) +camellia_setkey(void *c, const byte *key, unsigned keylen, + gcry_cipher_hd_t hd) { CAMELLIA_context *ctx=c; static int initialized=0; @@ -213,6 +214,8 @@ camellia_setkey(void *c, const byte *key, unsigned keylen) unsigned int hwf = _gcry_get_hw_features (); #endif + (void)hd; + if(keylen!=16 && keylen!=24 && keylen!=32) return GPG_ERR_INV_KEYLEN; @@ -991,7 +994,7 @@ selftest(void) 0x20,0xef,0x7c,0x91,0x9e,0x3a,0x75,0x09 }; - camellia_setkey(&ctx,key_128,sizeof(key_128)); + camellia_setkey(&ctx,key_128,sizeof(key_128),NULL); camellia_encrypt(&ctx,scratch,plaintext); if(memcmp(scratch,ciphertext_128,sizeof(ciphertext_128))!=0) return "CAMELLIA-128 test encryption failed."; @@ -999,7 +1002,7 @@ selftest(void) if(memcmp(scratch,plaintext,sizeof(plaintext))!=0) return "CAMELLIA-128 test decryption failed."; - camellia_setkey(&ctx,key_192,sizeof(key_192)); + camellia_setkey(&ctx,key_192,sizeof(key_192),NULL); camellia_encrypt(&ctx,scratch,plaintext); if(memcmp(scratch,ciphertext_192,sizeof(ciphertext_192))!=0) return "CAMELLIA-192 test encryption failed."; @@ -1007,7 +1010,7 @@ selftest(void) if(memcmp(scratch,plaintext,sizeof(plaintext))!=0) return "CAMELLIA-192 test decryption failed."; - camellia_setkey(&ctx,key_256,sizeof(key_256)); + camellia_setkey(&ctx,key_256,sizeof(key_256),NULL); camellia_encrypt(&ctx,scratch,plaintext); if(memcmp(scratch,ciphertext_256,sizeof(ciphertext_256))!=0) return "CAMELLIA-256 test encryption failed."; |