crypto/mlx5: add support for plaintext import method
cover crypto/mlx5: add support for plaintext import method
Using crypto devs requires the user to log in and the supplied DEK to be encrypted with a KEK (keys encryption key).
KEK is burned once on the nic, along with credentials for users, and for a user to log in, he is needed to supply his creds wrapped with the KEK.
A device comes out of the Mellanox factory with a pre-defined import method for each algorithm. The defined method could be wrapped mode, so the device can be used as described above, or plaintext mode, without the need to log in and wrap supplied DEKs.
Raja Zidane (2):
common/mlx5: extend crypto capabilities
crypto/mlx5: support plaintext keys
doc/guides/cryptodevs/mlx5.rst | 17 ++++++++-- drivers/common/mlx5/mlx5_devx_cmds.c | 13 ++++++-- drivers/common/mlx5/mlx5_devx_cmds.h | 1 + drivers/common/mlx5/mlx5_prm.h | 29 +++++++++++++++++ drivers/crypto/mlx5/mlx5_crypto.c | 43 +++++++++++++++--------- drivers/crypto/mlx5/mlx5_crypto.h | 3 +- drivers/crypto/mlx5/mlx5_crypto_dek.c | 47 +++++++++++++++++++-------- 7 files changed, 117 insertions(+), 36 deletions(-)
--
dependant on https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
2.21.0
PATCH 1/2 common/mlx5: extend crypto capabilities
Crypto capabilities struct contains info about crypto import method (wrapped/plaintext DEK) for each of the supported algorithms.
Query crypto capabilities struct and save import methods.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 13 +++++++++++-- drivers/common/mlx5/mlx5_devx_cmds.h | 1 + drivers/common/mlx5/mlx5_prm.h | 29 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +11 -2
@@ -964,12 +964,21 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,MLX5_GET (cmd_hca_cap, hcattr, umr_modify_entity_size_disabled); attr->wait_on_time =MLX5_GET (cmd_hca_cap, hcattr, wait_on_time); attr->crypto =MLX5_GET (cmd_hca_cap, hcattr, crypto); -if (attr->crypto) - attr->aes_xts =MLX5_GET (cmd_hca_cap, hcattr, aes_xts); attr->ct_offload = !!(MLX5_GET64 (cmd_hca_cap, hcattr, general_obj_types) &MLX5_GENERAL_OBJ_TYPES_CAP_CONN_TRACK_OFFLOAD ); attr->rq_delay_drop =MLX5_GET (cmd_hca_cap, hcattr, rq_delay_drop); +if (attr->crypto) { + attr->aes_xts =MLX5_GET (cmd_hca_cap, hcattr, aes_xts); + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_CRYPTO | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) +return -1 ; + attr->crypto_wrapped_import_method = !!(MLX5_GET (crypto_caps, + hcattr, wrapped_import_method) + &1 <<2 ); + }if (hca_cap_2_sup) { hcattr = mlx5_devx_get_hca_cap(ctx, in, out, &rc, MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE_2 |
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
@@ -254,6 +254,7 @@ struct mlx5_hca_attr { uint32_t umr_indirect_mkey_disabled:1; uint32_t log_min_stride_wqe_sz:5; uint32_t esw_mgr_vport_id_valid:1; /* E-Switch Mgr vport ID is valid. */ + uint32_t crypto_wrapped_import_method:1;uint16_t esw_mgr_vport_id;/* E-Switch Mgr vport ID . */ uint16_t max_wqe_sz_sq; };
drivers/common/mlx5/mlx5_prm.h +29 -0
@@ -1293,6 +1293,7 @@ enum {MLX5_GET_HCA_CAP_OP_MOD_NIC_FLOW_TABLE =0x7 <<1 ,MLX5_SET_HCA_CAP_OP_MOD_ESW =0x9 <<1 ,MLX5_GET_HCA_CAP_OP_MOD_VDPA_EMULATION =0x13 <<1 , +MLX5_GET_HCA_CAP_OP_MOD_CRYPTO =0x1A <<1 ,MLX5_GET_HCA_CAP_OP_MOD_PARSE_GRAPH_NODE_CAP =0x1C <<1 , MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE_2 = 0x20 << 1, };
@@ -3794,6 +3795,34 @@ struct mlx5_ifc_crypto_operational_register_bits {u8 reserved_at_280[0x180 ]; }; +struct mlx5_ifc_crypto_caps_bits { +u8 wrapped_crypto_operational[0x1 ]; +u8 wrapped_crypto_going_to_commissioning[0x1 ]; +u8 sw_wrapped_dek[0x1 ]; +u8 synchronize_dek[0x1 ]; +u8 int_kek_manual[0x1 ]; +u8 int_kek_auto[0x1 ]; +u8 reserved_at_6[0x12 ]; +u8 wrapped_import_method[0x8 ]; +u8 reserved_at_20[0x3 ]; +u8 log_dek_max_alloc[0x5 ]; +u8 reserved_at_28[0x3 ]; +u8 log_max_num_deks[0x5 ]; +u8 reserved_at_30[0x3 ]; +u8 log_max_num_import_keks[0x5 ]; +u8 reserved_at_38[0x3 ]; +u8 log_max_num_creds[0x5 ]; +u8 failed_selftests[0x10 ]; +u8 num_nv_import_keks[0x8 ]; +u8 num_nv_credentials[0x8 ]; +u8 reserved_at_60[0x3 ]; +u8 log_dek_granularity[0x5 ]; +u8 reserved_at_68[0x3 ]; +u8 log_max_num_int_kek[0x5 ]; +u8 reserved_at_70[0x10 ]; +u8 reserved_at_80[0x780 ]; +}; +struct mlx5_ifc_crypto_commissioning_register_bits {u8 token[0x1 ];/* TODO: add size after PRM update */ };
Signature · 1 line
2.21.0
RE: [EXT] [PATCH 1/2] common/mlx5: extend crypto capabilities
Quoted 17 lines
drivers/common/mlx5/mlx5_prm.h +17
-0+struct mlx5_ifc_crypto_caps_bits { +u8 wrapped_crypto_operational[0x1 ]; +u8 wrapped_crypto_going_to_commissioning[0x1 ]; +u8 sw_wrapped_dek[0x1 ]; +u8 synchronize_dek[0x1 ]; +u8 int_kek_manual[0x1 ]; +u8 int_kek_auto[0x1 ]; +u8 reserved_at_6[0x12 ]; +u8 wrapped_import_method[0x8 ]; +u8 reserved_at_20[0x3 ]; +u8 log_dek_max_alloc[0x5 ]; +u8 reserved_at_28[0x3 ]; +u8 log_max_num_deks[0x5 ]; +u8 reserved_at_30[0x3 ]; +u8 log_max_num_import_keks[0x5 ]; +u8 reserved_at_38[0x3 ]; +u8 log_max_num_creds[0x5 ];
drivers/common/mlx5/mlx5_prm.h struct mlx5_ifc_crypto_operational_register_bits { · line 3824
Quoted 10 lines
drivers/common/mlx5/mlx5_prm.h +10
-0+u8 failed_selftests[0x10 ]; +u8 num_nv_import_keks[0x8 ]; +u8 num_nv_credentials[0x8 ]; +u8 reserved_at_60[0x3 ]; +u8 log_dek_granularity[0x5 ]; +u8 reserved_at_68[0x3 ]; +u8 log_max_num_int_kek[0x5 ]; +u8 reserved_at_70[0x10 ]; +u8 reserved_at_80[0x780 ]; +};
Where is this structure getting used?
PATCH 2/2 crypto/mlx5: support plaintext keys
In reply to Raja ZidaneUsing crypto devs requires the user to log in and the supplied DEK to be encrypted with a KEK (keys encryption key).
KEK is burned once on the nic, along with credentials for users, and for a user to log in, he is needed to supply his creds wrapped with the KEK.
A device comes out of the Mellanox factory with a pre-defined import method for each algorithm. The defined method could be wrapped mode, so the device can be used as described above, or plaintext mode, without the need to log in and wrap supplied DEKs.
Support crypto operations with the plaintext import method.
--- doc/guides/cryptodevs/mlx5.rst | 17 ++++++++-- drivers/crypto/mlx5/mlx5_crypto.c | 43 +++++++++++++++--------- drivers/crypto/mlx5/mlx5_crypto.h | 3 +- drivers/crypto/mlx5/mlx5_crypto_dek.c | 47 +++++++++++++++++++-------- 4 files changed, 76 insertions(+), 34 deletions(-)
doc/guides/cryptodevs/mlx5.rst +14 -3
@@ -35,6 +35,10 @@ Configuration See the :ref:`mlx5 common configuration <mlx5_common_env>`. +A device comes out of Mellanox factory with pre-defined import methods. +There are two possible import methods: wrapped or plaintext. + +In case the device is in wrapped mode, it needs to be moved to crypto operational mode. In order to move the device to crypto operational mode, credential and KEK (Key Encrypting Key) should be set as the first step. The credential will be used by the software in order to perform crypto login, and the KEK is
@@ -89,10 +93,17 @@ The mlxreg dedicated tool should be used as follows: The "wrapped_crypto_operational" value will be "0x00000001" if the mode was successfully changed to operational mode. +On the other hand, in case of plaintext mode, there is no need for all the above, +DEK is passed in plaintext without keytag. + The mlx5 crypto PMD can be verified by running the test application:: + Wrapped mode: + dpdk-test -c 1 -n 1 -w <dev>,class=crypto,wcs_file=<file_path> + RTE>>cryptodev_mlx5_autotest - dpdk-test -c 1 -n 1 -w <dev>,class=crypto,wcs_file=<file_path> - RTE>>cryptodev_mlx5_autotest + Plaintext mode: + dpdk-test -c 1 -n 1 -w <dev>,class=crypto + RTE>>cryptodev_mlx5_autotest Driver options
@@ -101,7 +112,7 @@ Driver options Please refer to :ref:`mlx5 common options <mlx5_common_driver_options>` for an additional list of options shared with other mlx5 drivers. -- ``wcs_file`` parameter [string] - mandatory +- ``wcs_file`` parameter [string] - mandatory in wrapped mode File path including only the wrapped credential in string format of hexadecimal numbers, represent 48 bytes (8 bytes IV added by the AES key wrap algorithm).
drivers/crypto/mlx5/mlx5_crypto.c +27 -16
116 lines not on this page · raw message
drivers/crypto/mlx5/mlx5_crypto.h +2 -1
@@ -38,6 +38,7 @@ struct mlx5_crypto_priv {uint16_t umr_wqe_size;uint16_t umr_wqe_stride;uint16_t max_rdmar_ds; + uint32_t is_wrapped_mode:1; };struct mlx5_crypto_qp {
@@ -59,7 +60,7 @@ struct mlx5_crypto_dek {struct mlx5_list_entry entry;/* Pointer to DEK hash list entry. */ struct mlx5_devx_obj *obj;/* Pointer to DEK DevX object. */ uint8_t data[MLX5_CRYPTO_KEY_LENGTH ];/* DEK key data. */ -bool size_is_48;/* Whether the key\data size is 48 bytes or not. */ +uint32_t size;/* key+keytag size. */ } __rte_cache_aligned;struct mlx5_crypto_devarg_params {
drivers/crypto/mlx5/mlx5_crypto_dek.c +33 -14
67 lines not on this page · raw message
Signature · 1 line
2.21.0