Skip to contentSkip to conversation

introduce IPsec Service in virtio-crypto

RFC PATCH Superseded Srujana Challa 3 participants 15 messages Jan 22, 2025 – Feb 17, 2025

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover introduce IPsec Service in virtio-crypto

This series enhances virtio-crypto by adding support for IPsec services. These patches aim to extend the capabilities of virtio-crypto, enabling it to handle IPsec operations efficiently. In addition to standard crypto processing, the IPsec protocol processing is also offloaded to the Crypto device as lookaside operation.

It utilizes new virtio basic facilities, including capability and resource objects. Below is a summary of the changes introduced:

Patch1:
This patch introduces the foundational support for IPsec services within the virtio-crypto framework, outlining the necessary capabilities for IPsec operations.

Patch2:
This patch adds resource objects required for programming IPsec Security Associations (SAs) for both encryption and decryption processes.

Patch3:
This patch includes new opcodes specific to IPsec operations, facilitating the handling of IPsec data requests within the virtio-crypto driver.

Patch4:
This patch specifies the requirements for both the device and the driver to support IPsec operations.

These enhancements are for providing support for IPsec within the virtio-crypto device/driver, improving security and performance for virtualized environments. We believe these additions will significantly benefit users who rely on virtio-crypto for secure data transmission.

v2:
- Addressed the review comments from Matias. v3:
- Addressed the review comments from Parav Pandit.

Srujana Challa (4):
virtio-crypto: Add IPsec service operation and Capabilities
virtio-crypto: Add resource objects for IPsec outbound and inbound SAs
virtio-crypto: Add new IPsec opcodes to data request
virtio-crypto: Add device and driver requirements for IPsec operation

 device-types/crypto/description.tex        | 486 ++++++++++++++++++++-
 device-types/crypto/device-conformance.tex |   1 +
 device-types/crypto/driver-conformance.tex |   1 +
 introduction.tex                           |  12 +
 4 files changed, 495 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

RFC PATCH v3 1/4 virtio-crypto: Add IPsec service operation and Capabilities

This commit introduces the IPsec service operation to the Crypto device, enabling offloading of IPsec processing.

Capabilities:

1. IPsec Resource Capability (VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP):
Indicates the device's IPsec resource limits, such as the number of outbound and inbound Security Associations (SAs).
2. IPsec SA Capability (VIRTIO_CRYPTO_IPSEC_SA_CAP): Specifies the supported IPsec modes, along with the supported cryptographic algorithms, authentication algorithms, IPsec options and anti-replay window size.

---
 device-types/crypto/description.tex | 166 +++++++++++++++++++++++++++-
 introduction.tex                    |  12 ++
 2 files changed, 173 insertions(+), 5 deletions(-)
device-types/crypto/description.tex +161 -5
index 5705e26..2c00e50 100644
@@ -2,13 +2,15 @@ \section{Crypto Device}\label{sec:Device Types / Crypto Device}
 
 The virtio crypto device is a virtual cryptography device as well as a
 virtual cryptographic accelerator. The virtio crypto device provides the
-following crypto services: CIPHER, MAC, HASH, AEAD and AKCIPHER. Virtio crypto
-devices have a single control queue and at least one data queue. Crypto
-operation requests are placed into a data queue, and serviced by the
-device. Some crypto operation requests are only valid in the context of a
-session. The role of the control queue is facilitating control operation
+following crypto services: CIPHER, MAC, HASH, AEAD, AKCIPHER and IPSEC.
+Virtio crypto devices have a single control queue and at least one data
+queue. Crypto operation requests are placed into a data queue, and serviced
+by the device. Some crypto operation requests are only valid in the context
+of a session. The role of the control queue is facilitating control operation
 requests. Sessions management is realized with control operation
 requests.
+The crypto device may have administration command interface through which
+IPsec service capabilities and resources are configured.
 
 \subsection{Device ID}\label{sec:Device Types / Crypto Device / Device ID}
 
@@ -72,6 +74,8 @@ \subsection{Supported crypto services}\label{sec:Device Types / Crypto Device /
 #define VIRTIO_CRYPTO_SERVICE_AEAD   3
 /* AKCIPHER (Asymmetric Key Cipher) service */
 #define VIRTIO_CRYPTO_SERVICE_AKCIPHER 4
+/* IPSEC service */
+#define VIRTIO_CRYPTO_SERVICE_IPSEC  5
 \end{lstlisting}
 
 The above constants designate bits used to indicate the which of crypto services are
@@ -318,6 +322,20 @@ \subsection{Device Initialization}\label{sec:Device Types / Crypto Device / Devi
 \item The driver MUST read the supported algorithms based on \field{crypto_services} field.
 \end{itemize*}
 
+\subsection{Device and driver capabilities}\label{sec:Device Types / Crypto Device / Device and driver capabilities}
+
+The crypto device has the following capabilities.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| }
+\hline
+Identifier & Name & Description \\
+\hline \hline
+0x0800 & \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-RESOURCE-CAP]{VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP} & IPsec resource capability \\
+\hline
+0x0801 & \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP]{VIRTIO_CRYPTO_IPSEC_SA_CAP} & IPsec Security Association(SA) capability \\
+\hline
+\end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto Device / Device Operation}
 
 The operation of a virtio crypto device is driven by requests placed on the virtqueues.
