Lines Matching refs:tctx

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