oweals/openssl.git
8 years agoCode cleanup UI
Rich Salz [Tue, 30 Aug 2016 17:31:18 +0000 (13:31 -0400)]
Code cleanup UI

Remove NULL check on parameter, and use NULL not ! on buffer.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit bde588df8a4d9f714cefe9cfd1a3931558de4c3c)

8 years agoAdd some CertStatus tests
Matt Caswell [Tue, 30 Aug 2016 13:20:18 +0000 (14:20 +0100)]
Add some CertStatus tests

The previous commit revealed a long standing problem where CertStatus
processing was broken in DTLS. This would have been revealed by better
testing - so add some!

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 767ccc3b77cde82c46ab4af541663f6c80e538d3)

8 years agoEnsure the CertStatus message adds a DTLS message header where needed
Matt Caswell [Tue, 30 Aug 2016 10:32:49 +0000 (11:32 +0100)]
Ensure the CertStatus message adds a DTLS message header where needed

The function tls_construct_cert_status() is called by both TLS and DTLS
code. However it only ever constructed a TLS message header for the message
which obviously failed in DTLS.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit f046afb0663fc4514f7fc5d1724439caa6858932)

8 years agoConfigure: save away the value of OPENSSL_LOCAL_CONFIG_DIR for reconf
Richard Levitte [Mon, 29 Aug 2016 20:11:36 +0000 (22:11 +0200)]
Configure: save away the value of OPENSSL_LOCAL_CONFIG_DIR for reconf

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit ee4cdb7fdbdc46f931cb6e2eca109cc92832eb33)

8 years agoConfigure: Redo the logic for finding build file templates
Richard Levitte [Mon, 29 Aug 2016 19:48:12 +0000 (21:48 +0200)]
Configure: Redo the logic for finding build file templates

Build file templates would be looked up like this if the user gave us
an additional directory to look for configuration files and build file
templates:

    $OPENSSL_LOCAL_CONFIG_DIR/$OSTYPE-Makefile.tmpl
    $SOURCEDIR/Configurations/$OSTYPE-Makefile.tmpl
    $OPENSSL_LOCAL_CONFIG_DIR/Makefile.tmpl
    $SOURCEDIR/Configurations/Makefile.tmpl

So for example, if the user created his own Makefile.tmpl and tried to
use it with a unixly config, it would never be user because we have a
unix-Makefile.tmpl in our Configurations directory.  This is clearly
wrong, and this change makes it look in this order instead:

    $OPENSSL_LOCAL_CONFIG_DIR/$OSTYPE-Makefile.tmpl
    $OPENSSL_LOCAL_CONFIG_DIR/Makefile.tmpl
    $SOURCEDIR/Configurations/$OSTYPE-Makefile.tmpl
    $SOURCEDIR/Configurations/Makefile.tmpl

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 79822c3cd55b9241187123fd016cb3c9a3beffbb)

8 years agoConfigure: clean away temporary section of code
Richard Levitte [Mon, 29 Aug 2016 19:46:29 +0000 (21:46 +0200)]
Configure: clean away temporary section of code

We've done away with Makefile as source of information and now use
configdata.pm exclusively.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit acc63c7d6d4ea28497a6192a3445b40f2af88133)

8 years agoMake it possible for the user to specify a different default build file
Richard Levitte [Mon, 29 Aug 2016 19:45:19 +0000 (21:45 +0200)]
Make it possible for the user to specify a different default build file

Make sure the information is kept for reconfiguration too.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 8b5156d18855f536cf5ceac10f5781e19fa8f1ea)

8 years agoRemove comment tags from structs (coding style)
Rich Salz [Mon, 29 Aug 2016 13:07:38 +0000 (09:07 -0400)]
Remove comment tags from structs (coding style)

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit d196305aa0de1fc38837c27cb1ea6e60af9dd98d)

8 years agoUse uppercase name for PCT_ enum
Rich Salz [Mon, 29 Aug 2016 12:23:25 +0000 (08:23 -0400)]
Use uppercase name for PCT_ enum

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 66117ab0f6c21a7c123becd58bd38a736e551c43)

8 years agoVMS: honor --openssldir setting
Richard Levitte [Fri, 26 Aug 2016 20:34:39 +0000 (22:34 +0200)]
VMS: honor --openssldir setting

