Linux-Crypto Archive on lore.kernel.org
 help / color / Atom feed
* [PATCHv3] crypto: inside-secure - Fixed authenc w/ (3)DES fails on Macchiatobin
@ 2019-11-08  8:53 Pascal van Leeuwen
  2019-11-08  8:57 ` Ard Biesheuvel
  0 siblings, 1 reply; 4+ messages in thread
From: Pascal van Leeuwen @ 2019-11-08  8:53 UTC (permalink / raw)
  To: linux-crypto; +Cc: antoine.tenart, herbert, davem, Pascal van Leeuwen

Fixed 2 copy-paste mistakes in the commit mentioned below 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

changes since v2:
- moved Fixes: tag down near other tags

Fixes: 13a1bb93f7b1c9 ("crypto: inside-secure - Fixed warnings on
inconsistent byte order handling")

Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCHv3] crypto: inside-secure - Fixed authenc w/ (3)DES fails on Macchiatobin
  2019-11-08  8:53 [PATCHv3] crypto: inside-secure - Fixed authenc w/ (3)DES fails on Macchiatobin Pascal van Leeuwen
@ 2019-11-08  8:57 ` Ard Biesheuvel
  2019-11-08  9:02   ` Pascal Van Leeuwen
  0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2019-11-08  8:57 UTC (permalink / raw)
  To: Pascal van Leeuwen
  Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Antoine Tenart,
	Herbert Xu, David S. Miller, Pascal van Leeuwen

On Fri, 8 Nov 2019 at 09:57, Pascal van Leeuwen <pascalvanl@gmail.com> wrote:
>
> Fixed 2 copy-paste mistakes in the commit mentioned below 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
>
> changes since v2:
> - moved Fixes: tag down near other tags
>

Please put the changelog below the ---
It does not belong in the commit log itself.


> Fixes: 13a1bb93f7b1c9 ("crypto: inside-secure - Fixed warnings on
> inconsistent byte order handling")
>
> Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com>
> ---
>  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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCHv3] crypto: inside-secure - Fixed authenc w/ (3)DES fails on Macchiatobin
  2019-11-08  8:57 ` Ard Biesheuvel
@ 2019-11-08  9:02   ` Pascal Van Leeuwen
  2019-11-08  9:19     ` Ard Biesheuvel
  0 siblings, 1 reply; 4+ messages in thread
From: Pascal Van Leeuwen @ 2019-11-08  9:02 UTC (permalink / raw)
  To: Ard Biesheuvel, Pascal van Leeuwen
  Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Antoine Tenart,
	Herbert Xu, David S. Miller



> -----Original Message-----
> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Sent: Friday, November 8, 2019 9:58 AM
> To: Pascal van Leeuwen <pascalvanl@gmail.com>
> Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE <linux-crypto@vger.kernel.org>;
> Antoine Tenart <antoine.tenart@bootlin.com>; Herbert Xu <herbert@gondor.apana.org.au>;
> David S. Miller <davem@davemloft.net>; Pascal Van Leeuwen <pvanleeuwen@verimatrix.com>
> Subject: Re: [PATCHv3] crypto: inside-secure - Fixed authenc w/ (3)DES fails on
> Macchiatobin
> 
> On Fri, 8 Nov 2019 at 09:57, Pascal van Leeuwen <pascalvanl@gmail.com> wrote:
> >
> > Fixed 2 copy-paste mistakes in the commit mentioned below 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
> >
> > changes since v2:
> > - moved Fixes: tag down near other tags
> >
> 
> Please put the changelog below the ---
> It does not belong in the commit log itself.
> 
Really? I've always done it like that (just checked some of my previous
patches) and this is the first time someone complains about it ...

> 
> > Fixes: 13a1bb93f7b1c9 ("crypto: inside-secure - Fixed warnings on
> > inconsistent byte order handling")
> >
> > Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com>
> > ---
> >  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
www.insidesecure.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCHv3] crypto: inside-secure - Fixed authenc w/ (3)DES fails on Macchiatobin
  2019-11-08  9:02   ` Pascal Van Leeuwen
@ 2019-11-08  9:19     ` Ard Biesheuvel
  0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2019-11-08  9:19 UTC (permalink / raw)
  To: Pascal Van Leeuwen
  Cc: Pascal van Leeuwen,
	open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Antoine Tenart,
	Herbert Xu, David S. Miller

On Fri, 8 Nov 2019 at 10:02, Pascal Van Leeuwen
<pvanleeuwen@verimatrix.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > Sent: Friday, November 8, 2019 9:58 AM
> > To: Pascal van Leeuwen <pascalvanl@gmail.com>
> > Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE <linux-crypto@vger.kernel.org>;
> > Antoine Tenart <antoine.tenart@bootlin.com>; Herbert Xu <herbert@gondor.apana.org.au>;
> > David S. Miller <davem@davemloft.net>; Pascal Van Leeuwen <pvanleeuwen@verimatrix.com>
> > Subject: Re: [PATCHv3] crypto: inside-secure - Fixed authenc w/ (3)DES fails on
> > Macchiatobin
> >
> > On Fri, 8 Nov 2019 at 09:57, Pascal van Leeuwen <pascalvanl@gmail.com> wrote:
> > >
> > > Fixed 2 copy-paste mistakes in the commit mentioned below 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
> > >
> > > changes since v2:
> > > - moved Fixes: tag down near other tags
> > >
> >
> > Please put the changelog below the ---
> > It does not belong in the commit log itself.
> >
> Really? I've always done it like that (just checked some of my previous
> patches) and this is the first time someone complains about it ...
>

Well, the point is that formatting your patch correctly will make it
easier for the maintainer to apply it, without having to open it in an
editor and move things around or deleting them ('git am' automatically
drops the content below ---)


> >
> > > Fixes: 13a1bb93f7b1c9 ("crypto: inside-secure - Fixed warnings on
> > > inconsistent byte order handling")
> > >
> > > Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com>
> > > ---
> > >  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
> www.insidesecure.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08  8:53 [PATCHv3] crypto: inside-secure - Fixed authenc w/ (3)DES fails on Macchiatobin Pascal van Leeuwen
2019-11-08  8:57 ` Ard Biesheuvel
2019-11-08  9:02   ` Pascal Van Leeuwen
2019-11-08  9:19     ` Ard Biesheuvel

Linux-Crypto Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-crypto/0 linux-crypto/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-crypto linux-crypto/ https://lore.kernel.org/linux-crypto \
		linux-crypto@vger.kernel.org
	public-inbox-index linux-crypto

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-crypto


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git