@@ -542,6 +542,13 @@ testsuite_setup(void)
542542 "Failed to configure cryptodev %u with %u qps" ,
543543 dev_id , ts_params -> conf .nb_queue_pairs );
544544
545+ ts_params -> session_mpool = rte_cryptodev_asym_session_pool_create (
546+ "test_asym_sess_mp" , TEST_NUM_SESSIONS , 0 , 0 ,
547+ SOCKET_ID_ANY );
548+
549+ TEST_ASSERT_NOT_NULL (ts_params -> session_mpool ,
550+ "session mempool allocation failed" );
551+
545552 /* configure qp */
546553 ts_params -> qp_conf .nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT ;
547554 ts_params -> qp_conf .mp_session = ts_params -> session_mpool ;
@@ -553,12 +560,6 @@ testsuite_setup(void)
553560 qp_id , dev_id );
554561 }
555562
556- ts_params -> session_mpool = rte_cryptodev_asym_session_pool_create (
557- "test_asym_sess_mp" , TEST_NUM_SESSIONS , 0 , 0 ,
558- SOCKET_ID_ANY );
559-
560- TEST_ASSERT_NOT_NULL (ts_params -> session_mpool ,
561- "session mempool allocation failed" );
562563 /* >8 End of device, op pool and session configuration for asymmetric crypto section. */
563564 return TEST_SUCCESS ;
564565}
@@ -1165,6 +1166,98 @@ test_mod_inv(void)
11651166 return status ;
11661167}
11671168
1169+ static int
1170+ test_mod_exp_sessionless (void )
1171+ {
1172+ struct crypto_testsuite_params_asym * ts_params = & testsuite_params ;
1173+ const struct rte_cryptodev_asymmetric_xform_capability * capability ;
1174+ struct rte_mempool * op_mpool = ts_params -> op_mpool ;
1175+ struct rte_crypto_op * op = NULL , * result_op = NULL ;
1176+ struct rte_cryptodev_asym_capability_idx cap_idx ;
1177+ uint8_t dev_id = ts_params -> valid_devs [0 ];
1178+ struct rte_crypto_asym_op * asym_op = NULL ;
1179+ uint8_t result [sizeof (mod_p )] = { 0 };
1180+ uint8_t input [TEST_DATA_SIZE ] = {0 };
1181+ struct rte_cryptodev_info info ;
1182+ int status = TEST_SUCCESS ;
1183+ int ret = 0 ;
1184+
1185+ rte_cryptodev_info_get (dev_id , & info );
1186+ if (!(info .feature_flags & RTE_CRYPTODEV_FF_ASYM_SESSIONLESS ))
1187+ return TEST_SKIPPED ;
1188+
1189+ if (rte_cryptodev_asym_get_xform_enum (& modex_xform .xform_type , "modexp" ) < 0 ) {
1190+ RTE_LOG (ERR , USER1 , "Invalid ASYM algorithm specified\n" );
1191+ return -1 ;
1192+ }
1193+
1194+ /* check for modlen capability */
1195+ cap_idx .type = modex_xform .xform_type ;
1196+ capability = rte_cryptodev_asym_capability_get (dev_id , & cap_idx );
1197+
1198+ if (capability == NULL ) {
1199+ RTE_LOG (INFO , USER1 , "Device doesn't support MOD EXP. Test Skipped\n" );
1200+ return TEST_SKIPPED ;
1201+ }
1202+
1203+ if (rte_cryptodev_asym_xform_capability_check_modlen (capability ,
1204+ modex_xform .modex .modulus .length )) {
1205+ RTE_LOG (ERR , USER1 , "Unsupported MODULUS length specified\n" );
1206+ return TEST_SKIPPED ;
1207+ }
1208+
1209+ /* Create op and process packets. */
1210+ op = rte_crypto_op_alloc (op_mpool , RTE_CRYPTO_OP_TYPE_ASYMMETRIC );
1211+ if (!op ) {
1212+ RTE_LOG (ERR , USER1 , "line %u FAILED: %s" , __LINE__ ,
1213+ "Failed to allocate asymmetric crypto operation struct" );
1214+ return TEST_FAILED ;
1215+ }
1216+
1217+ asym_op = op -> asym ;
1218+ memcpy (input , base , sizeof (base ));
1219+ asym_op -> modex .base .data = input ;
1220+ asym_op -> modex .base .length = sizeof (base );
1221+ asym_op -> modex .result .data = result ;
1222+ asym_op -> modex .result .length = sizeof (result );
1223+ asym_op -> xform = & modex_xform ;
1224+ op -> sess_type = RTE_CRYPTO_OP_SESSIONLESS ;
1225+
1226+ RTE_LOG (DEBUG , USER1 , "Process ASYM operation" );
1227+ /* Process crypto operation */
1228+ if (rte_cryptodev_enqueue_burst (dev_id , 0 , & op , 1 ) != 1 ) {
1229+ RTE_LOG (ERR , USER1 ,
1230+ "line %u FAILED: %s" ,
1231+ __LINE__ , "Error sending packet for operation" );
1232+ status = TEST_FAILED ;
1233+ goto error_exit ;
1234+ }
1235+
1236+ while (rte_cryptodev_dequeue_burst (dev_id , 0 , & result_op , 1 ) == 0 )
1237+ rte_pause ();
1238+
1239+ if (result_op == NULL ) {
1240+ RTE_LOG (ERR , USER1 ,
1241+ "line %u FAILED: %s" ,
1242+ __LINE__ , "Failed to process asym crypto op" );
1243+ status = TEST_FAILED ;
1244+ goto error_exit ;
1245+ }
1246+
1247+ ret = verify_modexp (mod_exp , result_op );
1248+ if (ret ) {
1249+ RTE_LOG (ERR , USER1 , "operation verification failed\n" );
1250+ status = TEST_FAILED ;
1251+ }
1252+
1253+ error_exit :
1254+ rte_crypto_op_free (op );
1255+
1256+ TEST_ASSERT_EQUAL (status , 0 , "Test failed" );
1257+
1258+ return status ;
1259+ }
1260+
11681261static int
11691262test_mod_exp (void )
11701263{
@@ -5184,6 +5277,7 @@ static struct unit_test_suite cryptodev_octeontx_asym_testsuite = {
51845277 TEST_CASE_ST (ut_setup_asym , ut_teardown_asym ,
51855278 test_ecpm_all_curve ),
51865279 TEST_CASE_ST (ut_setup_asym , ut_teardown_asym , test_eddsa_sign_verify_all_curve ),
5280+ TEST_CASE_ST (ut_setup_asym , ut_teardown_asym , test_mod_exp_sessionless ),
51875281 TEST_CASE_ST (ut_setup_asym , ut_teardown_asym , test_mlkem_keygen ),
51885282 TEST_CASE_ST (ut_setup_asym , ut_teardown_asym , test_mlkem_encap ),
51895283 TEST_CASE_ST (ut_setup_asym , ut_teardown_asym , test_mlkem_decap ),
0 commit comments