Because of a perl operator priority mixup, the --openssldir argument
wasn't honored.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 661a396373fbd2082eee4ad6829336219ec7dac6)

8 years agoRemove trailing zeros
Rich Salz [Fri, 26 Aug 2016 17:07:56 +0000 (13:07 -0400)]
Remove trailing zeros

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit e5f969a82fa81fad8d1721fc0bc915ad3eea927c)

8 years agoImprove the definition of STITCHED_CALL in e_rc4_hmac_md5.c
Richard Levitte [Fri, 26 Aug 2016 07:59:55 +0000 (09:59 +0200)]
Improve the definition of STITCHED_CALL in e_rc4_hmac_md5.c

The definition of STITCHED_CALL relies on OPENSSL_NO_ASM.  However,
when a configuration simply lacks the assembler implementation for RC4
(which is where we have implemented the stitched call), OPENSSL_NO_ASM
isn't implemented.  Better, then, to rely on specific macros that
indicated that RC4 (and MD5) are implemented in assembler.

For this to work properly, we must also make sure Configure adds the
definition of RC4_ASM among the C flags.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 216e8d91033d237880cff7da0d02d46d47bae41b)

8 years agoRemove note from CHANGES about EC DRBG
Matt Caswell [Thu, 25 Aug 2016 20:55:02 +0000 (21:55 +0100)]
Remove note from CHANGES about EC DRBG

EC DRBG support was added in 7fdcb457 in 2011 and then later removed.
However the CHANGES entry for its original addition was left behind.
This just removes the spurious CHANGES entry.

Reviewed-by: Stephen Henson <steve@openssl.org>
(cherry picked from commit bbf73f84fc42628cb619f9e8e02691530cfeb08e)

8 years agoPrepare for 1.1.0a-dev
Matt Caswell [Thu, 25 Aug 2016 15:30:15 +0000 (16:30 +0100)]
Prepare for 1.1.0a-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoPrepare for 1.1.0 release OpenSSL_1_1_0
Matt Caswell [Thu, 25 Aug 2016 15:29:18 +0000 (16:29 +0100)]
Prepare for 1.1.0 release

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix uninit read in sslapitest
Matt Caswell [Thu, 25 Aug 2016 14:58:53 +0000 (15:58 +0100)]
Fix uninit read in sslapitest

msan detected an uninit read.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoCHANGES: mention Windows UTF-8 opt-in option.
Andy Polyakov [Thu, 25 Aug 2016 10:08:35 +0000 (12:08 +0200)]
CHANGES: mention Windows UTF-8 opt-in option.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoWindows: UTF-8 opt-in for command-line arguments and console input.
Andy Polyakov [Thu, 25 Aug 2016 06:06:26 +0000 (08:06 +0200)]
Windows: UTF-8 opt-in for command-line arguments and console input.

User can make Windows openssl.exe to treat command-line arguments
and console input as UTF-8 By setting OPENSSL_WIN32_UTF8 environment
variable (to any value). This is likely to be required for data
interchangeability with other OSes and PKCS#12 containers generated
with Windows CryptoAPI.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoSupport broken PKCS#12 key generation.
Dr. Stephen Henson [Wed, 24 Aug 2016 17:55:51 +0000 (18:55 +0100)]
Support broken PKCS#12 key generation.

OpenSSL versions before 1.1.0 didn't convert non-ASCII
UTF8 PKCS#12 passwords to Unicode correctly.

To correctly decrypt older files, if MAC verification fails
with the supplied password attempt to use the broken format
which is compatible with earlier versions of OpenSSL.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't switch password formats using global state.
Andy Polyakov [Wed, 24 Aug 2016 17:54:10 +0000 (18:54 +0100)]
Don't switch password formats using global state.

To avoid possible race conditions don't switch password format using
global state in crypto/pkcs12

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix an uninitialised read on an error path
Matt Caswell [Thu, 25 Aug 2016 08:40:17 +0000 (09:40 +0100)]
Fix an uninitialised read on an error path

Found by Coverity.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoNEWS: add a number of the types that were made opaque
Richard Levitte [Thu, 25 Aug 2016 08:06:55 +0000 (10:06 +0200)]
NEWS: add a number of the types that were made opaque

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoUn-delete still documented X509_STORE_CTX_set_verify
Viktor Dukhovni [Wed, 24 Aug 2016 18:53:09 +0000 (14:53 -0400)]
Un-delete still documented X509_STORE_CTX_set_verify

