Merge branch '4478-redefinition-of-hmac-as-different-kind-of-symbol-on-netbsd' into 'main'

Resolve "Redefinition of 'hmac' as different kind of symbol on NetBSD"

Closes #4478

See merge request isc-projects/bind9!8555
This commit is contained in:
Mark Andrews 2023-12-13 23:32:41 +00:00
commit 3389df6d89
9 changed files with 205 additions and 197 deletions

View file

@ -1,3 +1,6 @@
6299. [port] NetBSD has added 'hmac' to libc which collides with our
use of 'hmac'. [GL #4478]
6298. [bug] Fix dns_qp_lookup bugs related to the iterator.
[GL !8558]

View file

@ -2811,7 +2811,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
ptr = ptr2;
ptr2 = ptr3;
} else {
hmac = DST_ALG_HMACMD5;
hmac_alg = DST_ALG_HMACMD5;
digestbits = 0;
}
/* XXXONDREJ: FIXME */

View file

@ -138,7 +138,7 @@ char keyfile[MXNAME] = "";
char keysecret[MXNAME] = "";
unsigned char cookie_secret[33];
unsigned char cookie[8];
dst_algorithm_t hmac = DST_ALG_UNKNOWN;
dst_algorithm_t hmac_alg = DST_ALG_UNKNOWN;
unsigned int digestbits = 0;
isc_buffer_t *namebuf = NULL;
dns_tsigkey_t *tsigkey = NULL;
@ -879,7 +879,7 @@ setup_text_key(void) {
secretsize = isc_buffer_usedlength(&secretbuf);
if (hmac == DST_ALG_UNKNOWN) {
if (hmac_alg == DST_ALG_UNKNOWN) {
result = DST_R_UNSUPPORTEDALG;
goto failure;
}
@ -889,7 +889,7 @@ setup_text_key(void) {
goto failure;
}
result = dns_tsigkey_create(&keyname, hmac, secretstore,
result = dns_tsigkey_create(&keyname, hmac_alg, secretstore,
(int)secretsize, mctx, &tsigkey);
failure:
if (result != ISC_R_SUCCESS) {
@ -1041,35 +1041,35 @@ parse_hmac(const char *algname) {
digestbits = 0;
if (strcasecmp(buf, "hmac-md5") == 0) {
hmac = DST_ALG_HMACMD5;
hmac_alg = DST_ALG_HMACMD5;
} else if (strncasecmp(buf, "hmac-md5-", 9) == 0) {
hmac = DST_ALG_HMACMD5;
hmac_alg = DST_ALG_HMACMD5;
digestbits = parse_bits(&buf[9], "digest-bits [0..128]", 128);
} else if (strcasecmp(buf, "hmac-sha1") == 0) {
hmac = DST_ALG_HMACSHA1;
hmac_alg = DST_ALG_HMACSHA1;
digestbits = 0;
} else if (strncasecmp(buf, "hmac-sha1-", 10) == 0) {
hmac = DST_ALG_HMACSHA1;
hmac_alg = DST_ALG_HMACSHA1;
digestbits = parse_bits(&buf[10], "digest-bits [0..160]", 160);
} else if (strcasecmp(buf, "hmac-sha224") == 0) {
hmac = DST_ALG_HMACSHA224;
hmac_alg = DST_ALG_HMACSHA224;
} else if (strncasecmp(buf, "hmac-sha224-", 12) == 0) {
hmac = DST_ALG_HMACSHA224;
hmac_alg = DST_ALG_HMACSHA224;
digestbits = parse_bits(&buf[12], "digest-bits [0..224]", 224);
} else if (strcasecmp(buf, "hmac-sha256") == 0) {
hmac = DST_ALG_HMACSHA256;
hmac_alg = DST_ALG_HMACSHA256;
} else if (strncasecmp(buf, "hmac-sha256-", 12) == 0) {
hmac = DST_ALG_HMACSHA256;
hmac_alg = DST_ALG_HMACSHA256;
digestbits = parse_bits(&buf[12], "digest-bits [0..256]", 256);
} else if (strcasecmp(buf, "hmac-sha384") == 0) {
hmac = DST_ALG_HMACSHA384;
hmac_alg = DST_ALG_HMACSHA384;
} else if (strncasecmp(buf, "hmac-sha384-", 12) == 0) {
hmac = DST_ALG_HMACSHA384;
hmac_alg = DST_ALG_HMACSHA384;
digestbits = parse_bits(&buf[12], "digest-bits [0..384]", 384);
} else if (strcasecmp(buf, "hmac-sha512") == 0) {
hmac = DST_ALG_HMACSHA512;
hmac_alg = DST_ALG_HMACSHA512;
} else if (strncasecmp(buf, "hmac-sha512-", 12) == 0) {
hmac = DST_ALG_HMACSHA512;
hmac_alg = DST_ALG_HMACSHA512;
digestbits = parse_bits(&buf[12], "digest-bits [0..512]", 512);
} else {
fprintf(stderr,
@ -1175,7 +1175,7 @@ setup_file_key(void) {
case DST_ALG_HMACSHA256:
case DST_ALG_HMACSHA384:
case DST_ALG_HMACSHA512:
hmac = dst_key_alg(dstkey);
hmac_alg = dst_key_alg(dstkey);
break;
default:
dst_key_attach(dstkey, &sig0key);
@ -1184,9 +1184,9 @@ setup_file_key(void) {
}
if (dstkey != NULL) {
result = dns_tsigkey_createfromkey(dst_key_name(dstkey), hmac,
dstkey, false, false, NULL,
0, 0, mctx, &tsigkey);
result = dns_tsigkey_createfromkey(
dst_key_name(dstkey), hmac_alg, dstkey, false, false,
NULL, 0, 0, mctx, &tsigkey);
if (result != ISC_R_SUCCESS) {
printf(";; Couldn't create key %s: %s\n", keynametext,
isc_result_totext(result));

View file

@ -266,7 +266,7 @@ extern isc_sockaddr_t localaddr;
extern char keynametext[MXNAME];
extern char keyfile[MXNAME];
extern char keysecret[MXNAME];
extern dst_algorithm_t hmac;
extern dst_algorithm_t hmac_alg;
extern unsigned int digestbits;
extern dns_tsigkey_t *tsigkey;
extern bool validated;

View file

@ -379,13 +379,13 @@ reset_system(void) {
}
static bool
parse_hmac(const char *hmacstr, size_t len, dst_algorithm_t *hmac,
parse_hmac(const char *hmacstr, size_t len, dst_algorithm_t *hmac_alg,
uint16_t *digestbitsp) {
uint16_t digestbits = 0;
isc_result_t result;
char buf[20];
REQUIRE(hmac != NULL);
REQUIRE(hmac_alg != NULL);
REQUIRE(hmacstr != NULL);
if (len >= sizeof(buf)) {
@ -397,9 +397,9 @@ parse_hmac(const char *hmacstr, size_t len, dst_algorithm_t *hmac,
strlcpy(buf, hmacstr, ISC_MIN(len + 1, sizeof(buf)));
if (strcasecmp(buf, "hmac-md5") == 0) {
*hmac = DST_ALG_HMACMD5;
*hmac_alg = DST_ALG_HMACMD5;
} else if (strncasecmp(buf, "hmac-md5-", 9) == 0) {
*hmac = DST_ALG_HMACMD5;
*hmac_alg = DST_ALG_HMACMD5;
result = isc_parse_uint16(&digestbits, &buf[9], 10);
if (result != ISC_R_SUCCESS || digestbits > 128) {
error("digest-bits out of range [0..128]");
@ -407,9 +407,9 @@ parse_hmac(const char *hmacstr, size_t len, dst_algorithm_t *hmac,
}
*digestbitsp = (digestbits + 7) & ~0x7U;
} else if (strcasecmp(buf, "hmac-sha1") == 0) {
*hmac = DST_ALG_HMACSHA1;
*hmac_alg = DST_ALG_HMACSHA1;
} else if (strncasecmp(buf, "hmac-sha1-", 10) == 0) {
*hmac = DST_ALG_HMACSHA1;
*hmac_alg = DST_ALG_HMACSHA1;
result = isc_parse_uint16(&digestbits, &buf[10], 10);
if (result != ISC_R_SUCCESS || digestbits > 160) {
error("digest-bits out of range [0..160]");
@ -417,9 +417,9 @@ parse_hmac(const char *hmacstr, size_t len, dst_algorithm_t *hmac,
}
*digestbitsp = (digestbits + 7) & ~0x7U;
} else if (strcasecmp(buf, "hmac-sha224") == 0) {
*hmac = DST_ALG_HMACSHA224;
*hmac_alg = DST_ALG_HMACSHA224;
} else if (strncasecmp(buf, "hmac-sha224-", 12) == 0) {
*hmac = DST_ALG_HMACSHA224;
*hmac_alg = DST_ALG_HMACSHA224;
result = isc_parse_uint16(&digestbits, &buf[12], 10);
if (result != ISC_R_SUCCESS || digestbits > 224) {
error("digest-bits out of range [0..224]");
@ -427,9 +427,9 @@ parse_hmac(const char *hmacstr, size_t len, dst_algorithm_t *hmac,
}
*digestbitsp = (digestbits + 7) & ~0x7U;
} else if (strcasecmp(buf, "hmac-sha256") == 0) {
*hmac = DST_ALG_HMACSHA256;
*hmac_alg = DST_ALG_HMACSHA256;
} else if (strncasecmp(buf, "hmac-sha256-", 12) == 0) {
*hmac = DST_ALG_HMACSHA256;
*hmac_alg = DST_ALG_HMACSHA256;
result = isc_parse_uint16(&digestbits, &buf[12], 10);
if (result != ISC_R_SUCCESS || digestbits > 256) {
error("digest-bits out of range [0..256]");
@ -437,9 +437,9 @@ parse_hmac(const char *hmacstr, size_t len, dst_algorithm_t *hmac,
}
*digestbitsp = (digestbits + 7) & ~0x7U;
} else if (strcasecmp(buf, "hmac-sha384") == 0) {
*hmac = DST_ALG_HMACSHA384;
*hmac_alg = DST_ALG_HMACSHA384;
} else if (strncasecmp(buf, "hmac-sha384-", 12) == 0) {
*hmac = DST_ALG_HMACSHA384;
*hmac_alg = DST_ALG_HMACSHA384;
result = isc_parse_uint16(&digestbits, &buf[12], 10);
if (result != ISC_R_SUCCESS || digestbits > 384) {
error("digest-bits out of range [0..384]");
@ -447,9 +447,9 @@ parse_hmac(const char *hmacstr, size_t len, dst_algorithm_t *hmac,
}
*digestbitsp = (digestbits + 7) & ~0x7U;
} else if (strcasecmp(buf, "hmac-sha512") == 0) {
*hmac = DST_ALG_HMACSHA512;
*hmac_alg = DST_ALG_HMACSHA512;
} else if (strncasecmp(buf, "hmac-sha512-", 12) == 0) {
*hmac = DST_ALG_HMACSHA512;
*hmac_alg = DST_ALG_HMACSHA512;
result = isc_parse_uint16(&digestbits, &buf[12], 10);
if (result != ISC_R_SUCCESS || digestbits > 512) {
error("digest-bits out of range [0..512]");
@ -489,7 +489,7 @@ setup_keystr(void) {
dns_fixedname_t fkeyname;
dns_name_t *mykeyname = NULL;
char *name = NULL;
dst_algorithm_t hmac;
dst_algorithm_t hmac_alg;
uint16_t digestbits = 0;
mykeyname = dns_fixedname_initname(&fkeyname);
@ -508,11 +508,11 @@ setup_keystr(void) {
}
name = secretstr;
secretstr = n + 1;
if (!parse_hmac(keystr, s - keystr, &hmac, &digestbits)) {
if (!parse_hmac(keystr, s - keystr, &hmac_alg, &digestbits)) {
exit(1);
}
} else {
hmac = DST_ALG_HMACMD5;
hmac_alg = DST_ALG_HMACMD5;
name = keystr;
n = s;
}
@ -539,8 +539,8 @@ setup_keystr(void) {
secretlen = isc_buffer_usedlength(&secretbuf);
debug("keycreate");
result = dns_tsigkey_create(mykeyname, hmac, secret, secretlen, gmctx,
&tsigkey);
result = dns_tsigkey_create(mykeyname, hmac_alg, secret, secretlen,
gmctx, &tsigkey);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "could not create key from %s: %s\n", keystr,
isc_result_totext(result));
@ -623,7 +623,7 @@ static void
setup_keyfile(isc_mem_t *mctx, isc_log_t *lctx) {
dst_key_t *dstkey = NULL;
isc_result_t result;
dst_algorithm_t hmac = DST_ALG_UNKNOWN;
dst_algorithm_t hmac_alg = DST_ALG_UNKNOWN;
debug("Creating key...");
@ -659,7 +659,7 @@ setup_keyfile(isc_mem_t *mctx, isc_log_t *lctx) {
case DST_ALG_HMACSHA256:
case DST_ALG_HMACSHA384:
case DST_ALG_HMACSHA512:
hmac = dst_key_alg(dstkey);
hmac_alg = dst_key_alg(dstkey);
break;
default:
dst_key_attach(dstkey, &sig0key);
@ -667,9 +667,9 @@ setup_keyfile(isc_mem_t *mctx, isc_log_t *lctx) {
return;
}
result = dns_tsigkey_createfromkey(dst_key_name(dstkey), hmac, dstkey,
false, false, NULL, 0, 0, mctx,
&tsigkey);
result = dns_tsigkey_createfromkey(dst_key_name(dstkey), hmac_alg,
dstkey, false, false, NULL, 0, 0,
mctx, &tsigkey);
dst_key_free(&dstkey);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "could not create key from %s: %s\n", keyfile,
@ -1634,7 +1634,7 @@ evaluate_key(char *cmdline) {
int secretlen;
unsigned char *secret = NULL;
isc_buffer_t secretbuf;
dst_algorithm_t hmac = DST_ALG_UNKNOWN;
dst_algorithm_t hmac_alg = DST_ALG_UNKNOWN;
uint16_t digestbits = 0;
char *n;
@ -1648,12 +1648,12 @@ evaluate_key(char *cmdline) {
n = strchr(namestr, ':');
if (n != NULL) {
if (!parse_hmac(namestr, n - namestr, &hmac, &digestbits)) {
if (!parse_hmac(namestr, n - namestr, &hmac_alg, &digestbits)) {
return (STATUS_SYNTAX);
}
namestr = n + 1;
} else {
hmac = DST_ALG_HMACMD5;
hmac_alg = DST_ALG_HMACMD5;
}
isc_buffer_init(&b, namestr, strlen(namestr));
@ -1685,8 +1685,8 @@ evaluate_key(char *cmdline) {
if (tsigkey != NULL) {
dns_tsigkey_detach(&tsigkey);
}
result = dns_tsigkey_create(mykeyname, hmac, secret, secretlen, gmctx,
&tsigkey);
result = dns_tsigkey_create(mykeyname, hmac_alg, secret, secretlen,
gmctx, &tsigkey);
isc_mem_free(gmctx, secret);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "could not create key from %s %s: %s\n",

View file

@ -416,7 +416,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (setquerytsig) {
isc_buffer_t b;
unsigned char hmacname[] = HMACSHA256;
unsigned char hmac[32] = {
unsigned char hmacvalue[32] = {
0x22, 0x4d, 0x58, 0x07, 0x64, 0x8d, 0x14, 0x00,
0x9d, 0x8e, 0xfc, 0x1c, 0xd0, 0x49, 0x55, 0xe9,
0xcc, 0x90, 0x21, 0x87, 0x3b, 0x5f, 0xaf, 0x5c,
@ -434,7 +434,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
isc_buffer_putuint16(&b, 300); /* Fudge */
isc_buffer_putuint16(&b, 32); /* Mac Length */
/* Mac */
isc_buffer_putmem(&b, hmac, 32);
isc_buffer_putmem(&b, hmacvalue, 32);
isc_buffer_putuint16(&b, 7674); /* Original Id */
isc_buffer_putuint16(&b, 0); /* Error */
isc_buffer_putuint16(&b, 0); /* Other len */

View file

@ -27,26 +27,26 @@
isc_hmac_t *
isc_hmac_new(void) {
EVP_MD_CTX *hmac = EVP_MD_CTX_new();
RUNTIME_CHECK(hmac != NULL);
return ((isc_hmac_t *)hmac);
EVP_MD_CTX *hmac_st = EVP_MD_CTX_new();
RUNTIME_CHECK(hmac_st != NULL);
return ((isc_hmac_t *)hmac_st);
}
void
isc_hmac_free(isc_hmac_t *hmac) {
if (hmac == NULL) {
isc_hmac_free(isc_hmac_t *hmac_st) {
if (hmac_st == NULL) {
return;
}
EVP_MD_CTX_free((EVP_MD_CTX *)hmac);
EVP_MD_CTX_free((EVP_MD_CTX *)hmac_st);
}
isc_result_t
isc_hmac_init(isc_hmac_t *hmac, const void *key, const size_t keylen,
isc_hmac_init(isc_hmac_t *hmac_st, const void *key, const size_t keylen,
const isc_md_type_t *md_type) {
EVP_PKEY *pkey;
REQUIRE(hmac != NULL);
REQUIRE(hmac_st != NULL);
REQUIRE(key != NULL);
REQUIRE(keylen <= INT_MAX);
@ -60,7 +60,7 @@ isc_hmac_init(isc_hmac_t *hmac, const void *key, const size_t keylen,
return (ISC_R_CRYPTOFAILURE);
}
if (EVP_DigestSignInit(hmac, NULL, md_type, NULL, pkey) != 1) {
if (EVP_DigestSignInit(hmac_st, NULL, md_type, NULL, pkey) != 1) {
EVP_PKEY_free(pkey);
ERR_clear_error();
return (ISC_R_CRYPTOFAILURE);
@ -72,10 +72,10 @@ isc_hmac_init(isc_hmac_t *hmac, const void *key, const size_t keylen,
}
isc_result_t
isc_hmac_reset(isc_hmac_t *hmac) {
REQUIRE(hmac != NULL);
isc_hmac_reset(isc_hmac_t *hmac_st) {
REQUIRE(hmac_st != NULL);
if (EVP_MD_CTX_reset(hmac) != 1) {
if (EVP_MD_CTX_reset(hmac_st) != 1) {
ERR_clear_error();
return (ISC_R_CRYPTOFAILURE);
}
@ -84,14 +84,15 @@ isc_hmac_reset(isc_hmac_t *hmac) {
}
isc_result_t
isc_hmac_update(isc_hmac_t *hmac, const unsigned char *buf, const size_t len) {
REQUIRE(hmac != NULL);
isc_hmac_update(isc_hmac_t *hmac_st, const unsigned char *buf,
const size_t len) {
REQUIRE(hmac_st != NULL);
if (buf == NULL || len == 0) {
return (ISC_R_SUCCESS);
}
if (EVP_DigestSignUpdate(hmac, buf, len) != 1) {
if (EVP_DigestSignUpdate(hmac_st, buf, len) != 1) {
ERR_clear_error();
return (ISC_R_CRYPTOFAILURE);
}
@ -100,15 +101,15 @@ isc_hmac_update(isc_hmac_t *hmac, const unsigned char *buf, const size_t len) {
}
isc_result_t
isc_hmac_final(isc_hmac_t *hmac, unsigned char *digest,
isc_hmac_final(isc_hmac_t *hmac_st, unsigned char *digest,
unsigned int *digestlen) {
REQUIRE(hmac != NULL);
REQUIRE(hmac_st != NULL);
REQUIRE(digest != NULL);
REQUIRE(digestlen != NULL);
size_t len = *digestlen;
if (EVP_DigestSignFinal(hmac, digest, &len) != 1) {
if (EVP_DigestSignFinal(hmac_st, digest, &len) != 1) {
ERR_clear_error();
return (ISC_R_CRYPTOFAILURE);
}
@ -119,24 +120,24 @@ isc_hmac_final(isc_hmac_t *hmac, unsigned char *digest,
}
const isc_md_type_t *
isc_hmac_get_md_type(isc_hmac_t *hmac) {
REQUIRE(hmac != NULL);
isc_hmac_get_md_type(isc_hmac_t *hmac_st) {
REQUIRE(hmac_st != NULL);
return (EVP_MD_CTX_get0_md(hmac));
return (EVP_MD_CTX_get0_md(hmac_st));
}
size_t
isc_hmac_get_size(isc_hmac_t *hmac) {
REQUIRE(hmac != NULL);
isc_hmac_get_size(isc_hmac_t *hmac_st) {
REQUIRE(hmac_st != NULL);
return ((size_t)EVP_MD_CTX_size(hmac));
return ((size_t)EVP_MD_CTX_size(hmac_st));
}
int
isc_hmac_get_block_size(isc_hmac_t *hmac) {
REQUIRE(hmac != NULL);
isc_hmac_get_block_size(isc_hmac_t *hmac_st) {
REQUIRE(hmac_st != NULL);
return (EVP_MD_CTX_block_size(hmac));
return (EVP_MD_CTX_block_size(hmac_st));
}
isc_result_t
@ -144,24 +145,24 @@ isc_hmac(const isc_md_type_t *type, const void *key, const size_t keylen,
const unsigned char *buf, const size_t len, unsigned char *digest,
unsigned int *digestlen) {
isc_result_t res;
isc_hmac_t *hmac = isc_hmac_new();
isc_hmac_t *hmac_st = isc_hmac_new();
res = isc_hmac_init(hmac, key, keylen, type);
res = isc_hmac_init(hmac_st, key, keylen, type);
if (res != ISC_R_SUCCESS) {
goto end;
}
res = isc_hmac_update(hmac, buf, len);
res = isc_hmac_update(hmac_st, buf, len);
if (res != ISC_R_SUCCESS) {
goto end;
}
res = isc_hmac_final(hmac, digest, digestlen);
res = isc_hmac_final(hmac_st, digest, digestlen);
if (res != ISC_R_SUCCESS) {
goto end;
}
end:
isc_hmac_free(hmac);
isc_hmac_free(hmac_st);
return (res);
}

View file

@ -254,7 +254,7 @@ list_towire(isccc_sexpr_t *list, isc_buffer_t **buffer) {
}
static isc_result_t
sign(unsigned char *data, unsigned int length, unsigned char *hmac,
sign(unsigned char *data, unsigned int length, unsigned char *out,
uint32_t algorithm, isccc_region_t *secret) {
const isc_md_type_t *md_type;
isc_result_t result;
@ -303,9 +303,9 @@ sign(unsigned char *data, unsigned int length, unsigned char *hmac,
return (result);
}
if (algorithm == ISCCC_ALG_HMACMD5) {
PUT_MEM(digestb64, HMD5_LENGTH, hmac);
PUT_MEM(digestb64, HMD5_LENGTH, out);
} else {
PUT_MEM(digestb64, HSHA_LENGTH, hmac);
PUT_MEM(digestb64, HSHA_LENGTH, out);
}
return (ISC_R_SUCCESS);
}
@ -381,7 +381,7 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length,
isccc_region_t source;
isccc_region_t target;
isc_result_t result;
isccc_sexpr_t *_auth, *hmac;
isccc_sexpr_t *_auth, *hmacvalue;
unsigned char digest[ISC_MAX_MD_SIZE];
unsigned int digestlen = sizeof(digest);
unsigned char digestb64[HSHA_LENGTH * 4];
@ -394,11 +394,11 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length,
return (ISC_R_FAILURE);
}
if (algorithm == ISCCC_ALG_HMACMD5) {
hmac = isccc_alist_lookup(_auth, "hmd5");
hmacvalue = isccc_alist_lookup(_auth, "hmd5");
} else {
hmac = isccc_alist_lookup(_auth, "hsha");
hmacvalue = isccc_alist_lookup(_auth, "hsha");
}
if (!isccc_sexpr_binaryp(hmac)) {
if (!isccc_sexpr_binaryp(hmacvalue)) {
return (ISC_R_FAILURE);
}
/*
@ -451,7 +451,7 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length,
isccc_region_t *region;
unsigned char *value;
region = isccc_sexpr_tobinary(hmac);
region = isccc_sexpr_tobinary(hmacvalue);
if ((region->rend - region->rstart) != HMD5_LENGTH) {
return (ISCCC_R_BADAUTH);
}
@ -464,7 +464,7 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length,
unsigned char *value;
uint32_t valalg;
region = isccc_sexpr_tobinary(hmac);
region = isccc_sexpr_tobinary(hmacvalue);
/*
* Note: with non-MD5 algorithms, there's an extra octet

View file

@ -46,11 +46,11 @@
static int
_setup(void **state) {
isc_hmac_t *hmac = isc_hmac_new();
if (hmac == NULL) {
isc_hmac_t *hmac_st = isc_hmac_new();
if (hmac_st == NULL) {
return (-1);
}
*state = hmac;
*state = hmac_st;
return (0);
}
@ -77,31 +77,32 @@ _reset(void **state) {
ISC_RUN_TEST_IMPL(isc_hmac_new) {
UNUSED(state);
isc_hmac_t *hmac = isc_hmac_new();
assert_non_null(hmac);
isc_hmac_free(hmac); /* Cleanup */
isc_hmac_t *hmac_st = isc_hmac_new();
assert_non_null(hmac_st);
isc_hmac_free(hmac_st); /* Cleanup */
}
ISC_RUN_TEST_IMPL(isc_hmac_free) {
UNUSED(state);
isc_hmac_t *hmac = isc_hmac_new();
assert_non_null(hmac);
isc_hmac_free(hmac); /* Test freeing valid message digest context */
isc_hmac_free(NULL); /* Test freeing NULL argument */
isc_hmac_t *hmac_st = isc_hmac_new();
assert_non_null(hmac_st);
isc_hmac_free(hmac_st); /* Test freeing valid message digest context */
isc_hmac_free(NULL); /* Test freeing NULL argument */
}
static void
isc_hmac_test(isc_hmac_t *hmac, const void *key, size_t keylen,
isc_hmac_test(isc_hmac_t *hmac_st, const void *key, size_t keylen,
const isc_md_type_t *type, const char *buf, size_t buflen,
const char *result, const size_t repeats) {
isc_result_t res;
assert_non_null(hmac);
assert_int_equal(isc_hmac_init(hmac, key, keylen, type), ISC_R_SUCCESS);
assert_non_null(hmac_st);
assert_int_equal(isc_hmac_init(hmac_st, key, keylen, type),
ISC_R_SUCCESS);
for (size_t i = 0; i < repeats; i++) {
assert_int_equal(isc_hmac_update(hmac,
assert_int_equal(isc_hmac_update(hmac_st,
(const unsigned char *)buf,
buflen),
ISC_R_SUCCESS);
@ -109,7 +110,7 @@ isc_hmac_test(isc_hmac_t *hmac, const void *key, size_t keylen,
unsigned char digest[ISC_MAX_MD_SIZE];
unsigned int digestlen = sizeof(digest);
assert_int_equal(isc_hmac_final(hmac, digest, &digestlen),
assert_int_equal(isc_hmac_final(hmac_st, digest, &digestlen),
ISC_R_SUCCESS);
char hexdigest[ISC_MAX_MD_SIZE * 2 + 3];
@ -122,76 +123,79 @@ isc_hmac_test(isc_hmac_t *hmac, const void *key, size_t keylen,
assert_return_code(res, ISC_R_SUCCESS);
assert_memory_equal(hexdigest, result, (result ? strlen(result) : 0));
assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS);
}
ISC_RUN_TEST_IMPL(isc_hmac_init) {
isc_hmac_t *hmac = *state;
assert_non_null(hmac);
isc_hmac_t *hmac_st = *state;
assert_non_null(hmac_st);
assert_int_equal(isc_hmac_init(hmac, "", 0, NULL),
assert_int_equal(isc_hmac_init(hmac_st, "", 0, NULL),
ISC_R_NOTIMPLEMENTED);
if (!isc_fips_mode()) {
expect_assert_failure(isc_hmac_init(NULL, "", 0, ISC_MD_MD5));
expect_assert_failure(isc_hmac_init(hmac, NULL, 0, ISC_MD_MD5));
expect_assert_failure(
isc_hmac_init(hmac_st, NULL, 0, ISC_MD_MD5));
assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_MD5),
assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_MD5),
ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS);
}
assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA1),
assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA1),
ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA224),
assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA224),
ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA256),
assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA256),
ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA384),
assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA384),
ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA512),
assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA512),
ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS);
}
ISC_RUN_TEST_IMPL(isc_hmac_update) {
isc_hmac_t *hmac = *state;
assert_non_null(hmac);
isc_hmac_t *hmac_st = *state;
assert_non_null(hmac_st);
/* Uses message digest context initialized in isc_hmac_init_test() */
expect_assert_failure(isc_hmac_update(NULL, NULL, 0));
assert_int_equal(isc_hmac_update(hmac, NULL, 100), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_update(hmac, (const unsigned char *)"", 0),
assert_int_equal(isc_hmac_update(hmac_st, NULL, 100), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_update(hmac_st, (const unsigned char *)"", 0),
ISC_R_SUCCESS);
}
ISC_RUN_TEST_IMPL(isc_hmac_reset) {
isc_hmac_t *hmac = *state;
isc_hmac_t *hmac_st = *state;
#if 0
unsigned char digest[ISC_MAX_MD_SIZE] ISC_ATTR_UNUSED;
unsigned int digestlen ISC_ATTR_UNUSED;
#endif /* if 0 */
assert_non_null(hmac);
assert_non_null(hmac_st);
assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA512),
ISC_R_SUCCESS);
assert_int_equal(isc_hmac_update(hmac, (const unsigned char *)"a", 1),
ISC_R_SUCCESS);
assert_int_equal(isc_hmac_update(hmac, (const unsigned char *)"b", 1),
assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA512),
ISC_R_SUCCESS);
assert_int_equal(
isc_hmac_update(hmac_st, (const unsigned char *)"a", 1),
ISC_R_SUCCESS);
assert_int_equal(
isc_hmac_update(hmac_st, (const unsigned char *)"b", 1),
ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS);
assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS);
#if 0
/*
@ -199,13 +203,13 @@ ISC_RUN_TEST_IMPL(isc_hmac_reset) {
* so this could be only manually checked that the test will
* segfault when called by hand
*/
expect_assert_failure(isc_hmac_final(hmac, digest, &digestlen));
expect_assert_failure(isc_hmac_final(hmac_st, digest, &digestlen));
#endif /* if 0 */
}
ISC_RUN_TEST_IMPL(isc_hmac_final) {
isc_hmac_t *hmac = *state;
assert_non_null(hmac);
isc_hmac_t *hmac_st = *state;
assert_non_null(hmac_st);
unsigned char digest[ISC_MAX_MD_SIZE];
unsigned int digestlen = sizeof(digest);
@ -213,16 +217,16 @@ ISC_RUN_TEST_IMPL(isc_hmac_final) {
/* Fail when message digest context is empty */
expect_assert_failure(isc_hmac_final(NULL, digest, &digestlen));
/* Fail when output buffer is empty */
expect_assert_failure(isc_hmac_final(hmac, NULL, &digestlen));
expect_assert_failure(isc_hmac_final(hmac_st, NULL, &digestlen));
assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA512),
assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA512),
ISC_R_SUCCESS);
/* Fail when the digest length pointer is empty */
expect_assert_failure(isc_hmac_final(hmac, digest, NULL));
expect_assert_failure(isc_hmac_final(hmac_st, digest, NULL));
}
ISC_RUN_TEST_IMPL(isc_hmac_md5) {
isc_hmac_t *hmac = *state;
isc_hmac_t *hmac_st = *state;
if (isc_fips_mode()) {
skip();
@ -230,11 +234,11 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) {
}
/* Test 0 */
isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_MD5, TEST_INPUT(""),
isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_MD5, TEST_INPUT(""),
"74E6F7298A9C2D168935F58C001BAD88", 1);
/* Test 1 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
"\x0b\x0b\x0b\x0b\x0b\x0b"),
ISC_MD_MD5,
@ -242,14 +246,14 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) {
"9294727A3638BB1C13F48EF8158BFC9D", 1);
/* Test 2 */
isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_MD5,
isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_MD5,
TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79"
"\x61\x20\x77\x61\x6e\x74\x20\x66\x6f"
"\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"),
"750C783E6AB0B503EAA86E310A5DB738", 1);
/* Test 3 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa"),
ISC_MD_MD5,
@ -260,7 +264,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) {
"\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"),
"56BE34521D144C88DBB8C733F0E8B3F6", 1);
/* Test 4 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a"
"\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
"\x15\x16\x17\x18\x19"),
@ -273,7 +277,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) {
"697EAF0ACA3A3AEA3A75164746FFAA79", 1);
#if 0
/* Test 5 -- unimplemented optional functionality */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"),
ISC_MD_MD5,
@ -281,7 +285,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) {
"4C1A03424B55E07FE7F27BE1",
1);
/* Test 6 -- unimplemented optional functionality */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -301,7 +305,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) {
"AA4AE5E15272D00E95705637CE8A3B55ED402112",
1);
/* Test 7 -- unimplemented optional functionality */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -324,27 +328,27 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) {
}
ISC_RUN_TEST_IMPL(isc_hmac_sha1) {
isc_hmac_t *hmac = *state;
isc_hmac_t *hmac_st = *state;
/* Test 0 */
isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA1, TEST_INPUT(""),
isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA1, TEST_INPUT(""),
"FBDB1D1B18AA6C08324B7D64B71FB76370690E1D", 1);
/* Test 1 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"),
ISC_MD_SHA1,
TEST_INPUT("\x48\x69\x20\x54\x68\x65\x72\x65"),
"B617318655057264E28BC0B6FB378C8EF146BE00", 1);
/* Test 2 */
isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA1,
isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA1,
TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61"
"\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20"
"\x6e\x6f\x74\x68\x69\x6e\x67\x3f"),
"EFFCDF6AE5EB2FA2D27416D5F184DF9C259A7C79", 1);
/* Test 3 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"),
ISC_MD_SHA1,
@ -355,7 +359,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) {
"\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"),
"125D7342B9AC11CD91A39AF48AA17B4F63F175D3", 1);
/* Test 4 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a"
"\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
"\x15\x16\x17\x18\x19"),
@ -368,7 +372,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) {
"4C9007F4026250C6BC8414F9BF50C86C2D7235DA", 1);
#if 0
/* Test 5 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"),
ISC_MD_SHA1,
@ -377,7 +381,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) {
1);
#endif /* if 0 */
/* Test 6 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -391,7 +395,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) {
"Hash Key First"),
"AA4AE5E15272D00E95705637CE8A3B55ED402112", 1);
/* Test 7 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -407,16 +411,16 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) {
}
ISC_RUN_TEST_IMPL(isc_hmac_sha224) {
isc_hmac_t *hmac = *state;
isc_hmac_t *hmac_st = *state;
/* Test 0 */
isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA224, TEST_INPUT(""),
isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA224, TEST_INPUT(""),
"5CE14F72894662213E2748D2A6BA234B74263910CEDDE2F5"
"A9271524",
1);
/* Test 1 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"),
ISC_MD_SHA224,
@ -425,7 +429,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) {
"4F53684B22",
1);
/* Test 2 */
isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA224,
isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA224,
TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61"
"\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20"
"\x6e\x6f\x74\x68\x69\x6e\x67\x3f"),
@ -433,7 +437,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) {
"08FD05E44",
1);
/* Test 3 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"),
ISC_MD_SHA224,
@ -446,7 +450,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) {
"D1EC8333EA",
1);
/* Test 4 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a"
"\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
"\x15\x16\x17\x18\x19"),
@ -461,7 +465,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) {
1);
#if 0
/* Test 5 -- unimplemented optional functionality */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"),
ISC_MD_SHA224,
@ -470,7 +474,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) {
1);
#endif /* if 0 */
/* Test 6 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -492,7 +496,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) {
"273FA6870E",
1);
/* Test 7 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -530,16 +534,16 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) {
}
ISC_RUN_TEST_IMPL(isc_hmac_sha256) {
isc_hmac_t *hmac = *state;
isc_hmac_t *hmac_st = *state;
/* Test 0 */
isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA256, TEST_INPUT(""),
isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA256, TEST_INPUT(""),
"B613679A0814D9EC772F95D778C35FC5FF1697C493715653"
"C6C712144292C5AD",
1);
/* Test 1 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"),
ISC_MD_SHA256,
@ -548,7 +552,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) {
"A726E9376C2E32CFF7",
1);
/* Test 2 */
isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA256,
isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA256,
TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61"
"\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20"
"\x6e\x6f\x74\x68\x69\x6e\x67\x3f"),
@ -556,7 +560,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) {
"839DEC58B964EC3843",
1);
/* Test 3 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"),
ISC_MD_SHA256,
@ -569,7 +573,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) {
"22D9635514CED565FE",
1);
/* Test 4 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a"
"\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
"\x15\x16\x17\x18\x19"),
@ -584,7 +588,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) {
1);
#if 0
/* Test 5 -- unimplemented optional functionality */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"),
ISC_MD_SHA256,
@ -593,7 +597,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) {
1);
#endif /* if 0 */
/* Test 6 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -615,7 +619,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) {
"140546040F0EE37F54",
1);
/* Test 7 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -653,16 +657,16 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) {
}
ISC_RUN_TEST_IMPL(isc_hmac_sha384) {
isc_hmac_t *hmac = *state;
isc_hmac_t *hmac_st = *state;
/* Test 0 */
isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA384, TEST_INPUT(""),
isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA384, TEST_INPUT(""),
"6C1F2EE938FAD2E24BD91298474382CA218C75DB3D83E114"
"B3D4367776D14D3551289E75E8209CD4B792302840234ADC",
1);
/* Test 1 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"),
ISC_MD_SHA384,
@ -672,7 +676,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) {
"E8B2FA9CB6",
1);
/* Test 2 */
isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA384,
isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA384,
TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61"
"\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20"
"\x6e\x6f\x74\x68\x69\x6e\x67\x3f"),
@ -681,7 +685,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) {
"ECFAB21649",
1);
/* Test 3 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"),
ISC_MD_SHA384,
@ -695,7 +699,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) {
"E101A34F27",
1);
/* Test 4 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a"
"\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
"\x15\x16\x17\x18\x19"),
@ -711,7 +715,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) {
1);
#if 0
/* Test 5 -- unimplemented optional functionality */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"),
ISC_MD_SHA384,
@ -720,7 +724,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) {
1);
#endif /* if 0 */
/* Test 6 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -743,7 +747,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) {
"F163F44952",
1);
/* Test 7 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -782,17 +786,17 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) {
}
ISC_RUN_TEST_IMPL(isc_hmac_sha512) {
isc_hmac_t *hmac = *state;
isc_hmac_t *hmac_st = *state;
/* Test 0 */
isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA512, TEST_INPUT(""),
isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA512, TEST_INPUT(""),
"B936CEE86C9F87AA5D3C6F2E84CB5A4239A5FE50480A6EC6"
"6B70AB5B1F4AC6730C6C515421B327EC1D69402E53DFB49A"
"D7381EB067B338FD7B0CB22247225D47",
1);
/* Test 1 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"),
ISC_MD_SHA512,
@ -802,7 +806,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) {
"4EAEA3F4E4BE9D914EEB61F1702E696C203A126854",
1);
/* Test 2 */
isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA512,
isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA512,
TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61"
"\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20"
"\x6e\x6f\x74\x68\x69\x6e\x67\x3f"),
@ -811,7 +815,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) {
"65F8F0E6FDCAEAB1A34D4A6B4B636E070A38BCE737",
1);
/* Test 3 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"),
ISC_MD_SHA512,
@ -825,7 +829,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) {
"A47E67C807B946A337BEE8942674278859E13292FB",
1);
/* Test 4 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a"
"\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
"\x15\x16\x17\x18\x19"),
@ -841,7 +845,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) {
1);
#if 0
/* Test 5 -- unimplemented optional functionality */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"),
ISC_MD_SHA512,
@ -850,7 +854,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) {
1);
#endif /* if 0 */
/* Test 6 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
@ -873,7 +877,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) {
"215D6A1E5295E64F73F63F0AEC8B915A985D786598",
1);
/* Test 7 */
isc_hmac_test(hmac,
isc_hmac_test(hmac_st,
TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"