From 5db682733de0afcfece92ac011c1eb1ca775c32a Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 15 Mar 2021 17:44:42 +0000 Subject: [PATCH] Fix a TODO(3.0) in the siphash code All 3 files that included crypto/siphash.h also included siphash_local.h, and no other files included siphash_local.h independently. They probably should be just one header file. Fixes #14360 Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/14558) --- crypto/siphash/siphash.c | 1 - crypto/siphash/siphash_local.h | 28 ------------------- include/crypto/siphash.h | 19 +++++++++++++ providers/implementations/macs/siphash_prov.c | 6 ---- test/siphash_internal_test.c | 1 - 5 files changed, 19 insertions(+), 36 deletions(-) delete mode 100644 crypto/siphash/siphash_local.h diff --git a/crypto/siphash/siphash.c b/crypto/siphash/siphash.c index 071339d444..7584255709 100644 --- a/crypto/siphash/siphash.c +++ b/crypto/siphash/siphash.c @@ -28,7 +28,6 @@ #include #include "crypto/siphash.h" -#include "siphash_local.h" #define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b)))) diff --git a/crypto/siphash/siphash_local.h b/crypto/siphash/siphash_local.h deleted file mode 100644 index 54d65dfc6e..0000000000 --- a/crypto/siphash/siphash_local.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the Apache License 2.0 (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* Based on https://131002.net/siphash C reference implementation */ - -struct siphash_st { - uint64_t total_inlen; - uint64_t v0; - uint64_t v1; - uint64_t v2; - uint64_t v3; - unsigned int len; - unsigned int hash_size; - unsigned int crounds; - unsigned int drounds; - unsigned char leavings[SIPHASH_BLOCK_SIZE]; -}; - -/* default: SipHash-2-4 */ -#define SIPHASH_C_ROUNDS 2 -#define SIPHASH_D_ROUNDS 4 - diff --git a/include/crypto/siphash.h b/include/crypto/siphash.h index 02f74c4ae2..0d0767fcf4 100644 --- a/include/crypto/siphash.h +++ b/include/crypto/siphash.h @@ -28,4 +28,23 @@ int SipHash_Init(SIPHASH *ctx, const unsigned char *k, void SipHash_Update(SIPHASH *ctx, const unsigned char *in, size_t inlen); int SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen); +/* Based on https://131002.net/siphash C reference implementation */ + +struct siphash_st { + uint64_t total_inlen; + uint64_t v0; + uint64_t v1; + uint64_t v2; + uint64_t v3; + unsigned int len; + unsigned int hash_size; + unsigned int crounds; + unsigned int drounds; + unsigned char leavings[SIPHASH_BLOCK_SIZE]; +}; + +/* default: SipHash-2-4 */ +# define SIPHASH_C_ROUNDS 2 +# define SIPHASH_D_ROUNDS 4 + #endif diff --git a/providers/implementations/macs/siphash_prov.c b/providers/implementations/macs/siphash_prov.c index 0181d68ed1..0c374bd861 100644 --- a/providers/implementations/macs/siphash_prov.c +++ b/providers/implementations/macs/siphash_prov.c @@ -16,12 +16,6 @@ #include #include "crypto/siphash.h" -/* - * TODO(3.0) when siphash has moved entirely to our providers, this - * header should be moved to the provider include directory. For the - * moment, crypto/siphash/siphash_ameth.c has us stuck. - */ -#include "../../../crypto/siphash/siphash_local.h" #include "prov/implementations.h" #include "prov/providercommon.h" diff --git a/test/siphash_internal_test.c b/test/siphash_internal_test.c index e77e9d265f..2361921c57 100644 --- a/test/siphash_internal_test.c +++ b/test/siphash_internal_test.c @@ -15,7 +15,6 @@ #include #include "testutil.h" #include "crypto/siphash.h" -#include "../crypto/siphash/siphash_local.h" #include "internal/nelem.h" typedef struct {