summaryrefslogtreecommitdiffstats
path: root/crypto/des/str2key.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>1999-05-16 12:26:16 +0000
committerBodo Möller <bodo@openssl.org>1999-05-16 12:26:16 +0000
commitedf0bfb52b46bb9c8bf44e9c486be60c7087618c (patch)
tree6ad2135e6ba0e639b8938729fd55696605913011 /crypto/des/str2key.c
parente186bf96b433b85fc3a87b3ca2fd6c1929212d72 (diff)
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).
Diffstat (limited to 'crypto/des/str2key.c')
-rw-r--r--crypto/des/str2key.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/crypto/des/str2key.c b/crypto/des/str2key.c
index 674079b14b..24841452f1 100644
--- a/crypto/des/str2key.c
+++ b/crypto/des/str2key.c
@@ -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);