All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] [crypto] padlock-aes loadkey ondemand
@ 2008-03-28 22:33 Sebastian Siewior
  2008-03-30 19:03 ` Stefan Hellermann
  2008-04-02  6:03 ` Herbert Xu
  0 siblings, 2 replies; 16+ messages in thread
From: Sebastian Siewior @ 2008-03-28 22:33 UTC (permalink / raw)
  To: Stefan Hellermann; +Cc: linux-crypto

Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
---
Stefan, if you have some spare time could you please look if this patch
improves padlock + xts performance somehow?

 drivers/crypto/padlock-aes.c |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index bb30eb9..1ebbe8c 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -48,6 +48,8 @@ struct aes_ctx {
 	u32 *D;
 };
 
+static struct aes_ctx *last_key;
+
 /* Tells whether the ACE is capable to generate
    the extended key for a given key_len. */
 static inline int
@@ -115,6 +117,7 @@ static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
 	ctx->cword.encrypt.ksize = (key_len - 16) / 8;
 	ctx->cword.decrypt.ksize = ctx->cword.encrypt.ksize;
 
+	last_key  = ctx;
 	/* Don't generate extended keys if the hardware can do it. */
 	if (aes_hw_extkey_available(key_len))
 		return 0;
@@ -205,14 +208,22 @@ static inline u8 *padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key,
 static void aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
 {
 	struct aes_ctx *ctx = aes_ctx(tfm);
-	padlock_reset_key();
+
+	if (last_key != ctx) {
+		last_key = ctx;
+		padlock_reset_key();
+	}
 	aes_crypt(in, out, ctx->E, &ctx->cword.encrypt);
 }
 
 static void aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
 {
 	struct aes_ctx *ctx = aes_ctx(tfm);
-	padlock_reset_key();
+
+	if (last_key != ctx) {
+		last_key = ctx;
+		padlock_reset_key();
+	}
 	aes_crypt(in, out, ctx->D, &ctx->cword.decrypt);
 }
 
@@ -245,7 +256,10 @@ static int ecb_aes_encrypt(struct blkcipher_desc *desc,
 	struct blkcipher_walk walk;
 	int err;
 
-	padlock_reset_key();
+	if (last_key != ctx) {
+		last_key = ctx;
+		padlock_reset_key();
+	}
 
 	blkcipher_walk_init(&walk, dst, src, nbytes);
 	err = blkcipher_walk_virt(desc, &walk);
@@ -269,7 +283,10 @@ static int ecb_aes_decrypt(struct blkcipher_desc *desc,
 	struct blkcipher_walk walk;
 	int err;
 
-	padlock_reset_key();
+	if (last_key != ctx) {
+		last_key = ctx;
+		padlock_reset_key();
+	}
 
 	blkcipher_walk_init(&walk, dst, src, nbytes);
 	err = blkcipher_walk_virt(desc, &walk);
@@ -315,7 +332,10 @@ static int cbc_aes_encrypt(struct blkcipher_desc *desc,
 	struct blkcipher_walk walk;
 	int err;
 
-	padlock_reset_key();
+	if (last_key != ctx) {
+		last_key = ctx;
+		padlock_reset_key();
+	}
 
 	blkcipher_walk_init(&walk, dst, src, nbytes);
 	err = blkcipher_walk_virt(desc, &walk);
@@ -341,7 +361,10 @@ static int cbc_aes_decrypt(struct blkcipher_desc *desc,
 	struct blkcipher_walk walk;
 	int err;
 
-	padlock_reset_key();
+	if (last_key != ctx) {
+		last_key = ctx;
+		padlock_reset_key();
+	}
 
 	blkcipher_walk_init(&walk, dst, src, nbytes);
 	err = blkcipher_walk_virt(desc, &walk);
-- 
1.5.4.3


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

end of thread, other threads:[~2008-08-31  6:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-28 22:33 [RFC] [crypto] padlock-aes loadkey ondemand Sebastian Siewior
2008-03-30 19:03 ` Stefan Hellermann
2008-03-30 21:01   ` Sebastian Siewior
2008-04-01 18:38     ` Stefan Hellermann
2008-04-02  6:44       ` Sebastian Siewior
2008-04-02  6:50         ` Herbert Xu
2008-04-02  7:17           ` Sebastian Siewior
2008-04-02  7:22             ` Herbert Xu
2008-08-07 14:53               ` Herbert Xu
2008-08-09 11:20                 ` Sebastian Siewior
2008-08-31  6:01                   ` Herbert Xu
2008-04-02 15:48           ` Stefan Hellermann
2008-04-09 16:38             ` Herbert Xu
2008-04-02  6:03 ` Herbert Xu
2008-04-02  6:26   ` Sebastian Siewior
2008-04-02  6:31     ` Herbert Xu

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.