oweals/openssl.git
8 years agoMake DTLSv1_listen a first class function and change its type
Matt Caswell [Fri, 5 Feb 2016 10:59:42 +0000 (10:59 +0000)]
Make DTLSv1_listen a first class function and change its type

The DTLSv1_listen function exposed details of the underlying BIO
abstraction and did not properly allow for IPv6. This commit changes the
"peer" argument to be a BIO_ADDR and makes it a first class function
(rather than a ctrl) to ensure proper type checking.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRT4292: Remove ===== line
Rich Salz [Fri, 5 Feb 2016 17:41:16 +0000 (12:41 -0500)]
RT4292: Remove ===== line

Also remove two mistakenly checked-in files.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoRT1596: Add clarifying doc.
Rich Salz [Fri, 5 Feb 2016 14:28:05 +0000 (09:28 -0500)]
RT1596: Add clarifying doc.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoGH628: Add -help to all apps docs.
A J Mohan Rao [Fri, 5 Feb 2016 16:58:45 +0000 (11:58 -0500)]
GH628: Add -help to all apps docs.

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoGH628: Add -help to all apps docs.
Rich Salz [Fri, 5 Feb 2016 16:17:00 +0000 (11:17 -0500)]
GH628: Add -help to all apps docs.

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoEnsure correct chain depth for policy checks with DANE bare key TA
Viktor Dukhovni [Mon, 1 Feb 2016 02:48:00 +0000 (21:48 -0500)]
Ensure correct chain depth for policy checks with DANE bare key TA

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoLong overdue cleanup of X509 policy tree verification
Viktor Dukhovni [Mon, 1 Feb 2016 02:14:51 +0000 (21:14 -0500)]
Long overdue cleanup of X509 policy tree verification

Replace all magic numbers with #defined constants except in boolean
functions that return 0 for failure and 1 for success.  Avoid a
couple memory leaks in error recovery code paths.  Code style
improvements.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoVarious RT doc fixes
Rich Salz [Mon, 1 Feb 2016 20:15:06 +0000 (15:15 -0500)]
Various RT doc fixes

RT1556: doc/crypto/threads.pod
RT2024: Missing pages mentioned in crypto.pod
RT2890: Wrong size in ERR_string_error description.
RT3461: Better description of PEM Encryption
        (Jeffrey Walton <noloader@gmail.com>)
        Also, fix up formatting and removed some code examples
        that encourage unsafe patterns, like unencrypted private
        keys (Rich Salz)
RT4240: Document some speed flags (Tomas Mraz <tmraz@redhat.com>)
RT4260: Fix return value doc for X509_REQ_sign and X509_sign
        (Laetitia Baudoin <lbaudoin@google.com>)

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoenable leak checking for danetest
Dr. Stephen Henson [Fri, 5 Feb 2016 14:50:06 +0000 (14:50 +0000)]
enable leak checking for danetest

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix return code in CRYPTO_mem_leaks_fp()
Dr. Stephen Henson [Fri, 5 Feb 2016 14:36:01 +0000 (14:36 +0000)]
Fix return code in CRYPTO_mem_leaks_fp()

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoIf memory debugging enabled return error on leaks.
Dr. Stephen Henson [Thu, 14 Jan 2016 22:00:03 +0000 (22:00 +0000)]
If memory debugging enabled return error on leaks.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRestore -no_comp switch for backwards compatible behaviour
Viktor Dukhovni [Wed, 3 Feb 2016 21:45:39 +0000 (16:45 -0500)]
Restore -no_comp switch for backwards compatible behaviour

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoVMS lacks socklen_t, give it one
Richard Levitte [Fri, 5 Feb 2016 13:08:05 +0000 (14:08 +0100)]
VMS lacks socklen_t, give it one

Fortunately, we only use socklen_t internally

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoInitialize variable
Richard Levitte [Fri, 5 Feb 2016 07:37:12 +0000 (08:37 +0100)]
Initialize variable

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoDon't export local symbols on Solaris
Matt Caswell [Wed, 16 Dec 2015 11:17:17 +0000 (11:17 +0000)]
Don't export local symbols on Solaris

