summaryrefslogtreecommitdiff
path: root/lib/isc/hmacsha.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/isc/hmacsha.c')
-rw-r--r--lib/isc/hmacsha.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/isc/hmacsha.c b/lib/isc/hmacsha.c
index ac2b70c59f6c..1f72330d35ce 100644
--- a/lib/isc/hmacsha.c
+++ b/lib/isc/hmacsha.c
@@ -40,7 +40,12 @@ void
isc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha1()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha1());
+#endif
}
void
@@ -52,7 +57,11 @@ void
isc_hmacsha1_update(isc_hmacsha1_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -61,7 +70,11 @@ isc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA1_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
@@ -71,7 +84,12 @@ void
isc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha224()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha224());
+#endif
}
void
@@ -83,7 +101,11 @@ void
isc_hmacsha224_update(isc_hmacsha224_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -92,7 +114,11 @@ isc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA224_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
@@ -102,7 +128,12 @@ void
isc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha256()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha256());
+#endif
}
void
@@ -114,7 +145,11 @@ void
isc_hmacsha256_update(isc_hmacsha256_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -123,7 +158,11 @@ isc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA256_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
@@ -133,7 +172,12 @@ void
isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha384()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha384());
+#endif
}
void
@@ -145,7 +189,11 @@ void
isc_hmacsha384_update(isc_hmacsha384_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -154,7 +202,11 @@ isc_hmacsha384_sign(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA384_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
@@ -164,7 +216,12 @@ void
isc_hmacsha512_init(isc_hmacsha512_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha512()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha512());
+#endif
}
void
@@ -176,7 +233,11 @@ void
isc_hmacsha512_update(isc_hmacsha512_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -185,7 +246,11 @@ isc_hmacsha512_sign(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA512_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));