Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Z4muL-0002Qu-9c for mharc-grub-devel@gnu.org; Tue, 16 Jun 2015 05:11:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4muI-0002NB-Fp for grub-devel@gnu.org; Tue, 16 Jun 2015 05:11:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4muH-0000Xp-4T for grub-devel@gnu.org; Tue, 16 Jun 2015 05:11:46 -0400 Received: from johnlane.plus.com ([212.159.104.145]:63712 helo=sodium.amajohn.co.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4muG-0000XO-Th for grub-devel@gnu.org; Tue, 16 Jun 2015 05:11:45 -0400 Received: by sodium.amajohn.co.uk (Postfix, from userid 1000) id 2F3DF8B5; Tue, 16 Jun 2015 10:11:44 +0100 (BST) Received: from hydrogen.amajohn.co.uk (hydrogen.amajohn.co.uk [10.0.200.1]) by sodium.amajohn.co.uk (Postfix) with ESMTPSA id D66168AB; Tue, 16 Jun 2015 10:11:43 +0100 (BST) From: John Lane To: grub-devel@gnu.org Subject: [PATCH 4/4] Cryptomount support for hyphens in UUID Date: Tue, 16 Jun 2015 10:11:15 +0100 Message-Id: <1434445875-6846-5-git-send-email-john@lane.uk.net> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1434445875-6846-1-git-send-email-john@lane.uk.net> References: <1434445875-6846-1-git-send-email-john@lane.uk.net> X-Outbound-Checked: Yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 212.159.104.145 Cc: John Lane 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: Tue, 16 Jun 2015 09:11:48 -0000 --- grub-core/disk/cryptodisk.c | 9 +++++++++ grub-core/disk/luks.c | 1 + include/grub/cryptodisk.h | 3 +++ 3 files changed, 13 insertions(+) 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, const grub_uint8_t *b) } } +void +grub_cryptodisk_uuid_dehyphenate(char *uuid) +{ + char *s, *d; + for (s=d=uuid;(*d=*s);d+=(*s++!='-')); +} + 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 disk) if (grub_memcmp (name, "cryptouuid/", sizeof ("cryptouuid/") - 1) == 0) { + grub_cryptodisk_uuid_dehyphenate((char *)name + sizeof ("cryptouuid/")); for (dev = cryptodisk_list; dev != NULL; dev = dev->next) if (grub_strcasecmp (name + sizeof ("cryptouuid/") - 1, dev->uuid) == 0) break; @@ -1025,6 +1033,7 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args) { grub_cryptodisk_t dev; + grub_cryptodisk_uuid_dehyphenate(args[0]); dev = 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 *check_uuid, hashspec[sizeof (header.hashSpec)] = 0; grub_memcpy (uuid, header.uuid, sizeof (header.uuid)); uuid[sizeof (header.uuid)] = 0; + grub_cryptodisk_uuid_dehyphenate (uuid); if (check_uuid && grub_strcasecmp (check_uuid, uuid) != 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); +void +grub_cryptodisk_uuid_dehyphenate(char *uuid); + #endif -- 2.1.2