| 1110 | } |
| 1111 | |
| 1112 | static int |
| 1113 | test_mod_exp(void) |
| 1114 | { |
| 1115 | struct crypto_testsuite_params_asym *ts_params = &testsuite_params; |
| 1116 | struct rte_mempool *op_mpool = ts_params->op_mpool; |
| 1117 | struct rte_mempool *sess_mpool = ts_params->session_mpool; |
| 1118 | uint8_t dev_id = ts_params->valid_devs[0]; |
| 1119 | struct rte_crypto_asym_op *asym_op = NULL; |
| 1120 | struct rte_crypto_op *op = NULL, *result_op = NULL; |
| 1121 | void *sess = NULL; |
| 1122 | int status = TEST_SUCCESS; |
| 1123 | struct rte_cryptodev_asym_capability_idx cap_idx; |
| 1124 | const struct rte_cryptodev_asymmetric_xform_capability *capability; |
| 1125 | uint8_t input[TEST_DATA_SIZE] = {0}; |
| 1126 | int ret = 0; |
| 1127 | uint8_t result[sizeof(mod_p)] = { 0 }; |
| 1128 | |
| 1129 | if (rte_cryptodev_asym_get_xform_enum(&modex_xform.xform_type, |
| 1130 | "modexp") |
| 1131 | < 0) { |
| 1132 | RTE_LOG(ERR, USER1, |
| 1133 | "Invalid ASYM algorithm specified\n"); |
| 1134 | return -1; |
| 1135 | } |
| 1136 | |
| 1137 | /* check for modlen capability */ |
| 1138 | cap_idx.type = modex_xform.xform_type; |
| 1139 | capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx); |
| 1140 | |
| 1141 | if (capability == NULL) { |
| 1142 | RTE_LOG(INFO, USER1, |
| 1143 | "Device doesn't support MOD EXP. Test Skipped\n"); |
| 1144 | return TEST_SKIPPED; |
| 1145 | } |
| 1146 | |
| 1147 | if (rte_cryptodev_asym_xform_capability_check_modlen( |
| 1148 | capability, modex_xform.modex.modulus.length)) { |
| 1149 | RTE_LOG(ERR, USER1, |
| 1150 | "Invalid MODULUS length specified\n"); |
| 1151 | return TEST_SKIPPED; |
| 1152 | } |
| 1153 | |
| 1154 | /* Create op, create session, and process packets. 8< */ |
| 1155 | op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC); |
| 1156 | if (!op) { |
| 1157 | RTE_LOG(ERR, USER1, |
| 1158 | "line %u FAILED: %s", |
| 1159 | __LINE__, "Failed to allocate asymmetric crypto " |
| 1160 | "operation struct"); |
| 1161 | status = TEST_FAILED; |
| 1162 | goto error_exit; |
| 1163 | } |
| 1164 | |
| 1165 | ret = rte_cryptodev_asym_session_create(dev_id, &modex_xform, sess_mpool, &sess); |
| 1166 | if (ret < 0) { |
| 1167 | RTE_LOG(ERR, USER1, |
| 1168 | "line %u " |
| 1169 | "FAILED: %s", __LINE__, |
nothing calls this directly
no test coverage detected