summaryrefslogblamecommitdiff
path: root/packaging/nacl/ports/openssl/nacl.patch
blob: 46b257ca468066409cb0095c749899c5ea03c618 (plain) (tree)




























































                                                                                                                                                                                                                                      
diff -Naur openssl-1.0.1e_old/config openssl-1.0.1e/config
--- openssl-1.0.1e_old/config	2013-02-11 07:26:04.000000000 -0800
+++ openssl-1.0.1e/config	2013-10-23 13:04:35.247827139 -0700
@@ -660,6 +660,7 @@
 	#fi
 	OUT="linux64-s390x"
 	;;
+  le32newlib-*-linux?) OUT="linux-le32newlib" ;;
   x86_64-*-linux?) OUT="linux-x86_64" ;;
   *86-*-linux2) OUT="linux-elf"
 	if [ "$GCCVER" -gt 28 ]; then
diff -Naur openssl-1.0.1e_old/Configure openssl-1.0.1e/Configure
--- openssl-1.0.1e_old/Configure	2013-02-11 07:26:04.000000000 -0800
+++ openssl-1.0.1e/Configure	2013-10-23 15:18:50.833411949 -0700
@@ -362,6 +362,11 @@
 "linux-ia64-icc","icc:-DL_ENDIAN -DTERMIO -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 "linux-x86_64",	"gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
 "linux64-s390x",	"gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
+
+#### NaCl Newlib version (much like linux-elf, which NaCl Glibc uses)
+#### Use linux-aout instead of linux-elf, since it's statically linked.
+"linux-le32newlib",	"gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out",
+
 #### So called "highgprs" target for z/Architecture CPUs
 # "Highgprs" is kernel feature first implemented in Linux 2.6.32, see
 # /proc/cpuinfo. The idea is to preserve most significant bits of
diff -Naur openssl-1.0.1e_old/crypto/rand/rand_unix.c openssl-1.0.1e/crypto/rand/rand_unix.c
--- openssl-1.0.1e_old/crypto/rand/rand_unix.c	2013-02-11 07:26:04.000000000 -0800
+++ openssl-1.0.1e/crypto/rand/rand_unix.c	2013-10-23 13:00:36.981427165 -0700
@@ -133,7 +133,30 @@
 # define FD_SETSIZE (8*sizeof(fd_set))
 #endif
 
-#if defined(OPENSSL_SYS_VOS)
+#if defined(__native_client__)
+#include <stdlib.h>
+#include <irt.h>
+/* TODO(sehr): remove this patch when nacl_io can handle /dev/urandom. */
+int RAND_poll(void)
+{
+  unsigned char buf[ENTROPY_NEEDED];
+  size_t n = 0;
+  struct nacl_irt_random rand_intf;
+  if (nacl_interface_query(NACL_IRT_RANDOM_v0_1, &rand_intf, sizeof(rand_intf))
+      != sizeof(rand_intf))
+    abort();
+  while (n < sizeof(buf)) {
+    size_t nread;
+    if (rand_intf.get_random_bytes((unsigned char *)buf+n,
+                                   ENTROPY_NEEDED-n, &nread) != 0)
+      abort();
+    n += nread;
+  }
+  RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
+  memset(buf, 0, sizeof(buf));
+  return 1;
+}
+#elif defined(OPENSSL_SYS_VOS)
 
 /* The following algorithm repeatedly samples the real-time clock
    (RTC) to generate a sequence of unpredictable data.  The algorithm