diff options
Diffstat (limited to 'lib/mesa/src/util/mesa-sha1.c')
-rw-r--r-- | lib/mesa/src/util/mesa-sha1.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/lib/mesa/src/util/mesa-sha1.c b/lib/mesa/src/util/mesa-sha1.c index bdca1233a..eed6e34fa 100644 --- a/lib/mesa/src/util/mesa-sha1.c +++ b/lib/mesa/src/util/mesa-sha1.c @@ -26,6 +26,7 @@ #include "sha1/sha1.h" #include "mesa-sha1.h" +#include "hex.h" #include <string.h> #include <inttypes.h> @@ -42,14 +43,7 @@ _mesa_sha1_compute(const void *data, size_t size, unsigned char result[20]) void _mesa_sha1_format(char *buf, const unsigned char *sha1) { - static const char hex_digits[] = "0123456789abcdef"; - int i; - - for (i = 0; i < 40; i += 2) { - buf[i] = hex_digits[sha1[i >> 1] >> 4]; - buf[i + 1] = hex_digits[sha1[i >> 1] & 0x0f]; - } - buf[i] = '\0'; + mesa_bytes_to_hex(buf, sha1, SHA1_DIGEST_LENGTH); } /* Convert a hashs string hexidecimal representation into its more compact @@ -58,13 +52,7 @@ _mesa_sha1_format(char *buf, const unsigned char *sha1) void _mesa_sha1_hex_to_sha1(unsigned char *buf, const char *hex) { - for (unsigned i = 0; i < 20; i++) { - char tmp[3]; - tmp[0] = hex[i * 2]; - tmp[1] = hex[(i * 2) + 1]; - tmp[2] = '\0'; - buf[i] = strtol(tmp, NULL, 16); - } + mesa_hex_to_bytes(buf, hex, SHA1_DIGEST_LENGTH); } static void |