mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Enable DNSSEC compilation on nettle 2.7.1
RHEL/CentOS 7 does not compile with DNSSEC enabled, because older version is not supported. Add few defines to compile also on older nettle versions. Adds also major version 4 check, taking into account higher major version.
This commit is contained in:
committed by
Simon Kelley
parent
8f9bd61505
commit
0b3ecf7432
24
src/crypto.c
24
src/crypto.c
@@ -18,11 +18,20 @@
|
|||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
|
|
||||||
|
/* Minimal version of nettle */
|
||||||
|
#define MIN_VERSION(major, minor) (NETTLE_VERSION_MAJOR == (major) && NETTLE_VERSION_MINOR >= (minor)) || \
|
||||||
|
(NETTLE_VERSION_MAJOR > (major))
|
||||||
|
|
||||||
#include <nettle/rsa.h>
|
#include <nettle/rsa.h>
|
||||||
#include <nettle/ecdsa.h>
|
#include <nettle/ecdsa.h>
|
||||||
#include <nettle/ecc-curve.h>
|
#include <nettle/ecc-curve.h>
|
||||||
|
#if !defined(NETTLE_VERSION_MAJOR)
|
||||||
|
#define NETTLE_VERSION_MAJOR 2
|
||||||
|
#endif
|
||||||
|
#if MIN_VERSION(3, 1)
|
||||||
#include <nettle/eddsa.h>
|
#include <nettle/eddsa.h>
|
||||||
#if NETTLE_VERSION_MAJOR == 3 && NETTLE_VERSION_MINOR >= 6
|
#endif
|
||||||
|
#if MIN_VERSION(3, 6)
|
||||||
# include <nettle/gostdsa.h>
|
# include <nettle/gostdsa.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -238,7 +247,7 @@ static int dnsmasq_ecdsa_verify(struct blockdata *key_data, unsigned int key_len
|
|||||||
static struct ecc_point *key_256 = NULL, *key_384 = NULL;
|
static struct ecc_point *key_256 = NULL, *key_384 = NULL;
|
||||||
static mpz_t x, y;
|
static mpz_t x, y;
|
||||||
static struct dsa_signature *sig_struct;
|
static struct dsa_signature *sig_struct;
|
||||||
#if NETTLE_VERSION_MAJOR == 3 && NETTLE_VERSION_MINOR < 4
|
#if !MIN_VERSION(3, 4)
|
||||||
#define nettle_get_secp_256r1() (&nettle_secp_256r1)
|
#define nettle_get_secp_256r1() (&nettle_secp_256r1)
|
||||||
#define nettle_get_secp_384r1() (&nettle_secp_384r1)
|
#define nettle_get_secp_384r1() (&nettle_secp_384r1)
|
||||||
#endif
|
#endif
|
||||||
@@ -301,7 +310,7 @@ static int dnsmasq_ecdsa_verify(struct blockdata *key_data, unsigned int key_len
|
|||||||
return nettle_ecdsa_verify(key, digest_len, digest, sig_struct);
|
return nettle_ecdsa_verify(key, digest_len, digest, sig_struct);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETTLE_VERSION_MAJOR == 3 && NETTLE_VERSION_MINOR >= 6
|
#if MIN_VERSION(3, 6)
|
||||||
static int dnsmasq_gostdsa_verify(struct blockdata *key_data, unsigned int key_len,
|
static int dnsmasq_gostdsa_verify(struct blockdata *key_data, unsigned int key_len,
|
||||||
unsigned char *sig, size_t sig_len,
|
unsigned char *sig, size_t sig_len,
|
||||||
unsigned char *digest, size_t digest_len, int algo)
|
unsigned char *digest, size_t digest_len, int algo)
|
||||||
@@ -342,6 +351,7 @@ static int dnsmasq_gostdsa_verify(struct blockdata *key_data, unsigned int key_l
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MIN_VERSION(3, 1)
|
||||||
static int dnsmasq_eddsa_verify(struct blockdata *key_data, unsigned int key_len,
|
static int dnsmasq_eddsa_verify(struct blockdata *key_data, unsigned int key_len,
|
||||||
unsigned char *sig, size_t sig_len,
|
unsigned char *sig, size_t sig_len,
|
||||||
unsigned char *digest, size_t digest_len, int algo)
|
unsigned char *digest, size_t digest_len, int algo)
|
||||||
@@ -368,7 +378,7 @@ static int dnsmasq_eddsa_verify(struct blockdata *key_data, unsigned int key_len
|
|||||||
((struct null_hash_digest *)digest)->buff,
|
((struct null_hash_digest *)digest)->buff,
|
||||||
sig);
|
sig);
|
||||||
|
|
||||||
#if NETTLE_VERSION_MAJOR == 3 && NETTLE_VERSION_MINOR >= 6
|
#if MIN_VERSION(3, 6)
|
||||||
case 16:
|
case 16:
|
||||||
if (key_len != ED448_KEY_SIZE ||
|
if (key_len != ED448_KEY_SIZE ||
|
||||||
sig_len != ED448_SIGNATURE_SIZE)
|
sig_len != ED448_SIGNATURE_SIZE)
|
||||||
@@ -384,6 +394,7 @@ static int dnsmasq_eddsa_verify(struct blockdata *key_data, unsigned int key_len
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int (*verify_func(int algo))(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
static int (*verify_func(int algo))(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
||||||
unsigned char *digest, size_t digest_len, int algo)
|
unsigned char *digest, size_t digest_len, int algo)
|
||||||
@@ -399,16 +410,17 @@ static int (*verify_func(int algo))(struct blockdata *key_data, unsigned int key
|
|||||||
case 5: case 7: case 8: case 10:
|
case 5: case 7: case 8: case 10:
|
||||||
return dnsmasq_rsa_verify;
|
return dnsmasq_rsa_verify;
|
||||||
|
|
||||||
#if NETTLE_VERSION_MAJOR == 3 && NETTLE_VERSION_MINOR >= 6
|
#if MIN_VERSION(3, 6)
|
||||||
case 12:
|
case 12:
|
||||||
return dnsmasq_gostdsa_verify;
|
return dnsmasq_gostdsa_verify;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case 13: case 14:
|
case 13: case 14:
|
||||||
return dnsmasq_ecdsa_verify;
|
return dnsmasq_ecdsa_verify;
|
||||||
|
#if MIN_VERSION(3, 1)
|
||||||
case 15: case 16:
|
case 15: case 16:
|
||||||
return dnsmasq_eddsa_verify;
|
return dnsmasq_eddsa_verify;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user