oweals/openssl.git
5 years agotest/params_test.c: Add run-time constructed OSSL_PARAM variant
Richard Levitte [Fri, 8 Mar 2019 08:54:04 +0000 (09:54 +0100)]
test/params_test.c: Add run-time constructed OSSL_PARAM variant

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8396)

5 years agotest/params_test.c: Add API test case, and mixed methods
Richard Levitte [Mon, 4 Mar 2019 19:34:51 +0000 (20:34 +0100)]
test/params_test.c: Add API test case, and mixed methods

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8396)

5 years agotest/params_test.c: Add "real world" parameter testing
Richard Levitte [Mon, 4 Mar 2019 16:22:45 +0000 (17:22 +0100)]
test/params_test.c: Add "real world" parameter testing

test/params_test.c is a program that tries to mimic how a provider and
an application would or could handle OSSL_PARAM arrays.

For the moment, this program tests a very raw way of handling
OSSL_PARAM arrays.  It is, however, written in a way that will
hopefully make it possible to extend with other methods as APIs arise,
and to set up test cases where a "provider" handles the array one way
while the "application" handles it another way.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8396)

5 years agoFix no-dso
Matt Caswell [Tue, 12 Mar 2019 11:36:08 +0000 (11:36 +0000)]
Fix no-dso

Don't try to load external provider modules in tests if we don't have DSO
capability

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8459)

5 years agoFix various no-* options
Matt Caswell [Tue, 12 Mar 2019 10:53:37 +0000 (10:53 +0000)]
Fix various no-* options

no-cmac, no-poly1305 and no-siphash all caused the new test_mac to fail.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8458)

5 years agoFix memory leaks in pkread.c demo file
Matt Caswell [Tue, 12 Mar 2019 10:21:39 +0000 (10:21 +0000)]
Fix memory leaks in pkread.c demo file

Also make various changes to bring the file into line with current coding
style.

Fixes #8456

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
(Merged from https://github.com/openssl/openssl/pull/8457)

5 years agoSupport SM2 certificate verification
杨洋 [Fri, 26 Oct 2018 13:34:08 +0000 (21:34 +0800)]
Support SM2 certificate verification

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8321)

5 years agoReplumbing: Add constructor of libcrypto internal method structures
Richard Levitte [Mon, 25 Feb 2019 00:59:02 +0000 (01:59 +0100)]
Replumbing: Add constructor of libcrypto internal method structures

This queries the provider for its available functionality (unless a
matching method structured is already cached, in which case that's
used instead), and creates method structure with the help of a passed
constructor.  The result is cached if the provider allows it (or if
caching is forced).

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8340)

5 years agoReplumbing: Add support for the provider query_operation function
Richard Levitte [Mon, 25 Feb 2019 00:57:28 +0000 (01:57 +0100)]
Replumbing: Add support for the provider query_operation function

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8340)

5 years agoReplumbing: Add an OSSL_PROVIDER iterator with callback
Richard Levitte [Mon, 25 Feb 2019 00:53:34 +0000 (01:53 +0100)]
Replumbing: Add an OSSL_PROVIDER iterator with callback

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8340)

5 years agoChange OSSL_PARAM_UTF8_STRING_PTR to OSSL_PARAM_UTF8_PTR
Richard Levitte [Mon, 11 Mar 2019 20:49:54 +0000 (21:49 +0100)]
Change OSSL_PARAM_UTF8_STRING_PTR to OSSL_PARAM_UTF8_PTR

In unrelated code

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8451)

5 years agogenerated files
Pauli [Fri, 8 Mar 2019 06:33:12 +0000 (16:33 +1000)]
generated files

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8451)

5 years agoOSSL_PARAM helper functions.
Pauli [Fri, 22 Feb 2019 02:21:33 +0000 (12:21 +1000)]
OSSL_PARAM helper functions.

Provide a number of functions to allow parameters to be set and
retrieved in a type safe manner.  Functions are provided for many
integral types plus double, BIGNUM, UTF8 strings and OCTET strings.

All of the integer functions will widen the parameter data as
required.  This permits a degree of malleability in the parameter
definition.  For example a type can be changed from a thirty two bit
integer to a sixty four bit one without changing application code.
Only four and eight byte integral sizes are supported here.

A pair of real functions are available for doubles.

A pair of functions is available for BIGNUMs.  These accept any sized
unsigned integer input and convert to/from a BIGNUM.

