Revision aa3b4b4d

View differences:

deps/openssl/openssl/CHANGES
2 2
 OpenSSL CHANGES
3 3
 _______________
4 4

  
5
 Changes between 1.0.1h and 1.0.1i [6 Aug 2014]
6

  
7
  *) Fix SRP buffer overrun vulnerability. Invalid parameters passed to the
8
     SRP code can be overrun an internal buffer. Add sanity check that
9
     g, A, B < N to SRP code.
10

  
11
     Thanks to Sean Devlin and Watson Ladd of Cryptography Services, NCC
12
     Group for discovering this issue.
13
     (CVE-2014-3512)
14
     [Steve Henson]
15

  
16
  *) A flaw in the OpenSSL SSL/TLS server code causes the server to negotiate
17
     TLS 1.0 instead of higher protocol versions when the ClientHello message
18
     is badly fragmented. This allows a man-in-the-middle attacker to force a
19
     downgrade to TLS 1.0 even if both the server and the client support a
20
     higher protocol version, by modifying the client's TLS records.
21

  
22
     Thanks to David Benjamin and Adam Langley (Google) for discovering and
23
     researching this issue.
24
     (CVE-2014-3511)
25
     [David Benjamin]
26

  
27
  *) OpenSSL DTLS clients enabling anonymous (EC)DH ciphersuites are subject
28
     to a denial of service attack. A malicious server can crash the client
29
     with a null pointer dereference (read) by specifying an anonymous (EC)DH
30
     ciphersuite and sending carefully crafted handshake messages.
31

  
32
     Thanks to Felix Gr?bert (Google) for discovering and researching this
33
     issue.
34
     (CVE-2014-3510)
35
     [Emilia K?sper]
36

  
37
  *) By sending carefully crafted DTLS packets an attacker could cause openssl
38
     to leak memory. This can be exploited through a Denial of Service attack.
39
     Thanks to Adam Langley for discovering and researching this issue.
40
     (CVE-2014-3507)
41
     [Adam Langley]
42

  
43
  *) An attacker can force openssl to consume large amounts of memory whilst
44
     processing DTLS handshake messages. This can be exploited through a
45
     Denial of Service attack.
46
     Thanks to Adam Langley for discovering and researching this issue.
47
     (CVE-2014-3506)
48
     [Adam Langley]
49

  
50
  *) An attacker can force an error condition which causes openssl to crash
51
     whilst processing DTLS packets due to memory being freed twice. This
52
     can be exploited through a Denial of Service attack.
53
     Thanks to Adam Langley and Wan-Teh Chang for discovering and researching
54
     this issue.
55
     (CVE-2014-3505)
56
     [Adam Langley]
57

  
58
  *) If a multithreaded client connects to a malicious server using a resumed
59
     session and the server sends an ec point format extension it could write
60
     up to 255 bytes to freed memory.
61

  
62
     Thanks to Gabor Tyukasz (LogMeIn Inc) for discovering and researching this
63
     issue.
64
     (CVE-2014-3509)
65
     [Gabor Tyukasz]
66

  
67
  *) A malicious server can crash an OpenSSL client with a null pointer
68
     dereference (read) by specifying an SRP ciphersuite even though it was not
69
     properly negotiated with the client. This can be exploited through a
70
     Denial of Service attack.
71

  
72
     Thanks to Joonas Kuorilehto and Riku Hietam?ki (Codenomicon) for
73
     discovering and researching this issue.
74
     (CVE-2014-5139)
75
     [Steve Henson]
76

  
77
  *) A flaw in OBJ_obj2txt may cause pretty printing functions such as
78
     X509_name_oneline, X509_name_print_ex et al. to leak some information
79
     from the stack. Applications may be affected if they echo pretty printing
80
     output to the attacker.
81

  
82
     Thanks to Ivan Fratric (Google) for discovering this issue.
83
     (CVE-2014-3508)
84
     [Emilia K?sper, and Steve Henson]
85

  
86
  *) Fix ec_GFp_simple_points_make_affine (thus, EC_POINTs_mul etc.)
87
     for corner cases. (Certain input points at infinity could lead to
88
     bogus results, with non-infinity inputs mapped to infinity too.)
89
     [Bodo Moeller]
90

  
5 91
 Changes between 1.0.1g and 1.0.1h [5 Jun 2014]
6 92

  
7 93
  *) Fix for SSL/TLS MITM flaw. An attacker using a carefully crafted
deps/openssl/openssl/Configure
720 720
		 "sctp"       => "default",
721 721
		 "shared"         => "default",
722 722
		 "store"	  => "experimental",
723
		 "unit-test"	  => "default",
723 724
		 "zlib"           => "default",
724 725
		 "zlib-dynamic"   => "default"
725 726
	       );
......
727 728

  
728 729
# This is what $depflags will look like with the above defaults
729 730
# (we need this to see if we should advise the user to run "make depend"):
730
my $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_STORE";
731
my $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST";
731 732

  
732 733
# Explicit "no-..." options will be collected in %disabled along with the defaults.
733 734
# To remove something from %disabled, use "enable-foo" (unless it's experimental).
deps/openssl/openssl/FAQ
113 113
documentation is included in each OpenSSL distribution under the docs
114 114
directory.
115 115

  
116
For information on parts of libcrypto that are not yet documented, you
117
might want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's
118
predecessor, at <URL: http://www.columbia.edu/~ariel/ssleay/>.  Much
119
of this still applies to OpenSSL.
120

  
121 116
There is some documentation about certificate extensions and PKCS#12
122 117
in doc/openssl.txt
123 118

  
deps/openssl/openssl/Makefile
4 4
## Makefile for OpenSSL
5 5
##
6 6

  
7
VERSION=1.0.1h
7
VERSION=1.0.1i
8 8
MAJOR=1
9 9
MINOR=0.1
10 10
SHLIB_VERSION_NUMBER=1.0.0
......
13 13
SHLIB_MINOR=0.0
14 14
SHLIB_EXT=
15 15
PLATFORM=dist
16
OPTIONS= no-ec_nistp_64_gcc_128 no-gmp no-jpake no-krb5 no-md2 no-rc5 no-rfc3779 no-sctp no-shared no-store no-zlib no-zlib-dynamic static-engine
16
OPTIONS= no-ec_nistp_64_gcc_128 no-gmp no-jpake no-krb5 no-md2 no-rc5 no-rfc3779 no-sctp no-shared no-store no-unit-test no-zlib no-zlib-dynamic static-engine
17 17
CONFIGURE_ARGS=dist
18 18
SHLIB_TARGET=
19 19

  
......
61 61

  
62 62
CC= cc
63 63
CFLAG= -O
64
DEPFLAG= -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_STORE
64
DEPFLAG= -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST
65 65
PEX_LIBS= 
66 66
EX_LIBS= 
67 67
EXE_EXT= 
deps/openssl/openssl/Makefile.bak
4 4
## Makefile for OpenSSL
5 5
##
6 6

  
7
VERSION=1.0.1h-dev
7
VERSION=1.0.1i-dev
8 8
MAJOR=1
9 9
MINOR=0.1
10 10
SHLIB_VERSION_NUMBER=1.0.0
......
13 13
SHLIB_MINOR=0.0
14 14
SHLIB_EXT=
15 15
PLATFORM=gcc
16
OPTIONS= no-ec_nistp_64_gcc_128 no-gmp no-jpake no-krb5 no-md2 no-rc5 no-rfc3779 no-sctp no-shared no-store no-zlib no-zlib-dynamic static-engine
16
OPTIONS= no-ec_nistp_64_gcc_128 no-gmp no-jpake no-krb5 no-md2 no-rc5 no-rfc3779 no-sctp no-shared no-store no-unit-test no-zlib no-zlib-dynamic static-engine
17 17
CONFIGURE_ARGS=gcc
18 18
SHLIB_TARGET=
19 19

  
......
61 61

  
62 62
CC= gcc
63 63
CFLAG= -O3
64
DEPFLAG= -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_STORE
64
DEPFLAG= -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST
65 65
PEX_LIBS= 
66 66
EX_LIBS= 
67 67
EXE_EXT= 
deps/openssl/openssl/NEWS
5 5
  This file gives a brief overview of the major changes between each OpenSSL
