oweals/openssl.git
5 years agoEVP_FETCH: deal with names without pre-defined NIDs
Richard Levitte [Sun, 5 May 2019 06:42:21 +0000 (08:42 +0200)]
EVP_FETCH: deal with names without pre-defined NIDs

We didn't deal very well with names that didn't have pre-defined NIDs,
as the NID zero travelled through the full process and resulted in an
inaccessible method.  By consequence, we need to refactor the method
construction callbacks to rely more on algorithm names.

We must, however, still store the legacy NID with the method, for the
sake of other code that depend on it (for example, CMS).

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

5 years agoMake the generic EVP fetching mechanism use the namenum map
Richard Levitte [Sat, 4 May 2019 10:56:32 +0000 (12:56 +0200)]
Make the generic EVP fetching mechanism use the namenum map

This avoids using the ASN1_OBJECT database, which is bloated for the
purpose of a simple number <-> name database.

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

5 years agoCreate internal number<->name mapping API
Richard Levitte [Sat, 4 May 2019 10:55:32 +0000 (12:55 +0200)]
Create internal number<->name mapping API

This can be used as a general name to identity map.

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

5 years agoIgnore entropy from RAND_add()/RAND_seed() in FIPS mode [fixup]
Dr. Matthias St. Pierre [Sun, 12 May 2019 07:01:55 +0000 (17:01 +1000)]
Ignore entropy from RAND_add()/RAND_seed() in FIPS mode [fixup]

Small correction to RAND_DRBG(7) (amends 3a50a8a91ad1)

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

5 years agoIgnore entropy from RAND_add()/RAND_seed() in FIPS mode
Dr. Matthias St. Pierre [Wed, 10 Apr 2019 22:06:37 +0000 (00:06 +0200)]
Ignore entropy from RAND_add()/RAND_seed() in FIPS mode

The functions RAND_add() and RAND_seed() provide a legacy API which
enables the application to seed the CSPRNG.

But NIST SP-800-90A clearly mandates that entropy *shall not* be provided
by the consuming application, neither for instantiation, nor for reseeding.

The provided random data will be mixed into the DRBG state as additional
data only, and no entropy will accounted for it.

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

5 years agoTest skip option.
Pauli [Sun, 14 Apr 2019 23:53:53 +0000 (09:53 +1000)]
Test skip option.

Provide C test cases with the option to skip tests and subtests.

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

5 years agoSkip the no derivation functions when in FIPS mode because they are not
Pauli [Wed, 10 Apr 2019 22:55:50 +0000 (08:55 +1000)]
Skip the no derivation functions when in FIPS mode because they are not
applicable.

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

5 years agoFixed 32bit issue for kdf_opts
Shane Lontis [Thu, 9 May 2019 02:33:46 +0000 (12:33 +1000)]
Fixed 32bit issue for kdf_opts

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

5 years agoDon't use '-z defs' if sanitizers are used
Richard Levitte [Tue, 7 May 2019 08:48:30 +0000 (10:48 +0200)]
Don't use '-z defs' if sanitizers are used

There are quite a number of sanitizers for clang that aren't
documented in the clang user documentation.  This makes it impossible
to be selective about what sanitizers to look at to determine if
'-z defs' should be used of not.

Under these circumstances, the sane thing to do is to just look for
any sanitizer specification and not use '-z defs' if there's one
present.

Fixes #8735

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

5 years agocrypto/ppccap.c: Fix which hwcap value used to check for HWCAP_ARCH_3_00
Rashmica Gupta [Tue, 7 May 2019 02:42:59 +0000 (12:42 +1000)]
crypto/ppccap.c: Fix which hwcap value used to check for HWCAP_ARCH_3_00

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/8889)

5 years agoSquashed commit of the following:
Lorinczy Zsigmond [Wed, 8 May 2019 23:16:19 +0000 (09:16 +1000)]
Squashed commit of the following:

Add new option '-http_server_binmode' which allows the server to open and send
binary files as well as text.

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

5 years agoossl_bsearch(): New generic internal binary search utility function
Richard Levitte [Wed, 8 May 2019 08:40:20 +0000 (10:40 +0200)]
ossl_bsearch(): New generic internal binary search utility function

