The unified diff between revisions [df7d36d4..] and [215497ae..] is displayed below. It can also be downloaded as a raw diff.

#
#
# add_file "include/noekeon.h"
#  content [b464b6d3d268d8bd7cac78f4ec02772dce95b478]
#
# add_file "src/noekeon.cpp"
#  content [7cb295dc93acee6b7c1185ee7c2e78bc46279ed4]
#
# patch "checks/algos.cpp"
#  from [35736c52ac6de2bbc014715da6e911fa6701d158]
#    to [8e6ef4eeba244e56f7933d4d84a9001f2e086662]
#
# patch "checks/validate.dat"
#  from [e2b614a78ea9578b546125d0c810194ce709e5e6]
#    to [b0ec2f555e64890112f962c2611d1c083befecff]
#
# patch "doc/log.txt"
#  from [18646f88b4427c1a29d87d89a9225f44c9651631]
#    to [6bc01055505715409331459417f2e8a5717b64b0]
#
# patch "src/def_alg.cpp"
#  from [3e5c9f01ff8e26698fb8740ddb6cef277a23460e]
#    to [428c2c6f1fa8d405c908ceab45a5e24137aa0ff3]
#
============================================================
--- include/noekeon.h	b464b6d3d268d8bd7cac78f4ec02772dce95b478
+++ include/noekeon.h	b464b6d3d268d8bd7cac78f4ec02772dce95b478
@@ -0,0 +1,35 @@
+/*************************************************
+* Noekeon Header File                            *
+* (C) 1999-2008 Jack Lloyd                       *
+*************************************************/
+
+#ifndef BOTAN_NOEKEON_H__
+#define BOTAN_NOEKEON_H__
+
+#include <botan/base.h>
+
+namespace Botan {
+
+/*************************************************
+* Noekeon                                        *
+*************************************************/
+class BOTAN_DLL Noekeon : public BlockCipher
+   {
+   public:
+      void clear() throw();
+      std::string name() const { return "Noekeon"; }
+      BlockCipher* clone() const { return new Noekeon; }
+      Noekeon() : BlockCipher(16, 16) {}
+   private:
+      void enc(const byte[], byte[]) const;
+      void dec(const byte[], byte[]) const;
+      void key(const byte[], u32bit);
+
+      static const byte RC[17];
+
+      SecureBuffer<u32bit, 4> EK, DK;
+   };
+
+}
+
+#endif
============================================================
--- src/noekeon.cpp	7cb295dc93acee6b7c1185ee7c2e78bc46279ed4
+++ src/noekeon.cpp	7cb295dc93acee6b7c1185ee7c2e78bc46279ed4
@@ -0,0 +1,175 @@
+/*************************************************
+* Noekeon Source File                            *
+* (C) 1999-2008 Jack Lloyd                       *
+*************************************************/
+
+#include <botan/noekeon.h>
+#include <botan/loadstor.h>
+#include <botan/bit_ops.h>
+
+namespace Botan {
+
+namespace {
+
+inline void theta(u32bit& A0, u32bit& A1,
+                  u32bit& A2, u32bit& A3,
+                  const u32bit EK[4])
+   {
+   u32bit T = A0 ^ A2;
+   T ^= rotate_left(T, 8) ^ rotate_right(T, 8);
+   A1 ^= T;
+   A3 ^= T;
+
+   A0 ^= EK[0];
+   A1 ^= EK[1];
+   A2 ^= EK[2];
+   A3 ^= EK[3];
+
+   T = A1 ^ A3;
+   T ^= rotate_left(T, 8) ^ rotate_right(T, 8);
+   A0 ^= T;
+   A2 ^= T;
+   }
+
+inline void gamma(u32bit& A0, u32bit& A1, u32bit& A2, u32bit& A3)
+   {
+   A1 ^= ~A3 & ~A2;
+   A0 ^= A2 & A1;
+
+   u32bit T = A3;
+   A3 = A0;
+   A0 = T;
+
+   A2 ^= A0 ^ A1 ^ A3;
+
+   A1 ^= ~A3 & ~A2;
+   A0 ^= A2 & A1;
+   }
+
+}
+
+/*************************************************
+* Noekeon Round Constants                        *
+*************************************************/
+const byte Noekeon::RC[] = {
+   0x80, 0x1B, 0x36, 0x6C, 0xD8, 0xAB, 0x4D, 0x9A,
+   0x2F, 0x5E, 0xBC, 0x63, 0xC6, 0x97, 0x35, 0x6A,
+   0xD4 };
+
+/*************************************************
+* Noekeon Encryption                             *
+*************************************************/
+void Noekeon::enc(const byte in[], byte out[]) const
+   {
+   u32bit A0 = load_be<u32bit>(in, 0);
+   u32bit A1 = load_be<u32bit>(in, 1);
+   u32bit A2 = load_be<u32bit>(in, 2);
+   u32bit A3 = load_be<u32bit>(in, 3);
+
+   for(u32bit j = 0; j != 16; ++j)
+      {
+      A0 ^= RC[j];
+      theta(A0, A1, A2, A3, EK);
+
+      A1 = rotate_left(A1, 1);
+      A2 = rotate_left(A2, 5);
+      A3 = rotate_left(A3, 2);
+
+      gamma(A0, A1, A2, A3);
+
+      A1 = rotate_right(A1, 1);
+      A2 = rotate_right(A2, 5);
+      A3 = rotate_right(A3, 2);
+      }
+
+   A0 ^= RC[16];
+   theta(A0, A1, A2, A3, EK);
+
+   store_be(out, A0, A1, A2, A3);
+   }
+
+/*************************************************
+* Noekeon Encryption                             *
+*************************************************/
+void Noekeon::dec(const byte in[], byte out[]) const
+   {
+   u32bit A0 = load_be<u32bit>(in, 0);
+   u32bit A1 = load_be<u32bit>(in, 1);
+   u32bit A2 = load_be<u32bit>(in, 2);
+   u32bit A3 = load_be<u32bit>(in, 3);
+
+   for(u32bit j = 16; j != 0; --j)
+      {
+      theta(A0, A1, A2, A3, DK);
+      A0 ^= RC[j];
+
+      A1 = rotate_left(A1, 1);
+      A2 = rotate_left(A2, 5);
+      A3 = rotate_left(A3, 2);
+
+      gamma(A0, A1, A2, A3);
+
+      A1 = rotate_right(A1, 1);
+      A2 = rotate_right(A2, 5);
+      A3 = rotate_right(A3, 2);
+      }
+
+   theta(A0, A1, A2, A3, DK);
+   A0 ^= RC[0];
+
+   store_be(out, A0, A1, A2, A3);
+   }
+
+/*************************************************
+* Noekeon Key Schedule                           *
+*************************************************/
+void Noekeon::key(const byte key[], u32bit)
+   {
+   const u32bit NullVector[] = { 0, 0, 0, 0 };
+
+   u32bit A0 = load_be<u32bit>(key, 0);
+   u32bit A1 = load_be<u32bit>(key, 1);
+   u32bit A2 = load_be<u32bit>(key, 2);
+   u32bit A3 = load_be<u32bit>(key, 3);
+
+   for(u32bit j = 0; j != 16; ++j)
+      {
+      A0 ^= RC[j];
+      theta(A0, A1, A2, A3, NullVector);
+
+      A1 = rotate_left(A1, 1);
+      A2 = rotate_left(A2, 5);
+      A3 = rotate_left(A3, 2);
+
+      gamma(A0, A1, A2, A3);
+
+      A1 = rotate_right(A1, 1);
+      A2 = rotate_right(A2, 5);
+      A3 = rotate_right(A3, 2);
+      }
+
+   A0 ^= RC[16];
+
+   DK[0] = A0;
+   DK[1] = A1;
+   DK[2] = A2;
+   DK[3] = A3;
+
+   theta(A0, A1, A2, A3, NullVector);
+
+   EK[0] = A0;
+   EK[1] = A1;
+   EK[2] = A2;
+   EK[3] = A3;
+   }
+
+/*************************************************
+* Clear memory of sensitive data                 *
+*************************************************/
+void Noekeon::clear() throw()
+   {
+   EK.clear();
+   DK.clear();
+   }
+
+}
============================================================
--- checks/algos.cpp	35736c52ac6de2bbc014715da6e911fa6701d158
+++ checks/algos.cpp	8e6ef4eeba244e56f7933d4d84a9001f2e086662
@@ -28,6 +28,7 @@ std::vector<algorithm> get_algos()
              "Luby-Rackoff(SHA-1)/ECB", 16));
    algos.push_back(algorithm("Block Cipher", "MARS", "MARS/ECB", 32));
    algos.push_back(algorithm("Block Cipher", "MISTY1", "MISTY1/ECB", 16));