For each OCTET and UTF8 strings, four functions are defined.  This
provide get and set functionality for string and for pointers to
strings.  The latter avoiding copies but have other inherent risks.

Finally, some utility macros and functions are defined to allow
OSSL_PARAM definition arrays to be specified in a simple manner.
There are two macro and one function for most types.  The exception
being BIGNUM, for which there is one macro and one function.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8451)

5 years agoRename 'buffer' to 'data' in OSSL_PARAM
Richard Levitte [Mon, 11 Mar 2019 20:51:01 +0000 (21:51 +0100)]
Rename 'buffer' to 'data' in OSSL_PARAM

The OSSL_PARAM attribute names |buffer| and |buffer_size| may lead to
confusion, as they may make some think that the memory pointed at is
an intermediate memory are.  This is not generally the case, so we
rename |buffer| and |buffer_size| to |data| and |data_size|

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8451)

5 years ago2nd chunk: CRMF code (crypto/crmf/, ) and its integration
David von Oheimb [Fri, 16 Nov 2018 13:05:31 +0000 (14:05 +0100)]
2nd chunk: CRMF code (crypto/crmf/, ) and its integration
in INSTALL, Configure, crypto/build.info, include/openssl/crmferr.h,
crypto/err/, include/openssl/err.h, and (to be updated:) util/libcrypto.num

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7646)

5 years agoCertificate Management Protocol (CMP, RFC 4210) extension to OpenSSL
David von Oheimb [Wed, 17 Oct 2018 13:51:19 +0000 (15:51 +0200)]
Certificate Management Protocol (CMP, RFC 4210) extension to OpenSSL
Also includes CRMF (RFC 4211) and HTTP transfer (RFC 6712)

CMP and CRMF API is added to libcrypto, and the "cmp" app to the openssl CLI.
Adds extensive man pages and tests.  Integration into build scripts.

Incremental pull request based on OpenSSL commit 1362190b1b78 of 2018-09-26

1st chunk: CRMF API (include/openssl/crmf.h) and its documentation (reviewed)

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7328)

5 years agoadded generated files
Shane Lontis [Tue, 12 Mar 2019 05:11:19 +0000 (15:11 +1000)]
added generated files

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6652)

5 years agoFIPS 186-4 RSA Generation & Validation
Shane Lontis [Wed, 4 Jul 2018 23:28:51 +0000 (09:28 +1000)]
FIPS 186-4 RSA Generation & Validation

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6652)

5 years agos390x assembly pack: import chacha from cryptogams repo
Patrick Steuer [Mon, 25 Feb 2019 17:55:04 +0000 (18:55 +0100)]
s390x assembly pack: import chacha from cryptogams repo

featuring 6x"horizontal" code path which is up to 25%
faster than present 4x"vertical" for larger blocks.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8287)

5 years agoAdd documentation
Richard Levitte [Thu, 21 Feb 2019 20:20:53 +0000 (21:20 +0100)]
Add documentation

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8287)

5 years agoAdd provider tests
Richard Levitte [Wed, 20 Feb 2019 21:55:43 +0000 (22:55 +0100)]
Add provider tests

Two tests are added, one that tests the internal API, the other tests
the public API.  Those two tests both test the same provider, which
acts both as a built-in provider and as a loadable provider module.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8287)

5 years agoAdd provider module infrastructure
Richard Levitte [Wed, 20 Feb 2019 21:55:29 +0000 (22:55 +0100)]
Add provider module infrastructure

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8287)

5 years agoReplumbing: New public API to load or add providers
Richard Levitte [Tue, 19 Feb 2019 22:07:57 +0000 (23:07 +0100)]
Replumbing: New public API to load or add providers

Adding a provider means creating an internal provier object and adding
it to the store.  This allows the addition of built in providers, be it
in the OpenSSL libraries or in any application.

"Loading" a provider is defined broadly.  A built in provider is already
"loaded" in essence and only needs activating, while a provider in a
dynamically loadable module requires actually loading the module itself.
In this API, "loading" a provider does both.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8287)

5 years agoReplumbing: Add the Provider Object, type OSSL_PROVIDER
Richard Levitte [Sun, 20 Jan 2019 12:14:58 +0000 (13:14 +0100)]
Replumbing: Add the Provider Object, type OSSL_PROVIDER

