|
@@ -31,7 +31,7 @@
|
|
|
#include "sha384.h"
|
|
|
#include "crypto.h"
|
|
|
|
|
|
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
|
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
|
|
/* Compatibility wrapper for older versions. */
|
|
|
static int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx)
|
|
|
{
|
|
@@ -73,7 +73,7 @@ static BIGNUM * get_group5_prime(void)
|
|
|
static int openssl_digest_vector(const EVP_MD *type, size_t num_elem,
|
|
|
const u8 *addr[], const size_t *len, u8 *mac)
|
|
|
{
|
|
|
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
|
|
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
|
|
EVP_MD_CTX *ctx;
|
|
|
size_t i;
|
|
|
unsigned int mac_len;
|
|
@@ -733,7 +733,7 @@ void dh5_free(void *ctx)
|
|
|
|
|
|
|
|
|
struct crypto_hash {
|
|
|
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
|
|
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
|
|
HMAC_CTX *ctx;
|
|
|
#else
|
|
|
HMAC_CTX ctx;
|
|
@@ -772,7 +772,7 @@ struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
|
|
|
ctx = os_zalloc(sizeof(*ctx));
|
|
|
if (ctx == NULL)
|
|
|
return NULL;
|
|
|
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
|
|
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
|
|
ctx->ctx = HMAC_CTX_new();
|
|
|
if (!ctx->ctx) {
|
|
|
os_free(ctx);
|
|
@@ -801,7 +801,7 @@ void crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len)
|
|
|
{
|
|
|
if (ctx == NULL)
|
|
|
return;
|
|
|
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
|
|
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
|
|
HMAC_Update(ctx->ctx, data, len);
|
|
|
#else
|
|
|
HMAC_Update(&ctx->ctx, data, len);
|
|
@@ -818,7 +818,7 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len)
|
|
|
return -2;
|
|
|
|
|
|
if (mac == NULL || len == NULL) {
|
|
|
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
|
|
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
|
|
HMAC_CTX_free(ctx->ctx);
|
|
|
#endif
|
|
|
bin_clear_free(ctx, sizeof(*ctx));
|
|
@@ -826,7 +826,7 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len)
|
|
|
}
|
|
|
|
|
|
mdlen = *len;
|
|
|
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
|
|
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
|
|
res = HMAC_Final(ctx->ctx, mac, &mdlen);
|
|
|
HMAC_CTX_free(ctx->ctx);
|
|
|
#else
|
|
@@ -849,7 +849,7 @@ static int openssl_hmac_vector(const EVP_MD *type, const u8 *key,
|
|
|
const u8 *addr[], const size_t *len, u8 *mac,
|
|
|
unsigned int mdlen)
|
|
|
{
|
|
|
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
|
|
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
|
|
HMAC_CTX *ctx;
|
|
|
size_t i;
|
|
|
int res;
|