openssl.git
8 months agoUpdate pkeyutl documentation about the digest option
Matt Caswell [Thu, 7 Mar 2019 14:02:56 +0000 (14:02 +0000)]
Update pkeyutl documentation about the digest option

DSA can accept other digests other than SHA1. EC ignores the digest option
altogether.

Fixes #8425

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

8 months agoSingle step kdf implementation
Shane Lontis [Fri, 4 Jan 2019 08:41:21 +0000 (18:41 +1000)]
Single step kdf implementation

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

8 months agoMove ASN1_BROKEN macros
Rich Salz [Thu, 21 Feb 2019 18:23:06 +0000 (13:23 -0500)]
Move ASN1_BROKEN macros

They're only used in one place, and only for a legacy datatype.

Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8302)

8 months agoEVP_PKEY_get0_engine documentation
Dmitry Belyavskiy [Mon, 25 Feb 2019 15:24:46 +0000 (18:24 +0300)]
EVP_PKEY_get0_engine documentation

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

8 months agoProviding missing accessor to EVP_PKEY.engine
Dmitry Belyavskiy [Mon, 25 Feb 2019 15:02:33 +0000 (18:02 +0300)]
Providing missing accessor to EVP_PKEY.engine

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

8 months agoapps/speed.c: properly address NO_EC2M on systems without SIGALRM
Vitezslav Cizek [Tue, 5 Mar 2019 21:52:33 +0000 (22:52 +0100)]
apps/speed.c: properly address NO_EC2M on systems without SIGALRM

The ecdh_c array is allocated of the same size as ecdh_choices,
whose size depends on whether the support for binary curves is enabled
or not.  (The same goes for ecdsa_c).
On systems without SIGALRM, ecdh_c is indexed by predefined constants
intended for representing the index of the ciphers in the ecdh_choices
array.
However, in case of NO_EC2M some of the #defined constants won't match
and would actually access the ecdh_c out-of-bounds.

Use enum instead of a macro to define the curve indexes so they're
within the bounds of the ecdh_c array.

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

8 months agoapps/speed.c: skip binary curves when compiling with OPENSSL_NO_EC2M
Vitezslav Cizek [Tue, 5 Mar 2019 16:14:33 +0000 (17:14 +0100)]
apps/speed.c: skip binary curves when compiling with OPENSSL_NO_EC2M

openssl speed doesn't take into account that the library could be
compiled without the support for the binary curves and happily uses
them, which results in EC_GROUP_new_by_curve_name() errors.

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

8 months agoAdd documentation for the -sigopt option.
Pauli [Tue, 19 Mar 2019 01:22:32 +0000 (11:22 +1000)]
Add documentation for the -sigopt option.

Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
(Merged from https://github.com/openssl/openssl/pull/8520)

8 months ago Configure: untabify indentation
Dr. Matthias St. Pierre [Mon, 18 Mar 2019 10:43:59 +0000 (11:43 +0100)]
Configure: untabify indentation

    The indentation in the Configure file is currently very strange when
    viewed in an editor with a tab width of four spaces, because it has
    mixed tab-and-whitespace indentation, which was apparently done with
    a tab width of eight spaces.

    This commit converts all tabs to spaces using expand(1) with default
settings. To verify that there are only whitespace changes, use

       git show --ignore-space-change  <this commit>

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

8 months agoFix resource leak coverity 1443711.
Pauli [Sun, 17 Mar 2019 09:58:24 +0000 (19:58 +1000)]
Fix resource leak coverity 1443711.
Free the allocated pointer on error.

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

8 months agoFix compiling error for mips32r6 and mips64r6
Hua Zhang [Wed, 13 Mar 2019 06:28:44 +0000 (14:28 +0800)]
Fix compiling error for mips32r6 and mips64r6

There are some compiling errors for mips32r6 and mips64r6:

crypto/bn/bn-mips.S:56: Error: opcode not supported on this processor: mips2 (mips2) `mulu $1,$12,$7'
crypto/mips_arch.h: Assembler messages:
crypto/mips_arch.h:15: Error: junk at end of line, first unrecognized character is `&'

Signed-off-by: Hua Zhang <hua.zhang1974@hotmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8464)

