diff usr/src/common/crypto/fips/fips_sha2_util.c @ 10979:00cad6413daf

6897371 cryptoadm needs changes in order to support fips-140 mode in local zones 6897374 Memory leaking in kernel algorithm modules and softtoken dsa with fips enabled
author Hai-May Chao <Hai-May.Chao@Sun.COM>
date Thu, 05 Nov 2009 21:57:36 -0800
parents a10fbcfc2f21
children
line wrap: on
line diff
--- a/usr/src/common/crypto/fips/fips_sha2_util.c	Fri Nov 06 13:10:19 2009 +0800
+++ b/usr/src/common/crypto/fips/fips_sha2_util.c	Thu Nov 05 21:57:36 2009 -0800
@@ -121,13 +121,24 @@
 	ulong_t inlen, uchar_t *out)
 {
 
+	int rv;
+
 	if (in != NULL) {
 		SHA2Update((SHA2_CTX *)sha2_context, in, inlen);
 		SHA2Final(out, (SHA2_CTX *)sha2_context);
-		return (CKR_OK);
+		rv = CKR_OK;
 	} else {
-		return (CKR_ARGUMENTS_BAD);
+		rv = CKR_ARGUMENTS_BAD;
 	}
+
+	if (sha2_context)
+#ifdef _KERNEL
+		kmem_free(sha2_context, sizeof (SHA2_CTX));
+#else
+		free(sha2_context);
+#endif
+	return (rv);
+
 }
 
 #ifndef _KERNEL
@@ -376,6 +387,8 @@
 	}
 
 	SHA2Final(hmac_computed, &((sha2_hmac_ctx)->hc_ocontext));
+
+	kmem_free(sha2_hmac_ctx, sizeof (sha2_hmac_ctx_t));
 }
 
 #endif