From patchwork Tue Oct 3 10:48:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anoob Joseph X-Patchwork-Id: 132276 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9D015426AE; Tue, 3 Oct 2023 12:49:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 714AE40608; Tue, 3 Oct 2023 12:49:01 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id B89C24026B for ; Tue, 3 Oct 2023 12:48:58 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3932IwEP028322; Tue, 3 Oct 2023 03:48:57 -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=KBj+K/00EDZ+zSDIyByWYcjepY2Lay2UQmP/8C4ANlI=; b=B/0Yuwccso1a/YUUrxGWzQBWNm7CEn4JDp2bTMbhOf4348ifwYKKuN2q2B9wremqGaQ9 UGyai6YfpSt/mq+eApzbIFyBzlS8r9KXOyWuv3wfl32NQTT1itv4YL3ibp+AfM6hj+xd k7AC6e/RL+benGOnRiyhfkwVlj0mHfPZXrpA3Brr5R4EIXqeuKGfA00rYBzCL0+MZAK6 aqoj+cZfPm6ebJeeBA42GD6hpdUBA2SUBRCPtdP4h8ly7Zhnqz4QJ1aDp0fMa2E8rVNl r6/oPX8H53tcoaD/5Efrze/Tr38h9yCf1gufVZXWKhIRyKQtm58UzoGIAgG7xqdNZL/f Gw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3tek6myvxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 03 Oct 2023 03:48:57 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 3 Oct 2023 03:48:55 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 3 Oct 2023 03:48:55 -0700 Received: from BG-LT92004.corp.innovium.com (unknown [10.28.163.189]) by maili.marvell.com (Postfix) with ESMTP id 881B23F7080; Tue, 3 Oct 2023 03:48:50 -0700 (PDT) From: Anoob Joseph To: Thomas Monjalon , Akhil Goyal , Jerin Jacob , Harry van Haaren CC: Konstantin Ananyev , Hemant Agrawal , , Olivier Matz , Vidya Sagar Velumuri Subject: [PATCH v2 1/5] net: add headers for TLS/DTLS packets Date: Tue, 3 Oct 2023 16:18:50 +0530 Message-ID: <20231003104854.1381-2-anoobj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231003104854.1381-1-anoobj@marvell.com> References: <20230811071712.240-1-anoobj@marvell.com> <20231003104854.1381-1-anoobj@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: JytaERQ7y3XtIIV6Qz8c27Rrav8LkNwA X-Proofpoint-GUID: JytaERQ7y3XtIIV6Qz8c27Rrav8LkNwA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_07,2023-10-02_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 From: Akhil Goyal Added TLS and DTLS packet headers for L4 security applications. Signed-off-by: Akhil Goyal Signed-off-by: Anoob Joseph Signed-off-by: Vidya Sagar Velumuri --- doc/api/doxy-api-index.md | 2 ++ lib/net/meson.build | 2 ++ lib/net/rte_dtls.h | 61 +++++++++++++++++++++++++++++++++++++++ lib/net/rte_tls.h | 48 ++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 lib/net/rte_dtls.h create mode 100644 lib/net/rte_tls.h diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index fdeda13932..03e2445bb1 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -128,6 +128,8 @@ The public API headers are grouped by topics: [eCPRI](@ref rte_ecpri.h), [PDCP hdr](@ref rte_pdcp_hdr.h), [PDCP](@ref rte_pdcp.h), + [TLS](@ref rte_tls.h), + [DTLS](@ref rte_dtls.h), [L2TPv2](@ref rte_l2tpv2.h), [PPP](@ref rte_ppp.h), [IB](@ref rte_ib.h) diff --git a/lib/net/meson.build b/lib/net/meson.build index b1bc27bad5..0b69138949 100644 --- a/lib/net/meson.build +++ b/lib/net/meson.build @@ -5,6 +5,8 @@ headers = files( 'rte_ip.h', 'rte_tcp.h', 'rte_udp.h', + 'rte_tls.h', + 'rte_dtls.h', 'rte_esp.h', 'rte_sctp.h', 'rte_icmp.h', diff --git a/lib/net/rte_dtls.h b/lib/net/rte_dtls.h new file mode 100644 index 0000000000..49bded1d96 --- /dev/null +++ b/lib/net/rte_dtls.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Marvell. + */ + +#ifndef RTE_DTLS_H +#define RTE_DTLS_H + +/** + * @file + * + * Datagram transport layer security(DTLS) related defines. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RTE_DTLS_TYPE_INVALID 0 /**< Invalid DTLS message type. */ +#define RTE_DTLS_TYPE_CHANGE_CIPHER_SPEC 20 /**< Change cipher spec message. */ +#define RTE_DTLS_TYPE_ALERT 21 /**< Alert message. */ +#define RTE_DTLS_TYPE_HANDSHAKE 22 /**< Handshake message for DTLS. */ +#define RTE_DTLS_TYPE_APPDATA 23 /**< DTLS application data message. */ +#define RTE_DTLS_TYPE_HEARTBEAT 24 /**< DTLS 1.3 heartbeat message. */ +#define RTE_DTLS_TYPE_CIPHERTEXT_WITH_CID 25 /**< DTLS 1.3 ciphertext with CID message. */ +#define RTE_DTLS_TYPE_ACK 26 /**< DTLS 1.3 ACK message. */ +#define RTE_DTLS_TYPE_MAX 255 /**< Maximum value as DTLS content type. */ + +#define RTE_DTLS_VERSION_1_2 0xFEFD /**< DTLS 1.2 version. 1's complement of 1.2. */ +#define RTE_DTLS_VERSION_1_3 0xFEFC /**< DTLS 1.3 version. 1's complement of 1.3. */ + +/** + * DTLS Header + */ +__extension__ +struct rte_dtls_hdr { + /** Content type of DTLS packet. Defined as RTE_DTLS_TYPE_*. */ + uint8_t type; + /** DTLS Version defined as RTE_DTLS_VERSION*. */ + rte_be16_t version; +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + /** The sequence number for the DTLS record. */ + uint64_t sequence_number : 48; + /** A counter value that is incremented on every cipher state change. */ + uint64_t epoch : 16; +#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN + /** A counter value that is incremented on every cipher state change. */ + uint64_t epoch : 16; + /** The sequence number for the DTLS record. */ + uint64_t sequence_number : 48; +#endif + /** The length (in bytes) of the following DTLS packet. */ + rte_be16_t length; +} __rte_packed; + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_DTLS_H */ diff --git a/lib/net/rte_tls.h b/lib/net/rte_tls.h new file mode 100644 index 0000000000..ee1e3aa249 --- /dev/null +++ b/lib/net/rte_tls.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Marvell. + */ + +#ifndef RTE_TLS_H +#define RTE_TLS_H + +/** + * @file + * + * Transport layer security(TLS) related defines. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RTE_TLS_TYPE_INVALID 0 /**< Invalid TLS message type. */ +#define RTE_TLS_TYPE_CHANGE_CIPHER_SPEC 20 /**< Change cipher spec message. */ +#define RTE_TLS_TYPE_ALERT 21 /**< Alert message. */ +#define RTE_TLS_TYPE_HANDSHAKE 22 /**< Handshake message for TLS. */ +#define RTE_TLS_TYPE_APPDATA 23 /**< TLS application data message. */ +#define RTE_TLS_TYPE_HEARTBEAT 24 /**< TLS 1.3 heartbeat message. */ +#define RTE_TLS_TYPE_MAX 255 /**< Maximum value as TLS content type. */ + +#define RTE_TLS_VERSION_1_2 0x0303 /**< TLS 1.2 version. */ +#define RTE_TLS_VERSION_1_3 0x0304 /**< TLS 1.3 version. */ + +/** + * TLS Header + */ +__extension__ +struct rte_tls_hdr { + /** Content type of TLS packet. Defined as RTE_TLS_TYPE_*. */ + uint8_t type; + /** TLS Version defined as RTE_TLS_VERSION*. */ + rte_be16_t version; + /** The length (in bytes) of the following TLS packet. */ + rte_be16_t length; +} __rte_packed; + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_TLS_H */