summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/e_cfb_3d.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/e_cfb_3d.c')
-rw-r--r--src/lib/libcrypto/evp/e_cfb_3d.c69
1 files changed, 29 insertions, 40 deletions
diff --git a/src/lib/libcrypto/evp/e_cfb_3d.c b/src/lib/libcrypto/evp/e_cfb_3d.c
index e7e3419411..bd32b072e2 100644
--- a/src/lib/libcrypto/evp/e_cfb_3d.c
+++ b/src/lib/libcrypto/evp/e_cfb_3d.c
@@ -56,24 +56,18 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DES
59#include <stdio.h> 60#include <stdio.h>
60#include "cryptlib.h" 61#include "cryptlib.h"
61#include "evp.h" 62#include <openssl/evp.h>
62#include "objects.h" 63#include <openssl/objects.h>
63 64
64#ifndef NOPROTO
65static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, 65static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc); 66 unsigned char *iv,int enc);
67static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, 67static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc); 68 unsigned char *iv,int enc);
69static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 69static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl); 70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_cfb_init_key();
73static void des_ede3_cfb_init_key();
74static void des_ede_cfb_cipher();
75#endif
76
77static EVP_CIPHER d_ede_cfb_cipher2= 71static EVP_CIPHER d_ede_cfb_cipher2=
78 { 72 {
79 NID_des_ede_cfb64, 73 NID_des_ede_cfb64,
@@ -100,67 +94,62 @@ static EVP_CIPHER d_ede3_cfb_cipher3=
100 EVP_CIPHER_get_asn1_iv, 94 EVP_CIPHER_get_asn1_iv,
101 }; 95 };
102 96
103EVP_CIPHER *EVP_des_ede_cfb() 97EVP_CIPHER *EVP_des_ede_cfb(void)
104 { 98 {
105 return(&d_ede_cfb_cipher2); 99 return(&d_ede_cfb_cipher2);
106 } 100 }
107 101
108EVP_CIPHER *EVP_des_ede3_cfb() 102EVP_CIPHER *EVP_des_ede3_cfb(void)
109 { 103 {
110 return(&d_ede3_cfb_cipher3); 104 return(&d_ede3_cfb_cipher3);
111 } 105 }
112 106
113static void des_ede_cfb_init_key(ctx,key,iv,enc) 107static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
114EVP_CIPHER_CTX *ctx; 108 unsigned char *iv, int enc)
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 { 109 {
110 des_cblock *deskey = (des_cblock *)key;
111
119 ctx->num=0; 112 ctx->num=0;
120 113
121 if (iv != NULL) 114 if (iv != NULL)
122 memcpy(&(ctx->oiv[0]),iv,8); 115 memcpy(&(ctx->oiv[0]),iv,8);
123 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
124 if (key != NULL) 117 if (deskey != NULL)
125 { 118 {
126 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); 119 des_set_key(&deskey[0],ctx->c.des_ede.ks1);
127 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); 120 des_set_key(&deskey[1],ctx->c.des_ede.ks2);
128 memcpy( (char *)ctx->c.des_ede.ks3, 121 memcpy( (char *)ctx->c.des_ede.ks3,
129 (char *)ctx->c.des_ede.ks1, 122 (char *)ctx->c.des_ede.ks1,
130 sizeof(ctx->c.des_ede.ks1)); 123 sizeof(ctx->c.des_ede.ks1));
131 } 124 }
132 } 125 }
133 126
134static void des_ede3_cfb_init_key(ctx,key,iv,enc) 127static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
135EVP_CIPHER_CTX *ctx; 128 unsigned char *iv, int enc)
136unsigned char *key;
137unsigned char *iv;
138int enc;
139 { 129 {
130 des_cblock *deskey = (des_cblock *)key;
131
140 ctx->num=0; 132 ctx->num=0;
141 133
142 if (iv != NULL) 134 if (iv != NULL)
143 memcpy(&(ctx->oiv[0]),iv,8); 135 memcpy(&(ctx->oiv[0]),iv,8);
144 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
145 if (key != NULL) 137 if (deskey != NULL)
146 { 138 {
147 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); 139 des_set_key(&deskey[0],ctx->c.des_ede.ks1);
148 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); 140 des_set_key(&deskey[1],ctx->c.des_ede.ks2);
149 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); 141 des_set_key(&deskey[2],ctx->c.des_ede.ks3);
150 } 142 }
151 } 143 }
152 144
153static void des_ede_cfb_cipher(ctx,out,in,inl) 145static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
154EVP_CIPHER_CTX *ctx; 146 unsigned char *in, unsigned int inl)
155unsigned char *out;
156unsigned char *in;
157unsigned int inl;
158 { 147 {
159 des_ede3_cfb64_encrypt( 148 des_ede3_cfb64_encrypt(in,out,(long)inl,
160 in,out,(long)inl, 149 ctx->c.des_ede.ks1,
161 ctx->c.des_ede.ks1, 150 ctx->c.des_ede.ks2,
162 ctx->c.des_ede.ks2, 151 ctx->c.des_ede.ks3,
163 ctx->c.des_ede.ks3, 152 (des_cblock*)&(ctx->iv[0]),
164 (des_cblock *)&(ctx->iv[0]), 153 &ctx->num,ctx->encrypt);
165 &ctx->num,ctx->encrypt);
166 } 154 }
155#endif