@@ -1872,3 +1890,141 @@ \subsubsection{AKCIPHER Service Operation}\label{sec:Device Types / Crypto Devic
 \item VIRTIO_CRYPTO_ERR if any failure not mentioned above occurs.
 \end{itemize*}
 \end{itemize*}
+
+\subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / Device Operation / IPSEC Service Operation}
+
+A crypto device can support the processing of IPsec protocol operations.
+In addition to standard crypto processing, the IPsec protocol operations
+are also handled by the Crypto Device as a lookaside operation.
+
+IPsec Inbound processing: The device will perform decryption, authentication,
+integrity checking and remove additional headers, including tunnel header if
+in tunnel mode, as well as the ESP/AH header from the packet(See \hyperref[intro:IPSEC]{IPSEC} RFC).
+The resulting packet contains only the plain data.
+
+IPsec Outbound processing: The device will perform encryption, attach ICV,
+update/add IP header, add ESP/AH header/trailer.
+
+A crypto device can support number of IPsec SAs, allowing it to manage multiple secure
+connections simultaneously.
+
+The device and the driver indicate IPsec SA resource limits using the
+VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability specifying the limits on the number of
+IPsec outbound and inbound SA resource objects.
+The VIRTIO_CRYPTO_IPSEC_SA_CAP capability  specifies which IPsec protocol capabilities
+the device supports. The driver indicates the IPsec parameters by setting the IPsec
+SA capability prior to adding any resource object.
+
+The driver controls the IPsec SA resource object using administration commands described in
+\ref{sec:Basic Facilities of a Virtio Device / Device groups / Group administration commands / Device resource objects}.
+
+\paragraph{Device and driver capabilities}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities}
+
+\subparagraph{VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-RESOURCE-CAP}
+
+The VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability indicates the IPsec SA resource limits.
+\field{cap_specific_data} is in the format
+\field{struct virtio_crypto_ipsec_resource_cap}.
+
+\begin{lstlisting}
+struct virtio_crypto_ipsec_resource_cap {
+        le32 inb_sa_limit;
+        le32 outb_sa_limit;
+};
+\end{lstlisting}
+
+\field{inb_sa_limit}, and \field{outb_sa_limit} denote the maximum number of IPsec
+security Associations (SAs) that can be utilized for IPsec inbound and outbound processing,
+respectively, which the device is capable of creating.
+
+\subparagraph{VIRTIO_CRYPTO_IPSEC_SA_CAP}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP}
+
+The VIRTIO_CRYPTO_IPSEC_SA_CAP capability lists the supported IPsec modes along with
+the supported cryptographic, authentication algorithms and anti-replay window size for
+each IPsec mode.
+\field{cap_specific_data} is in the format \field{struct virtio_crypto_ipsec_sa_cap_data}.
+
+\begin{lstlisting}[label={lst:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / virtio-crypto-ipsec-mode-cap}]
+struct virtio_crypto_ipsec_mode_cap {
+        u8 mode;
+        u8 reserved[3];
+        le32 max_replay_win_sz;
+        le32 options;
+        le64 cipher_algo;
+        le64 hmac_algo;
+        le32 aead_algo;
+        le32 max_cipher_key_len;
+        le32 max_auth_key_len;
+};
+
+struct virtio_crypto_ipsec_sa_cap_data {
+        u8 count;
+        u8 reserved[7];
+        struct virtio_crypto_ipsec_mode_cap mode[];
+};
+\end{lstlisting}
+
+\field{count} indicates number of valid entries in the \field{mode} array.
+\field{mode[]} is an array of supported IPsec modes. Within each array entry:
+
+\field{mode} specifies the IPsec mode, as defined in table
+\ref{table:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}.
+\field{max_replay_win_sz} specifies the maximum anti-replay window size the device supports.
+This field is applicable only for inbound operation.
+
+\field{options} Each bit indicates the IPsec protocol options supported by the device, as defined in table
+\ref{table:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.
+
+\field{cipher_algo} CIPHER algorithms mask, see \ref{sec:Device Types / Crypto Device / Supported crypto services  / CIPHER services}.
+
+\field{hmac_algo} HMAC algorithms mask, see \ref{sec:Device Types / Crypto Device / Supported crypto services  / MAC services}.
+
+\field{aead_algo} AEAD algorithms mask, see \ref{sec:Device Types / Crypto Device / Supported crypto services  / AEAD services}.
+
+\field{max_cipher_key_len} is the maximum length of cipher key supported by the device.
+
+\field{max_auth_key_len} is the maximum length of authenticated key supported by the device.
+
+\begin{table}[H]
+\caption{IPsec Modes}
+\label{table:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}
+\begin{tabularx}{\textwidth}{ |l|X|X| }
+\hline
+Type & Name & Description \\
+\hline \hline
+0x0 & - & Reserved \\
+\hline
+0x1 & VIRTIO_CRYPTO_IPSEC_MODE_ESP_TUNNEL & IPsec ESP protocol in tunnel mode \\
+\hline
+0x2 & VIRTIO_CRYPTO_IPSEC_MODE_ESP_TRANSPORT & IPsec ESP protocol in transport mode \\
+\hline
+0x3 & VIRTIO_CRYPTO_IPSEC_MODE_AH_TUNNEL & IPsec AH protocol in tunnel mode \\
+\hline
+0x4 & VIRTIO_CRYPTO_IPSEC_MODE_AH_TRANSPORT & IPsec AH protocol in transport mode \\
+\hline
+\end{tabularx}
+\end{table}
+
+See \hyperref[intro:IPSEC]{IPSEC} for more information on tunnel and transport modes in ESP/AH IPsec processing.
+
+\begin{table}[H]
+\caption{IPsec Options}
+\label{table:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}
+\begin{tabularx}{\textwidth}{ |l|X|X| }
+\hline
+Bit Number & Name & Description \\
+\hline \hline
+0 & VIRTIO_CRYPTO_IPSEC_ESN & Specifies whether extended sequence number is supported, as described in \hyperref[intro:ESN]{ESN}\\
+\hline
+1 & VIRTIO_CRYPTO_IPSEC_UDP_ENCAP & Specifies whether udp encapsulation is supported, as described in
+                                    \hyperref[intro:UDP-Encapsulation]{UDP Encapsulation}, applicable only for ESP IPsec processing \\
+\hline
+2 & VIRTIO_CRYPTO_IPSEC_COPY_DSCP & Specifies whether copy dscp is supported, as described in \hyperref[intro:IPSEC]{IPSEC} \\
+\hline
+3 & VIRTIO_CRYPTO_IPSEC_DEC_TTL & Specifies whether decrementing the time to live is supported, as described in \hyperref[intro:IPSEC]{IPSEC} \\
+\hline
+\end{tabularx}
+\end{table}
introduction.tex +12 -0
index e60298a..80aa67a 100644
@@ -162,6 +162,18 @@ \section{Normative References}\label{sec:Normative References}
 	\phantomsection\label{intro:TCP-Header-Format}\textbf{[TCP Header Format]} &
     TCP Header Format
 	\newline\url{https://www.rfc-editor.org/rfc/rfc9293#name-header-format}\\
+	\phantomsection\label{intro:IPSEC}\textbf{[IPSEC]} &
+    IPsec Protocol
+	\newline\url{https://www.rfc-editor.org/rfc/rfc4301}\\
+	\phantomsection\label{intro:ESP}\textbf{[ESP]} &
+    IPsec ESP
+	\newline\url{https://www.rfc-editor.org/rfc/rfc4303}\\
+	\phantomsection\label{intro:ESN}\textbf{[ESN]} &
+    IPsec ESN
+	\newline\url{https://www.rfc-editor.org/rfc/rfc4304}\\
+	\phantomsection\label{intro:UDP-Encapsulation}\textbf{[UDP Encapsulation]} &
+    IPsec UDP Encapsulation
+	\newline\url{https://www.rfc-editor.org/rfc/rfc3948}\\
 	\phantomsection\label{intro:CAN}\textbf{[CAN]} &
     ISO 11898-1:2015 Road vehicles -- Controller area network (CAN) -- Part 1: Data link layer and physical signalling\\
 	\phantomsection\label{intro:rfc8174}\textbf{[RFC8174]} &
Signature · 1 line
2.25.1
#2 lore raw

RE: [PATCH RFC v3 1/4] virtio-crypto: Add IPsec service operation and Capabilities

Quoted 93 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:47 AM

This commit introduces the IPsec service operation to the Crypto device, enabling offloading of IPsec processing.

Capabilities:

1. IPsec Resource Capability (VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP):
Indicates the device's IPsec resource limits, such as the number of outbound and inbound Security Associations (SAs).
2. IPsec SA Capability (VIRTIO_CRYPTO_IPSEC_SA_CAP): Specifies the supported IPsec modes, along with the supported cryptographic algorithms, authentication algorithms, IPsec options and anti-replay window size.

---
 device-types/crypto/description.tex | 166 +++++++++++++++++++++++++++-
 introduction.tex                    |  12 ++
 2 files changed, 173 insertions(+), 5 deletions(-)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex
index 5705e26..2c00e50 100644

device-types/crypto/description.tex +0 -0
@@ -2,13 +2,15 @@ \section{Crypto Device}\label{sec:Device Types / Crypto
 Device}
 
 The virtio crypto device is a virtual cryptography device as well as a  virtual

cryptographic accelerator. The virtio crypto device provides the -following crypto services: CIPHER, MAC, HASH, AEAD and AKCIPHER. Virtio crypto - devices have a single control queue and at least one data queue. Crypto - operation requests are placed into a data queue, and serviced by the -device. Some crypto operation requests are only valid in the context of a -session. The role of the control queue is facilitating control operation

device-types/crypto/description.tex +8 -0
+following crypto services: CIPHER, MAC, HASH, AEAD, AKCIPHER and IPSEC.
+Virtio crypto devices have a single control queue and at least one data
+queue. Crypto operation requests are placed into a data queue, and
+serviced by the device. Some crypto operation requests are only valid
+in the context of a session. The role of the control queue is
+facilitating control operation
 requests. Sessions management is realized with control operation  requests.
+The crypto device may have administration command interface through
+which IPsec service capabilities and resources are configured.
 
 \subsection{Device ID}\label{sec:Device Types / Crypto Device / Device ID}
@@ -72,6 +74,8 @@ \subsection{Supported crypto services}\label{sec:Device

Types / Crypto Device /
#define VIRTIO_CRYPTO_SERVICE_AEAD 3
/* AKCIPHER (Asymmetric Key Cipher) service */ #define
VIRTIO_CRYPTO_SERVICE_AKCIPHER 4

device-types/crypto/description.tex +2 -0
+/* IPSEC service */
+#define VIRTIO_CRYPTO_SERVICE_IPSEC  5
 \end{lstlisting}
 
 The above constants designate bits used to indicate the which of crypto

services are @@ -318,6 +322,20 @@ \subsection{Device Initialization}\label{sec:Device Types / Crypto Device / Devi \item The driver MUST read the supported algorithms based on \field{crypto_services} field.
\end{itemize*}

+\subsection{Device and driver capabilities}\label{sec:Device Types /

device-types/crypto/description.tex +9 -0
+Crypto Device / Device and driver capabilities}
+
+The crypto device has the following capabilities.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| } \hline Identifier & Name &
+Description \\ \hline \hline
+0x0800 & \hyperref[par:Device Types / Crypto Device / Device Operation
+/ IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-RESOURCE-

CAP]{VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP} &

device-types/crypto/description.tex +6 -0
+IPsec resource capability \\ \hline
+0x0801 & \hyperref[par:Device Types / Crypto Device / Device Operation
+/ IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP]{VIRTIO_CRYPTO_IPSEC_SA_CAP} & IPsec
+Security Association(SA) capability \\ \hline \end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto Device /

Device Operation}

The operation of a virtio crypto device is driven by requests placed on the
virtqueues.

device-types/crypto/description.tex +0 -0
@@ -1872,3 +1890,141 @@ \subsubsection{AKCIPHER Service

Operation}\label{sec:Device Types / Crypto Devic \item VIRTIO_CRYPTO_ERR if any failure not mentioned above occurs.
\end{itemize*}
\end{itemize*}

device-types/crypto/description.tex \subsubsection{AKCIPHER Service Operation}\label{sec:Device Types / Crypto Devic · line 1899

Quoted 8 lines
device-types/crypto/description.tex +8 -0
+
+\subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto
+Device / Device Operation / IPSEC Service Operation}
+
+A crypto device can support the processing of IPsec protocol operations.
+In addition to standard crypto processing, the IPsec protocol
+operations are also handled by the Crypto Device as a lookaside operation.
+

s/Crypto Device/crypto device/

Quoted 65 lines
device-types/crypto/description.tex +3 -0
+IPsec Inbound processing: The device will perform decryption,
+authentication, integrity checking and remove additional headers,
+including tunnel header if in tunnel mode, as well as the ESP/AH header from

the packet(See \hyperref[intro:IPSEC]{IPSEC} RFC).

device-types/crypto/description.tex +14 -0
+The resulting packet contains only the plain data.
+
+IPsec Outbound processing: The device will perform encryption, attach
+ICV, update/add IP header, add ESP/AH header/trailer.
+
+A crypto device can support number of IPsec SAs, allowing it to manage
+multiple secure connections simultaneously.
+
+The device and the driver indicate IPsec SA resource limits using the
+VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability specifying the limits on
+the number of IPsec outbound and inbound SA resource objects.
+The VIRTIO_CRYPTO_IPSEC_SA_CAP capability  specifies which IPsec
+protocol capabilities the device supports. The driver indicates the
+IPsec parameters by setting the IPsec SA capability prior to adding any

resource object.

device-types/crypto/description.tex +3 -0
+
+The driver controls the IPsec SA resource object using administration
+commands described in \ref{sec:Basic Facilities of a Virtio Device / Device

groups / Group administration commands / Device resource objects}.

device-types/crypto/description.tex +11 -0
+
+\paragraph{Device and driver capabilities} \label{par:Device Types /
+Crypto Device / Device Operation / IPsec Service Operation / Device and
+driver capabilities}
+
+\subparagraph{VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-RESOURCE-CAP}
+
+The VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability indicates the IPsec SA

resource limits.
+\field{cap_specific_data} is in the format \field{struct

device-types/crypto/description.tex +12 -0
+virtio_crypto_ipsec_resource_cap}.
+
+\begin{lstlisting}
+struct virtio_crypto_ipsec_resource_cap {
+        le32 inb_sa_limit;
+        le32 outb_sa_limit;
+};
+\end{lstlisting}
+
+\field{inb_sa_limit}, and \field{outb_sa_limit} denote the maximum
+number of IPsec security Associations (SAs) that can be utilized for
+IPsec inbound and outbound processing, respectively, which the device is

capable of creating.

device-types/crypto/description.tex +10 -0
+
+\subparagraph{VIRTIO_CRYPTO_IPSEC_SA_CAP}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP}
+
+The VIRTIO_CRYPTO_IPSEC_SA_CAP capability lists the supported IPsec
+modes along with the supported cryptographic, authentication algorithms
+and anti-replay window size for each IPsec mode.
+\field{cap_specific_data} is in the format \field{struct

virtio_crypto_ipsec_sa_cap_data}.

device-types/crypto/description.tex +3 -0
+
+\begin{lstlisting}[label={lst:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-

CRYPTO-IPSEC-SA-CAP / virtio-crypto-ipsec-mode-cap}] struct virtio_crypto_ipsec_mode_cap {

device-types/crypto/description.tex \subsubsection{AKCIPHER Service Operation}\label{sec:Device Types / Crypto Devic · line 1955

Quoted 4 lines
device-types/crypto/description.tex +4 -0
+        u8 mode;
+        u8 reserved[3];
+        le32 max_replay_win_sz;
+        le32 options;

Please add le32 reserved for 64-bit natural alignment.

device-types/crypto/description.tex \subsubsection{AKCIPHER Service Operation}\label{sec:Device Types / Crypto Devic · line 1969

Quoted 12 lines
device-types/crypto/description.tex +12 -0
+        le64 cipher_algo;
+        le64 hmac_algo;
+        le32 aead_algo;
+        le32 max_cipher_key_len;
+        le32 max_auth_key_len;
+};
+
+struct virtio_crypto_ipsec_sa_cap_data {
+        u8 count;
+        u8 reserved[7];
+        struct virtio_crypto_ipsec_mode_cap mode[]; }; \end{lstlisting}
+

Better to name this 'mode' or as 'cap_mode'.

Quoted 23 lines

+\field{count} indicates number of valid entries in the \field{mode} array. +\field{mode[]} is an array of supported IPsec modes. Within each array entry:
+
+\field{mode} specifies the IPsec mode, as defined in table +\ref{table:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}.
+\field{max_replay_win_sz} specifies the maximum anti-replay window size the device supports.

device-types/crypto/description.tex +4 -0
+This field is applicable only for inbound operation.
+
+\field{options} Each bit indicates the IPsec protocol options supported
+by the device, as defined in table \ref{table:Device Types / Crypto Device /

Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.
+
+\field{cipher_algo} CIPHER algorithms mask, see \ref{sec:Device Types / Crypto Device / Supported crypto services / CIPHER services}.
+
+\field{hmac_algo} HMAC algorithms mask, see \ref{sec:Device Types / Crypto Device / Supported crypto services / MAC services}.
+
+\field{aead_algo} AEAD algorithms mask, see \ref{sec:Device Types / Crypto

Quoted 8 lines

Device / Supported crypto services / AEAD services}.
+
+\field{max_cipher_key_len} is the maximum length of cipher key supported by the device.
+
+\field{max_auth_key_len} is the maximum length of authenticated key supported by the device.
+

Authenticated or authentication?

#3 lore raw

RE: [PATCH RFC v3 1/4] virtio-crypto: Add IPsec service operation and Capabilities

In reply to Srujana Challa
Quoted 252 lines

-----Original Message-----
From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 7:17 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH RFC v3 1/4] virtio-crypto: Add IPsec service operation and Capabilities

This commit introduces the IPsec service operation to the Crypto device, enabling offloading of IPsec processing.

Capabilities:

1. IPsec Resource Capability (VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP):
Indicates the device's IPsec resource limits, such as the number of outbound and inbound Security Associations (SAs).
2. IPsec SA Capability (VIRTIO_CRYPTO_IPSEC_SA_CAP): Specifies the supported IPsec modes, along with the supported cryptographic algorithms, authentication algorithms, IPsec options and anti-replay window size.

---
 device-types/crypto/description.tex | 166 +++++++++++++++++++++++++++-
 introduction.tex                    |  12 ++
 2 files changed, 173 insertions(+), 5 deletions(-)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex
index 5705e26..2c00e50 100644

device-types/crypto/description.tex +0 -0
@@ -2,13 +2,15 @@ \section{Crypto Device}\label{sec:Device Types / Crypto
 Device}
 
 The virtio crypto device is a virtual cryptography device as well as a  virtual

cryptographic accelerator. The virtio crypto device provides the -following crypto
services: CIPHER, MAC, HASH, AEAD and AKCIPHER. Virtio crypto -devices have a single control queue and at least one data queue. Crypto -operation requests are placed into a data queue, and serviced by the -device. Some crypto operation requests are only valid in the context of a -session. The role of the control queue is facilitating control operation

device-types/crypto/description.tex +8 -0
+following crypto services: CIPHER, MAC, HASH, AEAD, AKCIPHER and IPSEC.
+Virtio crypto devices have a single control queue and at least one data
+queue. Crypto operation requests are placed into a data queue, and
+serviced by the device. Some crypto operation requests are only valid
+in the context of a session. The role of the control queue is
+facilitating control operation
 requests. Sessions management is realized with control operation  requests.
+The crypto device may have administration command interface through
+which IPsec service capabilities and resources are configured.
 
 \subsection{Device ID}\label{sec:Device Types / Crypto Device / Device ID}
@@ -72,6 +74,8 @@ \subsection{Supported crypto services}\label{sec:Device

Types / Crypto Device /
#define VIRTIO_CRYPTO_SERVICE_AEAD 3
/* AKCIPHER (Asymmetric Key Cipher) service */ #define
VIRTIO_CRYPTO_SERVICE_AKCIPHER 4

device-types/crypto/description.tex +2 -0
+/* IPSEC service */
+#define VIRTIO_CRYPTO_SERVICE_IPSEC  5
 \end{lstlisting}
 
 The above constants designate bits used to indicate the which of crypto services

are @@ -318,6 +322,20 @@ \subsection{Device Initialization}\label{sec:Device Types / Crypto Device / Devi \item The driver MUST read the supported algorithms based on \field{crypto_services} field.
\end{itemize*}

+\subsection{Device and driver capabilities}\label{sec:Device Types /

device-types/crypto/description.tex +9 -0
+Crypto Device / Device and driver capabilities}
+
+The crypto device has the following capabilities.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| } \hline Identifier & Name &
+Description \\ \hline \hline
+0x0800 & \hyperref[par:Device Types / Crypto Device / Device Operation
+/ IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-RESOURCE-

CAP]{VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP} &

device-types/crypto/description.tex +6 -0
+IPsec resource capability \\ \hline
+0x0801 & \hyperref[par:Device Types / Crypto Device / Device Operation
+/ IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP]{VIRTIO_CRYPTO_IPSEC_SA_CAP} & IPsec
+Security Association(SA) capability \\ \hline \end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto Device / Device

Operation}

The operation of a virtio crypto device is driven by requests placed on the
virtqueues.

device-types/crypto/description.tex +0 -0
@@ -1872,3 +1890,141 @@ \subsubsection{AKCIPHER Service

Operation}\label{sec:Device Types / Crypto Devic \item VIRTIO_CRYPTO_ERR if any failure not mentioned above occurs.
\end{itemize*}
\end{itemize*}

device-types/crypto/description.tex +11 -0
+
+\subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto
+Device / Device Operation / IPSEC Service Operation}
+
+A crypto device can support the processing of IPsec protocol operations.
+In addition to standard crypto processing, the IPsec protocol
+operations are also handled by the Crypto Device as a lookaside operation.
+
+IPsec Inbound processing: The device will perform decryption,
+authentication, integrity checking and remove additional headers,
+including tunnel header if in tunnel mode, as well as the ESP/AH header from the

packet(See \hyperref[intro:IPSEC]{IPSEC} RFC).

device-types/crypto/description.tex +14 -0
+The resulting packet contains only the plain data.
+
+IPsec Outbound processing: The device will perform encryption, attach
+ICV, update/add IP header, add ESP/AH header/trailer.
+
+A crypto device can support number of IPsec SAs, allowing it to manage
+multiple secure connections simultaneously.
+
+The device and the driver indicate IPsec SA resource limits using the
+VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability specifying the limits on
+the number of IPsec outbound and inbound SA resource objects.
+The VIRTIO_CRYPTO_IPSEC_SA_CAP capability  specifies which IPsec
+protocol capabilities the device supports. The driver indicates the
+IPsec parameters by setting the IPsec SA capability prior to adding any resource

object.

device-types/crypto/description.tex +3 -0
+
+The driver controls the IPsec SA resource object using administration
+commands described in \ref{sec:Basic Facilities of a Virtio Device / Device

groups / Group administration commands / Device resource objects}.

device-types/crypto/description.tex +11 -0
+
+\paragraph{Device and driver capabilities} \label{par:Device Types /
+Crypto Device / Device Operation / IPsec Service Operation / Device and
+driver capabilities}
+
+\subparagraph{VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-RESOURCE-CAP}
+
+The VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability indicates the IPsec SA

resource limits.
+\field{cap_specific_data} is in the format \field{struct

device-types/crypto/description.tex +12 -0
+virtio_crypto_ipsec_resource_cap}.
+
+\begin{lstlisting}
+struct virtio_crypto_ipsec_resource_cap {
+        le32 inb_sa_limit;
+        le32 outb_sa_limit;
+};
+\end{lstlisting}
+
+\field{inb_sa_limit}, and \field{outb_sa_limit} denote the maximum
+number of IPsec security Associations (SAs) that can be utilized for
+IPsec inbound and outbound processing, respectively, which the device is

capable of creating.

device-types/crypto/description.tex +10 -0
+
+\subparagraph{VIRTIO_CRYPTO_IPSEC_SA_CAP}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP}
+
+The VIRTIO_CRYPTO_IPSEC_SA_CAP capability lists the supported IPsec
+modes along with the supported cryptographic, authentication algorithms
+and anti-replay window size for each IPsec mode.
+\field{cap_specific_data} is in the format \field{struct

virtio_crypto_ipsec_sa_cap_data}.

device-types/crypto/description.tex +3 -0
+
+\begin{lstlisting}[label={lst:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-

CRYPTO-IPSEC-SA-CAP / virtio-crypto-ipsec-mode-cap}] struct virtio_crypto_ipsec_mode_cap {

device-types/crypto/description.tex +21 -0
+        u8 mode;
+        u8 reserved[3];
+        le32 max_replay_win_sz;
+        le32 options;
+        le64 cipher_algo;
+        le64 hmac_algo;
+        le32 aead_algo;
+        le32 max_cipher_key_len;
+        le32 max_auth_key_len;
+};
+
+struct virtio_crypto_ipsec_sa_cap_data {
+        u8 count;
+        u8 reserved[7];
+        struct virtio_crypto_ipsec_mode_cap mode[]; }; \end{lstlisting}
+
+\field{count} indicates number of valid entries in the \field{mode} array.
+\field{mode[]} is an array of supported IPsec modes. Within each array entry:
+
+\field{mode} specifies the IPsec mode, as defined in table
+\ref{table:Device Types / Crypto Device / Device Operation / IPsec Service

Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}.
+\field{max_replay_win_sz} specifies the maximum anti-replay window size the device supports.

device-types/crypto/description.tex +4 -0
+This field is applicable only for inbound operation.
+
+\field{options} Each bit indicates the IPsec protocol options supported
+by the device, as defined in table \ref{table:Device Types / Crypto Device /

Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.
+
+\field{cipher_algo} CIPHER algorithms mask, see \ref{sec:Device Types / Crypto Device / Supported crypto services / CIPHER services}.
+
+\field{hmac_algo} HMAC algorithms mask, see \ref{sec:Device Types / Crypto Device / Supported crypto services / MAC services}.
+
+\field{aead_algo} AEAD algorithms mask, see \ref{sec:Device Types / Crypto Device / Supported crypto services / AEAD services}.
+
+\field{max_cipher_key_len} is the maximum length of cipher key supported by the device.
+
+\field{max_auth_key_len} is the maximum length of authenticated key supported by the device.

device-types/crypto/description.tex +14 -0
+
+\begin{table}[H]
+\caption{IPsec Modes}
+\label{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes} \begin{tabularx}{\textwidth}{
+|l|X|X| } \hline Type & Name & Description \\ \hline \hline
+0x0 & - & Reserved \\
+\hline
+0x1 & VIRTIO_CRYPTO_IPSEC_MODE_ESP_TUNNEL & IPsec ESP protocol in
+tunnel mode \\ \hline
+0x2 & VIRTIO_CRYPTO_IPSEC_MODE_ESP_TRANSPORT & IPsec ESP protocol in
+transport mode \\ \hline
+0x3 & VIRTIO_CRYPTO_IPSEC_MODE_AH_TUNNEL & IPsec AH protocol in

tunnel

device-types/crypto/description.tex +5 -0
+mode \\ \hline
+0x4 & VIRTIO_CRYPTO_IPSEC_MODE_AH_TRANSPORT & IPsec AH protocol in
+transport mode \\ \hline \end{tabularx} \end{table}
+
+See \hyperref[intro:IPSEC]{IPSEC} for more information on tunnel and transport

modes in ESP/AH IPsec processing.

device-types/crypto/description.tex +11 -0
+
+\begin{table}[H]
+\caption{IPsec Options}
+\label{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}
+\begin{tabularx}{\textwidth}{ |l|X|X| } \hline Bit Number & Name &
+Description \\ \hline \hline
+0 & VIRTIO_CRYPTO_IPSEC_ESN & Specifies whether extended sequence
+number is supported, as described in \hyperref[intro:ESN]{ESN}\\ \hline
+1 & VIRTIO_CRYPTO_IPSEC_UDP_ENCAP & Specifies whether udp

encapsulation is supported, as described in

device-types/crypto/description.tex

Quoted 8 lines
device-types/crypto/description.tex +8 -0
+
+\hyperref[intro:UDP-Encapsulation]{UDP Encapsulation}, applicable only
+for ESP IPsec processing \\ \hline
+2 & VIRTIO_CRYPTO_IPSEC_COPY_DSCP & Specifies whether copy dscp is
+supported, as described in \hyperref[intro:IPSEC]{IPSEC} \\ \hline
+3 & VIRTIO_CRYPTO_IPSEC_DEC_TTL & Specifies whether decrementing the
+time to live is supported, as described in
+\hyperref[intro:IPSEC]{IPSEC} \\ \hline \end{tabularx} \end{table}

I understand that the virtio IPsec specification has a more focused scope than some other specifications. However, is there a reason why "COPY DF" and "COPY ECN" are not specified for the options above? These seem to be standard options for many implementations. Both are mentioned in RFC4301 and having a DF-bit handling option is explicitly mandated in section 8.1. The DF bit option can be written in a few different ways, sometimes as "COPY DF", sometimes as "IGNORE DF", or "SET/CLEAR DF" depending on desired behavior and default value, but using the same syntax as https://doc.dpdk.org/api/structrte__security__ipsec__sa__options.html makes sense to me. Although this is just the table for what is supported by the device it is the same values available to the SA as specified in patch 2.

Quoted 47 lines
introduction.tex +0 -0
@@ -162,6 +162,18 @@ \section{Normative References}\label{sec:Normative
 References}
      \phantomsection\label{intro:TCP-Header-Format}\textbf{[TCP Header

Format]} &
TCP Header Format

\newline\url{https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fww
w.rfc-editor.org%2frfc%2frfc9293%23name-header- format%7d%5c%5c&c=E,1,yctuJ_HPpQdfi7LKMo- AIANZtS1pBTRess9vFdl6Mu1iVKiQmcvpT9hZEWwpKUqcAnnoYj_CC6gXfefCkqJ_V t7FXU73J4BM4c1JP5bg6e5D7WHSPb7SIINNIw,,&typo=1

introduction.tex +3 -0
+     \phantomsection\label{intro:IPSEC}\textbf{[IPSEC]} &
+    IPsec Protocol
+
      \newline\url{https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fww

w.rfc-editor.org%2frfc%2frfc4301%7d%5c%5c&c=E,1,e- QdZRfZcESjhYGwp9jIvKHZ- dS1unQryxQRpW6wRd3PPJrNRzVy8yraVl6270wq4RW3up5fmoVQ4tKc-vev- XfA7XtlWMaRdeRtobBHB7sjn14,&typo=1

introduction.tex +3 -0
+     \phantomsection\label{intro:ESP}\textbf{[ESP]} &
+    IPsec ESP
+
      \newline\url{https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fww

w.rfc- editor.org%2frfc%2frfc4303%7d%5c%5c&c=E,1,sU3qAviy8vuoW9TNNIZwlEGHu M34S7rvKbpDJ4dl7489xZNlHuugvd1acq8U_YIoExhjBVyNfbgcy2EWwYktZvmiGtB 9XeZ9rQuvUbAUnnUyPnPxfBzg&typo=1

introduction.tex +3 -0
+     \phantomsection\label{intro:ESN}\textbf{[ESN]} &
+    IPsec ESN
+
      \newline\url{https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fww

w.rfc-editor.org%2frfc%2frfc4304%7d%5c%5c&c=E,1,- t8hgnMs1V4TWkJiPStGMA6duGXLRprVz_mwF7cnT1njat2PShVnYEBOpu_sg_bdvX Hxw_JQ0K6Y2iA8EMn2YG1ApNfvd2oDCLqhk0AS9VifEQI94YnA&typo=1
+ \phantomsection\label{intro:UDP-Encapsulation}\textbf{[UDP
Encapsulation]} &

introduction.tex +4 -0
+    IPsec UDP Encapsulation
+
+\newline\url{https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.rf
+c-

editor.org%2frfc%2frfc3948%7d%5c%5c&c=E,1,E8WXWFiJfT_JclVMamXhzI4JpOa +DF11dLhempOYE1__ZgfhR2n_eKPn2bXefPj1mjJcWaN5kgOidz8_q2UDqBmzPL4I UEkNotR
+NqVXiqwREmBckSLA,,&typo=1

Quoted 7 lines
      \phantomsection\label{intro:CAN}\textbf{[CAN]} &
     ISO 11898-1:2015 Road vehicles -- Controller area network (CAN) -- Part 1:
Data link layer and physical signalling\\
      \phantomsection\label{intro:rfc8174}\textbf{[RFC8174]} &

--
2.25.1

Disclaimer: This email and any files transmitted with it may contain confidential information intended for the addressee(s) only. The information is not to be surrendered or copied to unauthorized persons. If you have received this communication in error, please notify the sender immediately and delete this e-mail from your system.

#4 lore raw

RE: [PATCH RFC v3 1/4] virtio-crypto: Add IPsec service operation and Capabilities

Quoted 292 lines
Quoted 23 lines

-----Original Message-----
From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 7:17 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH RFC v3 1/4] virtio-crypto: Add IPsec service operation and Capabilities

This commit introduces the IPsec service operation to the Crypto device, enabling offloading of IPsec processing.

Capabilities:

1. IPsec Resource Capability (VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP):
Indicates the device's IPsec resource limits, such as the number of outbound and inbound Security Associations (SAs).
2. IPsec SA Capability (VIRTIO_CRYPTO_IPSEC_SA_CAP): Specifies the supported IPsec modes, along with the supported cryptographic algorithms, authentication algorithms, IPsec options and anti-replay window size.

Quoted 3 lines
---
 device-types/crypto/description.tex | 166

+++++++++++++++++++++++++++-

Quoted 42 lines
 introduction.tex                    |  12 ++
 2 files changed, 173 insertions(+), 5 deletions(-)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex index 5705e26..2c00e50 100644

device-types/crypto/description.tex +0 -0
@@ -2,13 +2,15 @@ \section{Crypto Device}\label{sec:Device Types /
 Crypto Device}
 
 The virtio crypto device is a virtual cryptography device as well as

a virtual cryptographic accelerator. The virtio crypto device provides the -following crypto
services: CIPHER, MAC, HASH, AEAD and AKCIPHER. Virtio crypto -devices have a single control queue and at least one data queue. Crypto

device-types/crypto/description.tex +0 -2
-operation requests are placed into a data queue, and serviced by the
-device. Some crypto operation requests are only valid in the context

of a -session. The role of the control queue is facilitating control operation

device-types/crypto/description.tex +8 -0
+following crypto services: CIPHER, MAC, HASH, AEAD, AKCIPHER and IPSEC.
+Virtio crypto devices have a single control queue and at least one
+data queue. Crypto operation requests are placed into a data queue,
+and serviced by the device. Some crypto operation requests are only
+valid in the context of a session. The role of the control queue is
+facilitating control operation
 requests. Sessions management is realized with control operation  requests.
+The crypto device may have administration command interface through
+which IPsec service capabilities and resources are configured.
 
 \subsection{Device ID}\label{sec:Device Types / Crypto Device /

Device ID}

device-types/crypto/description.tex +0 -0
@@ -72,6 +74,8 @@ \subsection{Supported crypto

services}\label{sec:Device Types / Crypto Device /
#define VIRTIO_CRYPTO_SERVICE_AEAD 3
/* AKCIPHER (Asymmetric Key Cipher) service */ #define
VIRTIO_CRYPTO_SERVICE_AKCIPHER 4

device-types/crypto/description.tex +2 -0
+/* IPSEC service */
+#define VIRTIO_CRYPTO_SERVICE_IPSEC  5
 \end{lstlisting}
 
 The above constants designate bits used to indicate the which of
Quoted 3 lines

crypto services are @@ -318,6 +322,20 @@ \subsection{Device Initialization}\label{sec:Device Types / Crypto Device / Devi \item The driver MUST read the supported algorithms based on

\field{crypto_services} field.

Quoted 118 lines

\end{itemize*}

+\subsection{Device and driver capabilities}\label{sec:Device Types /

device-types/crypto/description.tex +10 -0
+Crypto Device / Device and driver capabilities}
+
+The crypto device has the following capabilities.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| } \hline Identifier & Name &
+Description \\ \hline \hline
+0x0800 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Device and driver capabilities
+/
+VIRTIO-CRYPTO-IPSEC-RESOURCE-

CAP]{VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP} &

device-types/crypto/description.tex +6 -0
+IPsec resource capability \\ \hline
+0x0801 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Device and driver capabilities
+/ VIRTIO-CRYPTO-IPSEC-SA-CAP]{VIRTIO_CRYPTO_IPSEC_SA_CAP} & IPsec
+Security Association(SA) capability \\ \hline \end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto Device

/ Device Operation}

The operation of a virtio crypto device is driven by requests placed
on the virtqueues.

device-types/crypto/description.tex +0 -0
@@ -1872,3 +1890,141 @@ \subsubsection{AKCIPHER Service

Operation}\label{sec:Device Types / Crypto Devic \item VIRTIO_CRYPTO_ERR if any failure not mentioned above occurs.
\end{itemize*}
\end{itemize*}

device-types/crypto/description.tex +12 -0
+
+\subsubsection{IPSEC Service Operation}\label{sec:Device Types /
+Crypto Device / Device Operation / IPSEC Service Operation}
+
+A crypto device can support the processing of IPsec protocol operations.
+In addition to standard crypto processing, the IPsec protocol
+operations are also handled by the Crypto Device as a lookaside operation.
+
+IPsec Inbound processing: The device will perform decryption,
+authentication, integrity checking and remove additional headers,
+including tunnel header if in tunnel mode, as well as the ESP/AH
+header from the

packet(See \hyperref[intro:IPSEC]{IPSEC} RFC).

device-types/crypto/description.tex +15 -0
+The resulting packet contains only the plain data.
+
+IPsec Outbound processing: The device will perform encryption, attach
+ICV, update/add IP header, add ESP/AH header/trailer.
+
+A crypto device can support number of IPsec SAs, allowing it to
+manage multiple secure connections simultaneously.
+
+The device and the driver indicate IPsec SA resource limits using the
+VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability specifying the limits on
+the number of IPsec outbound and inbound SA resource objects.
+The VIRTIO_CRYPTO_IPSEC_SA_CAP capability  specifies which IPsec
+protocol capabilities the device supports. The driver indicates the
+IPsec parameters by setting the IPsec SA capability prior to adding
+any resource

object.

device-types/crypto/description.tex +4 -0
+
+The driver controls the IPsec SA resource object using administration
+commands described in \ref{sec:Basic Facilities of a Virtio Device /
+Device

groups / Group administration commands / Device resource objects}.

device-types/crypto/description.tex +12 -0
+
+\paragraph{Device and driver capabilities} \label{par:Device Types /
+Crypto Device / Device Operation / IPsec Service Operation / Device
+and driver capabilities}
+
+\subparagraph{VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-RESOURCE-CAP}
+
+The VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability indicates the IPsec
+SA

resource limits.
+\field{cap_specific_data} is in the format \field{struct

device-types/crypto/description.tex +13 -0
+virtio_crypto_ipsec_resource_cap}.
+
+\begin{lstlisting}
+struct virtio_crypto_ipsec_resource_cap {
+        le32 inb_sa_limit;
+        le32 outb_sa_limit;
+};
+\end{lstlisting}
+
+\field{inb_sa_limit}, and \field{outb_sa_limit} denote the maximum
+number of IPsec security Associations (SAs) that can be utilized for
+IPsec inbound and outbound processing, respectively, which the device
+is

capable of creating.

device-types/crypto/description.tex +10 -0
+
+\subparagraph{VIRTIO_CRYPTO_IPSEC_SA_CAP}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP}
+
+The VIRTIO_CRYPTO_IPSEC_SA_CAP capability lists the supported IPsec
+modes along with the supported cryptographic, authentication
+algorithms and anti-replay window size for each IPsec mode.
+\field{cap_specific_data} is in the format \field{struct

virtio_crypto_ipsec_sa_cap_data}.

device-types/crypto/description.tex +4 -0
+
+\begin{lstlisting}[label={lst:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Device and driver capabilities
+/ VIRTIO-

CRYPTO-IPSEC-SA-CAP / virtio-crypto-ipsec-mode-cap}] struct virtio_crypto_ipsec_mode_cap {

device-types/crypto/description.tex +9 -0
+        u8 mode;
+        u8 reserved[3];
+        le32 max_replay_win_sz;
+        le32 options;
+        le64 cipher_algo;
+        le64 hmac_algo;
+        le32 aead_algo;
+        le32 max_cipher_key_len;
+        le32 max_auth_key_len;

device-types/crypto/description.tex \subsubsection{AKCIPHER Service Operation}\label{sec:Device Types / Crypto Devic

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+};
+
+struct virtio_crypto_ipsec_sa_cap_data {
+        u8 count;
+        u8 reserved[7];
+        struct virtio_crypto_ipsec_mode_cap mode[]; };
+\end{lstlisting}
+
+\field{count} indicates number of valid entries in the \field{mode} array.
+\field{mode[]} is an array of supported IPsec modes. Within each array

entry:

Quoted 38 lines
device-types/crypto/description.tex +4 -0
+
+\field{mode} specifies the IPsec mode, as defined in table
+\ref{table:Device Types / Crypto Device / Device Operation / IPsec
+Service

Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}. +\field{max_replay_win_sz} specifies the maximum anti-replay window +size the
device supports.

device-types/crypto/description.tex +5 -0
+This field is applicable only for inbound operation.
+
+\field{options} Each bit indicates the IPsec protocol options
+supported by the device, as defined in table \ref{table:Device Types
+/ Crypto Device /

Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.

device-types/crypto/description.tex +3 -0
+
+\field{cipher_algo} CIPHER algorithms mask, see \ref{sec:Device Types
+/ Crypto

Device / Supported crypto services / CIPHER services}.

device-types/crypto/description.tex +3 -0
+
+\field{hmac_algo} HMAC algorithms mask, see \ref{sec:Device Types /
+Crypto

Device / Supported crypto services / MAC services}.

device-types/crypto/description.tex +3 -0
+
+\field{aead_algo} AEAD algorithms mask, see \ref{sec:Device Types /
+Crypto

Device / Supported crypto services / AEAD services}.

device-types/crypto/description.tex +3 -0
+
+\field{max_cipher_key_len} is the maximum length of cipher key
+supported by

the device.
+
+\field{max_auth_key_len} is the maximum length of authenticated key supported by the device.

device-types/crypto/description.tex +3 -0
+
+\begin{table}[H]
+\caption{IPsec Modes}

device-types/crypto/description.tex

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+\label{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}
+\begin{tabularx}{\textwidth}{
+|l|X|X| } \hline Type & Name & Description \\ \hline \hline
+0x0 & - & Reserved \\
+\hline
+0x1 & VIRTIO_CRYPTO_IPSEC_MODE_ESP_TUNNEL & IPsec ESP protocol in
+tunnel mode \\ \hline
+0x2 & VIRTIO_CRYPTO_IPSEC_MODE_ESP_TRANSPORT & IPsec ESP

protocol in

Quoted 5 lines

+transport mode \\ \hline
+0x3 & VIRTIO_CRYPTO_IPSEC_MODE_AH_TUNNEL & IPsec AH protocol in tunnel
+mode \\ \hline
+0x4 & VIRTIO_CRYPTO_IPSEC_MODE_AH_TRANSPORT & IPsec AH protocol

in

Quoted 18 lines
device-types/crypto/description.tex +4 -0
+transport mode \\ \hline \end{tabularx} \end{table}
+
+See \hyperref[intro:IPSEC]{IPSEC} for more information on tunnel and
+transport

modes in ESP/AH IPsec processing.

device-types/crypto/description.tex +12 -0
+
+\begin{table}[H]
+\caption{IPsec Options}
+\label{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}
+\begin{tabularx}{\textwidth}{ |l|X|X| } \hline Bit Number & Name &
+Description \\ \hline \hline
+0 & VIRTIO_CRYPTO_IPSEC_ESN & Specifies whether extended sequence
+number is supported, as described in \hyperref[intro:ESN]{ESN}\\
+\hline
+1 & VIRTIO_CRYPTO_IPSEC_UDP_ENCAP & Specifies whether udp

encapsulation is supported, as described in

device-types/crypto/description.tex

Quoted 8 lines
device-types/crypto/description.tex +8 -0
+
+\hyperref[intro:UDP-Encapsulation]{UDP Encapsulation}, applicable
+only for ESP IPsec processing \\ \hline
+2 & VIRTIO_CRYPTO_IPSEC_COPY_DSCP & Specifies whether copy dscp is
+supported, as described in \hyperref[intro:IPSEC]{IPSEC} \\ \hline
+3 & VIRTIO_CRYPTO_IPSEC_DEC_TTL & Specifies whether decrementing the
+time to live is supported, as described in
+\hyperref[intro:IPSEC]{IPSEC} \\ \hline \end{tabularx} \end{table}

I understand that the virtio IPsec specification has a more focused scope than some other specifications. However, is there a reason why "COPY DF" and "COPY ECN" are not specified for the options above? These seem to be standard options for many implementations. Both are mentioned in RFC4301 and having a DF-bit handling option is explicitly mandated in section 8.1. The DF bit option can be written in a few different ways, sometimes as "COPY DF", sometimes as "IGNORE DF", or "SET/CLEAR DF" depending on desired behavior and default value, but using the same syntax as

Quoted 8 lines

https://urldefense.proofpoint.com/v2/url?u=https-
3A__doc.dpdk.org_api_structrte-5F-5Fsecurity-5F-5Fipsec-5F-5Fsa-5F- 5Foptions.html&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcKFp ANhTWdwQzjT1Jpf7veC5263T47JVpnc&m=YMnMDG2jh0e7XjMN29qpCKi_ NAueHUl9FY7AfArW34hexe_sAtgVfypcyMZSHGLw&s=iFRDdg1tOZYoL6LctrU hog6ugChYCG6Fhbc7zPe3mvE&e= makes sense to me.
Although this is just the table for what is supported by the device it is the same values available to the SA as specified in patch 2.

I initially planned to introduce more options in the future. I missed that DF is a mandatory option. I will include it.

Thanks.

Quoted 125 lines
Quoted 12 lines
introduction.tex index renamed from introduction.tex +0 -0

e60298a..80aa67a 100644

introduction.tex +0 -0
@@ -162,6 +162,18 @@ \section{Normative
 References}\label{sec:Normative References}
      \phantomsection\label{intro:TCP-Header-Format}\textbf{[TCP

Header Format]} &
TCP Header Format

Quoted 2 lines

\newline\url{https://urldefense.proofpoint.com/v2/url?u=https-3A__link protect.cudasvc.com_url-3Fa-3Dhttps-253a-252f-

252fww&d=DwIFAg&c=nKjWec

Quoted 1 line

2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcKFpANhTWdwQzjT1Jpf7veC5263T47JVpn c&m=YMnMD

Quoted 1 line

G2jh0e7XjMN29qpCKi_NAueHUl9FY7AfArW34hexe_sAtgVfypcyMZSHGLw&s =UOFWBqqU

Quoted 4 lines

Xy9b49SUR0Y_QDdqC0RxUBs8NROtSokxMos&e=
w.rfc-editor.org%2frfc%2frfc9293%23name-header-
format%7d%5c%5c&c=E,1,yctuJ_HPpQdfi7LKMo-

AIANZtS1pBTRess9vFdl6Mu1iVKiQmcvpT9hZEWwpKUqcAnnoYj_CC6gXfefCk qJ_V

Quoted 7 lines

t7FXU73J4BM4c1JP5bg6e5D7WHSPb7SIINNIw,,&typo=1

introduction.tex +3 -0
+     \phantomsection\label{intro:IPSEC}\textbf{[IPSEC]} &
+    IPsec Protocol
+

\newline\url{https://urldefense.proofpoint.com/v2/url?u=https-3A__link protect.cudasvc.com_url-3Fa-3Dhttps-253a-252f-

252fww&d=DwIFAg&c=nKjWec

Quoted 1 line

2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcKFpANhTWdwQzjT1Jpf7veC5263T47JVpn c&m=YMnMD

Quoted 1 line

G2jh0e7XjMN29qpCKi_NAueHUl9FY7AfArW34hexe_sAtgVfypcyMZSHGLw&s =UOFWBqqU

Quoted 4 lines

Xy9b49SUR0Y_QDdqC0RxUBs8NROtSokxMos&e= w.rfc-editor.org%2frfc%2frfc4301%7d%5c%5c&c=E,1,e- QdZRfZcESjhYGwp9jIvKHZ- dS1unQryxQRpW6wRd3PPJrNRzVy8yraVl6270wq4RW3up5fmoVQ4tKc-

vev-

Quoted 7 lines

XfA7XtlWMaRdeRtobBHB7sjn14,&typo=1

introduction.tex +3 -0
+     \phantomsection\label{intro:ESP}\textbf{[ESP]} &
+    IPsec ESP
+

\newline\url{https://urldefense.proofpoint.com/v2/url?u=https-3A__link protect.cudasvc.com_url-3Fa-3Dhttps-253a-252f-

252fww&d=DwIFAg&c=nKjWec

Quoted 1 line

2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcKFpANhTWdwQzjT1Jpf7veC5263T47JVpn c&m=YMnMD

Quoted 1 line

G2jh0e7XjMN29qpCKi_NAueHUl9FY7AfArW34hexe_sAtgVfypcyMZSHGLw&s =UOFWBqqU

Quoted 3 lines

Xy9b49SUR0Y_QDdqC0RxUBs8NROtSokxMos&e=
w.rfc-

editor.org%2frfc%2frfc4303%7d%5c%5c&c=E,1,sU3qAviy8vuoW9TNNIZwlEG Hu

Quoted 1 line

M34S7rvKbpDJ4dl7489xZNlHuugvd1acq8U_YIoExhjBVyNfbgcy2EWwYktZvmi GtB

Quoted 7 lines

9XeZ9rQuvUbAUnnUyPnPxfBzg&typo=1

introduction.tex +3 -0
+     \phantomsection\label{intro:ESN}\textbf{[ESN]} &
+    IPsec ESN
+

\newline\url{https://urldefense.proofpoint.com/v2/url?u=https-3A__link protect.cudasvc.com_url-3Fa-3Dhttps-253a-252f-

252fww&d=DwIFAg&c=nKjWec

Quoted 1 line

2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcKFpANhTWdwQzjT1Jpf7veC5263T47JVpn c&m=YMnMD

Quoted 1 line

G2jh0e7XjMN29qpCKi_NAueHUl9FY7AfArW34hexe_sAtgVfypcyMZSHGLw&s =UOFWBqqU

Quoted 3 lines

Xy9b49SUR0Y_QDdqC0RxUBs8NROtSokxMos&e=
w.rfc-editor.org%2frfc%2frfc4304%7d%5c%5c&c=E,1,-

t8hgnMs1V4TWkJiPStGMA6duGXLRprVz_mwF7cnT1njat2PShVnYEBOpu_sg_ bdvX

introduction.tex

Quoted 7 lines

Hxw_JQ0K6Y2iA8EMn2YG1ApNfvd2oDCLqhk0AS9VifEQI94YnA&typo=1
+ \phantomsection\label{intro:UDP-Encapsulation}\textbf{[UDP
Encapsulation]} &

introduction.tex +4 -0
+    IPsec UDP Encapsulation
+
+\newline\url{https://urldefense.proofpoint.com/v2/url?u=https-3A__lin
+kprotect.cudasvc.com_url-3Fa-3Dhttps-253a-252f-

252fwww.rf&d=DwIFAg&c=

Quoted 1 line

+nKjWec2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcKFpANhTWdwQzjT1Jpf7veC5263 T47JVpnc&

Quoted 1 line

+m=YMnMDG2jh0e7XjMN29qpCKi_NAueHUl9FY7AfArW34hexe_sAtgVfypcy MZSHGLw&s=

introduction.tex

Quoted 3 lines
introduction.tex +2 -0
+Z-1fKjgyS6ihHsL68Y7mh-cXXoM6D19F5pOwafWzkA4&e=
+c-

editor.org%2frfc%2frfc3948%7d%5c%5c&c=E,1,E8WXWFiJfT_JclVMamXhzI4J pOa

Quoted 1 line

+DF11dLhempOYE1__ZgfhR2n_eKPn2bXefPj1mjJcWaN5kgOidz8_q2UDqBmz PL4I

Quoted 4 lines

UEkNotR
+NqVXiqwREmBckSLA,,&typo=1

      \phantomsection\label{intro:CAN}\textbf{[CAN]} &
     ISO 11898-1:2015 Road vehicles -- Controller area network (CAN) -- Part

1:

Quoted 5 lines

Data link layer and physical signalling\\

      \phantomsection\label{intro:rfc8174}\textbf{[RFC8174]} &

--
2.25.1

Disclaimer: This email and any files transmitted with it may contain confidential information intended for the addressee(s) only. The information is not to be surrendered or copied to unauthorized persons. If you have received this communication in error, please notify the sender immediately and delete this e-mail from your system.

#5 lore raw

RFC PATCH v3 2/4 virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

In reply to Srujana Challa

This commit introduces resource objects to enable the driver/device to create IPsec Security Associations (SAs) for both inbound and outbound directions.

The IPsec SA objects include essential parameters required for packet outbound and inbound processing, such as SPI, tunnel headers, IPsec mode, IPsec options and cipher/authentication specific data.

---
 device-types/crypto/description.tex | 145 ++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
device-types/crypto/description.tex +145 -0
index 2c00e50..0ba09df 100644
@@ -336,6 +336,20 @@ \subsection{Device and driver capabilities}\label{sec:Device Types / Crypto Devi
 \hline
 \end{tabularx}
 
+\subsection{Device resource objects}\label{sec:Device Types / Crypto Device / Device resource objects}
+
+The crypto device has the following resource objects.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| }
+\hline
+type & Name & Description \\
+\hline \hline
+0x0200 & \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA]{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA} & IPsec outbound SA resource object \\
+\hline
+0x0201 & \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA]{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA} & IPsec inbound SA resource object \\
+\hline
+\end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto Device / Device Operation}
 
 The operation of a virtio crypto device is driven by requests placed on the virtqueues.
@@ -2028,3 +2042,134 @@ \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device /
 \hline
 \end{tabularx}
 \end{table}
+
+\paragraph{Resource objects}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects}
+
+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA}\label{par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA}
+
+A driver can have outbound SAs between 0 and \field{outb_sa_limit}, as specified by the
+capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For the IPsec outbound SA resource object
+\field{resource_obj_specific_data} is in the format
+\field{struct virtio_crypto_resource_obj_ipsec_sa}.
+
+\begin{lstlisting}
+struct in_addr {
+        le32 s_addr;
+};
+
+struct in6_addr {
+        union {
+                u8  S6_u8[16];
+                le32 S6_u32[4];
+                le64 S6_u64[2];
+        } S6_un;
+};
+
+struct virtio_crypto_ipsec_tunnel_param {
+        /* Tunnel type: IPv4 or IPv6 */
+        u8 type;
+        u8 reserved[3];
+        union {
+                /* IPv4 tunnel header parameters */
+                struct {
+                        /* IPv4 source address */
+                        struct in_addr src_ip;
+                        /* IPv4 destination address */
+                        struct in_addr dst_ip;
+                        /* IPv4 Differentiated Services Code Point */
+                        u8 dscp;
+                        /* IPv4 Don't Fragment bit */
+                        u8 df;
+                        /* IPv4 Time To Live */
+                        u8 ttl;
+                } ipv4;
+                /* IPv6 tunnel header parameters */
+                struct {
+                        /* IPv6 source address */
+                        struct in6_addr src_addr;
+                        /* IPv6 destination address */
+                        struct in6_addr dst_addr;
+                        /* IPv6 flow label */
+                        le32 flabel;
+                        /* IPv6 hop limit */
+                        u8 hlimit;
+                        /* IPv6 Differentiated Services Code Point */
+                        u8 dscp;
+                } ipv6;
+        };
+};
+
+struct virtio_crypto_resource_obj_ipsec_sa {
+        le32 spi;
+        le32 salt;
+        le64 options;
+        struct virtio_crypto_ipsec_tunnel_param param;
+        le64 esn;
+        le16 udp_sport;
+        le16 udp_dport;
+        le32 replay_win_sz;
+        le64 cipher_algo;
+        struct {
+            le16 length;
+            u8 data[];
+        } cipher_key;
+        le64 auth_algo;
+        struct {
+            le16 length;
+            u8 data[];
+        } auth_key;
+        le32 obj_id;
+        u8 mode;
+        u8 direction;
+}
+\end{lstlisting}
+
+\field{spi} is the Security Parameter Index(SPI) used to uniquely identify the IPsec SA.
+\field{salt} is the 32 bit salt value used in the cryptographic operations. 
+
+\field{options} specifies the Options for configuring the IPsec SA, see
+\ref{table:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.
+
+\field{param} specifies the parameters for IPsec tunnel mode.
+\field{esn} is the starting sequence number.
+\field{udp_sport} is the source port for UDP encapsulation. \field{udp_dport} is the
+destination port for UDP encapsulation.
+\field{replay_win_sz} is the anti-replay window size to enable sequence replay attack
+handling, replay checking is disabled if the window size is 0.
+
+\field{cipher_algo} is the cipher algorithm identifier
+see \ref{sec:Device Types / Crypto Device / Supported crypto services  / CIPHER services}
+\field{cipher_key} specifies the cipher key and its length.
+\field{auth_algo} is the Authentication algorithm identifier
+\field{auth_key} specifies the authentication key data and its length.
+\field{obj_id} specifies the object id of the SA that can be used to retrieve
+driver-defined data associated with the IPsec SA.
+
+\field{mode} specifies the mode of the IPsec SA, see
+\ref{table:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}.
+
+\field{direction} specifies IPsec SA direction.
+
+\begin{table}[H]
+\caption{IPsec Direction}
+\label{table:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA / IPsec Direction}
+\begin{tabularx}{\textwidth}{ |l|X|X| }
+\hline
+Type & Name & Description \\
+\hline \hline
+0x0 & - & Reserved \\
+\hline
+0x1 & VIRTIO_CRYPTO_IPSEC_DIR_OUTBOUND & IPsec direction outbound \\
+\hline
+0x2 & VIRTIO_CRYPTO_IPSEC_DIR_INBOUND & IPsec direction inbound \\
+\hline
+\end{tabularx}
+\end{table}
+
+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA}\label{par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA}
+
+A driver can have inbound SAs between 0 and \field{inb_sa_limit}, as specified by the
+capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For the IPsec inbound SA resource object
+\field{resource_obj_specific_data} is in the format
+\field{struct virtio_crypto_resource_obj_ipsec_sa}.
Signature · 1 line
2.25.1
#6 lore raw

RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

Quoted 72 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:47 AM

This commit introduces resource objects to enable the driver/device to create IPsec Security Associations (SAs) for both inbound and outbound directions.

The IPsec SA objects include essential parameters required for packet outbound and inbound processing, such as SPI, tunnel headers, IPsec mode, IPsec options and cipher/authentication specific data.

---
 device-types/crypto/description.tex | 145
++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex
index 2c00e50..0ba09df 100644

device-types/crypto/description.tex +10 -0
@@ -336,6 +336,20 @@ \subsection{Device and driver
 capabilities}\label{sec:Device Types / Crypto Devi  \hline  \end{tabularx}
 
+\subsection{Device resource objects}\label{sec:Device Types / Crypto
+Device / Device resource objects}
+
+The crypto device has the following resource objects.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| } \hline type & Name &
+Description \\ \hline \hline
+0x0200 & \hyperref[par:Device Types / Crypto Device / Device Operation
+/ IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OB

device-types/crypto/description.tex +4 -0
+J_IPSEC_OUTBOUND_SA} & IPsec outbound SA resource object \\ \hline
+0x0201 & \hyperref[par:Device Types / Crypto Device / Device Operation
+/ IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OBJ

device-types/crypto/description.tex +3 -0
+_IPSEC_INBOUND_SA} & IPsec inbound SA resource object \\ \hline
+\end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto Device /

Device Operation}

The operation of a virtio crypto device is driven by requests placed on the
virtqueues.

device-types/crypto/description.tex +6 -0
@@ -2028,3 +2042,134 @@ \subsubsection{IPSEC Service
 Operation}\label{sec:Device Types / Crypto Device /  \hline  \end{tabularx}
 \end{table}
+
+\paragraph{Resource objects}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Resource objects}
+
+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA}\lab

el{par:D

device-types/crypto/description.tex +12 -0
+evice Types / Crypto Device / Device Operation / IPsec Service
+Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA}
+
+A driver can have outbound SAs between 0 and \field{outb_sa_limit}, as
+specified by the capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For the
+IPsec outbound SA resource object \field{resource_obj_specific_data} is
+in the format \field{struct virtio_crypto_resource_obj_ipsec_sa}.
+
+\begin{lstlisting}
+struct in_addr {
+        le32 s_addr;

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2068

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+};
+
+struct in6_addr {
+        union {
+                u8  S6_u8[16];
+                le32 S6_u32[4];
+                le64 S6_u64[2];
+        } S6_un;
+};
+

Any reason for union? Can we just have s6_u8?
(s6 in small).

Quoted 7 lines
device-types/crypto/description.tex +7 -0
+struct virtio_crypto_ipsec_tunnel_param {
+        /* Tunnel type: IPv4 or IPv6 */
+        u8 type;
+        u8 reserved[3];
+        union {
+                /* IPv4 tunnel header parameters */
+                struct {

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2085

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+                        /* IPv4 source address */
+                        struct in_addr src_ip;
+                        /* IPv4 destination address */
+                        struct in_addr dst_ip;
+                        /* IPv4 Differentiated Services Code Point */
+                        u8 dscp;
+                        /* IPv4 Don't Fragment bit */
+                        u8 df;
+                        /* IPv4 Time To Live */
+                        u8 ttl;

Please add padding bytes to align to 32-bit.

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2098

Quoted 13 lines
device-types/crypto/description.tex +13 -0
+                } ipv4;
+                /* IPv6 tunnel header parameters */
+                struct {
+                        /* IPv6 source address */
+                        struct in6_addr src_addr;
+                        /* IPv6 destination address */
+                        struct in6_addr dst_addr;
+                        /* IPv6 flow label */
+                        le32 flabel;
+                        /* IPv6 hop limit */
+                        u8 hlimit;
+                        /* IPv6 Differentiated Services Code Point */
+                        u8 dscp;

This one too. Please check in both the series, vnet ipsec and this one.

Quoted 13 lines
device-types/crypto/description.tex +13 -0
+                } ipv6;
+        };
+};
+
+struct virtio_crypto_resource_obj_ipsec_sa {
+        le32 spi;
+        le32 salt;
+        le64 options;
+        struct virtio_crypto_ipsec_tunnel_param param;
+        le64 esn;
+        le16 udp_sport;
+        le16 udp_dport;
+        le32 replay_win_sz;

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2121

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+        le64 cipher_algo;
+        struct {
+            le16 length;
+            u8 data[];
+        } cipher_key;
+        le64 auth_algo;
+        struct {
+            le16 length;
+            u8 data[];
+        } auth_key;

Two dynamic arrays in one is problematic.
And below fields can never be referenced without learning the length of auth_key and cipher_key. Below are critical fields to access the whole rest of the object.
So please move them at start.

Also can we have above two dynamic array as constant size array, instead of dynamic?

Quoted 62 lines
device-types/crypto/description.tex +7 -0
+        le32 obj_id;
+        u8 mode;
+        u8 direction;
+}
+\end{lstlisting}
+
+\field{spi} is the Security Parameter Index(SPI) used to uniquely identify the

IPsec SA.
+\field{salt} is the 32 bit salt value used in the cryptographic operations. +
+\field{options} specifies the Options for configuring the IPsec SA, see +\ref{table:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.

device-types/crypto/description.tex +18 -0
+
+\field{param} specifies the parameters for IPsec tunnel mode.
+\field{esn} is the starting sequence number.
+\field{udp_sport} is the source port for UDP encapsulation.
+\field{udp_dport} is the destination port for UDP encapsulation.
+\field{replay_win_sz} is the anti-replay window size to enable sequence
+replay attack handling, replay checking is disabled if the window size is 0.
+
+\field{cipher_algo} is the cipher algorithm identifier see
+\ref{sec:Device Types / Crypto Device / Supported crypto services  /
+CIPHER services} \field{cipher_key} specifies the cipher key and its length.
+\field{auth_algo} is the Authentication algorithm identifier
+\field{auth_key} specifies the authentication key data and its length.
+\field{obj_id} specifies the object id of the SA that can be used to
+retrieve driver-defined data associated with the IPsec SA.
+
+\field{mode} specifies the mode of the IPsec SA, see \ref{table:Device
+Types / Crypto Device / Device Operation / IPsec Service Operation / Device

and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}.

device-types/crypto/description.tex +13 -0
+
+\field{direction} specifies IPsec SA direction.
+
+\begin{table}[H]
+\caption{IPsec Direction}
+\label{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA / IPsec Direction}
+\begin{tabularx}{\textwidth}{ |l|X|X| } \hline Type & Name &
+Description \\ \hline \hline
+0x0 & - & Reserved \\
+\hline
+0x1 & VIRTIO_CRYPTO_IPSEC_DIR_OUTBOUND & IPsec direction outbound

\\
+\hline
+0x2 & VIRTIO_CRYPTO_IPSEC_DIR_INBOUND & IPsec direction inbound \\
+\hline \end{tabularx} \end{table}
+ +\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA}\label {par:De

device-types/crypto/description.tex +7 -1
+vice Types / Crypto Device / Device Operation / IPsec Service Operation
+/ Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA}
+
+A driver can have inbound SAs between 0 and \field{inb_sa_limit}, as
+specified by the capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For the
+IPsec inbound SA resource object \field{resource_obj_specific_data} is
+in the format \field{struct virtio_crypto_resource_obj_ipsec_sa}.
--

2.25.1

#7 lore raw

RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

Quoted 162 lines

-----Original Message-----
From: Parav Pandit <[email protected]>
Sent: Monday, February 10, 2025 8:47 PM
To: Srujana Challa <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

Quoted 5 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:47 AM

This commit introduces resource objects to enable the driver/device to create IPsec Security Associations (SAs) for both inbound and outbound

directions.

Quoted 47 lines

The IPsec SA objects include essential parameters required for packet outbound and inbound processing, such as SPI, tunnel headers, IPsec mode, IPsec options and cipher/authentication specific data.

---
 device-types/crypto/description.tex | 145
++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex index 2c00e50..0ba09df 100644

device-types/crypto/description.tex +0 -0
@@ -336,6 +336,20 @@ \subsection{Device and driver

capabilities}\label{sec:Device Types / Crypto Devi \hline \end{tabularx}

+\subsection{Device resource objects}\label{sec:Device Types / Crypto

device-types/crypto/description.tex +9 -0
+Device / Device resource objects}
+
+The crypto device has the following resource objects.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| } \hline type & Name &
+Description \\ \hline \hline
+0x0200 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OB

device-types/crypto/description.tex +4 -0
+J_IPSEC_OUTBOUND_SA} & IPsec outbound SA resource object \\ \hline
+0x0201 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OBJ

device-types/crypto/description.tex +3 -0
+_IPSEC_INBOUND_SA} & IPsec inbound SA resource object \\ \hline
+\end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto Device

/ Device Operation}

The operation of a virtio crypto device is driven by requests placed
on the virtqueues.

device-types/crypto/description.tex +0 -0
@@ -2028,3 +2042,134 @@ \subsubsection{IPSEC Service

Operation}\label{sec:Device Types / Crypto Device / \hline \end{tabularx} \end{table}

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2048

Quoted 5 lines
device-types/crypto/description.tex +5 -0
+
+\paragraph{Resource objects}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Resource objects}
+

+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA}\lab

device-types/crypto/description.tex

Quoted 9 lines

el{par:D

device-types/crypto/description.tex +8 -0
+evice Types / Crypto Device / Device Operation / IPsec Service
+Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA}
+
+A driver can have outbound SAs between 0 and \field{outb_sa_limit},
+as specified by the capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For
+the IPsec outbound SA resource object
+\field{resource_obj_specific_data} is in the format \field{struct

virtio_crypto_resource_obj_ipsec_sa}.

Quoted 4 lines
device-types/crypto/description.tex +4 -0
+
+\begin{lstlisting}
+struct in_addr {
+        le32 s_addr;

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2068

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+};
+
+struct in6_addr {
+        union {
+                u8  S6_u8[16];
+                le32 S6_u32[4];
+                le64 S6_u64[2];
+        } S6_un;
+};
+

Any reason for union? Can we just have s6_u8?
(s6 in small).

Quoted 7 lines
device-types/crypto/description.tex +7 -0
+struct virtio_crypto_ipsec_tunnel_param {
+        /* Tunnel type: IPv4 or IPv6 */
+        u8 type;
+        u8 reserved[3];
+        union {
+                /* IPv4 tunnel header parameters */
+                struct {

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2085

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+                        /* IPv4 source address */
+                        struct in_addr src_ip;
+                        /* IPv4 destination address */
+                        struct in_addr dst_ip;
+                        /* IPv4 Differentiated Services Code Point */
+                        u8 dscp;
+                        /* IPv4 Don't Fragment bit */
+                        u8 df;
+                        /* IPv4 Time To Live */
+                        u8 ttl;

Please add padding bytes to align to 32-bit.

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2098

Quoted 13 lines
device-types/crypto/description.tex +13 -0
+                } ipv4;
+                /* IPv6 tunnel header parameters */
+                struct {
+                        /* IPv6 source address */
+                        struct in6_addr src_addr;
+                        /* IPv6 destination address */
+                        struct in6_addr dst_addr;
+                        /* IPv6 flow label */
+                        le32 flabel;
+                        /* IPv6 hop limit */
+                        u8 hlimit;
+                        /* IPv6 Differentiated Services Code Point */
+                        u8 dscp;

This one too. Please check in both the series, vnet ipsec and this one.

Quoted 13 lines
device-types/crypto/description.tex +13 -0
+                } ipv6;
+        };
+};
+
+struct virtio_crypto_resource_obj_ipsec_sa {
+        le32 spi;
+        le32 salt;
+        le64 options;
+        struct virtio_crypto_ipsec_tunnel_param param;
+        le64 esn;
+        le16 udp_sport;
+        le16 udp_dport;
+        le32 replay_win_sz;

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2121

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+        le64 cipher_algo;
+        struct {
+            le16 length;
+            u8 data[];
+        } cipher_key;
+        le64 auth_algo;
+        struct {
+            le16 length;
+            u8 data[];
+        } auth_key;

Two dynamic arrays in one is problematic.
And below fields can never be referenced without learning the length of auth_key and cipher_key.
Below are critical fields to access the whole rest of the object. So please move them at start.

Quoted 8 lines

Also can we have above two dynamic array as constant size array, instead of dynamic?

Quoted 5 lines
device-types/crypto/description.tex +5 -0
+        le32 obj_id;
+        u8 mode;
+        u8 direction;
+}
+\end{lstlisting}

Have you considered having a lifetime entry in struct virtio_crypto_resource_obj_ipsec_sa? Compare for example with https://doc.dpdk.org/api/structrte__security__ipsec__xform.html. I realize it may be handled by the application doing the SA configuration to keep track of this, but could it be considered to include it in the specification since having a hard cap on the key usage is such an important part of the IPsec concept?

Quoted 54 lines
Quoted 11 lines
device-types/crypto/description.tex +3 -0
+
+\field{spi} is the Security Parameter Index(SPI) used to uniquely
+identify the

IPsec SA.
+\field{salt} is the 32 bit salt value used in the cryptographic operations.

device-types/crypto/description.tex +4 -0
+
+\field{options} specifies the Options for configuring the IPsec SA,
+see \ref{table:Device Types / Crypto Device / Device Operation /
+IPsec Service

Operation / Device and driver capabilities /
VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.

device-types/crypto/description.tex

Quoted 7 lines
device-types/crypto/description.tex +7 -0
+
+\field{param} specifies the parameters for IPsec tunnel mode.
+\field{esn} is the starting sequence number.
+\field{udp_sport} is the source port for UDP encapsulation.
+\field{udp_dport} is the destination port for UDP encapsulation.
+\field{replay_win_sz} is the anti-replay window size to enable
+sequence replay attack handling, replay checking is disabled if the window size

is 0.

Quoted 35 lines
device-types/crypto/description.tex +12 -0
+
+\field{cipher_algo} is the cipher algorithm identifier see
+\ref{sec:Device Types / Crypto Device / Supported crypto services  /
+CIPHER services} \field{cipher_key} specifies the cipher key and its length.
+\field{auth_algo} is the Authentication algorithm identifier
+\field{auth_key} specifies the authentication key data and its length.
+\field{obj_id} specifies the object id of the SA that can be used to
+retrieve driver-defined data associated with the IPsec SA.
+
+\field{mode} specifies the mode of the IPsec SA, see
+\ref{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device

and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}.

device-types/crypto/description.tex +13 -0
+
+\field{direction} specifies IPsec SA direction.
+
+\begin{table}[H]
+\caption{IPsec Direction}
+\label{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA / IPsec Direction}
+\begin{tabularx}{\textwidth}{ |l|X|X| } \hline Type & Name &
+Description \\ \hline \hline
+0x0 & - & Reserved \\
+\hline
+0x1 & VIRTIO_CRYPTO_IPSEC_DIR_OUTBOUND & IPsec direction outbound

\\
+\hline
+0x2 & VIRTIO_CRYPTO_IPSEC_DIR_INBOUND & IPsec direction inbound \\
+\hline \end{tabularx} \end{table}
+ +\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA}\label {par:De

device-types/crypto/description.tex +2 -0
+vice Types / Crypto Device / Device Operation / IPsec Service
+Operation / Resource objects /
Quoted 9 lines
Quoted 8 lines
device-types/crypto/description.tex +6 -1
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA}
+
+A driver can have inbound SAs between 0 and \field{inb_sa_limit}, as
+specified by the capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For the
+IPsec inbound SA resource object \field{resource_obj_specific_data}
+is in the format \field{struct virtio_crypto_resource_obj_ipsec_sa}.
--

2.25.1

Disclaimer: This email and any files transmitted with it may contain confidential information intended for the addressee(s) only. The information is not to be surrendered or copied to unauthorized persons. If you have received this communication in error, please notify the sender immediately and delete this e-mail from your system.

#8 lore raw

RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

In reply to Parav Pandit
Quoted 80 lines

Subject: [EXTERNAL] RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

Quoted 7 lines

From: Srujana Challa <schalla@ marvell. com> > Sent: Wednesday, January 22, 2025 11: 47 AM > > This commit introduces resource objects to enable the driver/device to create > IPsec Security Associations (SAs) for both inbound

Quoted 5 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:47 AM

This commit introduces resource objects to enable the driver/device to create IPsec Security Associations (SAs) for both inbound and outbound

directions.

Quoted 47 lines

The IPsec SA objects include essential parameters required for packet outbound and inbound processing, such as SPI, tunnel headers, IPsec mode, IPsec options and cipher/authentication specific data.

---
 device-types/crypto/description.tex | 145
++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex index 2c00e50..0ba09df 100644

device-types/crypto/description.tex +0 -0
@@ -336,6 +336,20 @@ \subsection{Device and driver

capabilities}\label{sec:Device Types / Crypto Devi \hline \end{tabularx}

+\subsection{Device resource objects}\label{sec:Device Types / Crypto

device-types/crypto/description.tex +9 -0
+Device / Device resource objects}
+
+The crypto device has the following resource objects.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| } \hline type & Name &
+Description \\ \hline \hline
+0x0200 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OB

device-types/crypto/description.tex +4 -0
+J_IPSEC_OUTBOUND_SA} & IPsec outbound SA resource object \\ \hline
+0x0201 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OBJ

device-types/crypto/description.tex +3 -0
+_IPSEC_INBOUND_SA} & IPsec inbound SA resource object \\ \hline
+\end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto Device

/ Device Operation}

The operation of a virtio crypto device is driven by requests placed
on the virtqueues.

device-types/crypto/description.tex +0 -0
@@ -2028,3 +2042,134 @@ \subsubsection{IPSEC Service

Operation}\label{sec:Device Types / Crypto Device / \hline \end{tabularx} \end{table}

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2048

Quoted 5 lines
device-types/crypto/description.tex +5 -0
+
+\paragraph{Resource objects}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Resource objects}
+

+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA}\la b

device-types/crypto/description.tex

Quoted 9 lines

el{par:D

device-types/crypto/description.tex +8 -0
+evice Types / Crypto Device / Device Operation / IPsec Service
+Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA}
+
+A driver can have outbound SAs between 0 and \field{outb_sa_limit},
+as specified by the capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For
+the IPsec outbound SA resource object
+\field{resource_obj_specific_data} is in the format \field{struct

virtio_crypto_resource_obj_ipsec_sa}.

Quoted 16 lines
Quoted 4 lines
device-types/crypto/description.tex +4 -0
+
+\begin{lstlisting}
+struct in_addr {
+        le32 s_addr;

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2068

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+};
+
+struct in6_addr {
+        union {
+                u8  S6_u8[16];
+                le32 S6_u32[4];
+                le64 S6_u64[2];
+        } S6_un;
+};
+

Any reason for union? Can we just have s6_u8?
(s6 in small).

I have copied from the RFC. Will change it or can we add reference to the RFC for these structures instead of defining here?

Quoted 18 lines
Quoted 8 lines
device-types/crypto/description.tex +7 -0
+struct virtio_crypto_ipsec_tunnel_param {
+        /* Tunnel type: IPv4 or IPv6 */
+        u8 type;
+        u8 reserved[3];
+        union {
+                /* IPv4 tunnel header parameters */
+                struct {

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2085

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+                        /* IPv4 source address */
+                        struct in_addr src_ip;
+                        /* IPv4 destination address */
+                        struct in_addr dst_ip;
+                        /* IPv4 Differentiated Services Code Point */
+                        u8 dscp;
+                        /* IPv4 Don't Fragment bit */
+                        u8 df;
+                        /* IPv4 Time To Live */
+                        u8 ttl;
Quoted 1 line

Please add padding bytes to align to 32-bit.

Will do.

Quoted 13 lines

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2098

Quoted 13 lines
device-types/crypto/description.tex +13 -0
+                } ipv4;
+                /* IPv6 tunnel header parameters */
+                struct {
+                        /* IPv6 source address */
+                        struct in6_addr src_addr;
+                        /* IPv6 destination address */
+                        struct in6_addr dst_addr;
+                        /* IPv6 flow label */
+                        le32 flabel;
+                        /* IPv6 hop limit */
+                        u8 hlimit;
+                        /* IPv6 Differentiated Services Code Point */
+                        u8 dscp;
Quoted 1 line

This one too. Please check in both the series, vnet ipsec and this one.

Will do.

Quoted 21 lines
Quoted 21 lines
device-types/crypto/description.tex +20 -0
+                } ipv6;
+        };
+};
+
+struct virtio_crypto_resource_obj_ipsec_sa {
+        le32 spi;
+        le32 salt;
+        le64 options;
+        struct virtio_crypto_ipsec_tunnel_param param;
+        le64 esn;
+        le16 udp_sport;
+        le16 udp_dport;
+        le32 replay_win_sz;
+        le64 cipher_algo;
+        struct {
+            le16 length;
+            u8 data[];
+        } cipher_key;
+        le64 auth_algo;
+        struct {
Quoted 8 lines

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2121

Quoted 3 lines
device-types/crypto/description.tex +3 -0
+            le16 length;
+            u8 data[];
+        } auth_key;

Two dynamic arrays in one is problematic.
And below fields can never be referenced without learning the length of auth_key and cipher_key.
Below are critical fields to access the whole rest of the object. So please move them at start.

Will do.

Quoted 3 lines

Also can we have above two dynamic array as constant size array, instead of dynamic?

We would like to make it a single dynamic array. Have both lengths auth_key_len and cipher_key_len at the end followed by data[] array. The first x(auth_key_len) bytes represents the auth_key and next y(cipher_key_len) bytes represents the cipher key.
Could you confirm if this approach is fine?

Quoted 70 lines
Quoted 17 lines
device-types/crypto/description.tex +8 -0
+        le32 obj_id;
+        u8 mode;
+        u8 direction;
+}
+\end{lstlisting}
+
+\field{spi} is the Security Parameter Index(SPI) used to uniquely
+identify the

IPsec SA.
+\field{salt} is the 32 bit salt value used in the cryptographic operations.

device-types/crypto/description.tex +4 -0
+
+\field{options} specifies the Options for configuring the IPsec SA,
+see \ref{table:Device Types / Crypto Device / Device Operation /
+IPsec Service

Operation / Device and driver capabilities /
VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.

device-types/crypto/description.tex

Quoted 7 lines
device-types/crypto/description.tex +7 -0
+
+\field{param} specifies the parameters for IPsec tunnel mode.
+\field{esn} is the starting sequence number.
+\field{udp_sport} is the source port for UDP encapsulation.
+\field{udp_dport} is the destination port for UDP encapsulation.
+\field{replay_win_sz} is the anti-replay window size to enable
+sequence replay attack handling, replay checking is disabled if the window

size is 0.

Quoted 26 lines
device-types/crypto/description.tex +12 -0
+
+\field{cipher_algo} is the cipher algorithm identifier see
+\ref{sec:Device Types / Crypto Device / Supported crypto services  /
+CIPHER services} \field{cipher_key} specifies the cipher key and its length.
+\field{auth_algo} is the Authentication algorithm identifier
+\field{auth_key} specifies the authentication key data and its length.
+\field{obj_id} specifies the object id of the SA that can be used to
+retrieve driver-defined data associated with the IPsec SA.
+
+\field{mode} specifies the mode of the IPsec SA, see
+\ref{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device

and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}.

device-types/crypto/description.tex +13 -0
+
+\field{direction} specifies IPsec SA direction.
+
+\begin{table}[H]
+\caption{IPsec Direction}
+\label{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA / IPsec Direction}
+\begin{tabularx}{\textwidth}{ |l|X|X| } \hline Type & Name &
+Description \\ \hline \hline
+0x0 & - & Reserved \\
+\hline
+0x1 & VIRTIO_CRYPTO_IPSEC_DIR_OUTBOUND & IPsec direction outbound
Quoted 6 lines

\\
+\hline
+0x2 & VIRTIO_CRYPTO_IPSEC_DIR_INBOUND & IPsec direction inbound \\
+\hline \end{tabularx} \end{table}
+

+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA}\labe l

Quoted 11 lines

{par:De

device-types/crypto/description.tex +8 -1
+vice Types / Crypto Device / Device Operation / IPsec Service
+Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA}
+
+A driver can have inbound SAs between 0 and \field{inb_sa_limit}, as
+specified by the capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For the
+IPsec inbound SA resource object \field{resource_obj_specific_data}
+is in the format \field{struct virtio_crypto_resource_obj_ipsec_sa}.
--

2.25.1

#9 lore raw

RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

Quoted 172 lines

From: Srujana Challa <[email protected]>
Sent: Thursday, February 13, 2025 8:06 PM

Quoted 59 lines

Subject: [EXTERNAL] RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

Quoted 8 lines

From: Srujana Challa <schalla@ marvell. com> > Sent: Wednesday, January 22, 2025 11: 47 AM > > This commit introduces resource objects to enable the driver/device to create > IPsec Security Associations
(SAs) for both inbound

Quoted 6 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:47 AM

This commit introduces resource objects to enable the driver/device to create IPsec Security Associations (SAs) for both inbound and outbound

directions.

Quoted 41 lines

The IPsec SA objects include essential parameters required for packet outbound and inbound processing, such as SPI, tunnel headers, IPsec mode, IPsec options and cipher/authentication specific data.

---
 device-types/crypto/description.tex | 145
++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex index 2c00e50..0ba09df 100644

device-types/crypto/description.tex +0 -0
@@ -336,6 +336,20 @@ \subsection{Device and driver

capabilities}\label{sec:Device Types / Crypto Devi \hline \end{tabularx}

+\subsection{Device resource objects}\label{sec:Device Types /

device-types/crypto/description.tex +9 -0
+Crypto Device / Device resource objects}
+
+The crypto device has the following resource objects.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| } \hline type & Name &
+Description \\ \hline \hline
+0x0200 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OB

device-types/crypto/description.tex +4 -0
+J_IPSEC_OUTBOUND_SA} & IPsec outbound SA resource object \\ \hline
+0x0201 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OBJ

device-types/crypto/description.tex +3 -0
+_IPSEC_INBOUND_SA} & IPsec inbound SA resource object \\ \hline
+\end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto

