crypto: caam - warn if blob_gen key is insecure

If CAAM is not in "trusted" or "secure" state, a fixed non-volatile key
is used instead of the unique device key. This is the default mode of
operation without secure boot (HAB). In this scenario, CAAM encrypted
blobs should be used only for testing but not in a production
environment, so issue a warning.

Signed-off-by: Nikolaus Voss <nikolaus.voss@haag-streit.com>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Nikolaus Voss 2022-11-21 15:12:41 +01:00 коммит произвёл Herbert Xu
Родитель 31f81401e2
Коммит 6a83830f64
2 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -6,6 +6,7 @@
#define pr_fmt(fmt) "caam blob_gen: " fmt #define pr_fmt(fmt) "caam blob_gen: " fmt
#include <linux/bitfield.h>
#include <linux/device.h> #include <linux/device.h>
#include <soc/fsl/caam-blob.h> #include <soc/fsl/caam-blob.h>
@ -61,12 +62,14 @@ static void caam_blob_job_done(struct device *dev, u32 *desc, u32 err, void *con
int caam_process_blob(struct caam_blob_priv *priv, int caam_process_blob(struct caam_blob_priv *priv,
struct caam_blob_info *info, bool encap) struct caam_blob_info *info, bool encap)
{ {
const struct caam_drv_private *ctrlpriv;
struct caam_blob_job_result testres; struct caam_blob_job_result testres;
struct device *jrdev = &priv->jrdev; struct device *jrdev = &priv->jrdev;
dma_addr_t dma_in, dma_out; dma_addr_t dma_in, dma_out;
int op = OP_PCLID_BLOB; int op = OP_PCLID_BLOB;
size_t output_len; size_t output_len;
u32 *desc; u32 *desc;
u32 moo;
int ret; int ret;
if (info->key_mod_len > CAAM_BLOB_KEYMOD_LENGTH) if (info->key_mod_len > CAAM_BLOB_KEYMOD_LENGTH)
@ -100,6 +103,12 @@ int caam_process_blob(struct caam_blob_priv *priv,
goto out_unmap_in; goto out_unmap_in;
} }
ctrlpriv = dev_get_drvdata(jrdev->parent);
moo = FIELD_GET(CSTA_MOO, ioread32(&ctrlpriv->ctrl->perfmon.status));
if (moo != CSTA_MOO_SECURE && moo != CSTA_MOO_TRUSTED)
dev_warn(jrdev,
"using insecure test key, enable HAB to use unique device key!\n");
/* /*
* A data blob is encrypted using a blob key (BK); a random number. * A data blob is encrypted using a blob key (BK); a random number.
* The BK is used as an AES-CCM key. The initial block (B0) and the * The BK is used as an AES-CCM key. The initial block (B0) and the

Просмотреть файл

@ -426,6 +426,9 @@ struct caam_perfmon {
u32 rsvd2; u32 rsvd2;
#define CSTA_PLEND BIT(10) #define CSTA_PLEND BIT(10)
#define CSTA_ALT_PLEND BIT(18) #define CSTA_ALT_PLEND BIT(18)
#define CSTA_MOO GENMASK(9, 8)
#define CSTA_MOO_SECURE 1
#define CSTA_MOO_TRUSTED 2
u32 status; /* CSTA - CAAM Status */ u32 status; /* CSTA - CAAM Status */
u64 rsvd3; u64 rsvd3;