Following on from earlier commits to prevent local symbols from being
exported in the shared libraries on Linux, this makes the equivalent changes
for Solaris.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agomake update
Dr. Stephen Henson [Thu, 4 Feb 2016 23:23:02 +0000 (23:23 +0000)]
make update

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoAdd EC_KEY_priv2buf()
Dr. Stephen Henson [Thu, 4 Feb 2016 23:18:57 +0000 (23:18 +0000)]
Add EC_KEY_priv2buf()

Add new function EC_KEY_priv2buf() to allocated and encode private
key octet in one call. Update and simplify ASN.1 and print routines.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoAllocate ASN1_bn_print buffer internally.
Dr. Stephen Henson [Thu, 4 Feb 2016 18:53:07 +0000 (18:53 +0000)]
Allocate ASN1_bn_print buffer internally.

Don't require an application to work out the appropriate buffer size for
ASN1_bn_print(), which is unsafe. Ignore the supplied buffer and allocate
it internally instead.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoUse BN_bn2binpad
Dr. Stephen Henson [Wed, 3 Feb 2016 18:51:02 +0000 (18:51 +0000)]
Use BN_bn2binpad

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agouse enum type for do_EC_KEY_print
Dr. Stephen Henson [Wed, 3 Feb 2016 14:53:15 +0000 (14:53 +0000)]
use enum type for do_EC_KEY_print

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoupdate EC ASN1 and print routines
Dr. Stephen Henson [Mon, 1 Feb 2016 15:46:29 +0000 (15:46 +0000)]
update EC ASN1 and print routines

Update EC ASN.1 and print routines to use EC_KEY_oct2priv and
EC_KEY_priv2oct.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoAdd EC_KEY_oct2priv and EC_KEY_priv2oct
Dr. Stephen Henson [Mon, 1 Feb 2016 15:34:13 +0000 (15:34 +0000)]
Add EC_KEY_oct2priv and EC_KEY_priv2oct

New functions EC_KEY_oct2priv and EC_KEY_priv2oct. These are private key
equivalents of EC_POINT_oct2point and EC_POINT_point2oct which convert
between the private key octet format and EC_KEY.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoAdd ASN1_buf_print to print a buffer in ASN1_bn_print format.
Dr. Stephen Henson [Wed, 27 Jan 2016 14:34:36 +0000 (14:34 +0000)]
Add ASN1_buf_print to print a buffer in ASN1_bn_print format.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoDon't use RDRAND if told not to
Matt Caswell [Thu, 4 Feb 2016 15:24:06 +0000 (15:24 +0000)]
Don't use RDRAND if told not to

Ensure we respect OPENSSL_NO_RDRAND

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoInitialise with -1 rather than 1
Richard Levitte [Thu, 4 Feb 2016 23:00:22 +0000 (00:00 +0100)]
Initialise with -1 rather than 1

A small typo crept in.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoAdd new DTLS-SRTP protection profiles from RFC 7714
Dmitry Sobinov [Sat, 2 Jan 2016 11:32:36 +0000 (22:32 +1100)]
Add new DTLS-SRTP protection profiles from RFC 7714

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdd checks for IPv4 and IPv6 in OpenSSL::Test::Utils and use them
Richard Levitte [Thu, 4 Feb 2016 22:22:52 +0000 (23:22 +0100)]
Add checks for IPv4 and IPv6 in OpenSSL::Test::Utils and use them

This uilds on the same way of checking for availability as we do in
TLSProxy.  We use all IP factories we know of, starting with those who
know both IPv6 and IPv4 and ending with the one that only knows IPv4
and cache their possible success as foundation for checking the
available of each IP domain.

80-test_ssl.t has bigger chances of working on platforms that do not
run both IP domains.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUpdate crypto/bio/build.info
Richard Levitte [Thu, 4 Feb 2016 22:34:20 +0000 (23:34 +0100)]
Update crypto/bio/build.info

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix pkeyutl inability to directly access keys on hardware tokens
Mouse [Thu, 14 Jan 2016 04:03:31 +0000 (23:03 -0500)]
Fix pkeyutl inability to directly access keys on hardware tokens

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoChange the transfer perl module so the real module gets properly registered
Richard Levitte [Thu, 4 Feb 2016 18:41:56 +0000 (19:41 +0100)]
Change the transfer perl module so the real module gets properly registered