Device / Device Operation}

Quoted 12 lines

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2048

Quoted 11 lines

The operation of a virtio crypto device is driven by requests
placed on the virtqueues.

device-types/crypto/description.tex +0 -0
@@ -2028,3 +2042,134 @@ \subsubsection{IPSEC Service

Operation}\label{sec:Device Types / Crypto Device / \hline \end{tabularx} \end{table}

device-types/crypto/description.tex +5 -0
+
+\paragraph{Resource objects}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Resource objects}
+

+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA}\la

Quoted 11 lines

b

device-types/crypto/description.tex

Quoted 9 lines

el{par:D

device-types/crypto/description.tex +8 -0
+evice Types / Crypto Device / Device Operation / IPsec Service
+Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA}
+
+A driver can have outbound SAs between 0 and \field{outb_sa_limit},
+as specified by the capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP.
+For the IPsec outbound SA resource object
+\field{resource_obj_specific_data} is in the format \field{struct

virtio_crypto_resource_obj_ipsec_sa}.

Quoted 16 lines
Quoted 4 lines
device-types/crypto/description.tex +4 -0
+
+\begin{lstlisting}
+struct in_addr {
+        le32 s_addr;

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2068

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+};
+
+struct in6_addr {
+        union {
+                u8  S6_u8[16];
+                le32 S6_u32[4];
+                le64 S6_u64[2];
+        } S6_un;
+};
+

