From f5563904625614a52da075bc7133e9d2e7095612 Mon Sep 17 00:00:00 2001 From: Steve Thomas Date: Wed, 27 Jan 2016 10:53:24 -0600 Subject: [PATCH] Added cipher_isHex() --- src/crypto.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/crypto.h b/src/crypto.h index b048b49..1148c30 100644 --- a/src/crypto.h +++ b/src/crypto.h @@ -160,6 +160,19 @@ static void cipher_bin2hex(const unsigned char* in, int sz, char *out) { } } +static int cipher_isHex(const unsigned char *hex, int sz){ + int i; + for(i = 0; i < sz; i++) { + unsigned char c = hex[i]; + if ((c < '0' || c > '9') && + (c < 'A' || c > 'F') && + (c < 'a' || c > 'f')) { + return 0; + } + } + return 1; +} + /* extensions defined in crypto_impl.c */ typedef struct codec_ctx codec_ctx;