]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Correctly invalidate the sha2/hmac2 contexts. This was already done in practice...
authorMark Andrews <marka@isc.org>
Tue, 25 Oct 2011 03:11:17 +0000 (03:11 +0000)
committerMark Andrews <marka@isc.org>
Tue, 25 Oct 2011 03:11:17 +0000 (03:11 +0000)
lib/isc/hmacsha.c
lib/isc/sha2.c

index dfcd8bf5a9f07addf21861a9f07882e3d54adde4..92b745159869387a9727cbcf48cef48b5431e5f1 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: hmacsha.c,v 1.8 2007/08/27 03:27:53 marka Exp $ */
+/* $Id: hmacsha.c,v 1.8.298.1 2011/10/25 03:11:17 marka Exp $ */
 
 /*
  * This code implements the HMAC-SHA1, HMAC-SHA224, HMAC-SHA256, HMAC-SHA384
@@ -64,8 +64,7 @@ isc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key,
 void
 isc_hmacsha1_invalidate(isc_hmacsha1_t *ctx) {
        isc_sha1_invalidate(&ctx->sha1ctx);
-       memset(ctx->key, 0, sizeof(ctx->key));
-       memset(ctx, 0, sizeof(ctx));
+       memset(ctx, 0, sizeof(*ctx));
 }
 
 /*
@@ -145,8 +144,7 @@ isc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key,
 
 void
 isc_hmacsha224_invalidate(isc_hmacsha224_t *ctx) {
-       memset(ctx->key, 0, sizeof(ctx->key));
-       memset(ctx, 0, sizeof(ctx));
+       memset(ctx, 0, sizeof(*ctx));
 }
 
 /*
@@ -225,8 +223,7 @@ isc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key,
 
 void
 isc_hmacsha256_invalidate(isc_hmacsha256_t *ctx) {
-       memset(ctx->key, 0, sizeof(ctx->key));
-       memset(ctx, 0, sizeof(ctx));
+       memset(ctx, 0, sizeof(*ctx));
 }
 
 /*
@@ -305,8 +302,7 @@ isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key,
 
 void
 isc_hmacsha384_invalidate(isc_hmacsha384_t *ctx) {
-       memset(ctx->key, 0, sizeof(ctx->key));
-       memset(ctx, 0, sizeof(ctx));
+       memset(ctx, 0, sizeof(*ctx));
 }
 
 /*
@@ -385,8 +381,7 @@ isc_hmacsha512_init(isc_hmacsha512_t *ctx, const unsigned char *key,
 
 void
 isc_hmacsha512_invalidate(isc_hmacsha512_t *ctx) {
-       memset(ctx->key, 0, sizeof(ctx->key));
-       memset(ctx, 0, sizeof(ctx));
+       memset(ctx, 0, sizeof(*ctx));
 }
 
 /*
index 7220af89cdbd2ffbc7f524eaded72995dcf974fb..9b4343450b745c0caf44c2af64d851c9e5f3eb0f 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: sha2.c,v 1.13.332.6 2011/03/12 04:57:28 tbox Exp $ */
+/* $Id: sha2.c,v 1.13.332.7 2011/10/25 03:11:17 marka Exp $ */
 
 /*     $FreeBSD: src/sys/crypto/sha2/sha2.c,v 1.2.2.2 2002/03/05 08:36:47 ume Exp $    */
 /*     $KAME: sha2.c,v 1.8 2001/11/08 01:07:52 itojun Exp $    */
@@ -450,7 +450,7 @@ isc_sha224_end(isc_sha224_t *context, char buffer[]) {
                }
                *buffer = (char)0;
        } else {
-               memset(context, 0, sizeof(context));
+               memset(context, 0, sizeof(*context));
        }
        memset(digest, 0, ISC_SHA224_DIGESTLENGTH);
        return buffer;
@@ -788,7 +788,7 @@ isc_sha256_final(isc_uint8_t digest[], isc_sha256_t *context) {
        }
 
        /* Clean up state data: */
-       memset(context, 0, sizeof(context));
+       memset(context, 0, sizeof(*context));
        usedspace = 0;
        POST(usedspace);
 }
@@ -811,7 +811,7 @@ isc_sha256_end(isc_sha256_t *context, char buffer[]) {
                }
                *buffer = (char)0;
        } else {
-               memset(context, 0, sizeof(context));
+               memset(context, 0, sizeof(*context));
        }
        memset(digest, 0, ISC_SHA256_DIGESTLENGTH);
        return buffer;
@@ -1149,7 +1149,7 @@ void isc_sha512_final(isc_uint8_t digest[], isc_sha512_t *context) {
        }
 
        /* Zero out state data */
-       memset(context, 0, sizeof(context));
+       memset(context, 0, sizeof(*context));
 }
 
 char *
@@ -1170,7 +1170,7 @@ isc_sha512_end(isc_sha512_t *context, char buffer[]) {
                }
                *buffer = (char)0;
        } else {
-               memset(context, 0, sizeof(context));
+               memset(context, 0, sizeof(*context));
        }
        memset(digest, 0, ISC_SHA512_DIGESTLENGTH);
        return buffer;
@@ -1237,7 +1237,7 @@ isc_sha384_final(isc_uint8_t digest[], isc_sha384_t *context) {
        }
 
        /* Zero out state data */
-       memset(context, 0, sizeof(context));
+       memset(context, 0, sizeof(*context));
 }
 
 char *
@@ -1258,7 +1258,7 @@ isc_sha384_end(isc_sha384_t *context, char buffer[]) {
                }
                *buffer = (char)0;
        } else {
-               memset(context, 0, sizeof(context));
+               memset(context, 0, sizeof(*context));
        }
        memset(digest, 0, ISC_SHA384_DIGESTLENGTH);
        return buffer;