From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0385F17591 for ; Mon, 10 Feb 2025 04:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739162695; cv=none; b=OTN5U4TRnQ8eyZSMyaLXFlKMVmoEKfBbhR19B0Eabw9sG5BYr/w5Mj2mkUtiSLO5OapvX07lpPb0Peu7T7hEbwC4oHu0XBdQTteL8qJexbeOEiJFFUU+cR15cT051lRP41XVqkXX0KZYHfXkflbk+pz1Hyy65WwxcTsvMRxMoWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739162695; c=relaxed/simple; bh=vTanPSj0WJSOQJ6VK+dSr4V6tineoC/hsdguGdxz6Ao=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UotJQMpUJ3CDAMfjPsxWtsS+CIzKEgG2Ub4Ev0nHT4J4PHdpM45uu/qQNXB6vhSBBoS1UwMX2kxonsyOQqgMpBmahMdnWDDvLm67wPIWof/oowNmMjiO60rU4r5igBNnFNIIFgyTvXf1Vg17W6nG4Yud5BxiDIyujD1JYRVVHyE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=XareteWg; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XareteWg" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2fa5af6d743so1527991a91.3 for ; Sun, 09 Feb 2025 20:44:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739162691; x=1739767491; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=nF3QMZZh+uHZ+XUypTIOVnYHXZf3sl/wR22/LqBDNSc=; b=XareteWg22SH0Jwhxaz2ViALmGAbvbFygvDRPm9MZUSIPSIcwOjCM+A0wXeZ8f9t1p gDampvr0OUV8RZ7ZVNLc37aceoCvw+XrI6MfGKKJKwC95v/U3yBHwlDNE9pBxXmjjSEM Aal+FesM1awuKFO5quF8KUzfFZ6eGR7Xs5afXKBpix19GLp4BlnhKLEYzLZ0FlG1OptU FTSujHq6XpN7y/vozITYu4jj+g6zjs5DApAM5/pwRhhnWhhN903cgUJIEDSWJtFoaDlv VANmO6yvc1FSQywTt+3oLAF0dnHZT1ST3NFIWqcUGoy9CYil5++0KG04BSveoISHbWwD NIsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739162691; x=1739767491; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nF3QMZZh+uHZ+XUypTIOVnYHXZf3sl/wR22/LqBDNSc=; b=uGes9CrWbGcghg7MVNoD3BDqIHBSGbTyYVPelIHr9TyllJHycfGQeDrb5tlNLaJs8c zae8Ggd6AMfzXB6fg0/fIylW8EfxYzmWPeXppuxzRBkrBexIVweP3Eg65lfIJRJYWc7g 3pTKAs1lFIPX0X6iZze2jGyCSJp1Ww9vgLi1jhAkKfPFnZL2Z7QWcbijwoC67GwHIZna RtovIrnACDbhxTVulEZ1i/1fQSQDHO8qeek5S/vDpT39CzgYADalmo//IAP0fMyAdUbL 3yIG7Rll1gLgmlEy4X8LSJCdQpkb/aUvimTSDF57t7j/yikBxolLKOlMFuA3RqS9vIdM CuWQ== X-Forwarded-Encrypted: i=1; AJvYcCVYH2RV9IyEjyQkfuJo+Rs7q1SVFh0XbUqoAkvyfIboBmggXoul4vhG0MMHvurvJzM/lUOYbXrTb0E=@vger.kernel.org X-Gm-Message-State: AOJu0YzFxAKEro5BXEKU954lN0jI4RCWJeTFfIk8uUSVjE6d61HoHAKm yMpMtlBXIzNeba/qYEQ8a/S1NQVe2w3xHCJKRn9l8LIoDrEzQsrwMOUNUrPwRA== X-Gm-Gg: ASbGncuo6F4r3ESUTZUByy730xj3Mr4+irHB60lfkSHaKE3Zup/MiFqRjhmc3EVmm0O /YbBTrJbd7KJFlFvWuIXtI8Pldb7tu8uy4kvrd2CKmxuPzWpgfhaq1c8zLJzwV0+F2bYyR9ookX cVPzGMvl6nM7xScOTgN3gyuGKtTXEUl5lNFdsGTYp4xEmYMgGuqz3MnO42hY4Z/Yx7HcBWp4VNP c9Vus0G2ReHFKqG9UHNdBfn+xdUZhS0Zv8U4JD2iiJUoqPdfD0hSdbbWvRTqbHMSl3y1WNp1YHi 01z1/8HAfpcy7WoFgxms2FOT2/KW X-Google-Smtp-Source: AGHT+IEI8FeVLv0rFukXvhLSeUcosU07zHjT/arxCxm962h4GX5fHHBVasy2JjWBqSIvNTOBRXSSKQ== X-Received: by 2002:a17:90a:d443:b0:2ee:5111:a54b with SMTP id 98e67ed59e1d1-2fa243eb4dcmr16162251a91.31.1739162691261; Sun, 09 Feb 2025 20:44:51 -0800 (PST) Received: from thinkpad ([220.158.156.173]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09b3f803sm7611469a91.32.2025.02.09.20.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Feb 2025 20:44:50 -0800 (PST) Date: Mon, 10 Feb 2025 10:14:45 +0530 From: Manivannan Sadhasivam To: Eric Biggers Cc: linux-block@vger.kernel.org, Jens Axboe , Bartosz Golaszewski , Gaurav Kashyap , linux-fscrypt@vger.kernel.org, linux-mmc@vger.kernel.org, linux-scsi@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , Dmitry Baryshkov Subject: Re: [PATCH v11 7/7] ufs: qcom: add support for wrapped keys Message-ID: <20250210044445.vmtfhqjibonhi6j2@thinkpad> References: <20250204060041.409950-1-ebiggers@kernel.org> <20250204060041.409950-8-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20250204060041.409950-8-ebiggers@kernel.org> On Mon, Feb 03, 2025 at 10:00:41PM -0800, Eric Biggers wrote: > From: Eric Biggers > > Wire up the wrapped key support for ufs-qcom by implementing the needed > methods in struct blk_crypto_ll_ops and setting the appropriate flag in > blk_crypto_profile::key_types_supported. > > For more information about this feature and how to use it, refer to > the sections about hardware-wrapped keys in > Documentation/block/inline-encryption.rst and > Documentation/filesystems/fscrypt.rst. > > Based on patches by Gaurav Kashyap . > Reworked to use the custom crypto profile support. > Instead of mentioning the contribution in description, you should use relevant tags IMO. > Signed-off-by: Eric Biggers Acked-by: Manivannan Sadhasivam - Mani > --- > drivers/ufs/host/ufs-qcom.c | 51 ++++++++++++++++++++++++++++++++----- > 1 file changed, 45 insertions(+), 6 deletions(-) > > diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c > index f34527fb02fb2..dc3eb6f29f5b2 100644 > --- a/drivers/ufs/host/ufs-qcom.c > +++ b/drivers/ufs/host/ufs-qcom.c > @@ -132,15 +132,10 @@ static int ufs_qcom_ice_init(struct ufs_qcom_host *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; > - } > - > host->ice = ice; > > /* Initialize the blk_crypto_profile */ > > caps.reg_val = cpu_to_le32(ufshcd_readl(hba, REG_UFS_CCAP)); > @@ -150,11 +145,11 @@ static int ufs_qcom_ice_init(struct ufs_qcom_host *host) > if (err) > return err; > > profile->ll_ops = ufs_qcom_crypto_ops; > profile->max_dun_bytes_supported = 8; > - profile->key_types_supported = BLK_CRYPTO_KEY_TYPE_RAW; > + profile->key_types_supported = qcom_ice_get_supported_key_type(ice); > profile->dev = dev; > > /* > * Currently this driver only supports AES-256-XTS. All known versions > * of ICE support it, but to be safe make sure it is really declared in > @@ -218,13 +213,57 @@ static int ufs_qcom_ice_keyslot_evict(struct blk_crypto_profile *profile, > err = qcom_ice_evict_key(host->ice, slot); > ufshcd_release(hba); > return err; > } > > +static int ufs_qcom_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 ufs_hba *hba = ufs_hba_from_crypto_profile(profile); > + struct ufs_qcom_host *host = ufshcd_get_variant(hba); > + > + return qcom_ice_derive_sw_secret(host->ice, eph_key, eph_key_size, > + sw_secret); > +} > + > +static int ufs_qcom_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 ufs_hba *hba = ufs_hba_from_crypto_profile(profile); > + struct ufs_qcom_host *host = ufshcd_get_variant(hba); > + > + return qcom_ice_import_key(host->ice, raw_key, raw_key_size, lt_key); > +} > + > +static int ufs_qcom_ice_generate_key(struct blk_crypto_profile *profile, > + u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE]) > +{ > + struct ufs_hba *hba = ufs_hba_from_crypto_profile(profile); > + struct ufs_qcom_host *host = ufshcd_get_variant(hba); > + > + return qcom_ice_generate_key(host->ice, lt_key); > +} > + > +static int ufs_qcom_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 ufs_hba *hba = ufs_hba_from_crypto_profile(profile); > + struct ufs_qcom_host *host = ufshcd_get_variant(hba); > + > + return qcom_ice_prepare_key(host->ice, lt_key, lt_key_size, eph_key); > +} > + > static const struct blk_crypto_ll_ops ufs_qcom_crypto_ops = { > .keyslot_program = ufs_qcom_ice_keyslot_program, > .keyslot_evict = ufs_qcom_ice_keyslot_evict, > + .derive_sw_secret = ufs_qcom_ice_derive_sw_secret, > + .import_key = ufs_qcom_ice_import_key, > + .generate_key = ufs_qcom_ice_generate_key, > + .prepare_key = ufs_qcom_ice_prepare_key, > }; > > #else > > static inline void ufs_qcom_ice_enable(struct ufs_qcom_host *host) > -- > 2.48.1 > -- மணிவண்ணன் சதாசிவம்