OBJ_bsearch_ and OBJ_bsearch_ex_ are generic functions that don't
really belong with the OBJ API, but should rather be generic utility
functions.  The ending underscore indicates that they are considered
internal, even though they are declared publicly.

Since crypto/stack/stack.c uses OBJ_bsearch_ex_, the stack API ends up
depending on the OBJ API, which is unnecessary, and carries along
other dependencies.

Therefor, a generic internal function is created, ossl_bsearch().
This removes the unecessary dependencies.

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

5 years agoAllow specifying the tag after AAD in CCM mode
Tobias Nießen [Fri, 14 Sep 2018 19:49:34 +0000 (21:49 +0200)]
Allow specifying the tag after AAD in CCM mode

This change allows to pass the authentication tag after specifying
the AAD in CCM mode. This is already true for the other two supported
AEAD modes (GCM and OCB) and it seems appropriate to match the
behavior.

GCM and OCB also support to set the tag at any point before the call
to `EVP_*Final`, but this won't work for CCM due to a restriction
imposed by section 2.6 of RFC3610: The tag must be set before
actually decrypting data.

This commit also adds a test case for setting the tag after supplying
plaintext length and AAD.

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

5 years agoEVP_EncryptUpdate, EVP_EncryptFinal_ex: don't branch on uninitialized memory
Guido Vranken [Fri, 3 May 2019 13:44:38 +0000 (15:44 +0200)]
EVP_EncryptUpdate, EVP_EncryptFinal_ex: don't branch on uninitialized memory

If ctx->cipher->cupdate/ctx->cipher->cfinal failed, 'soutl' is left
uninitialized.

This patch incorporates the same logic as present in EVP_DecryptUpdate and
EVP_DecryptFinal_ex: only branch on 'soutl' if the preceding call succeeded.

Bug found by OSS-Fuzz.

Signed-off-by: Guido Vranken <guidovranken@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8874)

5 years agoCoverity CID 1444950: Control flow issues
Pauli [Tue, 7 May 2019 01:10:33 +0000 (11:10 +1000)]
Coverity CID 1444950: Control flow issues

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

5 years agoCoverity CID 1444951: Null pointer dereferences
Pauli [Tue, 7 May 2019 01:07:41 +0000 (11:07 +1000)]
Coverity CID 1444951: Null pointer dereferences

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

5 years agoCoverity CID 1444952: Null pointer dereferences
Pauli [Tue, 7 May 2019 01:06:33 +0000 (11:06 +1000)]
Coverity CID 1444952: Null pointer dereferences

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

5 years agoCoverity CID 1444953: Null pointer dereferences
Pauli [Tue, 7 May 2019 01:04:37 +0000 (11:04 +1000)]
Coverity CID 1444953: Null pointer dereferences

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

5 years agoCoverity CID 1444954: Integer handling issues
Pauli [Tue, 7 May 2019 00:59:14 +0000 (10:59 +1000)]
Coverity CID 1444954: Integer handling issues

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

5 years agoCoverity CID 1444955: Null pointer dereferences
Pauli [Tue, 7 May 2019 00:57:34 +0000 (10:57 +1000)]
Coverity CID 1444955: Null pointer dereferences

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

5 years agoCoverity CID 1444956: Integer handling issues
Pauli [Tue, 7 May 2019 00:55:39 +0000 (10:55 +1000)]
Coverity CID 1444956: Integer handling issues

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

5 years agoCoverity CID 1444957: Error handling issues
Pauli [Tue, 7 May 2019 00:52:52 +0000 (10:52 +1000)]
Coverity CID 1444957: Error handling issues

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

5 years agoCoverity CID 1444958: Null pointer dereferences
Pauli [Tue, 7 May 2019 00:48:42 +0000 (10:48 +1000)]
Coverity CID 1444958: Null pointer dereferences

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

5 years agoCoverity CID 1444959: Integer handling issues
Pauli [Tue, 7 May 2019 00:45:57 +0000 (10:45 +1000)]
Coverity CID 1444959: Integer handling issues

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

5 years agoCoverity CID 1444960: Error handling issues
Pauli [Tue, 7 May 2019 00:42:58 +0000 (10:42 +1000)]
Coverity CID 1444960: Error handling issues

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

5 years agoCoverity CID 1444961: Integer handling issues
Pauli [Tue, 7 May 2019 00:26:32 +0000 (10:26 +1000)]
Coverity CID 1444961: Integer handling issues

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

