aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/nx/nx.c
diff options
context:
space:
mode:
authorLeonidas Da Silva Barbosa <leosilva@linux.vnet.ibm.com>2015-04-23 16:41:43 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-04-26 02:33:19 -0400
commit10d87b730e1d9f1442cae6487bb3aef8632bed23 (patch)
tree4bffed8c0ee49a629ae7805334a2e56a52fec4c8 /drivers/crypto/nx/nx.c
parentc3365ce130e50176533debe1cabebcdb8e61156c (diff)
crypto: nx - Fixing SHA update bug
Bug happens when a data size less than SHA block size is passed. Since first attempt will be saved in buffer, second round attempt get into two step to calculate op.inlen and op.outlen. The issue resides in this step. A wrong value of op.inlen and outlen was being calculated. This patch fix this eliminate the nx_sha_build_sg_list, that is useless in SHA's algorithm context. Instead we call nx_build_sg_list directly and pass a previous calculated max_sg_len to it. Signed-off-by: Leonidas S. Barbosa <leosilva@linux.vnet.ibm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/nx/nx.c')
-rw-r--r--drivers/crypto/nx/nx.c47
1 files changed, 0 insertions, 47 deletions
diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c
index 4856f7287eae..2e2529ce8d31 100644
--- a/drivers/crypto/nx/nx.c
+++ b/drivers/crypto/nx/nx.c
@@ -252,53 +252,6 @@ static long int trim_sg_list(struct nx_sg *sg,
252} 252}
253 253
254/** 254/**
255 * nx_sha_build_sg_list - walk and build sg list to sha modes
256 * using right bounds and limits.
257 * @nx_ctx: NX crypto context for the lists we're building
258 * @nx_sg: current sg list in or out list
259 * @op_len: current op_len to be used in order to build a sg list
260 * @nbytes: number or bytes to be processed
261 * @offset: buf offset
262 * @mode: SHA256 or SHA512
263 */
264int nx_sha_build_sg_list(struct nx_crypto_ctx *nx_ctx,
265 struct nx_sg *nx_in_outsg,
266 s64 *op_len,
267 unsigned int *nbytes,
268 u8 *offset,
269 u32 mode)
270{
271 unsigned int delta = 0;
272 unsigned int total = *nbytes;
273 struct nx_sg *nx_insg = nx_in_outsg;
274 unsigned int max_sg_len;
275
276 max_sg_len = min_t(u64, nx_ctx->ap->sglen,
277 nx_driver.of.max_sg_len/sizeof(struct nx_sg));
278 max_sg_len = min_t(u64, max_sg_len,
279 nx_ctx->ap->databytelen/NX_PAGE_SIZE);
280
281 *nbytes = min_t(u64, *nbytes, nx_ctx->ap->databytelen);
282 nx_insg = nx_build_sg_list(nx_insg, offset, nbytes, max_sg_len);
283
284 switch (mode) {
285 case NX_DS_SHA256:
286 if (*nbytes < total)
287 delta = *nbytes - (*nbytes & ~(SHA256_BLOCK_SIZE - 1));
288 break;
289 case NX_DS_SHA512:
290 if (*nbytes < total)
291 delta = *nbytes - (*nbytes & ~(SHA512_BLOCK_SIZE - 1));
292 break;
293 default:
294 return -EINVAL;
295 }
296 *op_len = trim_sg_list(nx_in_outsg, nx_insg, delta);
297
298 return 0;
299}
300
301/**
302 * nx_build_sg_lists - walk the input scatterlists and build arrays of NX 255 * nx_build_sg_lists - walk the input scatterlists and build arrays of NX
303 * scatterlists based on them. 256 * scatterlists based on them.
304 * 257 *