summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2016-04-13 15:58:28 -0400
committerRich Salz <rsalz@openssl.org>2016-04-18 09:02:11 -0400
commit14f051a0ae3d752c50f419d3583e85fdf4c5bfc9 (patch)
tree16bb50151db9c67cd1dec3b1d25cc537fd10f874 /apps
parent9021a5dfb37fd3a6f7726f07ef0f27dcb71048e2 (diff)
Make string_to_hex/hex_to_string public
Give the API new names, document it. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'apps')
-rw-r--r--apps/apps.c39
-rw-r--r--apps/apps.h1
-rw-r--r--apps/cms.c4
-rw-r--r--apps/enc.c2
-rw-r--r--apps/ocsp.c4
-rw-r--r--apps/rehash.c2
-rw-r--r--apps/ts.c4
7 files changed, 9 insertions, 47 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 7ba12fea5a..6d8c4897d0 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -2340,45 +2340,6 @@ int app_access(const char* name, int flag)
#endif
}
-int app_hex(char c)
-{
- switch (c) {
- default:
- case '0':
- return 0;
- case '1':
- return 1;
- case '2':
- return 2;
- case '3':
- return 3;
- case '4':
- return 4;
- case '5':
- return 5;
- case '6':
- return 6;
- case '7':
- return 7;
- case '8':
- return 8;
- case '9':
- return 9;
- case 'a': case 'A':
- return 0x0A;
- case 'b': case 'B':
- return 0x0B;
- case 'c': case 'C':
- return 0x0C;
- case 'd': case 'D':
- return 0x0D;
- case 'e': case 'E':
- return 0x0E;
- case 'f': case 'F':
- return 0x0F;
- }
-}
-
/* app_isdir section */
#ifdef _WIN32
int app_isdir(const char *name)
diff --git a/apps/apps.h b/apps/apps.h
index a310dd2b78..10e1534503 100644
--- a/apps/apps.h
+++ b/apps/apps.h
@@ -624,7 +624,6 @@ void store_setup_crl_download(X509_STORE *st);
# define SERIAL_RAND_BITS 64
-int app_hex(char);
int app_isdir(const char *);
int app_access(const char *, int flag);
int raw_read_stdin(void *, int);
diff --git a/apps/cms.c b/apps/cms.c
index a74ca9d4ca..95f21245eb 100644
--- a/apps/cms.c
+++ b/apps/cms.c
@@ -453,7 +453,7 @@ int cms_main(int argc, char **argv)
noout = print = 1;
break;
case OPT_SECRETKEY:
- secret_key = string_to_hex(opt_arg(), &ltmp);
+ secret_key = OPENSSL_hexstr2buf(opt_arg(), &ltmp);
if (secret_key == NULL) {
BIO_printf(bio_err, "Invalid key %s\n", opt_arg());
goto end;
@@ -461,7 +461,7 @@ int cms_main(int argc, char **argv)
secret_keylen = (size_t)ltmp;
break;
case OPT_SECRETKEYID:
- secret_keyid = string_to_hex(opt_arg(), &ltmp);
+ secret_keyid = OPENSSL_hexstr2buf(opt_arg(), &ltmp);
if (secret_keyid == NULL) {
BIO_printf(bio_err, "Invalid id %s\n", opt_arg());
goto opthelp;
diff --git a/apps/enc.c b/apps/enc.c
index 7f25009ba9..9e7d069264 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -636,7 +636,7 @@ static int set_hex(char *in, unsigned char *out, int size)
BIO_printf(bio_err, "non-hex digit\n");
return (0);
}
- j = (unsigned char)app_hex(j);
+ j = (unsigned char)OPENSSL_hexchar2int(j);
if (i & 1)
out[i / 2] |= j;
else
diff --git a/apps/ocsp.c b/apps/ocsp.c
index 24d88da5c3..ca293a9709 100644
--- a/apps/ocsp.c
+++ b/apps/ocsp.c
@@ -1075,7 +1075,9 @@ static int urldecode(char *p)
if (*p != '%')
*out++ = *p;
else if (isxdigit(_UC(p[1])) && isxdigit(_UC(p[2]))) {
- *out++ = (app_hex(p[1]) << 4) | app_hex(p[2]);
+ /* Don't check, can't fail because of ixdigit() call. */
+ *out++ = (OPENSSL_hexchar2int(p[1]) << 4)
+ | OPENSSL_hexchar2int(p[2]);
p += 2;
}
else
diff --git a/apps/rehash.c b/apps/rehash.c
index 38084a247f..895a222f0c 100644
--- a/apps/rehash.c
+++ b/apps/rehash.c
@@ -210,7 +210,7 @@ static int handle_symlink(const char *filename, const char *fullpath)
if (!isxdigit(ch))
return -1;
hash <<= 4;
- hash += app_hex(ch);
+ hash += OPENSSL_hexchar2int(ch);
}
if (filename[i++] != '.')
return -1;
diff --git a/apps/ts.c b/apps/ts.c
index ec0cfa9d92..70a9013e2b 100644
--- a/apps/ts.c
+++ b/apps/ts.c
@@ -567,7 +567,7 @@ static int create_digest(BIO *input, char *digest, const EVP_MD *md,
EVP_MD_CTX_free(md_ctx);
} else {
long digest_len;
- *md_value = string_to_hex(digest, &digest_len);
+ *md_value = OPENSSL_hexstr2buf(digest, &digest_len);
if (!*md_value || md_value_len != digest_len) {
OPENSSL_free(*md_value);
*md_value = NULL;
@@ -939,7 +939,7 @@ static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,
goto err;
} else if (digest != NULL) {
long imprint_len;
- unsigned char *hexstr = string_to_hex(digest, &imprint_len);
+ unsigned char *hexstr = OPENSSL_hexstr2buf(digest, &imprint_len);
f |= TS_VFY_IMPRINT;
if (TS_VERIFY_CTX_set_imprint(ctx, hexstr, imprint_len) == NULL) {
BIO_printf(bio_err, "invalid digest string\n");