Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: openssl/crypto/evp/evp_locl.h

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « openssl/crypto/evp/evp_lib.c ('k') | openssl/crypto/evp/evp_pbe.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* evp_locl.h */ 1 /* evp_locl.h */
2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5 /* ==================================================================== 5 /* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 * (eay@cryptsoft.com). This product includes software written by Tim 54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com). 55 * Hudson (tjh@cryptsoft.com).
56 * 56 *
57 */ 57 */
58 58
59 /* Macros to code block cipher wrappers */ 59 /* Macros to code block cipher wrappers */
60 60
61 /* Wrapper functions for each cipher mode */ 61 /* Wrapper functions for each cipher mode */
62 62
63 #define BLOCK_CIPHER_ecb_loop() \ 63 #define BLOCK_CIPHER_ecb_loop() \
64 » unsigned int i, bl; \ 64 » size_t i, bl; \
65 bl = ctx->cipher->block_size;\ 65 bl = ctx->cipher->block_size;\
66 if(inl < bl) return 1;\ 66 if(inl < bl) return 1;\
67 inl -= bl; \ 67 inl -= bl; \
68 for(i=0; i <= inl; i+=bl) 68 for(i=0; i <= inl; i+=bl)
69 69
70 #define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ 70 #define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
71 static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns igned char *in, unsigned int inl) \ 71 static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns igned char *in, size_t inl) \
72 {\ 72 {\
73 BLOCK_CIPHER_ecb_loop() \ 73 BLOCK_CIPHER_ecb_loop() \
74 cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_ data)->ksched, ctx->encrypt);\ 74 cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_ data)->ksched, ctx->encrypt);\
75 return 1;\ 75 return 1;\
76 } 76 }
77 77
78 #define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))
79
78 #define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ 80 #define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
79 static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns igned char *in, unsigned int inl) \ 81 static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns igned char *in, size_t inl) \
80 {\ 82 {\
81 » cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cip her_data)->ksched, ctx->iv, &ctx->num);\ 83 » while(inl>=EVP_MAXCHUNK)\
84 » {\
85 » cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstru ct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\
86 » inl-=EVP_MAXCHUNK;\
87 » in +=EVP_MAXCHUNK;\
88 » out+=EVP_MAXCHUNK;\
89 » }\
90 » if (inl)\
91 » cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx- >cipher_data)->ksched, ctx->iv, &ctx->num);\
82 return 1;\ 92 return 1;\
83 } 93 }
84 94
85 #define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ 95 #define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
86 static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns igned char *in, unsigned int inl) \ 96 static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns igned char *in, size_t inl) \
87 {\ 97 {\
88 » cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data) ->ksched, ctx->iv, ctx->encrypt);\ 98 » while(inl>=EVP_MAXCHUNK) \
99 » {\
100 » cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx- >cipher_data)->ksched, ctx->iv, ctx->encrypt);\
101 » inl-=EVP_MAXCHUNK;\
102 » in +=EVP_MAXCHUNK;\
103 » out+=EVP_MAXCHUNK;\
104 » }\
105 » if (inl)\
106 » cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_d ata)->ksched, ctx->iv, ctx->encrypt);\
89 return 1;\ 107 return 1;\
90 } 108 }
91 109
92 #define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ 110 #define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
93 static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 111 static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
94 {\ 112 {\
95 » cprefix##_cfb##cbits##_encrypt(in, out, (long)((cbits==1) && !(ctx->flag s & EVP_CIPH_FLAG_LENGTH_BITS) ?inl*8:inl), &((kstruct *)ctx->cipher_data)->ksch ed, ctx->iv, &ctx->num, ctx->encrypt);\ 113 » size_t chunk=EVP_MAXCHUNK;\
114 » if (cbits==1) chunk>>=3;\
115 » if (inl<chunk) chunk=inl;\
116 » while(inl && inl>=chunk)\
117 » {\
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);\
119 » inl-=chunk;\
120 » in +=chunk;\
121 » out+=chunk;\
122 » if(inl<chunk) chunk=inl;\
123 » }\
96 return 1;\ 124 return 1;\
97 } 125 }
98 126
99 #define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ 127 #define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
100 BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ 128 BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
101 BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ 129 BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
102 BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ 130 BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
103 BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) 131 BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
104 132
105 #define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \ 133 #define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 block_size, key_len, iv_len, cbits, \ 247 block_size, key_len, iv_len, cbits, \
220 flags, init_key, \ 248 flags, init_key, \
221 cleanup, set_asn1, get_asn1, ctrl) \ 249 cleanup, set_asn1, get_asn1, ctrl) \
222 BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ 250 BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
223 BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ 251 BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
224 cbits, flags, init_key, cleanup, set_asn1, \ 252 cbits, flags, init_key, cleanup, set_asn1, \
225 get_asn1, ctrl) 253 get_asn1, ctrl)
226 254
227 #define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data) 255 #define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data)
228 256
229 #define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \ 257 #define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \
230 BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ 258 BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
231 BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ 259 BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
232 NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ 260 NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
233 » » » (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \ 261 » » » 0, cipher##_init_key, NULL, \
234 » » » cipher##_init_key, NULL, NULL, NULL, NULL) 262 » » » EVP_CIPHER_set_asn1_iv, \
263 » » » EVP_CIPHER_get_asn1_iv, \
264 » » » NULL)
235 265
236 #ifdef OPENSSL_FIPS 266 struct evp_pkey_ctx_st
237 #define RC2_set_key» private_RC2_set_key 267 » {
238 #define RC4_set_key» private_RC4_set_key 268 » /* Method associated with this operation */
239 #define CAST_set_key» private_CAST_set_key 269 » const EVP_PKEY_METHOD *pmeth;
240 #define RC5_32_set_key» private_RC5_32_set_key 270 » /* Engine that implements this method or NULL if builtin */
241 #define BF_set_key» private_BF_set_key 271 » ENGINE *engine;
242 #define Camellia_set_key private_Camellia_set_key 272 » /* Key: may be NULL */
243 #define idea_set_encrypt_key private_idea_set_encrypt_key 273 » EVP_PKEY *pkey;
274 » /* Peer key for key agreement, may be NULL */
275 » EVP_PKEY *peerkey;
276 » /* Actual operation */
277 » int operation;
278 » /* Algorithm specific data */
279 » void *data;
280 » /* Application specific data */
281 » void *app_data;
282 » /* Keygen callback */
283 » EVP_PKEY_gen_cb *pkey_gencb;
284 » /* implementation specific keygen data */
285 » int *keygen_info;
286 » int keygen_info_count;
287 » } /* EVP_PKEY_CTX */;
244 288
245 #define MD5_Init» private_MD5_Init 289 #define EVP_PKEY_FLAG_DYNAMIC» 1
246 #define MD4_Init» private_MD4_Init
247 #define MD2_Init» private_MD2_Init
248 #define MDC2_Init» private_MDC2_Init
249 #define SHA_Init» private_SHA_Init
250 290
251 #endif 291 struct evp_pkey_method_st
292 » {
293 » int pkey_id;
294 » int flags;
252 295
296 int (*init)(EVP_PKEY_CTX *ctx);
297 int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
298 void (*cleanup)(EVP_PKEY_CTX *ctx);
299
300 int (*paramgen_init)(EVP_PKEY_CTX *ctx);
301 int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
302
303 int (*keygen_init)(EVP_PKEY_CTX *ctx);
304 int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
305
306 int (*sign_init)(EVP_PKEY_CTX *ctx);
307 int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
308 const unsigned char *tbs, size_t tbslen);
309
310 int (*verify_init)(EVP_PKEY_CTX *ctx);
311 int (*verify)(EVP_PKEY_CTX *ctx,
312 const unsigned char *sig, size_t siglen,
313 const unsigned char *tbs, size_t tbslen);
314
315 int (*verify_recover_init)(EVP_PKEY_CTX *ctx);
316 int (*verify_recover)(EVP_PKEY_CTX *ctx,
317 unsigned char *rout, size_t *routlen,
318 const unsigned char *sig, size_t siglen);
319
320 int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
321 int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
322 EVP_MD_CTX *mctx);
323
324 int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
325 int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig,int siglen,
326 EVP_MD_CTX *mctx);
327
328 int (*encrypt_init)(EVP_PKEY_CTX *ctx);
329 int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
330 const unsigned char *in, size_t inlen);
331
332 int (*decrypt_init)(EVP_PKEY_CTX *ctx);
333 int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
334 const unsigned char *in, size_t inlen);
335
336 int (*derive_init)(EVP_PKEY_CTX *ctx);
337 int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
338
339 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
340 int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value);
341
342
343 } /* EVP_PKEY_METHOD */;
344
345 void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);
OLDNEW
« no previous file with comments | « openssl/crypto/evp/evp_lib.c ('k') | openssl/crypto/evp/evp_pbe.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698