提交 90ba7e21 编写于 作者: B Ben Laurie

Avoid shadowing, and a bit of constification while I'm at it.

上级 224551f7
...@@ -64,8 +64,9 @@ ...@@ -64,8 +64,9 @@
* 64bit block we have used is contained in *num; * 64bit block we have used is contained in *num;
*/ */
void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
CAST_KEY *schedule, unsigned char *ivec, int *num, int encrypt) long length, CAST_KEY *schedule, unsigned char *ivec,
int *num, int _encrypt)
{ {
register CAST_LONG v0,v1,t; register CAST_LONG v0,v1,t;
register int n= *num; register int n= *num;
...@@ -73,8 +74,8 @@ void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, ...@@ -73,8 +74,8 @@ void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
CAST_LONG ti[2]; CAST_LONG ti[2];
unsigned char *iv,c,cc; unsigned char *iv,c,cc;
iv=(unsigned char *)ivec; iv=ivec;
if (encrypt) if (_encrypt)
{ {
while (l--) while (l--)
{ {
...@@ -83,10 +84,10 @@ void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, ...@@ -83,10 +84,10 @@ void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
n2l(iv,v0); ti[0]=v0; n2l(iv,v0); ti[0]=v0;
n2l(iv,v1); ti[1]=v1; n2l(iv,v1); ti[1]=v1;
CAST_encrypt((CAST_LONG *)ti,schedule); CAST_encrypt((CAST_LONG *)ti,schedule);
iv=(unsigned char *)ivec; iv=ivec;
t=ti[0]; l2n(t,iv); t=ti[0]; l2n(t,iv);
t=ti[1]; l2n(t,iv); t=ti[1]; l2n(t,iv);
iv=(unsigned char *)ivec; iv=ivec;
} }
c= *(in++)^iv[n]; c= *(in++)^iv[n];
*(out++)=c; *(out++)=c;
...@@ -103,10 +104,10 @@ void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, ...@@ -103,10 +104,10 @@ void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
n2l(iv,v0); ti[0]=v0; n2l(iv,v0); ti[0]=v0;
n2l(iv,v1); ti[1]=v1; n2l(iv,v1); ti[1]=v1;
CAST_encrypt((CAST_LONG *)ti,schedule); CAST_encrypt((CAST_LONG *)ti,schedule);
iv=(unsigned char *)ivec; iv=ivec;
t=ti[0]; l2n(t,iv); t=ti[0]; l2n(t,iv);
t=ti[1]; l2n(t,iv); t=ti[1]; l2n(t,iv);
iv=(unsigned char *)ivec; iv=ivec;
} }
cc= *(in++); cc= *(in++);
c=iv[n]; c=iv[n];
......
...@@ -62,14 +62,14 @@ ...@@ -62,14 +62,14 @@
char *CAST_version="CAST" OPENSSL_VERSION_PTEXT; char *CAST_version="CAST" OPENSSL_VERSION_PTEXT;
void CAST_ecb_encrypt(unsigned char *in, unsigned char *out, CAST_KEY *ks, void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
int encrypt) CAST_KEY *ks, int _encrypt)
{ {
CAST_LONG l,d[2]; CAST_LONG l,d[2];
n2l(in,l); d[0]=l; n2l(in,l); d[0]=l;
n2l(in,l); d[1]=l; n2l(in,l); d[1]=l;
if (encrypt) if (_encrypt)
CAST_encrypt(d,ks); CAST_encrypt(d,ks);
else else
CAST_decrypt(d,ks); CAST_decrypt(d,ks);
......
...@@ -123,15 +123,15 @@ void CAST_decrypt(CAST_LONG *data, CAST_KEY *key) ...@@ -123,15 +123,15 @@ void CAST_decrypt(CAST_LONG *data, CAST_KEY *key)
data[0]=r&0xffffffffL; data[0]=r&0xffffffffL;
} }
void CAST_cbc_encrypt(unsigned char *in, unsigned char *out, long length, void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
CAST_KEY *ks, unsigned char *iv, int encrypt) CAST_KEY *ks, unsigned char *iv, int _encrypt)
{ {
register CAST_LONG tin0,tin1; register CAST_LONG tin0,tin1;
register CAST_LONG tout0,tout1,xor0,xor1; register CAST_LONG tout0,tout1,xor0,xor1;
register long l=length; register long l=length;
CAST_LONG tin[2]; CAST_LONG tin[2];
if (encrypt) if (_encrypt)
{ {
n2l(iv,tout0); n2l(iv,tout0);
n2l(iv,tout1); n2l(iv,tout1);
......
...@@ -63,8 +63,9 @@ ...@@ -63,8 +63,9 @@
* used. The extra state information to record how much of the * used. The extra state information to record how much of the
* 64bit block we have used is contained in *num; * 64bit block we have used is contained in *num;
*/ */
void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
CAST_KEY *schedule, unsigned char *ivec, int *num) long length, CAST_KEY *schedule, unsigned char *ivec,
int *num)
{ {
register CAST_LONG v0,v1,t; register CAST_LONG v0,v1,t;
register int n= *num; register int n= *num;
...@@ -75,7 +76,7 @@ void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, ...@@ -75,7 +76,7 @@ void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
unsigned char *iv; unsigned char *iv;
int save=0; int save=0;
iv=(unsigned char *)ivec; iv=ivec;
n2l(iv,v0); n2l(iv,v0);
n2l(iv,v1); n2l(iv,v1);
ti[0]=v0; ti[0]=v0;
...@@ -100,7 +101,7 @@ void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, ...@@ -100,7 +101,7 @@ void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
{ {
v0=ti[0]; v0=ti[0];
v1=ti[1]; v1=ti[1];
iv=(unsigned char *)ivec; iv=ivec;
l2n(v0,iv); l2n(v0,iv);
l2n(v1,iv); l2n(v1,iv);
} }
......
...@@ -83,16 +83,18 @@ typedef struct cast_key_st ...@@ -83,16 +83,18 @@ typedef struct cast_key_st
void CAST_set_key(CAST_KEY *key, int len, unsigned char *data); 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, void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key,
int enc); int enc);
void CAST_encrypt(CAST_LONG *data,CAST_KEY *key); void CAST_encrypt(CAST_LONG *data,CAST_KEY *key);
void CAST_decrypt(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, void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
CAST_KEY *ks, unsigned char *iv, int enc); CAST_KEY *ks, unsigned char *iv, int enc);
void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
CAST_KEY *schedule, unsigned char *ivec, int *num, int enc); long length, CAST_KEY *schedule, unsigned char *ivec,
void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, int *num, int enc);
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);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册