@@ -103,13 +103,14 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
struct af_alg_ctx *ctx = ask->private;
struct crypto_skcipher *tfm = pask->private;
unsigned int bs = crypto_skcipher_chunksize(tfm);
+ unsigned int ts = crypto_skcipher_tailsize(tfm);
struct af_alg_async_req *areq;
unsigned cflags = 0;
int err = 0;
size_t len = 0;
- if (!ctx->init || (ctx->more && ctx->used < bs)) {
- err = af_alg_wait_for_data(sk, flags, bs);
+ if (!ctx->init || (ctx->more && ctx->used < bs + ts)) {
+ err = af_alg_wait_for_data(sk, flags, bs + ts);
if (err)
return err;
}
@@ -130,6 +131,8 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
* full block size buffers.
*/
if (ctx->more || len < ctx->used) {
+ if (ctx->more && ctx->used - ts < len)
+ len = ctx->used - ts;
len -= len % bs;
cflags |= CRYPTO_SKCIPHER_REQ_NOTFINAL;
}
This patch makes use of the new tailsize attribute so that algorithms such as CTS can be supported properly when a request it too large to be processed in one go. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> --- crypto/algif_skcipher.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)