5 years agoCoverity CID 1444963: Null pointer dereferences
Pauli [Tue, 7 May 2019 00:18:29 +0000 (10:18 +1000)]
Coverity CID 1444963: Null pointer dereferences

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

5 years agoReject obviously invalid DSA parameters during signing
Matt Caswell [Fri, 3 May 2019 14:56:08 +0000 (15:56 +0100)]
Reject obviously invalid DSA parameters during signing

Fixes #8875

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

5 years agossl: Add SSL_sendfile
Boris Pismenny [Sat, 13 Apr 2019 14:20:35 +0000 (17:20 +0300)]
ssl: Add SSL_sendfile

This commit adds the SSL_sendfile call, which allows KTLS sockets to
transmit file using zero-copy semantics.

Signed-off-by: Boris Pismenny <borisp@mellanox.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8727)

5 years agoLinux ktls sendfile
Boris Pismenny [Thu, 11 Apr 2019 13:24:42 +0000 (16:24 +0300)]
Linux ktls sendfile

This commit introduces support for Linux KTLS sendfile.
Sendfile semantics require the use of a kernel TLS socket to construct the TLS
record headers, encrypt and authenticate the data.
KTLS sendfile improves performance by avoiding the copy of file data into user
space, which is required today.

Signed-off-by: Boris Pismenny <borisp@mellanox.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8727)

5 years agoman: fix a typo and a grammar nit in EVP_PKEY_meth_new(3)
Dr. Matthias St. Pierre [Tue, 7 May 2019 09:59:11 +0000 (11:59 +0200)]
man: fix a typo and a grammar nit in EVP_PKEY_meth_new(3)

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

5 years agoChange the digest string from "md" to "digest"
Simo Sorce [Thu, 18 Apr 2019 12:26:29 +0000 (08:26 -0400)]
Change the digest string from "md" to "digest"

Conform to other modules which were changed at the last minute and this
discrepancy was not noticed.
Retain "md" as an alias so not to break 3rd party backports/tests scripts.

Signed-off-by: Simo Sorce <simo@redhat.com>
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/8783)

5 years agoAdded generated files for EVP_KDF changes
Shane Lontis [Wed, 24 Apr 2019 00:06:54 +0000 (10:06 +1000)]
Added generated files for EVP_KDF changes

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

5 years agoAdded EVP_KDF (similiar to the EVP_MAC)
Shane Lontis [Mon, 22 Apr 2019 07:18:56 +0000 (17:18 +1000)]
Added EVP_KDF (similiar to the EVP_MAC)

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

5 years agoAdd documentation for running unit tests under Valgrind
Todd Short [Thu, 2 May 2019 18:37:18 +0000 (14:37 -0400)]
Add documentation for running unit tests under Valgrind

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

5 years agoUpdate internal documentation after global data move to OPENSSL_CTX
Matt Caswell [Thu, 2 May 2019 13:32:44 +0000 (14:32 +0100)]
Update internal documentation after global data move to OPENSSL_CTX

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

5 years agoAdd some TODO notes into init.c
Matt Caswell [Thu, 2 May 2019 12:42:31 +0000 (13:42 +0100)]
Add some TODO notes into init.c

We should be seeking to move the OPENSSL_init_crypto and OPENSSL_cleanup
processing into OPENSSL_CTX instead.

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

5 years agoInstead of global data store it in an OPENSSL_CTX
Matt Caswell [Wed, 1 May 2019 10:02:43 +0000 (11:02 +0100)]
Instead of global data store it in an OPENSSL_CTX

Various core and property related code files used global data. We should
store all of that in an OPENSSL_CTX instead.

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

5 years agoAdd support for openssl_ctx_run_once and openssl_ctx_onfree
Matt Caswell [Tue, 30 Apr 2019 14:15:48 +0000 (15:15 +0100)]
Add support for openssl_ctx_run_once and openssl_ctx_onfree

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

5 years agoUse vxRandLib for VxWorks7
Klotz, Tobias [Tue, 19 Feb 2019 12:34:32 +0000 (13:34 +0100)]
Use vxRandLib for VxWorks7

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/8023)

5 years agoopenssl cms: add error message if operation option is missing
Dr. Matthias St. Pierre [Thu, 2 May 2019 12:49:34 +0000 (14:49 +0200)]
openssl cms: add error message if operation option is missing

If the `openssl cms` command is called without specifying an
operation option, it replies with the following laconic error message:

    cms: Use -help for summary.

This commit adds a helpful error message:

    No operation option (-encrypt|-decrypt|-sign|-verify|...) specified.

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

5 years agoTest: use keywords instead of magic numbers for 'rsa_pss_saltlen'
Dr. Matthias St. Pierre [Thu, 2 May 2019 11:57:35 +0000 (13:57 +0200)]
Test: use keywords instead of magic numbers for 'rsa_pss_saltlen'

Since commit 137096a7ead it is possible to specify keywords instead
of negative magic numbers for the salt length. This commit replaces
the remaining occurrences of `rsa_pss_saltlen:-3` in the test recipes
by `rsa_pss_saltlen:max`.

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

5 years agoAllow setting RCFLAGS as Configure option or environment variable
Wojciech Kaluza [Sun, 21 Apr 2019 11:39:20 +0000 (12:39 +0100)]
Allow setting RCFLAGS as Configure option or environment variable

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

5 years agoAdd RCFLAGS variable in Windows build file, and use it
Wojciech Kaluza [Sun, 21 Apr 2019 11:14:34 +0000 (12:14 +0100)]
Add RCFLAGS variable in Windows build file, and use it

- Allow user-defined RCFLAGS
- Pass RCFLAGS to RC

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

5 years agoFix no-srp
Matt Caswell [Tue, 30 Apr 2019 12:49:25 +0000 (13:49 +0100)]
Fix no-srp

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

5 years agop_get_params() [test/p_test.c]: clear the OSSL_PARAM buffers for every test
Richard Levitte [Tue, 30 Apr 2019 13:24:06 +0000 (15:24 +0200)]
p_get_params() [test/p_test.c]: clear the OSSL_PARAM buffers for every test

Fixes #8796

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

5 years agogendsa: dsaparam: introduce -verbose option to enable output
Philip Prindeville [Thu, 9 Aug 2018 21:19:19 +0000 (15:19 -0600)]
gendsa: dsaparam: introduce -verbose option to enable output

Other commands like 'req' support -verbose, so why not gendsa and dsaparam?

Part of a larger and more ambitious effort to add -verbose to all apps
that might be used in scripts and need to otherwise run silently (well,
without belching out anything that isn't a warning or error... which ties
into a later scrub of using STDOUT were appropriate for informative
messages instead of STDERR)... so that scripts also have the option of
doing >/dev/null without losing anything critical.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/6908)

5 years agogenrsa: introduce -verbose option to enable output
Philip Prindeville [Wed, 8 Aug 2018 17:51:23 +0000 (11:51 -0600)]
genrsa: introduce -verbose option to enable output

Other commands like 'req' support -verbose, so why not genrsa?

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/6897)

5 years agoStructure alignment macro.
Pauli [Tue, 30 Apr 2019 10:36:16 +0000 (20:36 +1000)]
Structure alignment macro.

Introduce a macro that allows all structure alignment tricks to be rolled up
into a single place.

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

5 years agoReplumbing: give the possibility for the provider to create a context
Richard Levitte [Tue, 30 Apr 2019 11:41:51 +0000 (13:41 +0200)]
Replumbing: give the possibility for the provider to create a context

OSSL_provider_init() gets another output parameter, holding a pointer
to a provider side context.  It's entirely up to the provider to
define the context and what it's being used for.  This pointer is
passed back to other provider functions, typically the provider global
get_params and set_params functions, and also the diverse algorithm
context creators, and of course, the teardown function.

With this, a provider can be instantiated more than once, or be
re-loaded as the case may be, while maintaining instance state.

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

5 years agoReplumbing: make the oneshot proider cipher function like the others
Richard Levitte [Tue, 30 Apr 2019 12:01:52 +0000 (14:01 +0200)]
Replumbing: make the oneshot proider cipher function like the others

The OP_cipher_final function takes a return output size and an output
buffer size argument.  The oneshot OP_cipher_cipher function should do
the same.

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

