test/crypto: add PDCP U-Plane encap cases
PDCP User/Data plane can support 5/7/12/15/18 bit sequence number. This patch add test cases and test vectors for all supported algos for cipher only. (NULL, AES, SNOW, ZUC ciphers) The test cases are added in DPAA_SEC and DPAA2_SEC test suite as a reference. Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com> Signed-off-by: Vakul Garg <vakul.garg@nxp.com> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
This commit is contained in:
parent
77371fe7ca
commit
0fce8f6a6c
@ -7215,6 +7215,19 @@ test_pdcp_proto_cplane_encap(int i)
|
||||
pdcp_test_data_in_len[i]+4);
|
||||
}
|
||||
|
||||
int
|
||||
test_pdcp_proto_uplane_encap(int i)
|
||||
{
|
||||
return test_pdcp_proto(i, 0,
|
||||
RTE_CRYPTO_CIPHER_OP_ENCRYPT,
|
||||
RTE_CRYPTO_AUTH_OP_GENERATE,
|
||||
pdcp_test_data_in[i],
|
||||
pdcp_test_data_in_len[i],
|
||||
pdcp_test_data_out[i],
|
||||
pdcp_test_data_in_len[i]);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
test_pdcp_proto_cplane_decap(int i)
|
||||
{
|
||||
@ -11647,6 +11660,9 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
|
||||
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_PDCP_PROTO_cplane_decap_all),
|
||||
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_PDCP_PROTO_uplane_encap_all),
|
||||
#endif
|
||||
/** AES GCM Authenticated Encryption */
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
@ -11759,6 +11775,9 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
|
||||
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_PDCP_PROTO_cplane_decap_all),
|
||||
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
test_PDCP_PROTO_uplane_encap_all),
|
||||
#endif
|
||||
/** AES GCM Authenticated Encryption */
|
||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||
|
@ -73,6 +73,32 @@ cplane_decap(uint32_t sn_size, uint8_t dir,
|
||||
return test_pdcp_proto_cplane_decap(i);
|
||||
}
|
||||
|
||||
static int uplane_encap_no_integrity(uint32_t sn_size, uint8_t dir,
|
||||
enum enc_alg_off enc_alg_off)
|
||||
{
|
||||
int i = PDCP_UPLANE_OFFSET + ((dir == 0) ? UPLINK : DOWNLINK) +
|
||||
enc_alg_off;
|
||||
|
||||
switch (sn_size) {
|
||||
case 7:
|
||||
i += SHORT_SEQ_NUM_OFFSET;
|
||||
break;
|
||||
case 15:
|
||||
i += FIFTEEN_BIT_SEQ_NUM_OFFSET;
|
||||
break;
|
||||
case 12:
|
||||
i += LONG_SEQ_NUM_OFFSET;
|
||||
break;
|
||||
case 18:
|
||||
i += EIGHTEEN_BIT_SEQ_NUM_OFFSET;
|
||||
break;
|
||||
default:
|
||||
printf("\nInvalid SN: %u\n", sn_size);
|
||||
}
|
||||
|
||||
return test_pdcp_proto_uplane_encap(i);
|
||||
}
|
||||
|
||||
#define TEST_PDCP_COUNT(func) do { \
|
||||
if (func == TEST_SUCCESS) { \
|
||||
printf("\t%d)", n++); \
|
||||
@ -243,3 +269,50 @@ test_PDCP_PROTO_cplane_decap_all(void)
|
||||
|
||||
return n - i;
|
||||
};
|
||||
|
||||
int
|
||||
test_PDCP_PROTO_uplane_encap_all(void)
|
||||
{
|
||||
int i = 0, n = 0;
|
||||
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(12, UPLINK, NULL_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(12, DOWNLINK, NULL_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(7, UPLINK, NULL_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(7, DOWNLINK, NULL_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(15, UPLINK, NULL_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(15, DOWNLINK, NULL_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(18, UPLINK, NULL_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(18, DOWNLINK, NULL_ENC));
|
||||
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(12, UPLINK, SNOW_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(12, DOWNLINK, SNOW_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(7, UPLINK, SNOW_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(7, DOWNLINK, SNOW_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(15, UPLINK, SNOW_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(15, DOWNLINK, SNOW_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(18, UPLINK, SNOW_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(18, DOWNLINK, SNOW_ENC));
|
||||
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(12, UPLINK, AES_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(12, DOWNLINK, AES_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(7, UPLINK, AES_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(7, DOWNLINK, AES_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(15, UPLINK, AES_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(15, DOWNLINK, AES_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(18, UPLINK, AES_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(18, DOWNLINK, AES_ENC));
|
||||
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(12, UPLINK, ZUC_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(12, DOWNLINK, ZUC_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(7, UPLINK, ZUC_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(7, DOWNLINK, ZUC_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(15, UPLINK, ZUC_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(15, DOWNLINK, ZUC_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(18, UPLINK, ZUC_ENC));
|
||||
TEST_PDCP_COUNT(uplane_encap_no_integrity(18, DOWNLINK, ZUC_ENC));
|
||||
|
||||
if (n - i)
|
||||
printf("## %s: %d passed out of %d\n", __func__, i, n);
|
||||
|
||||
return n - i;
|
||||
};
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#define PDCP_CPLANE_OFFSET 0
|
||||
#define PDCP_CPLANE_LONG_SN_OFFSET 32
|
||||
#define PDCP_UPLANE_OFFSET 64
|
||||
#define LONG_SEQ_NUM_OFFSET 0
|
||||
#define SHORT_SEQ_NUM_OFFSET 2
|
||||
#define FIFTEEN_BIT_SEQ_NUM_OFFSET 4
|
||||
@ -16,6 +17,9 @@
|
||||
/* key length(in bytes) for F8 */
|
||||
#define F8_KEY_LEN 16
|
||||
|
||||
#define PDCP_UPLANE_12BIT_OFFSET (PDCP_UPLANE_OFFSET + 32)
|
||||
#define PDCP_UPLANE_18BIT_OFFSET (PDCP_UPLANE_12BIT_OFFSET + 32)
|
||||
|
||||
enum enc_alg_off {
|
||||
NULL_ENC = 0,
|
||||
SNOW_ENC = 8,
|
||||
@ -30,9 +34,11 @@ enum auth_alg_off {
|
||||
};
|
||||
|
||||
int test_pdcp_proto_cplane_encap(int i);
|
||||
int test_pdcp_proto_uplane_encap(int i);
|
||||
int test_pdcp_proto_cplane_decap(int i);
|
||||
|
||||
int test_PDCP_PROTO_cplane_encap_all(void);
|
||||
int test_PDCP_PROTO_cplane_decap_all(void);
|
||||
int test_PDCP_PROTO_uplane_encap_all(void);
|
||||
|
||||
#endif /* SECURITY_PDCP_TEST_FUNC_H_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user