Avoid shadowing, and a bit of constification while I'm at it.
authorBen Laurie <ben@openssl.org>
Thu, 13 May 1999 17:10:42 +0000 (17:10 +0000)
committerBen Laurie <ben@openssl.org>
Thu, 13 May 1999 17:10:42 +0000 (17:10 +0000)
crypto/cast/c_cfb64.c
crypto/cast/c_ecb.c
crypto/cast/c_enc.c
crypto/cast/c_ofb64.c
crypto/cast/cast.h

index 50d234b4667a6a3b4aaad1bee8715f13c9cee3c6..095e05a563a42ceb3fd88f0fb61ce258f90fdb1f 100644 (file)
@@ -64,8 +64,9 @@
  * 64bit block we have used is contained in *num;
  */
 
-void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
-            CAST_KEY *schedule, unsigned char *ivec, int *num, int encrypt)
+void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
+                       long length, CAST_KEY *schedule, unsigned char *ivec,
+                       int *num, int _encrypt)
        {
        register CAST_LONG v0,v1,t;
        register int n= *num;
@@ -73,8 +74,8 @@ void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
        CAST_LONG ti[2];
        unsigned char *iv,c,cc;
 
-       iv=(unsigned char *)ivec;
-       if (encrypt)
+       iv=ivec;
+       if (_encrypt)
                {
                while (l--)
                        {
@@ -83,10 +84,10 @@ void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
                                n2l(iv,v0); ti[0]=v0;
                                n2l(iv,v1); ti[1]=v1;
                                CAST_encrypt((CAST_LONG *)ti,schedule);
-                               iv=(unsigned char *)ivec;
+                               iv=ivec;
                                t=ti[0]; l2n(t,iv);
                                t=ti[1]; l2n(t,iv);
-                               iv=(unsigned char *)ivec;
+                               iv=ivec;
                                }
                        c= *(in++)^iv[n];
                        *(out++)=c;
@@ -103,10 +104,10 @@ void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
                                n2l(iv,v0); ti[0]=v0;
                                n2l(iv,v1); ti[1]=v1;
                                CAST_encrypt((CAST_LONG *)ti,schedule);
-                               iv=(unsigned char *)ivec;
+                               iv=ivec;
                                t=ti[0]; l2n(t,iv);
                                t=ti[1]; l2n(t,iv);
-                               iv=(unsigned char *)ivec;
+                               iv=ivec;
                                }
                        cc= *(in++);
                        c=iv[n];
index 4b523ffc7576e2be783d35c56ff2c668634747a9..e237ebcac43356fcb91950ad7b7d85272abfb0ea 100644 (file)
 
 char *CAST_version="CAST" OPENSSL_VERSION_PTEXT;
 
-void CAST_ecb_encrypt(unsigned char *in, unsigned char *out, CAST_KEY *ks,
-            int encrypt)
+void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
+                     CAST_KEY *ks, int _encrypt)
        {
        CAST_LONG l,d[2];
 
        n2l(in,l); d[0]=l;
        n2l(in,l); d[1]=l;
-       if (encrypt)
+       if (_encrypt)
                CAST_encrypt(d,ks);
        else
                CAST_decrypt(d,ks);
index b62b4680b0c0d3f877da075207beeece535a1487..ef70c8898121642febcce7162c8aa67a0ca06ccb 100644 (file)
@@ -123,15 +123,15 @@ void CAST_decrypt(CAST_LONG *data, CAST_KEY *key)
        data[0]=r&0xffffffffL;
        }
 
-void CAST_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
-            CAST_KEY *ks, unsigned char *iv, int encrypt)
+void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
+            CAST_KEY *ks, unsigned char *iv, int _encrypt)
        {
        register CAST_LONG tin0,tin1;
        register CAST_LONG tout0,tout1,xor0,xor1;
        register long l=length;
        CAST_LONG tin[2];
 
-       if (encrypt)
+       if (_encrypt)
                {
                n2l(iv,tout0);
                n2l(iv,tout1);
index 4249870d9e34e6a7abcca751a7888f6a52d267a5..fd0469a62faa73def09d3516bb66d5813d216229 100644 (file)
@@ -63,8 +63,9 @@
  * used.  The extra state information to record how much of the
  * 64bit block we have used is contained in *num;
  */
-void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
-            CAST_KEY *schedule, unsigned char *ivec, int *num)
+void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
+                       long length, CAST_KEY *schedule, unsigned char *ivec,
+                       int *num)
        {
        register CAST_LONG v0,v1,t;
        register int n= *num;
@@ -75,7 +76,7 @@ void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
        unsigned char *iv;
        int save=0;
 
-       iv=(unsigned char *)ivec;
+       iv=ivec;
        n2l(iv,v0);
        n2l(iv,v1);
        ti[0]=v0;
@@ -100,7 +101,7 @@ void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
                {
                v0=ti[0];
                v1=ti[1];
-               iv=(unsigned char *)ivec;
+               iv=ivec;
                l2n(v0,iv);
                l2n(v1,iv);
                }
index 215356dbe4aad46ec030f51585f9fe889632be32..6cc5e8aa8cf046c125032e38ef7a5c4b3647bbe3 100644 (file)
@@ -83,16 +83,18 @@ typedef struct cast_key_st
 
  
 void CAST_set_key(CAST_KEY *key, int len, unsigned char *data);
-void CAST_ecb_encrypt(unsigned char *in,unsigned char *out,CAST_KEY *key,
-       int enc);
+void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key,
+                     int enc);
 void CAST_encrypt(CAST_LONG *data,CAST_KEY *key);
 void CAST_decrypt(CAST_LONG *data,CAST_KEY *key);
-void CAST_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
-       CAST_KEY *ks, unsigned char *iv, int enc);
-void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
-       CAST_KEY *schedule, unsigned char *ivec, int *num, int enc);
-void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
-       CAST_KEY *schedule, unsigned char *ivec, int *num);
+void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
+                     CAST_KEY *ks, unsigned char *iv, int enc);
+void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
+                       long length, CAST_KEY *schedule, unsigned char *ivec,
+                       int *num, int enc);
+void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, 
+                       long length, CAST_KEY *schedule, unsigned char *ivec,
+                       int *num);
 
 #ifdef  __cplusplus
 }