]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2f.patch
04ee8af1df3ec71a575f638d0d3ac915db795e88
[mirror_edk2.git] / CryptoPkg / Library / OpensslLib / EDKII_openssl-1.0.2f.patch
1 diff --git a/Configure b/Configure
2 index 4a715dc..eb61eda 100755
3 --- a/Configure
4 +++ b/Configure
5 @@ -1082,7 +1082,7 @@ if (defined($disabled{"tls1"}))
6 }
7
8 if (defined($disabled{"ec"}) || defined($disabled{"dsa"})
9 - || defined($disabled{"dh"}))
10 + || defined($disabled{"dh"}) || defined($disabled{"stdio"}))
11 {
12 $disabled{"gost"} = "forced";
13 }
14 diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c
15 index 35fd44c..9f39bff 100644
16 --- a/crypto/asn1/a_strex.c
17 +++ b/crypto/asn1/a_strex.c
18 @@ -104,6 +104,7 @@ static int send_bio_chars(void *arg, const void *buf, int len)
19 return 1;
20 }
21
22 +#ifndef OPENSSL_NO_FP_API
23 static int send_fp_chars(void *arg, const void *buf, int len)
24 {
25 if (!arg)
26 @@ -112,6 +113,7 @@ static int send_fp_chars(void *arg, const void *buf, int len)
27 return 0;
28 return 1;
29 }
30 +#endif
31
32 typedef int char_io (void *arg, const void *buf, int len);
33
34 diff --git a/crypto/asn1/asn1_mac.h b/crypto/asn1/asn1_mac.h
35 index abc6dc3..3a672e9 100644
36 --- a/crypto/asn1/asn1_mac.h
37 +++ b/crypto/asn1/asn1_mac.h
38 @@ -70,7 +70,7 @@ extern "C" {
39 # endif
40
41 # define ASN1_MAC_H_err(f,r,line) \
42 - ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))
43 + ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),OPENSSL_FILE,(line))
44
45 # define M_ASN1_D2I_vars(a,type,func) \
46 ASN1_const_CTX c; \
47 @@ -81,7 +81,7 @@ extern "C" {
48 c.error=ERR_R_NESTED_ASN1_ERROR; \
49 if ((a == NULL) || ((*a) == NULL)) \
50 { if ((ret=(type)func()) == NULL) \
51 - { c.line=__LINE__; goto err; } } \
52 + { c.line=OPENSSL_LINE; goto err; } } \
53 else ret=(*a);
54
55 # define M_ASN1_D2I_Init() \
56 @@ -90,7 +90,7 @@ extern "C" {
57
58 # define M_ASN1_D2I_Finish_2(a) \
59 if (!asn1_const_Finish(&c)) \
60 - { c.line=__LINE__; goto err; } \
61 + { c.line=OPENSSL_LINE; goto err; } \
62 *(const unsigned char **)pp=c.p; \
63 if (a != NULL) (*a)=ret; \
64 return(ret);
65 @@ -105,7 +105,7 @@ err:\
66
67 # define M_ASN1_D2I_start_sequence() \
68 if (!asn1_GetSequence(&c,&length)) \
69 - { c.line=__LINE__; goto err; }
70 + { c.line=OPENSSL_LINE; goto err; }
71 /* Begin reading ASN1 without a surrounding sequence */
72 # define M_ASN1_D2I_begin() \
73 c.slen = length;
74 @@ -129,21 +129,21 @@ err:\
75 # define M_ASN1_D2I_get(b, func) \
76 c.q=c.p; \
77 if (func(&(b),&c.p,c.slen) == NULL) \
78 - {c.line=__LINE__; goto err; } \
79 + {c.line=OPENSSL_LINE; goto err; } \
80 c.slen-=(c.p-c.q);
81
82 /* Don't use this with d2i_ASN1_BOOLEAN() */
83 # define M_ASN1_D2I_get_x(type,b,func) \
84 c.q=c.p; \
85 if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \
86 - {c.line=__LINE__; goto err; } \
87 + {c.line=OPENSSL_LINE; goto err; } \
88 c.slen-=(c.p-c.q);
89
90 /* use this instead () */
91 # define M_ASN1_D2I_get_int(b,func) \
92 c.q=c.p; \
93 if (func(&(b),&c.p,c.slen) < 0) \
94 - {c.line=__LINE__; goto err; } \
95 + {c.line=OPENSSL_LINE; goto err; } \
96 c.slen-=(c.p-c.q);
97
98 # define M_ASN1_D2I_get_opt(b,func,type) \
99 @@ -164,7 +164,7 @@ err:\
100 M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \
101 c.q=c.p; \
102 if (func(&(b),&c.p,c.slen) == NULL) \
103 - {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \
104 + {c.line=OPENSSL_LINE; M_ASN1_next_prev = _tmp; goto err; } \
105 c.slen-=(c.p-c.q);\
106 M_ASN1_next_prev=_tmp;
107
108 @@ -258,20 +258,20 @@ err:\
109 c.q=c.p; \
110 if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\
111 (void (*)())free_func,a,b) == NULL) \
112 - { c.line=__LINE__; goto err; } \
113 + { c.line=OPENSSL_LINE; goto err; } \
114 c.slen-=(c.p-c.q);
115
116 # define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \
117 c.q=c.p; \
118 if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\
119 free_func,a,b) == NULL) \
120 - { c.line=__LINE__; goto err; } \
121 + { c.line=OPENSSL_LINE; goto err; } \
122 c.slen-=(c.p-c.q);
123
124 # define M_ASN1_D2I_get_set_strings(r,func,a,b) \
125 c.q=c.p; \
126 if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \
127 - { c.line=__LINE__; goto err; } \
128 + { c.line=OPENSSL_LINE; goto err; } \
129 c.slen-=(c.p-c.q);
130
131 # define M_ASN1_D2I_get_EXP_opt(r,func,tag) \
132 @@ -285,16 +285,16 @@ err:\
133 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
134 if (Tinf & 0x80) \
135 { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
136 - c.line=__LINE__; goto err; } \
137 + c.line=OPENSSL_LINE; goto err; } \
138 if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
139 Tlen = c.slen - (c.p - c.q) - 2; \
140 if (func(&(r),&c.p,Tlen) == NULL) \
141 - { c.line=__LINE__; goto err; } \
142 + { c.line=OPENSSL_LINE; goto err; } \
143 if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
144 Tlen = c.slen - (c.p - c.q); \
145 if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \
146 { c.error=ERR_R_MISSING_ASN1_EOS; \
147 - c.line=__LINE__; goto err; } \
148 + c.line=OPENSSL_LINE; goto err; } \
149 }\
150 c.slen-=(c.p-c.q); \
151 }
152 @@ -310,18 +310,18 @@ err:\
153 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
154 if (Tinf & 0x80) \
155 { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
156 - c.line=__LINE__; goto err; } \
157 + c.line=OPENSSL_LINE; goto err; } \
158 if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
159 Tlen = c.slen - (c.p - c.q) - 2; \
160 if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \
161 (void (*)())free_func, \
162 b,V_ASN1_UNIVERSAL) == NULL) \
163 - { c.line=__LINE__; goto err; } \
164 + { c.line=OPENSSL_LINE; goto err; } \
165 if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
166 Tlen = c.slen - (c.p - c.q); \
167 if(!ASN1_check_infinite_end(&c.p, Tlen)) \
168 { c.error=ERR_R_MISSING_ASN1_EOS; \
169 - c.line=__LINE__; goto err; } \
170 + c.line=OPENSSL_LINE; goto err; } \
171 }\
172 c.slen-=(c.p-c.q); \
173 }
174 @@ -337,17 +337,17 @@ err:\
175 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
176 if (Tinf & 0x80) \
177 { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
178 - c.line=__LINE__; goto err; } \
179 + c.line=OPENSSL_LINE; goto err; } \
180 if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
181 Tlen = c.slen - (c.p - c.q) - 2; \
182 if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \
183 free_func,b,V_ASN1_UNIVERSAL) == NULL) \
184 - { c.line=__LINE__; goto err; } \
185 + { c.line=OPENSSL_LINE; goto err; } \
186 if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
187 Tlen = c.slen - (c.p - c.q); \
188 if(!ASN1_check_infinite_end(&c.p, Tlen)) \
189 { c.error=ERR_R_MISSING_ASN1_EOS; \
190 - c.line=__LINE__; goto err; } \
191 + c.line=OPENSSL_LINE; goto err; } \
192 }\
193 c.slen-=(c.p-c.q); \
194 }
195 @@ -355,7 +355,7 @@ err:\
196 /* New macros */
197 # define M_ASN1_New_Malloc(ret,type) \
198 if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \
199 - { c.line=__LINE__; goto err2; }
200 + { c.line=OPENSSL_LINE; goto err2; }
201
202 # define M_ASN1_New(arg,func) \
203 if (((arg)=func()) == NULL) return(NULL)
204 diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c
205 index 1d25687..e933ead 100644
206 --- a/crypto/bn/bn_prime.c
207 +++ b/crypto/bn/bn_prime.c
208 @@ -131,7 +131,7 @@
209 static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
210 const BIGNUM *a1_odd, int k, BN_CTX *ctx,
211 BN_MONT_CTX *mont);
212 -static int probable_prime(BIGNUM *rnd, int bits);
213 +static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods);
214 static int probable_prime_dh(BIGNUM *rnd, int bits,
215 const BIGNUM *add, const BIGNUM *rem,
216 BN_CTX *ctx);
217 @@ -166,9 +166,13 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
218 BIGNUM *t;
219 int found = 0;
220 int i, j, c1 = 0;
221 - BN_CTX *ctx;
222 + BN_CTX *ctx = NULL;
223 + prime_t *mods = NULL;
224 int checks = BN_prime_checks_for_size(bits);
225
226 + mods = OPENSSL_malloc(sizeof(*mods) * NUMPRIMES);
227 + if (mods == NULL)
228 + goto err;
229 ctx = BN_CTX_new();
230 if (ctx == NULL)
231 goto err;
232 @@ -179,7 +183,7 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
233 loop:
234 /* make a random number and set the top and bottom bits */
235 if (add == NULL) {
236 - if (!probable_prime(ret, bits))
237 + if (!probable_prime(ret, bits, mods))
238 goto err;
239 } else {
240 if (safe) {
241 @@ -230,6 +234,7 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
242 /* we have a prime :-) */
243 found = 1;
244 err:
245 + OPENSSL_free(mods);
246 if (ctx != NULL) {
247 BN_CTX_end(ctx);
248 BN_CTX_free(ctx);
249 @@ -375,10 +380,9 @@ static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
250 return 1;
251 }
252
253 -static int probable_prime(BIGNUM *rnd, int bits)
254 +static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods)
255 {
256 int i;
257 - prime_t mods[NUMPRIMES];
258 BN_ULONG delta, maxdelta;
259
260 again:
261 diff --git a/crypto/conf/conf.h b/crypto/conf/conf.h
262 index 8d926d5..41cf38e 100644
263 --- a/crypto/conf/conf.h
264 +++ b/crypto/conf/conf.h
265 @@ -118,8 +118,10 @@ typedef void conf_finish_func (CONF_IMODULE *md);
266
267 int CONF_set_default_method(CONF_METHOD *meth);
268 void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);
269 +# ifndef OPENSSL_NO_STDIO
270 LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
271 long *eline);
272 +# endif
273 # ifndef OPENSSL_NO_FP_API
274 LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
275 long *eline);
276 @@ -133,7 +135,9 @@ char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,
277 long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,
278 const char *name);
279 void CONF_free(LHASH_OF(CONF_VALUE) *conf);
280 +#ifndef OPENSSL_NO_FP_API
281 int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
282 +#endif
283 int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
284
285 void OPENSSL_config(const char *config_name);
286 @@ -160,7 +164,9 @@ CONF_METHOD *NCONF_XML(void);
287 void NCONF_free(CONF *conf);
288 void NCONF_free_data(CONF *conf);
289
290 +# ifndef OPENSSL_NO_STDIO
291 int NCONF_load(CONF *conf, const char *file, long *eline);
292 +# endif
293 # ifndef OPENSSL_NO_FP_API
294 int NCONF_load_fp(CONF *conf, FILE *fp, long *eline);
295 # endif
296 @@ -170,7 +176,9 @@ STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,
297 char *NCONF_get_string(const CONF *conf, const char *group, const char *name);
298 int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
299 long *result);
300 +#ifndef OPENSSL_NO_FP_API
301 int NCONF_dump_fp(const CONF *conf, FILE *out);
302 +#endif
303 int NCONF_dump_bio(const CONF *conf, BIO *out);
304
305 # if 0 /* The following function has no error
306 @@ -184,8 +192,10 @@ long NCONF_get_number(CONF *conf, char *group, char *name);
307
308 int CONF_modules_load(const CONF *cnf, const char *appname,
309 unsigned long flags);
310 +#ifndef OPENSSL_NO_STDIO
311 int CONF_modules_load_file(const char *filename, const char *appname,
312 unsigned long flags);
313 +#endif
314 void CONF_modules_unload(int all);
315 void CONF_modules_finish(void);
316 void CONF_modules_free(void);
317 diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
318 index 68c77ce..3d308c7 100644
319 --- a/crypto/conf/conf_def.c
320 +++ b/crypto/conf/conf_def.c
321 @@ -182,6 +182,10 @@ static int def_destroy_data(CONF *conf)
322
323 static int def_load(CONF *conf, const char *name, long *line)
324 {
325 +#ifdef OPENSSL_NO_STDIO
326 + CONFerr(CONF_F_DEF_LOAD, ERR_R_SYS_LIB);
327 + return 0;
328 +#else
329 int ret;
330 BIO *in = NULL;
331
332 @@ -202,6 +206,7 @@ static int def_load(CONF *conf, const char *name, long *line)
333 BIO_free(in);
334
335 return ret;
336 +#endif
337 }
338
339 static int def_load_bio(CONF *conf, BIO *in, long *line)
340 diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
341 index 5281384..952b545 100644
342 --- a/crypto/conf/conf_lib.c
343 +++ b/crypto/conf/conf_lib.c
344 @@ -90,6 +90,7 @@ int CONF_set_default_method(CONF_METHOD *meth)
345 return 1;
346 }
347
348 +#ifndef OPENSSL_NO_STDIO
349 LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
350 long *eline)
351 {
352 @@ -111,6 +112,7 @@ LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
353
354 return ltmp;
355 }
356 +#endif
357
358 #ifndef OPENSSL_NO_FP_API
359 LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
360 @@ -255,6 +257,7 @@ void NCONF_free_data(CONF *conf)
361 conf->meth->destroy_data(conf);
362 }
363
364 +#ifndef OPENSSL_NO_STDIO
365 int NCONF_load(CONF *conf, const char *file, long *eline)
366 {
367 if (conf == NULL) {
368 @@ -264,6 +267,7 @@ int NCONF_load(CONF *conf, const char *file, long *eline)
369
370 return conf->meth->load(conf, file, eline);
371 }
372 +#endif
373
374 #ifndef OPENSSL_NO_FP_API
375 int NCONF_load_fp(CONF *conf, FILE *fp, long *eline)
376 diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
377 index 9acfca4..5e0a482 100644
378 --- a/crypto/conf/conf_mod.c
379 +++ b/crypto/conf/conf_mod.c
380 @@ -159,6 +159,7 @@ int CONF_modules_load(const CONF *cnf, const char *appname,
381
382 }
383
384 +#ifndef OPENSSL_NO_STDIO
385 int CONF_modules_load_file(const char *filename, const char *appname,
386 unsigned long flags)
387 {
388 @@ -194,6 +195,7 @@ int CONF_modules_load_file(const char *filename, const char *appname,
389
390 return ret;
391 }
392 +#endif
393
394 static int module_run(const CONF *cnf, char *name, char *value,
395 unsigned long flags)
396 diff --git a/crypto/conf/conf_sap.c b/crypto/conf/conf_sap.c
397 index c042cf2..a25b636 100644
398 --- a/crypto/conf/conf_sap.c
399 +++ b/crypto/conf/conf_sap.c
400 @@ -87,9 +87,11 @@ void OPENSSL_config(const char *config_name)
401 ENGINE_load_builtin_engines();
402 #endif
403 ERR_clear_error();
404 +#ifndef OPENSSL_NO_STDIO
405 CONF_modules_load_file(NULL, config_name,
406 CONF_MFLAGS_DEFAULT_SECTION |
407 CONF_MFLAGS_IGNORE_MISSING_FILE);
408 +#endif
409 openssl_configured = 1;
410 }
411
412 diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
413 index c9f674b..39ead7f 100644
414 --- a/crypto/cryptlib.c
415 +++ b/crypto/cryptlib.c
416 @@ -263,7 +263,7 @@ int CRYPTO_get_new_dynlockid(void)
417 return (0);
418 }
419 pointer->references = 1;
420 - pointer->data = dynlock_create_callback(__FILE__, __LINE__);
421 + pointer->data = dynlock_create_callback(OPENSSL_FILE, OPENSSL_LINE);
422 if (pointer->data == NULL) {
423 OPENSSL_free(pointer);
424 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
425 @@ -289,7 +289,7 @@ int CRYPTO_get_new_dynlockid(void)
426 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
427
428 if (i == -1) {
429 - dynlock_destroy_callback(pointer->data, __FILE__, __LINE__);
430 + dynlock_destroy_callback(pointer->data, OPENSSL_FILE, OPENSSL_LINE);
431 OPENSSL_free(pointer);
432 } else
433 i += 1; /* to avoid 0 */
434 @@ -328,7 +328,7 @@ void CRYPTO_destroy_dynlockid(int i)
435 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
436
437 if (pointer) {
438 - dynlock_destroy_callback(pointer->data, __FILE__, __LINE__);
439 + dynlock_destroy_callback(pointer->data, OPENSSL_FILE, OPENSSL_LINE);
440 OPENSSL_free(pointer);
441 }
442 }
443 @@ -670,6 +670,7 @@ unsigned long *OPENSSL_ia32cap_loc(void)
444 }
445
446 # if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
447 +#include <stdio.h>
448 # define OPENSSL_CPUID_SETUP
449 # if defined(_WIN32)
450 typedef unsigned __int64 IA32CAP;
451 @@ -980,11 +981,13 @@ void OPENSSL_showfatal(const char *fmta, ...)
452 #else
453 void OPENSSL_showfatal(const char *fmta, ...)
454 {
455 +#ifndef OPENSSL_NO_STDIO
456 va_list ap;
457
458 va_start(ap, fmta);
459 vfprintf(stderr, fmta, ap);
460 va_end(ap);
461 +#endif
462 }
463
464 int OPENSSL_isservice(void)
465 @@ -1011,10 +1014,12 @@ void OpenSSLDie(const char *file, int line, const char *assertion)
466 #endif
467 }
468
469 +#ifndef OPENSSL_NO_STDIO
470 void *OPENSSL_stderr(void)
471 {
472 return stderr;
473 }
474 +#endif
475
476 int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
477 {
478 diff --git a/crypto/cryptlib.h b/crypto/cryptlib.h
479 index fba180a..3e3ea5e 100644
480 --- a/crypto/cryptlib.h
481 +++ b/crypto/cryptlib.h
482 @@ -101,7 +101,9 @@ extern "C" {
483 void OPENSSL_cpuid_setup(void);
484 extern unsigned int OPENSSL_ia32cap_P[];
485 void OPENSSL_showfatal(const char *fmta, ...);
486 +#ifndef OPENSSL_NO_STDIO
487 void *OPENSSL_stderr(void);
488 +#endif
489 extern int OPENSSL_NONPIC_relocated;
490
491 #ifdef __cplusplus
492 diff --git a/crypto/crypto.h b/crypto/crypto.h
493 index c450d7a..063d78e 100644
494 --- a/crypto/crypto.h
495 +++ b/crypto/crypto.h
496 @@ -235,15 +235,15 @@ typedef struct openssl_item_st {
497 # ifndef OPENSSL_NO_LOCKING
498 # ifndef CRYPTO_w_lock
499 # define CRYPTO_w_lock(type) \
500 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
501 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
502 # define CRYPTO_w_unlock(type) \
503 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
504 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
505 # define CRYPTO_r_lock(type) \
506 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
507 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
508 # define CRYPTO_r_unlock(type) \
509 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
510 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
511 # define CRYPTO_add(addr,amount,type) \
512 - CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
513 + CRYPTO_add_lock(addr,amount,type,OPENSSL_FILE,OPENSSL_LINE)
514 # endif
515 # else
516 # define CRYPTO_w_lock(a)
517 @@ -378,19 +378,19 @@ int CRYPTO_is_mem_check_on(void);
518 # define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
519 # define is_MemCheck_on() CRYPTO_is_mem_check_on()
520
521 -# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
522 -# define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
523 +# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,OPENSSL_FILE,OPENSSL_LINE)
524 +# define OPENSSL_strdup(str) CRYPTO_strdup((str),OPENSSL_FILE,OPENSSL_LINE)
525 # define OPENSSL_realloc(addr,num) \
526 - CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
527 + CRYPTO_realloc((char *)addr,(int)num,OPENSSL_FILE,OPENSSL_LINE)
528 # define OPENSSL_realloc_clean(addr,old_num,num) \
529 - CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
530 + CRYPTO_realloc_clean(addr,old_num,num,OPENSSL_FILE,OPENSSL_LINE)
531 # define OPENSSL_remalloc(addr,num) \
532 - CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
533 + CRYPTO_remalloc((char **)addr,(int)num,OPENSSL_FILE,OPENSSL_LINE)
534 # define OPENSSL_freeFunc CRYPTO_free
535 # define OPENSSL_free(addr) CRYPTO_free(addr)
536
537 # define OPENSSL_malloc_locked(num) \
538 - CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
539 + CRYPTO_malloc_locked((int)num,OPENSSL_FILE,OPENSSL_LINE)
540 # define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
541
542 const char *SSLeay_version(int type);
543 @@ -545,7 +545,7 @@ void CRYPTO_set_mem_debug_options(long bits);
544 long CRYPTO_get_mem_debug_options(void);
545
546 # define CRYPTO_push_info(info) \
547 - CRYPTO_push_info_(info, __FILE__, __LINE__);
548 + CRYPTO_push_info_(info, OPENSSL_FILE, OPENSSL_LINE);
549 int CRYPTO_push_info_(const char *info, const char *file, int line);
550 int CRYPTO_pop_info(void);
551 int CRYPTO_remove_all_info(void);
552 @@ -588,7 +588,7 @@ void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
553
554 /* die if we have to */
555 void OpenSSLDie(const char *file, int line, const char *assertion);
556 -# define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
557 +# define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(OPENSSL_FILE, OPENSSL_LINE, #e),1))
558
559 unsigned long *OPENSSL_ia32cap_loc(void);
560 # define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
561 @@ -605,14 +605,14 @@ void OPENSSL_init(void);
562 # define fips_md_init_ctx(alg, cx) \
563 int alg##_Init(cx##_CTX *c) \
564 { \
565 - if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
566 + if (FIPS_mode()) OpenSSLDie(OPENSSL_FILE, OPENSSL_LINE, \
567 "Low level API call to digest " #alg " forbidden in FIPS mode!"); \
568 return private_##alg##_Init(c); \
569 } \
570 int private_##alg##_Init(cx##_CTX *c)
571
572 # define fips_cipher_abort(alg) \
573 - if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
574 + if (FIPS_mode()) OpenSSLDie(OPENSSL_FILE, OPENSSL_LINE, \
575 "Low level API call to cipher " #alg " forbidden in FIPS mode!")
576
577 # else
578 diff --git a/crypto/des/read2pwd.c b/crypto/des/read2pwd.c
579 index 01e275f..7633139 100644
580 --- a/crypto/des/read2pwd.c
581 +++ b/crypto/des/read2pwd.c
582 @@ -114,6 +114,10 @@
583 #include <openssl/ui.h>
584 #include <openssl/crypto.h>
585
586 +#ifndef BUFSIZ
587 +#define BUFSIZ 256
588 +#endif
589 +
590 int DES_read_password(DES_cblock *key, const char *prompt, int verify)
591 {
592 int ok;
593 diff --git a/crypto/dh/Makefile b/crypto/dh/Makefile
594 index 46fa5ac..cc366ec 100644
595 --- a/crypto/dh/Makefile
596 +++ b/crypto/dh/Makefile
597 @@ -134,7 +134,7 @@ dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
598 dh_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
599 dh_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
600 dh_gen.o: ../cryptlib.h dh_gen.c
601 -dh_kdf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
602 +dh_kdf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
603 dh_kdf.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
604 dh_kdf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
605 dh_kdf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
606 diff --git a/crypto/dh/dh.h b/crypto/dh/dh.h
607 index 5498a9d..4a5c665 100644
608 --- a/crypto/dh/dh.h
609 +++ b/crypto/dh/dh.h
610 @@ -240,11 +240,13 @@ DH *DH_get_1024_160(void);
611 DH *DH_get_2048_224(void);
612 DH *DH_get_2048_256(void);
613
614 +# ifndef OPENSSL_NO_CMS
615 /* RFC2631 KDF */
616 int DH_KDF_X9_42(unsigned char *out, size_t outlen,
617 const unsigned char *Z, size_t Zlen,
618 ASN1_OBJECT *key_oid,
619 const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);
620 +# endif
621
622 # define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \
623 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
624 @@ -337,7 +339,9 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen,
625
626 /* KDF types */
627 # define EVP_PKEY_DH_KDF_NONE 1
628 +# ifndef OPENSSL_NO_CMS
629 # define EVP_PKEY_DH_KDF_X9_42 2
630 +# endif
631
632 /* BEGIN ERROR CODES */
633 /*
634 diff --git a/crypto/dh/dh_kdf.c b/crypto/dh/dh_kdf.c
635 index a882cb2..4eddb9a 100644
636 --- a/crypto/dh/dh_kdf.c
637 +++ b/crypto/dh/dh_kdf.c
638 @@ -51,13 +51,18 @@
639 * ====================================================================
640 */
641
642 +#include <e_os.h>
643 +
644 +#ifndef OPENSSL_NO_CMS
645 #include <string.h>
646 #include <openssl/dh.h>
647 #include <openssl/evp.h>
648 #include <openssl/asn1.h>
649 #include <openssl/cms.h>
650
651 +
652 /* Key derivation from X9.42/RFC2631 */
653 +/* Uses CMS functions, hence the #ifdef wrapper. */
654
655 #define DH_KDF_MAX (1L << 30)
656
657 @@ -185,3 +190,4 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen,
658 EVP_MD_CTX_cleanup(&mctx);
659 return rv;
660 }
661 +#endif
662 diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c
663 index b58e3fa..c6288f6 100644
664 --- a/crypto/dh/dh_pmeth.c
665 +++ b/crypto/dh/dh_pmeth.c
666 @@ -207,7 +207,11 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
667 case EVP_PKEY_CTRL_DH_KDF_TYPE:
668 if (p1 == -2)
669 return dctx->kdf_type;
670 +#ifdef OPENSSL_NO_CMS
671 + if (p1 != EVP_PKEY_DH_KDF_NONE)
672 +#else
673 if (p1 != EVP_PKEY_DH_KDF_NONE && p1 != EVP_PKEY_DH_KDF_X9_42)
674 +#endif
675 return -2;
676 dctx->kdf_type = p1;
677 return 1;
678 @@ -448,7 +452,10 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
679 return ret;
680 *keylen = ret;
681 return 1;
682 - } else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) {
683 + }
684 +#ifndef OPENSSL_NO_CMS
685 + else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) {
686 +
687 unsigned char *Z = NULL;
688 size_t Zlen = 0;
689 if (!dctx->kdf_outlen || !dctx->kdf_oid)
690 @@ -479,7 +486,8 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
691 }
692 return ret;
693 }
694 - return 1;
695 +#endif
696 + return 0;
697 }
698
699 const EVP_PKEY_METHOD dh_pkey_meth = {
700 diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c
701 index 83e208c..4869098 100644
702 --- a/crypto/ec/ec_ameth.c
703 +++ b/crypto/ec/ec_ameth.c
704 @@ -67,8 +67,10 @@
705 #include <openssl/asn1t.h>
706 #include "asn1_locl.h"
707
708 +#ifndef OPENSSL_NO_CMS
709 static int ecdh_cms_decrypt(CMS_RecipientInfo *ri);
710 static int ecdh_cms_encrypt(CMS_RecipientInfo *ri);
711 +#endif
712
713 static int eckey_param2type(int *pptype, void **ppval, EC_KEY *ec_key)
714 {
715 diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h
716 index 46f163b..b4a72a0 100644
717 --- a/crypto/engine/eng_int.h
718 +++ b/crypto/engine/eng_int.h
719 @@ -88,7 +88,7 @@ extern "C" {
720 (unsigned int)(e), (isfunct ? "funct" : "struct"), \
721 ((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \
722 ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
723 - (__FILE__), (__LINE__));
724 + (OPENSSL_FILE), (OPENSSL_LINE));
725
726 # else
727
728 @@ -136,7 +136,7 @@ ENGINE *engine_table_select(ENGINE_TABLE **table, int nid);
729 # else
730 ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
731 int l);
732 -# define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__)
733 +# define engine_table_select(t,n) engine_table_select_tmp(t,n,OPENSSL_FILE,OPENSSL_LINE)
734 # endif
735 typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk,
736 ENGINE *def, void *arg);
737 diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c
738 index 34b0029..cf622bb 100644
739 --- a/crypto/engine/eng_openssl.c
740 +++ b/crypto/engine/eng_openssl.c
741 @@ -86,7 +86,9 @@
742 * this is no longer automatic in ENGINE_load_builtin_engines().
743 */
744 #define TEST_ENG_OPENSSL_RC4
745 +#ifndef OPENSSL_NO_FP_API
746 #define TEST_ENG_OPENSSL_PKEY
747 +#endif
748 /* #define TEST_ENG_OPENSSL_RC4_OTHERS */
749 #define TEST_ENG_OPENSSL_RC4_P_INIT
750 /* #define TEST_ENG_OPENSSL_RC4_P_CIPHER */
751 diff --git a/crypto/err/err.h b/crypto/err/err.h
752 index 585aa8b..04c6cfc 100644
753 --- a/crypto/err/err.h
754 +++ b/crypto/err/err.h
755 @@ -200,39 +200,39 @@ typedef struct err_state_st {
756
757 # define ERR_LIB_USER 128
758
759 -# define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)
760 -# define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)
761 -# define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)
762 -# define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)
763 -# define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)
764 -# define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)
765 -# define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)
766 -# define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)
767 -# define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)
768 -# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)
769 -# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)
770 -# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)
771 -# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)
772 -# define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)
773 -# define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)
774 -# define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)
775 -# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)
776 -# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)
777 -# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)
778 -# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)
779 -# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)
780 -# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)
781 -# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)
782 -# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)
783 -# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)
784 -# define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)
785 -# define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)
786 -# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)
787 -# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)
788 -# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)
789 -# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)
790 -# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)
791 -# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)
792 +# define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
793 +# define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
794 +# define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
795 +# define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
796 +# define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
797 +# define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
798 +# define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
799 +# define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
800 +# define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
801 +# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
802 +# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
803 +# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
804 +# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
805 +# define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
806 +# define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
807 +# define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
808 +# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
809 +# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
810 +# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
811 +# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
812 +# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
813 +# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
814 +# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
815 +# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
816 +# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
817 +# define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
818 +# define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
819 +# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
820 +# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
821 +# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
822 +# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
823 +# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
824 +# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
825
826 /*
827 * Borland C seems too stupid to be able to shift and do longs in the
828 diff --git a/crypto/opensslconf.h.in b/crypto/opensslconf.h.in
829 index 7a1c85d..a5f51a7 100644
830 --- a/crypto/opensslconf.h.in
831 +++ b/crypto/opensslconf.h.in
832 @@ -1,5 +1,15 @@
833 /* crypto/opensslconf.h.in */
834
835 +#ifndef OPENSSL_FILE
836 +#ifdef OPENSSL_NO_FILENAMES
837 +#define OPENSSL_FILE ""
838 +#define OPENSSL_LINE 0
839 +#else
840 +#define OPENSSL_FILE __FILE__
841 +#define OPENSSL_LINE __LINE__
842 +#endif
843 +#endif
844 +
845 /* Generate 80386 code? */
846 #undef I386_ONLY
847
848 diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h
849 index d3b23fc..87b0b6a 100644
850 --- a/crypto/pem/pem.h
851 +++ b/crypto/pem/pem.h
852 @@ -324,6 +324,7 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
853
854 # define DECLARE_PEM_read_fp(name, type) /**/
855 # define DECLARE_PEM_write_fp(name, type) /**/
856 +# define DECLARE_PEM_write_fp_const(name, type) /**/
857 # define DECLARE_PEM_write_cb_fp(name, type) /**/
858 # else
859
860 @@ -417,6 +418,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
861 pem_password_cb *cd, void *u);
862 # endif
863
864 +#ifndef OPENSSL_NO_FP_API
865 int PEM_read(FILE *fp, char **name, char **header,
866 unsigned char **data, long *len);
867 int PEM_write(FILE *fp, const char *name, const char *hdr,
868 @@ -428,6 +430,7 @@ int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
869 int klen, pem_password_cb *callback, void *u);
870 STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
871 pem_password_cb *cb, void *u);
872 +#endif
873
874 int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
875 EVP_MD *md_type, unsigned char **ek, int *ekl,
876 @@ -494,6 +497,7 @@ int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
877 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
878 void *u);
879
880 +#ifndef OPENSSL_NO_FP_API
881 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
882 char *kstr, int klen,
883 pem_password_cb *cb, void *u);
884 @@ -510,7 +514,7 @@ EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
885 int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
886 char *kstr, int klen, pem_password_cb *cd,
887 void *u);
888 -
889 +#endif
890 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
891 int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
892
893 diff --git a/crypto/pem/pem_pk8.c b/crypto/pem/pem_pk8.c
894 index 5747c73..fe465cc 100644
895 --- a/crypto/pem/pem_pk8.c
896 +++ b/crypto/pem/pem_pk8.c
897 @@ -69,10 +69,12 @@
898 static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder,
899 int nid, const EVP_CIPHER *enc,
900 char *kstr, int klen, pem_password_cb *cb, void *u);
901 +
902 +#ifndef OPENSSL_NO_FP_API
903 static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder,
904 int nid, const EVP_CIPHER *enc,
905 char *kstr, int klen, pem_password_cb *cb, void *u);
906 -
907 +#endif
908 /*
909 * These functions write a private key in PKCS#8 format: it is a "drop in"
910 * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc'
911 diff --git a/crypto/pkcs7/pk7_smime.c b/crypto/pkcs7/pk7_smime.c
912 index c4d3724..0bc3d43 100644
913 --- a/crypto/pkcs7/pk7_smime.c
914 +++ b/crypto/pkcs7/pk7_smime.c
915 @@ -64,6 +64,9 @@
916 #include <openssl/x509.h>
917 #include <openssl/x509v3.h>
918
919 +
920 +#define BUFFERSIZE 4096
921 +
922 static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
923
924 PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
925 @@ -254,7 +257,7 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
926 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
927 PKCS7_SIGNER_INFO *si;
928 X509_STORE_CTX cert_ctx;
929 - char buf[4096];
930 + char *buf = NULL;
931 int i, j = 0, k, ret = 0;
932 BIO *p7bio = NULL;
933 BIO *tmpin = NULL, *tmpout = NULL;
934 @@ -274,12 +277,29 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
935 PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_NO_CONTENT);
936 return 0;
937 }
938 +#if 0
939 + /*
940 + * NB: this test commented out because some versions of Netscape
941 + * illegally include zero length content when signing data. Also
942 + * Microsoft Authenticode includes a SpcIndirectDataContent data
943 + * structure which describes the content to be protected by the
944 + * signature, rather than directly embedding that content. So
945 + * Authenticode implementations are also expected to use
946 + * PKCS7_verify() with explicit external data, on non-detached
947 + * PKCS#7 signatures.
948 + *
949 + * In OpenSSL 1.1 a new flag PKCS7_NO_DUAL_CONTENT has been
950 + * introduced to disable this sanity check. For the 1.0.2 branch
951 + * this change is not acceptable, so the check remains completely
952 + * commented out (as it has been for a long time).
953 + */
954
955 /* Check for data and content: two sets of data */
956 if (!PKCS7_get_detached(p7) && indata) {
957 PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_CONTENT_AND_DATA_PRESENT);
958 return 0;
959 }
960 +#endif
961
962 sinfos = PKCS7_get_signer_info(p7);
963
964 @@ -356,8 +376,12 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
965 tmpout = out;
966
967 /* We now have to 'read' from p7bio to calculate digests etc. */
968 + if ((buf = OPENSSL_malloc(BUFFERSIZE)) == NULL) {
969 + PKCS7err(PKCS7_F_PKCS7_VERIFY, ERR_R_MALLOC_FAILURE);
970 + goto err;
971 + }
972 for (;;) {
973 - i = BIO_read(p7bio, buf, sizeof(buf));
974 + i = BIO_read(p7bio, buf, BUFFERSIZE);
975 if (i <= 0)
976 break;
977 if (tmpout)
978 @@ -388,6 +412,7 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
979 ret = 1;
980
981 err:
982 + OPENSSL_free(buf);
983 if (tmpin == indata) {
984 if (indata)
985 BIO_pop(p7bio);
986 @@ -506,7 +531,7 @@ int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags)
987 {
988 BIO *tmpmem;
989 int ret, i;
990 - char buf[4096];
991 + char *buf = NULL;
992
993 if (!p7) {
994 PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_INVALID_NULL_POINTER);
995 @@ -550,24 +575,29 @@ int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags)
996 }
997 BIO_free_all(bread);
998 return ret;
999 - } else {
1000 - for (;;) {
1001 - i = BIO_read(tmpmem, buf, sizeof(buf));
1002 - if (i <= 0) {
1003 - ret = 1;
1004 - if (BIO_method_type(tmpmem) == BIO_TYPE_CIPHER) {
1005 - if (!BIO_get_cipher_status(tmpmem))
1006 - ret = 0;
1007 - }
1008 -
1009 - break;
1010 - }
1011 - if (BIO_write(data, buf, i) != i) {
1012 - ret = 0;
1013 - break;
1014 + }
1015 + if ((buf = OPENSSL_malloc(BUFFERSIZE)) == NULL) {
1016 + PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE);
1017 + goto err;
1018 + }
1019 + for (;;) {
1020 + i = BIO_read(tmpmem, buf, BUFFERSIZE);
1021 + if (i <= 0) {
1022 + ret = 1;
1023 + if (BIO_method_type(tmpmem) == BIO_TYPE_CIPHER) {
1024 + if (!BIO_get_cipher_status(tmpmem))
1025 + ret = 0;
1026 }
1027 +
1028 + break;
1029 + }
1030 + if (BIO_write(data, buf, i) != i) {
1031 + ret = 0;
1032 + break;
1033 }
1034 - BIO_free_all(tmpmem);
1035 - return ret;
1036 }
1037 +err:
1038 + OPENSSL_free(buf);
1039 + BIO_free_all(tmpmem);
1040 + return ret;
1041 }
1042 diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
1043 index 266111e..f60fac6 100644
1044 --- a/crypto/rand/rand_unix.c
1045 +++ b/crypto/rand/rand_unix.c
1046 @@ -116,7 +116,7 @@
1047 #include <openssl/rand.h>
1048 #include "rand_lcl.h"
1049
1050 -#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE))
1051 +#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_UEFI))
1052
1053 # include <sys/types.h>
1054 # include <sys/time.h>
1055 @@ -439,7 +439,7 @@ int RAND_poll(void)
1056 * defined(OPENSSL_SYS_VXWORKS) ||
1057 * defined(OPENSSL_SYS_NETWARE)) */
1058
1059 -#if defined(OPENSSL_SYS_VXWORKS)
1060 +#if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
1061 int RAND_poll(void)
1062 {
1063 return 0;
1064 diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c
1065 index 4e06218..ddead3d 100644
1066 --- a/crypto/rsa/rsa_ameth.c
1067 +++ b/crypto/rsa/rsa_ameth.c
1068 @@ -68,10 +68,12 @@
1069 #endif
1070 #include "asn1_locl.h"
1071
1072 +#ifndef OPENSSL_NO_CMS
1073 static int rsa_cms_sign(CMS_SignerInfo *si);
1074 static int rsa_cms_verify(CMS_SignerInfo *si);
1075 static int rsa_cms_decrypt(CMS_RecipientInfo *ri);
1076 static int rsa_cms_encrypt(CMS_RecipientInfo *ri);
1077 +#endif
1078
1079 static int rsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
1080 {
1081 @@ -665,6 +667,7 @@ static int rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx,
1082 return rv;
1083 }
1084
1085 +#ifndef OPENSSL_NO_CMS
1086 static int rsa_cms_verify(CMS_SignerInfo *si)
1087 {
1088 int nid, nid2;
1089 @@ -683,6 +686,7 @@ static int rsa_cms_verify(CMS_SignerInfo *si)
1090 }
1091 return 0;
1092 }
1093 +#endif
1094
1095 /*
1096 * Customised RSA item verification routine. This is called when a signature
1097 @@ -705,6 +709,7 @@ static int rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
1098 return -1;
1099 }
1100
1101 +#ifndef OPENSSL_NO_CMS
1102 static int rsa_cms_sign(CMS_SignerInfo *si)
1103 {
1104 int pad_mode = RSA_PKCS1_PADDING;
1105 @@ -729,6 +734,7 @@ static int rsa_cms_sign(CMS_SignerInfo *si)
1106 X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsassaPss), V_ASN1_SEQUENCE, os);
1107 return 1;
1108 }
1109 +#endif
1110
1111 static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
1112 X509_ALGOR *alg1, X509_ALGOR *alg2,
1113 @@ -762,6 +768,7 @@ static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
1114 return 2;
1115 }
1116
1117 +#ifndef OPENSSL_NO_CMS
1118 static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg,
1119 X509_ALGOR **pmaskHash)
1120 {
1121 @@ -920,6 +927,7 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
1122 ASN1_STRING_free(os);
1123 return rv;
1124 }
1125 +#endif
1126
1127 const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = {
1128 {
1129 diff --git a/crypto/srp/srp.h b/crypto/srp/srp.h
1130 index d072536..73b945f 100644
1131 --- a/crypto/srp/srp.h
1132 +++ b/crypto/srp/srp.h
1133 @@ -114,7 +114,9 @@ DECLARE_STACK_OF(SRP_gN)
1134
1135 SRP_VBASE *SRP_VBASE_new(char *seed_key);
1136 int SRP_VBASE_free(SRP_VBASE *vb);
1137 +#ifndef OPENSSL_NO_STDIO
1138 int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
1139 +#endif
1140 SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);
1141 char *SRP_create_verifier(const char *user, const char *pass, char **salt,
1142 char **verifier, const char *N, const char *g);
1143 diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c
1144 index a3f1a8a..3fbb186 100644
1145 --- a/crypto/srp/srp_vfy.c
1146 +++ b/crypto/srp/srp_vfy.c
1147 @@ -225,6 +225,7 @@ static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,
1148 return (info == NULL || NULL != (vinfo->info = BUF_strdup(info)));
1149 }
1150
1151 +#ifndef OPENSSL_NO_STDIO
1152 static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
1153 const char *v)
1154 {
1155 @@ -239,6 +240,7 @@ static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
1156 len = t_fromb64(tmp, s);
1157 return ((vinfo->s = BN_bin2bn(tmp, len, NULL)) != NULL);
1158 }
1159 +#endif
1160
1161 static int SRP_user_pwd_set_sv_BN(SRP_user_pwd *vinfo, BIGNUM *s, BIGNUM *v)
1162 {
1163 @@ -279,6 +281,7 @@ int SRP_VBASE_free(SRP_VBASE *vb)
1164 return 0;
1165 }
1166
1167 +#ifndef OPENSSL_NO_STDIO
1168 static SRP_gN_cache *SRP_gN_new_init(const char *ch)
1169 {
1170 unsigned char tmp[MAX_LEN];
1171 @@ -310,6 +313,7 @@ static void SRP_gN_free(SRP_gN_cache *gN_cache)
1172 BN_free(gN_cache->bn);
1173 OPENSSL_free(gN_cache);
1174 }
1175 +#endif
1176
1177 static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)
1178 {
1179 @@ -326,6 +330,7 @@ static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)
1180 return SRP_get_default_gN(id);
1181 }
1182
1183 +#ifndef OPENSSL_NO_STDIO
1184 static BIGNUM *SRP_gN_place_bn(STACK_OF(SRP_gN_cache) *gN_cache, char *ch)
1185 {
1186 int i;
1187 @@ -467,6 +472,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
1188 return error_code;
1189
1190 }
1191 +#endif
1192
1193 SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)
1194 {
1195 diff --git a/crypto/ts/ts.h b/crypto/ts/ts.h
1196 index 16eccbb..a9fe40e 100644
1197 --- a/crypto/ts/ts.h
1198 +++ b/crypto/ts/ts.h
1199 @@ -281,8 +281,10 @@ TS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);
1200
1201 TS_REQ *TS_REQ_dup(TS_REQ *a);
1202
1203 +#ifndef OPENSSL_NO_FP_API
1204 TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);
1205 int i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);
1206 +#endif
1207 TS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);
1208 int i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);
1209
1210 @@ -294,10 +296,12 @@ TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,
1211
1212 TS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);
1213
1214 +#ifndef OPENSSL_NO_FP_API
1215 TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);
1216 int i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);
1217 -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT **a);
1218 -int i2d_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT *a);
1219 +#endif
1220 +TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a);
1221 +int i2d_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT *a);
1222
1223 TS_RESP *TS_RESP_new(void);
1224 void TS_RESP_free(TS_RESP *a);
1225 @@ -306,10 +310,12 @@ TS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);
1226 TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);
1227 TS_RESP *TS_RESP_dup(TS_RESP *a);
1228
1229 +#ifndef OPENSSL_NO_FP_API
1230 TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);
1231 int i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);
1232 -TS_RESP *d2i_TS_RESP_bio(BIO *fp, TS_RESP **a);
1233 -int i2d_TS_RESP_bio(BIO *fp, TS_RESP *a);
1234 +#endif
1235 +TS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a);
1236 +int i2d_TS_RESP_bio(BIO *bio, TS_RESP *a);
1237
1238 TS_STATUS_INFO *TS_STATUS_INFO_new(void);
1239 void TS_STATUS_INFO_free(TS_STATUS_INFO *a);
1240 @@ -325,10 +331,12 @@ TS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,
1241 long length);
1242 TS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);
1243
1244 +#ifndef OPENSSL_NO_FP_API
1245 TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);
1246 int i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);
1247 -TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO **a);
1248 -int i2d_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO *a);
1249 +#endif
1250 +TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a);
1251 +int i2d_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO *a);
1252
1253 TS_ACCURACY *TS_ACCURACY_new(void);
1254 void TS_ACCURACY_free(TS_ACCURACY *a);
1255 @@ -728,15 +736,18 @@ int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);
1256 * ts/ts_conf.c
1257 */
1258
1259 +#ifndef OPENSSL_NO_STDIO
1260 X509 *TS_CONF_load_cert(const char *file);
1261 STACK_OF(X509) *TS_CONF_load_certs(const char *file);
1262 EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);
1263 +#endif
1264 const char *TS_CONF_get_tsa_section(CONF *conf, const char *section);
1265 int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,
1266 TS_RESP_CTX *ctx);
1267 int TS_CONF_set_crypto_device(CONF *conf, const char *section,
1268 const char *device);
1269 int TS_CONF_set_default_engine(const char *name);
1270 +#ifndef OPENSSL_NO_STDIO
1271 int TS_CONF_set_signer_cert(CONF *conf, const char *section,
1272 const char *cert, TS_RESP_CTX *ctx);
1273 int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
1274 @@ -744,6 +755,7 @@ int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
1275 int TS_CONF_set_signer_key(CONF *conf, const char *section,
1276 const char *key, const char *pass,
1277 TS_RESP_CTX *ctx);
1278 +#endif
1279 int TS_CONF_set_def_policy(CONF *conf, const char *section,
1280 const char *policy, TS_RESP_CTX *ctx);
1281 int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);
1282 @@ -784,6 +796,11 @@ void ERR_load_TS_strings(void);
1283 # define TS_F_TS_CHECK_SIGNING_CERTS 103
1284 # define TS_F_TS_CHECK_STATUS_INFO 104
1285 # define TS_F_TS_COMPUTE_IMPRINT 145
1286 +# define TS_F_TS_CONF_INVALID 151
1287 +# define TS_F_TS_CONF_LOAD_CERT 153
1288 +# define TS_F_TS_CONF_LOAD_CERTS 154
1289 +# define TS_F_TS_CONF_LOAD_KEY 155
1290 +# define TS_F_TS_CONF_LOOKUP_FAIL 152
1291 # define TS_F_TS_CONF_SET_DEFAULT_ENGINE 146
1292 # define TS_F_TS_GET_STATUS_TEXT 105
1293 # define TS_F_TS_MSG_IMPRINT_SET_ALGO 118
1294 @@ -822,6 +839,8 @@ void ERR_load_TS_strings(void);
1295 /* Reason codes. */
1296 # define TS_R_BAD_PKCS7_TYPE 132
1297 # define TS_R_BAD_TYPE 133
1298 +# define TS_R_CANNOT_LOAD_CERT 137
1299 +# define TS_R_CANNOT_LOAD_KEY 138
1300 # define TS_R_CERTIFICATE_VERIFY_ERROR 100
1301 # define TS_R_COULD_NOT_SET_ENGINE 127
1302 # define TS_R_COULD_NOT_SET_TIME 115
1303 @@ -854,6 +873,8 @@ void ERR_load_TS_strings(void);
1304 # define TS_R_UNACCEPTABLE_POLICY 125
1305 # define TS_R_UNSUPPORTED_MD_ALGORITHM 126
1306 # define TS_R_UNSUPPORTED_VERSION 113
1307 +# define TS_R_VAR_BAD_VALUE 135
1308 +# define TS_R_VAR_LOOKUP_FAILURE 136
1309 # define TS_R_WRONG_CONTENT_TYPE 114
1310
1311 #ifdef __cplusplus
1312 diff --git a/crypto/ts/ts_conf.c b/crypto/ts/ts_conf.c
1313 index 4716b23..c4416ba 100644
1314 --- a/crypto/ts/ts_conf.c
1315 +++ b/crypto/ts/ts_conf.c
1316 @@ -92,6 +92,7 @@
1317
1318 /* Function definitions for certificate and key loading. */
1319
1320 +#ifndef OPENSSL_NO_STDIO
1321 X509 *TS_CONF_load_cert(const char *file)
1322 {
1323 BIO *cert = NULL;
1324 @@ -102,7 +103,7 @@ X509 *TS_CONF_load_cert(const char *file)
1325 x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL);
1326 end:
1327 if (x == NULL)
1328 - fprintf(stderr, "unable to load certificate: %s\n", file);
1329 + TSerr(TS_F_TS_CONF_LOAD_CERT, TS_R_CANNOT_LOAD_CERT);
1330 BIO_free(cert);
1331 return x;
1332 }
1333 @@ -129,7 +130,7 @@ STACK_OF(X509) *TS_CONF_load_certs(const char *file)
1334 }
1335 end:
1336 if (othercerts == NULL)
1337 - fprintf(stderr, "unable to load certificates: %s\n", file);
1338 + TSerr(TS_F_TS_CONF_LOAD_CERTS, TS_R_CANNOT_LOAD_CERT);
1339 sk_X509_INFO_pop_free(allcerts, X509_INFO_free);
1340 BIO_free(certs);
1341 return othercerts;
1342 @@ -145,21 +146,24 @@ EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass)
1343 pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, (char *)pass);
1344 end:
1345 if (pkey == NULL)
1346 - fprintf(stderr, "unable to load private key: %s\n", file);
1347 + TSerr(TS_F_TS_CONF_LOAD_KEY, TS_R_CANNOT_LOAD_KEY);
1348 BIO_free(key);
1349 return pkey;
1350 }
1351 +#endif /* !OPENSSL_NO_STDIO */
1352
1353 /* Function definitions for handling configuration options. */
1354
1355 static void TS_CONF_lookup_fail(const char *name, const char *tag)
1356 {
1357 - fprintf(stderr, "variable lookup failed for %s::%s\n", name, tag);
1358 + TSerr(TS_F_TS_CONF_LOOKUP_FAIL, TS_R_VAR_LOOKUP_FAILURE);
1359 + ERR_add_error_data(3, name, "::", tag);
1360 }
1361
1362 static void TS_CONF_invalid(const char *name, const char *tag)
1363 {
1364 - fprintf(stderr, "invalid variable value for %s::%s\n", name, tag);
1365 + TSerr(TS_F_TS_CONF_INVALID, TS_R_VAR_BAD_VALUE);
1366 + ERR_add_error_data(3, name, "::", tag);
1367 }
1368
1369 const char *TS_CONF_get_tsa_section(CONF *conf, const char *section)
1370 @@ -237,6 +241,7 @@ int TS_CONF_set_default_engine(const char *name)
1371
1372 #endif
1373
1374 +#ifndef OPENSSL_NO_STDIO
1375 int TS_CONF_set_signer_cert(CONF *conf, const char *section,
1376 const char *cert, TS_RESP_CTX *ctx)
1377 {
1378 @@ -302,6 +307,7 @@ int TS_CONF_set_signer_key(CONF *conf, const char *section,
1379 EVP_PKEY_free(key_obj);
1380 return ret;
1381 }
1382 +#endif /* !OPENSSL_NO_STDIO */
1383
1384 int TS_CONF_set_def_policy(CONF *conf, const char *section,
1385 const char *policy, TS_RESP_CTX *ctx)
1386 diff --git a/crypto/ts/ts_err.c b/crypto/ts/ts_err.c
1387 index ff1abf4..3f5b78f 100644
1388 --- a/crypto/ts/ts_err.c
1389 +++ b/crypto/ts/ts_err.c
1390 @@ -1,6 +1,6 @@
1391 /* crypto/ts/ts_err.c */
1392 /* ====================================================================
1393 - * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
1394 + * Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved.
1395 *
1396 * Redistribution and use in source and binary forms, with or without
1397 * modification, are permitted provided that the following conditions
1398 @@ -87,6 +87,11 @@ static ERR_STRING_DATA TS_str_functs[] = {
1399 {ERR_FUNC(TS_F_TS_CHECK_SIGNING_CERTS), "TS_CHECK_SIGNING_CERTS"},
1400 {ERR_FUNC(TS_F_TS_CHECK_STATUS_INFO), "TS_CHECK_STATUS_INFO"},
1401 {ERR_FUNC(TS_F_TS_COMPUTE_IMPRINT), "TS_COMPUTE_IMPRINT"},
1402 + {ERR_FUNC(TS_F_TS_CONF_INVALID), "ts_CONF_invalid"},
1403 + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERT), "TS_CONF_load_cert"},
1404 + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERTS), "TS_CONF_load_certs"},
1405 + {ERR_FUNC(TS_F_TS_CONF_LOAD_KEY), "TS_CONF_load_key"},
1406 + {ERR_FUNC(TS_F_TS_CONF_LOOKUP_FAIL), "ts_CONF_lookup_fail"},
1407 {ERR_FUNC(TS_F_TS_CONF_SET_DEFAULT_ENGINE), "TS_CONF_set_default_engine"},
1408 {ERR_FUNC(TS_F_TS_GET_STATUS_TEXT), "TS_GET_STATUS_TEXT"},
1409 {ERR_FUNC(TS_F_TS_MSG_IMPRINT_SET_ALGO), "TS_MSG_IMPRINT_set_algo"},
1410 @@ -132,6 +137,8 @@ static ERR_STRING_DATA TS_str_functs[] = {
1411 static ERR_STRING_DATA TS_str_reasons[] = {
1412 {ERR_REASON(TS_R_BAD_PKCS7_TYPE), "bad pkcs7 type"},
1413 {ERR_REASON(TS_R_BAD_TYPE), "bad type"},
1414 + {ERR_REASON(TS_R_CANNOT_LOAD_CERT), "cannot load certificate"},
1415 + {ERR_REASON(TS_R_CANNOT_LOAD_KEY), "cannot load private key"},
1416 {ERR_REASON(TS_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"},
1417 {ERR_REASON(TS_R_COULD_NOT_SET_ENGINE), "could not set engine"},
1418 {ERR_REASON(TS_R_COULD_NOT_SET_TIME), "could not set time"},
1419 @@ -170,6 +177,8 @@ static ERR_STRING_DATA TS_str_reasons[] = {
1420 {ERR_REASON(TS_R_UNACCEPTABLE_POLICY), "unacceptable policy"},
1421 {ERR_REASON(TS_R_UNSUPPORTED_MD_ALGORITHM), "unsupported md algorithm"},
1422 {ERR_REASON(TS_R_UNSUPPORTED_VERSION), "unsupported version"},
1423 + {ERR_REASON(TS_R_VAR_BAD_VALUE), "var bad value"},
1424 + {ERR_REASON(TS_R_VAR_LOOKUP_FAILURE), "cannot find config variable"},
1425 {ERR_REASON(TS_R_WRONG_CONTENT_TYPE), "wrong content type"},
1426 {0, NULL}
1427 };
1428 diff --git a/crypto/ui/ui_util.c b/crypto/ui/ui_util.c
1429 index 0f29011..80dd40e 100644
1430 --- a/crypto/ui/ui_util.c
1431 +++ b/crypto/ui/ui_util.c
1432 @@ -56,6 +56,10 @@
1433 #include <string.h>
1434 #include "ui_locl.h"
1435
1436 +#ifndef BUFSIZ
1437 +#define BUFSIZ 256
1438 +#endif
1439 +
1440 int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,
1441 int verify)
1442 {
1443 diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
1444 index 9ee8f8d..64b052e 100644
1445 --- a/crypto/x509/by_dir.c
1446 +++ b/crypto/x509/by_dir.c
1447 @@ -69,6 +69,8 @@
1448 # include <sys/stat.h>
1449 #endif
1450
1451 +#ifndef OPENSSL_NO_STDIO
1452 +
1453 #include <openssl/lhash.h>
1454 #include <openssl/x509.h>
1455
1456 @@ -434,3 +436,5 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
1457 BUF_MEM_free(b);
1458 return (ok);
1459 }
1460 +
1461 +#endif /* OPENSSL_NO_STDIO */
1462 diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
1463 index 0429767..7ddc21c 100644
1464 --- a/crypto/x509/x509_vfy.c
1465 +++ b/crypto/x509/x509_vfy.c
1466 @@ -940,6 +940,8 @@ static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify)
1467 ctx->current_crl = crl;
1468 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
1469 ptime = &ctx->param->check_time;
1470 + else if (ctx->param->flags & X509_V_FLAG_NO_CHECK_TIME)
1471 + return 1;
1472 else
1473 ptime = NULL;
1474
1475 @@ -1663,6 +1665,8 @@ static int check_cert_time(X509_STORE_CTX *ctx, X509 *x)
1476
1477 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
1478 ptime = &ctx->param->check_time;
1479 + else if (ctx->param->flags & X509_V_FLAG_NO_CHECK_TIME)
1480 + return 1;
1481 else
1482 ptime = NULL;
1483
1484 diff --git a/crypto/x509/x509_vfy.h b/crypto/x509/x509_vfy.h
1485 index 2663e1c..3790ef5 100644
1486 --- a/crypto/x509/x509_vfy.h
1487 +++ b/crypto/x509/x509_vfy.h
1488 @@ -438,6 +438,8 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
1489 * will force the behaviour to match that of previous versions.
1490 */
1491 # define X509_V_FLAG_NO_ALT_CHAINS 0x100000
1492 +/* Do not check certificate/CRL validity against current time */
1493 +# define X509_V_FLAG_NO_CHECK_TIME 0x200000
1494
1495 # define X509_VP_FLAG_DEFAULT 0x1
1496 # define X509_VP_FLAG_OVERWRITE 0x2
1497 @@ -490,9 +492,10 @@ void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
1498 X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);
1499
1500 X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
1501 -
1502 +#ifndef OPENSSL_NO_STDIO
1503 X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
1504 X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
1505 +#endif
1506
1507 int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
1508 int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
1509 diff --git a/crypto/x509v3/ext_dat.h b/crypto/x509v3/ext_dat.h
1510 index c3a6fce..01edd2a 100644
1511 --- a/crypto/x509v3/ext_dat.h
1512 +++ b/crypto/x509v3/ext_dat.h
1513 @@ -127,8 +127,10 @@ static const X509V3_EXT_METHOD *standard_exts[] = {
1514 &v3_idp,
1515 &v3_alt[2],
1516 &v3_freshest_crl,
1517 +#ifndef OPENSSL_SYS_UEFI
1518 &v3_ct_scts[0],
1519 &v3_ct_scts[1],
1520 +#endif
1521 };
1522
1523 /* Number of standard extensions */
1524 diff --git a/crypto/x509v3/v3_pci.c b/crypto/x509v3/v3_pci.c
1525 index 34cad53..12f12a7 100644
1526 --- a/crypto/x509v3/v3_pci.c
1527 +++ b/crypto/x509v3/v3_pci.c
1528 @@ -149,6 +149,7 @@ static int process_pci_value(CONF_VALUE *val,
1529 goto err;
1530 }
1531 OPENSSL_free(tmp_data2);
1532 +#ifndef OPENSSL_NO_STDIO
1533 } else if (strncmp(val->value, "file:", 5) == 0) {
1534 unsigned char buf[2048];
1535 int n;
1536 @@ -181,6 +182,7 @@ static int process_pci_value(CONF_VALUE *val,
1537 X509V3_conf_err(val);
1538 goto err;
1539 }
1540 +#endif /* !OPENSSL_NO_STDIO */
1541 } else if (strncmp(val->value, "text:", 5) == 0) {
1542 val_len = strlen(val->value + 5);
1543 tmp_data = OPENSSL_realloc((*policy)->data,
1544 diff --git a/crypto/x509v3/x509v3.h b/crypto/x509v3/x509v3.h
1545 index f5c6156..a2e78aa 100644
1546 --- a/crypto/x509v3/x509v3.h
1547 +++ b/crypto/x509v3/x509v3.h
1548 @@ -688,8 +688,9 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
1549 int ml);
1550 int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
1551 int indent);
1552 +#ifndef OPENSSL_NO_FP_API
1553 int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
1554 -
1555 +#endif
1556 int X509V3_extensions_print(BIO *out, char *title,
1557 STACK_OF(X509_EXTENSION) *exts,
1558 unsigned long flag, int indent);
1559 diff --git a/demos/engines/cluster_labs/hw_cluster_labs_err.h b/demos/engines/cluster_labs/hw_cluster_labs_err.h
1560 index 3300e11..e9e58d5 100644
1561 --- a/demos/engines/cluster_labs/hw_cluster_labs_err.h
1562 +++ b/demos/engines/cluster_labs/hw_cluster_labs_err.h
1563 @@ -67,7 +67,7 @@ extern "C" {
1564 static void ERR_load_CL_strings(void);
1565 static void ERR_unload_CL_strings(void);
1566 static void ERR_CL_error(int function, int reason, char *file, int line);
1567 -# define CLerr(f,r) ERR_CL_error((f),(r),__FILE__,__LINE__)
1568 +# define CLerr(f,r) ERR_CL_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1569
1570 /* Error codes for the CL functions. */
1571
1572 diff --git a/demos/engines/ibmca/hw_ibmca_err.h b/demos/engines/ibmca/hw_ibmca_err.h
1573 index c17e0c9..10d0212 100644
1574 --- a/demos/engines/ibmca/hw_ibmca_err.h
1575 +++ b/demos/engines/ibmca/hw_ibmca_err.h
1576 @@ -67,7 +67,7 @@ extern "C" {
1577 static void ERR_load_IBMCA_strings(void);
1578 static void ERR_unload_IBMCA_strings(void);
1579 static void ERR_IBMCA_error(int function, int reason, char *file, int line);
1580 -# define IBMCAerr(f,r) ERR_IBMCA_error((f),(r),__FILE__,__LINE__)
1581 +# define IBMCAerr(f,r) ERR_IBMCA_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1582
1583 /* Error codes for the IBMCA functions. */
1584
1585 diff --git a/demos/engines/rsaref/rsaref_err.h b/demos/engines/rsaref/rsaref_err.h
1586 index 4356815..598836f 100644
1587 --- a/demos/engines/rsaref/rsaref_err.h
1588 +++ b/demos/engines/rsaref/rsaref_err.h
1589 @@ -68,7 +68,7 @@ extern "C" {
1590 static void ERR_load_RSAREF_strings(void);
1591 static void ERR_unload_RSAREF_strings(void);
1592 static void ERR_RSAREF_error(int function, int reason, char *file, int line);
1593 -# define RSAREFerr(f,r) ERR_RSAREF_error((f),(r),__FILE__,__LINE__)
1594 +# define RSAREFerr(f,r) ERR_RSAREF_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1595 /* Error codes for the RSAREF functions. */
1596
1597 /* Function codes. */
1598 diff --git a/demos/engines/zencod/hw_zencod_err.h b/demos/engines/zencod/hw_zencod_err.h
1599 index f4a8358..94d3293 100644
1600 --- a/demos/engines/zencod/hw_zencod_err.h
1601 +++ b/demos/engines/zencod/hw_zencod_err.h
1602 @@ -67,7 +67,7 @@ extern "C" {
1603 static void ERR_load_ZENCOD_strings(void);
1604 static void ERR_unload_ZENCOD_strings(void);
1605 static void ERR_ZENCOD_error(int function, int reason, char *file, int line);
1606 -# define ZENCODerr(f,r) ERR_ZENCOD_error((f),(r),__FILE__,__LINE__)
1607 +# define ZENCODerr(f,r) ERR_ZENCOD_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1608
1609 /* Error codes for the ZENCOD functions. */
1610
1611 diff --git a/doc/crypto/threads.pod b/doc/crypto/threads.pod
1612 index dc0e939..fe123bb 100644
1613 --- a/doc/crypto/threads.pod
1614 +++ b/doc/crypto/threads.pod
1615 @@ -51,15 +51,15 @@ CRYPTO_destroy_dynlockid, CRYPTO_lock - OpenSSL thread support
1616 void CRYPTO_lock(int mode, int n, const char *file, int line);
1617
1618 #define CRYPTO_w_lock(type) \
1619 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
1620 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
1621 #define CRYPTO_w_unlock(type) \
1622 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
1623 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
1624 #define CRYPTO_r_lock(type) \
1625 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
1626 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
1627 #define CRYPTO_r_unlock(type) \
1628 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
1629 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
1630 #define CRYPTO_add(addr,amount,type) \
1631 - CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
1632 + CRYPTO_add_lock(addr,amount,type,OPENSSL_FILE,OPENSSL_LINE)
1633
1634 =head1 DESCRIPTION
1635
1636 diff --git a/e_os.h b/e_os.h
1637 index 1fa36c1..3e9dae2 100644
1638 --- a/e_os.h
1639 +++ b/e_os.h
1640 @@ -136,7 +136,7 @@ extern "C" {
1641 # define MSDOS
1642 # endif
1643
1644 -# if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
1645 +# if (defined(MSDOS) || defined(OPENSSL_SYS_UEFI)) && !defined(GETPID_IS_MEANINGLESS)
1646 # define GETPID_IS_MEANINGLESS
1647 # endif
1648
1649 diff --git a/e_os2.h b/e_os2.h
1650 index 7be9989..909e22f 100644
1651 --- a/e_os2.h
1652 +++ b/e_os2.h
1653 @@ -97,7 +97,14 @@ extern "C" {
1654 * For 32 bit environment, there seems to be the CygWin environment and then
1655 * all the others that try to do the same thing Microsoft does...
1656 */
1657 -# if defined(OPENSSL_SYSNAME_UWIN)
1658 +/*
1659 + * UEFI lives here because it might be built with a Microsoft toolchain and
1660 + * we need to avoid the false positive match on Windows.
1661 + */
1662 +# if defined(OPENSSL_SYSNAME_UEFI)
1663 +# undef OPENSSL_SYS_UNIX
1664 +# define OPENSSL_SYS_UEFI
1665 +# elif defined(OPENSSL_SYSNAME_UWIN)
1666 # undef OPENSSL_SYS_UNIX
1667 # define OPENSSL_SYS_WIN32_UWIN
1668 # else
1669 diff --git a/engines/ccgost/e_gost_err.h b/engines/ccgost/e_gost_err.h
1670 index a2018ec..9eacdcf 100644
1671 --- a/engines/ccgost/e_gost_err.h
1672 +++ b/engines/ccgost/e_gost_err.h
1673 @@ -67,7 +67,7 @@ extern "C" {
1674 void ERR_load_GOST_strings(void);
1675 void ERR_unload_GOST_strings(void);
1676 void ERR_GOST_error(int function, int reason, char *file, int line);
1677 -# define GOSTerr(f,r) ERR_GOST_error((f),(r),__FILE__,__LINE__)
1678 +# define GOSTerr(f,r) ERR_GOST_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1679
1680 /* Error codes for the GOST functions. */
1681
1682 diff --git a/engines/e_4758cca_err.h b/engines/e_4758cca_err.h
1683 index 2f29d96..47a2635 100644
1684 --- a/engines/e_4758cca_err.h
1685 +++ b/engines/e_4758cca_err.h
1686 @@ -67,7 +67,7 @@ extern "C" {
1687 static void ERR_load_CCA4758_strings(void);
1688 static void ERR_unload_CCA4758_strings(void);
1689 static void ERR_CCA4758_error(int function, int reason, char *file, int line);
1690 -# define CCA4758err(f,r) ERR_CCA4758_error((f),(r),__FILE__,__LINE__)
1691 +# define CCA4758err(f,r) ERR_CCA4758_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1692
1693 /* Error codes for the CCA4758 functions. */
1694
1695 diff --git a/engines/e_aep_err.h b/engines/e_aep_err.h
1696 index 2ed0114..1f8fa5b 100644
1697 --- a/engines/e_aep_err.h
1698 +++ b/engines/e_aep_err.h
1699 @@ -67,7 +67,7 @@ extern "C" {
1700 static void ERR_load_AEPHK_strings(void);
1701 static void ERR_unload_AEPHK_strings(void);
1702 static void ERR_AEPHK_error(int function, int reason, char *file, int line);
1703 -# define AEPHKerr(f,r) ERR_AEPHK_error((f),(r),__FILE__,__LINE__)
1704 +# define AEPHKerr(f,r) ERR_AEPHK_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1705
1706 /* Error codes for the AEPHK functions. */
1707
1708 diff --git a/engines/e_atalla_err.h b/engines/e_atalla_err.h
1709 index 7b71eff..d958496 100644
1710 --- a/engines/e_atalla_err.h
1711 +++ b/engines/e_atalla_err.h
1712 @@ -67,7 +67,7 @@ extern "C" {
1713 static void ERR_load_ATALLA_strings(void);
1714 static void ERR_unload_ATALLA_strings(void);
1715 static void ERR_ATALLA_error(int function, int reason, char *file, int line);
1716 -# define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),__FILE__,__LINE__)
1717 +# define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1718
1719 /* Error codes for the ATALLA functions. */
1720
1721 diff --git a/engines/e_capi_err.h b/engines/e_capi_err.h
1722 index b5d06dc..cfe46b1 100644
1723 --- a/engines/e_capi_err.h
1724 +++ b/engines/e_capi_err.h
1725 @@ -67,7 +67,7 @@ extern "C" {
1726 static void ERR_load_CAPI_strings(void);
1727 static void ERR_unload_CAPI_strings(void);
1728 static void ERR_CAPI_error(int function, int reason, char *file, int line);
1729 -# define CAPIerr(f,r) ERR_CAPI_error((f),(r),__FILE__,__LINE__)
1730 +# define CAPIerr(f,r) ERR_CAPI_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1731
1732 /* Error codes for the CAPI functions. */
1733
1734 diff --git a/engines/e_chil_err.h b/engines/e_chil_err.h
1735 index d86a4ce..3d961b9 100644
1736 --- a/engines/e_chil_err.h
1737 +++ b/engines/e_chil_err.h
1738 @@ -67,7 +67,7 @@ extern "C" {
1739 static void ERR_load_HWCRHK_strings(void);
1740 static void ERR_unload_HWCRHK_strings(void);
1741 static void ERR_HWCRHK_error(int function, int reason, char *file, int line);
1742 -# define HWCRHKerr(f,r) ERR_HWCRHK_error((f),(r),__FILE__,__LINE__)
1743 +# define HWCRHKerr(f,r) ERR_HWCRHK_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1744
1745 /* Error codes for the HWCRHK functions. */
1746
1747 diff --git a/engines/e_cswift_err.h b/engines/e_cswift_err.h
1748 index fde3a82..7c20691 100644
1749 --- a/engines/e_cswift_err.h
1750 +++ b/engines/e_cswift_err.h
1751 @@ -67,7 +67,7 @@ extern "C" {
1752 static void ERR_load_CSWIFT_strings(void);
1753 static void ERR_unload_CSWIFT_strings(void);
1754 static void ERR_CSWIFT_error(int function, int reason, char *file, int line);
1755 -# define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),__FILE__,__LINE__)
1756 +# define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1757
1758 /* Error codes for the CSWIFT functions. */
1759
1760 diff --git a/engines/e_gmp_err.h b/engines/e_gmp_err.h
1761 index 637abbc..ccaf3da 100644
1762 --- a/engines/e_gmp_err.h
1763 +++ b/engines/e_gmp_err.h
1764 @@ -67,7 +67,7 @@ extern "C" {
1765 static void ERR_load_GMP_strings(void);
1766 static void ERR_unload_GMP_strings(void);
1767 static void ERR_GMP_error(int function, int reason, char *file, int line);
1768 -# define GMPerr(f,r) ERR_GMP_error((f),(r),__FILE__,__LINE__)
1769 +# define GMPerr(f,r) ERR_GMP_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1770
1771 /* Error codes for the GMP functions. */
1772
1773 diff --git a/engines/e_nuron_err.h b/engines/e_nuron_err.h
1774 index aa7849c..e607d3e 100644
1775 --- a/engines/e_nuron_err.h
1776 +++ b/engines/e_nuron_err.h
1777 @@ -67,7 +67,7 @@ extern "C" {
1778 static void ERR_load_NURON_strings(void);
1779 static void ERR_unload_NURON_strings(void);
1780 static void ERR_NURON_error(int function, int reason, char *file, int line);
1781 -# define NURONerr(f,r) ERR_NURON_error((f),(r),__FILE__,__LINE__)
1782 +# define NURONerr(f,r) ERR_NURON_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1783
1784 /* Error codes for the NURON functions. */
1785
1786 diff --git a/engines/e_sureware_err.h b/engines/e_sureware_err.h
1787 index bef8623..54f2848 100644
1788 --- a/engines/e_sureware_err.h
1789 +++ b/engines/e_sureware_err.h
1790 @@ -68,7 +68,7 @@ static void ERR_load_SUREWARE_strings(void);
1791 static void ERR_unload_SUREWARE_strings(void);
1792 static void ERR_SUREWARE_error(int function, int reason, char *file,
1793 int line);
1794 -# define SUREWAREerr(f,r) ERR_SUREWARE_error((f),(r),__FILE__,__LINE__)
1795 +# define SUREWAREerr(f,r) ERR_SUREWARE_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1796
1797 /* Error codes for the SUREWARE functions. */
1798
1799 diff --git a/engines/e_ubsec_err.h b/engines/e_ubsec_err.h
1800 index c8aec7c..67110ed 100644
1801 --- a/engines/e_ubsec_err.h
1802 +++ b/engines/e_ubsec_err.h
1803 @@ -67,7 +67,7 @@ extern "C" {
1804 static void ERR_load_UBSEC_strings(void);
1805 static void ERR_unload_UBSEC_strings(void);
1806 static void ERR_UBSEC_error(int function, int reason, char *file, int line);
1807 -# define UBSECerr(f,r) ERR_UBSEC_error((f),(r),__FILE__,__LINE__)
1808 +# define UBSECerr(f,r) ERR_UBSEC_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1809
1810 /* Error codes for the UBSEC functions. */
1811
1812 diff --git a/ssl/d1_both.c b/ssl/d1_both.c
1813 index d1fc716..d5f661a 100644
1814 --- a/ssl/d1_both.c
1815 +++ b/ssl/d1_both.c
1816 @@ -1053,7 +1053,7 @@ int dtls1_send_change_cipher_spec(SSL *s, int a, int b)
1817 int dtls1_read_failed(SSL *s, int code)
1818 {
1819 if (code > 0) {
1820 - fprintf(stderr, "invalid state reached %s:%d", __FILE__, __LINE__);
1821 + fprintf(stderr, "dtls1_read_failed(); invalid state reached\n");
1822 return 1;
1823 }
1824
1825 diff --git a/ssl/ssl_asn1.c b/ssl/ssl_asn1.c
1826 index 35cc27c..a1f5335 100644
1827 --- a/ssl/ssl_asn1.c
1828 +++ b/ssl/ssl_asn1.c
1829 @@ -418,7 +418,7 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
1830 if (ssl_version == SSL2_VERSION) {
1831 if (os.length != 3) {
1832 c.error = SSL_R_CIPHER_CODE_WRONG_LENGTH;
1833 - c.line = __LINE__;
1834 + c.line = OPENSSL_LINE;
1835 goto err;
1836 }
1837 id = 0x02000000L |
1838 @@ -429,14 +429,14 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
1839 || ssl_version == DTLS1_BAD_VER) {
1840 if (os.length != 2) {
1841 c.error = SSL_R_CIPHER_CODE_WRONG_LENGTH;
1842 - c.line = __LINE__;
1843 + c.line = OPENSSL_LINE;
1844 goto err;
1845 }
1846 id = 0x03000000L |
1847 ((unsigned long)os.data[0] << 8L) | (unsigned long)os.data[1];
1848 } else {
1849 c.error = SSL_R_UNKNOWN_SSL_VERSION;
1850 - c.line = __LINE__;
1851 + c.line = OPENSSL_LINE;
1852 goto err;
1853 }
1854
1855 @@ -526,7 +526,7 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
1856 if (os.data != NULL) {
1857 if (os.length > SSL_MAX_SID_CTX_LENGTH) {
1858 c.error = SSL_R_BAD_LENGTH;
1859 - c.line = __LINE__;
1860 + c.line = OPENSSL_LINE;
1861 goto err;
1862 } else {
1863 ret->sid_ctx_length = os.length;
1864 diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
1865 index a73f866..d534c0a 100644
1866 --- a/ssl/ssl_cert.c
1867 +++ b/ssl/ssl_cert.c
1868 @@ -855,12 +855,13 @@ int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x)
1869 return (add_client_CA(&(ctx->client_CA), x));
1870 }
1871
1872 +#ifndef OPENSSL_NO_STDIO
1873 +
1874 static int xname_cmp(const X509_NAME *const *a, const X509_NAME *const *b)
1875 {
1876 return (X509_NAME_cmp(*a, *b));
1877 }
1878
1879 -#ifndef OPENSSL_NO_STDIO
1880 /**
1881 * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed;
1882 * it doesn't really have anything to do with clients (except that a common use
1883 @@ -928,7 +929,6 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
1884 ERR_clear_error();
1885 return (ret);
1886 }
1887 -#endif
1888
1889 /**
1890 * Add a file of certs to a stack.
1891 @@ -1048,6 +1048,7 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
1892 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
1893 return ret;
1894 }
1895 +#endif /* !OPENSSL_NO_STDIO */
1896
1897 /* Add a certificate to a BUF_MEM structure */
1898
1899 diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c
1900 index 5478840..c2ad7c9 100644
1901 --- a/ssl/ssl_conf.c
1902 +++ b/ssl/ssl_conf.c
1903 @@ -362,6 +362,7 @@ static int cmd_Options(SSL_CONF_CTX *cctx, const char *value)
1904 return CONF_parse_list(value, ',', 1, ssl_set_option_list, cctx);
1905 }
1906
1907 +#ifndef OPENSSL_NO_STDIO
1908 static int cmd_Certificate(SSL_CONF_CTX *cctx, const char *value)
1909 {
1910 int rv = 1;
1911 @@ -428,7 +429,9 @@ static int cmd_DHParameters(SSL_CONF_CTX *cctx, const char *value)
1912 BIO_free(in);
1913 return rv > 0;
1914 }
1915 -#endif
1916 +#endif /* !OPENSSL_NO_DH */
1917 +#endif /* !OPENSSL_NO_STDIO */
1918 +
1919 typedef struct {
1920 int (*cmd) (SSL_CONF_CTX *cctx, const char *value);
1921 const char *str_file;
1922 @@ -454,12 +457,14 @@ static const ssl_conf_cmd_tbl ssl_conf_cmds[] = {
1923 SSL_CONF_CMD_STRING(CipherString, "cipher"),
1924 SSL_CONF_CMD_STRING(Protocol, NULL),
1925 SSL_CONF_CMD_STRING(Options, NULL),
1926 +#ifndef OPENSSL_NO_STDIO
1927 SSL_CONF_CMD(Certificate, "cert", SSL_CONF_TYPE_FILE),
1928 SSL_CONF_CMD(PrivateKey, "key", SSL_CONF_TYPE_FILE),
1929 SSL_CONF_CMD(ServerInfoFile, NULL, SSL_CONF_TYPE_FILE),
1930 #ifndef OPENSSL_NO_DH
1931 SSL_CONF_CMD(DHParameters, "dhparam", SSL_CONF_TYPE_FILE)
1932 #endif
1933 +#endif
1934 };
1935
1936 static int ssl_conf_cmd_skip_prefix(SSL_CONF_CTX *cctx, const char **pcmd)
1937 diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c
1938 index 514fcb3..2a54cc9 100644
1939 --- a/ssl/t1_enc.c
1940 +++ b/ssl/t1_enc.c
1941 @@ -780,9 +780,7 @@ int tls1_enc(SSL *s, int send)
1942 * we can't write into the input stream: Can this ever
1943 * happen?? (steve)
1944 */
1945 - fprintf(stderr,
1946 - "%s:%d: rec->data != rec->input\n",
1947 - __FILE__, __LINE__);
1948 + fprintf(stderr, "tls1_enc: rec->data != rec->input\n");
1949 else if (RAND_bytes(rec->input, ivlen) <= 0)
1950 return -1;
1951 }
1952 diff --git a/test/cms-test.pl b/test/cms-test.pl
1953 index baa3b59..1ee3f02 100644
1954 --- a/test/cms-test.pl
1955 +++ b/test/cms-test.pl
1956 @@ -100,6 +100,13 @@ my $no_ec2m;
1957 my $no_ecdh;
1958 my $ossl8 = `$ossl_path version -v` =~ /0\.9\.8/;
1959
1960 +system ("$ossl_path no-cms > $null_path");
1961 +if ($? == 0)
1962 + {
1963 + print "CMS disabled\n";
1964 + exit 0;
1965 + }
1966 +
1967 system ("$ossl_path no-ec > $null_path");
1968 if ($? == 0)
1969 {
1970 diff --git a/util/libeay.num b/util/libeay.num
1971 index 7f7487d..13b2e3a 100755
1972 --- a/util/libeay.num
1973 +++ b/util/libeay.num
1974 @@ -4368,7 +4368,7 @@ DH_compute_key_padded 4732 EXIST::FUNCTION:DH
1975 ECDSA_METHOD_set_sign 4733 EXIST::FUNCTION:ECDSA
1976 CMS_RecipientEncryptedKey_cert_cmp 4734 EXIST:!VMS:FUNCTION:CMS
1977 CMS_RecipEncryptedKey_cert_cmp 4734 EXIST:VMS:FUNCTION:CMS
1978 -DH_KDF_X9_42 4735 EXIST::FUNCTION:DH
1979 +DH_KDF_X9_42 4735 EXIST::FUNCTION:CMS,DH
1980 RSA_OAEP_PARAMS_free 4736 EXIST::FUNCTION:RSA
1981 EVP_des_ede3_wrap 4737 EXIST::FUNCTION:DES
1982 RSA_OAEP_PARAMS_it 4738 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA
1983 diff --git a/util/mkerr.pl b/util/mkerr.pl
1984 index 09ebebe..cd57ade 100644
1985 --- a/util/mkerr.pl
1986 +++ b/util/mkerr.pl
1987 @@ -89,7 +89,7 @@ Options:
1988 void ERR_load_<LIB>_strings(void);
1989 void ERR_unload_<LIB>_strings(void);
1990 void ERR_<LIB>_error(int f, int r, char *fn, int ln);
1991 - #define <LIB>err(f,r) ERR_<LIB>_error(f,r,__FILE__,__LINE__)
1992 + #define <LIB>err(f,r) ERR_<LIB>_error(f,r,OPENSSL_FILE,OPENSSL_LINE)
1993 while the code facilitates the use of these in an environment
1994 where the error support routines are dynamically loaded at
1995 runtime.
1996 @@ -474,7 +474,7 @@ EOF
1997 ${staticloader}void ERR_load_${lib}_strings(void);
1998 ${staticloader}void ERR_unload_${lib}_strings(void);
1999 ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line);
2000 -# define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__)
2001 +# define ${lib}err(f,r) ERR_${lib}_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
2002
2003 EOF
2004 }