diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2011-02-14 19:42:49 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2011-02-14 19:42:49 +0000 |
commit | 943a0ceed0c35bd17c6c4deae087bb77308d6830 (patch) | |
tree | 5712a6d75046086c726bdd466b0bf6e110424be7 /fips/fips_utl.h | |
parent | 5d2f1538a0d73cbb3cfd663e5859f78ad9362de2 (diff) |
Update ECDSA test program to handle ECDSA2 format files.
Correctly handle hex strings with an odd number of digits.
Diffstat (limited to 'fips/fips_utl.h')
-rw-r--r-- | fips/fips_utl.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fips/fips_utl.h b/fips/fips_utl.h index 7ead612478..63541d996e 100644 --- a/fips/fips_utl.h +++ b/fips/fips_utl.h @@ -116,6 +116,15 @@ int hex2bin(const char *in, unsigned char *out) out[n2++]=ch; break; } + /* If input is odd length first digit is least significant: assumes + * all digits valid hex and null terminated which is true for the + * strings we pass. + */ + if (n1 == 1 && strlen(in) & 1) + { + out[n2++] = ch; + continue; + } out[n2] = ch << 4; /* second byte */ if ((in[n1] >= '0') && (in[n1] <= '9')) |