It should not have been removed.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoConfigurations/10-main.conf: fix solaris64-*-cc link problems.
Andy Polyakov [Wed, 24 Aug 2016 15:05:05 +0000 (17:05 +0200)]
Configurations/10-main.conf: fix solaris64-*-cc link problems.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoec/asm/ecp_nistz256-x86_64.pl: /cmovb/cmovc/ as nasm doesn't recognize cmovb.
Andy Polyakov [Wed, 24 Aug 2016 15:13:09 +0000 (17:13 +0200)]
ec/asm/ecp_nistz256-x86_64.pl: /cmovb/cmovc/ as nasm doesn't recognize cmovb.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoClarify the error messages in 08f6ae5b28
Matt Caswell [Wed, 24 Aug 2016 12:36:07 +0000 (13:36 +0100)]
Clarify the error messages in 08f6ae5b28

Ensure it is clear to the user why there has been an error.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix no-ec2m
Matt Caswell [Wed, 24 Aug 2016 12:54:05 +0000 (13:54 +0100)]
Fix no-ec2m

The new curves test did not take into account no-ec2m

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoCRYPTO_atomic_add(): check that the object is lock free
Richard Levitte [Wed, 24 Aug 2016 07:14:44 +0000 (09:14 +0200)]
CRYPTO_atomic_add(): check that the object is lock free

If not, fall back to our own code, using the given mutex

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoCRYPTO_atomic_add(): use acquire release memory order rather than relaxed
Richard Levitte [Wed, 24 Aug 2016 10:01:39 +0000 (12:01 +0200)]
CRYPTO_atomic_add(): use acquire release memory order rather than relaxed

For increments, the relaxed model is fine.  For decrements, it's
recommended to use the acquire release model.  We therefore go for the
latter.

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoCheck for __GNUC__ to use GNU C atomic buildins
Richard Levitte [Wed, 24 Aug 2016 11:03:20 +0000 (13:03 +0200)]
Check for __GNUC__ to use GNU C atomic buildins

Note: we trust any other compiler that fully implements GNU extension
to define __GNUC__

RT#4642

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoTrust RSA_check_key() to return correct values
Richard Levitte [Wed, 24 Aug 2016 10:46:09 +0000 (12:46 +0200)]
Trust RSA_check_key() to return correct values

In apps/rsa.c, we were second guessing RSA_check_key() to leave error
codes lying around without returning -1 properly.  However, this also
catches other errors that are lying around and that we should not care
about.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAvoid overflow in MDC2_Update()
Dr. Stephen Henson [Fri, 19 Aug 2016 22:28:29 +0000 (23:28 +0100)]
Avoid overflow in MDC2_Update()

Thanks to Shi Lei for reporting this issue.

CVE-2016-6303

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoPut DES into "not default" category.
Rich Salz [Thu, 18 Aug 2016 12:56:42 +0000 (08:56 -0400)]
Put DES into "not default" category.

Add CVE to CHANGES

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoTo avoid SWEET32 attack, move 3DES to weak
Rich Salz [Sat, 30 Jul 2016 16:21:32 +0000 (12:21 -0400)]
To avoid SWEET32 attack, move 3DES to weak

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoTypo fixes
Rob Percival [Wed, 24 Aug 2016 09:11:15 +0000 (10:11 +0100)]
Typo fixes

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoUpdates the CT_POLICY_EVAL_CTX POD
Rob Percival [Tue, 23 Aug 2016 17:41:18 +0000 (18:41 +0100)]
Updates the CT_POLICY_EVAL_CTX POD

Ownership semantics and function names have changed.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoCorrect documentation about SCT setters resetting validation status
Rob Percival [Tue, 23 Aug 2016 17:30:18 +0000 (18:30 +0100)]
Correct documentation about SCT setters resetting validation status

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRemoves the SCT_verify* POD
Rob Percival [Tue, 23 Aug 2016 17:11:13 +0000 (18:11 +0100)]
Removes the SCT_verify* POD

