diff options
Diffstat (limited to 'src/lib/libcrypto/evp/e_xcbc_d.c')
| -rw-r--r-- | src/lib/libcrypto/evp/e_xcbc_d.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/lib/libcrypto/evp/e_xcbc_d.c b/src/lib/libcrypto/evp/e_xcbc_d.c index 0d7fda0c47..a6f849e93d 100644 --- a/src/lib/libcrypto/evp/e_xcbc_d.c +++ b/src/lib/libcrypto/evp/e_xcbc_d.c | |||
| @@ -56,67 +56,67 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #ifndef OPENSSL_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> |
| 64 | #include <openssl/des.h> | ||
| 63 | 65 | ||
| 64 | #ifndef NOPROTO | 66 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
| 65 | static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | 67 | const unsigned char *iv,int enc); |
| 66 | unsigned char *iv,int enc); | 68 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
| 67 | static void desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 69 | const unsigned char *in, unsigned int inl); |
| 68 | unsigned char *in, unsigned int inl); | 70 | |
| 69 | #else | 71 | |
| 70 | static void desx_cbc_init_key(); | 72 | typedef struct |
| 71 | static void desx_cbc_cipher(); | 73 | { |
| 72 | #endif | 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) | ||
| 73 | 80 | ||
| 74 | static EVP_CIPHER d_xcbc_cipher= | 81 | static const EVP_CIPHER d_xcbc_cipher= |
| 75 | { | 82 | { |
| 76 | NID_desx_cbc, | 83 | NID_desx_cbc, |
| 77 | 8,24,8, | 84 | 8,24,8, |
| 85 | EVP_CIPH_CBC_MODE, | ||
| 78 | desx_cbc_init_key, | 86 | desx_cbc_init_key, |
| 79 | desx_cbc_cipher, | 87 | desx_cbc_cipher, |
| 80 | NULL, | 88 | NULL, |
| 81 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | 89 | sizeof(DESX_CBC_KEY), |
| 82 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.desx_cbc)), | ||
| 83 | EVP_CIPHER_set_asn1_iv, | 90 | EVP_CIPHER_set_asn1_iv, |
| 84 | EVP_CIPHER_get_asn1_iv, | 91 | EVP_CIPHER_get_asn1_iv, |
| 92 | NULL | ||
| 85 | }; | 93 | }; |
| 86 | 94 | ||
| 87 | EVP_CIPHER *EVP_desx_cbc() | 95 | const EVP_CIPHER *EVP_desx_cbc(void) |
| 88 | { | 96 | { |
| 89 | return(&d_xcbc_cipher); | 97 | return(&d_xcbc_cipher); |
| 90 | } | 98 | } |
| 91 | 99 | ||
| 92 | static void desx_cbc_init_key(ctx,key,iv,enc) | 100 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
| 93 | EVP_CIPHER_CTX *ctx; | 101 | const unsigned char *iv, int enc) |
| 94 | unsigned char *key; | ||
| 95 | unsigned char *iv; | ||
| 96 | int enc; | ||
| 97 | { | 102 | { |
| 98 | if (iv != NULL) | 103 | DES_cblock *deskey = (DES_cblock *)key; |
| 99 | memcpy(&(ctx->oiv[0]),iv,8); | 104 | |
| 100 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | 105 | DES_set_key_unchecked(deskey,&data(ctx)->ks); |
| 101 | if (key != NULL) | 106 | memcpy(&data(ctx)->inw[0],&key[8],8); |
| 102 | { | 107 | memcpy(&data(ctx)->outw[0],&key[16],8); |
| 103 | des_set_key((des_cblock *)key,ctx->c.desx_cbc.ks); | 108 | |
| 104 | memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); | 109 | return 1; |
| 105 | memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); | ||
| 106 | } | ||
| 107 | } | 110 | } |
| 108 | 111 | ||
| 109 | static void desx_cbc_cipher(ctx,out,in,inl) | 112 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
| 110 | EVP_CIPHER_CTX *ctx; | 113 | const unsigned char *in, unsigned int inl) |
| 111 | unsigned char *out; | ||
| 112 | unsigned char *in; | ||
| 113 | unsigned int inl; | ||
| 114 | { | 114 | { |
| 115 | des_xcbc_encrypt( | 115 | DES_xcbc_encrypt(in,out,inl,&data(ctx)->ks, |
| 116 | (des_cblock *)in,(des_cblock *)out, | 116 | (DES_cblock *)&(ctx->iv[0]), |
| 117 | (long)inl, ctx->c.desx_cbc.ks, | 117 | &data(ctx)->inw, |
| 118 | (des_cblock *)&(ctx->iv[0]), | 118 | &data(ctx)->outw, |
| 119 | (des_cblock *)&(ctx->c.desx_cbc.inw[0]), | 119 | ctx->encrypt); |
| 120 | (des_cblock *)&(ctx->c.desx_cbc.outw[0]), | 120 | return 1; |
| 121 | ctx->encrypt); | ||
| 122 | } | 121 | } |
| 122 | #endif | ||