5 years agoFIPS: Fix compiler errors in rsa_chk.c when building with `-DFIPS_MODE`
Dr. Matthias St. Pierre [Mon, 29 Apr 2019 17:12:38 +0000 (19:12 +0200)]
FIPS: Fix compiler errors in rsa_chk.c when building with `-DFIPS_MODE`

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

5 years agoConfigure: process shared-info.pl later
Richard Levitte [Tue, 30 Apr 2019 08:33:55 +0000 (10:33 +0200)]
Configure: process shared-info.pl later

The reason is that the shared-info attributes may depend on %disabled,
so we need to process all enablings/disablings first.

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

5 years agoSquashed commit of the following:
Pauli [Tue, 30 Apr 2019 03:43:19 +0000 (13:43 +1000)]
Squashed commit of the following:

Digest stored entropy for CRNG test.

Via the FIPS lab, NIST confirmed:

    The CMVP had a chance to discuss this inquiry and we agree that
    hashing the NDRNG block does meet the spirit and letter of AS09.42.

    However, the CMVP did have a few questions: what hash algorithm would
    be used in this application? Is it approved? Is it CAVs tested?

SHA256 is being used here and it will be both approved and CAVs tested.

This means that no raw entropy needs to be kept between RNG seedings, preventing
a potential attack vector aganst the randomness source and the DRBG chains.

It also means the block of secure memory allocated for this purpose is no longer
required.

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

5 years agoCollapse ssl3_state_st (s3) into ssl_st
Todd Short [Wed, 12 Dec 2018 18:09:50 +0000 (13:09 -0500)]
Collapse ssl3_state_st (s3) into ssl_st

With the removal of SSLv2, the s3 structure is always allocated, so
there is little point in having it be an allocated pointer. Collapse
the ssl3_state_st structure into ssl_st and fixup any references.

This should be faster than going through an indirection and due to
fewer allocations, but I'm not seeing any significant performance
improvement; it seems to be within the margin of error in timing.

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

5 years agoCopy RSA-PSS saltlen in EVP_PKEY_CTX_dup.
David Benjamin [Tue, 16 Apr 2019 03:36:40 +0000 (22:36 -0500)]
Copy RSA-PSS saltlen in EVP_PKEY_CTX_dup.

pkey_rsa_copy was missing a field. Test this by repeating the operation
through an EVP_PKEY_CTX_dup copy in evp_test.

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

5 years agos390x assembly pack: remove poly1305 dependency on non-base memnonics
Patrick Steuer [Mon, 25 Mar 2019 17:23:59 +0000 (18:23 +0100)]
s390x assembly pack: remove poly1305 dependency on non-base memnonics

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8181)

5 years agos390x assembly pack: remove chacha20 dependency on non-base memnonics
Patrick Steuer [Mon, 25 Mar 2019 17:22:02 +0000 (18:22 +0100)]
s390x assembly pack: remove chacha20 dependency on non-base memnonics

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8181)

5 years agos390x assembly pack: update perlasm module
Patrick Steuer [Mon, 25 Mar 2019 17:20:27 +0000 (18:20 +0100)]
s390x assembly pack: update perlasm module

Add non-base instructions which are used by the chacha20 and
poly1305 modules.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8181)

5 years agos390x assembly pack: allow alignment hints for vector load/store
Patrick Steuer [Thu, 7 Feb 2019 15:44:05 +0000 (16:44 +0100)]
s390x assembly pack: allow alignment hints for vector load/store

z14 introduced alignment hints to help vector load/store
performance. For its predecessors, alignment hint defaults
to 0 (no alignment indicated).

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8181)

5 years agoStatistically test BN_rand_range().
Pauli [Wed, 24 Apr 2019 01:24:11 +0000 (11:24 +1000)]
Statistically test BN_rand_range().

Add a Chi^2 goodness of fit test to empirically provide a degree of confidence
in the uniformity of the output of the random range generation function.

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

5 years agoFix error in BIO_get_ktls_send() and BIO_get_ktls_recv()
Matt Caswell [Fri, 19 Apr 2019 12:55:08 +0000 (13:55 +0100)]
Fix error in BIO_get_ktls_send() and BIO_get_ktls_recv()

If we were using a different type of BIO than a socket BIO then
BIO_get_ktls_send() and BIO_get_ktls_recv() could return the wrong
result.