This is an important move if scripts want to refer to the loaded
module without having perl think it needs to be loaded (again).

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd option to disable async
Todd Short [Thu, 4 Feb 2016 16:41:25 +0000 (11:41 -0500)]
Add option to disable async

Add no-async option to Configure that forces ASYNC_NULL.
Related to RT1979
An embedded system or replacement C library (e.g. musl or uClibc)
may not support the *context APIs that are needed for async operation.

Compiles with musl. Ran unit tests, async tests skipped as expected.

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoMake sure getaddrinfo and getnameinfo works as intended on Windows
Richard Levitte [Thu, 4 Feb 2016 16:17:36 +0000 (17:17 +0100)]
Make sure getaddrinfo and getnameinfo works as intended on Windows

Both getaddrinfo() and getnameinfo() have to be preceeded with a call
to BIO_sock_init().

Also, make sure to give gai_strerror() the actual error code.

Reviewed-by: Stephen Henson <steve@openssl.org>
8 years agoIf egd is disabled by default, it should be possible to enable
Richard Levitte [Wed, 3 Feb 2016 20:08:17 +0000 (21:08 +0100)]
If egd is disabled by default, it should be possible to enable

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoAdd ec -check option
Dr. Stephen Henson [Thu, 4 Feb 2016 14:47:40 +0000 (14:47 +0000)]
Add ec -check option

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoFix potential buffer overrun
Dmitry-Me [Thu, 4 Feb 2016 07:11:26 +0000 (10:11 +0300)]
Fix potential buffer overrun

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoUse WSAGetLastError() on windows
Kurt Roeckx [Thu, 4 Feb 2016 14:20:26 +0000 (15:20 +0100)]
Use WSAGetLastError() on windows

Windows doesn't have h_error or hstrerror()

Reviewed-by: Richard Levitte <levitte@openssl.org>
MR: #1848

8 years agoRestore xmm7 from the correct address on win64
Kurt Roeckx [Wed, 3 Feb 2016 17:54:02 +0000 (18:54 +0100)]
Restore xmm7 from the correct address on win64

Reviewed-by: Richard Levitte <levitte@openssl.org>
RT: #4288, MR: #1831

8 years agoupdate OID tables
Dr. Stephen Henson [Thu, 4 Feb 2016 14:10:52 +0000 (14:10 +0000)]
update OID tables

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdd Curve OIDs from draft-josefsson-pkix-newcurves
Dr. Stephen Henson [Wed, 3 Feb 2016 22:41:30 +0000 (22:41 +0000)]
Add Curve OIDs from draft-josefsson-pkix-newcurves

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRT2887: Add more packet and handshake types
Daniel Black [Thu, 4 Feb 2016 01:04:10 +0000 (20:04 -0500)]
RT2887: Add more packet and handshake types

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFix BN_gcd errors for some curves
Billy Brumley [Wed, 20 Jan 2016 11:18:21 +0000 (13:18 +0200)]
Fix BN_gcd errors for some curves

Those even order that do not play nicely with Montgomery arithmetic

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoRT3095: allow NULL key for single-shot HMAC
Emilia Kasper [Thu, 10 Sep 2015 13:17:58 +0000 (15:17 +0200)]
RT3095: allow NULL key for single-shot HMAC

In HMAC_Init_ex, NULL key signals reuse, but in single-shot HMAC,
we can allow it to signal an empty key for convenience.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agobio_err.c: remove a reappeared filename comment
Viktor Szakats [Thu, 4 Feb 2016 00:04:53 +0000 (01:04 +0100)]
bio_err.c: remove a reappeared filename comment
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoMake fallback addresses static so that we can initialize it
Kurt Roeckx [Thu, 4 Feb 2016 00:59:20 +0000 (01:59 +0100)]
Make fallback addresses static so that we can initialize it

Reviewed-by: Richard Levitte <levitte@openssl.org>
MR: #1841

8 years agoOnly use TLS1.2 when it's available
Richard Levitte [Wed, 3 Feb 2016 23:25:49 +0000 (00:25 +0100)]
Only use TLS1.2 when it's available

Reviewed-by: Ben Laurie <ben@openssl.org>
8 years agoHave 70-test_clienthello.t be selective on when it can be run
Richard Levitte [Wed, 3 Feb 2016 23:24:16 +0000 (00:24 +0100)]
Have 70-test_clienthello.t be selective on when it can be run

