Skip to content

Commit

Permalink
ran OQS-bind through clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Martyrshot committed Oct 23, 2023
1 parent 1b3d8d2 commit 274bd21
Show file tree
Hide file tree
Showing 41 changed files with 300 additions and 277 deletions.
4 changes: 2 additions & 2 deletions bin/dnssec/dnssec-keygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,6 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv) {
}
}
dst_key_free(&key);

}
} while (conflict);

Expand Down Expand Up @@ -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 = {
Expand Down
9 changes: 6 additions & 3 deletions bin/dnssec/dnssec-signzone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions bin/named/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions lib/dns/adb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/dns/dnssec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/dns/dst_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
121 changes: 62 additions & 59 deletions lib/dns/dst_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
29 changes: 17 additions & 12 deletions lib/dns/dst_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
#include <isc/lang.h>

#include <dst/dst.h>
// 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

/*
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions lib/dns/include/dns/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/dns/include/dns/dbiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions lib/dns/include/dns/keytable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
*/
Expand Down
Loading

0 comments on commit 274bd21

Please sign in to comment.