The OSSL_PROVIDER is the core object involved in loading a provider
module, initialize a provider and do the initial communication of
provider wide and core wide dispatch tables.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8287)

5 years agoReplumbing: Add MODULESDIR macro and OPENSSL_MODULES environment variable
Richard Levitte [Tue, 5 Feb 2019 22:18:50 +0000 (23:18 +0100)]
Replumbing: Add MODULESDIR macro and OPENSSL_MODULES environment variable

These will be used to point out general OpenSSL modules directory.
ENGINE modules are kept apart for backward compatibility.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8287)

5 years agofix truncation of integers on 32bit AIX
Shane Lontis [Wed, 6 Mar 2019 02:57:09 +0000 (12:57 +1000)]
fix truncation of integers on 32bit AIX

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8417)

5 years agoAdd regenerated header files
Rich Salz [Tue, 5 Mar 2019 13:22:17 +0000 (08:22 -0500)]
Add regenerated header files

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8397)

5 years agoutil/mkerr.pl: Add an inclusion of symhacks.h in all error files
Rich Salz [Mon, 4 Mar 2019 20:53:58 +0000 (15:53 -0500)]
util/mkerr.pl: Add an inclusion of symhacks.h in all error files

This does no harm, and ensures that the inclusion isn't mistakenly
removed in the generated *err.h where it's actually needed.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8397)

5 years agoopenssl app for macs that uses the new EVP_MAC interface (the code inside dgst uses...
Shane Lontis [Tue, 20 Nov 2018 00:45:44 +0000 (10:45 +1000)]
openssl app for macs that uses the new EVP_MAC interface (the code inside dgst uses EVP_PKEY)

Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7661)

5 years agosha/asm/keccak1600-ppc64.pl: up 10% performance improvement.
Andy Polyakov [Fri, 8 Mar 2019 13:40:56 +0000 (14:40 +0100)]
sha/asm/keccak1600-ppc64.pl: up 10% performance improvement.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8444)

5 years agoFix two spelling errors
A. Schulze [Sat, 9 Mar 2019 18:05:31 +0000 (19:05 +0100)]
Fix two spelling errors

CLA: trivial

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8447)

5 years agoFix typo in ifndef OPENSSL_NO_ENGINES.
Darren Tucker [Sun, 10 Mar 2019 00:26:34 +0000 (11:26 +1100)]
Fix typo in ifndef OPENSSL_NO_ENGINES.

All other instances are OPENSSL_NO_ENGINE without the trailing "S".
Fixes build when configured with no-engine.

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8449)

5 years agoPrint all loaded engines with openssl list -engines
Tomas Mraz [Thu, 7 Mar 2019 14:28:30 +0000 (15:28 +0100)]
Print all loaded engines with openssl list -engines

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8434)

5 years agoChange arg to cms_CompressedData_init_bio to be const
Matt Caswell [Thu, 7 Mar 2019 14:14:30 +0000 (14:14 +0000)]
Change arg to cms_CompressedData_init_bio to be const

The argument to this function is declared const in the header file. However
the implementation did not have this. This issue is only visible when using
enable-zlib.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8433)

5 years agoUpdate documentation of RSA_padding_check_PKCS1_OAEP_mgf1
Bernd Edlinger [Sun, 3 Mar 2019 13:25:52 +0000 (14:25 +0100)]
Update documentation of RSA_padding_check_PKCS1_OAEP_mgf1

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

5 years agoDo the error handling in pkey_rsa_decrypt in constant time
Bernd Edlinger [Sun, 3 Mar 2019 09:36:57 +0000 (10:36 +0100)]
Do the error handling in pkey_rsa_decrypt in constant time

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

5 years agoAdd a simple test for RSA_SSLV23_PADDING
Bernd Edlinger [Sat, 2 Mar 2019 23:04:11 +0000 (00:04 +0100)]
Add a simple test for RSA_SSLV23_PADDING

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

5 years agoUpdate documentation regarding required output buffer memory size
Bernd Edlinger [Fri, 1 Mar 2019 08:27:32 +0000 (09:27 +0100)]
Update documentation regarding required output buffer memory size
of RSA_private_decrypt/RSA_public_encrypt.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

5 years agoFix memory overrun in rsa padding check functions
Bernd Edlinger [Thu, 28 Feb 2019 09:08:18 +0000 (10:08 +0100)]
Fix memory overrun in rsa padding check functions

Fixes #8364 and #8357

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

5 years agoLimit DEVRANDOM_WAIT to linux
Bernd Edlinger [Thu, 7 Mar 2019 07:19:28 +0000 (08:19 +0100)]
Limit DEVRANDOM_WAIT to linux

Fixes #8416

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8428)

5 years agoAdd a test for underflow in ecp_nistp521.c
Matt Caswell [Wed, 6 Mar 2019 11:51:28 +0000 (11:51 +0000)]
Add a test for underflow in ecp_nistp521.c

The previous commit fixed an underflow that may occur in ecp_nistp521.c.
This commit adds a test for that condition. It is heavily based on an
original test harness by Billy Brumley.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/8405)

5 years agoAvoid an underflow in ecp_nistp521.c
Matt Caswell [Tue, 5 Mar 2019 13:26:45 +0000 (13:26 +0000)]
Avoid an underflow in ecp_nistp521.c

The function felem_diff_128_64 in ecp_nistp521.c substracts the number |in|
from |out| mod p. In order to avoid underflow it first adds 32p mod p
(which is equivalent to 0 mod p) to |out|. The comments and variable naming
suggest that the original author intended to add 64p mod p. In fact it
has been shown that with certain unusual co-ordinates it is possible to
cause an underflow in this function when only adding 32p mod p while
performing a point double operation. By changing this to 64p mod p the
underflow is avoided.

It turns out to be quite difficult to construct points that satisfy the
underflow criteria although this has been done and the underflow
demonstrated. However none of these points are actually on the curve.
Finding points that satisfy the underflow criteria and are also *on* the
curve is considered significantly more difficult. For this reason we do
not believe that this issue is currently practically exploitable and
therefore no CVE has been assigned.

This only impacts builds using the enable-ec_nistp_64_gcc_128 Configure
option.

With thanks to Bo-Yin Yang, Billy Brumley and Dr Liu for their significant
help in investigating this issue.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/8405)

5 years agoFIPS AES_GCM IV gen changes
Shane Lontis [Wed, 20 Feb 2019 22:27:25 +0000 (08:27 +1000)]
FIPS AES_GCM IV gen changes

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8393)

5 years agoconstify *_dup() and *i2d_*() and related functions as far as possible, introducing...
David von Oheimb [Tue, 15 Jan 2019 20:51:25 +0000 (21:51 +0100)]
constify *_dup() and *i2d_*() and related functions as far as possible, introducing DECLARE_ASN1_DUP_FUNCTION

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8029)

5 years agoUpdate ChaCha20-Poly1305 documentation
Matt Caswell [Tue, 5 Mar 2019 15:41:27 +0000 (15:41 +0000)]
Update ChaCha20-Poly1305 documentation

Correctly describe the maximum IV length.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8406)

5 years agoTest an overlong ChaCha20-Poly1305 nonce
Matt Caswell [Tue, 5 Mar 2019 14:51:07 +0000 (14:51 +0000)]
Test an overlong ChaCha20-Poly1305 nonce

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8406)

5 years agoPrevent over long nonces in ChaCha20-Poly1305
Matt Caswell [Tue, 5 Mar 2019 14:39:15 +0000 (14:39 +0000)]
Prevent over long nonces in ChaCha20-Poly1305

ChaCha20-Poly1305 is an AEAD cipher, and requires a unique nonce input for
every encryption operation. RFC 7539 specifies that the nonce value (IV)
should be 96 bits (12 bytes). OpenSSL allows a variable nonce length and
front pads the nonce with 0 bytes if it is less than 12 bytes. However it
also incorrectly allows a nonce to be set of up to 16 bytes. In this case
only the last 12 bytes are significant and any additional leading bytes are
ignored.

It is a requirement of using this cipher that nonce values are unique.
Messages encrypted using a reused nonce value are susceptible to serious
confidentiality and integrity attacks. If an application changes the
default nonce length to be longer than 12 bytes and then makes a change to
the leading bytes of the nonce expecting the new value to be a new unique
nonce then such an application could inadvertently encrypt messages with a
reused nonce.

Additionally the ignored bytes in a long nonce are not covered by the
integrity guarantee of this cipher. Any application that relies on the
integrity of these ignored leading bytes of a long nonce may be further
affected.

Any OpenSSL internal use of this cipher, including in SSL/TLS, is safe
because no such use sets such a long nonce value. However user
applications that use this cipher directly and set a non-default nonce
length to be longer than 12 bytes may be vulnerable.

CVE-2019-1543

Fixes #8345

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8406)

5 years agoapps/openssl.c: avoid memory leaks
Richard Levitte [Sun, 10 Feb 2019 14:16:20 +0000 (15:16 +0100)]
apps/openssl.c: avoid memory leaks

The trace API doesn't know that the BIOs we give it, let alone those
we attach to callbacks as 'void *data', need to be cleaned up.  This
must be done in the application.

To ensure this cleanup is done as late as possible, use atexit().

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdd a log about the tracing functionality
Richard Levitte [Fri, 14 Dec 2018 16:18:00 +0000 (17:18 +0100)]
Add a log about the tracing functionality

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoDocument the tracing functionality
Richard Levitte [Fri, 14 Dec 2018 16:17:22 +0000 (17:17 +0100)]
Document the tracing functionality

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoMake it possible to trace the trace functionality itself
Richard Levitte [Sat, 9 Feb 2019 11:37:49 +0000 (12:37 +0100)]
Make it possible to trace the trace functionality itself

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt BN_CTX_DEBUG to the new generic trace API
Richard Levitte [Thu, 13 Dec 2018 11:35:48 +0000 (12:35 +0100)]
Adapt BN_CTX_DEBUG to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt OPENSSL_DEBUG_DECRYPT to the new generic trace API
Richard Levitte [Thu, 13 Dec 2018 11:04:26 +0000 (12:04 +0100)]
Adapt OPENSSL_DEBUG_DECRYPT to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt OPENSSL_POLICY_DEBUG to the new generic trace API
Richard Levitte [Thu, 13 Dec 2018 07:19:08 +0000 (08:19 +0100)]
Adapt OPENSSL_POLICY_DEBUG to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt OPENSSL_DEBUG_KEYGEN to the new generic trace API
Richard Levitte [Thu, 13 Dec 2018 07:07:25 +0000 (08:07 +0100)]
Adapt OPENSSL_DEBUG_KEYGEN to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt OPENSSL_DEBUG_PKCS5V2 to the new generic trace API
Richard Levitte [Thu, 13 Dec 2018 00:53:13 +0000 (01:53 +0100)]
Adapt OPENSSL_DEBUG_PKCS5V2 to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt ENGINE_REF_COUNT_DEBUG to the new generic trace API
Richard Levitte [Thu, 13 Dec 2018 00:42:46 +0000 (01:42 +0100)]
Adapt ENGINE_REF_COUNT_DEBUG to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt ENGINE_TABLE_DEBUG to the new generic trace API
Richard Levitte [Thu, 13 Dec 2018 00:42:07 +0000 (01:42 +0100)]
Adapt ENGINE_TABLE_DEBUG to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt ENGINE_CONF_DEBUG to the new generic trace API
Richard Levitte [Thu, 13 Dec 2018 00:37:10 +0000 (01:37 +0100)]
Adapt ENGINE_CONF_DEBUG to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt OPENSSL_INIT_DEBUG to the new generic trace API
Richard Levitte [Wed, 12 Dec 2018 23:32:57 +0000 (00:32 +0100)]
Adapt OPENSSL_INIT_DEBUG to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt CIPHER_DEBUG to the new generic trace API
Richard Levitte [Wed, 12 Dec 2018 22:57:48 +0000 (23:57 +0100)]
Adapt CIPHER_DEBUG to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdapt SSL_DEBUG to the new generic trace API
Richard Levitte [Tue, 11 Dec 2018 23:04:44 +0000 (00:04 +0100)]
Adapt SSL_DEBUG to the new generic trace API

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoMake it possible to disable the TRACE API
Richard Levitte [Wed, 12 Dec 2018 20:31:36 +0000 (21:31 +0100)]
Make it possible to disable the TRACE API

This disabled the tracing functionality by making functions do
nothing, and making convenience macros produce dead code.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoapps/openssl.c: Adapt to enable tracing output
Richard Levitte [Fri, 14 Dec 2018 14:48:53 +0000 (15:48 +0100)]
apps/openssl.c: Adapt to enable tracing output

Use the environment variables OPENSSL_TRACE to determine what's going
to be enabled.  The value of this variables is a comma separated list
of trace and debugging names, which correspond to the trace category
macros defined in include/openssl/trace.h.

For example, setting OPENSSL_DEBUG=TRACE,SSL will enable debugging output
for the types OSSL_TRACE_CATEGORY_TRACE and OSSL_TRACE_CATEGORY_SSL.

This also slightly changes the handling of the prefix method in
apps/apps.c.  This is for the better, as the prefix method pointer was
unneccessarily stored in two places.

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoAdd generic trace API
Richard Levitte [Tue, 11 Dec 2018 22:58:29 +0000 (23:58 +0100)]
Add generic trace API

The idea is that the application shall be able to register output
channels or callbacks to print tracing output as it sees fit.

OpenSSL internals, on the other hand, want to print thoses texts using
normal printing routines, such as BIO_printf() or BIO_dump() through
well defined BIOs.

When the application registers callbacks, the tracing functionality
sets up an internal BIO that simply forwards received text to the
appropriate application provided callback.

Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8198)

5 years agoMake the sparse array code use ossl_uintmax_t as its index rather than size_t.
Pauli [Wed, 6 Mar 2019 03:50:54 +0000 (13:50 +1000)]
Make the sparse array code use ossl_uintmax_t as its index rather than size_t.

This should never reduce the range covered and might increase it on some
platforms.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8415)

5 years agopadlock: generate assembler source for static libraries too
Richard Levitte [Tue, 5 Mar 2019 17:38:16 +0000 (18:38 +0100)]
padlock: generate assembler source for static libraries too

The GENERATE lines for generating the padlock assembler source were
wrongly placed in such a way that they only applied to the shared
library build.

[extended tests]

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/8412)

5 years agoDon't write the tick_identity to the session
Matt Caswell [Fri, 1 Mar 2019 15:40:20 +0000 (15:40 +0000)]
Don't write the tick_identity to the session

Sessions must be immutable once they can be shared with multiple threads.
We were breaking that rule by writing the ticket index into it during the
handshake. This can lead to incorrect behaviour, including failed
connections in multi-threaded environments.

Reported by David Benjamin.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8383)

5 years agoAdd advice on setting CXX at the same time as CC
Richard Levitte [Fri, 1 Mar 2019 10:54:07 +0000 (11:54 +0100)]
Add advice on setting CXX at the same time as CC

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8370)

5 years agoTravis: use enable-buildtest-c++
Richard Levitte [Thu, 28 Feb 2019 12:35:32 +0000 (13:35 +0100)]
Travis: use enable-buildtest-c++

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8370)

5 years agoConfigure: make C++ build tests optional and configurable
Richard Levitte [Thu, 28 Feb 2019 12:28:43 +0000 (13:28 +0100)]
Configure: make C++ build tests optional and configurable

Disabled by default

Fixes #8360

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8370)

5 years agoVMS: fix util/[un]local.com.in to handle attributes
Richard Levitte [Fri, 1 Mar 2019 13:15:13 +0000 (14:15 +0100)]
VMS: fix util/[un]local.com.in to handle attributes

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8382)

5 years agotestutil: ensure good treatment of argv on non-Unix platforms
Richard Levitte [Sun, 3 Mar 2019 09:27:10 +0000 (10:27 +0100)]
testutil: ensure good treatment of argv on non-Unix platforms

From a Unix point of view, some other platform families have certain
quirks.  Windows command prompt doesn't expand globs into actual file
names, so we must do this.  VMS has some oddity with argv pointer size
that can cause crashes if you're not careful (by copying it to a less
surprising pointer size array).

The fixups already exist and are used in the apps/ code.  However, the
testutil code started using the opt routines from apps/ without
including the non-Unix fixups.  This change fixes that.

For VMS' sake, libtestutil gets an app_malloc() shim, to avoid sucking
in all of apps/apps.c.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8381)

5 years agoVMS: move copy_argc to its own module and make it an aux source
Richard Levitte [Sun, 3 Mar 2019 09:20:37 +0000 (10:20 +0100)]
VMS: move copy_argc to its own module and make it an aux source

copy_argv was never initialization code.

Make it self-cleaning too.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8381)

5 years agoDeprecate the "hw" configuration options, make "padlockeng" disablable
Richard Levitte [Fri, 1 Mar 2019 12:18:11 +0000 (13:18 +0100)]
Deprecate the "hw" configuration options, make "padlockeng" disablable

