Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jOp1A-0002bR-U3 for mharc-grub-devel@gnu.org; Wed, 15 Apr 2020 16:52:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40007) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOp17-0002b5-6A for grub-devel@gnu.org; Wed, 15 Apr 2020 16:52:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOp15-0002W8-1F for grub-devel@gnu.org; Wed, 15 Apr 2020 16:52:16 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:37629) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jOp14-0002VY-Ce for grub-devel@gnu.org; Wed, 15 Apr 2020 16:52:14 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 9F66DB13; Wed, 15 Apr 2020 16:52:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 15 Apr 2020 16:52:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=oX7emWTBzd1fQYaMeD9rKswx5ql yXLH322L/4IYlsSI=; b=KFJ7ktD4N1mKWOgCU5oQmjS2FSkghrKwFlnYGwtWod9 5ROsELSSQC07Z6jP9Rjxne5QjdfYFTBaGmn95Wt4ZU3K40m/wMtwmoYar9clL/9J 6/VpoJKSzr6c6NM5rIDoOuDoexZ+Vu3DqokmmhZIwP3F+L8QG5q9oeUyQC7T1WEQ YcTBI9RBiKWk8Hf3onhEvsgrEAi6I2BZZ4oFcMui95OcVJWCpgIiJkiDM66ixPDf lPhfV/TVBtxkf6AeUA3DizrPxD6aftMjNR1HDO6uBgOs3DyLmDubzCOiRilO/hA4 REQWbWhKYXUc8hJ39+Z7KkCifVlI5X9qyxRs6laN5Xw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=oX7emW TBzd1fQYaMeD9rKswx5qlyXLH322L/4IYlsSI=; b=QAmm1lrZcjxIygHPo9OsFA qTPtZvZ2NvRVSeQTPSF45DRWfx5x6k/Pc/XpCo8LUG8ImsxT8rl6JeEOsA7y1Qp2 HZhYcyg/AAMMdd6uONP/+KpJ5tPg65e+TprQHZpZp+HgmgBDUJpRZQIM171m5vjV FZvlKM6fVB3bAVAEP3p1dMzEV9Do9J101yvnsISlLkG/nZbccCIcDIdA5lLyI0ki VYxGdq1fEmgCzl9XPeXMuwMGr2+hf/hgbYVpHPQEsyoehmyXMR93KgxkylbLFB8A 9E5zx/rPP7vUbSRGzaUTZOlQGoU5TpBuW7cr7Qxr4sy8R5Kb23ztD3qizrCO6vIQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrfeefgddugeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucfkphepjeejrdduke efrdduieehrdeltdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: from vm-mail.pks.im (x4db7a55a.dyn.telefonica.de [77.183.165.90]) by mail.messagingengine.com (Postfix) with ESMTPA id 439693280060; Wed, 15 Apr 2020 16:52:10 -0400 (EDT) Received: from localhost (xps [10.192.0.12]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 3033acb5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 15 Apr 2020 20:52:06 +0000 (UTC) Date: Wed, 15 Apr 2020 22:52:53 +0200 From: Patrick Steinhardt To: Daniel Kiper Cc: grub-devel@gnu.org Subject: Re: [PATCH 1/2] luks2: Improve error reporting when decrypting/verifying key Message-ID: <20200415205253.GA4561@xps.pks.im> References: <20200414181222.dfbb7gjryewarcw2@tomti.i.net-space.pl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="FCuugMFkClbJLl1L" Content-Disposition: inline In-Reply-To: <20200414181222.dfbb7gjryewarcw2@tomti.i.net-space.pl> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.24 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Apr 2020 20:52:19 -0000 --FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 14, 2020 at 08:12:22PM +0200, Daniel Kiper wrote: > On Tue, Apr 07, 2020 at 06:02:23PM +0200, Patrick Steinhardt wrote: > > While we already set up error messages in both `luks2_verify_key()` and > > `luks2_decrypt_key()`, we do not ever print them. This makes it really > > hard to discover why a given key actually failed to decrypt a disk. > > > > Improve this by including the error message in the user-visible output. > > --- > > grub-core/disk/luks2.c | 8 +++++--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c > > index 65c4f0aac..58ac7bae1 100644 > > --- a/grub-core/disk/luks2.c > > +++ b/grub-core/disk/luks2.c > > @@ -487,7 +487,7 @@ luks2_decrypt_key (grub_uint8_t *out_key, > > ret =3D grub_disk_read (disk, 0, k->area.offset, k->area.size, split= _key); > > if (ret) > > { > > - grub_dprintf ("luks2", "Read error: %s\n", grub_errmsg); > > + grub_error (GRUB_ERR_IO, "luks2", "Read error: %s\n", grub_errms= g); >=20 > I think that you should drop "luks2" here. Oops, yes, obviously. > > goto err; > > } > > > > @@ -610,14 +610,16 @@ luks2_recover_key (grub_disk_t disk, > > (const grub_uint8_t *) passphrase, grub_strlen (passphrase)); > > if (ret) > > { > > - grub_dprintf ("luks2", "Decryption with keyslot %"PRIuGRUB_SIZE" fa= iled\n", i); > > + grub_dprintf ("luks2", "Decryption with keyslot %"PRIuGRUB_SIZE" fa= iled: %s\n", > > + i, grub_errmsg); > > continue; > > } > > > > ret =3D luks2_verify_key (&digest, candidate_key, keyslot.key_si= ze); > > if (ret) > > { > > - grub_dprintf ("luks2", "Could not open keyslot %"PRIuGRUB_SIZE"\n",= i); > > + grub_dprintf ("luks2", "Could not open keyslot %"PRIuGRUB_SIZE": %s= \n", > > + i, grub_errmsg); >=20 > This messages will be printed only if debugging is enabled. Is it what > you expect? Well, I'm honestly not quite sure. The thing is that we potentially have a number of different keyslots, not only one. So when we try keyslots in turn, it's not unexpected for the first n-1 keyslots to not work if the nth keyslot is the one we're trying to unlock. The above is probably just an edge case as I expect most users to use a single keyslot, only. And in that case it would probably we useful to always print those messages, not only in case debugging is turned on. What do you think? Patrick --FCuugMFkClbJLl1L Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl6XdCQACgkQVbJhu7ck PpTrVg//V18R1ortsZhW43bsDPd5QLex5QoCzq/7gy6BlQBItvrGZ67eZTo3a5zT RyGKN9VjvlVZ/lqwn0W33Ww94mZWkksQVMlyH1wb7rwrxtuSEnrPhju6WOrW/hIQ xzFhxRmsovFNtRPy1DaHIPVJROKmDZaoHqupQlG71NCf0pUaXw2oxK5eW22SOcJJ 3u5sbWqSMm7hdqoxsLHMapF4+KjCxuo9j/i0WYw231qwDytL0GpGgH060m+h0gCJ Or/e5JRxcN2q14WUm2X3iiCi3fHqZo3kRVOXSeWxaBfMBSpojCwK0Q8pjuORHSFx P/inWEh5zJl3uYucWPzjljZnZIfEqyVd5T1xt0CkZaWCwVsc3k5TtLa8L+ZWYhat TTUzt/Z2CJC54Mxy7J3HGHTprl5lLqd/95l8v3/+q1OJ41FbdVTumpT2fRc8Bpkx NAEFvJRsXflE2z7wTq+Uk8ECaLjjs1cCX0jFYrLjb18QxG7cgdZ1A0WsszxedcGO uiVqSesbkcAaKuhNP701HWQffwlAA2hJjnMGYZf5TR/4NqzKC1oooxXKM6XtpVdP Fwnrl7id2Tqv3mdp6rXZjqJFuWlgsXP5PkfWRc33j4NShxyqptKHFefLi7E3zzkf 19HYvobRpfYXZwUvcbbVuursxgNwZcAM0xv3LN4pdOzuxpks8A8= =vLRi -----END PGP SIGNATURE----- --FCuugMFkClbJLl1L--