aboutsummaryrefslogtreecommitdiffstats
path: root/libkeccak_unhex.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-11 17:56:37 +0100
committerMattias Andrée <maandree@kth.se>2019-02-11 17:56:37 +0100
commit5cee9b9c6394cffee6f31fab00323d9e559f0702 (patch)
treed21ba3da234c46b4f3c96e0065eb83d8c3cc8e96 /libkeccak_unhex.c
parentDeprecate typedefs (diff)
downloadlibkeccak-5cee9b9c6394cffee6f31fab00323d9e559f0702.tar.gz
libkeccak-5cee9b9c6394cffee6f31fab00323d9e559f0702.tar.bz2
libkeccak-5cee9b9c6394cffee6f31fab00323d9e559f0702.tar.xz
General improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libkeccak_unhex.c')
-rw-r--r--libkeccak_unhex.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libkeccak_unhex.c b/libkeccak_unhex.c
index a12beb1..00bb039 100644
--- a/libkeccak_unhex.c
+++ b/libkeccak_unhex.c
@@ -15,6 +15,7 @@ libkeccak_unhex(void *restrict output_, const char *restrict hashsum)
unsigned char *restrict output = output_;
size_t n = strlen(hashsum) / 2;
unsigned char a, b;
+
while (n--) {
a = (unsigned char)hashsum[2 * n + 0];
b = (unsigned char)hashsum[2 * n + 1];
@@ -22,7 +23,7 @@ libkeccak_unhex(void *restrict output_, const char *restrict hashsum)
a = (unsigned char)((a & 15) + (a > '9' ? 9 : 0));
b = (unsigned char)((b & 15) + (b > '9' ? 9 : 0));
- a <<= 4;
+ a = (unsigned char)(a << 4);
a |= b;
output[n] = a;
}