diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-12-17 08:34:32 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-01-10 16:16:41 -0500 |
commit | 5311f248b7764ba8b59e6d477355f766e5609686 (patch) | |
tree | 228910c68fc3d29a6bfe82cccfdc042e4003ebd2 /crypto/gcm.c | |
parent | 653ebd9c8510a7d647ed23e66e1338f848ebdbab (diff) |
[CRYPTO] ctr: Refactor into ctr and rfc3686
As discussed previously, this patch moves the basic CTR functionality
into a chainable algorithm called ctr. The IPsec-specific variant of
it is now placed on top with the name rfc3686.
So ctr(aes) gives a chainable cipher with IV size 16 while the IPsec
variant will be called rfc3686(ctr(aes)). This patch also adjusts
gcm accordingly.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/gcm.c')
-rw-r--r-- | crypto/gcm.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/crypto/gcm.c b/crypto/gcm.c index 08183171913c..c54d478948a0 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c | |||
@@ -160,7 +160,7 @@ static void crypto_gcm_ghash_final_xor(struct crypto_gcm_ghash_ctx *ctx, | |||
160 | 160 | ||
161 | static inline void crypto_gcm_set_counter(u8 *counterblock, u32 value) | 161 | static inline void crypto_gcm_set_counter(u8 *counterblock, u32 value) |
162 | { | 162 | { |
163 | *((u32 *)&counterblock[12]) = cpu_to_be32(value); | 163 | *((u32 *)&counterblock[12]) = cpu_to_be32(value + 1); |
164 | } | 164 | } |
165 | 165 | ||
166 | static int crypto_gcm_encrypt_counter(struct crypto_aead *aead, u8 *block, | 166 | static int crypto_gcm_encrypt_counter(struct crypto_aead *aead, u8 *block, |
@@ -400,9 +400,8 @@ static struct crypto_instance *crypto_gcm_alloc(struct rtattr **tb) | |||
400 | return inst; | 400 | return inst; |
401 | 401 | ||
402 | inst = ERR_PTR(ENAMETOOLONG); | 402 | inst = ERR_PTR(ENAMETOOLONG); |
403 | if (snprintf( | 403 | if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", |
404 | ctr_name, CRYPTO_MAX_ALG_NAME, | 404 | cipher->cra_name) >= CRYPTO_MAX_ALG_NAME) |
405 | "ctr(%s,0,16,4)", cipher->cra_name) >= CRYPTO_MAX_ALG_NAME) | ||
406 | return inst; | 405 | return inst; |
407 | 406 | ||
408 | ctr = crypto_alg_mod_lookup(ctr_name, CRYPTO_ALG_TYPE_BLKCIPHER, | 407 | ctr = crypto_alg_mod_lookup(ctr_name, CRYPTO_ALG_TYPE_BLKCIPHER, |