Skip to contentSkip to conversation

talitos: Freescale integrated security engine (SEC) driver

PATCH In review Kim Phillips 2 participants 4 messages May 31, 2008 – Jun 5, 2008 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 talitos: Freescale integrated security engine (SEC) driver

Add support for the SEC available on a wide range of PowerQUICC devices, e.g. MPC8349E, MPC8548E.

this initial version supports authenc(hmac(sha1),cbc(aes)) for use with IPsec.

---
removed priv->status hw interrupt status assignment. Done tasklet now checks all channels unconditionally.

 drivers/crypto/Kconfig   |   15 +
 drivers/crypto/Makefile  |    1 +
 drivers/crypto/talitos.c | 1367 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/crypto/talitos.h |  191 +++++++
 4 files changed, 1574 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/talitos.c
 create mode 100644 drivers/crypto/talitos.h
drivers/crypto/Kconfig +15 -0
index 43b71b6..98d96df 100644
@@ -174,4 +174,19 @@ config CRYPTO_DEV_HIFN_795X_RNG
 	  Select this option if you want to enable the random number generator
 	  on the HIFN 795x crypto adapters.
 
+config CRYPTO_DEV_TALITOS
+	tristate "Talitos Freescale Security Engine (SEC)"
+	select CRYPTO_ALGAPI
+	select CRYPTO_AUTHENC
+	depends on FSL_SOC
+	help
+	  Say 'Y' here to use the Freescale Security Engine (SEC)
+	  to offload cryptographic algorithm computation.
+
+	  The Freescale SEC is present on PowerQUICC 'E' processors, such
+	  as the MPC8349E and MPC8548E.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called talitos.
+
 endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
index c0327f0..d29d2cd 100644
@@ -2,3 +2,4 @@ obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o
 obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o
 obj-$(CONFIG_CRYPTO_DEV_GEODE) += geode-aes.o
 obj-$(CONFIG_CRYPTO_DEV_HIFN_795X) += hifn_795x.o
+obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
drivers/crypto/talitos.c new file +1367 -0

1,367 lines not on this page · raw message

drivers/crypto/talitos.h new file +191 -0

191 lines not on this page · raw message

Signature · 1 line
1.5.5.1.125.gc697a
maintainer
#1 lore raw

drivers/crypto/talitos.c line 1024

Quoted 3 lines · Kim Phillips
drivers/crypto/talitos.c new file +2 -0
+	/* get random IV */
+	get_random_bytes(req->giv, crypto_aead_ivsize(authenc));

Sorry but this is unworkable given our current RNG infrastructure. Draining 16 bytes for every packet is going to make /dev/random unuseable (if it wasn't already :).

Perhaps just use eseqiv (it should be pretty cheap sinec it just tacks on an extra block to the encryption) for now until we have a PRNG?

We'll need to extend eseqiv to support AEAD first though. Perhaps change it so that it can be called as a library by AEAD algorithms?

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
Quoted 8 lines · On Thu, 5 Jun 2008 15:22:24 +1000 Herbert Xu <[email protected]>…

Review

Quoted 3 lines · Kim Phillips
(quoted diff) +2 -0
+	/* get random IV */
+	get_random_bytes(req->giv, crypto_aead_ivsize(authenc));

Sorry but this is unworkable given our current RNG infrastructure. Draining 16 bytes for every packet is going to make /dev/random unuseable (if it wasn't already :).

it is :). I'm working on it :).

Quoted 3 lines

Perhaps just use eseqiv (it should be pretty cheap sinec it just tacks on an extra block to the encryption) for now until we have a PRNG?

the h/w has a IV out feature we should probably be using. How about something like this (UNTESTED):

drivers/crypto/talitos.c +8 -4
index cf2e6f3..5ebb0f1 100644
@@ -566,6 +566,7 @@ struct talitos_ctx {
 	struct device *dev;
 	__be32 desc_hdr_template;
 	u8 key[TALITOS_MAX_KEY_SIZE];
+	u8 iv[TALITOS_AES_IV_LENGTH];
 	unsigned int keylen;
 	unsigned int enckeylen;
 	unsigned int authkeylen;
@@ -873,8 +874,9 @@ static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
 					   edesc->dma_len, DMA_BIDIRECTIONAL);
 	}
 
-	/* optional iv out - entry points use random IVs instead */
-	desc->ptr[6].len = 0;
+	/* iv out */
+	map_single_talitos_ptr(dev, &desc->ptr[6], ivsize, ctx->iv, 0,
+			       DMA_FROM_DEVICE);
 
 	return talitos_submit(dev, desc, callback, areq);
 }
@@ -1020,8 +1022,7 @@ static int aes_cbc_sha1_hmac_authenc_givencrypt(
 	/* set encrypt */
 	edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_AESU_ENC;
 
-	/* get random IV */
-	get_random_bytes(req->giv, crypto_aead_ivsize(authenc));
+	memcpy(req->giv, ctx->iv, crypto_aead_ivsize(authenc));
 
 	return ipsec_esp(edesc, areq, req->giv, req->seq,
 			 ipsec_esp_encrypt_done);
@@ -1081,6 +1082,9 @@ static int talitos_cra_init(struct crypto_tfm *tfm)
 	/* copy descriptor header template value */
 	ctx->desc_hdr_template = talitos_alg->desc_hdr_template;
 
+	/* random first IV */
+	get_random_bytes(ctx->iv, TALITOS_AES_IV_LENGTH);
+
 	return 0;
 }
 

Kim

maintainer
#3 lore raw
Quoted 2 lines · Kim Phillips

it is :). I'm working on it :).

Good :)

Quoted 2 lines

the h/w has a IV out feature we should probably be using. How about something like this (UNTESTED):

Looks great!

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt