Skip to contentSkip to conversation

cryptodev: formalize key wrap method in API

PATCH Superseded Matan Azrad 2 participants 6 messages Mar 16, 2021 – Apr 16, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cryptodev: formalize key wrap method in API

The Key Wrap approach is used by applications in order to protect keys located in untrusted storage or transmitted over untrusted communications networks. The constructions are typically built from standard primitives such as block ciphers and cryptographic hash functions.

The Key Wrap method and its parameters are a secret between the keys provider and the device, means that the device is preconfigured for this method using very secured way.

The key wrap method may change the key length and layout.

Add a description for the cipher transformation key to allow wrapped key to be forwarded by the same API.

---
 lib/librte_cryptodev/rte_crypto_sym.h | 7 +++++++
 1 file changed, 7 insertions(+)
lib/librte_cryptodev/rte_crypto_sym.h +7 -0
index 5973e31..6aca2c7 100644
@@ -200,6 +200,13 @@ struct rte_crypto_cipher_xform {
 		uint16_t length;	/**< key length in bytes */
 	} key;
 	/**< Cipher key
+	 * The original key data may be provided wrapped (encrypted) using a key
+	 * wrap algorithm such as AES key wrap (from rfc3394) or other. In such
+	 * case, the wrapping details is a secret between the key provider and
+	 * the device. Such key wrapping may increase the length of the provided
+	 * key beyond the advertised supported key size. Hence it is the
+	 * responsibility of the driver/device to validate the length of the
+	 * provided key.
 	 *
 	 * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.data will
 	 * point to a concatenation of the AES encryption key followed by a
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 cryptodev: formalize key wrap method in API

The Key Wrap approach is used by applications in order to protect keys located in untrusted storage or transmitted over untrusted communications networks. The constructions are typically built from standard primitives such as block ciphers and cryptographic hash functions.

The Key Wrap method and its parameters are a secret between the keys provider and the device, means that the device is preconfigured for this method using very secured way.

The key wrap method may change the key length and layout.

Add a description for the cipher transformation key to allow wrapped key to be forwarded by the same API.

Add a new feature flag RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY to be enabled by PMDs support wrapped key in cipher trasformation.

---

V2:
Address Akhil coment to introduce ne feature flag for wrapped keys.

 doc/guides/cryptodevs/features/default.ini | 1 +
 doc/guides/cryptodevs/overview.rst         | 3 +++
 doc/guides/rel_notes/release_21_05.rst     | 5 +++++
 lib/librte_cryptodev/rte_crypto_sym.h      | 8 ++++++++
 lib/librte_cryptodev/rte_cryptodev.c       | 2 ++
 lib/librte_cryptodev/rte_cryptodev.h       | 2 ++
 6 files changed, 21 insertions(+)
doc/guides/cryptodevs/features/default.ini +1 -0
index 978bb30cc1..c24814de98 100644
@@ -32,6 +32,7 @@ Symmetric sessionless  =
 Non-Byte aligned data  =
 Sym raw data path API  =
 Cipher multiple data units =
+Cipher wrapped key     =
 
 ;
 ; Supported crypto algorithms of a default crypto driver.
doc/guides/cryptodevs/overview.rst +3 -0
index e24e3e1993..47b1231226 100644
@@ -49,6 +49,9 @@ Supported Feature Flags
    - "CIPHER_MULTIPLE_DATA_UNITS" feature flag means PMD support operations
       on multiple data-units message.
 
+   - "CIPHER_WRAPPED_KEY" feature flag means PMD support wrapped key in cipher
+      transformation.
+
 
 Supported Cipher Algorithms
 ---------------------------
doc/guides/rel_notes/release_21_05.rst +5 -0
index 1537fac4bc..75b2b86c5f 100644
@@ -132,6 +132,11 @@ New Features
   data-units for AES-XTS algorithm, the data-unit length should be set in the
   transformation. A capability for it was added too.
 
+* **Added feature to support cipher wrapped key on cryptodev library API.**
+
+  The Cryptodev library has been enhanced to allow providing wrapped key in
+  cipher transformation. 
+
 
 Removed Items
 -------------
lib/librte_cryptodev/rte_crypto_sym.h +8 -0
index 5973e31f30..0e08d2ef9e 100644
@@ -200,6 +200,14 @@ struct rte_crypto_cipher_xform {
 		uint16_t length;	/**< key length in bytes */
 	} key;
 	/**< Cipher key
+	 * When the device RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY feature is
+	 * enabled, the original key data may be provided wrapped (encrypted)
+	 * using a key wrap algorithm such as AES key wrap (from rfc3394) or
+	 * other. In such case, the wrapping details is a secret between the key
+	 * provider and the device. Such key wrapping may increase the length of
+	 * the provided key beyond the advertised supported key size. Hence it
+	 * is the responsibility of the driver/device to validate the length of
+	 * the provided key.
 	 *
 	 * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.data will
 	 * point to a concatenation of the AES encryption key followed by a
lib/librte_cryptodev/rte_cryptodev.c +2 -0
index e02e001325..a84cd745f9 100644
@@ -619,6 +619,8 @@ rte_cryptodev_get_feature_name(uint64_t flag)
 		return "NON_BYTE_ALIGNED_DATA";
 	case RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS:
 		return "CIPHER_MULTIPLE_DATA_UNITS";
+	case RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY:
+		return "CIPHER_WRAPPED_KEY";
 	default:
 		return NULL;
 	}
lib/librte_cryptodev/rte_cryptodev.h +2 -0
index c274e208ed..16c20de94c 100644
@@ -476,6 +476,8 @@ rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum,
 /**< Support accelerator specific symmetric raw data-path APIs */
 #define RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS	(1ULL << 25)
 /**< Support operations on multiple data-units message */
