linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antoine Tenart <antoine.tenart@bootlin.com>
To: Pascal van Leeuwen <pascalvanl@gmail.com>
Cc: linux-crypto@vger.kernel.org, antoine.tenart@bootlin.com,
	herbert@gondor.apana.org.au, davem@davemloft.net,
	Pascal van Leeuwen <pvanleeuwen@verimatrix.com>
Subject: Re: [PATCH 2/2] crypto: inside-secure - Add support for the Chacha20-Poly1305 AEAD
Date: Wed, 11 Sep 2019 16:29:47 +0100	[thread overview]
Message-ID: <20190911152947.GB5492@kwain> (raw)
In-Reply-To: <1568126293-4039-3-git-send-email-pvanleeuwen@verimatrix.com>

Hello Pascal,

On Tue, Sep 10, 2019 at 04:38:13PM +0200, Pascal van Leeuwen wrote:
> @@ -43,8 +44,8 @@ struct safexcel_cipher_ctx {
>  
>  	u32 mode;
>  	enum safexcel_cipher_alg alg;
> -	bool aead;
> -	int  xcm; /* 0=authenc, 1=GCM, 2 reserved for CCM */
> +	char aead; /* !=0=AEAD, 2=IPSec ESP AEAD */
> +	char xcm;  /* 0=authenc, 1=GCM, 2 reserved for CCM */

You could use an u8 instead. It also seems the aead comment has an
issue, I'll let you check that.

> -		dev_err(priv->dev, "aead: unsupported hash algorithm\n");
> +		dev_err(priv->dev, "aead: unsupported hash algorithmn");

You remove the '\' here.

> @@ -440,6 +459,17 @@ static int safexcel_context_control(struct safexcel_cipher_ctx *ctx,
>  				CONTEXT_CONTROL_DIGEST_XCM |
>  				ctx->hash_alg |
>  				CONTEXT_CONTROL_SIZE(ctrl_size);
> +		} else if (ctx->alg == SAFEXCEL_CHACHA20) {
> +			/* Chacha20-Poly1305 */
> +			cdesc->control_data.control0 =
> +				CONTEXT_CONTROL_KEY_EN |
> +				CONTEXT_CONTROL_CRYPTO_ALG_CHACHA20 |
> +				(sreq->direction == SAFEXCEL_ENCRYPT ?
> +					CONTEXT_CONTROL_TYPE_ENCRYPT_HASH_OUT :
> +					CONTEXT_CONTROL_TYPE_HASH_DECRYPT_IN) |
> +				ctx->hash_alg |
> +				CONTEXT_CONTROL_SIZE(ctrl_size);

I think you could use an if + |= for readability here.

> +static int safexcel_aead_chachapoly_crypt(struct aead_request *req,
> +					  enum safexcel_cipher_direction dir)
> +{
> +	struct safexcel_cipher_req *creq = aead_request_ctx(req);
> +	struct crypto_aead *aead = crypto_aead_reqtfm(req);
> +	struct crypto_tfm *tfm = crypto_aead_tfm(aead);
> +	struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
> +	struct aead_request *subreq = aead_request_ctx(req);
> +	u32 key[CHACHA_KEY_SIZE / sizeof(u32) + 1];

Shouldn't you explicitly memzero the key at the end of the function?

Thanks!
Antoine

-- 
Antoine Ténart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2019-09-11 15:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10 14:38 [PATCH 0/2] crypto: inside-secure: Add support for the Chacha20 skcipher and the Chacha20-Poly1305 AEAD suites Pascal van Leeuwen
2019-09-10 14:38 ` [PATCH 1/2] crypto: inside-secure - Added support for the CHACHA20 skcipher Pascal van Leeuwen
2019-09-10 17:32   ` Antoine Tenart
2019-09-10 18:58     ` Pascal Van Leeuwen
2019-09-11 15:21       ` Antoine Tenart
2019-09-11 15:32         ` Pascal Van Leeuwen
2019-09-10 14:38 ` [PATCH 2/2] crypto: inside-secure - Add support for the Chacha20-Poly1305 AEAD Pascal van Leeuwen
2019-09-11 15:29   ` Antoine Tenart [this message]
2019-09-11 15:37     ` Pascal Van Leeuwen
2019-09-11 15:45       ` Antoine Tenart
2019-09-11 15:49         ` Pascal Van Leeuwen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190911152947.GB5492@kwain \
    --to=antoine.tenart@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=pascalvanl@gmail.com \
    --cc=pvanleeuwen@verimatrix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).