31#ifdef ENABLE_CRYPTO_OPENSSL
32#include <openssl/opensslv.h>
38#if defined(ENABLE_CRYPTO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x30000000L
39#include <openssl/evp.h>
62 const void *k, uint8_t *out,
const size_t outlen)
64 struct siphash_context *sip = sip_context;
67 sip->params[1] = OSSL_PARAM_construct_octet_string(
"key", (
void *)k,
69 if (!EVP_MAC_init(sip->ctx, NULL, 0, sip->params))
73 EVP_MAC_update(sip->ctx, in, inlen);
76 EVP_MAC_final(sip->ctx, out, &outl, outlen);
83 struct siphash_context *sip;
86 sip->mac = EVP_MAC_fetch(NULL,
"SIPHASH", NULL);
92 sip->ctx = EVP_MAC_CTX_new(sip->mac);
95 sip->size = hash_size;
96 sip->params[0] = OSSL_PARAM_construct_size_t(
"size", &sip->size);
98 sip->params[2] = OSSL_PARAM_construct_end();
105 const struct siphash_context *sip = sip_context;
107 return (
bool)(sip->mac);
113 struct siphash_context *sip = sip_context;
114 EVP_MAC_CTX_free(sip->ctx);
115 EVP_MAC_free(sip->mac);
124 const void *k, uint8_t *out,
const size_t outlen)
Buffer management functions and garbage collection.
#define ALLOC_OBJ(dptr, type)
Allocate memory for a single object of the given type.
Data Channel Cryptography SSL library-specific backend interface.
Data Channel Cryptography OpenSSL-specific backend interface.
#define crypto_msg(flags,...)
Retrieve any OpenSSL errors, then print the supplied error message.
void * siphash_openssl_init(size_t hash_size)
void siphash_openssl_uninit(void *sip_context)
Free the siphash context used for the crypto library.
int siphash_openssl(void *sip_context, const void *in, const size_t inlen, const void *k, uint8_t *out, const size_t outlen)
Calculates SIPHASH using the crypto library function.
bool siphash_openssl_available(const void *sip_context)
Returns if the crypto library is available (and should be used).