6 6
  release. For more details please read the CHANGES file.
7 7

  
8
  Major changes between OpenSSL 1.0.1h and OpenSSL 1.0.1i [6 Aug 2014]
9

  
10
      o Fix for CVE-2014-3512
11
      o Fix for CVE-2014-3511
12
      o Fix for CVE-2014-3510
13
      o Fix for CVE-2014-3507
14
      o Fix for CVE-2014-3506
15
      o Fix for CVE-2014-3505
16
      o Fix for CVE-2014-3509
17
      o Fix for CVE-2014-5139
18
      o Fix for CVE-2014-3508
19

  
8 20
  Major changes between OpenSSL 1.0.1g and OpenSSL 1.0.1h [5 Jun 2014]
9 21

  
10 22
      o Fix for CVE-2014-0224
11 23
      o Fix for CVE-2014-0221
24
      o Fix for CVE-2014-0198
12 25
      o Fix for CVE-2014-0195
13 26
      o Fix for CVE-2014-3470
14 27
      o Fix for CVE-2010-5298
deps/openssl/openssl/README
1 1

  
2
 OpenSSL 1.0.1h 5 Jun 2014
2
 OpenSSL 1.0.1i 6 Aug 2014
3 3

  
4 4
 Copyright (c) 1998-2011 The OpenSSL Project
5 5
 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
deps/openssl/openssl/apps/apps.c
390 390
		{
391 391
		arg->count=20;
392 392
		arg->data=(char **)OPENSSL_malloc(sizeof(char *)*arg->count);
393
		if (arg->data == NULL)
394
			return 0;
393 395
		}
394 396
	for (i=0; i<arg->count; i++)
395 397
		arg->data[i]=NULL;
......
1542 1544

  
1543 1545
	len=strlen(t)+strlen(OPENSSL_CONF)+2;
1544 1546
	p=OPENSSL_malloc(len);
1547
	if (p == NULL)
1548
		return NULL;
1545 1549
	BUF_strlcpy(p,t,len);
1546 1550
#ifndef OPENSSL_SYS_VMS
1547 1551
	BUF_strlcat(p,"/",len);
deps/openssl/openssl/apps/ca.c
1620 1620
		{
1621 1621
		ok=0;
1622 1622
		BIO_printf(bio_err,"Signature verification problems....\n");
1623
		ERR_print_errors(bio_err);
1623 1624
		goto err;
1624 1625
		}
1625 1626
	if (i == 0)
1626 1627
		{
1627 1628
		ok=0;
1628 1629
		BIO_printf(bio_err,"Signature did not match the certificate request\n");
1630
		ERR_print_errors(bio_err);
1629 1631
		goto err;
1630 1632
		}
1631 1633
	else
......
2777 2779

  
2778 2780
	revtm = X509_gmtime_adj(NULL, 0);
2779 2781

  
2782
	if (!revtm)
2783
		return NULL;
2784

  
2780 2785
	i = revtm->length + 1;
2781 2786

  
2782 2787
	if (reason) i += strlen(reason) + 1;
deps/openssl/openssl/apps/ciphers.c
96 96
	char buf[512];
97 97
	BIO *STDout=NULL;
98 98

  
99
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
100 99
	meth=SSLv23_server_method();
101
#elif !defined(OPENSSL_NO_SSL3)
102
	meth=SSLv3_server_method();
103
#elif !defined(OPENSSL_NO_SSL2)
104
	meth=SSLv2_server_method();
105
#endif
106 100

  
107 101
	apps_startup();
108 102

  
deps/openssl/openssl/apps/crl2p7.c
141 141
			{
142 142
			if (--argc < 1) goto bad;
143 143
			if(!certflst) certflst = sk_OPENSSL_STRING_new_null();
144
			sk_OPENSSL_STRING_push(certflst,*(++argv));
144
			if (!certflst)
145
				goto end;
146
			if (!sk_OPENSSL_STRING_push(certflst,*(++argv)))
147
				{
148
				sk_OPENSSL_STRING_free(certflst);
149
				goto end;
150
				}
145 151
			}
146 152
		else
147 153
			{
deps/openssl/openssl/apps/enc.c
67 67
#include <openssl/x509.h>
68 68
#include <openssl/rand.h>
69 69
#include <openssl/pem.h>
70
#ifndef OPENSSL_NO_COMP
70 71
#include <openssl/comp.h>
72
#endif
71 73
#include <ctype.h>
72 74

  
73 75
int set_hex(char *in,unsigned char *out,int size);
......
337 339
		goto end;
338 340
		}
339 341

  
342
	if (cipher && (EVP_CIPHER_mode(cipher) == EVP_CIPH_XTS_MODE))
343
		{
344
		BIO_printf(bio_err, "Ciphers in XTS mode are not supported by the enc utility\n");
345
		goto end;
346
		}
347

  
340 348
	if (md && (dgst=EVP_get_digestbyname(md)) == NULL)
341 349
		{
342 350
		BIO_printf(bio_err,"%s is an unsupported message digest type\n",md);
deps/openssl/openssl/apps/ocsp.c
1419 1419
		}
1420 1420
	resp = query_responder(err, cbio, path, headers, req, req_timeout);
1421 1421
	if (!resp)
1422
		BIO_printf(bio_err, "Error querying OCSP responsder\n");
1422
		BIO_printf(bio_err, "Error querying OCSP responder\n");
1423 1423
	end:
1424 1424
	if (cbio)
1425 1425
		BIO_free_all(cbio);
deps/openssl/openssl/apps/progs.h
107 107
	{FUNC_TYPE_GENERAL,"gendsa",gendsa_main},
108 108
#endif
109 109
	{FUNC_TYPE_GENERAL,"genpkey",genpkey_main},
110
#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
110
#if !defined(OPENSSL_NO_SOCK)
111 111
	{FUNC_TYPE_GENERAL,"s_server",s_server_main},
112 112
#endif
113
#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
113
#if !defined(OPENSSL_NO_SOCK)
114 114
	{FUNC_TYPE_GENERAL,"s_client",s_client_main},
115 115
#endif
116 116
#ifndef OPENSSL_NO_SPEED
117 117
	{FUNC_TYPE_GENERAL,"speed",speed_main},
118 118
#endif
119
#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
119
#if !defined(OPENSSL_NO_SOCK)
120 120
	{FUNC_TYPE_GENERAL,"s_time",s_time_main},
121 121
#endif
122 122
	{FUNC_TYPE_GENERAL,"version",version_main},
......
126 126
#endif
127 127
	{FUNC_TYPE_GENERAL,"crl2pkcs7",crl2pkcs7_main},
128 128
	{FUNC_TYPE_GENERAL,"sess_id",sess_id_main},
129
#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
129
#if !defined(OPENSSL_NO_SOCK)
130 130
	{FUNC_TYPE_GENERAL,"ciphers",ciphers_main},
131 131
#endif
132 132
	{FUNC_TYPE_GENERAL,"nseq",nseq_main},