+#define RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY		(1ULL << 26)
+/**< Support wrapped key in cipher transformation  */
 
 /**
  * Get the name of a crypto device feature flag
Signature · 1 line
2.25.1
#2 lore raw

Hi Matan,

Quoted 10 lines

The Key Wrap approach is used by applications in order to protect keys located in untrusted storage or transmitted over untrusted communications networks. The constructions are typically built from standard primitives such as block ciphers and cryptographic hash functions.

The Key Wrap method and its parameters are a secret between the keys provider and the device, means that the device is preconfigured for this method using very secured way.

Quoted 8 lines

The key wrap method may change the key length and layout.

Add a description for the cipher transformation key to allow wrapped key to be forwarded by the same API.

Add a new feature flag RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY to be enabled
by PMDs support wrapped key in cipher trasformation.

Spell check

Quoted 59 lines

---

V2:
Address Akhil coment to introduce ne feature flag for wrapped keys.

 doc/guides/cryptodevs/features/default.ini | 1 +
 doc/guides/cryptodevs/overview.rst         | 3 +++
 doc/guides/rel_notes/release_21_05.rst     | 5 +++++
 lib/librte_cryptodev/rte_crypto_sym.h      | 8 ++++++++
 lib/librte_cryptodev/rte_cryptodev.c       | 2 ++
 lib/librte_cryptodev/rte_cryptodev.h       | 2 ++
 6 files changed, 21 insertions(+)
doc/guides/cryptodevs/features/default.ini +1 -0
index 978bb30cc1..c24814de98 100644
@@ -32,6 +32,7 @@ Symmetric sessionless  =
 Non-Byte aligned data  =
 Sym raw data path API  =
 Cipher multiple data units =
+Cipher wrapped key     =
 
 ;
 ; Supported crypto algorithms of a default crypto driver.
doc/guides/cryptodevs/overview.rst +0 -0
index e24e3e1993..47b1231226 100644
@@ -49,6 +49,9 @@ Supported Feature Flags
    - "CIPHER_MULTIPLE_DATA_UNITS" feature flag means PMD support

operations
on multiple data-units message.

+ - "CIPHER_WRAPPED_KEY" feature flag means PMD support wrapped key
in cipher

doc/guides/cryptodevs/overview.rst +2 -0
+      transformation.
+
 
 Supported Cipher Algorithms
 ---------------------------
doc/guides/rel_notes/release_21_05.rst +1 -0
index 1537fac4bc..75b2b86c5f 100644
@@ -132,6 +132,11 @@ New Features
   data-units for AES-XTS algorithm, the data-unit length should be set in the
   transformation. A capability for it was added too.
 
+* **Added feature to support cipher wrapped key on cryptodev library

API.**

doc/guides/rel_notes/release_21_05.rst +2 -0
+
+  The Cryptodev library has been enhanced to allow providing wrapped key
Quoted 2 lines

in
+ cipher transformation.

Added a crypto PMD feature flag to support cipher wrapped keys

A new feature flag is added to allow application to provide cipher wrapped keys in session xforms.

Quoted 24 lines
doc/guides/rel_notes/release_21_05.rst +1 -0
+
 
 Removed Items
 -------------
lib/librte_cryptodev/rte_crypto_sym.h +1 -0
index 5973e31f30..0e08d2ef9e 100644
@@ -200,6 +200,14 @@ struct rte_crypto_cipher_xform {
 		uint16_t length;	/**< key length in bytes */
 	} key;
 	/**< Cipher key
+	 * When the device RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY

feature is

lib/librte_cryptodev/rte_crypto_sym.h +1 -0
+	 * enabled, the original key data may be provided wrapped

(encrypted)

lib/librte_cryptodev/rte_crypto_sym.h +2 -0
+	 * using a key wrap algorithm such as AES key wrap (from rfc3394) or
+	 * other. In such case, the wrapping details is a secret between the

key

lib/librte_cryptodev/rte_crypto_sym.h +1 -0
+	 * provider and the device. Such key wrapping may increase the

length of

lib/librte_cryptodev/rte_crypto_sym.h +1 -0
+	 * the provided key beyond the advertised supported key size. Hence

it

lib/librte_cryptodev/rte_crypto_sym.h struct rte_crypto_cipher_xform { · line 210

Quoted 2 lines
lib/librte_cryptodev/rte_crypto_sym.h +2 -0
+	 * is the responsibility of the driver/device to validate the length of
+	 * the provided key.

How will the PMD respond if length of the provided key is not correct. Which API will return error? Session_init?
It should also be mentioned here.

Also, the application should check the capability key lengths only in case FF_CIPHER_WRAPPED_KEY is set. Otherwise it should be checked as it was Done before.
Please align the l2fwd-crypto patch as per this patch.

You may rephrase it as
"In case the PMD supports RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY, the original key data provided may be wrapped(encrypted) using key wrap algorithm such as AES key wrap (rfc3394) and hence length of the key may increase beyond the PMD advertised supported key size. PMD shall validate the key length and report error while configuring the Session and application can skip checking the capability key length in Such cases."

Quoted 35 lines
lib/librte_cryptodev/rte_crypto_sym.h +0 -0
 	 *
 	 * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.data

will

lib/librte_cryptodev/rte_crypto_sym.h +0 -0
 	 * point to a concatenation of the AES encryption key followed by a
lib/librte_cryptodev/rte_cryptodev.c +2 -0
index e02e001325..a84cd745f9 100644
@@ -619,6 +619,8 @@ rte_cryptodev_get_feature_name(uint64_t flag)
 		return "NON_BYTE_ALIGNED_DATA";
 	case RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS:
 		return "CIPHER_MULTIPLE_DATA_UNITS";
+	case RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY:
+		return "CIPHER_WRAPPED_KEY";
 	default:
 		return NULL;
 	}
lib/librte_cryptodev/rte_cryptodev.h +2 -0
index c274e208ed..16c20de94c 100644
@@ -476,6 +476,8 @@ rte_cryptodev_asym_get_xform_enum(enum
 rte_crypto_asym_xform_type *xform_enum,
 /**< Support accelerator specific symmetric raw data-path APIs */
 #define RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS	(1ULL << 25)
 /**< Support operations on multiple data-units message */
