summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/e_xcbc_d.c
diff options
context:
space:
mode:
authorbeck <>2002-05-15 02:29:21 +0000
committerbeck <>2002-05-15 02:29:21 +0000
commitb64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch)
treefa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/evp/e_xcbc_d.c
parente471e1ea98d673597b182ea85f29e30c97cd08b5 (diff)
downloadopenbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/evp/e_xcbc_d.c')
-rw-r--r--src/lib/libcrypto/evp/e_xcbc_d.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/lib/libcrypto/evp/e_xcbc_d.c b/src/lib/libcrypto/evp/e_xcbc_d.c
index e5b15acc7d..a6f849e93d 100644
--- a/src/lib/libcrypto/evp/e_xcbc_d.c
+++ b/src/lib/libcrypto/evp/e_xcbc_d.c
@@ -56,17 +56,29 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DES 59#ifndef OPENSSL_NO_DES
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/des.h>
64 65
65static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 66static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
66 const unsigned char *iv,int enc); 67 const unsigned char *iv,int enc);
67static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 68static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 const unsigned char *in, unsigned int inl); 69 const unsigned char *in, unsigned int inl);
69static EVP_CIPHER d_xcbc_cipher= 70
71
72typedef struct
73 {
74 DES_key_schedule ks;/* key schedule */
75 DES_cblock inw;
76 DES_cblock outw;
77 } DESX_CBC_KEY;
78
79#define data(ctx) ((DESX_CBC_KEY *)(ctx)->cipher_data)
80
81static const EVP_CIPHER d_xcbc_cipher=
70 { 82 {
71 NID_desx_cbc, 83 NID_desx_cbc,
72 8,24,8, 84 8,24,8,
@@ -74,14 +86,13 @@ static EVP_CIPHER d_xcbc_cipher=
74 desx_cbc_init_key, 86 desx_cbc_init_key,
75 desx_cbc_cipher, 87 desx_cbc_cipher,
76 NULL, 88 NULL,
77 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ 89 sizeof(DESX_CBC_KEY),
78 sizeof((((EVP_CIPHER_CTX *)NULL)->c.desx_cbc)),
79 EVP_CIPHER_set_asn1_iv, 90 EVP_CIPHER_set_asn1_iv,
80 EVP_CIPHER_get_asn1_iv, 91 EVP_CIPHER_get_asn1_iv,
81 NULL 92 NULL
82 }; 93 };
83 94
84EVP_CIPHER *EVP_desx_cbc(void) 95const EVP_CIPHER *EVP_desx_cbc(void)
85 { 96 {
86 return(&d_xcbc_cipher); 97 return(&d_xcbc_cipher);
87 } 98 }
@@ -89,11 +100,11 @@ EVP_CIPHER *EVP_desx_cbc(void)
89static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 100static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
90 const unsigned char *iv, int enc) 101 const unsigned char *iv, int enc)
91 { 102 {
92 des_cblock *deskey = (des_cblock *)key; 103 DES_cblock *deskey = (DES_cblock *)key;
93 104
94 des_set_key_unchecked(deskey,ctx->c.desx_cbc.ks); 105 DES_set_key_unchecked(deskey,&data(ctx)->ks);
95 memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); 106 memcpy(&data(ctx)->inw[0],&key[8],8);
96 memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); 107 memcpy(&data(ctx)->outw[0],&key[16],8);
97 108
98 return 1; 109 return 1;
99 } 110 }
@@ -101,11 +112,11 @@ static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
101static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 112static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
102 const unsigned char *in, unsigned int inl) 113 const unsigned char *in, unsigned int inl)
103 { 114 {
104 des_xcbc_encrypt(in,out,inl,ctx->c.desx_cbc.ks, 115 DES_xcbc_encrypt(in,out,inl,&data(ctx)->ks,
105 (des_cblock *)&(ctx->iv[0]), 116 (DES_cblock *)&(ctx->iv[0]),
106 &ctx->c.desx_cbc.inw, 117 &data(ctx)->inw,
107 &ctx->c.desx_cbc.outw, 118 &data(ctx)->outw,
108 ctx->encrypt); 119 ctx->encrypt);
109 return 1; 120 return 1;
110 } 121 }
111#endif 122#endif