2017-07-25 00:58:03

by Megha Dey

[permalink] [raw]
Subject: Re: FW: [PATCH V6 5/7] crypto: AES CBC multi-buffer glue code

On Tue, 2017-07-25 at 00:53 +0000, Dey, Megha wrote:
>
> -----Original Message-----
> From: Herbert Xu [mailto:[email protected]]
> Sent: Wednesday, July 19, 2017 12:02 AM
> To: Dey, Megha <[email protected]>
> Cc: Tim Chen <[email protected]>; [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH V6 5/7] crypto: AES CBC multi-buffer glue code
>
> On Tue, Jul 18, 2017 at 06:18:59PM -0700, Megha Dey wrote:
> >
> > > >> +/*
> > > >> + * CRYPTO_ALG_ASYNC flag is passed to indicate we have an ablk
> > > >> + * scatter-gather walk.
> > > >> + */
> > > >> +static struct skcipher_alg aes_cbc_mb_alg = {
> > > >> + .base = {
> > > >> + .cra_name = "cbc(aes)",
> > > >> + .cra_driver_name = "cbc-aes-aesni-mb",
> > > >> + .cra_priority = 500,
> > > >> + .cra_flags = CRYPTO_ALG_INTERNAL,
> > > >> + .cra_blocksize = AES_BLOCK_SIZE,
> > > >> + .cra_ctxsize = CRYPTO_AES_CTX_SIZE,
> > > >> + .cra_module = THIS_MODULE,
> > > >> + },
> > > >> + .min_keysize = AES_MIN_KEY_SIZE,
> > > >> + .max_keysize = AES_MAX_KEY_SIZE,
> > > >> + .ivsize = AES_BLOCK_SIZE,
> > > >> + .setkey = aes_set_key,
> > > >> + .encrypt = mb_aes_cbc_encrypt,
> > > >> + .decrypt = mb_aes_cbc_decrypt
> > > >> +};
> > > >
> > > > So this claims to be a sync algorithm. Is this really the case?
> >
> > yes, the inner algorithm is sync whereas the outer algorithm is async.
>
> Are you saying that once mb_aes_cbc_encrypt returns it will never touch the input/output again? This doesn't seem to agree with the actual code:
>
> + if (!ret_rctx) {
> + /* we submitted a job, but none completed */
> + /* just notify the caller */
> + notify_callback(rctx, cstate, -EINPROGRESS);
> + return 0;
> + }
>
> Just because an algorithm is internal doesn't mean that it can arbitrarily violate the crypto API requirements.
>
> Cheers,

Hi Herbert,

Under the skcipher interface, if both the outer and inner alg are async,
there should not be any problem right? Currently I do not see any
existing algorithms have both algorithms async.
> --
> Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


2017-07-25 02:17:51

by Herbert Xu

[permalink] [raw]
Subject: Re: FW: [PATCH V6 5/7] crypto: AES CBC multi-buffer glue code

On Mon, Jul 24, 2017 at 06:09:56PM -0700, Megha Dey wrote:
>
> Under the skcipher interface, if both the outer and inner alg are async,
> there should not be any problem right? Currently I do not see any
> existing algorithms have both algorithms async.

That's because the purpose of cryptd is to turn a sync algorithm
into an async one.

Your mcryptd is completely different. We already went through
this discussion for sha1-mb. This is no different. You should
choose the type that fits your circumstances.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2017-07-26 02:01:41

by Megha Dey

[permalink] [raw]
Subject: Re: FW: [PATCH V6 5/7] crypto: AES CBC multi-buffer glue code

On Tue, 2017-07-25 at 10:17 +0800, Herbert Xu wrote:
> On Mon, Jul 24, 2017 at 06:09:56PM -0700, Megha Dey wrote:
> >
> > Under the skcipher interface, if both the outer and inner alg are async,
> > there should not be any problem right? Currently I do not see any
> > existing algorithms have both algorithms async.
>
> That's because the purpose of cryptd is to turn a sync algorithm
> into an async one.
>
> Your mcryptd is completely different. We already went through
> this discussion for sha1-mb. This is no different. You should
> choose the type that fits your circumstances.

I have updated the inner algorithm to also be async in v7 patch series.
>
> Cheers,