From 274bd216b3a846a972474677c480f6d9d573a4b2 Mon Sep 17 00:00:00 2001 From: Martyrshot Date: Sun, 22 Oct 2023 23:24:55 -0700 Subject: [PATCH] ran OQS-bind through clang-format --- bin/dnssec/dnssec-keygen.c | 4 +- bin/dnssec/dnssec-signzone.c | 9 ++- bin/named/main.c | 6 +- lib/dns/adb.c | 6 +- lib/dns/dnssec.c | 2 +- lib/dns/dst_api.c | 2 +- lib/dns/dst_parse.c | 121 ++++++++++++++-------------- lib/dns/dst_parse.h | 29 ++++--- lib/dns/include/dns/db.h | 14 ++-- lib/dns/include/dns/dbiterator.h | 2 +- lib/dns/include/dns/keytable.h | 6 +- lib/dns/include/dns/keyvalues.h | 48 +++++------ lib/dns/include/dns/qp.h | 6 +- lib/dns/include/dns/rbt.h | 2 +- lib/dns/include/dns/rdataset.h | 12 +-- lib/dns/include/dns/rdatasetiter.h | 4 +- lib/dns/include/dns/rdatatype.h | 2 +- lib/dns/include/dns/stats.h | 2 +- lib/dns/include/dns/update.h | 4 +- lib/dns/include/dns/view.h | 18 ++--- lib/dns/master.c | 2 +- lib/dns/nsec3.c | 8 +- lib/dns/openssloqs_link.c | 94 +++++++++++---------- lib/dns/private.c | 8 +- lib/dns/rcode.c | 43 +++++----- lib/dns/zone.c | 2 +- lib/isc/hashmap.c | 26 +++--- lib/isc/include/isc/endian.h | 34 ++++---- lib/isc/include/isc/job.h | 2 +- lib/isc/include/isc/net.h | 4 +- lib/isc/include/isc/radix.h | 2 +- lib/isc/include/isc/thread.h | 2 +- lib/isc/include/isc/work.h | 4 +- lib/isc/netaddr.c | 2 +- lib/isc/url.c | 5 +- lib/isccfg/include/isccfg/cfg.h | 8 +- lib/isccfg/include/isccfg/grammar.h | 10 +-- lib/ns/include/ns/client.h | 16 ++-- lib/ns/query.c | 2 +- tests/bench/siphash.c | 2 +- tests/isc/doh_test.c | 2 +- 41 files changed, 300 insertions(+), 277 deletions(-) diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index 67562a2563..f0fe4a6e76 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -828,7 +828,6 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv) { } } dst_key_free(&key); - } } while (conflict); @@ -885,7 +884,8 @@ main(int argc, char **argv) { int ch; bool set_fips_mode = false; #if OPENSSL_VERSION_NUMBER >= 0x30200000L && OPENSSL_API_LEVEL >= 30200 - OSSL_PROVIDER *fips = NULL, *base = NULL, *oqs = NULL, *default_provider = NULL; + OSSL_PROVIDER *fips = NULL, *base = NULL, *oqs = NULL, + *default_provider = NULL; #endif keygen_ctx_t ctx = { diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 501419e102..0e1c6428dc 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -106,11 +106,13 @@ static int nsec_datatype = dns_rdatatype_nsec; "dns_dbiterator_current()") #define IS_NSEC3 (nsec_datatype == dns_rdatatype_nsec3) -#define OPTOUT(x) (((x)&DNS_NSEC3FLAG_OPTOUT) != 0) +#define OPTOUT(x) (((x) & DNS_NSEC3FLAG_OPTOUT) != 0) #define REVOKE(x) ((dst_key_flags(x) & DNS_KEYFLAG_REVOKE) != 0) -#define BUFSIZE 8192 // OQS increased from 2049 to 8192 to account for SPHINCS+ 128S signatures. +#define BUFSIZE \ + 8192 // OQS increased from 2049 to 8192 to account for SPHINCS+ 128S + // signatures. #define MAXDSKEYS 8 #define SIGNER_EVENTCLASS ISC_EVENTCLASS(0x4453) @@ -3372,7 +3374,8 @@ main(int argc, char *argv[]) { bool nonsecify = false; bool set_fips_mode = false; #if OPENSSL_VERSION_NUMBER >= 0x30200000L && OPENSSL_API_LEVEL >= 30200 - OSSL_PROVIDER *fips = NULL, *base = NULL, *oqs = NULL, *default_provider = NULL; + OSSL_PROVIDER *fips = NULL, *base = NULL, *oqs = NULL, + *default_provider = NULL; #endif atomic_init(&shuttingdown, false); diff --git a/bin/named/main.c b/bin/named/main.c index 0b8238502e..65a44657b7 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -154,7 +154,8 @@ static bool disable6 = false; static bool disable4 = false; #if OPENSSL_VERSION_NUMBER >= 0x30200000L && OPENSSL_API_LEVEL >= 30200 -static OSSL_PROVIDER *fips = NULL, *base = NULL, *oqs = NULL, *default_provider = NULL; +static OSSL_PROVIDER *fips = NULL, *base = NULL, *oqs = NULL, + *default_provider = NULL; #endif void @@ -1562,7 +1563,8 @@ main(int argc, char *argv[]) { ERR_clear_error(); named_main_earlyfatal("Failed to load default provider"); } -#endif /* if OPENSSL_VERSION_NUMER >= 0x30200000L && OPENSSL_API_LEVEL >= 30200 */ +#endif /* if OPENSSL_VERSION_NUMER >= 0x30200000L && OPENSSL_API_LEVEL >= \ + 30200 */ #ifdef ENABLE_AFL if (named_g_fuzz_type != isc_fuzz_none) { named_fuzz_setup(); diff --git a/lib/dns/adb.c b/lib/dns/adb.c index fb99b4cf86..0d042f3ffb 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -457,8 +457,8 @@ enum { * These are currently used on simple unsigned ints, so they are * not really associated with any particular type. */ -#define WANT_INET(x) (((x)&DNS_ADBFIND_INET) != 0) -#define WANT_INET6(x) (((x)&DNS_ADBFIND_INET6) != 0) +#define WANT_INET(x) (((x) & DNS_ADBFIND_INET) != 0) +#define WANT_INET6(x) (((x) & DNS_ADBFIND_INET6) != 0) #define EXPIRE_OK(exp, now) ((exp == INT_MAX) || (exp < now)) @@ -469,7 +469,7 @@ enum { */ #define STARTATZONE_MATCHES(nf, o) \ (((nf)->flags & DNS_ADBFIND_STARTATZONE) == \ - ((o)&DNS_ADBFIND_STARTATZONE)) + ((o) & DNS_ADBFIND_STARTATZONE)) #define ENTER_LEVEL ISC_LOG_DEBUG(50) #define CLEAN_LEVEL ISC_LOG_DEBUG(100) diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index 763c90527b..fdc46430c8 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -1155,7 +1155,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg, dns_rdata_toregion(&rdata, &r); r.length -= sig.siglen; RETERR(dst_context_adddata(ctx, &r)); - + /* * If this is a response, digest the query. */ diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index d21f71af1b..0f286fcf7b 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -231,7 +231,7 @@ dst_lib_init(isc_mem_t *mctx, const char *engine) { RETERR(dst__openssloqs_init(&dst_t_func[DST_ALG_FALCON512])); RETERR(dst__openssloqs_init(&dst_t_func[DST_ALG_DILITHIUM2])); RETERR(dst__openssloqs_init(&dst_t_func[DST_ALG_SPHINCSSHA256128S])); - + dst_initialized = true; return (ISC_R_SUCCESS); diff --git a/lib/dns/dst_parse.c b/lib/dns/dst_parse.c index a6652475dd..a0d223c013 100644 --- a/lib/dns/dst_parse.c +++ b/lib/dns/dst_parse.c @@ -70,60 +70,63 @@ struct parse_map { const char *tag; }; -static struct parse_map map[] = { { TAG_RSA_MODULUS, "Modulus:" }, - { TAG_RSA_PUBLICEXPONENT, "PublicExponent:" }, - { TAG_RSA_PRIVATEEXPONENT, "PrivateExponent" - ":" }, - { TAG_RSA_PRIME1, "Prime1:" }, - { TAG_RSA_PRIME2, "Prime2:" }, - { TAG_RSA_EXPONENT1, "Exponent1:" }, - { TAG_RSA_EXPONENT2, "Exponent2:" }, - { TAG_RSA_COEFFICIENT, "Coefficient:" }, - { TAG_RSA_ENGINE, "Engine:" }, - { TAG_RSA_LABEL, "Label:" }, - - { TAG_ECDSA_PRIVATEKEY, "PrivateKey:" }, - { TAG_ECDSA_ENGINE, "Engine:" }, - { TAG_ECDSA_LABEL, "Label:" }, - - { TAG_EDDSA_PRIVATEKEY, "PrivateKey:" }, - { TAG_EDDSA_ENGINE, "Engine:" }, - { TAG_EDDSA_LABEL, "Label:" }, - - { TAG_HMACMD5_KEY, "Key:" }, - { TAG_HMACMD5_BITS, "Bits:" }, - - { TAG_HMACSHA1_KEY, "Key:" }, - { TAG_HMACSHA1_BITS, "Bits:" }, - - { TAG_HMACSHA224_KEY, "Key:" }, - { TAG_HMACSHA224_BITS, "Bits:" }, - - { TAG_HMACSHA256_KEY, "Key:" }, - { TAG_HMACSHA256_BITS, "Bits:" }, - - { TAG_HMACSHA384_KEY, "Key:" }, - { TAG_HMACSHA384_BITS, "Bits:" }, - - { TAG_HMACSHA512_KEY, "Key:" }, - { TAG_HMACSHA512_BITS, "Bits:" }, - - { TAG_FALCON512_PRIVATEKEY, "PrivateKey:" }, - { TAG_FALCON512_PUBLICKEY, "PublicKey:" }, - { TAG_FALCON512_ENGINE, "Engine:" }, // Probably won't use for now - { TAG_FALCON512_LABEL, "Label:" }, // Probably won't use for now - - { TAG_DILITHIUM2_PRIVATEKEY, "PrivateKey:" }, - { TAG_DILITHIUM2_PUBLICKEY, "PublicKey:" }, - { TAG_DILITHIUM2_ENGINE, "Engine:" }, // Probably won't use for now - { TAG_DILITHIUM2_LABEL, "Label:" }, // Probably won't use for now - - { TAG_SPHINCSSHA256128S_PRIVATEKEY, "PrivateKey:" }, - { TAG_SPHINCSSHA256128S_PUBLICKEY, "PublicKey:" }, - { TAG_SPHINCSSHA256128S_ENGINE, "Engine:" }, // Probably won't use for now - { TAG_SPHINCSSHA256128S_LABEL, "Label:" }, // Probably won't use for now - - { 0, NULL } }; +static struct parse_map map[] = { + { TAG_RSA_MODULUS, "Modulus:" }, + { TAG_RSA_PUBLICEXPONENT, "PublicExponent:" }, + { TAG_RSA_PRIVATEEXPONENT, "PrivateExponent" + ":" }, + { TAG_RSA_PRIME1, "Prime1:" }, + { TAG_RSA_PRIME2, "Prime2:" }, + { TAG_RSA_EXPONENT1, "Exponent1:" }, + { TAG_RSA_EXPONENT2, "Exponent2:" }, + { TAG_RSA_COEFFICIENT, "Coefficient:" }, + { TAG_RSA_ENGINE, "Engine:" }, + { TAG_RSA_LABEL, "Label:" }, + + { TAG_ECDSA_PRIVATEKEY, "PrivateKey:" }, + { TAG_ECDSA_ENGINE, "Engine:" }, + { TAG_ECDSA_LABEL, "Label:" }, + + { TAG_EDDSA_PRIVATEKEY, "PrivateKey:" }, + { TAG_EDDSA_ENGINE, "Engine:" }, + { TAG_EDDSA_LABEL, "Label:" }, + + { TAG_HMACMD5_KEY, "Key:" }, + { TAG_HMACMD5_BITS, "Bits:" }, + + { TAG_HMACSHA1_KEY, "Key:" }, + { TAG_HMACSHA1_BITS, "Bits:" }, + + { TAG_HMACSHA224_KEY, "Key:" }, + { TAG_HMACSHA224_BITS, "Bits:" }, + + { TAG_HMACSHA256_KEY, "Key:" }, + { TAG_HMACSHA256_BITS, "Bits:" }, + + { TAG_HMACSHA384_KEY, "Key:" }, + { TAG_HMACSHA384_BITS, "Bits:" }, + + { TAG_HMACSHA512_KEY, "Key:" }, + { TAG_HMACSHA512_BITS, "Bits:" }, + + { TAG_FALCON512_PRIVATEKEY, "PrivateKey:" }, + { TAG_FALCON512_PUBLICKEY, "PublicKey:" }, + { TAG_FALCON512_ENGINE, "Engine:" }, // Probably won't use for now + { TAG_FALCON512_LABEL, "Label:" }, // Probably won't use for now + + { TAG_DILITHIUM2_PRIVATEKEY, "PrivateKey:" }, + { TAG_DILITHIUM2_PUBLICKEY, "PublicKey:" }, + { TAG_DILITHIUM2_ENGINE, "Engine:" }, // Probably won't use for now + { TAG_DILITHIUM2_LABEL, "Label:" }, // Probably won't use for now + + { TAG_SPHINCSSHA256128S_PRIVATEKEY, "PrivateKey:" }, + { TAG_SPHINCSSHA256128S_PUBLICKEY, "PublicKey:" }, + { TAG_SPHINCSSHA256128S_ENGINE, "Engine:" }, // Probably won't use for + // now + { TAG_SPHINCSSHA256128S_LABEL, "Label:" }, // Probably won't use for now + + { 0, NULL } +}; static int find_value(const char *s, const unsigned int alg) { @@ -341,10 +344,10 @@ check_hmac_sha(const dst_private_t *priv, unsigned int ntags, // we only need to use one of the algorithms tags. This is define is // to make the code below easier to read. -#define TAG_OQS_LABEL TAG_FALCON512_LABEL -#define TAG_OQS_ENGINE TAG_FALCON512_ENGINE +#define TAG_OQS_LABEL TAG_FALCON512_LABEL +#define TAG_OQS_ENGINE TAG_FALCON512_ENGINE #define TAG_OQS_PRIVATEKEY TAG_FALCON512_PRIVATEKEY -#define TAG_OQS_PUBLICKEY TAG_FALCON512_PUBLICKEY +#define TAG_OQS_PUBLICKEY TAG_FALCON512_PUBLICKEY static int check_oqs(const dst_private_t *priv, const unsigned int alg, bool external) { @@ -376,8 +379,8 @@ check_oqs(const dst_private_t *priv, const unsigned int alg, bool external) { if (have[TAG_OQS_ENGINE & mask]) { ok = have[TAG_OQS_LABEL & mask]; } else { - ok = have[TAG_OQS_PRIVATEKEY & mask] - && have[TAG_OQS_PUBLICKEY & mask]; + ok = have[TAG_OQS_PRIVATEKEY & mask] && + have[TAG_OQS_PUBLICKEY & mask]; } return (ok ? 0 : -1); } diff --git a/lib/dns/dst_parse.h b/lib/dns/dst_parse.h index a07bf975c2..94f94d9700 100644 --- a/lib/dns/dst_parse.h +++ b/lib/dns/dst_parse.h @@ -33,7 +33,8 @@ #include #include -// OQS: updated from 512 to 8000 (SPHINCS+-SHA256-128S signature size + extra bytes to be safe) +// OQS: updated from 512 to 8000 (SPHINCS+-SHA256-128S signature size + extra +// bytes to be safe) #define MAXFIELDSIZE 8000 /* @@ -94,19 +95,23 @@ #define TAG_HMACSHA512_KEY ((DST_ALG_HMACSHA512 << TAG_SHIFT) + 0) #define TAG_HMACSHA512_BITS ((DST_ALG_HMACSHA512 << TAG_SHIFT) + 1) -#define OQS_NTAGS 4 -#define TAG_FALCON512_PRIVATEKEY ((DST_ALG_FALCON512 << TAG_SHIFT) + 0) -#define TAG_FALCON512_PUBLICKEY ((DST_ALG_FALCON512 << TAG_SHIFT) + 1) -#define TAG_FALCON512_ENGINE ((DST_ALG_FALCON512 << TAG_SHIFT) + 2) -#define TAG_FALCON512_LABEL ((DST_ALG_FALCON512 << TAG_SHIFT) + 3) +#define OQS_NTAGS 4 +#define TAG_FALCON512_PRIVATEKEY ((DST_ALG_FALCON512 << TAG_SHIFT) + 0) +#define TAG_FALCON512_PUBLICKEY ((DST_ALG_FALCON512 << TAG_SHIFT) + 1) +#define TAG_FALCON512_ENGINE ((DST_ALG_FALCON512 << TAG_SHIFT) + 2) +#define TAG_FALCON512_LABEL ((DST_ALG_FALCON512 << TAG_SHIFT) + 3) #define TAG_DILITHIUM2_PRIVATEKEY ((DST_ALG_DILITHIUM2 << TAG_SHIFT) + 0) #define TAG_DILITHIUM2_PUBLICKEY ((DST_ALG_DILITHIUM2 << TAG_SHIFT) + 1) -#define TAG_DILITHIUM2_ENGINE ((DST_ALG_DILITHIUM2 << TAG_SHIFT) + 2) -#define TAG_DILITHIUM2_LABEL ((DST_ALG_DILITHIUM2 << TAG_SHIFT) + 3) -#define TAG_SPHINCSSHA256128S_PRIVATEKEY ((DST_ALG_SPHINCSSHA256128S << TAG_SHIFT) + 0) -#define TAG_SPHINCSSHA256128S_PUBLICKEY ((DST_ALG_SPHINCSSHA256128S << TAG_SHIFT) + 1) -#define TAG_SPHINCSSHA256128S_ENGINE ((DST_ALG_SPHINCSSHA256128S << TAG_SHIFT) + 2) -#define TAG_SPHINCSSHA256128S_LABEL ((DST_ALG_SPHINCSSHA256128S << TAG_SHIFT) + 3) +#define TAG_DILITHIUM2_ENGINE ((DST_ALG_DILITHIUM2 << TAG_SHIFT) + 2) +#define TAG_DILITHIUM2_LABEL ((DST_ALG_DILITHIUM2 << TAG_SHIFT) + 3) +#define TAG_SPHINCSSHA256128S_PRIVATEKEY \ + ((DST_ALG_SPHINCSSHA256128S << TAG_SHIFT) + 0) +#define TAG_SPHINCSSHA256128S_PUBLICKEY \ + ((DST_ALG_SPHINCSSHA256128S << TAG_SHIFT) + 1) +#define TAG_SPHINCSSHA256128S_ENGINE \ + ((DST_ALG_SPHINCSSHA256128S << TAG_SHIFT) + 2) +#define TAG_SPHINCSSHA256128S_LABEL \ + ((DST_ALG_SPHINCSSHA256128S << TAG_SHIFT) + 3) struct dst_private_element { unsigned short tag; diff --git a/lib/dns/include/dns/db.h b/lib/dns/include/dns/db.h index 373fa30384..b2eea41a0f 100644 --- a/lib/dns/include/dns/db.h +++ b/lib/dns/include/dns/db.h @@ -79,15 +79,15 @@ extern unsigned int dns_pps; *****/ typedef struct dns_dbmethods { - void (*destroy)(dns_db_t *db); + void (*destroy)(dns_db_t *db); isc_result_t (*beginload)(dns_db_t *db, dns_rdatacallbacks_t *callbacks); isc_result_t (*endload)(dns_db_t *db, dns_rdatacallbacks_t *callbacks); void (*currentversion)(dns_db_t *db, dns_dbversion_t **versionp); isc_result_t (*newversion)(dns_db_t *db, dns_dbversion_t **versionp); - void (*attachversion)(dns_db_t *db, dns_dbversion_t *source, + void (*attachversion)(dns_db_t *db, dns_dbversion_t *source, dns_dbversion_t **targetp); - void (*closeversion)(dns_db_t *db, dns_dbversion_t **versionp, + void (*closeversion)(dns_db_t *db, dns_dbversion_t **versionp, bool commit DNS__DB_FLARG); isc_result_t (*findnode)(dns_db_t *db, const dns_name_t *name, bool create, @@ -104,7 +104,7 @@ typedef struct dns_dbmethods { dns_name_t *dcname, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset DNS__DB_FLARG); - void (*attachnode)(dns_db_t *db, dns_dbnode_t *source, + void (*attachnode)(dns_db_t *db, dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG); void (*detachnode)(dns_db_t *db, dns_dbnode_t **targetp DNS__DB_FLARG); isc_result_t (*createiterator)(dns_db_t *db, unsigned int options, @@ -132,9 +132,9 @@ typedef struct dns_dbmethods { dns_dbversion_t *version, dns_rdatatype_t type, dns_rdatatype_t covers DNS__DB_FLARG); - bool (*issecure)(dns_db_t *db); + bool (*issecure)(dns_db_t *db); unsigned int (*nodecount)(dns_db_t *db, dns_dbtree_t); - void (*setloop)(dns_db_t *db, isc_loop_t *); + void (*setloop)(dns_db_t *db, isc_loop_t *); isc_result_t (*getoriginnode)(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG); isc_result_t (*getnsec3parameters)(dns_db_t *db, @@ -165,7 +165,7 @@ typedef struct dns_dbmethods { dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset DNS__DB_FLARG); isc_result_t (*setcachestats)(dns_db_t *db, isc_stats_t *stats); - size_t (*hashsize)(dns_db_t *db); + size_t (*hashsize)(dns_db_t *db); isc_result_t (*getsize)(dns_db_t *db, dns_dbversion_t *version, uint64_t *records, uint64_t *bytes); isc_result_t (*setservestalettl)(dns_db_t *db, dns_ttl_t ttl); diff --git a/lib/dns/include/dns/dbiterator.h b/lib/dns/include/dns/dbiterator.h index e03636a7e7..d9b31ad4e3 100644 --- a/lib/dns/include/dns/dbiterator.h +++ b/lib/dns/include/dns/dbiterator.h @@ -68,7 +68,7 @@ ISC_LANG_BEGINDECLS *****/ typedef struct dns_dbiteratormethods { - void (*destroy)(dns_dbiterator_t **iteratorp DNS__DB_FLARG); + void (*destroy)(dns_dbiterator_t **iteratorp DNS__DB_FLARG); isc_result_t (*first)(dns_dbiterator_t *iterator DNS__DB_FLARG); isc_result_t (*last)(dns_dbiterator_t *iterator DNS__DB_FLARG); isc_result_t (*seek)(dns_dbiterator_t *iterator, diff --git a/lib/dns/include/dns/keytable.h b/lib/dns/include/dns/keytable.h index b407cf2552..1712abe9a9 100644 --- a/lib/dns/include/dns/keytable.h +++ b/lib/dns/include/dns/keytable.h @@ -287,9 +287,9 @@ dns_keynode_trust(dns_keynode_t *keynode); void dns_keytable_forall(dns_keytable_t *keytable, - void (*func)(dns_keytable_t *, dns_keynode_t *, - dns_name_t *, void *), - void *arg); + void (*func)(dns_keytable_t *, dns_keynode_t *, + dns_name_t *, void *), + void *arg); /*%< * Call 'func' on each keynode in 'keytable'. */ diff --git a/lib/dns/include/dns/keyvalues.h b/lib/dns/include/dns/keyvalues.h index 53c9386aec..b16a449a37 100644 --- a/lib/dns/include/dns/keyvalues.h +++ b/lib/dns/include/dns/keyvalues.h @@ -52,29 +52,29 @@ #define DNS_KEYFLAG_RESERVEDMASK2 0xFFFF /*%< no bits defined here */ /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ -#define DNS_KEYALG_RSAMD5 1 /*%< RSA with MD5 */ -#define DNS_KEYALG_RSA 1 /*%< Used just for tagging */ -#define DNS_KEYALG_DH_DEPRECATED 2 /*%< deprecated */ -#define DNS_KEYALG_DSA 3 /*%< DSA KEY */ -#define DNS_KEYALG_NSEC3DSA 6 -#define DNS_KEYALG_DSS DNS_ALG_DSA -#define DNS_KEYALG_ECC 4 -#define DNS_KEYALG_RSASHA1 5 -#define DNS_KEYALG_NSEC3RSASHA1 7 -#define DNS_KEYALG_RSASHA256 8 -#define DNS_KEYALG_RSASHA512 10 -#define DNS_KEYALG_ECCGOST 12 -#define DNS_KEYALG_ECDSA256 13 -#define DNS_KEYALG_ECDSA384 14 -#define DNS_KEYALG_ED25519 15 -#define DNS_KEYALG_ED448 16 -#define DNS_KEYALG_FALCON512 17 -#define DNS_KEYALG_DILITHIUM2 18 -#define DNS_KEYALG_SPHINCSSHA256128S 19 -#define DNS_KEYALG_INDIRECT 252 -#define DNS_KEYALG_PRIVATEDNS 253 -#define DNS_KEYALG_PRIVATEOID 254 /*%< Key begins with OID giving alg */ -#define DNS_KEYALG_MAX 255 +#define DNS_KEYALG_RSAMD5 1 /*%< RSA with MD5 */ +#define DNS_KEYALG_RSA 1 /*%< Used just for tagging */ +#define DNS_KEYALG_DH_DEPRECATED 2 /*%< deprecated */ +#define DNS_KEYALG_DSA 3 /*%< DSA KEY */ +#define DNS_KEYALG_NSEC3DSA 6 +#define DNS_KEYALG_DSS DNS_ALG_DSA +#define DNS_KEYALG_ECC 4 +#define DNS_KEYALG_RSASHA1 5 +#define DNS_KEYALG_NSEC3RSASHA1 7 +#define DNS_KEYALG_RSASHA256 8 +#define DNS_KEYALG_RSASHA512 10 +#define DNS_KEYALG_ECCGOST 12 +#define DNS_KEYALG_ECDSA256 13 +#define DNS_KEYALG_ECDSA384 14 +#define DNS_KEYALG_ED25519 15 +#define DNS_KEYALG_ED448 16 +#define DNS_KEYALG_FALCON512 17 +#define DNS_KEYALG_DILITHIUM2 18 +#define DNS_KEYALG_SPHINCSSHA256128S 19 +#define DNS_KEYALG_INDIRECT 252 +#define DNS_KEYALG_PRIVATEDNS 253 +#define DNS_KEYALG_PRIVATEOID 254 /*%< Key begins with OID giving alg */ +#define DNS_KEYALG_MAX 255 /* Protocol values */ #define DNS_KEYPROTO_RESERVED 0 @@ -113,4 +113,4 @@ #define DNS_KEY_DILITHIUM2SIZE 1312 #define DNS_SIG_SPHINCSSHA256128SSIZE 7856 -#define DNS_KEY_SPHINCSSHA256128SSIZE 32 +#define DNS_KEY_SPHINCSSHA256128SSIZE 32 diff --git a/lib/dns/include/dns/qp.h b/lib/dns/include/dns/qp.h index 2801c49040..67f7d648e1 100644 --- a/lib/dns/include/dns/qp.h +++ b/lib/dns/include/dns/qp.h @@ -227,11 +227,11 @@ typedef struct dns_qpiter { * readable identifier into `buf` which has max length `size`. */ typedef struct dns_qpmethods { - void (*attach)(void *uctx, void *pval, uint32_t ival); - void (*detach)(void *uctx, void *pval, uint32_t ival); + void (*attach)(void *uctx, void *pval, uint32_t ival); + void (*detach)(void *uctx, void *pval, uint32_t ival); size_t (*makekey)(dns_qpkey_t key, void *uctx, void *pval, uint32_t ival); - void (*triename)(void *uctx, char *buf, size_t size); + void (*triename)(void *uctx, char *buf, size_t size); } dns_qpmethods_t; /*% diff --git a/lib/dns/include/dns/rbt.h b/lib/dns/include/dns/rbt.h index 08b4803ab9..88d87ebb5d 100644 --- a/lib/dns/include/dns/rbt.h +++ b/lib/dns/include/dns/rbt.h @@ -698,7 +698,7 @@ dns_rbt_destroy2(dns_rbt_t **rbtp, unsigned int quantum); void dns_rbt_printtext(dns_rbt_t *rbt, void (*data_printer)(FILE *, void *), - FILE *f); + FILE *f); /*%< * Print an ASCII representation of the internal structure of the red-black * tree of trees to the passed stream. diff --git a/lib/dns/include/dns/rdataset.h b/lib/dns/include/dns/rdataset.h index 8216164100..df804f0546 100644 --- a/lib/dns/include/dns/rdataset.h +++ b/lib/dns/include/dns/rdataset.h @@ -75,11 +75,11 @@ typedef enum { } dns_rdatasetadditional_t; typedef struct dns_rdatasetmethods { - void (*disassociate)(dns_rdataset_t *rdataset DNS__DB_FLARG); + void (*disassociate)(dns_rdataset_t *rdataset DNS__DB_FLARG); isc_result_t (*first)(dns_rdataset_t *rdataset); isc_result_t (*next)(dns_rdataset_t *rdataset); - void (*current)(dns_rdataset_t *rdataset, dns_rdata_t *rdata); - void (*clone)(dns_rdataset_t *source, + void (*current)(dns_rdataset_t *rdataset, dns_rdata_t *rdata); + void (*clone)(dns_rdataset_t *source, dns_rdataset_t *target DNS__DB_FLARG); unsigned int (*count)(dns_rdataset_t *rdataset); isc_result_t (*addnoqname)(dns_rdataset_t *rdataset, @@ -92,9 +92,9 @@ typedef struct dns_rdatasetmethods { isc_result_t (*getclosest)(dns_rdataset_t *rdataset, dns_name_t *name, dns_rdataset_t *neg, dns_rdataset_t *negsig DNS__DB_FLARG); - void (*settrust)(dns_rdataset_t *rdataset, dns_trust_t trust); - void (*expire)(dns_rdataset_t *rdataset DNS__DB_FLARG); - void (*clearprefetch)(dns_rdataset_t *rdataset); + void (*settrust)(dns_rdataset_t *rdataset, dns_trust_t trust); + void (*expire)(dns_rdataset_t *rdataset DNS__DB_FLARG); + void (*clearprefetch)(dns_rdataset_t *rdataset); void (*setownercase)(dns_rdataset_t *rdataset, const dns_name_t *name); void (*getownercase)(const dns_rdataset_t *rdataset, dns_name_t *name); isc_result_t (*addglue)(dns_rdataset_t *rdataset, diff --git a/lib/dns/include/dns/rdatasetiter.h b/lib/dns/include/dns/rdatasetiter.h index 4689d333c3..4976babcd0 100644 --- a/lib/dns/include/dns/rdatasetiter.h +++ b/lib/dns/include/dns/rdatasetiter.h @@ -67,10 +67,10 @@ ISC_LANG_BEGINDECLS *****/ typedef struct dns_rdatasetitermethods { - void (*destroy)(dns_rdatasetiter_t **iteratorp DNS__DB_FLARG); + void (*destroy)(dns_rdatasetiter_t **iteratorp DNS__DB_FLARG); isc_result_t (*first)(dns_rdatasetiter_t *iterator DNS__DB_FLARG); isc_result_t (*next)(dns_rdatasetiter_t *iterator DNS__DB_FLARG); - void (*current)(dns_rdatasetiter_t *iterator, + void (*current)(dns_rdatasetiter_t *iterator, dns_rdataset_t *rdataset DNS__DB_FLARG); } dns_rdatasetitermethods_t; diff --git a/lib/dns/include/dns/rdatatype.h b/lib/dns/include/dns/rdatatype.h index 46ecef329f..a1b301ac85 100644 --- a/lib/dns/include/dns/rdatatype.h +++ b/lib/dns/include/dns/rdatatype.h @@ -19,7 +19,7 @@ #include -#define DNS_TYPEPAIR_TYPE(type) ((dns_rdatatype_t)((type)&0xFFFF)) +#define DNS_TYPEPAIR_TYPE(type) ((dns_rdatatype_t)((type) & 0xFFFF)) #define DNS_TYPEPAIR_COVERS(type) ((dns_rdatatype_t)((type) >> 16)) #define DNS_TYPEPAIR_VALUE(base, ext) \ ((dns_typepair_t)(((uint32_t)ext) << 16) | (((uint32_t)base) & 0xffff)) diff --git a/lib/dns/include/dns/stats.h b/lib/dns/include/dns/stats.h index ffa7e21ae1..447ec95277 100644 --- a/lib/dns/include/dns/stats.h +++ b/lib/dns/include/dns/stats.h @@ -234,7 +234,7 @@ enum { /*%< * Conversion macros among dns_rdatatype_t, attributes and isc_statscounter_t. */ -#define DNS_RDATASTATSTYPE_BASE(type) ((dns_rdatatype_t)((type)&0xFFFF)) +#define DNS_RDATASTATSTYPE_BASE(type) ((dns_rdatatype_t)((type) & 0xFFFF)) #define DNS_RDATASTATSTYPE_ATTR(type) ((type) >> 16) #define DNS_RDATASTATSTYPE_VALUE(b, a) (((a) << 16) | (b)) diff --git a/lib/dns/include/dns/update.h b/lib/dns/include/dns/update.h index 8ca1bf090e..95dea85b5c 100644 --- a/lib/dns/include/dns/update.h +++ b/lib/dns/include/dns/update.h @@ -27,8 +27,8 @@ #include typedef struct { - void (*func)(void *arg, dns_zone_t *zone, int level, - const char *message); + void (*func)(void *arg, dns_zone_t *zone, int level, + const char *message); void *arg; } dns_update_log_t; diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index f8b1d943c7..f9640b9b4a 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -212,13 +212,13 @@ struct dns_view { * XXX: This should be a pointer to an opaque type that * named implements. */ - char *new_zone_dir; - char *new_zone_file; - char *new_zone_db; - void *new_zone_dbenv; - uint64_t new_zone_mapsize; - void *new_zone_config; - void (*cfg_destroy)(void **); + char *new_zone_dir; + char *new_zone_file; + char *new_zone_db; + void *new_zone_dbenv; + uint64_t new_zone_mapsize; + void *new_zone_config; + void (*cfg_destroy)(void **); isc_mutex_t new_zone_lock; unsigned char secret[32]; /* Client secret */ @@ -230,11 +230,11 @@ struct dns_view { /* Registered module instances */ void *plugins; - void (*plugins_free)(isc_mem_t *, void **); + void (*plugins_free)(isc_mem_t *, void **); /* Hook table */ void *hooktable; /* ns_hooktable */ - void (*hooktable_free)(isc_mem_t *, void **); + void (*hooktable_free)(isc_mem_t *, void **); }; #define DNS_VIEW_MAGIC ISC_MAGIC('V', 'i', 'e', 'w') diff --git a/lib/dns/master.c b/lib/dns/master.c index b8f1bfaff6..81cc999b00 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -87,7 +87,7 @@ #define DNS_MASTER_LHS 2048 #define DNS_MASTER_RHS MINTSIZ -#define CHECKNAMESFAIL(x) (((x)&DNS_MASTER_CHECKNAMESFAIL) != 0) +#define CHECKNAMESFAIL(x) (((x) & DNS_MASTER_CHECKNAMESFAIL) != 0) typedef ISC_LIST(dns_rdatalist_t) rdatalist_head_t; diff --git a/lib/dns/nsec3.c b/lib/dns/nsec3.c index 227ac5c129..7a9d6becdd 100644 --- a/lib/dns/nsec3.c +++ b/lib/dns/nsec3.c @@ -48,10 +48,10 @@ goto failure; \ } while (0) -#define OPTOUT(x) (((x)&DNS_NSEC3FLAG_OPTOUT) != 0) -#define CREATE(x) (((x)&DNS_NSEC3FLAG_CREATE) != 0) -#define INITIAL(x) (((x)&DNS_NSEC3FLAG_INITIAL) != 0) -#define REMOVE(x) (((x)&DNS_NSEC3FLAG_REMOVE) != 0) +#define OPTOUT(x) (((x) & DNS_NSEC3FLAG_OPTOUT) != 0) +#define CREATE(x) (((x) & DNS_NSEC3FLAG_CREATE) != 0) +#define INITIAL(x) (((x) & DNS_NSEC3FLAG_INITIAL) != 0) +#define REMOVE(x) (((x) & DNS_NSEC3FLAG_REMOVE) != 0) isc_result_t dns_nsec3_buildrdata(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node, diff --git a/lib/dns/openssloqs_link.c b/lib/dns/openssloqs_link.c index aac1cf5310..d37d36a32b 100644 --- a/lib/dns/openssloqs_link.c +++ b/lib/dns/openssloqs_link.c @@ -29,7 +29,6 @@ #include - #include "dst_internal.h" #include "dst_openssl.h" #include "dst_parse.h" @@ -40,12 +39,13 @@ goto err; \ } -#define FALCON512_PRIVATEKEYSIZE 1281 -#define DILITHIUM2_PRIVATEKEYSIZE 2528 +#define FALCON512_PRIVATEKEYSIZE 1281 +#define DILITHIUM2_PRIVATEKEYSIZE 2528 #define SPHINCSSHA256128S_PRIVATEKEYSIZE 64 typedef struct oqs_tags { - unsigned int ntags, private_key_tag, public_key_tag, engine_tag, label_tag; + unsigned int ntags, private_key_tag, public_key_tag, engine_tag, + label_tag; } oqs_tags_t; typedef struct oqs_alginfo { @@ -54,7 +54,6 @@ typedef struct oqs_alginfo { oqs_tags_t tags; } oqs_alginfo_t; - static const oqs_alginfo_t * openssloqs_alg_info(unsigned int key_alg) { if (key_alg == DST_ALG_FALCON512) { @@ -109,7 +108,8 @@ openssloqs_alg_info(unsigned int key_alg) { } static isc_result_t -raw_pub_key_to_ossl(const oqs_alginfo_t *alginfo, const unsigned char *pub_key, size_t *pub_key_len, EVP_PKEY **pkey) { +raw_pub_key_to_ossl(const oqs_alginfo_t *alginfo, const unsigned char *pub_key, + size_t *pub_key_len, EVP_PKEY **pkey) { isc_result_t ret = DST_R_INVALIDPUBLICKEY; const char *alg_name = alginfo->alg_name; @@ -117,7 +117,8 @@ raw_pub_key_to_ossl(const oqs_alginfo_t *alginfo, const unsigned char *pub_key, if (pub_key_len == NULL || *pub_key_len < alginfo->key_size) { return (ret); } - *pkey = EVP_PKEY_new_raw_public_key_ex(NULL, alg_name, NULL, pub_key, alginfo->key_size); + *pkey = EVP_PKEY_new_raw_public_key_ex( + NULL, alg_name, NULL, pub_key, alginfo->key_size); } if (*pkey == NULL) { return (dst__openssl_toresult(ret)); @@ -126,8 +127,10 @@ raw_pub_key_to_ossl(const oqs_alginfo_t *alginfo, const unsigned char *pub_key, return (ISC_R_SUCCESS); } static isc_result_t -raw_priv_key_to_ossl(const oqs_alginfo_t *alginfo, const unsigned char *priv_key, size_t *priv_key_len, - const unsigned char *pub_key, size_t *pub_key_len, EVP_PKEY **pkey) { +raw_priv_key_to_ossl(const oqs_alginfo_t *alginfo, + const unsigned char *priv_key, size_t *priv_key_len, + const unsigned char *pub_key, size_t *pub_key_len, + EVP_PKEY **pkey) { EVP_PKEY *pk = NULL; EVP_PKEY_CTX *ctx = NULL; OSSL_PARAM_BLD *param_bld = NULL; @@ -137,9 +140,12 @@ raw_priv_key_to_ossl(const oqs_alginfo_t *alginfo, const unsigned char *priv_key if (pkey == NULL) { return (ISC_R_NOMEMORY); } - if ((param_bld = OSSL_PARAM_BLD_new()) == NULL - || !OSSL_PARAM_BLD_push_octet_string(param_bld, "priv", priv_key, *priv_key_len) - || !OSSL_PARAM_BLD_push_octet_string(param_bld, "pub", pub_key, *pub_key_len)) { + if ((param_bld = OSSL_PARAM_BLD_new()) == NULL || + !OSSL_PARAM_BLD_push_octet_string(param_bld, "priv", priv_key, + *priv_key_len) || + !OSSL_PARAM_BLD_push_octet_string(param_bld, "pub", pub_key, + *pub_key_len)) + { return (ISC_R_NOMEMORY); } params = OSSL_PARAM_BLD_to_param(param_bld); @@ -150,8 +156,9 @@ raw_priv_key_to_ossl(const oqs_alginfo_t *alginfo, const unsigned char *priv_key if (ctx == NULL) { goto ctxt_err; } - if (EVP_PKEY_fromdata_init(ctx) <= 0 - || EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEY_PARAMETERS, params) <= 0) { + if (EVP_PKEY_fromdata_init(ctx) <= 0 || + EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEY_PARAMETERS, params) <= 0) + { goto fromdata_err; } if (pk == NULL) { @@ -161,7 +168,7 @@ raw_priv_key_to_ossl(const oqs_alginfo_t *alginfo, const unsigned char *priv_key ret = ISC_R_SUCCESS; fromdata_err: - EVP_PKEY_CTX_free(ctx); + EVP_PKEY_CTX_free(ctx); ctxt_err: OSSL_PARAM_free(params); @@ -174,8 +181,7 @@ raw_priv_key_to_ossl(const oqs_alginfo_t *alginfo, const unsigned char *priv_key static isc_result_t openssloqs_createctx(dst_key_t *key, dst_context_t *dctx) { isc_buffer_t *buf = NULL; - const oqs_alginfo_t *alginfo = - openssloqs_alg_info(dctx->key->key_alg); + const oqs_alginfo_t *alginfo = openssloqs_alg_info(dctx->key->key_alg); UNUSED(key); @@ -190,11 +196,10 @@ openssloqs_createctx(dst_key_t *key, dst_context_t *dctx) { static void openssloqs_destroyctx(dst_context_t *dctx) { isc_buffer_t *buf = (isc_buffer_t *)dctx->ctxdata.generic; - const oqs_alginfo_t *alginfo = - openssloqs_alg_info(dctx->key->key_alg); + const oqs_alginfo_t *alginfo = openssloqs_alg_info(dctx->key->key_alg); REQUIRE(alginfo != NULL); - + if (buf != NULL) { isc_buffer_free(&buf); } @@ -208,8 +213,7 @@ openssloqs_adddata(dst_context_t *dctx, const isc_region_t *data) { isc_region_t r; unsigned int length; isc_result_t result; - const oqs_alginfo_t *alginfo = - openssloqs_alg_info(dctx->key->key_alg); + const oqs_alginfo_t *alginfo = openssloqs_alg_info(dctx->key->key_alg); REQUIRE(alginfo != NULL); @@ -260,7 +264,8 @@ openssloqs_sign(dst_context_t *dctx, isc_buffer_t *sig) { dctx->category, "EVP_DigestSignInit", ISC_R_FAILURE)); } if (EVP_DigestSign(ctx, sigreg.base, &siglen, tbsreg.base, - tbsreg.length) != 1) { + tbsreg.length) != 1) + { DST_RET(dst__openssl_toresult3(dctx->category, "EVP_DigestSign", DST_R_SIGNFAILURE)); } @@ -337,25 +342,25 @@ openssloqs_generate(dst_key_t *key, int unused, void (*callback)(int)) { UNUSED(unused); UNUSED(callback); - + REQUIRE(alginfo != NULL); ctx = EVP_PKEY_CTX_new_from_name(NULL, alginfo->alg_name, NULL); if (ctx == NULL) { return (dst__openssl_toresult2("EVP_PKEY_CTX_new_id", - DST_R_OPENSSLFAILURE)); + DST_R_OPENSSLFAILURE)); } status = EVP_PKEY_keygen_init(ctx); if (status != 1) { DST_RET(dst__openssl_toresult2("EVP_PKEY_keygen_init", - DST_R_OPENSSLFAILURE)); + DST_R_OPENSSLFAILURE)); } status = EVP_PKEY_keygen(ctx, &pkey); if (status != 1) { DST_RET(dst__openssl_toresult2("EVP_PKEY_keygen", - DST_R_OPENSSLFAILURE)); + DST_R_OPENSSLFAILURE)); } key->key_size = alginfo->key_size * 8; @@ -433,7 +438,9 @@ openssloqs_tofile(const dst_key_t *key, const char *directory) { publen = alginfo->key_size; privlen = alginfo->priv_key_size; - if (key->keydata.pkeypair.pub == NULL || key->keydata.pkeypair.priv == NULL) { + if (key->keydata.pkeypair.pub == NULL || + key->keydata.pkeypair.priv == NULL) + { return (DST_R_NULLKEY); } @@ -446,16 +453,16 @@ openssloqs_tofile(const dst_key_t *key, const char *directory) { if (dst__openssl_keypair_isprivate(key)) { privbuf = isc_mem_get(key->mctx, privlen); - if (EVP_PKEY_get_raw_private_key(key->keydata.pkeypair.priv, privbuf, - &privlen) != 1) + if (EVP_PKEY_get_raw_private_key(key->keydata.pkeypair.priv, + privbuf, &privlen) != 1) DST_RET(dst__openssl_toresult(ISC_R_FAILURE)); priv.elements[i].tag = alginfo->tags.private_key_tag; priv.elements[i].length = privlen; priv.elements[i].data = privbuf; i++; pubbuf = isc_mem_get(key->mctx, publen); - if (EVP_PKEY_get_raw_public_key(key->keydata.pkeypair.priv, pubbuf, - &publen) != 1) + if (EVP_PKEY_get_raw_public_key(key->keydata.pkeypair.priv, + pubbuf, &publen) != 1) DST_RET(dst__openssl_toresult(ISC_R_FAILURE)); priv.elements[i].tag = alginfo->tags.public_key_tag; priv.elements[i].length = publen; @@ -485,11 +492,11 @@ openssloqs_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) { size_t pub_len, priv_len; isc_mem_t *mctx = key->mctx; const oqs_alginfo_t *alginfo = openssloqs_alg_info(key->key_alg); - + UNUSED(engine); UNUSED(label); UNUSED(pubpkey); - + REQUIRE(alginfo != NULL); /* read private key file */ @@ -547,7 +554,8 @@ openssloqs_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) { priv_len = priv.elements[privkey_index].length; pub_len = priv.elements[pubkey_index].length; ret = raw_priv_key_to_ossl(alginfo, priv.elements[privkey_index].data, - &priv_len, priv.elements[pubkey_index].data, &pub_len, &pkey); + &priv_len, priv.elements[pubkey_index].data, + &pub_len, &pkey); if (ret != ISC_R_SUCCESS) { DST_RET(ret); } @@ -579,15 +587,17 @@ static dst_func_t openssloqs_functions = { NULL, /*%< paramcompare */ openssloqs_generate, dst__openssl_keypair_isprivate, - dst__openssl_keypair_destroy, - openssloqs_todns, // called by dst_key_todns converts a dst_key to a buffer - openssloqs_fromdns, // called by from buffer and constructs a key from dns + dst__openssl_keypair_destroy, + openssloqs_todns, // called by dst_key_todns converts a dst_key to a + // buffer + openssloqs_fromdns, // called by from buffer and constructs a key from + // dns openssloqs_tofile, openssloqs_parse, - NULL, /*%< cleanup */ - NULL, /*%< fromlabel */ - NULL, /*%< dump */ - NULL, /*%< restore */ + NULL, /*%< cleanup */ + NULL, /*%< fromlabel */ + NULL, /*%< dump */ + NULL, /*%< restore */ }; isc_result_t diff --git a/lib/dns/private.c b/lib/dns/private.c index 35ccda0223..a6bd714e8c 100644 --- a/lib/dns/private.c +++ b/lib/dns/private.c @@ -38,10 +38,10 @@ * been requested to be built otherwise a NSEC chain needs to be built. */ -#define REMOVE(x) (((x)&DNS_NSEC3FLAG_REMOVE) != 0) -#define CREATE(x) (((x)&DNS_NSEC3FLAG_CREATE) != 0) -#define INITIAL(x) (((x)&DNS_NSEC3FLAG_INITIAL) != 0) -#define NONSEC(x) (((x)&DNS_NSEC3FLAG_NONSEC) != 0) +#define REMOVE(x) (((x) & DNS_NSEC3FLAG_REMOVE) != 0) +#define CREATE(x) (((x) & DNS_NSEC3FLAG_CREATE) != 0) +#define INITIAL(x) (((x) & DNS_NSEC3FLAG_INITIAL) != 0) +#define NONSEC(x) (((x) & DNS_NSEC3FLAG_NONSEC) != 0) #define CHECK(x) \ do { \ diff --git a/lib/dns/rcode.c b/lib/dns/rcode.c index 833a8767a6..fc970255cf 100644 --- a/lib/dns/rcode.c +++ b/lib/dns/rcode.c @@ -97,28 +97,27 @@ /* RFC2535 section 7, RFC3110 */ -#define SECALGNAMES \ - { DNS_KEYALG_RSAMD5, "RSAMD5", 0 }, \ - { DNS_KEYALG_DSA, "DSA", 0 }, \ - { DNS_KEYALG_RSASHA1, "RSASHA1", 0 }, \ - { DNS_KEYALG_NSEC3DSA, "NSEC3DSA", 0 }, \ - { DNS_KEYALG_NSEC3RSASHA1, "NSEC3RSASHA1", 0 }, \ - { DNS_KEYALG_RSASHA256, "RSASHA256", 0 }, \ - { DNS_KEYALG_RSASHA512, "RSASHA512", 0 }, \ - { DNS_KEYALG_ECCGOST, "ECCGOST", 0 }, \ - { DNS_KEYALG_ECDSA256, "ECDSAP256SHA256", 0 }, \ - { DNS_KEYALG_ECDSA256, "ECDSA256", 0 }, \ - { DNS_KEYALG_ECDSA384, "ECDSAP384SHA384", 0 }, \ - { DNS_KEYALG_ECDSA384, "ECDSA384", 0 }, \ - { DNS_KEYALG_ED25519, "ED25519", 0 }, \ - { DNS_KEYALG_ED448, "ED448", 0 }, \ - { DNS_KEYALG_FALCON512, "FALCON512", 0 }, \ - { DNS_KEYALG_DILITHIUM2, "DILITHIUM2", 0 }, \ - { DNS_KEYALG_SPHINCSSHA256128S, "SPHINCS+-SHA256-128S", 0 }, \ - { DNS_KEYALG_INDIRECT, "INDIRECT", 0 }, \ - { DNS_KEYALG_PRIVATEDNS, "PRIVATEDNS", 0 }, \ - { DNS_KEYALG_PRIVATEOID, "PRIVATEOID", 0 }, { \ - 0, NULL, 0 \ +#define SECALGNAMES \ + { DNS_KEYALG_RSAMD5, "RSAMD5", 0 }, { DNS_KEYALG_DSA, "DSA", 0 }, \ + { DNS_KEYALG_RSASHA1, "RSASHA1", 0 }, \ + { DNS_KEYALG_NSEC3DSA, "NSEC3DSA", 0 }, \ + { DNS_KEYALG_NSEC3RSASHA1, "NSEC3RSASHA1", 0 }, \ + { DNS_KEYALG_RSASHA256, "RSASHA256", 0 }, \ + { DNS_KEYALG_RSASHA512, "RSASHA512", 0 }, \ + { DNS_KEYALG_ECCGOST, "ECCGOST", 0 }, \ + { DNS_KEYALG_ECDSA256, "ECDSAP256SHA256", 0 }, \ + { DNS_KEYALG_ECDSA256, "ECDSA256", 0 }, \ + { DNS_KEYALG_ECDSA384, "ECDSAP384SHA384", 0 }, \ + { DNS_KEYALG_ECDSA384, "ECDSA384", 0 }, \ + { DNS_KEYALG_ED25519, "ED25519", 0 }, \ + { DNS_KEYALG_ED448, "ED448", 0 }, \ + { DNS_KEYALG_FALCON512, "FALCON512", 0 }, \ + { DNS_KEYALG_DILITHIUM2, "DILITHIUM2", 0 }, \ + { DNS_KEYALG_SPHINCSSHA256128S, "SPHINCS+-SHA256-128S", 0 }, \ + { DNS_KEYALG_INDIRECT, "INDIRECT", 0 }, \ + { DNS_KEYALG_PRIVATEDNS, "PRIVATEDNS", 0 }, \ + { DNS_KEYALG_PRIVATEOID, "PRIVATEOID", 0 }, { \ + 0, NULL, 0 \ } /* RFC2535 section 7.1 */ diff --git a/lib/dns/zone.c b/lib/dns/zone.c index affce8c0d5..1eaecd0763 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -126,7 +126,7 @@ */ #define RANGE(a, min, max) (((a) < (min)) ? (min) : ((a) < (max) ? (a) : (max))) -#define NSEC3REMOVE(x) (((x)&DNS_NSEC3FLAG_REMOVE) != 0) +#define NSEC3REMOVE(x) (((x) & DNS_NSEC3FLAG_REMOVE) != 0) /*% * Key flags diff --git a/lib/isc/hashmap.c b/lib/isc/hashmap.c index b54e61137e..fcae61dd37 100644 --- a/lib/isc/hashmap.c +++ b/lib/isc/hashmap.c @@ -41,19 +41,19 @@ #include #include -#define APPROX_99_PERCENT(x) (((x)*1013) >> 10) -#define APPROX_95_PERCENT(x) (((x)*972) >> 10) -#define APPROX_90_PERCENT(x) (((x)*921) >> 10) -#define APPROX_85_PERCENT(x) (((x)*870) >> 10) -#define APPROX_40_PERCENT(x) (((x)*409) >> 10) -#define APPROX_35_PERCENT(x) (((x)*359) >> 10) -#define APPROX_30_PERCENT(x) (((x)*308) >> 10) -#define APPROX_25_PERCENT(x) (((x)*256) >> 10) -#define APPROX_20_PERCENT(x) (((x)*205) >> 10) -#define APPROX_15_PERCENT(x) (((x)*154) >> 10) -#define APPROX_10_PERCENT(x) (((x)*103) >> 10) -#define APPROX_05_PERCENT(x) (((x)*52) >> 10) -#define APPROX_01_PERCENT(x) (((x)*11) >> 10) +#define APPROX_99_PERCENT(x) (((x) * 1013) >> 10) +#define APPROX_95_PERCENT(x) (((x) * 972) >> 10) +#define APPROX_90_PERCENT(x) (((x) * 921) >> 10) +#define APPROX_85_PERCENT(x) (((x) * 870) >> 10) +#define APPROX_40_PERCENT(x) (((x) * 409) >> 10) +#define APPROX_35_PERCENT(x) (((x) * 359) >> 10) +#define APPROX_30_PERCENT(x) (((x) * 308) >> 10) +#define APPROX_25_PERCENT(x) (((x) * 256) >> 10) +#define APPROX_20_PERCENT(x) (((x) * 205) >> 10) +#define APPROX_15_PERCENT(x) (((x) * 154) >> 10) +#define APPROX_10_PERCENT(x) (((x) * 103) >> 10) +#define APPROX_05_PERCENT(x) (((x) * 52) >> 10) +#define APPROX_01_PERCENT(x) (((x) * 11) >> 10) #define ISC_HASHMAP_MAGIC ISC_MAGIC('H', 'M', 'a', 'p') #define ISC_HASHMAP_VALID(hashmap) ISC_MAGIC_VALID(hashmap, ISC_HASHMAP_MAGIC) diff --git a/lib/isc/include/isc/endian.h b/lib/isc/include/isc/endian.h index 6d5e6c2b4f..3c7ffbc298 100644 --- a/lib/isc/include/isc/endian.h +++ b/lib/isc/include/isc/endian.h @@ -86,29 +86,29 @@ #include #ifndef bswap_16 -#define bswap_16(x) \ - ((uint16_t)((((uint16_t)(x)&0xff00) >> 8) | \ - (((uint16_t)(x)&0x00ff) << 8))) +#define bswap_16(x) \ + ((uint16_t)((((uint16_t)(x) & 0xff00) >> 8) | \ + (((uint16_t)(x) & 0x00ff) << 8))) #endif /* !bswap_16 */ #ifndef bswap_32 -#define bswap_32(x) \ - ((uint32_t)((((uint32_t)(x)&0xff000000) >> 24) | \ - (((uint32_t)(x)&0x00ff0000) >> 8) | \ - (((uint32_t)(x)&0x0000ff00) << 8) | \ - (((uint32_t)(x)&0x000000ff) << 24))) +#define bswap_32(x) \ + ((uint32_t)((((uint32_t)(x) & 0xff000000) >> 24) | \ + (((uint32_t)(x) & 0x00ff0000) >> 8) | \ + (((uint32_t)(x) & 0x0000ff00) << 8) | \ + (((uint32_t)(x) & 0x000000ff) << 24))) #endif /* !bswap_32 */ #ifndef bswap_64 -#define bswap_64(x) \ - ((uint64_t)((((uint64_t)(x)&0xff00000000000000ULL) >> 56) | \ - (((uint64_t)(x)&0x00ff000000000000ULL) >> 40) | \ - (((uint64_t)(x)&0x0000ff0000000000ULL) >> 24) | \ - (((uint64_t)(x)&0x000000ff00000000ULL) >> 8) | \ - (((uint64_t)(x)&0x00000000ff000000ULL) << 8) | \ - (((uint64_t)(x)&0x0000000000ff0000ULL) << 24) | \ - (((uint64_t)(x)&0x000000000000ff00ULL) << 40) | \ - (((uint64_t)(x)&0x00000000000000ffULL) << 56))) +#define bswap_64(x) \ + ((uint64_t)((((uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \ + (((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \ + (((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \ + (((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \ + (((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \ + (((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \ + (((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \ + (((uint64_t)(x) & 0x00000000000000ffULL) << 56))) #endif /* !bswap_64 */ #ifndef htobe16 diff --git a/lib/isc/include/isc/job.h b/lib/isc/include/isc/job.h index 9a44974c25..56a95e3d84 100644 --- a/lib/isc/include/isc/job.h +++ b/lib/isc/include/isc/job.h @@ -30,7 +30,7 @@ #include #include -typedef void (*isc_job_cb)(void *); +typedef void (*isc_job_cb)(void *); typedef struct isc_job isc_job_t; struct isc_job { diff --git a/lib/isc/include/isc/net.h b/lib/isc/include/isc/net.h index 320c5f682d..d24715624b 100644 --- a/lib/isc/include/isc/net.h +++ b/lib/isc/include/isc/net.h @@ -191,10 +191,10 @@ /*% Is IP address multicast? */ #define ISC_IPADDR_ISMULTICAST(i) \ - (((uint32_t)(i)&ISC__IPADDR(0xf0000000)) == ISC__IPADDR(0xe0000000)) + (((uint32_t)(i) & ISC__IPADDR(0xf0000000)) == ISC__IPADDR(0xe0000000)) #define ISC_IPADDR_ISEXPERIMENTAL(i) \ - (((uint32_t)(i)&ISC__IPADDR(0xf0000000)) == ISC__IPADDR(0xf0000000)) + (((uint32_t)(i) & ISC__IPADDR(0xf0000000)) == ISC__IPADDR(0xf0000000)) /*** *** Functions. diff --git a/lib/isc/include/isc/radix.h b/lib/isc/include/isc/radix.h index 9a91118090..b385e12f6b 100644 --- a/lib/isc/include/isc/radix.h +++ b/lib/isc/include/isc/radix.h @@ -192,7 +192,7 @@ isc_radix_process(isc_radix_tree_t *radix, isc_radix_processfunc_t func); */ #define RADIX_MAXBITS 128 -#define RADIX_NBIT(x) (0x80 >> ((x)&0x7f)) +#define RADIX_NBIT(x) (0x80 >> ((x) & 0x7f)) #define RADIX_NBYTE(x) ((x) >> 3) #define RADIX_WALK(Xhead, Xnode) \ diff --git a/lib/isc/include/isc/thread.h b/lib/isc/include/isc/thread.h index a24dfcdca5..b9bbaabdc3 100644 --- a/lib/isc/include/isc/thread.h +++ b/lib/isc/include/isc/thread.h @@ -33,7 +33,7 @@ ISC_LANG_BEGINDECLS typedef pthread_t isc_thread_t; -typedef void *(*isc_threadfunc_t)(void *); +typedef void *(*isc_threadfunc_t)(void *); /*% * like isc_thread_create(), but run the function on the current diff --git a/lib/isc/include/isc/work.h b/lib/isc/include/isc/work.h index df196e95ea..e456e90597 100644 --- a/lib/isc/include/isc/work.h +++ b/lib/isc/include/isc/work.h @@ -18,8 +18,8 @@ #include #include -typedef void (*isc_work_cb)(void *arg); -typedef void (*isc_after_work_cb)(void *arg); +typedef void (*isc_work_cb)(void *arg); +typedef void (*isc_after_work_cb)(void *arg); typedef struct isc_work isc_work_t; ISC_LANG_BEGINDECLS diff --git a/lib/isc/netaddr.c b/lib/isc/netaddr.c index 29d5e6834b..456c11bb91 100644 --- a/lib/isc/netaddr.c +++ b/lib/isc/netaddr.c @@ -423,7 +423,7 @@ isc_netaddr_issitelocal(const isc_netaddr_t *na) { } #define ISC_IPADDR_ISNETZERO(i) \ - (((uint32_t)(i)&ISC__IPADDR(0xff000000)) == ISC__IPADDR(0x00000000)) + (((uint32_t)(i) & ISC__IPADDR(0xff000000)) == ISC__IPADDR(0x00000000)) bool isc_netaddr_isnetzero(const isc_netaddr_t *na) { diff --git a/lib/isc/url.c b/lib/isc/url.c index cccb712be3..320a8638e4 100644 --- a/lib/isc/url.c +++ b/lib/isc/url.c @@ -44,7 +44,7 @@ #ifndef BIT_AT #define BIT_AT(a, i) \ (!!((unsigned int)(a)[(unsigned int)(i) >> 3] & \ - (1 << ((unsigned int)(i)&7)))) + (1 << ((unsigned int)(i) & 7)))) #endif #if HTTP_PARSER_STRICT @@ -201,7 +201,8 @@ typedef enum { #define IS_URL_CHAR(c) (BIT_AT(normal_url_char, (unsigned char)c)) #define IS_HOST_CHAR(c) (isalnum((unsigned char)c) || (c) == '.' || (c) == '-') #else -#define IS_URL_CHAR(c) (BIT_AT(normal_url_char, (unsigned char)c) || ((c)&0x80)) +#define IS_URL_CHAR(c) \ + (BIT_AT(normal_url_char, (unsigned char)c) || ((c) & 0x80)) #define IS_HOST_CHAR(c) \ (isalnum((unsigned char)c) || (c) == '.' || (c) == '-' || (c) == '_') #endif diff --git a/lib/isccfg/include/isccfg/cfg.h b/lib/isccfg/include/isccfg/cfg.h index f790cd4377..2f9c81b907 100644 --- a/lib/isccfg/include/isccfg/cfg.h +++ b/lib/isccfg/include/isccfg/cfg.h @@ -501,11 +501,11 @@ cfg_listelt_value(const cfg_listelt_t *elt); void cfg_print(const cfg_obj_t *obj, - void (*f)(void *closure, const char *text, int textlen), - void *closure); + void (*f)(void *closure, const char *text, int textlen), + void *closure); void cfg_printx(const cfg_obj_t *obj, unsigned int flags, - void (*f)(void *closure, const char *text, int textlen), + void (*f)(void *closure, const char *text, int textlen), void *closure); #define CFG_PRINTER_XKEY 0x1 /* '?' out shared keys. */ @@ -527,7 +527,7 @@ cfg_printx(const cfg_obj_t *obj, unsigned int flags, void cfg_print_grammar(const cfg_type_t *type, unsigned int flags, - void (*f)(void *closure, const char *text, int textlen), + void (*f)(void *closure, const char *text, int textlen), void *closure); /*%< * Print a summary of the grammar of the configuration type 'type'. diff --git a/lib/isccfg/include/isccfg/grammar.h b/lib/isccfg/include/isccfg/grammar.h index 7cbcf7f470..b93d38d139 100644 --- a/lib/isccfg/include/isccfg/grammar.h +++ b/lib/isccfg/include/isccfg/grammar.h @@ -87,9 +87,9 @@ typedef struct cfg_rep cfg_rep_t; typedef isc_result_t (*cfg_parsefunc_t)(cfg_parser_t *, const cfg_type_t *type, cfg_obj_t **); -typedef void (*cfg_printfunc_t)(cfg_printer_t *, const cfg_obj_t *); -typedef void (*cfg_docfunc_t)(cfg_printer_t *, const cfg_type_t *); -typedef void (*cfg_freefunc_t)(cfg_parser_t *, cfg_obj_t *); +typedef void (*cfg_printfunc_t)(cfg_printer_t *, const cfg_obj_t *); +typedef void (*cfg_docfunc_t)(cfg_printer_t *, const cfg_type_t *); +typedef void (*cfg_freefunc_t)(cfg_parser_t *, cfg_obj_t *); /* * Structure definitions @@ -101,7 +101,7 @@ typedef void (*cfg_freefunc_t)(cfg_parser_t *, cfg_obj_t *); * by calling the function 'f'. */ struct cfg_printer { - void (*f)(void *closure, const char *text, int textlen); + void (*f)(void *closure, const char *text, int textlen); void *closure; int indent; int flags; @@ -574,7 +574,7 @@ cfg_clause_validforzone(const char *name, unsigned int ztype); void cfg_print_zonegrammar(const unsigned int zonetype, unsigned int flags, - void (*f)(void *closure, const char *text, int textlen), + void (*f)(void *closure, const char *text, int textlen), void *closure); /*%< * Print a summary of the grammar of the zone type represented by diff --git a/lib/ns/include/ns/client.h b/lib/ns/include/ns/client.h index a6b91a9e8e..bd2053d113 100644 --- a/lib/ns/include/ns/client.h +++ b/lib/ns/include/ns/client.h @@ -80,7 +80,7 @@ *** Types ***/ -#define NS_CLIENT_TCP_BUFFER_SIZE 65535 +#define NS_CLIENT_TCP_BUFFER_SIZE 65535 // OQS updated from 4096 to 8192 #define NS_CLIENT_SEND_BUFFER_SIZE 8192 @@ -182,13 +182,13 @@ struct ns_client { uint16_t extflags; int16_t ednsversion; /* -1 noedns */ uint16_t additionaldepth; - void (*cleanup)(ns_client_t *); - ns_query_t query; - isc_time_t requesttime; - isc_stdtime_t now; - isc_time_t tnow; - dns_name_t signername; /*%< [T]SIG key name */ - dns_name_t *signer; /*%< NULL if not valid sig */ + void (*cleanup)(ns_client_t *); + ns_query_t query; + isc_time_t requesttime; + isc_stdtime_t now; + isc_time_t tnow; + dns_name_t signername; /*%< [T]SIG key name */ + dns_name_t *signer; /*%< NULL if not valid sig */ isc_sockaddr_t peeraddr; bool peeraddr_valid; diff --git a/lib/ns/query.c b/lib/ns/query.c index fdad387a87..ae71e3317c 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -202,7 +202,7 @@ client_trace(ns_client_t *client, int level, const char *message) { #define DNS_GETDB_IGNOREACL 0x08U #define DNS_GETDB_STALEFIRST 0X0CU -#define PENDINGOK(x) (((x)&DNS_DBFIND_PENDINGOK) != 0) +#define PENDINGOK(x) (((x) & DNS_DBFIND_PENDINGOK) != 0) #define SFCACHE_CDFLAG 0x1 diff --git a/tests/bench/siphash.c b/tests/bench/siphash.c index 292cd6d8e1..8c1238537b 100644 --- a/tests/bench/siphash.c +++ b/tests/bench/siphash.c @@ -23,7 +23,7 @@ #define SIZE (1024 * 1024) -#define KILOHASHES(count, us) ((us) == 0 ? 0.0 : ((count)*1000.0 / (us))) +#define KILOHASHES(count, us) ((us) == 0 ? 0.0 : ((count) * 1000.0 / (us))) int main(void) { diff --git a/tests/isc/doh_test.c b/tests/isc/doh_test.c index 91d2ed8e2d..2a05429ba8 100644 --- a/tests/isc/doh_test.c +++ b/tests/isc/doh_test.c @@ -744,7 +744,7 @@ doh_connect_thread(void *arg) { isc_loopmgr_shutdown(loopmgr); } -next : {} +next: {} } static void