projects/linux·commit 2efd7c0f

Merge git://github.com/herbertx/crypto

2efd7c0f · Linus Torvalds <[email protected]> · 2011-10-21 17:02:18 +03:00

* git://github.com/herbertx/crypto:
  crypto: ghash - Avoid null pointer dereference if no key is set
Commit
2efd7c0fdcbe041173e248ccc2d9c91df7f84ce5
Parents
62ddc004 · 7ed47b7d

Merge commit. Changes below are compared with the first parent: 62ddc004.

Changes

1 files changed · +6 −0

FileStatusAddDelContent
crypto/ghash-generic.cmodified+6−0View file

crypto/ghash-generic.c

View file
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c
index be44256..7835b8f 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);