summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/lib/isc/hmacmd5.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/lib/isc/hmacmd5.c')
-rw-r--r--contrib/bind9/lib/isc/hmacmd5.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/contrib/bind9/lib/isc/hmacmd5.c b/contrib/bind9/lib/isc/hmacmd5.c
index 5166a98..f832146 100644
--- a/contrib/bind9/lib/isc/hmacmd5.c
+++ b/contrib/bind9/lib/isc/hmacmd5.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000, 2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -15,11 +15,11 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: hmacmd5.c,v 1.5.12.5 2006/02/26 23:49:48 marka Exp $ */
+/* $Id: hmacmd5.c,v 1.7.18.5 2006/02/26 22:30:56 marka Exp $ */
-/*
+/*! \file
* This code implements the HMAC-MD5 keyed hash algorithm
- * described in RFC 2104.
+ * described in RFC2104.
*/
#include "config.h"
@@ -35,7 +35,7 @@
#define IPAD 0x36
#define OPAD 0x5C
-/*
+/*!
* Start HMAC-MD5 process. Initialize an md5 context and digest the key.
*/
void
@@ -67,7 +67,7 @@ isc_hmacmd5_invalidate(isc_hmacmd5_t *ctx) {
memset(ctx->key, 0, sizeof(ctx->key));
}
-/*
+/*!
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
@@ -78,7 +78,7 @@ isc_hmacmd5_update(isc_hmacmd5_t *ctx, const unsigned char *buf,
isc_md5_update(&ctx->md5ctx, buf, len);
}
-/*
+/*!
* Compute signature - finalize MD5 operation and reapply MD5.
*/
void
@@ -99,14 +99,20 @@ isc_hmacmd5_sign(isc_hmacmd5_t *ctx, unsigned char *digest) {
isc_hmacmd5_invalidate(ctx);
}
-/*
+/*!
* Verify signature - finalize MD5 operation and reapply MD5, then
* compare to the supplied digest.
*/
isc_boolean_t
isc_hmacmd5_verify(isc_hmacmd5_t *ctx, unsigned char *digest) {
+ return (isc_hmacmd5_verify2(ctx, digest, ISC_MD5_DIGESTLENGTH));
+}
+
+isc_boolean_t
+isc_hmacmd5_verify2(isc_hmacmd5_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_MD5_DIGESTLENGTH];
+ REQUIRE(len <= ISC_MD5_DIGESTLENGTH);
isc_hmacmd5_sign(ctx, newdigest);
- return (ISC_TF(memcmp(digest, newdigest, ISC_MD5_DIGESTLENGTH) == 0));
+ return (ISC_TF(memcmp(digest, newdigest, len) == 0));
}
OpenPOWER on IntegriCloud