Skip to content

Commit

Permalink
Merge git://github.com/herbertx/crypto
Browse files Browse the repository at this point in the history
* git://github.com/herbertx/crypto:
  crypto: ghash - Avoid null pointer dereference if no key is set
  • Loading branch information
torvalds committed Oct 21, 2011
2 parents 62ddc00 + 7ed47b7 commit 2efd7c0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crypto/ghash-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 2efd7c0

Please sign in to comment.