LIBS=../../libcrypto
-$COMMON=hashtable.c
+$COMMON=hashtable.c hashfunc.c
SOURCE[../../libcrypto]=$COMMON
SOURCE[../../providers/libfips.a]=$COMMON
--- /dev/null
+/*
+ * Copyright 2025 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
+ *
+ */
+
+#include "internal/hashfunc.h"
+
+ossl_unused uint64_t fnv1a_hash(uint8_t *key, size_t len)
+{
+ uint64_t hash = 0xcbf29ce484222325ULL;
+ size_t i;
+
+ for (i = 0; i < len; i++) {
+ hash ^= key[i];
+ hash *= 0x00000100000001B3ULL;
+ }
+ return hash;
+}
#include <string.h>
#include <internal/rcu.h>
#include <internal/hashtable.h>
+#include <internal/hashfunc.h>
#include <openssl/rand.h>
/*
# define PREFETCH(x)
#endif
-static ossl_unused uint64_t fnv1a_hash(uint8_t *key, size_t len)
-{
- uint64_t hash = 0xcbf29ce484222325ULL;
- size_t i;
-
- for (i = 0; i < len; i++) {
- hash ^= key[i];
- hash *= 0x00000100000001B3ULL;
- }
- return hash;
-}
-
/*
* Define our neighborhood list length
* Note: It should always be a power of 2
--- /dev/null
+/*
+ * Copyright 2025 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
+ */
+
+#ifndef OPENSSL_HASHFUNC_H
+# define OPENSSL_HASHFUNC_H
+
+# include <openssl/e_os2.h>
+/**
+ * Generalized fnv1a 64 bit hash function
+ */
+ossl_unused uint64_t fnv1a_hash(uint8_t *key, size_t len);
+
+#endif
# For shared builds we need to include the libcrypto packet.c and quic_vlint.c
# in libssl as well.
SHARED_SOURCE[../libssl]=\
- ../crypto/packet.c ../crypto/quic_vlint.c ../crypto/time.c
+ ../crypto/packet.c ../crypto/quic_vlint.c ../crypto/time.c \
+ ../crypto/hashtable/hashfunc.c
IF[{- !$disabled{'deprecated-3.0'} -}]
SOURCE[../libssl]=ssl_rsa_legacy.c
#include <openssl/sslerr.h>
#include <crypto/rand.h>
#include "quic_local.h"
+#include "internal/hashfunc.h"
#include "internal/ssl_unwrap.h"
#include "internal/quic_tls.h"
#include "internal/quic_rx_depack.h"
CRYPTO_MUTEX *mutex;
};
-static uint64_t fnv1a_hash_token(uint8_t *key, size_t len)
-{
- uint64_t hash = 0xcbf29ce484222325ULL;
- size_t i;
-
- for (i = 0; i < len; i++) {
- hash ^= key[i];
- hash *= 0x00000100000001B3ULL;
- }
- return hash;
-}
-
static unsigned long quic_token_hash(const QUIC_TOKEN *item)
{
- return (unsigned long)fnv1a_hash_token(item->hashkey, item->hashkey_len);
+ return (unsigned long)fnv1a_hash(item->hashkey, item->hashkey_len);
}
static int quic_token_cmp(const QUIC_TOKEN *a, const QUIC_TOKEN *b)