diff options
Diffstat (limited to 'src/lib/libcrypto/evp/e_xcbc_d.c')
-rw-r--r-- | src/lib/libcrypto/evp/e_xcbc_d.c | 39 |
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 | ||
65 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 66 | static 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); |
67 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 68 | static 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); |
69 | static EVP_CIPHER d_xcbc_cipher= | 70 | |
71 | |||
72 | typedef 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 | |||
81 | static 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 | ||
84 | EVP_CIPHER *EVP_desx_cbc(void) | 95 | const 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) | |||
89 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 100 | static 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, | |||
101 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 112 | static 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 |