+   algos.push_back(algorithm("Block Cipher", "Noekeon", "Noekeon/ECB", 16));
    algos.push_back(algorithm("Block Cipher", "RC2", "RC2/ECB", 16));
    algos.push_back(algorithm("Block Cipher", "RC5(12)", "RC5(12)/ECB", 16));
    algos.push_back(algorithm("Block Cipher", "RC5(16)", "RC5(16)/ECB", 16));
============================================================
--- checks/validate.dat	e2b614a78ea9578b546125d0c810194ce709e5e6
+++ checks/validate.dat	b0ec2f555e64890112f962c2611d1c083befecff
@@ -8042,8 +8042,19 @@ FFFFFFFFFFFFFFFF:651F3092AFA551D0:FFFFFF

 FFFFFFFFFFFFFFFF:651F3092AFA551D0:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

-# First three came from RFC 2268, the rest were randomly generated by OpenSSL
+[Noekeon]
+# From the Nessie reference code
+00000000000000000000000000000000:BA6933819299C71699A99F08F678178B:\
+00000000000000000000000000000000
+
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:52F88A7B283C1F7BDF7B6FAA5011C7D8:\
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+
+52F88A7B283C1F7BDF7B6FAA5011C7D8:5096F2BFC82AE6E2D9495515C277FA70:\
+BA6933819299C71699A99F08F678178B
+
 [RC2]
