Change type of various DES function arguments from des_cblock
authorBodo Möller <bodo@openssl.org>
Sun, 16 May 1999 12:26:16 +0000 (12:26 +0000)
committerBodo Möller <bodo@openssl.org>
Sun, 16 May 1999 12:26:16 +0000 (12:26 +0000)
(meaning pointer to char) to des_cblock * (meaning pointer to
array with 8 char elements), which allows the compiler to
do more typechecking.  (The changed argument types were of type
des_cblock * back in SSLeay, and a lot of ugly casts were
used then to turn them into pointers to elements; but it can be
done without those casts.)

Introduce new type const_des_cblock -- before, the pointers rather
than the elements pointed to were declared const, and for
some reason gcc did not complain about this (but some other
compilers did).

37 files changed:
apps/speed.c
crypto/des/cbc_cksm.c
crypto/des/cbc_enc.c
crypto/des/cfb64ede.c
crypto/des/cfb64enc.c
crypto/des/cfb_enc.c
crypto/des/des.h
crypto/des/des_enc.c
crypto/des/destest.c
crypto/des/ecb3_enc.c
crypto/des/ecb_enc.c
crypto/des/ede_cbcm_enc.c
crypto/des/enc_read.c
crypto/des/enc_writ.c
crypto/des/fcrypt.c
crypto/des/ofb64ede.c
crypto/des/ofb64enc.c
crypto/des/ofb_enc.c
crypto/des/pcbc_enc.c
crypto/des/qud_cksm.c
crypto/des/rand_key.c
crypto/des/read2pwd.c
crypto/des/rpc_enc.c
crypto/des/set_key.c
crypto/des/str2key.c
crypto/des/supp.c
crypto/des/xcbc_enc.c
crypto/evp/e_cbc_3d.c
crypto/evp/e_cbc_d.c
crypto/evp/e_cfb_3d.c
crypto/evp/e_cfb_d.c
crypto/evp/e_ecb_3d.c
crypto/evp/e_ecb_d.c
crypto/evp/e_ofb_3d.c
crypto/evp/e_ofb_d.c
crypto/evp/e_xcbc_d.c
crypto/mdc2/mdc2dgst.c

index eae1374..a8371fb 100644 (file)
@@ -580,9 +580,9 @@ int MAIN(int argc, char **argv)
 #endif
 
 #ifndef NO_DES
-       des_set_key(key,sch);
-       des_set_key(key2,sch2);
-       des_set_key(key3,sch3);
+       des_set_key(&key,sch);
+       des_set_key(&key2,sch2);
+       des_set_key(&key3,sch3);
 #endif
 #ifndef NO_IDEA
        idea_set_encrypt_key(key16,&idea_ks);
@@ -833,7 +833,7 @@ int MAIN(int argc, char **argv)
                        Time_F(START);
                        for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
                                des_ncbc_encrypt(buf,buf,lengths[j],sch,
-                                                &(iv[0]),DES_ENCRYPT);
+                                                &iv,DES_ENCRYPT);
                        d=Time_F(STOP);
                        BIO_printf(bio_err,"%ld %s's in %.2fs\n",
                                count,names[D_CBC_DES],d);
@@ -850,7 +850,7 @@ int MAIN(int argc, char **argv)
                        for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
                                des_ede3_cbc_encrypt(buf,buf,lengths[j],
                                                     sch,sch2,sch3,
-                                                    &(iv[0]),DES_ENCRYPT);
+                                                    &iv,DES_ENCRYPT);
                        d=Time_F(STOP);
                        BIO_printf(bio_err,"%ld %s's in %.2fs\n",
                                count,names[D_EDE3_DES],d);
index aeb0a79..1e543cb 100644 (file)
 
 #include "des_locl.h"
 
-DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock out, long length,
-            des_key_schedule schedule, const des_cblock iv)
+DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output,
+               long length,
+               des_key_schedule schedule, const_des_cblock *ivec)
        {
        register DES_LONG tout0,tout1,tin0,tin1;
        register long l=length;
        DES_LONG tin[2];
+       unsigned char *out = &(*output)[0];
+       const unsigned char *iv = &(*ivec)[0];
 
        c2l(iv,tout0);
        c2l(iv,tout1);
index c989a7f..4ccabc9 100644 (file)
@@ -61,7 +61,7 @@
 /* Note that this is inconsistent with other DES functions, in that it doesn't
    update ivec */
 void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
-            des_key_schedule schedule, des_cblock ivec, int enc)
+            des_key_schedule schedule, des_cblock *ivec, int enc)
        {
        register DES_LONG tin0,tin1;
        register DES_LONG tout0,tout1,xor0,xor1;
@@ -69,7 +69,7 @@ void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
        DES_LONG tin[2];
        unsigned char *iv;
 
-       iv=ivec;
+       iv = &(*ivec)[0];
 
        if (enc)
                {
index 1f936fa..5362a55 100644 (file)
@@ -65,7 +65,7 @@
 
 void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
             long length, des_key_schedule ks1, des_key_schedule ks2,
-            des_key_schedule ks3, des_cblock ivec, int *num, int enc)
+            des_key_schedule ks3, des_cblock *ivec, int *num, int enc)
        {
        register DES_LONG v0,v1;
        register long l=length;
@@ -73,7 +73,7 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
        DES_LONG ti[2];
        unsigned char *iv,c,cc;
 
-       iv=ivec;
+       iv=&(*ivec)[0];
        if (enc)
                {
                while (l--)
@@ -89,10 +89,10 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
                                v0=ti[0];
                                v1=ti[1];
 
-                               iv=ivec;
+                               iv = &(*ivec)[0];
                                l2c(v0,iv);
                                l2c(v1,iv);
-                               iv=ivec;
+                               iv = &(*ivec)[0];
                                }
                        c= *(in++)^iv[n];
                        *(out++)=c;
@@ -115,10 +115,10 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
                                v0=ti[0];
                                v1=ti[1];
 
-                               iv=ivec;
+                               iv = &(*ivec)[0];
                                l2c(v0,iv);
                                l2c(v1,iv);
-                               iv=ivec;
+                               iv = &(*ivec)[0];
                                }
                        cc= *(in++);
                        c=iv[n];
index e2525a7..389a232 100644 (file)
@@ -64,8 +64,8 @@
  */
 
 void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
-            long length, des_key_schedule schedule, des_cblock ivec, int *num,
-            int enc)
+            long length, des_key_schedule schedule, des_cblock *ivec,
+            int *num, int enc)
        {
        register DES_LONG v0,v1;
        register long l=length;
@@ -73,7 +73,7 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
        DES_LONG ti[2];
        unsigned char *iv,c,cc;
 
-       iv=ivec;
+       iv = &(*ivec)[0];
        if (enc)
                {
                while (l--)
@@ -83,10 +83,10 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
                                c2l(iv,v0); ti[0]=v0;
                                c2l(iv,v1); ti[1]=v1;
                                des_encrypt(ti,schedule,DES_ENCRYPT);
-                               iv=ivec;
+                               iv = &(*ivec)[0];
                                v0=ti[0]; l2c(v0,iv);
                                v0=ti[1]; l2c(v0,iv);
-                               iv=ivec;
+                               iv = &(*ivec)[0];
                                }
                        c= *(in++)^iv[n];
                        *(out++)=c;
@@ -103,10 +103,10 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
                                c2l(iv,v0); ti[0]=v0;
                                c2l(iv,v1); ti[1]=v1;
                                des_encrypt(ti,schedule,DES_ENCRYPT);
-                               iv=ivec;
+                               iv = &(*ivec)[0];
                                v0=ti[0]; l2c(v0,iv);
                                v0=ti[1]; l2c(v0,iv);
-                               iv=ivec;
+                               iv = &(*ivec)[0];
                                }
                        cc= *(in++);
                        c=iv[n];
index 12c1d5e..cca34dd 100644 (file)
@@ -65,7 +65,7 @@
  * byte.
  */
 void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