Any reason for union? Can we just have s6_u8?
(s6 in small).

I have copied from the RFC. Will change it or can we add reference to the RFC for these structures instead of defining here?

Quoted 18 lines
Quoted 8 lines
device-types/crypto/description.tex +7 -0
+struct virtio_crypto_ipsec_tunnel_param {
+        /* Tunnel type: IPv4 or IPv6 */
+        u8 type;
+        u8 reserved[3];
+        union {
+                /* IPv4 tunnel header parameters */
+                struct {

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2085

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+                        /* IPv4 source address */
+                        struct in_addr src_ip;
+                        /* IPv4 destination address */
+                        struct in_addr dst_ip;
+                        /* IPv4 Differentiated Services Code Point */
+                        u8 dscp;
+                        /* IPv4 Don't Fragment bit */
+                        u8 df;
+                        /* IPv4 Time To Live */
+                        u8 ttl;
Quoted 1 line

Please add padding bytes to align to 32-bit.

Will do.

Quoted 13 lines

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2098

Quoted 13 lines
device-types/crypto/description.tex +13 -0
+                } ipv4;
+                /* IPv6 tunnel header parameters */
+                struct {
+                        /* IPv6 source address */
+                        struct in6_addr src_addr;
+                        /* IPv6 destination address */
+                        struct in6_addr dst_addr;
+                        /* IPv6 flow label */
+                        le32 flabel;
+                        /* IPv6 hop limit */
+                        u8 hlimit;
+                        /* IPv6 Differentiated Services Code Point */
+                        u8 dscp;
Quoted 1 line

This one too. Please check in both the series, vnet ipsec and this one.

Will do.

Quoted 21 lines
Quoted 21 lines
device-types/crypto/description.tex +20 -0
+                } ipv6;
+        };
+};
+
+struct virtio_crypto_resource_obj_ipsec_sa {
+        le32 spi;
+        le32 salt;
+        le64 options;
+        struct virtio_crypto_ipsec_tunnel_param param;
+        le64 esn;
+        le16 udp_sport;
+        le16 udp_dport;
+        le32 replay_win_sz;
+        le64 cipher_algo;
+        struct {
+            le16 length;
+            u8 data[];
+        } cipher_key;
+        le64 auth_algo;
+        struct {
Quoted 8 lines

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2121

Quoted 3 lines
device-types/crypto/description.tex +3 -0
+            le16 length;
+            u8 data[];
+        } auth_key;

Two dynamic arrays in one is problematic.
And below fields can never be referenced without learning the length of auth_key and cipher_key.
Below are critical fields to access the whole rest of the object. So please move them at start.

Will do.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Also can we have above two dynamic array as constant size array, instead of dynamic?

We would like to make it a single dynamic array. Have both lengths auth_key_len and cipher_key_len at the end followed by data[] array. The first x(auth_key_len) bytes represents the auth_key and next y(cipher_key_len) bytes represents the cipher key.
Could you confirm if this approach is fine?

Code wont be able to make sure of flexible array related kernel and/or compiler facilities. If most common keys are 256-bit wide, can we limit each array size for 64B for 512-bits future key size? This way, there are still two arrays, static/dynamic checkers enabled and covers common cases too?

And if there is use case for 1024 or 4K bits key, may be for it can we define just new struct for it? May be ipsec_sa_large_key {} for it with rest of the fields as common?

Quoted 76 lines
Quoted 26 lines
Quoted 17 lines
device-types/crypto/description.tex +8 -0
+        le32 obj_id;
+        u8 mode;
+        u8 direction;
+}
+\end{lstlisting}
+
+\field{spi} is the Security Parameter Index(SPI) used to uniquely
+identify the

