Skip site navigation (1)Skip section navigation (2)
Date:      Mon,  8 Aug 2005 01:36:21 +0200 (CEST)
From:      Benjamin Lutz <benlutz@datacomm.ch>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Pawel Jakub Dawidek <pjd@FreeBSD.org>
Subject:   kern/84659: geli accepts only lower case algorithm names
Message-ID:  <20050807233621.09C53347@maxlor.mine.nu>
Resent-Message-ID: <200508072340.j77NeFDA000737@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         84659
>Category:       kern
>Synopsis:       geli accepts only lower case algorithm names
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 07 23:40:15 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Benjamin Lutz
>Release:        FreeBSD 6.0-BETA2 amd64
>Organization:
>Environment:
System: FreeBSD merlin 6.0-BETA2 FreeBSD 6.0-BETA2 #4: Mon Aug 8 01:09:06 CEST 2005 root@merlin:/usr/obj/usr/src/sys/MERLIN64 amd64

>Description:
In the geli(8) manpage, it says that either AES, Blowfish or 3DES should
used as algorithm. In practice, however, geli accepts only "aes",
"blowfish" and "3des", ie lower case versions. I think this is a bug,
and either the manpage should be synced with the code, or, better, the
code should allow both upper and lower case names, or only upper case
names.

I have played around with the code a bit, see the diff below.
>How-To-Repeat:
$ geli init -a Blowfish /dev/md0
Invalid encryption algorithm.
$ geli init -a AES /dev/md0
Invalid encryption algorithm.
$
>Fix:

--- g_eli.h.diff begins here ---
--- g_eli.h.orig	Fri Aug  5 21:58:14 2005
+++ g_eli.h	Mon Aug  8 01:27:48 2005
@@ -36,9 +36,11 @@
 #include <opencrypto/cryptodev.h>
 #ifdef _KERNEL
 #include <sys/bio.h>
+#include <sys/ctype.h>
 #include <sys/libkern.h>
 #include <geom/geom.h>
 #else
+#include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 #endif
@@ -222,14 +224,22 @@
 static __inline u_int
 g_eli_str2algo(const char *name)
 {
+	char lc_name[9];
+	unsigned int i;
 
-	if (strcmp("null", name) == 0)
+	strlcpy(lc_name, name, sizeof(lc_name));
+	for(i = 0; lc_name[i] != '\0'; i++)
+	{
+		lc_name[i] = tolower(lc_name[i]);
+	}
+
+	if (strcmp("null", lc_name) == 0)
 		return (CRYPTO_NULL_CBC);
-	if (strcmp("aes", name) == 0)
+	if (strcmp("aes", lc_name) == 0)
 		return (CRYPTO_AES_CBC);
-	else if (strcmp("blowfish", name) == 0)
+	else if (strcmp("blowfish", lc_name) == 0)
 		return (CRYPTO_BLF_CBC);
-	else if (strcmp("3des", name) == 0)
+	else if (strcmp("3des", lc_name) == 0)
 		return (CRYPTO_3DES_CBC);
 	return (CRYPTO_ALGORITHM_MIN - 1);
 }
--- g_eli.h.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050807233621.09C53347>