Module Name:    src
Committed By:   ozaki-r
Date:           Thu Apr 13 01:24:34 UTC 2017

Modified Files:
        src/sys/opencrypto: cryptosoft.c

Log Message:
Fix usage of MD5Final/SHA1Final

Passing NULL as the digest parameter is wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/opencrypto/cryptosoft.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/opencrypto/cryptosoft.c
diff -u src/sys/opencrypto/cryptosoft.c:1.47 src/sys/opencrypto/cryptosoft.c:1.48
--- src/sys/opencrypto/cryptosoft.c:1.47	Thu Aug 20 14:40:19 2015
+++ src/sys/opencrypto/cryptosoft.c	Thu Apr 13 01:24:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptosoft.c,v 1.47 2015/08/20 14:40:19 christos Exp $ */
+/*	$NetBSD: cryptosoft.c,v 1.48 2017/04/13 01:24:34 ozaki-r Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptosoft.c,v 1.2.2.1 2002/11/21 23:34:23 sam Exp $	*/
 /*	$OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $	*/
 
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.47 2015/08/20 14:40:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.48 2017/04/13 01:24:34 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -948,7 +948,9 @@ swcr_newsession(void *arg, u_int32_t *si
 			axf = &swcr_auth_hash_key_md5;
 			goto auth2common;
 
-		case CRYPTO_SHA1_KPDK:
+		case CRYPTO_SHA1_KPDK: {
+			unsigned char digest[SHA1_DIGEST_LENGTH];
+			CTASSERT(SHA1_DIGEST_LENGTH >= MD5_DIGEST_LENGTH);
 			axf = &swcr_auth_hash_key_sha1;
 		auth2common:
 			(*swd)->sw_ictx = malloc(axf->ctxsize,
@@ -971,9 +973,10 @@ swcr_newsession(void *arg, u_int32_t *si
 			axf->Init((*swd)->sw_ictx);
 			axf->Update((*swd)->sw_ictx, cri->cri_key,
 			    cri->cri_klen / 8);
-			axf->Final(NULL, (*swd)->sw_ictx);
+			axf->Final(digest, (*swd)->sw_ictx);
 			(*swd)->sw_axf = axf;
 			break;
+		    }
 
 		case CRYPTO_MD5:
 			axf = &swcr_auth_hash_md5;

Reply via email to