2019-11-08 08:52:17

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCHv2] crypto: inside-secure - Fixed authenc w/ (3)DES fails on Macchiatobin

On Fri, 8 Nov 2019 at 09:50, Pascal van Leeuwen <[email protected]> wrote:
>
> Fixes: 13a1bb93f7b1c9 ("crypto: inside-secure - Fixed warnings on
> inconsistent byte order handling")
>

Please put the fixes tag with the tags (S-o-b etc)

> Fixed 2 copy-paste mistakes in the abovementioned commit that caused
> authenc w/ (3)DES to consistently fail on Macchiatobin (but strangely
> work fine on x86+FPGA??).
> Now fully tested on both platforms.
>
> changes since v1:
> - added Fixes: tag
>

Please put your changelog below the ---

> Signed-off-by: Pascal van Leeuwen <[email protected]>
> ---
> drivers/crypto/inside-secure/safexcel_cipher.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c
> index 98f9fc6..c029956 100644
> --- a/drivers/crypto/inside-secure/safexcel_cipher.c
> +++ b/drivers/crypto/inside-secure/safexcel_cipher.c
> @@ -405,7 +405,8 @@ static int safexcel_aead_setkey(struct crypto_aead *ctfm, const u8 *key,
>
> if (priv->flags & EIP197_TRC_CACHE && ctx->base.ctxr_dma) {
> for (i = 0; i < keys.enckeylen / sizeof(u32); i++) {
> - if (le32_to_cpu(ctx->key[i]) != aes.key_enc[i]) {
> + if (le32_to_cpu(ctx->key[i]) !=
> + ((u32 *)keys.enckey)[i]) {
> ctx->base.needs_inv = true;
> break;
> }
> @@ -459,7 +460,7 @@ static int safexcel_aead_setkey(struct crypto_aead *ctfm, const u8 *key,
>
> /* Now copy the keys into the context */
> for (i = 0; i < keys.enckeylen / sizeof(u32); i++)
> - ctx->key[i] = cpu_to_le32(aes.key_enc[i]);
> + ctx->key[i] = cpu_to_le32(((u32 *)keys.enckey)[i]);
> ctx->key_len = keys.enckeylen;
>
> memcpy(ctx->ipad, &istate.state, ctx->state_sz);
> --
> 1.8.3.1
>


2019-11-08 08:53:55

by Pascal Van Leeuwen

[permalink] [raw]
Subject: RE: [PATCHv2] crypto: inside-secure - Fixed authenc w/ (3)DES fails on Macchiatobin

> -----Original Message-----
> From: Ard Biesheuvel <[email protected]>
> Sent: Friday, November 8, 2019 9:52 AM
> To: Pascal van Leeuwen <[email protected]>
> Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE <[email protected]>;
> Antoine Tenart <[email protected]>; Herbert Xu <[email protected]>;
> David S. Miller <[email protected]>; Pascal Van Leeuwen <[email protected]>
> Subject: Re: [PATCHv2] crypto: inside-secure - Fixed authenc w/ (3)DES fails on
> Macchiatobin
>
> On Fri, 8 Nov 2019 at 09:50, Pascal van Leeuwen <[email protected]> wrote:
> >
> > Fixes: 13a1bb93f7b1c9 ("crypto: inside-secure - Fixed warnings on
> > inconsistent byte order handling")
> >
>
> Please put the fixes tag with the tags (S-o-b etc)
>
That's why I asked - I did not manage to extract that requirement from
the documentation I could find ...
(https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html)

I will move it then.

> > Fixed 2 copy-paste mistakes in the abovementioned commit that caused
> > authenc w/ (3)DES to consistently fail on Macchiatobin (but strangely
> > work fine on x86+FPGA??).
> > Now fully tested on both platforms.
> >
> > changes since v1:
> > - added Fixes: tag
> >
>
> Please put your changelog below the ---
>
> > Signed-off-by: Pascal van Leeuwen <[email protected]>
> > ---
> > drivers/crypto/inside-secure/safexcel_cipher.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-
> secure/safexcel_cipher.c
> > index 98f9fc6..c029956 100644
> > --- a/drivers/crypto/inside-secure/safexcel_cipher.c
> > +++ b/drivers/crypto/inside-secure/safexcel_cipher.c
> > @@ -405,7 +405,8 @@ static int safexcel_aead_setkey(struct crypto_aead *ctfm, const u8
> *key,
> >
> > if (priv->flags & EIP197_TRC_CACHE && ctx->base.ctxr_dma) {
> > for (i = 0; i < keys.enckeylen / sizeof(u32); i++) {
> > - if (le32_to_cpu(ctx->key[i]) != aes.key_enc[i]) {
> > + if (le32_to_cpu(ctx->key[i]) !=
> > + ((u32 *)keys.enckey)[i]) {
> > ctx->base.needs_inv = true;
> > break;
> > }
> > @@ -459,7 +460,7 @@ static int safexcel_aead_setkey(struct crypto_aead *ctfm, const u8
> *key,
> >
> > /* Now copy the keys into the context */
> > for (i = 0; i < keys.enckeylen / sizeof(u32); i++)
> > - ctx->key[i] = cpu_to_le32(aes.key_enc[i]);
> > + ctx->key[i] = cpu_to_le32(((u32 *)keys.enckey)[i]);
> > ctx->key_len = keys.enckeylen;
> >
> > memcpy(ctx->ipad, &istate.state, ctx->state_sz);
> > --
> > 1.8.3.1
> >


Regards,
Pascal van Leeuwen
Silicon IP Architect, Multi-Protocol Engines @ Verimatrix
http://www.insidesecure.com