summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkus <>2003-11-11 21:22:16 +0000
committermarkus <>2003-11-11 21:22:16 +0000
commitfd84abe5019daf5a6869e1d12702e3e11b7a81bc (patch)
tree03feb4834f445bfefefaf10e53418c5bb708c9c0
parent9cea7b85baecb1a02a3ea617de73d9693a9792eb (diff)
downloadopenbsd-fd84abe5019daf5a6869e1d12702e3e11b7a81bc.tar.gz
openbsd-fd84abe5019daf5a6869e1d12702e3e11b7a81bc.tar.bz2
openbsd-fd84abe5019daf5a6869e1d12702e3e11b7a81bc.zip
import 0.9.7c
-rw-r--r--src/lib/libcrypto/des/destest.c2
-rw-r--r--src/lib/libcrypto/engine/hw_ubsec.c1
-rw-r--r--src/lib/libcrypto/idea/ideatest.c232
-rw-r--r--src/lib/libcrypto/md2/md2test.c2
-rw-r--r--src/lib/libcrypto/md5/asm/md5-sparcv9.S4
-rw-r--r--src/lib/libcrypto/perlasm/x86ms.pl3
-rw-r--r--src/lib/libcrypto/perlasm/x86nasm.pl3
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl3
-rw-r--r--src/lib/libcrypto/rand/rand_win.c14
-rw-r--r--src/lib/libcrypto/rc5/rc5test.c386
-rw-r--r--src/lib/libcrypto/util/extract-names.pl4
-rw-r--r--src/lib/libcrypto/util/libeay.num2
-rw-r--r--src/lib/libcrypto/util/pl/Mingw32.pl2
-rw-r--r--src/lib/libcrypto/util/point.sh6
-rw-r--r--src/lib/libssl/src/CHANGES105
-rw-r--r--src/lib/libssl/src/Configure2
-rw-r--r--src/lib/libssl/src/FAQ2
-rw-r--r--src/lib/libssl/src/INSTALL.W322
-rw-r--r--src/lib/libssl/src/Makefile.org22
-rw-r--r--src/lib/libssl/src/NEWS12
-rw-r--r--src/lib/libssl/src/README2
-rw-r--r--src/lib/libssl/src/apps/CA.pl2
-rw-r--r--src/lib/libssl/src/apps/ocsp.c5
-rw-r--r--src/lib/libssl/src/apps/openssl.c2
-rw-r--r--src/lib/libssl/src/apps/pkcs8.c11
-rw-r--r--src/lib/libssl/src/apps/s_apps.h8
-rw-r--r--src/lib/libssl/src/apps/s_client.c38
-rw-r--r--src/lib/libssl/src/apps/s_server.c20
-rw-r--r--src/lib/libssl/src/apps/smime.c4
-rw-r--r--src/lib/libssl/src/apps/x509.c2
-rw-r--r--src/lib/libssl/src/bugs/SSLv32
-rw-r--r--src/lib/libssl/src/crypto/aes/aes.h2
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_cbc.c12
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_ctr.c54
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_mbstr.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_strex.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_strnid.c5
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_lib.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_dec.c9
-rw-r--r--src/lib/libssl/src/crypto/bio/b_print.c2
-rw-r--r--src/lib/libssl/src/crypto/bio/bf_buff.c1
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_bio.c55
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_file.c21
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mul.c4
-rw-r--r--src/lib/libssl/src/crypto/des/cfb_enc.c84
-rw-r--r--src/lib/libssl/src/crypto/des/destest.c2
-rw-r--r--src/lib/libssl/src/crypto/dso/dso_dlfcn.c6
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_mult.c13
-rw-r--r--src/lib/libssl/src/crypto/engine/engine.h8
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ubsec.c1
-rw-r--r--src/lib/libssl/src/crypto/err/err.c42
-rw-r--r--src/lib/libssl/src/crypto/err/err.h1
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_b64.c38
-rw-r--r--src/lib/libssl/src/crypto/evp/c_all.c3
-rw-r--r--src/lib/libssl/src/crypto/idea/ideatest.c232
-rw-r--r--src/lib/libssl/src/crypto/md2/md2test.c2
-rw-r--r--src/lib/libssl/src/crypto/md5/asm/md5-586.pl2
-rw-r--r--src/lib/libssl/src/crypto/md5/asm/md5-sparcv9.S4
-rw-r--r--src/lib/libssl/src/crypto/o_time.c2
-rw-r--r--src/lib/libssl/src/crypto/opensslv.h4
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86ms.pl3
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86nasm.pl3
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86unix.pl3
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_doit.c5
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_mime.c105
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_smime.c2
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pkcs7.h2
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_win.c14
-rw-r--r--src/lib/libssl/src/crypto/rc5/rc5test.c386
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa.h11
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_eay.c2
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_lib.c8
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_trs.c1
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_vfy.c6
-rw-r--r--src/lib/libssl/src/crypto/x509/x509type.c5
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_conf.c2
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_cpols.c24
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_lib.c1
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_prn.c2
-rw-r--r--src/lib/libssl/src/demos/engines/zencod/hw_zencod.h2
-rw-r--r--src/lib/libssl/src/doc/apps/ca.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/s_client.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_f_base64.pod5
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod6
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod4
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_accept.pod3
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_connect.pod3
-rw-r--r--src/lib/libssl/src/e_os.h15
-rw-r--r--src/lib/libssl/src/openssl.spec20
-rw-r--r--src/lib/libssl/src/ssl/kssl.c35
-rw-r--r--src/lib/libssl/src/ssl/kssl.h2
-rw-r--r--src/lib/libssl/src/ssl/s3_clnt.c1
-rw-r--r--src/lib/libssl/src/ssl/s3_srvr.c14
-rw-r--r--src/lib/libssl/src/ssl/ssl_lib.c5
-rw-r--r--src/lib/libssl/src/ssl/ssl_rsa.c4
-rw-r--r--src/lib/libssl/src/ssl/ssl_sess.c4
-rw-r--r--src/lib/libssl/src/ssl/ssltest.c2
-rw-r--r--src/lib/libssl/src/tools/c_rehash2
-rw-r--r--src/lib/libssl/src/util/extract-names.pl4
-rw-r--r--src/lib/libssl/src/util/libeay.num2
-rw-r--r--src/lib/libssl/src/util/pl/Mingw32.pl2
-rw-r--r--src/lib/libssl/src/util/point.sh6
102 files changed, 1976 insertions, 280 deletions
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c
index 687c00c792..3983ac8e5f 100644
--- a/src/lib/libcrypto/des/destest.c
+++ b/src/lib/libcrypto/des/destest.c
@@ -431,7 +431,7 @@ int main(int argc, char *argv[])
431 431
432#ifndef LIBDES_LIT 432#ifndef LIBDES_LIT
433 printf("Doing ede ecb\n"); 433 printf("Doing ede ecb\n");
434 for (i=0; i<(NUM_TESTS-1); i++) 434 for (i=0; i<(NUM_TESTS-2); i++)
435 { 435 {
436 DES_set_key_unchecked(&key_data[i],&ks); 436 DES_set_key_unchecked(&key_data[i],&ks);
437 DES_set_key_unchecked(&key_data[i+1],&ks2); 437 DES_set_key_unchecked(&key_data[i+1],&ks2);
diff --git a/src/lib/libcrypto/engine/hw_ubsec.c b/src/lib/libcrypto/engine/hw_ubsec.c
index 6286dd851c..5234a08a07 100644
--- a/src/lib/libcrypto/engine/hw_ubsec.c
+++ b/src/lib/libcrypto/engine/hw_ubsec.c
@@ -561,7 +561,6 @@ static int ubsec_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
561 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_BN_EXPAND_FAIL); 561 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_BN_EXPAND_FAIL);
562 return 0; 562 return 0;
563 } 563 }
564 memset(r->d, 0, BN_num_bytes(m));
565 564
566 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) { 565 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
567 fd = 0; 566 fd = 0;
diff --git a/src/lib/libcrypto/idea/ideatest.c b/src/lib/libcrypto/idea/ideatest.c
new file mode 100644
index 0000000000..98f805d72a
--- /dev/null
+++ b/src/lib/libcrypto/idea/ideatest.c
@@ -0,0 +1,232 @@
1/* crypto/idea/ideatest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <string.h>
61#include <stdlib.h>
62
63#include "../e_os.h"
64
65#ifdef OPENSSL_NO_IDEA
66int main(int argc, char *argv[])
67{
68 printf("No IDEA support\n");
69 return(0);
70}
71#else
72#include <openssl/idea.h>
73
74unsigned char k[16]={
75 0x00,0x01,0x00,0x02,0x00,0x03,0x00,0x04,
76 0x00,0x05,0x00,0x06,0x00,0x07,0x00,0x08};
77
78unsigned char in[8]={0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x03};
79unsigned char c[8]={0x11,0xFB,0xED,0x2B,0x01,0x98,0x6D,0xE5};
80unsigned char out[80];
81
82char *text="Hello to all people out there";
83
84static unsigned char cfb_key[16]={
85 0xe1,0xf0,0xc3,0xd2,0xa5,0xb4,0x87,0x96,
86 0x69,0x78,0x4b,0x5a,0x2d,0x3c,0x0f,0x1e,
87 };
88static unsigned char cfb_iv[80]={0x34,0x12,0x78,0x56,0xab,0x90,0xef,0xcd};
89static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8];
90#define CFB_TEST_SIZE 24
91static unsigned char plain[CFB_TEST_SIZE]=
92 {
93 0x4e,0x6f,0x77,0x20,0x69,0x73,
94 0x20,0x74,0x68,0x65,0x20,0x74,
95 0x69,0x6d,0x65,0x20,0x66,0x6f,
96 0x72,0x20,0x61,0x6c,0x6c,0x20
97 };
98static unsigned char cfb_cipher64[CFB_TEST_SIZE]={
99 0x59,0xD8,0xE2,0x65,0x00,0x58,0x6C,0x3F,
100 0x2C,0x17,0x25,0xD0,0x1A,0x38,0xB7,0x2A,
101 0x39,0x61,0x37,0xDC,0x79,0xFB,0x9F,0x45
102
103/* 0xF9,0x78,0x32,0xB5,0x42,0x1A,0x6B,0x38,
104 0x9A,0x44,0xD6,0x04,0x19,0x43,0xC4,0xD9,
105 0x3D,0x1E,0xAE,0x47,0xFC,0xCF,0x29,0x0B,*/
106 };
107
108static int cfb64_test(unsigned char *cfb_cipher);
109static char *pt(unsigned char *p);
110int main(int argc, char *argv[])
111 {
112 int i,err=0;
113 IDEA_KEY_SCHEDULE key,dkey;
114 unsigned char iv[8];
115
116 idea_set_encrypt_key(k,&key);
117 idea_ecb_encrypt(in,out,&key);
118 if (memcmp(out,c,8) != 0)
119 {
120 printf("ecb idea error encrypting\n");
121 printf("got :");
122 for (i=0; i<8; i++)
123 printf("%02X ",out[i]);
124 printf("\n");
125 printf("expected:");
126 for (i=0; i<8; i++)
127 printf("%02X ",c[i]);
128 err=20;
129 printf("\n");
130 }
131
132 idea_set_decrypt_key(&key,&dkey);
133 idea_ecb_encrypt(c,out,&dkey);
134 if (memcmp(out,in,8) != 0)
135 {
136 printf("ecb idea error decrypting\n");
137 printf("got :");
138 for (i=0; i<8; i++)
139 printf("%02X ",out[i]);
140 printf("\n");
141 printf("expected:");
142 for (i=0; i<8; i++)
143 printf("%02X ",in[i]);
144 printf("\n");
145 err=3;
146 }
147
148 if (err == 0) printf("ecb idea ok\n");
149
150 memcpy(iv,k,8);
151 idea_cbc_encrypt((unsigned char *)text,out,strlen(text)+1,&key,iv,1);
152 memcpy(iv,k,8);
153 idea_cbc_encrypt(out,out,8,&dkey,iv,0);
154 idea_cbc_encrypt(&(out[8]),&(out[8]),strlen(text)+1-8,&dkey,iv,0);
155 if (memcmp(text,out,strlen(text)+1) != 0)
156 {
157 printf("cbc idea bad\n");
158 err=4;
159 }
160 else
161 printf("cbc idea ok\n");
162
163 printf("cfb64 idea ");
164 if (cfb64_test(cfb_cipher64))
165 {
166 printf("bad\n");
167 err=5;
168 }
169 else
170 printf("ok\n");
171
172 EXIT(err);
173 return(err);
174 }
175
176static int cfb64_test(unsigned char *cfb_cipher)
177 {
178 IDEA_KEY_SCHEDULE eks,dks;
179 int err=0,i,n;
180
181 idea_set_encrypt_key(cfb_key,&eks);
182 idea_set_decrypt_key(&eks,&dks);
183 memcpy(cfb_tmp,cfb_iv,8);
184 n=0;
185 idea_cfb64_encrypt(plain,cfb_buf1,(long)12,&eks,
186 cfb_tmp,&n,IDEA_ENCRYPT);
187 idea_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
188 (long)CFB_TEST_SIZE-12,&eks,
189 cfb_tmp,&n,IDEA_ENCRYPT);
190 if (memcmp(cfb_cipher,cfb_buf1,CFB_TEST_SIZE) != 0)
191 {
192 err=1;
193 printf("idea_cfb64_encrypt encrypt error\n");
194 for (i=0; i<CFB_TEST_SIZE; i+=8)
195 printf("%s\n",pt(&(cfb_buf1[i])));
196 }
197 memcpy(cfb_tmp,cfb_iv,8);
198 n=0;
199 idea_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,&eks,
200 cfb_tmp,&n,IDEA_DECRYPT);
201 idea_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
202 (long)CFB_TEST_SIZE-17,&dks,
203 cfb_tmp,&n,IDEA_DECRYPT);
204 if (memcmp(plain,cfb_buf2,CFB_TEST_SIZE) != 0)
205 {
206 err=1;
207 printf("idea_cfb_encrypt decrypt error\n");
208 for (i=0; i<24; i+=8)
209 printf("%s\n",pt(&(cfb_buf2[i])));
210 }
211 return(err);
212 }
213
214static char *pt(unsigned char *p)
215 {
216 static char bufs[10][20];
217 static int bnum=0;
218 char *ret;
219 int i;
220 static char *f="0123456789ABCDEF";
221
222 ret= &(bufs[bnum++][0]);
223 bnum%=10;
224 for (i=0; i<8; i++)
225 {
226 ret[i*2]=f[(p[i]>>4)&0xf];
227 ret[i*2+1]=f[p[i]&0xf];
228 }
229 ret[16]='\0';
230 return(ret);
231 }
232#endif
diff --git a/src/lib/libcrypto/md2/md2test.c b/src/lib/libcrypto/md2/md2test.c
index 901d0a7d8e..9c1e28b6ce 100644
--- a/src/lib/libcrypto/md2/md2test.c
+++ b/src/lib/libcrypto/md2/md2test.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#include <openssl/md2.h>
63 62
64#include "../e_os.h" 63#include "../e_os.h"
65 64
@@ -71,6 +70,7 @@ int main(int argc, char *argv[])
71} 70}
72#else 71#else
73#include <openssl/evp.h> 72#include <openssl/evp.h>
73#include <openssl/md2.h>
74 74
75#ifdef CHARSET_EBCDIC 75#ifdef CHARSET_EBCDIC
76#include <openssl/ebcdic.h> 76#include <openssl/ebcdic.h>
diff --git a/src/lib/libcrypto/md5/asm/md5-sparcv9.S b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
index a599ed5660..db45aa4c97 100644
--- a/src/lib/libcrypto/md5/asm/md5-sparcv9.S
+++ b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
@@ -34,10 +34,12 @@
34 * 34 *
35 * or if above fails (it does if you have gas): 35 * or if above fails (it does if you have gas):
36 * 36 *
37 * gcc -E -DULTRASPARC -DMD5_BLOCK_DATA_ORDER md5_block.sparc.S | \ 37 * gcc -E -DOPENSSL_SYSNAMEULTRASPARC -DMD5_BLOCK_DATA_ORDER md5_block.sparc.S | \
38 * as -xarch=v8plus /dev/fd/0 -o md5-sparcv9.o 38 * as -xarch=v8plus /dev/fd/0 -o md5-sparcv9.o
39 */ 39 */
40 40
41#include <openssl/e_os2.h>
42
41#define A %o0 43#define A %o0
42#define B %o1 44#define B %o1
43#define C %o2 45#define C %o2
diff --git a/src/lib/libcrypto/perlasm/x86ms.pl b/src/lib/libcrypto/perlasm/x86ms.pl
index 35f1a4ddb9..fbb4afb9bd 100644
--- a/src/lib/libcrypto/perlasm/x86ms.pl
+++ b/src/lib/libcrypto/perlasm/x86ms.pl
@@ -144,7 +144,10 @@ sub main'jle { &out1("jle",@_); }
144sub main'jz { &out1("jz",@_); } 144sub main'jz { &out1("jz",@_); }
145sub main'jge { &out1("jge",@_); } 145sub main'jge { &out1("jge",@_); }
146sub main'jl { &out1("jl",@_); } 146sub main'jl { &out1("jl",@_); }
147sub main'ja { &out1("ja",@_); }
148sub main'jae { &out1("jae",@_); }
147sub main'jb { &out1("jb",@_); } 149sub main'jb { &out1("jb",@_); }
150sub main'jbe { &out1("jbe",@_); }
148sub main'jc { &out1("jc",@_); } 151sub main'jc { &out1("jc",@_); }
149sub main'jnc { &out1("jnc",@_); } 152sub main'jnc { &out1("jnc",@_); }
150sub main'jnz { &out1("jnz",@_); } 153sub main'jnz { &out1("jnz",@_); }
diff --git a/src/lib/libcrypto/perlasm/x86nasm.pl b/src/lib/libcrypto/perlasm/x86nasm.pl
index f30b7466d4..30346af4ea 100644
--- a/src/lib/libcrypto/perlasm/x86nasm.pl
+++ b/src/lib/libcrypto/perlasm/x86nasm.pl
@@ -152,7 +152,10 @@ sub main'jle { &out1("jle NEAR",@_); }
152sub main'jz { &out1("jz NEAR",@_); } 152sub main'jz { &out1("jz NEAR",@_); }
153sub main'jge { &out1("jge NEAR",@_); } 153sub main'jge { &out1("jge NEAR",@_); }
154sub main'jl { &out1("jl NEAR",@_); } 154sub main'jl { &out1("jl NEAR",@_); }
155sub main'ja { &out1("ja NEAR",@_); }
156sub main'jae { &out1("jae NEAR",@_); }
155sub main'jb { &out1("jb NEAR",@_); } 157sub main'jb { &out1("jb NEAR",@_); }
158sub main'jbe { &out1("jbe NEAR",@_); }
156sub main'jc { &out1("jc NEAR",@_); } 159sub main'jc { &out1("jc NEAR",@_); }
157sub main'jnc { &out1("jnc NEAR",@_); } 160sub main'jnc { &out1("jnc NEAR",@_); }
158sub main'jnz { &out1("jnz NEAR",@_); } 161sub main'jnz { &out1("jnz NEAR",@_); }
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
index 72bde061c5..10b669bf04 100644
--- a/src/lib/libcrypto/perlasm/x86unix.pl
+++ b/src/lib/libcrypto/perlasm/x86unix.pl
@@ -156,7 +156,10 @@ sub main'jnz { &out1("jnz",@_); }
156sub main'jz { &out1("jz",@_); } 156sub main'jz { &out1("jz",@_); }
157sub main'jge { &out1("jge",@_); } 157sub main'jge { &out1("jge",@_); }
158sub main'jl { &out1("jl",@_); } 158sub main'jl { &out1("jl",@_); }
159sub main'ja { &out1("ja",@_); }
160sub main'jae { &out1("jae",@_); }
159sub main'jb { &out1("jb",@_); } 161sub main'jb { &out1("jb",@_); }
162sub main'jbe { &out1("jbe",@_); }
160sub main'jc { &out1("jc",@_); } 163sub main'jc { &out1("jc",@_); }
161sub main'jnc { &out1("jnc",@_); } 164sub main'jnc { &out1("jnc",@_); }
162sub main'jno { &out1("jno",@_); } 165sub main'jno { &out1("jno",@_); }
diff --git a/src/lib/libcrypto/rand/rand_win.c b/src/lib/libcrypto/rand/rand_win.c
index 113b58678f..263068d256 100644
--- a/src/lib/libcrypto/rand/rand_win.c
+++ b/src/lib/libcrypto/rand/rand_win.c
@@ -162,6 +162,7 @@ typedef BOOL (WINAPI *GETCURSORINFO)(PCURSORINFO);
162typedef DWORD (WINAPI *GETQUEUESTATUS)(UINT); 162typedef DWORD (WINAPI *GETQUEUESTATUS)(UINT);
163 163
164typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD); 164typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD);
165typedef BOOL (WINAPI *CLOSETOOLHELP32SNAPSHOT)(HANDLE);
165typedef BOOL (WINAPI *HEAP32FIRST)(LPHEAPENTRY32, DWORD, DWORD); 166typedef BOOL (WINAPI *HEAP32FIRST)(LPHEAPENTRY32, DWORD, DWORD);
166typedef BOOL (WINAPI *HEAP32NEXT)(LPHEAPENTRY32); 167typedef BOOL (WINAPI *HEAP32NEXT)(LPHEAPENTRY32);
167typedef BOOL (WINAPI *HEAP32LIST)(HANDLE, LPHEAPLIST32); 168typedef BOOL (WINAPI *HEAP32LIST)(HANDLE, LPHEAPLIST32);
@@ -431,7 +432,7 @@ int RAND_poll(void)
431 * This seeding method was proposed in Peter Gutmann, Software 432 * This seeding method was proposed in Peter Gutmann, Software
432 * Generation of Practically Strong Random Numbers, 433 * Generation of Practically Strong Random Numbers,
433 * http://www.usenix.org/publications/library/proceedings/sec98/gutmann.html 434 * http://www.usenix.org/publications/library/proceedings/sec98/gutmann.html
434 * revised version at http://www.cryptoengines.com/~peter/06_random.pdf 435 * revised version at http://www.cryptoengines.com/~peter/06_random.pdf
435 * (The assignment of entropy estimates below is arbitrary, but based 436 * (The assignment of entropy estimates below is arbitrary, but based
436 * on Peter's analysis the full poll appears to be safe. Additional 437 * on Peter's analysis the full poll appears to be safe. Additional
437 * interactive seeding is encouraged.) 438 * interactive seeding is encouraged.)
@@ -440,6 +441,7 @@ int RAND_poll(void)
440 if (kernel) 441 if (kernel)
441 { 442 {
442 CREATETOOLHELP32SNAPSHOT snap; 443 CREATETOOLHELP32SNAPSHOT snap;
444 CLOSETOOLHELP32SNAPSHOT close_snap;
443 HANDLE handle; 445 HANDLE handle;
444 446
445 HEAP32FIRST heap_first; 447 HEAP32FIRST heap_first;
@@ -457,6 +459,8 @@ int RAND_poll(void)
457 459
458 snap = (CREATETOOLHELP32SNAPSHOT) 460 snap = (CREATETOOLHELP32SNAPSHOT)
459 GetProcAddress(kernel, TEXT("CreateToolhelp32Snapshot")); 461 GetProcAddress(kernel, TEXT("CreateToolhelp32Snapshot"));
462 close_snap = (CLOSETOOLHELP32SNAPSHOT)
463 GetProcAddress(kernel, TEXT("CloseToolhelp32Snapshot"));
460 heap_first = (HEAP32FIRST) GetProcAddress(kernel, TEXT("Heap32First")); 464 heap_first = (HEAP32FIRST) GetProcAddress(kernel, TEXT("Heap32First"));
461 heap_next = (HEAP32NEXT) GetProcAddress(kernel, TEXT("Heap32Next")); 465 heap_next = (HEAP32NEXT) GetProcAddress(kernel, TEXT("Heap32Next"));
462 heaplist_first = (HEAP32LIST) GetProcAddress(kernel, TEXT("Heap32ListFirst")); 466 heaplist_first = (HEAP32LIST) GetProcAddress(kernel, TEXT("Heap32ListFirst"));
@@ -472,7 +476,7 @@ int RAND_poll(void)
472 heaplist_next && process_first && process_next && 476 heaplist_next && process_first && process_next &&
473 thread_first && thread_next && module_first && 477 thread_first && thread_next && module_first &&
474 module_next && (handle = snap(TH32CS_SNAPALL,0)) 478 module_next && (handle = snap(TH32CS_SNAPALL,0))
475 != NULL) 479 != INVALID_HANDLE_VALUE)
476 { 480 {
477 /* heap list and heap walking */ 481 /* heap list and heap walking */
478 /* HEAPLIST32 contains 3 fields that will change with 482 /* HEAPLIST32 contains 3 fields that will change with
@@ -534,8 +538,10 @@ int RAND_poll(void)
534 do 538 do
535 RAND_add(&m, m.dwSize, 9); 539 RAND_add(&m, m.dwSize, 9);
536 while (module_next(handle, &m)); 540 while (module_next(handle, &m));
537 541 if (close_snap)
538 CloseHandle(handle); 542 close_snap(handle);
543 else
544 CloseHandle(handle);
539 } 545 }
540 546
541 FreeLibrary(kernel); 547 FreeLibrary(kernel);
diff --git a/src/lib/libcrypto/rc5/rc5test.c b/src/lib/libcrypto/rc5/rc5test.c
new file mode 100644
index 0000000000..ce3d0cc16f
--- /dev/null
+++ b/src/lib/libcrypto/rc5/rc5test.c
@@ -0,0 +1,386 @@
1/* crypto/rc5/rc5test.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* This has been a quickly hacked 'ideatest.c'. When I add tests for other
60 * RC5 modes, more of the code will be uncommented. */
61
62#include <stdio.h>
63#include <string.h>
64#include <stdlib.h>
65
66#include "../e_os.h"
67
68#ifdef OPENSSL_NO_RC5
69int main(int argc, char *argv[])
70{
71 printf("No RC5 support\n");
72 return(0);
73}
74#else
75#include <openssl/rc5.h>
76
77static unsigned char RC5key[5][16]={
78 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
79 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
80 {0x91,0x5f,0x46,0x19,0xbe,0x41,0xb2,0x51,
81 0x63,0x55,0xa5,0x01,0x10,0xa9,0xce,0x91},
82 {0x78,0x33,0x48,0xe7,0x5a,0xeb,0x0f,0x2f,
83 0xd7,0xb1,0x69,0xbb,0x8d,0xc1,0x67,0x87},
84 {0xdc,0x49,0xdb,0x13,0x75,0xa5,0x58,0x4f,
85 0x64,0x85,0xb4,0x13,0xb5,0xf1,0x2b,0xaf},
86 {0x52,0x69,0xf1,0x49,0xd4,0x1b,0xa0,0x15,
87 0x24,0x97,0x57,0x4d,0x7f,0x15,0x31,0x25},
88 };
89
90static unsigned char RC5plain[5][8]={
91 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
92 {0x21,0xA5,0xDB,0xEE,0x15,0x4B,0x8F,0x6D},
93 {0xF7,0xC0,0x13,0xAC,0x5B,0x2B,0x89,0x52},
94 {0x2F,0x42,0xB3,0xB7,0x03,0x69,0xFC,0x92},
95 {0x65,0xC1,0x78,0xB2,0x84,0xD1,0x97,0xCC},
96 };
97
98static unsigned char RC5cipher[5][8]={
99 {0x21,0xA5,0xDB,0xEE,0x15,0x4B,0x8F,0x6D},
100 {0xF7,0xC0,0x13,0xAC,0x5B,0x2B,0x89,0x52},
101 {0x2F,0x42,0xB3,0xB7,0x03,0x69,0xFC,0x92},
102 {0x65,0xC1,0x78,0xB2,0x84,0xD1,0x97,0xCC},
103 {0xEB,0x44,0xE4,0x15,0xDA,0x31,0x98,0x24},
104 };
105
106#define RC5_CBC_NUM 27
107static unsigned char rc5_cbc_cipher[RC5_CBC_NUM][8]={
108 {0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1e},
109 {0x79,0x7b,0xba,0x4d,0x78,0x11,0x1d,0x1e},
110 {0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1f},
111 {0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1f},
112 {0x8b,0x9d,0xed,0x91,0xce,0x77,0x94,0xa6},
113 {0x2f,0x75,0x9f,0xe7,0xad,0x86,0xa3,0x78},
114 {0xdc,0xa2,0x69,0x4b,0xf4,0x0e,0x07,0x88},
115 {0xdc,0xa2,0x69,0x4b,0xf4,0x0e,0x07,0x88},
116 {0xdc,0xfe,0x09,0x85,0x77,0xec,0xa5,0xff},
117 {0x96,0x46,0xfb,0x77,0x63,0x8f,0x9c,0xa8},
118 {0xb2,0xb3,0x20,0x9d,0xb6,0x59,0x4d,0xa4},
119 {0x54,0x5f,0x7f,0x32,0xa5,0xfc,0x38,0x36},
120 {0x82,0x85,0xe7,0xc1,0xb5,0xbc,0x74,0x02},
121 {0xfc,0x58,0x6f,0x92,0xf7,0x08,0x09,0x34},
122 {0xcf,0x27,0x0e,0xf9,0x71,0x7f,0xf7,0xc4},
123 {0xe4,0x93,0xf1,0xc1,0xbb,0x4d,0x6e,0x8c},
124 {0x5c,0x4c,0x04,0x1e,0x0f,0x21,0x7a,0xc3},
125 {0x92,0x1f,0x12,0x48,0x53,0x73,0xb4,0xf7},
126 {0x5b,0xa0,0xca,0x6b,0xbe,0x7f,0x5f,0xad},
127 {0xc5,0x33,0x77,0x1c,0xd0,0x11,0x0e,0x63},
128 {0x29,0x4d,0xdb,0x46,0xb3,0x27,0x8d,0x60},
129 {0xda,0xd6,0xbd,0xa9,0xdf,0xe8,0xf7,0xe8},
130 {0x97,0xe0,0x78,0x78,0x37,0xed,0x31,0x7f},
131 {0x78,0x75,0xdb,0xf6,0x73,0x8c,0x64,0x78},
132 {0x8f,0x34,0xc3,0xc6,0x81,0xc9,0x96,0x95},
133 {0x7c,0xb3,0xf1,0xdf,0x34,0xf9,0x48,0x11},
134 {0x7f,0xd1,0xa0,0x23,0xa5,0xbb,0xa2,0x17},
135 };
136
137static unsigned char rc5_cbc_key[RC5_CBC_NUM][17]={
138 { 1,0x00},
139 { 1,0x00},
140 { 1,0x00},
141 { 1,0x00},
142 { 1,0x00},
143 { 1,0x11},
144 { 1,0x00},
145 { 4,0x00,0x00,0x00,0x00},
146 { 1,0x00},
147 { 1,0x00},
148 { 1,0x00},
149 { 1,0x00},
150 { 4,0x01,0x02,0x03,0x04},
151 { 4,0x01,0x02,0x03,0x04},
152 { 4,0x01,0x02,0x03,0x04},
153 { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
154 { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
155 { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
156 { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
157 {16,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
158 0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
159 {16,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
160 0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
161 {16,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
162 0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
163 { 5,0x01,0x02,0x03,0x04,0x05},
164 { 5,0x01,0x02,0x03,0x04,0x05},
165 { 5,0x01,0x02,0x03,0x04,0x05},
166 { 5,0x01,0x02,0x03,0x04,0x05},
167 { 5,0x01,0x02,0x03,0x04,0x05},
168 };
169
170static unsigned char rc5_cbc_plain[RC5_CBC_NUM][8]={
171 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
172 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
173 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
174 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
175 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
176 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
177 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
178 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
179 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
180 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
181 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
182 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
183 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
184 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
185 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
186 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
187 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
188 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
189 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
190 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
191 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
192 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
193 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
194 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
195 {0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08},
196 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
197 {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x01},
198 };
199
200static int rc5_cbc_rounds[RC5_CBC_NUM]={
201 0, 0, 0, 0, 0, 1, 2, 2,
202 8, 8,12,16, 8,12,16,12,
203 8,12,16, 8,12,16,12, 8,
204 8, 8, 8,
205 };
206
207static unsigned char rc5_cbc_iv[RC5_CBC_NUM][8]={
208 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
209 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
210 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
211 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
212 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
213 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
214 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
215 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
216 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
217 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
218 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
219 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
220 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
221 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
222 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
223 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
224 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
225 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
226 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
227 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
228 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
229 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
230 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
231 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
232 {0x78,0x75,0xdb,0xf6,0x73,0x8c,0x64,0x78},
233 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
234 {0x7c,0xb3,0xf1,0xdf,0x34,0xf9,0x48,0x11},
235 };
236
237int main(int argc, char *argv[])
238 {
239 int i,n,err=0;
240 RC5_32_KEY key;
241 unsigned char buf[8],buf2[8],ivb[8];
242
243 for (n=0; n<5; n++)
244 {
245 RC5_32_set_key(&key,16,&(RC5key[n][0]),12);
246
247 RC5_32_ecb_encrypt(&(RC5plain[n][0]),buf,&key,RC5_ENCRYPT);
248 if (memcmp(&(RC5cipher[n][0]),buf,8) != 0)
249 {
250 printf("ecb RC5 error encrypting (%d)\n",n+1);
251 printf("got :");
252 for (i=0; i<8; i++)
253 printf("%02X ",buf[i]);
254 printf("\n");
255 printf("expected:");
256 for (i=0; i<8; i++)
257 printf("%02X ",RC5cipher[n][i]);
258 err=20;
259 printf("\n");
260 }
261
262 RC5_32_ecb_encrypt(buf,buf2,&key,RC5_DECRYPT);
263 if (memcmp(&(RC5plain[n][0]),buf2,8) != 0)
264 {
265 printf("ecb RC5 error decrypting (%d)\n",n+1);
266 printf("got :");
267 for (i=0; i<8; i++)
268 printf("%02X ",buf2[i]);
269 printf("\n");
270 printf("expected:");
271 for (i=0; i<8; i++)
272 printf("%02X ",RC5plain[n][i]);
273 printf("\n");
274 err=3;
275 }
276 }
277 if (err == 0) printf("ecb RC5 ok\n");
278
279 for (n=0; n<RC5_CBC_NUM; n++)
280 {
281 i=rc5_cbc_rounds[n];
282 if (i < 8) continue;
283
284 RC5_32_set_key(&key,rc5_cbc_key[n][0],&(rc5_cbc_key[n][1]),i);
285
286 memcpy(ivb,&(rc5_cbc_iv[n][0]),8);
287 RC5_32_cbc_encrypt(&(rc5_cbc_plain[n][0]),buf,8,
288 &key,&(ivb[0]),RC5_ENCRYPT);
289
290 if (memcmp(&(rc5_cbc_cipher[n][0]),buf,8) != 0)
291 {
292 printf("cbc RC5 error encrypting (%d)\n",n+1);
293 printf("got :");
294 for (i=0; i<8; i++)
295 printf("%02X ",buf[i]);
296 printf("\n");
297 printf("expected:");
298 for (i=0; i<8; i++)
299 printf("%02X ",rc5_cbc_cipher[n][i]);
300 err=30;
301 printf("\n");
302 }
303
304 memcpy(ivb,&(rc5_cbc_iv[n][0]),8);
305 RC5_32_cbc_encrypt(buf,buf2,8,
306 &key,&(ivb[0]),RC5_DECRYPT);
307 if (memcmp(&(rc5_cbc_plain[n][0]),buf2,8) != 0)
308 {
309 printf("cbc RC5 error decrypting (%d)\n",n+1);
310 printf("got :");
311 for (i=0; i<8; i++)
312 printf("%02X ",buf2[i]);
313 printf("\n");
314 printf("expected:");
315 for (i=0; i<8; i++)
316 printf("%02X ",rc5_cbc_plain[n][i]);
317 printf("\n");
318 err=3;
319 }
320 }
321 if (err == 0) printf("cbc RC5 ok\n");
322
323 EXIT(err);
324 return(err);
325 }
326
327#ifdef undef
328static int cfb64_test(unsigned char *cfb_cipher)
329 {
330 IDEA_KEY_SCHEDULE eks,dks;
331 int err=0,i,n;
332
333 idea_set_encrypt_key(cfb_key,&eks);
334 idea_set_decrypt_key(&eks,&dks);
335 memcpy(cfb_tmp,cfb_iv,8);
336 n=0;
337 idea_cfb64_encrypt(plain,cfb_buf1,(long)12,&eks,
338 cfb_tmp,&n,IDEA_ENCRYPT);
339 idea_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
340 (long)CFB_TEST_SIZE-12,&eks,
341 cfb_tmp,&n,IDEA_ENCRYPT);
342 if (memcmp(cfb_cipher,cfb_buf1,CFB_TEST_SIZE) != 0)
343 {
344 err=1;
345 printf("idea_cfb64_encrypt encrypt error\n");
346 for (i=0; i<CFB_TEST_SIZE; i+=8)
347 printf("%s\n",pt(&(cfb_buf1[i])));
348 }
349 memcpy(cfb_tmp,cfb_iv,8);
350 n=0;
351 idea_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,&eks,
352 cfb_tmp,&n,IDEA_DECRYPT);
353 idea_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
354 (long)CFB_TEST_SIZE-17,&dks,
355 cfb_tmp,&n,IDEA_DECRYPT);
356 if (memcmp(plain,cfb_buf2,CFB_TEST_SIZE) != 0)
357 {
358 err=1;
359 printf("idea_cfb_encrypt decrypt error\n");
360 for (i=0; i<24; i+=8)
361 printf("%s\n",pt(&(cfb_buf2[i])));
362 }
363 return(err);
364 }
365
366static char *pt(unsigned char *p)
367 {
368 static char bufs[10][20];
369 static int bnum=0;
370 char *ret;
371 int i;
372 static char *f="0123456789ABCDEF";
373
374 ret= &(bufs[bnum++][0]);
375 bnum%=10;
376 for (i=0; i<8; i++)
377 {
378 ret[i*2]=f[(p[i]>>4)&0xf];
379 ret[i*2+1]=f[p[i]&0xf];
380 }
381 ret[16]='\0';
382 return(ret);
383 }
384
385#endif
386#endif
diff --git a/src/lib/libcrypto/util/extract-names.pl b/src/lib/libcrypto/util/extract-names.pl
index d413a045cc..9f2ad5ef16 100644
--- a/src/lib/libcrypto/util/extract-names.pl
+++ b/src/lib/libcrypto/util/extract-names.pl
@@ -9,8 +9,8 @@ while(<STDIN>) {
9 } elsif ($name) { 9 } elsif ($name) {
10 if (/ - /) { 10 if (/ - /) {
11 s/ - .*//; 11 s/ - .*//;
12 s/[ \t,]+/ /g; 12 s/,[ \t]+/,/g;
13 push @words, split ' '; 13 push @words, split ',';
14 } 14 }
15 } 15 }
16 if (/^=head1 *NAME *$/) { 16 if (/^=head1 *NAME *$/) {
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num
index f5c8c0be8a..203c7713e7 100644
--- a/src/lib/libcrypto/util/libeay.num
+++ b/src/lib/libcrypto/util/libeay.num
@@ -2801,3 +2801,5 @@ BIO_indent 3242 EXIST::FUNCTION:
2801BUF_strlcpy 3243 EXIST::FUNCTION: 2801BUF_strlcpy 3243 EXIST::FUNCTION:
2802OpenSSLDie 3244 EXIST::FUNCTION: 2802OpenSSLDie 3244 EXIST::FUNCTION:
2803OPENSSL_cleanse 3245 EXIST::FUNCTION: 2803OPENSSL_cleanse 3245 EXIST::FUNCTION:
2804ENGINE_setup_bsd_cryptodev 3246 EXIST:__FreeBSD__:FUNCTION:ENGINE
2805ERR_release_err_state_table 3247 EXIST::FUNCTION:LHASH
diff --git a/src/lib/libcrypto/util/pl/Mingw32.pl b/src/lib/libcrypto/util/pl/Mingw32.pl
index 043a3a53ee..4bee638c4a 100644
--- a/src/lib/libcrypto/util/pl/Mingw32.pl
+++ b/src/lib/libcrypto/util/pl/Mingw32.pl
@@ -85,7 +85,7 @@ sub do_lib_rule
85 ($Name=$name) =~ tr/a-z/A-Z/; 85 ($Name=$name) =~ tr/a-z/A-Z/;
86 86
87 $ret.="$target: \$(${Name}OBJ)\n"; 87 $ret.="$target: \$(${Name}OBJ)\n";
88 $ret.="\t\$(RM) $target\n"; 88 $ret.="\tif exist $target \$(RM) $target\n";
89 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n"; 89 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
90 $ret.="\t\$(RANLIB) $target\n\n"; 90 $ret.="\t\$(RANLIB) $target\n\n";
91 } 91 }
diff --git a/src/lib/libcrypto/util/point.sh b/src/lib/libcrypto/util/point.sh
index ce7dcc56df..4790e08f8a 100644
--- a/src/lib/libcrypto/util/point.sh
+++ b/src/lib/libcrypto/util/point.sh
@@ -1,10 +1,10 @@
1#!/bin/sh 1#!/bin/sh
2 2
3rm -f $2 3rm -f "$2"
4if test "$OSTYPE" = msdosdjgpp; then 4if test "$OSTYPE" = msdosdjgpp; then
5 cp $1 $2 5 cp "$1" "$2"
6else 6else
7 ln -s $1 $2 7 ln -s "$1" "$2"
8fi 8fi
9echo "$2 => $1" 9echo "$2 => $1"
10 10
diff --git a/src/lib/libssl/src/CHANGES b/src/lib/libssl/src/CHANGES
index 1e85275800..b8630792ad 100644
--- a/src/lib/libssl/src/CHANGES
+++ b/src/lib/libssl/src/CHANGES
@@ -2,6 +2,57 @@
2 OpenSSL CHANGES 2 OpenSSL CHANGES
3 _______________ 3 _______________
4 4
5 Changes between 0.9.7b and 0.9.7c [30 Sep 2003]
6
7 *) Fix various bugs revealed by running the NISCC test suite:
8
9 Stop out of bounds reads in the ASN1 code when presented with
10 invalid tags (CAN-2003-0543 and CAN-2003-0544).
11
12 Free up ASN1_TYPE correctly if ANY type is invalid (CAN-2003-0545).
13
14 If verify callback ignores invalid public key errors don't try to check
15 certificate signature with the NULL public key.
16
17 [Steve Henson]
18
19 *) New -ignore_err option in ocsp application to stop the server
20 exiting on the first error in a request.
21 [Steve Henson]
22
23 *) In ssl3_accept() (ssl/s3_srvr.c) only accept a client certificate
24 if the server requested one: as stated in TLS 1.0 and SSL 3.0
25 specifications.
26 [Steve Henson]
27
28 *) In ssl3_get_client_hello() (ssl/s3_srvr.c), tolerate additional
29 extra data after the compression methods not only for TLS 1.0
30 but also for SSL 3.0 (as required by the specification).
31 [Bodo Moeller; problem pointed out by Matthias Loepfe]
32
33 *) Change X509_certificate_type() to mark the key as exported/exportable
34 when it's 512 *bits* long, not 512 bytes.
35 [Richard Levitte]
36
37 *) Change AES_cbc_encrypt() so it outputs exact multiple of
38 blocks during encryption.
39 [Richard Levitte]
40
41 *) Various fixes to base64 BIO and non blocking I/O. On write
42 flushes were not handled properly if the BIO retried. On read
43 data was not being buffered properly and had various logic bugs.
44 This also affects blocking I/O when the data being decoded is a
45 certain size.
46 [Steve Henson]
47
48 *) Various S/MIME bugfixes and compatibility changes:
49 output correct application/pkcs7 MIME type if
50 PKCS7_NOOLDMIMETYPE is set. Tolerate some broken signatures.
51 Output CR+LF for EOL if PKCS7_CRLFEOL is set (this makes opening
52 of files as .eml work). Correctly handle very long lines in MIME
53 parser.
54 [Steve Henson]
55
5 Changes between 0.9.7a and 0.9.7b [10 Apr 2003] 56 Changes between 0.9.7a and 0.9.7b [10 Apr 2003]
6 57
7 *) Countermeasure against the Klima-Pokorny-Rosa extension of 58 *) Countermeasure against the Klima-Pokorny-Rosa extension of
@@ -120,6 +171,9 @@
120 171
121 Changes between 0.9.6h and 0.9.7 [31 Dec 2002] 172 Changes between 0.9.6h and 0.9.7 [31 Dec 2002]
122 173
174 [NB: OpenSSL 0.9.6i and later 0.9.6 patch levels were released after
175 OpenSSL 0.9.7.]
176
123 *) Fix session ID handling in SSLv2 client code: the SERVER FINISHED 177 *) Fix session ID handling in SSLv2 client code: the SERVER FINISHED
124 code (06) was taken as the first octet of the session ID and the last 178 code (06) was taken as the first octet of the session ID and the last
125 octet was ignored consequently. As a result SSLv2 client side session 179 octet was ignored consequently. As a result SSLv2 client side session
@@ -1938,6 +1992,57 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
1938 *) Clean old EAY MD5 hack from e_os.h. 1992 *) Clean old EAY MD5 hack from e_os.h.
1939 [Richard Levitte] 1993 [Richard Levitte]
1940 1994
1995 Changes between 0.9.6j and 0.9.6k [30 Sep 2003]
1996
1997 *) Fix various bugs revealed by running the NISCC test suite:
1998
1999 Stop out of bounds reads in the ASN1 code when presented with
2000 invalid tags (CAN-2003-0543 and CAN-2003-0544).
2001
2002 If verify callback ignores invalid public key errors don't try to check
2003 certificate signature with the NULL public key.
2004
2005 [Steve Henson]
2006
2007 *) In ssl3_accept() (ssl/s3_srvr.c) only accept a client certificate
2008 if the server requested one: as stated in TLS 1.0 and SSL 3.0
2009 specifications.
2010 [Steve Henson]
2011
2012 *) In ssl3_get_client_hello() (ssl/s3_srvr.c), tolerate additional
2013 extra data after the compression methods not only for TLS 1.0
2014 but also for SSL 3.0 (as required by the specification).
2015 [Bodo Moeller; problem pointed out by Matthias Loepfe]
2016
2017 *) Change X509_certificate_type() to mark the key as exported/exportable
2018 when it's 512 *bits* long, not 512 bytes.
2019 [Richard Levitte]
2020
2021 Changes between 0.9.6i and 0.9.6j [10 Apr 2003]
2022
2023 *) Countermeasure against the Klima-Pokorny-Rosa extension of
2024 Bleichbacher's attack on PKCS #1 v1.5 padding: treat
2025 a protocol version number mismatch like a decryption error
2026 in ssl3_get_client_key_exchange (ssl/s3_srvr.c).
2027 [Bodo Moeller]
2028
2029 *) Turn on RSA blinding by default in the default implementation
2030 to avoid a timing attack. Applications that don't want it can call
2031 RSA_blinding_off() or use the new flag RSA_FLAG_NO_BLINDING.
2032 They would be ill-advised to do so in most cases.
2033 [Ben Laurie, Steve Henson, Geoff Thorpe, Bodo Moeller]
2034
2035 *) Change RSA blinding code so that it works when the PRNG is not
2036 seeded (in this case, the secret RSA exponent is abused as
2037 an unpredictable seed -- if it is not unpredictable, there
2038 is no point in blinding anyway). Make RSA blinding thread-safe
2039 by remembering the creator's thread ID in rsa->blinding and
2040 having all other threads use local one-time blinding factors
2041 (this requires more computation than sharing rsa->blinding, but
2042 avoids excessive locking; and if an RSA object is not shared
2043 between threads, blinding will still be very fast).
2044 [Bodo Moeller]
2045
1941 Changes between 0.9.6h and 0.9.6i [19 Feb 2003] 2046 Changes between 0.9.6h and 0.9.6i [19 Feb 2003]
1942 2047
1943 *) In ssl3_get_record (ssl/s3_pkt.c), minimize information leaked 2048 *) In ssl3_get_record (ssl/s3_pkt.c), minimize information leaked
diff --git a/src/lib/libssl/src/Configure b/src/lib/libssl/src/Configure
index 7763dc4138..61331dbb51 100644
--- a/src/lib/libssl/src/Configure
+++ b/src/lib/libssl/src/Configure
@@ -560,6 +560,8 @@ my %table=(
560"vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::", 560"vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
561"vxworks-ppc750","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h \$(DEBUG_FLAG):::VXWORKS:-r:::::", 561"vxworks-ppc750","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h \$(DEBUG_FLAG):::VXWORKS:-r:::::",
562"vxworks-ppc750-debug","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g:::VXWORKS:-r:::::", 562"vxworks-ppc750-debug","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g:::VXWORKS:-r:::::",
563"vxworks-ppc860","ccppc:-nostdinc -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
564"vxworks-mipsle","ccmips:-B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -DL_ENDIAN -EL -Wl,-EL -mips2 -mno-branch-likely -G 0 -fno-builtin -msoft-float -DCPU=MIPS32 -DMIPSEL -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-r::::::::::::::::ranlibmips:",
563 565
564##### Compaq Non-Stop Kernel (Tandem) 566##### Compaq Non-Stop Kernel (Tandem)
565"tandem-c89","c89:-Ww -D__TANDEM -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D_TANDEM_SOURCE -DB_ENDIAN::(unknown):::THIRTY_TWO_BIT:::", 567"tandem-c89","c89:-Ww -D__TANDEM -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D_TANDEM_SOURCE -DB_ENDIAN::(unknown):::THIRTY_TWO_BIT:::",
diff --git a/src/lib/libssl/src/FAQ b/src/lib/libssl/src/FAQ
index 7812ae88cb..ca5683def7 100644
--- a/src/lib/libssl/src/FAQ
+++ b/src/lib/libssl/src/FAQ
@@ -68,7 +68,7 @@ OpenSSL - Frequently Asked Questions
68* Which is the current version of OpenSSL? 68* Which is the current version of OpenSSL?
69 69
70The current version is available from <URL: http://www.openssl.org>. 70The current version is available from <URL: http://www.openssl.org>.
71OpenSSL 0.9.7b was released on April 10, 2003. 71OpenSSL 0.9.7c was released on September 30, 2003.
72 72
73In addition to the current stable release, you can also access daily 73In addition to the current stable release, you can also access daily
74snapshots of the OpenSSL development version at <URL: 74snapshots of the OpenSSL development version at <URL:
diff --git a/src/lib/libssl/src/INSTALL.W32 b/src/lib/libssl/src/INSTALL.W32
index 78d289e16a..0f6c302f0d 100644
--- a/src/lib/libssl/src/INSTALL.W32
+++ b/src/lib/libssl/src/INSTALL.W32
@@ -225,7 +225,7 @@
225 $ md c:\openssl\lib 225 $ md c:\openssl\lib
226 $ md c:\openssl\include 226 $ md c:\openssl\include
227 $ md c:\openssl\include\openssl 227 $ md c:\openssl\include\openssl
228 $ copy /b inc32\* c:\openssl\include\openssl 228 $ copy /b inc32\openssl\* c:\openssl\include\openssl
229 $ copy /b out32dll\ssleay32.lib c:\openssl\lib 229 $ copy /b out32dll\ssleay32.lib c:\openssl\lib
230 $ copy /b out32dll\libeay32.lib c:\openssl\lib 230 $ copy /b out32dll\libeay32.lib c:\openssl\lib
231 $ copy /b out32dll\ssleay32.dll c:\openssl\bin 231 $ copy /b out32dll\ssleay32.dll c:\openssl\bin
diff --git a/src/lib/libssl/src/Makefile.org b/src/lib/libssl/src/Makefile.org
index 4d0627bfdd..e80b22a32a 100644
--- a/src/lib/libssl/src/Makefile.org
+++ b/src/lib/libssl/src/Makefile.org
@@ -78,7 +78,7 @@ MAKEDEPPROG=makedepend
78# gcc, then the driver will automatically translate it to -xarch=v8plus 78# gcc, then the driver will automatically translate it to -xarch=v8plus
79# and pass it down to assembler. 79# and pass it down to assembler.
80AS=$(CC) -c 80AS=$(CC) -c
81ASFLAGS=$(CFLAG) 81ASFLAG=$(CFLAG)
82 82
83# Set BN_ASM to bn_asm.o if you want to use the C version 83# Set BN_ASM to bn_asm.o if you want to use the C version
84BN_ASM= bn_asm.o 84BN_ASM= bn_asm.o
@@ -194,6 +194,7 @@ MAKE= make -f Makefile.ssl
194MANDIR=$(OPENSSLDIR)/man 194MANDIR=$(OPENSSLDIR)/man
195MAN1=1 195MAN1=1
196MAN3=3 196MAN3=3
197MANSUFFIX=
197SHELL=/bin/sh 198SHELL=/bin/sh
198 199
199TOP= . 200TOP= .
@@ -225,7 +226,7 @@ sub_all:
225 do \ 226 do \
226 if [ -d "$$i" ]; then \ 227 if [ -d "$$i" ]; then \
227 (cd $$i && echo "making all in $$i..." && \ 228 (cd $$i && echo "making all in $$i..." && \
228 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' AS='${AS}' ASFLAGS='${ASFLAGS}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' all ) || exit 1; \ 229 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' AS='${AS}' ASFLAG='${ASFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' all ) || exit 1; \
229 else \ 230 else \
230 $(MAKE) $$i; \ 231 $(MAKE) $$i; \
231 fi; \ 232 fi; \
@@ -410,7 +411,7 @@ do_svr3-shared:
410 find . -name "*.o" -print > allobjs ; \ 411 find . -name "*.o" -print > allobjs ; \
411 OBJS= ; export OBJS ; \ 412 OBJS= ; export OBJS ; \
412 for obj in `ar t lib$$i.a` ; do \ 413 for obj in `ar t lib$$i.a` ; do \
413 OBJS="$${OBJS} `grep $$obj allobjs`" ; \ 414 OBJS="$${OBJS} `grep /$$obj allobjs`" ; \
414 done ; \ 415 done ; \
415 set -x; ${CC} ${SHARED_LDFLAGS} \ 416 set -x; ${CC} ${SHARED_LDFLAGS} \
416 -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 417 -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
@@ -435,7 +436,7 @@ do_svr5-shared:
435 find . -name "*.o" -print > allobjs ; \ 436 find . -name "*.o" -print > allobjs ; \
436 OBJS= ; export OBJS ; \ 437 OBJS= ; export OBJS ; \
437 for obj in `ar t lib$$i.a` ; do \ 438 for obj in `ar t lib$$i.a` ; do \
438 OBJS="$${OBJS} `grep $$obj allobjs`" ; \ 439 OBJS="$${OBJS} `grep /$$obj allobjs`" ; \
439 done ; \ 440 done ; \
440 set -x; LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH \ 441 set -x; LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH \
441 ${CC} ${SHARED_LDFLAGS} \ 442 ${CC} ${SHARED_LDFLAGS} \
@@ -831,6 +832,7 @@ install: all install_docs
831 fi; \ 832 fi; \
832 fi 833 fi
833 cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig 834 cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig
835 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig
834 836
835install_docs: 837install_docs:
836 @$(PERL) $(TOP)/util/mkdir-p.pl \ 838 @$(PERL) $(TOP)/util/mkdir-p.pl \
@@ -847,33 +849,33 @@ install_docs:
847 for i in doc/apps/*.pod; do \ 849 for i in doc/apps/*.pod; do \
848 fn=`basename $$i .pod`; \ 850 fn=`basename $$i .pod`; \
849 if [ "$$fn" = "config" ]; then sec=5; else sec=1; fi; \ 851 if [ "$$fn" = "config" ]; then sec=5; else sec=1; fi; \
850 echo "installing man$$sec/$$fn.$$sec"; \ 852 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
851 (cd `$(PERL) util/dirname.pl $$i`; \ 853 (cd `$(PERL) util/dirname.pl $$i`; \
852 sh -c "$$pod2man \ 854 sh -c "$$pod2man \
853 --section=$$sec --center=OpenSSL \ 855 --section=$$sec --center=OpenSSL \
854 --release=$(VERSION) `basename $$i`") \ 856 --release=$(VERSION) `basename $$i`") \
855 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$$sec; \ 857 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
856 $(PERL) util/extract-names.pl < $$i | \ 858 $(PERL) util/extract-names.pl < $$i | \
857 grep -v $$filecase "^$$fn\$$" | \ 859 grep -v $$filecase "^$$fn\$$" | \
858 (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \ 860 (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
859 while read n; do \ 861 while read n; do \
860 $$here/util/point.sh $$fn.$$sec $$n.$$sec; \ 862 $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
861 done); \ 863 done); \
862 done; \ 864 done; \
863 for i in doc/crypto/*.pod doc/ssl/*.pod; do \ 865 for i in doc/crypto/*.pod doc/ssl/*.pod; do \
864 fn=`basename $$i .pod`; \ 866 fn=`basename $$i .pod`; \
865 if [ "$$fn" = "des_modes" ]; then sec=7; else sec=3; fi; \ 867 if [ "$$fn" = "des_modes" ]; then sec=7; else sec=3; fi; \
866 echo "installing man$$sec/$$fn.$$sec"; \ 868 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
867 (cd `$(PERL) util/dirname.pl $$i`; \ 869 (cd `$(PERL) util/dirname.pl $$i`; \
868 sh -c "$$pod2man \ 870 sh -c "$$pod2man \
869 --section=$$sec --center=OpenSSL \ 871 --section=$$sec --center=OpenSSL \
870 --release=$(VERSION) `basename $$i`") \ 872 --release=$(VERSION) `basename $$i`") \
871 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$$sec; \ 873 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
872 $(PERL) util/extract-names.pl < $$i | \ 874 $(PERL) util/extract-names.pl < $$i | \
873 grep -v $$filecase "^$$fn\$$" | \ 875 grep -v $$filecase "^$$fn\$$" | \
874 (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \ 876 (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
875 while read n; do \ 877 while read n; do \
876 $$here/util/point.sh $$fn.$$sec $$n.$$sec; \ 878 $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
877 done); \ 879 done); \
878 done 880 done
879 881
diff --git a/src/lib/libssl/src/NEWS b/src/lib/libssl/src/NEWS
index dce63f0549..f0282ebb87 100644
--- a/src/lib/libssl/src/NEWS
+++ b/src/lib/libssl/src/NEWS
@@ -5,6 +5,13 @@
5 This file gives a brief overview of the major changes between each OpenSSL 5 This file gives a brief overview of the major changes between each OpenSSL
6 release. For more details please read the CHANGES file. 6 release. For more details please read the CHANGES file.
7 7
8 Major changes between OpenSSL 0.9.7b and OpenSSL 0.9.7c:
9
10 o Security: fix various ASN1 parsing bugs.
11 o New -ignore_err option to OCSP utility.
12 o Various interop and bug fixes in S/MIME code.
13 o SSL/TLS protocol fix for unrequested client certificates.
14
8 Major changes between OpenSSL 0.9.7a and OpenSSL 0.9.7b: 15 Major changes between OpenSSL 0.9.7a and OpenSSL 0.9.7b:
9 16
10 o Security: counter the Klima-Pokorny-Rosa extension of 17 o Security: counter the Klima-Pokorny-Rosa extension of
@@ -73,6 +80,11 @@
73 o SSL/TLS: add callback to retrieve SSL/TLS messages. 80 o SSL/TLS: add callback to retrieve SSL/TLS messages.
74 o SSL/TLS: support AES cipher suites (RFC3268). 81 o SSL/TLS: support AES cipher suites (RFC3268).
75 82
83 Major changes between OpenSSL 0.9.6j and OpenSSL 0.9.6k:
84
85 o Security: fix various ASN1 parsing bugs.
86 o SSL/TLS protocol fix for unrequested client certificates.
87
76 Major changes between OpenSSL 0.9.6i and OpenSSL 0.9.6j: 88 Major changes between OpenSSL 0.9.6i and OpenSSL 0.9.6j:
77 89
78 o Security: counter the Klima-Pokorny-Rosa extension of 90 o Security: counter the Klima-Pokorny-Rosa extension of
diff --git a/src/lib/libssl/src/README b/src/lib/libssl/src/README
index 3af69bfdb5..65e3a12426 100644
--- a/src/lib/libssl/src/README
+++ b/src/lib/libssl/src/README
@@ -1,5 +1,5 @@
1 1
2 OpenSSL 0.9.7b 10 Apr 2003 2 OpenSSL 0.9.7c 30 Sep 2003
3 3
4 Copyright (c) 1998-2003 The OpenSSL Project 4 Copyright (c) 1998-2003 The OpenSSL Project
5 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson 5 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
diff --git a/src/lib/libssl/src/apps/CA.pl b/src/lib/libssl/src/apps/CA.pl
index 8b2ce7ea42..669a016b84 100644
--- a/src/lib/libssl/src/apps/CA.pl
+++ b/src/lib/libssl/src/apps/CA.pl
@@ -1,4 +1,4 @@
1#!/usr/local/bin/perl 1#!/usr/bin/perl
2# 2#
3# CA - wrapper around ca to make it easier to use ... basically ca requires 3# CA - wrapper around ca to make it easier to use ... basically ca requires
4# some setup stuff to be done before you can use it and this makes 4# some setup stuff to be done before you can use it and this makes
diff --git a/src/lib/libssl/src/apps/ocsp.c b/src/lib/libssl/src/apps/ocsp.c
index 17e84366d9..e5f186fd5e 100644
--- a/src/lib/libssl/src/apps/ocsp.c
+++ b/src/lib/libssl/src/apps/ocsp.c
@@ -136,6 +136,7 @@ int MAIN(int argc, char **argv)
136 int accept_count = -1; 136 int accept_count = -1;
137 int badarg = 0; 137 int badarg = 0;
138 int i; 138 int i;
139 int ignore_err = 0;
139 STACK *reqnames = NULL; 140 STACK *reqnames = NULL;
140 STACK_OF(OCSP_CERTID) *ids = NULL; 141 STACK_OF(OCSP_CERTID) *ids = NULL;
141 142
@@ -195,6 +196,8 @@ int MAIN(int argc, char **argv)
195 } 196 }
196 else badarg = 1; 197 else badarg = 1;
197 } 198 }
199 else if (!strcmp(*args, "-ignore_err"))
200 ignore_err = 1;
198 else if (!strcmp(*args, "-noverify")) 201 else if (!strcmp(*args, "-noverify"))
199 noverify = 1; 202 noverify = 1;
200 else if (!strcmp(*args, "-nonce")) 203 else if (!strcmp(*args, "-nonce"))
@@ -809,6 +812,8 @@ int MAIN(int argc, char **argv)
809 { 812 {
810 BIO_printf(out, "Responder Error: %s (%ld)\n", 813 BIO_printf(out, "Responder Error: %s (%ld)\n",
811 OCSP_response_status_str(i), i); 814 OCSP_response_status_str(i), i);
815 if (ignore_err)
816 goto redo_accept;
812 ret = 0; 817 ret = 0;
813 goto end; 818 goto end;
814 } 819 }
diff --git a/src/lib/libssl/src/apps/openssl.c b/src/lib/libssl/src/apps/openssl.c
index 45af2ba7f9..e0d89d4ab4 100644
--- a/src/lib/libssl/src/apps/openssl.c
+++ b/src/lib/libssl/src/apps/openssl.c
@@ -163,7 +163,7 @@ static void lock_dbg_cb(int mode, int type, const char *file, int line)
163 goto err; 163 goto err;
164 } 164 }
165 165
166 if (type < 0 || type > CRYPTO_NUM_LOCKS) 166 if (type < 0 || type >= CRYPTO_NUM_LOCKS)
167 { 167 {
168 errstr = "type out of bounds"; 168 errstr = "type out of bounds";
169 goto err; 169 goto err;
diff --git a/src/lib/libssl/src/apps/pkcs8.c b/src/lib/libssl/src/apps/pkcs8.c
index 6be27e7f44..ee8cf02813 100644
--- a/src/lib/libssl/src/apps/pkcs8.c
+++ b/src/lib/libssl/src/apps/pkcs8.c
@@ -235,7 +235,7 @@ int MAIN(int argc, char **argv)
235 return (1); 235 return (1);
236 } 236 }
237 if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) { 237 if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) {
238 BIO_printf(bio_err, "Error converting key\n", outfile); 238 BIO_printf(bio_err, "Error converting key\n");
239 ERR_print_errors(bio_err); 239 ERR_print_errors(bio_err);
240 return (1); 240 return (1);
241 } 241 }
@@ -259,8 +259,7 @@ int MAIN(int argc, char **argv)
259 if (!(p8 = PKCS8_encrypt(pbe_nid, cipher, 259 if (!(p8 = PKCS8_encrypt(pbe_nid, cipher,
260 p8pass, strlen(p8pass), 260 p8pass, strlen(p8pass),
261 NULL, 0, iter, p8inf))) { 261 NULL, 0, iter, p8inf))) {
262 BIO_printf(bio_err, "Error encrypting key\n", 262 BIO_printf(bio_err, "Error encrypting key\n");
263 outfile);
264 ERR_print_errors(bio_err); 263 ERR_print_errors(bio_err);
265 return (1); 264 return (1);
266 } 265 }
@@ -303,7 +302,7 @@ int MAIN(int argc, char **argv)
303 } 302 }
304 303
305 if (!p8) { 304 if (!p8) {
306 BIO_printf (bio_err, "Error reading key\n", outfile); 305 BIO_printf (bio_err, "Error reading key\n");
307 ERR_print_errors(bio_err); 306 ERR_print_errors(bio_err);
308 return (1); 307 return (1);
309 } 308 }
@@ -317,13 +316,13 @@ int MAIN(int argc, char **argv)
317 } 316 }
318 317
319 if (!p8inf) { 318 if (!p8inf) {
320 BIO_printf(bio_err, "Error decrypting key\n", outfile); 319 BIO_printf(bio_err, "Error decrypting key\n");
321 ERR_print_errors(bio_err); 320 ERR_print_errors(bio_err);
322 return (1); 321 return (1);
323 } 322 }
324 323
325 if (!(pkey = EVP_PKCS82PKEY(p8inf))) { 324 if (!(pkey = EVP_PKCS82PKEY(p8inf))) {
326 BIO_printf(bio_err, "Error converting key\n", outfile); 325 BIO_printf(bio_err, "Error converting key\n");
327 ERR_print_errors(bio_err); 326 ERR_print_errors(bio_err);
328 return (1); 327 return (1);
329 } 328 }
diff --git a/src/lib/libssl/src/apps/s_apps.h b/src/lib/libssl/src/apps/s_apps.h
index ff18a72fe0..66b6edd442 100644
--- a/src/lib/libssl/src/apps/s_apps.h
+++ b/src/lib/libssl/src/apps/s_apps.h
@@ -112,6 +112,14 @@
112#include <sys/types.h> 112#include <sys/types.h>
113#include <openssl/opensslconf.h> 113#include <openssl/opensslconf.h>
114 114
115#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
116#include <conio.h>
117#endif
118
119#ifdef OPENSSL_SYS_MSDOS
120#define _kbhit kbhit
121#endif
122
115#if defined(OPENSSL_SYS_VMS) && !defined(FD_SET) 123#if defined(OPENSSL_SYS_VMS) && !defined(FD_SET)
116/* VAX C does not defined fd_set and friends, but it's actually quite simple */ 124/* VAX C does not defined fd_set and friends, but it's actually quite simple */
117/* These definitions are borrowed from SOCKETSHR. /Richard Levitte */ 125/* These definitions are borrowed from SOCKETSHR. /Richard Levitte */
diff --git a/src/lib/libssl/src/apps/s_client.c b/src/lib/libssl/src/apps/s_client.c
index 2e73f34676..eb6fd7c1c3 100644
--- a/src/lib/libssl/src/apps/s_client.c
+++ b/src/lib/libssl/src/apps/s_client.c
@@ -136,10 +136,6 @@ typedef unsigned int u_int;
136#include <openssl/rand.h> 136#include <openssl/rand.h>
137#include "s_apps.h" 137#include "s_apps.h"
138 138
139#ifdef OPENSSL_SYS_WINDOWS
140#include <conio.h>
141#endif
142
143#ifdef OPENSSL_SYS_WINCE 139#ifdef OPENSSL_SYS_WINCE
144/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */ 140/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */
145#ifdef fileno 141#ifdef fileno
@@ -221,7 +217,7 @@ static void sc_usage(void)
221 BIO_printf(bio_err," -starttls prot - use the STARTTLS command before starting TLS\n"); 217 BIO_printf(bio_err," -starttls prot - use the STARTTLS command before starting TLS\n");
222 BIO_printf(bio_err," for those protocols that support it, where\n"); 218 BIO_printf(bio_err," for those protocols that support it, where\n");
223 BIO_printf(bio_err," 'prot' defines which one to assume. Currently,\n"); 219 BIO_printf(bio_err," 'prot' defines which one to assume. Currently,\n");
224 BIO_printf(bio_err," only \"smtp\" is supported.\n"); 220 BIO_printf(bio_err," only \"smtp\" and \"pop3\" are supported.\n");
225#ifndef OPENSSL_NO_ENGINE 221#ifndef OPENSSL_NO_ENGINE
226 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n"); 222 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n");
227#endif 223#endif
@@ -251,7 +247,7 @@ int MAIN(int argc, char **argv)
251 int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending; 247 int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
252 SSL_CTX *ctx=NULL; 248 SSL_CTX *ctx=NULL;
253 int ret=1,in_init=1,i,nbio_test=0; 249 int ret=1,in_init=1,i,nbio_test=0;
254 int smtp_starttls = 0; 250 int starttls_proto = 0;
255 int prexit = 0, vflags = 0; 251 int prexit = 0, vflags = 0;
256 SSL_METHOD *meth=NULL; 252 SSL_METHOD *meth=NULL;
257 BIO *sbio; 253 BIO *sbio;
@@ -260,7 +256,7 @@ int MAIN(int argc, char **argv)
260 char *engine_id=NULL; 256 char *engine_id=NULL;
261 ENGINE *e=NULL; 257 ENGINE *e=NULL;
262#endif 258#endif
263#ifdef OPENSSL_SYS_WINDOWS 259#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
264 struct timeval tv; 260 struct timeval tv;
265#endif 261#endif
266 262
@@ -415,7 +411,9 @@ int MAIN(int argc, char **argv)
415 if (--argc < 1) goto bad; 411 if (--argc < 1) goto bad;
416 ++argv; 412 ++argv;
417 if (strcmp(*argv,"smtp") == 0) 413 if (strcmp(*argv,"smtp") == 0)
418 smtp_starttls = 1; 414 starttls_proto = 1;
415 else if (strcmp(*argv,"pop3") == 0)
416 starttls_proto = 2;
419 else 417 else
420 goto bad; 418 goto bad;
421 } 419 }
@@ -587,12 +585,18 @@ re_start:
587 sbuf_off=0; 585 sbuf_off=0;
588 586
589 /* This is an ugly hack that does a lot of assumptions */ 587 /* This is an ugly hack that does a lot of assumptions */
590 if (smtp_starttls) 588 if (starttls_proto == 1)
591 { 589 {
592 BIO_read(sbio,mbuf,BUFSIZZ); 590 BIO_read(sbio,mbuf,BUFSIZZ);
593 BIO_printf(sbio,"STARTTLS\r\n"); 591 BIO_printf(sbio,"STARTTLS\r\n");
594 BIO_read(sbio,sbuf,BUFSIZZ); 592 BIO_read(sbio,sbuf,BUFSIZZ);
595 } 593 }
594 if (starttls_proto == 2)
595 {
596 BIO_read(sbio,mbuf,BUFSIZZ);
597 BIO_printf(sbio,"STLS\r\n");
598 BIO_read(sbio,sbuf,BUFSIZZ);
599 }
596 600
597 for (;;) 601 for (;;)
598 { 602 {
@@ -613,11 +617,11 @@ re_start:
613 print_stuff(bio_c_out,con,full_log); 617 print_stuff(bio_c_out,con,full_log);
614 if (full_log > 0) full_log--; 618 if (full_log > 0) full_log--;
615 619
616 if (smtp_starttls) 620 if (starttls_proto)
617 { 621 {
618 BIO_printf(bio_err,"%s",mbuf); 622 BIO_printf(bio_err,"%s",mbuf);
619 /* We don't need to know any more */ 623 /* We don't need to know any more */
620 smtp_starttls = 0; 624 starttls_proto = 0;
621 } 625 }
622 626
623 if (reconnect) 627 if (reconnect)
@@ -636,7 +640,7 @@ re_start:
636 640
637 if (!ssl_pending) 641 if (!ssl_pending)
638 { 642 {
639#ifndef OPENSSL_SYS_WINDOWS 643#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
640 if (tty_on) 644 if (tty_on)
641 { 645 {
642 if (read_tty) FD_SET(fileno(stdin),&readfds); 646 if (read_tty) FD_SET(fileno(stdin),&readfds);
@@ -663,8 +667,8 @@ re_start:
663 * will choke the compiler: if you do have a cast then 667 * will choke the compiler: if you do have a cast then
664 * you can either go for (int *) or (void *). 668 * you can either go for (int *) or (void *).
665 */ 669 */
666#ifdef OPENSSL_SYS_WINDOWS 670#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
667 /* Under Windows we make the assumption that we can 671 /* Under Windows/DOS we make the assumption that we can
668 * always write to the tty: therefore if we need to 672 * always write to the tty: therefore if we need to
669 * write to the tty we just fall through. Otherwise 673 * write to the tty we just fall through. Otherwise
670 * we timeout the select every second and see if there 674 * we timeout the select every second and see if there
@@ -678,7 +682,7 @@ re_start:
678 tv.tv_usec = 0; 682 tv.tv_usec = 0;
679 i=select(width,(void *)&readfds,(void *)&writefds, 683 i=select(width,(void *)&readfds,(void *)&writefds,
680 NULL,&tv); 684 NULL,&tv);
681#ifdef OPENSSL_SYS_WINCE 685#if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
682 if(!i && (!_kbhit() || !read_tty) ) continue; 686 if(!i && (!_kbhit() || !read_tty) ) continue;
683#else 687#else
684 if(!i && (!((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) || !read_tty) ) continue; 688 if(!i && (!((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) || !read_tty) ) continue;
@@ -847,8 +851,8 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
847 } 851 }
848 } 852 }
849 853
850#ifdef OPENSSL_SYS_WINDOWS 854#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
851#ifdef OPENSSL_SYS_WINCE 855#if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
852 else if (_kbhit()) 856 else if (_kbhit())
853#else 857#else
854 else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) 858 else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0)))
diff --git a/src/lib/libssl/src/apps/s_server.c b/src/lib/libssl/src/apps/s_server.c
index 5157aae4d1..ff4ab6ef28 100644
--- a/src/lib/libssl/src/apps/s_server.c
+++ b/src/lib/libssl/src/apps/s_server.c
@@ -140,10 +140,6 @@ typedef unsigned int u_int;
140#include <openssl/rand.h> 140#include <openssl/rand.h>
141#include "s_apps.h" 141#include "s_apps.h"
142 142
143#ifdef OPENSSL_SYS_WINDOWS
144#include <conio.h>
145#endif
146
147#ifdef OPENSSL_SYS_WINCE 143#ifdef OPENSSL_SYS_WINCE
148/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */ 144/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */
149#ifdef fileno 145#ifdef fileno
@@ -917,7 +913,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
917 unsigned long l; 913 unsigned long l;
918 SSL *con=NULL; 914 SSL *con=NULL;
919 BIO *sbio; 915 BIO *sbio;
920#ifdef OPENSSL_SYS_WINDOWS 916#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
921 struct timeval tv; 917 struct timeval tv;
922#endif 918#endif
923 919
@@ -991,7 +987,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
991 if (!read_from_sslcon) 987 if (!read_from_sslcon)
992 { 988 {
993 FD_ZERO(&readfds); 989 FD_ZERO(&readfds);
994#ifndef OPENSSL_SYS_WINDOWS 990#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
995 FD_SET(fileno(stdin),&readfds); 991 FD_SET(fileno(stdin),&readfds);
996#endif 992#endif
997 FD_SET(s,&readfds); 993 FD_SET(s,&readfds);
@@ -1001,8 +997,8 @@ static int sv_body(char *hostname, int s, unsigned char *context)
1001 * the compiler: if you do have a cast then you can either 997 * the compiler: if you do have a cast then you can either
1002 * go for (int *) or (void *). 998 * go for (int *) or (void *).
1003 */ 999 */
1004#ifdef OPENSSL_SYS_WINDOWS 1000#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
1005 /* Under Windows we can't select on stdin: only 1001 /* Under DOS (non-djgpp) and Windows we can't select on stdin: only
1006 * on sockets. As a workaround we timeout the select every 1002 * on sockets. As a workaround we timeout the select every
1007 * second and check for any keypress. In a proper Windows 1003 * second and check for any keypress. In a proper Windows
1008 * application we wouldn't do this because it is inefficient. 1004 * application we wouldn't do this because it is inefficient.
@@ -1263,7 +1259,13 @@ static int init_ssl_connection(SSL *con)
1263 if (SSL_ctrl(con,SSL_CTRL_GET_FLAGS,0,NULL) & 1259 if (SSL_ctrl(con,SSL_CTRL_GET_FLAGS,0,NULL) &
1264 TLS1_FLAGS_TLS_PADDING_BUG) 1260 TLS1_FLAGS_TLS_PADDING_BUG)
1265 BIO_printf(bio_s_out,"Peer has incorrect TLSv1 block padding\n"); 1261 BIO_printf(bio_s_out,"Peer has incorrect TLSv1 block padding\n");
1266 1262#ifndef OPENSSL_NO_KRB5
1263 if (con->kssl_ctx->client_princ != NULL)
1264 {
1265 BIO_printf(bio_s_out,"Kerberos peer principal is %s\n",
1266 con->kssl_ctx->client_princ);
1267 }
1268#endif /* OPENSSL_NO_KRB5 */
1267 return(1); 1269 return(1);
1268 } 1270 }
1269 1271
diff --git a/src/lib/libssl/src/apps/smime.c b/src/lib/libssl/src/apps/smime.c
index cc248d377b..51bc893ffa 100644
--- a/src/lib/libssl/src/apps/smime.c
+++ b/src/lib/libssl/src/apps/smime.c
@@ -168,6 +168,10 @@ int MAIN(int argc, char **argv)
168 flags |= PKCS7_BINARY; 168 flags |= PKCS7_BINARY;
169 else if (!strcmp (*args, "-nosigs")) 169 else if (!strcmp (*args, "-nosigs"))
170 flags |= PKCS7_NOSIGS; 170 flags |= PKCS7_NOSIGS;
171 else if (!strcmp (*args, "-nooldmime"))
172 flags |= PKCS7_NOOLDMIMETYPE;
173 else if (!strcmp (*args, "-crlfeol"))
174 flags |= PKCS7_CRLFEOL;
171 else if (!strcmp (*args, "-crl_check")) 175 else if (!strcmp (*args, "-crl_check"))
172 store_flags |= X509_V_FLAG_CRL_CHECK; 176 store_flags |= X509_V_FLAG_CRL_CHECK;
173 else if (!strcmp (*args, "-crl_check_all")) 177 else if (!strcmp (*args, "-crl_check_all"))
diff --git a/src/lib/libssl/src/apps/x509.c b/src/lib/libssl/src/apps/x509.c
index 66f0074f45..2020b51de0 100644
--- a/src/lib/libssl/src/apps/x509.c
+++ b/src/lib/libssl/src/apps/x509.c
@@ -1145,7 +1145,7 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
1145 else if (!(bs = load_serial(CAfile, serialfile, create))) 1145 else if (!(bs = load_serial(CAfile, serialfile, create)))
1146 goto end; 1146 goto end;
1147 1147
1148 if (!X509_STORE_add_cert(ctx,x)) goto end; 1148/* if (!X509_STORE_add_cert(ctx,x)) goto end;*/
1149 1149
1150 /* NOTE: this certificate can/should be self signed, unless it was 1150 /* NOTE: this certificate can/should be self signed, unless it was
1151 * a certificate request in which case it is not. */ 1151 * a certificate request in which case it is not. */
diff --git a/src/lib/libssl/src/bugs/SSLv3 b/src/lib/libssl/src/bugs/SSLv3
index db53e1343a..a75a1652d9 100644
--- a/src/lib/libssl/src/bugs/SSLv3
+++ b/src/lib/libssl/src/bugs/SSLv3
@@ -29,7 +29,7 @@ RC4-MD5, but a re-connect tries to use DES-CBC-SHA. So netscape, when
29doing a re-connect, always takes the first cipher in the cipher list. 29doing a re-connect, always takes the first cipher in the cipher list.
30 30
31If we accept a netscape connection, demand a client cert, have a 31If we accept a netscape connection, demand a client cert, have a
32non-self-sighed CA which does not have it's CA in netscape, and the 32non-self-signed CA which does not have it's CA in netscape, and the
33browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta 33browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta
34 34
35Netscape browsers do not really notice the server sending a 35Netscape browsers do not really notice the server sending a
diff --git a/src/lib/libssl/src/crypto/aes/aes.h b/src/lib/libssl/src/crypto/aes/aes.h
index 8294a41a3a..da067f4a8f 100644
--- a/src/lib/libssl/src/crypto/aes/aes.h
+++ b/src/lib/libssl/src/crypto/aes/aes.h
@@ -100,7 +100,7 @@ void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
100 unsigned char *ivec, int *num); 100 unsigned char *ivec, int *num);
101void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 101void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
102 const unsigned long length, const AES_KEY *key, 102 const unsigned long length, const AES_KEY *key,
103 unsigned char counter[AES_BLOCK_SIZE], 103 unsigned char ivec[AES_BLOCK_SIZE],
104 unsigned char ecount_buf[AES_BLOCK_SIZE], 104 unsigned char ecount_buf[AES_BLOCK_SIZE],
105 unsigned int *num); 105 unsigned int *num);
106 106
diff --git a/src/lib/libssl/src/crypto/aes/aes_cbc.c b/src/lib/libssl/src/crypto/aes/aes_cbc.c
index de438306b1..86b27b10d6 100644
--- a/src/lib/libssl/src/crypto/aes/aes_cbc.c
+++ b/src/lib/libssl/src/crypto/aes/aes_cbc.c
@@ -72,7 +72,7 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
72 72
73 if (AES_ENCRYPT == enc) { 73 if (AES_ENCRYPT == enc) {
74 while (len >= AES_BLOCK_SIZE) { 74 while (len >= AES_BLOCK_SIZE) {
75 for(n=0; n < sizeof tmp; ++n) 75 for(n=0; n < AES_BLOCK_SIZE; ++n)
76 tmp[n] = in[n] ^ ivec[n]; 76 tmp[n] = in[n] ^ ivec[n];
77 AES_encrypt(tmp, out, key); 77 AES_encrypt(tmp, out, key);
78 memcpy(ivec, out, AES_BLOCK_SIZE); 78 memcpy(ivec, out, AES_BLOCK_SIZE);
@@ -86,12 +86,12 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
86 for(n=len; n < AES_BLOCK_SIZE; ++n) 86 for(n=len; n < AES_BLOCK_SIZE; ++n)
87 tmp[n] = ivec[n]; 87 tmp[n] = ivec[n];
88 AES_encrypt(tmp, tmp, key); 88 AES_encrypt(tmp, tmp, key);
89 memcpy(out, tmp, len); 89 memcpy(out, tmp, AES_BLOCK_SIZE);
90 memcpy(ivec, tmp, sizeof tmp); 90 memcpy(ivec, tmp, AES_BLOCK_SIZE);
91 } 91 }
92 } else { 92 } else {
93 while (len >= AES_BLOCK_SIZE) { 93 while (len >= AES_BLOCK_SIZE) {
94 memcpy(tmp, in, sizeof tmp); 94 memcpy(tmp, in, AES_BLOCK_SIZE);
95 AES_decrypt(in, out, key); 95 AES_decrypt(in, out, key);
96 for(n=0; n < AES_BLOCK_SIZE; ++n) 96 for(n=0; n < AES_BLOCK_SIZE; ++n)
97 out[n] ^= ivec[n]; 97 out[n] ^= ivec[n];
@@ -101,11 +101,11 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
101 out += AES_BLOCK_SIZE; 101 out += AES_BLOCK_SIZE;
102 } 102 }
103 if (len) { 103 if (len) {
104 memcpy(tmp, in, sizeof tmp); 104 memcpy(tmp, in, AES_BLOCK_SIZE);
105 AES_decrypt(tmp, tmp, key); 105 AES_decrypt(tmp, tmp, key);
106 for(n=0; n < len; ++n) 106 for(n=0; n < len; ++n)
107 out[n] ^= ivec[n]; 107 out[n] ^= ivec[n];
108 memcpy(ivec, tmp, sizeof tmp); 108 memcpy(ivec, tmp, AES_BLOCK_SIZE);
109 } 109 }
110 } 110 }
111} 111}
diff --git a/src/lib/libssl/src/crypto/aes/aes_ctr.c b/src/lib/libssl/src/crypto/aes/aes_ctr.c
index 59088499a0..79e1c18f19 100644
--- a/src/lib/libssl/src/crypto/aes/aes_ctr.c
+++ b/src/lib/libssl/src/crypto/aes/aes_ctr.c
@@ -62,19 +62,49 @@
62/* NOTE: CTR mode is big-endian. The rest of the AES code 62/* NOTE: CTR mode is big-endian. The rest of the AES code
63 * is endian-neutral. */ 63 * is endian-neutral. */
64 64
65/* increment counter (128-bit int) by 2^64 */ 65/* increment counter (128-bit int) by 1 */
66static void AES_ctr128_inc(unsigned char *counter) { 66static void AES_ctr128_inc(unsigned char *counter) {
67 unsigned long c; 67 unsigned long c;
68 68
69 /* Grab 3rd dword of counter and increment */ 69 /* Grab bottom dword of counter and increment */
70#ifdef L_ENDIAN 70#ifdef L_ENDIAN
71 c = GETU32(counter + 8); 71 c = GETU32(counter + 0);
72 c++; 72 c++;
73 PUTU32(counter + 8, c); 73 PUTU32(counter + 0, c);
74#else 74#else
75 c = GETU32(counter + 4); 75 c = GETU32(counter + 12);
76 c++; 76 c++;
77 PUTU32(counter + 4, c); 77 PUTU32(counter + 12, c);
78#endif
79
80 /* if no overflow, we're done */
81 if (c)
82 return;
83
84 /* Grab 1st dword of counter and increment */
85#ifdef L_ENDIAN
86 c = GETU32(counter + 4);
87 c++;
88 PUTU32(counter + 4, c);
89#else
90 c = GETU32(counter + 8);
91 c++;
92 PUTU32(counter + 8, c);
93#endif
94
95 /* if no overflow, we're done */
96 if (c)
97 return;
98
99 /* Grab 2nd dword of counter and increment */
100#ifdef L_ENDIAN
101 c = GETU32(counter + 8);
102 c++;
103 PUTU32(counter + 8, c);
104#else
105 c = GETU32(counter + 4);
106 c++;
107 PUTU32(counter + 4, c);
78#endif 108#endif
79 109
80 /* if no overflow, we're done */ 110 /* if no overflow, we're done */
@@ -100,10 +130,16 @@ static void AES_ctr128_inc(unsigned char *counter) {
100 * encrypted counter is kept in ecount_buf. Both *num and 130 * encrypted counter is kept in ecount_buf. Both *num and
101 * ecount_buf must be initialised with zeros before the first 131 * ecount_buf must be initialised with zeros before the first
102 * call to AES_ctr128_encrypt(). 132 * call to AES_ctr128_encrypt().
133 *
134 * This algorithm assumes that the counter is in the x lower bits
135 * of the IV (ivec), and that the application has full control over
136 * overflow and the rest of the IV. This implementation takes NO
137 * responsability for checking that the counter doesn't overflow
138 * into the rest of the IV when incremented.
103 */ 139 */
104void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 140void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
105 const unsigned long length, const AES_KEY *key, 141 const unsigned long length, const AES_KEY *key,
106 unsigned char counter[AES_BLOCK_SIZE], 142 unsigned char ivec[AES_BLOCK_SIZE],
107 unsigned char ecount_buf[AES_BLOCK_SIZE], 143 unsigned char ecount_buf[AES_BLOCK_SIZE],
108 unsigned int *num) { 144 unsigned int *num) {
109 145
@@ -117,8 +153,8 @@ void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
117 153
118 while (l--) { 154 while (l--) {
119 if (n == 0) { 155 if (n == 0) {
120 AES_encrypt(counter, ecount_buf, key); 156 AES_encrypt(ivec, ecount_buf, key);
121 AES_ctr128_inc(counter); 157 AES_ctr128_inc(ivec);
122 } 158 }
123 *(out++) = *(in++) ^ ecount_buf[n]; 159 *(out++) = *(in++) ^ ecount_buf[n];
124 n = (n+1) % AES_BLOCK_SIZE; 160 n = (n+1) % AES_BLOCK_SIZE;
diff --git a/src/lib/libssl/src/crypto/asn1/a_mbstr.c b/src/lib/libssl/src/crypto/asn1/a_mbstr.c
index 5d981c6553..e8a26af521 100644
--- a/src/lib/libssl/src/crypto/asn1/a_mbstr.c
+++ b/src/lib/libssl/src/crypto/asn1/a_mbstr.c
@@ -296,7 +296,7 @@ static int in_utf8(unsigned long value, void *arg)
296 296
297static int out_utf8(unsigned long value, void *arg) 297static int out_utf8(unsigned long value, void *arg)
298{ 298{
299 long *outlen; 299 int *outlen;
300 outlen = arg; 300 outlen = arg;
301 *outlen += UTF8_putc(NULL, -1, value); 301 *outlen += UTF8_putc(NULL, -1, value);
302 return 1; 302 return 1;
diff --git a/src/lib/libssl/src/crypto/asn1/a_strex.c b/src/lib/libssl/src/crypto/asn1/a_strex.c
index 1def6c6549..8abfdfe598 100644
--- a/src/lib/libssl/src/crypto/asn1/a_strex.c
+++ b/src/lib/libssl/src/crypto/asn1/a_strex.c
@@ -279,7 +279,7 @@ static int do_dump(unsigned long lflags, char_io *io_ch, void *arg, ASN1_STRING
279 * otherwise it is the number of bytes per character 279 * otherwise it is the number of bytes per character
280 */ 280 */
281 281
282const static char tag2nbyte[] = { 282const static signed char tag2nbyte[] = {
283 -1, -1, -1, -1, -1, /* 0-4 */ 283 -1, -1, -1, -1, -1, /* 0-4 */
284 -1, -1, -1, -1, -1, /* 5-9 */ 284 -1, -1, -1, -1, -1, /* 5-9 */
285 -1, -1, 0, -1, /* 10-13 */ 285 -1, -1, 0, -1, /* 10-13 */
diff --git a/src/lib/libssl/src/crypto/asn1/a_strnid.c b/src/lib/libssl/src/crypto/asn1/a_strnid.c
index aa49e9d7d0..613bbc4a7d 100644
--- a/src/lib/libssl/src/crypto/asn1/a_strnid.c
+++ b/src/lib/libssl/src/crypto/asn1/a_strnid.c
@@ -143,7 +143,7 @@ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
143/* Now the tables and helper functions for the string table: 143/* Now the tables and helper functions for the string table:
144 */ 144 */
145 145
146/* size limits: this stuff is taken straight from RFC2459 */ 146/* size limits: this stuff is taken straight from RFC3280 */
147 147
148#define ub_name 32768 148#define ub_name 32768
149#define ub_common_name 64 149#define ub_common_name 64
@@ -153,6 +153,8 @@ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
153#define ub_organization_unit_name 64 153#define ub_organization_unit_name 64
154#define ub_title 64 154#define ub_title 64
155#define ub_email_address 128 155#define ub_email_address 128
156#define ub_serial_number 64
157
156 158
157/* This table must be kept in NID order */ 159/* This table must be kept in NID order */
158 160
@@ -170,6 +172,7 @@ static ASN1_STRING_TABLE tbl_standard[] = {
170{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0}, 172{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
171{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0}, 173{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
172{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0}, 174{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
175{NID_serialNumber, 1, ub_serial_number, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
173{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}, 176{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
174{NID_name, 1, ub_name, DIRSTRING_TYPE, 0}, 177{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
175{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, 178{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
diff --git a/src/lib/libssl/src/crypto/asn1/asn1_lib.c b/src/lib/libssl/src/crypto/asn1/asn1_lib.c
index 0638870ab7..e30d5dd303 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_lib.c
+++ b/src/lib/libssl/src/crypto/asn1/asn1_lib.c
@@ -104,10 +104,12 @@ int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,
104 l<<=7L; 104 l<<=7L;
105 l|= *(p++)&0x7f; 105 l|= *(p++)&0x7f;
106 if (--max == 0) goto err; 106 if (--max == 0) goto err;
107 if (l > (INT_MAX >> 7L)) goto err;
107 } 108 }
108 l<<=7L; 109 l<<=7L;
109 l|= *(p++)&0x7f; 110 l|= *(p++)&0x7f;
110 tag=(int)l; 111 tag=(int)l;
112 if (--max == 0) goto err;
111 } 113 }
112 else 114 else
113 { 115 {
diff --git a/src/lib/libssl/src/crypto/asn1/tasn_dec.c b/src/lib/libssl/src/crypto/asn1/tasn_dec.c
index 76fc023230..2426cb6253 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_dec.c
+++ b/src/lib/libssl/src/crypto/asn1/tasn_dec.c
@@ -691,6 +691,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, unsigned char **in, long inl
691 691
692int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it) 692int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it)
693{ 693{
694 ASN1_VALUE **opval = NULL;
694 ASN1_STRING *stmp; 695 ASN1_STRING *stmp;
695 ASN1_TYPE *typ = NULL; 696 ASN1_TYPE *typ = NULL;
696 int ret = 0; 697 int ret = 0;
@@ -705,6 +706,7 @@ int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char
705 *pval = (ASN1_VALUE *)typ; 706 *pval = (ASN1_VALUE *)typ;
706 } else typ = (ASN1_TYPE *)*pval; 707 } else typ = (ASN1_TYPE *)*pval;
707 if(utype != typ->type) ASN1_TYPE_set(typ, utype, NULL); 708 if(utype != typ->type) ASN1_TYPE_set(typ, utype, NULL);
709 opval = pval;
708 pval = (ASN1_VALUE **)&typ->value.ptr; 710 pval = (ASN1_VALUE **)&typ->value.ptr;
709 } 711 }
710 switch(utype) { 712 switch(utype) {
@@ -796,7 +798,12 @@ int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char
796 798
797 ret = 1; 799 ret = 1;
798 err: 800 err:
799 if(!ret) ASN1_TYPE_free(typ); 801 if(!ret)
802 {
803 ASN1_TYPE_free(typ);
804 if (opval)
805 *opval = NULL;
806 }
800 return ret; 807 return ret;
801} 808}
802 809
diff --git a/src/lib/libssl/src/crypto/bio/b_print.c b/src/lib/libssl/src/crypto/bio/b_print.c
index a9e552f245..2cfc689dd6 100644
--- a/src/lib/libssl/src/crypto/bio/b_print.c
+++ b/src/lib/libssl/src/crypto/bio/b_print.c
@@ -836,5 +836,5 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
836 * had the buffer been large enough.) */ 836 * had the buffer been large enough.) */
837 return -1; 837 return -1;
838 else 838 else
839 return (retlen <= INT_MAX) ? retlen : -1; 839 return (retlen <= INT_MAX) ? (int)retlen : -1;
840 } 840 }
diff --git a/src/lib/libssl/src/crypto/bio/bf_buff.c b/src/lib/libssl/src/crypto/bio/bf_buff.c
index 1cecd70579..c1fd75aaad 100644
--- a/src/lib/libssl/src/crypto/bio/bf_buff.c
+++ b/src/lib/libssl/src/crypto/bio/bf_buff.c
@@ -494,6 +494,7 @@ static int buffer_gets(BIO *b, char *buf, int size)
494 if (i <= 0) 494 if (i <= 0)
495 { 495 {
496 BIO_copy_next_retry(b); 496 BIO_copy_next_retry(b);
497 *buf='\0';
497 if (i < 0) return((num > 0)?num:i); 498 if (i < 0) return((num > 0)?num:i);
498 if (i == 0) return(num); 499 if (i == 0) return(num);
499 } 500 }
diff --git a/src/lib/libssl/src/crypto/bio/bss_bio.c b/src/lib/libssl/src/crypto/bio/bss_bio.c
index aa58dab046..0f9f0955b4 100644
--- a/src/lib/libssl/src/crypto/bio/bss_bio.c
+++ b/src/lib/libssl/src/crypto/bio/bss_bio.c
@@ -1,4 +1,57 @@
1/* crypto/bio/bss_bio.c -*- Mode: C; c-file-style: "eay" -*- */ 1/* crypto/bio/bss_bio.c -*- Mode: C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
2 55
3/* Special method for a BIO where the other endpoint is also a BIO 56/* Special method for a BIO where the other endpoint is also a BIO
4 * of this kind, handled by the same thread (i.e. the "peer" is actually 57 * of this kind, handled by the same thread (i.e. the "peer" is actually
@@ -502,7 +555,7 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
502 break; 555 break;
503 556
504 case BIO_C_DESTROY_BIO_PAIR: 557 case BIO_C_DESTROY_BIO_PAIR:
505 /* Effects both BIOs in the pair -- call just once! 558 /* Affects both BIOs in the pair -- call just once!
506 * Or let BIO_free(bio1); BIO_free(bio2); do the job. */ 559 * Or let BIO_free(bio1); BIO_free(bio2); do the job. */
507 bio_destroy_pair(bio); 560 bio_destroy_pair(bio);
508 ret = 1; 561 ret = 1;
diff --git a/src/lib/libssl/src/crypto/bio/bss_file.c b/src/lib/libssl/src/crypto/bio/bss_file.c
index a66600c1a3..6904b5c081 100644
--- a/src/lib/libssl/src/crypto/bio/bss_file.c
+++ b/src/lib/libssl/src/crypto/bio/bss_file.c
@@ -213,12 +213,29 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
213 b->shutdown=(int)num&BIO_CLOSE; 213 b->shutdown=(int)num&BIO_CLOSE;
214 b->ptr=(char *)ptr; 214 b->ptr=(char *)ptr;
215 b->init=1; 215 b->init=1;
216#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) 216#if defined(OPENSSL_SYS_WINDOWS)
217 /* Set correct text/binary mode */
218 if (num & BIO_FP_TEXT) 217 if (num & BIO_FP_TEXT)
219 _setmode(fileno((FILE *)ptr),_O_TEXT); 218 _setmode(fileno((FILE *)ptr),_O_TEXT);
220 else 219 else
221 _setmode(fileno((FILE *)ptr),_O_BINARY); 220 _setmode(fileno((FILE *)ptr),_O_BINARY);
221#elif defined(OPENSSL_SYS_MSDOS)
222 {
223 int fd = fileno((FILE*)ptr);
224 /* Set correct text/binary mode */
225 if (num & BIO_FP_TEXT)
226 _setmode(fd,_O_TEXT);
227 /* Dangerous to set stdin/stdout to raw (unless redirected) */
228 else
229 {
230 if (fd == STDIN_FILENO || fd == STDOUT_FILENO)
231 {
232 if (isatty(fd) <= 0)
233 _setmode(fd,_O_BINARY);
234 }
235 else
236 _setmode(fd,_O_BINARY);
237 }
238 }
222#elif defined(OPENSSL_SYS_OS2) 239#elif defined(OPENSSL_SYS_OS2)
223 if (num & BIO_FP_TEXT) 240 if (num & BIO_FP_TEXT)
224 setmode(fileno((FILE *)ptr), O_TEXT); 241 setmode(fileno((FILE *)ptr), O_TEXT);
diff --git a/src/lib/libssl/src/crypto/bn/bn_mul.c b/src/lib/libssl/src/crypto/bn/bn_mul.c
index cb93ac3356..3ae3822bc2 100644
--- a/src/lib/libssl/src/crypto/bn/bn_mul.c
+++ b/src/lib/libssl/src/crypto/bn/bn_mul.c
@@ -224,7 +224,7 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
224 int n, BN_ULONG *t) 224 int n, BN_ULONG *t)
225 { 225 {
226 int i,j,n2=n*2; 226 int i,j,n2=n*2;
227 unsigned int c1,c2,neg,zero; 227 int c1,c2,neg,zero;
228 BN_ULONG ln,lo,*p; 228 BN_ULONG ln,lo,*p;
229 229
230# ifdef BN_COUNT 230# ifdef BN_COUNT
@@ -376,7 +376,7 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
376 376
377 /* The overflow will stop before we over write 377 /* The overflow will stop before we over write
378 * words we should not overwrite */ 378 * words we should not overwrite */
379 if (ln < c1) 379 if (ln < (BN_ULONG)c1)
380 { 380 {
381 do { 381 do {
382 p++; 382 p++;
diff --git a/src/lib/libssl/src/crypto/des/cfb_enc.c b/src/lib/libssl/src/crypto/des/cfb_enc.c
index 17bf77ca9e..2600bdfc93 100644
--- a/src/lib/libssl/src/crypto/des/cfb_enc.c
+++ b/src/lib/libssl/src/crypto/des/cfb_enc.c
@@ -64,32 +64,22 @@
64 * the second. The second 12 bits will come from the 3rd and half the 4th 64 * the second. The second 12 bits will come from the 3rd and half the 4th
65 * byte. 65 * byte.
66 */ 66 */
67/* WARNING WARNING: this uses in and out in 8-byte chunks regardless of
68 * length */
69/* Until Aug 1 2003 this function did not correctly implement CFB-r, so it
70 * will not be compatible with any encryption prior to that date. Ben. */
67void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, 71void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
68 long length, DES_key_schedule *schedule, DES_cblock *ivec, int enc) 72 long length, DES_key_schedule *schedule, DES_cblock *ivec,
73 int enc)
69 { 74 {
70 register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8; 75 register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
71 register DES_LONG mask0,mask1;
72 register unsigned long l=length; 76 register unsigned long l=length;
73 register int num=numbits; 77 register int num=numbits;
74 DES_LONG ti[2]; 78 DES_LONG ti[2];
75 unsigned char *iv; 79 unsigned char *iv;
80 unsigned char ovec[16];
76 81
77 if (num > 64) return; 82 if (num > 64) return;
78 if (num > 32)
79 {
80 mask0=0xffffffffL;
81 if (num == 64)
82 mask1=mask0;
83 else mask1=(1L<<(num-32))-1;
84 }
85 else
86 {
87 if (num == 32)
88 mask0=0xffffffffL;
89 else mask0=(1L<<num)-1;
90 mask1=0x00000000L;
91 }
92
93 iv = &(*ivec)[0]; 83 iv = &(*ivec)[0];
94 c2l(iv,v0); 84 c2l(iv,v0);
95 c2l(iv,v1); 85 c2l(iv,v1);
@@ -103,8 +93,8 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
103 DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); 93 DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
104 c2ln(in,d0,d1,n); 94 c2ln(in,d0,d1,n);
105 in+=n; 95 in+=n;
106 d0=(d0^ti[0])&mask0; 96 d0^=ti[0];
107 d1=(d1^ti[1])&mask1; 97 d1^=ti[1];
108 l2cn(d0,d1,out,n); 98 l2cn(d0,d1,out,n);
109 out+=n; 99 out+=n;
110 /* 30-08-94 - eay - changed because l>>32 and 100 /* 30-08-94 - eay - changed because l>>32 and
@@ -113,15 +103,25 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
113 { v0=v1; v1=d0; } 103 { v0=v1; v1=d0; }
114 else if (num == 64) 104 else if (num == 64)
115 { v0=d0; v1=d1; } 105 { v0=d0; v1=d1; }
116 else if (num > 32) /* && num != 64 */ 106 else
117 {
118 v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffffL;
119 v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffffL;
120 }
121 else /* num < 32 */
122 { 107 {
123 v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL; 108 iv=&ovec[0];
124 v1=((v1>>num)|(d0<<(32-num)))&0xffffffffL; 109 l2c(v0,iv);
110 l2c(v1,iv);
111 l2c(d0,iv);
112 l2c(d1,iv);
113 /* shift ovec left most of the bits... */
114 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
115 /* now the remaining bits */
116 if(num%8 != 0)
117 for(n=0 ; n < 8 ; ++n)
118 {
119 ovec[n]<<=num%8;
120 ovec[n]|=ovec[n+1]>>(8-num%8);
121 }
122 iv=&ovec[0];
123 c2l(iv,v0);
124 c2l(iv,v1);
125 } 125 }
126 } 126 }
127 } 127 }
@@ -141,18 +141,28 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
141 { v0=v1; v1=d0; } 141 { v0=v1; v1=d0; }
142 else if (num == 64) 142 else if (num == 64)
143 { v0=d0; v1=d1; } 143 { v0=d0; v1=d1; }
144 else if (num > 32) /* && num != 64 */ 144 else
145 {
146 v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffffL;
147 v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffffL;
148 }
149 else /* num < 32 */
150 { 145 {
151 v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL; 146 iv=&ovec[0];
152 v1=((v1>>num)|(d0<<(32-num)))&0xffffffffL; 147 l2c(v0,iv);
148 l2c(v1,iv);
149 l2c(d0,iv);
150 l2c(d1,iv);
151 /* shift ovec left most of the bits... */
152 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
153 /* now the remaining bits */
154 if(num%8 != 0)
155 for(n=0 ; n < 8 ; ++n)
156 {
157 ovec[n]<<=num%8;
158 ovec[n]|=ovec[n+1]>>(8-num%8);
159 }
160 iv=&ovec[0];
161 c2l(iv,v0);
162 c2l(iv,v1);
153 } 163 }
154 d0=(d0^ti[0])&mask0; 164 d0^=ti[0];
155 d1=(d1^ti[1])&mask1; 165 d1^=ti[1];
156 l2cn(d0,d1,out,n); 166 l2cn(d0,d1,out,n);
157 out+=n; 167 out+=n;
158 } 168 }
diff --git a/src/lib/libssl/src/crypto/des/destest.c b/src/lib/libssl/src/crypto/des/destest.c
index 687c00c792..3983ac8e5f 100644
--- a/src/lib/libssl/src/crypto/des/destest.c
+++ b/src/lib/libssl/src/crypto/des/destest.c
@@ -431,7 +431,7 @@ int main(int argc, char *argv[])
431 431
432#ifndef LIBDES_LIT 432#ifndef LIBDES_LIT
433 printf("Doing ede ecb\n"); 433 printf("Doing ede ecb\n");
434 for (i=0; i<(NUM_TESTS-1); i++) 434 for (i=0; i<(NUM_TESTS-2); i++)
435 { 435 {
436 DES_set_key_unchecked(&key_data[i],&ks); 436 DES_set_key_unchecked(&key_data[i],&ks);
437 DES_set_key_unchecked(&key_data[i+1],&ks2); 437 DES_set_key_unchecked(&key_data[i+1],&ks2);
diff --git a/src/lib/libssl/src/crypto/dso/dso_dlfcn.c b/src/lib/libssl/src/crypto/dso/dso_dlfcn.c
index 906b4703de..9d49ebc253 100644
--- a/src/lib/libssl/src/crypto/dso/dso_dlfcn.c
+++ b/src/lib/libssl/src/crypto/dso/dso_dlfcn.c
@@ -125,7 +125,11 @@ DSO_METHOD *DSO_METHOD_dlfcn(void)
125# endif 125# endif
126# endif 126# endif
127#else 127#else
128# define DLOPEN_FLAG RTLD_NOW /* Hope this works everywhere else */ 128# ifdef OPENSSL_SYS_SUNOS
129# define DLOPEN_FLAG 1
130# else
131# define DLOPEN_FLAG RTLD_NOW /* Hope this works everywhere else */
132# endif
129#endif 133#endif
130 134
131/* For this DSO_METHOD, our meth_data STACK will contain; 135/* For this DSO_METHOD, our meth_data STACK will contain;
diff --git a/src/lib/libssl/src/crypto/ec/ec_mult.c b/src/lib/libssl/src/crypto/ec/ec_mult.c
index 4dbc931120..16822a73cf 100644
--- a/src/lib/libssl/src/crypto/ec/ec_mult.c
+++ b/src/lib/libssl/src/crypto/ec/ec_mult.c
@@ -175,12 +175,13 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len, B
175 * (thus the boundaries should be increased) 175 * (thus the boundaries should be increased)
176 */ 176 */
177#define EC_window_bits_for_scalar_size(b) \ 177#define EC_window_bits_for_scalar_size(b) \
178 ((b) >= 2000 ? 6 : \ 178 ((size_t) \
179 (b) >= 800 ? 5 : \ 179 ((b) >= 2000 ? 6 : \
180 (b) >= 300 ? 4 : \ 180 (b) >= 800 ? 5 : \
181 (b) >= 70 ? 3 : \ 181 (b) >= 300 ? 4 : \
182 (b) >= 20 ? 2 : \ 182 (b) >= 70 ? 3 : \
183 1) 183 (b) >= 20 ? 2 : \
184 1))
184 185
185/* Compute 186/* Compute
186 * \sum scalars[i]*points[i], 187 * \sum scalars[i]*points[i],
diff --git a/src/lib/libssl/src/crypto/engine/engine.h b/src/lib/libssl/src/crypto/engine/engine.h
index 8686879e1a..9c3ab182d3 100644
--- a/src/lib/libssl/src/crypto/engine/engine.h
+++ b/src/lib/libssl/src/crypto/engine/engine.h
@@ -538,10 +538,10 @@ void ENGINE_add_conf_module(void);
538/**************************/ 538/**************************/
539 539
540/* Binary/behaviour compatibility levels */ 540/* Binary/behaviour compatibility levels */
541#define OSSL_DYNAMIC_VERSION (unsigned long)0x00010100 541#define OSSL_DYNAMIC_VERSION (unsigned long)0x00010200
542/* Binary versions older than this are too old for us (whether we're a loader or 542/* Binary versions older than this are too old for us (whether we're a loader or
543 * a loadee) */ 543 * a loadee) */
544#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00010100 544#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00010200
545 545
546/* When compiling an ENGINE entirely as an external shared library, loadable by 546/* When compiling an ENGINE entirely as an external shared library, loadable by
547 * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure 547 * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure
@@ -630,6 +630,10 @@ typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id,
630 if(!fn(e,id)) return 0; \ 630 if(!fn(e,id)) return 0; \
631 return 1; } 631 return 1; }
632 632
633#if defined(__OpenBSD__) || defined(__FreeBSD__)
634void ENGINE_setup_bsd_cryptodev(void);
635#endif
636
633/* BEGIN ERROR CODES */ 637/* BEGIN ERROR CODES */
634/* The following lines are auto generated by the script mkerr.pl. Any changes 638/* The following lines are auto generated by the script mkerr.pl. Any changes
635 * made after this point may be overwritten when the script is next run. 639 * made after this point may be overwritten when the script is next run.
diff --git a/src/lib/libssl/src/crypto/engine/hw_ubsec.c b/src/lib/libssl/src/crypto/engine/hw_ubsec.c
index 6286dd851c..5234a08a07 100644
--- a/src/lib/libssl/src/crypto/engine/hw_ubsec.c
+++ b/src/lib/libssl/src/crypto/engine/hw_ubsec.c
@@ -561,7 +561,6 @@ static int ubsec_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
561 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_BN_EXPAND_FAIL); 561 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_BN_EXPAND_FAIL);
562 return 0; 562 return 0;
563 } 563 }
564 memset(r->d, 0, BN_num_bytes(m));
565 564
566 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) { 565 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
567 fd = 0; 566 fd = 0;
diff --git a/src/lib/libssl/src/crypto/err/err.c b/src/lib/libssl/src/crypto/err/err.c
index b873270c04..633a1addfe 100644
--- a/src/lib/libssl/src/crypto/err/err.c
+++ b/src/lib/libssl/src/crypto/err/err.c
@@ -225,6 +225,7 @@ struct st_ERR_FNS
225 ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *); 225 ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *);
226 /* Works on the "thread_hash" error-state table */ 226 /* Works on the "thread_hash" error-state table */
227 LHASH *(*cb_thread_get)(int create); 227 LHASH *(*cb_thread_get)(int create);
228 void (*cb_thread_release)(LHASH **hash);
228 ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *); 229 ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *);
229 ERR_STATE *(*cb_thread_set_item)(ERR_STATE *); 230 ERR_STATE *(*cb_thread_set_item)(ERR_STATE *);
230 void (*cb_thread_del_item)(const ERR_STATE *); 231 void (*cb_thread_del_item)(const ERR_STATE *);
@@ -239,6 +240,7 @@ static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
239static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *); 240static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *);
240static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *); 241static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *);
241static LHASH *int_thread_get(int create); 242static LHASH *int_thread_get(int create);
243static void int_thread_release(LHASH **hash);
242static ERR_STATE *int_thread_get_item(const ERR_STATE *); 244static ERR_STATE *int_thread_get_item(const ERR_STATE *);
243static ERR_STATE *int_thread_set_item(ERR_STATE *); 245static ERR_STATE *int_thread_set_item(ERR_STATE *);
244static void int_thread_del_item(const ERR_STATE *); 246static void int_thread_del_item(const ERR_STATE *);
@@ -252,6 +254,7 @@ static const ERR_FNS err_defaults =
252 int_err_set_item, 254 int_err_set_item,
253 int_err_del_item, 255 int_err_del_item,
254 int_thread_get, 256 int_thread_get,
257 int_thread_release,
255 int_thread_get_item, 258 int_thread_get_item,
256 int_thread_set_item, 259 int_thread_set_item,
257 int_thread_del_item, 260 int_thread_del_item,
@@ -271,6 +274,7 @@ static const ERR_FNS *err_fns = NULL;
271 * and state in the loading application. */ 274 * and state in the loading application. */
272static LHASH *int_error_hash = NULL; 275static LHASH *int_error_hash = NULL;
273static LHASH *int_thread_hash = NULL; 276static LHASH *int_thread_hash = NULL;
277static int int_thread_hash_references = 0;
274static int int_err_library_number= ERR_LIB_USER; 278static int int_err_library_number= ERR_LIB_USER;
275 279
276/* Internal function that checks whether "err_fns" is set and if not, sets it to 280/* Internal function that checks whether "err_fns" is set and if not, sets it to
@@ -417,11 +421,37 @@ static LHASH *int_thread_get(int create)
417 CRYPTO_pop_info(); 421 CRYPTO_pop_info();
418 } 422 }
419 if (int_thread_hash) 423 if (int_thread_hash)
424 {
425 int_thread_hash_references++;
420 ret = int_thread_hash; 426 ret = int_thread_hash;
427 }
421 CRYPTO_w_unlock(CRYPTO_LOCK_ERR); 428 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
422 return ret; 429 return ret;
423 } 430 }
424 431
432static void int_thread_release(LHASH **hash)
433 {
434 int i;
435
436 if (hash == NULL || *hash == NULL)
437 return;
438
439 i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR);
440
441#ifdef REF_PRINT
442 fprintf(stderr,"%4d:%s\n",int_thread_hash_references,"ERR");
443#endif
444 if (i > 0) return;
445#ifdef REF_CHECK
446 if (i < 0)
447 {
448 fprintf(stderr,"int_thread_release, bad reference count\n");
449 abort(); /* ok */
450 }
451#endif
452 *hash = NULL;
453 }
454
425static ERR_STATE *int_thread_get_item(const ERR_STATE *d) 455static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
426 { 456 {
427 ERR_STATE *p; 457 ERR_STATE *p;
@@ -436,6 +466,7 @@ static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
436 p = (ERR_STATE *)lh_retrieve(hash, d); 466 p = (ERR_STATE *)lh_retrieve(hash, d);
437 CRYPTO_r_unlock(CRYPTO_LOCK_ERR); 467 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
438 468
469 ERRFN(thread_release)(&hash);
439 return p; 470 return p;
440 } 471 }
441 472
@@ -453,6 +484,7 @@ static ERR_STATE *int_thread_set_item(ERR_STATE *d)
453 p = (ERR_STATE *)lh_insert(hash, d); 484 p = (ERR_STATE *)lh_insert(hash, d);
454 CRYPTO_w_unlock(CRYPTO_LOCK_ERR); 485 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
455 486
487 ERRFN(thread_release)(&hash);
456 return p; 488 return p;
457 } 489 }
458 490
@@ -469,13 +501,15 @@ static void int_thread_del_item(const ERR_STATE *d)
469 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 501 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
470 p = (ERR_STATE *)lh_delete(hash, d); 502 p = (ERR_STATE *)lh_delete(hash, d);
471 /* make sure we don't leak memory */ 503 /* make sure we don't leak memory */
472 if (int_thread_hash && (lh_num_items(int_thread_hash) == 0)) 504 if (int_thread_hash_references == 1
505 && int_thread_hash && (lh_num_items(int_thread_hash) == 0))
473 { 506 {
474 lh_free(int_thread_hash); 507 lh_free(int_thread_hash);
475 int_thread_hash = NULL; 508 int_thread_hash = NULL;
476 } 509 }
477 CRYPTO_w_unlock(CRYPTO_LOCK_ERR); 510 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
478 511
512 ERRFN(thread_release)(&hash);
479 if (p) 513 if (p)
480 ERR_STATE_free(p); 514 ERR_STATE_free(p);
481 } 515 }
@@ -845,6 +879,12 @@ LHASH *ERR_get_err_state_table(void)
845 return ERRFN(thread_get)(0); 879 return ERRFN(thread_get)(0);
846 } 880 }
847 881
882void ERR_release_err_state_table(LHASH **hash)
883 {
884 err_fns_check();
885 ERRFN(thread_release)(hash);
886 }
887
848const char *ERR_lib_error_string(unsigned long e) 888const char *ERR_lib_error_string(unsigned long e)
849 { 889 {
850 ERR_STRING_DATA d,*p; 890 ERR_STRING_DATA d,*p;
diff --git a/src/lib/libssl/src/crypto/err/err.h b/src/lib/libssl/src/crypto/err/err.h
index 988ef81aa0..8faa3a7b4f 100644
--- a/src/lib/libssl/src/crypto/err/err.h
+++ b/src/lib/libssl/src/crypto/err/err.h
@@ -278,6 +278,7 @@ ERR_STATE *ERR_get_state(void);
278#ifndef OPENSSL_NO_LHASH 278#ifndef OPENSSL_NO_LHASH
279LHASH *ERR_get_string_table(void); 279LHASH *ERR_get_string_table(void);
280LHASH *ERR_get_err_state_table(void); 280LHASH *ERR_get_err_state_table(void);
281void ERR_release_err_state_table(LHASH **hash);
281#endif 282#endif
282 283
283int ERR_get_next_error_library(void); 284int ERR_get_next_error_library(void);
diff --git a/src/lib/libssl/src/crypto/evp/bio_b64.c b/src/lib/libssl/src/crypto/evp/bio_b64.c
index 6e550f6a43..33349c2f98 100644
--- a/src/lib/libssl/src/crypto/evp/bio_b64.c
+++ b/src/lib/libssl/src/crypto/evp/bio_b64.c
@@ -184,7 +184,9 @@ static int b64_read(BIO *b, char *out, int outl)
184 ret_code=0; 184 ret_code=0;
185 while (outl > 0) 185 while (outl > 0)
186 { 186 {
187 if (ctx->cont <= 0) break; 187
188 if (ctx->cont <= 0)
189 break;
188 190
189 i=BIO_read(b->next_bio,&(ctx->tmp[ctx->tmp_len]), 191 i=BIO_read(b->next_bio,&(ctx->tmp[ctx->tmp_len]),
190 B64_BLOCK_SIZE-ctx->tmp_len); 192 B64_BLOCK_SIZE-ctx->tmp_len);
@@ -195,11 +197,21 @@ static int b64_read(BIO *b, char *out, int outl)
195 197
196 /* Should be continue next time we are called? */ 198 /* Should be continue next time we are called? */
197 if (!BIO_should_retry(b->next_bio)) 199 if (!BIO_should_retry(b->next_bio))
200 {
198 ctx->cont=i; 201 ctx->cont=i;
199 /* else we should continue when called again */ 202 /* If buffer empty break */
200 break; 203 if(ctx->tmp_len == 0)
204 break;
205 /* Fall through and process what we have */
206 else
207 i = 0;
208 }
209 /* else we retry and add more data to buffer */
210 else
211 break;
201 } 212 }
202 i+=ctx->tmp_len; 213 i+=ctx->tmp_len;
214 ctx->tmp_len = i;
203 215
204 /* We need to scan, a line at a time until we 216 /* We need to scan, a line at a time until we
205 * have a valid line if we are starting. */ 217 * have a valid line if we are starting. */
@@ -255,8 +267,12 @@ static int b64_read(BIO *b, char *out, int outl)
255 * reading until a new line. */ 267 * reading until a new line. */
256 if (p == (unsigned char *)&(ctx->tmp[0])) 268 if (p == (unsigned char *)&(ctx->tmp[0]))
257 { 269 {
258 ctx->tmp_nl=1; 270 /* Check buffer full */
259 ctx->tmp_len=0; 271 if (i == B64_BLOCK_SIZE)
272 {
273 ctx->tmp_nl=1;
274 ctx->tmp_len=0;
275 }
260 } 276 }
261 else if (p != q) /* finished on a '\n' */ 277 else if (p != q) /* finished on a '\n' */
262 { 278 {
@@ -271,6 +287,11 @@ static int b64_read(BIO *b, char *out, int outl)
271 else 287 else
272 ctx->tmp_len=0; 288 ctx->tmp_len=0;
273 } 289 }
290 /* If buffer isn't full and we can retry then
291 * restart to read in more data.
292 */
293 else if ((i < B64_BLOCK_SIZE) && (ctx->cont > 0))
294 continue;
274 295
275 if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) 296 if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)
276 { 297 {
@@ -310,8 +331,8 @@ static int b64_read(BIO *b, char *out, int outl)
310 i=EVP_DecodeUpdate(&(ctx->base64), 331 i=EVP_DecodeUpdate(&(ctx->base64),
311 (unsigned char *)ctx->buf,&ctx->buf_len, 332 (unsigned char *)ctx->buf,&ctx->buf_len,
312 (unsigned char *)ctx->tmp,i); 333 (unsigned char *)ctx->tmp,i);
334 ctx->tmp_len = 0;
313 } 335 }
314 ctx->cont=i;
315 ctx->buf_off=0; 336 ctx->buf_off=0;
316 if (i < 0) 337 if (i < 0)
317 { 338 {
@@ -484,10 +505,7 @@ again:
484 { 505 {
485 i=b64_write(b,NULL,0); 506 i=b64_write(b,NULL,0);
486 if (i < 0) 507 if (i < 0)
487 { 508 return i;
488 ret=i;
489 break;
490 }
491 } 509 }
492 if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) 510 if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)
493 { 511 {
diff --git a/src/lib/libssl/src/crypto/evp/c_all.c b/src/lib/libssl/src/crypto/evp/c_all.c
index 1b31a14e37..fa60a73ead 100644
--- a/src/lib/libssl/src/crypto/evp/c_all.c
+++ b/src/lib/libssl/src/crypto/evp/c_all.c
@@ -59,6 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#ifndef OPENSSL_NO_ENGINE
63#include <openssl/engine.h>
64#endif
62 65
63#if 0 66#if 0
64#undef OpenSSL_add_all_algorithms 67#undef OpenSSL_add_all_algorithms
diff --git a/src/lib/libssl/src/crypto/idea/ideatest.c b/src/lib/libssl/src/crypto/idea/ideatest.c
new file mode 100644
index 0000000000..98f805d72a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/idea/ideatest.c
@@ -0,0 +1,232 @@
1/* crypto/idea/ideatest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <string.h>
61#include <stdlib.h>
62
63#include "../e_os.h"
64
65#ifdef OPENSSL_NO_IDEA
66int main(int argc, char *argv[])
67{
68 printf("No IDEA support\n");
69 return(0);
70}
71#else
72#include <openssl/idea.h>
73
74unsigned char k[16]={
75 0x00,0x01,0x00,0x02,0x00,0x03,0x00,0x04,
76 0x00,0x05,0x00,0x06,0x00,0x07,0x00,0x08};
77
78unsigned char in[8]={0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x03};
79unsigned char c[8]={0x11,0xFB,0xED,0x2B,0x01,0x98,0x6D,0xE5};
80unsigned char out[80];
81
82char *text="Hello to all people out there";
83
84static unsigned char cfb_key[16]={
85 0xe1,0xf0,0xc3,0xd2,0xa5,0xb4,0x87,0x96,
86 0x69,0x78,0x4b,0x5a,0x2d,0x3c,0x0f,0x1e,
87 };
88static unsigned char cfb_iv[80]={0x34,0x12,0x78,0x56,0xab,0x90,0xef,0xcd};
89static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8];
90#define CFB_TEST_SIZE 24
91static unsigned char plain[CFB_TEST_SIZE]=
92 {
93 0x4e,0x6f,0x77,0x20,0x69,0x73,
94 0x20,0x74,0x68,0x65,0x20,0x74,
95 0x69,0x6d,0x65,0x20,0x66,0x6f,
96 0x72,0x20,0x61,0x6c,0x6c,0x20
97 };
98static unsigned char cfb_cipher64[CFB_TEST_SIZE]={
99 0x59,0xD8,0xE2,0x65,0x00,0x58,0x6C,0x3F,
100 0x2C,0x17,0x25,0xD0,0x1A,0x38,0xB7,0x2A,
101 0x39,0x61,0x37,0xDC,0x79,0xFB,0x9F,0x45
102
103/* 0xF9,0x78,0x32,0xB5,0x42,0x1A,0x6B,0x38,
104 0x9A,0x44,0xD6,0x04,0x19,0x43,0xC4,0xD9,
105 0x3D,0x1E,0xAE,0x47,0xFC,0xCF,0x29,0x0B,*/
106 };
107
108static int cfb64_test(unsigned char *cfb_cipher);
109static char *pt(unsigned char *p);
110int main(int argc, char *argv[])
111 {
112 int i,err=0;
113 IDEA_KEY_SCHEDULE key,dkey;
114 unsigned char iv[8];
115
116 idea_set_encrypt_key(k,&key);
117 idea_ecb_encrypt(in,out,&key);
118 if (memcmp(out,c,8) != 0)
119 {
120 printf("ecb idea error encrypting\n");
121 printf("got :");
122 for (i=0; i<8; i++)
123 printf("%02X ",out[i]);
124 printf("\n");
125 printf("expected:");
126 for (i=0; i<8; i++)
127 printf("%02X ",c[i]);
128 err=20;
129 printf("\n");
130 }
131
132 idea_set_decrypt_key(&key,&dkey);
133 idea_ecb_encrypt(c,out,&dkey);
134 if (memcmp(out,in,8) != 0)
135 {
136 printf("ecb idea error decrypting\n");
137 printf("got :");
138 for (i=0; i<8; i++)
139 printf("%02X ",out[i]);
140 printf("\n");
141 printf("expected:");
142 for (i=0; i<8; i++)
143 printf("%02X ",in[i]);
144 printf("\n");
145 err=3;
146 }
147
148 if (err == 0) printf("ecb idea ok\n");
149
150 memcpy(iv,k,8);
151 idea_cbc_encrypt((unsigned char *)text,out,strlen(text)+1,&key,iv,1);
152 memcpy(iv,k,8);
153 idea_cbc_encrypt(out,out,8,&dkey,iv,0);
154 idea_cbc_encrypt(&(out[8]),&(out[8]),strlen(text)+1-8,&dkey,iv,0);
155 if (memcmp(text,out,strlen(text)+1) != 0)
156 {
157 printf("cbc idea bad\n");
158 err=4;
159 }
160 else
161 printf("cbc idea ok\n");
162
163 printf("cfb64 idea ");
164 if (cfb64_test(cfb_cipher64))
165 {
166 printf("bad\n");
167 err=5;
168 }
169 else
170 printf("ok\n");
171
172 EXIT(err);
173 return(err);
174 }
175
176static int cfb64_test(unsigned char *cfb_cipher)
177 {
178 IDEA_KEY_SCHEDULE eks,dks;
179 int err=0,i,n;
180
181 idea_set_encrypt_key(cfb_key,&eks);
182 idea_set_decrypt_key(&eks,&dks);
183 memcpy(cfb_tmp,cfb_iv,8);
184 n=0;
185 idea_cfb64_encrypt(plain,cfb_buf1,(long)12,&eks,
186 cfb_tmp,&n,IDEA_ENCRYPT);
187 idea_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
188 (long)CFB_TEST_SIZE-12,&eks,
189 cfb_tmp,&n,IDEA_ENCRYPT);
190 if (memcmp(cfb_cipher,cfb_buf1,CFB_TEST_SIZE) != 0)
191 {
192 err=1;
193 printf("idea_cfb64_encrypt encrypt error\n");
194 for (i=0; i<CFB_TEST_SIZE; i+=8)
195 printf("%s\n",pt(&(cfb_buf1[i])));
196 }
197 memcpy(cfb_tmp,cfb_iv,8);
198 n=0;
199 idea_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,&eks,
200 cfb_tmp,&n,IDEA_DECRYPT);
201 idea_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
202 (long)CFB_TEST_SIZE-17,&dks,
203 cfb_tmp,&n,IDEA_DECRYPT);
204 if (memcmp(plain,cfb_buf2,CFB_TEST_SIZE) != 0)
205 {
206 err=1;
207 printf("idea_cfb_encrypt decrypt error\n");
208 for (i=0; i<24; i+=8)
209 printf("%s\n",pt(&(cfb_buf2[i])));
210 }
211 return(err);
212 }
213
214static char *pt(unsigned char *p)
215 {
216 static char bufs[10][20];
217 static int bnum=0;
218 char *ret;
219 int i;
220 static char *f="0123456789ABCDEF";
221
222 ret= &(bufs[bnum++][0]);
223 bnum%=10;
224 for (i=0; i<8; i++)
225 {
226 ret[i*2]=f[(p[i]>>4)&0xf];
227 ret[i*2+1]=f[p[i]&0xf];
228 }
229 ret[16]='\0';
230 return(ret);
231 }
232#endif
diff --git a/src/lib/libssl/src/crypto/md2/md2test.c b/src/lib/libssl/src/crypto/md2/md2test.c
index 901d0a7d8e..9c1e28b6ce 100644
--- a/src/lib/libssl/src/crypto/md2/md2test.c
+++ b/src/lib/libssl/src/crypto/md2/md2test.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#include <openssl/md2.h>
63 62
64#include "../e_os.h" 63#include "../e_os.h"
65 64
@@ -71,6 +70,7 @@ int main(int argc, char *argv[])
71} 70}
72#else 71#else
73#include <openssl/evp.h> 72#include <openssl/evp.h>
73#include <openssl/md2.h>
74 74
75#ifdef CHARSET_EBCDIC 75#ifdef CHARSET_EBCDIC
76#include <openssl/ebcdic.h> 76#include <openssl/ebcdic.h>
diff --git a/src/lib/libssl/src/crypto/md5/asm/md5-586.pl b/src/lib/libssl/src/crypto/md5/asm/md5-586.pl
index 5fc6a205ce..fa3fa3bed5 100644
--- a/src/lib/libssl/src/crypto/md5/asm/md5-586.pl
+++ b/src/lib/libssl/src/crypto/md5/asm/md5-586.pl
@@ -293,7 +293,7 @@ sub md5_block
293 &mov(&DWP(12,$tmp2,"",0),$D); 293 &mov(&DWP(12,$tmp2,"",0),$D);
294 294
295 &cmp($tmp1,$X) unless $normal; # check count 295 &cmp($tmp1,$X) unless $normal; # check count
296 &jge(&label("start")) unless $normal; 296 &jae(&label("start")) unless $normal;
297 297
298 &pop("eax"); # pop the temp variable off the stack 298 &pop("eax"); # pop the temp variable off the stack
299 &pop("ebx"); 299 &pop("ebx");
diff --git a/src/lib/libssl/src/crypto/md5/asm/md5-sparcv9.S b/src/lib/libssl/src/crypto/md5/asm/md5-sparcv9.S
index a599ed5660..db45aa4c97 100644
--- a/src/lib/libssl/src/crypto/md5/asm/md5-sparcv9.S
+++ b/src/lib/libssl/src/crypto/md5/asm/md5-sparcv9.S
@@ -34,10 +34,12 @@
34 * 34 *
35 * or if above fails (it does if you have gas): 35 * or if above fails (it does if you have gas):
36 * 36 *
37 * gcc -E -DULTRASPARC -DMD5_BLOCK_DATA_ORDER md5_block.sparc.S | \ 37 * gcc -E -DOPENSSL_SYSNAMEULTRASPARC -DMD5_BLOCK_DATA_ORDER md5_block.sparc.S | \
38 * as -xarch=v8plus /dev/fd/0 -o md5-sparcv9.o 38 * as -xarch=v8plus /dev/fd/0 -o md5-sparcv9.o
39 */ 39 */
40 40
41#include <openssl/e_os2.h>
42
41#define A %o0 43#define A %o0
42#define B %o1 44#define B %o1
43#define C %o2 45#define C %o2
diff --git a/src/lib/libssl/src/crypto/o_time.c b/src/lib/libssl/src/crypto/o_time.c
index 723eb1b5af..785468131e 100644
--- a/src/lib/libssl/src/crypto/o_time.c
+++ b/src/lib/libssl/src/crypto/o_time.c
@@ -73,7 +73,7 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
73 { 73 {
74 struct tm *ts = NULL; 74 struct tm *ts = NULL;
75 75
76#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX) 76#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_SUNOS)
77 /* should return &data, but doesn't on some systems, 77 /* should return &data, but doesn't on some systems,
78 so we don't even look at the return value */ 78 so we don't even look at the return value */
79 gmtime_r(timer,result); 79 gmtime_r(timer,result);
diff --git a/src/lib/libssl/src/crypto/opensslv.h b/src/lib/libssl/src/crypto/opensslv.h
index 08cb1d5018..e226d9de79 100644
--- a/src/lib/libssl/src/crypto/opensslv.h
+++ b/src/lib/libssl/src/crypto/opensslv.h
@@ -25,8 +25,8 @@
25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for 25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
26 * major minor fix final patch/beta) 26 * major minor fix final patch/beta)
27 */ 27 */
28#define OPENSSL_VERSION_NUMBER 0x0090702fL 28#define OPENSSL_VERSION_NUMBER 0x0090703fL
29#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7b 10 Apr 2003" 29#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7c 30 Sep 2003"
30#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 30#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
31 31
32 32
diff --git a/src/lib/libssl/src/crypto/perlasm/x86ms.pl b/src/lib/libssl/src/crypto/perlasm/x86ms.pl
index 35f1a4ddb9..fbb4afb9bd 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86ms.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86ms.pl
@@ -144,7 +144,10 @@ sub main'jle { &out1("jle",@_); }
144sub main'jz { &out1("jz",@_); } 144sub main'jz { &out1("jz",@_); }
145sub main'jge { &out1("jge",@_); } 145sub main'jge { &out1("jge",@_); }
146sub main'jl { &out1("jl",@_); } 146sub main'jl { &out1("jl",@_); }
147sub main'ja { &out1("ja",@_); }
148sub main'jae { &out1("jae",@_); }
147sub main'jb { &out1("jb",@_); } 149sub main'jb { &out1("jb",@_); }
150sub main'jbe { &out1("jbe",@_); }
148sub main'jc { &out1("jc",@_); } 151sub main'jc { &out1("jc",@_); }
149sub main'jnc { &out1("jnc",@_); } 152sub main'jnc { &out1("jnc",@_); }
150sub main'jnz { &out1("jnz",@_); } 153sub main'jnz { &out1("jnz",@_); }
diff --git a/src/lib/libssl/src/crypto/perlasm/x86nasm.pl b/src/lib/libssl/src/crypto/perlasm/x86nasm.pl
index f30b7466d4..30346af4ea 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86nasm.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86nasm.pl
@@ -152,7 +152,10 @@ sub main'jle { &out1("jle NEAR",@_); }
152sub main'jz { &out1("jz NEAR",@_); } 152sub main'jz { &out1("jz NEAR",@_); }
153sub main'jge { &out1("jge NEAR",@_); } 153sub main'jge { &out1("jge NEAR",@_); }
154sub main'jl { &out1("jl NEAR",@_); } 154sub main'jl { &out1("jl NEAR",@_); }
155sub main'ja { &out1("ja NEAR",@_); }
156sub main'jae { &out1("jae NEAR",@_); }
155sub main'jb { &out1("jb NEAR",@_); } 157sub main'jb { &out1("jb NEAR",@_); }
158sub main'jbe { &out1("jbe NEAR",@_); }
156sub main'jc { &out1("jc NEAR",@_); } 159sub main'jc { &out1("jc NEAR",@_); }
157sub main'jnc { &out1("jnc NEAR",@_); } 160sub main'jnc { &out1("jnc NEAR",@_); }
158sub main'jnz { &out1("jnz NEAR",@_); } 161sub main'jnz { &out1("jnz NEAR",@_); }
diff --git a/src/lib/libssl/src/crypto/perlasm/x86unix.pl b/src/lib/libssl/src/crypto/perlasm/x86unix.pl
index 72bde061c5..10b669bf04 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86unix.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86unix.pl
@@ -156,7 +156,10 @@ sub main'jnz { &out1("jnz",@_); }
156sub main'jz { &out1("jz",@_); } 156sub main'jz { &out1("jz",@_); }
157sub main'jge { &out1("jge",@_); } 157sub main'jge { &out1("jge",@_); }
158sub main'jl { &out1("jl",@_); } 158sub main'jl { &out1("jl",@_); }
159sub main'ja { &out1("ja",@_); }
160sub main'jae { &out1("jae",@_); }
159sub main'jb { &out1("jb",@_); } 161sub main'jb { &out1("jb",@_); }
162sub main'jbe { &out1("jbe",@_); }
160sub main'jc { &out1("jc",@_); } 163sub main'jc { &out1("jc",@_); }
161sub main'jnc { &out1("jnc",@_); } 164sub main'jnc { &out1("jnc",@_); }
162sub main'jno { &out1("jno",@_); } 165sub main'jno { &out1("jno",@_); }
diff --git a/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c b/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
index 0060a2ea3d..190ca0e9bf 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
+++ b/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
@@ -767,6 +767,11 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
767 } 767 }
768 if (EVP_MD_CTX_type(mdc) == md_type) 768 if (EVP_MD_CTX_type(mdc) == md_type)
769 break; 769 break;
770 /* Workaround for some broken clients that put the signature
771 * OID instead of the digest OID in digest_alg->algorithm
772 */
773 if (EVP_MD_pkey_type(EVP_MD_CTX_md(mdc)) == md_type)
774 break;
770 btmp=BIO_next(btmp); 775 btmp=BIO_next(btmp);
771 } 776 }
772 777
diff --git a/src/lib/libssl/src/crypto/pkcs7/pk7_mime.c b/src/lib/libssl/src/crypto/pkcs7/pk7_mime.c
index 086d394270..5d2a97839d 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_mime.c
+++ b/src/lib/libssl/src/crypto/pkcs7/pk7_mime.c
@@ -3,7 +3,7 @@
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -101,7 +101,7 @@ static int mime_param_cmp(const MIME_PARAM * const *a,
101static void mime_param_free(MIME_PARAM *param); 101static void mime_param_free(MIME_PARAM *param);
102static int mime_bound_check(char *line, int linelen, char *bound, int blen); 102static int mime_bound_check(char *line, int linelen, char *bound, int blen);
103static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret); 103static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret);
104static int iscrlf(char c); 104static int strip_eol(char *linebuf, int *plen);
105static MIME_HEADER *mime_hdr_find(STACK_OF(MIME_HEADER) *hdrs, char *name); 105static MIME_HEADER *mime_hdr_find(STACK_OF(MIME_HEADER) *hdrs, char *name);
106static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name); 106static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name);
107static void mime_hdr_free(MIME_HEADER *hdr); 107static void mime_hdr_free(MIME_HEADER *hdr);
@@ -150,9 +150,17 @@ static PKCS7 *B64_read_PKCS7(BIO *bio)
150 150
151int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) 151int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
152{ 152{
153 char linebuf[MAX_SMLEN];
154 char bound[33], c; 153 char bound[33], c;
155 int i; 154 int i;
155 char *mime_prefix, *mime_eol;
156 if (flags & PKCS7_NOOLDMIMETYPE)
157 mime_prefix = "application/pkcs7-";
158 else
159 mime_prefix = "application/x-pkcs7-";
160 if (flags & PKCS7_CRLFEOL)
161 mime_eol = "\r\n";
162 else
163 mime_eol = "\n";
156 if((flags & PKCS7_DETACHED) && data) { 164 if((flags & PKCS7_DETACHED) && data) {
157 /* We want multipart/signed */ 165 /* We want multipart/signed */
158 /* Generate a random boundary */ 166 /* Generate a random boundary */
@@ -164,34 +172,42 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
164 bound[i] = c; 172 bound[i] = c;
165 } 173 }
166 bound[32] = 0; 174 bound[32] = 0;
167 BIO_printf(bio, "MIME-Version: 1.0\n"); 175 BIO_printf(bio, "MIME-Version: 1.0%s", mime_eol);
168 BIO_printf(bio, "Content-Type: multipart/signed;"); 176 BIO_printf(bio, "Content-Type: multipart/signed;");
169 BIO_printf(bio, " protocol=\"application/x-pkcs7-signature\";"); 177 BIO_printf(bio, " protocol=\"%ssignature\";", mime_prefix);
170 BIO_printf(bio, " micalg=sha1; boundary=\"----%s\"\n\n", bound); 178 BIO_printf(bio, " micalg=sha1; boundary=\"----%s\"%s%s",
171 BIO_printf(bio, "This is an S/MIME signed message\n\n"); 179 bound, mime_eol, mime_eol);
180 BIO_printf(bio, "This is an S/MIME signed message%s%s",
181 mime_eol, mime_eol);
172 /* Now write out the first part */ 182 /* Now write out the first part */
173 BIO_printf(bio, "------%s\n", bound); 183 BIO_printf(bio, "------%s%s", bound, mime_eol);
174 if(flags & PKCS7_TEXT) BIO_printf(bio, "Content-Type: text/plain\n\n"); 184 SMIME_crlf_copy(data, bio, flags);
175 while((i = BIO_read(data, linebuf, MAX_SMLEN)) > 0) 185 BIO_printf(bio, "%s------%s%s", mime_eol, bound, mime_eol);
176 BIO_write(bio, linebuf, i);
177 BIO_printf(bio, "\n------%s\n", bound);
178 186
179 /* Headers for signature */ 187 /* Headers for signature */
180 188
181 BIO_printf(bio, "Content-Type: application/x-pkcs7-signature; name=\"smime.p7s\"\n"); 189 BIO_printf(bio, "Content-Type: %ssignature;", mime_prefix);
182 BIO_printf(bio, "Content-Transfer-Encoding: base64\n"); 190 BIO_printf(bio, " name=\"smime.p7s\"%s", mime_eol);
183 BIO_printf(bio, "Content-Disposition: attachment; filename=\"smime.p7s\"\n\n"); 191 BIO_printf(bio, "Content-Transfer-Encoding: base64%s",
192 mime_eol);
193 BIO_printf(bio, "Content-Disposition: attachment;");
194 BIO_printf(bio, " filename=\"smime.p7s\"%s%s",
195 mime_eol, mime_eol);
184 B64_write_PKCS7(bio, p7); 196 B64_write_PKCS7(bio, p7);
185 BIO_printf(bio,"\n------%s--\n\n", bound); 197 BIO_printf(bio,"%s------%s--%s%s", mime_eol, bound,
198 mime_eol, mime_eol);
186 return 1; 199 return 1;
187 } 200 }
188 /* MIME headers */ 201 /* MIME headers */
189 BIO_printf(bio, "MIME-Version: 1.0\n"); 202 BIO_printf(bio, "MIME-Version: 1.0%s", mime_eol);
190 BIO_printf(bio, "Content-Disposition: attachment; filename=\"smime.p7m\"\n"); 203 BIO_printf(bio, "Content-Disposition: attachment;");
191 BIO_printf(bio, "Content-Type: application/x-pkcs7-mime; name=\"smime.p7m\"\n"); 204 BIO_printf(bio, " filename=\"smime.p7m\"%s", mime_eol);
192 BIO_printf(bio, "Content-Transfer-Encoding: base64\n\n"); 205 BIO_printf(bio, "Content-Type: %smime;", mime_prefix);
206 BIO_printf(bio, " name=\"smime.p7m\"%s", mime_eol);
207 BIO_printf(bio, "Content-Transfer-Encoding: base64%s%s",
208 mime_eol, mime_eol);
193 B64_write_PKCS7(bio, p7); 209 B64_write_PKCS7(bio, p7);
194 BIO_printf(bio, "\n"); 210 BIO_printf(bio, "%s", mime_eol);
195 return 1; 211 return 1;
196} 212}
197 213
@@ -316,12 +332,9 @@ int SMIME_crlf_copy(BIO *in, BIO *out, int flags)
316 } 332 }
317 if(flags & PKCS7_TEXT) BIO_printf(out, "Content-Type: text/plain\r\n\r\n"); 333 if(flags & PKCS7_TEXT) BIO_printf(out, "Content-Type: text/plain\r\n\r\n");
318 while ((len = BIO_gets(in, linebuf, MAX_SMLEN)) > 0) { 334 while ((len = BIO_gets(in, linebuf, MAX_SMLEN)) > 0) {
319 eol = 0; 335 eol = strip_eol(linebuf, &len);
320 while(iscrlf(linebuf[len - 1])) { 336 if (len)
321 len--; 337 BIO_write(out, linebuf, len);
322 eol = 1;
323 }
324 BIO_write(out, linebuf, len);
325 if(eol) BIO_write(out, "\r\n", 2); 338 if(eol) BIO_write(out, "\r\n", 2);
326 } 339 }
327 return 1; 340 return 1;
@@ -364,6 +377,7 @@ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret)
364{ 377{
365 char linebuf[MAX_SMLEN]; 378 char linebuf[MAX_SMLEN];
366 int len, blen; 379 int len, blen;
380 int eol = 0, next_eol = 0;
367 BIO *bpart = NULL; 381 BIO *bpart = NULL;
368 STACK_OF(BIO) *parts; 382 STACK_OF(BIO) *parts;
369 char state, part, first; 383 char state, part, first;
@@ -383,26 +397,23 @@ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret)
383 sk_BIO_push(parts, bpart); 397 sk_BIO_push(parts, bpart);
384 return 1; 398 return 1;
385 } else if(part) { 399 } else if(part) {
400 /* Strip CR+LF from linebuf */
401 next_eol = strip_eol(linebuf, &len);
386 if(first) { 402 if(first) {
387 first = 0; 403 first = 0;
388 if(bpart) sk_BIO_push(parts, bpart); 404 if(bpart) sk_BIO_push(parts, bpart);
389 bpart = BIO_new(BIO_s_mem()); 405 bpart = BIO_new(BIO_s_mem());
390 406 BIO_set_mem_eof_return(bpart, 0);
391 } else BIO_write(bpart, "\r\n", 2); 407 } else if (eol)
392 /* Strip CR+LF from linebuf */ 408 BIO_write(bpart, "\r\n", 2);
393 while(iscrlf(linebuf[len - 1])) len--; 409 eol = next_eol;
394 BIO_write(bpart, linebuf, len); 410 if (len)
411 BIO_write(bpart, linebuf, len);
395 } 412 }
396 } 413 }
397 return 0; 414 return 0;
398} 415}
399 416
400static int iscrlf(char c)
401{
402 if(c == '\r' || c == '\n') return 1;
403 return 0;
404}
405
406/* This is the big one: parse MIME header lines up to message body */ 417/* This is the big one: parse MIME header lines up to message body */
407 418
408#define MIME_INVALID 0 419#define MIME_INVALID 0
@@ -683,3 +694,21 @@ static int mime_bound_check(char *line, int linelen, char *bound, int blen)
683 } 694 }
684 return 0; 695 return 0;
685} 696}
697
698static int strip_eol(char *linebuf, int *plen)
699 {
700 int len = *plen;
701 char *p, c;
702 int is_eol = 0;
703 p = linebuf + len - 1;
704 for (p = linebuf + len - 1; len > 0; len--, p--)
705 {
706 c = *p;
707 if (c == '\n')
708 is_eol = 1;
709 else if (c != '\r')
710 break;
711 }
712 *plen = len;
713 return is_eol;
714 }
diff --git a/src/lib/libssl/src/crypto/pkcs7/pk7_smime.c b/src/lib/libssl/src/crypto/pkcs7/pk7_smime.c
index f0d071e282..6e5735de11 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_smime.c
+++ b/src/lib/libssl/src/crypto/pkcs7/pk7_smime.c
@@ -3,7 +3,7 @@
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
diff --git a/src/lib/libssl/src/crypto/pkcs7/pkcs7.h b/src/lib/libssl/src/crypto/pkcs7/pkcs7.h
index 5819700a85..15372e18f8 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pkcs7.h
+++ b/src/lib/libssl/src/crypto/pkcs7/pkcs7.h
@@ -260,6 +260,8 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
260#define PKCS7_BINARY 0x80 260#define PKCS7_BINARY 0x80
261#define PKCS7_NOATTR 0x100 261#define PKCS7_NOATTR 0x100
262#define PKCS7_NOSMIMECAP 0x200 262#define PKCS7_NOSMIMECAP 0x200
263#define PKCS7_NOOLDMIMETYPE 0x400
264#define PKCS7_CRLFEOL 0x800
263 265
264/* Flags: for compatibility with older code */ 266/* Flags: for compatibility with older code */
265 267
diff --git a/src/lib/libssl/src/crypto/rand/rand_win.c b/src/lib/libssl/src/crypto/rand/rand_win.c
index 113b58678f..263068d256 100644
--- a/src/lib/libssl/src/crypto/rand/rand_win.c
+++ b/src/lib/libssl/src/crypto/rand/rand_win.c
@@ -162,6 +162,7 @@ typedef BOOL (WINAPI *GETCURSORINFO)(PCURSORINFO);
162typedef DWORD (WINAPI *GETQUEUESTATUS)(UINT); 162typedef DWORD (WINAPI *GETQUEUESTATUS)(UINT);
163 163
164typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD); 164typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD);
165typedef BOOL (WINAPI *CLOSETOOLHELP32SNAPSHOT)(HANDLE);
165typedef BOOL (WINAPI *HEAP32FIRST)(LPHEAPENTRY32, DWORD, DWORD); 166typedef BOOL (WINAPI *HEAP32FIRST)(LPHEAPENTRY32, DWORD, DWORD);
166typedef BOOL (WINAPI *HEAP32NEXT)(LPHEAPENTRY32); 167typedef BOOL (WINAPI *HEAP32NEXT)(LPHEAPENTRY32);
167typedef BOOL (WINAPI *HEAP32LIST)(HANDLE, LPHEAPLIST32); 168typedef BOOL (WINAPI *HEAP32LIST)(HANDLE, LPHEAPLIST32);
@@ -431,7 +432,7 @@ int RAND_poll(void)
431 * This seeding method was proposed in Peter Gutmann, Software 432 * This seeding method was proposed in Peter Gutmann, Software
432 * Generation of Practically Strong Random Numbers, 433 * Generation of Practically Strong Random Numbers,
433 * http://www.usenix.org/publications/library/proceedings/sec98/gutmann.html 434 * http://www.usenix.org/publications/library/proceedings/sec98/gutmann.html
434 * revised version at http://www.cryptoengines.com/~peter/06_random.pdf 435 * revised version at http://www.cryptoengines.com/~peter/06_random.pdf
435 * (The assignment of entropy estimates below is arbitrary, but based 436 * (The assignment of entropy estimates below is arbitrary, but based
436 * on Peter's analysis the full poll appears to be safe. Additional 437 * on Peter's analysis the full poll appears to be safe. Additional
437 * interactive seeding is encouraged.) 438 * interactive seeding is encouraged.)
@@ -440,6 +441,7 @@ int RAND_poll(void)
440 if (kernel) 441 if (kernel)
441 { 442 {
442 CREATETOOLHELP32SNAPSHOT snap; 443 CREATETOOLHELP32SNAPSHOT snap;
444 CLOSETOOLHELP32SNAPSHOT close_snap;
443 HANDLE handle; 445 HANDLE handle;
444 446
445 HEAP32FIRST heap_first; 447 HEAP32FIRST heap_first;
@@ -457,6 +459,8 @@ int RAND_poll(void)
457 459
458 snap = (CREATETOOLHELP32SNAPSHOT) 460 snap = (CREATETOOLHELP32SNAPSHOT)
459 GetProcAddress(kernel, TEXT("CreateToolhelp32Snapshot")); 461 GetProcAddress(kernel, TEXT("CreateToolhelp32Snapshot"));
462 close_snap = (CLOSETOOLHELP32SNAPSHOT)
463 GetProcAddress(kernel, TEXT("CloseToolhelp32Snapshot"));
460 heap_first = (HEAP32FIRST) GetProcAddress(kernel, TEXT("Heap32First")); 464 heap_first = (HEAP32FIRST) GetProcAddress(kernel, TEXT("Heap32First"));
461 heap_next = (HEAP32NEXT) GetProcAddress(kernel, TEXT("Heap32Next")); 465 heap_next = (HEAP32NEXT) GetProcAddress(kernel, TEXT("Heap32Next"));
462 heaplist_first = (HEAP32LIST) GetProcAddress(kernel, TEXT("Heap32ListFirst")); 466 heaplist_first = (HEAP32LIST) GetProcAddress(kernel, TEXT("Heap32ListFirst"));
@@ -472,7 +476,7 @@ int RAND_poll(void)
472 heaplist_next && process_first && process_next && 476 heaplist_next && process_first && process_next &&
473 thread_first && thread_next && module_first && 477 thread_first && thread_next && module_first &&
474 module_next && (handle = snap(TH32CS_SNAPALL,0)) 478 module_next && (handle = snap(TH32CS_SNAPALL,0))
475 != NULL) 479 != INVALID_HANDLE_VALUE)
476 { 480 {
477 /* heap list and heap walking */ 481 /* heap list and heap walking */
478 /* HEAPLIST32 contains 3 fields that will change with 482 /* HEAPLIST32 contains 3 fields that will change with
@@ -534,8 +538,10 @@ int RAND_poll(void)
534 do 538 do
535 RAND_add(&m, m.dwSize, 9); 539 RAND_add(&m, m.dwSize, 9);
536 while (module_next(handle, &m)); 540 while (module_next(handle, &m));
537 541 if (close_snap)
538 CloseHandle(handle); 542 close_snap(handle);
543 else
544 CloseHandle(handle);
539 } 545 }
540 546
541 FreeLibrary(kernel); 547 FreeLibrary(kernel);
diff --git a/src/lib/libssl/src/crypto/rc5/rc5test.c b/src/lib/libssl/src/crypto/rc5/rc5test.c
new file mode 100644
index 0000000000..ce3d0cc16f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/rc5test.c
@@ -0,0 +1,386 @@
1/* crypto/rc5/rc5test.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* This has been a quickly hacked 'ideatest.c'. When I add tests for other
60 * RC5 modes, more of the code will be uncommented. */
61
62#include <stdio.h>
63#include <string.h>
64#include <stdlib.h>
65
66#include "../e_os.h"
67
68#ifdef OPENSSL_NO_RC5
69int main(int argc, char *argv[])
70{
71 printf("No RC5 support\n");
72 return(0);
73}
74#else
75#include <openssl/rc5.h>
76
77static unsigned char RC5key[5][16]={
78 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
79 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
80 {0x91,0x5f,0x46,0x19,0xbe,0x41,0xb2,0x51,
81 0x63,0x55,0xa5,0x01,0x10,0xa9,0xce,0x91},
82 {0x78,0x33,0x48,0xe7,0x5a,0xeb,0x0f,0x2f,
83 0xd7,0xb1,0x69,0xbb,0x8d,0xc1,0x67,0x87},
84 {0xdc,0x49,0xdb,0x13,0x75,0xa5,0x58,0x4f,
85 0x64,0x85,0xb4,0x13,0xb5,0xf1,0x2b,0xaf},
86 {0x52,0x69,0xf1,0x49,0xd4,0x1b,0xa0,0x15,
87 0x24,0x97,0x57,0x4d,0x7f,0x15,0x31,0x25},
88 };
89
90static unsigned char RC5plain[5][8]={
91 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
92 {0x21,0xA5,0xDB,0xEE,0x15,0x4B,0x8F,0x6D},
93 {0xF7,0xC0,0x13,0xAC,0x5B,0x2B,0x89,0x52},
94 {0x2F,0x42,0xB3,0xB7,0x03,0x69,0xFC,0x92},
95 {0x65,0xC1,0x78,0xB2,0x84,0xD1,0x97,0xCC},
96 };
97
98static unsigned char RC5cipher[5][8]={
99 {0x21,0xA5,0xDB,0xEE,0x15,0x4B,0x8F,0x6D},
100 {0xF7,0xC0,0x13,0xAC,0x5B,0x2B,0x89,0x52},
101 {0x2F,0x42,0xB3,0xB7,0x03,0x69,0xFC,0x92},
102 {0x65,0xC1,0x78,0xB2,0x84,0xD1,0x97,0xCC},
103 {0xEB,0x44,0xE4,0x15,0xDA,0x31,0x98,0x24},
104 };
105
106#define RC5_CBC_NUM 27
107static unsigned char rc5_cbc_cipher[RC5_CBC_NUM][8]={
108 {0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1e},
109 {0x79,0x7b,0xba,0x4d,0x78,0x11,0x1d,0x1e},
110 {0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1f},
111 {0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1f},
112 {0x8b,0x9d,0xed,0x91,0xce,0x77,0x94,0xa6},
113 {0x2f,0x75,0x9f,0xe7,0xad,0x86,0xa3,0x78},
114 {0xdc,0xa2,0x69,0x4b,0xf4,0x0e,0x07,0x88},
115 {0xdc,0xa2,0x69,0x4b,0xf4,0x0e,0x07,0x88},
116 {0xdc,0xfe,0x09,0x85,0x77,0xec,0xa5,0xff},
117 {0x96,0x46,0xfb,0x77,0x63,0x8f,0x9c,0xa8},
118 {0xb2,0xb3,0x20,0x9d,0xb6,0x59,0x4d,0xa4},
119 {0x54,0x5f,0x7f,0x32,0xa5,0xfc,0x38,0x36},
120 {0x82,0x85,0xe7,0xc1,0xb5,0xbc,0x74,0x02},
121 {0xfc,0x58,0x6f,0x92,0xf7,0x08,0x09,0x34},
122 {0xcf,0x27,0x0e,0xf9,0x71,0x7f,0xf7,0xc4},
123 {0xe4,0x93,0xf1,0xc1,0xbb,0x4d,0x6e,0x8c},
124 {0x5c,0x4c,0x04,0x1e,0x0f,0x21,0x7a,0xc3},
125 {0x92,0x1f,0x12,0x48,0x53,0x73,0xb4,0xf7},
126 {0x5b,0xa0,0xca,0x6b,0xbe,0x7f,0x5f,0xad},
127 {0xc5,0x33,0x77,0x1c,0xd0,0x11,0x0e,0x63},
128 {0x29,0x4d,0xdb,0x46,0xb3,0x27,0x8d,0x60},
129 {0xda,0xd6,0xbd,0xa9,0xdf,0xe8,0xf7,0xe8},
130 {0x97,0xe0,0x78,0x78,0x37,0xed,0x31,0x7f},
131 {0x78,0x75,0xdb,0xf6,0x73,0x8c,0x64,0x78},
132 {0x8f,0x34,0xc3,0xc6,0x81,0xc9,0x96,0x95},
133 {0x7c,0xb3,0xf1,0xdf,0x34,0xf9,0x48,0x11},
134 {0x7f,0xd1,0xa0,0x23,0xa5,0xbb,0xa2,0x17},
135 };
136
137static unsigned char rc5_cbc_key[RC5_CBC_NUM][17]={
138 { 1,0x00},
139 { 1,0x00},
140 { 1,0x00},
141 { 1,0x00},
142 { 1,0x00},
143 { 1,0x11},
144 { 1,0x00},
145 { 4,0x00,0x00,0x00,0x00},
146 { 1,0x00},
147 { 1,0x00},
148 { 1,0x00},
149 { 1,0x00},
150 { 4,0x01,0x02,0x03,0x04},
151 { 4,0x01,0x02,0x03,0x04},
152 { 4,0x01,0x02,0x03,0x04},
153 { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
154 { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
155 { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
156 { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
157 {16,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
158 0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
159 {16,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
160 0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
161 {16,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
162 0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
163 { 5,0x01,0x02,0x03,0x04,0x05},
164 { 5,0x01,0x02,0x03,0x04,0x05},
165 { 5,0x01,0x02,0x03,0x04,0x05},
166 { 5,0x01,0x02,0x03,0x04,0x05},
167 { 5,0x01,0x02,0x03,0x04,0x05},
168 };
169
170static unsigned char rc5_cbc_plain[RC5_CBC_NUM][8]={
171 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
172 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
173 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
174 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
175 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
176 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
177 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
178 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
179 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
180 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
181 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
182 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
183 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
184 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
185 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
186 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
187 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
188 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
189 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
190 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
191 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
192 {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80},
193 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
194 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
195 {0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08},
196 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
197 {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x01},
198 };
199
200static int rc5_cbc_rounds[RC5_CBC_NUM]={
201 0, 0, 0, 0, 0, 1, 2, 2,
202 8, 8,12,16, 8,12,16,12,
203 8,12,16, 8,12,16,12, 8,
204 8, 8, 8,
205 };
206
207static unsigned char rc5_cbc_iv[RC5_CBC_NUM][8]={
208 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
209 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
210 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
211 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
212 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
213 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
214 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
215 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
216 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
217 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
218 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
219 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
220 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
221 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
222 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
223 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
224 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
225 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
226 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
227 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
228 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
229 {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08},
230 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
231 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
232 {0x78,0x75,0xdb,0xf6,0x73,0x8c,0x64,0x78},
233 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
234 {0x7c,0xb3,0xf1,0xdf,0x34,0xf9,0x48,0x11},
235 };
236
237int main(int argc, char *argv[])
238 {
239 int i,n,err=0;
240 RC5_32_KEY key;
241 unsigned char buf[8],buf2[8],ivb[8];
242
243 for (n=0; n<5; n++)
244 {
245 RC5_32_set_key(&key,16,&(RC5key[n][0]),12);
246
247 RC5_32_ecb_encrypt(&(RC5plain[n][0]),buf,&key,RC5_ENCRYPT);
248 if (memcmp(&(RC5cipher[n][0]),buf,8) != 0)
249 {
250 printf("ecb RC5 error encrypting (%d)\n",n+1);
251 printf("got :");
252 for (i=0; i<8; i++)
253 printf("%02X ",buf[i]);
254 printf("\n");
255 printf("expected:");
256 for (i=0; i<8; i++)
257 printf("%02X ",RC5cipher[n][i]);
258 err=20;
259 printf("\n");
260 }
261
262 RC5_32_ecb_encrypt(buf,buf2,&key,RC5_DECRYPT);
263 if (memcmp(&(RC5plain[n][0]),buf2,8) != 0)
264 {
265 printf("ecb RC5 error decrypting (%d)\n",n+1);
266 printf("got :");
267 for (i=0; i<8; i++)
268 printf("%02X ",buf2[i]);
269 printf("\n");
270 printf("expected:");
271 for (i=0; i<8; i++)
272 printf("%02X ",RC5plain[n][i]);
273 printf("\n");
274 err=3;
275 }
276 }
277 if (err == 0) printf("ecb RC5 ok\n");
278
279 for (n=0; n<RC5_CBC_NUM; n++)
280 {
281 i=rc5_cbc_rounds[n];
282 if (i < 8) continue;
283
284 RC5_32_set_key(&key,rc5_cbc_key[n][0],&(rc5_cbc_key[n][1]),i);
285
286 memcpy(ivb,&(rc5_cbc_iv[n][0]),8);
287 RC5_32_cbc_encrypt(&(rc5_cbc_plain[n][0]),buf,8,
288 &key,&(ivb[0]),RC5_ENCRYPT);
289
290 if (memcmp(&(rc5_cbc_cipher[n][0]),buf,8) != 0)
291 {
292 printf("cbc RC5 error encrypting (%d)\n",n+1);
293 printf("got :");
294 for (i=0; i<8; i++)
295 printf("%02X ",buf[i]);
296 printf("\n");
297 printf("expected:");
298 for (i=0; i<8; i++)
299 printf("%02X ",rc5_cbc_cipher[n][i]);
300 err=30;
301 printf("\n");
302 }
303
304 memcpy(ivb,&(rc5_cbc_iv[n][0]),8);
305 RC5_32_cbc_encrypt(buf,buf2,8,
306 &key,&(ivb[0]),RC5_DECRYPT);
307 if (memcmp(&(rc5_cbc_plain[n][0]),buf2,8) != 0)
308 {
309 printf("cbc RC5 error decrypting (%d)\n",n+1);
310 printf("got :");
311 for (i=0; i<8; i++)
312 printf("%02X ",buf2[i]);
313 printf("\n");
314 printf("expected:");
315 for (i=0; i<8; i++)
316 printf("%02X ",rc5_cbc_plain[n][i]);
317 printf("\n");
318 err=3;
319 }
320 }
321 if (err == 0) printf("cbc RC5 ok\n");
322
323 EXIT(err);
324 return(err);
325 }
326
327#ifdef undef
328static int cfb64_test(unsigned char *cfb_cipher)
329 {
330 IDEA_KEY_SCHEDULE eks,dks;
331 int err=0,i,n;
332
333 idea_set_encrypt_key(cfb_key,&eks);
334 idea_set_decrypt_key(&eks,&dks);
335 memcpy(cfb_tmp,cfb_iv,8);
336 n=0;
337 idea_cfb64_encrypt(plain,cfb_buf1,(long)12,&eks,
338 cfb_tmp,&n,IDEA_ENCRYPT);
339 idea_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
340 (long)CFB_TEST_SIZE-12,&eks,
341 cfb_tmp,&n,IDEA_ENCRYPT);
342 if (memcmp(cfb_cipher,cfb_buf1,CFB_TEST_SIZE) != 0)
343 {
344 err=1;
345 printf("idea_cfb64_encrypt encrypt error\n");
346 for (i=0; i<CFB_TEST_SIZE; i+=8)
347 printf("%s\n",pt(&(cfb_buf1[i])));
348 }
349 memcpy(cfb_tmp,cfb_iv,8);
350 n=0;
351 idea_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,&eks,
352 cfb_tmp,&n,IDEA_DECRYPT);
353 idea_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
354 (long)CFB_TEST_SIZE-17,&dks,
355 cfb_tmp,&n,IDEA_DECRYPT);
356 if (memcmp(plain,cfb_buf2,CFB_TEST_SIZE) != 0)
357 {
358 err=1;
359 printf("idea_cfb_encrypt decrypt error\n");
360 for (i=0; i<24; i+=8)
361 printf("%s\n",pt(&(cfb_buf2[i])));
362 }
363 return(err);
364 }
365
366static char *pt(unsigned char *p)
367 {
368 static char bufs[10][20];
369 static int bnum=0;
370 char *ret;
371 int i;
372 static char *f="0123456789ABCDEF";
373
374 ret= &(bufs[bnum++][0]);
375 bnum%=10;
376 for (i=0; i<8; i++)
377 {
378 ret[i*2]=f[(p[i]>>4)&0xf];
379 ret[i*2+1]=f[p[i]&0xf];
380 }
381 ret[16]='\0';
382 return(ret);
383 }
384
385#endif
386#endif
diff --git a/src/lib/libssl/src/crypto/rsa/rsa.h b/src/lib/libssl/src/crypto/rsa/rsa.h
index e26a68b482..62fa745f79 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa.h
+++ b/src/lib/libssl/src/crypto/rsa/rsa.h
@@ -158,11 +158,6 @@ struct rsa_st
158#define RSA_FLAG_CACHE_PUBLIC 0x02 158#define RSA_FLAG_CACHE_PUBLIC 0x02
159#define RSA_FLAG_CACHE_PRIVATE 0x04 159#define RSA_FLAG_CACHE_PRIVATE 0x04
160#define RSA_FLAG_BLINDING 0x08 160#define RSA_FLAG_BLINDING 0x08
161#define RSA_FLAG_NO_BLINDING 0x80 /* new with 0.9.6j and 0.9.7b; the built-in
162 * RSA implementation now uses blinding by
163 * default (ignoring RSA_FLAG_BLINDING),
164 * but other engines might not need it
165 */
166#define RSA_FLAG_THREAD_SAFE 0x10 161#define RSA_FLAG_THREAD_SAFE 0x10
167/* This flag means the private key operations will be handled by rsa_mod_exp 162/* This flag means the private key operations will be handled by rsa_mod_exp
168 * and that they do not depend on the private key components being present: 163 * and that they do not depend on the private key components being present:
@@ -175,7 +170,11 @@ struct rsa_st
175 */ 170 */
176#define RSA_FLAG_SIGN_VER 0x40 171#define RSA_FLAG_SIGN_VER 0x40
177 172
178#define RSA_FLAG_NO_BLINDING 0x80 173#define RSA_FLAG_NO_BLINDING 0x80 /* new with 0.9.6j and 0.9.7b; the built-in
174 * RSA implementation now uses blinding by
175 * default (ignoring RSA_FLAG_BLINDING),
176 * but other engines might not need it
177 */
179 178
180#define RSA_PKCS1_PADDING 1 179#define RSA_PKCS1_PADDING 1
181#define RSA_SSLV23_PADDING 2 180#define RSA_SSLV23_PADDING 2
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_eay.c b/src/lib/libssl/src/crypto/rsa/rsa_eay.c
index 027b4dc754..e0d286266e 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_eay.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_eay.c
@@ -484,6 +484,8 @@ err:
484 if (ctx != NULL) BN_CTX_free(ctx); 484 if (ctx != NULL) BN_CTX_free(ctx);
485 BN_clear_free(&f); 485 BN_clear_free(&f);
486 BN_clear_free(&ret); 486 BN_clear_free(&ret);
487 if (local_blinding)
488 BN_BLINDING_free(blinding);
487 if (buf != NULL) 489 if (buf != NULL)
488 { 490 {
489 OPENSSL_cleanse(buf,num); 491 OPENSSL_cleanse(buf,num);
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_lib.c b/src/lib/libssl/src/crypto/rsa/rsa_lib.c
index 53c5092014..e4d622851e 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_lib.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_lib.c
@@ -316,7 +316,7 @@ void RSA_blinding_off(RSA *rsa)
316 316
317int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx) 317int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
318 { 318 {
319 BIGNUM *A,*Ai; 319 BIGNUM *A,*Ai = NULL;
320 BN_CTX *ctx; 320 BN_CTX *ctx;
321 int ret=0; 321 int ret=0;
322 322
@@ -327,8 +327,12 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
327 else 327 else
328 ctx=p_ctx; 328 ctx=p_ctx;
329 329
330 /* XXXXX: Shouldn't this be RSA_blinding_off(rsa)? */
330 if (rsa->blinding != NULL) 331 if (rsa->blinding != NULL)
332 {
331 BN_BLINDING_free(rsa->blinding); 333 BN_BLINDING_free(rsa->blinding);
334 rsa->blinding = NULL;
335 }
332 336
333 /* NB: similar code appears in setup_blinding (rsa_eay.c); 337 /* NB: similar code appears in setup_blinding (rsa_eay.c);
334 * this should be placed in a new function of its own, but for reasons 338 * this should be placed in a new function of its own, but for reasons
@@ -356,9 +360,9 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
356 rsa->blinding->thread_id = CRYPTO_thread_id(); 360 rsa->blinding->thread_id = CRYPTO_thread_id();
357 rsa->flags |= RSA_FLAG_BLINDING; 361 rsa->flags |= RSA_FLAG_BLINDING;
358 rsa->flags &= ~RSA_FLAG_NO_BLINDING; 362 rsa->flags &= ~RSA_FLAG_NO_BLINDING;
359 BN_free(Ai);
360 ret=1; 363 ret=1;
361err: 364err:
365 if (Ai != NULL) BN_free(Ai);
362 BN_CTX_end(ctx); 366 BN_CTX_end(ctx);
363 if (ctx != p_ctx) BN_CTX_free(ctx); 367 if (ctx != p_ctx) BN_CTX_free(ctx);
364 return(ret); 368 return(ret);
diff --git a/src/lib/libssl/src/crypto/x509/x509_trs.c b/src/lib/libssl/src/crypto/x509/x509_trs.c
index 17d69ac005..881252608d 100644
--- a/src/lib/libssl/src/crypto/x509/x509_trs.c
+++ b/src/lib/libssl/src/crypto/x509/x509_trs.c
@@ -82,6 +82,7 @@ static X509_TRUST trstandard[] = {
82{X509_TRUST_SSL_CLIENT, 0, trust_1oidany, "SSL Client", NID_client_auth, NULL}, 82{X509_TRUST_SSL_CLIENT, 0, trust_1oidany, "SSL Client", NID_client_auth, NULL},
83{X509_TRUST_SSL_SERVER, 0, trust_1oidany, "SSL Server", NID_server_auth, NULL}, 83{X509_TRUST_SSL_SERVER, 0, trust_1oidany, "SSL Server", NID_server_auth, NULL},
84{X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL}, 84{X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL},
85{X509_TRUST_OBJECT_SIGN, 0, trust_1oidany, "Object Signer", NID_code_sign, NULL},
85{X509_TRUST_OCSP_SIGN, 0, trust_1oid, "OCSP responder", NID_OCSP_sign, NULL}, 86{X509_TRUST_OCSP_SIGN, 0, trust_1oid, "OCSP responder", NID_OCSP_sign, NULL},
86{X509_TRUST_OCSP_REQUEST, 0, trust_1oid, "OCSP request", NID_ad_OCSP, NULL} 87{X509_TRUST_OCSP_REQUEST, 0, trust_1oid, "OCSP request", NID_ad_OCSP, NULL}
87}; 88};
diff --git a/src/lib/libssl/src/crypto/x509/x509_vfy.c b/src/lib/libssl/src/crypto/x509/x509_vfy.c
index 552d1e7251..2bb21b443e 100644
--- a/src/lib/libssl/src/crypto/x509/x509_vfy.c
+++ b/src/lib/libssl/src/crypto/x509/x509_vfy.c
@@ -453,9 +453,9 @@ static int check_revocation(X509_STORE_CTX *ctx)
453 if (!(ctx->flags & X509_V_FLAG_CRL_CHECK)) 453 if (!(ctx->flags & X509_V_FLAG_CRL_CHECK))
454 return 1; 454 return 1;
455 if (ctx->flags & X509_V_FLAG_CRL_CHECK_ALL) 455 if (ctx->flags & X509_V_FLAG_CRL_CHECK_ALL)
456 last = 0;
457 else
458 last = sk_X509_num(ctx->chain) - 1; 456 last = sk_X509_num(ctx->chain) - 1;
457 else
458 last = 0;
459 for(i = 0; i <= last; i++) 459 for(i = 0; i <= last; i++)
460 { 460 {
461 ctx->error_depth = i; 461 ctx->error_depth = i;
@@ -674,7 +674,7 @@ static int internal_verify(X509_STORE_CTX *ctx)
674 ok=(*cb)(0,ctx); 674 ok=(*cb)(0,ctx);
675 if (!ok) goto end; 675 if (!ok) goto end;
676 } 676 }
677 if (X509_verify(xs,pkey) <= 0) 677 else if (X509_verify(xs,pkey) <= 0)
678 /* XXX For the final trusted self-signed cert, 678 /* XXX For the final trusted self-signed cert,
679 * this is a waste of time. That check should 679 * this is a waste of time. That check should
680 * optional so that e.g. 'openssl x509' can be 680 * optional so that e.g. 'openssl x509' can be
diff --git a/src/lib/libssl/src/crypto/x509/x509type.c b/src/lib/libssl/src/crypto/x509/x509type.c
index 8e78b34458..f78c2a6b43 100644
--- a/src/lib/libssl/src/crypto/x509/x509type.c
+++ b/src/lib/libssl/src/crypto/x509/x509type.c
@@ -99,14 +99,15 @@ int X509_certificate_type(X509 *x, EVP_PKEY *pkey)
99 case EVP_PKEY_RSA: 99 case EVP_PKEY_RSA:
100 ret|=EVP_PKS_RSA; 100 ret|=EVP_PKS_RSA;
101 break; 101 break;
102 case EVP_PKS_DSA: 102 case EVP_PKEY_DSA:
103 ret|=EVP_PKS_DSA; 103 ret|=EVP_PKS_DSA;
104 break; 104 break;
105 default: 105 default:
106 break; 106 break;
107 } 107 }
108 108
109 if (EVP_PKEY_size(pk) <= 512) 109 if (EVP_PKEY_size(pk) <= 512/8) /* /8 because it's 512 bits we look
110 for, not bytes */
110 ret|=EVP_PKT_EXP; 111 ret|=EVP_PKT_EXP;
111 if(pkey==NULL) EVP_PKEY_free(pk); 112 if(pkey==NULL) EVP_PKEY_free(pk);
112 return(ret); 113 return(ret);
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_conf.c b/src/lib/libssl/src/crypto/x509v3/v3_conf.c
index 1a3448e121..1284d5aaa5 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_conf.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_conf.c
@@ -236,7 +236,7 @@ static int v3_check_critical(char **value)
236static int v3_check_generic(char **value) 236static int v3_check_generic(char **value)
237{ 237{
238 char *p = *value; 238 char *p = *value;
239 if ((strlen(p) < 4) || strncmp(p, "DER:,", 4)) return 0; 239 if ((strlen(p) < 4) || strncmp(p, "DER:", 4)) return 0;
240 p+=4; 240 p+=4;
241 while (isspace((unsigned char)*p)) p++; 241 while (isspace((unsigned char)*p)) p++;
242 *value = p; 242 *value = p;
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_cpols.c b/src/lib/libssl/src/crypto/x509v3/v3_cpols.c
index 0d4ab1f680..0d554f3a2c 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_cpols.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_cpols.c
@@ -73,7 +73,7 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx,
73 STACK_OF(CONF_VALUE) *polstrs, int ia5org); 73 STACK_OF(CONF_VALUE) *polstrs, int ia5org);
74static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, 74static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
75 STACK_OF(CONF_VALUE) *unot, int ia5org); 75 STACK_OF(CONF_VALUE) *unot, int ia5org);
76static STACK_OF(ASN1_INTEGER) *nref_nos(STACK_OF(CONF_VALUE) *nos); 76static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos);
77 77
78X509V3_EXT_METHOD v3_cpols = { 78X509V3_EXT_METHOD v3_cpols = {
79NID_certificate_policies, 0,ASN1_ITEM_ref(CERTIFICATEPOLICIES), 79NID_certificate_policies, 0,ASN1_ITEM_ref(CERTIFICATEPOLICIES),
@@ -226,6 +226,8 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx,
226 qual = notice_section(ctx, unot, ia5org); 226 qual = notice_section(ctx, unot, ia5org);
227 X509V3_section_free(ctx, unot); 227 X509V3_section_free(ctx, unot);
228 if(!qual) goto err; 228 if(!qual) goto err;
229 if(!pol->qualifiers) pol->qualifiers =
230 sk_POLICYQUALINFO_new_null();
229 if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) 231 if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual))
230 goto merr; 232 goto merr;
231 } else { 233 } else {
@@ -255,7 +257,7 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx,
255static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, 257static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
256 STACK_OF(CONF_VALUE) *unot, int ia5org) 258 STACK_OF(CONF_VALUE) *unot, int ia5org)
257{ 259{
258 int i; 260 int i, ret;
259 CONF_VALUE *cnf; 261 CONF_VALUE *cnf;
260 USERNOTICE *not; 262 USERNOTICE *not;
261 POLICYQUALINFO *qual; 263 POLICYQUALINFO *qual;
@@ -275,8 +277,8 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
275 if(!(nref = NOTICEREF_new())) goto merr; 277 if(!(nref = NOTICEREF_new())) goto merr;
276 not->noticeref = nref; 278 not->noticeref = nref;
277 } else nref = not->noticeref; 279 } else nref = not->noticeref;
278 if(ia5org) nref->organization = M_ASN1_IA5STRING_new(); 280 if(ia5org) nref->organization->type = V_ASN1_IA5STRING;
279 else nref->organization = M_ASN1_VISIBLESTRING_new(); 281 else nref->organization->type = V_ASN1_VISIBLESTRING;
280 if(!ASN1_STRING_set(nref->organization, cnf->value, 282 if(!ASN1_STRING_set(nref->organization, cnf->value,
281 strlen(cnf->value))) goto merr; 283 strlen(cnf->value))) goto merr;
282 } else if(!strcmp(cnf->name, "noticeNumbers")) { 284 } else if(!strcmp(cnf->name, "noticeNumbers")) {
@@ -292,12 +294,12 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
292 X509V3_conf_err(cnf); 294 X509V3_conf_err(cnf);
293 goto err; 295 goto err;
294 } 296 }
295 nref->noticenos = nref_nos(nos); 297 ret = nref_nos(nref->noticenos, nos);
296 sk_CONF_VALUE_pop_free(nos, X509V3_conf_free); 298 sk_CONF_VALUE_pop_free(nos, X509V3_conf_free);
297 if(!nref->noticenos) goto err; 299 if (!ret)
300 goto err;
298 } else { 301 } else {
299 X509V3err(X509V3_F_NOTICE_SECTION,X509V3_R_INVALID_OPTION); 302 X509V3err(X509V3_F_NOTICE_SECTION,X509V3_R_INVALID_OPTION);
300
301 X509V3_conf_err(cnf); 303 X509V3_conf_err(cnf);
302 goto err; 304 goto err;
303 } 305 }
@@ -319,15 +321,13 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
319 return NULL; 321 return NULL;
320} 322}
321 323
322static STACK_OF(ASN1_INTEGER) *nref_nos(STACK_OF(CONF_VALUE) *nos) 324static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos)
323{ 325{
324 STACK_OF(ASN1_INTEGER) *nnums;
325 CONF_VALUE *cnf; 326 CONF_VALUE *cnf;
326 ASN1_INTEGER *aint; 327 ASN1_INTEGER *aint;
327 328
328 int i; 329 int i;
329 330
330 if(!(nnums = sk_ASN1_INTEGER_new_null())) goto merr;
331 for(i = 0; i < sk_CONF_VALUE_num(nos); i++) { 331 for(i = 0; i < sk_CONF_VALUE_num(nos); i++) {
332 cnf = sk_CONF_VALUE_value(nos, i); 332 cnf = sk_CONF_VALUE_value(nos, i);
333 if(!(aint = s2i_ASN1_INTEGER(NULL, cnf->name))) { 333 if(!(aint = s2i_ASN1_INTEGER(NULL, cnf->name))) {
@@ -336,14 +336,14 @@ static STACK_OF(ASN1_INTEGER) *nref_nos(STACK_OF(CONF_VALUE) *nos)
336 } 336 }
337 if(!sk_ASN1_INTEGER_push(nnums, aint)) goto merr; 337 if(!sk_ASN1_INTEGER_push(nnums, aint)) goto merr;
338 } 338 }
339 return nnums; 339 return 1;
340 340
341 merr: 341 merr:
342 X509V3err(X509V3_F_NOTICE_SECTION,ERR_R_MALLOC_FAILURE); 342 X509V3err(X509V3_F_NOTICE_SECTION,ERR_R_MALLOC_FAILURE);
343 343
344 err: 344 err:
345 sk_ASN1_INTEGER_pop_free(nnums, ASN1_STRING_free); 345 sk_ASN1_INTEGER_pop_free(nnums, ASN1_STRING_free);
346 return NULL; 346 return 0;
347} 347}
348 348
349 349
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_lib.c b/src/lib/libssl/src/crypto/x509v3/v3_lib.c
index 482ca8ccf5..ca5a4a4a57 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_lib.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_lib.c
@@ -202,6 +202,7 @@ void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx)
202 if(OBJ_obj2nid(ex->object) == nid) { 202 if(OBJ_obj2nid(ex->object) == nid) {
203 if(idx) { 203 if(idx) {
204 *idx = i; 204 *idx = i;
205 found_ex = ex;
205 break; 206 break;
206 } else if(found_ex) { 207 } else if(found_ex) {
207 /* Found more than one */ 208 /* Found more than one */
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_prn.c b/src/lib/libssl/src/crypto/x509v3/v3_prn.c
index 754808b625..5d268eb768 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_prn.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_prn.c
@@ -184,7 +184,7 @@ int X509V3_extensions_print(BIO *bp, char *title, STACK_OF(X509_EXTENSION) *exts
184 j=X509_EXTENSION_get_critical(ex); 184 j=X509_EXTENSION_get_critical(ex);
185 if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0) 185 if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0)
186 return 0; 186 return 0;
187 if(!X509V3_EXT_print(bp, ex, flag, 12)) 187 if(!X509V3_EXT_print(bp, ex, flag, indent + 4))
188 { 188 {
189 BIO_printf(bp, "%*s", indent + 4, ""); 189 BIO_printf(bp, "%*s", indent + 4, "");
190 M_ASN1_OCTET_STRING_print(bp,ex->value); 190 M_ASN1_OCTET_STRING_print(bp,ex->value);
diff --git a/src/lib/libssl/src/demos/engines/zencod/hw_zencod.h b/src/lib/libssl/src/demos/engines/zencod/hw_zencod.h
index 195345d8c6..415c9a6be8 100644
--- a/src/lib/libssl/src/demos/engines/zencod/hw_zencod.h
+++ b/src/lib/libssl/src/demos/engines/zencod/hw_zencod.h
@@ -46,7 +46,7 @@ typedef int t_zencod_dump_key (FILE *stream, char *msg, KEY *key);
46 46
47 47
48/* 48/*
49 * Key managment tools 49 * Key management tools
50 */ 50 */
51typedef KEY *t_zencod_new_number (unsigned long len, unsigned char *data); 51typedef KEY *t_zencod_new_number (unsigned long len, unsigned char *data);
52typedef int t_zencod_init_number (KEY *n, unsigned long len, unsigned char *data); 52typedef int t_zencod_init_number (KEY *n, unsigned long len, unsigned char *data);
diff --git a/src/lib/libssl/src/doc/apps/ca.pod b/src/lib/libssl/src/doc/apps/ca.pod
index de66c534b5..74f45ca2f9 100644
--- a/src/lib/libssl/src/doc/apps/ca.pod
+++ b/src/lib/libssl/src/doc/apps/ca.pod
@@ -359,7 +359,7 @@ the same as the B<-md> option. The message digest to use. Mandatory.
359the text database file to use. Mandatory. This file must be present 359the text database file to use. Mandatory. This file must be present
360though initially it will be empty. 360though initially it will be empty.
361 361
362=item B<serialfile> 362=item B<serial>
363 363
364a text file containing the next serial number to use in hex. Mandatory. 364a text file containing the next serial number to use in hex. Mandatory.
365This file must be present and contain a valid serial number. 365This file must be present and contain a valid serial number.
@@ -400,7 +400,7 @@ here, except the B<no_signame> and B<no_sigdump> are permanently set
400and cannot be disabled (this is because the certificate signature cannot 400and cannot be disabled (this is because the certificate signature cannot
401be displayed because the certificate has not been signed at this point). 401be displayed because the certificate has not been signed at this point).
402 402
403For convenience the values B<default_ca> are accepted by both to produce 403For convenience the values B<ca_default> are accepted by both to produce
404a reasonable output. 404a reasonable output.
405 405
406If neither option is present the format used in earlier versions of 406If neither option is present the format used in earlier versions of
@@ -513,8 +513,8 @@ A sample configuration file with the relevant sections for B<ca>:
513 policy = policy_any # default policy 513 policy = policy_any # default policy
514 email_in_dn = no # Don't add the email into cert DN 514 email_in_dn = no # Don't add the email into cert DN
515 515
516 nameopt = default_ca # Subject name display option 516 nameopt = ca_default # Subject name display option
517 certopt = default_ca # Certificate display option 517 certopt = ca_default # Certificate display option
518 copy_extensions = none # Don't copy extensions from request 518 copy_extensions = none # Don't copy extensions from request
519 519
520 [ policy_any ] 520 [ policy_any ]
diff --git a/src/lib/libssl/src/doc/apps/s_client.pod b/src/lib/libssl/src/doc/apps/s_client.pod
index 47dc93cb3f..d061326c1f 100644
--- a/src/lib/libssl/src/doc/apps/s_client.pod
+++ b/src/lib/libssl/src/doc/apps/s_client.pod
@@ -168,7 +168,7 @@ command for more information.
168 168
169send the protocol-specific message(s) to switch to TLS for communication. 169send the protocol-specific message(s) to switch to TLS for communication.
170B<protocol> is a keyword for the intended protocol. Currently, the only 170B<protocol> is a keyword for the intended protocol. Currently, the only
171supported keyword is "smtp". 171supported keywords are "smtp" and "pop3".
172 172
173=item B<-engine id> 173=item B<-engine id>
174 174
diff --git a/src/lib/libssl/src/doc/crypto/BIO_f_base64.pod b/src/lib/libssl/src/doc/crypto/BIO_f_base64.pod
index fdb603b38e..929557d22f 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_f_base64.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_f_base64.pod
@@ -55,16 +55,15 @@ to standard output:
55Read Base64 encoded data from standard input and write the decoded 55Read Base64 encoded data from standard input and write the decoded
56data to standard output: 56data to standard output:
57 57
58 BIO *bio, *b64, bio_out; 58 BIO *bio, *b64, *bio_out;
59 char inbuf[512]; 59 char inbuf[512];
60 int inlen; 60 int inlen;
61 char message[] = "Hello World \n";
62 61
63 b64 = BIO_new(BIO_f_base64()); 62 b64 = BIO_new(BIO_f_base64());
64 bio = BIO_new_fp(stdin, BIO_NOCLOSE); 63 bio = BIO_new_fp(stdin, BIO_NOCLOSE);
65 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); 64 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
66 bio = BIO_push(b64, bio); 65 bio = BIO_push(b64, bio);
67 while((inlen = BIO_read(bio, inbuf, strlen(message))) > 0) 66 while((inlen = BIO_read(bio, inbuf, 512) > 0)
68 BIO_write(bio_out, inbuf, inlen); 67 BIO_write(bio_out, inbuf, inlen);
69 68
70 BIO_free_all(bio); 69 BIO_free_all(bio);
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
index d15b2a3a1a..ca8d81b82c 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
@@ -135,9 +135,9 @@ process is immediately stopped with "verification failed" state. If
135SSL_VERIFY_PEER is set, a verification failure alert is sent to the peer and 135SSL_VERIFY_PEER is set, a verification failure alert is sent to the peer and
136the TLS/SSL handshake is terminated. If B<verify_callback> returns 1, 136the TLS/SSL handshake is terminated. If B<verify_callback> returns 1,
137the verification process is continued. If B<verify_callback> always returns 137the verification process is continued. If B<verify_callback> always returns
1381, the TLS/SSL handshake will never be terminated because of this application 1381, the TLS/SSL handshake will not be terminated with respect to verification
139experiencing a verification failure. The calling process can however 139failures and the connection will be established. The calling process can
140retrieve the error code of the last verification error using 140however retrieve the error code of the last verification error using
141L<SSL_get_verify_result(3)|SSL_get_verify_result(3)> or by maintaining its 141L<SSL_get_verify_result(3)|SSL_get_verify_result(3)> or by maintaining its
142own error storage managed by B<verify_callback>. 142own error storage managed by B<verify_callback>.
143 143
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
index b8868f18bf..ea2faba3ec 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
@@ -68,7 +68,9 @@ should be preferred.
68 68
69SSL_CTX_use_certificate_chain_file() loads a certificate chain from 69SSL_CTX_use_certificate_chain_file() loads a certificate chain from
70B<file> into B<ctx>. The certificates must be in PEM format and must 70B<file> into B<ctx>. The certificates must be in PEM format and must
71be sorted starting with the certificate to the highest level (root CA). 71be sorted starting with the subject's certificate (actual client or server
72certificate), followed by intermediate CA certificates if applicable, and
73ending at the highest level (root) CA.
72There is no corresponding function working on a single SSL object. 74There is no corresponding function working on a single SSL object.
73 75
74SSL_CTX_use_PrivateKey() adds B<pkey> as private key to B<ctx>. 76SSL_CTX_use_PrivateKey() adds B<pkey> as private key to B<ctx>.
diff --git a/src/lib/libssl/src/doc/ssl/SSL_accept.pod b/src/lib/libssl/src/doc/ssl/SSL_accept.pod
index a673edba85..cc724c0d56 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_accept.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_accept.pod
@@ -28,7 +28,8 @@ should be called again.
28 28
29If the underlying BIO is B<non-blocking>, SSL_accept() will also return 29If the underlying BIO is B<non-blocking>, SSL_accept() will also return
30when the underlying BIO could not satisfy the needs of SSL_accept() 30when the underlying BIO could not satisfy the needs of SSL_accept()
31to continue the handshake. In this case a call to SSL_get_error() with the 31to continue the handshake, indicating the problem by the return value -1.
32In this case a call to SSL_get_error() with the
32return value of SSL_accept() will yield B<SSL_ERROR_WANT_READ> or 33return value of SSL_accept() will yield B<SSL_ERROR_WANT_READ> or
33B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after 34B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after
34taking appropriate action to satisfy the needs of SSL_accept(). 35taking appropriate action to satisfy the needs of SSL_accept().
diff --git a/src/lib/libssl/src/doc/ssl/SSL_connect.pod b/src/lib/libssl/src/doc/ssl/SSL_connect.pod
index 8426310c0d..cc56ebb75f 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_connect.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_connect.pod
@@ -25,7 +25,8 @@ handshake has been finished or an error occurred.
25 25
26If the underlying BIO is B<non-blocking>, SSL_connect() will also return 26If the underlying BIO is B<non-blocking>, SSL_connect() will also return
27when the underlying BIO could not satisfy the needs of SSL_connect() 27when the underlying BIO could not satisfy the needs of SSL_connect()
28to continue the handshake. In this case a call to SSL_get_error() with the 28to continue the handshake, indicating the problem by the return value -1.
29In this case a call to SSL_get_error() with the
29return value of SSL_connect() will yield B<SSL_ERROR_WANT_READ> or 30return value of SSL_connect() will yield B<SSL_ERROR_WANT_READ> or
30B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after 31B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after
31taking appropriate action to satisfy the needs of SSL_connect(). 32taking appropriate action to satisfy the needs of SSL_connect().
diff --git a/src/lib/libssl/src/e_os.h b/src/lib/libssl/src/e_os.h
index f7d09c5295..096eabe09a 100644
--- a/src/lib/libssl/src/e_os.h
+++ b/src/lib/libssl/src/e_os.h
@@ -174,6 +174,13 @@ extern "C" {
174#define closesocket(s) close(s) 174#define closesocket(s) close(s)
175#define readsocket(s,b,n) recv((s),(b),(n),0) 175#define readsocket(s,b,n) recv((s),(b),(n),0)
176#define writesocket(s,b,n) send((s),(b),(n),0) 176#define writesocket(s,b,n) send((s),(b),(n),0)
177#elif defined(OPENSSL_SYS_VXWORKS)
178#define get_last_socket_error() errno
179#define clear_socket_error() errno=0
180#define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
181#define closesocket(s) close(s)
182#define readsocket(s,b,n) read((s),(b),(n))
183#define writesocket(s,b,n) write((s),(char *)(b),(n))
177#else 184#else
178#define get_last_socket_error() errno 185#define get_last_socket_error() errno
179#define clear_socket_error() errno=0 186#define clear_socket_error() errno=0
@@ -250,7 +257,7 @@ extern "C" {
250# define EXIT(n) _wsetexit(_WINEXITNOPERSIST) 257# define EXIT(n) _wsetexit(_WINEXITNOPERSIST)
251# define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0) 258# define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0)
252# else 259# else
253# define EXIT(n) return(n) 260# define EXIT(n) exit(n)
254# endif 261# endif
255# define LIST_SEPARATOR_CHAR ';' 262# define LIST_SEPARATOR_CHAR ';'
256# ifndef X_OK 263# ifndef X_OK
@@ -331,6 +338,8 @@ extern "C" {
331# define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP 338# define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
332 * (unless when compiling with -D_POSIX_SOURCE, 339 * (unless when compiling with -D_POSIX_SOURCE,
333 * which doesn't work for us) */ 340 * which doesn't work for us) */
341# endif
342# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
334# define ssize_t int /* ditto */ 343# define ssize_t int /* ditto */
335# endif 344# endif
336# ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */ 345# ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
@@ -517,10 +526,6 @@ extern char *sys_errlist[]; extern int sys_nerr;
517#define TTY_STRUCT int 526#define TTY_STRUCT int
518 527
519#define sleep(a) taskDelay((a) * sysClkRateGet()) 528#define sleep(a) taskDelay((a) * sysClkRateGet())
520#if defined(ioctlsocket)
521#undef ioctlsocket
522#endif
523#define ioctlsocket(a,b,c) ioctl((a),(b),*(c))
524 529
525#include <vxWorks.h> 530#include <vxWorks.h>
526#include <sockLib.h> 531#include <sockLib.h>
diff --git a/src/lib/libssl/src/openssl.spec b/src/lib/libssl/src/openssl.spec
index 9bd9c8375e..9ce236e0d2 100644
--- a/src/lib/libssl/src/openssl.spec
+++ b/src/lib/libssl/src/openssl.spec
@@ -1,7 +1,7 @@
1%define libmaj 0 1%define libmaj 0
2%define libmin 9 2%define libmin 9
3%define librel 7 3%define librel 7
4%define librev b 4%define librev c
5Release: 1 5Release: 1
6 6
7%define openssldir /var/ssl 7%define openssldir /var/ssl
@@ -83,18 +83,18 @@ documentation and POD files from which the man pages were produced.
83 83
84%build 84%build
85 85
86%define CONFIG_FLAGS -DSSL_ALLOW_ADH --prefix=/usr 86%define CONFIG_FLAGS -DSSL_ALLOW_ADH --prefix=/usr --openssldir=%{openssldir}
87 87
88perl util/perlpath.pl /usr/bin/perl 88perl util/perlpath.pl /usr/bin/perl
89 89
90%ifarch i386 i486 i586 i686 90%ifarch i386 i486 i586 i686
91./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-elf shared 91./Configure %{CONFIG_FLAGS} linux-elf shared
92%endif 92%endif
93%ifarch ppc 93%ifarch ppc
94./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-ppc shared 94./Configure %{CONFIG_FLAGS} linux-ppc shared
95%endif 95%endif
96%ifarch alpha 96%ifarch alpha
97./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-alpha shared 97./Configure %{CONFIG_FLAGS} linux-alpha shared
98%endif 98%endif
99LD_LIBRARY_PATH=`pwd` make 99LD_LIBRARY_PATH=`pwd` make
100LD_LIBRARY_PATH=`pwd` make rehash 100LD_LIBRARY_PATH=`pwd` make rehash
@@ -102,12 +102,7 @@ LD_LIBRARY_PATH=`pwd` make test
102 102
103%install 103%install
104rm -rf $RPM_BUILD_ROOT 104rm -rf $RPM_BUILD_ROOT
105make MANDIR=/usr/man INSTALL_PREFIX="$RPM_BUILD_ROOT" install 105make MANDIR=/usr/man MANSUFFIX=ssl INSTALL_PREFIX="$RPM_BUILD_ROOT" install
106
107# Rename manpages
108for x in $RPM_BUILD_ROOT/usr/man/man*/*
109 do mv ${x} ${x}ssl
110done
111 106
112# Make backwards-compatibility symlink to ssleay 107# Make backwards-compatibility symlink to ssleay
113ln -sf /usr/bin/openssl $RPM_BUILD_ROOT/usr/bin/ssleay 108ln -sf /usr/bin/openssl $RPM_BUILD_ROOT/usr/bin/ssleay
@@ -135,6 +130,7 @@ rm -rf $RPM_BUILD_ROOT
135%doc CHANGES CHANGES.SSLeay LICENSE NEWS README 130%doc CHANGES CHANGES.SSLeay LICENSE NEWS README
136 131
137%attr(0644,root,root) /usr/lib/*.a 132%attr(0644,root,root) /usr/lib/*.a
133%attr(0644,root,root) /usr/lib/pkgconfig/openssl.pc
138%attr(0644,root,root) /usr/include/openssl/* 134%attr(0644,root,root) /usr/include/openssl/*
139%attr(0644,root,root) /usr/man/man[3]/* 135%attr(0644,root,root) /usr/man/man[3]/*
140 136
@@ -150,6 +146,8 @@ ldconfig
150ldconfig 146ldconfig
151 147
152%changelog 148%changelog
149* Wed May 7 2003 Richard Levitte <richard@levitte.org>
150- Add /usr/lib/pkgconfig/openssl.pc to the development section.
153* Thu Mar 22 2001 Richard Levitte <richard@levitte.org> 151* Thu Mar 22 2001 Richard Levitte <richard@levitte.org>
154- Removed redundant subsection that re-installed libcrypto.a and libssl.a 152- Removed redundant subsection that re-installed libcrypto.a and libssl.a
155 as well. Also remove RSAref stuff completely, since it's not needed 153 as well. Also remove RSAref stuff completely, since it's not needed
diff --git a/src/lib/libssl/src/ssl/kssl.c b/src/lib/libssl/src/ssl/kssl.c
index a80f5b2f74..7c45f8ff4e 100644
--- a/src/lib/libssl/src/ssl/kssl.c
+++ b/src/lib/libssl/src/ssl/kssl.c
@@ -1496,8 +1496,9 @@ kssl_sget_tkt( /* UPDATE */ KSSL_CTX *kssl_ctx,
1496 "bad ticket from krb5_rd_req.\n"); 1496 "bad ticket from krb5_rd_req.\n");
1497 } 1497 }
1498 else if (kssl_ctx_setprinc(kssl_ctx, KSSL_CLIENT, 1498 else if (kssl_ctx_setprinc(kssl_ctx, KSSL_CLIENT,
1499 &krb5ticket->enc_part2->client->realm, 1499 &krb5ticket->enc_part2->client->realm,
1500 krb5ticket->enc_part2->client->data)) 1500 krb5ticket->enc_part2->client->data,
1501 krb5ticket->enc_part2->client->length))
1501 { 1502 {
1502 kssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET, 1503 kssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET,
1503 "kssl_ctx_setprinc() fails.\n"); 1504 "kssl_ctx_setprinc() fails.\n");
@@ -1564,16 +1565,17 @@ kssl_ctx_free(KSSL_CTX *kssl_ctx)
1564 } 1565 }
1565 1566
1566 1567
1567/* Given a (krb5_data *) entity (and optional realm), 1568/* Given an array of (krb5_data *) entity (and optional realm),
1568** set the plain (char *) client_princ or service_host member 1569** set the plain (char *) client_princ or service_host member
1569** of the kssl_ctx struct. 1570** of the kssl_ctx struct.
1570*/ 1571*/
1571krb5_error_code 1572krb5_error_code
1572kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, 1573kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,
1573 krb5_data *realm, krb5_data *entity) 1574 krb5_data *realm, krb5_data *entity, int nentities)
1574 { 1575 {
1575 char **princ; 1576 char **princ;
1576 int length; 1577 int length;
1578 int i;
1577 1579
1578 if (kssl_ctx == NULL || entity == NULL) return KSSL_CTX_ERR; 1580 if (kssl_ctx == NULL || entity == NULL) return KSSL_CTX_ERR;
1579 1581
@@ -1585,18 +1587,33 @@ kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,
1585 } 1587 }
1586 if (*princ) free(*princ); 1588 if (*princ) free(*princ);
1587 1589
1588 length = entity->length + ((realm)? realm->length + 2: 1); 1590 /* Add up all the entity->lengths */
1591 length = 0;
1592 for (i=0; i < nentities; i++)
1593 {
1594 length += entity[i].length;
1595 }
1596 /* Add in space for the '/' character(s) (if any) */
1597 length += nentities-1;
1598 /* Space for the ('@'+realm+NULL | NULL) */
1599 length += ((realm)? realm->length + 2: 1);
1600
1589 if ((*princ = calloc(1, length)) == NULL) 1601 if ((*princ = calloc(1, length)) == NULL)
1590 return KSSL_CTX_ERR; 1602 return KSSL_CTX_ERR;
1591 else 1603 else
1592 { 1604 {
1593 strncpy(*princ, entity->data, entity->length); 1605 for (i = 0; i < nentities; i++)
1594 (*princ)[entity->length]='\0'; 1606 {
1607 strncat(*princ, entity[i].data, entity[i].length);
1608 if (i < nentities-1)
1609 {
1610 strcat (*princ, "/");
1611 }
1612 }
1595 if (realm) 1613 if (realm)
1596 { 1614 {
1597 strcat (*princ, "@"); 1615 strcat (*princ, "@");
1598 (void) strncat(*princ, realm->data, realm->length); 1616 (void) strncat(*princ, realm->data, realm->length);
1599 (*princ)[entity->length+1+realm->length]='\0';
1600 } 1617 }
1601 } 1618 }
1602 1619
diff --git a/src/lib/libssl/src/ssl/kssl.h b/src/lib/libssl/src/ssl/kssl.h
index cf7ebdd168..19a689b089 100644
--- a/src/lib/libssl/src/ssl/kssl.h
+++ b/src/lib/libssl/src/ssl/kssl.h
@@ -149,7 +149,7 @@ KSSL_CTX *kssl_ctx_new(void);
149KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx); 149KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx);
150void kssl_ctx_show(KSSL_CTX *kssl_ctx); 150void kssl_ctx_show(KSSL_CTX *kssl_ctx);
151krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, 151krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,
152 krb5_data *realm, krb5_data *entity); 152 krb5_data *realm, krb5_data *entity, int nentities);
153krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp, 153krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp,
154 krb5_data *authenp, KSSL_ERR *kssl_err); 154 krb5_data *authenp, KSSL_ERR *kssl_err);
155krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata, 155krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata,
diff --git a/src/lib/libssl/src/ssl/s3_clnt.c b/src/lib/libssl/src/ssl/s3_clnt.c
index fae8eadada..eb7daebfdf 100644
--- a/src/lib/libssl/src/ssl/s3_clnt.c
+++ b/src/lib/libssl/src/ssl/s3_clnt.c
@@ -1769,6 +1769,7 @@ static int ssl3_send_client_verify(SSL *s)
1769 *(d++)=SSL3_MT_CERTIFICATE_VERIFY; 1769 *(d++)=SSL3_MT_CERTIFICATE_VERIFY;
1770 l2n3(n,d); 1770 l2n3(n,d);
1771 1771
1772 s->state=SSL3_ST_CW_CERT_VRFY_B;
1772 s->init_num=(int)n+4; 1773 s->init_num=(int)n+4;
1773 s->init_off=0; 1774 s->init_off=0;
1774 } 1775 }
diff --git a/src/lib/libssl/src/ssl/s3_srvr.c b/src/lib/libssl/src/ssl/s3_srvr.c
index 58cf774967..881f68b998 100644
--- a/src/lib/libssl/src/ssl/s3_srvr.c
+++ b/src/lib/libssl/src/ssl/s3_srvr.c
@@ -431,10 +431,11 @@ int ssl3_accept(SSL *s)
431 if (ret == 2) 431 if (ret == 2)
432 s->state = SSL3_ST_SR_CLNT_HELLO_C; 432 s->state = SSL3_ST_SR_CLNT_HELLO_C;
433 else { 433 else {
434 /* could be sent for a DH cert, even if we 434 if (s->s3->tmp.cert_request)
435 * have not asked for it :-) */ 435 {
436 ret=ssl3_get_client_certificate(s); 436 ret=ssl3_get_client_certificate(s);
437 if (ret <= 0) goto end; 437 if (ret <= 0) goto end;
438 }
438 s->init_num=0; 439 s->init_num=0;
439 s->state=SSL3_ST_SR_KEY_EXCH_A; 440 s->state=SSL3_ST_SR_KEY_EXCH_A;
440 } 441 }
@@ -844,6 +845,9 @@ static int ssl3_get_client_hello(SSL *s)
844 } 845 }
845 846
846 /* TLS does not mind if there is extra stuff */ 847 /* TLS does not mind if there is extra stuff */
848#if 0 /* SSL 3.0 does not mind either, so we should disable this test
849 * (was enabled in 0.9.6d through 0.9.6j and 0.9.7 through 0.9.7b,
850 * in earlier SSLeay/OpenSSL releases this test existed but was buggy) */
847 if (s->version == SSL3_VERSION) 851 if (s->version == SSL3_VERSION)
848 { 852 {
849 if (p < (d+n)) 853 if (p < (d+n))
@@ -855,6 +859,7 @@ static int ssl3_get_client_hello(SSL *s)
855 goto f_err; 859 goto f_err;
856 } 860 }
857 } 861 }
862#endif
858 863
859 /* Given s->session->ciphers and SSL_get_ciphers, we must 864 /* Given s->session->ciphers and SSL_get_ciphers, we must
860 * pick a cipher */ 865 * pick a cipher */
@@ -1352,6 +1357,7 @@ static int ssl3_send_certificate_request(SSL *s)
1352 s->init_num += 4; 1357 s->init_num += 4;
1353#endif 1358#endif
1354 1359
1360 s->state = SSL3_ST_SW_CERT_REQ_B;
1355 } 1361 }
1356 1362
1357 /* SSL3_ST_SW_CERT_REQ_B */ 1363 /* SSL3_ST_SW_CERT_REQ_B */
diff --git a/src/lib/libssl/src/ssl/ssl_lib.c b/src/lib/libssl/src/ssl/ssl_lib.c
index ddd8114587..6d69890688 100644
--- a/src/lib/libssl/src/ssl/ssl_lib.c
+++ b/src/lib/libssl/src/ssl/ssl_lib.c
@@ -473,6 +473,11 @@ void SSL_free(SSL *s)
473 473
474 if (s->method != NULL) s->method->ssl_free(s); 474 if (s->method != NULL) s->method->ssl_free(s);
475 475
476#ifndef OPENSSL_NO_KRB5
477 if (s->kssl_ctx != NULL)
478 kssl_ctx_free(s->kssl_ctx);
479#endif /* OPENSSL_NO_KRB5 */
480
476 OPENSSL_free(s); 481 OPENSSL_free(s);
477 } 482 }
478 483
diff --git a/src/lib/libssl/src/ssl/ssl_rsa.c b/src/lib/libssl/src/ssl/ssl_rsa.c
index 03828b6632..330390519b 100644
--- a/src/lib/libssl/src/ssl/ssl_rsa.c
+++ b/src/lib/libssl/src/ssl/ssl_rsa.c
@@ -207,7 +207,7 @@ static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
207 ok=1; 207 ok=1;
208 else 208 else
209#endif 209#endif
210 if (!X509_check_private_key(c->pkeys[i].x509,pkey)) 210 if (!X509_check_private_key(c->pkeys[i].x509,pkey))
211 { 211 {
212 if ((i == SSL_PKEY_DH_RSA) || (i == SSL_PKEY_DH_DSA)) 212 if ((i == SSL_PKEY_DH_RSA) || (i == SSL_PKEY_DH_DSA))
213 { 213 {
@@ -241,6 +241,8 @@ static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
241 return(0); 241 return(0);
242 } 242 }
243 243
244 ERR_clear_error(); /* make sure no error from X509_check_private_key()
245 * is left if we have chosen to ignore it */
244 if (c->pkeys[i].privatekey != NULL) 246 if (c->pkeys[i].privatekey != NULL)
245 EVP_PKEY_free(c->pkeys[i].privatekey); 247 EVP_PKEY_free(c->pkeys[i].privatekey);
246 CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY); 248 CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
diff --git a/src/lib/libssl/src/ssl/ssl_sess.c b/src/lib/libssl/src/ssl/ssl_sess.c
index fbc30b94e6..fabcdefa6e 100644
--- a/src/lib/libssl/src/ssl/ssl_sess.c
+++ b/src/lib/libssl/src/ssl/ssl_sess.c
@@ -79,11 +79,11 @@ SSL_SESSION *SSL_get1_session(SSL *ssl)
79 /* Need to lock this all up rather than just use CRYPTO_add so that 79 /* Need to lock this all up rather than just use CRYPTO_add so that
80 * somebody doesn't free ssl->session between when we check it's 80 * somebody doesn't free ssl->session between when we check it's
81 * non-null and when we up the reference count. */ 81 * non-null and when we up the reference count. */
82 CRYPTO_r_lock(CRYPTO_LOCK_SSL_SESSION); 82 CRYPTO_w_lock(CRYPTO_LOCK_SSL_SESSION);
83 sess = ssl->session; 83 sess = ssl->session;
84 if(sess) 84 if(sess)
85 sess->references++; 85 sess->references++;
86 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_SESSION); 86 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_SESSION);
87 return(sess); 87 return(sess);
88 } 88 }
89 89
diff --git a/src/lib/libssl/src/ssl/ssltest.c b/src/lib/libssl/src/ssl/ssltest.c
index 47c383200a..42289c255b 100644
--- a/src/lib/libssl/src/ssl/ssltest.c
+++ b/src/lib/libssl/src/ssl/ssltest.c
@@ -290,7 +290,7 @@ static void lock_dbg_cb(int mode, int type, const char *file, int line)
290 goto err; 290 goto err;
291 } 291 }
292 292
293 if (type < 0 || type > CRYPTO_NUM_LOCKS) 293 if (type < 0 || type >= CRYPTO_NUM_LOCKS)
294 { 294 {
295 errstr = "type out of bounds"; 295 errstr = "type out of bounds";
296 goto err; 296 goto err;
diff --git a/src/lib/libssl/src/tools/c_rehash b/src/lib/libssl/src/tools/c_rehash
index 3e9ba1efe4..e614fb5466 100644
--- a/src/lib/libssl/src/tools/c_rehash
+++ b/src/lib/libssl/src/tools/c_rehash
@@ -1,4 +1,4 @@
1#!/usr/local/bin/perl 1#!/usr/bin/perl
2 2
3 3
4# Perl c_rehash script, scan all files in a directory 4# Perl c_rehash script, scan all files in a directory
diff --git a/src/lib/libssl/src/util/extract-names.pl b/src/lib/libssl/src/util/extract-names.pl
index d413a045cc..9f2ad5ef16 100644
--- a/src/lib/libssl/src/util/extract-names.pl
+++ b/src/lib/libssl/src/util/extract-names.pl
@@ -9,8 +9,8 @@ while(<STDIN>) {
9 } elsif ($name) { 9 } elsif ($name) {
10 if (/ - /) { 10 if (/ - /) {
11 s/ - .*//; 11 s/ - .*//;
12 s/[ \t,]+/ /g; 12 s/,[ \t]+/,/g;
13 push @words, split ' '; 13 push @words, split ',';
14 } 14 }
15 } 15 }
16 if (/^=head1 *NAME *$/) { 16 if (/^=head1 *NAME *$/) {
diff --git a/src/lib/libssl/src/util/libeay.num b/src/lib/libssl/src/util/libeay.num
index f5c8c0be8a..203c7713e7 100644
--- a/src/lib/libssl/src/util/libeay.num
+++ b/src/lib/libssl/src/util/libeay.num
@@ -2801,3 +2801,5 @@ BIO_indent 3242 EXIST::FUNCTION:
2801BUF_strlcpy 3243 EXIST::FUNCTION: 2801BUF_strlcpy 3243 EXIST::FUNCTION:
2802OpenSSLDie 3244 EXIST::FUNCTION: 2802OpenSSLDie 3244 EXIST::FUNCTION:
2803OPENSSL_cleanse 3245 EXIST::FUNCTION: 2803OPENSSL_cleanse 3245 EXIST::FUNCTION:
2804ENGINE_setup_bsd_cryptodev 3246 EXIST:__FreeBSD__:FUNCTION:ENGINE
2805ERR_release_err_state_table 3247 EXIST::FUNCTION:LHASH
diff --git a/src/lib/libssl/src/util/pl/Mingw32.pl b/src/lib/libssl/src/util/pl/Mingw32.pl
index 043a3a53ee..4bee638c4a 100644
--- a/src/lib/libssl/src/util/pl/Mingw32.pl
+++ b/src/lib/libssl/src/util/pl/Mingw32.pl
@@ -85,7 +85,7 @@ sub do_lib_rule
85 ($Name=$name) =~ tr/a-z/A-Z/; 85 ($Name=$name) =~ tr/a-z/A-Z/;
86 86
87 $ret.="$target: \$(${Name}OBJ)\n"; 87 $ret.="$target: \$(${Name}OBJ)\n";
88 $ret.="\t\$(RM) $target\n"; 88 $ret.="\tif exist $target \$(RM) $target\n";
89 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n"; 89 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
90 $ret.="\t\$(RANLIB) $target\n\n"; 90 $ret.="\t\$(RANLIB) $target\n\n";
91 } 91 }
diff --git a/src/lib/libssl/src/util/point.sh b/src/lib/libssl/src/util/point.sh
index ce7dcc56df..4790e08f8a 100644
--- a/src/lib/libssl/src/util/point.sh
+++ b/src/lib/libssl/src/util/point.sh
@@ -1,10 +1,10 @@
1#!/bin/sh 1#!/bin/sh
2 2
3rm -f $2 3rm -f "$2"
4if test "$OSTYPE" = msdosdjgpp; then 4if test "$OSTYPE" = msdosdjgpp; then
5 cp $1 $2 5 cp "$1" "$2"
6else 6else
7 ln -s $1 $2 7 ln -s "$1" "$2"
8fi 8fi
9echo "$2 => $1" 9echo "$2 => $1"
10 10