deps/openssl/openssl/apps/progs.pl
32 32
	push(@files,$_);
33 33
	$str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
34 34
	if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
35
		{ print "#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))\n${str}#endif\n"; } 
35
		{ print "#if !defined(OPENSSL_NO_SOCK)\n${str}#endif\n"; } 
36 36
	elsif ( ($_ =~ /^speed$/))
37 37
		{ print "#ifndef OPENSSL_NO_SPEED\n${str}#endif\n"; }
38 38
	elsif ( ($_ =~ /^engine$/))
deps/openssl/openssl/apps/s_client.c
178 178
#include <fcntl.h>
179 179
#endif
180 180

  
181
/* Use Windows API with STD_INPUT_HANDLE when checking for input?
182
   Don't look at OPENSSL_SYS_MSDOS for this, since it is always defined if
183
   OPENSSL_SYS_WINDOWS is defined */
184
#if defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_WINCE) && defined(STD_INPUT_HANDLE)
185
#define OPENSSL_USE_STD_INPUT_HANDLE
186
#endif
187

  
188 181
#undef PROG
189 182
#define PROG	s_client_main
190 183

  
......
297 290
	BIO_printf(bio_err," -connect host:port - who to connect to (default is %s:%s)\n",SSL_HOST_NAME,PORT_STR);
298 291

  
299 292
	BIO_printf(bio_err," -verify arg   - turn on peer certificate verification\n");
293
	BIO_printf(bio_err," -verify_return_error - return verification errors\n");
300 294
	BIO_printf(bio_err," -cert arg     - certificate file to use, PEM format assumed\n");
301 295
	BIO_printf(bio_err," -certform arg - certificate format (PEM or DER) PEM default\n");
302 296
	BIO_printf(bio_err," -key arg      - Private key file to use, in cert file if\n");
......
307 301
	BIO_printf(bio_err," -CAfile arg   - PEM format file of CA's\n");
308 302
	BIO_printf(bio_err," -reconnect    - Drop and re-make the connection with the same Session-ID\n");
309 303
	BIO_printf(bio_err," -pause        - sleep(1) after each read(2) and write(2) system call\n");
304
	BIO_printf(bio_err," -prexit       - print session information even on connection failure\n");
310 305
	BIO_printf(bio_err," -showcerts    - show all certificates in the chain\n");
311 306
	BIO_printf(bio_err," -debug        - extra output\n");
312 307
#ifdef WATT32
......
1611 1606
					tv.tv_usec = 0;
1612 1607
					i=select(width,(void *)&readfds,(void *)&writefds,
1613 1608
						 NULL,&tv);
1614
#if defined(OPENSSL_USE_STD_INPUT_HANDLE)
1615
					if(!i && (!((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) || !read_tty) ) continue;
1616
#else
1609
#if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
1617 1610
					if(!i && (!_kbhit() || !read_tty) ) continue;
1611
#else
1612
					if(!i && (!((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) || !read_tty) ) continue;
1618 1613
#endif
1619 1614
				} else 	i=select(width,(void *)&readfds,(void *)&writefds,
1620 1615
					 NULL,timeoutp);
......
1819 1814
			}
1820 1815

  
1821 1816
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
1822
#if defined(OPENSSL_USE_STD_INPUT_HANDLE)
1823
		else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0)))
1824
#else
1817
#if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
1825 1818
		else if (_kbhit())
1819
#else
1820
		else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0)))
1826 1821
#endif
1827 1822
#elif defined (OPENSSL_SYS_NETWARE)
1828 1823
		else if (_kbhit())
deps/openssl/openssl/apps/s_server.c
463 463
	BIO_printf(bio_err," -context arg  - set session ID context\n");
464 464
	BIO_printf(bio_err," -verify arg   - turn on peer certificate verification\n");
465 465
	BIO_printf(bio_err," -Verify arg   - turn on peer certificate verification, must have a cert.\n");
466
	BIO_printf(bio_err," -verify_return_error - return verification errors\n");
466 467
	BIO_printf(bio_err," -cert arg     - certificate file to use\n");
467 468
	BIO_printf(bio_err,"                 (default is %s)\n",TEST_CERT);