The "hw" and "hw-.*" style options are historical artifacts, sprung
from the time when ENGINE was first designed, with hardware crypto
accelerators and HSMs in mind.

Today, these options have largely lost their value, replaced by
options such as "no-{foo}eng" and "no-engine".

This completes the transition by making "hw" and "hw-.*" deprecated,
but automatically translated into more modern variants of the same.

In the process, we get rid of the last regular expression in
Configure's @disablables, a feature that was ill supported anyway.
Also, padlock now gets treated just as every other engine.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8380)

5 years agoopenssl_strerror_r: Fix handling of GNU strerror_r
Vitezslav Cizek [Thu, 28 Feb 2019 12:47:18 +0000 (13:47 +0100)]
openssl_strerror_r: Fix handling of GNU strerror_r

GNU strerror_r may return either a pointer to a string that the function
stores in buf, or a pointer to some (immutable) static string in which case
buf is unused.

In such a case we need to set buf manually.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8371)

5 years agoCheck for negative return for signature size.Addresses Coverity 1442933
Pauli [Mon, 4 Mar 2019 03:37:39 +0000 (13:37 +1000)]
Check for negative return for signature size.Addresses Coverity 1442933

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8392)

5 years agoFix seeding from random device w/o getrandom syscall
Bernd Edlinger [Thu, 14 Feb 2019 23:03:50 +0000 (00:03 +0100)]
Fix seeding from random device w/o getrandom syscall

Use select to wait for /dev/random in readable state,
but do not actually read anything from /dev/random,
use /dev/urandom first.

Use linux define __NR_getrandom instead of the
glibc define SYS_getrandom, in case the kernel headers
are more current than the glibc headers.

Fixes #8215

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8251)

5 years agoFix no-ec, no-sm2 and no-sm3
Matt Caswell [Thu, 28 Feb 2019 13:47:26 +0000 (13:47 +0000)]
Fix no-ec, no-sm2 and no-sm3

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8372)

5 years agoAdd section order check in util/find-doc-nits
Paul Yang [Tue, 26 Feb 2019 05:51:02 +0000 (13:51 +0800)]
Add section order check in util/find-doc-nits

This patch checks if the EXAMPLES section in a pod file is placed
before the RETURN VALUES section.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8338)

5 years agoPlace return values after examples in doc
Paul Yang [Tue, 26 Feb 2019 05:11:10 +0000 (13:11 +0800)]
Place return values after examples in doc

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8338)

5 years agoapps/ca.c: only output DER with SPKAC input and when -out is chosen
Richard Levitte [Thu, 28 Feb 2019 10:30:19 +0000 (11:30 +0100)]
apps/ca.c: only output DER with SPKAC input and when -out is chosen

So say the docs

Fixes #8055

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8368)

5 years agoThe use of the likes of UINT32_MAX requires internal/numbers.h
Richard Levitte [Thu, 28 Feb 2019 09:31:20 +0000 (10:31 +0100)]
The use of the likes of UINT32_MAX requires internal/numbers.h

Found a few more cases.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8366)

5 years agoConfigure: support a few more "make variables" defaulting from env
Richard Levitte [Tue, 26 Feb 2019 22:18:02 +0000 (23:18 +0100)]
Configure: support a few more "make variables" defaulting from env

CFLAGS, CXXFLAGS, CPPFLAGS, LDFLAGS, and LDLIBS

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8325)

5 years ago.travis.yml: change -std=c89 to -ansi
Richard Levitte [Tue, 26 Feb 2019 08:34:00 +0000 (09:34 +0100)]
.travis.yml: change -std=c89 to -ansi

For C, -ansi is equivalent to -std=c90
For C++, -ansi is equivalent to -std=c++98

We also place -ansi in CPPFLAGS instead of the usual command line config,
to avoid getting it when linking (clang complains)

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8325)

5 years agoConfiguration: divide devteam flags into language specific sets
Richard Levitte [Tue, 26 Feb 2019 08:32:52 +0000 (09:32 +0100)]
Configuration: divide devteam flags into language specific sets

Some of the devteam flags are not for C++

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8325)

5 years agoDo buildtests on our public header files with C++ as well
Richard Levitte [Mon, 25 Feb 2019 10:43:00 +0000 (11:43 +0100)]
Do buildtests on our public header files with C++ as well

This ensures that we don't mistakenly use C++ keywords anywhere public.