IPsec SA.
+\field{salt} is the 32 bit salt value used in the cryptographic operations.

device-types/crypto/description.tex +4 -0
+
+\field{options} specifies the Options for configuring the IPsec SA,
+see \ref{table:Device Types / Crypto Device / Device Operation /
+IPsec Service

Operation / Device and driver capabilities /
VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.

device-types/crypto/description.tex

Quoted 8 lines
device-types/crypto/description.tex +8 -0
+
+\field{param} specifies the parameters for IPsec tunnel mode.
+\field{esn} is the starting sequence number.
+\field{udp_sport} is the source port for UDP encapsulation.
+\field{udp_dport} is the destination port for UDP encapsulation.
+\field{replay_win_sz} is the anti-replay window size to enable
+sequence replay attack handling, replay checking is disabled if the
+window

size is 0.

Quoted 4 lines

device-types/crypto/description.tex

Quoted 4 lines
device-types/crypto/description.tex +4 -0
+
+\field{cipher_algo} is the cipher algorithm identifier see
+\ref{sec:Device Types / Crypto Device / Supported crypto services
+/ CIPHER services} \field{cipher_key} specifies the cipher key and its

length.

Quoted 14 lines
Quoted 14 lines

+\field{auth_algo} is the Authentication algorithm identifier +\field{auth_key} specifies the authentication key data and its length. +\field{obj_id} specifies the object id of the SA that can be used

device-types/crypto/description.tex +5 -0
+to retrieve driver-defined data associated with the IPsec SA.
+
+\field{mode} specifies the mode of the IPsec SA, see
+\ref{table:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Device

and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}.

device-types/crypto/description.tex +5 -0
+
+\field{direction} specifies IPsec SA direction.
+
+\begin{table}[H]
+\caption{IPsec Direction}
Quoted 8 lines

device-types/crypto/description.tex

Quoted 8 lines

+\label{table:Device Types / Crypto Device / Device Operation /

device-types/crypto/description.tex +7 -0
+IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA / IPsec Direction}
+\begin{tabularx}{\textwidth}{ |l|X|X| } \hline Type & Name &
+Description \\ \hline \hline
+0x0 & - & Reserved \\
+\hline
+0x1 & VIRTIO_CRYPTO_IPSEC_DIR_OUTBOUND & IPsec direction

outbound

Quoted 3 lines
Quoted 3 lines

\\
+\hline
+0x2 & VIRTIO_CRYPTO_IPSEC_DIR_INBOUND & IPsec direction inbound

\\

Quoted 4 lines
Quoted 3 lines

+\hline \end{tabularx} \end{table}
+

+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA}\labe