SCT_verify_v1 has been removed and SCT_verify is no longer part of the
public API.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoDocuments the SCT validation functions
Rob Percival [Tue, 23 Aug 2016 17:05:28 +0000 (18:05 +0100)]
Documents the SCT validation functions

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRemoves {o2i,i2o}_SCT_signature from PODs
Rob Percival [Tue, 23 Aug 2016 16:39:53 +0000 (17:39 +0100)]
Removes {o2i,i2o}_SCT_signature from PODs

These functions have been removed from the public API.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoDocuments the CTLOG functions
Rob Percival [Tue, 23 Aug 2016 15:51:57 +0000 (16:51 +0100)]
Documents the CTLOG functions

CTLOG_new_null() has been removed from the code, so it has also been
removed from this POD.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoDocument the i2o and o2i SCT functions
Rob Percival [Tue, 23 Aug 2016 15:17:09 +0000 (16:17 +0100)]
Document the i2o and o2i SCT functions

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRemoves d2i_SCT_LIST.pod
Rob Percival [Tue, 23 Aug 2016 15:16:32 +0000 (16:16 +0100)]
Removes d2i_SCT_LIST.pod

This is covered by d2i_X509.pod.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoDocument that SCT_set_source returns 0 on failure.
Rob Percival [Fri, 5 Aug 2016 12:40:05 +0000 (13:40 +0100)]
Document that SCT_set_source returns 0 on failure.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoClarifies the format of a log's public key in the CONF file
Rob Percival [Thu, 4 Aug 2016 17:41:23 +0000 (18:41 +0100)]
Clarifies the format of a log's public key in the CONF file

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRefer to OPENSSLDIR rather than "the OpenSSL install directory"
Rob Percival [Thu, 4 Aug 2016 16:05:18 +0000 (17:05 +0100)]
Refer to OPENSSLDIR rather than "the OpenSSL install directory"

The prior wording was less accurate.
See https://github.com/openssl/openssl/pull/1372#discussion_r73127000.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdds history section to CT PODs
Rob Percival [Thu, 4 Aug 2016 15:42:42 +0000 (16:42 +0100)]
Adds history section to CT PODs

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFixes final issue in CT PODs highlighted by util/find-doc-nits.pl
Rob Percival [Thu, 4 Aug 2016 10:37:35 +0000 (11:37 +0100)]
Fixes final issue in CT PODs highlighted by util/find-doc-nits.pl

Fixes complaint "ct missing from SYNOPSIS".

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRenames CT_POLICY_EVAL_CTX.pod to CT_POLICY_EVAL_CTX_new.pod
Rob Percival [Thu, 4 Aug 2016 10:36:11 +0000 (11:36 +0100)]
Renames CT_POLICY_EVAL_CTX.pod to CT_POLICY_EVAL_CTX_new.pod

util/fix-doc-nits.pl complains that
"CT_POLICY_EVAL_CTX (filename) missing from NAME section".

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdds copyright section to ct.pod
Rob Percival [Thu, 4 Aug 2016 10:29:36 +0000 (11:29 +0100)]
Adds copyright section to ct.pod

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdds newline after =cut in PODs
Rob Percival [Thu, 4 Aug 2016 10:29:23 +0000 (11:29 +0100)]
Adds newline after =cut in PODs

util/find-doc-nits.pl complains that the file "doesn't end with =cut".

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdds missing function names to NAME section of PODs
Rob Percival [Thu, 4 Aug 2016 10:28:04 +0000 (11:28 +0100)]
Adds missing function names to NAME section of PODs

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdd enum definitions to CT pods
Rob Percival [Tue, 2 Aug 2016 14:39:41 +0000 (15:39 +0100)]
Add enum definitions to CT pods

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRemove unnecessary bold tags in CT pods
Rob Percival [Tue, 2 Aug 2016 14:39:23 +0000 (15:39 +0100)]
Remove unnecessary bold tags in CT pods

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdd comment about calling CT_POLICY_EVAL_CTX_free
Rob Percival [Mon, 1 Aug 2016 19:08:11 +0000 (20:08 +0100)]
Add comment about calling CT_POLICY_EVAL_CTX_free

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFix comment about what SCT_LIST_validate does.
Rob Percival [Mon, 1 Aug 2016 19:07:15 +0000 (20:07 +0100)]
Fix comment about what SCT_LIST_validate does.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdd SSL_get0_peer_scts to ssl.pod
Rob Percival [Mon, 1 Aug 2016 14:37:10 +0000 (15:37 +0100)]
Add SSL_get0_peer_scts to ssl.pod

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFix comment about return value of ct_extract_tls_extension_scts
Rob Percival [Mon, 1 Aug 2016 14:36:38 +0000 (15:36 +0100)]
Fix comment about return value of ct_extract_tls_extension_scts

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFirst draft of CT documentation
Rob Percival [Thu, 28 Apr 2016 06:37:24 +0000 (07:37 +0100)]
First draft of CT documentation

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRemove some dead code from rec_layer_s3.c
Matt Caswell [Wed, 24 Aug 2016 10:28:58 +0000 (11:28 +0100)]
Remove some dead code from rec_layer_s3.c

