Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: mxs-dcp - Only set OTP_KEY bit for OTP key

While MXS_DCP_CONTROL0_OTP_KEY is set, the CRYPTO_KEY (DCP_PAES_KEY_OTP)
is used even if the UNIQUE_KEY (DCP_PAES_KEY_UNIQUE) is selected. This
is not clearly documented, but this implementation is consistent with
NXP's downstream kernel fork and optee_os.

Signed-off-by: Sven Schwermer <sven@svenschwermer.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Sven Schwermer and committed by
Herbert Xu
caa9dbb7 d4880fe6

+4 -4
+4 -4
drivers/crypto/mxs-dcp.c
··· 265 265 MXS_DCP_CONTROL0_INTERRUPT | 266 266 MXS_DCP_CONTROL0_ENABLE_CIPHER; 267 267 268 - if (key_referenced) 269 - /* Set OTP key bit to select the key via KEY_SELECT. */ 270 - desc->control0 |= MXS_DCP_CONTROL0_OTP_KEY; 271 - else 268 + if (!key_referenced) 272 269 /* Payload contains the key. */ 273 270 desc->control0 |= MXS_DCP_CONTROL0_PAYLOAD_KEY; 271 + else if (actx->key[0] == DCP_PAES_KEY_OTP) 272 + /* Set OTP key bit to select the key via KEY_SELECT. */ 273 + desc->control0 |= MXS_DCP_CONTROL0_OTP_KEY; 274 274 275 275 if (rctx->enc) 276 276 desc->control0 |= MXS_DCP_CONTROL0_CIPHER_ENCRYPT;