Further comment changes for reformat
[openssl.git] / crypto / des / set_key.c
index 683916e71b010de076820c7bec701ce3a3e52893..b621c9a6deb75af3d158d5739d6cf3dde15768b0 100644 (file)
  * [including the GNU Public Licence.]
  */
 
-/* set_key.c v 1.4 eay 24/9/91
+/*-
+ * set_key.c v 1.4 eay 24/9/91
  * 1.4 Speed up by 400% :-)
  * 1.3 added register declarations.
  * 1.2 unrolled make_key_sched a bit more
  * 1.1 added norm_expand_bits
  * 1.0 First working version
  */
+#include <openssl/crypto.h>
 #include "des_locl.h"
 
-OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key);   /* defaults to false */
+OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key,0)  /* defaults to false */
 
 static const unsigned char odd_parity[256]={
   1,  1,  2,  2,  4,  4,  7,  7,  8,  8, 11, 11, 13, 13, 14, 14,
@@ -87,7 +89,7 @@ static const unsigned char odd_parity[256]={
 
 void DES_set_odd_parity(DES_cblock *key)
        {
-       int i;
+       unsigned int i;
 
        for (i=0; i<DES_KEY_SZ; i++)
                (*key)[i]=odd_parity[(*key)[i]];
@@ -95,7 +97,7 @@ void DES_set_odd_parity(DES_cblock *key)
 
 int DES_check_key_parity(const_DES_cblock *key)
        {
-       int i;
+       unsigned int i;
 
        for (i=0; i<DES_KEY_SZ; i++)
                {
@@ -105,7 +107,8 @@ int DES_check_key_parity(const_DES_cblock *key)
        return(1);
        }
 
-/* Weak and semi week keys as take from
+/*-
+ * Weak and semi week keys as take from
  * %A D.W. Davies
  * %A W.L. Price
  * %T Security for Computer Networks
@@ -115,7 +118,7 @@ int DES_check_key_parity(const_DES_cblock *key)
  * (and actual cblock values).
  */
 #define NUM_WEAK_KEY   16
-static DES_cblock weak_keys[NUM_WEAK_KEY]={
+static const DES_cblock weak_keys[NUM_WEAK_KEY]={
        /* weak keys */
        {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
        {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE},
@@ -150,7 +153,8 @@ int DES_is_weak_key(const_DES_cblock *key)
        return(0);
        }
 
-/* NOW DEFINED IN des_local.h
+/*-
+ * NOW DEFINED IN des_local.h
  * See ecb_encrypt.c for a pseudo description of these macros. 
  * #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
  *     (b)^=(t),\
@@ -320,7 +324,8 @@ int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule)
                }
        }
 
-/* return 0 if key parity is odd (correct),
+/*-
+ * return 0 if key parity is odd (correct),
  * return -1 if key parity error,
  * return -2 if illegal weak key.
  */
@@ -335,14 +340,21 @@ int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule)
        }
 
 void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
+#ifdef OPENSSL_FIPS
+       {
+       fips_cipher_abort(DES);
+       private_DES_set_key_unchecked(key, schedule);
+       }
+void private_DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
+#endif
        {
-       static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
+       static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
        register DES_LONG c,d,t,s,t2;
        register const unsigned char *in;
        register DES_LONG *k;
        register int i;
 
-#if OPENBSD_DEV_CRYPTO
+#ifdef OPENBSD_DEV_CRYPTO
        memcpy(schedule->key,key,sizeof schedule->key);
        schedule->session=NULL;
 #endif
@@ -398,7 +410,7 @@ int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule)
        {
        return(DES_set_key(key,schedule));
        }
-/*
+/*-
 #undef des_fixup_key_parity
 void des_fixup_key_parity(des_cblock *key)
        {