Lines Matching refs:c_ctx

644 	struct sec_cipher_ctx *c_ctx = &ctx->c_ctx;  in sec_cipher_init()  local
646 c_ctx->c_key = dma_alloc_coherent(ctx->dev, SEC_MAX_KEY_SIZE, in sec_cipher_init()
647 &c_ctx->c_key_dma, GFP_KERNEL); in sec_cipher_init()
648 if (!c_ctx->c_key) in sec_cipher_init()
656 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; in sec_cipher_uninit() local
658 memzero_explicit(c_ctx->c_key, SEC_MAX_KEY_SIZE); in sec_cipher_uninit()
660 c_ctx->c_key, c_ctx->c_key_dma); in sec_cipher_uninit()
688 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; in sec_skcipher_fbtfm_init() local
690 c_ctx->fallback = false; in sec_skcipher_fbtfm_init()
696 c_ctx->fbtfm = crypto_alloc_sync_skcipher(alg, 0, in sec_skcipher_fbtfm_init()
698 if (IS_ERR(c_ctx->fbtfm)) { in sec_skcipher_fbtfm_init()
700 return PTR_ERR(c_ctx->fbtfm); in sec_skcipher_fbtfm_init()
713 ctx->c_ctx.ivsize = crypto_skcipher_ivsize(tfm); in sec_skcipher_init()
714 if (ctx->c_ctx.ivsize > SEC_IV_SIZE) { in sec_skcipher_init()
744 if (ctx->c_ctx.fbtfm) in sec_skcipher_uninit()
745 crypto_free_sync_skcipher(ctx->c_ctx.fbtfm); in sec_skcipher_uninit()
756 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; in sec_skcipher_3des_setkey() local
765 c_ctx->c_key_len = SEC_CKEY_3DES_2KEY; in sec_skcipher_3des_setkey()
768 c_ctx->c_key_len = SEC_CKEY_3DES_3KEY; in sec_skcipher_3des_setkey()
777 static int sec_skcipher_aes_sm4_setkey(struct sec_cipher_ctx *c_ctx, in sec_skcipher_aes_sm4_setkey() argument
784 c_ctx->c_key_len = SEC_CKEY_128BIT; in sec_skcipher_aes_sm4_setkey()
787 c_ctx->fallback = true; in sec_skcipher_aes_sm4_setkey()
790 c_ctx->c_key_len = SEC_CKEY_256BIT; in sec_skcipher_aes_sm4_setkey()
797 if (c_ctx->c_alg == SEC_CALG_SM4 && in sec_skcipher_aes_sm4_setkey()
804 c_ctx->c_key_len = SEC_CKEY_128BIT; in sec_skcipher_aes_sm4_setkey()
807 c_ctx->c_key_len = SEC_CKEY_192BIT; in sec_skcipher_aes_sm4_setkey()
810 c_ctx->c_key_len = SEC_CKEY_256BIT; in sec_skcipher_aes_sm4_setkey()
827 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; in sec_skcipher_setkey() local
839 c_ctx->c_alg = c_alg; in sec_skcipher_setkey()
840 c_ctx->c_mode = c_mode; in sec_skcipher_setkey()
848 ret = sec_skcipher_aes_sm4_setkey(c_ctx, keylen, c_mode); in sec_skcipher_setkey()
859 memcpy(c_ctx->c_key, key, keylen); in sec_skcipher_setkey()
860 if (c_ctx->fallback && c_ctx->fbtfm) { in sec_skcipher_setkey()
861 ret = crypto_sync_skcipher_setkey(c_ctx->fbtfm, key, keylen); in sec_skcipher_setkey()
1068 static int sec_aead_aes_set_key(struct sec_cipher_ctx *c_ctx, in sec_aead_aes_set_key() argument
1073 c_ctx->c_key_len = SEC_CKEY_128BIT; in sec_aead_aes_set_key()
1076 c_ctx->c_key_len = SEC_CKEY_192BIT; in sec_aead_aes_set_key()
1079 c_ctx->c_key_len = SEC_CKEY_256BIT; in sec_aead_aes_set_key()
1085 memcpy(c_ctx->c_key, keys->enckey, keys->enckeylen); in sec_aead_aes_set_key()
1148 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; in sec_aead_setkey() local
1155 ctx->c_ctx.c_alg = c_alg; in sec_aead_setkey()
1157 c_ctx->c_mode = c_mode; in sec_aead_setkey()
1160 ret = sec_skcipher_aes_sm4_setkey(c_ctx, keylen, c_mode); in sec_aead_setkey()
1165 memcpy(c_ctx->c_key, key, keylen); in sec_aead_setkey()
1179 ret = sec_aead_aes_set_key(c_ctx, &keys); in sec_aead_setkey()
1272 memcpy(c_req->c_ivin, sk_req->iv, ctx->c_ctx.ivsize); in sec_skcipher_copy_iv()
1277 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; in sec_skcipher_bd_fill() local
1286 sec_sqe->type2.c_key_addr = cpu_to_le64(c_ctx->c_key_dma); in sec_skcipher_bd_fill()
1291 sec_sqe->type2.icvw_kmode |= cpu_to_le16(((u16)c_ctx->c_mode) << in sec_skcipher_bd_fill()
1293 sec_sqe->type2.c_alg = c_ctx->c_alg; in sec_skcipher_bd_fill()
1294 sec_sqe->type2.icvw_kmode |= cpu_to_le16(((u16)c_ctx->c_key_len) << in sec_skcipher_bd_fill()
1329 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; in sec_skcipher_bd_fill_v3() local
1336 sec_sqe3->c_key_addr = cpu_to_le64(c_ctx->c_key_dma); in sec_skcipher_bd_fill_v3()
1341 sec_sqe3->c_mode_alg = ((u8)c_ctx->c_alg << SEC_CALG_OFFSET_V3) | in sec_skcipher_bd_fill_v3()
1342 c_ctx->c_mode; in sec_skcipher_bd_fill_v3()
1343 sec_sqe3->c_icv_key |= cpu_to_le16(((u16)c_ctx->c_key_len) << in sec_skcipher_bd_fill_v3()
1392 u32 iv_size = req->ctx->c_ctx.ivsize; in sec_update_iv()
1411 if (req->ctx->c_ctx.c_mode == SEC_CMODE_CBC) { in sec_update_iv()
1453 if (!err && (ctx->c_ctx.c_mode == SEC_CMODE_CBC || in sec_skcipher_callback()
1454 ctx->c_ctx.c_mode == SEC_CMODE_CTR) && req->c_req.encrypt) in sec_skcipher_callback()
1483 c_req->c_ivin[ctx->c_ctx.ivsize - cl] = 0x00; in set_aead_auth_iv()
1484 memset(&c_req->c_ivin[ctx->c_ctx.ivsize - cl], 0, cl); in set_aead_auth_iv()
1485 c_req->c_ivin[ctx->c_ctx.ivsize - IV_LAST_BYTE1] = IV_CTR_INIT; in set_aead_auth_iv()
1496 memcpy(a_req->a_ivin, c_req->c_ivin, ctx->c_ctx.ivsize); in set_aead_auth_iv()
1507 a_req->a_ivin[ctx->c_ctx.ivsize - IV_LAST_BYTE1] = in set_aead_auth_iv()
1510 a_req->a_ivin[ctx->c_ctx.ivsize - IV_LAST_BYTE2] = in set_aead_auth_iv()
1522 memcpy(c_req->c_ivin, aead_req->iv, ctx->c_ctx.ivsize); in sec_aead_set_iv()
1524 if (ctx->c_ctx.c_mode == SEC_CMODE_CCM) { in sec_aead_set_iv()
1535 if (ctx->c_ctx.c_mode == SEC_CMODE_GCM) { in sec_aead_set_iv()
1637 if (ctx->c_ctx.c_mode == SEC_CMODE_CCM || in sec_aead_bd_fill()
1638 ctx->c_ctx.c_mode == SEC_CMODE_GCM) in sec_aead_bd_fill()
1692 if (ctx->c_ctx.c_mode == SEC_CMODE_CCM || in sec_aead_bd_fill_v3()
1693 ctx->c_ctx.c_mode == SEC_CMODE_GCM) in sec_aead_bd_fill_v3()
1715 if (!err && c->c_ctx.c_mode == SEC_CMODE_CBC && c_req->encrypt) in sec_aead_callback()
1786 if (!req->c_req.encrypt && (ctx->c_ctx.c_mode == SEC_CMODE_CBC || in sec_process()
1787 ctx->c_ctx.c_mode == SEC_CMODE_CTR)) in sec_process()
1801 if (ctx->c_ctx.c_mode == SEC_CMODE_CBC && !req->c_req.encrypt) { in sec_process()
1804 ctx->c_ctx.ivsize); in sec_process()
1807 ctx->c_ctx.ivsize); in sec_process()
1888 ctx->c_ctx.ivsize = crypto_aead_ivsize(tfm); in sec_aead_init()
1889 if (ctx->c_ctx.ivsize < SEC_AIV_SIZE || in sec_aead_init()
1890 ctx->c_ctx.ivsize > SEC_IV_SIZE) { in sec_aead_init()
2017 u8 c_mode = ctx->c_ctx.c_mode; in sec_skcipher_cryptlen_ckeck()
2053 u8 c_alg = ctx->c_ctx.c_alg; in sec_skcipher_param_check()
2085 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; in sec_skcipher_soft_crypto() local
2086 SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, c_ctx->fbtfm); in sec_skcipher_soft_crypto()
2090 if (!c_ctx->fbtfm) { in sec_skcipher_soft_crypto()
2095 skcipher_request_set_sync_tfm(subreq, c_ctx->fbtfm); in sec_skcipher_soft_crypto()
2120 if (ctx->c_ctx.c_mode == SEC_CMODE_XTS) in sec_skcipher_crypto()
2134 if (unlikely(ctx->c_ctx.fallback)) in sec_skcipher_crypto()
2266 u8 c_mode = ctx->c_ctx.c_mode; in sec_aead_spec_check()
2315 u8 c_alg = ctx->c_ctx.c_alg; in sec_aead_param_check()