Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Kim Phillips <kim.phillips@freescale.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, linuxppc-dev@ozlabs.org,
	Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Subject: Re: [PATCH 2/2 v2] talitos: Freescale integrated security engine (SEC) driver
Date: Thu, 5 Jun 2008 16:44:15 -0500	[thread overview]
Message-ID: <20080605164415.d486a299.kim.phillips@freescale.com> (raw)
In-Reply-To: <20080605052224.GA23150@gondor.apana.org.au>

On Thu, 5 Jun 2008 15:22:24 +1000
Herbert Xu <herbert@gondor.apana.org.au> wrote:

> On Fri, May 30, 2008 at 06:58:30PM -0500, Kim Phillips wrote:
> >
> > +	/* 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 :).

> 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):

diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index cf2e6f3..5ebb0f1 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -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

  reply	other threads:[~2008-06-05 21:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-30 23:58 [PATCH 2/2 v2] talitos: Freescale integrated security engine (SEC) driver Kim Phillips
2008-06-05  5:22 ` Herbert Xu
2008-06-05 21:44   ` Kim Phillips [this message]
2008-06-05 22:52     ` Herbert Xu

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=20080605164415.d486a299.kim.phillips@freescale.com \
    --to=kim.phillips@freescale.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    /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