[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Aarg! Counter-mode is done wrong on little-endian mach...



Update of /home/minion/cvsroot/src/minion/src
In directory moria.mit.edu:/tmp/cvs-serv8319/src

Modified Files:
	aes_ctr.c 
Log Message:
Aarg!  Counter-mode is done wrong on little-endian machines!  For now,
I'll break big-endian too so both work the same.  With 0.0.3, I'm
going to do the right thing, and drop backward packet compatibility.


Index: aes_ctr.c
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/aes_ctr.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- aes_ctr.c	16 Dec 2002 02:40:11 -0000	1.9
+++ aes_ctr.c	14 Jan 2003 05:09:38 -0000	1.10
@@ -27,11 +27,14 @@
 #undef GET_U32
 #undef SET_U32
 
+#if 0
+/* Reinstate this code when we do the big backward-compatibility lossage. */
 #ifdef MM_B_ENDIAN
 #define GET_U32(ptr) (*(u32*)(ptr))
 #define SET_U32(ptr,i) (*(u32*)(ptr)) = i
 #define INCR_U32(ptr, i) i = ++(*(u32*)(ptr))
 #endif
+#endif
 
 /* An earlier version used bswap_32 where available to try to get the
    supposed benefits of inline assembly.  Bizarrely, on my Athlon,
@@ -40,6 +43,12 @@
    off encryption.  We seem to be near the point of diminishing
    returns here. */
 
+/*
+ * This code is incorrect; the correct version appears below.  Sadly,
+ * Mixminion 0.0.1 through 0.0.2.2 shipped with this junk, so if we
+ * change it, we'll make packets nobody can read.  With 0.0.3, we'll
+ * bump the packet version and do the right thing.
+ */ 
 #ifndef GET_U32
 #define GET_U32_cp(ptr) (  (u32)ptr[0] ^         \
                          (((u32)ptr[1]) << 8) ^  \
@@ -52,6 +61,23 @@
 #define GET_U32(ptr)   GET_U32_cp(((u8*)(ptr)))
 #define SET_U32(ptr,i) SET_U32_cp(((u8*)(ptr)), i)
 #define INCR_U32(ptr, i) { i = GET_U32(ptr)+1; SET_U32(ptr,i); }
+#endif
+
+
+#if 0
+#ifndef GET_U32
+#define GET_U32_cp(ptr) (  (u32)ptr[3] ^         \
+                         (((u32)ptr[2]) << 8) ^  \
+                         (((u32)ptr[1]) << 16) ^ \
+                         (((u32)ptr[0]) << 24))
+#define SET_U32_cp(ptr, i) { ptr[3] = (i)     & 0xff; \
+                             ptr[2] = (i>>8)  & 0xff; \
+                             ptr[1] = (i>>16) & 0xff; \
+                             ptr[0] = (i>>24) & 0xff; }
+#define GET_U32(ptr)   GET_U32_cp(((u8*)(ptr)))
+#define SET_U32(ptr,i) SET_U32_cp(((u8*)(ptr)), i)
+#define INCR_U32(ptr, i) { i = GET_U32(ptr)+1; SET_U32(ptr,i); }
+#endif
 #endif
 
 static inline void