-            long length, des_key_schedule schedule, des_cblock ivec, int enc)
+            long length, des_key_schedule schedule, des_cblock *ivec, int enc)
        {
        register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
        register DES_LONG mask0,mask1;
@@ -90,7 +90,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
                mask1=0x00000000L;
                }
 
-       iv=ivec;
+       iv = &(*ivec)[0];
        c2l(iv,v0);
        c2l(iv,v1);
        if (enc)
@@ -157,7 +157,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
                        out+=n;
                        }
                }
-       iv=ivec;
+       iv = &(*ivec)[0];
        l2c(v0,iv);
        l2c(v1,iv);
        v0=v1=d0=d1=ti[0]=ti[1]=0;
index 348ba69..51958cc 100644 (file)
@@ -77,8 +77,8 @@ extern "C" {
 #endif
 
 typedef unsigned char des_cblock[8];
-typedef unsigned char *des_cblocks; /* Unfortunately there's no way to say that
-                                      we want a multiple of 8 */
+typedef const unsigned char const_des_cblock[8];
+
 typedef struct des_ks_struct
        {
        union   {
@@ -87,7 +87,9 @@ typedef struct des_ks_struct
                 * 8 byte longs */
                DES_LONG pad[2];
                } ks;
-#undef _
+#if defined _
+# error "_ is defined, but some strange definition the DES library cannot handle that."
+#endif
 #define _      ks._
        int weak_key;
        } des_key_schedule[16];
@@ -143,25 +145,25 @@ OPENSSL_EXTERN int des_rw_mode;           /* defaults to DES_PCBC_MODE */
 OPENSSL_EXTERN int des_set_weak_key_flag; /* set the weak key flag */
 
 const char *des_options(void);
-void des_ecb3_encrypt(const des_cblock input, des_cblock output,
+void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
                      des_key_schedule ks1,des_key_schedule ks2,
                      des_key_schedule ks3, int enc);
-DES_LONG des_cbc_cksum(const unsigned char *input,des_cblock output,
+DES_LONG des_cbc_cksum(const unsigned char *input,des_cblock *output,
                       long length,des_key_schedule schedule,
-                      const des_cblock ivec);
+                      const_des_cblock *ivec);
 void des_cbc_encrypt(const unsigned char *input,unsigned char *output,
-                    long length,des_key_schedule schedule,des_cblock ivec,
+                    long length,des_key_schedule schedule,des_cblock *ivec,
                     int enc);
 void des_ncbc_encrypt(const unsigned char *input,unsigned char *output,
-                     long length,des_key_schedule schedule,des_cblock ivec,
+                     long length,des_key_schedule schedule,des_cblock *ivec,
                      int enc);
 void des_xcbc_encrypt(const unsigned char *input,unsigned char *output,
-                     long length,des_key_schedule schedule,des_cblock ivec,
-                     const des_cblock inw,const des_cblock outw,int enc);
+                     long length,des_key_schedule schedule,des_cblock *ivec,
+                     const_des_cblock *inw,const_des_cblock *outw,int enc);
 void des_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
-                    long length,des_key_schedule schedule,des_cblock ivec,
+                    long length,des_key_schedule schedule,des_cblock *ivec,
                     int enc);
-void des_ecb_encrypt(const des_cblock input,des_cblock output,
+void des_ecb_encrypt(const_des_cblock *input,des_cblock *output,
                     des_key_schedule ks,int enc);
 void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
 void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
@@ -172,29 +174,29 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
 void des_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, 
                          long length,
                          des_key_schedule ks1,des_key_schedule ks2,
-                         des_key_schedule ks3,des_cblock ivec,int enc);
+                         des_key_schedule ks3,des_cblock *ivec,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,
+                          des_cblock *ivec1,des_cblock *ivec2,
                           int enc);
 void des_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out,
                            long length,des_key_schedule ks1,
                            des_key_schedule ks2,des_key_schedule ks3,
-                           des_cblock ivec,int *num,int enc);
+                           des_cblock *ivec,int *num,int enc);
 void des_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out,
                            long length,des_key_schedule ks1,
                            des_key_schedule ks2,des_key_schedule ks3,
-                           des_cblock ivec,int *num);
+                           des_cblock *ivec,int *num);
 
-void des_xwhite_in2out(const des_cblock des_key,const des_cblock in_white,
-                      des_cblock out_white);
+void des_xwhite_in2out(const_des_cblock *des_key,const_des_cblock *in_white,
+                      des_cblock *out_white);
 
 int des_enc_read(int fd,void *buf,int len,des_key_schedule sched,
-                des_cblock iv);
+                des_cblock *iv);
 int des_enc_write(int fd,const void *buf,int len,des_key_schedule sched,
-                 des_cblock iv);
+                 des_cblock *iv);
 char *des_fcrypt(const char *buf,const char *salt, char *ret);
 #if defined(PERL5) || defined(__FreeBSD__)
 char *des_crypt(const char *buf,const char *salt);
@@ -208,33 +210,33 @@ char *crypt();
 #endif
 #endif
 void des_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
-                    long length,des_key_schedule schedule,des_cblock ivec);
+                    long length,des_key_schedule schedule,des_cblock *ivec);
 void des_pcbc_encrypt(const unsigned char *input,unsigned char *output,
-                     long length,des_key_schedule schedule,des_cblock ivec,
+                     long length,des_key_schedule schedule,des_cblock *ivec,
                      int enc);
-DES_LONG des_quad_cksum(const unsigned char *input,des_cblocks output,
-                       long length,int out_count,des_cblock seed);
-void des_random_seed(des_cblock key);
-void des_random_key(des_cblock ret);
-int des_read_password(des_cblock key,const char *prompt,int verify);
-int des_read_2passwords(des_cblock key1,des_cblock key2,
+DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[],
+                       long length,int out_count,des_cblock *seed);
+void des_random_seed(des_cblock *key);
+void des_random_key(des_cblock *ret);
+int des_read_password(des_cblock *key,const char *prompt,int verify);
+int des_read_2passwords(des_cblock *key1,des_cblock *key2,
                        const char *prompt,int verify);
 int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
-void des_set_odd_parity(des_cblock key);
-int des_is_weak_key(const des_cblock key);
-int des_set_key(const des_cblock key,des_key_schedule schedule);
-int des_key_sched(const des_cblock key,des_key_schedule schedule);
-void des_string_to_key(const char *str,des_cblock key);
-void des_string_to_2keys(const char *str,des_cblock key1,des_cblock key2);
+void des_set_odd_parity(des_cblock *key);
+int des_is_weak_key(const_des_cblock *key);
+int des_set_key(const_des_cblock *key,des_key_schedule schedule);
+int des_key_sched(const_des_cblock *key,des_key_schedule schedule);
+void des_string_to_key(const char *str,des_cblock *key);
+void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2);
 void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
-                      des_key_schedule schedule,des_cblock ivec,int *num,
+                      des_key_schedule schedule,des_cblock *ivec,int *num,
                       int enc);
 void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
-                      des_key_schedule schedule,des_cblock ivec,int *num);
+                      des_key_schedule schedule,des_cblock *ivec,int *num);
 int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
 
 /* Extra functions from Mark Murray <mark@grondar.za> */