It is never valid to call ssl3_read_bytes with
type == SSL3_RT_CHANGE_CIPHER_SPEC, and in fact we check for valid values
for type near the beginning of the function. Therefore this check will never
be true and can be removed.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoRemove useless assignment
Matt Caswell [Wed, 24 Aug 2016 10:25:23 +0000 (11:25 +0100)]
Remove useless assignment

The variable assignment c1 is never read before it is overwritten.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoFix some resource leaks in the apps
Matt Caswell [Wed, 24 Aug 2016 10:22:47 +0000 (11:22 +0100)]
Fix some resource leaks in the apps

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoec/ecp_nistz256: harmonize is_infinity with ec_GFp_simple_is_at_infinity.
Andy Polyakov [Fri, 19 Aug 2016 21:18:35 +0000 (23:18 +0200)]
ec/ecp_nistz256: harmonize is_infinity with ec_GFp_simple_is_at_infinity.

RT#4625

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoec/ecp_nistz256: harmonize is_infinity with ec_GFp_simple_is_at_infinity.
Andy Polyakov [Fri, 19 Aug 2016 21:16:04 +0000 (23:16 +0200)]
ec/ecp_nistz256: harmonize is_infinity with ec_GFp_simple_is_at_infinity.

RT#4625

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoec/asm/ecp_nistz256-*.pl: addition to perform stricter reduction.
Andy Polyakov [Sat, 20 Aug 2016 20:10:24 +0000 (22:10 +0200)]
ec/asm/ecp_nistz256-*.pl: addition to perform stricter reduction.

Addition was not preserving inputs' property of being fully reduced.

Thanks to Brian Smith for reporting this.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoec/asm/ecp_nistz256-x86_64.pl: addition to perform stricter reduction.
Andy Polyakov [Sat, 20 Aug 2016 20:04:21 +0000 (22:04 +0200)]
ec/asm/ecp_nistz256-x86_64.pl: addition to perform stricter reduction.

Addition was not preserving inputs' property of being fully reduced.

Thanks to Brian Smith for reporting this.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoevp/bio_enc.c: stop using pointer arithmetic for error detection.
Andy Polyakov [Tue, 23 Aug 2016 11:31:36 +0000 (13:31 +0200)]
evp/bio_enc.c: stop using pointer arithmetic for error detection.

Thanks to David Benjamin for reporting this.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix no-sock
Matt Caswell [Tue, 23 Aug 2016 19:49:26 +0000 (20:49 +0100)]
Fix no-sock

The declaration of bio_type_lock is independent of no-sock so should not be
inside OPENSSL_NO_SOCK guards.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoSanity check ticket length.
Dr. Stephen Henson [Mon, 22 Aug 2016 16:20:01 +0000 (17:20 +0100)]
Sanity check ticket length.

If a ticket callback changes the HMAC digest to SHA512 the existing
sanity checks are not sufficient and an attacker could perform a DoS
attack with a malformed ticket. Add additional checks based on
HMAC size.

Thanks to Shi Lei for reporting this bug.

CVE-2016-6302

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years ago80-test_pkcs12.t: skip the test on Windows with non-Greek locale.
Andy Polyakov [Tue, 23 Aug 2016 07:45:03 +0000 (09:45 +0200)]
80-test_pkcs12.t: skip the test on Windows with non-Greek locale.

Test doesn't work on Windows with non-Greek locale, because of
Win32 perl[!] limitation, not OpenSSL. For example it passes on
Cygwin and MSYS...

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFix math in BN_bn2dec comment.
David Benjamin [Tue, 23 Aug 2016 05:39:24 +0000 (22:39 -0700)]
Fix math in BN_bn2dec comment.

