diff options
Diffstat (limited to 'src/lib/libcrypto/evp/e_xcbc_d.c')
| -rw-r--r-- | src/lib/libcrypto/evp/e_xcbc_d.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/lib/libcrypto/evp/e_xcbc_d.c b/src/lib/libcrypto/evp/e_xcbc_d.c index 7568fad4ff..e5b15acc7d 100644 --- a/src/lib/libcrypto/evp/e_xcbc_d.c +++ b/src/lib/libcrypto/evp/e_xcbc_d.c | |||
| @@ -62,14 +62,15 @@ | |||
| 62 | #include <openssl/evp.h> | 62 | #include <openssl/evp.h> |
| 63 | #include <openssl/objects.h> | 63 | #include <openssl/objects.h> |
| 64 | 64 | ||
| 65 | static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | 65 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
| 66 | unsigned char *iv,int enc); | 66 | const unsigned char *iv,int enc); |
| 67 | static void desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 67 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
| 68 | unsigned char *in, unsigned int inl); | 68 | const unsigned char *in, unsigned int inl); |
| 69 | static EVP_CIPHER d_xcbc_cipher= | 69 | static EVP_CIPHER d_xcbc_cipher= |
| 70 | { | 70 | { |
| 71 | NID_desx_cbc, | 71 | NID_desx_cbc, |
| 72 | 8,24,8, | 72 | 8,24,8, |
| 73 | EVP_CIPH_CBC_MODE, | ||
| 73 | desx_cbc_init_key, | 74 | desx_cbc_init_key, |
| 74 | desx_cbc_cipher, | 75 | desx_cbc_cipher, |
| 75 | NULL, | 76 | NULL, |
| @@ -77,6 +78,7 @@ static EVP_CIPHER d_xcbc_cipher= | |||
| 77 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.desx_cbc)), | 78 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.desx_cbc)), |
| 78 | EVP_CIPHER_set_asn1_iv, | 79 | EVP_CIPHER_set_asn1_iv, |
| 79 | EVP_CIPHER_get_asn1_iv, | 80 | EVP_CIPHER_get_asn1_iv, |
| 81 | NULL | ||
| 80 | }; | 82 | }; |
| 81 | 83 | ||
| 82 | EVP_CIPHER *EVP_desx_cbc(void) | 84 | EVP_CIPHER *EVP_desx_cbc(void) |
| @@ -84,29 +86,26 @@ EVP_CIPHER *EVP_desx_cbc(void) | |||
| 84 | return(&d_xcbc_cipher); | 86 | return(&d_xcbc_cipher); |
| 85 | } | 87 | } |
| 86 | 88 | ||
| 87 | static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | 89 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
| 88 | unsigned char *iv, int enc) | 90 | const unsigned char *iv, int enc) |
| 89 | { | 91 | { |
| 90 | des_cblock *deskey = (des_cblock *)key; | 92 | des_cblock *deskey = (des_cblock *)key; |
| 91 | 93 | ||
| 92 | if (iv != NULL) | 94 | des_set_key_unchecked(deskey,ctx->c.desx_cbc.ks); |
| 93 | memcpy(&(ctx->oiv[0]),iv,8); | 95 | memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); |
| 94 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | 96 | memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); |
| 95 | if (deskey != NULL) | 97 | |
| 96 | { | 98 | return 1; |
| 97 | des_set_key_unchecked(deskey,ctx->c.desx_cbc.ks); | ||
| 98 | memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); | ||
| 99 | memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); | ||
| 100 | } | ||
| 101 | } | 99 | } |
| 102 | 100 | ||
| 103 | static void desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 101 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
| 104 | unsigned char *in, unsigned int inl) | 102 | const unsigned char *in, unsigned int inl) |
| 105 | { | 103 | { |
| 106 | des_xcbc_encrypt(in,out,inl,ctx->c.desx_cbc.ks, | 104 | des_xcbc_encrypt(in,out,inl,ctx->c.desx_cbc.ks, |
| 107 | (des_cblock *)&(ctx->iv[0]), | 105 | (des_cblock *)&(ctx->iv[0]), |
| 108 | &ctx->c.desx_cbc.inw, | 106 | &ctx->c.desx_cbc.inw, |
| 109 | &ctx->c.desx_cbc.outw, | 107 | &ctx->c.desx_cbc.outw, |
| 110 | ctx->encrypt); | 108 | ctx->encrypt); |
| 109 | return 1; | ||
| 111 | } | 110 | } |
| 112 | #endif | 111 | #endif |
