Commit edf0bfb5 authored by Bodo Möller's avatar Bodo Möller
Browse files

Change type of various DES function arguments from des_cblock

(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).
parent e186bf96
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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);
+5 −2
Original line number Diff line number Diff line
@@ -58,12 +58,15 @@

#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);
+2 −2
Original line number Diff line number Diff line
@@ -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)
		{
+6 −6
Original line number Diff line number Diff line
@@ -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];
+7 −7
Original line number Diff line number Diff line
@@ -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];
Loading