All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Horia Geantă" <horia.geanta@freescale.com>
To: Martin Hicks <mort@bork.org>,
	Kim Phillips <kim.phillips@freescale.com>,
	Scott Wood <scottwood@freescale.com>,
	Kumar Gala <galak@kernel.crashing.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH 2/2] crypto: talitos: Add AES-XTS Support
Date: Fri, 27 Feb 2015 17:46:43 +0200	[thread overview]
Message-ID: <54F09163.5080007@freescale.com> (raw)
In-Reply-To: <1424451610-5786-3-git-send-email-mort@bork.org>

On 2/20/2015 7:00 PM, Martin Hicks wrote:
> The newer talitos hardware has support for AES in XTS mode.
> 
> Signed-off-by: Martin Hicks <mort@bork.org>
> ---

checkpatch complains about formatting, please check.

>  drivers/crypto/talitos.c |   33 +++++++++++++++++++++++++++++++++
>  drivers/crypto/talitos.h |    1 +
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
> index 6b2a19a..38cbde1 100644
> --- a/drivers/crypto/talitos.c
> +++ b/drivers/crypto/talitos.c
> @@ -40,9 +40,11 @@
>  #include <linux/spinlock.h>
>  #include <linux/rtnetlink.h>
>  #include <linux/slab.h>
> +#include <linux/device-mapper.h>
>  
>  #include <crypto/algapi.h>
>  #include <crypto/aes.h>
> +#include <crypto/xts.h>
>  #include <crypto/des.h>
>  #include <crypto/sha.h>
>  #include <crypto/md5.h>
> @@ -1464,9 +1466,22 @@ static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request *
>  						    areq, bool encrypt)
>  {
>  	struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
> +	struct crypto_tfm *tfm = (struct crypto_tfm *)cipher;
>  	struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
>  	unsigned int ivsize = crypto_ablkcipher_ivsize(cipher);
>  
> +	/*
> +	 * AES-XTS uses the first two AES Context registers for:
> +	 *
> +	 *     Register 1:   Sector Number (Little Endian)
> +	 *     Register 2:   Sector Size   (Big Endian)
> +	 *
> +	 * Whereas AES-CBC uses registers 1/2 as a 16-byte IV.
> +	 */
> +	if (!strcmp(crypto_tfm_alg_name(tfm),"xts(aes)"))

I guess it would be better to use ctx->desc_hdr_template instead of
string comparison.

> +		/* Fixed sized sector */
> +		*((u64 *)areq->info + 1) = cpu_to_be64((1<<SECTOR_SHIFT));
> +
>  	return talitos_edesc_alloc(ctx->dev, NULL, areq->src, areq->dst,
>  				   areq->info, 0, areq->nbytes, 0, ivsize, 0,
>  				   areq->base.flags, &areq->base, encrypt);
> @@ -2192,6 +2207,24 @@ static struct talitos_alg_template driver_algs[] = {
>  		                     DESC_HDR_MODE0_DEU_CBC |
>  		                     DESC_HDR_MODE0_DEU_3DES,
>  	},
> +	{	.type = CRYPTO_ALG_TYPE_ABLKCIPHER,
> +		.alg.crypto = {
> +			.cra_name = "xts(aes)",
> +			.cra_driver_name = "xts-aes-talitos",
> +			.cra_blocksize = XTS_BLOCK_SIZE,
> +			.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
> +                                     CRYPTO_ALG_ASYNC,
> +			.cra_ablkcipher = {
> +				.min_keysize = AES_MIN_KEY_SIZE * 2,
> +				.max_keysize = AES_MAX_KEY_SIZE * 2,
> +				.ivsize = XTS_BLOCK_SIZE,
> +			}
> +		},
> +		.desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
> +					DESC_HDR_SEL0_AESU |
> +					DESC_HDR_MODE0_AESU_XTS,
> +	},
> +
>  	/* AHASH algorithms. */
>  	{	.type = CRYPTO_ALG_TYPE_AHASH,
>  		.alg.hash = {
> diff --git a/drivers/crypto/talitos.h b/drivers/crypto/talitos.h
> index a6f73e2..735da82 100644
> --- a/drivers/crypto/talitos.h
> +++ b/drivers/crypto/talitos.h
> @@ -316,6 +316,7 @@ extern int talitos_submit(struct device *dev, int ch, struct talitos_edesc *edes
>  /* primary execution unit mode (MODE0) and derivatives */
>  #define	DESC_HDR_MODE0_ENCRYPT		cpu_to_be32(0x00100000)
>  #define	DESC_HDR_MODE0_AESU_CBC		cpu_to_be32(0x00200000)
> +#define	DESC_HDR_MODE0_AESU_XTS		cpu_to_be32(0x04200000)
>  #define	DESC_HDR_MODE0_DEU_CBC		cpu_to_be32(0x00400000)
>  #define	DESC_HDR_MODE0_DEU_3DES		cpu_to_be32(0x00200000)
>  #define	DESC_HDR_MODE0_MDEU_CONT	cpu_to_be32(0x08000000)
> 


_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

WARNING: multiple messages have this Message-ID (diff)
From: "Horia Geantă" <horia.geanta@freescale.com>
To: Martin Hicks <mort@bork.org>,
	Kim Phillips <kim.phillips@freescale.com>,
	Scott Wood <scottwood@freescale.com>,
	Kumar Gala <galak@kernel.crashing.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH 2/2] crypto: talitos: Add AES-XTS Support
Date: Fri, 27 Feb 2015 17:46:43 +0200	[thread overview]
Message-ID: <54F09163.5080007@freescale.com> (raw)
In-Reply-To: <1424451610-5786-3-git-send-email-mort@bork.org>

On 2/20/2015 7:00 PM, Martin Hicks wrote:
> The newer talitos hardware has support for AES in XTS mode.
> 
> Signed-off-by: Martin Hicks <mort@bork.org>
> ---

checkpatch complains about formatting, please check.

>  drivers/crypto/talitos.c |   33 +++++++++++++++++++++++++++++++++
>  drivers/crypto/talitos.h |    1 +
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
> index 6b2a19a..38cbde1 100644
> --- a/drivers/crypto/talitos.c
> +++ b/drivers/crypto/talitos.c
> @@ -40,9 +40,11 @@
>  #include <linux/spinlock.h>
>  #include <linux/rtnetlink.h>
>  #include <linux/slab.h>
> +#include <linux/device-mapper.h>
>  
>  #include <crypto/algapi.h>
>  #include <crypto/aes.h>
> +#include <crypto/xts.h>
>  #include <crypto/des.h>
>  #include <crypto/sha.h>
>  #include <crypto/md5.h>
> @@ -1464,9 +1466,22 @@ static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request *
>  						    areq, bool encrypt)
>  {
>  	struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
> +	struct crypto_tfm *tfm = (struct crypto_tfm *)cipher;
>  	struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
>  	unsigned int ivsize = crypto_ablkcipher_ivsize(cipher);
>  
> +	/*
> +	 * AES-XTS uses the first two AES Context registers for:
> +	 *
> +	 *     Register 1:   Sector Number (Little Endian)
> +	 *     Register 2:   Sector Size   (Big Endian)
> +	 *
> +	 * Whereas AES-CBC uses registers 1/2 as a 16-byte IV.
> +	 */
> +	if (!strcmp(crypto_tfm_alg_name(tfm),"xts(aes)"))

I guess it would be better to use ctx->desc_hdr_template instead of
string comparison.

> +		/* Fixed sized sector */
> +		*((u64 *)areq->info + 1) = cpu_to_be64((1<<SECTOR_SHIFT));
> +
>  	return talitos_edesc_alloc(ctx->dev, NULL, areq->src, areq->dst,
>  				   areq->info, 0, areq->nbytes, 0, ivsize, 0,
>  				   areq->base.flags, &areq->base, encrypt);
> @@ -2192,6 +2207,24 @@ static struct talitos_alg_template driver_algs[] = {
>  		                     DESC_HDR_MODE0_DEU_CBC |
>  		                     DESC_HDR_MODE0_DEU_3DES,
>  	},
> +	{	.type = CRYPTO_ALG_TYPE_ABLKCIPHER,
> +		.alg.crypto = {
> +			.cra_name = "xts(aes)",
> +			.cra_driver_name = "xts-aes-talitos",
> +			.cra_blocksize = XTS_BLOCK_SIZE,
> +			.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
> +                                     CRYPTO_ALG_ASYNC,
> +			.cra_ablkcipher = {
> +				.min_keysize = AES_MIN_KEY_SIZE * 2,
> +				.max_keysize = AES_MAX_KEY_SIZE * 2,
> +				.ivsize = XTS_BLOCK_SIZE,
> +			}
> +		},
> +		.desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
> +					DESC_HDR_SEL0_AESU |
> +					DESC_HDR_MODE0_AESU_XTS,
> +	},
> +
>  	/* AHASH algorithms. */
>  	{	.type = CRYPTO_ALG_TYPE_AHASH,
>  		.alg.hash = {
> diff --git a/drivers/crypto/talitos.h b/drivers/crypto/talitos.h
> index a6f73e2..735da82 100644
> --- a/drivers/crypto/talitos.h
> +++ b/drivers/crypto/talitos.h
> @@ -316,6 +316,7 @@ extern int talitos_submit(struct device *dev, int ch, struct talitos_edesc *edes
>  /* primary execution unit mode (MODE0) and derivatives */
>  #define	DESC_HDR_MODE0_ENCRYPT		cpu_to_be32(0x00100000)
>  #define	DESC_HDR_MODE0_AESU_CBC		cpu_to_be32(0x00200000)
> +#define	DESC_HDR_MODE0_AESU_XTS		cpu_to_be32(0x04200000)
>  #define	DESC_HDR_MODE0_DEU_CBC		cpu_to_be32(0x00400000)
>  #define	DESC_HDR_MODE0_DEU_3DES		cpu_to_be32(0x00200000)
>  #define	DESC_HDR_MODE0_MDEU_CONT	cpu_to_be32(0x08000000)
> 

  reply	other threads:[~2015-02-27 15:46 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20 17:00 [PATCH 0/2] crypto: talitos: Add AES-XTS mode Martin Hicks
2015-02-20 17:00 ` Martin Hicks
2015-02-20 17:00 ` [PATCH 1/2] crypto: talitos: Clean ups and comment fixes for ablkcipher commands Martin Hicks
2015-02-20 17:00   ` Martin Hicks
2015-02-20 17:00 ` [PATCH 2/2] crypto: talitos: Add AES-XTS Support Martin Hicks
2015-02-20 17:00   ` Martin Hicks
2015-02-27 15:46   ` Horia Geantă [this message]
2015-02-27 15:46     ` Horia Geantă
2015-03-06  0:16   ` Kim Phillips
2015-03-06  0:16     ` Kim Phillips
2015-03-06 16:49     ` Martin Hicks
2015-03-06 16:49       ` Martin Hicks
2015-03-06 19:28       ` Martin Hicks
2015-03-06 19:28         ` Martin Hicks
2015-03-07  1:16       ` Kim Phillips
2015-03-07  1:16         ` Kim Phillips
2015-03-09  9:22         ` Horia Geantă
2015-03-09  9:22           ` Horia Geantă
2015-03-02 13:25 ` [PATCH 0/2] crypto: talitos: Add AES-XTS mode Horia Geantă
2015-03-02 13:25   ` Horia Geantă
2015-03-02 14:37   ` Milan Broz
2015-03-02 22:09     ` Martin Hicks
2015-03-02 22:09       ` Martin Hicks
2015-03-03 15:44       ` Horia Geantă
2015-03-03 15:44         ` Horia Geantă
2015-03-03 17:44         ` Martin Hicks
2015-03-03 17:44           ` Martin Hicks
2015-03-09 10:16           ` Horia Geantă
2015-03-09 10:16             ` Horia Geantă
2015-03-09 15:08             ` Martin Hicks
2015-03-09 15:08               ` Martin Hicks
2015-03-11 15:48               ` Horia Geantă
2015-03-11 15:48                 ` Horia Geantă
2015-03-13 14:08                 ` Martin Hicks
2015-03-13 14:08                   ` Martin Hicks
2015-03-16 18:46                   ` Horia Geantă
2015-03-16 18:46                     ` Horia Geantă
2015-03-02 21:44   ` Martin Hicks
2015-03-02 21:44     ` Martin Hicks
2015-03-02 22:03     ` Martin Hicks
2015-03-02 22:03       ` Martin Hicks

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=54F09163.5080007@freescale.com \
    --to=horia.geanta@freescale.com \
    --cc=galak@kernel.crashing.org \
    --cc=kim.phillips@freescale.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mort@bork.org \
    --cc=scottwood@freescale.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.