Related to #8313

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8325)

5 years agoOpenSSL::Util::Pod: allow slashes in names
Richard Levitte [Tue, 19 Feb 2019 11:10:14 +0000 (12:10 +0100)]
OpenSSL::Util::Pod: allow slashes in names

The names in the NAME section may describe headers, which contain a slash
for OpenSSL headers.  We deal with that by converting slashes to dashes
for the file names.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8286)

5 years agoReplumbing: Add include/openssl/core.h, initially with core types
Richard Levitte [Sun, 20 Jan 2019 12:23:30 +0000 (13:23 +0100)]
Replumbing: Add include/openssl/core.h, initially with core types

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8286)

5 years agoImplement SSH KDF
Simo Sorce [Wed, 19 Sep 2018 20:23:45 +0000 (16:23 -0400)]
Implement SSH KDF

SSH's KDF is defined in RFC 4253 in Section 7.2

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7290)

5 years agoMake the padlock engine build correctly
Richard Levitte [Wed, 13 Feb 2019 03:23:14 +0000 (04:23 +0100)]
Make the padlock engine build correctly

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8220)

5 years agoEnsure configured module specific and application specific defines are used
Richard Levitte [Wed, 13 Feb 2019 03:21:59 +0000 (04:21 +0100)]
Ensure configured module specific and application specific defines are used

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8220)

5 years agoAdd PADLOCK_ASM to dso_defines rather than lib_defines
Richard Levitte [Wed, 13 Feb 2019 02:58:52 +0000 (03:58 +0100)]
Add PADLOCK_ASM to dso_defines rather than lib_defines

Since the padlock code is an engine, the assembler is for a module,
not a library link to when building a program...  there's a
distinction.

Fixes #2311

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8220)

5 years agoThe use of the likes of UINT32_MAX requires internal/numbers.h
Richard Levitte [Wed, 27 Feb 2019 08:53:17 +0000 (09:53 +0100)]
The use of the likes of UINT32_MAX requires internal/numbers.h

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8354)

5 years agoFix the default digest algorthm of SM2
Paul Yang [Mon, 25 Feb 2019 09:34:03 +0000 (17:34 +0800)]
Fix the default digest algorthm of SM2

Currently SM2 shares the ameth with EC, so the current default digest
algorithm returned is SHA256. This fixes the default digest algorithm of
SM2 to SM3, which is the only valid digest algorithm for SM2 signature.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8186)

5 years agoSupport raw input data in apps/pkeyutl
Paul Yang [Wed, 16 Jan 2019 08:16:28 +0000 (16:16 +0800)]
Support raw input data in apps/pkeyutl

Some signature algorithms require special treatment for digesting, such
as SM2. This patch adds the ability of handling raw input data in
apps/pkeyutl other than accepting only pre-hashed input data.

Beside, SM2 requries an ID string when signing or verifying a piece of data,
this patch also adds the ability for apps/pkeyutil to specify that ID
string.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8186)

5 years agoRevert "Configure: stop forcing use of DEFINE macros in headers"
Richard Levitte [Fri, 15 Feb 2019 10:48:24 +0000 (11:48 +0100)]
Revert "Configure: stop forcing use of DEFINE macros in headers"

Github PR #8246 provides a better solution to the problem.

This reverts commit f11ffa505f8a9345145a26a05bf77b012b6941bd.

[extended tests]

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/8247)

5 years agoAdd BN_native2bn and BN_bn2nativepad, for native BIGNUM import/export
Richard Levitte [Tue, 26 Feb 2019 12:08:31 +0000 (13:08 +0100)]
Add BN_native2bn and BN_bn2nativepad, for native BIGNUM import/export

These are a couple of utility functions, to make import and export of
BIGNUMs to byte strings in platform native for (little-endian or
big-endian) easier.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8346)

5 years ago[test] modernize ecdsatest and extend ECDSA sign KATs
Billy Brumley [Sat, 23 Feb 2019 08:12:35 +0000 (10:12 +0200)]
[test] modernize ecdsatest and extend ECDSA sign KATs

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8314)

5 years agoFix trivial typo in EVP_DigestVerifyInit doc
Nicola Tuveri [Sun, 24 Feb 2019 19:29:32 +0000 (21:29 +0200)]
Fix trivial typo in EVP_DigestVerifyInit doc

Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8319)