| 1103 | } |
| 1104 | |
| 1105 | static int |
| 1106 | ccp_configure_session_aead(struct ccp_session *sess, |
| 1107 | const struct rte_crypto_sym_xform *xform) |
| 1108 | { |
| 1109 | const struct rte_crypto_aead_xform *aead_xform = NULL; |
| 1110 | size_t i; |
| 1111 | |
| 1112 | aead_xform = &xform->aead; |
| 1113 | |
| 1114 | sess->cipher.key_length = aead_xform->key.length; |
| 1115 | rte_memcpy(sess->cipher.key, aead_xform->key.data, |
| 1116 | aead_xform->key.length); |
| 1117 | |
| 1118 | if (aead_xform->op == RTE_CRYPTO_AEAD_OP_ENCRYPT) { |
| 1119 | sess->cipher.dir = CCP_CIPHER_DIR_ENCRYPT; |
| 1120 | sess->auth.op = CCP_AUTH_OP_GENERATE; |
| 1121 | } else { |
| 1122 | sess->cipher.dir = CCP_CIPHER_DIR_DECRYPT; |
| 1123 | sess->auth.op = CCP_AUTH_OP_VERIFY; |
| 1124 | } |
| 1125 | sess->aead_algo = aead_xform->algo; |
| 1126 | sess->auth.aad_length = aead_xform->aad_length; |
| 1127 | sess->auth.digest_length = aead_xform->digest_length; |
| 1128 | |
| 1129 | /* set iv parameters */ |
| 1130 | sess->iv.offset = aead_xform->iv.offset; |
| 1131 | sess->iv.length = aead_xform->iv.length; |
| 1132 | |
| 1133 | switch (aead_xform->algo) { |
| 1134 | case RTE_CRYPTO_AEAD_AES_GCM: |
| 1135 | sess->cipher.algo = CCP_CIPHER_ALGO_AES_GCM; |
| 1136 | sess->cipher.um.aes_mode = CCP_AES_MODE_GCTR; |
| 1137 | sess->cipher.engine = CCP_ENGINE_AES; |
| 1138 | if (sess->cipher.key_length == 16) |
| 1139 | sess->cipher.ut.aes_type = CCP_AES_TYPE_128; |
| 1140 | else if (sess->cipher.key_length == 24) |
| 1141 | sess->cipher.ut.aes_type = CCP_AES_TYPE_192; |
| 1142 | else if (sess->cipher.key_length == 32) |
| 1143 | sess->cipher.ut.aes_type = CCP_AES_TYPE_256; |
| 1144 | else { |
| 1145 | CCP_LOG_ERR("Invalid aead key length"); |
| 1146 | return -1; |
| 1147 | } |
| 1148 | for (i = 0; i < sess->cipher.key_length; i++) |
| 1149 | sess->cipher.key_ccp[sess->cipher.key_length - i - 1] = |
| 1150 | sess->cipher.key[i]; |
| 1151 | sess->auth.algo = CCP_AUTH_ALGO_AES_GCM; |
| 1152 | sess->auth.engine = CCP_ENGINE_AES; |
| 1153 | sess->auth.um.aes_mode = CCP_AES_MODE_GHASH; |
| 1154 | sess->auth.ctx_len = CCP_SB_BYTES; |
| 1155 | sess->auth.offset = 0; |
| 1156 | sess->auth.block_size = AES_BLOCK_SIZE; |
| 1157 | sess->cmd_id = CCP_CMD_COMBINED; |
| 1158 | break; |
| 1159 | default: |
| 1160 | CCP_LOG_ERR("Unsupported aead algo"); |
| 1161 | return -ENOTSUP; |
| 1162 | } |
no test coverage detected