mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
scsi: ufs: rpmb: Use a fixed-length RPMB dev_id
The RPMB authentication key is derived from the dev_id handed to the RPMB subsystem. OP-TEE implements the eMMC RPMB flow, where the dev_id is the eMMC CID: a fixed 16-byte value the key derivation depends on. The UFS RPMB id is "<device_id>-R<region>", which is variable length and longer than 16 bytes. Handing it to the RPMB subsystem as-is would tie the derived key to a length OP-TEE does not expect and diverge from the fixed-CID eMMC ABI, forcing OP-TEE to be taught about variable-length UFS ids. A fixed 16-byte dev_id is needed so the derived key stays stable and unique per region while matching the eMMC CID layout OP-TEE relies on, keeping the key-derivation ABI identical with no OP-TEE change. The reduction to a fixed 16 bytes must also be reproducible by the bootloaders (such as U-Boot) that derive the same dev_id. Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com> Reviewed-by: Bean Huo <beanhuo@micron.com> Reviewed-by: Stanley Jhu <stanleyjhu@google.com> Link: https://patch.msgid.link/20260831154804.719528-3-jorge.ramirez@oss.qualcomm.com Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
This commit is contained in:
parent
a8a34238e5
commit
657eff806d
|
|
@ -7,6 +7,7 @@ menuconfig SCSI_UFSHCD
|
|||
tristate "Universal Flash Storage Controller"
|
||||
depends on SCSI && SCSI_DMA
|
||||
depends on RPMB || !RPMB
|
||||
select CRYPTO_LIB_BLAKE2B if RPMB
|
||||
select PM_DEVFREQ
|
||||
select DEVFREQ_GOV_SIMPLE_ONDEMAND
|
||||
select NLS
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
* Can Guo <can.guo@oss.qualcomm.com>
|
||||
*/
|
||||
|
||||
#include <crypto/blake2b.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/kernel.h>
|
||||
|
|
@ -21,6 +22,7 @@
|
|||
#include <linux/unaligned.h>
|
||||
#include "ufshcd-priv.h"
|
||||
|
||||
#define UFS_RPMB_ID_LEN 16 /* Match eMMC CID Length */
|
||||
#define UFS_RPMB_UA_RETRIES 3 /* Retries for the power-on UNIT ATTENTION */
|
||||
#define UFS_RPMB_SEC_PROTOCOL 0xEC /* JEDEC UFS application */
|
||||
#define UFS_RPMB_SEC_PROTOCOL_ID 0x01 /* JEDEC UFS RPMB protocol ID, CDB byte3 */
|
||||
|
|
@ -157,6 +159,7 @@ static void ufs_rpmb_device_release(struct device *dev)
|
|||
int ufs_rpmb_probe(struct ufs_hba *hba)
|
||||
{
|
||||
struct ufs_rpmb_dev *ufs_rpmb, *it, *tmp;
|
||||
u8 dev_id[UFS_RPMB_ID_LEN];
|
||||
struct rpmb_dev *rdev;
|
||||
char *cid = NULL;
|
||||
int region;
|
||||
|
|
@ -215,8 +218,10 @@ int ufs_rpmb_probe(struct ufs_hba *hba)
|
|||
goto err_out;
|
||||
}
|
||||
|
||||
descr.dev_id = cid;
|
||||
descr.dev_id_len = strlen(cid);
|
||||
blake2b(NULL, 0, cid, strlen(cid), dev_id, UFS_RPMB_ID_LEN);
|
||||
|
||||
descr.dev_id = dev_id;
|
||||
descr.dev_id_len = UFS_RPMB_ID_LEN;
|
||||
descr.capacity = cap;
|
||||
|
||||
/* Register RPMB device */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user