Go to the documentation of this file.
63 #define BLOCK_CIPHER_ecb_loop() \
65 bl = ctx->cipher->block_size;\
66 if(inl < bl) return 1;\
68 for(i=0; i <= inl; i+=bl)
70 #define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
71 static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
73 BLOCK_CIPHER_ecb_loop() \
74 cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\
78 #define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))
80 #define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
81 static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
83 while(inl>=EVP_MAXCHUNK)\
85 cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\
91 cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\
95 #define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
96 static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
98 while(inl>=EVP_MAXCHUNK) \
100 cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\
106 cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\
110 #define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
111 static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
113 size_t chunk=EVP_MAXCHUNK;\
114 if (cbits==1) chunk>>=3;\
115 if (inl<chunk) chunk=inl;\
116 while(inl && inl>=chunk)\
118 cprefix##_cfb##cbits##_encrypt(in, out, (long)((cbits==1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ?inl*8:inl), &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\
122 if(inl<chunk) chunk=inl;\
127 #define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
128 BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
129 BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
130 BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
131 BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
133 #define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
134 key_len, iv_len, flags, init_key, cleanup, \
135 set_asn1, get_asn1, ctrl) \
136 static const EVP_CIPHER cname##_##mode = { \
137 nid##_##nmode, block_size, key_len, iv_len, \
138 flags | EVP_CIPH_##MODE##_MODE, \
140 cname##_##mode##_cipher, \
147 const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
149 #define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \
150 iv_len, flags, init_key, cleanup, set_asn1, \
152 BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
153 iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
155 #define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \
156 iv_len, cbits, flags, init_key, cleanup, \
157 set_asn1, get_asn1, ctrl) \
158 BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \
159 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
162 #define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \
163 iv_len, cbits, flags, init_key, cleanup, \
164 set_asn1, get_asn1, ctrl) \
165 BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
166 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
169 #define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
170 flags, init_key, cleanup, set_asn1, \
172 BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
173 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
175 #define BLOCK_CIPHER_defs(cname, kstruct, \
176 nid, block_size, key_len, iv_len, cbits, flags, \
177 init_key, cleanup, set_asn1, get_asn1, ctrl) \
178 BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
179 init_key, cleanup, set_asn1, get_asn1, ctrl) \
180 BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
181 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
182 BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
183 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
184 BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \
185 init_key, cleanup, set_asn1, get_asn1, ctrl)
246 #define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \
247 block_size, key_len, iv_len, cbits, \
249 cleanup, set_asn1, get_asn1, ctrl) \
250 BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
251 BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
252 cbits, flags, init_key, cleanup, set_asn1, \
255 #define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data)
257 #define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \
258 BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
259 BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
260 NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
261 0, cipher##_init_key, NULL, \
262 EVP_CIPHER_set_asn1_iv, \
263 EVP_CIPHER_get_asn1_iv, \
289 #define EVP_PKEY_FLAG_DYNAMIC 1
308 const unsigned char *tbs,
size_t tbslen);
312 const unsigned char *sig,
size_t siglen,
313 const unsigned char *tbs,
size_t tbslen);
317 unsigned char *rout,
size_t *routlen,
318 const unsigned char *sig,
size_t siglen);
330 const unsigned char *
in,
size_t inlen);
334 const unsigned char *
in,
size_t inlen);
353 #ifdef OPENSSL_DOING_MAKEDEPEND
360 #undef DES_set_key_unchecked
363 #define RIPEMD160_Init private_RIPEMD160_Init
364 #define WHIRLPOOL_Init private_WHIRLPOOL_Init
365 #define MD5_Init private_MD5_Init
366 #define MD4_Init private_MD4_Init
367 #define MD2_Init private_MD2_Init
368 #define MDC2_Init private_MDC2_Init
369 #define SHA_Init private_SHA_Init
370 #define SHA1_Init private_SHA1_Init
371 #define SHA224_Init private_SHA224_Init
372 #define SHA256_Init private_SHA256_Init
373 #define SHA384_Init private_SHA384_Init
374 #define SHA512_Init private_SHA512_Init
376 #define BF_set_key private_BF_set_key
377 #define CAST_set_key private_CAST_set_key
378 #define idea_set_encrypt_key private_idea_set_encrypt_key
379 #define SEED_set_key private_SEED_set_key
380 #define RC2_set_key private_RC2_set_key
381 #define RC4_set_key private_RC4_set_key
382 #define DES_set_key_unchecked private_DES_set_key_unchecked
383 #define Camellia_set_key private_Camellia_set_key