- if (SipHash_Init(&siphash, key, 4, 0, 0)) {
- BIO_printf(b_stderr, "SipHash_Init(output size = 4) should have failed\n");
- return 0;
- }
-
- /* Use hash size = 8 */
- if (!SipHash_Init(&siphash, key, 8, 0, 0)) {
- BIO_printf(b_stderr, "SipHash_Init(output size = 8) should have succeeded\n");
- return 0;
- }
- if (!SipHash_Final(&siphash, output, 8)) {
- BIO_printf(b_stderr, "SipHash_Final(output size = 8) should have succeeded\n");
- return 0;
- }
- if (SipHash_Final(&siphash, output, 16)) {
- BIO_printf(b_stderr, "SipHash_Final(output size = 16) should have failed\n");
- return 0;
- }
-
- /* Use hash size = 16 */
- if (!SipHash_Init(&siphash, key, 16, 0, 0)) {
- BIO_printf(b_stderr, "SipHash_Init(output size = 16) should have succeeded\n");
- return 0;
- }
- if (SipHash_Final(&siphash, output, 8)) {
- BIO_printf(b_stderr, "SipHash_Final(output size = 8) should have failed\n");
- return 0;
- }
- if (!SipHash_Final(&siphash, output, 16)) {
- BIO_printf(b_stderr, "SipHash_Final(output size = 16) should have succeeded\n");
- return 0;
- }
-
- /* Use hash size = 0 (default = 16) */
- if (!SipHash_Init(&siphash, key, 0, 0, 0)) {
- BIO_printf(b_stderr, "SipHash_Init(output size = 0) should have succeeded\n");
- return 0;
- }
- if (SipHash_Final(&siphash, output, 8)) {
- BIO_printf(b_stderr, "SipHash_Final(output size = 8) should have failed\n");
- return 0;
- }
- if (!SipHash_Final(&siphash, output, 16)) {
- BIO_printf(b_stderr, "SipHash_Final(output size = 16) should have succeeded\n");
- return 0;
- }
- return 1;
+ return TEST_int_eq(SipHash_Init(&siphash, key, 4, 0, 0), 0)
+ /* Use hash size = 8 */
+ && TEST_true(SipHash_Init(&siphash, key, 8, 0, 0))
+ && TEST_true(SipHash_Final(&siphash, output, 8))
+ && TEST_int_eq(SipHash_Final(&siphash, output, 16), 0)
+
+ /* Use hash size = 16 */
+ && TEST_true(SipHash_Init(&siphash, key, 16, 0, 0))
+ && TEST_int_eq(SipHash_Final(&siphash, output, 8), 0)
+ && TEST_true(SipHash_Final(&siphash, output, 16))
+
+ /* Use hash size = 0 (default = 16) */
+ && TEST_true(SipHash_Init(&siphash, key, 0, 0, 0))
+ && TEST_int_eq(SipHash_Final(&siphash, output, 8), 0)
+ && TEST_true(SipHash_Final(&siphash, output, 16));