| 998 | } |
| 999 | |
| 1000 | static int |
| 1001 | test_mod_inv(void) |
| 1002 | { |
| 1003 | struct crypto_testsuite_params_asym *ts_params = &testsuite_params; |
| 1004 | struct rte_mempool *op_mpool = ts_params->op_mpool; |
| 1005 | struct rte_mempool *sess_mpool = ts_params->session_mpool; |
| 1006 | uint8_t dev_id = ts_params->valid_devs[0]; |
| 1007 | struct rte_crypto_asym_op *asym_op = NULL; |
| 1008 | struct rte_crypto_op *op = NULL, *result_op = NULL; |
| 1009 | void *sess = NULL; |
| 1010 | int status = TEST_SUCCESS; |
| 1011 | struct rte_cryptodev_asym_capability_idx cap_idx; |
| 1012 | const struct rte_cryptodev_asymmetric_xform_capability *capability; |
| 1013 | uint8_t input[TEST_DATA_SIZE] = {0}; |
| 1014 | int ret = 0; |
| 1015 | uint8_t result[sizeof(mod_p)] = { 0 }; |
| 1016 | |
| 1017 | if (rte_cryptodev_asym_get_xform_enum( |
| 1018 | &modinv_xform.xform_type, "modinv") < 0) { |
| 1019 | RTE_LOG(ERR, USER1, |
| 1020 | "Invalid ASYM algorithm specified\n"); |
| 1021 | return -1; |
| 1022 | } |
| 1023 | |
| 1024 | cap_idx.type = modinv_xform.xform_type; |
| 1025 | capability = rte_cryptodev_asym_capability_get(dev_id, |
| 1026 | &cap_idx); |
| 1027 | |
| 1028 | if (capability == NULL) { |
| 1029 | RTE_LOG(INFO, USER1, |
| 1030 | "Device doesn't support MOD INV. Test Skipped\n"); |
| 1031 | return TEST_SKIPPED; |
| 1032 | } |
| 1033 | |
| 1034 | if (rte_cryptodev_asym_xform_capability_check_modlen( |
| 1035 | capability, |
| 1036 | modinv_xform.modinv.modulus.length)) { |
| 1037 | RTE_LOG(ERR, USER1, |
| 1038 | "Invalid MODULUS length specified\n"); |
| 1039 | return TEST_SKIPPED; |
| 1040 | } |
| 1041 | |
| 1042 | ret = rte_cryptodev_asym_session_create(dev_id, &modinv_xform, sess_mpool, &sess); |
| 1043 | if (ret < 0) { |
| 1044 | RTE_LOG(ERR, USER1, "line %u " |
| 1045 | "FAILED: %s", __LINE__, |
| 1046 | "Session creation failed"); |
| 1047 | status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED; |
| 1048 | goto error_exit; |
| 1049 | } |
| 1050 | |
| 1051 | /* generate crypto op data structure */ |
| 1052 | op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC); |
| 1053 | if (!op) { |
| 1054 | RTE_LOG(ERR, USER1, |
| 1055 | "line %u FAILED: %s", |
| 1056 | __LINE__, "Failed to allocate asymmetric crypto " |
| 1057 | "operation struct"); |
nothing calls this directly
no test coverage detected