-void des_cblock_print_file(const des_cblock cb, FILE *fp);
+void des_cblock_print_file(const_des_cblock *cb, FILE *fp);
 
 #ifdef FreeBSD
 /* The following functions are not in the normal unix build or the
index a0ecfbc..3a30e64 100644 (file)
@@ -290,7 +290,7 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
 #ifndef DES_DEFAULT_OPTIONS
 
 void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
-            des_key_schedule schedule, des_cblock ivec, int enc)
+            des_key_schedule schedule, des_cblock *ivec, int enc)
        {
        register DES_LONG tin0,tin1;
        register DES_LONG tout0,tout1,xor0,xor1;
@@ -298,7 +298,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
        DES_LONG tin[2];
        unsigned char *iv;
 
-       iv=ivec;
+       iv = &(*ivec)[0];
 
        if (enc)
                {
@@ -323,7 +323,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
                        tout0=tin[0]; l2c(tout0,out);
                        tout1=tin[1]; l2c(tout1,out);
                        }
-               iv=ivec;
+               iv = &(*ivec)[0];
                l2c(tout0,iv);
                l2c(tout1,iv);
                }
@@ -355,7 +355,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
                        xor1=tin1;
                        }
 
-               iv=ivec;
+               iv = &(*ivec)[0];
                l2c(xor0,iv);
                l2c(xor1,iv);
                }
@@ -365,7 +365,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
 
 void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
             long length, des_key_schedule ks1, des_key_schedule ks2,
-            des_key_schedule ks3, des_cblock ivec, int enc)
+            des_key_schedule ks3, des_cblock *ivec, int enc)
        {
        register DES_LONG tin0,tin1;
        register DES_LONG tout0,tout1,xor0,xor1;
@@ -377,7 +377,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
 
        in=input;
        out=output;
-       iv=ivec;
+       iv = &(*ivec)[0];
 
        if (enc)
                {
@@ -414,7 +414,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
                        l2c(tout0,out);
                        l2c(tout1,out);
                        }
-               iv=ivec;
+               iv = &(*ivec)[0];
                l2c(tout0,iv);
                l2c(tout1,iv);
                }
@@ -466,7 +466,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
                        xor1=t1;
                        }
 
-               iv=ivec;
+               iv = &(*ivec)[0];
                l2c(xor0,iv);
                l2c(xor1,iv);
                }
index e6489ae..0054fb9 100644 (file)
@@ -330,17 +330,17 @@ int main(int argc, char *argv[])
 
 #ifndef NO_DESCBCM
        printf("Doing cbcm\n");
-       if ((j=des_key_sched(cbc_key,ks)) != 0)
+       if ((j=des_key_sched(&cbc_key,ks)) != 0)
                {
                printf("Key error %d\n",j);
                err=1;
                }
-       if ((j=des_key_sched(cbc2_key,ks2)) != 0)
+       if ((j=des_key_sched(&cbc2_key,ks2)) != 0)
                {
                printf("Key error %d\n",j);
                err=1;
                }
-       if ((j=des_key_sched(cbc3_key,ks3)) != 0)
+       if ((j=des_key_sched(&cbc3_key,ks3)) != 0)
                {
                printf("Key error %d\n",j);
                err=1;
@@ -352,10 +352,10 @@ int main(int argc, char *argv[])
        memcpy(iv3,cbc_iv,sizeof(cbc_iv));
        memset(iv2,'\0',sizeof iv2);
 
-       des_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,iv3,iv2,
+       des_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,&iv2,
                              DES_ENCRYPT);
        des_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,ks,ks2,ks3,
-                             iv3,iv2,DES_ENCRYPT);
+                             &iv3,&iv2,DES_ENCRYPT);
        /*      if (memcmp(cbc_out,cbc3_ok,
                (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
                {
@@ -365,7 +365,7 @@ int main(int argc, char *argv[])
        */
        memcpy(iv3,cbc_iv,sizeof(cbc_iv));
        memset(iv2,'\0',sizeof iv2);
-       des_ede3_cbcm_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,iv3,iv2,DES_DECRYPT);
+       des_ede3_cbcm_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,&iv2,DES_DECRYPT);
        if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
                {
                int n;
@@ -384,7 +384,7 @@ int main(int argc, char *argv[])
        printf("Doing ecb\n");
        for (i=0; i<NUM_TESTS; i++)
                {
-               if ((j=des_key_sched(key_data[i],ks)) != 0)
+               if ((j=des_key_sched(&key_data[i],ks)) != 0)
                        {
                        printf("Key error %2d:%d\n",i+1,j);
                        err=1;
@@ -392,8 +392,8 @@ int main(int argc, char *argv[])
                memcpy(in,plain_data[i],8);
                memset(out,0,8);
                memset(outin,0,8);
-               des_ecb_encrypt(in,out,ks,DES_ENCRYPT);
-               des_ecb_encrypt(out,outin,ks,DES_DECRYPT);
+               des_ecb_encrypt(&in,&out,ks,DES_ENCRYPT);
+               des_ecb_encrypt(&out,&outin,ks,DES_DECRYPT);
 
                if (memcmp(out,cipher_data[i],8) != 0)
                        {
@@ -414,17 +414,17 @@ int main(int argc, char *argv[])
        printf("Doing ede ecb\n");
        for (i=0; i<(NUM_TESTS-1); i++)
                {
-               if ((j=des_key_sched(key_data[i],ks)) != 0)
+               if ((j=des_key_sched(&key_data[i],ks)) != 0)
                        {
                        err=1;
                        printf("Key error %2d:%d\n",i+1,j);
                        }
-               if ((j=des_key_sched(key_data[i+1],ks2)) != 0)
+               if ((j=des_key_sched(&key_data[i+1],ks2)) != 0)
                        {
                        printf("Key error %2d:%d\n",i+2,j);
                        err=1;
                        }
-               if ((j=des_key_sched(key_data[i+2],ks3)) != 0)
+               if ((j=des_key_sched(&key_data[i+2],ks3)) != 0)
                        {
                        printf("Key error %2d:%d\n",i+3,j);
                        err=1;
@@ -432,8 +432,8 @@ int main(int argc, char *argv[])
                memcpy(in,plain_data[i],8);
                memset(out,0,8);
                memset(outin,0,8);
-               des_ecb2_encrypt(in,out,ks,ks2,DES_ENCRYPT);
-               des_ecb2_encrypt(out,outin,ks,ks2,DES_DECRYPT);
+               des_ecb2_encrypt(&in,&out,ks,ks2,DES_ENCRYPT);
+               des_ecb2_encrypt(&out,&outin,ks,ks2,DES_DECRYPT);
 
                if (memcmp(out,cipher_ecb2[i],8) != 0)
                        {
@@ -452,7 +452,7 @@ int main(int argc, char *argv[])
 #endif
 
        printf("Doing cbc\n");
-       if ((j=des_key_sched(cbc_key,ks)) != 0)
+       if ((j=des_key_sched(&cbc_key,ks)) != 0)
                {
                printf("Key error %d\n",j);
                err=1;
@@ -461,13 +461,13 @@ int main(int argc, char *argv[])
        memset(cbc_in,0,40);
        memcpy(iv3,cbc_iv,sizeof(cbc_iv));
        des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
-                        iv3,DES_ENCRYPT);
+                        &iv3,DES_ENCRYPT);
        if (memcmp(cbc_out,cbc_ok,32) != 0)
                printf("cbc_encrypt encrypt error\n");
 
        memcpy(iv3,cbc_iv,sizeof(cbc_iv));
        des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
-                        iv3,DES_DECRYPT);
+                        &iv3,DES_DECRYPT);
        if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0)
                {
                printf("cbc_encrypt decrypt error\n");
@@ -476,7 +476,7 @@ int main(int argc, char *argv[])
 
 #ifndef LIBDES_LIT
        printf("Doing desx cbc\n");
-       if ((j=des_key_sched(cbc_key,ks)) != 0)
+       if ((j=des_key_sched(&cbc_key,ks)) != 0)
                {
                printf("Key error %d\n",j);
                err=1;
@@ -485,14 +485,14 @@ int main(int argc, char *argv[])
        memset(cbc_in,0,40);
        memcpy(iv3,cbc_iv,sizeof(cbc_iv));
        des_xcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
-                        iv3,cbc2_key,cbc3_key, DES_ENCRYPT);
+                        &iv3,&cbc2_key,&cbc3_key, DES_ENCRYPT);
        if (memcmp(cbc_out,xcbc_ok,32) != 0)
                {
                printf("des_xcbc_encrypt encrypt error\n");
                }
        memcpy(iv3,cbc_iv,sizeof(cbc_iv));
        des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
-                        iv3,cbc2_key,cbc3_key, DES_DECRYPT);
+                        &iv3,&cbc2_key,&cbc3_key, DES_DECRYPT);
        if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
                {
                printf("des_xcbc_encrypt decrypt error\n");
@@ -501,17 +501,17 @@ int main(int argc, char *argv[])
 #endif
 
        printf("Doing ede cbc\n");
-       if ((j=des_key_sched(cbc_key,ks)) != 0)
+       if ((j=des_key_sched(&cbc_key,ks)) != 0)
                {
                printf("Key error %d\n",j);
                err=1;
                }
-       if ((j=des_key_sched(cbc2_key,ks2)) != 0)
+       if ((j=des_key_sched(&cbc2_key,ks2)) != 0)
                {
                printf("Key error %d\n",j);
                err=1;
                }
-       if ((j=des_key_sched(cbc3_key,ks3)) != 0)
+       if ((j=des_key_sched(&cbc3_key,ks3)) != 0)
                {
                printf("Key error %d\n",j);
                err=1;
@@ -522,9 +522,9 @@ int main(int argc, char *argv[])
        /* i=((i+7)/8)*8; */
        memcpy(iv3,cbc_iv,sizeof(cbc_iv));
 
-       des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,iv3,DES_ENCRYPT);
+       des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,DES_ENCRYPT);
        des_ede3_cbc_encrypt(&(cbc_data[16]),&(cbc_out[16]),i-16,ks,ks2,ks3,
-                            iv3,DES_ENCRYPT);
+                            &iv3,DES_ENCRYPT);
        if (memcmp(cbc_out,cbc3_ok,
                (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
                {
@@ -533,7 +533,7 @@ int main(int argc, char *argv[])
                }
 
        memcpy(iv3,cbc_iv,sizeof(cbc_iv));
-       des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,iv3,DES_DECRYPT);
+       des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT);
        if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
                {
                printf("des_ede3_cbc_encrypt decrypt error\n");
@@ -542,21 +542,21 @@ int main(int argc, char *argv[])
 
 #ifndef LIBDES_LIT
        printf("Doing pcbc\n");
-       if ((j=des_key_sched(cbc_key,ks)) != 0)
+       if ((j=des_key_sched(&cbc_key,ks)) != 0)
                {
                printf("Key error %d\n",j);
                err=1;
                }
        memset(cbc_out,0,40);
        memset(cbc_in,0,40);
-       des_pcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,cbc_iv,
-                        DES_ENCRYPT);
+       des_pcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
+                        &cbc_iv,DES_ENCRYPT);
        if (memcmp(cbc_out,pcbc_ok,32) != 0)
                {
                printf("pcbc_encrypt encrypt error\n");
                err=1;
                }
