Commit 14f051a0 authored by Rich Salz's avatar Rich Salz
Browse files

Make string_to_hex/hex_to_string public



Give the API new names, document it.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
parent 9021a5df
Loading
Loading
Loading
Loading
+0 −39
Original line number Diff line number Diff line
@@ -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)
+0 −1
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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
+3 −1
Original line number Diff line number Diff line
@@ -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
Loading