The bound on log(2)/3 on the second line is incorrect and has an extra
zero compared to the divisions in the third line. log(2)/3 = 0.10034...
which is bounded by 0.101 and not 0.1001. The divisions actually
correspond to 0.101 which is fine. The third line also dropped a factor
of three.

The actual code appears to be fine. Just the comments are wrong.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoSCT_set_source resets validation_status
Rob Percival [Tue, 23 Aug 2016 17:31:16 +0000 (18:31 +0100)]
SCT_set_source resets validation_status

This makes it consistent with all of the other SCT setters.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoDocument that o2i_SCT_signature can leave the SCT in an inconsistent state
Rob Percival [Tue, 23 Aug 2016 16:35:14 +0000 (17:35 +0100)]
Document that o2i_SCT_signature can leave the SCT in an inconsistent state

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRemoves {i2o,o2i}_SCT_signature from the CT public API
Rob Percival [Tue, 23 Aug 2016 16:27:35 +0000 (17:27 +0100)]
Removes {i2o,o2i}_SCT_signature from the CT public API

They may return if an SCT_signature struct is added in the future that
allows them to be refactored to conform to the i2d/d2i function signature
conventions.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoPrevent double-free of CTLOG public key
Rob Percival [Tue, 23 Aug 2016 15:55:09 +0000 (16:55 +0100)]
Prevent double-free of CTLOG public key

Previously, if ct_v1_log_id_from_pkey failed, public_key would be freed by
CTLOG_free at the end of the function, and then again by the caller (who
would assume ownership was not transferred when CTLOG_new returned NULL).

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoInternalizes SCT_verify and removes SCT_verify_v1
Rob Percival [Tue, 23 Aug 2016 11:52:43 +0000 (12:52 +0100)]
Internalizes SCT_verify and removes SCT_verify_v1

SCT_verify is impossible to call through the public API (SCT_CTX_new() is
not part of the public API), so rename it to SCT_CTX_verify and move it
out of the public API.

SCT_verify_v1 is redundant, since SCT_validate does the same verification
(by calling SCT_verify) and more. The API is less confusing with a single
verification function (SCT_validate).

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoUpdate fuzz corpora
Kurt Roeckx [Fri, 12 Aug 2016 16:54:11 +0000 (18:54 +0200)]
Update fuzz corpora

This is a new minimal corpus with the following changes:
- asn1: files: 1135 (+474), tuples: 27236 (+7496)
- asn1parse: files: 305 (-3), tuples: 8758 (+11)
- bignum: files: 370 (-1), tuples: 9547 (+10)
- bndiv: files: 160 (+0), tuples: 2416 (+6)
- cms: files: 155 (-1), tuples: 3408 (+0)
- conf: files: 231 (-11), tuples: 4668 (+3)
- crl: files: 905 (+188), tuples: 22876 (+4096)
- ct: files: 117 (+35), tuples: 3557 (+908)
- x509: files: 920, tuples: 28334

Note that tuple count depends on the binary and is random.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoConstify a bit X509_NAME_get_entry
FdaSilvaYY [Fri, 19 Aug 2016 17:44:10 +0000 (19:44 +0200)]
Constify a bit X509_NAME_get_entry

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoConstify some X509_NAME, ASN1 printing code
FdaSilvaYY [Thu, 7 Jul 2016 21:45:55 +0000 (23:45 +0200)]
Constify some X509_NAME, ASN1 printing code

 ASN1_buf_print, asn1_print_*, X509_NAME_oneline, X509_NAME_print

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoConstify some input parameters.
FdaSilvaYY [Thu, 11 Aug 2016 22:40:49 +0000 (00:40 +0200)]
Constify some input parameters.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoConstify some inputs buffers
FdaSilvaYY [Sat, 6 Aug 2016 15:54:32 +0000 (17:54 +0200)]
Constify some inputs buffers

remove useless cast to call ASN1_STRING_set

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoConstify ASN1_PCTX_*
FdaSilvaYY [Tue, 2 Aug 2016 18:19:00 +0000 (20:19 +0200)]
Constify ASN1_PCTX_*

... add a static keyword.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix bio_enc_test
Matt Caswell [Mon, 22 Aug 2016 15:11:55 +0000 (16:11 +0100)]
Fix bio_enc_test

