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 F3729C433F5 for ; Thu, 10 Feb 2022 07:33:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D7B7A80FDE; Thu, 10 Feb 2022 08:33:55 +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="efPQ7SPp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8227680FE1; Thu, 10 Feb 2022 08:33:53 +0100 (CET) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (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 764B980FAE for ; Thu, 10 Feb 2022 08:33:49 +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=ilias.apalodimas@linaro.org Received: by mail-wr1-x436.google.com with SMTP id h6so7870856wrb.9 for ; Wed, 09 Feb 2022 23:33:49 -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:references:mime-version :content-disposition:in-reply-to; bh=lL6MBgIQTA3ql04mFA65ltqUO7XCGA6WdtY918tksC4=; b=efPQ7SPpUETIU82pa5k/b15V9x4e+f2fwQNACP91A5N4IIdljnl7w2lBitagkAUGJO /Bckzqc/fsJQiuCUR0jvmCkCRPIDJKh5ML9zmrcvRUONrQnYq7BXduN4y8Jxyp56z1Pt ay1l+5NO6Qtrm0vJULP6vAobcS7j9T/nrr/VRgx/5eA9GkVGvn5zx54T5ndV61d9LPs7 KHpWqqzPD2JrNNVRHWccyYZA4jPm1sWvKyJO2wcXEGlNb2i0CpbW0gHL0k1O++BRYWjK PEQ6R10lwqKPAWmCCleyA30rZX3u9896nbHXXP7YJdCCl6JpmwPwnGofkcg/JT3iBuGY T8bA== 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:references :mime-version:content-disposition:in-reply-to; bh=lL6MBgIQTA3ql04mFA65ltqUO7XCGA6WdtY918tksC4=; b=7E+vbo72FH0JlA3gJYwcOe1ntxzwG9FdExrwe0zyBl0hpMX/FxI8TxEyB1gR1kilYT 61Hnd4PV2T+AuL8CyHmhP63Ojt45DROfNln8rPEsSVUL9rdUCCy/w7uw/ZEeZGxkFevX YSY4LuLWoOaqVzEsoQhPotngel3xKGkyKI8N69pP/+ADqeABL13oHcJ5G+v9vW+CLKGq 9qPeTBHWKx2cgBvxqzDNyBoghKwZNnVz2xsDBQbq20vXeEw8Hm2RheelRoqMRj5fLznb zj4kGXtLlF8VG1T9CRh0oIvFVg4y5WofFwL/LX6nUUWw39jU5ZgyLIijaOliV+cTLc4l 0EzQ== X-Gm-Message-State: AOAM532dLfQ1qnOIy2zpiWjFs8V/4PkXf/T2WSo5xqe0dgtS3FlO56xL qUJsWjun7zfn/T4D7Y8EOsUlsw== X-Google-Smtp-Source: ABdhPJy3Us7OaXw1eybRHJnf9/BAmOFVtWj3/YmDUUNlfyMpfMk1suAI6cbYK5b13tksD5nFXcdNRg== X-Received: by 2002:a05:6000:38e:: with SMTP id u14mr5119637wrf.638.1644478428983; Wed, 09 Feb 2022 23:33:48 -0800 (PST) Received: from hades (athedsl-4461669.home.otenet.gr. [94.71.4.85]) by smtp.gmail.com with ESMTPSA id t18sm18818953wri.34.2022.02.09.23.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 23:33:48 -0800 (PST) Date: Thu, 10 Feb 2022 09:33:46 +0200 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: AKASHI Takahiro , u-boot@lists.denx.de Subject: Re: [RFC PATCH 1/2] efi_loader: fix dual signed image certification Message-ID: 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: <730ecf32-43d3-58be-63a3-122985d25583@gmx.de> 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 > > > > 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. 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. > > > > > > -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 >