From 90ba7e21e1e04ba833c807bcb3dc2bdc5136a6b5 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Thu, 13 May 1999 17:10:42 +0000 Subject: [PATCH] Avoid shadowing, and a bit of constification while I'm at it. --- crypto/cast/c_cfb64.c | 17 +++++++++-------- crypto/cast/c_ecb.c | 6 +++--- crypto/cast/c_enc.c | 6 +++--- crypto/cast/c_ofb64.c | 9 +++++---- crypto/cast/cast.h | 18 ++++++++++-------- 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/crypto/cast/c_cfb64.c b/crypto/cast/c_cfb64.c index 50d234b466..095e05a563 100644 --- a/crypto/cast/c_cfb64.c +++ b/crypto/cast/c_cfb64.c @@ -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]; diff --git a/crypto/cast/c_ecb.c b/crypto/cast/c_ecb.c index 4b523ffc75..e237ebcac4 100644 --- a/crypto/cast/c_ecb.c +++ b/crypto/cast/c_ecb.c @@ -62,14 +62,14 @@ 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); diff --git a/crypto/cast/c_enc.c b/crypto/cast/c_enc.c index b62b4680b0..ef70c88981 100644 --- a/crypto/cast/c_enc.c +++ b/crypto/cast/c_enc.c @@ -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); diff --git a/crypto/cast/c_ofb64.c b/crypto/cast/c_ofb64.c index 4249870d9e..fd0469a62f 100644 --- a/crypto/cast/c_ofb64.c +++ b/crypto/cast/c_ofb64.c @@ -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); } diff --git a/crypto/cast/cast.h b/crypto/cast/cast.h index 215356dbe4..6cc5e8aa8c 100644 --- a/crypto/cast/cast.h +++ b/crypto/cast/cast.h @@ -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 } -- GitLab