8 months agoAdd missing '.text' in crypto/bn/asm/ppc.pl
Richard Levitte [Sat, 16 Mar 2019 09:15:19 +0000 (10:15 +0100)]
Add missing '.text' in crypto/bn/asm/ppc.pl

Fixes #8495

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8496)

8 months agoFix no-posix-io
Richard Levitte [Sat, 16 Mar 2019 11:07:35 +0000 (12:07 +0100)]
Fix no-posix-io

'openssl pkeyutl' uses stat() to determine the file size when signing using
Ed25519/Ed448, and this was guarded with OPENSSL_NO_POSIX_IO.

It is however arguable if stat() is a POSIX IO function, considering
that it doesn't use file descriptors, and even more so since we use
stat() elsewhere without that guard.

This will allow test/recipes/20-test_pkeyutl.t to be able to do its
work for Ed25519/Ed448 signature tests.

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

8 months agoAdded NULL check to BN_clear() & BN_CTX_end()
Shane Lontis [Mon, 18 Mar 2019 23:58:09 +0000 (09:58 +1000)]
Added NULL check to BN_clear() & BN_CTX_end()

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

8 months agoFix strict-warnings build on FreeBSD
Benjamin Kaduk [Thu, 14 Mar 2019 17:55:03 +0000 (12:55 -0500)]
Fix strict-warnings build on FreeBSD

The 'key' member of the (system-defined!) struct session op is of
type c_caddr_t, which can be (signed) char, so inter-casting with the
unsigned char* input to cipher_init() causes -Wpointer-sign errors, and we
can't change the signature of cipher_init() due to the function pointer
type required by EVP_CIPHER_meth_set_init().

As the least-bad option, introduce a void* cast to quell the following
warning:
engines/e_devcrypto.c:356:36: error: passing 'c_caddr_t' (aka 'const char *') to
      parameter of type 'const unsigned char *' converts between pointers to integer
      types with different sign [-Werror,-Wpointer-sign]
        return cipher_init(to_ctx, cipher_ctx->sess.key, EVP_CIPHER_CTX_iv(ctx),
                                   ^~~~~~~~~~~~~~~~~~~~
engines/e_devcrypto.c:191:66: note: passing argument to parameter 'key' here
static int cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,

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

8 months agodoc/man3/OSSL_PARAM_TYPE.pod: modify Example 2 to allow unspecified params
Richard Levitte [Tue, 19 Mar 2019 05:52:15 +0000 (06:52 +0100)]
doc/man3/OSSL_PARAM_TYPE.pod: modify Example 2 to allow unspecified params

A parameter requestor is never obligated to ask for all available
parameters on an object.  Unfortunately, Example 2 showed a code
pattern that introduced such an obligation, and therefore needed a
small adjustment.

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

8 months agoAdd -new and -subj options to x509 app for direct cert generation
David von Oheimb [Mon, 18 Mar 2019 23:35:03 +0000 (09:35 +1000)]
Add -new and -subj options to x509 app for direct cert generation

Complete and improve error output of parse_name() in apps/apps.c

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8193)

8 months agoClear the point S before freeing in ec_scalar_mul_ladder
Bernd Edlinger [Sun, 17 Mar 2019 16:28:24 +0000 (17:28 +0100)]
Clear the point S before freeing in ec_scalar_mul_ladder

The secret point R can be recovered from S using the equation R = S - P.
The X and Z coordinates should be sufficient for that.

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

8 months agoClear the secret point in ecdh_simple_compute_key
Bernd Edlinger [Sun, 17 Mar 2019 08:48:15 +0000 (09:48 +0100)]
Clear the secret point in ecdh_simple_compute_key

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

