diff --git a/test/validation/api/crypto/crypto_op_test.c b/test/validation/api/crypto/crypto_op_test.c index 0d7482fa27..9e8ab05843 100644 --- a/test/validation/api/crypto/crypto_op_test.c +++ b/test/validation/api/crypto/crypto_op_test.c @@ -46,6 +46,7 @@ int crypto_op(odp_packet_t pkt_in, odp_packet_t *pkt_out, odp_bool_t *ok, const odp_crypto_packet_op_param_t *op_params, + odp_crypto_op_type_t session_op_type, odp_crypto_op_type_t op_type) { int rc; @@ -69,7 +70,7 @@ int crypto_op(odp_packet_t pkt_in, } else { odp_packet_t *out_param = pkt_out; - if (op_type == ODP_CRYPTO_OP_TYPE_BASIC) + if (session_op_type == ODP_CRYPTO_OP_TYPE_BASIC) out_param = NULL; rc = odp_crypto_op_enq(&pkt_in, out_param, op_params, 1); @@ -337,7 +338,7 @@ static void prepare_ignore_info(const crypto_op_test_param_t *param, param->session.op == ODP_CRYPTO_OP_DECODE) { uint32_t offs = param->digest_offset; - if (param->session.op_type != ODP_CRYPTO_OP_TYPE_OOP || + if (param->op_type != ODP_CRYPTO_OP_TYPE_OOP || is_in_range(offs, cipher_offset, cipher_len) || is_in_range(offs, auth_offset, auth_len)) { add_ignored_range(ignore, @@ -351,7 +352,7 @@ static void prepare_ignore_info(const crypto_op_test_param_t *param, param->wrong_digest) { add_ignored_range(ignore, cipher_offset + shift, cipher_len); /* In OOP case, auth range may not get copied */ - if (param->session.op_type == ODP_CRYPTO_OP_TYPE_OOP) + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) add_ignored_range(ignore, auth_offset + shift, auth_len); } } @@ -368,9 +369,9 @@ static void prepare_expected_data(const crypto_op_test_param_t *param, uint32_t cipher_len = cipher_range->length; uint32_t auth_offset = auth_range->offset; uint32_t auth_len = auth_range->length; - const int32_t shift = param->session.op_type == ODP_CRYPTO_OP_TYPE_OOP ? param->oop_shift + const int32_t shift = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? param->oop_shift : 0; - const odp_packet_t base_pkt = param->session.op_type == ODP_CRYPTO_OP_TYPE_OOP ? pkt_out + const odp_packet_t base_pkt = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? pkt_out : pkt_in; int rc; uint32_t cipher_offset_in_ref = param->cipher_range.offset; @@ -400,7 +401,7 @@ static void prepare_expected_data(const crypto_op_test_param_t *param, rc = odp_packet_copy_to_mem(base_pkt, 0, ex->len, ex->data); CU_ASSERT(rc == 0); - if (param->session.op_type == ODP_CRYPTO_OP_TYPE_OOP && auth_len > 0) { + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP && auth_len > 0) { /* copy auth range from input packet */ rc = odp_packet_copy_to_mem(pkt_in, auth_offset, auth_len, ex->data + auth_offset + shift); @@ -516,7 +517,7 @@ static void do_test_crypto_op(const crypto_op_test_param_t *param) if (prepare_input_packet(param, &pkt)) return; - if (param->session.op_type == ODP_CRYPTO_OP_TYPE_OOP) { + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) { prepare_oop_output_packet(param, &pkt_out, odp_packet_len(pkt)); pkt_copy = odp_packet_copy(pkt, suite_context.pool); @@ -535,7 +536,7 @@ static void do_test_crypto_op(const crypto_op_test_param_t *param) prepare_expected_data(param, &op_params.cipher_range, &op_params.auth_range, pkt, pkt_out, &expected); - if (param->session.op_type == ODP_CRYPTO_OP_TYPE_OOP && + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP && param->session.op == ODP_CRYPTO_OP_ENCODE) { /* * In this type of sessions digest offset is an offset to the output @@ -547,12 +548,13 @@ static void do_test_crypto_op(const crypto_op_test_param_t *param) test_packet_set_md(pkt); test_packet_get_md(pkt, &md_in); - if (crypto_op(pkt, &pkt_out, &ok, &op_params, param->session.op_type)) + if (crypto_op(pkt, &pkt_out, &ok, &op_params, + param->session.op_type, param->op_type)) return; test_packet_get_md(pkt_out, &md_out); - if (param->session.op_type == ODP_CRYPTO_OP_TYPE_OOP) { + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) { test_packet_md_t md; /* check that input packet has not changed */ diff --git a/test/validation/api/crypto/crypto_op_test.h b/test/validation/api/crypto/crypto_op_test.h index a93f10f2fd..9805457ad4 100644 --- a/test/validation/api/crypto/crypto_op_test.h +++ b/test/validation/api/crypto/crypto_op_test.h @@ -23,6 +23,7 @@ typedef struct crypto_session_t { typedef struct crypto_op_test_param_t { crypto_session_t session; + odp_crypto_op_type_t op_type; int32_t oop_shift; crypto_test_reference_t *ref; odp_packet_data_range_t cipher_range; @@ -42,6 +43,7 @@ int crypto_op(odp_packet_t pkt_in, odp_packet_t *pkt_out, odp_bool_t *ok, const odp_crypto_packet_op_param_t *op_params, + odp_crypto_op_type_t session_op_type, odp_crypto_op_type_t op_type); #endif diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index c6fdc20df1..59e734174f 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -69,6 +69,10 @@ static void print_alg_test_param(const crypto_op_test_param_t *p) case ODP_CRYPTO_OP_TYPE_OOP: printf("out-of-place "); break; + case ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP: + printf("basic-and-out-of-place (%s)", + p->op_type == ODP_CRYPTO_OP_TYPE_BASIC ? "basic" : "oop"); + break; default: printf("unknown (internal error) "); break; @@ -94,7 +98,7 @@ static void print_alg_test_param(const crypto_op_test_param_t *p) printf("header length: %d, trailer length: %d\n", p->header_len, p->trailer_len); if (p->adjust_segmentation) printf("segmentation adjusted, first_seg_len: %d\n", p->first_seg_len); - if (p->session.op_type == ODP_CRYPTO_OP_TYPE_OOP) + if (p->op_type == ODP_CRYPTO_OP_TYPE_OOP) printf("oop_shift: %d\n", p->oop_shift); if (p->session.null_crypto_enable) printf("null crypto enabled in session\n"); @@ -121,13 +125,13 @@ static void alg_test_execute_and_print(crypto_op_test_param_t *param) } } -static void alg_test_op(crypto_op_test_param_t *param) +static void alg_test_op2(crypto_op_test_param_t *param) { int32_t oop_shifts[] = {0, 3, 130, -10}; for (uint32_t n = 0; n < ARRAY_SIZE(oop_shifts); n++) { if (oop_shifts[n] != 0 && - param->session.op_type != ODP_CRYPTO_OP_TYPE_OOP) + param->op_type != ODP_CRYPTO_OP_TYPE_OOP) continue; if ((int32_t)param->header_len + oop_shifts[n] < 0) continue; @@ -145,12 +149,25 @@ static void alg_test_op(crypto_op_test_param_t *param) if (!full_test && param->session.null_crypto_enable) break; + if (!full_test && param->session.op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP) + break; param->wrong_digest = true; alg_test_execute_and_print(param); } } +static void alg_test_op(crypto_op_test_param_t *param) +{ + param->op_type = param->session.op_type; + if (param->op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP) { + param->op_type = ODP_CRYPTO_OP_TYPE_BASIC; + alg_test_op2(param); + param->op_type = ODP_CRYPTO_OP_TYPE_OOP; + } + alg_test_op2(param); +} + static int combo_warning_shown; static int oop_warning_shown; @@ -244,9 +261,10 @@ static int session_create(crypto_session_t *session, /* For now, allow out-of-place sessions not to be supported. */ if (rc < 0 && status == ODP_CRYPTO_SES_ERR_PARAMS && - ses_params.op_type == ODP_CRYPTO_OP_TYPE_OOP) { + (ses_params.op_type == ODP_CRYPTO_OP_TYPE_OOP || + ses_params.op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP)) { if (!oop_warning_shown) - printf("\n Skipping ODP_CRYPTO_OP_TYPE_OOP tests\n"); + printf("\n Skipping out-of-place tests\n"); oop_warning_shown = 1; return -1; } @@ -316,7 +334,8 @@ static void alg_test_ses(odp_crypto_op_t op, if (!full_test) if ((ref->cipher != ODP_CIPHER_ALG_NULL && ref->auth != ODP_AUTH_ALG_NULL) || - test_param.session.null_crypto_enable) { + test_param.session.null_crypto_enable || + test_param.session.op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP) { /* run the loop body just once */ seg_len = max_shift / 2; max_shift = seg_len; @@ -366,6 +385,7 @@ static void alg_test_op_types(odp_crypto_op_t op, ODP_CRYPTO_OP_TYPE_LEGACY, ODP_CRYPTO_OP_TYPE_BASIC, ODP_CRYPTO_OP_TYPE_OOP, + ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP, }; for (unsigned int n = 0; n < ARRAY_SIZE(op_types); n++) { @@ -643,7 +663,8 @@ static int create_hash_test_reference(odp_auth_alg_t auth, .auth_range = { .offset = 0, .length = auth_bytes }, .dst_offset_shift = 0, }; - rc = crypto_op(pkt, &pkt, &ok, &op_params, ODP_CRYPTO_OP_TYPE_BASIC); + rc = crypto_op(pkt, &pkt, &ok, &op_params, + ODP_CRYPTO_OP_TYPE_BASIC, ODP_CRYPTO_OP_TYPE_BASIC); CU_ASSERT(rc == 0); if (rc) { @@ -862,7 +883,8 @@ static int crypto_encode_ref(crypto_test_reference_t *ref, .auth_range = auth_range, .dst_offset_shift = 0, }; - rc = crypto_op(pkt, &pkt, &ok, &op_params, ODP_CRYPTO_OP_TYPE_BASIC); + rc = crypto_op(pkt, &pkt, &ok, &op_params, + ODP_CRYPTO_OP_TYPE_BASIC, ODP_CRYPTO_OP_TYPE_BASIC); CU_ASSERT(rc == 0); if (rc) { (void)odp_crypto_session_destroy(session.session);