components/openssl/openssl-1.0.1/patches/30_wanboot.patch
branchs11u2-sru
changeset 4016 7f9e1e7611b8
parent 3402 110b254c69b8
child 4366 8e8f535e48a5
equal deleted inserted replaced
4013:29dc96079508 4016:7f9e1e7611b8
    34  ENGDIRS= ccgost
    34  ENGDIRS= ccgost
    35  SHLIBDIRS= crypto ssl
    35  SHLIBDIRS= crypto ssl
    36 
    36 
    37 --- openssl-1.0.0e/crypto/cryptlib.c	2011-06-22 08:39:00.000000000 -0700
    37 --- openssl-1.0.0e/crypto/cryptlib.c	2011-06-22 08:39:00.000000000 -0700
    38 +++ openssl-1.0.0e_patched/crypto/cryptlib.c	2011-12-12 06:17:45.422476900 -0800
    38 +++ openssl-1.0.0e_patched/crypto/cryptlib.c	2011-12-12 06:17:45.422476900 -0800
    39 @@ -415,6 +415,7 @@
    39 @@ -412,6 +412,7 @@
    40  static void solaris_locking_callback(int mode, int type, const char *file,
    40  static void solaris_locking_callback(int mode, int type, const char *file,
    41      int line)
    41      int line)
    42  	{
    42  	{
    43 +#ifndef	_BOOT
    43 +#ifndef	_BOOT
    44  	if (mode & CRYPTO_LOCK)
    44  	if (mode & CRYPTO_LOCK)
    45  		{
    45  		{
    46  		pthread_mutex_lock(&solaris_openssl_locks[type]);
    46  		pthread_mutex_lock(&solaris_openssl_locks[type]);
    47 @@ -423,6 +424,7 @@
    47 @@ -420,6 +421,7 @@
    48  		{
    48  		{
    49  		pthread_mutex_unlock(&solaris_openssl_locks[type]);
    49  		pthread_mutex_unlock(&solaris_openssl_locks[type]);
    50  		}
    50  		}
    51 +#endif
    51 +#endif
    52  	}
    52  	}
    53 
    53  
    54 
    54  
    55 @@ -456,6 +458,12 @@
    55 @@ -453,6 +455,12 @@
    56  		}
    56  		}
    57  
    57  
    58  	/*
    58  	/*
    59 +	 * pthread_* can't be used in wanboot.
    59 +	 * pthread_* can't be used in wanboot.
    60 +	 * wanboot needs not be thread-safe and mutexes and locking callback
    60 +	 * wanboot needs not be thread-safe and mutexes and locking callback
    63 +#ifndef	_BOOT
    63 +#ifndef	_BOOT
    64 +	/*
    64 +	/*
    65  	 * Set atfork handler so that child can setup its own mutexes and
    65  	 * Set atfork handler so that child can setup its own mutexes and
    66  	 * locking callbacks when it is forked
    66  	 * locking callbacks when it is forked
    67  	 */
    67  	 */
    68 @@ -478,7 +486,7 @@
    68 @@ -475,7 +483,7 @@
    69  		pthread_mutex_init(&solaris_openssl_locks[i], NULL);
    69  		pthread_mutex_init(&solaris_openssl_locks[i], NULL);
    70  		}
    70  		}
    71  	locking_callback = solaris_locking_callback;
    71  	locking_callback = solaris_locking_callback;
    72 -
    72 -
    73 +#endif
    73 +#endif
    74  	}
    74  }
    75  
    75  
    76  void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
    76  void CRYPTO_set_locking_callback(void (*func) (int mode, int type,
    77 @@ -979,6 +979,10 @@
    77 @@ -1021,6 +1029,12 @@
    78  	MessageBox (NULL,buf,_T("OpenSSL: FATAL"),MB_OK|MB_ICONSTOP);
    78          MessageBox(NULL, buf, _T("OpenSSL: FATAL"), MB_OK | MB_ICONSTOP);
    79  }
    79  }
    80  #else
    80  #else
    81 +/* Solaris libsa.a used for WAN boot doesn't provide for vfprintf(). Since
    81 +/*
    82 + *  * OPENSSL_showfatal() is not used anywhere else then here we can safely use
    82 + * Solaris libsa.a used for WAN boot doesn't provide for vfprintf(). Since
    83 + *   * the code from 0.9.7d version. */
    83 + * OPENSSL_showfatal() is not used anywhere else then here we can safely use
    84 +#ifndef	_BOOT
    84 + * the code from 0.9.7d version.
    85  void OPENSSL_showfatal (const char *fmta,...)
    85 + */
    86  { va_list ap;
    86 +#ifndef	_BOOT
    87  
    87  void OPENSSL_showfatal(const char *fmta, ...)
    88 @@ -986,14 +990,21 @@
    88  {
    89      vfprintf (stderr,fmta,ap);
    89      va_list ap;
    90      va_end (ap);
    90 @@ -1029,6 +1043,7 @@
       
    91      vfprintf(stderr, fmta, ap);
       
    92      va_end(ap);
    91  }
    93  }
    92 +#endif	/* _BOOT */
    94 +#endif	/* _BOOT */
    93  int OPENSSL_isservice (void) { return 0; }
    95  
    94  #endif
    96  int OPENSSL_isservice(void)
    95  
    97  {
    96  void OpenSSLDie(const char *file,int line,const char *assertion)
    98 @@ -1038,9 +1053,15 @@
    97  	{
    99  
       
   100  void OpenSSLDie(const char *file, int line, const char *assertion)
       
   101  {
    98 +#ifndef	_BOOT		
   102 +#ifndef	_BOOT		
    99  	OPENSSL_showfatal(
   103      OPENSSL_showfatal
   100  		"%s(%d): OpenSSL internal error, assertion failed: %s\n",
   104          ("%s(%d): OpenSSL internal error, assertion failed: %s\n", file, line,
   101  		file,line,assertion);
   105           assertion);
   102 +#else
   106 +#else
   103 +	fprintf(stderr,
   107 +	fprintf(stderr,
   104 +		"%s(%d): OpenSSL internal error, assertion failed: %s\n",
   108 +		"%s(%d): OpenSSL internal error, assertion failed: %s\n",
   105 +		file,line,assertion);
   109 +		file,line,assertion);
   106 +#endif	
   110 +#endif	
   107  #if !defined(_WIN32) || defined(__CYGWIN__)
   111  #if !defined(_WIN32) || defined(__CYGWIN__)
   108  	abort();
   112      abort();
   109  #else
   113  #else
   110 --- openssl-1.0.0e/crypto/err/err_all.c	2009-08-09 07:58:05.000000000 -0700
   114 --- openssl-1.0.0e/crypto/err/err_all.c	2009-08-09 07:58:05.000000000 -0700
   111 +++ openssl-1.0.0e_patched/crypto/err/err_all.c	2011-12-13 05:22:01.205351400 -0800
   115 +++ openssl-1.0.0e_patched/crypto/err/err_all.c	2011-12-13 05:22:01.205351400 -0800
   112 @@ -148,7 +148,9 @@
   116 @@ -148,7 +148,9 @@
   113  	ERR_load_X509V3_strings();
   117      ERR_load_X509V3_strings();
   114  	ERR_load_PKCS12_strings();
   118      ERR_load_PKCS12_strings();
   115  	ERR_load_RAND_strings();
   119      ERR_load_RAND_strings();
   116 +#ifndef _BOOT
   120 +#ifndef _BOOT
   117  	ERR_load_DSO_strings();
   121      ERR_load_DSO_strings();
   118 +#endif /* _BOOT */
   122 +#endif /* _BOOT */
   119  	ERR_load_TS_strings();
   123      ERR_load_TS_strings();
   120  #ifndef OPENSSL_NO_ENGINE
   124  # ifndef OPENSSL_NO_ENGINE
   121  	ERR_load_ENGINE_strings();
   125      ERR_load_ENGINE_strings();
   122 --- openssl-1.0.0e/crypto/evp/evp_key.c	2010-03-27 12:27:50.000000000 -0700
   126 --- openssl-1.0.0e/crypto/evp/evp_key.c	2010-03-27 12:27:50.000000000 -0700
   123 +++ openssl-1.0.0e_patched/crypto/evp/evp_key.c	2011-12-13 05:19:32.956908600 -0800
   127 +++ openssl-1.0.0e_patched/crypto/evp/evp_key.c	2011-12-13 05:19:32.956908600 -0800
   124 @@ -84,7 +84,7 @@
   128 @@ -83,7 +83,7 @@
   125  	else
   129      else
   126  		return(prompt_string);
   130          return (prompt_string);
   127  	}
   131  }
   128 -
   132 -
   129 +#ifndef	_BOOT
   133 +#ifndef	_BOOT
   130  /* For historical reasons, the standard function for reading passwords is
   134  /*
   131   * in the DES library -- if someone ever wants to disable DES,
   135   * For historical reasons, the standard function for reading passwords is in
   132   * this function will fail */
   136   * the DES library -- if someone ever wants to disable DES, this function
   133 @@ -111,6 +111,7 @@
   137 @@ -115,6 +115,7 @@
   134  	OPENSSL_cleanse(buff,BUFSIZ);
   138      OPENSSL_cleanse(buff, BUFSIZ);
   135  	return ret;
   139      return ret;
   136  	}
   140  }
   137 +#endif	/* !_BOOT */
   141 +#endif	/* !_BOOT */
   138  
   142  
   139  int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, 
   143  int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
   140  	     const unsigned char *salt, const unsigned char *data, int datal,
   144                     const unsigned char *salt, const unsigned char *data,
   141 --- openssl-1.0.0e/crypto/rand/rand_unix.c	2009-04-06 07:31:36.000000000 -0700
   145 --- openssl-1.0.0e/crypto/rand/rand_unix.c	2009-04-06 07:31:36.000000000 -0700
   142 +++ openssl-1.0.0e_patched/crypto/rand/rand_unix.c	2011-12-19 07:28:39.988944800 -0800
   146 +++ openssl-1.0.0e_patched/crypto/rand/rand_unix.c	2011-12-19 07:28:39.988944800 -0800
   143 @@ -122,7 +122,11 @@
   147 @@ -122,7 +122,11 @@
   144  #include <sys/time.h>
   148  # include <sys/time.h>
   145  #include <sys/times.h>
   149  # include <sys/times.h>
   146  #include <sys/stat.h>
   150  # include <sys/stat.h>
   147 +#ifdef	_BOOT
   151 +#ifdef	_BOOT
   148 +#include <sys/fcntl.h>
   152 +# include <sys/fcntl.h>
   149 +#else
   153 +#else
   150  #include <fcntl.h>
   154  # include <fcntl.h>
   151 +#endif
   155 +#endif
   152  #include <unistd.h>
   156  # include <unistd.h>
   153  #include <time.h>
   157  # include <time.h>
   154  #if defined(OPENSSL_SYS_LINUX) /* should actually be available virtually everywhere */
   158  # if defined(OPENSSL_SYS_LINUX) /* should actually be available virtually
   155 @@ -253,6 +257,11 @@
   159 @@ -259,6 +263,11 @@
   156  	const char **egdsocket = NULL;
   160      const char **egdsocket = NULL;
   157  #endif
   161  #  endif
   158  
   162  
   159 +#ifdef _BOOT
   163 +#ifdef _BOOT
   160 +/* open() is provided by standalone libsa not visible from here */
   164 +/* open() is provided by standalone libsa not visible from here */
   161 +extern int open(const char *, int);
   165 +extern int open(const char *, int);
   162 +#endif
   166 +#endif
   163 +
   167 +
   164  #ifdef DEVRANDOM
   168  #  ifdef DEVRANDOM
   165  	memset(randomstats,0,sizeof(randomstats));
   169      memset(randomstats, 0, sizeof(randomstats));
   166  	/* Use a random entropy pool device. Linux, FreeBSD and OpenBSD
   170      /*
   167 @@ -295,9 +304,13 @@
   171 @@ -307,11 +316,15 @@
   168  				{
   172              do {
   169  				int try_read = 0;
   173                  int try_read = 0;
   170  
   174 
   171 -#if defined(OPENSSL_SYS_BEOS_R5)
   175 -#   if defined(OPENSSL_SYS_BEOS_R5)
   172 +#if defined(OPENSSL_SYS_BEOS_R5) || defined(_BOOT)
   176 +#   if defined(OPENSSL_SYS_BEOS_R5) || defined(_BOOT)
   173  				/* select() is broken in BeOS R5, so we simply
   177                  /*
   174  				 *  try to read something and snooze if we couldn't */
   178                   * select() is broken in BeOS R5, so we simply try to read
   175 +				/* 
   179                   * something and snooze if we couldn't
   176 +				 * select() is not available when linking stand-alone
   180                   */
   177 +				 * library for wanboot 
   181 +               /*
   178 +				 */
   182 +                * select() is not available when linking stand-alone
   179  				try_read = 1;
   183 +                * library for wanboot
   180  
   184 +                */
   181  #elif defined(OPENSSL_SYS_LINUX)
   185                  try_read = 1;
   182 @@ -355,6 +368,7 @@
   186  
   183  				else
   187  #   elif defined(OPENSSL_SYS_LINUX)
   184  					r = -1;
   188 @@ -365,6 +378,7 @@
   185  				
   189                  } else
   186 +#ifndef	_BOOT				
   190                      r = -1;
   187  				/* Some Unixen will update t in select(), some
   191 
   188  				   won't.  For those who won't, or if we
   192 +#ifndef        _BOOT
   189  				   didn't use select() in the first place,
   193                  /*
   190 @@ -366,13 +380,17 @@
   194                   * Some Unixen will update t in select(), some won't.  For
   191  				}
   195                   * those who won't, or if we didn't use select() in the first
   192  			while ((r > 0 ||
   196 @@ -377,13 +391,17 @@
   193  			       (errno == EINTR || errno == EAGAIN)) && usec != 0 && n < ENTROPY_NEEDED);
   197              while ((r > 0 ||
   194 +#else	/* _BOOT */
   198                      (errno == EINTR || errno == EAGAIN)) && usec != 0
   195 +				}
   199                     && n < ENTROPY_NEEDED);
   196 +			while (r > 0 && n < ENTROPY_NEEDED);
   200 +#else  /* _BOOT */
   197 +#endif	/* _BOOT */			
   201 +            }
   198  
   202 +            while (r > 0 && n < ENTROPY_NEEDED);
   199  			close(fd);
   203 +#endif /* _BOOT */
   200  			}
   204 
   201  		}
   205              close(fd);
   202  #endif /* defined(DEVRANDOM) */
   206          }
   203  
   207      }
   204 -#ifdef DEVRANDOM_EGD
   208  #  endif                        /* defined(DEVRANDOM) */
   205 +#if defined(DEVRANDOM_EGD) && !defined(_BOOT)
   209 
   206  	/* Use an EGD socket to read entropy from an EGD or PRNGD entropy
   210 -#  ifdef DEVRANDOM_EGD
   207  	 * collecting daemon. */
   211 +#  if defined(DEVRANDOM_EGD) && !defined(_BOOT)
   208  
   212      /*
   209 @@ -395,6 +413,7 @@
   213       * Use an EGD socket to read entropy from an EGD or PRNGD entropy
   210  		}
   214       * collecting daemon.
   211  #endif
   215 @@ -407,6 +424,7 @@
   212  
   216      }
   213 +#ifndef	_BOOT
   217  #  endif
   214  	/* put in some default random data, we need more than just this */
   218  
   215  	l=curr_pid;
   219 +#ifndef	_BOOT
   216  	RAND_add(&l,sizeof(l),0.0);
   220      /* put in some default random data, we need more than just this */
   217 @@ -403,6 +422,7 @@
   221      l = curr_pid;
   218  
   222      RAND_add(&l, sizeof(l), 0.0);
   219  	l=time(NULL);
   223 @@ -415,6 +433,7 @@
   220  	RAND_add(&l,sizeof(l),0.0);
   224  
       
   225      l = time(NULL);
       
   226      RAND_add(&l, sizeof(l), 0.0);
   221 +#endif /* !_BOOT */	
   227 +#endif /* !_BOOT */	
   222  
   228  
   223  #if defined(OPENSSL_SYS_BEOS)
   229  #  if defined(OPENSSL_SYS_BEOS)
   224  	{
   230      {
   225 
       
   226 --- openssl-1.0.0e/crypto/rand/randfile.c	2011-03-19 02:44:37.000000000 -0700
   231 --- openssl-1.0.0e/crypto/rand/randfile.c	2011-03-19 02:44:37.000000000 -0700
   227 +++ openssl-1.0.0e_patched/crypto/rand/randfile.c	2011-12-13 05:26:51.884824200 -0800
   232 +++ openssl-1.0.0e_patched/crypto/rand/randfile.c	2011-12-13 05:26:51.884824200 -0800
   228 @@ -57,9 +57,11 @@
   233 @@ -57,9 +57,11 @@
   229   */
   234   */
   230  
   235  
   231  /* We need to define this to get macros like S_IFBLK and S_IFCHR */
   236  /* We need to define this to get macros like S_IFBLK and S_IFCHR */
   232 +#ifndef	_BOOT
   237 +#ifndef	_BOOT
   233  #if !defined(OPENSSL_SYS_VXWORKS)
   238  #if !defined(OPENSSL_SYS_VXWORKS)
   234  #define _XOPEN_SOURCE 500
   239  # define _XOPEN_SOURCE 500
   235  #endif
   240  #endif
   236 +#endif	/* _BOOT */
   241 +#endif	/* _BOOT */
   237  
   242  
   238  #include <errno.h>
   243  #include <errno.h>
   239  #include <stdio.h>
   244  #include <stdio.h>
   240 @@ -179,6 +181,7 @@
   245 @@ -191,6 +193,7 @@
   241  	return(ret);
   246      return (ret);
   242  	}
   247  }
   243  
   248  
   244 +#ifndef	_BOOT
   249 +#ifndef	_BOOT
   245  int RAND_write_file(const char *file)
   250  int RAND_write_file(const char *file)
   246  	{
   251  {
   247  	unsigned char buf[BUFSIZE];
   252      unsigned char buf[BUFSIZE];
   248 @@ -327,3 +330,5 @@
   253 @@ -335,3 +338,5 @@
   249  #endif
   254  #endif
   250  	return(buf);
   255      return (buf);
   251  	}
   256  }
   252 +
   257 +
   253 +#endif /* _BOOT */
   258 +#endif /* _BOOT */
   254 --- openssl-1.0.0e/crypto/x509v3/v3_utl.c	2009-07-27 14:08:53.000000000 -0700
   259 --- openssl-1.0.0e/crypto/x509v3/v3_utl.c	2009-07-27 14:08:53.000000000 -0700
   255 +++ openssl-1.0.0e_patched/crypto/x509v3/v3_utl.c	2011-12-13 05:10:08.844191400 -0800
   260 +++ openssl-1.0.0e_patched/crypto/x509v3/v3_utl.c	2011-12-13 05:10:08.844191400 -0800
   256 @@ -659,9 +659,52 @@
   261 @@ -715,9 +715,50 @@
   257  		}
   262      }
   258  	}
   263  }
   259  
   264  
   260 +#if	defined(_BOOT)
   265 +#if	defined(_BOOT)
   261 +/* This function was copied from bio/b_sock.c */
   266 +/* This function was copied from bio/b_sock.c */
   262 +static int get_ip(const char *str, unsigned char ip[4])
   267 +static int get_ip(const char *str, unsigned char ip[4])
   263 +	{
   268 +{
   264 +	unsigned int tmp[4];
   269 +    unsigned int tmp[4];
   265 +	int num=0,c,ok=0;
   270 +    int num = 0, c, ok = 0;
   266 +
   271 +
   267 +	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
   272 +    tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
   268 +
   273 +
   269 +	for (;;)
   274 +    for (;;) {
   270 +		{
   275 +        c = *(str++);
   271 +		c= *(str++);
   276 +        if ((c >= '0') && (c <= '9')) {
   272 +		if ((c >= '0') && (c <= '9'))
   277 +            ok = 1;
   273 +			{
   278 +            tmp[num] = tmp[num]*10+c-'0';
   274 +			ok=1;
   279 +            if (tmp[num] > 255)
   275 +			tmp[num]=tmp[num]*10+c-'0';
   280 +                return(0);
   276 +			if (tmp[num] > 255) return(0);
   281 +        } else if (c == '.') {
   277 +			}
   282 +            if (!ok)
   278 +		else if (c == '.')
   283 +                return (-1);
   279 +			{
   284 +            if (num == 3)
   280 +			if (!ok) return(-1);
   285 +                return (0);
   281 +			if (num == 3) return(0);
   286 +            num++;
   282 +			num++;
   287 +            ok = 0;
   283 +			ok=0;
   288 +        } else if (c == '\0' && (num == 3) && ok)
   284 +			}
   289 +            break;
   285 +		else if (c == '\0' && (num == 3) && ok)
   290 +        else
   286 +			break;
   291 +            return(0);
   287 +		else
   292 +        }
   288 +			return(0);
   293 +    ip[0]=tmp[0];
   289 +		}
   294 +    ip[1]=tmp[1];
   290 +	ip[0]=tmp[0];
   295 +    ip[2]=tmp[2];
   291 +	ip[1]=tmp[1];
   296 +    ip[3]=tmp[3];
   292 +	ip[2]=tmp[2];
   297 +    return(1);
   293 +	ip[3]=tmp[3];
   298 +}
   294 +	return(1);
       
   295 +	}
       
   296 +#endif /* _BOOT */
   299 +#endif /* _BOOT */
   297 +
   300 +
   298  static int ipv4_from_asc(unsigned char *v4, const char *in)
   301  static int ipv4_from_asc(unsigned char *v4, const char *in)
   299  	{
   302  {
   300  	int a0, a1, a2, a3;
   303      int a0, a1, a2, a3;
   301 +
   304 +
   302 +#if	defined(_BOOT)
   305 +#if	defined(_BOOT)
   303 +	if (get_ip(in, v4) != 1)
   306 +	if (get_ip(in, v4) != 1)
   304 +		return 0;
   307 +		return 0;
   305 +#else	/* _BOOT */
   308 +#else	/* _BOOT */
   306  	if (sscanf(in, "%d.%d.%d.%d", &a0, &a1, &a2, &a3) != 4)
   309      if (sscanf(in, "%d.%d.%d.%d", &a0, &a1, &a2, &a3) != 4)
   307  		return 0;
   310          return 0;
   308  	if ((a0 < 0) || (a0 > 255) || (a1 < 0) || (a1 > 255)
   311      if ((a0 < 0) || (a0 > 255) || (a1 < 0) || (a1 > 255)
   309 @@ -671,6 +716,7 @@
   312 @@ -727,6 +768,7 @@
   310  	v4[1] = a1;
   313      v4[1] = a1;
   311  	v4[2] = a2;
   314      v4[2] = a2;
   312  	v4[3] = a3;
   315      v4[3] = a3;
   313 +#endif	/* _BOOT */
   316 +#endif	/* _BOOT */
   314  	return 1;
   317      return 1;
   315  	}
   318  }
   316  
   319 
   317 --- openssl-1.0.0e/e_os.h	2011-12-19 04:17:51.631087400 -0800
   320 --- openssl-1.0.0e/e_os.h	2011-12-19 04:17:51.631087400 -0800
   318 +++ openssl-1.0.0e_patched/e_os.h	2011-12-19 04:15:15.776668900 -0800
   321 +++ openssl-1.0.0e_patched/e_os.h	2011-12-19 04:15:15.776668900 -0800
   319 @@ -206,10 +206,19 @@
   322 @@ -213,10 +213,19 @@
   320  #define get_last_socket_error()	errno
   323  #  define get_last_socket_error() errno
   321  #define clear_socket_error()	errno=0
   324  #  define clear_socket_error()    errno=0
   322  #define ioctlsocket(a,b,c)	ioctl(a,b,c)
   325  #  define ioctlsocket(a,b,c)      ioctl(a,b,c)
   323 +#ifdef	_BOOT
   326 +#ifdef	_BOOT
   324 +#include <netinet/in.h>
   327 +#include <netinet/in.h>
   325 +extern int socket_read(int, void *, size_t, int);
   328 +extern int socket_read(int, void *, size_t, int);
   326 +extern int socket_close(int);
   329 +extern int socket_close(int);
   327 +#define	closesocket(s)		socket_close(s)
   330 +#  define closesocket(s)          socket_close(s)
   328 +#define	readsocket(s,b,n)	socket_read((s),(b),(n), 200)
   331 +#  define readsocket(s,b,n)       socket_read((s),(b),(n), 200)
   329 +#define	writesocket(s,b,n)	send((s),(b),(n), 0)
   332 +#  define writesocket(s,b,n)      send((s),(b),(n), 0)
   330 +#else  /* !_BOOT */
   333 +#else  /* !_BOOT */
   331  #define closesocket(s)		close(s)
   334  #  define closesocket(s)          close(s)
   332  #define readsocket(s,b,n)	read((s),(b),(n))
   335  #  define readsocket(s,b,n)       read((s),(b),(n))
   333  #define writesocket(s,b,n)	write((s),(b),(n))
   336  #  define writesocket(s,b,n)      write((s),(b),(n))
   334  #endif
   337  # endif
   335 +#endif
   338 +#endif
   336  
   339  
   337  #ifdef WIN16 /* never the case */
   340  # ifdef WIN16                   /* never the case */
   338  #  define MS_CALLBACK	_far _loadds
   341  #  define MS_CALLBACK   _far _loadds
   339 --- openssl-1.0.0e/crypto/sparcv9cap.c	2010-09-05 12:48:01.000000000 -0700
   342 --- openssl-1.0.0e/crypto/sparcv9cap.c	2010-09-05 12:48:01.000000000 -0700
   340 +++ openssl-1.0.0e_patched/crypto/sparcv9cap.c	2011-12-23 05:24:02.011607700 -0800
   343 +++ openssl-1.0.0e_patched/crypto/sparcv9cap.c	2011-12-23 05:24:02.011607700 -0800
   341 @@ -12,7 +12,11 @@
   344 @@ -12,7 +12,11 @@
   342  #define SPARCV9_VIS2		(1<<3)	/* reserved */
   345  #define SPARCV9_VIS2            (1<<3) /* reserved */
   343  #define SPARCV9_FMADD		(1<<4)	/* reserved for SPARC64 V */
   346  #define SPARCV9_FMADD           (1<<4) /* reserved for SPARC64 V */
   344  
   347 
   345 +#ifndef	_BOOT
   348 +#ifndef        _BOOT
   346  static int OPENSSL_sparcv9cap_P=SPARCV9_TICK_PRIVILEGED;
   349  static int OPENSSL_sparcv9cap_P = SPARCV9_TICK_PRIVILEGED;
   347 +#else
   350 +#else
   348 +static int OPENSSL_sparcv9cap_P = SPARCV9_VIS1;
   351 +static int OPENSSL_sparcv9cap_P = SPARCV9_VIS1;
   349 +#endif
   352 +#endif
   350  
   353  
   351  int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num)
   354  int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
   352  	{
   355                  const BN_ULONG *np, const BN_ULONG *n0, int num)
   353 @@ -33,6 +37,7 @@
   356 @@ -36,6 +40,7 @@
   354  void		_sparcv9_vis2_probe(void);
   357  void _sparcv9_vis2_probe(void);
   355  void		_sparcv9_fmadd_probe(void);
   358  void _sparcv9_fmadd_probe(void);
   356  
   359  
   357 +#ifndef _BOOT
   360 +#ifndef _BOOT
   358  unsigned long OPENSSL_rdtsc(void)
   361  unsigned long OPENSSL_rdtsc(void)
   359  	{
   362  {
   360  	if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED)
   363      if (OPENSSL_sparcv9cap_P & SPARCV9_TICK_PRIVILEGED)
   361 @@ -44,8 +49,19 @@
   364 @@ -47,8 +52,19 @@
   362  	else
   365      else
   363  		return _sparcv9_rdtick();
   366          return _sparcv9_rdtick();
   364  	}
   367  }
   365 +#endif
   368 +#endif
   366 +
   369 +
   367 +#if defined(_BOOT)
   370 +#if defined(_BOOT)
   368 +/*
   371 +/*
   369 + * Hardcoding sparc capabilities for wanboot.
   372 + * Hardcoding sparc capabilities for wanboot.
   370 + * Older CPUs are EOLed anyway.
   373 + * Older CPUs are EOLed anyway.
   371 + */
   374 + */
   372 +void OPENSSL_cpuid_setup(void)
   375 +void OPENSSL_cpuid_setup(void)
   373 +	{
   376 +       {
   374 +	OPENSSL_sparcv9cap_P = SPARCV9_VIS1;
   377 +       OPENSSL_sparcv9cap_P = SPARCV9_VIS1;
   375 +	}
   378 +       }
   376  
   379 
   377 -#if 0 && defined(__sun) && defined(__SVR4)
   380 -#if 0 && defined(__sun) && defined(__SVR4)
   378 +#elif 0 && defined(__sun) && defined(__SVR4)
   381 +#elif 0 && defined(__sun) && defined(__SVR4)
   379  /* This code path is disabled, because of incompatibility of
   382  /*
   380   * libdevinfo.so.1 and libmalloc.so.1 (see below for details)
   383   * This code path is disabled, because of incompatibility of libdevinfo.so.1
   381   */
   384   * and libmalloc.so.1 (see below for details)
   382 --- openssl-1.0.0e/crypto/sparccpuid.S	2010-09-05 12:48:01.000000000 -0700
   385 --- openssl-1.0.0e/crypto/sparccpuid.S	2010-09-05 12:48:01.000000000 -0700
   383 +++ openssl-1.0.0e_patched/crypto/sparccpuid.S	2012-02-13 07:42:58.259478325 -0800
   386 +++ openssl-1.0.0e_patched/crypto/sparccpuid.S	2012-02-13 07:42:58.259478325 -0800
   384 @@ -397,8 +397,13 @@
   387 @@ -397,8 +397,13 @@
   385  .type	OPENSSL_cleanse,#function
   388  .type	OPENSSL_cleanse,#function
   386  .size	OPENSSL_cleanse,.-OPENSSL_cleanse
   389  .size	OPENSSL_cleanse,.-OPENSSL_cleanse
   395 +	nop
   398 +	nop
   396 +	nop
   399 +	nop
   397 +#endif
   400 +#endif
   398 --- openssl-1.0.1c/crypto/Makefile      Thu Aug  2 12:56:38 2012
   401 --- openssl-1.0.1c/crypto/Makefile      Thu Aug  2 12:56:38 2012
   399 +++ openssl-1.0.1c/crypto/Makefile.new  Thu Aug  2 12:59:43 2012
   402 +++ openssl-1.0.1c/crypto/Makefile.new  Thu Aug  2 12:59:43 2012
   400 @@ -35,9 +35,9 @@
   403 @@ -36,9 +36,9 @@
   401  LIB= $(TOP)/libcrypto.a
   404  LIB= $(TOP)/libcrypto.a
   402  SHARED_LIB= libcrypto$(SHLIB_EXT)
   405  SHARED_LIB= libcrypto$(SHLIB_EXT)
   403  LIBSRC=	cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c \
   406  LIBSRC=	cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c \
   404 -	ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c
   407 -	ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c
   405 +	ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c wanboot-stubs.c
   408 +	ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c wanboot-stubs.c
   409 
   412 
   410  SRC= $(LIBSRC)
   413  SRC= $(LIBSRC)
   411 
   414 
   412 --- openssl-1.0.1f/ssl/s3_clnt.c    Thu Jan 30 02:53:33 2014
   415 --- openssl-1.0.1f/ssl/s3_clnt.c    Thu Jan 30 02:53:33 2014
   413 +++ openssl-1.0.1f/ssl/s3_clnt.c.new   Thu Jan 30 02:57:51 2014
   416 +++ openssl-1.0.1f/ssl/s3_clnt.c.new   Thu Jan 30 02:57:51 2014
   414 @@ -681,8 +681,13 @@
   417 @@ -668,7 +668,11 @@
   415  
   418  
   416  		p=s->s3->client_random;
   419          p = s->s3->client_random;
   417  
   420 
   418 +#ifndef	_BOOT
   421 +#ifndef	_BOOT
   419  		if (ssl_fill_hello_random(s, 0, p, SSL3_RANDOM_SIZE) <= 0)
   422          if (ssl_fill_hello_random(s, 0, p, SSL3_RANDOM_SIZE) <= 0)
   420  			goto err;
   423 +#else
   421 +#else
   424 +        if (RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE) <= 0)
   422 +		if (RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE) <= 0)
   425 +#endif
   423 +			goto err;
   426              goto err;
   424 +#endif
   427  
   425  
   428          /* Do the message type and length last */
   426  		/* Do the message type and length last */
       
   427  		d=p= &(buf[4]);
       
   428 --- openssl-1.0.1f/ssl/s3_lib.c       Wed Oct 15 11:18:30 2014
   429 --- openssl-1.0.1f/ssl/s3_lib.c       Wed Oct 15 11:18:30 2014
   429 +++ openssl-1.0.1f/ssl/s3_lib.c.new    Wed Oct 15 11:20:07 2014
   430 +++ openssl-1.0.1f/ssl/s3_lib.c.new    Wed Oct 15 11:20:07 2014
   430 @@ -3364,7 +3364,11 @@
   431 @@ -3343,7 +3343,11 @@
   431  			return 1;
   432           * Apparently we're using a version-flexible SSL_METHOD (not at its
   432  		/* Apparently we're using a version-flexible SSL_METHOD
   433           * highest protocol version).
   433  		 * (not at its highest protocol version). */
   434           */
   434 +#ifndef	_BOOT
   435 +#ifndef	_BOOT
   435  		if (s->ctx->method->version == SSLv23_method()->version)
   436          if (s->ctx->method->version == SSLv23_method()->version) {
   436 +#else
   437 +#else
   437 +		if (s->ctx->method->version == TLS1_2_VERSION)
   438 +        if (s->ctx->method->version == TLS1_2_VERSION) {
   438 +#endif
   439 +#endif
   439  			{
       
   440  #if TLS_MAX_VERSION != TLS1_2_VERSION
   440  #if TLS_MAX_VERSION != TLS1_2_VERSION
   441  #  error Code needs update for SSLv23_method() support beyond TLS1_2_VERSION.
   441  # error Code needs update for SSLv23_method() support beyond TLS1_2_VERSION.
       
   442  #endif