summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/e_cbc_d.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/e_cbc_d.c')
-rw-r--r--src/lib/libcrypto/evp/e_cbc_d.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/src/lib/libcrypto/evp/e_cbc_d.c b/src/lib/libcrypto/evp/e_cbc_d.c
index c67706e3a0..9203f3f52d 100644
--- a/src/lib/libcrypto/evp/e_cbc_d.c
+++ b/src/lib/libcrypto/evp/e_cbc_d.c
@@ -56,21 +56,16 @@
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_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, 65static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc); 66 unsigned char *iv,int enc);
67static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 67static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl); 68 unsigned char *in, unsigned int inl);
69#else
70static void des_cbc_init_key();
71static void des_cbc_cipher();
72#endif
73
74static EVP_CIPHER d_cbc_cipher= 69static EVP_CIPHER d_cbc_cipher=
75 { 70 {
76 NID_des_cbc, 71 NID_des_cbc,
@@ -80,37 +75,32 @@ static EVP_CIPHER d_cbc_cipher=
80 NULL, 75 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ 76 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), 77 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_get_asn1_iv,
84 EVP_CIPHER_set_asn1_iv, 78 EVP_CIPHER_set_asn1_iv,
79 EVP_CIPHER_get_asn1_iv,
85 }; 80 };
86 81
87EVP_CIPHER *EVP_des_cbc() 82EVP_CIPHER *EVP_des_cbc(void)
88 { 83 {
89 return(&d_cbc_cipher); 84 return(&d_cbc_cipher);
90 } 85 }
91 86
92static void des_cbc_init_key(ctx,key,iv,enc) 87static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
93EVP_CIPHER_CTX *ctx; 88 unsigned char *iv, int enc)
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 { 89 {
90 des_cblock *deskey = (des_cblock *)key;
91
98 if (iv != NULL) 92 if (iv != NULL)
99 memcpy(&(ctx->oiv[0]),iv,8); 93 memcpy(&(ctx->oiv[0]),iv,8);
100 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 94 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
101 if (key != NULL) 95 if (deskey != NULL)
102 des_set_key((des_cblock *)key,ctx->c.des_ks); 96 des_set_key(deskey,ctx->c.des_ks);
103 } 97 }
104 98
105static void des_cbc_cipher(ctx,out,in,inl) 99static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
106EVP_CIPHER_CTX *ctx; 100 unsigned char *in, unsigned int inl)
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 { 101 {
111 des_ncbc_encrypt( 102 des_ncbc_encrypt(in,out,inl,ctx->c.des_ks,
112 (des_cblock *)in,(des_cblock *)out,
113 (long)inl, ctx->c.des_ks,
114 (des_cblock *)&(ctx->iv[0]), 103 (des_cblock *)&(ctx->iv[0]),
115 ctx->encrypt); 104 ctx->encrypt);
116 } 105 }
106#endif