summaryrefslogtreecommitdiffstats
path: root/crypto/rsa-pkcs1pad.c
diff options
context:
space:
mode:
authorTadeusz Struk <tadeusz.struk@intel.com>2016-04-06 17:42:32 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2016-04-15 10:13:55 -0400
commit6f0904ada402a45b3a0a3b9b6507d91d3a9da67a (patch)
tree81481775bdc12aa649e9a0b805437618d9620756 /crypto/rsa-pkcs1pad.c
parent47cd30608f3fc3dbb4fdf37300baca911e2dde34 (diff)
crypto: rsa-pkcs1pad - fix dst len
The output buffer length has to be at least as big as the key_size. It is then updated to the actual output size by the implementation. Cc: <stable@vger.kernel.org> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/rsa-pkcs1pad.c')
-rw-r--r--crypto/rsa-pkcs1pad.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c
index 1cea67d43e1d..ead8dc0d084e 100644
--- a/crypto/rsa-pkcs1pad.c
+++ b/crypto/rsa-pkcs1pad.c
@@ -387,16 +387,16 @@ static int pkcs1pad_decrypt(struct akcipher_request *req)
387 req_ctx->child_req.src = req->src; 387 req_ctx->child_req.src = req->src;
388 req_ctx->child_req.src_len = req->src_len; 388 req_ctx->child_req.src_len = req->src_len;
389 req_ctx->child_req.dst = req_ctx->out_sg; 389 req_ctx->child_req.dst = req_ctx->out_sg;
390 req_ctx->child_req.dst_len = ctx->key_size - 1; 390 req_ctx->child_req.dst_len = ctx->key_size ;
391 391
392 req_ctx->out_buf = kmalloc(ctx->key_size - 1, 392 req_ctx->out_buf = kmalloc(ctx->key_size,
393 (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? 393 (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
394 GFP_KERNEL : GFP_ATOMIC); 394 GFP_KERNEL : GFP_ATOMIC);
395 if (!req_ctx->out_buf) 395 if (!req_ctx->out_buf)
396 return -ENOMEM; 396 return -ENOMEM;
397 397
398 pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf, 398 pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf,
399 ctx->key_size - 1, NULL); 399 ctx->key_size, NULL);
400 400
401 akcipher_request_set_tfm(&req_ctx->child_req, ctx->child); 401 akcipher_request_set_tfm(&req_ctx->child_req, ctx->child);
402 akcipher_request_set_callback(&req_ctx->child_req, req->base.flags, 402 akcipher_request_set_callback(&req_ctx->child_req, req->base.flags,
@@ -595,16 +595,16 @@ static int pkcs1pad_verify(struct akcipher_request *req)
595 req_ctx->child_req.src = req->src; 595 req_ctx->child_req.src = req->src;
596 req_ctx->child_req.src_len = req->src_len; 596 req_ctx->child_req.src_len = req->src_len;
597 req_ctx->child_req.dst = req_ctx->out_sg; 597 req_ctx->child_req.dst = req_ctx->out_sg;
598 req_ctx->child_req.dst_len = ctx->key_size - 1; 598 req_ctx->child_req.dst_len = ctx->key_size;
599 599
600 req_ctx->out_buf = kmalloc(ctx->key_size - 1, 600 req_ctx->out_buf = kmalloc(ctx->key_size,
601 (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? 601 (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
602 GFP_KERNEL : GFP_ATOMIC); 602 GFP_KERNEL : GFP_ATOMIC);
603 if (!req_ctx->out_buf) 603 if (!req_ctx->out_buf)
604 return -ENOMEM; 604 return -ENOMEM;
605 605
606 pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf, 606 pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf,
607 ctx->key_size - 1, NULL); 607 ctx->key_size, NULL);
608 608
609 akcipher_request_set_tfm(&req_ctx->child_req, ctx->child); 609 akcipher_request_set_tfm(&req_ctx->child_req, ctx->child);
610 akcipher_request_set_callback(&req_ctx->child_req, req->base.flags, 610 akcipher_request_set_callback(&req_ctx->child_req, req->base.flags,