+#define RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY		(1ULL << 26)
+/**< Support wrapped key in cipher transformation  */
 
 /**

* Get the name of a crypto device feature flag
--
2.25.1

#3 lore raw

PATCH v3 1/1 cryptodev: formalize key wrap method in API

In reply to Matan Azrad

The Key Wrap approach is used by applications in order to protect keys located in untrusted storage or transmitted over untrusted communications networks. The constructions are typically built from standard primitives such as block ciphers and cryptographic hash functions.

The Key Wrap method and its parameters are a secret between the keys provider and the device, means that the device is preconfigured for this method using very secured way.

The key wrap method may change the key length and layout.

Add a description for the cipher transformation key to allow wrapped key to be forwarded by the same API.

Add a new feature flag RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY to be enabled by PMDs support wrapped key in cipher trasformation.

---

V2:
Address Akhil coment to introduce ne feature flag for wrapped keys.

V3:
Improve descriptions\spelling suggested by Akhil.

 doc/guides/cryptodevs/features/default.ini | 1 +
 doc/guides/cryptodevs/overview.rst         | 3 +++
 doc/guides/rel_notes/release_21_05.rst     | 5 +++++
 lib/librte_cryptodev/rte_crypto_sym.h      | 8 ++++++++
 lib/librte_cryptodev/rte_cryptodev.c       | 2 ++
 lib/librte_cryptodev/rte_cryptodev.h       | 2 ++
 6 files changed, 21 insertions(+)
doc/guides/cryptodevs/features/default.ini +1 -0
index 978bb30cc1..c24814de98 100644
@@ -32,6 +32,7 @@ Symmetric sessionless  =
 Non-Byte aligned data  =
 Sym raw data path API  =
 Cipher multiple data units =
+Cipher wrapped key     =
 
 ;
 ; Supported crypto algorithms of a default crypto driver.
doc/guides/cryptodevs/overview.rst +3 -0
index e24e3e1993..b87c4c6a27 100644
@@ -49,6 +49,9 @@ Supported Feature Flags
    - "CIPHER_MULTIPLE_DATA_UNITS" feature flag means PMD support operations
       on multiple data-units message.
 
+   - "CIPHER_WRAPPED_KEY" feature flag means PMD support wrapped key in cipher
+      xform.
+
 
 Supported Cipher Algorithms
 ---------------------------
doc/guides/rel_notes/release_21_05.rst +5 -0
index 1537fac4bc..24b8b28253 100644
@@ -132,6 +132,11 @@ New Features
   data-units for AES-XTS algorithm, the data-unit length should be set in the
   transformation. A capability for it was added too.
 
+* **Added a crypto PMD feature flag to support cipher wrapped keys.**
+
+  A new feature flag is added to allow application to provide cipher wrapped
+  keys in session xforms.
+
 
 Removed Items
 -------------
lib/librte_cryptodev/rte_crypto_sym.h +8 -0
index 5973e31f30..a1fb5b0f5c 100644
@@ -200,6 +200,14 @@ struct rte_crypto_cipher_xform {
 		uint16_t length;	/**< key length in bytes */
 	} key;
 	/**< Cipher key
+	 *
+	 * In case the PMD supports RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY, the
+	 * original key data provided may be wrapped(encrypted) using key wrap
+	 * algorithm such as AES key wrap (rfc3394) and hence length of the key
+	 * may increase beyond the PMD advertised supported key size.
+	 * PMD shall validate the key length and report EMSGSIZE error while
+	 * configuring the session and application can skip checking the
+	 * capability key length in such cases.
 	 *
 	 * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.data will
 	 * point to a concatenation of the AES encryption key followed by a
lib/librte_cryptodev/rte_cryptodev.c +2 -0
index e02e001325..a84cd745f9 100644
@@ -619,6 +619,8 @@ rte_cryptodev_get_feature_name(uint64_t flag)
 		return "NON_BYTE_ALIGNED_DATA";
 	case RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS:
 		return "CIPHER_MULTIPLE_DATA_UNITS";
+	case RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY:
+		return "CIPHER_WRAPPED_KEY";
 	default:
 		return NULL;
 	}
lib/librte_cryptodev/rte_cryptodev.h +2 -0
index c274e208ed..a823831065 100644
@@ -476,6 +476,8 @@ rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum,
 /**< Support accelerator specific symmetric raw data-path APIs */
 #define RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS	(1ULL << 25)
 /**< Support operations on multiple data-units message */