The test program clienthello checks TLS extensions, so there's no
point running it when no TLS protocol is available.

Reviewed-by: Ben Laurie <ben@openssl.org>
8 years agoHave OpenSSL::Test::Utils::available_protocols load configdata as well
Richard Levitte [Wed, 3 Feb 2016 23:22:59 +0000 (00:22 +0100)]
Have OpenSSL::Test::Utils::available_protocols load configdata as well

Otherwise, it could typically always return an empty list, since it's
often called first if at all.

Reviewed-by: Ben Laurie <ben@openssl.org>
8 years agoRT2752: Add some EKU OID's
Rich Salz [Thu, 4 Feb 2016 01:26:03 +0000 (20:26 -0500)]
RT2752: Add some EKU OID's

And some others found in the Internet.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoHandle localhost being either 127.0.0.1 or ::1
Viktor Dukhovni [Wed, 3 Feb 2016 23:32:25 +0000 (18:32 -0500)]
Handle localhost being either 127.0.0.1 or ::1

When connecting to "localhost" the Proxy's choice of client address
family may not match the server's choice address family.  Without
MultiHomed => 1, the proxy may try the wrong address family first,
and give up without trying the other.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoUse matching quotes
Richard Levitte [Thu, 4 Feb 2016 00:44:51 +0000 (01:44 +0100)]
Use matching quotes

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoMake the mk1mf 'mv' command variable
Richard Levitte [Wed, 3 Feb 2016 23:40:41 +0000 (00:40 +0100)]
Make the mk1mf 'mv' command variable

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoTweak opensslconf.h.in for style
Rich Salz [Mon, 1 Feb 2016 01:31:00 +0000 (20:31 -0500)]
Tweak opensslconf.h.in for style

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoUse BIO_snprintf() rather than snprintf()
Richard Levitte [Wed, 3 Feb 2016 21:41:14 +0000 (22:41 +0100)]
Use BIO_snprintf() rather than snprintf()

Some platforms do not have the latter.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRefactoring BIO: small test correction
Richard Levitte [Wed, 3 Feb 2016 20:43:43 +0000 (21:43 +0100)]
Refactoring BIO: small test correction

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoGH614: Use memcpy()/strdup() when possible
Dmitry-Me [Wed, 3 Feb 2016 14:34:14 +0000 (17:34 +0300)]
GH614: Use memcpy()/strdup() when possible

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: Add a few lines in CHANGES & NEWS
Richard Levitte [Wed, 3 Feb 2016 00:04:44 +0000 (01:04 +0100)]
Refactoring BIO: Add a few lines in CHANGES & NEWS

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: add a simple networking test of s_client and s_server
Richard Levitte [Tue, 2 Feb 2016 23:57:30 +0000 (00:57 +0100)]
Refactoring BIO: add a simple networking test of s_client and s_server

This makes use of TLSProxy, which was expanded to use IO::Socket::IP
(which is a core perl module) or IO::Socket::INET6 (which is said to
be more popular) instead IO::Socket::INET if one of them is installed.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoRefactoring BIO: Adapt s_client and s_server
Richard Levitte [Tue, 2 Feb 2016 23:47:42 +0000 (00:47 +0100)]
Refactoring BIO: Adapt s_client and s_server

s_socket.c gets brutally cleaned out and now consists of only two
functions, one for client and the other for server.  They both handle
AF_INET, AF_INET6 and additionally AF_UNIX where supported.  The rest
is just easy adaptation.

Both s_client and s_server get the new flags -4 and -6 to force the
use of IPv4 or IPv6 only.

Also, the default host "localhost" in s_client is removed.  It's not
certain that this host is set up for both IPv4 and IPv6.  For example,
Debian has "ip6-localhost" as the default hostname for [::1].  The
better way is to default |host| to NULL and rely on BIO_lookup() to
return a BIO_ADDRINFO with the appropriate loopback address for IPv4
or IPv6 as indicated by the |family| parameter.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: Adapt BIO_s_datagram and all that depends on it
Richard Levitte [Tue, 2 Feb 2016 23:27:44 +0000 (00:27 +0100)]
Refactoring BIO: Adapt BIO_s_datagram and all that depends on it

