For a long time, I've wanted to be able to easily run one or a few
[oweals/openssl.git] / crypto / des / ede_cbcm_enc.c
index a40b1d60732957af96b66d80d929b70a3fcb341e..c53062481ddd5441080f7d5589209b89024b872f 100644 (file)
 This is an implementation of Triple DES Cipher Block Chaining with Output
 Feedback Masking, by Coppersmith, Johnson and Matyas, (IBM and Certicom).
 
 This is an implementation of Triple DES Cipher Block Chaining with Output
 Feedback Masking, by Coppersmith, Johnson and Matyas, (IBM and Certicom).
 
+Note that there is a known attack on this by Biham and Knudsen but it takes
+a lot of work:
+
+http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz
+
 */
 
 */
 
+#ifndef NO_DESCBCM
 #include "des_locl.h"
 
 #include "des_locl.h"
 
-void des_ede3_cbcm_encrypt(const unsigned char *input,unsigned char *output,
-                          long length,
-                          des_key_schedule ks1,des_key_schedule ks2,
-                          des_key_schedule ks3,
-                          des_cblock ivec1,des_cblock ivec2,
-                          int enc)
+void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
+            long length, des_key_schedule ks1, des_key_schedule ks2,
+            des_key_schedule ks3, des_cblock *ivec1, des_cblock *ivec2,
+            int enc)
     {
     register DES_LONG tin0,tin1;
     register DES_LONG tout0,tout1,xor0,xor1,m0,m1;
     {
     register DES_LONG tin0,tin1;
     register DES_LONG tout0,tout1,xor0,xor1,m0,m1;
-    register unsigned char *in,*out;
     register long l=length;
     DES_LONG tin[2];
     unsigned char *iv1,*iv2;
 
     register long l=length;
     DES_LONG tin[2];
     unsigned char *iv1,*iv2;
 
-    in=(unsigned char *)input;
-    out=(unsigned char *)output;
-    iv1=(unsigned char *)ivec1;
-    iv2=(unsigned char *)ivec2;
+    iv1 = &(*ivec1)[0];
+    iv2 = &(*ivec2)[0];
 
     if (enc)
        {
 
     if (enc)
        {
@@ -125,11 +126,11 @@ void des_ede3_cbcm_encrypt(const unsigned char *input,unsigned char *output,
            l2c(tout0,out);
            l2c(tout1,out);
            }
            l2c(tout0,out);
            l2c(tout1,out);
            }
-       iv1=(unsigned char *)ivec1;
+       iv1=&(*ivec1)[0];
        l2c(m0,iv1);
        l2c(m1,iv1);
 
        l2c(m0,iv1);
        l2c(m1,iv1);
 
-       iv2=(unsigned char *)ivec2;
+       iv2=&(*ivec2)[0];
        l2c(tout0,iv2);
        l2c(tout1,iv2);
        }
        l2c(tout0,iv2);
        l2c(tout1,iv2);
        }
@@ -182,14 +183,15 @@ void des_ede3_cbcm_encrypt(const unsigned char *input,unsigned char *output,
            xor1=t1;
            }
 
            xor1=t1;
            }
 
-       iv1=(unsigned char *)ivec1;
+       iv1=&(*ivec1)[0];
        l2c(m0,iv1);
        l2c(m1,iv1);
 
        l2c(m0,iv1);
        l2c(m1,iv1);
 
-       iv2=(unsigned char *)ivec2;
+       iv2=&(*ivec2)[0];
        l2c(xor0,iv2);
        l2c(xor1,iv2);
        }
     tin0=tin1=tout0=tout1=xor0=xor1=0;
     tin[0]=tin[1]=0;
     }
        l2c(xor0,iv2);
        l2c(xor1,iv2);
        }
     tin0=tin1=tout0=tout1=xor0=xor1=0;
     tin[0]=tin[1]=0;
     }
+#endif