Re: [PATCH -mm crypto] AES: x86_64 asm implementation optimization

2008-05-04 Thread dean gaudet
one of the more important details in evaluating these changes would be the 
family/model/stepping of the processors being microbenchmarked... could 
you folks include /proc/cpuinfo with the results?

also -- please drop the #define for R16 to %rsp ... it obfuscates more 
than it helps anything.

thanks
-dean

On Wed, 30 Apr 2008, Sebastian Siewior wrote:

 * Huang, Ying | 2008-04-25 11:11:17 [+0800]:
 
 Hi, Sebastian,
 Hi Huang,
 
 sorry for the delay.
 
 I changed the patches to group the read or write together instead of
 interleaving. Can you help me to test these new patches? The new patches
 is attached with the mail.
 The new results are attached.
 
 
 Best Regards,
 Huang Ying
 
 Sebastian
 
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3][CRYPTO] RIPEMD: add support for RIPEMD hash algorithms.

2008-05-04 Thread Adrian-Ken Rueegsegger
This patch adds support for RIPEMD-128 and RIPEMD-160
hash algorithms.

Signed-off-by: Adrian-Ken Rueegsegger [EMAIL PROTECTED]
---
 crypto/Makefile |2 +
 crypto/rmd128.c |  343 +
 crypto/rmd160.c |  387 +++
 include/crypto/ripemd.h |   26 +++
 4 files changed, 758 insertions(+), 0 deletions(-)
 create mode 100644 crypto/rmd128.c
 create mode 100644 crypto/rmd160.c
 create mode 100644 include/crypto/ripemd.h

diff --git a/crypto/Makefile b/crypto/Makefile
index ca02441..c21b455 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -27,6 +27,8 @@ obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 obj-$(CONFIG_CRYPTO_MD4) += md4.o
 obj-$(CONFIG_CRYPTO_MD5) += md5.o
+obj-$(CONFIG_CRYPTO_RMD160) += rmd128.o
+obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o
 obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o
 obj-$(CONFIG_CRYPTO_SHA512) += sha512_generic.o