The control commands that previously took a struct sockaddr * have
been changed to take a BIO_ADDR * instead.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: add a test, using test/ssltest
Richard Levitte [Tue, 2 Feb 2016 22:50:52 +0000 (23:50 +0100)]
Refactoring BIO: add a test, using test/ssltest

This adds a couple of simple tests to see that SSL traffic using the
reimplemented BIO_s_accept() and BIO_s_connect() works as expected,
both on IPv4 and on IPv6.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agomake update
Richard Levitte [Tue, 2 Feb 2016 22:50:41 +0000 (23:50 +0100)]
make update

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: adapt BIO_s_connect and BIO_s_accept
Richard Levitte [Tue, 2 Feb 2016 22:40:34 +0000 (23:40 +0100)]
Refactoring BIO: adapt BIO_s_connect and BIO_s_accept

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agomake update
Richard Levitte [Tue, 2 Feb 2016 21:43:01 +0000 (22:43 +0100)]
make update

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: reimplement old socket handling functions with new ones
Richard Levitte [Tue, 2 Feb 2016 21:33:57 +0000 (22:33 +0100)]
Refactoring BIO: reimplement old socket handling functions with new ones

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agomake update
Richard Levitte [Tue, 2 Feb 2016 20:44:01 +0000 (21:44 +0100)]
make update

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoTemporary pragma to have GCC quiet down about deprecated functions
Richard Levitte [Tue, 2 Feb 2016 20:42:45 +0000 (21:42 +0100)]
Temporary pragma to have GCC quiet down about deprecated functions

Future commits will change our use to newer functions and the pragmas
will go away at that time.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: new socket-handling functions, deprecate older ones
Richard Levitte [Tue, 2 Feb 2016 20:04:54 +0000 (21:04 +0100)]
Refactoring BIO: new socket-handling functions, deprecate older ones

Added functions:

BIO_socket
BIO_connect
BIO_listen
BIO_accept_ex
BIO_closesocket
BIO_sock_info

These get deprecated:

BIO_gethostbyname
BIO_get_port
BIO_get_host_ip
BIO_get_accept_socket
BIO_accept

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: add error macros & text, and make update
Richard Levitte [Tue, 2 Feb 2016 15:25:42 +0000 (16:25 +0100)]
Refactoring BIO: add error macros & text, and make update

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: Small adjustments
Richard Levitte [Tue, 2 Feb 2016 15:23:26 +0000 (16:23 +0100)]
Refactoring BIO: Small adjustments

Because of the way bio_lcl.h is organised, we must not include
internal/cryptlib.h before it.  As a matter of fact, bio_lcl.h
includes internal/cryptlib.h on its own.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRefactoring BIO: add wrappers around sockaddr et al
Richard Levitte [Tue, 2 Feb 2016 14:54:57 +0000 (15:54 +0100)]
Refactoring BIO: add wrappers around sockaddr et al

Because different platforms have different levels of support for IPv6,
different kinds of sockaddr variants, and some have getaddrinfo et al
while others don't, we could end up with a mess if ifdefs, duplicate
code and other maintainance nightmares.

Instead, we're introducing wrappers around the common form for socket
communication:
BIO_ADDR, closely related to struct sockaddr and some of its variants.
BIO_ADDRINFO, closely related to struct addrinfo.

With that comes support routines, both convenient creators and
accessors, plus a few utility functions:

BIO_parse_hostserv, takes a string of the form host:service and
splits it into host and service.  It checks for * in both parts, and
converts any [ipv6-address] syntax to ust the IPv6 address.

BIO_lookup, looks up information on a host.

All routines handle IPv4 (AF_INET) and IPv6 (AF_INET6) addresses, and
there is support for local sockets (AF_UNIX) as well.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRT4148
Emilia Kasper [Tue, 2 Feb 2016 17:03:33 +0000 (18:03 +0100)]
RT4148

Accept leading 0-byte in PKCS1 type 1 padding. Internally, the byte is
stripped by BN_bn2bin but external callers may have other expectations.

Reviewed-by: Kurt Roeckx<kurt@openssl.org>
8 years ago[Configure] Make --with-zlib-* work with configdata.pm
Michael Lee [Wed, 3 Feb 2016 16:31:40 +0000 (11:31 -0500)]
[Configure] Make --with-zlib-* work with configdata.pm

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRT3234: disable compression
Emilia Kasper [Tue, 2 Feb 2016 15:26:38 +0000 (16:26 +0100)]
RT3234: disable compression

