aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/nx/nx-sha512.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/crypto/nx/nx-sha512.c')
-rw-r--r--drivers/crypto/nx/nx-sha512.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/crypto/nx/nx-sha512.c b/drivers/crypto/nx/nx-sha512.c
index 3177b8c3d5f1..08eee1122349 100644
--- a/drivers/crypto/nx/nx-sha512.c
+++ b/drivers/crypto/nx/nx-sha512.c
@@ -69,7 +69,7 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
69 * 1: <= SHA512_BLOCK_SIZE: copy into state, return 0 69 * 1: <= SHA512_BLOCK_SIZE: copy into state, return 0
70 * 2: > SHA512_BLOCK_SIZE: process X blocks, copy in leftover 70 * 2: > SHA512_BLOCK_SIZE: process X blocks, copy in leftover
71 */ 71 */
72 if ((u64)len + sctx->count[0] <= SHA512_BLOCK_SIZE) { 72 if ((u64)len + sctx->count[0] < SHA512_BLOCK_SIZE) {
73 memcpy(sctx->buf + sctx->count[0], data, len); 73 memcpy(sctx->buf + sctx->count[0], data, len);
74 sctx->count[0] += len; 74 sctx->count[0] += len;
75 goto out; 75 goto out;
@@ -110,7 +110,8 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
110 atomic_inc(&(nx_ctx->stats->sha512_ops)); 110 atomic_inc(&(nx_ctx->stats->sha512_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[0] = leftover; 115 sctx->count[0] = leftover;
115 116
116 spbc_bits = csbcpb->cpb.sha512.spbc * 8; 117 spbc_bits = csbcpb->cpb.sha512.spbc * 8;
@@ -168,7 +169,7 @@ static int nx_sha512_final(struct shash_desc *desc, u8 *out)
168 goto out; 169 goto out;
169 170
170 atomic_inc(&(nx_ctx->stats->sha512_ops)); 171 atomic_inc(&(nx_ctx->stats->sha512_ops));
171 atomic64_add(csbcpb->cpb.sha512.message_bit_length_lo, 172 atomic64_add(csbcpb->cpb.sha512.message_bit_length_lo / 8,
172 &(nx_ctx->stats->sha512_bytes)); 173 &(nx_ctx->stats->sha512_bytes));
173 174
174 memcpy(out, csbcpb->cpb.sha512.message_digest, SHA512_DIGEST_SIZE); 175 memcpy(out, csbcpb->cpb.sha512.message_digest, SHA512_DIGEST_SIZE);