MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ccp_configure_session_cipher

Function ccp_configure_session_cipher

dpdk/drivers/crypto/ccp/ccp_crypto.c:663–751  ·  view source on GitHub ↗

configure session */

Source from the content-addressed store, hash-verified

661
662/* configure session */
663static int
664ccp_configure_session_cipher(struct ccp_session *sess,
665 const struct rte_crypto_sym_xform *xform)
666{
667 const struct rte_crypto_cipher_xform *cipher_xform = NULL;
668 size_t i, j, x;
669
670 cipher_xform = &xform->cipher;
671
672 /* set cipher direction */
673 if (cipher_xform->op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
674 sess->cipher.dir = CCP_CIPHER_DIR_ENCRYPT;
675 else
676 sess->cipher.dir = CCP_CIPHER_DIR_DECRYPT;
677
678 /* set cipher key */
679 sess->cipher.key_length = cipher_xform->key.length;
680 rte_memcpy(sess->cipher.key, cipher_xform->key.data,
681 cipher_xform->key.length);
682
683 /* set iv parameters */
684 sess->iv.offset = cipher_xform->iv.offset;
685 sess->iv.length = cipher_xform->iv.length;
686
687 switch (cipher_xform->algo) {
688 case RTE_CRYPTO_CIPHER_AES_CTR:
689 sess->cipher.algo = CCP_CIPHER_ALGO_AES_CTR;
690 sess->cipher.um.aes_mode = CCP_AES_MODE_CTR;
691 sess->cipher.engine = CCP_ENGINE_AES;
692 break;
693 case RTE_CRYPTO_CIPHER_AES_ECB:
694 sess->cipher.algo = CCP_CIPHER_ALGO_AES_CBC;
695 sess->cipher.um.aes_mode = CCP_AES_MODE_ECB;
696 sess->cipher.engine = CCP_ENGINE_AES;
697 break;
698 case RTE_CRYPTO_CIPHER_AES_CBC:
699 sess->cipher.algo = CCP_CIPHER_ALGO_AES_CBC;
700 sess->cipher.um.aes_mode = CCP_AES_MODE_CBC;
701 sess->cipher.engine = CCP_ENGINE_AES;
702 break;
703 case RTE_CRYPTO_CIPHER_3DES_CBC:
704 sess->cipher.algo = CCP_CIPHER_ALGO_3DES_CBC;
705 sess->cipher.um.des_mode = CCP_DES_MODE_CBC;
706 sess->cipher.engine = CCP_ENGINE_3DES;
707 break;
708 default:
709 CCP_LOG_ERR("Unsupported cipher algo");
710 return -1;
711 }
712
713
714 switch (sess->cipher.engine) {
715 case CCP_ENGINE_AES:
716 if (sess->cipher.key_length == 16)
717 sess->cipher.ut.aes_type = CCP_AES_TYPE_128;
718 else if (sess->cipher.key_length == 24)
719 sess->cipher.ut.aes_type = CCP_AES_TYPE_192;
720 else if (sess->cipher.key_length == 32)

Callers 1

Calls 2

rte_memcpyFunction · 0.50
rte_mem_virt2iovaFunction · 0.50

Tested by

no test coverage detected