summaryrefslogtreecommitdiffstats
path: root/crypto/evp/e_xcbc_d.c
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2001-07-30 23:57:25 +0000
committerBen Laurie <ben@openssl.org>2001-07-30 23:57:25 +0000
commitdbad169019598981174ff46c7a9bf58373b0e53a (patch)
treece8ca1188d5614648f24b03967785543f1edc8f5 /crypto/evp/e_xcbc_d.c
parent3ba5d1cf2eb6ef28ac5f6d9f3d28020d00c5be50 (diff)
Really add the EVP and all of the DES changes.
Diffstat (limited to 'crypto/evp/e_xcbc_d.c')
-rw-r--r--crypto/evp/e_xcbc_d.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/crypto/evp/e_xcbc_d.c b/crypto/evp/e_xcbc_d.c
index faec338e38..ab94630fd2 100644
--- a/crypto/evp/e_xcbc_d.c
+++ b/crypto/evp/e_xcbc_d.c
@@ -61,11 +61,23 @@
#include "cryptlib.h"
#include <openssl/evp.h>
#include <openssl/objects.h>
+#include <openssl/des.h>
static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv,int enc);
static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, unsigned int inl);
+
+
+typedef struct
+ {
+ des_key_schedule ks;/* key schedule */
+ des_cblock inw;
+ des_cblock outw;
+ } DESX_CBC_KEY;
+
+#define data(ctx) ((DESX_CBC_KEY *)(ctx)->cipher_data)
+
static const EVP_CIPHER d_xcbc_cipher=
{
NID_desx_cbc,
@@ -74,8 +86,7 @@ static const EVP_CIPHER d_xcbc_cipher=
desx_cbc_init_key,
desx_cbc_cipher,
NULL,
- sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
- sizeof((((EVP_CIPHER_CTX *)NULL)->c.desx_cbc)),
+ sizeof(DESX_CBC_KEY),
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
NULL
@@ -91,9 +102,9 @@ static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
{
des_cblock *deskey = (des_cblock *)key;
- des_set_key_unchecked(deskey,ctx->c.desx_cbc.ks);
- memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8);
- memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8);
+ des_set_key_unchecked(deskey,&data(ctx)->ks);
+ memcpy(&data(ctx)->inw[0],&key[8],8);
+ memcpy(&data(ctx)->outw[0],&key[16],8);
return 1;
}
@@ -101,11 +112,11 @@ static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, unsigned int inl)
{
- des_xcbc_encrypt(in,out,inl,ctx->c.desx_cbc.ks,
- (des_cblock *)&(ctx->iv[0]),
- &ctx->c.desx_cbc.inw,
- &ctx->c.desx_cbc.outw,
- ctx->encrypt);
+ des_xcbc_encrypt(in,out,inl,&data(ctx)->ks,
+ (des_cblock *)&(ctx->iv[0]),
+ &data(ctx)->inw,
+ &data(ctx)->outw,
+ ctx->encrypt);
return 1;
}
#endif