+# First three came from RFC 2268, the rest were randomly generated by OpenSSL
 FFFFFFFFFFFFFFFF:278B27E42E2F0D49:FFFFFFFFFFFFFFFF
 1000000000000001:30649EDF9BE7D2C2:3000000000000000
 0000000000000000:2269552AB0F85CA6:88BCA90E90875A7F0F79C384627BAFB2
============================================================
--- doc/log.txt	18646f88b4427c1a29d87d89a9225f44c9651631
+++ doc/log.txt	6bc01055505715409331459417f2e8a5717b64b0
@@ -1,5 +1,6 @@

 * 1.7.8, 2008-??-??
+ - Added the block cipher Noekeon
  - Remove global deref_alias function
  - X509_Store takes timeout options as constructor arguments
  - Add Shanks-Tonelli algorithm, contributed by FlexSecure GmbH
============================================================
--- src/def_alg.cpp	3e5c9f01ff8e26698fb8740ddb6cef277a23460e
+++ src/def_alg.cpp	428c2c6f1fa8d405c908ceab45a5e24137aa0ff3
@@ -19,6 +19,7 @@
 #include <botan/lubyrack.h>
 #include <botan/mars.h>
 #include <botan/misty1.h>
+#include <botan/noekeon.h>
 #include <botan/rc2.h>
 #include <botan/rc5.h>
 #include <botan/rc6.h>
@@ -131,6 +132,7 @@ Default_Engine::find_block_cipher(const
    HANDLE_TYPE_ONE_STRING("Luby-Rackoff", LubyRackoff);
    HANDLE_TYPE_NO_ARGS("MARS", MARS);
    HANDLE_TYPE_ONE_U32BIT("MISTY1", MISTY1, 8);
+   HANDLE_TYPE_NO_ARGS("Noekeon", Noekeon);
    HANDLE_TYPE_NO_ARGS("RC2", RC2);
    HANDLE_TYPE_ONE_U32BIT("RC5", RC5, 12);
    HANDLE_TYPE_NO_ARGS("RC6", RC6);