diff --git a/demos/test.c b/demos/test.c index 051cb8d..1ae530e 100644 --- a/demos/test.c +++ b/demos/test.c @@ -17,6 +17,7 @@ int main(void) #endif printf("build == \n%s\n", crypt_build_settings); + printf("MP_DIGIT_BIT = %d\n", MP_DIGIT_BIT); printf("\nstore_test...."); fflush(stdout); x = store_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE); printf("\nmisc_test....."); fflush(stdout); x = misc_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE); printf("\ncipher_test..."); fflush(stdout); x = cipher_hash_test(); printf(x ? "failed" : "passed");if (x) exit(EXIT_FAILURE); diff --git a/src/headers/tomcrypt_pk.h b/src/headers/tomcrypt_pk.h index 31d66c9..f8b934a 100644 --- a/src/headers/tomcrypt_pk.h +++ b/src/headers/tomcrypt_pk.h @@ -439,21 +439,25 @@ int dsa_shared_secret(void *private_key, void *base, /* DER handling */ typedef enum ltc_asn1_type_ { + /* 0 */ LTC_ASN1_EOL, LTC_ASN1_BOOLEAN, LTC_ASN1_INTEGER, LTC_ASN1_SHORT_INTEGER, LTC_ASN1_BIT_STRING, + /* 5 */ LTC_ASN1_OCTET_STRING, LTC_ASN1_NULL, LTC_ASN1_OBJECT_IDENTIFIER, LTC_ASN1_IA5_STRING, LTC_ASN1_PRINTABLE_STRING, + /* 10 */ LTC_ASN1_UTF8_STRING, LTC_ASN1_UTCTIME, LTC_ASN1_CHOICE, LTC_ASN1_SEQUENCE, LTC_ASN1_SET, + /* 15 */ LTC_ASN1_SETOF, LTC_ASN1_RAW_BIT_STRING, LTC_ASN1_TELETEX_STRING, diff --git a/testprof/der_tests.c b/testprof/der_tests.c index c75e3d3..eb47f25 100644 --- a/testprof/der_tests.c +++ b/testprof/der_tests.c @@ -549,12 +549,12 @@ int der_tests(void) /* test short integer */ for (zz = 0; zz < 256; zz++) { for (z = 1; z < 4; z++) { - if (yarrow_read(buf[0], z, &yarrow_prng) != z) { + if (yarrow_read(buf[2], z, &yarrow_prng) != z) { fprintf(stderr, "Failed to read %lu bytes from yarrow\n", z); return 1; } /* encode with normal */ - DO(mp_read_unsigned_bin(a, buf[0], z)); + DO(mp_read_unsigned_bin(a, buf[2], z)); x = sizeof(buf[0]); DO(der_encode_integer(a, buf[0], &x)); @@ -563,7 +563,8 @@ int der_tests(void) y = sizeof(buf[1]); DO(der_encode_short_integer(mp_get_int(a), buf[1], &y)); if (x != y || memcmp(buf[0], buf[1], x)) { - fprintf(stderr, "DER INTEGER short encoding failed, %lu, %lu\n", x, y); + fprintf(stderr, "DER INTEGER short encoding failed, %lu, %lu, 0x%lX\n", x, y, mp_get_int(a)); + for (zz = 0; zz < z; zz++) fprintf(stderr, "%02x ", buf[2][zz]); fprintf(stderr, "\n"); for (z = 0; z < x; z++) fprintf(stderr, "%02x ", buf[0][z]); fprintf(stderr, "\n"); for (z = 0; z < y; z++) fprintf(stderr, "%02x ", buf[1][z]); fprintf(stderr, "\n"); mp_clear_multi(a, b, c, d, e, f, g, NULL);