468 469
	BIO_printf(bio_err," -crl_check    - check the peer certificate has not been revoked by its CA.\n" \
......
534 535
	BIO_printf(bio_err," -no_ecdhe     - Disable ephemeral ECDH\n");
535 536
#endif
536 537
	BIO_printf(bio_err," -bugs         - Turn on SSL bug compatibility\n");
538
	BIO_printf(bio_err," -hack         - workaround for early Netscape code\n");
537 539
	BIO_printf(bio_err," -www          - Respond to a 'GET /' with a status page\n");
538 540
	BIO_printf(bio_err," -WWW          - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
539 541
	BIO_printf(bio_err," -HTTP         - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
......
562 564
#endif
563 565
	BIO_printf(bio_err," -keymatexport label   - Export keying material using label\n");
564 566
	BIO_printf(bio_err," -keymatexportlen len  - Export len bytes of keying material (default 20)\n");
567
	BIO_printf(bio_err," -status           - respond to certificate status requests\n");
568
	BIO_printf(bio_err," -status_verbose   - enable status request verbose printout\n");
569
	BIO_printf(bio_err," -status_timeout n - status request responder timeout\n");
570
	BIO_printf(bio_err," -status_url URL   - status request fallback URL\n");
565 571
	}
566 572

  
567 573
static int local_argc=0;
......
739 745
	
740 746
	if (servername)
741 747
		{
742
    		if (strcmp(servername,p->servername)) 
748
    		if (strcasecmp(servername,p->servername)) 
743 749
			return p->extension_error;
744 750
		if (ctx2)
745 751
			{
......
1356 1362
		sv_usage();
1357 1363
		goto end;
1358 1364
		}
1365
#ifndef OPENSSL_NO_DTLS1
1366
	if (www && socket_type == SOCK_DGRAM)
1367
		{
1368
		BIO_printf(bio_err,
1369
				"Can't use -HTTP, -www or -WWW with DTLS\n");
1370
		goto end;
1371
		}
1372
#endif
1359 1373

  
1360 1374
#if !defined(OPENSSL_NO_JPAKE) && !defined(OPENSSL_NO_PSK)
1361 1375
	if (jpake_secret)
deps/openssl/openssl/crypto/asn1/a_object.c
283 283
	ASN1err(ASN1_F_D2I_ASN1_OBJECT,i);
284 284
	return(NULL);
285 285
}
286

  
286 287
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
287 288
	     long len)
288 289
	{
289 290
	ASN1_OBJECT *ret=NULL;
290 291
	const unsigned char *p;
291 292
	unsigned char *data;
292
	int i;
293
	/* Sanity check OID encoding: can't have leading 0x80 in
294
	 * subidentifiers, see: X.690 8.19.2
293
	int i, length;
294

  
295
	/* Sanity check OID encoding.
296
	 * Need at least one content octet.
297
	 * MSB must be clear in the last octet.
298
	 * can't have leading 0x80 in subidentifiers, see: X.690 8.19.2
295 299
	 */
296
	for (i = 0, p = *pp; i < len; i++, p++)
300
	if (len <= 0 || len > INT_MAX || pp == NULL || (p = *pp) == NULL ||
301
	    p[len - 1] & 0x80)
302
		{
303
		ASN1err(ASN1_F_C2I_ASN1_OBJECT,ASN1_R_INVALID_OBJECT_ENCODING);
304
		return NULL;
305
		}
306
	/* Now 0 < len <= INT_MAX, so the cast is safe. */
307
	length = (int)len;
308
	for (i = 0; i < length; i++, p++)
297 309
		{
298 310
		if (*p == 0x80 && (!i || !(p[-1] & 0x80)))
299 311
			{
......
316 328
	data = (unsigned char *)ret->data;
317 329
	ret->data = NULL;
318 330
	/* once detached we can change it */
319
	if ((data == NULL) || (ret->length < len))
331
	if ((data == NULL) || (ret->length < length))
320 332
		{
321 333
		ret->length=0;
322 334
		if (data != NULL) OPENSSL_free(data);
323
		data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1);
335
		data=(unsigned char *)OPENSSL_malloc(length);
324 336
		if (data == NULL)
325 337
			{ i=ERR_R_MALLOC_FAILURE; goto err; }
326 338
		ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
327 339
		}
328
	memcpy(data,p,(int)len);
340
	memcpy(data,p,length);
329 341
	/* reattach data to object, after which it remains const */
330 342
	ret->data  =data;
331
	ret->length=(int)len;
343
	ret->length=length;
332 344
	ret->sn=NULL;
333 345
	ret->ln=NULL;
334 346
	/* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
335
	p+=len;
347
	p+=length;
336 348

  
337 349
	if (a != NULL) (*a)=ret;
338 350
	*pp=p;
deps/openssl/openssl/crypto/asn1/a_utctm.c
196 196
	struct tm *ts;
197 197
	struct tm data;
198 198
	size_t len = 20;
199
	int free_s = 0;
199 200

  
200 201
	if (s == NULL)
202
		{
203
		free_s = 1;
201 204
		s=M_ASN1_UTCTIME_new();
205
		}
202 206
	if (s == NULL)
203
		return(NULL);
207
		goto err;
208

  
204 209

  
205 210
	ts=OPENSSL_gmtime(&t, &data);
206 211
	if (ts == NULL)
207
		return(NULL);
212
		goto err;
208 213

  
209 214
	if (offset_day || offset_sec)
210 215
		{ 
211 216
		if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
212
			return NULL;
217
			goto err;
213 218
		}
214 219

  
215 220
	if((ts->tm_year < 50) || (ts->tm_year >= 150))
216
		return NULL;
221
		goto err;
217 222

  
218 223
	p=(char *)s->data;
219 224
	if ((p == NULL) || ((size_t)s->length < len))
......
222 227
		if (p == NULL)
223 228
			{
224 229
			ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE);
225
			return(NULL);
230
			goto err;
226 231
			}
227 232
		if (s->data != NULL)
228 233
			OPENSSL_free(s->data);
......
237 242
	ebcdic2ascii(s->data, s->data, s->length);
238 243
#endif
239 244
	return(s);
245
	err:
246
	if (free_s && s)
247
		M_ASN1_UTCTIME_free(s);
248
	return NULL;
240 249
	}
241 250

  
242 251

  
......
261 270
	t -= offset*60; /* FIXME: may overflow in extreme cases */
262 271

  
263 272
	tm = OPENSSL_gmtime(&t, &data);
273
	/* NB: -1, 0, 1 already valid return values so use -2 to
274
	 * indicate error.
275
	 */
276
	if (tm == NULL)
277
		return -2;
264 278
	
265 279
#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
266 280
	year = g2(s->data);
deps/openssl/openssl/crypto/asn1/ameth_lib.c
258 258
	if (!ameth)
259 259
		return 0;
260 260
	ameth->pkey_base_id = to;
261
	return EVP_PKEY_asn1_add0(ameth);
261
	if (!EVP_PKEY_asn1_add0(ameth))
262
		{
263
		EVP_PKEY_asn1_free(ameth);
264
		return 0;
265
		}
266
	return 1;
262 267
	}
263 268

  
264 269
int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags,
deps/openssl/openssl/crypto/asn1/asn1_lib.c
131 131
	*pclass=xclass;
132 132
	if (!asn1_get_length(&p,&inf,plength,(int)max)) goto err;
133 133

  
134
	if (inf && !(ret & V_ASN1_CONSTRUCTED))
135
		goto err;
136

  
134 137
#if 0
135 138
	fprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d  (%d > %d)\n", 
136 139
		(int)p,*plength,omax,(int)*pp,(int)(p+ *plength),
deps/openssl/openssl/crypto/asn1/asn_mime.c
667 667
	int len, state, save_state = 0;
668 668

  
669 669
	headers = sk_MIME_HEADER_new(mime_hdr_cmp);
670
	if (!headers)
671
		return NULL;
670 672
	while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
671 673
	/* If whitespace at line start then continuation line */
672 674
	if(mhdr && isspace((unsigned char)linebuf[0])) state = MIME_NAME;
deps/openssl/openssl/crypto/asn1/asn_pack.c
134 134
		
135 135
	if (!(octmp->length = i2d(obj, NULL))) {
136 136
		ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR);
137
		return NULL;
137
		goto err;
138 138
	}
139 139
	if (!(p = OPENSSL_malloc (octmp->length))) {
140 140
		ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE);
141
		return NULL;
141
		goto err;
142 142
	}
143 143
	octmp->data = p;
144 144
	i2d (obj, &p);
145 145
	return octmp;
146
	err:
147
	if (!oct || !*oct)
148
		{
149
		ASN1_STRING_free(octmp);
150
		if (oct)
151
			*oct = NULL;
152
		}
153
	return NULL;
146 154
}
147 155

  
148 156
#endif
deps/openssl/openssl/crypto/asn1/bio_asn1.c
154 154
	if (!ctx)
155 155
		return 0;
156 156
	if (!asn1_bio_init(ctx, DEFAULT_ASN1_BUF_SIZE))
157
		{
158
		OPENSSL_free(ctx);
157 159
		return 0;
160
		}
158 161
	b->init = 1;
159 162
	b->ptr = (char *)ctx;
160 163
	b->flags = 0;
deps/openssl/openssl/crypto/asn1/charmap.pl
1 1
#!/usr/local/bin/perl -w
2 2

  
3
# Written by Dr Stephen N Henson (steve@openssl.org).
4
# Licensed under the terms of the OpenSSL license.
5

  
3 6
use strict;
4 7

  
5 8
my ($i, @arr);
deps/openssl/openssl/crypto/asn1/evp_asn1.c
66 66
	ASN1_STRING *os;
67 67

  
68 68
	if ((os=M_ASN1_OCTET_STRING_new()) == NULL) return(0);
69
	if (!M_ASN1_OCTET_STRING_set(os,data,len)) return(0);
69
	if (!M_ASN1_OCTET_STRING_set(os,data,len))
70
		{
71
		M_ASN1_OCTET_STRING_free(os);
72
		return 0;
73
		}
70 74
	ASN1_TYPE_set(a,V_ASN1_OCTET_STRING,os);
71 75
	return(1);
72 76
	}
deps/openssl/openssl/crypto/asn1/t_x509.c
475 475
	l=80-2-obase;
476 476

  
477 477
	b=X509_NAME_oneline(name,NULL,0);
478
	if (!b)
479
		return 0;
478 480
	if (!*b)
479 481
		{
480 482
		OPENSSL_free(b);
deps/openssl/openssl/crypto/asn1/tasn_enc.c
453 453
			{
454 454
			derlst = OPENSSL_malloc(sk_ASN1_VALUE_num(sk)
455 455
						* sizeof(*derlst));
456
			if (!derlst)
457
				return 0;
456 458
			tmpdat = OPENSSL_malloc(skcontlen);
457
			if (!derlst || !tmpdat)
459
			if (!tmpdat)
460
				{
461
				OPENSSL_free(derlst);
458 462
				return 0;
463
				}
459 464
			}
460 465
		}
