From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B8E9CC433EF for ; Thu, 10 Feb 2022 07:41:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 68F4980FE1; Thu, 10 Feb 2022 08:41:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="xEIOzqSG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A890780FE1; Thu, 10 Feb 2022 08:41:24 +0100 (CET) Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (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 BA50D80FE1 for ; Thu, 10 Feb 2022 08:41:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x62f.google.com with SMTP id w1so1127098plb.6 for ; Wed, 09 Feb 2022 23:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=6wZH1v5gv+yRMHmp77P3+a9P+qT0PLnKIAajWyacgiU=; b=xEIOzqSGe2P1wjw6jdJr2KcnJx17txffBDFXeoYjV3jmm0t581P0xfAlnLHCdhlxtl ovljPOjwkJGuFAf2njI+QPqmloCp3jW2rx0C/sMoegAU6O1ZKlaIffQZJPAPrc5wuWd9 coOdcCEm+0B5FX6isyt8LsaZcyW17ioW40pZy6OsThhtXnOe/Yffqm2BVuZdokP6530d Ou7Sn3jrENGJ5MyETPZmcsdSbV28paezk2aMASLytoY0B9/iQ49mqPZK2+YjauuLLoIn awjir04uAaTkZKXkG5mT0eflt8RpwpVWGoK6DBEz2QEcYpLOyBDiDRLUvO+dW2+vP626 zCcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=6wZH1v5gv+yRMHmp77P3+a9P+qT0PLnKIAajWyacgiU=; b=GtXVWkzQcYLuCD7pmJbi56dkZg5wAHg6bfsLaJmFrHXBSo7GyXCs0uTTrJUyGgxmer rcPffi+6S5oRRINR/3HXf/hiEuX8v7ZNxWv+jOAtBZXXTYYx78GxKYu1CzQRMBh+SDWf W8mDxGvl+bT6l/xWHM1VaIXRGU+rsu7vr86tbfxMzBvWEYT9TWQmON7/ZupXmmdjlM4f pZ4SDlN8EeKaac3cWlOSgVkkyI61w5ysZdaATUC3a0NxMEzxq1h7vf76zNpHeW2GBfFG Nqmt87jcgavfVhTscVraxV8MVh0fVji9kEl3ARsRLNMegjybEK1pdDC5A/L10A9q96hr ftxA== X-Gm-Message-State: AOAM5312D3XU/DH9j/x6z9wyzsfXnxJwmoj1vXqtjpVI1CqmtZK7gSBi x6srlcPf3nLtOJyGUOIZlrQUNg== X-Google-Smtp-Source: ABdhPJxZlDuVXvmBpunLR4dfmuDacseYj5AdyMA0X5o+JAFv6HPvn6/fawJjcT0M2Oo5LOyCxuL7Xw== X-Received: by 2002:a17:90b:3802:: with SMTP id mq2mr1454746pjb.236.1644478879063; Wed, 09 Feb 2022 23:41:19 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id g12sm5465933pfj.148.2022.02.09.23.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 23:41:18 -0800 (PST) Date: Thu, 10 Feb 2022 16:41:15 +0900 From: AKASHI Takahiro To: Ilias Apalodimas Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: Re: [RFC PATCH 1/2] efi_loader: fix dual signed image certification Message-ID: <20220210074115.GH12412@laputa> Mail-Followup-To: AKASHI Takahiro , Ilias Apalodimas , Heinrich Schuchardt , u-boot@lists.denx.de References: <20220204073202.4141198-1-ilias.apalodimas@linaro.org> <20220210051348.GD12412@laputa> <730ecf32-43d3-58be-63a3-122985d25583@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean On Thu, Feb 10, 2022 at 09:33:46AM +0200, Ilias Apalodimas wrote: > > > > > msg = pkcs7_parse_message(auth, auth_size); > > [...] > > > > > > @@ -717,32 +665,32 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) > > > > > */ > > > > > /* try black-list first */ > > > > > if (efi_signature_verify_one(regs, msg, dbx)) { > > > > > + ret = false; > > > > > EFI_PRINT("Signature was rejected by \"dbx\"\n"); > > > > > - continue; > > > > > + goto out; > > > > > > > > If we go to "out" here, we have no chance to verify some cases: > > > > 1) An image has two signatures, for instance, one signed by SHA1 cert > > > > and the other signed by SHA256 cert. A user wants to reject SHA1 cert > > > > and put the cert in dbx. > > > > > > I am not sure I am following, what does he gain be rejecting the SHA1 > > > portion only? Avoid potential collisions? > > > > If an image has a SHA1 and a SHA256 signature attached and SHA1 *or* > > SHA256 is in dbx, we must reject the image. Don't expect a dbx entry for > > each of the hashes. - But isn't this what your are doing here: for all > > signatures of the image look for one hit in dbx? > > > > Yes exactly. Any match on dbx of any certificate or sha256 of a certificate > or a sha256 of the executable will reject the image. But we believe that SHA256-based signature is still valid even if we don't trust SHA1. > Regards > /Ilias > > Best regards > > > > Heinrich > > > > > > > > > But this image can and should yet be verified by SHA256 cert. > > > > > > Why should it be verified? My understanding of the EFI spec is that any match > > > in dbx of any certificate in the signing chain of the signature being verified means > > > reject the image. > > > > > > > 2) A user knows that a given image is safe for some reason even though > > > > he or she doesn't trust the certficate which is used for signing > > > > the image. What do you think of this case? -Takahiro Akashi > > > > -Takahiro Akashi > > > > > > > > > } > > > > > > > > > > if (!efi_signature_check_signers(msg, dbx)) { > > > > > + ret = false; > > > > > EFI_PRINT("Signer(s) in \"dbx\"\n"); > > > > > - continue; > > > > > + goto out; > > > > > } > > > > > > > > > > /* try white-list */ > > > > > if (efi_signature_verify(regs, msg, db, dbx)) { > > > > > ret = true; > > > > > - break; > > > > > + continue; > > > > > } > > > > > > > > > > EFI_PRINT("Signature was not verified by \"db\"\n"); > > > > > + } > > > > > > > > > > - if (efi_signature_lookup_digest(regs, db, false)) { > > > > > - ret = true; > > > > > - break; > > > > > - } > > > > > > > > > > - EFI_PRINT("Image's digest was not found in \"db\" or \"dbx\"\n"); > > > > > - } > > > > > + /* last resort try the image sha256 hash in db */ > > > > > + if (!ret && efi_signature_lookup_digest(regs, db, false)) > > > > > + ret = true; > > > > > > > > > > -err: > > > > > +out: > > > > > efi_sigstore_free(db); > > > > > efi_sigstore_free(dbx); > > > > > pkcs7_free_message(msg); > > > > > -- > > > > > 2.32.0 > > > > > > > > > > > Thanks > > > /Ilias > >