Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B21CC433EF for ; Fri, 12 Nov 2021 19:28:59 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A95B760F41 for ; Fri, 12 Nov 2021 19:28:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A95B760F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5F6298303D; Fri, 12 Nov 2021 20:28:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Qv/+URp5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 169BC83036; Fri, 12 Nov 2021 20:28:54 +0100 (CET) Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1A32982F5A for ; Fri, 12 Nov 2021 20:28:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x230.google.com with SMTP id r26so19769889oiw.5 for ; Fri, 12 Nov 2021 11:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hakeC/iQ8yPrSkjgQmhBvpdcEx3qDWS+u73FaWsTs0Y=; b=Qv/+URp52mBWo0l7xOBiUmNDxKd2eMHikzU83CryfdF5OKThJ7jH63PE5hGOMD5t/V t1iZp394ZfuS4y3X62rjX2BzN0duci77PMDSHhogFytBhXdPWG9/e/5O80G3V0KFbvn8 Ward1AlERhBJMW3m039ClP1+6bRAJfv2Ttw6M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hakeC/iQ8yPrSkjgQmhBvpdcEx3qDWS+u73FaWsTs0Y=; b=FQLlIsRweLiUqABPjsJcnZMyEfYIh9Z67+GBdnTZ4LZaRlLtSNu4PYCAk3OWd34FR/ WS3Vgnyb0yynLbeP/KMHAJWvTVXlbTgyCoNcZ/OnXTliHhy/PUXam3M5P/LBFeS+r/mQ sWONvZ0JLvj0XhZPkgKAuC+zgT4Zn+Oe53CMvpHIXuqMDOFEgyeevX1c96HTuAj8V/sF gcSKGCxonFdIpEovVMsuQrjytS6Jzv3nldb/idhw+g/2RxzpPRS6dZ2YpbkEhAM2QRD5 H2ycWUsoYYICxWngGlJXi/gw0VCvVyv4nmDvvSFxzTZ46zcY6aYQOBrx4TpJfySy2ooU o2jw== X-Gm-Message-State: AOAM531aVIbFD9DoQaU1edrndDIqKQqwR+09JZiamc3mCdT1/gGP2XDh BAREA4WlIoAEPEzxK+pWjY8Ezmat8XA3sw== X-Google-Smtp-Source: ABdhPJz9GGCexVFN0s1l8ndOUxYLheIOJixTqOkkdx0rFw6MjdcIRy6/rpt8JiySAG/s/X1Lj316uQ== X-Received: by 2002:a05:6808:1482:: with SMTP id e2mr6705982oiw.45.1636745328502; Fri, 12 Nov 2021 11:28:48 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id n20sm1283527ooe.7.2021.11.12.11.28.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 11:28:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Rob Herring , Tom Rini , Bill Mills , Simon Glass , Alexandru Gagniuc , Philippe Reynes , Sean Anderson , Thomas Perrot Subject: [PATCH 01/16] rsa: Add debugging for failure cases Date: Fri, 12 Nov 2021 12:28:02 -0700 Message-Id: <20211112192817.199075-2-sjg@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211112192817.199075-1-sjg@chromium.org> References: <20211112192817.199075-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.35 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Add some more debugging to make it easier to see what is being tried and what fails. Fix a few comment styles while here. Signed-off-by: Simon Glass --- lib/rsa/rsa-verify.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 83f7564101c..26ee256cf4c 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -79,14 +79,14 @@ int padding_pkcs_15_verify(struct image_sign_info *info, struct checksum_algo *checksum = info->checksum; int ret, pad_len = msg_len - checksum->checksum_len; - /* Check pkcs1.5 padding bytes. */ + /* Check pkcs1.5 padding bytes */ ret = rsa_verify_padding(msg, pad_len, checksum); if (ret) { debug("In RSAVerify(): Padding check failed!\n"); return -EINVAL; } - /* Check hash. */ + /* Check hash */ if (memcmp((uint8_t *)msg + pad_len, hash, msg_len - pad_len)) { debug("In RSAVerify(): Hash check failed!\n"); return -EACCES; @@ -502,7 +502,8 @@ int rsa_verify_hash(struct image_sign_info *info, if (CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) && !info->fdt_blob) { /* don't rely on fdt properties */ ret = rsa_verify_with_pkey(info, hash, sig, sig_len); - + if (ret) + debug("%s: rsa_verify_with_pkey() failed\n", __func__); return ret; } @@ -522,6 +523,9 @@ int rsa_verify_hash(struct image_sign_info *info, if (info->required_keynode != -1) { ret = rsa_verify_with_keynode(info, hash, sig, sig_len, info->required_keynode); + if (ret) + debug("%s: Failed to verify required_keynode\n", + __func__); return ret; } @@ -531,6 +535,8 @@ int rsa_verify_hash(struct image_sign_info *info, ret = rsa_verify_with_keynode(info, hash, sig, sig_len, node); if (!ret) return ret; + debug("%s: Could not verify key '%s', trying all\n", __func__, + name); /* No luck, so try each of the keys in turn */ for (ndepth = 0, noffset = fdt_next_node(blob, sig_node, @@ -546,6 +552,7 @@ int rsa_verify_hash(struct image_sign_info *info, } } } + debug("%s: Failed to verify by any means\n", __func__); return ret; } -- 2.34.0.rc1.387.gb447b232ab-goog