461 466
	/* If not sorting just output each item */
deps/openssl/openssl/crypto/asn1/x_crl.c
270 270
				{
271 271
				/* We handle IDP and deltas */
272 272
				if ((nid == NID_issuing_distribution_point)
273
					|| (nid == NID_authority_key_identifier)
273 274
					|| (nid == NID_delta_crl))
274 275
					break;;
275 276
				crl->flags |= EXFLAG_CRITICAL;
deps/openssl/openssl/crypto/bio/bio_lib.c
132 132

  
133 133
	CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);
134 134

  
135
	if ((a->method == NULL) || (a->method->destroy == NULL)) return(1);
136
	a->method->destroy(a);
135
	if ((a->method != NULL) && (a->method->destroy != NULL))
136
		a->method->destroy(a);
137 137
	OPENSSL_free(a);
138 138
	return(1);
139 139
	}
deps/openssl/openssl/crypto/bn/bn_lib.c
320 320
		BNerr(BN_F_BN_EXPAND_INTERNAL,ERR_R_MALLOC_FAILURE);
321 321
		return(NULL);
322 322
		}
323
#ifdef PURIFY
324
	/* Valgrind complains in BN_consttime_swap because we process the whole
325
	 * array even if it's not initialised yet. This doesn't matter in that
326
	 * function - what's important is constant time operation (we're not
327
	 * actually going to use the data)
328
	*/
329
	memset(a, 0, sizeof(BN_ULONG)*words);
330
#endif
331

  
323 332
#if 1
324 333
	B=b->d;
325 334
	/* Check if the previous number needs to be copied */
deps/openssl/openssl/crypto/bn/bn_sqr.c
77 77
	if (al <= 0)
78 78
		{
79 79
		r->top=0;
80
		r->neg = 0;
80 81
		return 1;
81 82
		}
82 83

  
deps/openssl/openssl/crypto/cms/cms_pwri.c
93 93
	X509_ALGOR *encalg = NULL;
94 94
	unsigned char iv[EVP_MAX_IV_LENGTH];
95 95
	int ivlen;
96

  
96 97
	env = cms_get0_enveloped(cms);
97 98
	if (!env)
98
		goto err;
99
		return NULL;
99 100

  
100 101
	if (wrap_nid <= 0)
101 102
		wrap_nid = NID_id_alg_PWRI_KEK;
deps/openssl/openssl/crypto/conf/conf_def.c
321 321
			p=eat_ws(conf, end);
322 322
			if (*p != ']')