8 months agoadd 'Signature Value:' line and correct indentation when printing X.509 signature...
David von Oheimb [Fri, 11 May 2018 12:52:51 +0000 (14:52 +0200)]
add 'Signature Value:' line and correct indentation when printing X.509 signature value

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

8 months agoupdate reference output of test_x509 in test/certs/cyrillic.*
David von Oheimb [Fri, 11 May 2018 10:01:49 +0000 (12:01 +0200)]
update reference output of test_x509 in test/certs/cyrillic.*

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

8 months agoremove 'keyid:' when printing simple X509 authority keyID (without issuer and serial)
David von Oheimb [Mon, 29 Jan 2018 15:58:07 +0000 (16:58 +0100)]
remove 'keyid:' when printing simple X509 authority keyID (without issuer and serial)

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

8 months agoremove needless empty lines when printing certificates
David von Oheimb [Mon, 29 Jan 2018 15:54:40 +0000 (16:54 +0100)]
remove needless empty lines when printing certificates

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

8 months agoAdd generic EVP method fetcher
Richard Levitte [Fri, 8 Feb 2019 16:01:56 +0000 (17:01 +0100)]
Add generic EVP method fetcher

This is an interface between Core dispatch table fetching and
EVP_{method}_fetch().  All that's needed from the diverse method
fetchers are the functions to create a method structure from a
dispatch table, a function that ups the method reference counter and a
function to free the method (in case of failure).

This routine is internal to the EVP API andis therefore only made
accessible within crypto/evp, by including evp_locl.h

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

8 months agoReplumbing: better reference counter control in ossl_method_construct()
Richard Levitte [Thu, 14 Mar 2019 20:51:50 +0000 (21:51 +0100)]
Replumbing: better reference counter control in ossl_method_construct()

Fully assume that the method constructors use reference counting.
Otherwise, we may leak memory, or loose track and do a double free.

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

8 months agoReplumbing: pass callback data to the algo destructor too
Richard Levitte [Wed, 13 Mar 2019 10:12:00 +0000 (11:12 +0100)]
Replumbing: pass callback data to the algo destructor too

All relevant OSSL_METHOD_CONSTRUCT_METHOD callbacks got the callback
data passed to them, except 'destruct'.  There's no reason why it
shouldn't get that pointer passed, so we make a small adjustment.

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

8 months agoPPC assembly pack: fix copy-paste error in CTR mode
Daniel Axtens [Sun, 17 Mar 2019 23:22:44 +0000 (10:22 +1100)]
PPC assembly pack: fix copy-paste error in CTR mode

There are two copy-paste errors in handling CTR mode. When dealing
with a 2 or 3 block tail, the code branches to the CBC decryption exit
path, rather than to the CTR exit path.

This can lead to data corruption: in the Linux kernel we have a copy
of this file, and the bug leads to corruption of the IV, which leads
to data corruption when we call the encryption function again later to
encrypt subsequent blocks.

Originally reported to the Linux kernel by Ondrej Mosnáček <omosnacek@gmail.com>

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8510)

8 months agocoverity fixes for bntest.c
Shane Lontis [Mon, 18 Mar 2019 00:39:07 +0000 (10:39 +1000)]
coverity fixes for bntest.c

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

8 months agoEVP_PBE_scrypt() handles salt=NULL as salt=""
Victor Stinner [Thu, 14 Mar 2019 14:23:04 +0000 (15:23 +0100)]
EVP_PBE_scrypt() handles salt=NULL as salt=""

Modify EVP_PBE_scrypt() to maintain OpenSSL 1.1.1 behavior: salt=NULL
is now handled as salt="" (and saltlen=0).

Commit 5a285addbf39f91d567f95f04b2b41764127950d changed the behavior
of EVP_PBE_scrypt(salt=NULL). Previously, salt=NULL was accepted, but
the function now fails with KDF_R_MISSING_SALT.

CLA: trivial

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

