Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1353760rwb; Mon, 7 Nov 2022 00:11:35 -0800 (PST) X-Google-Smtp-Source: AMsMyM4yy+nbfdmUjGtljGCdYJuihKDbY0hBJoIn5UlW6U8W4NfATmwp4ZexH4SEhP+1aGsvAByx X-Received: by 2002:a05:6a00:a04:b0:534:d8a6:40ce with SMTP id p4-20020a056a000a0400b00534d8a640cemr50088110pfh.15.1667808695699; Mon, 07 Nov 2022 00:11:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667808695; cv=none; d=google.com; s=arc-20160816; b=hy+eaaUdOD9KtjpsVoAYy7RqxQScLPoGagemtfKaOU0o4j+e2VXDmV98usXY5tPRh0 niHXechEvJWCs2hvhl5EGVKbCoOPKlGv4eE/JBR6tFa744M4aLUjO+qu+R7tqQv6yFQG g2eSJTXBaDV8ODFtV7IuacEbT2cnyBLmR1ZC0skpQwRbK8A0GeL8rX9Zsf6dDsTYuF6l QUat2Y566eqF1/zfVPyvbts7WNc9NHXXeTVbNkrFLHjKV9f59aXR7gJvUmP7mxoMCOj3 YGZx7tuTQY0USSR3OPM9wHc0HRpq9XcwGuV+DWvtLpCg2ugzrckeHP0I+a9Afs7c9Boa XbUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:subject:date:cc:to:from; bh=A7KTOFjQKBYM1LbFVheBtYMhhRPoePK4l1jhiz4z20M=; b=I0BxZbnEFrhv1ubcXrxyoyaxfzJqr0gAhrSMW6JWnjHVfrcDKVQP9hGS4sfuyiKYj7 a304cbzPlZrfc+owXiWkW3HJamUfwg+1skRbLVUvc0mod3uEpRX/zTE6S66oRZa94NOF tE2xOzW/aEuI0QTvbqIsqwiUXisvMTNge5xvOncKvRLZu/Kia8HfAIsuGlK3OYRfuIuI nF4GRMJ2OsF2eRGlXStgDtg0dxw1z3Gp7d7MQOF7n+1a3wU1SFi4vh6fh7aYB1AjZelD lgk3mCWEDCfzFH2+YYrX7Hf0Ije0XAgJZM3GWg9nre84SLHFz10w7f7yFmYtsxD6Nkws oJBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=haag-streit.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x20-20020a170902e05400b00174e7dc1ddesi7877108plx.541.2022.11.07.00.11.21; Mon, 07 Nov 2022 00:11:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=haag-streit.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbiKGIID (ORCPT + 99 others); Mon, 7 Nov 2022 03:08:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231377AbiKGIIC (ORCPT ); Mon, 7 Nov 2022 03:08:02 -0500 Received: from mail.steuer-voss.de (mail.steuer-voss.de [85.183.69.95]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F377212AB3; Mon, 7 Nov 2022 00:08:00 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at mail.steuer-voss.de Received: by mail.steuer-voss.de (Postfix, from userid 1000) id E0AA673D8; Mon, 7 Nov 2022 09:07:56 +0100 (CET) From: Nikolaus Voss To: "Horia Geanta" , Pankaj Gupta , Gaurav Jain , Herbert Xu , "David S. Miller" , Ahmad Fatoum , David Gstir , Steffen Trumtrar , Nikolaus Voss Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 7 Nov 2022 09:00:30 +0100 Subject: [PATCH v2] crypto: caam: blob_gen.c: warn if key is insecure Message-Id: <20221107080756.E0AA673D8@mail.steuer-voss.de> X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 --- Changes ======= v2: make warning more verbose, correct register, style fixes drivers/crypto/caam/blob_gen.c | 9 +++++++++ drivers/crypto/caam/regs.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/drivers/crypto/caam/blob_gen.c b/drivers/crypto/caam/blob_gen.c index 6345c7269eb0..4185cf5f5c55 100644 --- a/drivers/crypto/caam/blob_gen.c +++ b/drivers/crypto/caam/blob_gen.c @@ -6,6 +6,7 @@ #define pr_fmt(fmt) "caam blob_gen: " fmt +#include #include #include @@ -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, struct caam_blob_info *info, bool encap) { + const struct caam_drv_private *ctrlpriv; struct caam_blob_job_result testres; struct device *jrdev = &priv->jrdev; dma_addr_t dma_in, dma_out; int op = OP_PCLID_BLOB; size_t output_len; u32 *desc; + u32 moo; int ret; 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; } + ctrlpriv = dev_get_drvdata(jrdev->parent); + moo = FIELD_GET(CSTA_MOO, 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. * The BK is used as an AES-CCM key. The initial block (B0) and the diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index 66d6dad841bb..66928f8a0c4b 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -426,6 +426,9 @@ struct caam_perfmon { u32 rsvd2; #define CSTA_PLEND BIT(10) #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 */ u64 rsvd3; -- 2.34.1