2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

apply the modified style

This commit is contained in:
Evan Hunt
2020-02-13 14:44:37 -08:00
parent 0255a97473
commit e851ed0bb5
669 changed files with 35995 additions and 42219 deletions

View File

@@ -47,73 +47,61 @@
#endif /* ifdef HAVE_FIPS_MODE */
#include "dst_parse.h"
#define ISC_MD_md5 ISC_MD_MD5
#define ISC_MD_sha1 ISC_MD_SHA1
#define ISC_MD_md5 ISC_MD_MD5
#define ISC_MD_sha1 ISC_MD_SHA1
#define ISC_MD_sha224 ISC_MD_SHA224
#define ISC_MD_sha256 ISC_MD_SHA256
#define ISC_MD_sha384 ISC_MD_SHA384
#define ISC_MD_sha512 ISC_MD_SHA512
#define hmac_register_algorithm(alg) \
static isc_result_t hmac##alg##_createctx(dst_key_t * key, \
dst_context_t *dctx) \
{ \
static isc_result_t hmac##alg##_createctx(dst_key_t *key, \
dst_context_t *dctx) { \
return (hmac_createctx(ISC_MD_##alg, key, dctx)); \
} \
static void hmac##alg##_destroyctx(dst_context_t *dctx) \
{ \
static void hmac##alg##_destroyctx(dst_context_t *dctx) { \
hmac_destroyctx(dctx); \
} \
static isc_result_t hmac##alg##_adddata(dst_context_t * dctx, \
const isc_region_t *data) \
{ \
static isc_result_t hmac##alg##_adddata(dst_context_t *dctx, \
const isc_region_t *data) { \
return (hmac_adddata(dctx, data)); \
} \
static isc_result_t hmac##alg##_sign(dst_context_t *dctx, \
isc_buffer_t * sig) \
{ \
isc_buffer_t *sig) { \
return (hmac_sign(dctx, sig)); \
} \
static isc_result_t hmac##alg##_verify(dst_context_t * dctx, \
const isc_region_t *sig) \
{ \
static isc_result_t hmac##alg##_verify(dst_context_t *dctx, \
const isc_region_t *sig) { \
return (hmac_verify(dctx, sig)); \
} \
static bool hmac##alg##_compare(const dst_key_t *key1, \
const dst_key_t *key2) \
{ \
const dst_key_t *key2) { \
return (hmac_compare(ISC_MD_##alg, key1, key2)); \
} \
static isc_result_t hmac##alg##_generate( \
dst_key_t *key, int pseudorandom_ok, void (*callback)(int)) \
{ \
dst_key_t *key, int pseudorandom_ok, void (*callback)(int)) { \
UNUSED(pseudorandom_ok); \
UNUSED(callback); \
return (hmac_generate(ISC_MD_##alg, key)); \
} \
static bool hmac##alg##_isprivate(const dst_key_t *key) \
{ \
static bool hmac##alg##_isprivate(const dst_key_t *key) { \
return (hmac_isprivate(key)); \
} \
static void hmac##alg##_destroy(dst_key_t *key) { hmac_destroy(key); } \
static isc_result_t hmac##alg##_todns(const dst_key_t *key, \
isc_buffer_t * data) \
{ \
isc_buffer_t *data) { \
return (hmac_todns(key, data)); \
} \
static isc_result_t hmac##alg##_fromdns(dst_key_t * key, \
isc_buffer_t *data) \
{ \
static isc_result_t hmac##alg##_fromdns(dst_key_t *key, \
isc_buffer_t *data) { \
return (hmac_fromdns(ISC_MD_##alg, key, data)); \
} \
static isc_result_t hmac##alg##_tofile(const dst_key_t *key, \
const char * directory) \
{ \
const char *directory) { \
return (hmac_tofile(ISC_MD_##alg, key, directory)); \
} \
static isc_result_t hmac##alg##_parse( \
dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) \
{ \
dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) { \
return (hmac_parse(ISC_MD_##alg, key, lexer, pub)); \
} \
static dst_func_t hmac##alg##_functions = { \
@@ -139,8 +127,7 @@
NULL, /*%< dump */ \
NULL, /*%< restore */ \
}; \
isc_result_t dst__hmac##alg##_init(dst_func_t **funcp) \
{ \
isc_result_t dst__hmac##alg##_init(dst_func_t **funcp) { \
REQUIRE(funcp != NULL); \
if (*funcp == NULL) { \
*funcp = &hmac##alg##_functions; \
@@ -148,16 +135,15 @@
return (ISC_R_SUCCESS); \
}
static isc_result_t
hmac_fromdns(isc_md_type_t type, dst_key_t *key, isc_buffer_t *data);
static isc_result_t hmac_fromdns(isc_md_type_t type, dst_key_t *key,
isc_buffer_t *data);
struct dst_hmac_key {
uint8_t key[ISC_MAX_BLOCK_SIZE];
};
static inline isc_result_t
getkeybits(dst_key_t *key, struct dst_private_element *element)
{
getkeybits(dst_key_t *key, struct dst_private_element *element) {
uint16_t *bits = (uint16_t *)element->data;
if (element->length != 2) {
@@ -170,9 +156,8 @@ getkeybits(dst_key_t *key, struct dst_private_element *element)
}
static inline isc_result_t
hmac_createctx(isc_md_type_t type, const dst_key_t *key, dst_context_t *dctx)
{
isc_result_t result;
hmac_createctx(isc_md_type_t type, const dst_key_t *key, dst_context_t *dctx) {
isc_result_t result;
const dst_hmac_key_t *hkey = key->keydata.hmac_key;
isc_hmac_t *ctx = isc_hmac_new(); /* Either returns or abort()s */
@@ -187,8 +172,7 @@ hmac_createctx(isc_md_type_t type, const dst_key_t *key, dst_context_t *dctx)
}
static inline void
hmac_destroyctx(dst_context_t *dctx)
{
hmac_destroyctx(dst_context_t *dctx) {
isc_hmac_t *ctx = dctx->ctxdata.hmac_ctx;
REQUIRE(ctx != NULL);
@@ -197,10 +181,9 @@ hmac_destroyctx(dst_context_t *dctx)
}
static inline isc_result_t
hmac_adddata(const dst_context_t *dctx, const isc_region_t *data)
{
hmac_adddata(const dst_context_t *dctx, const isc_region_t *data) {
isc_result_t result;
isc_hmac_t * ctx = dctx->ctxdata.hmac_ctx;
isc_hmac_t *ctx = dctx->ctxdata.hmac_ctx;
REQUIRE(ctx != NULL);
@@ -213,11 +196,10 @@ hmac_adddata(const dst_context_t *dctx, const isc_region_t *data)
}
static inline isc_result_t
hmac_sign(const dst_context_t *dctx, isc_buffer_t *sig)
{
hmac_sign(const dst_context_t *dctx, isc_buffer_t *sig) {
isc_hmac_t *ctx = dctx->ctxdata.hmac_ctx;
REQUIRE(ctx != NULL);
unsigned int digestlen;
unsigned int digestlen;
unsigned char digest[ISC_MAX_MD_SIZE];
if (isc_hmac_final(ctx, digest, &digestlen) != ISC_R_SUCCESS) {
@@ -238,10 +220,9 @@ hmac_sign(const dst_context_t *dctx, isc_buffer_t *sig)
}
static inline isc_result_t
hmac_verify(const dst_context_t *dctx, const isc_region_t *sig)
{
isc_hmac_t * ctx = dctx->ctxdata.hmac_ctx;
unsigned int digestlen;
hmac_verify(const dst_context_t *dctx, const isc_region_t *sig) {
isc_hmac_t *ctx = dctx->ctxdata.hmac_ctx;
unsigned int digestlen;
unsigned char digest[ISC_MAX_MD_SIZE];
REQUIRE(ctx != NULL);
@@ -264,8 +245,7 @@ hmac_verify(const dst_context_t *dctx, const isc_region_t *sig)
}
static inline bool
hmac_compare(isc_md_type_t type, const dst_key_t *key1, const dst_key_t *key2)
{
hmac_compare(isc_md_type_t type, const dst_key_t *key1, const dst_key_t *key2) {
dst_hmac_key_t *hkey1, *hkey2;
hkey1 = key1->keydata.hmac_key;
@@ -282,11 +262,10 @@ hmac_compare(isc_md_type_t type, const dst_key_t *key1, const dst_key_t *key2)
}
static inline isc_result_t
hmac_generate(isc_md_type_t type, dst_key_t *key)
{
isc_buffer_t b;
isc_result_t ret;
unsigned int bytes, len;
hmac_generate(isc_md_type_t type, dst_key_t *key) {
isc_buffer_t b;
isc_result_t ret;
unsigned int bytes, len;
unsigned char data[ISC_MAX_MD_SIZE] = { 0 };
len = isc_md_type_get_block_size(type);
@@ -311,15 +290,13 @@ hmac_generate(isc_md_type_t type, dst_key_t *key)
}
static inline bool
hmac_isprivate(const dst_key_t *key)
{
hmac_isprivate(const dst_key_t *key) {
UNUSED(key);
return (true);
}
static inline void
hmac_destroy(dst_key_t *key)
{
hmac_destroy(dst_key_t *key) {
dst_hmac_key_t *hkey = key->keydata.hmac_key;
isc_safe_memwipe(hkey, sizeof(*hkey));
isc_mem_put(key->mctx, hkey, sizeof(*hkey));
@@ -327,10 +304,9 @@ hmac_destroy(dst_key_t *key)
}
static inline isc_result_t
hmac_todns(const dst_key_t *key, isc_buffer_t *data)
{
hmac_todns(const dst_key_t *key, isc_buffer_t *data) {
dst_hmac_key_t *hkey = key->keydata.hmac_key;
unsigned int bytes;
unsigned int bytes;
REQUIRE(hkey != NULL);
@@ -344,11 +320,10 @@ hmac_todns(const dst_key_t *key, isc_buffer_t *data)
}
static inline isc_result_t
hmac_fromdns(isc_md_type_t type, dst_key_t *key, isc_buffer_t *data)
{
hmac_fromdns(isc_md_type_t type, dst_key_t *key, isc_buffer_t *data) {
dst_hmac_key_t *hkey;
unsigned int keylen;
isc_region_t r;
unsigned int keylen;
isc_region_t r;
isc_buffer_remainingregion(data, &r);
if (r.length == 0) {
@@ -380,8 +355,7 @@ hmac_fromdns(isc_md_type_t type, dst_key_t *key, isc_buffer_t *data)
}
static inline int
hmac__get_tag_key(isc_md_type_t type)
{
hmac__get_tag_key(isc_md_type_t type) {
if (type == ISC_MD_MD5) {
return (TAG_HMACMD5_KEY);
} else if (type == ISC_MD_SHA1) {
@@ -401,8 +375,7 @@ hmac__get_tag_key(isc_md_type_t type)
}
static inline int
hmac__get_tag_bits(isc_md_type_t type)
{
hmac__get_tag_bits(isc_md_type_t type) {
if (type == ISC_MD_MD5) {
return (TAG_HMACMD5_BITS);
} else if (type == ISC_MD_SHA1) {
@@ -422,12 +395,11 @@ hmac__get_tag_bits(isc_md_type_t type)
}
static inline isc_result_t
hmac_tofile(isc_md_type_t type, const dst_key_t *key, const char *directory)
{
hmac_tofile(isc_md_type_t type, const dst_key_t *key, const char *directory) {
dst_hmac_key_t *hkey;
dst_private_t priv;
int bytes = (key->key_size + 7) / 8;
uint16_t bits;
dst_private_t priv;
int bytes = (key->key_size + 7) / 8;
uint16_t bits;
if (key->keydata.hmac_key == NULL) {
return (DST_R_NULLKEY);
@@ -455,8 +427,7 @@ hmac_tofile(isc_md_type_t type, const dst_key_t *key, const char *directory)
}
static inline int
hmac__to_dst_alg(isc_md_type_t type)
{
hmac__to_dst_alg(isc_md_type_t type) {
if (type == ISC_MD_MD5) {
return (DST_ALG_HMACMD5);
} else if (type == ISC_MD_SHA1) {
@@ -476,13 +447,13 @@ hmac__to_dst_alg(isc_md_type_t type)
}
static inline isc_result_t
hmac_parse(isc_md_type_t type, dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub)
{
hmac_parse(isc_md_type_t type, dst_key_t *key, isc_lex_t *lexer,
dst_key_t *pub) {
dst_private_t priv;
isc_result_t result, tresult;
isc_buffer_t b;
isc_mem_t * mctx = key->mctx;
unsigned int i;
isc_result_t result, tresult;
isc_buffer_t b;
isc_mem_t *mctx = key->mctx;
unsigned int i;
UNUSED(pub);
/* read private key file */