61 #ifndef OPENSSL_NO_DES
71 const unsigned char *iv,
int enc);
74 const unsigned char *iv,
int enc);
85 #define data(ctx) ((DES_EDE_KEY *)(ctx)->cipher_data)
89 static int des_ede_ecb_cipher(
EVP_CIPHER_CTX *ctx,
unsigned char *out,
90 const unsigned char *in,
size_t inl)
101 static int des_ede_ofb_cipher(
EVP_CIPHER_CTX *ctx,
unsigned char *out,
102 const unsigned char *in,
size_t inl)
121 static int des_ede_cbc_cipher(
EVP_CIPHER_CTX *ctx,
unsigned char *out,
122 const unsigned char *in,
size_t inl)
128 printf(
"des_ede_cbc_cipher(ctx=%lx, buflen=%d)\n", ctx, ctx->
buf_len);
131 printf(
"%02X",ctx->
iv[i]);
135 if (inl>=EVP_MAXCHUNK)
151 static int des_ede_cfb64_cipher(
EVP_CIPHER_CTX *ctx,
unsigned char *out,
152 const unsigned char *in,
size_t inl)
154 if (inl>=EVP_MAXCHUNK)
172 static int des_ede3_cfb1_cipher(
EVP_CIPHER_CTX *ctx,
unsigned char *out,
173 const unsigned char *in,
size_t inl)
176 unsigned char c[1],d[1];
178 for(n=0 ; n < inl ; ++n)
180 c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0;
184 out[n/8]=(out[n/8]&~(0x80 >> (
unsigned int)(n%8))) |
185 ((d[0]&0x80) >> (
unsigned int)(n%8));
191 static int des_ede3_cfb8_cipher(
EVP_CIPHER_CTX *ctx,
unsigned char *out,
192 const unsigned char *in,
size_t inl)
194 while (inl>=EVP_MAXCHUNK)
216 #define des_ede3_cfb64_cipher des_ede_cfb64_cipher
217 #define des_ede3_ofb_cipher des_ede_ofb_cipher
218 #define des_ede3_cbc_cipher des_ede_cbc_cipher
219 #define des_ede3_ecb_cipher des_ede_ecb_cipher
234 EVP_CIPH_RAND_KEY, des_ede3_init_key,NULL,
235 EVP_CIPHER_set_asn1_iv,
236 EVP_CIPHER_get_asn1_iv,
240 const
unsigned char *iv,
int enc)
243 #ifdef EVP_CHECK_DES_KEY
251 memcpy(&
data(ctx)->ks3,&
data(ctx)->ks1,
252 sizeof(
data(ctx)->ks1));
257 const unsigned char *iv,
int enc)
263 printf(
"des_ede3_init_key(ctx=%lx)\n", ctx);
265 for(i=0;i<24;i++) printf(
"%02X",key[i]); printf(
"\n");
267 for(i=0;i<8;i++) printf(
"%02X",iv[i]); printf(
"\n");
271 #ifdef EVP_CHECK_DES_KEY
313 return &des_ede3_ecb;