]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add extern key buffer setup for hash table
authorNeil Horman <nhorman@openssl.org>
Tue, 3 Mar 2026 14:45:19 +0000 (09:45 -0500)
committerAlexandr Nedvedicky <sashan@openssl.org>
Tue, 24 Mar 2026 16:22:47 +0000 (17:22 +0100)
One thing @npajkovsky noted in our recent discussion about the internal
hash table was that its unfortunate that keys have to be sized for the
maximal use case in our current hashtable code.

We can avoid that.

Introduce a new init mechanism that allows for keys to initalized using
an external buffer that can be setup and marshalled independently of the
key itself.  This allows us to only allocate the amount of data needed
for the key, rather than a maximally sized buffer where appropriate and
adventageous.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
MergeDate: Tue Mar 24 16:23:07 2026
(Merged from https://github.com/openssl/openssl/pull/30254)

include/internal/hashtable.h

index 320408bba4b91b7d2fd5581b5627b456fcf854be..b4d1f283f8aec280755008813e0317feadef3156 100644 (file)
@@ -176,6 +176,13 @@ static ossl_inline ossl_unused int ossl_key_raw_copy(HT_KEY *key, const uint8_t
         (key)->key_header.cached_hash = hash; \
     } while (0)
 
+#define HT_INIT_KEY_EXTERNAL(key, buf, len) \
+    do {                                    \
+        HT_INIT_KEY((key));                 \
+        (key)->key_header.keybuf = (buf);   \
+        (key)->key_header.keysize = (len);  \
+    } while (0)
+
 #define HT_KEY_GET_HASH(key) (key)->key_header.cached_hash
 
 /*