+#define RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY		(1ULL << 26)
+/**< Support wrapped key in cipher xform  */
 
 /**
  * Get the name of a crypto device feature flag
Signature · 1 line
2.25.1
Acked-by on v3 1/1
#4 lore raw
Quoted 15 lines

The Key Wrap approach is used by applications in order to protect keys located in untrusted storage or transmitted over untrusted communications networks. The constructions are typically built from standard primitives such as block ciphers and cryptographic hash functions.

The Key Wrap method and its parameters are a secret between the keys provider and the device, means that the device is preconfigured for this method using very secured way.

The key wrap method may change the key length and layout.

Add a description for the cipher transformation key to allow wrapped key to be forwarded by the same API.

Quoted 6 lines

Add a new feature flag RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY to be enabled
by PMDs support wrapped key in cipher trasformation.

---

I hope crypto mlx5 driver support this feature. Do not forget to add this flag In that.

Quoted 117 lines

V2:
Address Akhil coment to introduce ne feature flag for wrapped keys.

V3:
Improve descriptions\spelling suggested by Akhil.

 doc/guides/cryptodevs/features/default.ini | 1 +
 doc/guides/cryptodevs/overview.rst         | 3 +++
 doc/guides/rel_notes/release_21_05.rst     | 5 +++++
 lib/librte_cryptodev/rte_crypto_sym.h      | 8 ++++++++
 lib/librte_cryptodev/rte_cryptodev.c       | 2 ++
 lib/librte_cryptodev/rte_cryptodev.h       | 2 ++
 6 files changed, 21 insertions(+)
doc/guides/cryptodevs/features/default.ini +1 -0
index 978bb30cc1..c24814de98 100644
@@ -32,6 +32,7 @@ Symmetric sessionless  =
 Non-Byte aligned data  =
 Sym raw data path API  =
 Cipher multiple data units =
+Cipher wrapped key     =
 
 ;
 ; Supported crypto algorithms of a default crypto driver.
doc/guides/cryptodevs/overview.rst +0 -0
index e24e3e1993..b87c4c6a27 100644
@@ -49,6 +49,9 @@ Supported Feature Flags
    - "CIPHER_MULTIPLE_DATA_UNITS" feature flag means PMD support

operations
on multiple data-units message.

+ - "CIPHER_WRAPPED_KEY" feature flag means PMD support wrapped key
in cipher

doc/guides/cryptodevs/overview.rst +2 -0
+      xform.
+
 
 Supported Cipher Algorithms
 ---------------------------
doc/guides/rel_notes/release_21_05.rst +5 -0
index 1537fac4bc..24b8b28253 100644
@@ -132,6 +132,11 @@ New Features
   data-units for AES-XTS algorithm, the data-unit length should be set in the
   transformation. A capability for it was added too.
 
+* **Added a crypto PMD feature flag to support cipher wrapped keys.**
+
+  A new feature flag is added to allow application to provide cipher wrapped
+  keys in session xforms.
+
 
 Removed Items
 -------------
lib/librte_cryptodev/rte_crypto_sym.h +2 -0
index 5973e31f30..a1fb5b0f5c 100644
@@ -200,6 +200,14 @@ struct rte_crypto_cipher_xform {
 		uint16_t length;	/**< key length in bytes */
 	} key;
 	/**< Cipher key
+	 *
+	 * In case the PMD supports

RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY, the

lib/librte_cryptodev/rte_crypto_sym.h +1 -0
+	 * original key data provided may be wrapped(encrypted) using key

wrap

lib/librte_cryptodev/rte_crypto_sym.h +1 -0
+	 * algorithm such as AES key wrap (rfc3394) and hence length of the

key

lib/librte_cryptodev/rte_crypto_sym.h +4 -0
+	 * may increase beyond the PMD advertised supported key size.
+	 * PMD shall validate the key length and report EMSGSIZE error while
+	 * configuring the session and application can skip checking the
+	 * capability key length in such cases.
 	 *
 	 * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.data

will

lib/librte_cryptodev/rte_crypto_sym.h +0 -0
 	 * point to a concatenation of the AES encryption key followed by a
lib/librte_cryptodev/rte_cryptodev.c +2 -0
index e02e001325..a84cd745f9 100644
@@ -619,6 +619,8 @@ rte_cryptodev_get_feature_name(uint64_t flag)
 		return "NON_BYTE_ALIGNED_DATA";
 	case RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS:
 		return "CIPHER_MULTIPLE_DATA_UNITS";
+	case RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY:
+		return "CIPHER_WRAPPED_KEY";
 	default:
 		return NULL;
 	}
lib/librte_cryptodev/rte_cryptodev.h +2 -0
index c274e208ed..a823831065 100644
@@ -476,6 +476,8 @@ rte_cryptodev_asym_get_xform_enum(enum
 rte_crypto_asym_xform_type *xform_enum,
 /**< Support accelerator specific symmetric raw data-path APIs */
 #define RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS	(1ULL << 25)
 /**< Support operations on multiple data-units message */
+#define RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY		(1ULL << 26)
+/**< Support wrapped key in cipher xform  */
 
 /**

* Get the name of a crypto device feature flag
--
2.25.1

Applied
#5 lore raw
Quoted 19 lines
Quoted 19 lines

The Key Wrap approach is used by applications in order to protect keys located in untrusted storage or transmitted over untrusted communications networks. The constructions are typically built from standard primitives such as block ciphers and cryptographic hash functions.

The Key Wrap method and its parameters are a secret between the keys provider and the device, means that the device is preconfigured for this method using very secured way.

The key wrap method may change the key length and layout.

Add a description for the cipher transformation key to allow wrapped key to be forwarded by the same API.

Add a new feature flag RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY to be enabled
by PMDs support wrapped key in cipher trasformation.

Quoted 6 lines
Quoted 2 lines

---

I hope crypto mlx5 driver support this feature. Do not forget to add this flag In that.

Applied to dpdk-next-crypto

Thanks.