Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

+233 -136
+206 -128
crypto/ctr.c
··· 11 11 */ 12 12 13 13 #include <crypto/algapi.h> 14 + #include <crypto/ctr.h> 14 15 #include <linux/err.h> 15 16 #include <linux/init.h> 16 17 #include <linux/kernel.h> ··· 20 19 #include <linux/scatterlist.h> 21 20 #include <linux/slab.h> 22 21 23 - struct ctr_instance_ctx { 24 - struct crypto_spawn alg; 25 - unsigned int noncesize; 26 - unsigned int ivsize; 27 - unsigned int countersize; 28 - }; 29 - 30 22 struct crypto_ctr_ctx { 31 23 struct crypto_cipher *child; 32 - u8 *nonce; 24 + }; 25 + 26 + struct crypto_rfc3686_ctx { 27 + struct crypto_blkcipher *child; 28 + u8 nonce[CTR_RFC3686_NONCE_SIZE]; 33 29 }; 34 30 35 31 static int crypto_ctr_setkey(struct crypto_tfm *parent, const u8 *key, ··· 34 36 { 35 37 struct crypto_ctr_ctx *ctx = crypto_tfm_ctx(parent); 36 38 struct crypto_cipher *child = ctx->child; 37 - struct ctr_instance_ctx *ictx = 38 - crypto_instance_ctx(crypto_tfm_alg_instance(parent)); 39 - unsigned int noncelen = ictx->noncesize; 40 - int err = 0; 41 - 42 - /* the nonce is stored in bytes at end of key */ 43 - if (keylen < noncelen) 44 - return -EINVAL; 45 - 46 - memcpy(ctx->nonce, key + (keylen - noncelen), noncelen); 47 - 48 - keylen -= noncelen; 39 + int err; 49 40 50 41 crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK); 51 42 crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) & ··· 47 60 } 48 61 49 62 static void crypto_ctr_crypt_final(struct blkcipher_walk *walk, 50 - struct crypto_cipher *tfm, u8 *ctrblk, 51 - unsigned int countersize) 63 + struct crypto_cipher *tfm) 52 64 { 53 65 unsigned int bsize = crypto_cipher_blocksize(tfm); 54 - u8 *keystream = ctrblk + bsize; 66 + unsigned long alignmask = crypto_cipher_alignmask(tfm); 67 + u8 *ctrblk = walk->iv; 68 + u8 tmp[bsize + alignmask]; 69 + u8 *keystream = PTR_ALIGN(tmp + 0, alignmask + 1); 55 70 u8 *src = walk->src.virt.addr; 56 71 u8 *dst = walk->dst.virt.addr; 57 72 unsigned int nbytes = walk->nbytes; ··· 61 72 crypto_cipher_encrypt_one(tfm, keystream, ctrblk); 62 73 crypto_xor(keystream, src, nbytes); 63 74 memcpy(dst, keystream, nbytes); 75 + 76 + crypto_inc(ctrblk, bsize); 64 77 } 65 78 66 79 static int crypto_ctr_crypt_segment(struct blkcipher_walk *walk, 67 - struct crypto_cipher *tfm, u8 *ctrblk, 68 - unsigned int countersize) 80 + struct crypto_cipher *tfm) 69 81 { 70 82 void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = 71 83 crypto_cipher_alg(tfm)->cia_encrypt; 72 84 unsigned int bsize = crypto_cipher_blocksize(tfm); 85 + u8 *ctrblk = walk->iv; 73 86 u8 *src = walk->src.virt.addr; 74 87 u8 *dst = walk->dst.virt.addr; 75 88 unsigned int nbytes = walk->nbytes; ··· 82 91 crypto_xor(dst, src, bsize); 83 92 84 93 /* increment counter in counterblock */ 85 - crypto_inc(ctrblk + bsize - countersize, countersize); 94 + crypto_inc(ctrblk, bsize); 86 95 87 96 src += bsize; 88 97 dst += bsize; ··· 92 101 } 93 102 94 103 static int crypto_ctr_crypt_inplace(struct blkcipher_walk *walk, 95 - struct crypto_cipher *tfm, u8 *ctrblk, 96 - unsigned int countersize) 104 + struct crypto_cipher *tfm) 97 105 { 98 106 void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = 99 107 crypto_cipher_alg(tfm)->cia_encrypt; 100 108 unsigned int bsize = crypto_cipher_blocksize(tfm); 109 + unsigned long alignmask = crypto_cipher_alignmask(tfm); 101 110 unsigned int nbytes = walk->nbytes; 111 + u8 *ctrblk = walk->iv; 102 112 u8 *src = walk->src.virt.addr; 103 - u8 *keystream = ctrblk + bsize; 113 + u8 tmp[bsize + alignmask]; 114 + u8 *keystream = PTR_ALIGN(tmp + 0, alignmask + 1); 104 115 105 116 do { 106 117 /* create keystream */ ··· 110 117 crypto_xor(src, keystream, bsize); 111 118 112 119 /* increment counter in counterblock */ 113 - crypto_inc(ctrblk + bsize - countersize, countersize); 120 + crypto_inc(ctrblk, bsize); 114 121 115 122 src += bsize; 116 123 } while ((nbytes -= bsize) >= bsize); ··· 127 134 struct crypto_ctr_ctx *ctx = crypto_blkcipher_ctx(tfm); 128 135 struct crypto_cipher *child = ctx->child; 129 136 unsigned int bsize = crypto_cipher_blocksize(child); 130 - struct ctr_instance_ctx *ictx = 131 - crypto_instance_ctx(crypto_tfm_alg_instance(&tfm->base)); 132 - unsigned long alignmask = crypto_cipher_alignmask(child) | 133 - (__alignof__(u32) - 1); 134 - u8 cblk[bsize * 2 + alignmask]; 135 - u8 *counterblk = (u8 *)ALIGN((unsigned long)cblk, alignmask + 1); 136 137 int err; 137 138 138 139 blkcipher_walk_init(&walk, dst, src, nbytes); 139 140 err = blkcipher_walk_virt_block(desc, &walk, bsize); 140 141 141 - /* set up counter block */ 142 - memset(counterblk, 0 , bsize); 143 - memcpy(counterblk, ctx->nonce, ictx->noncesize); 144 - memcpy(counterblk + ictx->noncesize, walk.iv, ictx->ivsize); 145 - 146 - /* initialize counter portion of counter block */ 147 - crypto_inc(counterblk + bsize - ictx->countersize, ictx->countersize); 148 - 149 142 while (walk.nbytes >= bsize) { 150 143 if (walk.src.virt.addr == walk.dst.virt.addr) 151 - nbytes = crypto_ctr_crypt_inplace(&walk, child, 152 - counterblk, 153 - ictx->countersize); 144 + nbytes = crypto_ctr_crypt_inplace(&walk, child); 154 145 else 155 - nbytes = crypto_ctr_crypt_segment(&walk, child, 156 - counterblk, 157 - ictx->countersize); 146 + nbytes = crypto_ctr_crypt_segment(&walk, child); 158 147 159 148 err = blkcipher_walk_done(desc, &walk, nbytes); 160 149 } 161 150 162 151 if (walk.nbytes) { 163 - crypto_ctr_crypt_final(&walk, child, counterblk, 164 - ictx->countersize); 152 + crypto_ctr_crypt_final(&walk, child); 165 153 err = blkcipher_walk_done(desc, &walk, 0); 166 154 } 167 155 ··· 152 178 static int crypto_ctr_init_tfm(struct crypto_tfm *tfm) 153 179 { 154 180 struct crypto_instance *inst = (void *)tfm->__crt_alg; 155 - struct ctr_instance_ctx *ictx = crypto_instance_ctx(inst); 181 + struct crypto_spawn *spawn = crypto_instance_ctx(inst); 156 182 struct crypto_ctr_ctx *ctx = crypto_tfm_ctx(tfm); 157 183 struct crypto_cipher *cipher; 158 184 159 - ctx->nonce = kzalloc(ictx->noncesize, GFP_KERNEL); 160 - if (!ctx->nonce) 161 - return -ENOMEM; 162 - 163 - cipher = crypto_spawn_cipher(&ictx->alg); 185 + cipher = crypto_spawn_cipher(spawn); 164 186 if (IS_ERR(cipher)) 165 187 return PTR_ERR(cipher); 166 188 ··· 169 199 { 170 200 struct crypto_ctr_ctx *ctx = crypto_tfm_ctx(tfm); 171 201 172 - kfree(ctx->nonce); 173 202 crypto_free_cipher(ctx->child); 174 203 } 175 204 ··· 176 207 { 177 208 struct crypto_instance *inst; 178 209 struct crypto_alg *alg; 179 - struct ctr_instance_ctx *ictx; 180 - unsigned int noncesize; 181 - unsigned int ivsize; 182 - unsigned int countersize; 183 210 int err; 184 211 185 212 err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER); ··· 187 222 if (IS_ERR(alg)) 188 223 return ERR_PTR(PTR_ERR(alg)); 189 224 190 - err = crypto_attr_u32(tb[2], &noncesize); 191 - if (err) 192 - goto out_put_alg; 193 - 194 - err = crypto_attr_u32(tb[3], &ivsize); 195 - if (err) 196 - goto out_put_alg; 197 - 198 - err = crypto_attr_u32(tb[4], &countersize); 199 - if (err) 200 - goto out_put_alg; 201 - 202 - /* verify size of nonce + iv + counter 203 - * counter must be >= 4 bytes. 204 - */ 225 + /* Block size must be >= 4 bytes. */ 205 226 err = -EINVAL; 206 - if (((noncesize + ivsize + countersize) < alg->cra_blocksize) || 207 - ((noncesize + ivsize) > alg->cra_blocksize) || 208 - (countersize > alg->cra_blocksize) || (countersize < 4)) 227 + if (alg->cra_blocksize < 4) 209 228 goto out_put_alg; 210 229 211 230 /* If this is false we'd fail the alignment of crypto_inc. */ 212 - if ((alg->cra_blocksize - countersize) % 4) 231 + if (alg->cra_blocksize % 4) 213 232 goto out_put_alg; 214 233 215 - inst = kzalloc(sizeof(*inst) + sizeof(*ictx), GFP_KERNEL); 216 - err = -ENOMEM; 217 - if (!inst) 218 - goto out_put_alg; 234 + inst = crypto_alloc_instance("ctr", alg); 235 + if (IS_ERR(inst)) 236 + goto out; 219 237 220 - err = -ENAMETOOLONG; 221 - if (snprintf(inst->alg.cra_name, CRYPTO_MAX_ALG_NAME, 222 - "ctr(%s,%u,%u,%u)", alg->cra_name, noncesize, 223 - ivsize, countersize) >= CRYPTO_MAX_ALG_NAME) { 224 - goto err_free_inst; 225 - } 226 - 227 - if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, 228 - "ctr(%s,%u,%u,%u)", alg->cra_driver_name, noncesize, 229 - ivsize, countersize) >= CRYPTO_MAX_ALG_NAME) { 230 - goto err_free_inst; 231 - } 232 - 233 - ictx = crypto_instance_ctx(inst); 234 - ictx->noncesize = noncesize; 235 - ictx->ivsize = ivsize; 236 - ictx->countersize = countersize; 237 - 238 - err = crypto_init_spawn(&ictx->alg, alg, inst, 239 - CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); 240 - if (err) 241 - goto err_free_inst; 242 - 243 - err = 0; 244 238 inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER; 245 239 inst->alg.cra_priority = alg->cra_priority; 246 240 inst->alg.cra_blocksize = 1; 247 241 inst->alg.cra_alignmask = alg->cra_alignmask | (__alignof__(u32) - 1); 248 242 inst->alg.cra_type = &crypto_blkcipher_type; 249 243 250 - inst->alg.cra_blkcipher.ivsize = ivsize; 251 - inst->alg.cra_blkcipher.min_keysize = alg->cra_cipher.cia_min_keysize 252 - + noncesize; 253 - inst->alg.cra_blkcipher.max_keysize = alg->cra_cipher.cia_max_keysize 254 - + noncesize; 244 + inst->alg.cra_blkcipher.ivsize = alg->cra_blocksize; 245 + inst->alg.cra_blkcipher.min_keysize = alg->cra_cipher.cia_min_keysize; 246 + inst->alg.cra_blkcipher.max_keysize = alg->cra_cipher.cia_max_keysize; 255 247 256 248 inst->alg.cra_ctxsize = sizeof(struct crypto_ctr_ctx); 257 249 ··· 219 297 inst->alg.cra_blkcipher.encrypt = crypto_ctr_crypt; 220 298 inst->alg.cra_blkcipher.decrypt = crypto_ctr_crypt; 221 299 222 - err_free_inst: 223 - if (err) 224 - kfree(inst); 300 + out: 301 + crypto_mod_put(alg); 302 + return inst; 225 303 226 304 out_put_alg: 227 - crypto_mod_put(alg); 228 - 229 - if (err) 230 - inst = ERR_PTR(err); 231 - 232 - return inst; 305 + inst = ERR_PTR(err); 306 + goto out; 233 307 } 234 308 235 309 static void crypto_ctr_free(struct crypto_instance *inst) 236 310 { 237 - struct ctr_instance_ctx *ictx = crypto_instance_ctx(inst); 238 - 239 - crypto_drop_spawn(&ictx->alg); 311 + crypto_drop_spawn(crypto_instance_ctx(inst)); 240 312 kfree(inst); 241 313 } 242 314 ··· 241 325 .module = THIS_MODULE, 242 326 }; 243 327 328 + static int crypto_rfc3686_setkey(struct crypto_tfm *parent, const u8 *key, 329 + unsigned int keylen) 330 + { 331 + struct crypto_rfc3686_ctx *ctx = crypto_tfm_ctx(parent); 332 + struct crypto_blkcipher *child = ctx->child; 333 + int err; 334 + 335 + /* the nonce is stored in bytes at end of key */ 336 + if (keylen < CTR_RFC3686_NONCE_SIZE) 337 + return -EINVAL; 338 + 339 + memcpy(ctx->nonce, key + (keylen - CTR_RFC3686_NONCE_SIZE), 340 + CTR_RFC3686_NONCE_SIZE); 341 + 342 + keylen -= CTR_RFC3686_NONCE_SIZE; 343 + 344 + crypto_blkcipher_clear_flags(child, CRYPTO_TFM_REQ_MASK); 345 + crypto_blkcipher_set_flags(child, crypto_tfm_get_flags(parent) & 346 + CRYPTO_TFM_REQ_MASK); 347 + err = crypto_blkcipher_setkey(child, key, keylen); 348 + crypto_tfm_set_flags(parent, crypto_blkcipher_get_flags(child) & 349 + CRYPTO_TFM_RES_MASK); 350 + 351 + return err; 352 + } 353 + 354 + static int crypto_rfc3686_crypt(struct blkcipher_desc *desc, 355 + struct scatterlist *dst, 356 + struct scatterlist *src, unsigned int nbytes) 357 + { 358 + struct crypto_blkcipher *tfm = desc->tfm; 359 + struct crypto_rfc3686_ctx *ctx = crypto_blkcipher_ctx(tfm); 360 + struct crypto_blkcipher *child = ctx->child; 361 + unsigned long alignmask = crypto_blkcipher_alignmask(tfm); 362 + u8 ivblk[CTR_RFC3686_BLOCK_SIZE + alignmask]; 363 + u8 *iv = PTR_ALIGN(ivblk + 0, alignmask + 1); 364 + u8 *info = desc->info; 365 + int err; 366 + 367 + /* set up counter block */ 368 + memcpy(iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE); 369 + memcpy(iv + CTR_RFC3686_NONCE_SIZE, info, CTR_RFC3686_IV_SIZE); 370 + 371 + /* initialize counter portion of counter block */ 372 + *(__be32 *)(iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) = 373 + cpu_to_be32(1); 374 + 375 + desc->tfm = child; 376 + desc->info = iv; 377 + err = crypto_blkcipher_encrypt_iv(desc, dst, src, nbytes); 378 + desc->tfm = tfm; 379 + desc->info = info; 380 + 381 + return err; 382 + } 383 + 384 + static int crypto_rfc3686_init_tfm(struct crypto_tfm *tfm) 385 + { 386 + struct crypto_instance *inst = (void *)tfm->__crt_alg; 387 + struct crypto_spawn *spawn = crypto_instance_ctx(inst); 388 + struct crypto_rfc3686_ctx *ctx = crypto_tfm_ctx(tfm); 389 + struct crypto_blkcipher *cipher; 390 + 391 + cipher = crypto_spawn_blkcipher(spawn); 392 + if (IS_ERR(cipher)) 393 + return PTR_ERR(cipher); 394 + 395 + ctx->child = cipher; 396 + 397 + return 0; 398 + } 399 + 400 + static void crypto_rfc3686_exit_tfm(struct crypto_tfm *tfm) 401 + { 402 + struct crypto_rfc3686_ctx *ctx = crypto_tfm_ctx(tfm); 403 + 404 + crypto_free_blkcipher(ctx->child); 405 + } 406 + 407 + static struct crypto_instance *crypto_rfc3686_alloc(struct rtattr **tb) 408 + { 409 + struct crypto_instance *inst; 410 + struct crypto_alg *alg; 411 + int err; 412 + 413 + err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER); 414 + if (err) 415 + return ERR_PTR(err); 416 + 417 + alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_BLKCIPHER, 418 + CRYPTO_ALG_TYPE_MASK); 419 + err = PTR_ERR(alg); 420 + if (IS_ERR(alg)) 421 + return ERR_PTR(err); 422 + 423 + /* We only support 16-byte blocks. */ 424 + err = -EINVAL; 425 + if (alg->cra_blkcipher.ivsize != CTR_RFC3686_BLOCK_SIZE) 426 + goto out_put_alg; 427 + 428 + /* Not a stream cipher? */ 429 + if (alg->cra_blocksize != 1) 430 + goto out_put_alg; 431 + 432 + inst = crypto_alloc_instance("rfc3686", alg); 433 + if (IS_ERR(inst)) 434 + goto out; 435 + 436 + inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER; 437 + inst->alg.cra_priority = alg->cra_priority; 438 + inst->alg.cra_blocksize = 1; 439 + inst->alg.cra_alignmask = alg->cra_alignmask; 440 + inst->alg.cra_type = &crypto_blkcipher_type; 441 + 442 + inst->alg.cra_blkcipher.ivsize = CTR_RFC3686_IV_SIZE; 443 + inst->alg.cra_blkcipher.min_keysize = alg->cra_blkcipher.min_keysize 444 + + CTR_RFC3686_NONCE_SIZE; 445 + inst->alg.cra_blkcipher.max_keysize = alg->cra_blkcipher.max_keysize 446 + + CTR_RFC3686_NONCE_SIZE; 447 + 448 + inst->alg.cra_ctxsize = sizeof(struct crypto_rfc3686_ctx); 449 + 450 + inst->alg.cra_init = crypto_rfc3686_init_tfm; 451 + inst->alg.cra_exit = crypto_rfc3686_exit_tfm; 452 + 453 + inst->alg.cra_blkcipher.setkey = crypto_rfc3686_setkey; 454 + inst->alg.cra_blkcipher.encrypt = crypto_rfc3686_crypt; 455 + inst->alg.cra_blkcipher.decrypt = crypto_rfc3686_crypt; 456 + 457 + out: 458 + crypto_mod_put(alg); 459 + return inst; 460 + 461 + out_put_alg: 462 + inst = ERR_PTR(err); 463 + goto out; 464 + } 465 + 466 + static struct crypto_template crypto_rfc3686_tmpl = { 467 + .name = "rfc3686", 468 + .alloc = crypto_rfc3686_alloc, 469 + .free = crypto_ctr_free, 470 + .module = THIS_MODULE, 471 + }; 472 + 244 473 static int __init crypto_ctr_module_init(void) 245 474 { 246 - return crypto_register_template(&crypto_ctr_tmpl); 475 + int err; 476 + 477 + err = crypto_register_template(&crypto_ctr_tmpl); 478 + if (err) 479 + goto out; 480 + 481 + err = crypto_register_template(&crypto_rfc3686_tmpl); 482 + if (err) 483 + goto out_drop_ctr; 484 + 485 + out: 486 + return err; 487 + 488 + out_drop_ctr: 489 + crypto_unregister_template(&crypto_ctr_tmpl); 490 + goto out; 247 491 } 248 492 249 493 static void __exit crypto_ctr_module_exit(void) 250 494 { 495 + crypto_unregister_template(&crypto_rfc3686_tmpl); 251 496 crypto_unregister_template(&crypto_ctr_tmpl); 252 497 } 253 498 ··· 417 340 418 341 MODULE_LICENSE("GPL"); 419 342 MODULE_DESCRIPTION("CTR Counter block mode"); 343 + MODULE_ALIAS("rfc3686");
+3 -4
crypto/gcm.c
··· 160 160 161 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 166 static int crypto_gcm_encrypt_counter(struct crypto_aead *aead, u8 *block, ··· 400 400 return inst; 401 401 402 402 inst = ERR_PTR(ENAMETOOLONG); 403 - if (snprintf( 404 - ctr_name, CRYPTO_MAX_ALG_NAME, 405 - "ctr(%s,0,16,4)", cipher->cra_name) >= CRYPTO_MAX_ALG_NAME) 403 + if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", 404 + cipher->cra_name) >= CRYPTO_MAX_ALG_NAME) 406 405 return inst; 407 406 408 407 ctr = crypto_alg_mod_lookup(ctr_name, CRYPTO_ALG_TYPE_BLKCIPHER,
+4 -4
crypto/tcrypt.c
··· 1193 1193 AES_XTS_ENC_TEST_VECTORS); 1194 1194 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template, 1195 1195 AES_XTS_DEC_TEST_VECTORS); 1196 - test_cipher("ctr(aes,4,8,4)", ENCRYPT, aes_ctr_enc_tv_template, 1196 + test_cipher("rfc3686(ctr(aes))", ENCRYPT, aes_ctr_enc_tv_template, 1197 1197 AES_CTR_ENC_TEST_VECTORS); 1198 - test_cipher("ctr(aes,4,8,4)", DECRYPT, aes_ctr_dec_tv_template, 1198 + test_cipher("rfc3686(ctr(aes))", DECRYPT, aes_ctr_dec_tv_template, 1199 1199 AES_CTR_DEC_TEST_VECTORS); 1200 1200 test_aead("gcm(aes)", ENCRYPT, aes_gcm_enc_tv_template, 1201 1201 AES_GCM_ENC_TEST_VECTORS); ··· 1394 1394 AES_XTS_ENC_TEST_VECTORS); 1395 1395 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template, 1396 1396 AES_XTS_DEC_TEST_VECTORS); 1397 - test_cipher("ctr(aes,4,8,4)", ENCRYPT, aes_ctr_enc_tv_template, 1397 + test_cipher("rfc3686(ctr(aes))", ENCRYPT, aes_ctr_enc_tv_template, 1398 1398 AES_CTR_ENC_TEST_VECTORS); 1399 - test_cipher("ctr(aes,4,8,4)", DECRYPT, aes_ctr_dec_tv_template, 1399 + test_cipher("rfc3686(ctr(aes))", DECRYPT, aes_ctr_dec_tv_template, 1400 1400 AES_CTR_DEC_TEST_VECTORS); 1401 1401 break; 1402 1402
+20
include/crypto/ctr.h
··· 1 + /* 2 + * CTR: Counter mode 3 + * 4 + * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License as published by the Free 8 + * Software Foundation; either version 2 of the License, or (at your option) 9 + * any later version. 10 + * 11 + */ 12 + 13 + #ifndef _CRYPTO_CTR_H 14 + #define _CRYPTO_CTR_H 15 + 16 + #define CTR_RFC3686_NONCE_SIZE 4 17 + #define CTR_RFC3686_IV_SIZE 8 18 + #define CTR_RFC3686_BLOCK_SIZE 16 19 + 20 + #endif /* _CRYPTO_CTR_H */