The above occurred even if KTLS was disabled at compile time - so we should
additionally ensure that those macros do nothing if KTLS is disabled.

Finally we make the logic in ssl3_get_record() a little more robust when
KTLS has been disabled.

[extended tests]

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

5 years agoFix KTLS compilation error
Matt Caswell [Fri, 19 Apr 2019 12:53:56 +0000 (13:53 +0100)]
Fix KTLS compilation error

If the kernel headers are sufficiently recent to have KTLS transmit
support, but not recent enough to have KTLS receive support then a
compilation error would be the result.

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

5 years agoEnforce a strict output length check in CRYPTO_ccm128_tag
Guido Vranken [Mon, 22 Apr 2019 12:11:12 +0000 (14:11 +0200)]
Enforce a strict output length check in CRYPTO_ccm128_tag

Return error if the output tag buffer size doesn't match
the tag size exactly. This prevents the caller from
using that portion of the tag buffer that remains
uninitialized after an otherwise succesfull call to
CRYPTO_ccm128_tag.

Bug found by OSS-Fuzz.

Fix suggested by Kurt Roeckx.

Signed-off-by: Guido Vranken <guidovranken@gmail.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8810)

5 years agodoc: Get rid of unrelated reference to DSA_new()
Jakub Jelen [Thu, 18 Apr 2019 14:09:45 +0000 (16:09 +0200)]
doc: Get rid of unrelated reference to DSA_new()

CLA: trivial

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8786)

5 years agoadded openssl app 'kdf' and 'mac' to the NEWS and CHANGES docs
Shane Lontis [Tue, 23 Apr 2019 09:17:40 +0000 (19:17 +1000)]
added openssl app 'kdf' and 'mac' to the NEWS and CHANGES docs

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

5 years agoAdded app for EVP_KDF
Shane Lontis [Tue, 16 Apr 2019 10:10:04 +0000 (20:10 +1000)]
Added app for EVP_KDF

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

5 years agoRecognise clang -fsanitize options and translate them
Richard Levitte [Wed, 17 Apr 2019 20:30:03 +0000 (22:30 +0200)]
Recognise clang -fsanitize options and translate them

Because we depend on knowing if clang's address, memory or undefinedbehavior
sanitizers are enabled, we make an extra effort to detect them among the
C flags, and adjust the %disabled values accordingly.

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

5 years agoAdd a way for the application to get OpenSSL configuration data
Richard Levitte [Tue, 9 Apr 2019 12:39:54 +0000 (14:39 +0200)]
Add a way for the application to get OpenSSL configuration data

OpenSSL_version(OPENSSL_DIR) gives you a nicely formatted string for
display, but if all you really want is the directory itself, you were
forced to parsed the string.

This introduces a new function to get diverse configuration data from
the library, OPENSSL_info().  This works the same way as
OpenSSL_version(), but has its own series of types, currently
including:

OPENSSL_INFO_CONFIG_DIR         returns OPENSSLDIR
OPENSSL_INFO_ENGINES_DIR        returns ENGINESDIR
OPENSSL_INFO_MODULES_DIR        returns MODULESDIR
OPENSSL_INFO_DSO_EXTENSION      returns DSO_EXTENSION

OPENSSL_INFO_DIR_FILENAME_SEPARATOR     returns directory/filename separator
OPENSSL_INFO_LIST_SEPARATOR             returns list separator

For scripting purposes, this also adds the command 'openssl info'.

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

5 years agoAdd the possibility to display and use MODULESDIR
Richard Levitte [Tue, 9 Apr 2019 12:33:29 +0000 (14:33 +0200)]
Add the possibility to display and use MODULESDIR

This adds the flag OPENSSL_MODULES_DIR for OpenSSL_version(), and the
flag '-m' for 'openssl version'.

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

5 years agoConfigure: make disabling stuff easier and safer
Richard Levitte [Tue, 23 Apr 2019 07:41:19 +0000 (09:41 +0200)]
Configure: make disabling stuff easier and safer

Disabling one thing may mean having to disable other things as well.
We already have a process to auto-disable things through cascading,
but that was under-used.

Making the cascading mechanism available through a function to be
called to disable stuff makes it more automatic, and helps us when we
forget how different disabling options affect others.

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