Quoted 13 lines

l

Quoted 12 lines

{par:De

device-types/crypto/description.tex +9 -1
+vice Types / Crypto Device / Device Operation / IPsec Service
+Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA}
+
+A driver can have inbound SAs between 0 and \field{inb_sa_limit},
+as specified by the capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP.
+For the IPsec inbound SA resource object
+\field{resource_obj_specific_data}
+is in the format \field{struct virtio_crypto_resource_obj_ipsec_sa}.
--

2.25.1

#10 lore raw

RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

Quoted 199 lines

Subject: [EXTERNAL] RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

Quoted 7 lines

From: Srujana Challa <schalla@ marvell. com> > Sent: Thursday, February 13, 2025 8: 06 PM > > > Subject: [EXTERNAL] RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource > > objects for IPsec outbound and inbound SAs >

Quoted 25 lines

From: Srujana Challa <[email protected]>
Sent: Thursday, February 13, 2025 8:06 PM

Quoted 22 lines

Subject: [EXTERNAL] RE: [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs

Quoted 8 lines

From: Srujana Challa <schalla@ marvell. com> > Sent: Wednesday, January 22, 2025 11: 47 AM > > This commit introduces resource objects to enable the driver/device to create > IPsec Security Associations
(SAs) for both inbound

Quoted 6 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:47 AM

This commit introduces resource objects to enable the driver/device to create IPsec Security Associations (SAs) for both inbound and outbound

directions.

Quoted 4 lines

The IPsec SA objects include essential parameters required for packet outbound and inbound processing, such as SPI, tunnel headers, IPsec mode, IPsec options and cipher/authentication specific

data.

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
---
 device-types/crypto/description.tex | 145
++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex index 2c00e50..0ba09df 100644

device-types/crypto/description.tex +0 -0
@@ -336,6 +336,20 @@ \subsection{Device and driver

capabilities}\label{sec:Device Types / Crypto Devi \hline \end{tabularx}

+\subsection{Device resource objects}\label{sec:Device Types /

device-types/crypto/description.tex +9 -0
+Crypto Device / Device resource objects}
+
+The crypto device has the following resource objects.
+
+\begin{tabularx}{\textwidth}{ |l||l|X| } \hline type & Name &
+Description \\ \hline \hline
+0x0200 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OB

device-types/crypto/description.tex +5 -0
+J_IPSEC_OUTBOUND_SA} & IPsec outbound SA resource object \\
+\hline
+0x0201 & \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-

SA]{VIRTIO_CRYPTO_RESOURCE_OBJ

device-types/crypto/description.tex +3 -0
+_IPSEC_INBOUND_SA} & IPsec inbound SA resource object \\ \hline
+\end{tabularx}
+
 \subsection{Device Operation}\label{sec:Device Types / Crypto

Device / Device Operation}

Quoted 13 lines
Quoted 12 lines

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2048

Quoted 11 lines

The operation of a virtio crypto device is driven by requests
placed on the virtqueues.

device-types/crypto/description.tex +0 -0
@@ -2028,3 +2042,134 @@ \subsubsection{IPSEC Service

Operation}\label{sec:Device Types / Crypto Device / \hline \end{tabularx} \end{table}

device-types/crypto/description.tex +5 -0
+
+\paragraph{Resource objects}
+\label{par:Device Types / Crypto Device / Device Operation /
+IPsec Service Operation / Resource objects}
+

+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA}\la

Quoted 8 lines
Quoted 8 lines

b

device-types/crypto/description.tex

Quoted 7 lines

el{par:D

device-types/crypto/description.tex +6 -0
+evice Types / Crypto Device / Device Operation / IPsec Service
+Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA}
+
+A driver can have outbound SAs between 0 and
+\field{outb_sa_limit}, as specified by the capability

VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP.

