From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0503242C5A; Thu, 8 Jun 2023 08:55:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7FA5E40A84; Thu, 8 Jun 2023 08:55:30 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 713B040042 for ; Thu, 8 Jun 2023 08:55:28 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 357LwHm9023579; Wed, 7 Jun 2023 23:55:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=juXo0UyXr2QPfyzFq6dln3kfkxw0fxkSg0XhCPGS04I=; b=VSIvFS/gTRWmxVO1X4mumU4xSjNArU6NtyrN6fsCD2DwxerZKOzMDK1uPM23ehhU7GqU 8DVM5gkI05c83ry5FbQxZMD+xny1RPJXfBP5eMPLYJqA3OR/lhS3p+PMJYyA/MmHkTyS Ar7nty0E+s0vncvR+WUHPtoEaSOOmSS9Tr8ZWIbP62eylh8pqiXcSpPtFSH6QWwo5N96 c3v9La/NQ1wosxPFmN3N7xWNjmJ8rcgiF5BBx3zrGJx5xUW/LSta7K/xDKWIs2dQwau3 i8y3FfIcJ+Rm0viituIQUZLW8d5MJxQGCUFxp/ewo8Z2PNzFIreGsVXeUdXdRMg2UsHF vA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3r329c1ju4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 07 Jun 2023 23:55:25 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 7 Jun 2023 23:55:23 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 7 Jun 2023 23:55:23 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 0EDCE3F7055; Wed, 7 Jun 2023 23:55:19 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , Akhil Goyal Subject: [PATCH v3 05/13] test/security: verify multi flow MACsec Date: Thu, 8 Jun 2023 12:24:50 +0530 Message-ID: <20230608065458.333670-6-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230608065458.333670-1-gakhil@marvell.com> References: <20230607151940.223417-1-gakhil@marvell.com> <20230608065458.333670-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: kBLOPMMS1PaoH_KZEdVZ6imwPRL1tLS3 X-Proofpoint-ORIG-GUID: kBLOPMMS1PaoH_KZEdVZ6imwPRL1tLS3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-08_04,2023-06-07_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Added test case and test vectors to verify multiple flows of MACsec. Signed-off-by: Akhil Goyal --- app/test/test_security_inline_macsec.c | 49 ++++++++ .../test_security_inline_macsec_vectors.h | 110 +++++++++++++++++- 2 files changed, 158 insertions(+), 1 deletion(-) diff --git a/app/test/test_security_inline_macsec.c b/app/test/test_security_inline_macsec.c index 7445b667e4..621074a928 100644 --- a/app/test/test_security_inline_macsec.c +++ b/app/test/test_security_inline_macsec.c @@ -1074,6 +1074,51 @@ test_inline_macsec_auth_verify_all(const void *data __rte_unused) return all_err; } +static int +test_inline_macsec_multi_flow(const void *data __rte_unused) +{ + const struct mcs_test_vector *tv[MCS_MAX_FLOWS]; + struct mcs_test_vector iter[MCS_MAX_FLOWS]; + struct mcs_test_opts opts = {0}; + int i, err; + + opts.val_frames = RTE_SECURITY_MACSEC_VALIDATE_STRICT; + opts.encrypt = true; + opts.protect_frames = true; + opts.sa_in_use = 1; + opts.nb_td = MCS_MAX_FLOWS; + opts.sectag_insert_mode = 1; + opts.mtu = RTE_ETHER_MTU; + + for (i = 0; i < MCS_MAX_FLOWS; i++) { + memcpy(&iter[i].sa_key.data, sa_key, MCS_MULTI_FLOW_TD_KEY_SZ); + memcpy(&iter[i].plain_pkt.data, eth_addrs[i], 2 * RTE_ETHER_ADDR_LEN); + memcpy(&iter[i].plain_pkt.data[2 * RTE_ETHER_ADDR_LEN], plain_user_data, + MCS_MULTI_FLOW_TD_PLAIN_DATA_SZ); + memcpy(&iter[i].secure_pkt.data, eth_addrs[i], 2 * RTE_ETHER_ADDR_LEN); + memcpy(&iter[i].secure_pkt.data[2 * RTE_ETHER_ADDR_LEN], secure_user_data, + MCS_MULTI_FLOW_TD_SECURE_DATA_SZ); + iter[i].sa_key.len = MCS_MULTI_FLOW_TD_KEY_SZ; + iter[i].plain_pkt.len = MCS_MULTI_FLOW_TD_PLAIN_DATA_SZ + + (2 * RTE_ETHER_ADDR_LEN); + iter[i].secure_pkt.len = MCS_MULTI_FLOW_TD_SECURE_DATA_SZ + + (2 * RTE_ETHER_ADDR_LEN); + iter[i].alg = RTE_SECURITY_MACSEC_ALG_GCM_128; + iter[i].ssci = 0x0; + iter[i].xpn = 0x0; + tv[i] = (const struct mcs_test_vector *)&iter[i]; + } + err = test_macsec(tv, MCS_ENCAP_DECAP, &opts); + if (err) { + printf("\nCipher Auth Encryption multi flow failed"); + err = -1; + } else { + printf("\nCipher Auth Encryption multi flow Passed"); + err = 0; + } + return err; +} + static int ut_setup_inline_macsec(void) { @@ -1219,6 +1264,10 @@ inline_macsec_testsuite_teardown(void) static struct unit_test_suite inline_macsec_testsuite = { .suite_name = "Inline MACsec Ethernet Device Unit Test Suite", .unit_test_cases = { + TEST_CASE_NAMED_ST( + "MACsec Encap + decap Multi flow", + ut_setup_inline_macsec, ut_teardown_inline_macsec, + test_inline_macsec_multi_flow), TEST_CASE_NAMED_ST( "MACsec encap(Cipher+Auth) known vector", ut_setup_inline_macsec, ut_teardown_inline_macsec, diff --git a/app/test/test_security_inline_macsec_vectors.h b/app/test/test_security_inline_macsec_vectors.h index f6c668c281..8d9c2cae77 100644 --- a/app/test/test_security_inline_macsec_vectors.h +++ b/app/test/test_security_inline_macsec_vectors.h @@ -8,7 +8,6 @@ #define MCS_MAX_KEY_LEN 32 #define MCS_IV_LEN 12 #define MCS_SALT_LEN 12 -#define MCS_MAX_FLOWS 63 enum mcs_op { MCS_NO_OP, @@ -2078,4 +2077,113 @@ static const struct mcs_test_vector list_mcs_integrity_vectors[] = { }, }; +#define MCS_MULTI_FLOW_TD_KEY_SZ 16 +#define MCS_MULTI_FLOW_TD_PLAIN_DATA_SZ 42 +#define MCS_MULTI_FLOW_TD_SECURE_DATA_SZ 66 +#define MCS_MULTI_FLOW_TD_KEY_SZ 16 +#define MCS_MAX_FLOWS 63 + +uint8_t sa_key[MCS_MULTI_FLOW_TD_KEY_SZ] = { + 0x07, 0x1B, 0x11, 0x3B, 0x0C, 0xA7, 0x43, 0xFE, + 0xCC, 0xCF, 0x3D, 0x05, 0x1F, 0x73, 0x73, 0x82, +}; + +uint8_t eth_addrs[MCS_MAX_FLOWS][2 * RTE_ETHER_ADDR_LEN] = { + {0xE2, 0x00, 0x06, 0xD7, 0xCD, 0x0D, 0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3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0x76, 0x1E, 0x8D, 0xCD, 0x3D,}, + {0xE2, 0x3A, 0x06, 0xD7, 0xCD, 0x0D, 0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,}, + {0xE2, 0x3B, 0x06, 0xD7, 0xCD, 0x0D, 0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,}, + {0xE2, 0x3C, 0x06, 0xD7, 0xCD, 0x0D, 0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,}, + {0xE2, 0x3D, 0x06, 0xD7, 0xCD, 0x0D, 0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,}, + {0xE2, 0x3E, 0x06, 0xD7, 0xCD, 0x0D, 0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,}, +}; + +uint8_t plain_user_data[MCS_MULTI_FLOW_TD_PLAIN_DATA_SZ] = { + /* User Data with Ethertype */ + 0x08, 0x00, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, + 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, + 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, + 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, + 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, + 0x00, 0x04, +}; + +uint8_t secure_user_data[MCS_MULTI_FLOW_TD_SECURE_DATA_SZ] = { + /* MACsec EtherType */ + 0x88, 0xE5, + /* TCI and AN */ + 0x4C, + /* SL */ + 0x2A, + /* PN */ + 0x76, 0xD4, 0x57, 0xED, + /* Secure Data */ + 0x13, 0xB4, 0xC7, 0x2B, 0x38, 0x9D, 0xC5, 0x01, + 0x8E, 0x72, 0xA1, 0x71, 0xDD, 0x85, 0xA5, 0xD3, + 0x75, 0x22, 0x74, 0xD3, 0xA0, 0x19, 0xFB, 0xCA, + 0xED, 0x09, 0xA4, 0x25, 0xCD, 0x9B, 0x2E, 0x1C, + 0x9B, 0x72, 0xEE, 0xE7, 0xC9, 0xDE, 0x7D, 0x52, + 0xB3, 0xF3, + /* ICV */ + 0xD6, 0xA5, 0x28, 0x4F, 0x4A, 0x6D, 0x3F, 0xE2, + 0x2A, 0x5D, 0x6C, 0x2B, 0x96, 0x04, 0x94, 0xC3, +}; + + #endif -- 2.25.1