test/crypto: support PDCP short MAC-I
This patch add support to test the PDCP short MAC packets in crypto. Signed-off-by: Gagandeep Singh <g.singh@nxp.com> Acked-by: Akhil Goyal <gakhil@marvell.com>
This commit is contained in:
parent
864c1a40d7
commit
c24489e479
@ -8767,6 +8767,50 @@ test_PDCP_SDAP_PROTO_encap_all(void)
|
||||
return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
|
||||
}
|
||||
|
||||
static int
|
||||
test_PDCP_PROTO_short_mac(void)
|
||||
{
|
||||
int i = 0, size = 0;
|
||||
int err, all_err = TEST_SUCCESS;
|
||||
const struct pdcp_short_mac_test *cur_test;
|
||||
|
||||
size = RTE_DIM(list_pdcp_smac_tests);
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
cur_test = &list_pdcp_smac_tests[i];
|
||||
err = test_pdcp_proto(
|
||||
i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
|
||||
RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
|
||||
cur_test->in_len, cur_test->data_out,
|
||||
cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
|
||||
RTE_CRYPTO_CIPHER_NULL, NULL,
|
||||
0, cur_test->param.auth_alg,
|
||||
cur_test->auth_key, cur_test->param.auth_key_len,
|
||||
0, cur_test->param.domain, 0, 0,
|
||||
0, 0, 0);
|
||||
if (err) {
|
||||
printf("\t%d) %s: Short MAC test failed\n",
|
||||
cur_test->test_idx,
|
||||
cur_test->param.name);
|
||||
err = TEST_FAILED;
|
||||
} else {
|
||||
printf("\t%d) %s: Short MAC test PASS\n",
|
||||
cur_test->test_idx,
|
||||
cur_test->param.name);
|
||||
rte_hexdump(stdout, "MAC I",
|
||||
cur_test->data_out + cur_test->in_len + 2,
|
||||
2);
|
||||
err = TEST_SUCCESS;
|
||||
}
|
||||
all_err += err;
|
||||
}
|
||||
|
||||
printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
|
||||
|
||||
return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
test_PDCP_SDAP_PROTO_decap_all(void)
|
||||
{
|
||||
@ -14039,6 +14083,8 @@ static struct unit_test_suite cryptodev_snow3g_testsuite = {
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_snow3g_encryption_test_case_5),
|
||||
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_PDCP_PROTO_short_mac),
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_snow3g_encryption_test_case_1_oop),
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
@ -14279,6 +14325,8 @@ static struct unit_test_suite cryptodev_kasumi_testsuite = {
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_kasumi_decryption_test_case_1_oop),
|
||||
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_PDCP_PROTO_short_mac),
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_kasumi_cipher_auth_test_case_1),
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (C) 2015-2016 Freescale Semiconductor,Inc.
|
||||
* Copyright 2018-2019 NXP
|
||||
* Copyright 2018-2021 NXP
|
||||
*/
|
||||
|
||||
#ifndef SECURITY_PDCP_TEST_VECTOR_H_
|
||||
@ -28,6 +28,109 @@ struct pdcp_test_param {
|
||||
const char *name;
|
||||
};
|
||||
|
||||
struct pdcp_short_mac_test {
|
||||
uint32_t test_idx;
|
||||
struct pdcp_short_mac_test_param {
|
||||
enum rte_security_pdcp_domain domain;
|
||||
enum rte_crypto_auth_algorithm auth_alg;
|
||||
uint8_t auth_key_len;
|
||||
const char *name;
|
||||
} param;
|
||||
const uint8_t *auth_key;
|
||||
const uint8_t *data_in;
|
||||
uint32_t in_len;
|
||||
const uint8_t *data_out;
|
||||
};
|
||||
|
||||
static const struct pdcp_short_mac_test list_pdcp_smac_tests[] = {
|
||||
{
|
||||
.test_idx = 1,
|
||||
.param = {.name = "PDCP-SMAC SNOW3G UIA2",
|
||||
.auth_alg = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
|
||||
.domain = RTE_SECURITY_PDCP_MODE_SHORT_MAC,
|
||||
.auth_key_len = 16,
|
||||
},
|
||||
.auth_key = (uint8_t[]){ 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5,
|
||||
0xb3, 0x00, 0x95, 0x2c, 0x49, 0x10,
|
||||
0x48, 0x81, 0xff, 0x48 },
|
||||
.data_in = (uint8_t[]){ 0x33, 0x32, 0x34, 0x62, 0x63, 0x39,
|
||||
0x38 },
|
||||
.in_len = 7,
|
||||
.data_out = (uint8_t[]){ 0x33, 0x32, 0x34, 0x62, 0x63, 0x39,
|
||||
0x38, 0x56, 0xd2, 0x09, 0xae },
|
||||
},
|
||||
|
||||
{
|
||||
.test_idx = 2,
|
||||
.param = {.name = "PDCP-SMAC AES CMAC 1",
|
||||
.auth_alg = RTE_CRYPTO_AUTH_AES_CMAC,
|
||||
.domain = RTE_SECURITY_PDCP_MODE_SHORT_MAC,
|
||||
.auth_key_len = 16,
|
||||
},
|
||||
.auth_key = (uint8_t[]){ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00 },
|
||||
.data_in = (uint8_t[]){ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00 },
|
||||
.in_len = 7,
|
||||
.data_out = (uint8_t[]){ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x13, 0xf8, 0x4b, 0xea },
|
||||
},
|
||||
|
||||
{
|
||||
.test_idx = 3,
|
||||
.param = {.name = "PDCP-SMAC AES CMAC 2",
|
||||
.auth_alg = RTE_CRYPTO_AUTH_AES_CMAC,
|
||||
.domain = RTE_SECURITY_PDCP_MODE_SHORT_MAC,
|
||||
.auth_key_len = 16,
|
||||
},
|
||||
.auth_key = (uint8_t[]){ 0x16, 0xc1, 0x98, 0x14, 0x9a, 0x2c,
|
||||
0xf4, 0x12, 0x4f, 0xd4, 0x14, 0xec,
|
||||
0x72, 0x43, 0x29, 0x04 },
|
||||
.data_in = (uint8_t[]){ 0x00, 0xc0, 0x00, 0x00, 0x00, 0x05,
|
||||
0x09, 0xe4 },
|
||||
.in_len = 8,
|
||||
.data_out = (uint8_t[]){ 0x00, 0xc0, 0x00, 0x00, 0x00, 0x05,
|
||||
0x09, 0xe4, 0xdd, 0xff, 0xde, 0xa9 },
|
||||
},
|
||||
|
||||
{
|
||||
.test_idx = 4,
|
||||
.param = {.name = "PDCP-SMAC AES CMAC 3",
|
||||
.auth_alg = RTE_CRYPTO_AUTH_AES_CMAC,
|
||||
.domain = RTE_SECURITY_PDCP_MODE_SHORT_MAC,
|
||||
.auth_key_len = 16,
|
||||
},
|
||||
.auth_key = (uint8_t[]){ 0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F,
|
||||
0xB1, 0x1C, 0x40, 0x35, 0xC6, 0x68,
|
||||
0x0A, 0xF8, 0xC6, 0xD3 },
|
||||
.data_in = (uint8_t[]){ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00 },
|
||||
.in_len = 7,
|
||||
.data_out = (uint8_t[]){ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x23, 0xea, 0x95, 0xb0 },
|
||||
},
|
||||
|
||||
{
|
||||
.test_idx = 5,
|
||||
.param = {.name = "PDCP-SMAC NULL",
|
||||
.auth_alg = RTE_CRYPTO_AUTH_NULL,
|
||||
.domain = RTE_SECURITY_PDCP_MODE_SHORT_MAC,
|
||||
.auth_key_len = 16,
|
||||
},
|
||||
.auth_key = (uint8_t[]){ 0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5,
|
||||
0xB3, 0x00, 0x95, 0x2C, 0x49, 0x10,
|
||||
0x48, 0x81, 0xFF, 0x48
|
||||
},
|
||||
.data_in = (uint8_t[]){ 0x33, 0x32, 0x34, 0x62, 0x63, 0x39,
|
||||
0x38 },
|
||||
.in_len = 7,
|
||||
.data_out = (uint8_t[]){ 0x33, 0x32, 0x34, 0x62, 0x63, 0x39,
|
||||
0x38, 0x00, 0x00, 0x00, 0x00 },
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
static struct pdcp_test_param pdcp_test_params[] = {
|
||||
{
|
||||
.name =
|
||||
|
Loading…
Reference in New Issue
Block a user