-       des_pcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,cbc_iv,
+       des_pcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,&cbc_iv,
                         DES_DECRYPT);
        if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
                {
@@ -582,7 +582,7 @@ int main(int argc, char *argv[])
        memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
        for (i=0; i<sizeof(plain); i++)
                des_cfb_encrypt(&(plain[i]),&(cfb_buf1[i]),
-                       8,1,ks,cfb_tmp,DES_ENCRYPT);
+                       8,1,ks,&cfb_tmp,DES_ENCRYPT);
        if (memcmp(cfb_cipher8,cfb_buf1,sizeof(plain)) != 0)
                {
                printf("cfb_encrypt small encrypt error\n");
@@ -592,7 +592,7 @@ int main(int argc, char *argv[])
        memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
        for (i=0; i<sizeof(plain); i++)
                des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]),
-                       8,1,ks,cfb_tmp,DES_DECRYPT);
+                       8,1,ks,&cfb_tmp,DES_DECRYPT);
        if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
                {
                printf("cfb_encrypt small decrypt error\n");
@@ -605,9 +605,9 @@ int main(int argc, char *argv[])
        printf("done\n");
 
        printf("Doing ofb\n");
-       des_key_sched(ofb_key,ks);
+       des_key_sched(&ofb_key,ks);
        memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
-       des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,ofb_tmp);
+       des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp);
        if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
                {
                printf("ofb_encrypt encrypt error\n");
@@ -620,7 +620,7 @@ ofb_buf1[8+4], ofb_cipher[8+5], ofb_cipher[8+6], ofb_cipher[8+7]);
                err=1;
                }
        memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
-       des_ofb_encrypt(ofb_buf1,ofb_buf2,64,sizeof(ofb_buf1)/8,ks,ofb_tmp);
+       des_ofb_encrypt(ofb_buf1,ofb_buf2,64,sizeof(ofb_buf1)/8,ks,&ofb_tmp);
        if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
                {
                printf("ofb_encrypt decrypt error\n");
@@ -634,14 +634,14 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
                }
 
        printf("Doing ofb64\n");
-       des_key_sched(ofb_key,ks);
+       des_key_sched(&ofb_key,ks);
        memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
        memset(ofb_buf1,0,sizeof(ofb_buf1));
        memset(ofb_buf2,0,sizeof(ofb_buf1));
        num=0;
        for (i=0; i<sizeof(plain); i++)
                {
-               des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ofb_tmp,
+               des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,&ofb_tmp,
                                  &num);
                }
        if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
@@ -651,7 +651,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
                }
        memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
        num=0;
-       des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,ofb_tmp,&num);
+       des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,&ofb_tmp,&num);
        if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
                {
                printf("ofb64_encrypt decrypt error\n");
@@ -659,7 +659,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
                }
 
        printf("Doing ede_ofb64\n");
-       des_key_sched(ofb_key,ks);
+       des_key_sched(&ofb_key,ks);
        memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
        memset(ofb_buf1,0,sizeof(ofb_buf1));
        memset(ofb_buf2,0,sizeof(ofb_buf1));
@@ -667,7 +667,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
        for (i=0; i<sizeof(plain); i++)
                {
                des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,ks,
-                                      ofb_tmp,&num);
+                                      &ofb_tmp,&num);
                }
        if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
                {
@@ -677,7 +677,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
        memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
        num=0;
        des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,
-                              ks,ks,ofb_tmp,&num);
+                              ks,ks,&ofb_tmp,&num);
        if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
                {
                printf("ede_ofb64_encrypt decrypt error\n");
@@ -685,8 +685,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
                }
 
        printf("Doing cbc_cksum\n");
-       des_key_sched(cbc_key,ks);
-       cs=des_cbc_cksum(cbc_data,cret,strlen((char *)cbc_data),ks,cbc_iv);
+       des_key_sched(&cbc_key,ks);
+       cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv);
        if (cs != cbc_cksum_ret)
                {
                printf("bad return value (%08lX), should be %08lX\n",
@@ -704,8 +704,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
           quad_cksum returns up to 4 groups of 8 bytes, this test gets it to
           produce 2 groups then treats them as 4 groups of 4 bytes.
           Ben 13 Feb 1999 */
-       cs=quad_cksum(cbc_data,(des_cblocks)qret,strlen((char *)cbc_data),2,
-                     cbc_iv);
+       cs=quad_cksum(cbc_data,(des_cblock *)qret,strlen((char *)cbc_data),2,
+                     &cbc_iv);
 
        { /* Big-endian fix */
        static DES_LONG l=1;
@@ -769,7 +769,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
                printf(" %d",i);
                des_ncbc_encrypt(&(cbc_out[i]),cbc_in,
                                 strlen((char *)cbc_data)+1,ks,
-                                cbc_iv,DES_ENCRYPT);
+                                &cbc_iv,DES_ENCRYPT);
                }
        printf("\noutput word alignment test");
        for (i=0; i<4; i++)
@@ -777,7 +777,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
                printf(" %d",i);
                des_ncbc_encrypt(cbc_out,&(cbc_in[i]),
                                 strlen((char *)cbc_data)+1,ks,
-                                cbc_iv,DES_ENCRYPT);
+                                &cbc_iv,DES_ENCRYPT);
                }
        printf("\n");
        printf("fast crypt test ");