CRIME protection: disable compression by default, even if OpenSSL is
compiled with zlib enabled. Applications can still enable compression by
calling SSL_CTX_clear_options(ctx, SSL_OP_NO_COMPRESSION), or by using
the SSL_CONF library to configure compression. SSL_CONF continues to
work as before:

SSL_CONF_cmd(ctx, "Options", "Compression") enables compression.

SSL_CONF_cmd(ctx, "Options", "-Compression") disables compression (now
no-op by default).

The command-line switch has changed from -no_comp to -comp.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix pkeyutl/rsautl empty encrypt-input/decrypt-output handling
Viktor Dukhovni [Tue, 2 Feb 2016 05:37:41 +0000 (00:37 -0500)]
Fix pkeyutl/rsautl empty encrypt-input/decrypt-output handling

Also fix option processing in pkeyutl to allow use of (formerly)
"out-of-order" switches that were needless implementation limitations.

Handle documented "ENGINE" form with -keyform and -peerform.

Better handling of OPENSSL_NO_ENGINE and OPENSSL_NO_RSA.

RT2018

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agofix code indentation issue
FdaSilvaYY [Sun, 31 Jan 2016 18:49:39 +0000 (19:49 +0100)]
fix code indentation issue

... related to engine_ref_debug macro.

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRT2353: Add ipsec IKE OID
Rich Salz [Tue, 2 Feb 2016 19:14:33 +0000 (14:14 -0500)]
RT2353: Add ipsec IKE OID

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoUse a simpler method to build a glob than splitpath and catpath
Richard Levitte [Tue, 2 Feb 2016 18:47:05 +0000 (19:47 +0100)]
Use a simpler method to build a glob than splitpath and catpath

