Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2583986rdb; Mon, 5 Feb 2024 10:53:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEU9f5FqlGh/2EqiMz+HCNqHhL3i3quC/l4WZcRcfq7Q56u9+69T5WbQbE4HmWAknrIJK5 X-Received: by 2002:a05:6808:181e:b0:3bd:e9e0:742f with SMTP id bh30-20020a056808181e00b003bde9e0742fmr728392oib.24.1707159206090; Mon, 05 Feb 2024 10:53:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707159206; cv=pass; d=google.com; s=arc-20160816; b=hOWTUUK+BUyH0woGXv6ya+bpIXtSYQDGvWk27tq45nsY2OemffpW1FfoHW+qzI47Vy TY4+vsuoGxx2C79Wg9KqLqO8TfGTkdplTYPY0euYjgcXc5vW/kgsRxq9AUwKjhDpRjlM pE5FYkWYyoZu6LAs/HpY9t04Dwf3ar2lkKknTrrkA+sPN4w677SihmMDQ6Z5zK5iB/xv S950h/drAiOcpTkHO56saijyni1BwHvBCSuVGmDNkYCLrTLmtjliWHhkW1VOBdJXE6gj CFVzjRnvZptENGCW5stEGb3Yghe4qoVU+xdnVUe0l1paRDbvLLsZiHWnDIUdAmu2iehj RDew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=kjzGJ6+VG2q6YyyIjm4mdcUaEPT7zDKwvxSE2vY/PKU=; fh=khWlGriqu7gBxP3PnMyjX4uFy3BSA3mq7dFZwhzJvRg=; b=Cwi/7grsIq6oHUlNT8rl8uHCkFZapLRGVAE2syE11JP09WrHxe4vnq4T24zrVGTShL Cb7mSwecuLliMe/wy1Dsql5R/NeoR1XCTh/cMRbPcbxBCJk0u7KAbWe37oVnRKqEMmTV Fv5oZq3ddZJvZOFL/o2ufLjPywFoqG02pXM7mVXUTbsh9axNsoNdjmIrhob+b8UO6e9b 8JlxbCUSbttrDrkpscO+qDg0cT3vPR4EiliHaFW+mn6RiAzfAL5XwnzyfU50aFZLP8Qh XFtCWKFxP/DTN1OLmoxa9D9QFzy6jXkY4vrug3XCSldxR9OPw/475JQi8/VxSaECoGHw o8Eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jXpc3DWW; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-crypto+bounces-1864-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1864-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCX2c/gieH2argS6ZFXy/ei3ze6z4A0gEHIrc2yKYJ3vrrGXjVr2KL1Wqf7yriDuaf5DYVe2q0YqdnSO9agnf5e3SaoR1KcXQwhDXYUv3A== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v13-20020a05622a144d00b0042c2742d804si462328qtx.765.2024.02.05.10.53.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:53:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1864-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jXpc3DWW; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-crypto+bounces-1864-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1864-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C2C051C22A4B for ; Mon, 5 Feb 2024 18:53:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2ED754B5BF; Mon, 5 Feb 2024 18:52:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="jXpc3DWW" X-Original-To: linux-crypto@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A2CA481DF; Mon, 5 Feb 2024 18:52:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707159159; cv=none; b=jGPQThn2GyKatT43XB764/bCsbjCHDpiUAvzM/j8bMG0JfSn/fDllM6/A2v0lnqUlY99cqKCDQoVSB7Zg9ggUHYtGqij07f+2r1bs65CYbmXxFBlnJpDiMy+wBRIY4QQL6IfsO7C5M8GG9LRRs1Z8hJh8jsIV/WGGtLGNMXmMzs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707159159; c=relaxed/simple; bh=hty5bfalgTAxBFUTkl9L2easTarTfXs+9225IUA9VuI=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=iT5mo1TWgCkgx6of2CVqYcn+JEVqC6dScR2vzqaZJb7nbhjVFW10x4RSobMOvrLM7so8BLl0nVWcrn4y83CfbeVa73/CXfO4/8eSCPTGDE4ip3H1DjNpYEA2pRI0u8N7p7XQO3Iqrqr+R7TN8vjxQf4MUlQ8AWAbTVm4jV6ULOU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=jXpc3DWW; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4158TS88011321; Mon, 5 Feb 2024 18:52:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=kjzGJ6+VG2q6YyyIjm4mdcUaEPT7zDKwvxSE2vY/PKU=; b=jX pc3DWW6L3ldASCT3y6aYDErxmHbk0iQVtkO3N9Qec3e4Gg7oM98zYqrGLL9DD356 hjyRfz1GxL9PAB+UABklUipjSXxXKRTREFIbaySjCTTVINjfR4hmDHIx3eEyY/Tq bNfvOdbJL+zeonbdj0bSXU4R3M8qFFQlwelL2fFaAM6Eip7P/lYbtHX3RIZht/Cn ZifJYKHi5Dwj0xp1hddMmlXiUWgAWZZE99ZeXkupA1wqXQ+TE0kxA/R84E0ikOX0 6Zi3pS6hpKjBRMHfJUFqbrCCTBwdwoVvURzoj80JggIY0+6V6bnxfcA2qWNUnw0Q oKs01/dUiJ8MCH57VnFQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w2v729ep9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 18:52:24 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 415IqNIK015622 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 5 Feb 2024 18:52:23 GMT Received: from [10.216.24.76] (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 5 Feb 2024 10:52:12 -0800 Message-ID: Date: Tue, 6 Feb 2024 00:22:08 +0530 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 08/15] ufs: core: add support to derive software secret Content-Language: en-US To: Gaurav Kashyap , , , , , , , , , CC: , , , , , , , , , , , , , References: <20240127232436.2632187-1-quic_gaurkash@quicinc.com> <20240127232436.2632187-9-quic_gaurkash@quicinc.com> From: Om Prakash Singh In-Reply-To: <20240127232436.2632187-9-quic_gaurkash@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: _dhgBUtqDWE-SCwyCYbPVC1wh1FcJJ7A X-Proofpoint-ORIG-GUID: _dhgBUtqDWE-SCwyCYbPVC1wh1FcJJ7A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-05_12,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 clxscore=1015 spamscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402050141 On 1/28/2024 4:44 AM, Gaurav Kashyap wrote: > Block crypto allows storage controllers like UFS to > register an op derive a software secret from wrapped > keys added to the kernel. > > Wrapped keys in most cases will have vendor specific > implementations, which means this op would need to have > a corresponding UFS variant op. > This change adds hooks in UFS core to support this variant > ops and tie them to the blk crypto op. > > Signed-off-by: Gaurav Kashyap > Tested-by: Neil Armstrong > --- Reviewed-by: Om Prakash Singh > drivers/ufs/core/ufshcd-crypto.c | 15 +++++++++++++++ > include/ufs/ufshcd.h | 4 ++++ > 2 files changed, 19 insertions(+) > > diff --git a/drivers/ufs/core/ufshcd-crypto.c b/drivers/ufs/core/ufshcd-crypto.c > index 399b55d67b3b..c14800eac1ff 100644 > --- a/drivers/ufs/core/ufshcd-crypto.c > +++ b/drivers/ufs/core/ufshcd-crypto.c > @@ -119,6 +119,20 @@ static int ufshcd_crypto_keyslot_evict(struct blk_crypto_profile *profile, > return ufshcd_clear_keyslot(hba, slot); > } > > +static int ufshcd_crypto_derive_sw_secret(struct blk_crypto_profile *profile, > + const u8 wkey[], size_t wkey_size, > + u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE]) > +{ > + struct ufs_hba *hba = > + container_of(profile, struct ufs_hba, crypto_profile); > + > + if (hba->vops && hba->vops->derive_sw_secret) > + return hba->vops->derive_sw_secret(hba, wkey, wkey_size, > + sw_secret); > + > + return -EOPNOTSUPP; > +} > + > bool ufshcd_crypto_enable(struct ufs_hba *hba) > { > if (!(hba->caps & UFSHCD_CAP_CRYPTO)) > @@ -132,6 +146,7 @@ bool ufshcd_crypto_enable(struct ufs_hba *hba) > static const struct blk_crypto_ll_ops ufshcd_crypto_ops = { > .keyslot_program = ufshcd_crypto_keyslot_program, > .keyslot_evict = ufshcd_crypto_keyslot_evict, > + .derive_sw_secret = ufshcd_crypto_derive_sw_secret, > }; > > static enum blk_crypto_mode_num > diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h > index 680c010a53d4..8a773434a329 100644 > --- a/include/ufs/ufshcd.h > +++ b/include/ufs/ufshcd.h > @@ -321,6 +321,7 @@ struct ufs_pwr_mode_info { > * @device_reset: called to issue a reset pulse on the UFS device > * @config_scaling_param: called to configure clock scaling parameters > * @program_key: program or evict an inline encryption key > + * @derive_sw_secret: derive sw secret from a wrapped key > * @event_notify: called to notify important events > * @reinit_notify: called to notify reinit of UFSHCD during max gear switch > * @mcq_config_resource: called to configure MCQ platform resources > @@ -365,6 +366,9 @@ struct ufs_hba_variant_ops { > int (*program_key)(struct ufs_hba *hba, > const struct blk_crypto_key *bkey, > const union ufs_crypto_cfg_entry *cfg, int slot); > + int (*derive_sw_secret)(struct ufs_hba *hba, const u8 wkey[], > + unsigned int wkey_size, > + u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE]); > void (*event_notify)(struct ufs_hba *hba, > enum ufs_event_type evt, void *data); > void (*reinit_notify)(struct ufs_hba *);