Quoted 87 lines
Quoted 19 lines
Quoted 2 lines

+For the IPsec outbound SA resource object +\field{resource_obj_specific_data} is in the format \field{struct

virtio_crypto_resource_obj_ipsec_sa}.

Quoted 4 lines
device-types/crypto/description.tex +4 -0
+
+\begin{lstlisting}
+struct in_addr {
+        le32 s_addr;

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2068

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+};
+
+struct in6_addr {
+        union {
+                u8  S6_u8[16];
+                le32 S6_u32[4];
+                le64 S6_u64[2];
+        } S6_un;
+};
+

Any reason for union? Can we just have s6_u8?
(s6 in small).

I have copied from the RFC. Will change it or can we add reference to the RFC for these structures instead of defining here?

Quoted 18 lines
Quoted 8 lines
device-types/crypto/description.tex +7 -0
+struct virtio_crypto_ipsec_tunnel_param {
+        /* Tunnel type: IPv4 or IPv6 */
+        u8 type;
+        u8 reserved[3];
+        union {
+                /* IPv4 tunnel header parameters */
+                struct {

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2085

Quoted 10 lines
device-types/crypto/description.tex +10 -0
+                        /* IPv4 source address */
+                        struct in_addr src_ip;
+                        /* IPv4 destination address */
+                        struct in_addr dst_ip;
+                        /* IPv4 Differentiated Services Code Point */
+                        u8 dscp;
+                        /* IPv4 Don't Fragment bit */
+                        u8 df;
+                        /* IPv4 Time To Live */
+                        u8 ttl;
Quoted 1 line

Please add padding bytes to align to 32-bit.

Will do.

Quoted 13 lines

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2098

Quoted 13 lines
device-types/crypto/description.tex +13 -0
+                } ipv4;
+                /* IPv6 tunnel header parameters */
+                struct {
+                        /* IPv6 source address */
+                        struct in6_addr src_addr;
+                        /* IPv6 destination address */
+                        struct in6_addr dst_addr;
+                        /* IPv6 flow label */
+                        le32 flabel;
+                        /* IPv6 hop limit */
+                        u8 hlimit;
+                        /* IPv6 Differentiated Services Code Point */
+                        u8 dscp;
Quoted 1 line

This one too. Please check in both the series, vnet ipsec and this one.

Will do.

Quoted 21 lines
Quoted 21 lines
device-types/crypto/description.tex +20 -0
+                } ipv6;
+        };
+};
+
+struct virtio_crypto_resource_obj_ipsec_sa {
+        le32 spi;
+        le32 salt;
+        le64 options;
+        struct virtio_crypto_ipsec_tunnel_param param;
+        le64 esn;
+        le16 udp_sport;
+        le16 udp_dport;
+        le32 replay_win_sz;
+        le64 cipher_algo;
+        struct {
+            le16 length;
+            u8 data[];
+        } cipher_key;
+        le64 auth_algo;
+        struct {
Quoted 8 lines

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / · line 2121

Quoted 3 lines
device-types/crypto/description.tex +3 -0
+            le16 length;
+            u8 data[];
+        } auth_key;

Two dynamic arrays in one is problematic.
And below fields can never be referenced without learning the length of auth_key and cipher_key.
Below are critical fields to access the whole rest of the object. So please move them at start.

Will do.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Also can we have above two dynamic array as constant size array, instead of dynamic?

We would like to make it a single dynamic array. Have both lengths auth_key_len and cipher_key_len at the end followed by data[] array. The first
x(auth_key_len) bytes represents the auth_key and next y(cipher_key_len) bytes represents the cipher key.
Could you confirm if this approach is fine?

Code wont be able to make sure of flexible array related kernel and/or compiler facilities.
If most common keys are 256-bit wide, can we limit each array size for 64B for 512-bits future key size?
This way, there are still two arrays, static/dynamic checkers enabled and covers common cases too?

Quoted 3 lines

And if there is use case for 1024 or 4K bits key, may be for it can we define just new struct for it?
May be ipsec_sa_large_key {} for it with rest of the fields as common?

Will do.

Quoted 68 lines
Quoted 42 lines
Quoted 27 lines
Quoted 18 lines
device-types/crypto/description.tex +8 -0
+        le32 obj_id;
+        u8 mode;
+        u8 direction;
+}
+\end{lstlisting}
+
+\field{spi} is the Security Parameter Index(SPI) used to uniquely
+identify the

IPsec SA.
+\field{salt} is the 32 bit salt value used in the cryptographic operations.

device-types/crypto/description.tex +4 -0
+
+\field{options} specifies the Options for configuring the IPsec
+SA, see \ref{table:Device Types / Crypto Device / Device
+Operation / IPsec Service

Operation / Device and driver capabilities /
VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Options}.

device-types/crypto/description.tex

Quoted 8 lines
device-types/crypto/description.tex +8 -0
+
+\field{param} specifies the parameters for IPsec tunnel mode.
+\field{esn} is the starting sequence number.
+\field{udp_sport} is the source port for UDP encapsulation.
+\field{udp_dport} is the destination port for UDP encapsulation.
+\field{replay_win_sz} is the anti-replay window size to enable
+sequence replay attack handling, replay checking is disabled if
+the window

size is 0.

Quoted 5 lines

device-types/crypto/description.tex

Quoted 5 lines
device-types/crypto/description.tex +5 -0
+
+\field{cipher_algo} is the cipher algorithm identifier see
+\ref{sec:Device Types / Crypto Device / Supported crypto services
+/ CIPHER services} \field{cipher_key} specifies the cipher key
+and its

length.

Quoted 9 lines
Quoted 9 lines

+\field{auth_algo} is the Authentication algorithm identifier +\field{auth_key} specifies the authentication key data and its length. +\field{obj_id} specifies the object id of the SA that can be used

device-types/crypto/description.tex +5 -0
+to retrieve driver-defined data associated with the IPsec SA.
+
+\field{mode} specifies the mode of the IPsec SA, see
+\ref{table:Device Types / Crypto Device / Device Operation /
+IPsec Service Operation / Device

and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP / IPsec Modes}.

Quoted 8 lines
Quoted 8 lines

device-types/crypto/description.tex \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device /

Quoted 8 lines
device-types/crypto/description.tex +8 -0
+
+\field{direction} specifies IPsec SA direction.
+
+\begin{table}[H]
+\caption{IPsec Direction}
+\label{table:Device Types / Crypto Device / Device Operation /
+IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA / IPsec

Direction}

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

+\begin{tabularx}{\textwidth}{ |l|X|X| } \hline Type & Name & +Description \\ \hline \hline
+0x0 & - & Reserved \\
+\hline
+0x1 & VIRTIO_CRYPTO_IPSEC_DIR_OUTBOUND & IPsec direction

Quoted 10 lines

outbound

Quoted 3 lines
Quoted 3 lines

\\
+\hline
+0x2 & VIRTIO_CRYPTO_IPSEC_DIR_INBOUND & IPsec direction inbound

\\

Quoted 4 lines
Quoted 3 lines

+\hline \end{tabularx} \end{table}
+

+\subparagraph{VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA}\labe

Quoted 1 line
Quoted 1 line

l

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

{par:De

device-types/crypto/description.tex +3 -0
+vice Types / Crypto Device / Device Operation / IPsec Service
+Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA}
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
device-types/crypto/description.tex +6 -1
+
+A driver can have inbound SAs between 0 and \field{inb_sa_limit},
+as specified by the capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP.
+For the IPsec inbound SA resource object
+\field{resource_obj_specific_data}
+is in the format \field{struct virtio_crypto_resource_obj_ipsec_sa}.
--

2.25.1

Thanks.

#11 lore raw

RFC PATCH v3 3/4 virtio-crypto: Add new IPsec opcodes to data request

In reply to Srujana Challa

Adds new IPsec opcodes, VIRTIO_CRYPTO_IPSEC_OUTBOUND and VIRTIO_CRYPTO_IPSEC_INBOUND and defines opcode specific data structures for IPsec data processing.

---
 device-types/crypto/description.tex | 80 +++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
device-types/crypto/description.tex +80 -0
index 0ba09df..cf5de23 100644
@@ -992,6 +992,10 @@ \subsubsection{Data Virtqueue}\label{sec:Device Types / Crypto Device / Device O
     VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x02)
 #define VIRTIO_CRYPTO_AKCIPHER_VERIFY \
     VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x03)
+#define VIRTIO_CRYPTO_IPSEC_OUTBOUND \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_IPSEC, 0x00)
+#define VIRTIO_CRYPTO_IPSEC_INBOUND \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_IPSEC, 0x01)
     le32 opcode;
     /* algo should be service-specific algorithms */
     le32 algo;
@@ -1009,6 +1013,17 @@ \subsubsection{Data Virtqueue}\label{sec:Device Types / Crypto Device / Device O
 If VIRTIO_CRYPTO_F_REVISION_1 is negotiated but VIRTIO_CRYPTO_F_<SERVICE>_STATELESS_MODE
 is not negotiated, then the device SHOULD reject <SERVICE> requests if
 VIRTIO_CRYPTO_FLAG_SESSION_MODE is not set (in \field{flag}).
+
+For VIRTIO_CRYPTO_IPSEC_OUTBOUND and VIRTIO_CRYPTO_IPSEC_INBOUND opcodes,
+\field{algo} is ignored.
+
+For VIRTIO_CRYPTO_IPSEC_OUTBOUND opcode, \field{session_id} MUST be set to
+one of the resource objects \field{id} created using
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA resource type.
+
+For VIRTIO_CRYPTO_IPSEC_INBOUND opcode, \field{session_id} MUST be set to
+one of the resource objects \field{id} created using
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA resource type.
 \end{note}
 
 The dataq request is composed of four parts:
@@ -1096,6 +1111,13 @@ \subsubsection{Data Virtqueue}\label{sec:Device Types / Crypto Device / Device O
         and struct virtio_crypto_akcipher_data_flf is padded to 48 bytes if NOT negotiated,
         and \field{op_vlf} is struct virtio_crypto_akcipher_data_vlf.
     \end{itemize*}
+\item If the the opcode (in \field{header}) is VIRTIO_CRYPTO_IPSEC_OUTBOUND
+    or VIRTIO_CRYPTO_IPSEC_INBOUND then:
+    \begin{itemize*}
+    \item \field{op_flf} is struct virtio_crypto_ipsec_data_flf and
+        \field{op_vlf} is struct virtio_crypto_ipsec_data_vlf.
+	Works only for session mode.
+    \end{itemize*}
 \end{itemize*}
 
 \field{inhdr} is a unified input header that used to return the status of
@@ -1916,11 +1938,27 @@ \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device /
 in tunnel mode, as well as the ESP/AH header from the packet(See \hyperref[intro:IPSEC]{IPSEC} RFC).
 The resulting packet contains only the plain data.
 
+The driver can request IPsec Inbound processing by
+\begin{itemize*}
+\item Creating inbound SAs using the VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA command.
+\item Setting the \field{opcode} in struct virtio_crypto_op_data_req to
+VIRTIO_CRYPTO_IPSEC_INBOUND.
+\end{itemize*}
+
 IPsec Outbound processing: The device will perform encryption, attach ICV,
 update/add IP header, add ESP/AH header/trailer.
 
+The driver can request IPsec outbound processing by
+\begin{itemize*}
+\item Creating outbound SAs using the VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA command.
+\item Setting the \field{opcode} in struct virtio_crypto_op_data_req to
+VIRTIO_CRYPTO_IPSEC_OUTBOUND.
+\end{itemize*}
+
 A crypto device can support number of IPsec SAs, allowing it to manage multiple secure
 connections simultaneously.
+See \ref{sec:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects}
+for IPsec SA information.
 
 The device and the driver indicate IPsec SA resource limits using the
 VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability specifying the limits on the number of
@@ -2173,3 +2211,45 @@ \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device /
 capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For the IPsec inbound SA resource object
 \field{resource_obj_specific_data} is in the format
 \field{struct virtio_crypto_resource_obj_ipsec_sa}.
+
+\paragraph{Data processing}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Data processing}
+
+Data requests for IPsec processing are as follows:
+
+\begin{lstlisting}
+struct virtio_crypto_ipsec_data_flf {
+        /* length of source data, full IP/IPsec packet */
+        le32 src_data_len;
+        /* length of dst data */
+        le32 dst_data_len;
+};
+
+struct virtio_crypto_ipsec_data_vlf {
+        /* Device read only portion */
+        /* Source data */
+        u8 src_data[src_data_len];
+
+        /* Device write only portion */
+        /* Pointer to output data */
+        u8 dst_data[dst_data_len];
+};
+\end{lstlisting}
+
+Each data request uses the virtio_crypto_ipsec_data_flf structure and
+the virtio_crypto_ipsec_data_vlf structure to store information used to
+run the IPSEC operations.
+
+For IPsec encryption:
+\field{src_data} is the full IP packet that will be processed.
+\field{src_data_len} is the length of source data.
+\field{dst_result} is the result ESP encrypted packet and
+\field{dst_data_len} is the length of it. Please note,
+dst_data_len MUST include additional header and trailer
+lengths.
+
+For IPsec decryption:
+\field{src_data} is the IPsec packet that will be processed.
+\field{src_data_len} is the length of source data.
+\field{dst_result} is the result plain IP packet and
+\field{dst_data_len} is the length of it.
Signature · 1 line
2.25.1
Reviewed-by on v3 3/4
#12 lore raw

RE: [PATCH RFC v3 3/4] virtio-crypto: Add new IPsec opcodes to data request

Quoted 148 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:47 AM

Adds new IPsec opcodes, VIRTIO_CRYPTO_IPSEC_OUTBOUND and VIRTIO_CRYPTO_IPSEC_INBOUND and defines opcode specific data structures for IPsec data processing.

---
 device-types/crypto/description.tex | 80
+++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex
index 0ba09df..cf5de23 100644

device-types/crypto/description.tex +0 -0
@@ -992,6 +992,10 @@ \subsubsection{Data Virtqueue}\label{sec:Device

Types / Crypto Device / Device O

     VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x02)
#define VIRTIO_CRYPTO_AKCIPHER_VERIFY \
     VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x03)
device-types/crypto/description.tex +4 -0
+#define VIRTIO_CRYPTO_IPSEC_OUTBOUND \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_IPSEC, 0x00) #define
+VIRTIO_CRYPTO_IPSEC_INBOUND \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_IPSEC, 0x01)
     le32 opcode;
     /* algo should be service-specific algorithms */
     le32 algo;
