aboutsummaryrefslogtreecommitdiff
path: root/lib/sha1.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-11-15 10:18:10 -0800
committerBen Pfaff <blp@nicira.com>2010-11-15 10:18:10 -0800
commitbf9712678fc9ec85bf2ac54407e16d76aa22e7b6 (patch)
tree2052e512f4606aad7ec50bea03ccf33118e0b44a /lib/sha1.c
parent96fc46e8fdafd6467906e11e0fb493e2b78f2fb5 (diff)
util: Add function hexits_value() for parsing multiple hex digits.
Suggested-by: Justin Pettit <jpettit@nicira.com>
Diffstat (limited to 'lib/sha1.c')
-rw-r--r--lib/sha1.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/sha1.c b/lib/sha1.c
index 205b82fe..3b16622d 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -1,7 +1,7 @@
/*
* This file is from the Apache Portable Runtime Library.
* The full upstream copyright and license statement is included below.
- * Modifications copyright (c) 2009 Nicira Networks.
+ * Modifications copyright (c) 2009, 2010 Nicira Networks.
*/
/* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -301,10 +301,12 @@ sha1_from_hex(uint8_t digest[SHA1_DIGEST_SIZE], const char *hex)
int i;
for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
- if (!isxdigit(hex[0]) || !isxdigit(hex[1])) {
+ bool ok;
+
+ digest[i] = hexits_value(hex, 2, &ok);
+ if (!ok) {
return false;
}
- digest[i] = (hexit_value(hex[0]) << 4) | hexit_value(hex[1]);
hex += 2;
}
return true;