Introduce "BIO pairs", which (when finished) will relay data
[openssl.git] / crypto / evp / e_ofb_3d.c
index dba58c118af77815f2ae7f405ca5d3aa804b4b22..5233567c0cc098a3edac01014f359341097b0939 100644 (file)
@@ -107,15 +107,17 @@ EVP_CIPHER *EVP_des_ede3_ofb(void)
 static void des_ede_ofb_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(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&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));
@@ -125,16 +127,18 @@ static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
 static void des_ede3_ofb_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(&deskey[0],ctx->c.des_ede.ks1);
+               des_set_key(&deskey[1],ctx->c.des_ede.ks2);
+               des_set_key(&deskey[2],ctx->c.des_ede.ks3);
                }
        }
 
@@ -143,6 +147,6 @@ static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        {
        des_ede3_ofb64_encrypt(in,out,inl,ctx->c.des_ede.ks1,
                               ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
-                              &(ctx->iv[0]),&ctx->num);
+                              (des_cblock *)&(ctx->iv[0]),&ctx->num);
        }
 #endif