diff options
Diffstat (limited to 'crypto/evp/evp_locl.h')
-rw-r--r-- | crypto/evp/evp_locl.h | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/crypto/evp/evp_locl.h b/crypto/evp/evp_locl.h index 264e9ced24..62fbeba699 100644 --- a/crypto/evp/evp_locl.h +++ b/crypto/evp/evp_locl.h @@ -66,40 +66,40 @@ inl -= 8; \ for(i=0; i <= inl; i+=8) \ -#define BLOCK_CIPHER_func_ecb(cname, cprefix, kname) \ +#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ {\ BLOCK_CIPHER_ecb_loop() \ - cprefix##_ecb_encrypt(in + i, out + i, &ctx->c.kname, ctx->encrypt);\ + cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\ return 1;\ } -#define BLOCK_CIPHER_func_ofb(cname, cprefix, kname) \ +#define BLOCK_CIPHER_func_ofb(cname, cprefix, kstruct, ksched) \ static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ {\ - cprefix##_ofb64_encrypt(in, out, (long)inl, &ctx->c.kname, ctx->iv, &ctx->num);\ + cprefix##_ofb64_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\ return 1;\ } -#define BLOCK_CIPHER_func_cbc(cname, cprefix, kname) \ +#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ {\ - cprefix##_cbc_encrypt(in, out, (long)inl, &ctx->c.kname, ctx->iv, ctx->encrypt);\ + cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\ return 1;\ } -#define BLOCK_CIPHER_func_cfb(cname, cprefix, kname) \ +#define BLOCK_CIPHER_func_cfb(cname, cprefix, kstruct, ksched) \ static int cname##_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ {\ - cprefix##_cfb64_encrypt(in, out, (long)inl, &ctx->c.kname, ctx->iv, &ctx->num, ctx->encrypt);\ + cprefix##_cfb64_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\ return 1;\ } -#define BLOCK_CIPHER_all_funcs(cname, cprefix, kname) \ - BLOCK_CIPHER_func_cbc(cname, cprefix, kname) \ - BLOCK_CIPHER_func_cfb(cname, cprefix, kname) \ - BLOCK_CIPHER_func_ecb(cname, cprefix, kname) \ - BLOCK_CIPHER_func_ofb(cname, cprefix, kname) +#define BLOCK_CIPHER_all_funcs(cname, cprefix, kstruct, ksched) \ + BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ + BLOCK_CIPHER_func_cfb(cname, cprefix, kstruct, ksched) \ + BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ + BLOCK_CIPHER_func_ofb(cname, cprefix, kstruct, ksched) #define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \ key_len, iv_len, flags, init_key, cleanup, \ @@ -110,8 +110,7 @@ static const EVP_CIPHER cname##_##mode = { \ init_key, \ cname##_##mode##_cipher, \ cleanup, \ - sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ - sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ + sizeof(kstruct), \ set_asn1, get_asn1,\ ctrl, \ NULL \ @@ -213,11 +212,11 @@ static const EVP_CIPHER cname##_ecb = {\ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } */ +#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \ + block_size, key_len, iv_len, flags, init_key, \ + cleanup, set_asn1, get_asn1, ctrl) \ + BLOCK_CIPHER_all_funcs(cname, cprefix, kstruct, ksched) \ + BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ + flags, init_key, cleanup, set_asn1, get_asn1, ctrl) -#define IMPLEMENT_BLOCK_CIPHER(cname, kname, cprefix, kstruct, \ - nid, block_size, key_len, iv_len, flags, \ - init_key, cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_all_funcs(cname, cprefix, kname) \ - BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, flags,\ - init_key, cleanup, set_asn1, get_asn1, ctrl) - +#define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data) |