@@ -1700,10 +1700,7 @@ int der_test(void)
1700
1700
#else
1701
1701
for (z = 0 ; z < 1024 ; z ++ ) {
1702
1702
#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 );
1707
1704
DO (mp_read_unsigned_bin (a , buf [0 ], z ));
1708
1705
/* if (mp_iszero(a) == LTC_MP_NO) { a.sign = buf[0][0] & 1 ? LTC_MP_ZPOS : LTC_MP_NEG; } */
1709
1706
x = sizeof (buf [0 ]);
@@ -1723,10 +1720,7 @@ int der_test(void)
1723
1720
/* test short integer */
1724
1721
for (zz = 0 ; zz < 256 ; zz ++ ) {
1725
1722
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 );
1730
1724
/* encode with normal */
1731
1725
DO (mp_read_unsigned_bin (a , buf [2 ], z ));
1732
1726
@@ -1763,10 +1757,7 @@ int der_test(void)
1763
1757
1764
1758
/* Test bit string */
1765
1759
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 );
1770
1761
for (z = 0 ; z < zz ; z ++ ) {
1771
1762
buf [0 ][z ] &= 0x01 ;
1772
1763
}
@@ -1788,10 +1779,7 @@ int der_test(void)
1788
1779
1789
1780
/* Test octet string */
1790
1781
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 );
1795
1783
x = sizeof (buf [1 ]);
1796
1784
DO (der_encode_octet_string (buf [0 ], zz , buf [1 ], & x ));
1797
1785
DO (der_length_octet_string (zz , & y ));
@@ -1829,10 +1817,7 @@ int der_test(void)
1829
1817
/* do random strings */
1830
1818
for (zz = 0 ; zz < 5000 ; zz ++ ) {
1831
1819
/* 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 );
1836
1821
LOAD32L (z , buf [0 ]);
1837
1822
z = 2 + (z % ((sizeof (oid [0 ])/sizeof (oid [0 ][0 ])) - 2 ));
1838
1823
@@ -1841,10 +1826,7 @@ int der_test(void)
1841
1826
oid [0 ][1 ] = buf [0 ][1 ] % 40 ;
1842
1827
1843
1828
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 );
1848
1830
LOAD32L (oid [0 ][y ], buf [0 ]);
1849
1831
}
1850
1832
0 commit comments