[PATCH 2/5] common/cnxk: derive hash key for MACsec
Akhil Goyal
gakhil at marvell.com
Wed Sep 28 14:45:13 CEST 2022
Signed-off-by: Akhil Goyal <gakhil at marvell.com>
---
drivers/common/cnxk/roc_aes.c | 17 +++++++++++++++++
drivers/common/cnxk/roc_aes.h | 2 ++
drivers/common/cnxk/version.map | 1 +
3 files changed, 20 insertions(+)
diff --git a/drivers/common/cnxk/roc_aes.c b/drivers/common/cnxk/roc_aes.c
index f821c8b710..f69ecc1d58 100644
--- a/drivers/common/cnxk/roc_aes.c
+++ b/drivers/common/cnxk/roc_aes.c
@@ -206,3 +206,20 @@ roc_aes_xcbc_key_derive(const uint8_t *auth_key, uint8_t *derived_key)
cipher(k3, derived_key, aes_ks);
}
+
+void
+roc_aes_hash_key_derive(const uint8_t *key, uint16_t len, uint8_t hash_key[])
+{
+ uint32_t aes_ks[KEY_SCHEDULE_LEN] = {0};
+ uint8_t data[16] = {0x0};
+ int i;
+
+ if (len == 16) {
+ aes_key_expand(key, aes_ks);
+ cipher(data, hash_key, aes_ks);
+ for (i = 0; i < 16; i++)
+ plt_info(" 0x%x", hash_key[i]);
+ } else {
+ plt_err("\n AES-256 key conversion not supported");
+ }
+}
diff --git a/drivers/common/cnxk/roc_aes.h b/drivers/common/cnxk/roc_aes.h
index 954039139f..e3f6160e7c 100644
--- a/drivers/common/cnxk/roc_aes.h
+++ b/drivers/common/cnxk/roc_aes.h
@@ -10,5 +10,7 @@
*/
void __roc_api roc_aes_xcbc_key_derive(const uint8_t *auth_key,
uint8_t *derived_key);
+void __roc_api roc_aes_hash_key_derive(const uint8_t *key, uint16_t len,
+ uint8_t *hash_key);
#endif /* _ROC_AES_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 5cdc70e0e0..38bf832388 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -29,6 +29,7 @@ INTERNAL {
roc_ae_ec_grp_put;
roc_ae_fpm_get;
roc_ae_fpm_put;
+ roc_aes_hash_key_derive;
roc_aes_xcbc_key_derive;
roc_bphy_cgx_cpri_mode_change;
roc_bphy_cgx_cpri_mode_misc;
--
2.25.1
More information about the dev
mailing list