Declare BN_pseudo_rand().
[openssl.git] / crypto / evp / e_cfb_3d.c
index a0321fa1330923ff5706475211713ce354a36a2f..b364bd4e318d44c5fc9745fe6cdf5d081d4cb4f4 100644 (file)
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DES
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
 #include <openssl/objects.h>
 
-#ifndef NOPROTO
 static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
        unsigned char *iv,int enc);
 static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
        unsigned char *iv,int enc);
 static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        unsigned char *in, unsigned int inl);
-#else
-static void des_ede_cfb_init_key();
-static void des_ede3_cfb_init_key();
-static void des_ede_cfb_cipher();
-#endif
-
 static EVP_CIPHER d_ede_cfb_cipher2=
        {
        NID_des_ede_cfb64,
@@ -113,15 +107,17 @@ EVP_CIPHER *EVP_des_ede3_cfb(void)
 static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        ctx->num=0;
 
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
+               des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
                memcpy( (char *)ctx->c.des_ede.ks3,
                        (char *)ctx->c.des_ede.ks1,
                        sizeof(ctx->c.des_ede.ks1));
@@ -131,16 +127,18 @@ static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
 static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
+       des_cblock *deskey = (des_cblock *)key;
+
        ctx->num=0;
 
        if (iv != NULL)
                memcpy(&(ctx->oiv[0]),iv,8);
        memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
+       if (deskey != NULL)
                {
-               des_set_key(key,ctx->c.des_ede.ks1);
-               des_set_key(&(key[8]),ctx->c.des_ede.ks2);
-               des_set_key(&(key[16]),ctx->c.des_ede.ks3);
+               des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
+               des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
                }
        }
 
@@ -151,5 +149,7 @@ static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
                               ctx->c.des_ede.ks1,
                               ctx->c.des_ede.ks2,
                               ctx->c.des_ede.ks3,
-                              &(ctx->iv[0]),&ctx->num,ctx->encrypt);
+                              (des_cblock*)&(ctx->iv[0]),
+                              &ctx->num,ctx->encrypt);
        }
+#endif