From 49445f21da5ad436a117d0d4cc6220c4bbbbf8a7 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Thu, 12 May 2016 15:52:58 -0400 Subject: Use OPENSSL_hexchar2int Reviewed-by: Richard Levitte --- crypto/poly1305/poly1305.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'crypto/poly1305') diff --git a/crypto/poly1305/poly1305.c b/crypto/poly1305/poly1305.c index a7c4a0824e..fd6d32090d 100644 --- a/crypto/poly1305/poly1305.c +++ b/crypto/poly1305/poly1305.c @@ -871,14 +871,11 @@ static const struct poly1305_test poly1305_tests[] = { static unsigned char hex_digit(char h) { - if (h >= '0' && h <= '9') - return h - '0'; - else if (h >= 'a' && h <= 'f') - return h - 'a' + 10; - else if (h >= 'A' && h <= 'F') - return h - 'A' + 10; - else + int i = OPENSSL_hexchar2int(h); + + if (i < 0) abort(); + return i; } static void hex_decode(unsigned char *out, const char *hex) -- cgit v1.2.3