Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions drivers/mmc/host/sdhci-msm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1914,11 +1914,6 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host,
if (IS_ERR_OR_NULL(ice))
return PTR_ERR_OR_ZERO(ice);

if (qcom_ice_get_supported_key_type(ice) != BLK_CRYPTO_KEY_TYPE_RAW) {
dev_warn(dev, "Wrapped keys not supported. Disabling inline encryption support.\n");
return 0;
}

msm_host->ice = ice;

/* Initialize the blk_crypto_profile */
Expand All @@ -1932,7 +1927,7 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host,

profile->ll_ops = sdhci_msm_crypto_ops;
profile->max_dun_bytes_supported = 4;
profile->key_types_supported = BLK_CRYPTO_KEY_TYPE_RAW;
profile->key_types_supported = qcom_ice_get_supported_key_type(ice);
profile->dev = dev;

/*
Expand Down Expand Up @@ -2013,9 +2008,49 @@ static int sdhci_msm_ice_keyslot_evict(struct blk_crypto_profile *profile,
return qcom_ice_evict_key(msm_host->ice, slot);
}

static int sdhci_msm_ice_derive_sw_secret(struct blk_crypto_profile *profile,
const u8 *eph_key, size_t eph_key_size,
u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE])
{
struct sdhci_msm_host *msm_host = sdhci_msm_host_from_crypto_profile(profile);

return qcom_ice_derive_sw_secret(msm_host->ice, eph_key, eph_key_size,
sw_secret);
}

static int sdhci_msm_ice_import_key(struct blk_crypto_profile *profile,
const u8 *raw_key, size_t raw_key_size,
u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE])
{
struct sdhci_msm_host *msm_host = sdhci_msm_host_from_crypto_profile(profile);

return qcom_ice_import_key(msm_host->ice, raw_key, raw_key_size, lt_key);
}

static int sdhci_msm_ice_generate_key(struct blk_crypto_profile *profile,
u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE])
{
struct sdhci_msm_host *msm_host = sdhci_msm_host_from_crypto_profile(profile);

return qcom_ice_generate_key(msm_host->ice, lt_key);
}

static int sdhci_msm_ice_prepare_key(struct blk_crypto_profile *profile,
const u8 *lt_key, size_t lt_key_size,
u8 eph_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE])
{
struct sdhci_msm_host *msm_host = sdhci_msm_host_from_crypto_profile(profile);

return qcom_ice_prepare_key(msm_host->ice, lt_key, lt_key_size, eph_key);
}

static const struct blk_crypto_ll_ops sdhci_msm_crypto_ops = {
.keyslot_program = sdhci_msm_ice_keyslot_program,
.keyslot_evict = sdhci_msm_ice_keyslot_evict,
.derive_sw_secret = sdhci_msm_ice_derive_sw_secret,
.import_key = sdhci_msm_ice_import_key,
.generate_key = sdhci_msm_ice_generate_key,
.prepare_key = sdhci_msm_ice_prepare_key,
};

#else /* CONFIG_MMC_CRYPTO */
Expand Down