5 years agoConfigure: recognise -static even if given through variables
Richard Levitte [Tue, 23 Apr 2019 07:29:45 +0000 (09:29 +0200)]
Configure: recognise -static even if given through variables

Fixes #8787

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

5 years agoConfigure: merge all of %user and %useradd into %config earlier
Richard Levitte [Tue, 23 Apr 2019 07:24:38 +0000 (09:24 +0200)]
Configure: merge all of %user and %useradd into %config earlier

This came about with the realisation that upper case CFLAGS, LDFLAGS
and so on aren't treated much after that, and this makes figuring out
user added flags significantly easier, just look in %config.

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

5 years agoIf key or iv is NULL set the respective length to 0
Matt Caswell [Fri, 19 Apr 2019 15:48:09 +0000 (16:48 +0100)]
If key or iv is NULL set the respective length to 0

[extended tests]

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

5 years agoFix EVP_CIPHER_CTX_rand_key()
Matt Caswell [Fri, 19 Apr 2019 15:21:10 +0000 (16:21 +0100)]
Fix EVP_CIPHER_CTX_rand_key()

Make sure we use the the correct key length in EVP_CIPHER_CTX_rand_key().
Now that ciphers may come from providers we need to make sure we ask the
provider for the value if appropriate.

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

5 years agoFix no-ec2m
Matt Caswell [Fri, 19 Apr 2019 10:17:44 +0000 (11:17 +0100)]
Fix no-ec2m

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

5 years agoFix bug in entropy gathering.
Pauli [Fri, 19 Apr 2019 06:23:23 +0000 (16:23 +1000)]
Fix bug in entropy gathering.

This only impacts FIPS mode or someone who has enabled the FIPS 140.2
4.9.2 Conditional Tests.  i.e. nobody currently.

Fix a significant issue in the entropy gathering for the continuous RNG
testing.  The impact is using an uninitialised buffer instead of the gathered
entropy.

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

5 years agoCheck if num is 0 before trying to malloc memory. Otherwise for client hellos without...
dyrock [Mon, 15 Apr 2019 16:01:58 +0000 (11:01 -0500)]
Check if num is 0 before trying to malloc memory. Otherwise for client hellos without extensions SSL_client_hello_get1_extensions_present will return MALLOC_FAILURE.

Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8756)

5 years agoAdd some more test vectors for ChaCha20
Matt Caswell [Thu, 18 Apr 2019 09:55:11 +0000 (10:55 +0100)]
Add some more test vectors for ChaCha20

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

5 years agoClarify the documentation on the use of ChaCha20
Matt Caswell [Thu, 18 Apr 2019 09:54:58 +0000 (10:54 +0100)]
Clarify the documentation on the use of ChaCha20

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

5 years agoCreate provider errors and use them
Matt Caswell [Thu, 18 Apr 2019 16:43:05 +0000 (17:43 +0100)]
Create provider errors and use them

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

5 years agoFix the S390X support for the basic AES ciphers
Matt Caswell [Tue, 16 Apr 2019 14:37:23 +0000 (15:37 +0100)]
Fix the S390X support for the basic AES ciphers

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

5 years agoAdd forward declarations of the AES dispatch table functions
Matt Caswell [Mon, 15 Apr 2019 14:33:58 +0000 (15:33 +0100)]
Add forward declarations of the AES dispatch table functions

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

5 years agoMake implementation of blocksize, iv_length and key_length mandatory
Matt Caswell [Wed, 10 Apr 2019 12:54:38 +0000 (13:54 +0100)]
Make implementation of blocksize, iv_length and key_length mandatory

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

5 years agoAdd a maximum output length to update and final calls
Matt Caswell [Wed, 10 Apr 2019 12:43:45 +0000 (13:43 +0100)]
Add a maximum output length to update and final calls

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

5 years agoAdd iv length and key length params to the cipher init calls
Matt Caswell [Wed, 10 Apr 2019 12:23:58 +0000 (13:23 +0100)]
Add iv length and key length params to the cipher init calls

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

5 years agoImplement AES CTR ciphers in the default provider
Matt Caswell [Mon, 8 Apr 2019 16:19:59 +0000 (17:19 +0100)]
Implement AES CTR ciphers in the default provider

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

5 years agoImplement AES CFB ciphers in the default provider
Matt Caswell [Mon, 8 Apr 2019 16:13:01 +0000 (17:13 +0100)]
Implement AES CFB ciphers in the default provider

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

