aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-10-21 10:02:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-21 10:02:18 -0400
commit2efd7c0fdcbe041173e248ccc2d9c91df7f84ce5 (patch)
tree789d66e6e61f09a3fc81a02d4d7a3da77d4702d6
parent62ddc0046eae6b8e8374f0ac3b27b12a57baa2f6 (diff)
parent7ed47b7d142ec99ad6880bbbec51e9f12b3af74c (diff)
Merge git://github.com/herbertx/crypto
* git://github.com/herbertx/crypto: crypto: ghash - Avoid null pointer dereference if no key is set
-rw-r--r--crypto/ghash-generic.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c
index be4425616931..7835b8fc94db 100644
--- a/crypto/ghash-generic.c
+++ b/crypto/ghash-generic.c
@@ -67,6 +67,9 @@ static int ghash_update(struct shash_desc *desc,
67 struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm); 67 struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
68 u8 *dst = dctx->buffer; 68 u8 *dst = dctx->buffer;
69 69
70 if (!ctx->gf128)
71 return -ENOKEY;
72
70 if (dctx->bytes) { 73 if (dctx->bytes) {
71 int n = min(srclen, dctx->bytes); 74 int n = min(srclen, dctx->bytes);
72 u8 *pos = dst + (GHASH_BLOCK_SIZE - dctx->bytes); 75 u8 *pos = dst + (GHASH_BLOCK_SIZE - dctx->bytes);
@@ -119,6 +122,9 @@ static int ghash_final(struct shash_desc *desc, u8 *dst)
119 struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm); 122 struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
120 u8 *buf = dctx->buffer; 123 u8 *buf = dctx->buffer;
121 124
125 if (!ctx->gf128)
126 return -ENOKEY;
127
122 ghash_flush(ctx, dctx); 128 ghash_flush(ctx, dctx);
123 memcpy(dst, buf, GHASH_BLOCK_SIZE); 129 memcpy(dst, buf, GHASH_BLOCK_SIZE);
124 130