mlx5dv_dek_creat...lx5dv_dek_destroy(3)
Hiii bestie π welcome to the mlx5dv_dek_creat...lx5dv_dek_destroy(3) manual page β the one all about DEKs and their whole lifecycle. Letβs get into it, no cap.
π NAME π
mlx5dv_dek_createβ creates a DEK.mlx5dv_dek_queryβ queries a DEKβs attributes.mlx5dv_dek_destroyβ destroys a DEK.
β¨ SYNOPSIS β¨
#include <infiniband/mlx5dv.h>
struct mlx5dv_dek *mlx5dv_dek_create(struct ibv_context *context,
struct mlx5dv_dek_init_attr *init_attr);
int mlx5dv_dek_query(struct mlx5dv_dek *dek, struct mlx5dv_dek_attr *attr);
int mlx5dv_dek_destroy(struct mlx5dv_dek *dek);
π¦ DESCRIPTION π¦
Data Encryption Keys (DEKs) are the little icons that encrypt and decrypt transmitted data π₯. Once a DEK is created, it can be configured in MKeys for crypto offload operations. DEKs are not persistent β they get destroyed when the process exits π β so a software process has to re-create all the DEKs it needs on startup.
mlx5dv_dek_create() creates a new DEK with the attributes you put in init_attr. It gives you back a pointer to the newly created dek, and that pointer is useful for DEK query, DEK destruction, and configuring a MKey for crypto offload operations.
Your DEK can be either wrapped or plaintext, and the format that should be used is decided by the specified crypto_login object.
To create a wrapped DEK, the application must have a valid crypto login object before it creates the DEK. Creating a wrapped DEK can be performed in two ways:
- Call
mlx5dv_crypto_login_create()to obtain a crypto login object. Indicate that the DEK is wrapped by settingMLX5DV_DEK_INIT_ATTR_CRYPTO_LOGINvalue incomp_maskand passing the crypto login object incrypto_loginfield ofinit_attr. Fill the other DEK attributes and create the DEK. - Call
mlx5dv_crypto_login()i.e., the old API. Supplycredential,import_kek_id
To create a plaintext DEK, the application must indicate that the DEK is in plaintext by setting MLX5DV_DEK_INIT_ATTR_CRYPTO_LOGIN value in comp_mask and passing NULL value in crypto_login field of init_attr, fill the other DEK attributes and create the DEK.
To use the created DEK (either wrapped or plaintext) in a MKey, a valid crypto login object or session is not needed. Revoking the import KEK or credential that were used for the crypto login object or session β and therefore rendering the crypto login invalid β does not prevent using a created DEK. Slay π .
mlx5dv_dek_query() queries the DEK specified by dek and returns the queried attributes in attr. A valid crypto login object or session is not required to query a plaintext DEK. On the other hand, to query a wrapped DEK, a valid crypto login object or session must be present.
mlx5dv_dek_destroy() destroys the DEK specified by dek.
πΈ ARGUMENTS πΈ
context
The device context to create the DEK with.
init_attr
enum mlx5dv_dek_init_attr_mask {
MLX5DV_DEK_INIT_ATTR_CRYPTO_LOGIN = 1 << 0,
};
struct mlx5dv_dek_init_attr {
enum mlx5dv_crypto_key_size key_size;
bool has_keytag;
enum mlx5dv_crypto_key_purpose key_purpose;
struct ibv_pd *pd;
char opaque[8];
char key[128];
uint64_t comp_mask; /* Use enum mlx5dv_dek_init_attr_mask */
struct mlx5dv_crypto_login_obj *crypto_login;
};
key_size
The size of the key. It can be one of these:
MLX5DV_CRYPTO_KEY_SIZE_128β key size is 128 bit.MLX5DV_CRYPTO_KEY_SIZE_256β key size is 256 bit.
has_keytag
Whether the DEK has a keytag or not. If set, the key should include a 8 Bytes keytag. The keytag is used to verify that the DEK being used by a MKey is the expected DEK. This is done by comparing the keytag that was defined during DEK creation with the keytag provided in the MKey crypto configuration, and failing the operation if they are different.
key_purpose
The purpose of the key. Currently it can only be the following value:
MLX5DV_CRYPTO_KEY_PURPOSE_AES_XTSβ the key will be used for AES-XTS crypto engine.
pd
The protection domain to be associated with the DEK.
opaque
Plaintext metadata to describe the key.
key
The key that will be used for encryption and decryption of transmitted data. For plaintext DEK, key must be provided in plaintext. For wrapped DEK, key must be provided wrapped by the import KEK that was specified in the crypto login. Actual size and layout of this field depend on the provided key_size and has_keytag fields, as well as on the format of the key (plaintext or wrapped). key should be constructed according to the following table.
DEK key Field Construction.
- Import Method: Plaintext; Has Keytag: No; Key size: 128 Bit; Key Layout:
key1_128b + key2_128b - Import Method: Plaintext; Has Keytag: No; Key size: 256 Bit; Key Layout:
key1_256b + key2_256b - Import Method: Plaintext; Has Keytag: Yes; Key size: 128 Bit; Key Layout:
key1_128b + key2_128b + keytag_64b - Import Method: Plaintext; Has Keytag: Yes; Key size: 256 Bit; Key Layout:
key1_256b + key2_256b + keytag_64b - Import Method: Wrapped; Has Keytag: No; Key size: 128 Bit; Key Layout:
ENC(iv_64b + key1_128b + key2_128b) - Import Method: Wrapped; Has Keytag: No; Key size: 256 Bit; Key Layout:
ENC(iv_64b + key1_256b + key2_256b) - Import Method: Wrapped; Has Keytag: Yes; Key size: 128 Bit; Key Layout:
ENC(iv_64b + key1_128b + key2_128b + keytag_64b) - Import Method: Wrapped; Has Keytag: Yes; Key size: 256 Bit; Key Layout:
ENC(iv_64b + key1_256b + key2_256b + keytag_64b)
Where ENC() is AES key wrap algorithm and iv_64b is 0xA6A6A6A6A6A6A6A6 as per the NIST SP 800-38F AES key wrap spec.
The following example shows how to wrap a 128 bit key that has keytag using a 128 bit import KEK in OpenSSL:
#include <openssl/evp.h>
unsigned char import_kek[16]; /* 128 bit import KEK in plaintext for wrapping */
unsigned char iv[8] = {0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6};
/*
* Indexes 0-15 are key1 in plaintext, indexes 16-31 are key2 in plaintext,
* and indexes 32-39 are key_tag in plaintext.
*/
unsigned char key[40];
unsigned char wrapped_key[48];
EVP_CIPHER_CTX *ctx;
int len;
ctx = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
EVP_EncryptInit_ex(ctx, EVP_aes_128_wrap(), NULL, import_kek, iv);
EVP_EncryptUpdate(ctx, wrapped_key, &len, key, sizeof(key));
EVP_EncryptFinal_ex(ctx, wrapped_key + len, &len);
EVP_CIPHER_CTX_free(ctx);
comp_mask
Currently can be the following value:
MLX5DV_DEK_INIT_ATTR_CRYPTO_LOGIN, which indicates thatcrypto_loginfield is applicable.
crypto_login
Pointer to a crypto login object. If set to a valid crypto login object, it indicates that this is a wrapped DEK that will be created using the given crypto login object. If set to NULL, it indicates that this is a plaintext DEK. Must be NULL if MLX5DV_DEK_INIT_ATTR_CRYPTO_LOGIN is not set. Only relevant when comp_mask is set with MLX5DV_DEK_INIT_ATTR_CRYPTO_LOGIN.
dek
Pointer to an existing DEK to query or to destroy.
attr
DEK attributes to be populated when querying a DEK.
struct mlx5dv_dek_attr {
enum mlx5dv_dek_state state;
char opaque[8];
uint64_t comp_mask;
};
state
The state of the DEK. It can be one of these:
MLX5DV_DEK_STATE_READYβ the key is ready for use. This is the state of the key when it is first created.MLX5DV_DEK_STATE_ERRORβ the key is unusable. The key needs to be destroyed and re-created in order to be used. This can happen, for example, due to DEK memory corruption.
opaque
Plaintext metadata to describe the key.
comp_mask
Reserved for future extension, must be 0 now.
π RETURN VALUE π
mlx5dv_dek_create()β returns a pointer to a newstruct mlx5dv_dekon success. On errorNULLis returned anderrnois set.mlx5dv_dek_query()β returns0on success and updatesattrwith the queried DEK attributes. On errorerrnovalue is returned.mlx5dv_dek_destroy()β returns0on success anderrnovalue on error.
π₯ SEE ALSO π₯
π AUTHORS π
Avihai Horon <avihaih@nvidia.com>
And thatβs the whole mlx5dv_dek_creat...lx5dv_dek_destroy(3) manual page, bestie π«Ά β the footer/source tag in this text is just mlx5dv_dek_creat...lx5dv_dek_destroy(3), with no separate date or version line attached. Byee πβ¨
π¦ where this page comes from
- alpine 3.24: rdma-core-doc 61.0-r0 Β· GPL-2.0-only OR BSD-2-Clause
- centos-stream 10: rdma-core-devel 62.0-3.el10 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms