30#ifdef ENABLE_CRYPTO_OPENSSL
31#include <openssl/opensslv.h>
37#if defined(ENABLE_CRYPTO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x30000000L
38#include <openssl/evp.h>
61 const void *k, uint8_t *out,
const size_t outlen)
63 struct siphash_context *sip = sip_context;
66 sip->params[1] = OSSL_PARAM_construct_octet_string(
"key", (
void *)k,
68 if (!EVP_MAC_init(sip->ctx, NULL, 0, sip->params))
72 EVP_MAC_update(sip->ctx, in, inlen);
75 EVP_MAC_final(sip->ctx, out, &outl, outlen);
82 struct siphash_context *sip;
85 sip->mac = EVP_MAC_fetch(NULL,
"SIPHASH", NULL);
91 sip->ctx = EVP_MAC_CTX_new(sip->mac);
94 sip->size = hash_size;
95 sip->params[0] = OSSL_PARAM_construct_size_t(
"size", &sip->size);
97 sip->params[2] = OSSL_PARAM_construct_end();
104 struct siphash_context *sip = sip_context;
106 return (
bool)(sip->mac);
112 struct siphash_context *sip = sip_context;
113 EVP_MAC_CTX_free(sip->ctx);
114 EVP_MAC_free(sip->mac);
121 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.
bool siphash_openssl_available(void *sip_context)
Returns if the crypto library is available (and should be used)
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.