]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2f.patch
8d5f4a810778a590974ddbab7781603cc5c0a4c7
[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/dh_pmeth.c b/crypto/dh/dh_pmeth.c
594 index b58e3fa..e5f345a 100644
595 --- a/crypto/dh/dh_pmeth.c
596 +++ b/crypto/dh/dh_pmeth.c
597 @@ -449,6 +449,9 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
598 *keylen = ret;
599 return 1;
600 } else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) {
601 +#ifdef OPENSSL_NO_CMS
602 + return 0;
603 +#else
604 unsigned char *Z = NULL;
605 size_t Zlen = 0;
606 if (!dctx->kdf_outlen || !dctx->kdf_oid)
607 @@ -478,6 +481,7 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
608 OPENSSL_free(Z);
609 }
610 return ret;
611 +#endif
612 }
613 return 1;
614 }
615 diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h
616 index 46f163b..b4a72a0 100644
617 --- a/crypto/engine/eng_int.h
618 +++ b/crypto/engine/eng_int.h
619 @@ -88,7 +88,7 @@ extern "C" {
620 (unsigned int)(e), (isfunct ? "funct" : "struct"), \
621 ((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \
622 ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
623 - (__FILE__), (__LINE__));
624 + (OPENSSL_FILE), (OPENSSL_LINE));
625
626 # else
627
628 @@ -136,7 +136,7 @@ ENGINE *engine_table_select(ENGINE_TABLE **table, int nid);
629 # else
630 ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
631 int l);
632 -# define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__)
633 +# define engine_table_select(t,n) engine_table_select_tmp(t,n,OPENSSL_FILE,OPENSSL_LINE)
634 # endif
635 typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk,
636 ENGINE *def, void *arg);
637 diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c
638 index 34b0029..cf622bb 100644
639 --- a/crypto/engine/eng_openssl.c
640 +++ b/crypto/engine/eng_openssl.c
641 @@ -86,7 +86,9 @@
642 * this is no longer automatic in ENGINE_load_builtin_engines().
643 */
644 #define TEST_ENG_OPENSSL_RC4
645 +#ifndef OPENSSL_NO_FP_API
646 #define TEST_ENG_OPENSSL_PKEY
647 +#endif
648 /* #define TEST_ENG_OPENSSL_RC4_OTHERS */
649 #define TEST_ENG_OPENSSL_RC4_P_INIT
650 /* #define TEST_ENG_OPENSSL_RC4_P_CIPHER */
651 diff --git a/crypto/err/err.h b/crypto/err/err.h
652 index 585aa8b..04c6cfc 100644
653 --- a/crypto/err/err.h
654 +++ b/crypto/err/err.h
655 @@ -200,39 +200,39 @@ typedef struct err_state_st {
656
657 # define ERR_LIB_USER 128
658
659 -# define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)
660 -# define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)
661 -# define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)
662 -# define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)
663 -# define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)
664 -# define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)
665 -# define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)
666 -# define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)
667 -# define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)
668 -# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)
669 -# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)
670 -# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)
671 -# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)
672 -# define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)
673 -# define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)
674 -# define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)
675 -# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)
676 -# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)
677 -# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)
678 -# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)
679 -# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)
680 -# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)
681 -# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)
682 -# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)
683 -# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)
684 -# define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)
685 -# define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)
686 -# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)
687 -# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)
688 -# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)
689 -# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)
690 -# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)
691 -# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)
692 +# define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
693 +# define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
694 +# define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
695 +# define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
696 +# define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
697 +# define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
698 +# define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
699 +# define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
700 +# define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
701 +# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
702 +# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
703 +# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
704 +# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
705 +# define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
706 +# define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
707 +# define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
708 +# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
709 +# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
710 +# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
711 +# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
712 +# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
713 +# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
714 +# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
715 +# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
716 +# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
717 +# define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
718 +# define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
719 +# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
720 +# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
721 +# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
722 +# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
723 +# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
724 +# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
725
726 /*
727 * Borland C seems too stupid to be able to shift and do longs in the
728 diff --git a/crypto/opensslconf.h.in b/crypto/opensslconf.h.in
729 index 7a1c85d..a5f51a7 100644
730 --- a/crypto/opensslconf.h.in
731 +++ b/crypto/opensslconf.h.in
732 @@ -1,5 +1,15 @@
733 /* crypto/opensslconf.h.in */
734
735 +#ifndef OPENSSL_FILE
736 +#ifdef OPENSSL_NO_FILENAMES
737 +#define OPENSSL_FILE ""
738 +#define OPENSSL_LINE 0
739 +#else
740 +#define OPENSSL_FILE __FILE__
741 +#define OPENSSL_LINE __LINE__
742 +#endif
743 +#endif
744 +
745 /* Generate 80386 code? */
746 #undef I386_ONLY
747
748 diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h
749 index d3b23fc..87b0b6a 100644
750 --- a/crypto/pem/pem.h
751 +++ b/crypto/pem/pem.h
752 @@ -324,6 +324,7 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
753
754 # define DECLARE_PEM_read_fp(name, type) /**/
755 # define DECLARE_PEM_write_fp(name, type) /**/
756 +# define DECLARE_PEM_write_fp_const(name, type) /**/
757 # define DECLARE_PEM_write_cb_fp(name, type) /**/
758 # else
759
760 @@ -417,6 +418,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
761 pem_password_cb *cd, void *u);
762 # endif
763
764 +#ifndef OPENSSL_NO_FP_API
765 int PEM_read(FILE *fp, char **name, char **header,
766 unsigned char **data, long *len);
767 int PEM_write(FILE *fp, const char *name, const char *hdr,
768 @@ -428,6 +430,7 @@ int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
769 int klen, pem_password_cb *callback, void *u);
770 STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
771 pem_password_cb *cb, void *u);
772 +#endif
773
774 int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
775 EVP_MD *md_type, unsigned char **ek, int *ekl,
776 @@ -494,6 +497,7 @@ int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
777 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
778 void *u);
779
780 +#ifndef OPENSSL_NO_FP_API
781 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
782 char *kstr, int klen,
783 pem_password_cb *cb, void *u);
784 @@ -510,7 +514,7 @@ EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
785 int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
786 char *kstr, int klen, pem_password_cb *cd,
787 void *u);
788 -
789 +#endif
790 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
791 int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
792
793 diff --git a/crypto/pem/pem_pk8.c b/crypto/pem/pem_pk8.c
794 index 5747c73..fe465cc 100644
795 --- a/crypto/pem/pem_pk8.c
796 +++ b/crypto/pem/pem_pk8.c
797 @@ -69,10 +69,12 @@
798 static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder,
799 int nid, const EVP_CIPHER *enc,
800 char *kstr, int klen, pem_password_cb *cb, void *u);
801 +
802 +#ifndef OPENSSL_NO_FP_API
803 static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder,
804 int nid, const EVP_CIPHER *enc,
805 char *kstr, int klen, pem_password_cb *cb, void *u);
806 -
807 +#endif
808 /*
809 * These functions write a private key in PKCS#8 format: it is a "drop in"
810 * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc'
811 diff --git a/crypto/pkcs7/pk7_smime.c b/crypto/pkcs7/pk7_smime.c
812 index c4d3724..0bc3d43 100644
813 --- a/crypto/pkcs7/pk7_smime.c
814 +++ b/crypto/pkcs7/pk7_smime.c
815 @@ -64,6 +64,9 @@
816 #include <openssl/x509.h>
817 #include <openssl/x509v3.h>
818
819 +
820 +#define BUFFERSIZE 4096
821 +
822 static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
823
824 PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
825 @@ -254,7 +257,7 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
826 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
827 PKCS7_SIGNER_INFO *si;
828 X509_STORE_CTX cert_ctx;
829 - char buf[4096];
830 + char *buf = NULL;
831 int i, j = 0, k, ret = 0;
832 BIO *p7bio = NULL;
833 BIO *tmpin = NULL, *tmpout = NULL;
834 @@ -274,12 +277,29 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
835 PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_NO_CONTENT);
836 return 0;
837 }
838 +#if 0
839 + /*
840 + * NB: this test commented out because some versions of Netscape
841 + * illegally include zero length content when signing data. Also
842 + * Microsoft Authenticode includes a SpcIndirectDataContent data
843 + * structure which describes the content to be protected by the
844 + * signature, rather than directly embedding that content. So
845 + * Authenticode implementations are also expected to use
846 + * PKCS7_verify() with explicit external data, on non-detached
847 + * PKCS#7 signatures.
848 + *
849 + * In OpenSSL 1.1 a new flag PKCS7_NO_DUAL_CONTENT has been
850 + * introduced to disable this sanity check. For the 1.0.2 branch
851 + * this change is not acceptable, so the check remains completely
852 + * commented out (as it has been for a long time).
853 + */
854
855 /* Check for data and content: two sets of data */
856 if (!PKCS7_get_detached(p7) && indata) {
857 PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_CONTENT_AND_DATA_PRESENT);
858 return 0;
859 }
860 +#endif
861
862 sinfos = PKCS7_get_signer_info(p7);
863
864 @@ -356,8 +376,12 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
865 tmpout = out;
866
867 /* We now have to 'read' from p7bio to calculate digests etc. */
868 + if ((buf = OPENSSL_malloc(BUFFERSIZE)) == NULL) {
869 + PKCS7err(PKCS7_F_PKCS7_VERIFY, ERR_R_MALLOC_FAILURE);
870 + goto err;
871 + }
872 for (;;) {
873 - i = BIO_read(p7bio, buf, sizeof(buf));
874 + i = BIO_read(p7bio, buf, BUFFERSIZE);
875 if (i <= 0)
876 break;
877 if (tmpout)
878 @@ -388,6 +412,7 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
879 ret = 1;
880
881 err:
882 + OPENSSL_free(buf);
883 if (tmpin == indata) {
884 if (indata)
885 BIO_pop(p7bio);
886 @@ -506,7 +531,7 @@ int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags)
887 {
888 BIO *tmpmem;
889 int ret, i;
890 - char buf[4096];
891 + char *buf = NULL;
892
893 if (!p7) {
894 PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_INVALID_NULL_POINTER);
895 @@ -550,24 +575,29 @@ int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags)
896 }
897 BIO_free_all(bread);
898 return ret;
899 - } else {
900 - for (;;) {
901 - i = BIO_read(tmpmem, buf, sizeof(buf));
902 - if (i <= 0) {
903 - ret = 1;
904 - if (BIO_method_type(tmpmem) == BIO_TYPE_CIPHER) {
905 - if (!BIO_get_cipher_status(tmpmem))
906 - ret = 0;
907 - }
908 -
909 - break;
910 - }
911 - if (BIO_write(data, buf, i) != i) {
912 - ret = 0;
913 - break;
914 + }
915 + if ((buf = OPENSSL_malloc(BUFFERSIZE)) == NULL) {
916 + PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE);
917 + goto err;
918 + }
919 + for (;;) {
920 + i = BIO_read(tmpmem, buf, BUFFERSIZE);
921 + if (i <= 0) {
922 + ret = 1;
923 + if (BIO_method_type(tmpmem) == BIO_TYPE_CIPHER) {
924 + if (!BIO_get_cipher_status(tmpmem))
925 + ret = 0;
926 }
927 +
928 + break;
929 + }
930 + if (BIO_write(data, buf, i) != i) {
931 + ret = 0;
932 + break;
933 }
934 - BIO_free_all(tmpmem);
935 - return ret;
936 }
937 +err:
938 + OPENSSL_free(buf);
939 + BIO_free_all(tmpmem);
940 + return ret;
941 }
942 diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
943 index 266111e..f60fac6 100644
944 --- a/crypto/rand/rand_unix.c
945 +++ b/crypto/rand/rand_unix.c
946 @@ -116,7 +116,7 @@
947 #include <openssl/rand.h>
948 #include "rand_lcl.h"
949
950 -#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))
951 +#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))
952
953 # include <sys/types.h>
954 # include <sys/time.h>
955 @@ -439,7 +439,7 @@ int RAND_poll(void)
956 * defined(OPENSSL_SYS_VXWORKS) ||
957 * defined(OPENSSL_SYS_NETWARE)) */
958
959 -#if defined(OPENSSL_SYS_VXWORKS)
960 +#if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
961 int RAND_poll(void)
962 {
963 return 0;
964 diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c
965 index 4e06218..f591f0f 100644
966 --- a/crypto/rsa/rsa_ameth.c
967 +++ b/crypto/rsa/rsa_ameth.c
968 @@ -68,10 +68,12 @@
969 #endif
970 #include "asn1_locl.h"
971
972 +#ifndef OPENSSL_NO_CMS
973 static int rsa_cms_sign(CMS_SignerInfo *si);
974 static int rsa_cms_verify(CMS_SignerInfo *si);
975 static int rsa_cms_decrypt(CMS_RecipientInfo *ri);
976 static int rsa_cms_encrypt(CMS_RecipientInfo *ri);
977 +#endif
978
979 static int rsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
980 {
981 @@ -665,6 +667,7 @@ static int rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx,
982 return rv;
983 }
984
985 +#ifndef OPENSSL_NO_CMS
986 static int rsa_cms_verify(CMS_SignerInfo *si)
987 {
988 int nid, nid2;
989 @@ -683,6 +686,7 @@ static int rsa_cms_verify(CMS_SignerInfo *si)
990 }
991 return 0;
992 }
993 +#endif
994
995 /*
996 * Customised RSA item verification routine. This is called when a signature
997 @@ -705,6 +709,7 @@ static int rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
998 return -1;
999 }
1000
1001 +#ifndef OPENSSL_NO_CMS
1002 static int rsa_cms_sign(CMS_SignerInfo *si)
1003 {
1004 int pad_mode = RSA_PKCS1_PADDING;
1005 @@ -729,6 +734,7 @@ static int rsa_cms_sign(CMS_SignerInfo *si)
1006 X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsassaPss), V_ASN1_SEQUENCE, os);
1007 return 1;
1008 }
1009 +#endif
1010
1011 static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
1012 X509_ALGOR *alg1, X509_ALGOR *alg2,
1013 @@ -785,6 +791,7 @@ static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg,
1014 return pss;
1015 }
1016
1017 +#ifndef OPENSSL_NO_CMS
1018 static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
1019 {
1020 EVP_PKEY_CTX *pkctx;
1021 @@ -857,7 +864,9 @@ static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
1022 X509_ALGOR_free(maskHash);
1023 return rv;
1024 }
1025 +#endif
1026
1027 +#ifndef OPENSSL_NO_CMS
1028 static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
1029 {
1030 const EVP_MD *md, *mgf1md;
1031 @@ -920,6 +929,7 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
1032 ASN1_STRING_free(os);
1033 return rv;
1034 }
1035 +#endif
1036
1037 const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = {
1038 {
1039 diff --git a/crypto/srp/srp.h b/crypto/srp/srp.h
1040 index d072536..73b945f 100644
1041 --- a/crypto/srp/srp.h
1042 +++ b/crypto/srp/srp.h
1043 @@ -114,7 +114,9 @@ DECLARE_STACK_OF(SRP_gN)
1044
1045 SRP_VBASE *SRP_VBASE_new(char *seed_key);
1046 int SRP_VBASE_free(SRP_VBASE *vb);
1047 +#ifndef OPENSSL_NO_STDIO
1048 int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
1049 +#endif
1050 SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);
1051 char *SRP_create_verifier(const char *user, const char *pass, char **salt,
1052 char **verifier, const char *N, const char *g);
1053 diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c
1054 index a3f1a8a..3fbb186 100644
1055 --- a/crypto/srp/srp_vfy.c
1056 +++ b/crypto/srp/srp_vfy.c
1057 @@ -225,6 +225,7 @@ static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,
1058 return (info == NULL || NULL != (vinfo->info = BUF_strdup(info)));
1059 }
1060
1061 +#ifndef OPENSSL_NO_STDIO
1062 static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
1063 const char *v)
1064 {
1065 @@ -239,6 +240,7 @@ static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
1066 len = t_fromb64(tmp, s);
1067 return ((vinfo->s = BN_bin2bn(tmp, len, NULL)) != NULL);
1068 }
1069 +#endif
1070
1071 static int SRP_user_pwd_set_sv_BN(SRP_user_pwd *vinfo, BIGNUM *s, BIGNUM *v)
1072 {
1073 @@ -279,6 +281,7 @@ int SRP_VBASE_free(SRP_VBASE *vb)
1074 return 0;
1075 }
1076
1077 +#ifndef OPENSSL_NO_STDIO
1078 static SRP_gN_cache *SRP_gN_new_init(const char *ch)
1079 {
1080 unsigned char tmp[MAX_LEN];
1081 @@ -310,6 +313,7 @@ static void SRP_gN_free(SRP_gN_cache *gN_cache)
1082 BN_free(gN_cache->bn);
1083 OPENSSL_free(gN_cache);
1084 }
1085 +#endif
1086
1087 static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)
1088 {
1089 @@ -326,6 +330,7 @@ static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)
1090 return SRP_get_default_gN(id);
1091 }
1092
1093 +#ifndef OPENSSL_NO_STDIO
1094 static BIGNUM *SRP_gN_place_bn(STACK_OF(SRP_gN_cache) *gN_cache, char *ch)
1095 {
1096 int i;
1097 @@ -467,6 +472,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
1098 return error_code;
1099
1100 }
1101 +#endif
1102
1103 SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)
1104 {
1105 diff --git a/crypto/ts/ts.h b/crypto/ts/ts.h
1106 index 16eccbb..a9fe40e 100644
1107 --- a/crypto/ts/ts.h
1108 +++ b/crypto/ts/ts.h
1109 @@ -281,8 +281,10 @@ TS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);
1110
1111 TS_REQ *TS_REQ_dup(TS_REQ *a);
1112
1113 +#ifndef OPENSSL_NO_FP_API
1114 TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);
1115 int i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);
1116 +#endif
1117 TS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);
1118 int i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);
1119
1120 @@ -294,10 +296,12 @@ TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,
1121
1122 TS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);
1123
1124 +#ifndef OPENSSL_NO_FP_API
1125 TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);
1126 int i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);
1127 -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT **a);
1128 -int i2d_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT *a);
1129 +#endif
1130 +TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a);
1131 +int i2d_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT *a);
1132
1133 TS_RESP *TS_RESP_new(void);
1134 void TS_RESP_free(TS_RESP *a);
1135 @@ -306,10 +310,12 @@ TS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);
1136 TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);
1137 TS_RESP *TS_RESP_dup(TS_RESP *a);
1138
1139 +#ifndef OPENSSL_NO_FP_API
1140 TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);
1141 int i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);
1142 -TS_RESP *d2i_TS_RESP_bio(BIO *fp, TS_RESP **a);
1143 -int i2d_TS_RESP_bio(BIO *fp, TS_RESP *a);
1144 +#endif
1145 +TS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a);
1146 +int i2d_TS_RESP_bio(BIO *bio, TS_RESP *a);
1147
1148 TS_STATUS_INFO *TS_STATUS_INFO_new(void);
1149 void TS_STATUS_INFO_free(TS_STATUS_INFO *a);
1150 @@ -325,10 +331,12 @@ TS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,
1151 long length);
1152 TS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);
1153
1154 +#ifndef OPENSSL_NO_FP_API
1155 TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);
1156 int i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);
1157 -TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO **a);
1158 -int i2d_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO *a);
1159 +#endif
1160 +TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a);
1161 +int i2d_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO *a);
1162
1163 TS_ACCURACY *TS_ACCURACY_new(void);
1164 void TS_ACCURACY_free(TS_ACCURACY *a);
1165 @@ -728,15 +736,18 @@ int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);
1166 * ts/ts_conf.c
1167 */
1168
1169 +#ifndef OPENSSL_NO_STDIO
1170 X509 *TS_CONF_load_cert(const char *file);
1171 STACK_OF(X509) *TS_CONF_load_certs(const char *file);
1172 EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);
1173 +#endif
1174 const char *TS_CONF_get_tsa_section(CONF *conf, const char *section);
1175 int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,
1176 TS_RESP_CTX *ctx);
1177 int TS_CONF_set_crypto_device(CONF *conf, const char *section,
1178 const char *device);
1179 int TS_CONF_set_default_engine(const char *name);
1180 +#ifndef OPENSSL_NO_STDIO
1181 int TS_CONF_set_signer_cert(CONF *conf, const char *section,
1182 const char *cert, TS_RESP_CTX *ctx);
1183 int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
1184 @@ -744,6 +755,7 @@ int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
1185 int TS_CONF_set_signer_key(CONF *conf, const char *section,
1186 const char *key, const char *pass,
1187 TS_RESP_CTX *ctx);
1188 +#endif
1189 int TS_CONF_set_def_policy(CONF *conf, const char *section,
1190 const char *policy, TS_RESP_CTX *ctx);
1191 int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);
1192 @@ -784,6 +796,11 @@ void ERR_load_TS_strings(void);
1193 # define TS_F_TS_CHECK_SIGNING_CERTS 103
1194 # define TS_F_TS_CHECK_STATUS_INFO 104
1195 # define TS_F_TS_COMPUTE_IMPRINT 145
1196 +# define TS_F_TS_CONF_INVALID 151
1197 +# define TS_F_TS_CONF_LOAD_CERT 153
1198 +# define TS_F_TS_CONF_LOAD_CERTS 154
1199 +# define TS_F_TS_CONF_LOAD_KEY 155
1200 +# define TS_F_TS_CONF_LOOKUP_FAIL 152
1201 # define TS_F_TS_CONF_SET_DEFAULT_ENGINE 146
1202 # define TS_F_TS_GET_STATUS_TEXT 105
1203 # define TS_F_TS_MSG_IMPRINT_SET_ALGO 118
1204 @@ -822,6 +839,8 @@ void ERR_load_TS_strings(void);
1205 /* Reason codes. */
1206 # define TS_R_BAD_PKCS7_TYPE 132
1207 # define TS_R_BAD_TYPE 133
1208 +# define TS_R_CANNOT_LOAD_CERT 137
1209 +# define TS_R_CANNOT_LOAD_KEY 138
1210 # define TS_R_CERTIFICATE_VERIFY_ERROR 100
1211 # define TS_R_COULD_NOT_SET_ENGINE 127
1212 # define TS_R_COULD_NOT_SET_TIME 115
1213 @@ -854,6 +873,8 @@ void ERR_load_TS_strings(void);
1214 # define TS_R_UNACCEPTABLE_POLICY 125
1215 # define TS_R_UNSUPPORTED_MD_ALGORITHM 126
1216 # define TS_R_UNSUPPORTED_VERSION 113
1217 +# define TS_R_VAR_BAD_VALUE 135
1218 +# define TS_R_VAR_LOOKUP_FAILURE 136
1219 # define TS_R_WRONG_CONTENT_TYPE 114
1220
1221 #ifdef __cplusplus
1222 diff --git a/crypto/ts/ts_conf.c b/crypto/ts/ts_conf.c
1223 index 4716b23..c4416ba 100644
1224 --- a/crypto/ts/ts_conf.c
1225 +++ b/crypto/ts/ts_conf.c
1226 @@ -92,6 +92,7 @@
1227
1228 /* Function definitions for certificate and key loading. */
1229
1230 +#ifndef OPENSSL_NO_STDIO
1231 X509 *TS_CONF_load_cert(const char *file)
1232 {
1233 BIO *cert = NULL;
1234 @@ -102,7 +103,7 @@ X509 *TS_CONF_load_cert(const char *file)
1235 x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL);
1236 end:
1237 if (x == NULL)
1238 - fprintf(stderr, "unable to load certificate: %s\n", file);
1239 + TSerr(TS_F_TS_CONF_LOAD_CERT, TS_R_CANNOT_LOAD_CERT);
1240 BIO_free(cert);
1241 return x;
1242 }
1243 @@ -129,7 +130,7 @@ STACK_OF(X509) *TS_CONF_load_certs(const char *file)
1244 }
1245 end:
1246 if (othercerts == NULL)
1247 - fprintf(stderr, "unable to load certificates: %s\n", file);
1248 + TSerr(TS_F_TS_CONF_LOAD_CERTS, TS_R_CANNOT_LOAD_CERT);
1249 sk_X509_INFO_pop_free(allcerts, X509_INFO_free);
1250 BIO_free(certs);
1251 return othercerts;
1252 @@ -145,21 +146,24 @@ EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass)
1253 pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, (char *)pass);
1254 end:
1255 if (pkey == NULL)
1256 - fprintf(stderr, "unable to load private key: %s\n", file);
1257 + TSerr(TS_F_TS_CONF_LOAD_KEY, TS_R_CANNOT_LOAD_KEY);
1258 BIO_free(key);
1259 return pkey;
1260 }
1261 +#endif /* !OPENSSL_NO_STDIO */
1262
1263 /* Function definitions for handling configuration options. */
1264
1265 static void TS_CONF_lookup_fail(const char *name, const char *tag)
1266 {
1267 - fprintf(stderr, "variable lookup failed for %s::%s\n", name, tag);
1268 + TSerr(TS_F_TS_CONF_LOOKUP_FAIL, TS_R_VAR_LOOKUP_FAILURE);
1269 + ERR_add_error_data(3, name, "::", tag);
1270 }
1271
1272 static void TS_CONF_invalid(const char *name, const char *tag)
1273 {
1274 - fprintf(stderr, "invalid variable value for %s::%s\n", name, tag);
1275 + TSerr(TS_F_TS_CONF_INVALID, TS_R_VAR_BAD_VALUE);
1276 + ERR_add_error_data(3, name, "::", tag);
1277 }
1278
1279 const char *TS_CONF_get_tsa_section(CONF *conf, const char *section)
1280 @@ -237,6 +241,7 @@ int TS_CONF_set_default_engine(const char *name)
1281
1282 #endif
1283
1284 +#ifndef OPENSSL_NO_STDIO
1285 int TS_CONF_set_signer_cert(CONF *conf, const char *section,
1286 const char *cert, TS_RESP_CTX *ctx)
1287 {
1288 @@ -302,6 +307,7 @@ int TS_CONF_set_signer_key(CONF *conf, const char *section,
1289 EVP_PKEY_free(key_obj);
1290 return ret;
1291 }
1292 +#endif /* !OPENSSL_NO_STDIO */
1293
1294 int TS_CONF_set_def_policy(CONF *conf, const char *section,
1295 const char *policy, TS_RESP_CTX *ctx)
1296 diff --git a/crypto/ts/ts_err.c b/crypto/ts/ts_err.c
1297 index ff1abf4..3f5b78f 100644
1298 --- a/crypto/ts/ts_err.c
1299 +++ b/crypto/ts/ts_err.c
1300 @@ -1,6 +1,6 @@
1301 /* crypto/ts/ts_err.c */
1302 /* ====================================================================
1303 - * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
1304 + * Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved.
1305 *
1306 * Redistribution and use in source and binary forms, with or without
1307 * modification, are permitted provided that the following conditions
1308 @@ -87,6 +87,11 @@ static ERR_STRING_DATA TS_str_functs[] = {
1309 {ERR_FUNC(TS_F_TS_CHECK_SIGNING_CERTS), "TS_CHECK_SIGNING_CERTS"},
1310 {ERR_FUNC(TS_F_TS_CHECK_STATUS_INFO), "TS_CHECK_STATUS_INFO"},
1311 {ERR_FUNC(TS_F_TS_COMPUTE_IMPRINT), "TS_COMPUTE_IMPRINT"},
1312 + {ERR_FUNC(TS_F_TS_CONF_INVALID), "ts_CONF_invalid"},
1313 + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERT), "TS_CONF_load_cert"},
1314 + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERTS), "TS_CONF_load_certs"},
1315 + {ERR_FUNC(TS_F_TS_CONF_LOAD_KEY), "TS_CONF_load_key"},
1316 + {ERR_FUNC(TS_F_TS_CONF_LOOKUP_FAIL), "ts_CONF_lookup_fail"},
1317 {ERR_FUNC(TS_F_TS_CONF_SET_DEFAULT_ENGINE), "TS_CONF_set_default_engine"},
1318 {ERR_FUNC(TS_F_TS_GET_STATUS_TEXT), "TS_GET_STATUS_TEXT"},
1319 {ERR_FUNC(TS_F_TS_MSG_IMPRINT_SET_ALGO), "TS_MSG_IMPRINT_set_algo"},
1320 @@ -132,6 +137,8 @@ static ERR_STRING_DATA TS_str_functs[] = {
1321 static ERR_STRING_DATA TS_str_reasons[] = {
1322 {ERR_REASON(TS_R_BAD_PKCS7_TYPE), "bad pkcs7 type"},
1323 {ERR_REASON(TS_R_BAD_TYPE), "bad type"},
1324 + {ERR_REASON(TS_R_CANNOT_LOAD_CERT), "cannot load certificate"},
1325 + {ERR_REASON(TS_R_CANNOT_LOAD_KEY), "cannot load private key"},
1326 {ERR_REASON(TS_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"},
1327 {ERR_REASON(TS_R_COULD_NOT_SET_ENGINE), "could not set engine"},
1328 {ERR_REASON(TS_R_COULD_NOT_SET_TIME), "could not set time"},
1329 @@ -170,6 +177,8 @@ static ERR_STRING_DATA TS_str_reasons[] = {
1330 {ERR_REASON(TS_R_UNACCEPTABLE_POLICY), "unacceptable policy"},
1331 {ERR_REASON(TS_R_UNSUPPORTED_MD_ALGORITHM), "unsupported md algorithm"},
1332 {ERR_REASON(TS_R_UNSUPPORTED_VERSION), "unsupported version"},
1333 + {ERR_REASON(TS_R_VAR_BAD_VALUE), "var bad value"},
1334 + {ERR_REASON(TS_R_VAR_LOOKUP_FAILURE), "cannot find config variable"},
1335 {ERR_REASON(TS_R_WRONG_CONTENT_TYPE), "wrong content type"},
1336 {0, NULL}
1337 };
1338 diff --git a/crypto/ui/ui_util.c b/crypto/ui/ui_util.c
1339 index 0f29011..80dd40e 100644
1340 --- a/crypto/ui/ui_util.c
1341 +++ b/crypto/ui/ui_util.c
1342 @@ -56,6 +56,10 @@
1343 #include <string.h>
1344 #include "ui_locl.h"
1345
1346 +#ifndef BUFSIZ
1347 +#define BUFSIZ 256
1348 +#endif
1349 +
1350 int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,
1351 int verify)
1352 {
1353 diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
1354 index 9ee8f8d..64b052e 100644
1355 --- a/crypto/x509/by_dir.c
1356 +++ b/crypto/x509/by_dir.c
1357 @@ -69,6 +69,8 @@
1358 # include <sys/stat.h>
1359 #endif
1360
1361 +#ifndef OPENSSL_NO_STDIO
1362 +
1363 #include <openssl/lhash.h>
1364 #include <openssl/x509.h>
1365
1366 @@ -434,3 +436,5 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
1367 BUF_MEM_free(b);
1368 return (ok);
1369 }
1370 +
1371 +#endif /* OPENSSL_NO_STDIO */
1372 diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
1373 index 0429767..7ddc21c 100644
1374 --- a/crypto/x509/x509_vfy.c
1375 +++ b/crypto/x509/x509_vfy.c
1376 @@ -940,6 +940,8 @@ static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify)
1377 ctx->current_crl = crl;
1378 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
1379 ptime = &ctx->param->check_time;
1380 + else if (ctx->param->flags & X509_V_FLAG_NO_CHECK_TIME)
1381 + return 1;
1382 else
1383 ptime = NULL;
1384
1385 @@ -1663,6 +1665,8 @@ static int check_cert_time(X509_STORE_CTX *ctx, X509 *x)
1386
1387 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
1388 ptime = &ctx->param->check_time;
1389 + else if (ctx->param->flags & X509_V_FLAG_NO_CHECK_TIME)
1390 + return 1;
1391 else
1392 ptime = NULL;
1393
1394 diff --git a/crypto/x509/x509_vfy.h b/crypto/x509/x509_vfy.h
1395 index 2663e1c..3790ef5 100644
1396 --- a/crypto/x509/x509_vfy.h
1397 +++ b/crypto/x509/x509_vfy.h
1398 @@ -438,6 +438,8 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
1399 * will force the behaviour to match that of previous versions.
1400 */
1401 # define X509_V_FLAG_NO_ALT_CHAINS 0x100000
1402 +/* Do not check certificate/CRL validity against current time */
1403 +# define X509_V_FLAG_NO_CHECK_TIME 0x200000
1404
1405 # define X509_VP_FLAG_DEFAULT 0x1
1406 # define X509_VP_FLAG_OVERWRITE 0x2
1407 @@ -490,9 +492,10 @@ void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
1408 X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);
1409
1410 X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
1411 -
1412 +#ifndef OPENSSL_NO_STDIO
1413 X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
1414 X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
1415 +#endif
1416
1417 int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
1418 int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
1419 diff --git a/crypto/x509v3/ext_dat.h b/crypto/x509v3/ext_dat.h
1420 index c3a6fce..01edd2a 100644
1421 --- a/crypto/x509v3/ext_dat.h
1422 +++ b/crypto/x509v3/ext_dat.h
1423 @@ -127,8 +127,10 @@ static const X509V3_EXT_METHOD *standard_exts[] = {
1424 &v3_idp,
1425 &v3_alt[2],
1426 &v3_freshest_crl,
1427 +#ifndef OPENSSL_SYS_UEFI
1428 &v3_ct_scts[0],
1429 &v3_ct_scts[1],
1430 +#endif
1431 };
1432
1433 /* Number of standard extensions */
1434 diff --git a/crypto/x509v3/v3_pci.c b/crypto/x509v3/v3_pci.c
1435 index 34cad53..12f12a7 100644
1436 --- a/crypto/x509v3/v3_pci.c
1437 +++ b/crypto/x509v3/v3_pci.c
1438 @@ -149,6 +149,7 @@ static int process_pci_value(CONF_VALUE *val,
1439 goto err;
1440 }
1441 OPENSSL_free(tmp_data2);
1442 +#ifndef OPENSSL_NO_STDIO
1443 } else if (strncmp(val->value, "file:", 5) == 0) {
1444 unsigned char buf[2048];
1445 int n;
1446 @@ -181,6 +182,7 @@ static int process_pci_value(CONF_VALUE *val,
1447 X509V3_conf_err(val);
1448 goto err;
1449 }
1450 +#endif /* !OPENSSL_NO_STDIO */
1451 } else if (strncmp(val->value, "text:", 5) == 0) {
1452 val_len = strlen(val->value + 5);
1453 tmp_data = OPENSSL_realloc((*policy)->data,
1454 diff --git a/crypto/x509v3/x509v3.h b/crypto/x509v3/x509v3.h
1455 index f5c6156..a2e78aa 100644
1456 --- a/crypto/x509v3/x509v3.h
1457 +++ b/crypto/x509v3/x509v3.h
1458 @@ -688,8 +688,9 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
1459 int ml);
1460 int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
1461 int indent);
1462 +#ifndef OPENSSL_NO_FP_API
1463 int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
1464 -
1465 +#endif
1466 int X509V3_extensions_print(BIO *out, char *title,
1467 STACK_OF(X509_EXTENSION) *exts,
1468 unsigned long flag, int indent);
1469 diff --git a/demos/engines/cluster_labs/hw_cluster_labs_err.h b/demos/engines/cluster_labs/hw_cluster_labs_err.h
1470 index 3300e11..e9e58d5 100644
1471 --- a/demos/engines/cluster_labs/hw_cluster_labs_err.h
1472 +++ b/demos/engines/cluster_labs/hw_cluster_labs_err.h
1473 @@ -67,7 +67,7 @@ extern "C" {
1474 static void ERR_load_CL_strings(void);
1475 static void ERR_unload_CL_strings(void);
1476 static void ERR_CL_error(int function, int reason, char *file, int line);
1477 -# define CLerr(f,r) ERR_CL_error((f),(r),__FILE__,__LINE__)
1478 +# define CLerr(f,r) ERR_CL_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1479
1480 /* Error codes for the CL functions. */
1481
1482 diff --git a/demos/engines/ibmca/hw_ibmca_err.h b/demos/engines/ibmca/hw_ibmca_err.h
1483 index c17e0c9..10d0212 100644
1484 --- a/demos/engines/ibmca/hw_ibmca_err.h
1485 +++ b/demos/engines/ibmca/hw_ibmca_err.h
1486 @@ -67,7 +67,7 @@ extern "C" {
1487 static void ERR_load_IBMCA_strings(void);
1488 static void ERR_unload_IBMCA_strings(void);
1489 static void ERR_IBMCA_error(int function, int reason, char *file, int line);
1490 -# define IBMCAerr(f,r) ERR_IBMCA_error((f),(r),__FILE__,__LINE__)
1491 +# define IBMCAerr(f,r) ERR_IBMCA_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1492
1493 /* Error codes for the IBMCA functions. */
1494
1495 diff --git a/demos/engines/rsaref/rsaref_err.h b/demos/engines/rsaref/rsaref_err.h
1496 index 4356815..598836f 100644
1497 --- a/demos/engines/rsaref/rsaref_err.h
1498 +++ b/demos/engines/rsaref/rsaref_err.h
1499 @@ -68,7 +68,7 @@ extern "C" {
1500 static void ERR_load_RSAREF_strings(void);
1501 static void ERR_unload_RSAREF_strings(void);
1502 static void ERR_RSAREF_error(int function, int reason, char *file, int line);
1503 -# define RSAREFerr(f,r) ERR_RSAREF_error((f),(r),__FILE__,__LINE__)
1504 +# define RSAREFerr(f,r) ERR_RSAREF_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1505 /* Error codes for the RSAREF functions. */
1506
1507 /* Function codes. */
1508 diff --git a/demos/engines/zencod/hw_zencod_err.h b/demos/engines/zencod/hw_zencod_err.h
1509 index f4a8358..94d3293 100644
1510 --- a/demos/engines/zencod/hw_zencod_err.h
1511 +++ b/demos/engines/zencod/hw_zencod_err.h
1512 @@ -67,7 +67,7 @@ extern "C" {
1513 static void ERR_load_ZENCOD_strings(void);
1514 static void ERR_unload_ZENCOD_strings(void);
1515 static void ERR_ZENCOD_error(int function, int reason, char *file, int line);
1516 -# define ZENCODerr(f,r) ERR_ZENCOD_error((f),(r),__FILE__,__LINE__)
1517 +# define ZENCODerr(f,r) ERR_ZENCOD_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1518
1519 /* Error codes for the ZENCOD functions. */
1520
1521 diff --git a/doc/crypto/threads.pod b/doc/crypto/threads.pod
1522 index dc0e939..fe123bb 100644
1523 --- a/doc/crypto/threads.pod
1524 +++ b/doc/crypto/threads.pod
1525 @@ -51,15 +51,15 @@ CRYPTO_destroy_dynlockid, CRYPTO_lock - OpenSSL thread support
1526 void CRYPTO_lock(int mode, int n, const char *file, int line);
1527
1528 #define CRYPTO_w_lock(type) \
1529 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
1530 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
1531 #define CRYPTO_w_unlock(type) \
1532 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
1533 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
1534 #define CRYPTO_r_lock(type) \
1535 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
1536 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
1537 #define CRYPTO_r_unlock(type) \
1538 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
1539 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
1540 #define CRYPTO_add(addr,amount,type) \
1541 - CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
1542 + CRYPTO_add_lock(addr,amount,type,OPENSSL_FILE,OPENSSL_LINE)
1543
1544 =head1 DESCRIPTION
1545
1546 diff --git a/e_os.h b/e_os.h
1547 index 1fa36c1..3e9dae2 100644
1548 --- a/e_os.h
1549 +++ b/e_os.h
1550 @@ -136,7 +136,7 @@ extern "C" {
1551 # define MSDOS
1552 # endif
1553
1554 -# if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
1555 +# if (defined(MSDOS) || defined(OPENSSL_SYS_UEFI)) && !defined(GETPID_IS_MEANINGLESS)
1556 # define GETPID_IS_MEANINGLESS
1557 # endif
1558
1559 diff --git a/e_os2.h b/e_os2.h
1560 index 7be9989..909e22f 100644
1561 --- a/e_os2.h
1562 +++ b/e_os2.h
1563 @@ -97,7 +97,14 @@ extern "C" {
1564 * For 32 bit environment, there seems to be the CygWin environment and then
1565 * all the others that try to do the same thing Microsoft does...
1566 */
1567 -# if defined(OPENSSL_SYSNAME_UWIN)
1568 +/*
1569 + * UEFI lives here because it might be built with a Microsoft toolchain and
1570 + * we need to avoid the false positive match on Windows.
1571 + */
1572 +# if defined(OPENSSL_SYSNAME_UEFI)
1573 +# undef OPENSSL_SYS_UNIX
1574 +# define OPENSSL_SYS_UEFI
1575 +# elif defined(OPENSSL_SYSNAME_UWIN)
1576 # undef OPENSSL_SYS_UNIX
1577 # define OPENSSL_SYS_WIN32_UWIN
1578 # else
1579 diff --git a/engines/ccgost/e_gost_err.h b/engines/ccgost/e_gost_err.h
1580 index a2018ec..9eacdcf 100644
1581 --- a/engines/ccgost/e_gost_err.h
1582 +++ b/engines/ccgost/e_gost_err.h
1583 @@ -67,7 +67,7 @@ extern "C" {
1584 void ERR_load_GOST_strings(void);
1585 void ERR_unload_GOST_strings(void);
1586 void ERR_GOST_error(int function, int reason, char *file, int line);
1587 -# define GOSTerr(f,r) ERR_GOST_error((f),(r),__FILE__,__LINE__)
1588 +# define GOSTerr(f,r) ERR_GOST_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1589
1590 /* Error codes for the GOST functions. */
1591
1592 diff --git a/engines/e_4758cca_err.h b/engines/e_4758cca_err.h
1593 index 2f29d96..47a2635 100644
1594 --- a/engines/e_4758cca_err.h
1595 +++ b/engines/e_4758cca_err.h
1596 @@ -67,7 +67,7 @@ extern "C" {
1597 static void ERR_load_CCA4758_strings(void);
1598 static void ERR_unload_CCA4758_strings(void);
1599 static void ERR_CCA4758_error(int function, int reason, char *file, int line);
1600 -# define CCA4758err(f,r) ERR_CCA4758_error((f),(r),__FILE__,__LINE__)
1601 +# define CCA4758err(f,r) ERR_CCA4758_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1602
1603 /* Error codes for the CCA4758 functions. */
1604
1605 diff --git a/engines/e_aep_err.h b/engines/e_aep_err.h
1606 index 2ed0114..1f8fa5b 100644
1607 --- a/engines/e_aep_err.h
1608 +++ b/engines/e_aep_err.h
1609 @@ -67,7 +67,7 @@ extern "C" {
1610 static void ERR_load_AEPHK_strings(void);
1611 static void ERR_unload_AEPHK_strings(void);
1612 static void ERR_AEPHK_error(int function, int reason, char *file, int line);
1613 -# define AEPHKerr(f,r) ERR_AEPHK_error((f),(r),__FILE__,__LINE__)
1614 +# define AEPHKerr(f,r) ERR_AEPHK_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1615
1616 /* Error codes for the AEPHK functions. */
1617
1618 diff --git a/engines/e_atalla_err.h b/engines/e_atalla_err.h
1619 index 7b71eff..d958496 100644
1620 --- a/engines/e_atalla_err.h
1621 +++ b/engines/e_atalla_err.h
1622 @@ -67,7 +67,7 @@ extern "C" {
1623 static void ERR_load_ATALLA_strings(void);
1624 static void ERR_unload_ATALLA_strings(void);
1625 static void ERR_ATALLA_error(int function, int reason, char *file, int line);
1626 -# define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),__FILE__,__LINE__)
1627 +# define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1628
1629 /* Error codes for the ATALLA functions. */
1630
1631 diff --git a/engines/e_capi_err.h b/engines/e_capi_err.h
1632 index b5d06dc..cfe46b1 100644
1633 --- a/engines/e_capi_err.h
1634 +++ b/engines/e_capi_err.h
1635 @@ -67,7 +67,7 @@ extern "C" {
1636 static void ERR_load_CAPI_strings(void);
1637 static void ERR_unload_CAPI_strings(void);
1638 static void ERR_CAPI_error(int function, int reason, char *file, int line);
1639 -# define CAPIerr(f,r) ERR_CAPI_error((f),(r),__FILE__,__LINE__)
1640 +# define CAPIerr(f,r) ERR_CAPI_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1641
1642 /* Error codes for the CAPI functions. */
1643
1644 diff --git a/engines/e_chil_err.h b/engines/e_chil_err.h
1645 index d86a4ce..3d961b9 100644
1646 --- a/engines/e_chil_err.h
1647 +++ b/engines/e_chil_err.h
1648 @@ -67,7 +67,7 @@ extern "C" {
1649 static void ERR_load_HWCRHK_strings(void);
1650 static void ERR_unload_HWCRHK_strings(void);
1651 static void ERR_HWCRHK_error(int function, int reason, char *file, int line);
1652 -# define HWCRHKerr(f,r) ERR_HWCRHK_error((f),(r),__FILE__,__LINE__)
1653 +# define HWCRHKerr(f,r) ERR_HWCRHK_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1654
1655 /* Error codes for the HWCRHK functions. */
1656
1657 diff --git a/engines/e_cswift_err.h b/engines/e_cswift_err.h
1658 index fde3a82..7c20691 100644
1659 --- a/engines/e_cswift_err.h
1660 +++ b/engines/e_cswift_err.h
1661 @@ -67,7 +67,7 @@ extern "C" {
1662 static void ERR_load_CSWIFT_strings(void);
1663 static void ERR_unload_CSWIFT_strings(void);
1664 static void ERR_CSWIFT_error(int function, int reason, char *file, int line);
1665 -# define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),__FILE__,__LINE__)
1666 +# define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1667
1668 /* Error codes for the CSWIFT functions. */
1669
1670 diff --git a/engines/e_gmp_err.h b/engines/e_gmp_err.h
1671 index 637abbc..ccaf3da 100644
1672 --- a/engines/e_gmp_err.h
1673 +++ b/engines/e_gmp_err.h
1674 @@ -67,7 +67,7 @@ extern "C" {
1675 static void ERR_load_GMP_strings(void);
1676 static void ERR_unload_GMP_strings(void);
1677 static void ERR_GMP_error(int function, int reason, char *file, int line);
1678 -# define GMPerr(f,r) ERR_GMP_error((f),(r),__FILE__,__LINE__)
1679 +# define GMPerr(f,r) ERR_GMP_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1680
1681 /* Error codes for the GMP functions. */
1682
1683 diff --git a/engines/e_nuron_err.h b/engines/e_nuron_err.h
1684 index aa7849c..e607d3e 100644
1685 --- a/engines/e_nuron_err.h
1686 +++ b/engines/e_nuron_err.h
1687 @@ -67,7 +67,7 @@ extern "C" {
1688 static void ERR_load_NURON_strings(void);
1689 static void ERR_unload_NURON_strings(void);
1690 static void ERR_NURON_error(int function, int reason, char *file, int line);
1691 -# define NURONerr(f,r) ERR_NURON_error((f),(r),__FILE__,__LINE__)
1692 +# define NURONerr(f,r) ERR_NURON_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1693
1694 /* Error codes for the NURON functions. */
1695
1696 diff --git a/engines/e_sureware_err.h b/engines/e_sureware_err.h
1697 index bef8623..54f2848 100644
1698 --- a/engines/e_sureware_err.h
1699 +++ b/engines/e_sureware_err.h
1700 @@ -68,7 +68,7 @@ static void ERR_load_SUREWARE_strings(void);
1701 static void ERR_unload_SUREWARE_strings(void);
1702 static void ERR_SUREWARE_error(int function, int reason, char *file,
1703 int line);
1704 -# define SUREWAREerr(f,r) ERR_SUREWARE_error((f),(r),__FILE__,__LINE__)
1705 +# define SUREWAREerr(f,r) ERR_SUREWARE_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1706
1707 /* Error codes for the SUREWARE functions. */
1708
1709 diff --git a/engines/e_ubsec_err.h b/engines/e_ubsec_err.h
1710 index c8aec7c..67110ed 100644
1711 --- a/engines/e_ubsec_err.h
1712 +++ b/engines/e_ubsec_err.h
1713 @@ -67,7 +67,7 @@ extern "C" {
1714 static void ERR_load_UBSEC_strings(void);
1715 static void ERR_unload_UBSEC_strings(void);
1716 static void ERR_UBSEC_error(int function, int reason, char *file, int line);
1717 -# define UBSECerr(f,r) ERR_UBSEC_error((f),(r),__FILE__,__LINE__)
1718 +# define UBSECerr(f,r) ERR_UBSEC_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1719
1720 /* Error codes for the UBSEC functions. */
1721
1722 diff --git a/ssl/d1_both.c b/ssl/d1_both.c
1723 index d1fc716..d5f661a 100644
1724 --- a/ssl/d1_both.c
1725 +++ b/ssl/d1_both.c
1726 @@ -1053,7 +1053,7 @@ int dtls1_send_change_cipher_spec(SSL *s, int a, int b)
1727 int dtls1_read_failed(SSL *s, int code)
1728 {
1729 if (code > 0) {
1730 - fprintf(stderr, "invalid state reached %s:%d", __FILE__, __LINE__);
1731 + fprintf(stderr, "dtls1_read_failed(); invalid state reached\n");
1732 return 1;
1733 }
1734
1735 diff --git a/ssl/ssl_asn1.c b/ssl/ssl_asn1.c
1736 index 35cc27c..a1f5335 100644
1737 --- a/ssl/ssl_asn1.c
1738 +++ b/ssl/ssl_asn1.c
1739 @@ -418,7 +418,7 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
1740 if (ssl_version == SSL2_VERSION) {
1741 if (os.length != 3) {
1742 c.error = SSL_R_CIPHER_CODE_WRONG_LENGTH;
1743 - c.line = __LINE__;
1744 + c.line = OPENSSL_LINE;
1745 goto err;
1746 }
1747 id = 0x02000000L |
1748 @@ -429,14 +429,14 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
1749 || ssl_version == DTLS1_BAD_VER) {
1750 if (os.length != 2) {
1751 c.error = SSL_R_CIPHER_CODE_WRONG_LENGTH;
1752 - c.line = __LINE__;
1753 + c.line = OPENSSL_LINE;
1754 goto err;
1755 }
1756 id = 0x03000000L |
1757 ((unsigned long)os.data[0] << 8L) | (unsigned long)os.data[1];
1758 } else {
1759 c.error = SSL_R_UNKNOWN_SSL_VERSION;
1760 - c.line = __LINE__;
1761 + c.line = OPENSSL_LINE;
1762 goto err;
1763 }
1764
1765 @@ -526,7 +526,7 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
1766 if (os.data != NULL) {
1767 if (os.length > SSL_MAX_SID_CTX_LENGTH) {
1768 c.error = SSL_R_BAD_LENGTH;
1769 - c.line = __LINE__;
1770 + c.line = OPENSSL_LINE;
1771 goto err;
1772 } else {
1773 ret->sid_ctx_length = os.length;
1774 diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
1775 index a73f866..d534c0a 100644
1776 --- a/ssl/ssl_cert.c
1777 +++ b/ssl/ssl_cert.c
1778 @@ -855,12 +855,13 @@ int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x)
1779 return (add_client_CA(&(ctx->client_CA), x));
1780 }
1781
1782 +#ifndef OPENSSL_NO_STDIO
1783 +
1784 static int xname_cmp(const X509_NAME *const *a, const X509_NAME *const *b)
1785 {
1786 return (X509_NAME_cmp(*a, *b));
1787 }
1788
1789 -#ifndef OPENSSL_NO_STDIO
1790 /**
1791 * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed;
1792 * it doesn't really have anything to do with clients (except that a common use
1793 @@ -928,7 +929,6 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
1794 ERR_clear_error();
1795 return (ret);
1796 }
1797 -#endif
1798
1799 /**
1800 * Add a file of certs to a stack.
1801 @@ -1048,6 +1048,7 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
1802 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
1803 return ret;
1804 }
1805 +#endif /* !OPENSSL_NO_STDIO */
1806
1807 /* Add a certificate to a BUF_MEM structure */
1808
1809 diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c
1810 index 5478840..c2ad7c9 100644
1811 --- a/ssl/ssl_conf.c
1812 +++ b/ssl/ssl_conf.c
1813 @@ -362,6 +362,7 @@ static int cmd_Options(SSL_CONF_CTX *cctx, const char *value)
1814 return CONF_parse_list(value, ',', 1, ssl_set_option_list, cctx);
1815 }
1816
1817 +#ifndef OPENSSL_NO_STDIO
1818 static int cmd_Certificate(SSL_CONF_CTX *cctx, const char *value)
1819 {
1820 int rv = 1;
1821 @@ -428,7 +429,9 @@ static int cmd_DHParameters(SSL_CONF_CTX *cctx, const char *value)
1822 BIO_free(in);
1823 return rv > 0;
1824 }
1825 -#endif
1826 +#endif /* !OPENSSL_NO_DH */
1827 +#endif /* !OPENSSL_NO_STDIO */
1828 +
1829 typedef struct {
1830 int (*cmd) (SSL_CONF_CTX *cctx, const char *value);
1831 const char *str_file;
1832 @@ -454,12 +457,14 @@ static const ssl_conf_cmd_tbl ssl_conf_cmds[] = {
1833 SSL_CONF_CMD_STRING(CipherString, "cipher"),
1834 SSL_CONF_CMD_STRING(Protocol, NULL),
1835 SSL_CONF_CMD_STRING(Options, NULL),
1836 +#ifndef OPENSSL_NO_STDIO
1837 SSL_CONF_CMD(Certificate, "cert", SSL_CONF_TYPE_FILE),
1838 SSL_CONF_CMD(PrivateKey, "key", SSL_CONF_TYPE_FILE),
1839 SSL_CONF_CMD(ServerInfoFile, NULL, SSL_CONF_TYPE_FILE),
1840 #ifndef OPENSSL_NO_DH
1841 SSL_CONF_CMD(DHParameters, "dhparam", SSL_CONF_TYPE_FILE)
1842 #endif
1843 +#endif
1844 };
1845
1846 static int ssl_conf_cmd_skip_prefix(SSL_CONF_CTX *cctx, const char **pcmd)
1847 diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c
1848 index 514fcb3..2a54cc9 100644
1849 --- a/ssl/t1_enc.c
1850 +++ b/ssl/t1_enc.c
1851 @@ -780,9 +780,7 @@ int tls1_enc(SSL *s, int send)
1852 * we can't write into the input stream: Can this ever
1853 * happen?? (steve)
1854 */
1855 - fprintf(stderr,
1856 - "%s:%d: rec->data != rec->input\n",
1857 - __FILE__, __LINE__);
1858 + fprintf(stderr, "tls1_enc: rec->data != rec->input\n");
1859 else if (RAND_bytes(rec->input, ivlen) <= 0)
1860 return -1;
1861 }
1862 diff --git a/util/mkerr.pl b/util/mkerr.pl
1863 index 09ebebe..cd57ade 100644
1864 --- a/util/mkerr.pl
1865 +++ b/util/mkerr.pl
1866 @@ -89,7 +89,7 @@ Options:
1867 void ERR_load_<LIB>_strings(void);
1868 void ERR_unload_<LIB>_strings(void);
1869 void ERR_<LIB>_error(int f, int r, char *fn, int ln);
1870 - #define <LIB>err(f,r) ERR_<LIB>_error(f,r,__FILE__,__LINE__)
1871 + #define <LIB>err(f,r) ERR_<LIB>_error(f,r,OPENSSL_FILE,OPENSSL_LINE)
1872 while the code facilitates the use of these in an environment
1873 where the error support routines are dynamically loaded at
1874 runtime.
1875 @@ -474,7 +474,7 @@ EOF
1876 ${staticloader}void ERR_load_${lib}_strings(void);
1877 ${staticloader}void ERR_unload_${lib}_strings(void);
1878 ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line);
1879 -# define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__)
1880 +# define ${lib}err(f,r) ERR_${lib}_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1881
1882 EOF
1883 }