mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
NetBSD has added 'hmac' to libc so rename our uses of hmac
(cherry picked from commit fd077c2661
)
This commit is contained in:
@@ -369,13 +369,13 @@ reset_system(void) {
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_hmac(const dns_name_t **hmac, const char *hmacstr, size_t len,
|
||||
parse_hmac(const dns_name_t **hmacp, const char *hmacstr, size_t len,
|
||||
uint16_t *digestbitsp) {
|
||||
uint16_t digestbits = 0;
|
||||
isc_result_t result;
|
||||
char buf[20];
|
||||
|
||||
REQUIRE(hmac != NULL && *hmac == NULL);
|
||||
REQUIRE(hmacp != NULL && *hmacp == NULL);
|
||||
REQUIRE(hmacstr != NULL);
|
||||
|
||||
if (len >= sizeof(buf)) {
|
||||
@@ -387,9 +387,9 @@ parse_hmac(const dns_name_t **hmac, const char *hmacstr, size_t len,
|
||||
strlcpy(buf, hmacstr, ISC_MIN(len + 1, sizeof(buf)));
|
||||
|
||||
if (strcasecmp(buf, "hmac-md5") == 0) {
|
||||
*hmac = DNS_TSIG_HMACMD5_NAME;
|
||||
*hmacp = DNS_TSIG_HMACMD5_NAME;
|
||||
} else if (strncasecmp(buf, "hmac-md5-", 9) == 0) {
|
||||
*hmac = DNS_TSIG_HMACMD5_NAME;
|
||||
*hmacp = DNS_TSIG_HMACMD5_NAME;
|
||||
result = isc_parse_uint16(&digestbits, &buf[9], 10);
|
||||
if (result != ISC_R_SUCCESS || digestbits > 128) {
|
||||
error("digest-bits out of range [0..128]");
|
||||
@@ -397,9 +397,9 @@ parse_hmac(const dns_name_t **hmac, const char *hmacstr, size_t len,
|
||||
}
|
||||
*digestbitsp = (digestbits + 7) & ~0x7U;
|
||||
} else if (strcasecmp(buf, "hmac-sha1") == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA1_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA1_NAME;
|
||||
} else if (strncasecmp(buf, "hmac-sha1-", 10) == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA1_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA1_NAME;
|
||||
result = isc_parse_uint16(&digestbits, &buf[10], 10);
|
||||
if (result != ISC_R_SUCCESS || digestbits > 160) {
|
||||
error("digest-bits out of range [0..160]");
|
||||
@@ -407,9 +407,9 @@ parse_hmac(const dns_name_t **hmac, const char *hmacstr, size_t len,
|
||||
}
|
||||
*digestbitsp = (digestbits + 7) & ~0x7U;
|
||||
} else if (strcasecmp(buf, "hmac-sha224") == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA224_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA224_NAME;
|
||||
} else if (strncasecmp(buf, "hmac-sha224-", 12) == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA224_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA224_NAME;
|
||||
result = isc_parse_uint16(&digestbits, &buf[12], 10);
|
||||
if (result != ISC_R_SUCCESS || digestbits > 224) {
|
||||
error("digest-bits out of range [0..224]");
|
||||
@@ -417,9 +417,9 @@ parse_hmac(const dns_name_t **hmac, const char *hmacstr, size_t len,
|
||||
}
|
||||
*digestbitsp = (digestbits + 7) & ~0x7U;
|
||||
} else if (strcasecmp(buf, "hmac-sha256") == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA256_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA256_NAME;
|
||||
} else if (strncasecmp(buf, "hmac-sha256-", 12) == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA256_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA256_NAME;
|
||||
result = isc_parse_uint16(&digestbits, &buf[12], 10);
|
||||
if (result != ISC_R_SUCCESS || digestbits > 256) {
|
||||
error("digest-bits out of range [0..256]");
|
||||
@@ -427,9 +427,9 @@ parse_hmac(const dns_name_t **hmac, const char *hmacstr, size_t len,
|
||||
}
|
||||
*digestbitsp = (digestbits + 7) & ~0x7U;
|
||||
} else if (strcasecmp(buf, "hmac-sha384") == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA384_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA384_NAME;
|
||||
} else if (strncasecmp(buf, "hmac-sha384-", 12) == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA384_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA384_NAME;
|
||||
result = isc_parse_uint16(&digestbits, &buf[12], 10);
|
||||
if (result != ISC_R_SUCCESS || digestbits > 384) {
|
||||
error("digest-bits out of range [0..384]");
|
||||
@@ -437,9 +437,9 @@ parse_hmac(const dns_name_t **hmac, const char *hmacstr, size_t len,
|
||||
}
|
||||
*digestbitsp = (digestbits + 7) & ~0x7U;
|
||||
} else if (strcasecmp(buf, "hmac-sha512") == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA512_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA512_NAME;
|
||||
} else if (strncasecmp(buf, "hmac-sha512-", 12) == 0) {
|
||||
*hmac = DNS_TSIG_HMACSHA512_NAME;
|
||||
*hmacp = DNS_TSIG_HMACSHA512_NAME;
|
||||
result = isc_parse_uint16(&digestbits, &buf[12], 10);
|
||||
if (result != ISC_R_SUCCESS || digestbits > 512) {
|
||||
error("digest-bits out of range [0..512]");
|
||||
|
@@ -478,7 +478,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,
|
||||
@@ -496,7 +496,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 */
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -255,7 +255,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;
|
||||
@@ -304,9 +304,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);
|
||||
}
|
||||
@@ -382,7 +382,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];
|
||||
@@ -395,11 +395,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);
|
||||
}
|
||||
/*
|
||||
@@ -452,7 +452,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);
|
||||
}
|
||||
@@ -465,7 +465,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
|
||||
|
@@ -45,11 +45,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);
|
||||
}
|
||||
|
||||
@@ -76,31 +76,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_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);
|
||||
@@ -108,7 +109,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];
|
||||
@@ -121,73 +122,76 @@ 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);
|
||||
|
||||
expect_assert_failure(isc_hmac_init(NULL, "", 0, ISC_MD_MD5));
|
||||
|
||||
assert_int_equal(isc_hmac_init(hmac, "", 0, NULL),
|
||||
assert_int_equal(isc_hmac_init(hmac_st, "", 0, NULL),
|
||||
ISC_R_NOTIMPLEMENTED);
|
||||
|
||||
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), ISC_R_SUCCESS);
|
||||
assert_int_equal(isc_hmac_reset(hmac), 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_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_SHA224),
|
||||
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_SHA256),
|
||||
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_SHA384),
|
||||
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_SHA512),
|
||||
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_st, "", 0, ISC_MD_SHA512),
|
||||
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] __attribute((unused));
|
||||
unsigned int digestlen __attribute((unused));
|
||||
#endif /* if 0 */
|
||||
|
||||
assert_non_null(hmac);
|
||||
assert_non_null(hmac_st);
|
||||
|
||||
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_update(hmac, (const unsigned char *)"a", 1),
|
||||
assert_int_equal(
|
||||
isc_hmac_update(hmac_st, (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_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
|
||||
/*
|
||||
@@ -195,13 +199,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);
|
||||
@@ -209,23 +213,23 @@ 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;
|
||||
|
||||
/* 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,
|
||||
@@ -233,14 +237,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,
|
||||
@@ -251,7 +255,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"),
|
||||
@@ -264,7 +268,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,
|
||||
@@ -272,7 +276,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"
|
||||
@@ -292,7 +296,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"
|
||||
@@ -315,27 +319,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,
|
||||
@@ -346,7 +350,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"),
|
||||
@@ -359,7 +363,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,
|
||||
@@ -368,7 +372,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"
|
||||
@@ -382,7 +386,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"
|
||||
@@ -398,16 +402,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,
|
||||
@@ -416,7 +420,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"),
|
||||
@@ -424,7 +428,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,
|
||||
@@ -437,7 +441,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"),
|
||||
@@ -452,7 +456,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,
|
||||
@@ -461,7 +465,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"
|
||||
@@ -483,7 +487,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"
|
||||
@@ -521,16 +525,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,
|
||||
@@ -539,7 +543,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"),
|
||||
@@ -547,7 +551,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,
|
||||
@@ -560,7 +564,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"),
|
||||
@@ -575,7 +579,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,
|
||||
@@ -584,7 +588,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"
|
||||
@@ -606,7 +610,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"
|
||||
@@ -644,16 +648,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,
|
||||
@@ -663,7 +667,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"),
|
||||
@@ -672,7 +676,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,
|
||||
@@ -686,7 +690,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"),
|
||||
@@ -702,7 +706,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,
|
||||
@@ -711,7 +715,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"
|
||||
@@ -734,7 +738,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"
|
||||
@@ -773,17 +777,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,
|
||||
@@ -793,7 +797,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"),
|
||||
@@ -802,7 +806,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,
|
||||
@@ -816,7 +820,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"),
|
||||
@@ -832,7 +836,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,
|
||||
@@ -841,7 +845,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"
|
||||
@@ -864,7 +868,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"
|
||||
|
Reference in New Issue
Block a user