From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1exewf-0007KW-2p for mharc-grub-devel@gnu.org; Sun, 18 Mar 2018 16:30:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exewa-0007GE-Bd for grub-devel@gnu.org; Sun, 18 Mar 2018 16:30:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1exewY-0004Z9-Vl for grub-devel@gnu.org; Sun, 18 Mar 2018 16:30:15 -0400 Received: from avasout05.plus.net ([84.93.230.250]:58934) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1exewY-0003zz-Hu for grub-devel@gnu.org; Sun, 18 Mar 2018 16:30:14 -0400 Received: from [10.0.200.1] ([212.159.104.145]) by smtp with ESMTP id xewXe1btT1fhExewYesue0; Sun, 18 Mar 2018 20:30:14 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.3 cv=J9KEEjvS c=1 sm=1 tr=0 a=LmiDhuzNXzDmzyv3sIr6Rw==:117 a=LmiDhuzNXzDmzyv3sIr6Rw==:17 a=IkcTkHD0fZMA:10 a=roRGj-gwrmZi4ctyYycA:9 a=QEXdDO2ut3YA:10 Subject: Re: [PATCH 3/7] cryptomount luks allow multiple passphrase attempts To: TJ , The development of GNU GRUB References: <20180314094504.6177-1-grub@jelmail.com> <20180314094504.6177-3-grub@jelmail.com> From: John Lane Message-ID: <0ed80698-0cf2-143c-c30a-b0ad0c5f5d96@jelmail.com> Date: Sun, 18 Mar 2018 20:30:13 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfEvxaGMUFgCXyM8vfJMXMkrnf0Jwyz4HHIWyFPskQdKKJ2e1t0AQFhOqVO3D3qnfSbkvA6HvMRidDMBRDISMZDhx89gr/0549m56EE+ibAANmliNhfzq p7ODlZub7a4yUY2qHmP3WKGgjwyluim9wVvIUluWfevYrLh7Kt7RGi/R X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 84.93.230.250 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Mar 2018 20:30:19 -0000 On 17/03/18 11:10, TJ wrote: > On 14/03/18 09:45, John Lane wrote: >> --- a/grub-core/disk/luks.c >> +++ b/grub-core/disk/luks.c >> @@ -321,10 +321,10 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, >> >> static grub_err_t >> luks_recover_key (grub_disk_t source, >> - grub_cryptodisk_t dev, >> - grub_file_t hdr, >> - grub_uint8_t *keyfile_bytes, >> - grub_size_t keyfile_bytes_size) >> + grub_cryptodisk_t dev, >> + grub_file_t hdr, >> + grub_uint8_t *keyfile_bytes, >> + grub_size_t keyfile_bytes_size) > > ---8-<--- snip > > Much of this patch is moving existing code around, could it be > refactored to avoid that so as to make the new code stand out? > The code that was moved was just indented into a while loop. Most of it pre-existed prior to my patches (#357-464), a small part was added by patch#2. I'm not sure how I would refactor it - any change would result in 100-ish lines changing position and/or indent and would lead to a similarly sized patch. The way the patch presents the changes is confusing but I am not sure how to control that. If it helps, all this patch did was add a while loop around the passphrase reading code to allow the user 3 attempts. i.e while (attempts) { grub_printf_ (N_("Failed to decrypt master key.\n")); if (--attempts) grub_printf_ (N_("%u attempt%s remaining.\n"), attempts, (attempts==1) ? "" : "s"); }