There was a block of code at the start that used the Camellia cipher. The
original idea behind this was to fill the buffer with non-zero data so that
oversteps can be detected. However this block failed when using no-camellia.
This has been replaced with a RAND_bytes() call.

I also updated the the CTR test section, since it seems to be using a CBC
cipher instead of a CTR cipher.

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoAdd some sanity checks when checking CRL scores
Matt Caswell [Mon, 22 Aug 2016 23:01:57 +0000 (00:01 +0100)]
Add some sanity checks when checking CRL scores

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoRemove some dead code
Matt Caswell [Mon, 22 Aug 2016 22:53:09 +0000 (23:53 +0100)]
Remove some dead code

The assignment to ret is dead, because ret is assigned again later.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoSanity check an ASN1_object_size result
Matt Caswell [Mon, 22 Aug 2016 22:41:15 +0000 (23:41 +0100)]
Sanity check an ASN1_object_size result

If it's negative don't try and malloc it.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoCheck for error return from ASN1_object_size
Matt Caswell [Mon, 22 Aug 2016 22:39:28 +0000 (23:39 +0100)]
Check for error return from ASN1_object_size

Otherwise we try to malloc a -1 size.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoCheck for malloc error in bn_x931p.c
Matt Caswell [Mon, 22 Aug 2016 22:34:30 +0000 (23:34 +0100)]
Check for malloc error in bn_x931p.c

Ensure BN_CTX_get() has been successful

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoFix mem leak on error path
Matt Caswell [Mon, 22 Aug 2016 22:23:31 +0000 (23:23 +0100)]
Fix mem leak on error path

The mem pointed to by cAB can be leaked on an error path.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoFix mem leak on error path
Matt Caswell [Mon, 22 Aug 2016 22:20:45 +0000 (23:20 +0100)]
Fix mem leak on error path

The mem pointed to by cAB can be leaked on an error path.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoFix mem leak on error path
Matt Caswell [Mon, 22 Aug 2016 22:18:50 +0000 (23:18 +0100)]
Fix mem leak on error path

The mem pointed to by tmp can be leaked on an error path.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoEnsure the mime_hdr_free function can handle NULLs
Matt Caswell [Mon, 22 Aug 2016 21:27:27 +0000 (22:27 +0100)]
Ensure the mime_hdr_free function can handle NULLs

Sometimes it is called with a NULL pointer

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoEnsure CT_POLICY_EVAL_CTX_free behaves properly with a NULL arg
Matt Caswell [Mon, 22 Aug 2016 21:21:30 +0000 (22:21 +0100)]
Ensure CT_POLICY_EVAL_CTX_free behaves properly with a NULL arg

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoFix leak on error in tls_construct_cke_gost
Matt Caswell [Mon, 22 Aug 2016 21:17:20 +0000 (22:17 +0100)]
Fix leak on error in tls_construct_cke_gost

Don't leak pke_ctx on error.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoTest the support curves in tls
Kurt Roeckx [Sat, 20 Aug 2016 17:51:14 +0000 (19:51 +0200)]
Test the support curves in tls

Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1472

8 years agoClosing output file from inside the loop who open it
FdaSilvaYY [Sat, 20 Aug 2016 16:31:45 +0000 (18:31 +0200)]
Closing output file from inside the loop who open it

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1471

8 years agoFix no-des
Matt Caswell [Mon, 22 Aug 2016 15:04:47 +0000 (16:04 +0100)]
Fix no-des

The PKCS12 command line utility is not available if no-des is used.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRT2676: Reject RSA eponent if even or 1
Rich Salz [Mon, 22 Aug 2016 15:25:12 +0000 (11:25 -0400)]
RT2676: Reject RSA eponent if even or 1

Also, re-organize RSA check to use goto err.
Add a test case.
Try all checks, not just stopping at first (via Richard Levitte)

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoConfigure: Properly cache the configured compiler command
Richard Levitte [Wed, 17 Aug 2016 13:39:49 +0000 (15:39 +0200)]
Configure: Properly cache the configured compiler command

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix a memory leak in EC_GROUP_get_ecparameters()
Kazuki Yamaguchi [Sat, 6 Aug 2016 13:24:44 +0000 (22:24 +0900)]
Fix a memory leak in EC_GROUP_get_ecparameters()

The variable 'buffer', allocated by EC_POINT_point2buf(), isn't
free'd on the success path.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>