]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2f.patch
CryptoPkg/OpensslLib: Switch to upstream fix for OpenSSL RT#3964
[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/conf/conf.h b/crypto/conf/conf.h
35 index 8d926d5..41cf38e 100644
36 --- a/crypto/conf/conf.h
37 +++ b/crypto/conf/conf.h
38 @@ -118,8 +118,10 @@ typedef void conf_finish_func (CONF_IMODULE *md);
39
40 int CONF_set_default_method(CONF_METHOD *meth);
41 void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);
42 +# ifndef OPENSSL_NO_STDIO
43 LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
44 long *eline);
45 +# endif
46 # ifndef OPENSSL_NO_FP_API
47 LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
48 long *eline);
49 @@ -133,7 +135,9 @@ char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,
50 long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,
51 const char *name);
52 void CONF_free(LHASH_OF(CONF_VALUE) *conf);
53 +#ifndef OPENSSL_NO_FP_API
54 int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
55 +#endif
56 int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
57
58 void OPENSSL_config(const char *config_name);
59 @@ -160,7 +164,9 @@ CONF_METHOD *NCONF_XML(void);
60 void NCONF_free(CONF *conf);
61 void NCONF_free_data(CONF *conf);
62
63 +# ifndef OPENSSL_NO_STDIO
64 int NCONF_load(CONF *conf, const char *file, long *eline);
65 +# endif
66 # ifndef OPENSSL_NO_FP_API
67 int NCONF_load_fp(CONF *conf, FILE *fp, long *eline);
68 # endif
69 @@ -170,7 +176,9 @@ STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,
70 char *NCONF_get_string(const CONF *conf, const char *group, const char *name);
71 int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
72 long *result);
73 +#ifndef OPENSSL_NO_FP_API
74 int NCONF_dump_fp(const CONF *conf, FILE *out);
75 +#endif
76 int NCONF_dump_bio(const CONF *conf, BIO *out);
77
78 # if 0 /* The following function has no error
79 @@ -184,8 +192,10 @@ long NCONF_get_number(CONF *conf, char *group, char *name);
80
81 int CONF_modules_load(const CONF *cnf, const char *appname,
82 unsigned long flags);
83 +#ifndef OPENSSL_NO_STDIO
84 int CONF_modules_load_file(const char *filename, const char *appname,
85 unsigned long flags);
86 +#endif
87 void CONF_modules_unload(int all);
88 void CONF_modules_finish(void);
89 void CONF_modules_free(void);
90 diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
91 index 68c77ce..3d308c7 100644
92 --- a/crypto/conf/conf_def.c
93 +++ b/crypto/conf/conf_def.c
94 @@ -182,6 +182,10 @@ static int def_destroy_data(CONF *conf)
95
96 static int def_load(CONF *conf, const char *name, long *line)
97 {
98 +#ifdef OPENSSL_NO_STDIO
99 + CONFerr(CONF_F_DEF_LOAD, ERR_R_SYS_LIB);
100 + return 0;
101 +#else
102 int ret;
103 BIO *in = NULL;
104
105 @@ -202,6 +206,7 @@ static int def_load(CONF *conf, const char *name, long *line)
106 BIO_free(in);
107
108 return ret;
109 +#endif
110 }
111
112 static int def_load_bio(CONF *conf, BIO *in, long *line)
113 diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
114 index 5281384..952b545 100644
115 --- a/crypto/conf/conf_lib.c
116 +++ b/crypto/conf/conf_lib.c
117 @@ -90,6 +90,7 @@ int CONF_set_default_method(CONF_METHOD *meth)
118 return 1;
119 }
120
121 +#ifndef OPENSSL_NO_STDIO
122 LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
123 long *eline)
124 {
125 @@ -111,6 +112,7 @@ LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
126
127 return ltmp;
128 }
129 +#endif
130
131 #ifndef OPENSSL_NO_FP_API
132 LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
133 @@ -255,6 +257,7 @@ void NCONF_free_data(CONF *conf)
134 conf->meth->destroy_data(conf);
135 }
136
137 +#ifndef OPENSSL_NO_STDIO
138 int NCONF_load(CONF *conf, const char *file, long *eline)
139 {
140 if (conf == NULL) {
141 @@ -264,6 +267,7 @@ int NCONF_load(CONF *conf, const char *file, long *eline)
142
143 return conf->meth->load(conf, file, eline);
144 }
145 +#endif
146
147 #ifndef OPENSSL_NO_FP_API
148 int NCONF_load_fp(CONF *conf, FILE *fp, long *eline)
149 diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
150 index 9acfca4..5e0a482 100644
151 --- a/crypto/conf/conf_mod.c
152 +++ b/crypto/conf/conf_mod.c
153 @@ -159,6 +159,7 @@ int CONF_modules_load(const CONF *cnf, const char *appname,
154
155 }
156
157 +#ifndef OPENSSL_NO_STDIO
158 int CONF_modules_load_file(const char *filename, const char *appname,
159 unsigned long flags)
160 {
161 @@ -194,6 +195,7 @@ int CONF_modules_load_file(const char *filename, const char *appname,
162
163 return ret;
164 }
165 +#endif
166
167 static int module_run(const CONF *cnf, char *name, char *value,
168 unsigned long flags)
169 diff --git a/crypto/conf/conf_sap.c b/crypto/conf/conf_sap.c
170 index c042cf2..a25b636 100644
171 --- a/crypto/conf/conf_sap.c
172 +++ b/crypto/conf/conf_sap.c
173 @@ -87,9 +87,11 @@ void OPENSSL_config(const char *config_name)
174 ENGINE_load_builtin_engines();
175 #endif
176 ERR_clear_error();
177 +#ifndef OPENSSL_NO_STDIO
178 CONF_modules_load_file(NULL, config_name,
179 CONF_MFLAGS_DEFAULT_SECTION |
180 CONF_MFLAGS_IGNORE_MISSING_FILE);
181 +#endif
182 openssl_configured = 1;
183 }
184
185 diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
186 index c9f674b..e223118 100644
187 --- a/crypto/cryptlib.c
188 +++ b/crypto/cryptlib.c
189 @@ -670,6 +670,7 @@ unsigned long *OPENSSL_ia32cap_loc(void)
190 }
191
192 # if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
193 +#include <stdio.h>
194 # define OPENSSL_CPUID_SETUP
195 # if defined(_WIN32)
196 typedef unsigned __int64 IA32CAP;
197 @@ -980,11 +981,13 @@ void OPENSSL_showfatal(const char *fmta, ...)
198 #else
199 void OPENSSL_showfatal(const char *fmta, ...)
200 {
201 +#ifndef OPENSSL_NO_STDIO
202 va_list ap;
203
204 va_start(ap, fmta);
205 vfprintf(stderr, fmta, ap);
206 va_end(ap);
207 +#endif
208 }
209
210 int OPENSSL_isservice(void)
211 @@ -1011,10 +1014,12 @@ void OpenSSLDie(const char *file, int line, const char *assertion)
212 #endif
213 }
214
215 +#ifndef OPENSSL_NO_STDIO
216 void *OPENSSL_stderr(void)
217 {
218 return stderr;
219 }
220 +#endif
221
222 int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
223 {
224 diff --git a/crypto/cryptlib.h b/crypto/cryptlib.h
225 index fba180a..3e3ea5e 100644
226 --- a/crypto/cryptlib.h
227 +++ b/crypto/cryptlib.h
228 @@ -101,7 +101,9 @@ extern "C" {
229 void OPENSSL_cpuid_setup(void);
230 extern unsigned int OPENSSL_ia32cap_P[];
231 void OPENSSL_showfatal(const char *fmta, ...);
232 +#ifndef OPENSSL_NO_STDIO
233 void *OPENSSL_stderr(void);
234 +#endif
235 extern int OPENSSL_NONPIC_relocated;
236
237 #ifdef __cplusplus
238 diff --git a/crypto/crypto.h b/crypto/crypto.h
239 index c450d7a..d6e804e 100644
240 --- a/crypto/crypto.h
241 +++ b/crypto/crypto.h
242 @@ -235,15 +235,15 @@ typedef struct openssl_item_st {
243 # ifndef OPENSSL_NO_LOCKING
244 # ifndef CRYPTO_w_lock
245 # define CRYPTO_w_lock(type) \
246 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
247 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,NULL,0)
248 # define CRYPTO_w_unlock(type) \
249 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
250 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,NULL,0)
251 # define CRYPTO_r_lock(type) \
252 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
253 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,NULL,0)
254 # define CRYPTO_r_unlock(type) \
255 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
256 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,NULL,0)
257 # define CRYPTO_add(addr,amount,type) \
258 - CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
259 + CRYPTO_add_lock(addr,amount,type,NULL,0)
260 # endif
261 # else
262 # define CRYPTO_w_lock(a)
263 @@ -378,19 +378,19 @@ int CRYPTO_is_mem_check_on(void);
264 # define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
265 # define is_MemCheck_on() CRYPTO_is_mem_check_on()
266
267 -# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
268 -# define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
269 +# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,NULL,0)
270 +# define OPENSSL_strdup(str) CRYPTO_strdup((str),NULL,0)
271 # define OPENSSL_realloc(addr,num) \
272 - CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
273 + CRYPTO_realloc((char *)addr,(int)num,NULL,0)
274 # define OPENSSL_realloc_clean(addr,old_num,num) \
275 - CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
276 + CRYPTO_realloc_clean(addr,old_num,num,NULL,0)
277 # define OPENSSL_remalloc(addr,num) \
278 - CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
279 + CRYPTO_remalloc((char **)addr,(int)num,NULL,0)
280 # define OPENSSL_freeFunc CRYPTO_free
281 # define OPENSSL_free(addr) CRYPTO_free(addr)
282
283 # define OPENSSL_malloc_locked(num) \
284 - CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
285 + CRYPTO_malloc_locked((int)num,NULL,0)
286 # define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
287
288 const char *SSLeay_version(int type);
289 @@ -545,7 +545,7 @@ void CRYPTO_set_mem_debug_options(long bits);
290 long CRYPTO_get_mem_debug_options(void);
291
292 # define CRYPTO_push_info(info) \
293 - CRYPTO_push_info_(info, __FILE__, __LINE__);
294 + CRYPTO_push_info_(info, NULL, 0);
295 int CRYPTO_push_info_(const char *info, const char *file, int line);
296 int CRYPTO_pop_info(void);
297 int CRYPTO_remove_all_info(void);
298 @@ -588,7 +588,7 @@ void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
299
300 /* die if we have to */
301 void OpenSSLDie(const char *file, int line, const char *assertion);
302 -# define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
303 +# define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(NULL, 0, #e),1))
304
305 unsigned long *OPENSSL_ia32cap_loc(void);
306 # define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
307 @@ -605,14 +605,14 @@ void OPENSSL_init(void);
308 # define fips_md_init_ctx(alg, cx) \
309 int alg##_Init(cx##_CTX *c) \
310 { \
311 - if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
312 + if (FIPS_mode()) OpenSSLDie(NULL, 0, \
313 "Low level API call to digest " #alg " forbidden in FIPS mode!"); \
314 return private_##alg##_Init(c); \
315 } \
316 int private_##alg##_Init(cx##_CTX *c)
317
318 # define fips_cipher_abort(alg) \
319 - if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
320 + if (FIPS_mode()) OpenSSLDie(NULL, 0, \
321 "Low level API call to cipher " #alg " forbidden in FIPS mode!")
322
323 # else
324 diff --git a/crypto/des/read2pwd.c b/crypto/des/read2pwd.c
325 index 01e275f..7633139 100644
326 --- a/crypto/des/read2pwd.c
327 +++ b/crypto/des/read2pwd.c
328 @@ -114,6 +114,10 @@
329 #include <openssl/ui.h>
330 #include <openssl/crypto.h>
331
332 +#ifndef BUFSIZ
333 +#define BUFSIZ 256
334 +#endif
335 +
336 int DES_read_password(DES_cblock *key, const char *prompt, int verify)
337 {
338 int ok;
339 diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c
340 index b58e3fa..e5f345a 100644
341 --- a/crypto/dh/dh_pmeth.c
342 +++ b/crypto/dh/dh_pmeth.c
343 @@ -449,6 +449,9 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
344 *keylen = ret;
345 return 1;
346 } else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) {
347 +#ifdef OPENSSL_NO_CMS
348 + return 0;
349 +#else
350 unsigned char *Z = NULL;
351 size_t Zlen = 0;
352 if (!dctx->kdf_outlen || !dctx->kdf_oid)
353 @@ -478,6 +481,7 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
354 OPENSSL_free(Z);
355 }
356 return ret;
357 +#endif
358 }
359 return 1;
360 }
361 diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c
362 index 34b0029..cf622bb 100644
363 --- a/crypto/engine/eng_openssl.c
364 +++ b/crypto/engine/eng_openssl.c
365 @@ -86,7 +86,9 @@
366 * this is no longer automatic in ENGINE_load_builtin_engines().
367 */
368 #define TEST_ENG_OPENSSL_RC4
369 +#ifndef OPENSSL_NO_FP_API
370 #define TEST_ENG_OPENSSL_PKEY
371 +#endif
372 /* #define TEST_ENG_OPENSSL_RC4_OTHERS */
373 #define TEST_ENG_OPENSSL_RC4_P_INIT
374 /* #define TEST_ENG_OPENSSL_RC4_P_CIPHER */
375 diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h
376 index d3b23fc..87b0b6a 100644
377 --- a/crypto/pem/pem.h
378 +++ b/crypto/pem/pem.h
379 @@ -324,6 +324,7 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
380
381 # define DECLARE_PEM_read_fp(name, type) /**/
382 # define DECLARE_PEM_write_fp(name, type) /**/
383 +# define DECLARE_PEM_write_fp_const(name, type) /**/
384 # define DECLARE_PEM_write_cb_fp(name, type) /**/
385 # else
386
387 @@ -417,6 +418,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
388 pem_password_cb *cd, void *u);
389 # endif
390
391 +#ifndef OPENSSL_NO_FP_API
392 int PEM_read(FILE *fp, char **name, char **header,
393 unsigned char **data, long *len);
394 int PEM_write(FILE *fp, const char *name, const char *hdr,
395 @@ -428,6 +430,7 @@ int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
396 int klen, pem_password_cb *callback, void *u);
397 STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
398 pem_password_cb *cb, void *u);
399 +#endif
400
401 int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
402 EVP_MD *md_type, unsigned char **ek, int *ekl,
403 @@ -494,6 +497,7 @@ int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
404 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
405 void *u);
406
407 +#ifndef OPENSSL_NO_FP_API
408 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
409 char *kstr, int klen,
410 pem_password_cb *cb, void *u);
411 @@ -510,7 +514,7 @@ EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
412 int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
413 char *kstr, int klen, pem_password_cb *cd,
414 void *u);
415 -
416 +#endif
417 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
418 int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
419
420 diff --git a/crypto/pem/pem_pk8.c b/crypto/pem/pem_pk8.c
421 index 5747c73..fe465cc 100644
422 --- a/crypto/pem/pem_pk8.c
423 +++ b/crypto/pem/pem_pk8.c
424 @@ -69,10 +69,12 @@
425 static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder,
426 int nid, const EVP_CIPHER *enc,
427 char *kstr, int klen, pem_password_cb *cb, void *u);
428 +
429 +#ifndef OPENSSL_NO_FP_API
430 static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder,
431 int nid, const EVP_CIPHER *enc,
432 char *kstr, int klen, pem_password_cb *cb, void *u);
433 -
434 +#endif
435 /*
436 * These functions write a private key in PKCS#8 format: it is a "drop in"
437 * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc'
438 diff --git a/crypto/pkcs7/pk7_smime.c b/crypto/pkcs7/pk7_smime.c
439 index c4d3724..fd531c9 100644
440 --- a/crypto/pkcs7/pk7_smime.c
441 +++ b/crypto/pkcs7/pk7_smime.c
442 @@ -254,7 +254,8 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
443 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
444 PKCS7_SIGNER_INFO *si;
445 X509_STORE_CTX cert_ctx;
446 - char buf[4096];
447 + char *buf = NULL;
448 + int bufsiz;
449 int i, j = 0, k, ret = 0;
450 BIO *p7bio = NULL;
451 BIO *tmpin = NULL, *tmpout = NULL;
452 @@ -274,12 +275,29 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
453 PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_NO_CONTENT);
454 return 0;
455 }
456 +#if 0
457 + /*
458 + * NB: this test commented out because some versions of Netscape
459 + * illegally include zero length content when signing data. Also
460 + * Microsoft Authenticode includes a SpcIndirectDataContent data
461 + * structure which describes the content to be protected by the
462 + * signature, rather than directly embedding that content. So
463 + * Authenticode implementations are also expected to use
464 + * PKCS7_verify() with explicit external data, on non-detached
465 + * PKCS#7 signatures.
466 + *
467 + * In OpenSSL 1.1 a new flag PKCS7_NO_DUAL_CONTENT has been
468 + * introduced to disable this sanity check. For the 1.0.2 branch
469 + * this change is not acceptable, so the check remains completely
470 + * commented out (as it has been for a long time).
471 + */
472
473 /* Check for data and content: two sets of data */
474 if (!PKCS7_get_detached(p7) && indata) {
475 PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_CONTENT_AND_DATA_PRESENT);
476 return 0;
477 }
478 +#endif
479
480 sinfos = PKCS7_get_signer_info(p7);
481
482 @@ -355,9 +373,14 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
483 } else
484 tmpout = out;
485
486 + bufsiz = 4096;
487 + buf = OPENSSL_malloc(bufsiz);
488 + if (buf == NULL) {
489 + goto err;
490 + }
491 /* We now have to 'read' from p7bio to calculate digests etc. */
492 for (;;) {
493 - i = BIO_read(p7bio, buf, sizeof(buf));
494 + i = BIO_read(p7bio, buf, bufsiz);
495 if (i <= 0)
496 break;
497 if (tmpout)
498 @@ -394,6 +417,9 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
499 }
500 BIO_free_all(p7bio);
501 sk_X509_free(signers);
502 + if (buf != NULL) {
503 + OPENSSL_free(buf);
504 + }
505 return ret;
506 }
507
508 diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
509 index 266111e..f60fac6 100644
510 --- a/crypto/rand/rand_unix.c
511 +++ b/crypto/rand/rand_unix.c
512 @@ -116,7 +116,7 @@
513 #include <openssl/rand.h>
514 #include "rand_lcl.h"
515
516 -#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))
517 +#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))
518
519 # include <sys/types.h>
520 # include <sys/time.h>
521 @@ -439,7 +439,7 @@ int RAND_poll(void)
522 * defined(OPENSSL_SYS_VXWORKS) ||
523 * defined(OPENSSL_SYS_NETWARE)) */
524
525 -#if defined(OPENSSL_SYS_VXWORKS)
526 +#if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
527 int RAND_poll(void)
528 {
529 return 0;
530 diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c
531 index 4e06218..f591f0f 100644
532 --- a/crypto/rsa/rsa_ameth.c
533 +++ b/crypto/rsa/rsa_ameth.c
534 @@ -68,10 +68,12 @@
535 #endif
536 #include "asn1_locl.h"
537
538 +#ifndef OPENSSL_NO_CMS
539 static int rsa_cms_sign(CMS_SignerInfo *si);
540 static int rsa_cms_verify(CMS_SignerInfo *si);
541 static int rsa_cms_decrypt(CMS_RecipientInfo *ri);
542 static int rsa_cms_encrypt(CMS_RecipientInfo *ri);
543 +#endif
544
545 static int rsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
546 {
547 @@ -665,6 +667,7 @@ static int rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx,
548 return rv;
549 }
550
551 +#ifndef OPENSSL_NO_CMS
552 static int rsa_cms_verify(CMS_SignerInfo *si)
553 {
554 int nid, nid2;
555 @@ -683,6 +686,7 @@ static int rsa_cms_verify(CMS_SignerInfo *si)
556 }
557 return 0;
558 }
559 +#endif
560
561 /*
562 * Customised RSA item verification routine. This is called when a signature
563 @@ -705,6 +709,7 @@ static int rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
564 return -1;
565 }
566
567 +#ifndef OPENSSL_NO_CMS
568 static int rsa_cms_sign(CMS_SignerInfo *si)
569 {
570 int pad_mode = RSA_PKCS1_PADDING;
571 @@ -729,6 +734,7 @@ static int rsa_cms_sign(CMS_SignerInfo *si)
572 X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsassaPss), V_ASN1_SEQUENCE, os);
573 return 1;
574 }
575 +#endif
576
577 static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
578 X509_ALGOR *alg1, X509_ALGOR *alg2,
579 @@ -785,6 +791,7 @@ static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg,
580 return pss;
581 }
582
583 +#ifndef OPENSSL_NO_CMS
584 static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
585 {
586 EVP_PKEY_CTX *pkctx;
587 @@ -857,7 +864,9 @@ static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
588 X509_ALGOR_free(maskHash);
589 return rv;
590 }
591 +#endif
592
593 +#ifndef OPENSSL_NO_CMS
594 static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
595 {
596 const EVP_MD *md, *mgf1md;
597 @@ -920,6 +929,7 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
598 ASN1_STRING_free(os);
599 return rv;
600 }
601 +#endif
602
603 const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = {
604 {
605 diff --git a/crypto/srp/srp.h b/crypto/srp/srp.h
606 index d072536..73b945f 100644
607 --- a/crypto/srp/srp.h
608 +++ b/crypto/srp/srp.h
609 @@ -114,7 +114,9 @@ DECLARE_STACK_OF(SRP_gN)
610
611 SRP_VBASE *SRP_VBASE_new(char *seed_key);
612 int SRP_VBASE_free(SRP_VBASE *vb);
613 +#ifndef OPENSSL_NO_STDIO
614 int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
615 +#endif
616 SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);
617 char *SRP_create_verifier(const char *user, const char *pass, char **salt,
618 char **verifier, const char *N, const char *g);
619 diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c
620 index a3f1a8a..3fbb186 100644
621 --- a/crypto/srp/srp_vfy.c
622 +++ b/crypto/srp/srp_vfy.c
623 @@ -225,6 +225,7 @@ static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,
624 return (info == NULL || NULL != (vinfo->info = BUF_strdup(info)));
625 }
626
627 +#ifndef OPENSSL_NO_STDIO
628 static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
629 const char *v)
630 {
631 @@ -239,6 +240,7 @@ static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
632 len = t_fromb64(tmp, s);
633 return ((vinfo->s = BN_bin2bn(tmp, len, NULL)) != NULL);
634 }
635 +#endif
636
637 static int SRP_user_pwd_set_sv_BN(SRP_user_pwd *vinfo, BIGNUM *s, BIGNUM *v)
638 {
639 @@ -279,6 +281,7 @@ int SRP_VBASE_free(SRP_VBASE *vb)
640 return 0;
641 }
642
643 +#ifndef OPENSSL_NO_STDIO
644 static SRP_gN_cache *SRP_gN_new_init(const char *ch)
645 {
646 unsigned char tmp[MAX_LEN];
647 @@ -310,6 +313,7 @@ static void SRP_gN_free(SRP_gN_cache *gN_cache)
648 BN_free(gN_cache->bn);
649 OPENSSL_free(gN_cache);
650 }
651 +#endif
652
653 static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)
654 {
655 @@ -326,6 +330,7 @@ static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)
656 return SRP_get_default_gN(id);
657 }
658
659 +#ifndef OPENSSL_NO_STDIO
660 static BIGNUM *SRP_gN_place_bn(STACK_OF(SRP_gN_cache) *gN_cache, char *ch)
661 {
662 int i;
663 @@ -467,6 +472,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
664 return error_code;
665
666 }
667 +#endif
668
669 SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)
670 {
671 diff --git a/crypto/ts/ts.h b/crypto/ts/ts.h
672 index 16eccbb..a9fe40e 100644
673 --- a/crypto/ts/ts.h
674 +++ b/crypto/ts/ts.h
675 @@ -281,8 +281,10 @@ TS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);
676
677 TS_REQ *TS_REQ_dup(TS_REQ *a);
678
679 +#ifndef OPENSSL_NO_FP_API
680 TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);
681 int i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);
682 +#endif
683 TS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);
684 int i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);
685
686 @@ -294,10 +296,12 @@ TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,
687
688 TS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);
689
690 +#ifndef OPENSSL_NO_FP_API
691 TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);
692 int i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);
693 -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT **a);
694 -int i2d_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT *a);
695 +#endif
696 +TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a);
697 +int i2d_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT *a);
698
699 TS_RESP *TS_RESP_new(void);
700 void TS_RESP_free(TS_RESP *a);
701 @@ -306,10 +310,12 @@ TS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);
702 TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);
703 TS_RESP *TS_RESP_dup(TS_RESP *a);
704
705 +#ifndef OPENSSL_NO_FP_API
706 TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);
707 int i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);
708 -TS_RESP *d2i_TS_RESP_bio(BIO *fp, TS_RESP **a);
709 -int i2d_TS_RESP_bio(BIO *fp, TS_RESP *a);
710 +#endif
711 +TS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a);
712 +int i2d_TS_RESP_bio(BIO *bio, TS_RESP *a);
713
714 TS_STATUS_INFO *TS_STATUS_INFO_new(void);
715 void TS_STATUS_INFO_free(TS_STATUS_INFO *a);
716 @@ -325,10 +331,12 @@ TS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,
717 long length);
718 TS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);
719
720 +#ifndef OPENSSL_NO_FP_API
721 TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);
722 int i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);
723 -TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO **a);
724 -int i2d_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO *a);
725 +#endif
726 +TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a);
727 +int i2d_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO *a);
728
729 TS_ACCURACY *TS_ACCURACY_new(void);
730 void TS_ACCURACY_free(TS_ACCURACY *a);
731 @@ -728,15 +736,18 @@ int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);
732 * ts/ts_conf.c
733 */
734
735 +#ifndef OPENSSL_NO_STDIO
736 X509 *TS_CONF_load_cert(const char *file);
737 STACK_OF(X509) *TS_CONF_load_certs(const char *file);
738 EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);
739 +#endif
740 const char *TS_CONF_get_tsa_section(CONF *conf, const char *section);
741 int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,
742 TS_RESP_CTX *ctx);
743 int TS_CONF_set_crypto_device(CONF *conf, const char *section,
744 const char *device);
745 int TS_CONF_set_default_engine(const char *name);
746 +#ifndef OPENSSL_NO_STDIO
747 int TS_CONF_set_signer_cert(CONF *conf, const char *section,
748 const char *cert, TS_RESP_CTX *ctx);
749 int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
750 @@ -744,6 +755,7 @@ int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
751 int TS_CONF_set_signer_key(CONF *conf, const char *section,
752 const char *key, const char *pass,
753 TS_RESP_CTX *ctx);
754 +#endif
755 int TS_CONF_set_def_policy(CONF *conf, const char *section,
756 const char *policy, TS_RESP_CTX *ctx);
757 int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);
758 @@ -784,6 +796,11 @@ void ERR_load_TS_strings(void);
759 # define TS_F_TS_CHECK_SIGNING_CERTS 103
760 # define TS_F_TS_CHECK_STATUS_INFO 104
761 # define TS_F_TS_COMPUTE_IMPRINT 145
762 +# define TS_F_TS_CONF_INVALID 151
763 +# define TS_F_TS_CONF_LOAD_CERT 153
764 +# define TS_F_TS_CONF_LOAD_CERTS 154
765 +# define TS_F_TS_CONF_LOAD_KEY 155
766 +# define TS_F_TS_CONF_LOOKUP_FAIL 152
767 # define TS_F_TS_CONF_SET_DEFAULT_ENGINE 146
768 # define TS_F_TS_GET_STATUS_TEXT 105
769 # define TS_F_TS_MSG_IMPRINT_SET_ALGO 118
770 @@ -822,6 +839,8 @@ void ERR_load_TS_strings(void);
771 /* Reason codes. */
772 # define TS_R_BAD_PKCS7_TYPE 132
773 # define TS_R_BAD_TYPE 133
774 +# define TS_R_CANNOT_LOAD_CERT 137
775 +# define TS_R_CANNOT_LOAD_KEY 138
776 # define TS_R_CERTIFICATE_VERIFY_ERROR 100
777 # define TS_R_COULD_NOT_SET_ENGINE 127
778 # define TS_R_COULD_NOT_SET_TIME 115
779 @@ -854,6 +873,8 @@ void ERR_load_TS_strings(void);
780 # define TS_R_UNACCEPTABLE_POLICY 125
781 # define TS_R_UNSUPPORTED_MD_ALGORITHM 126
782 # define TS_R_UNSUPPORTED_VERSION 113
783 +# define TS_R_VAR_BAD_VALUE 135
784 +# define TS_R_VAR_LOOKUP_FAILURE 136
785 # define TS_R_WRONG_CONTENT_TYPE 114
786
787 #ifdef __cplusplus
788 diff --git a/crypto/ts/ts_conf.c b/crypto/ts/ts_conf.c
789 index 4716b23..c4416ba 100644
790 --- a/crypto/ts/ts_conf.c
791 +++ b/crypto/ts/ts_conf.c
792 @@ -92,6 +92,7 @@
793
794 /* Function definitions for certificate and key loading. */
795
796 +#ifndef OPENSSL_NO_STDIO
797 X509 *TS_CONF_load_cert(const char *file)
798 {
799 BIO *cert = NULL;
800 @@ -102,7 +103,7 @@ X509 *TS_CONF_load_cert(const char *file)
801 x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL);
802 end:
803 if (x == NULL)
804 - fprintf(stderr, "unable to load certificate: %s\n", file);
805 + TSerr(TS_F_TS_CONF_LOAD_CERT, TS_R_CANNOT_LOAD_CERT);
806 BIO_free(cert);
807 return x;
808 }
809 @@ -129,7 +130,7 @@ STACK_OF(X509) *TS_CONF_load_certs(const char *file)
810 }
811 end:
812 if (othercerts == NULL)
813 - fprintf(stderr, "unable to load certificates: %s\n", file);
814 + TSerr(TS_F_TS_CONF_LOAD_CERTS, TS_R_CANNOT_LOAD_CERT);
815 sk_X509_INFO_pop_free(allcerts, X509_INFO_free);
816 BIO_free(certs);
817 return othercerts;
818 @@ -145,21 +146,24 @@ EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass)
819 pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, (char *)pass);
820 end:
821 if (pkey == NULL)
822 - fprintf(stderr, "unable to load private key: %s\n", file);
823 + TSerr(TS_F_TS_CONF_LOAD_KEY, TS_R_CANNOT_LOAD_KEY);
824 BIO_free(key);
825 return pkey;
826 }
827 +#endif /* !OPENSSL_NO_STDIO */
828
829 /* Function definitions for handling configuration options. */
830
831 static void TS_CONF_lookup_fail(const char *name, const char *tag)
832 {
833 - fprintf(stderr, "variable lookup failed for %s::%s\n", name, tag);
834 + TSerr(TS_F_TS_CONF_LOOKUP_FAIL, TS_R_VAR_LOOKUP_FAILURE);
835 + ERR_add_error_data(3, name, "::", tag);
836 }
837
838 static void TS_CONF_invalid(const char *name, const char *tag)
839 {
840 - fprintf(stderr, "invalid variable value for %s::%s\n", name, tag);
841 + TSerr(TS_F_TS_CONF_INVALID, TS_R_VAR_BAD_VALUE);
842 + ERR_add_error_data(3, name, "::", tag);
843 }
844
845 const char *TS_CONF_get_tsa_section(CONF *conf, const char *section)
846 @@ -237,6 +241,7 @@ int TS_CONF_set_default_engine(const char *name)
847
848 #endif
849
850 +#ifndef OPENSSL_NO_STDIO
851 int TS_CONF_set_signer_cert(CONF *conf, const char *section,
852 const char *cert, TS_RESP_CTX *ctx)
853 {
854 @@ -302,6 +307,7 @@ int TS_CONF_set_signer_key(CONF *conf, const char *section,
855 EVP_PKEY_free(key_obj);
856 return ret;
857 }
858 +#endif /* !OPENSSL_NO_STDIO */
859
860 int TS_CONF_set_def_policy(CONF *conf, const char *section,
861 const char *policy, TS_RESP_CTX *ctx)
862 diff --git a/crypto/ts/ts_err.c b/crypto/ts/ts_err.c
863 index ff1abf4..3f5b78f 100644
864 --- a/crypto/ts/ts_err.c
865 +++ b/crypto/ts/ts_err.c
866 @@ -1,6 +1,6 @@
867 /* crypto/ts/ts_err.c */
868 /* ====================================================================
869 - * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
870 + * Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved.
871 *
872 * Redistribution and use in source and binary forms, with or without
873 * modification, are permitted provided that the following conditions
874 @@ -87,6 +87,11 @@ static ERR_STRING_DATA TS_str_functs[] = {
875 {ERR_FUNC(TS_F_TS_CHECK_SIGNING_CERTS), "TS_CHECK_SIGNING_CERTS"},
876 {ERR_FUNC(TS_F_TS_CHECK_STATUS_INFO), "TS_CHECK_STATUS_INFO"},
877 {ERR_FUNC(TS_F_TS_COMPUTE_IMPRINT), "TS_COMPUTE_IMPRINT"},
878 + {ERR_FUNC(TS_F_TS_CONF_INVALID), "ts_CONF_invalid"},
879 + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERT), "TS_CONF_load_cert"},
880 + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERTS), "TS_CONF_load_certs"},
881 + {ERR_FUNC(TS_F_TS_CONF_LOAD_KEY), "TS_CONF_load_key"},
882 + {ERR_FUNC(TS_F_TS_CONF_LOOKUP_FAIL), "ts_CONF_lookup_fail"},
883 {ERR_FUNC(TS_F_TS_CONF_SET_DEFAULT_ENGINE), "TS_CONF_set_default_engine"},
884 {ERR_FUNC(TS_F_TS_GET_STATUS_TEXT), "TS_GET_STATUS_TEXT"},
885 {ERR_FUNC(TS_F_TS_MSG_IMPRINT_SET_ALGO), "TS_MSG_IMPRINT_set_algo"},
886 @@ -132,6 +137,8 @@ static ERR_STRING_DATA TS_str_functs[] = {
887 static ERR_STRING_DATA TS_str_reasons[] = {
888 {ERR_REASON(TS_R_BAD_PKCS7_TYPE), "bad pkcs7 type"},
889 {ERR_REASON(TS_R_BAD_TYPE), "bad type"},
890 + {ERR_REASON(TS_R_CANNOT_LOAD_CERT), "cannot load certificate"},
891 + {ERR_REASON(TS_R_CANNOT_LOAD_KEY), "cannot load private key"},
892 {ERR_REASON(TS_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"},
893 {ERR_REASON(TS_R_COULD_NOT_SET_ENGINE), "could not set engine"},
894 {ERR_REASON(TS_R_COULD_NOT_SET_TIME), "could not set time"},
895 @@ -170,6 +177,8 @@ static ERR_STRING_DATA TS_str_reasons[] = {
896 {ERR_REASON(TS_R_UNACCEPTABLE_POLICY), "unacceptable policy"},
897 {ERR_REASON(TS_R_UNSUPPORTED_MD_ALGORITHM), "unsupported md algorithm"},
898 {ERR_REASON(TS_R_UNSUPPORTED_VERSION), "unsupported version"},
899 + {ERR_REASON(TS_R_VAR_BAD_VALUE), "var bad value"},
900 + {ERR_REASON(TS_R_VAR_LOOKUP_FAILURE), "cannot find config variable"},
901 {ERR_REASON(TS_R_WRONG_CONTENT_TYPE), "wrong content type"},
902 {0, NULL}
903 };
904 diff --git a/crypto/ui/ui_util.c b/crypto/ui/ui_util.c
905 index 0f29011..80dd40e 100644
906 --- a/crypto/ui/ui_util.c
907 +++ b/crypto/ui/ui_util.c
908 @@ -56,6 +56,10 @@
909 #include <string.h>
910 #include "ui_locl.h"
911
912 +#ifndef BUFSIZ
913 +#define BUFSIZ 256
914 +#endif
915 +
916 int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,
917 int verify)
918 {
919 diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
920 index 9ee8f8d..64b052e 100644
921 --- a/crypto/x509/by_dir.c
922 +++ b/crypto/x509/by_dir.c
923 @@ -69,6 +69,8 @@
924 # include <sys/stat.h>
925 #endif
926
927 +#ifndef OPENSSL_NO_STDIO
928 +
929 #include <openssl/lhash.h>
930 #include <openssl/x509.h>
931
932 @@ -434,3 +436,5 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
933 BUF_MEM_free(b);
934 return (ok);
935 }
936 +
937 +#endif /* OPENSSL_NO_STDIO */
938 diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
939 index 0429767..7ddc21c 100644
940 --- a/crypto/x509/x509_vfy.c
941 +++ b/crypto/x509/x509_vfy.c
942 @@ -940,6 +940,8 @@ static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify)
943 ctx->current_crl = crl;
944 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
945 ptime = &ctx->param->check_time;
946 + else if (ctx->param->flags & X509_V_FLAG_NO_CHECK_TIME)
947 + return 1;
948 else
949 ptime = NULL;
950
951 @@ -1663,6 +1665,8 @@ static int check_cert_time(X509_STORE_CTX *ctx, X509 *x)
952
953 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
954 ptime = &ctx->param->check_time;
955 + else if (ctx->param->flags & X509_V_FLAG_NO_CHECK_TIME)
956 + return 1;
957 else
958 ptime = NULL;
959
960 diff --git a/crypto/x509/x509_vfy.h b/crypto/x509/x509_vfy.h
961 index 2663e1c..3790ef5 100644
962 --- a/crypto/x509/x509_vfy.h
963 +++ b/crypto/x509/x509_vfy.h
964 @@ -438,6 +438,8 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
965 * will force the behaviour to match that of previous versions.
966 */
967 # define X509_V_FLAG_NO_ALT_CHAINS 0x100000
968 +/* Do not check certificate/CRL validity against current time */
969 +# define X509_V_FLAG_NO_CHECK_TIME 0x200000
970
971 # define X509_VP_FLAG_DEFAULT 0x1
972 # define X509_VP_FLAG_OVERWRITE 0x2
973 @@ -490,9 +492,10 @@ void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
974 X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);
975
976 X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
977 -
978 +#ifndef OPENSSL_NO_STDIO
979 X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
980 X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
981 +#endif
982
983 int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
984 int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
985 diff --git a/crypto/x509v3/ext_dat.h b/crypto/x509v3/ext_dat.h
986 index c3a6fce..01edd2a 100644
987 --- a/crypto/x509v3/ext_dat.h
988 +++ b/crypto/x509v3/ext_dat.h
989 @@ -127,8 +127,10 @@ static const X509V3_EXT_METHOD *standard_exts[] = {
990 &v3_idp,
991 &v3_alt[2],
992 &v3_freshest_crl,
993 +#ifndef OPENSSL_SYS_UEFI
994 &v3_ct_scts[0],
995 &v3_ct_scts[1],
996 +#endif
997 };
998
999 /* Number of standard extensions */
1000 diff --git a/crypto/x509v3/v3_pci.c b/crypto/x509v3/v3_pci.c
1001 index 34cad53..12f12a7 100644
1002 --- a/crypto/x509v3/v3_pci.c
1003 +++ b/crypto/x509v3/v3_pci.c
1004 @@ -149,6 +149,7 @@ static int process_pci_value(CONF_VALUE *val,
1005 goto err;
1006 }
1007 OPENSSL_free(tmp_data2);
1008 +#ifndef OPENSSL_NO_STDIO
1009 } else if (strncmp(val->value, "file:", 5) == 0) {
1010 unsigned char buf[2048];
1011 int n;
1012 @@ -181,6 +182,7 @@ static int process_pci_value(CONF_VALUE *val,
1013 X509V3_conf_err(val);
1014 goto err;
1015 }
1016 +#endif /* !OPENSSL_NO_STDIO */
1017 } else if (strncmp(val->value, "text:", 5) == 0) {
1018 val_len = strlen(val->value + 5);
1019 tmp_data = OPENSSL_realloc((*policy)->data,
1020 diff --git a/crypto/x509v3/x509v3.h b/crypto/x509v3/x509v3.h
1021 index f5c6156..a2e78aa 100644
1022 --- a/crypto/x509v3/x509v3.h
1023 +++ b/crypto/x509v3/x509v3.h
1024 @@ -688,8 +688,9 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
1025 int ml);
1026 int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
1027 int indent);
1028 +#ifndef OPENSSL_NO_FP_API
1029 int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
1030 -
1031 +#endif
1032 int X509V3_extensions_print(BIO *out, char *title,
1033 STACK_OF(X509_EXTENSION) *exts,
1034 unsigned long flag, int indent);
1035 diff --git a/e_os.h b/e_os.h
1036 index 1fa36c1..3e9dae2 100644
1037 --- a/e_os.h
1038 +++ b/e_os.h
1039 @@ -136,7 +136,7 @@ extern "C" {
1040 # define MSDOS
1041 # endif
1042
1043 -# if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
1044 +# if (defined(MSDOS) || defined(OPENSSL_SYS_UEFI)) && !defined(GETPID_IS_MEANINGLESS)
1045 # define GETPID_IS_MEANINGLESS
1046 # endif
1047
1048 diff --git a/e_os2.h b/e_os2.h
1049 index 7be9989..909e22f 100644
1050 --- a/e_os2.h
1051 +++ b/e_os2.h
1052 @@ -97,7 +97,14 @@ extern "C" {
1053 * For 32 bit environment, there seems to be the CygWin environment and then
1054 * all the others that try to do the same thing Microsoft does...
1055 */
1056 -# if defined(OPENSSL_SYSNAME_UWIN)
1057 +/*
1058 + * UEFI lives here because it might be built with a Microsoft toolchain and
1059 + * we need to avoid the false positive match on Windows.
1060 + */
1061 +# if defined(OPENSSL_SYSNAME_UEFI)
1062 +# undef OPENSSL_SYS_UNIX
1063 +# define OPENSSL_SYS_UEFI
1064 +# elif defined(OPENSSL_SYSNAME_UWIN)
1065 # undef OPENSSL_SYS_UNIX
1066 # define OPENSSL_SYS_WIN32_UWIN
1067 # else
1068 diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
1069 index a73f866..d534c0a 100644
1070 --- a/ssl/ssl_cert.c
1071 +++ b/ssl/ssl_cert.c
1072 @@ -855,12 +855,13 @@ int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x)
1073 return (add_client_CA(&(ctx->client_CA), x));
1074 }
1075
1076 +#ifndef OPENSSL_NO_STDIO
1077 +
1078 static int xname_cmp(const X509_NAME *const *a, const X509_NAME *const *b)
1079 {
1080 return (X509_NAME_cmp(*a, *b));
1081 }
1082
1083 -#ifndef OPENSSL_NO_STDIO
1084 /**
1085 * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed;
1086 * it doesn't really have anything to do with clients (except that a common use
1087 @@ -928,7 +929,6 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
1088 ERR_clear_error();
1089 return (ret);
1090 }
1091 -#endif
1092
1093 /**
1094 * Add a file of certs to a stack.
1095 @@ -1048,6 +1048,7 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
1096 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
1097 return ret;
1098 }
1099 +#endif /* !OPENSSL_NO_STDIO */
1100
1101 /* Add a certificate to a BUF_MEM structure */
1102
1103 diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c
1104 index 5478840..c2ad7c9 100644
1105 --- a/ssl/ssl_conf.c
1106 +++ b/ssl/ssl_conf.c
1107 @@ -362,6 +362,7 @@ static int cmd_Options(SSL_CONF_CTX *cctx, const char *value)
1108 return CONF_parse_list(value, ',', 1, ssl_set_option_list, cctx);
1109 }
1110
1111 +#ifndef OPENSSL_NO_STDIO
1112 static int cmd_Certificate(SSL_CONF_CTX *cctx, const char *value)
1113 {
1114 int rv = 1;
1115 @@ -428,7 +429,9 @@ static int cmd_DHParameters(SSL_CONF_CTX *cctx, const char *value)
1116 BIO_free(in);
1117 return rv > 0;
1118 }
1119 -#endif
1120 +#endif /* !OPENSSL_NO_DH */
1121 +#endif /* !OPENSSL_NO_STDIO */
1122 +
1123 typedef struct {
1124 int (*cmd) (SSL_CONF_CTX *cctx, const char *value);
1125 const char *str_file;
1126 @@ -454,12 +457,14 @@ static const ssl_conf_cmd_tbl ssl_conf_cmds[] = {
1127 SSL_CONF_CMD_STRING(CipherString, "cipher"),
1128 SSL_CONF_CMD_STRING(Protocol, NULL),
1129 SSL_CONF_CMD_STRING(Options, NULL),
1130 +#ifndef OPENSSL_NO_STDIO
1131 SSL_CONF_CMD(Certificate, "cert", SSL_CONF_TYPE_FILE),
1132 SSL_CONF_CMD(PrivateKey, "key", SSL_CONF_TYPE_FILE),
1133 SSL_CONF_CMD(ServerInfoFile, NULL, SSL_CONF_TYPE_FILE),
1134 #ifndef OPENSSL_NO_DH
1135 SSL_CONF_CMD(DHParameters, "dhparam", SSL_CONF_TYPE_FILE)
1136 #endif
1137 +#endif
1138 };
1139
1140 static int ssl_conf_cmd_skip_prefix(SSL_CONF_CTX *cctx, const char **pcmd)