Lines Matching defs:tctx

83 static inline u8 *hctr2_hashed_tweaklen(const struct hctr2_tfm_ctx *tctx,
86 u8 *p = (u8 *)tctx + sizeof(*tctx);
89 p += crypto_shash_statesize(tctx->polyval);
93 static inline u8 *hctr2_hashed_tweak(const struct hctr2_tfm_ctx *tctx,
96 return (u8 *)rctx + tctx->hashed_tweak_offset;
109 static int hctr2_hash_tweaklen(struct hctr2_tfm_ctx *tctx, bool has_remainder)
115 shash->tfm = tctx->polyval;
126 return crypto_shash_export(shash, hctr2_hashed_tweaklen(tctx, has_remainder));
132 struct hctr2_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
136 crypto_cipher_clear_flags(tctx->blockcipher, CRYPTO_TFM_REQ_MASK);
137 crypto_cipher_set_flags(tctx->blockcipher,
140 err = crypto_cipher_setkey(tctx->blockcipher, key, keylen);
144 crypto_skcipher_clear_flags(tctx->xctr, CRYPTO_TFM_REQ_MASK);
145 crypto_skcipher_set_flags(tctx->xctr,
148 err = crypto_skcipher_setkey(tctx->xctr, key, keylen);
153 crypto_cipher_encrypt_one(tctx->blockcipher, hbar, hbar);
155 memset(tctx->L, 0, sizeof(tctx->L));
156 tctx->L[0] = 0x01;
157 crypto_cipher_encrypt_one(tctx->blockcipher, tctx->L, tctx->L);
159 crypto_shash_clear_flags(tctx->polyval, CRYPTO_TFM_REQ_MASK);
160 crypto_shash_set_flags(tctx->polyval, crypto_skcipher_get_flags(tfm) &
162 err = crypto_shash_setkey(tctx->polyval, hbar, BLOCKCIPHER_BLOCK_SIZE);
167 return hctr2_hash_tweaklen(tctx, true) ?: hctr2_hash_tweaklen(tctx, false);
173 const struct hctr2_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
179 hash_desc->tfm = tctx->polyval;
180 err = crypto_shash_import(hash_desc, hctr2_hashed_tweaklen(tctx, has_remainder));
189 return crypto_shash_export(hash_desc, hctr2_hashed_tweak(tctx, rctx));
232 const struct hctr2_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
240 hash_desc->tfm = tctx->polyval;
241 err = crypto_shash_import(hash_desc, hctr2_hashed_tweak(tctx, rctx));
268 const struct hctr2_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
301 crypto_cipher_encrypt_one(tctx->blockcipher, rctx->first_block,
304 crypto_cipher_decrypt_one(tctx->blockcipher, rctx->first_block,
309 crypto_xor_cpy(rctx->xctr_iv, digest, tctx->L, BLOCKCIPHER_BLOCK_SIZE);
313 skcipher_request_set_tfm(&rctx->u.xctr_req, tctx->xctr);
338 struct hctr2_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
361 tctx->xctr = xctr;
362 tctx->blockcipher = blockcipher;
363 tctx->polyval = polyval;
372 tctx->hashed_tweak_offset = offsetof(struct hctr2_request_ctx, u) +
374 crypto_skcipher_set_reqsize(tfm, tctx->hashed_tweak_offset +
387 struct hctr2_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
389 crypto_free_cipher(tctx->blockcipher);
390 crypto_free_skcipher(tctx->xctr);
391 crypto_free_shash(tctx->polyval);