From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Z6B5r-00040A-RO for mharc-grub-devel@gnu.org; Sat, 20 Jun 2015 01:13:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6B5p-0003zH-9O for grub-devel@gnu.org; Sat, 20 Jun 2015 01:13:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z6B5m-0001WX-2u for grub-devel@gnu.org; Sat, 20 Jun 2015 01:13:25 -0400 Received: from mail-lb0-x231.google.com ([2a00:1450:4010:c04::231]:34371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6B5l-0001WI-Qp for grub-devel@gnu.org; Sat, 20 Jun 2015 01:13:22 -0400 Received: by lbbti3 with SMTP id ti3so82639515lbb.1 for ; Fri, 19 Jun 2015 22:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=RulI4Hi5aQ/FYN8k4yhqkV3GoDWCWnXGKfRuyZRw0Ak=; b=KiEBqn6I3BY8dkM7jxNWdcGnvxpmVivMtG2ncINJKQarpVScOmJYlf1Dta/71zM7ty /fFP0VyILUJO9WW9by4RFuKYvY/8b3ynYFc1WHXmBnJMmZzSNh0kdJukqtwTNTEVLVqH RN4cjXO377MLtRHMdDotM0GqOy1XxeZvsM6GNej1yhdKLT0X/usc9+sBJaUKTr/HYnd2 cNRJcI2FQ2AZX3MEgIHDHhT901q9F+5p/STW1w9hYUl7Rmhbw9rzlsC/iIWL1dANRmTd 7ek2FBEt64bJXYVpTK4kE8d1M7KNFxXemsDFcHW/Ycw3LdvPhE/y0iNL7HyeMdH1ehDI 1pLA== X-Received: by 10.112.83.135 with SMTP id q7mr21023545lby.13.1434777201056; Fri, 19 Jun 2015 22:13:21 -0700 (PDT) Received: from opensuse.site (ppp91-76-14-38.pppoe.mtu-net.ru. [91.76.14.38]) by mx.google.com with ESMTPSA id u15sm2972760lal.38.2015.06.19.22.13.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jun 2015 22:13:20 -0700 (PDT) Date: Sat, 20 Jun 2015 08:13:19 +0300 From: Andrei Borzenkov To: John Lane Subject: Re: [PATCH 4/4] Cryptomount support for hyphens in UUID Message-ID: <20150620081319.7fa8a865@opensuse.site> In-Reply-To: <1434445875-6846-5-git-send-email-john@lane.uk.net> References: <1434445875-6846-1-git-send-email-john@lane.uk.net> <1434445875-6846-5-git-send-email-john@lane.uk.net> X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.28; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::231 Cc: grub-devel@gnu.org X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jun 2015 05:13:26 -0000 =D0=92 Tue, 16 Jun 2015 10:11:15 +0100 John Lane =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > --- > grub-core/disk/cryptodisk.c | 9 +++++++++ > grub-core/disk/luks.c | 1 + > include/grub/cryptodisk.h | 3 +++ > 3 files changed, 13 insertions(+) >=20 > diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c > index c519c55..b800d6f 100644 > --- a/grub-core/disk/cryptodisk.c > +++ b/grub-core/disk/cryptodisk.c > @@ -113,6 +113,13 @@ gf_mul_be (grub_uint8_t *o, const grub_uint8_t *a, c= onst grub_uint8_t *b) > } > } > =20 > +void > +grub_cryptodisk_uuid_dehyphenate(char *uuid) > +{ > + char *s, *d; > + for (s=3Dd=3Duuid;(*d=3D*s);d+=3D(*s++!=3D'-')); Did you try to fit smartphone size? We are not short on spaces yet. > +} > + > static gcry_err_code_t > grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher, > void *out, void *in, grub_size_t size, > @@ -506,6 +513,7 @@ grub_cryptodisk_open (const char *name, grub_disk_t d= isk) > =20 > if (grub_memcmp (name, "cryptouuid/", sizeof ("cryptouuid/") - 1) =3D= =3D 0) > { > + grub_cryptodisk_uuid_dehyphenate((char *)name + sizeof ("cryptouui= d/")); We do not really know what underlying implementation expects as UUID. It *may* contain hyphens as valid character. > for (dev =3D cryptodisk_list; dev !=3D NULL; dev =3D dev->next) > if (grub_strcasecmp (name + sizeof ("cryptouuid/") - 1, dev->uuid) =3D= =3D 0) > break; > @@ -1025,6 +1033,7 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, i= nt argc, char **args) > { > grub_cryptodisk_t dev; > =20 > + grub_cryptodisk_uuid_dehyphenate(args[0]); Same: cryptomount is generic interface. We do not know what underlying implementation expects. > dev =3D grub_cryptodisk_get_by_uuid (args[0]); > if (dev) > { > diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c > index 069e72c..0e570cf 100644 > --- a/grub-core/disk/luks.c > +++ b/grub-core/disk/luks.c > @@ -111,6 +111,7 @@ configure_ciphers (grub_disk_t disk, const char *chec= k_uuid, > hashspec[sizeof (header.hashSpec)] =3D 0; > grub_memcpy (uuid, header.uuid, sizeof (header.uuid)); > uuid[sizeof (header.uuid)] =3D 0; > + grub_cryptodisk_uuid_dehyphenate (uuid); > It already removes hyphens when getting UUID from LUKS. But you may want to remove hyphens from check_uuid string too. =20 > if (check_uuid && grub_strcasecmp (check_uuid, uuid) !=3D 0) > { > diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h > index 4076412..cfb0f0d 100644 > --- a/include/grub/cryptodisk.h > +++ b/include/grub/cryptodisk.h > @@ -167,4 +167,7 @@ grub_cryptodisk_t grub_cryptodisk_get_by_source_disk = (grub_disk_t disk); > grub_cryptodisk_t grub_cryptodisk_create (grub_disk_t disk, char *uuid, > char *ciphername, char *ciphermode, char *digest); > =20 > +void > +grub_cryptodisk_uuid_dehyphenate(char *uuid); > + > #endif This function is needed in one place only, so moving it into luks makes more sense for now.