Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jP1Mo-0003WQ-GD for mharc-grub-devel@gnu.org; Thu, 16 Apr 2020 06:03:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59507) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jP1Ml-0003WD-LV for grub-devel@gnu.org; Thu, 16 Apr 2020 06:03:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jP1Mk-0001AJ-99 for grub-devel@gnu.org; Thu, 16 Apr 2020 06:03:27 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:45041) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jP1Mj-00018w-Q3 for grub-devel@gnu.org; Thu, 16 Apr 2020 06:03:26 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 37B9D733; Thu, 16 Apr 2020 06:03:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 16 Apr 2020 06:03:23 -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=HqElLmrnTyk5wrfIvzzybQyo/n1 2H5q8QMtiT8RVPSQ=; b=CRlyzP/ekQyDR/+1/StWa1r7JvjBRUso0bc1k/qA1/i UV45A/EWhEMx8WZavJnjldBaVr4q19x/sLfb9rJwp/2EDZo9qs6Uy4ltTF8PnlRu NrAk6rhAJG2YLv98Xrheq4j/itaWwav6qT9Vn10Msmjz6itTnVWYo4AbrDAuA3s3 rsWHJ/kbekDcAq+Q4Hyl6iUPX9uEVj+ESNePB7O//jY+xWAnKOZ2qJ320Hmupm8g OmoghDheR9bk1N0iU6tvXk4krBVwZp/KqUkY4def4Kx2WS+ZHERhdLOR4HG/DXGh 5WgI1bEcOeCjUz90jS7yvqumGk2RFnr7TLy9uO4wFRA== 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=HqElLm rnTyk5wrfIvzzybQyo/n12H5q8QMtiT8RVPSQ=; b=Me2I/AUu1LROE+UgKH6Rqw Ktwa9Bf8PaD94PMmU1LYxWuzdaNm1H81LoScco4xdzpQlB2waT8edvv3tQ3vx3CY CVjvlvleBR2b8s1mM6ir5J3OZr5mo3PkJGGs20/2ICqcaEFUbbhXjWMpIldpdEoQ V9jDgN8Hx+KwmD1zg9Fi1rd3PDoIBb9Rq/bz6wrNMh9YTV0FXiwRJISO4KJBZjSx bt6ce8czMLEL9OySXXbo+OuPSW2o4Iqi3pz0QUaxyZUR5dU8MGE+2wNGqMBe9jZ7 jnK7r2isDoRG2ZrLYXhL5Q4dsmmP3LMuKDgLS+Z3wf4F6ri+dNWBJoKWMY20UKDQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrfeehgddvfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhrihgt khcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecukfhppeejkedrheehrd dukeefrdejieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: from vm-mail.pks.im (x4e37b74c.dyn.telefonica.de [78.55.183.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 03B4E3060069; Thu, 16 Apr 2020 06:03:21 -0400 (EDT) Received: from localhost (tanuki [10.192.0.23]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id ca61a35f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 16 Apr 2020 10:03:17 +0000 (UTC) Date: Thu, 16 Apr 2020 12:03:16 +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: <20200416100316.GA172943@tanuki.pks.im> References: <20200414181222.dfbb7gjryewarcw2@tomti.i.net-space.pl> <20200415205253.GA4561@xps.pks.im> <20200416095217.cmjdbxtg4h4at2xo@tomti.i.net-space.pl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bp/iNruPH9dso1Pn" Content-Disposition: inline In-Reply-To: <20200416095217.cmjdbxtg4h4at2xo@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: Thu, 16 Apr 2020 10:03:29 -0000 --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 16, 2020 at 11:52:17AM +0200, Daniel Kiper wrote: > On Wed, Apr 15, 2020 at 10:52:53PM +0200, Patrick Steinhardt wrote: > > 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 rea= lly > > > > hard to discover why a given key actually failed to decrypt a disk. > > > > > > > > Improve this by including the error message in the user-visible out= put. > > > > --- > > > > 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, s= plit_key); > > > > if (ret) > > > > { > > > > - grub_dprintf ("luks2", "Read error: %s\n", grub_errmsg); > > > > + grub_error (GRUB_ERR_IO, "luks2", "Read error: %s\n", grub_e= rrmsg); > > > > > > 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 (passphra= se)); > > > > if (ret) > > > > { > > > > - grub_dprintf ("luks2", "Decryption with keyslot %"PRIuGRUB_SIZE= " failed\n", i); > > > > + grub_dprintf ("luks2", "Decryption with keyslot %"PRIuGRUB_SIZE= " failed: %s\n", > > > > + i, grub_errmsg); > > > > continue; > > > > } > > > > > > > > ret =3D luks2_verify_key (&digest, candidate_key, keyslot.ke= y_size); > > > > 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); > > > > > > 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? >=20 > Should not we print an error unconditionally if all n slots failed? > Then user will know that decryption is not possible but will not be > bothered by subsequent keyslot failures. However, I would still print > error for each keyslot if debugging is enabled. Then if you have some > problems you can enable debugging and see which keyslots fail. Does it > make sense? >=20 > Daniel Okay, so that's exactly how it works right now: in case no slot succeeds, we print "Invalid passphrase" to let the user know about it. If he turns on debugging, he'll see why each of the individual keyslots has failed, and this patch only increases the verbosity to actually include useful information. I'll resend this patch separate from the jsmn updates with the SOB and the above fix for `grub_error()`. Patrick --bp/iNruPH9dso1Pn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl6YLWMACgkQVbJhu7ck PpQD8RAAngi+5r2pvNJej8EMpyYLJkBsTE1eP/dzSTrTHKcfidCT/D6Vrs5Rn/ra KsxQvPnHJgfZGhyCoJJ6HrG01ul6IZjgA5+K0NPBtv/7hpzWc/kKeAu+GNYUQR0s 5BEvjr5HxHHVEQEPEkwo5+tNBwwFS6D5xl2DvwWho95i3eBpRO6A5RJHpC8NXWxh yrh161Qzvyfgdecf3j4UHIrikd+ZcHNyOqePAd2G0zpQx2uiTxcLlKvo5G6oA1Vi dEyvAqem4Vo1K1iOt3HiAOYofWUhXe/Uo5dTGsfgp2miSw9OoPzyzoQWuBLjosAs pMFw665e1+n8DnQ+ZWYstwyH82QRiQ5Yne4A+EH59LEOimINpCtyrF6hfJVmagHH 0fX4VDGxKMEcXg3II4YfaTCXYsOVM5uaRVNZBEISDKGILOV2BTrAagio9qV3xNA/ YLj8XSOSKv4XwBWzSY6+nUjnBl+a6yxR55APBDsBCQxksAjtUKot6fUU+svITp+J Z6M69xbdDKlKTBH0h4ZIafx0ZWrhEzNf/2V4dlsWl4N6D5UmOK9/yKVrUubbjq6e fAXSLagnqgHYaJYPGQUscmRJPzMCiXUpD7Fg9cr5D0eigbF5w3u5/wAlJnDxqKj4 E6oLDBrTBTLDsKFuf9hSFbmlZGJJbaRfJ0rBYvHmhHYjDDuoyYo= =Zcw4 -----END PGP SIGNATURE----- --bp/iNruPH9dso1Pn--