From ae7d90a1594dabf72123f395f9f2436452ab5d9a Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 25 Feb 2021 09:52:26 +1000 Subject: siphash: Add the C and D round parameters for SipHash. This represents a gap in functionality from the low level APIs. Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/14310) --- crypto/siphash/siphash.c | 8 ++------ crypto/siphash/siphash_local.h | 11 ++++++++--- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'crypto/siphash') diff --git a/crypto/siphash/siphash.c b/crypto/siphash/siphash.c index 03f9b4982d..eaad0a8e4a 100644 --- a/crypto/siphash/siphash.c +++ b/crypto/siphash/siphash.c @@ -30,10 +30,6 @@ #include "crypto/siphash.h" #include "siphash_local.h" -/* default: SipHash-2-4 */ -#define SIPHASH_C_ROUNDS 2 -#define SIPHASH_D_ROUNDS 4 - #define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b)))) #define U32TO8_LE(p, v) \ @@ -146,7 +142,7 @@ void SipHash_Update(SIPHASH *ctx, const unsigned char *in, size_t inlen) uint64_t m; const uint8_t *end; int left; - int i; + unsigned int i; uint64_t v0 = ctx->v0; uint64_t v1 = ctx->v1; uint64_t v2 = ctx->v2; @@ -202,7 +198,7 @@ void SipHash_Update(SIPHASH *ctx, const unsigned char *in, size_t inlen) int SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen) { /* finalize hash */ - int i; + unsigned int i; uint64_t b = ctx->total_inlen << 56; uint64_t v0 = ctx->v0; uint64_t v1 = ctx->v1; diff --git a/crypto/siphash/siphash_local.h b/crypto/siphash/siphash_local.h index 4841284c04..8cd7c208cc 100644 --- a/crypto/siphash/siphash_local.h +++ b/crypto/siphash/siphash_local.h @@ -16,8 +16,13 @@ struct siphash_st { uint64_t v2; uint64_t v3; unsigned int len; - int hash_size; - int crounds; - int drounds; + 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 + -- cgit v1.2.3