linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: rsnel@cube.dyndns.org
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, Rik Snel <rsnel@cube.dyndns.org>
Subject: [PATCHv2 3/6] crypto: some common 128-bit block operations, nicely centralized
Date: Sat, 02 Sep 2006 03:00:24 +0200	[thread overview]
Message-ID: <11571588312623-git-send-email-rsnel@cube.dyndns.org> (raw)
In-Reply-To: <20060901103707.GA17110@gondor.apana.org.au>

From: Rik Snel <rsnel@cube.dyndns.org>

128bit is a common blocksize in linux kernel cryptography, so it helps to
centralize some common operations. The data must be aligned at sizeof(int)
for decent performance.

The code, while mostly trivial, is based on a header file mode_hdr.h in
http://fp.gladman.plus.com/AES/modes.vc8.19-06-06.zip

The original copyright (and GPL statement) of the original author,
Dr Brian Gladman, is preserved.

Signed-off-by: Rik Snel <rsnel@cube.dyndns.org>
---
 crypto/b128ops.h |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/crypto/b128ops.h b/crypto/b128ops.h
new file mode 100644
index 0000000..73d8a5f
--- /dev/null
+++ b/crypto/b128ops.h
@@ -0,0 +1,72 @@
+/* b128ops.h - common 128-bit block operations
+ *
+ * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.
+ * Copyright (c) 2006, Rik Snel <rsnel@cube.dyndns.org>
+ *
+ * Based on Dr Brian Gladman's (GPL'd) work published at
+ * http://fp.gladman.plus.com/cryptography_technology/index.htm
+ * See the original copyright notice below.
+ *
+ * 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.
+ */
+/*
+ ---------------------------------------------------------------------------
+ Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.   All rights reserved.
+
+ LICENSE TERMS
+
+ The free distribution and use of this software in both source and binary
+ form is allowed (with or without changes) provided that:
+
+   1. distributions of this source code include the above copyright
+      notice, this list of conditions and the following disclaimer;
+
+   2. distributions in binary form include the above copyright
+      notice, this list of conditions and the following disclaimer
+      in the documentation and/or other associated materials;
+
+   3. the copyright holder's name is not used to endorse products
+      built using this software without specific written permission.
+
+ ALTERNATIVELY, provided that this notice is retained in full, this product
+ may be distributed under the terms of the GNU General Public License (GPL),
+ in which case the provisions of the GPL apply INSTEAD OF those given above.
+
+ DISCLAIMER
+
+ This software is provided 'as is' with no explicit or implied warranties
+ in respect of its properties, including, but not limited to, correctness
+ and/or fitness for purpose.
+ ---------------------------------------------------------------------------
+ Issue Date: 13/06/2006
+*/
+
+#ifndef _LINUX_B128OPS_H
+#define _LINUX_B128OPS_H
+
+#include <linux/byteorder/swab.h>
+
+/* watch out: for good performance p and q must be aligned to 32bit
+ * boundaries on a 32bit machine and to 64bit boundaries on a 64bit
+ * machine. */
+inline void b128ops_mov(void *p, const void *q)
+{
+	((u64 *)p)[0] = ((u64 *)q)[0];
+	((u64 *)p)[1] = ((u64 *)q)[1];
+}
+
+inline void b128ops_xor(void *p, const void *q)
+{
+	((u64 *)p)[0] ^= ((u64 *)q)[0];
+	((u64 *)p)[1] ^= ((u64 *)q)[1];
+}
+
+inline void bswap64_block(void *d, const void *s, u32 n)
+{
+	while(n--) ((u64 *)d)[n] = __swab64(((u64 *)s)[n]);
+}
+
+#endif /* _LINUX_B128OPS_H */
-- 
1.4.1.1


-- 
VGER BF report: U 0.5

  parent reply	other threads:[~2006-09-02  1:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-31 12:39 LRW implementation, please comment Rik Snel
2006-08-31 12:39 ` [PATCH 1/6] crypto: trivial comment improvements Rik Snel
2006-08-31 12:39 ` [PATCH 2/6] crypto: benbi IV, big endian narrow block count for LRW-32-AES Rik Snel
2006-08-31 12:39 ` [PATCH 3/6] crypto: some common 128-bit block operations, nicely centralized Rik Snel
2006-08-31 12:39 ` [PATCH 4/6] crypto: table driven multiplications in GF(2^128), needed by LRW (and in the future ABL) Rik Snel
2006-08-31 12:39 ` [PATCH 5/6] crypto: LRW, Liskov Rivest Wagner, a tweakable narrow block cipher mode Rik Snel
2006-08-31 12:39 ` [PATCH 6/6] crypto: a simple way of storing and checking test vectors, LRW vectors included Rik Snel
2006-09-01  3:52 ` LRW implementation, please comment Herbert Xu
2006-09-01  8:55   ` rsnel
2006-09-01 10:37     ` Herbert Xu
2006-09-02  1:00       ` LRW... v2 rsnel
2006-11-29  8:04         ` Herbert Xu
2006-09-02  1:00       ` [PATCHv2 1/6] crypto: trivial comment improvements rsnel
2006-09-02  1:00       ` [PATCHv2 2/6] crypto: benbi IV, big endian narrow block count for LRW-32-AES rsnel
2006-09-02  1:00       ` rsnel [this message]
2006-09-02  1:00       ` [PATCHv2 4/6] crypto: table driven multiplications in GF(2^128), needed by LRW (and in the future ABL) rsnel
2006-11-26 23:56         ` Herbert Xu
2006-11-28 20:02           ` rsnel
2006-11-28 21:13             ` Herbert Xu
2006-11-28 21:17               ` rsnel
2006-11-28 22:24                 ` Herbert Xu
2006-09-02  1:00       ` [PATCHv2 5/6] LRW, Liskov Rivest Wagner, a tweakable narrow block cipher mode rsnel
2006-09-02  1:00       ` [PATCHv2 6/6] LRW testvectors in tcrypt.[ch] rsnel

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=11571588312623-git-send-email-rsnel@cube.dyndns.org \
    --to=rsnel@cube.dyndns.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).