diff --git a/crypto/rmd128.c b/crypto/rmd128.c
new file mode 100644
index 000..8f5e3c8
--- /dev/null
+++ b/crypto/rmd128.c
@@ -0,0 +1,343 @@
+/*
+ * Cryptographic API.
+ *
+ * RIPEMD-128 - RACE Integrity Primitives Evaluation Message Digest.
+ *
+ * Based on the reference implementation by Antoon Bosselaers, ESAT-COSIC
+ *
+ * Copyright (c) 2008 Adrian-Ken Rueegsegger rueegsegger (at) swiss-it.ch
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include linux/init.h
+#include linux/module.h
+#include linux/mm.h
+#include linux/crypto.h
+#include linux/cryptohash.h
+#include linux/types.h
+#include crypto/ripemd.h
+#include asm/byteorder.h
+
+struct rmd128_ctx {
+   u64 byte_count;
+   u32 state[4];
+   u32 buffer[16];
+};
+
+#define K1  0xUL
+#define K2  0x5a827999UL
+#define K3  0x6ed9eba1UL
+#define K4  0x8f1bbcdcUL
+#define KK1 0x50a28be6UL
+#define KK2 0x5c4dd124UL
+#define KK3 0x6d703ef3UL
+#define KK4 0xUL
+
+#define F1(x, y, z) (x ^ y ^ z)/* XOR */
+#define F2(x, y, z) (z ^ (x  (y ^ z)))/* x ? y : z */
+#define F3(x, y, z) ((x | ~y) ^ z)
+#define F4(x, y, z) (y ^ (z  (x ^ y)))/* z ? x : y */
+
+#define ROUND(a, b, c, d, f, k, x, s)  { \
+   (a) += f((b), (c), (d)) + (x) + (k); \
+   (a) = rol32((a), (s)); \
+}
+
+static void rmd128_transform(u32 *state, u32 const *in)
+{
+   u32 aa, bb, cc, dd, aaa, bbb, ccc, ddd;
+
+   /* Initialize left lane */
+   aa = state[0];
+   bb = state[1];
+   cc = state[2];
+   dd = state[3];
+
+   /* Initialize right lane */
+   aaa = state[0];
+   bbb = state[1];
+   ccc = state[2];
+   ddd = state[3];
+
+   /* round 1: left lane */
+   ROUND(aa, bb, cc, dd, F1, K1, in[0],  11);
+   ROUND(dd, aa, bb, cc, F1, K1, in[1],  14);
+   ROUND(cc, dd, aa, bb, F1, K1, in[2],  15);
+   ROUND(bb, cc, dd, aa, F1, K1, in[3],  12);
+   ROUND(aa, bb, cc, dd, F1, K1, in[4],   5);
+   ROUND(dd, aa, bb, cc, F1, K1, in[5],   8);
+   ROUND(cc, dd, aa, bb, F1, K1, in[6],   7);
+   ROUND(bb, cc, dd, aa, F1, K1, in[7],   9);
+   ROUND(aa, bb, cc, dd, F1, K1, in[8],  11);
+   ROUND(dd, aa, bb, cc, F1, K1, in[9],  13);
+   ROUND(cc, dd, aa, bb, F1, K1, in[10], 14);
+   ROUND(bb, cc, dd, aa, F1, K1, in[11], 15);
+   ROUND(aa, bb, cc, dd, F1, K1, in[12],  6);
+   ROUND(dd, aa, bb, cc, F1, K1, in[13],  7);
+   ROUND(cc, dd, aa, bb, F1, K1, in[14],  9);
+   ROUND(bb, cc, dd, aa, F1, K1, in[15],  8);
+
+   /* round 2: left lane */
+   ROUND(aa, bb, cc, dd, F2, K2, in[7],   7);
+   ROUND(dd, aa, bb, cc, F2, K2, in[4],   6);
+   ROUND(cc, dd, aa, bb, F2, K2, in[13],  8);
+   ROUND(bb, cc, dd, aa, F2, K2, in[1],  13);
+   ROUND(aa, bb, cc, dd, F2, K2, in[10], 11);
+   ROUND(dd, aa, bb, cc, F2, K2, in[6],   9);
+   ROUND(cc, dd, aa, bb, F2, K2, in[15],  7);
+   ROUND(bb, cc, dd, aa, F2, K2, in[3],  15);
+   ROUND(aa, bb, cc, dd, F2, K2, in[12],  7);
+   ROUND(dd, aa, bb, cc, F2, K2, in[0],  12);
+   ROUND(cc, dd, aa, bb, F2, K2, in[9],  15);
+   ROUND(bb, cc, dd, aa, F2, K2, in[5],   9);
+   ROUND(aa, bb, cc, dd, F2, K2, in[2],  11);
+   ROUND(dd, aa, bb, cc, F2, K2, in[14],  7);
+   ROUND(cc, dd, aa, bb, F2, K2, in[11], 13);
+   ROUND(bb, cc, dd, aa, F2, K2, in[8],  12);
+
+   /* round 3: left lane */
+   ROUND(aa, bb, cc, dd, F3, K3, in[3],  11);
+   ROUND(dd, aa, bb, cc, F3, K3, in[10], 13);
+   ROUND(cc, dd, aa, bb, F3, K3, in[14],  6);
+   ROUND(bb, cc, dd, aa, F3, K3, in[4],   7);
+   ROUND(aa, bb, cc, dd, F3, K3, in[9],  14);
+   ROUND(dd, aa, bb, cc, F3, K3, in[15],  9);
+   

[PATCH 3/3][CRYPTO] RIPEMD: add Kconfig entries for RIPEMD hash algorithms.

2008-05-04 Thread Adrian-Ken Rueegsegger
This  patch adds Kconfig entries for RIPEMD-128 and
RIPEMD-160.

Signed-off-by: Adrian-Ken Rueegsegger [EMAIL PROTECTED]
---
 crypto/Kconfig |   26 ++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 864456c..cfc521a 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -241,6 +241,32 @@ config CRYPTO_MICHAEL_MIC
  should not be used for other purposes because of the weakness
  of the algorithm.
 
+config CRYPTO_RMD128
+  tristate RIPEMD-128 digest algorithm
+  select CRYPTO_ALGAPI
+  help
+RIPEMD-128 (ISO/IEC 10118-3:2004).
+
+RIPEMD-128 is a 128-bit cryptographic hash function. It should only
+to be used as a secure replacement for RIPEMD. For other use cases
+RIPEMD-160 should be used.
+
+Developed by Hans Dobbertin, Antoon Bosselaers and Bart Preneel.
+See http://home.esat.kuleuven.be/~bosselae/ripemd160.html
+
+config CRYPTO_RMD160
+  tristate RIPEMD-160 digest algorithm
+  select CRYPTO_ALGAPI
+  help
+RIPEMD-160 (ISO/IEC 10118-3:2004).
+
+RIPEMD-160 is a 160-bit cryptographic hash function. It is intended
+to be used as a secure replacement for the 128-bit hash functions
+MD4, MD5 and it's predecessor RIPEMD (not to be confused with RIPEMD-128).
+
+Developed by Hans Dobbertin, Antoon Bosselaers and Bart Preneel.
+See http://home.esat.kuleuven.be/~bosselae/ripemd160.html
+
 config CRYPTO_SHA1
tristate SHA1 digest algorithm
select CRYPTO_ALGAPI
-- 
1.5.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3][CRYPTO] RIPEMD: add support for RIPEMD hash algorithms.

2008-05-04 Thread Adrian-Ken Rueegsegger
These patches add RIPEMD-128/160 support to the cryptoapi.

The first patch contains the actual implementation of the hash
algorithms. It is based on the sample implementation by Antoon
Bosselaers (ESAT-COSIC) found at:
 http://homes.esat.kuleuven.be/~bosselae/ripemd160.html

The second patch adds test vectors for both hash functions and their
respective digests (HMAC) to tcrypt. The test vectors for the hash
functions are taken from ISO/IEC 10118-3:2004 and the ones for HMAC
from RFC2286.

The third patch contains the Kconfig entries for both algorithms.

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html