Lines Matching refs:ctx
321 static void vhash_abort(struct vmac_ctx *ctx) in vhash_abort() argument
323 ctx->polytmp[0] = ctx->polykey[0] ; in vhash_abort()
324 ctx->polytmp[1] = ctx->polykey[1] ; in vhash_abort()
325 ctx->first_block_processed = 0; in vhash_abort()
369 struct vmac_ctx *ctx) in vhash_update() argument
372 const u64 *kptr = (u64 *)ctx->nhkey; in vhash_update()
375 u64 pkh = ctx->polykey[0]; in vhash_update()
376 u64 pkl = ctx->polykey[1]; in vhash_update()
386 ch = ctx->polytmp[0]; in vhash_update()
387 cl = ctx->polytmp[1]; in vhash_update()
389 if (!ctx->first_block_processed) { in vhash_update()
390 ctx->first_block_processed = 1; in vhash_update()
405 ctx->polytmp[0] = ch; in vhash_update()
406 ctx->polytmp[1] = cl; in vhash_update()
410 u64 *tagl, struct vmac_ctx *ctx) in vhash() argument
413 const u64 *kptr = (u64 *)ctx->nhkey; in vhash()
416 u64 pkh = ctx->polykey[0]; in vhash()
417 u64 pkl = ctx->polykey[1]; in vhash()
423 if (ctx->first_block_processed) { in vhash()
424 ch = ctx->polytmp[0]; in vhash()
425 cl = ctx->polytmp[1]; in vhash()
456 vhash_abort(ctx); in vhash()
458 return l3hash(ch, cl, ctx->l3key[0], ctx->l3key[1], remaining); in vhash()
463 struct vmac_ctx_t *ctx) in vmac() argument
469 in_n = ctx->__vmac_ctx.cached_nonce; in vmac()
470 out_p = ctx->__vmac_ctx.cached_aes; in vmac()
477 crypto_cipher_encrypt_one(ctx->child, in vmac()
483 h = vhash(m, mbytes, (u64 *)0, &ctx->__vmac_ctx); in vmac()
487 static int vmac_set_key(unsigned char user_key[], struct vmac_ctx_t *ctx) in vmac_set_key() argument
493 err = crypto_cipher_setkey(ctx->child, user_key, VMAC_KEY_LEN); in vmac_set_key()
499 for (i = 0; i < sizeof(ctx->__vmac_ctx.nhkey)/8; i += 2) { in vmac_set_key()
500 crypto_cipher_encrypt_one(ctx->child, in vmac_set_key()
502 ctx->__vmac_ctx.nhkey[i] = be64_to_cpup(out); in vmac_set_key()
503 ctx->__vmac_ctx.nhkey[i+1] = be64_to_cpup(out+1); in vmac_set_key()
510 for (i = 0; i < sizeof(ctx->__vmac_ctx.polykey)/8; i += 2) { in vmac_set_key()
511 crypto_cipher_encrypt_one(ctx->child, in vmac_set_key()
513 ctx->__vmac_ctx.polytmp[i] = in vmac_set_key()
514 ctx->__vmac_ctx.polykey[i] = in vmac_set_key()
516 ctx->__vmac_ctx.polytmp[i+1] = in vmac_set_key()
517 ctx->__vmac_ctx.polykey[i+1] = in vmac_set_key()
525 for (i = 0; i < sizeof(ctx->__vmac_ctx.l3key)/8; i += 2) { in vmac_set_key()
527 crypto_cipher_encrypt_one(ctx->child, in vmac_set_key()
529 ctx->__vmac_ctx.l3key[i] = be64_to_cpup(out); in vmac_set_key()
530 ctx->__vmac_ctx.l3key[i+1] = be64_to_cpup(out+1); in vmac_set_key()
532 } while (ctx->__vmac_ctx.l3key[i] >= p64 in vmac_set_key()
533 || ctx->__vmac_ctx.l3key[i+1] >= p64); in vmac_set_key()
537 ctx->__vmac_ctx.cached_nonce[0] = (u64)-1; /* Ensure illegal nonce */ in vmac_set_key()
538 ctx->__vmac_ctx.cached_nonce[1] = (u64)0; /* Ensure illegal nonce */ in vmac_set_key()
539 ctx->__vmac_ctx.first_block_processed = 0; in vmac_set_key()
547 struct vmac_ctx_t *ctx = crypto_shash_ctx(parent); in vmac_setkey() local
554 return vmac_set_key((u8 *)key, ctx); in vmac_setkey()
566 struct vmac_ctx_t *ctx = crypto_shash_ctx(parent); in vmac_update() local
570 expand = VMAC_NHBYTES - ctx->partial_size > 0 ? in vmac_update()
571 VMAC_NHBYTES - ctx->partial_size : 0; in vmac_update()
575 memcpy(ctx->partial + ctx->partial_size, p, min); in vmac_update()
576 ctx->partial_size += min; in vmac_update()
581 vhash_update(ctx->partial, VMAC_NHBYTES, &ctx->__vmac_ctx); in vmac_update()
582 ctx->partial_size = 0; in vmac_update()
588 memcpy(ctx->partial, p + len - (len % VMAC_NHBYTES), in vmac_update()
590 ctx->partial_size = len % VMAC_NHBYTES; in vmac_update()
593 vhash_update(p, len - len % VMAC_NHBYTES, &ctx->__vmac_ctx); in vmac_update()
601 struct vmac_ctx_t *ctx = crypto_shash_ctx(parent); in vmac_final() local
610 if (ctx->partial_size) { in vmac_final()
611 memset(ctx->partial + ctx->partial_size, 0, in vmac_final()
612 VMAC_NHBYTES - ctx->partial_size); in vmac_final()
614 mac = vmac(ctx->partial, ctx->partial_size, nonce, NULL, ctx); in vmac_final()
617 memset(&ctx->__vmac_ctx, 0, sizeof(struct vmac_ctx)); in vmac_final()
618 ctx->partial_size = 0; in vmac_final()
627 struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm); in vmac_init_tfm() local
633 ctx->child = cipher; in vmac_init_tfm()
639 struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm); in vmac_exit_tfm() local
640 crypto_free_cipher(ctx->child); in vmac_exit_tfm()