@@ -824,9 +824,9 @@ static int cfb_test(int bits, unsigned char *cfb_cipher)
        des_key_schedule ks;
        int i,err=0;
 
-       des_key_sched(cfb_key,ks);
+       des_key_sched(&cfb_key,ks);
        memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
-       des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,cfb_tmp,
+       des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp,
                        DES_ENCRYPT);
        if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
                {
@@ -836,7 +836,7 @@ static int cfb_test(int bits, unsigned char *cfb_cipher)
                        printf("%s\n",pt(&(cfb_buf1[i])));
                }
        memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
-       des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,cfb_tmp,
+       des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,&cfb_tmp,
                        DES_DECRYPT);
        if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
                {
@@ -853,12 +853,12 @@ static int cfb64_test(unsigned char *cfb_cipher)
        des_key_schedule ks;
        int err=0,i,n;
 
-       des_key_sched(cfb_key,ks);
+       des_key_sched(&cfb_key,ks);
        memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
        n=0;
-       des_cfb64_encrypt(plain,cfb_buf1,12,ks,cfb_tmp,&n,DES_ENCRYPT);
+       des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
        des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,ks,
-                         cfb_tmp,&n,DES_ENCRYPT);
+                         &cfb_tmp,&n,DES_ENCRYPT);
        if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
                {
                err=1;
@@ -868,9 +868,9 @@ static int cfb64_test(unsigned char *cfb_cipher)
                }
        memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
        n=0;
-       des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,cfb_tmp,&n,DES_DECRYPT);
+       des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,&cfb_tmp,&n,DES_DECRYPT);
        des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
-                         sizeof(plain)-17,ks,cfb_tmp,&n,DES_DECRYPT);
+                         sizeof(plain)-17,ks,&cfb_tmp,&n,DES_DECRYPT);
        if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
                {
                err=1;
@@ -886,14 +886,14 @@ static int ede_cfb64_test(unsigned char *cfb_cipher)
        des_key_schedule ks;
        int err=0,i,n;
 
-       des_key_sched(cfb_key,ks);
+       des_key_sched(&cfb_key,ks);
        memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
        n=0;
-       des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,cfb_tmp,&n,
+       des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n,
                               DES_ENCRYPT);
        des_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
                               sizeof(plain)-12,ks,ks,ks,
-                              cfb_tmp,&n,DES_ENCRYPT);
+                              &cfb_tmp,&n,DES_ENCRYPT);
        if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
                {
                err=1;
@@ -904,10 +904,10 @@ static int ede_cfb64_test(unsigned char *cfb_cipher)
        memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
        n=0;
        des_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,ks,ks,
-                              cfb_tmp,&n,DES_DECRYPT);
+                              &cfb_tmp,&n,DES_DECRYPT);
        des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
                               sizeof(plain)-17,ks,ks,ks,
-                              cfb_tmp,&n,DES_DECRYPT);
+                              &cfb_tmp,&n,DES_DECRYPT);
        if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
                {
                err=1;
index 5ffcdd7..fb28b97 100644 (file)
 
 #include "des_locl.h"
 
-void des_ecb3_encrypt(const des_cblock in, des_cblock out,
+void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
             des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3,
             int enc)
        {
        register DES_LONG l0,l1;
        DES_LONG ll[2];
+       const unsigned char *in = &(*input)[0];
+       unsigned char *out = &(*output)[0];
 
        c2l(in,l0);
        c2l(in,l1);
index dfeb187..badb7e1 100644 (file)
@@ -103,11 +103,14 @@ const char *des_options(void)
        }
                
 
-void des_ecb_encrypt(const des_cblock in, des_cblock out, des_key_schedule ks,
+void des_ecb_encrypt(const_des_cblock *input, des_cblock *output,
+            des_key_schedule ks,
             int enc)
        {
        register DES_LONG l;
        DES_LONG ll[2];
+       const unsigned char *in = &(*input)[0];
+       unsigned char *out = &(*output)[0];
 
        c2l(in,l); ll[0]=l;
        c2l(in,l); ll[1]=l;
index 302e32e..c530624 100644 (file)
@@ -73,7 +73,8 @@ http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz
 
 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)
+            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;
@@ -81,8 +82,8 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
     DES_LONG tin[2];
     unsigned char *iv1,*iv2;
 
-    iv1=ivec1;
-    iv2=ivec2;
+    iv1 = &(*ivec1)[0];
+    iv2 = &(*ivec2)[0];
 
     if (enc)
        {
@@ -125,11 +126,11 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
            l2c(tout0,out);
            l2c(tout1,out);
            }
-       iv1=ivec1;
+       iv1=&(*ivec1)[0];
        l2c(m0,iv1);
        l2c(m1,iv1);
 
-       iv2=ivec2;
+       iv2=&(*ivec2)[0];
        l2c(tout0,iv2);
        l2c(tout1,iv2);
        }
@@ -182,11 +183,11 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
            xor1=t1;
            }
 
-       iv1=ivec1;
+       iv1=&(*ivec1)[0];
        l2c(m0,iv1);
        l2c(m1,iv1);
 
-       iv2=ivec2;
+       iv2=&(*ivec2)[0];
        l2c(xor0,iv2);
        l2c(xor1,iv2);
        }
index 51694a8..694970c 100644 (file)
@@ -85,7 +85,7 @@ OPENSSL_GLOBAL int des_rw_mode=DES_PCBC_MODE;
 
 
 int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