323 323
				{
324
				if (*p != '\0')
324
				if (*p != '\0' && ss != p)
325 325
					{
326 326
					ss=p;
327 327
					goto again;
deps/openssl/openssl/crypto/ec/ec_lib.c
942 942

  
943 943
int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx)
944 944
	{
945
	if (group->meth->dbl == 0)
945
	if (group->meth->invert == 0)
946 946
		{
947 947
		ECerr(EC_F_EC_POINT_INVERT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
948 948
		return 0;
deps/openssl/openssl/crypto/ec/ecp_smpl.c
1181 1181
int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
1182 1182
	{
1183 1183
	BN_CTX *new_ctx = NULL;
1184
	BIGNUM *tmp0, *tmp1;
1185
	size_t pow2 = 0;
1186
	BIGNUM **heap = NULL;
1184
	BIGNUM *tmp, *tmp_Z;
1185
	BIGNUM **prod_Z = NULL;
1187 1186
	size_t i;
1188 1187
	int ret = 0;
1189 1188

  
......
1198 1197
		}
1199 1198

  
1200 1199
	BN_CTX_start(ctx);
1201
	tmp0 = BN_CTX_get(ctx);
1202
	tmp1 = BN_CTX_get(ctx);
1203
	if (tmp0  == NULL || tmp1 == NULL) goto err;
1200
	tmp = BN_CTX_get(ctx);
1201
	tmp_Z = BN_CTX_get(ctx);
1202
	if (tmp == NULL || tmp_Z == NULL) goto err;
1204 1203

  
1205
	/* Before converting the individual points, compute inverses of all Z values.
1206
	 * Modular inversion is rather slow, but luckily we can do with a single
1207
	 * explicit inversion, plus about 3 multiplications per input value.
1208
	 */
1204
	prod_Z = OPENSSL_malloc(num * sizeof prod_Z[0]);
1205
	if (prod_Z == NULL) goto err;
1206
	for (i = 0; i < num; i++)
1207
		{
1208
		prod_Z[i] = BN_new();
1209
		if (prod_Z[i] == NULL) goto err;
1210
		}
1209 1211

  
1210
	pow2 = 1;
1211
	while (num > pow2)
1212
		pow2 <<= 1;
1213
	/* Now pow2 is the smallest power of 2 satifsying pow2 >= num.
1214
	 * We need twice that. */
1215
	pow2 <<= 1;
1212
	/* Set each prod_Z[i] to the product of points[0]->Z .. points[i]->Z,
1213
	 * skipping any zero-valued inputs (pretend that they're 1). */
1216 1214

  
1217
	heap = OPENSSL_malloc(pow2 * sizeof heap[0]);
1218
	if (heap == NULL) goto err;
1219
	
1220
	/* The array is used as a binary tree, exactly as in heapsort:
1221
	 *
1222
	 *                               heap[1]
1223
	 *                 heap[2]                     heap[3]
1224
	 *          heap[4]       heap[5]       heap[6]       heap[7]
1225
	 *   heap[8]heap[9] heap[10]heap[11] heap[12]heap[13] heap[14] heap[15]
1226
	 *
1227
	 * We put the Z's in the last line;
1228
	 * then we set each other node to the product of its two child-nodes (where
1229
	 * empty or 0 entries are treated as ones);
1230
	 * then we invert heap[1];
1231
	 * then we invert each other node by replacing it by the product of its
1232
	 * parent (after inversion) and its sibling (before inversion).
1233
	 */
1234
	heap[0] = NULL;
1235
	for (i = pow2/2 - 1; i > 0; i--)
1236
		heap[i] = NULL;
1237
	for (i = 0; i < num; i++)
1238
		heap[pow2/2 + i] = &points[i]->Z;
1239
	for (i = pow2/2 + num; i < pow2; i++)
1240
		heap[i] = NULL;
1241
	
1242
	/* set each node to the product of its children */
1243
	for (i = pow2/2 - 1; i > 0; i--)
1215
	if (!BN_is_zero(&points[0]->Z))
1244 1216
		{
1245
		heap[i] = BN_new();
1246
		if (heap[i] == NULL) goto err;
1247
		
1248
		if (heap[2*i] != NULL)
1217
		if (!BN_copy(prod_Z[0], &points[0]->Z)) goto err;
1218
		}
1219
	else
1220
		{
1221
		if (group->meth->field_set_to_one != 0)
1249 1222
			{
1250
			if ((heap[2*i + 1] == NULL) || BN_is_zero(heap[2*i + 1]))
1251
				{
1252
				if (!BN_copy(heap[i], heap[2*i])) goto err;
1253
				}
1254
			else
1255
				{
1256
				if (BN_is_zero(heap[2*i]))
1257
					{
1258
					if (!BN_copy(heap[i], heap[2*i + 1])) goto err;
1259
					}
1260
				else
1261
					{
1262
					if (!group->meth->field_mul(group, heap[i],
1263
						heap[2*i], heap[2*i + 1], ctx)) goto err;
1264
					}
1265
				}
1223
			if (!group->meth->field_set_to_one(group, prod_Z[0], ctx)) goto err;
1224
			}
1225
		else
1226
			{
1227
			if (!BN_one(prod_Z[0])) goto err;
1266 1228
			}
1267 1229
		}
1268 1230

  
1269
	/* invert heap[1] */
1270
	if (!BN_is_zero(heap[1]))
1231
	for (i = 1; i < num; i++)
1271 1232
		{
1272
		if (!BN_mod_inverse(heap[1], heap[1], &group->field, ctx))
1233
		if (!BN_is_zero(&points[i]->Z))
1273 1234
			{
1274
			ECerr(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE, ERR_R_BN_LIB);
1275
			goto err;
1235
			if (!group->meth->field_mul(group, prod_Z[i], prod_Z[i - 1], &points[i]->Z, ctx)) goto err;
1236
			}
1237
		else
1238
			{
1239
			if (!BN_copy(prod_Z[i], prod_Z[i - 1])) goto err;
1276 1240
			}
1277 1241
		}
1242

  
1243
	/* Now use a single explicit inversion to replace every
1244
	 * non-zero points[i]->Z by its inverse. */
1245

  
1246
	if (!BN_mod_inverse(tmp, prod_Z[num - 1], &group->field, ctx))
1247
		{
1248
		ECerr(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE, ERR_R_BN_LIB);
1249
		goto err;
1250
		}
1278 1251
	if (group->meth->field_encode != 0)
1279 1252
		{
1280
		/* in the Montgomery case, we just turned  R*H  (representing H)
1253
		/* In the Montgomery case, we just turned  R*H  (representing H)
1281 1254
		 * into  1/(R*H),  but we need  R*(1/H)  (representing 1/H);
1282
		 * i.e. we have need to multiply by the Montgomery factor twice */
1283
		if (!group->meth->field_encode(group, heap[1], heap[1], ctx)) goto err;
1284
		if (!group->meth->field_encode(group, heap[1], heap[1], ctx)) goto err;
1255
		 * i.e. we need to multiply by the Montgomery factor twice. */
1256
		if (!group->meth->field_encode(group, tmp, tmp, ctx)) goto err;
1257
		if (!group->meth->field_encode(group, tmp, tmp, ctx)) goto err;
1285 1258
		}
1286 1259

  
1287
	/* set other heap[i]'s to their inverses */
1288
	for (i = 2; i < pow2/2 + num; i += 2)
1260
	for (i = num - 1; i > 0; --i)
1289 1261
		{
1290
		/* i is even */
1291
		if ((heap[i + 1] != NULL) && !BN_is_zero(heap[i + 1]))
1292
			{
1293
			if (!group->meth->field_mul(group, tmp0, heap[i/2], heap[i + 1], ctx)) goto err;
1294
			if (!group->meth->field_mul(group, tmp1, heap[i/2], heap[i], ctx)) goto err;
1295
			if (!BN_copy(heap[i], tmp0)) goto err;
1296
			if (!BN_copy(heap[i + 1], tmp1)) goto err;
1297
			}
1298
		else
1262
		/* Loop invariant: tmp is the product of the inverses of
1263
		 * points[0]->Z .. points[i]->Z (zero-valued inputs skipped). */
1264
		if (!BN_is_zero(&points[i]->Z))
1299 1265
			{
1300
			if (!BN_copy(heap[i], heap[i/2])) goto err;
1266
			/* Set tmp_Z to the inverse of points[i]->Z (as product
1267
			 * of Z inverses 0 .. i, Z values 0 .. i - 1). */
1268
			if (!group->meth->field_mul(group, tmp_Z, prod_Z[i - 1], tmp, ctx)) goto err;
1269
			/* Update tmp to satisfy the loop invariant for i - 1. */
1270
			if (!group->meth->field_mul(group, tmp, tmp, &points[i]->Z, ctx)) goto err;
1271
			/* Replace points[i]->Z by its inverse. */
1272
			if (!BN_copy(&points[i]->Z, tmp_Z)) goto err;
1301 1273
			}
1302 1274
		}
1303 1275

  
1304
	/* we have replaced all non-zero Z's by their inverses, now fix up all the points */
1276
	if (!BN_is_zero(&points[0]->Z))
1277
		{
1278
		/* Replace points[0]->Z by its inverse. */
1279
		if (!BN_copy(&points[0]->Z, tmp)) goto err;
1280
		}
1281

  
1282
	/* Finally, fix up the X and Y coordinates for all points. */
1283

  
1305 1284
	for (i = 0; i < num; i++)
1306 1285
		{
1307 1286
		EC_POINT *p = points[i];
1308
		
1287

  
1309 1288
		if (!BN_is_zero(&p->Z))
1310 1289
			{
1311 1290
			/* turn  (X, Y, 1/Z)  into  (X/Z^2, Y/Z^3, 1) */
1312 1291

  
1313
			if (!group->meth->field_sqr(group, tmp1, &p->Z, ctx)) goto err;
1314
			if (!group->meth->field_mul(group, &p->X, &p->X, tmp1, ctx)) goto err;
1292
			if (!group->meth->field_sqr(group, tmp, &p->Z, ctx)) goto err;
1293
			if (!group->meth->field_mul(group, &p->X, &p->X, tmp, ctx)) goto err;
1294

  
1295
			if (!group->meth->field_mul(group, tmp, tmp, &p->Z, ctx)) goto err;
1296
			if (!group->meth->field_mul(group, &p->Y, &p->Y, tmp, ctx)) goto err;
1315 1297

  
1316
			if (!group->meth->field_mul(group, tmp1, tmp1, &p->Z, ctx)) goto err;
1317
			if (!group->meth->field_mul(group, &p->Y, &p->Y, tmp1, ctx)) goto err;
1318
		
1319 1298
			if (group->meth->field_set_to_one != 0)
1320 1299
				{
1321 1300
				if (!group->meth->field_set_to_one(group, &p->Z, ctx)) goto err;
......
1329 1308
		}
1330 1309

  
1331 1310
	ret = 1;
1332
		
1311

  
1333 1312
 err:
1334 1313
	BN_CTX_end(ctx);
1335 1314
	if (new_ctx != NULL)
1336 1315
		BN_CTX_free(new_ctx);
1337
	if (heap != NULL)
1316
	if (prod_Z != NULL)
1338 1317
		{
1339
		/* heap[pow2/2] .. heap[pow2-1] have not been allocated locally! */
1340
		for (i = pow2/2 - 1; i > 0; i--)
1318
		for (i = 0; i < num; i++)
1341 1319
			{
1342
			if (heap[i] != NULL)
1343
				BN_clear_free(heap[i]);
1320
			if (prod_Z[i] != NULL)
1321
				BN_clear_free(prod_Z[i]);
1344 1322
			}
1345
		OPENSSL_free(heap);
1323
		OPENSSL_free(prod_Z);
1346 1324
		}
1347 1325
	return ret;
1348 1326
	}
deps/openssl/openssl/crypto/ec/ectest.c
199 199
	EC_POINT *P = EC_POINT_new(group);
200 200
	EC_POINT *Q = EC_POINT_new(group);
201 201
	BN_CTX *ctx = BN_CTX_new();
202
	int i;
202 203

  
203 204
	n1 = BN_new(); n2 = BN_new(); order = BN_new();
204 205
	fprintf(stdout, "verify group order ...");
......
212 213
	if (!EC_POINT_mul(group, Q, order, NULL, NULL, ctx)) ABORT;
213 214
	if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
214 215
	fprintf(stdout, " ok\n");
215
	fprintf(stdout, "long/negative scalar tests ... ");
216
	if (!BN_one(n1)) ABORT;
217
	/* n1 = 1 - order */
218
	if (!BN_sub(n1, n1, order)) ABORT;
219
	if(!EC_POINT_mul(group, Q, NULL, P, n1, ctx)) ABORT;
220
	if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT;
221
	/* n2 = 1 + order */
222
	if (!BN_add(n2, order, BN_value_one())) ABORT;
223
	if(!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT;
224
	if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT;
225
	/* n2 = (1 - order) * (1 + order) */
226
	if (!BN_mul(n2, n1, n2, ctx)) ABORT;
227
	if(!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT;
228
	if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT;
216
	fprintf(stdout, "long/negative scalar tests ");
217
        for (i = 1; i <= 2; i++)
218
		{
219
		const BIGNUM *scalars[6];
220
		const EC_POINT *points[6];
221

  
222
		fprintf(stdout, i == 1 ?
223
			"allowing precomputation ... " :
224
			"without precomputation ... ");
225
		if (!BN_set_word(n1, i)) ABORT;
226
		/* If i == 1, P will be the predefined generator for which
227
		 * EC_GROUP_precompute_mult has set up precomputation. */
228
		if (!EC_POINT_mul(group, P, n1, NULL, NULL, ctx)) ABORT;
229

  
230
		if (!BN_one(n1)) ABORT;
231
		/* n1 = 1 - order */
232
		if (!BN_sub(n1, n1, order)) ABORT;
233
		if (!EC_POINT_mul(group, Q, NULL, P, n1, ctx)) ABORT;
234
		if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT;
235

  
236
		/* n2 = 1 + order */
237
		if (!BN_add(n2, order, BN_value_one())) ABORT;
238
		if (!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT;
239
		if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT;
240

  
241
		/* n2 = (1 - order) * (1 + order) = 1 - order^2 */
242
		if (!BN_mul(n2, n1, n2, ctx)) ABORT;
243
		if (!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT;
244
		if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT;
245

  
246
		/* n2 = order^2 - 1 */
247
		BN_set_negative(n2, 0);
248
		if (!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT;
249
		/* Add P to verify the result. */
250
		if (!EC_POINT_add(group, Q, Q, P, ctx)) ABORT;
251
		if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
252

  
253
		/* Exercise EC_POINTs_mul, including corner cases. */
254
		scalars[0] = n1; points[0] = Q; /* => infinity */
255
		scalars[1] = n2; points[1] = P; /* => -P */
256
		scalars[2] = n1; points[2] = Q; /* => infinity */
257
		scalars[3] = n2; points[3] = Q; /* => infinity */
258
		scalars[4] = n1; points[4] = P; /* => P */
259
		scalars[5] = n2; points[5] = Q; /* => infinity */
260
		if (!EC_POINTs_mul(group, Q, NULL, 5, points, scalars, ctx)) ABORT;
261
		if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
262
		}
229 263
	fprintf(stdout, "ok\n");
264

  
230 265
	EC_POINT_free(P);
231 266
	EC_POINT_free(Q);
232 267
	BN_free(n1);
deps/openssl/openssl/crypto/evp/e_aes.c
808 808
		/* Extra padding: tag appended to record */
809 809
		return EVP_GCM_TLS_TAG_LEN;
810 810

  
811
	case EVP_CTRL_COPY:
812
		{
813
			EVP_CIPHER_CTX *out = ptr;
814
			EVP_AES_GCM_CTX *gctx_out = out->cipher_data;
815
			if (gctx->gcm.key)
816
				{
817
				if (gctx->gcm.key != &gctx->ks)
818
					return 0;
819
				gctx_out->gcm.key = &gctx_out->ks;
820
				}
821
			if (gctx->iv == c->iv)
822
				gctx_out->iv = out->iv;
823
			else
824
			{
825
				gctx_out->iv = OPENSSL_malloc(gctx->ivlen);
826
				if (!gctx_out->iv)
827
					return 0;
828
				memcpy(gctx_out->iv, gctx->iv, gctx->ivlen);
829
			}
830
			return 1;
831
		}
832

  
811 833
	default:
812 834
		return -1;
813 835

  
......
1032 1054

  
1033 1055
#define CUSTOM_FLAGS	(EVP_CIPH_FLAG_DEFAULT_ASN1 \
1034 1056
		| EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \
1035
		| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT)
1057
		| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \
1058
		| EVP_CIPH_CUSTOM_COPY)
1036 1059

  
1037 1060
BLOCK_CIPHER_custom(NID_aes,128,1,12,gcm,GCM,
1038 1061
		EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS)
......
1044 1067
static int aes_xts_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
1045 1068
	{
1046 1069
	EVP_AES_XTS_CTX *xctx = c->cipher_data;
1047
	if (type != EVP_CTRL_INIT)
1070
	if (type == EVP_CTRL_COPY)
1071
		{
1072
		EVP_CIPHER_CTX *out = ptr;
1073
		EVP_AES_XTS_CTX *xctx_out = out->cipher_data;
1074
		if (xctx->xts.key1)
1075
			{
1076
			if (xctx->xts.key1 != &xctx->ks1)
1077
				return 0;
1078
			xctx_out->xts.key1 = &xctx_out->ks1;
1079
			}
1080
		if (xctx->xts.key2)
1081
			{
1082
			if (xctx->xts.key2 != &xctx->ks2)
1083
				return 0;
1084
			xctx_out->xts.key2 = &xctx_out->ks2;
1085
			}
1086
		return 1;
1087
		}
1088
	else if (type != EVP_CTRL_INIT)
1048 1089
		return -1;
1049 1090
	/* key1 and key2 are used as an indicator both key and IV are set */
1050 1091
	xctx->xts.key1 = NULL;
......
1153 1194
#define aes_xts_cleanup NULL
1154 1195

  
1155 1196
#define XTS_FLAGS	(EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CUSTOM_IV \
1156
			 | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT)
1197
			 | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \
1198
			 | EVP_CIPH_CUSTOM_COPY)
1157 1199

  
1158 1200
BLOCK_CIPHER_custom(NID_aes,128,1,16,xts,XTS,EVP_CIPH_FLAG_FIPS|XTS_FLAGS)
1159 1201
BLOCK_CIPHER_custom(NID_aes,256,1,16,xts,XTS,EVP_CIPH_FLAG_FIPS|XTS_FLAGS)
......
1203 1245
		cctx->len_set = 0;
1204 1246
		return 1;
1205 1247

  
1248
	case EVP_CTRL_COPY:
1249
		{
1250
			EVP_CIPHER_CTX *out = ptr;
1251
			EVP_AES_CCM_CTX *cctx_out = out->cipher_data;
1252
			if (cctx->ccm.key)
1253
				{
1254
				if (cctx->ccm.key != &cctx->ks)
1255
					return 0;
1256
				cctx_out->ccm.key = &cctx_out->ks;
1257
				}
1258
			return 1;
1259
		}
1260

  
1206 1261
	default:
1207 1262
		return -1;
1208 1263

  
deps/openssl/openssl/crypto/evp/evp_pbe.c
259 259
	{
260 260
	int cipher_nid, md_nid;
261 261
	if (cipher)
262
		cipher_nid = EVP_CIPHER_type(cipher);
262
		cipher_nid = EVP_CIPHER_nid(cipher);
263 263
	else
264 264
		cipher_nid = -1;
265 265
	if (md)
deps/openssl/openssl/crypto/idea/ideatest.c
199 199
                }
200 200
        memcpy(cfb_tmp,cfb_iv,8);
201 201
        n=0;
202
        idea_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,&eks,
202
        idea_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)13,&eks,
203 203
                cfb_tmp,&n,IDEA_DECRYPT);
204
        idea_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
205
                (long)CFB_TEST_SIZE-17,&dks,
204
        idea_cfb64_encrypt(&(cfb_buf1[13]),&(cfb_buf2[13]),
205
                (long)CFB_TEST_SIZE-13,&eks,
206 206
                cfb_tmp,&n,IDEA_DECRYPT);
207 207
        if (memcmp(plain,cfb_buf2,CFB_TEST_SIZE) != 0)
208 208
                {
deps/openssl/openssl/crypto/objects/obj_dat.c
471 471
	const unsigned char *p;
472 472
	char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
473 473

  
474
	if ((a == NULL) || (a->data == NULL)) {
475
		buf[0]='\0';
476
		return(0);
477
	}
474
	/* Ensure that, at every state, |buf| is NUL-terminated. */
475
	if (buf && buf_len > 0)
476
		buf[0] = '\0';
478 477

  
478
	if ((a == NULL) || (a->data == NULL))
479
		return(0);
479 480

  
480 481
	if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
481 482
		{
......
554 555
				i=(int)(l/40);
555 556
				l-=(long)(i*40);
556 557
				}
557
			if (buf && (buf_len > 0))
558
			if (buf && (buf_len > 1))
558 559
				{
559 560
				*buf++ = i + '0';
561
				*buf = '\0';
560 562
				buf_len--;
561 563
				}
562 564
			n++;
......
571 573
			i = strlen(bndec);
572 574
			if (buf)
573 575
				{
574
				if (buf_len > 0)
576
				if (buf_len > 1)
575 577
					{
576 578
					*buf++ = '.';
579
					*buf = '\0';
577 580
					buf_len--;
578 581
					}
579 582
				BUF_strlcpy(buf,bndec,buf_len);
......
807 810
	OPENSSL_free(buf);
808 811
	return(ok);
809 812
	}
810

  
deps/openssl/openssl/crypto/objects/obj_dat.h
67 67
#define NUM_LN 913
68 68
#define NUM_OBJ 857
69 69

  
70
static const unsigned char lvalues[5980]={
71
0x00,                                        /* [  0] OBJ_undef */
72
0x2A,0x86,0x48,0x86,0xF7,0x0D,               /* [  1] OBJ_rsadsi */
73
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,          /* [  7] OBJ_pkcs */
74
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02,     /* [ 14] OBJ_md2 */
75
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x05,     /* [ 22] OBJ_md5 */
76
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x04,     /* [ 30] OBJ_rc4 */
77
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,/* [ 38] OBJ_rsaEncryption */
78
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,/* [ 47] OBJ_md2WithRSAEncryption */
79
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,/* [ 56] OBJ_md5WithRSAEncryption */
80
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x01,/* [ 65] OBJ_pbeWithMD2AndDES_CBC */
81
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x03,/* [ 74] OBJ_pbeWithMD5AndDES_CBC */
82
0x55,                                        /* [ 83] OBJ_X500 */
83
0x55,0x04,                                   /* [ 84] OBJ_X509 */
84
0x55,0x04,0x03,                              /* [ 86] OBJ_commonName */
85
0x55,0x04,0x06,                              /* [ 89] OBJ_countryName */
86
0x55,0x04,0x07,                              /* [ 92] OBJ_localityName */
87
0x55,0x04,0x08,                              /* [ 95] OBJ_stateOrProvinceName */
88
0x55,0x04,0x0A,                              /* [ 98] OBJ_organizationName */
89
0x55,0x04,0x0B,                              /* [101] OBJ_organizationalUnitName */
90
0x55,0x08,0x01,0x01,                         /* [104] OBJ_rsa */
91
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,     /* [108] OBJ_pkcs7 */
92
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x01,/* [116] OBJ_pkcs7_data */
93
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,/* [125] OBJ_pkcs7_signed */
94
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x03,/* [134] OBJ_pkcs7_enveloped */
95
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x04,/* [143] OBJ_pkcs7_signedAndEnveloped */
96
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x05,/* [152] OBJ_pkcs7_digest */
97
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x06,/* [161] OBJ_pkcs7_encrypted */
98
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x03,     /* [170] OBJ_pkcs3 */
99
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x03,0x01,/* [178] OBJ_dhKeyAgreement */
100
0x2B,0x0E,0x03,0x02,0x06,                    /* [187] OBJ_des_ecb */
101
0x2B,0x0E,0x03,0x02,0x09,                    /* [192] OBJ_des_cfb64 */
102
0x2B,0x0E,0x03,0x02,0x07,                    /* [197] OBJ_des_cbc */
103
0x2B,0x0E,0x03,0x02,0x11,                    /* [202] OBJ_des_ede_ecb */
104
0x2B,0x06,0x01,0x04,0x01,0x81,0x3C,0x07,0x01,0x01,0x02,/* [207] OBJ_idea_cbc */
105
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x02,     /* [218] OBJ_rc2_cbc */
106
0x2B,0x0E,0x03,0x02,0x12,                    /* [226] OBJ_sha */
107
0x2B,0x0E,0x03,0x02,0x0F,                    /* [231] OBJ_shaWithRSAEncryption */
108
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x07,     /* [236] OBJ_des_ede3_cbc */
109
0x2B,0x0E,0x03,0x02,0x08,                    /* [244] OBJ_des_ofb64 */
110
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,     /* [249] OBJ_pkcs9 */
111
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,/* [257] OBJ_pkcs9_emailAddress */
112
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x02,/* [266] OBJ_pkcs9_unstructuredName */
113
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,/* [275] OBJ_pkcs9_contentType */
114
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x04,/* [284] OBJ_pkcs9_messageDigest */
115
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x05,/* [293] OBJ_pkcs9_signingTime */
116
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x06,/* [302] OBJ_pkcs9_countersignature */
117
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x07,/* [311] OBJ_pkcs9_challengePassword */
118
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x08,/* [320] OBJ_pkcs9_unstructuredAddress */
119
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x09,/* [329] OBJ_pkcs9_extCertAttributes */
120
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,          /* [338] OBJ_netscape */
121
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,     /* [345] OBJ_netscape_cert_extension */
122
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x02,     /* [353] OBJ_netscape_data_type */
123
0x2B,0x0E,0x03,0x02,0x1A,                    /* [361] OBJ_sha1 */
124
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,/* [366] OBJ_sha1WithRSAEncryption */
125
0x2B,0x0E,0x03,0x02,0x0D,                    /* [375] OBJ_dsaWithSHA */
126
0x2B,0x0E,0x03,0x02,0x0C,                    /* [380] OBJ_dsa_2 */
127
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0B,/* [385] OBJ_pbeWithSHA1AndRC2_CBC */
128
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0C,/* [394] OBJ_id_pbkdf2 */
129
0x2B,0x0E,0x03,0x02,0x1B,                    /* [403] OBJ_dsaWithSHA1_2 */
130
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x01,/* [408] OBJ_netscape_cert_type */
131
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x02,/* [417] OBJ_netscape_base_url */
132
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x03,/* [426] OBJ_netscape_revocation_url */
133
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x04,/* [435] OBJ_netscape_ca_revocation_url */
134
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x07,/* [444] OBJ_netscape_renewal_url */
135
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x08,/* [453] OBJ_netscape_ca_policy_url */
136
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0C,/* [462] OBJ_netscape_ssl_server_name */
137
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0D,/* [471] OBJ_netscape_comment */
138
0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x02,0x05,/* [480] OBJ_netscape_cert_sequence */
139
0x55,0x1D,                                   /* [489] OBJ_id_ce */
140
0x55,0x1D,0x0E,                              /* [491] OBJ_subject_key_identifier */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff