@@ -1700,10 +1700,7 @@ int der_test(void)
17001700#else
17011701 for (z = 0 ; z < 1024 ; z ++ ) {
17021702#endif
1703- if (yarrow_read (buf [0 ], z , & yarrow_prng ) != z ) {
1704- fprintf (stderr , "%d: Failed to read %lu bytes from yarrow\n" , __LINE__ , z );
1705- return 1 ;
1706- }
1703+ ENSURE (yarrow_read (buf [0 ], z , & yarrow_prng ) == z );
17071704 DO (mp_read_unsigned_bin (a , buf [0 ], z ));
17081705/* if (mp_iszero(a) == LTC_MP_NO) { a.sign = buf[0][0] & 1 ? LTC_MP_ZPOS : LTC_MP_NEG; } */
17091706 x = sizeof (buf [0 ]);
@@ -1723,10 +1720,7 @@ int der_test(void)
17231720/* test short integer */
17241721 for (zz = 0 ; zz < 256 ; zz ++ ) {
17251722 for (z = 1 ; z < 4 ; z ++ ) {
1726- if (yarrow_read (buf [2 ], z , & yarrow_prng ) != z ) {
1727- fprintf (stderr , "%d: Failed to read %lu bytes from yarrow\n" , __LINE__ , z );
1728- return 1 ;
1729- }
1723+ ENSURE (yarrow_read (buf [2 ], z , & yarrow_prng ) == z );
17301724 /* encode with normal */
17311725 DO (mp_read_unsigned_bin (a , buf [2 ], z ));
17321726
@@ -1763,10 +1757,7 @@ int der_test(void)
17631757
17641758/* Test bit string */
17651759 for (zz = 1 ; zz < 1536 ; zz ++ ) {
1766- if (yarrow_read (buf [0 ], zz , & yarrow_prng ) != zz ) {
1767- fprintf (stderr , "%d: Failed to read %lu bytes from yarrow\n" , __LINE__ , zz );
1768- return 1 ;
1769- }
1760+ ENSURE (yarrow_read (buf [0 ], zz , & yarrow_prng ) == zz );
17701761 for (z = 0 ; z < zz ; z ++ ) {
17711762 buf [0 ][z ] &= 0x01 ;
17721763 }
@@ -1788,10 +1779,7 @@ int der_test(void)
17881779
17891780/* Test octet string */
17901781 for (zz = 1 ; zz < 1536 ; zz ++ ) {
1791- if (yarrow_read (buf [0 ], zz , & yarrow_prng ) != zz ) {
1792- fprintf (stderr , "%d: Failed to read %lu bytes from yarrow\n" , __LINE__ , zz );
1793- return 1 ;
1794- }
1782+ ENSURE (yarrow_read (buf [0 ], zz , & yarrow_prng ) == zz );
17951783 x = sizeof (buf [1 ]);
17961784 DO (der_encode_octet_string (buf [0 ], zz , buf [1 ], & x ));
17971785 DO (der_length_octet_string (zz , & y ));
@@ -1829,10 +1817,7 @@ int der_test(void)
18291817 /* do random strings */
18301818 for (zz = 0 ; zz < 5000 ; zz ++ ) {
18311819 /* pick a random number of words */
1832- if (yarrow_read (buf [0 ], 4 , & yarrow_prng ) != 4 ) {
1833- fprintf (stderr , "%d: Failed to read %d bytes from yarrow\n" , __LINE__ , 4 );
1834- return 1 ;
1835- }
1820+ ENSURE (yarrow_read (buf [0 ], 4 , & yarrow_prng ) == 4 );
18361821 LOAD32L (z , buf [0 ]);
18371822 z = 2 + (z % ((sizeof (oid [0 ])/sizeof (oid [0 ][0 ])) - 2 ));
18381823
@@ -1841,10 +1826,7 @@ int der_test(void)
18411826 oid [0 ][1 ] = buf [0 ][1 ] % 40 ;
18421827
18431828 for (y = 2 ; y < z ; y ++ ) {
1844- if (yarrow_read (buf [0 ], 4 , & yarrow_prng ) != 4 ) {
1845- fprintf (stderr , "%d: Failed to read %d bytes from yarrow\n" , __LINE__ , 4 );
1846- return 1 ;
1847- }
1829+ ENSURE (yarrow_read (buf [0 ], 4 , & yarrow_prng ) == 4 );
18481830 LOAD32L (oid [0 ][y ], buf [0 ]);
18491831 }
18501832
0 commit comments