diff options
author | Alexander Hall <halex@cvs.openbsd.org> | 2012-11-23 23:53:55 +0000 |
---|---|---|
committer | Alexander Hall <halex@cvs.openbsd.org> | 2012-11-23 23:53:55 +0000 |
commit | 30e230976c330f06cab650e743db8538dedd5374 (patch) | |
tree | c725a922a8d3191c73d817479617d3fa8f5c5e71 | |
parent | 6068c0461b424cd52f9166099e2d28eb27ed1dbf (diff) |
make hex and modhex decoding case insensitive, the latter particulary
useful to avoid issues with SHIFT and CAPS LOCK on any keyboard.
pointers on proper tolower usage by guenther@
"Yup" deraadt@, ok sthen@ on initial version
ok guenther@ on final version
-rw-r--r-- | libexec/login_yubikey/yubikey.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libexec/login_yubikey/yubikey.c b/libexec/login_yubikey/yubikey.c index 1ef5d427f36..92de3afc7bb 100644 --- a/libexec/login_yubikey/yubikey.c +++ b/libexec/login_yubikey/yubikey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yubikey.c,v 1.2 2012/01/31 16:58:38 sobrado Exp $ */ +/* $OpenBSD: yubikey.c,v 1.3 2012/11/23 23:53:54 halex Exp $ */ /* * Written by Simon Josefsson <simon@josefsson.org>. @@ -32,6 +32,8 @@ * */ +#include <ctype.h> + #include "yubikey.h" static const uint8_t RC[] = { @@ -252,7 +254,8 @@ yubikey_hex_decode(char *dst, const char *src, size_t dstSize) char *p1; for (; *src && dstSize > 0; src++) { - if ((p1 = strchr(hex_trans, *src)) == NULL) + p1 = strchr(hex_trans, tolower((unsigned char)*src)); + if (p1 == NULL) b = 0; else b = (char)(p1 - hex_trans); @@ -278,7 +281,8 @@ yubikey_modhex_decode(char *dst, const char *src, size_t dstSize) char *p1; for (; *src && dstSize > 0; src++) { - if ((p1 = strchr(modhex_trans, *src)) == NULL) + p1 = strchr(modhex_trans, tolower((unsigned char)*src)); + if (p1 == NULL) b = 0; else b = (char)(p1 - modhex_trans); |