summaryrefslogtreecommitdiff
path: root/crypto/ghash-generic.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-10-21 17:02:18 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-21 17:02:18 +0300
commit2efd7c0fdcbe041173e248ccc2d9c91df7f84ce5 (patch)
tree789d66e6e61f09a3fc81a02d4d7a3da77d4702d6 /crypto/ghash-generic.c
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
Diffstat (limited to 'crypto/ghash-generic.c')
-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,
struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
u8 *dst = dctx->buffer;
+ if (!ctx->gf128)
+ return -ENOKEY;
+
if (dctx->bytes) {
int n = min(srclen, dctx->bytes);
u8 *pos = dst + (GHASH_BLOCK_SIZE - dctx->bytes);
@@ -119,6 +122,9 @@ static int ghash_final(struct shash_desc *desc, u8 *dst)
struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
u8 *buf = dctx->buffer;
+ if (!ctx->gf128)
+ return -ENOKEY;
+
ghash_flush(ctx, dctx);
memcpy(dst, buf, GHASH_BLOCK_SIZE);