It turns out that the combination splitpath() could return an empty
string for the directory part.  This doesn't play well with catdir().

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agomake update
Dr. Stephen Henson [Tue, 2 Feb 2016 16:59:58 +0000 (16:59 +0000)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoNew BN functions.
Dr. Stephen Henson [Mon, 1 Feb 2016 00:02:05 +0000 (00:02 +0000)]
New BN functions.

Add new function BN_bn2binpad() which checks the length of the output
buffer and pads the result with zeroes if necessary.

New functions BN_bn2lebinpad() and BN_lebin2bn() which use little endian
format.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoGH608: Ensure 64-bit shift no matter sizeof(long)
Dmitry-Me [Tue, 2 Feb 2016 06:55:06 +0000 (09:55 +0300)]
GH608: Ensure 64-bit shift no matter sizeof(long)

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoRT3854 Update docs.
Emilia Kasper [Tue, 2 Feb 2016 10:36:44 +0000 (11:36 +0100)]
RT3854 Update docs.

Remove ancient unused configuration file in crypto/conf.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoStyle; add "!= NULL"
Rich Salz [Mon, 1 Feb 2016 13:44:33 +0000 (08:44 -0500)]
Style; add "!= NULL"

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoGH554: Improve pkeyutl doc
Hubert Kario [Mon, 1 Feb 2016 16:14:34 +0000 (11:14 -0500)]
GH554: Improve pkeyutl doc

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoconstify PACKET
Emilia Kasper [Mon, 1 Feb 2016 14:26:18 +0000 (15:26 +0100)]
constify PACKET

PACKET contents should be read-only. To achieve this, also
- constify two user callbacks
- constify BUF_reverse.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoupdate DSA docs
Dr. Stephen Henson [Thu, 28 Jan 2016 23:57:46 +0000 (23:57 +0000)]
update DSA docs

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoadd option to exclude public key from EC keys
Dr. Stephen Henson [Wed, 27 Jan 2016 23:45:15 +0000 (23:45 +0000)]
add option to exclude public key from EC keys

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix memory leak and print out keygen errors.
Dr. Stephen Henson [Mon, 25 Jan 2016 16:59:19 +0000 (16:59 +0000)]
Fix memory leak and print out keygen errors.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoBetter check for gcc/clang
Rich Salz [Sat, 30 Jan 2016 00:50:28 +0000 (19:50 -0500)]
Better check for gcc/clang

Iteratively improved with Richard and Andy.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoComment "secure memcmp" implementation
Dmitry-Me [Mon, 1 Feb 2016 08:48:28 +0000 (11:48 +0300)]
Comment "secure memcmp" implementation

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoUse PKCS#8 format EC key so test is skipped with no-ec
Dr. Stephen Henson [Mon, 1 Feb 2016 03:59:48 +0000 (03:59 +0000)]
Use PKCS#8 format EC key so test is skipped with no-ec

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agounified build scheme: add a personal configuration to test it
Richard Levitte [Fri, 29 Jan 2016 22:36:12 +0000 (23:36 +0100)]
unified build scheme: add a personal configuration to test it

Nothing else will run the unified scheme for now.

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agounified build scheme: add build.info files
Richard Levitte [Fri, 29 Jan 2016 22:33:10 +0000 (23:33 +0100)]
unified build scheme: add build.info files

Now that we have the foundation for the "unified" build scheme in
place, we add build.info files.  They have been generated from the
Makefiles in the same directories.  Things that are platform specific
will appear in later commits.

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agounified build scheme: a first introduction
Richard Levitte [Fri, 29 Jan 2016 18:45:51 +0000 (19:45 +0100)]
unified build scheme: a first introduction

The "unified" build scheme revolves around small information files,
build.info, which each describe their own bit of everything that needs
to be built, using a mini-language described in Configurations/README.

The information in build.info file contain references to source files
and final result.  Object files are not mentioned at all, they are
simply from source files.  Because of this, all the *_obj items in
Configurations/*.conf are renamed to *_asm_src and the files listed
in the values are change from object files to their corresponding
source files.  For the sake of the other build schemes, Configure
generates corresponding *_obj entries in %target.

Furthermore, the "unified" build scheme supports having a build
directory tree separate from the source directry tree.

All paths in a build.info file is assumed to be relative to its
location, either within the source tree or within the build tree.

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoAdd tests for non-ca trusted roots and intermediates
Viktor Dukhovni [Fri, 29 Jan 2016 17:22:21 +0000 (12:22 -0500)]
Add tests for non-ca trusted roots and intermediates

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoCompat self-signed trust with reject-only aux data
Viktor Dukhovni [Fri, 29 Jan 2016 07:28:43 +0000 (02:28 -0500)]
Compat self-signed trust with reject-only aux data

When auxiliary data contains only reject entries, continue to trust
self-signed objects just as when no auxiliary data is present.

This makes it possible to reject specific uses without changing
what's accepted (and thus overring the underlying EKU).

Added new supported certs and doubled test count from 38 to 76.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoCheck chain extensions also for trusted certificates
Viktor Dukhovni [Thu, 28 Jan 2016 08:01:45 +0000 (03:01 -0500)]
Check chain extensions also for trusted certificates

This includes basic constraints, key usages, issuer EKUs and auxiliary
trust OIDs (given a trust suitably related to the intended purpose).

Added tests and updated documentation.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoZero newly allocated points
Dr. Stephen Henson [Sun, 31 Jan 2016 18:13:43 +0000 (18:13 +0000)]
Zero newly allocated points

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRemove redundant code.
Dr. Stephen Henson [Sun, 31 Jan 2016 16:35:37 +0000 (16:35 +0000)]
Remove redundant code.

d2i_ECPrivateKey always caculates the public key so there is
no need to caculate it again in eckey_priv_decode().

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd EC_GROUP_order_bits, EC_GROUP_get0_order and EC_GROUP_get0_cofactor
Dr. Stephen Henson [Sun, 31 Jan 2016 16:34:07 +0000 (16:34 +0000)]
Add EC_GROUP_order_bits, EC_GROUP_get0_order and EC_GROUP_get0_cofactor

New functions to return internal pointer for order and cofactor. This
avoids the need to allocate a new BIGNUM which to copy the value to.
Simplify code to use new functions.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoEngage poly1305-sparcv9 module.
Andy Polyakov [Fri, 29 Jan 2016 11:40:56 +0000 (12:40 +0100)]
Engage poly1305-sparcv9 module.

Reviewed-by: Richard Levitte <levitte@openssl.org>