Remove OpenSSL based SipHash 2-4 implementation
Creation of EVP_MD_CTX and EVP_PKEY is quite expensive, so until we fix the code
to reuse the OpenSSL contexts and keys we'll use our own implementation of
siphash instead of trying to integrate with OpenSSL.
(cherry picked from commit 21d751dfc7)
This commit is contained in:
@@ -22,32 +22,7 @@
|
||||
|
||||
#include <isc/siphash.h>
|
||||
|
||||
void
|
||||
native_isc_siphash24(const uint8_t *, const uint8_t *, const size_t, uint8_t *);
|
||||
|
||||
#if HAVE_OPENSSL_SIPHASH
|
||||
|
||||
void
|
||||
openssl_isc_siphash24(const uint8_t *, const uint8_t *, const size_t,
|
||||
uint8_t *);
|
||||
|
||||
#undef HAVE_OPENSSL_SIPHASH
|
||||
#define isc_siphash24 native_isc_siphash24
|
||||
#include "../siphash.c"
|
||||
#undef isc_siphash24
|
||||
|
||||
#define HAVE_OPENSSL_SIPHASH 1
|
||||
#define isc_siphash24 openssl_isc_siphash24
|
||||
#include "../siphash.c"
|
||||
#undef isc_siphash24
|
||||
|
||||
#else /* if HAVE_OPENSSL_SIPHASH */
|
||||
|
||||
#define isc_siphash24 native_isc_siphash24
|
||||
#include "../siphash.c"
|
||||
#undef isc_siphash24
|
||||
|
||||
#endif /* if HAVE_OPENSSL_SIPHASH */
|
||||
|
||||
const uint8_t vectors[64][8] = {
|
||||
{
|
||||
@@ -692,36 +667,18 @@ const uint8_t vectors[64][8] = {
|
||||
},
|
||||
};
|
||||
|
||||
#if HAVE_OPENSSL_SIPHASH
|
||||
static void
|
||||
openssl_isc_siphash24_test(void **state) {
|
||||
isc_siphash24_test(void **state) {
|
||||
UNUSED(state);
|
||||
|
||||
uint8_t in[64], out[8], key[16];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(key); i++) {
|
||||
key[i] = i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 64; i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(in); i++) {
|
||||
in[i] = i;
|
||||
openssl_isc_siphash24(key, in, i, out);
|
||||
assert_memory_equal(out, vectors[i], 8);
|
||||
}
|
||||
}
|
||||
#endif /* if HAVE_OPENSSL_SIPHASH */
|
||||
|
||||
static void
|
||||
native_isc_siphash24_test(void **state) {
|
||||
UNUSED(state);
|
||||
|
||||
uint8_t in[64], out[8], key[16];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
key[i] = i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 64; i++) {
|
||||
in[i] = i;
|
||||
native_isc_siphash24(key, in, i, out);
|
||||
isc_siphash24(key, in, i, out);
|
||||
assert_memory_equal(out, vectors[i], 8);
|
||||
}
|
||||
}
|
||||
@@ -729,10 +686,7 @@ native_isc_siphash24_test(void **state) {
|
||||
int
|
||||
main(void) {
|
||||
const struct CMUnitTest tests[] = {
|
||||
#if HAVE_OPENSSL_SIPHASH
|
||||
cmocka_unit_test(openssl_isc_siphash24_test),
|
||||
#endif /* if HAVE_OPENSSL_SIPHASH */
|
||||
cmocka_unit_test(native_isc_siphash24_test),
|
||||
cmocka_unit_test(isc_siphash24_test),
|
||||
};
|
||||
|
||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
||||
|
||||
Reference in New Issue
Block a user