Module Name: src Committed By: drochner Date: Sat May 21 13:22:45 UTC 2011
Modified Files: src/sys/opencrypto: cryptosoft_xform.c Log Message: check key size on initialization -- othwise the rijndael code can fail silently To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/opencrypto/cryptosoft_xform.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_xform.c diff -u src/sys/opencrypto/cryptosoft_xform.c:1.15 src/sys/opencrypto/cryptosoft_xform.c:1.16 --- src/sys/opencrypto/cryptosoft_xform.c:1.15 Thu May 5 17:44:39 2011 +++ src/sys/opencrypto/cryptosoft_xform.c Sat May 21 13:22:45 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cryptosoft_xform.c,v 1.15 2011/05/05 17:44:39 drochner Exp $ */ +/* $NetBSD: cryptosoft_xform.c,v 1.16 2011/05/21 13:22:45 drochner Exp $ */ /* $FreeBSD: src/sys/opencrypto/xform.c,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $ */ /* $OpenBSD: xform.c,v 1.19 2002/08/16 22:47:25 dhartmei Exp $ */ @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: cryptosoft_xform.c,v 1.15 2011/05/05 17:44:39 drochner Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cryptosoft_xform.c,v 1.16 2011/05/21 13:22:45 drochner Exp $"); #include <crypto/blowfish/blowfish.h> #include <crypto/cast128/cast128.h> @@ -66,7 +66,7 @@ const struct enc_xform *enc_xform; void (*encrypt)(void *, uint8_t *); void (*decrypt)(void *, uint8_t *); - int (*setkey)(uint8_t **, const uint8_t *, int len); + int (*setkey)(uint8_t **, const uint8_t *, int); void (*zerokey)(uint8_t **); }; @@ -555,6 +555,8 @@ { int err; + if (len != 16 && len != 24 && len != 32) + return EINVAL; *sched = malloc(sizeof(rijndael_ctx), M_CRYPTO_DATA, M_NOWAIT|M_ZERO); if (*sched != NULL) {