8 months agotest/params_api_test.c: fix size_t assumptions
Richard Levitte [Sat, 16 Mar 2019 09:43:48 +0000 (10:43 +0100)]
test/params_api_test.c: fix size_t assumptions

size_t isn't always as large as a int64_t, so the compiler complains
about possible data loss.  In this case, we are in control, so a
simple cast will do.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8497)

8 months agoUpdate to xenial
Bernd Edlinger [Tue, 5 Mar 2019 16:44:53 +0000 (17:44 +0100)]
Update to xenial

[extended tests]

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

8 months agoConfigurations/windows-makefile.tmpl: small fixes
Richard Levitte [Wed, 13 Mar 2019 12:24:17 +0000 (13:24 +0100)]
Configurations/windows-makefile.tmpl: small fixes

Fixes #8467 #8478

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

8 months agoGuard some SM2 functions with OPENSSL_NO_SM2
Matt Caswell [Thu, 14 Mar 2019 11:14:38 +0000 (11:14 +0000)]
Guard some SM2 functions with OPENSSL_NO_SM2

Fixes the no-ec build

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

8 months agotrace: update the documentation
Dr. Matthias St. Pierre [Tue, 12 Mar 2019 22:35:45 +0000 (23:35 +0100)]
trace: update the documentation

This commit adds some missing symbols and other minor enhancements.
In particular, it establishes the term 'channel' as a synonym for
a BIO object attached to a trace category, and introduces the
concept of a 'simple' channel versus a 'callback' channel.

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

8 months agotrace: ensure correct grouping
Dr. Matthias St. Pierre [Tue, 12 Mar 2019 23:14:55 +0000 (00:14 +0100)]
trace: ensure correct grouping

It is important that output to the trace channels occurs only inside
a trace group. This precondtion is satisfied whenever the standard
TRACE macros are used. It can be violated only by a bad programming
mistake, like copying the 'trc_out' pointer and using it outside
the trace group.

This commit enforces correct pairing of the OSSL_TRACE_CTRL_BEGIN and
OSSL_TRACE_CTRL_END callbacks, and checks that OSSL_TRACE_CTRL_WRITE
callbacks only occur within such groups.

While implementing it, it turned out that the group assertion failed

  apps/openssl.c:152: OpenSSL internal error: \
                      Assertion failed: trace_data->ingroup

because the set_trace_data() function invokes some callbacks which
generate trace output, but the correct channel type was set only
after the set_trace_data() call.

To fix the failed assertions, the correct channel type is now set
inside the set_trace_data() call, instead of doing it afterwards.

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

8 months agotrace: don't leak the line prefix
Dr. Matthias St. Pierre [Tue, 12 Mar 2019 22:04:14 +0000 (23:04 +0100)]
trace: don't leak the line prefix

The openssl app registers trace callbacks which automatically
set a line prefix in the OSSL_TRACE_CTRL_BEGIN callback.
This prefix needs to be cleared in the OSSL_TRACE_CTRL_END
callback, otherwise a memory leak is reported when openssl
is built with crypto-mdebug enabled.

This leak causes the tests to fail when tracing and memory
debugging are enabled.

The leak can be observed by any command that produces trace
output, e.g. by

  OPENSSL_TRACE=ANY util/shlib_wrap.sh  apps/openssl version
  ...
  [00:19:14]  4061 file=apps/bf_prefix.c, line=152, ...
  26 bytes leaked in 1 chunks

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

8 months agotrace: rename the trace channel types
Dr. Matthias St. Pierre [Sun, 10 Mar 2019 10:07:27 +0000 (11:07 +0100)]
trace: rename the trace channel types

Since the term 'channel' is already used as synonym for a BIO object attached
to a trace category, having a 't_channel' channel type and a 't_callback' channel
type somehow overburdens this term. For that reason the type enum constants are
renamed to 'SIMPE_CHANNEL' and 'CALLBACK_CHANNEL'.
(The conversion to capital letters was done to comply to the coding style.)

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

