test/crypto: add PDCP C-Plane decap cases
authorAkhil Goyal <akhil.goyal@nxp.com>
Mon, 30 Sep 2019 19:27:41 +0000 (00:57 +0530)
committerAkhil Goyal <akhil.goyal@nxp.com>
Wed, 9 Oct 2019 09:50:12 +0000 (11:50 +0200)
This patch add test cases for control plane PDCP
5 and 12 bit SN test cases for decapsulation of
cipher+integrity for all algo combinations

Test vectors are reused from the encap cases
by swapping the input and output data.

The case are added to DPAA_SEC and DPAA2_SEC testsuite.

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>
app/test/test_cryptodev.c
app/test/test_cryptodev_security_pdcp.c
app/test/test_cryptodev_security_pdcp_test_func.h

index 35fe16a..ac575c8 100644 (file)
@@ -7215,6 +7215,18 @@ test_pdcp_proto_cplane_encap(int i)
                pdcp_test_data_in_len[i]+4);
 }
 
+int
+test_pdcp_proto_cplane_decap(int i)
+{
+       return test_pdcp_proto(i, 0,
+               RTE_CRYPTO_CIPHER_OP_DECRYPT,
+               RTE_CRYPTO_AUTH_OP_VERIFY,
+               pdcp_test_data_out[i],
+               pdcp_test_data_in_len[i] + 4,
+               pdcp_test_data_in[i],
+               pdcp_test_data_in_len[i]);
+}
+
 #endif
 
 static int
@@ -11632,6 +11644,9 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
 #ifdef RTE_LIBRTE_SECURITY
                TEST_CASE_ST(ut_setup, ut_teardown,
                        test_PDCP_PROTO_cplane_encap_all),
+
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_PDCP_PROTO_cplane_decap_all),
 #endif
                /** AES GCM Authenticated Encryption */
                TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11741,6 +11756,9 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 #ifdef RTE_LIBRTE_SECURITY
                TEST_CASE_ST(ut_setup, ut_teardown,
                        test_PDCP_PROTO_cplane_encap_all),
+
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_PDCP_PROTO_cplane_decap_all),
 #endif
                /** AES GCM Authenticated Encryption */
                TEST_CASE_ST(ut_setup, ut_teardown,
index cdf6639..803fc1d 100644 (file)
@@ -48,6 +48,31 @@ static int cplane_encap(uint32_t sn_size, uint8_t dir,
        return test_pdcp_proto_cplane_encap(i);
 }
 
+static int
+cplane_decap(uint32_t sn_size, uint8_t dir,
+            enum enc_alg_off enc_alg_off,
+            enum auth_alg_off auth_alg_off)
+{
+       int i = 0;
+
+       switch (sn_size) {
+       case 5:
+               i = PDCP_CPLANE_OFFSET + enc_alg_off +
+                       auth_alg_off + ((dir == 0) ?
+                               UPLINK : DOWNLINK);
+               break;
+       case 12:
+               i = PDCP_CPLANE_LONG_SN_OFFSET + enc_alg_off +
+                       auth_alg_off + ((dir == 0) ?
+                               UPLINK : DOWNLINK);
+               break;
+       default:
+               printf("\nInvalid SN: %u for %s\n", sn_size, __func__);
+       }
+
+       return test_pdcp_proto_cplane_decap(i);
+}
+
 #define TEST_PDCP_COUNT(func) do {                     \
        if (func == TEST_SUCCESS)  {                    \
                printf("\t%d)", n++);                   \
@@ -138,3 +163,83 @@ test_PDCP_PROTO_cplane_encap_all(void)
 
        return n - i;
 };
+
+int
+test_PDCP_PROTO_cplane_decap_all(void)
+{
+       int i = 0, n = 0;
+
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, NULL_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, NULL_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, NULL_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, NULL_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, NULL_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, NULL_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, NULL_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, NULL_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, SNOW_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, SNOW_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, SNOW_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, SNOW_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, SNOW_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, SNOW_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, SNOW_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, SNOW_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, AES_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, AES_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, AES_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, AES_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, AES_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, AES_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, AES_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, AES_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, ZUC_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, ZUC_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, ZUC_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, ZUC_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, ZUC_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, ZUC_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, UPLINK, ZUC_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(5, DOWNLINK, ZUC_ENC, ZUC_AUTH));
+
+       /* C-plane 12-bit */
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, NULL_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, NULL_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, NULL_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, NULL_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, NULL_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, NULL_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, NULL_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, NULL_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, SNOW_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, SNOW_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, SNOW_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, SNOW_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, SNOW_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, SNOW_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, SNOW_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, SNOW_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, AES_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, AES_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, AES_ENC, SNOW_AUTH));
+
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, AES_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, AES_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, AES_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, AES_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, AES_ENC, ZUC_AUTH));
+
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, ZUC_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, ZUC_ENC, NULL_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, ZUC_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, ZUC_ENC, SNOW_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, ZUC_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, ZUC_ENC, AES_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, UPLINK, ZUC_ENC, ZUC_AUTH));
+       TEST_PDCP_COUNT(cplane_decap(12, DOWNLINK, ZUC_ENC, ZUC_AUTH));
+
+       if (n - i)
+               printf("## %s: %d passed out of %d\n", __func__, i, n);
+
+       return n - i;
+};
index ad1e7c7..21a6e8a 100644 (file)
@@ -30,7 +30,9 @@ enum auth_alg_off {
 };
 
 int test_pdcp_proto_cplane_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);
 
 #endif /* SECURITY_PDCP_TEST_FUNC_H_ */