diff mbox series

[RFC,6/6] mmc: host: support for generate, import and prepare key

Message ID 20241101031539.13285-7-quic_spuppala@quicinc.com
State New
Headers show
Series Hardware wrapped key support for MMC core | expand

Commit Message

Seshu Madhavi Puppala Nov. 1, 2024, 3:15 a.m. UTC
MMC defines variant ops to support generate, prepare and import
wrapped key blk crypto ops to tie these operations to vendor
specific implementations. This patch defines and implements
these variant ops for Qualcomm SoCs which uses eMMC storage.

Signed-off-by: Seshu Madhavi Puppala <quic_spuppala@quicinc.com>
---
 drivers/mmc/host/sdhci-msm.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index aba1d6e688b6..9b3090c1f917 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -1912,6 +1912,37 @@  static int sdhci_msm_ice_derive_sw_secret(struct cqhci_host *cq_host, const u8 w
 	return qcom_ice_derive_sw_secret(msm_host->ice, wkey, wkey_size, sw_secret);
 }
 
+static int sdhci_msm_generate_key(struct cqhci_host *cq_host,
+				  u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE])
+{
+	struct sdhci_host *host = mmc_priv(cq_host->mmc);
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
+
+	return qcom_ice_generate_key(msm_host->ice, lt_key);
+}
+
+static int sdhci_msm_prepare_key(struct cqhci_host *cq_host,
+			  const u8 *lt_key, size_t lt_key_size,
+			  u8 eph_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE])
+{
+	struct sdhci_host *host = mmc_priv(cq_host->mmc);
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
+
+	return qcom_ice_prepare_key(msm_host->ice, lt_key, lt_key_size, eph_key);
+}
+
+static int sdhci_msm_import_key(struct cqhci_host *cq_host,
+				const u8 *imp_key, size_t imp_key_size,
+				u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE])
+{
+	struct sdhci_host *host = mmc_priv(cq_host->mmc);
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
+
+	return qcom_ice_import_key(msm_host->ice, imp_key, imp_key_size, lt_key);
+}
 #else /* CONFIG_MMC_CRYPTO */
 
 static inline int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host,
@@ -2019,6 +2050,9 @@  static const struct cqhci_host_ops sdhci_msm_cqhci_ops = {
 #ifdef CONFIG_MMC_CRYPTO
 	.program_key	= sdhci_msm_program_key,
 	.derive_sw_secret	= sdhci_msm_ice_derive_sw_secret,
+	.generate_key	= sdhci_msm_generate_key,
+	.prepare_key	= sdhci_msm_prepare_key,
+	.import_key	= sdhci_msm_import_key,
 #endif
 };