[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/4] Cryptomount support for hyphens in UUID
From: |
Andrei Borzenkov |
Subject: |
Re: [PATCH 4/4] Cryptomount support for hyphens in UUID |
Date: |
Sat, 20 Jun 2015 08:13:19 +0300 |
В Tue, 16 Jun 2015 10:11:15 +0100
John Lane <address@hidden> пишет:
> ---
> 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++!='-'));
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 disk)
>
> if (grub_memcmp (name, "cryptouuid/", sizeof ("cryptouuid/") - 1) == 0)
> {
> + grub_cryptodisk_uuid_dehyphenate((char *)name + sizeof
> ("cryptouuid/"));
We do not really know what underlying implementation expects as UUID.
It *may* contain hyphens as valid character.
> 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]);
Same: cryptomount is generic interface. We do not know what underlying
implementation expects.
> 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);
>
It already removes hyphens when getting UUID from LUKS. But you may
want to remove hyphens from check_uuid string too.
> 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
This function is needed in one place only, so moving it into luks makes
more sense for now.
- Cryptomount enhancements: detached headers, key-files and plain mode, John Lane, 2015/06/16
- [PATCH 2/4] Cryptomount support key files, John Lane, 2015/06/16
- Re: [PATCH 2/4] Cryptomount support key files, Andrei Borzenkov, 2015/06/20
- Re: [PATCH 2/4] Cryptomount support key files, John Lane, 2015/06/23
- Re: [PATCH 2/4] Cryptomount support key files, Andrei Borzenkov, 2015/06/24
- Re: [PATCH 2/4] Cryptomount support key files, John Lane, 2015/06/24
- Re: [PATCH 2/4] Cryptomount support key files, Andrei Borzenkov, 2015/06/24
- Re: [PATCH 2/4] Cryptomount support key files, John Lane, 2015/06/25
[PATCH 4/4] Cryptomount support for hyphens in UUID, John Lane, 2015/06/16
- Re: [PATCH 4/4] Cryptomount support for hyphens in UUID,
Andrei Borzenkov <=
[PATCH 1/4] Cryptomount support LUKS detached header, John Lane, 2015/06/16
[PATCH 3/4] Cryptomount support plain dm-crypt, John Lane, 2015/06/16