|
@@ -1700,10 +1700,7 @@ int der_test(void)
|
|
#else
|
|
#else
|
|
for (z = 0; z < 1024; z++) {
|
|
for (z = 0; z < 1024; z++) {
|
|
#endif
|
|
#endif
|
|
- if (yarrow_read(buf[0], z, &yarrow_prng) != z) {
|
|
|
|
- fprintf(stderr, "%d: Failed to read %lu bytes from yarrow\n", __LINE__, z);
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
|
|
+ ENSURE(yarrow_read(buf[0], z, &yarrow_prng) == z);
|
|
DO(mp_read_unsigned_bin(a, buf[0], z));
|
|
DO(mp_read_unsigned_bin(a, buf[0], z));
|
|
/* if (mp_iszero(a) == LTC_MP_NO) { a.sign = buf[0][0] & 1 ? LTC_MP_ZPOS : LTC_MP_NEG; } */
|
|
/* if (mp_iszero(a) == LTC_MP_NO) { a.sign = buf[0][0] & 1 ? LTC_MP_ZPOS : LTC_MP_NEG; } */
|
|
x = sizeof(buf[0]);
|
|
x = sizeof(buf[0]);
|
|
@@ -1723,10 +1720,7 @@ int der_test(void)
|
|
/* test short integer */
|
|
/* test short integer */
|
|
for (zz = 0; zz < 256; zz++) {
|
|
for (zz = 0; zz < 256; zz++) {
|
|
for (z = 1; z < 4; z++) {
|
|
for (z = 1; z < 4; z++) {
|
|
- if (yarrow_read(buf[2], z, &yarrow_prng) != z) {
|
|
|
|
- fprintf(stderr, "%d: Failed to read %lu bytes from yarrow\n", __LINE__, z);
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
|
|
+ ENSURE(yarrow_read(buf[2], z, &yarrow_prng) == z);
|
|
/* encode with normal */
|
|
/* encode with normal */
|
|
DO(mp_read_unsigned_bin(a, buf[2], z));
|
|
DO(mp_read_unsigned_bin(a, buf[2], z));
|
|
|
|
|
|
@@ -1763,10 +1757,7 @@ int der_test(void)
|
|
|
|
|
|
/* Test bit string */
|
|
/* Test bit string */
|
|
for (zz = 1; zz < 1536; zz++) {
|
|
for (zz = 1; zz < 1536; zz++) {
|
|
- if (yarrow_read(buf[0], zz, &yarrow_prng) != zz) {
|
|
|
|
- fprintf(stderr, "%d: Failed to read %lu bytes from yarrow\n", __LINE__, zz);
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
|
|
+ ENSURE(yarrow_read(buf[0], zz, &yarrow_prng) == zz);
|
|
for (z = 0; z < zz; z++) {
|
|
for (z = 0; z < zz; z++) {
|
|
buf[0][z] &= 0x01;
|
|
buf[0][z] &= 0x01;
|
|
}
|
|
}
|
|
@@ -1788,10 +1779,7 @@ int der_test(void)
|
|
|
|
|
|
/* Test octet string */
|
|
/* Test octet string */
|
|
for (zz = 1; zz < 1536; zz++) {
|
|
for (zz = 1; zz < 1536; zz++) {
|
|
- if (yarrow_read(buf[0], zz, &yarrow_prng) != zz) {
|
|
|
|
- fprintf(stderr, "%d: Failed to read %lu bytes from yarrow\n", __LINE__, zz);
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
|
|
+ ENSURE(yarrow_read(buf[0], zz, &yarrow_prng) == zz);
|
|
x = sizeof(buf[1]);
|
|
x = sizeof(buf[1]);
|
|
DO(der_encode_octet_string(buf[0], zz, buf[1], &x));
|
|
DO(der_encode_octet_string(buf[0], zz, buf[1], &x));
|
|
DO(der_length_octet_string(zz, &y));
|
|
DO(der_length_octet_string(zz, &y));
|
|
@@ -1829,10 +1817,7 @@ int der_test(void)
|
|
/* do random strings */
|
|
/* do random strings */
|
|
for (zz = 0; zz < 5000; zz++) {
|
|
for (zz = 0; zz < 5000; zz++) {
|
|
/* pick a random number of words */
|
|
/* pick a random number of words */
|
|
- if (yarrow_read(buf[0], 4, &yarrow_prng) != 4) {
|
|
|
|
- fprintf(stderr, "%d: Failed to read %d bytes from yarrow\n", __LINE__, 4);
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
|
|
+ ENSURE(yarrow_read(buf[0], 4, &yarrow_prng) == 4);
|
|
LOAD32L(z, buf[0]);
|
|
LOAD32L(z, buf[0]);
|
|
z = 2 + (z % ((sizeof(oid[0])/sizeof(oid[0][0])) - 2));
|
|
z = 2 + (z % ((sizeof(oid[0])/sizeof(oid[0][0])) - 2));
|
|
|
|
|
|
@@ -1841,10 +1826,7 @@ int der_test(void)
|
|
oid[0][1] = buf[0][1] % 40;
|
|
oid[0][1] = buf[0][1] % 40;
|
|
|
|
|
|
for (y = 2; y < z; y++) {
|
|
for (y = 2; y < z; y++) {
|
|
- if (yarrow_read(buf[0], 4, &yarrow_prng) != 4) {
|
|
|
|
- fprintf(stderr, "%d: Failed to read %d bytes from yarrow\n", __LINE__, 4);
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
|
|
+ ENSURE(yarrow_read(buf[0], 4, &yarrow_prng) == 4);
|
|
LOAD32L(oid[0][y], buf[0]);
|
|
LOAD32L(oid[0][y], buf[0]);
|
|
}
|
|
}
|
|
|
|
|