5 years agoImplement AES OFB ciphers in the default provider
Matt Caswell [Mon, 8 Apr 2019 15:55:34 +0000 (16:55 +0100)]
Implement AES OFB ciphers in the default provider

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

5 years agoImplement AES CBC ciphers in the default provider
Matt Caswell [Wed, 3 Apr 2019 17:01:21 +0000 (18:01 +0100)]
Implement AES CBC ciphers in the default provider

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

5 years agoAdd support in the default provider for 192/128 bit AES ECB
Matt Caswell [Wed, 3 Apr 2019 15:53:22 +0000 (16:53 +0100)]
Add support in the default provider for 192/128 bit AES ECB

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

5 years agoAdd the provider_algs.h internal header file
Matt Caswell [Wed, 3 Apr 2019 15:39:34 +0000 (16:39 +0100)]
Add the provider_algs.h internal header file

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

5 years agoImplement support for AES-256-ECB in the default provider
Matt Caswell [Wed, 3 Apr 2019 14:34:08 +0000 (15:34 +0100)]
Implement support for AES-256-ECB in the default provider

We also lay the ground work for various of other the basic AES ciphers.

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

5 years agoMake EVP_Encrypt*/EVP_Decrypt* and EVP_Cipher* provider aware
Matt Caswell [Wed, 3 Apr 2019 14:38:07 +0000 (15:38 +0100)]
Make EVP_Encrypt*/EVP_Decrypt* and EVP_Cipher* provider aware

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

5 years agoossl_method_store_cache_get(): ensure non-NULL property query
Richard Levitte [Thu, 18 Apr 2019 15:46:32 +0000 (17:46 +0200)]
ossl_method_store_cache_get(): ensure non-NULL property query

The comparator further down the call stack doesn't tolerate NULL, so
if we got that as input, use the empty string.

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

5 years agoOPENSSL_LH_flush(): assign NULL after freeing
Richard Levitte [Thu, 18 Apr 2019 14:33:21 +0000 (16:33 +0200)]
OPENSSL_LH_flush(): assign NULL after freeing

OPENSSL_LH_flush() frees the linked lists for each slot, but didn't
set the list head to NULL after doing so, with the result that an
operation that affects these lists is likely to cause a crash.

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

5 years agoFix the generic EVP algorithm fetch to actually cache them
Richard Levitte [Thu, 18 Apr 2019 10:23:21 +0000 (12:23 +0200)]
Fix the generic EVP algorithm fetch to actually cache them

ossl_method_store_cache_get() and ossl_method_store_cache_set() were
called with a NULL argument for store, which means no caching is
done.  Give them a real store instead.

Also, increment the refcount when we do get a method out of the cache.

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

5 years agoasn1parse: avoid double free
Richard Levitte [Mon, 15 Apr 2019 11:15:55 +0000 (13:15 +0200)]
asn1parse: avoid double free

|str| was used for multiple conflicting purposes.  When using
'-strictpem', it's used to uniquely hold a reference to the loaded
payload.  However, when using '-strparse', |str| was re-used to hold
the position from where to start parsing.

So when '-strparse' and '-strictpem' are were together, |str| ended up
pointing into data pointed at by |at|, and was yet being freed, with
the result that the payload it held a reference to became a memory
leak, and there was a double free conflict when both |str| and |at|
were being freed.

The situation is resolved by always having |buf| hold the pointer to
the file data, and always and only use |str| to hold the position to
start parsing from.  Now, we only need to free |buf| properly and not
|str|.

Fixes #8752

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

5 years agoAdd SSHKDF in evp_kdf_test
Simo Sorce [Wed, 17 Apr 2019 14:48:49 +0000 (10:48 -0400)]
Add SSHKDF in evp_kdf_test

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8774)

5 years agochacha/asm/chacha-armv8.pl: replace 3+1 code paths with 4+1.
Andy Polyakov [Wed, 17 Apr 2019 19:31:01 +0000 (21:31 +0200)]
chacha/asm/chacha-armv8.pl: replace 3+1 code paths with 4+1.

The change is triggered by ThunderX2 where 3+1 was slower than scalar
code path, but it helps all processors [to handle <512 inputs].

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