8 months agotrace: remove some magic numbers
Dr. Matthias St. Pierre [Sun, 10 Mar 2019 00:35:16 +0000 (01:35 +0100)]
trace: remove some magic numbers

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

8 months agoVMS: only use the high precision on VMS v8.4 and up
Dr. Matthias St. Pierre [Fri, 15 Mar 2019 00:48:51 +0000 (01:48 +0100)]
VMS: only use the high precision on VMS v8.4 and up

Fixes #8487
Amends #7230

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

8 months agointernal/refcount.h: allow non-atomic build
Richard Levitte [Thu, 14 Mar 2019 08:59:00 +0000 (09:59 +0100)]
internal/refcount.h: allow non-atomic build

Configure with -DOPENSSL_DEV_NO_ATOMICS and you get refcount without
atomics.  This is intended for internal development only, to check the
refcounting is properly coded.  It should never become a configuration
option, hence the name of the macro.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8479)

8 months agocrypto/provider_core.c: correct definition and use of lock
Richard Levitte [Thu, 14 Mar 2019 06:59:28 +0000 (07:59 +0100)]
crypto/provider_core.c: correct definition and use of lock

Fixes #8476

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

8 months agoEnable pkeyutl to use Ed448 and Ed25519
Matt Caswell [Thu, 7 Mar 2019 10:37:34 +0000 (10:37 +0000)]
Enable pkeyutl to use Ed448 and Ed25519

With the recent addition of the -rawin option it should be possible for
pkeyutl to sign and verify with Ed448 and Ed2559. The main remaining
stumbling block is that those algorirthms only support "oneshot" operation.
This commit enables pkeyutl to handle that.

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

8 months agoConfigure: disable new trace api by default
Dr. Matthias St. Pierre [Wed, 13 Mar 2019 22:16:29 +0000 (23:16 +0100)]
Configure: disable new trace api by default

Fixes #8472

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

8 months agoDon't fail when tracing is disabled
Richard Levitte [Wed, 13 Mar 2019 23:39:28 +0000 (00:39 +0100)]
Don't fail when tracing is disabled

When tracing is disabled, don't generate errors, especially during
init.  Instead, just pretend the everything is fine.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8475)

8 months agoFix memory leak in ectest
Nicola Tuveri [Wed, 13 Mar 2019 09:38:40 +0000 (11:38 +0200)]
Fix memory leak in ectest

Fixes #8462

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

8 months agotest/params_test.c: use TEST_double_eq to check doubles
Richard Levitte [Wed, 13 Mar 2019 13:06:03 +0000 (14:06 +0100)]
test/params_test.c: use TEST_double_eq to check doubles

TEST_ulong_eq was used previously because TEST_double_eq didn't exist
at the time.

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

8 months agotest/params_test.c: make more global variables static
Richard Levitte [Wed, 13 Mar 2019 13:01:27 +0000 (14:01 +0100)]
test/params_test.c: make more global variables static

Again, compilers that don't like them being undeclared...

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

8 months agotest/params_test.c: make construct_api_params() static
Richard Levitte [Wed, 13 Mar 2019 12:56:46 +0000 (13:56 +0100)]
test/params_test.c: make construct_api_params() static

With enough warning flags, compilers complain when a non-static
function hasn't been properly declared...

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

8 months agoprevent app_get_pass() from revealing cleartext password on syntax error
David von Oheimb [Thu, 1 Feb 2018 10:06:03 +0000 (11:06 +0100)]
prevent app_get_pass() from revealing cleartext password on syntax error

When the argument for '-pass' was badly formed, that argument got
displayed in full.  This turns out to not be such a good idea if the
user simply forgot to start the argument with 'pass:', or spellt the
prefix incorrectly.  We therefore change the display to say that a
colon is missing or only showing the incorrect prefix.

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

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

8 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)

9 months 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)