-                des_cblock iv)
+                des_cblock *iv)
        {
        /* data to be unencrypted */
        int net_num=0;
index 763765e..26c3903 100644 (file)
@@ -77,7 +77,7 @@
  */
 
 int des_enc_write(int fd, const void *_buf, int len,
-                 des_key_schedule sched, des_cblock iv)
+                 des_key_schedule sched, des_cblock *iv)
        {
 #ifdef _LIBC
        extern int srandom();
index db27108..db24541 100644 (file)
@@ -108,7 +108,7 @@ r=(r+7)/8;
        for (; i<8; i++)
                key[i]=0;
 
-       des_set_key(key,ks);
+       des_set_key(&key,ks);
        fcrypt_body(&(out[0]),ks,Eswap0,Eswap1);
 
        ll=out[0]; l2c(ll,b);
index 36245de..6eafe90 100644 (file)
@@ -64,7 +64,8 @@
  */
 void des_ede3_ofb64_encrypt(register const unsigned char *in,
             register unsigned char *out, long length, des_key_schedule k1,
-            des_key_schedule k2, des_key_schedule k3, des_cblock ivec, int *num)
+            des_key_schedule k2, des_key_schedule k3, des_cblock *ivec,
+            int *num)
        {
        register DES_LONG v0,v1;
        register int n= *num;
@@ -75,7 +76,7 @@ void des_ede3_ofb64_encrypt(register const unsigned char *in,
        unsigned char *iv;
        int save=0;
 
-       iv=ivec;
+       iv = &(*ivec)[0];
        c2l(iv,v0);
        c2l(iv,v1);
        ti[0]=v0;
@@ -105,7 +106,7 @@ void des_ede3_ofb64_encrypt(register const unsigned char *in,
                {
 /*             v0=ti[0];
                v1=ti[1];*/
-               iv=ivec;
+               iv = &(*ivec)[0];
                l2c(v0,iv);
                l2c(v1,iv);
                }
index 545c749..6495395 100644 (file)
@@ -64,7 +64,7 @@
  */
 void des_ofb64_encrypt(register const unsigned char *in,
             register unsigned char *out, long length, des_key_schedule schedule,
-            des_cblock ivec, int *num)
+            des_cblock *ivec, int *num)
        {
        register DES_LONG v0,v1,t;
        register int n= *num;
@@ -75,7 +75,7 @@ void des_ofb64_encrypt(register const unsigned char *in,
        unsigned char *iv;
        int save=0;
 
-       iv=ivec;
+       iv = &(*ivec)[0];
        c2l(iv,v0);
        c2l(iv,v1);
        ti[0]=v0;
@@ -100,7 +100,7 @@ void des_ofb64_encrypt(register const unsigned char *in,
                {
                v0=ti[0];
                v1=ti[1];
-               iv=ivec;
+               iv = &(*ivec)[0];
                l2c(v0,iv);
                l2c(v1,iv);
                }
index 9ee221e..a8f425a 100644 (file)
@@ -65,7 +65,7 @@
  * byte.
  */
 void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
-            long length, des_key_schedule schedule, des_cblock ivec)
+            long length, des_key_schedule schedule, des_cblock *ivec)
        {
        register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8;
        register DES_LONG mask0,mask1;
@@ -92,7 +92,7 @@ void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
                mask1=0x00000000L;
                }
 
-       iv=ivec;
+       iv = &(*ivec)[0];
        c2l(iv,v0);
        c2l(iv,v1);
        ti[0]=v0;
@@ -126,7 +126,7 @@ void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
                        v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL;
                        }
                }
-       iv=ivec;
+       iv = &(*ivec)[0];
        l2c(v0,iv);
        l2c(v1,iv);
        v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0;
index 1880217..dd69a26 100644 (file)
@@ -59,7 +59,7 @@
 #include "des_locl.h"
 
 void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
-            long length, des_key_schedule schedule, des_cblock ivec, int enc)
+            long length, des_key_schedule schedule, des_cblock *ivec, int enc)
        {
        register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1;
        DES_LONG tin[2];
@@ -68,7 +68,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
 
        in=input;
        out=output;
-       iv=ivec;
+       iv = &(*ivec)[0];
 
        if (enc)
                {
index 09797f2..6ce8c61 100644 (file)
@@ -73,8 +73,8 @@
 /* Got the value MIT uses via brute force :-) 2/10/90 eay */
 #define NOISE  ((DES_LONG)83653421L)
 
-DES_LONG des_quad_cksum(const unsigned char *input, des_cblocks output,
-            long length, int out_count, des_cblock seed)
+DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[],
+            long length, int out_count, des_cblock *seed)
        {
        DES_LONG z0,z1,t0,t1;
        int i;
@@ -83,10 +83,10 @@ DES_LONG des_quad_cksum(const unsigned char *input, des_cblocks output,
        unsigned char *lp;
 
        if (out_count < 1) out_count=1;
-       lp=output;
+       lp = &(output[0])[0];
 
-       z0=Q_B0(seed[0])|Q_B1(seed[1])|Q_B2(seed[2])|Q_B3(seed[3]);
-       z1=Q_B0(seed[4])|Q_B1(seed[5])|Q_B2(seed[6])|Q_B3(seed[7]);
+       z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]);
+       z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]);
 
        for (i=0; ((i<4)&&(i<out_count)); i++)
                {
@@ -129,7 +129,7 @@ DES_LONG des_quad_cksum(const unsigned char *input, des_cblocks output,
                                }
                        else
                                {
-                               lp=&output[(out_count-i-1)*8];
+                               lp = &(output[out_count-i-1])[0];
                                l2n(z1,lp);
                                l2n(z0,lp);
                                }
index 00db2be..fc11792 100644 (file)
 static int seed=0;
 static des_cblock init;
 
-void des_random_seed(des_cblock key)
+void des_random_seed(des_cblock *key)
        {
-       memcpy(init,key,sizeof(des_cblock));
+       memcpy(&init,key,sizeof(des_cblock));
        seed=1;
        }
 
-void des_random_key(unsigned char *ret)
+void des_random_key(des_cblock *ret)
        {
        des_key_schedule ks;
        static DES_LONG c=0;
@@ -99,13 +99,13 @@ void des_random_key(unsigned char *ret)
        t=(DES_LONG)((pid)|((c++)<<16));
        l2c(t,p);
 
-       des_set_odd_parity(data);
-       des_set_key(data,ks);
-       des_cbc_cksum(key,key,sizeof(key),ks,data);
+       des_set_odd_parity(&data);
+       des_set_key(&data,ks);
+       des_cbc_cksum(key,&key,sizeof(key),ks,&data);
 
-       des_set_odd_parity(key);
-       des_set_key(key,ks);
-       des_cbc_cksum(key,data,sizeof(key),ks,key);
+       des_set_odd_parity(&key);
+       des_set_key(&key,ks);
+       des_cbc_cksum(key,&data,sizeof(key),ks,&key);
 
        memcpy(ret,data,sizeof(key));
        memset(key,0,sizeof(key));
index 1534f79..a8ceaf0 100644 (file)
@@ -58,7 +58,7 @@
 
 #include "des_locl.h"
 
-int des_read_password(des_cblock key, const char *prompt, int verify)
+int des_read_password(des_cblock *key, const char *prompt, int verify)
        {
        int ok;
        char buf[BUFSIZ],buff[BUFSIZ];
@@ -70,7 +70,7 @@ int des_read_password(des_cblock key, const char *prompt, int verify)
        return(ok);
        }
 
-int des_read_2passwords(des_cblock key1, des_cblock key2, const char *prompt,
+int des_read_2passwords(des_cblock *key1, des_cblock *key2, const char *prompt,
             int verify)
        {
        int ok;
index e34c9af..c96c204 100644 (file)
@@ -66,16 +66,17 @@ int _des_crypt(char *buf, int len, struct desparams *desp)
        des_key_schedule ks;
        int enc;
 
-       des_set_key(desp->des_key,ks);
+       des_set_key(&desp->des_key,ks);
        enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT;
 
        if (desp->des_mode == CBC)
-               des_ecb_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,ks,
+               des_ecb_encrypt((const_des_cblock *)desp->UDES.UDES_buf,
+                               (des_cblock *)desp->UDES.UDES_buf,ks,
                                enc);
        else
                {
                des_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,
-                               len,ks,desp->des_ivec,enc);
+                               len,ks,&desp->des_ivec,enc);
 #ifdef undef
                /* len will always be %8 if called from common_crypt
                 * in secure_rpc.
index 11ef891..70b870f 100644 (file)
 #include "podd.h"
 #include "sk.h"
 
-static int check_parity(const des_cblock key);
+static int check_parity(const_des_cblock *key);
 OPENSSL_GLOBAL int des_check_key=0;
 
-void des_set_odd_parity(des_cblock key)
+void des_set_odd_parity(des_cblock *key)
        {
        int i;
 
        for (i=0; i<DES_KEY_SZ; i++)
-               key[i]=odd_parity[key[i]];
+               (*key)[i]=odd_parity[(*key)[i]];
        }
 
-static int check_parity(const des_cblock key)
+static int check_parity(const_des_cblock *key)
        {
        int i;
 
        for (i=0; i<DES_KEY_SZ; i++)
                {
-               if (key[i] != odd_parity[key[i]])
+               if ((*key)[i] != odd_parity[(*key)[i]])
                        return(0);
                }
        return(1);
@@ -120,7 +120,7 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={
        {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE},
        {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}};
 
-int des_is_weak_key(const des_cblock key)
+int des_is_weak_key(const_des_cblock *key)
        {
        int i;
 
@@ -149,7 +149,7 @@ int des_is_weak_key(const des_cblock key)
  * return -1 if key parity error,
  * return -2 if illegal weak key.
  */
-int des_set_key(const des_cblock key, des_key_schedule schedule)
+int des_set_key(const_des_cblock *key, des_key_schedule schedule)
        {
        static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
        register DES_LONG c,d,t,s,t2;
@@ -167,7 +167,7 @@ int des_set_key(const des_cblock key, des_key_schedule schedule)
                }
 
        k=(DES_LONG *)schedule;
-       in=key;
+       in = &(*key)[0];
 
        c2l(in,c);
        c2l(in,d);
@@ -228,7 +228,7 @@ int des_set_key(const des_cblock key, des_key_schedule schedule)
        return(0);
        }
 
-int des_key_sched(const des_cblock key, des_key_schedule schedule)
+int des_key_sched(const_des_cblock *key, des_key_schedule schedule)
        {
        return(des_set_key(key,schedule));
        }
index 674079b..2484145 100644 (file)
@@ -60,7 +60,7 @@
 
 OPENSSL_EXTERN int des_check_key;
 
-void des_string_to_key(const char *str, des_cblock key)
+void des_string_to_key(const char *str, des_cblock *key)
        {
        des_key_schedule ks;
        int i,length;
@@ -70,20 +70,20 @@ void des_string_to_key(const char *str, des_cblock key)
        length=strlen(str);
 #ifdef OLD_STR_TO_KEY
        for (i=0; i<length; i++)
-               key[i%8]^=(str[i]<<1);
+               (*key)[i%8]^=(str[i]<<1);
 #else /* MIT COMPATIBLE */
        for (i=0; i<length; i++)
                {
                j=str[i];
                if ((i%16) < 8)
-                       key[i%8]^=(j<<1);
+                       (*key)[i%8]^=(j<<1);
                else
                        {
                        /* Reverse the bit order 05/05/92 eay */
                        j=((j<<4)&0xf0)|((j>>4)&0x0f);
                        j=((j<<2)&0xcc)|((j>>2)&0x33);
                        j=((j<<1)&0xaa)|((j>>1)&0x55);
-                       key[7-(i%8)]^=j;
+                       (*key)[7-(i%8)]^=j;
                        }
                }
 #endif
@@ -97,7 +97,7 @@ void des_string_to_key(const char *str, des_cblock key)
        des_set_odd_parity(key);
        }
 
-void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2)
+void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2)
        {
        des_key_schedule ks;
        int i,length;
@@ -111,7 +111,7 @@ void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2)
                {
                for (i=0; i<length; i++)
                        {
-                       key2[i]=key1[i]=(str[i]<<1);
+                       (*key2)[i]=(*key1)[i]=(str[i]<<1);
                        }
                }
        else
