]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
cryptodisk: Fix cipher IV mode "plain64" always being set as "plain"
authorGlenn Washburn <development@efficientek.com>
Mon, 19 Oct 2020 23:09:53 +0000 (18:09 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Fri, 30 Oct 2020 14:37:20 +0000 (15:37 +0100)
When setting cipher IV mode, detection is done by prefix matching the
cipher IV mode part of the cipher mode string. Since "plain" matches
"plain64", we must check for "plain64" first. Otherwise, "plain64" will
be detected as "plain".

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/disk/cryptodisk.c

index 13af84dd1dd06c551d6a989a9f7a44c8c8eabefa..a3d672f683f6cbf81ca74acb41142bc8ccd08f30 100644 (file)
@@ -501,10 +501,10 @@ grub_cryptodisk_setcipher (grub_cryptodisk_t crypt, const char *ciphername, cons
 
   if (cipheriv == NULL)
       ;
-  else if (grub_memcmp (cipheriv, "plain", sizeof ("plain") - 1) == 0)
-      mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN;
   else if (grub_memcmp (cipheriv, "plain64", sizeof ("plain64") - 1) == 0)
       mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN64;
+  else if (grub_memcmp (cipheriv, "plain", sizeof ("plain") - 1) == 0)
+      mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN;
   else if (grub_memcmp (cipheriv, "benbi", sizeof ("benbi") - 1) == 0)
     {
       if (cipher->cipher->blocksize & (cipher->cipher->blocksize - 1)