Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-28 Thread David Gstir
Horia, > On 28 Jun 2017, at 10:32, Horia Geantă wrote: > >>> + sg_pcopy_to_buffer(req->dst, nents, req->info, ivsize, >>> + req->nbytes - ivsize); >> >> scatterwalk_map_and_copy() should be used instead. >> > David, IIUC this is the only change

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-28 Thread David Gstir
Horia, > On 28 Jun 2017, at 10:32, Horia Geantă wrote: > >>> + sg_pcopy_to_buffer(req->dst, nents, req->info, ivsize, >>> + req->nbytes - ivsize); >> >> scatterwalk_map_and_copy() should be used instead. >> > David, IIUC this is the only change needed in this patch

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-28 Thread Horia Geantă
On 6/19/2017 1:31 PM, Horia Geantă wrote: > On 6/2/2017 3:25 PM, David Gstir wrote: >> Certain cipher modes like CTS expect the IV (req->info) of >> ablkcipher_request (or equivalently req->iv of skcipher_request) to >> contain the last ciphertext block when the {en,de}crypt operation is done. >>

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-28 Thread Horia Geantă
On 6/19/2017 1:31 PM, Horia Geantă wrote: > On 6/2/2017 3:25 PM, David Gstir wrote: >> Certain cipher modes like CTS expect the IV (req->info) of >> ablkcipher_request (or equivalently req->iv of skcipher_request) to >> contain the last ciphertext block when the {en,de}crypt operation is done. >>

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-26 Thread Herbert Xu
On Mon, Jun 26, 2017 at 07:40:58AM +0200, David Gstir wrote: > > So, am I correct in assuming that it is required for all modes including AEAD > modes like GCM? > In that case I'll include a fix for the CAAM GCM mode too. It's only required for skcihper. As we do not do chunking/streaming with

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-26 Thread Herbert Xu
On Mon, Jun 26, 2017 at 07:40:58AM +0200, David Gstir wrote: > > So, am I correct in assuming that it is required for all modes including AEAD > modes like GCM? > In that case I'll include a fix for the CAAM GCM mode too. It's only required for skcihper. As we do not do chunking/streaming with

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-25 Thread David Gstir
Herbert, > On 20 Jun 2017, at 03:28, Herbert Xu wrote: > > On Mon, Jun 19, 2017 at 10:31:27AM +, Horia Geantă wrote: >> >> IIUC, IV update is required only in case of CBC. >> Since this callback is used also for CTR, we should avoid the copy: >> if

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-25 Thread David Gstir
Herbert, > On 20 Jun 2017, at 03:28, Herbert Xu wrote: > > On Mon, Jun 19, 2017 at 10:31:27AM +, Horia Geantă wrote: >> >> IIUC, IV update is required only in case of CBC. >> Since this callback is used also for CTR, we should avoid the copy: >> if ((ctx->cdata.algtype & OP_ALG_AAI_MASK)

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-19 Thread Herbert Xu
On Mon, Jun 19, 2017 at 10:31:27AM +, Horia Geantă wrote: > > IIUC, IV update is required only in case of CBC. > Since this callback is used also for CTR, we should avoid the copy: > if ((ctx->cdata.algtype & OP_ALG_AAI_MASK) == OP_ALG_AAI_CBC) ... No it is needed for CTR too. Cheers, --

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-19 Thread Herbert Xu
On Mon, Jun 19, 2017 at 10:31:27AM +, Horia Geantă wrote: > > IIUC, IV update is required only in case of CBC. > Since this callback is used also for CTR, we should avoid the copy: > if ((ctx->cdata.algtype & OP_ALG_AAI_MASK) == OP_ALG_AAI_CBC) ... No it is needed for CTR too. Cheers, --

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-19 Thread Horia Geantă
On 6/2/2017 3:25 PM, David Gstir wrote: > Certain cipher modes like CTS expect the IV (req->info) of > ablkcipher_request (or equivalently req->iv of skcipher_request) to > contain the last ciphertext block when the {en,de}crypt operation is done. > This is currently not the case for the CAAM

Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-19 Thread Horia Geantă
On 6/2/2017 3:25 PM, David Gstir wrote: > Certain cipher modes like CTS expect the IV (req->info) of > ablkcipher_request (or equivalently req->iv of skcipher_request) to > contain the last ciphertext block when the {en,de}crypt operation is done. > This is currently not the case for the CAAM

[RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-02 Thread David Gstir
Certain cipher modes like CTS expect the IV (req->info) of ablkcipher_request (or equivalently req->iv of skcipher_request) to contain the last ciphertext block when the {en,de}crypt operation is done. This is currently not the case for the CAAM driver which in turn breaks e.g. cts(cbc(aes)) when

[RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-02 Thread David Gstir
Certain cipher modes like CTS expect the IV (req->info) of ablkcipher_request (or equivalently req->iv of skcipher_request) to contain the last ciphertext block when the {en,de}crypt operation is done. This is currently not the case for the CAAM driver which in turn breaks e.g. cts(cbc(aes)) when