@@ -119,9 +119,9 @@ void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2)
                for (i=0; i<length; i++)
                        {
                        if ((i/8)&1)
-                               key2[i%8]^=(str[i]<<1);
+                               (*key2)[i%8]^=(str[i]<<1);
                        else
-                               key1[i%8]^=(str[i]<<1);
+                               (*key1)[i%8]^=(str[i]<<1);
                        }
                }
 #else /* MIT COMPATIBLE */
@@ -131,9 +131,9 @@ void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2)
                if ((i%32) < 16)
                        {
                        if ((i%16) < 8)
-                               key1[i%8]^=(j<<1);
+                               (*key1)[i%8]^=(j<<1);
                        else
-                               key2[i%8]^=(j<<1);
+                               (*key2)[i%8]^=(j<<1);
                        }
                else
                        {
@@ -141,9 +141,9 @@ void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2)
                        j=((j<<2)&0xcc)|((j>>2)&0x33);
                        j=((j<<1)&0xaa)|((j>>1)&0x55);
                        if ((i%16) < 8)
-                               key1[7-(i%8)]^=j;
+                               (*key1)[7-(i%8)]^=j;
                        else
-                               key2[7-(i%8)]^=j;
+                               (*key2)[7-(i%8)]^=j;
                        }
                }
        if (length <= 8) memcpy(key2,key1,8);
index 8fa0a3e..e51b36c 100644 (file)
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: supp.c,v 1.4 1999/04/19 21:28:07 ulf Exp $
+ * $Id: supp.c,v 1.5 1999/05/16 12:25:45 bodo Exp $
  */
 
 #include <stdio.h>
 #include "des_locl.h"
 
-void des_cblock_print_file(const des_cblock cb, FILE *fp)
+void des_cblock_print_file(const_des_cblock *cb, FILE *fp)
 {
        int i;
        const unsigned int *p = (const unsigned int *)cb;
index 0d3b6a4..51e17e6 100644 (file)
@@ -79,11 +79,14 @@ static unsigned char desx_white_in2out[256]={
 0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB,
        };
 
-void des_xwhite_in2out(const des_cblock key, const des_cblock in,
-            des_cblock out)
+void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white,
+            des_cblock *out_white)
        {
        int out0,out1;
        int i;
+       const unsigned char *key = &(*des_key)[0];
+       const unsigned char *in = &(*in_white)[0];
+       unsigned char *out = &(*out_white)[0];
 
        out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0;
        out0=out1=0;
@@ -104,9 +107,9 @@ void des_xwhite_in2out(const des_cblock key, const des_cblock in,
                }
        }
 
-void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length,
-            des_key_schedule schedule, des_cblock ivec, const des_cblock inw,
-            const des_cblock outw, int enc)
+void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
+           long length, des_key_schedule schedule, des_cblock *ivec,
+           const_des_cblock *inw, const_des_cblock *outw, int enc)
        {
        register DES_LONG tin0,tin1;
        register DES_LONG tout0,tout1,xor0,xor1;
@@ -116,14 +119,14 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length,
        DES_LONG tin[2];
        unsigned char *iv;
 
-       in2=inw;
+       in2 = &(*inw)[0];
        c2l(in2,inW0);
        c2l(in2,inW1);
-       in2=outw;
+       in2 = &(*outw)[0];
        c2l(in2,outW0);
        c2l(in2,outW1);
 
-       iv=ivec;
+       iv = &(*ivec)[0];
 
        if (enc)
                {
@@ -148,7 +151,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length,
                        tout0=tin[0]^outW0; l2c(tout0,out);
                        tout1=tin[1]^outW1; l2c(tout1,out);
                        }
-               iv=ivec;
+               iv = &(*ivec)[0];
                l2c(tout0,iv);
                l2c(tout1,iv);
                }
@@ -180,7 +183,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length,
                        xor1=tin1;
                        }
 
-               iv=ivec;
+               iv = &(*ivec)[0];
                l2c(xor0,iv);
                l2c(xor1,iv);
                }
index 3c16f5a..02ccc6d 100644 (file)
@@ -107,14 +107,16 @@ EVP_CIPHER *EVP_des_ede3_cbc(void)
 static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
 
-       if (key != NULL)
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
+               des_set_key(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&deskey[1],ctx->c.des_ede.ks2);
                memcpy( (char *)ctx->c.des_ede.ks3,
                        (char *)ctx->c.des_ede.ks1,
                        sizeof(ctx->c.des_ede.ks1));
@@ -124,15 +126,17 @@ static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
 static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
 
-       if (key != NULL)
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
-               des_set_key(&(key[16]),ctx->c.des_ede.ks3);
+               des_set_key(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&deskey[1],ctx->c.des_ede.ks2);
+               des_set_key(&deskey[2],ctx->c.des_ede.ks3);
                }
        }
 
@@ -141,7 +145,7 @@ static void des_cbc_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        {
        des_ede3_cbc_encrypt(in,out,inl, ctx->c.des_ede.ks1,
                ctx->c.des_ede.ks2,ctx->c.des_ede.ks3,
-               &(ctx->iv[0]),
+               (des_cblock *) &(ctx->iv[0]),
                ctx->encrypt);
        }
 #endif
index f394fa4..9203f3f 100644 (file)
@@ -87,16 +87,20 @@ EVP_CIPHER *EVP_des_cbc(void)
 static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
-               des_set_key(key,ctx->c.des_ks);
+       if (deskey != NULL)
+               des_set_key(deskey,ctx->c.des_ks);
        }
 
 static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
             unsigned char *in, unsigned int inl)
        {
-       des_ncbc_encrypt(in,out,inl,ctx->c.des_ks,&(ctx->iv[0]),ctx->encrypt);
+       des_ncbc_encrypt(in,out,inl,ctx->c.des_ks,
+               (des_cblock *)&(ctx->iv[0]),
+               ctx->encrypt);
        }
 #endif
index 7a6a65b..bd32b07 100644 (file)
@@ -107,15 +107,17 @@ EVP_CIPHER *EVP_des_ede3_cfb(void)
 static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        ctx->num=0;
 
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
+               des_set_key(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&deskey[1],ctx->c.des_ede.ks2);
                memcpy( (char *)ctx->c.des_ede.ks3,
                        (char *)ctx->c.des_ede.ks1,
                        sizeof(ctx->c.des_ede.ks1));
