diff --git a/Configure b/Configure\r
-index 4a715dc..eb61eda 100755\r
+index 4a715dc..b4a4781 100755\r
--- a/Configure\r
+++ b/Configure\r
-@@ -1082,7 +1082,7 @@ if (defined($disabled{"tls1"}))\r
+@@ -605,6 +605,9 @@ my %table=(\r
+ # with itself, Applink is never engaged and can as well be omitted.\r
+ "mingw64", "gcc:-mno-cygwin -DL_ENDIAN -O3 -Wall -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE::-D_MT:MINGW64:-lws2_32 -lgdi32 -lcrypt32:SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:${x86_64_asm}:mingw64:win32:cygwin-shared:-D_WINDLL:-mno-cygwin:.dll.a",\r
+ \r
++# UEFI\r
++"UEFI", "cc:-DL_ENDIAN -O:::UEFI::::",\r
++\r
+ # UWIN \r
+ "UWIN", "cc:-DTERMIOS -DL_ENDIAN -O -Wall:::UWIN::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:win32",\r
+ \r
+@@ -1082,7 +1085,7 @@ if (defined($disabled{"tls1"}))\r
}\r
\r
if (defined($disabled{"ec"}) || defined($disabled{"dsa"})\r
/*\r
* Borland C seems too stupid to be able to shift and do longs in the\r
diff --git a/crypto/opensslconf.h.in b/crypto/opensslconf.h.in\r
-index 7a1c85d..a5f51a7 100644\r
+index 7a1c85d..7162c0f 100644\r
--- a/crypto/opensslconf.h.in\r
+++ b/crypto/opensslconf.h.in\r
@@ -1,5 +1,15 @@\r
/* Generate 80386 code? */\r
#undef I386_ONLY\r
\r
+@@ -56,7 +66,7 @@\r
+ #endif\r
+ #endif\r
+ \r
+-#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)\r
++#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) && !defined(OPENSSL_SYSNAME_UEFI)\r
+ #define CONFIG_HEADER_BN_H\r
+ #undef BN_LLONG\r
+ \r
diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h\r
index d3b23fc..87b0b6a 100644\r
--- a/crypto/pem/pem.h\r
+ BIO_free_all(tmpmem);\r
+ return ret;\r
}\r
+diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c\r
+index 737aebf..f23f348 100644\r
+--- a/crypto/rand/rand_egd.c\r
++++ b/crypto/rand/rand_egd.c\r
+@@ -95,7 +95,7 @@\r
+ * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255.\r
+ */\r
+ \r
+-#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_BEOS)\r
++#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_BEOS) || defined(OPENSSL_SYS_UEFI)\r
+ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)\r
+ {\r
+ return (-1);\r
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c\r
index 266111e..f60fac6 100644\r
--- a/crypto/rand/rand_unix.c\r