@@ -1009,6 +1013,17 @@ \subsubsection{Data Virtqueue}\label{sec:Device

Types / Crypto Device / Device O If VIRTIO_CRYPTO_F_REVISION_1 is negotiated but VIRTIO_CRYPTO_F_<SERVICE>_STATELESS_MODE
is not negotiated, then the device SHOULD reject <SERVICE> requests if
VIRTIO_CRYPTO_FLAG_SESSION_MODE is not set (in \field{flag}).

device-types/crypto/description.tex +2 -0
+
+For VIRTIO_CRYPTO_IPSEC_OUTBOUND and

VIRTIO_CRYPTO_IPSEC_INBOUND

device-types/crypto/description.tex +3 -0
+opcodes, \field{algo} is ignored.
+
+For VIRTIO_CRYPTO_IPSEC_OUTBOUND opcode, \field{session_id} MUST be

set

device-types/crypto/description.tex +4 -0
+to one of the resource objects \field{id} created using
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA resource type.
+
+For VIRTIO_CRYPTO_IPSEC_INBOUND opcode, \field{session_id} MUST be

set

device-types/crypto/description.tex +2 -0
+to one of the resource objects \field{id} created using
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA resource type.
 \end{note}
 
 The dataq request is composed of four parts:
@@ -1096,6 +1111,13 @@ \subsubsection{Data Virtqueue}\label{sec:Device

Types / Crypto Device / Device O
and struct virtio_crypto_akcipher_data_flf is padded to 48 bytes if NOT
negotiated,
and \field{op_vlf} is struct virtio_crypto_akcipher_data_vlf.
\end{itemize*}
+\item If the the opcode (in \field{header}) is VIRTIO_CRYPTO_IPSEC_OUTBOUND

device-types/crypto/description.tex +6 -0
+    or VIRTIO_CRYPTO_IPSEC_INBOUND then:
+    \begin{itemize*}
+    \item \field{op_flf} is struct virtio_crypto_ipsec_data_flf and
+        \field{op_vlf} is struct virtio_crypto_ipsec_data_vlf.
+	Works only for session mode.
+    \end{itemize*}
 \end{itemize*}
 
 \field{inhdr} is a unified input header that used to return the status of @@ -

1916,11 +1938,27 @@ \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / in tunnel mode, as well as the ESP/AH header from the packet(See \hyperref[intro:IPSEC]{IPSEC} RFC).
The resulting packet contains only the plain data.

+The driver can request IPsec Inbound processing by \begin{itemize*} +\item Creating inbound SAs using the VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA command.
+\item Setting the \field{opcode} in struct virtio_crypto_op_data_req to

device-types/crypto/description.tex +3 -0
+VIRTIO_CRYPTO_IPSEC_INBOUND.
+\end{itemize*}
+
 IPsec Outbound processing: The device will perform encryption, attach ICV,

update/add IP header, add ESP/AH header/trailer.

+The driver can request IPsec outbound processing by \begin{itemize*} +\item Creating outbound SAs using the VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA command.
+\item Setting the \field{opcode} in struct virtio_crypto_op_data_req to

device-types/crypto/description.tex +3 -0
+VIRTIO_CRYPTO_IPSEC_OUTBOUND.
+\end{itemize*}
+
 A crypto device can support number of IPsec SAs, allowing it to manage

multiple secure connections simultaneously.

device-types/crypto/description.tex +2 -0
+See \ref{sec:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Resource objects} for IPsec SA information.
 
 The device and the driver indicate IPsec SA resource limits using the

VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability specifying the limits on the number of @@ -2173,3 +2211,45 @@ \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device / capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For the IPsec inbound SA resource object \field{resource_obj_specific_data} is in the format \field{struct virtio_crypto_resource_obj_ipsec_sa}.

device-types/crypto/description.tex +42 -1
+
+\paragraph{Data processing}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec
+Service Operation / Data processing}
+
+Data requests for IPsec processing are as follows:
+
+\begin{lstlisting}
+struct virtio_crypto_ipsec_data_flf {
+        /* length of source data, full IP/IPsec packet */
+        le32 src_data_len;
+        /* length of dst data */
+        le32 dst_data_len;
+};
+
+struct virtio_crypto_ipsec_data_vlf {
+        /* Device read only portion */
+        /* Source data */
+        u8 src_data[src_data_len];
+
+        /* Device write only portion */
+        /* Pointer to output data */
+        u8 dst_data[dst_data_len];
+};
+\end{lstlisting}
+
+Each data request uses the virtio_crypto_ipsec_data_flf structure and
+the virtio_crypto_ipsec_data_vlf structure to store information used to
+run the IPSEC operations.
+
+For IPsec encryption:
+\field{src_data} is the full IP packet that will be processed.
+\field{src_data_len} is the length of source data.
+\field{dst_result} is the result ESP encrypted packet and
+\field{dst_data_len} is the length of it. Please note, dst_data_len
+MUST include additional header and trailer lengths.
+
+For IPsec decryption:
+\field{src_data} is the IPsec packet that will be processed.
+\field{src_data_len} is the length of source data.
+\field{dst_result} is the result plain IP packet and
+\field{dst_data_len} is the length of it.
--
Quoted 1 line

2.25.1

#13 lore raw

RFC PATCH v3 4/4 virtio-crypto: Add device and driver requirements for IPsec operation

In reply to Srujana Challa

Add device and driver requirements for IPsec Operation.

---
 device-types/crypto/description.tex        | 95 ++++++++++++++++++++++
 device-types/crypto/device-conformance.tex |  1 +
 device-types/crypto/driver-conformance.tex |  1 +
 3 files changed, 97 insertions(+)
device-types/crypto/description.tex +95 -0
index cf5de23..845a3e4 100644
@@ -2253,3 +2253,98 @@ \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device /
 \field{src_data_len} is the length of source data.
 \field{dst_result} is the result plain IP packet and
 \field{dst_data_len} is the length of it.
+
+\devicenormative{\paragraph}{IPsec Service Operation}{Device Types / Crypto Device / Device Operation / IPsec Service Operation}
+
+When the device supports IPsec operations,
+\begin{itemize}
+\item the device MUST set VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP, VIRTIO_CRYPTO_IPSEC_SA_CAP
+capability in the \field{supported_caps} in the command VIRTIO_ADMIN_CMD_CAP_SUPPORT_QUERY.
+\item the device MUST support the administration commands
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_MODIFY, VIRTIO_ADMIN_CMD_RESOURCE_OBJ_QUERY,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY for the resource types
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA and VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA.
+\end{itemize}
+
+When any of the VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP or VIRTIO_CRYPTO_IPSEC_SA_CAP
+capability is disabled, the device MUST set \field{status} to
+VIRTIO_ADMIN_STATUS_Q_INVALID_OPCODE for the commands
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_MODIFY, VIRTIO_ADMIN_CMD_RESOURCE_OBJ_QUERY,
+and VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY for the resource types
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA and VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA.
+
+The device MUST set \field{status} to VIRTIO_ADMIN_STATUS_EEXIST for the
+command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE when the resource \field{type}
+is VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA or VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA,
+if the object already exists with the supplied \field{id}.
+
+The device MUST fail the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE with
+the \field{status} set to VIRTIO_ADMIN_STATUS_EINVAL, for the
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA object if,
+\begin{itemize}
+\item \field{id} is greater than or equal to \field{outb_sa_limit}.
+\item the supplied SA parameters, such as mode, options, cipher and authentication
+      algorithms are not supported in the capabitlity VIRTIO_CRYPTO_IPSEC_SA_CAP.
+\end{itemize}
+
+The device MUST fail the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE with
+the \field{status} set to VIRTIO_ADMIN_STATUS_EINVAL, for the
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA object if,
+\begin{itemize}
+\item \field{id} is greater than or equal to \field{inb_sa_limit}.
+\item the supplied SA parameters, such as mode, options, cipher and authentication
+      algorithms are not supported in the capabitlity VIRTIO_CRYPTO_IPSEC_SA_CAP.
+\end{itemize}
+
+The device SHOULD maintain a table for subsequent lookups for inbound/outbound data
+processing with the corresponding SA based on the supplied \field{id}.
+
+The device MUST allow recreating the resource objects using the command
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE which was previously destroyed using
+the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY respectively without
+undergoing a device reset.
+
+The device MAY fail the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE with
+the \field{status} set to VIRTIO_ADMIN_STATUS_EINVAL for the
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA or VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA
+commands if the resource object with the same \field{spi} already exists.
+
+On device reset, the device MUST destroy all the resource objects which have been created.
+
+The device MUST copy the result of IPsec operation in the \field{dst_data[]}.
+The device MUST set the \field{status} field in struct virtio_crypto_inhdr to
+one of the following values of enum VIRTIO_CRYPTO_STATUS:
+\begin{itemize*}
+\item VIRTIO_CRYPTO_OK if the operation success.
+\item VIRTIO_CRYPTO_NOTSUPP if the requested algorithm or operation is unsupported.
+\item VIRTIO_CRYPTO_BADMSG if the integrity check is failed for IPsec decryption.
+\item VIRTIO_CRYPTO_INVSESS if the session ID invalid.
+\item VIRTIO_CRYPTO_ERR if any failure not mentioned above occurs.
+\end{itemize*}
+
+\drivernormative{\paragraph}{IPsec Service Operation}{Device Types / Crypto Device / Device Operation / IPsec Service Operation}
+
+The driver MUST query the capabilities using VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY
+to discover the capability types the device offers.
+
+The driver MUST get VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP and VIRTIO_CRYPTO_IPSEC_SA_CAP
+if listed in VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY command result, using
+VIRTION_ADMIN_CMD_DEVICE_CAP_GET to discover the capabilities the device is
+able to offer.
+The driver MUST set VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP and VIRTIO_CRYPTO_IPSEC_SA_CAP
+using VIRTIO_ADMIN_CMD_DEVICE_CAP_SET to indicate the device which capability
+the driver uses.
+
+For the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE, when creating a resource
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA, the driver MUST set all the parameters
+in \field{struct virtio_crypto_resource_obj_ipsec_sa} with relevant values.
+And when create a resource object VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA,
+the driver MUST set all the parameters except \field{struct virtio_crypto_ipsec_tunnel_param}.
+
+The driver MUST set \field{session_id} in struct virtio_crypto_op_header to a
+valid VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA or
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA \field{id}.
+The driver MUST set the \field{opcode} field in struct virtio_crypto_op_header
+to one of VIRTIO_CRYPTO_IPSEC_OUTBOUND and VIRTIO_CRYPTO_IPSEC_INBOUND.
device-types/crypto/device-conformance.tex +1 -0
index 1667120..5d1c59f 100644
@@ -10,4 +10,5 @@
 \item \ref{devicenormative:Device Types / Crypto Device / Device Operation / MAC Service Operation}
 \item \ref{devicenormative:Device Types / Crypto Device / Device Operation / Symmetric algorithms Operation}
 \item \ref{devicenormative:Device Types / Crypto Device / Device Operation / AEAD Service Operation}
+\item \ref{devicenormative:Device Types / Crypto Device / Device Operation / IPsec Service Operation}
 \end{itemize}
device-types/crypto/driver-conformance.tex +1 -0
index 672d0f6..4083ea4 100644
@@ -11,4 +11,5 @@
 \item \ref{drivernormative:Device Types / Crypto Device / Device Operation / MAC Service Operation}
 \item \ref{drivernormative:Device Types / Crypto Device / Device Operation / Symmetric algorithms Operation}
 \item \ref{drivernormative:Device Types / Crypto Device / Device Operation / AEAD Service Operation}
+\item \ref{drivernormative:Device Types / Crypto Device / Device Operation / IPsec Service Operation}
 \end{itemize}
Signature · 1 line
2.25.1
Reviewed-by on v3 4/4
#14 lore raw

RE: [PATCH RFC v3 4/4] virtio-crypto: Add device and driver requirements for IPsec operation

Quoted 175 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:47 AM

Add device and driver requirements for IPsec Operation.

---
 device-types/crypto/description.tex        | 95 ++++++++++++++++++++++
 device-types/crypto/device-conformance.tex |  1 +  device-
types/crypto/driver-conformance.tex |  1 +
 3 files changed, 97 insertions(+)
device- renamed from device-types/crypto/description.tex +0 -0

types/crypto/description.tex
index cf5de23..845a3e4 100644

device-types/crypto/description.tex +0 -0
@@ -2253,3 +2253,98 @@ \subsubsection{IPSEC Service

Operation}\label{sec:Device Types / Crypto Device / \field{src_data_len} is the length of source data.
\field{dst_result} is the result plain IP packet and \field{dst_data_len} is the
length of it.

device-types/crypto/description.tex +7 -0
+
+\devicenormative{\paragraph}{IPsec Service Operation}{Device Types /
+Crypto Device / Device Operation / IPsec Service Operation}
+
+When the device supports IPsec operations, \begin{itemize} \item the
+device MUST set VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP,
+VIRTIO_CRYPTO_IPSEC_SA_CAP capability in the \field{supported_caps} in

the command VIRTIO_ADMIN_CMD_CAP_SUPPORT_QUERY. +\item the device MUST support the administration commands

device-types/crypto/description.tex +5 -0
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_MODIFY,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_QUERY,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY for the resource types
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA and

VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA.
+\end{itemize}

device-types/crypto/description.tex +4 -0
+
+When any of the VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP or
+VIRTIO_CRYPTO_IPSEC_SA_CAP capability is disabled, the device MUST set
+\field{status} to VIRTIO_ADMIN_STATUS_Q_INVALID_OPCODE for the

commands

device-types/crypto/description.tex +5 -0
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_MODIFY,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_QUERY,
+and VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY for the resource types
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA and

VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA.

device-types/crypto/description.tex +3 -0
+
+The device MUST set \field{status} to VIRTIO_ADMIN_STATUS_EEXIST for
+the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE when the

resource
+\field{type} is VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA or

device-types/crypto/description.tex +4 -0
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA,
+if the object already exists with the supplied \field{id}.
+
+The device MUST fail the command

VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE

device-types/crypto/description.tex +2 -0
+with the \field{status} set to VIRTIO_ADMIN_STATUS_EINVAL, for the
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA object if,

\begin{itemize}
+\item \field{id} is greater than or equal to \field{outb_sa_limit}. +\item the supplied SA parameters, such as mode, options, cipher and authentication
+ algorithms are not supported in the capabitlity
VIRTIO_CRYPTO_IPSEC_SA_CAP.
+\end{itemize}

device-types/crypto/description.tex +2 -0
+
+The device MUST fail the command

VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE

device-types/crypto/description.tex +2 -0
+with the \field{status} set to VIRTIO_ADMIN_STATUS_EINVAL, for the
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA object if,

\begin{itemize}
+\item \field{id} is greater than or equal to \field{inb_sa_limit}. +\item the supplied SA parameters, such as mode, options, cipher and authentication
+ algorithms are not supported in the capabitlity
VIRTIO_CRYPTO_IPSEC_SA_CAP.
+\end{itemize}

device-types/crypto/description.tex +3 -0
+
+The device SHOULD maintain a table for subsequent lookups for
+inbound/outbound data processing with the corresponding SA based on the

supplied \field{id}.

device-types/crypto/description.tex +3 -0
+
+The device MUST allow recreating the resource objects using the command
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE which was previously

destroyed
+using the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY respectively

device-types/crypto/description.tex +3 -0
+without undergoing a device reset.
+
+The device MAY fail the command

VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE

device-types/crypto/description.tex +6 -0
+with the \field{status} set to VIRTIO_ADMIN_STATUS_EINVAL for the
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA or
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA
+commands if the resource object with the same \field{spi} already exists.
+
+On device reset, the device MUST destroy all the resource objects which have

been created.

device-types/crypto/description.tex +4 -0
+
+The device MUST copy the result of IPsec operation in the \field{dst_data[]}.
+The device MUST set the \field{status} field in struct
+virtio_crypto_inhdr to one of the following values of enum

VIRTIO_CRYPTO_STATUS:
+\begin{itemize*}
+\item VIRTIO_CRYPTO_OK if the operation success.
+\item VIRTIO_CRYPTO_NOTSUPP if the requested algorithm or operation is unsupported.
+\item VIRTIO_CRYPTO_BADMSG if the integrity check is failed for IPsec decryption.
+\item VIRTIO_CRYPTO_INVSESS if the session ID invalid. +\item VIRTIO_CRYPTO_ERR if any failure not mentioned above occurs. +\end{itemize*}

device-types/crypto/description.tex +12 -0
+
+\drivernormative{\paragraph}{IPsec Service Operation}{Device Types /
+Crypto Device / Device Operation / IPsec Service Operation}
+
+The driver MUST query the capabilities using
+VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY
+to discover the capability types the device offers.
+
+The driver MUST get VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP and
+VIRTIO_CRYPTO_IPSEC_SA_CAP if listed in
+VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY command result, using
+VIRTION_ADMIN_CMD_DEVICE_CAP_GET to discover the capabilities the

device is able to offer.

device-types/crypto/description.tex +2 -0
+The driver MUST set VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP and
+VIRTIO_CRYPTO_IPSEC_SA_CAP using

VIRTIO_ADMIN_CMD_DEVICE_CAP_SET to

device-types/crypto/description.tex +3 -0
+indicate the device which capability the driver uses.
+
+For the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE, when

creating a
+resource VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA, the driver MUST
+set all the parameters in \field{struct virtio_crypto_resource_obj_ipsec_sa} with relevant values.

device-types/crypto/description.tex +3 -0
+And when create a resource object
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA,
+the driver MUST set all the parameters except \field{struct

virtio_crypto_ipsec_tunnel_param}.

device-types/crypto/description.tex +4 -0
+
+The driver MUST set \field{session_id} in struct
+virtio_crypto_op_header to a valid
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA or

VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA \field{id}.

device-types/crypto/description.tex +2 -0
+The driver MUST set the \field{opcode} field in struct
+virtio_crypto_op_header to one of VIRTIO_CRYPTO_IPSEC_OUTBOUND and

VIRTIO_CRYPTO_IPSEC_INBOUND.

device- renamed from device-types/crypto/device-conformance.tex +0 -0

types/crypto/device-conformance.tex
index 1667120..5d1c59f 100644

device-types/crypto/device-conformance.tex +0 -0
@@ -10,4 +10,5 @@
 \item \ref{devicenormative:Device Types / Crypto Device / Device Operation

/ MAC Service Operation} \item \ref{devicenormative:Device Types / Crypto Device / Device Operation / Symmetric algorithms Operation} \item \ref{devicenormative:Device Types / Crypto Device / Device Operation / AEAD Service Operation}
+\item \ref{devicenormative:Device Types / Crypto Device / Device

device-types/crypto/device-conformance.tex +1 -0
+Operation / IPsec Service Operation}
 \end{itemize}
device- renamed from device-types/crypto/driver-conformance.tex +0 -0

types/crypto/driver-conformance.tex
index 672d0f6..4083ea4 100644

device-types/crypto/driver-conformance.tex +0 -0
@@ -11,4 +11,5 @@
 \item \ref{drivernormative:Device Types / Crypto Device / Device Operation /

MAC Service Operation} \item \ref{drivernormative:Device Types / Crypto

Quoted 8 lines

Device / Device Operation / Symmetric algorithms Operation} \item \ref{drivernormative:Device Types / Crypto Device / Device Operation / AEAD Service Operation}
+\item \ref{drivernormative:Device Types / Crypto Device / Device +Operation / IPsec Service Operation}
\end{itemize}
--
2.25.1