@@ -125,16 +127,18 @@ static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
 static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        ctx->num=0;
 
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
-               des_set_key(&(key[16]),ctx->c.des_ede.ks3);
+               des_set_key(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&deskey[1],ctx->c.des_ede.ks2);
+               des_set_key(&deskey[2],ctx->c.des_ede.ks3);
                }
        }
 
@@ -145,6 +149,7 @@ static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
                               ctx->c.des_ede.ks1,
                               ctx->c.des_ede.ks2,
                               ctx->c.des_ede.ks3,
-                              &(ctx->iv[0]),&ctx->num,ctx->encrypt);
+                              (des_cblock*)&(ctx->iv[0]),
+                              &ctx->num,ctx->encrypt);
        }
 #endif
index 8b77430..6bdf20b 100644 (file)
@@ -87,13 +87,15 @@ EVP_CIPHER *EVP_des_cfb(void)
 static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        ctx->num=0;
 
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
-               des_set_key(key,ctx->c.des_ks);
+       if (deskey != NULL)
+               des_set_key(deskey,ctx->c.des_ks);
        }
 
 static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
@@ -102,7 +104,7 @@ static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        des_cfb64_encrypt(
                in,out,
                (long)inl, ctx->c.des_ks,
-               &(ctx->iv[0]),
+               (des_cblock *)&(ctx->iv[0]),
                &ctx->num,ctx->encrypt);
        }
 #endif
index 7bcecee..354a8b7 100644 (file)
@@ -106,10 +106,12 @@ EVP_CIPHER *EVP_des_ede3(void)
 static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
-       if (key != NULL)
+       des_cblock *deskey = (des_cblock *)key;
+
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
+               des_set_key(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&deskey[1],ctx->c.des_ede.ks2);
                memcpy( (char *)ctx->c.des_ede.ks3,
                        (char *)ctx->c.des_ede.ks1,
                        sizeof(ctx->c.des_ede.ks1));
@@ -119,11 +121,13 @@ static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
 static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
-       if (key != NULL)
+       des_cblock *deskey = (des_cblock *)key;
+
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
-               des_set_key(&(key[16]),ctx->c.des_ede.ks3);
+               des_set_key(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&deskey[1],ctx->c.des_ede.ks2);
+               des_set_key(&deskey[2],ctx->c.des_ede.ks3);
                }
        }
 
@@ -131,16 +135,24 @@ static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
             unsigned char *in, unsigned int inl)
        {
        unsigned int i;
+       des_cblock *output   /* = (des_cblock *)out */;
+       des_cblock *input    /* = (des_cblock *)in */;
 
        if (inl < 8) return;
        inl-=8;
        for (i=0; i<=inl; i+=8)
                {
-               des_ecb3_encrypt(&(in[i]),&(out[i]),
+               output = (des_cblock *)(out + i);
+               input = (des_cblock *)(in + i);
+
+               des_ecb3_encrypt(input,output,
                        ctx->c.des_ede.ks1,
                        ctx->c.des_ede.ks2,
                        ctx->c.des_ede.ks3,
                        ctx->encrypt);
+
+               /* output++; */
+               /* input++; */
                }
        }
 #endif
index 3496ca5..5fb4e64 100644 (file)
@@ -87,20 +87,32 @@ EVP_CIPHER *EVP_des_ecb(void)
 static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
-       if (key != NULL)
-               des_set_key(key,ctx->c.des_ks);
+       des_cblock *deskey = (des_cblock *)key;
+
+       if (deskey != NULL)
+               des_set_key(deskey,ctx->c.des_ks);
        }
 
 static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
             unsigned char *in, unsigned int inl)
        {
        unsigned int i;
+       des_cblock *output  /* = (des_cblock *)out */;
+       des_cblock *input   /* = (des_cblock *)in */; 
 
        if (inl < 8) return;
        inl-=8;
        for (i=0; i<=inl; i+=8)
                {
-               des_ecb_encrypt(&(in[i]),&(out[i]),ctx->c.des_ks,ctx->encrypt);
+               /* Either this ... */
+               output = (des_cblock *)(out + i);
+               input = (des_cblock *)(in + i);
+
+               des_ecb_encrypt(input,output,ctx->c.des_ks,ctx->encrypt);
+
+               /* ... or this. */
+               /* output++; */
+               /* input++; */
                }
        }
 #endif
index dba58c1..5233567 100644 (file)
@@ -107,15 +107,17 @@ EVP_CIPHER *EVP_des_ede3_ofb(void)
 static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        ctx->num=0;
 
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
+               des_set_key(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&deskey[1],ctx->c.des_ede.ks2);
                memcpy( (char *)ctx->c.des_ede.ks3,
                        (char *)ctx->c.des_ede.ks1,
                        sizeof(ctx->c.des_ede.ks1));
@@ -125,16 +127,18 @@ static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
 static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        ctx->num=0;
 
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
-               des_set_key(&(key[16]),ctx->c.des_ede.ks3);
+               des_set_key(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&deskey[1],ctx->c.des_ede.ks2);
+               des_set_key(&deskey[2],ctx->c.des_ede.ks3);
                }
        }
 
@@ -143,6 +147,6 @@ static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        {
        des_ede3_ofb64_encrypt(in,out,inl,ctx->c.des_ede.ks1,
                               ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
-                              &(ctx->iv[0]),&ctx->num);
+                              (des_cblock *)&(ctx->iv[0]),&ctx->num);
        }
 #endif
index fd75b73..398b3a0 100644 (file)
@@ -87,18 +87,21 @@ EVP_CIPHER *EVP_des_ofb(void)
 static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        ctx->num=0;
 
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
-               des_set_key(key,ctx->c.des_ks);
+       if (deskey != NULL)
+               des_set_key(deskey,ctx->c.des_ks);
        }
 
 static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
             unsigned char *in, unsigned int inl)
        {
-       des_ofb64_encrypt(in,out,inl,ctx->c.des_ks,&(ctx->iv[0]),&ctx->num);
+       des_ofb64_encrypt(in,out,inl,ctx->c.des_ks,
+               (des_cblock *)&(ctx->iv[0]),&ctx->num);
        }
 #endif
index 3238de0..3a6628a 100644 (file)
@@ -87,12 +87,14 @@ EVP_CIPHER *EVP_desx_cbc(void)
 static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.desx_cbc.ks);
+               des_set_key(deskey,ctx->c.desx_cbc.ks);
                memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8);
                memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8);
                }
@@ -102,9 +104,9 @@ static void desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
             unsigned char *in, unsigned int inl)
        {
        des_xcbc_encrypt(in,out,inl,ctx->c.desx_cbc.ks,
-               &(ctx->iv[0]),
-               &(ctx->c.desx_cbc.inw[0]),
-               &(ctx->c.desx_cbc.outw[0]),
+               (des_cblock *)&(ctx->iv[0]),
+               &ctx->c.desx_cbc.inw,
+               &ctx->c.desx_cbc.outw,
                ctx->encrypt);
        }
 #endif
index 8b5314f..4fc39ed 100644 (file)
@@ -134,12 +134,12 @@ static void mdc2_body(MDC2_CTX *c, unsigned char *in, unsigned int len)
                c->h[0]=(c->h[0]&0x9f)|0x40;
                c->hh[0]=(c->hh[0]&0x9f)|0x20;
 
-               des_set_odd_parity(c->h);
-               des_set_key(c->h,k);
+               des_set_odd_parity(&c->h);
+               des_set_key(&c->h,k);
                des_encrypt(d,k,1);
 
-               des_set_odd_parity(c->hh);
-               des_set_key(c->hh,k);
+               des_set_odd_parity(&c->hh);
+               des_set_key(&c->hh,k);
                des_encrypt(dd,k,1);
 
                ttin0=tin0^dd[0];