diff options
author | Kent Yoder <key@linux.vnet.ibm.com> | 2013-04-12 13:13:59 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-05-24 04:11:10 -0400 |
commit | 1ad936e850a896bc16e0d72a56be432f9954ad7e (patch) | |
tree | d0108b0f99c61e6779eadbaebf29ed5b6be2e485 /drivers/crypto/nx/nx-sha256.c | |
parent | 519fe2ecb755b875d9814cdda19778c2e88c6901 (diff) |
drivers/crypto/nx: Fixes for multiple races and issues
Fixes a race on driver init with registering algorithms where the
driver status flag wasn't being set before self testing started.
Added the cra_alignmask field for CBC and ECB modes.
Fixed a bug in GCM where AES block size was being used instead of
authsize.
Removed use of blkcipher_walk routines for scatterlist processing.
Corner cases in the code prevent us from processing an entire
scatterlist at a time and walking the buffers in block sized chunks
turns out to be unecessary anyway.
Fixed off-by-one error in saving off extra data in the sha code.
Fixed accounting error for number of bytes processed in the sha code.
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/crypto/nx/nx-sha256.c')
-rw-r--r-- | drivers/crypto/nx/nx-sha256.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/crypto/nx/nx-sha256.c b/drivers/crypto/nx/nx-sha256.c index 9767315f8c0b..67024f2f0b78 100644 --- a/drivers/crypto/nx/nx-sha256.c +++ b/drivers/crypto/nx/nx-sha256.c | |||
@@ -69,7 +69,7 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data, | |||
69 | * 1: <= SHA256_BLOCK_SIZE: copy into state, return 0 | 69 | * 1: <= SHA256_BLOCK_SIZE: copy into state, return 0 |
70 | * 2: > SHA256_BLOCK_SIZE: process X blocks, copy in leftover | 70 | * 2: > SHA256_BLOCK_SIZE: process X blocks, copy in leftover |
71 | */ | 71 | */ |
72 | if (len + sctx->count <= SHA256_BLOCK_SIZE) { | 72 | if (len + sctx->count < SHA256_BLOCK_SIZE) { |
73 | memcpy(sctx->buf + sctx->count, data, len); | 73 | memcpy(sctx->buf + sctx->count, data, len); |
74 | sctx->count += len; | 74 | sctx->count += len; |
75 | goto out; | 75 | goto out; |
@@ -110,7 +110,8 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data, | |||
110 | atomic_inc(&(nx_ctx->stats->sha256_ops)); | 110 | atomic_inc(&(nx_ctx->stats->sha256_ops)); |
111 | 111 | ||
112 | /* copy the leftover back into the state struct */ | 112 | /* copy the leftover back into the state struct */ |
113 | memcpy(sctx->buf, data + len - leftover, leftover); | 113 | if (leftover) |
114 | memcpy(sctx->buf, data + len - leftover, leftover); | ||
114 | sctx->count = leftover; | 115 | sctx->count = leftover; |
115 | 116 | ||
116 | csbcpb->cpb.sha256.message_bit_length += (u64) | 117 | csbcpb->cpb.sha256.message_bit_length += (u64) |
@@ -130,6 +131,7 @@ static int nx_sha256_final(struct shash_desc *desc, u8 *out) | |||
130 | struct nx_sg *in_sg, *out_sg; | 131 | struct nx_sg *in_sg, *out_sg; |
131 | int rc; | 132 | int rc; |
132 | 133 | ||
134 | |||
133 | if (NX_CPB_FDM(csbcpb) & NX_FDM_CONTINUATION) { | 135 | if (NX_CPB_FDM(csbcpb) & NX_FDM_CONTINUATION) { |
134 | /* we've hit the nx chip previously, now we're finalizing, | 136 | /* we've hit the nx chip previously, now we're finalizing, |
135 | * so copy over the partial digest */ | 137 | * so copy over the partial digest */ |
@@ -162,7 +164,7 @@ static int nx_sha256_final(struct shash_desc *desc, u8 *out) | |||
162 | 164 | ||
163 | atomic_inc(&(nx_ctx->stats->sha256_ops)); | 165 | atomic_inc(&(nx_ctx->stats->sha256_ops)); |
164 | 166 | ||
165 | atomic64_add(csbcpb->cpb.sha256.message_bit_length, | 167 | atomic64_add(csbcpb->cpb.sha256.message_bit_length / 8, |
166 | &(nx_ctx->stats->sha256_bytes)); | 168 | &(nx_ctx->stats->sha256_bytes)); |
167 | memcpy(out, csbcpb->cpb.sha256.message_digest, SHA256_DIGEST_SIZE); | 169 | memcpy(out, csbcpb->cpb.sha256.message_digest, SHA256_DIGEST_SIZE); |
168 | out: | 170 | out: |