X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=test%2Fsiphash_internal_test.c;h=dfdce48d1306757fbba1aacd64cf4ba2b012069b;hp=d5602d9222d166f06a88d19a7ec1ec5ce442fa63;hb=d74f23d2dbf2de0f374bff004c135242cfb65174;hpb=7ff3a3b9e98104e3d080e652712c42b0dff915dd diff --git a/test/siphash_internal_test.c b/test/siphash_internal_test.c index d5602d9222..dfdce48d13 100644 --- a/test/siphash_internal_test.c +++ b/test/siphash_internal_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -196,7 +196,8 @@ static int test_siphash(int idx) for (i = 0; i < inlen; i++) in[i] = (unsigned char)i; - if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0))) + if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen)) + || !TEST_true(SipHash_Init(&siphash, key, 0, 0))) return 0; SipHash_Update(&siphash, in, inlen); if (!TEST_true(SipHash_Final(&siphash, out, expectedlen)) @@ -204,7 +205,8 @@ static int test_siphash(int idx) return 0; if (inlen > 16) { - if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0))) + if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen)) + || !TEST_true(SipHash_Init(&siphash, key, 0, 0))) return 0; SipHash_Update(&siphash, in, 1); SipHash_Update(&siphash, in+1, inlen-1); @@ -220,7 +222,8 @@ static int test_siphash(int idx) if (inlen > 32) { size_t half = inlen / 2; - if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0))) + if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen)) + || !TEST_true(SipHash_Init(&siphash, key, 0, 0))) return 0; SipHash_Update(&siphash, in, half); SipHash_Update(&siphash, in+half, inlen-half); @@ -233,7 +236,8 @@ static int test_siphash(int idx) } for (half = 16; half < inlen; half += 16) { - if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0))) + if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen)) + || !TEST_true(SipHash_Init(&siphash, key, 0, 0))) return 0; SipHash_Update(&siphash, in, half); SipHash_Update(&siphash, in+half, inlen-half); @@ -258,19 +262,22 @@ static int test_siphash_basic(void) unsigned char output[SIPHASH_MAX_DIGEST_SIZE]; /* Use invalid hash size */ - return TEST_int_eq(SipHash_Init(&siphash, key, 4, 0, 0), 0) + return TEST_int_eq(SipHash_set_hash_size(&siphash, 4), 0) /* Use hash size = 8 */ - && TEST_true(SipHash_Init(&siphash, key, 8, 0, 0)) + && TEST_true(SipHash_set_hash_size(&siphash, 8)) + && TEST_true(SipHash_Init(&siphash, key, 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_true(SipHash_set_hash_size(&siphash, 16)) + && TEST_true(SipHash_Init(&siphash, key, 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_true(SipHash_set_hash_size(&siphash, 0)) + && TEST_true(SipHash_Init(&siphash, key, 0, 0)) && TEST_int_eq(SipHash_Final(&siphash, output, 8), 0) && TEST_true(SipHash_Final(&siphash, output, 16)); }