oweals/openssl.git
9 years agoAdd more features that may be disabled
Richard Levitte [Sat, 19 Sep 2015 23:31:47 +0000 (01:31 +0200)]
Add more features that may be disabled

A grep of OPENSSL_NO_ in the rest of the source tree revealed a few
more features to check.

NOTE: there are some of those macros that I ignore because a check of
them doesn't seem useful to external apps.  This might change later on.

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoAdd more features that may be disabled
Richard Levitte [Sat, 19 Sep 2015 22:54:03 +0000 (00:54 +0200)]
Add more features that may be disabled

After a grep of OPENSSL_NO_ in apps/*.c, a few more features that may
be interesting to check the availability of came up.

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoAdd more features that may be disabled
Richard Levitte [Sat, 19 Sep 2015 22:26:14 +0000 (00:26 +0200)]
Add more features that may be disabled

I've tried to make this list as complete as possible, based on
information found in apps/progs.pl.

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoSort the disabled features alphabetically
Richard Levitte [Sat, 19 Sep 2015 22:25:14 +0000 (00:25 +0200)]
Sort the disabled features alphabetically

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agotypo
Dr. Stephen Henson [Sat, 19 Sep 2015 22:50:02 +0000 (23:50 +0100)]
typo

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoUpdate Simple.pm to use disabled()
Dr. Stephen Henson [Sat, 19 Sep 2015 22:49:26 +0000 (23:49 +0100)]
Update Simple.pm to use disabled()

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoChange test recipes to use disabled()
Dr. Stephen Henson [Sat, 19 Sep 2015 21:19:14 +0000 (22:19 +0100)]
Change test recipes to use disabled()

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoAdd Utils.pm
Dr. Stephen Henson [Sat, 19 Sep 2015 16:10:34 +0000 (17:10 +0100)]
Add Utils.pm

Add Utils.pm for test utilities. This currently just contains one function:
disabled which checks if a feature is disabled based on the output of
openssl list -disabled

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoSmall typo
Richard Levitte [Sat, 19 Sep 2015 22:46:44 +0000 (00:46 +0200)]
Small typo

OPENSSL_NO_ECA changed to OPENSSL_NO_EC

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoMake sure to actually use @smime_cms_comp_test when testing it...
Richard Levitte [Sat, 19 Sep 2015 20:55:55 +0000 (22:55 +0200)]
Make sure to actually use @smime_cms_comp_test when testing it...

Obvious typo, and it took configuring with 'zlib' to discover it,
otherwise there was a previous skip that bypassed this section
entirely.

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoFix some test failures when Configured with zlib
Matt Caswell [Sat, 19 Sep 2015 19:07:33 +0000 (20:07 +0100)]
Fix some test failures when Configured with zlib

TLSProxy was failing if we are Configured with compression because it
doesn't support it. This fix simply switches compression off for the
purposes of the test.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoPrint out a list of disabled features.
Dr. Stephen Henson [Tue, 15 Sep 2015 14:29:02 +0000 (15:29 +0100)]
Print out a list of disabled features.

New option "openssl list -disabled" this lists a set of disabled features
in a form which can be conveniently parsed by the test framework so it
knows which tests to skip.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoReturn shared OIDs when decoding.
Dr. Stephen Henson [Thu, 17 Sep 2015 22:50:13 +0000 (23:50 +0100)]
Return shared OIDs when decoding.

When an OID is decoded see if it exists in the registered OID table
and if so return the shared OID instead of dynamically allocating
an ASN1_OBJECT.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoFix indentation
Viktor Dukhovni [Sat, 19 Sep 2015 01:15:42 +0000 (21:15 -0400)]
Fix indentation

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoCheck if test_rehash is run as root
Richard Levitte [Fri, 18 Sep 2015 19:27:29 +0000 (21:27 +0200)]
Check if test_rehash is run as root

If test/recipes/40-test_rehash.t is executed as root, the last test
will fail, since the created directory will remain writable no matter
what.  Make sure it complains loudly about being run as root.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRemove PACKET_back
Emilia Kasper [Thu, 17 Sep 2015 16:55:19 +0000 (18:55 +0200)]
Remove PACKET_back

It's unused, and the same functionality can be achieved with saving a
copy of the struct.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoMake sure OPENSSL_cleanse checks for NULL
Matt Caswell [Wed, 16 Sep 2015 09:47:15 +0000 (10:47 +0100)]
Make sure OPENSSL_cleanse checks for NULL

In master we have the function OPENSSL_clear_free(x,y), which immediately
returns if x == NULL. In <=1.0.2 this function does not exist so we have to
do:
OPENSSL_cleanse(x, y);
OPENSSL_free(x);

However, previously, OPENSSL_cleanse did not check that if x == NULL, so
the real equivalent check would have to be:
if (x != NULL)
    OPENSSL_cleanse(x, y);
OPENSSL_free(x);

It would be easy to get this wrong during cherry-picking to other branches
and therefore, for safety, it is best to just ensure OPENSSL_cleanse also
checks for NULL.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agobase64 decode: check for high bit
Emilia Kasper [Thu, 17 Sep 2015 18:08:48 +0000 (20:08 +0200)]
base64 decode: check for high bit

Previously, the conversion would silently coerce to ASCII. Now, we error
out.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoRT3757: base64 encoding bugs
Emilia Kasper [Wed, 2 Sep 2015 13:31:28 +0000 (15:31 +0200)]
RT3757: base64 encoding bugs

Rewrite EVP_DecodeUpdate.

In particular: reject extra trailing padding, and padding in the middle
of the content. Don't limit line length. Add tests.

Previously, the behaviour was ill-defined, and depended on the position
of the padding within the input.

In addition, this appears to fix a possible two-byte oob read.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Dr Stephen Henson <steve@openssl.org>
9 years agoRemove PACKET_(get|goto)_bookmark
Emilia Kasper [Thu, 17 Sep 2015 16:11:46 +0000 (18:11 +0200)]
Remove PACKET_(get|goto)_bookmark

The bookmark API results in a lot of boilerplate error checking that can
be much more easily achieved with a simple struct copy. It also lays the
path for removing the third PACKET field.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoEmbed various signature algorithms.
Dr. Stephen Henson [Thu, 17 Sep 2015 13:44:19 +0000 (14:44 +0100)]
Embed various signature algorithms.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRT4033: Use OPENSSL_SYS_UNIX not "unix"
Rich Salz [Thu, 17 Sep 2015 02:17:55 +0000 (22:17 -0400)]
RT4033: Use OPENSSL_SYS_UNIX not "unix"

Real fix for RT 4033

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoRT4047: Set reference count earlier
Filipe DA SILVA [Thu, 17 Sep 2015 02:25:31 +0000 (22:25 -0400)]
RT4047: Set reference count earlier

Make sure it's valid very early.

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoDisentangle RSA premaster secret parsing
Emilia Kasper [Wed, 9 Sep 2015 12:45:00 +0000 (14:45 +0200)]
Disentangle RSA premaster secret parsing

Simplify encrypted premaster secret reading by using new methods in the
PACKET API.

Don't overwrite the packet buffer. RSA decrypt accepts truncated
ciphertext with leading zeroes omitted, so it's even possible that by
crafting a valid ciphertext with several leading zeroes, this could
cause a few bytes out-of-bounds write. The write is harmless because of
the size of the underlying message buffer, but nevertheless we shouldn't
write into the packet.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoEmbed X509_REQ_INFO
Dr. Stephen Henson [Wed, 16 Sep 2015 17:46:16 +0000 (18:46 +0100)]
Embed X509_REQ_INFO

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoEmbed X509_CINF
Dr. Stephen Henson [Wed, 16 Sep 2015 17:40:26 +0000 (18:40 +0100)]
Embed X509_CINF

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoX509_CRL_INFO embed
Dr. Stephen Henson [Tue, 15 Sep 2015 23:24:43 +0000 (00:24 +0100)]
X509_CRL_INFO embed

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoChange X509_VAL in X509 structure to embedded.
Dr. Stephen Henson [Tue, 15 Sep 2015 16:10:51 +0000 (17:10 +0100)]
Change X509_VAL in X509 structure to embedded.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoNew ASN.1 embed macro.
Dr. Stephen Henson [Tue, 15 Sep 2015 14:54:19 +0000 (15:54 +0100)]
New ASN.1 embed macro.

New ASN.1 macro ASN1_EMBED. This is the same as ASN1_SIMPLE except the
structure is not allocated: it is part of the parent. That is instead of

FOO *x;

it must be:

FOO x;

This reduces memory fragmentation and make it impossible to accidentally
set a mandatory field to NULL.

This currently only works for SEQUENCE and since it is equivalent to
ASN1_SIMPLE it cannot be tagged, OPTIONAL, SET OF or SEQUENCE OF.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoFix build on mingw
Alessandro Ghedini [Wed, 16 Sep 2015 19:53:58 +0000 (21:53 +0200)]
Fix build on mingw

When OPENSSL_EXPORT_VAR_AS_FUNCTION is defined, the static_ASN1_ITEM_start
macro doesn't exist so the build fails. This problem was introduced in
commit df2ee0e.

Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFix return values when adding serverinfo fails.
Kurt Roeckx [Tue, 15 Sep 2015 19:26:32 +0000 (21:26 +0200)]
Fix return values when adding serverinfo fails.

Reviewed-by: Rich Salz <rsalz@openssl.org>
MR #1128

9 years agomake update
Matt Caswell [Wed, 16 Sep 2015 11:40:55 +0000 (12:40 +0100)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoExtend the notes on how to do testing
Richard Levitte [Tue, 15 Sep 2015 12:07:46 +0000 (14:07 +0200)]
Extend the notes on how to do testing

These notes include the use of HARNESS_VERBOSE (see the manual for
Test::Harness) and the method to enumerate specific tests to run.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
9 years agoAdd a method to list available tests
Richard Levitte [Tue, 15 Sep 2015 12:07:10 +0000 (14:07 +0200)]
Add a method to list available tests

Reviewed-by: Emilia Käsper <emilia@openssl.org>
9 years agoAdd a few notes on perl
Richard Levitte [Thu, 10 Sep 2015 11:02:42 +0000 (13:02 +0200)]
Add a few notes on perl

Reviewed-by: Emilia Käsper <emilia@openssl.org>
9 years agod2i: don't update input pointer on failure
Kurt Roeckx [Mon, 17 Aug 2015 14:02:18 +0000 (16:02 +0200)]
d2i: don't update input pointer on failure

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
MR #1005

9 years agoFix PSK identity hint handling.
Dr. Stephen Henson [Mon, 14 Sep 2015 16:58:04 +0000 (17:58 +0100)]
Fix PSK identity hint handling.

For server use a PSK identity hint value in the CERT structure which
is inherited when SSL_new is called and which allows applications to
set hints on a per-SSL basis. The previous version of
SSL_use_psk_identity_hint tried (wrongly) to use the SSL_SESSION structure.

PR#4039

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoConstify ECDSA_METHOD_new.
Dr. Stephen Henson [Sat, 12 Sep 2015 00:53:52 +0000 (01:53 +0100)]
Constify ECDSA_METHOD_new.

PR#3920.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoFix zlib CMS compilation.
Dr. Stephen Henson [Fri, 11 Sep 2015 22:10:29 +0000 (23:10 +0100)]
Fix zlib CMS compilation.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoUse default field separator.
Dr. Stephen Henson [Fri, 11 Sep 2015 15:13:52 +0000 (16:13 +0100)]
Use default field separator.

If the field separator isn't specified through -nameopt then use
XN_FLAG_SEP_CPLUS_SPC instead of printing nothing and returing an error.

PR#2397

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoFix "defined but not used" warnings.
Dr. Stephen Henson [Fri, 11 Sep 2015 17:16:23 +0000 (18:16 +0100)]
Fix "defined but not used" warnings.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoEnable -Wmissing-variable-declarations and
Ben Laurie [Sat, 5 Sep 2015 12:32:58 +0000 (13:32 +0100)]
Enable -Wmissing-variable-declarations and
-Wincompatible-pointer-types-discards-qualifiers (the latter did not require
any code changes).

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoUnwriteable directories are errors
Rich Salz [Thu, 10 Sep 2015 15:46:13 +0000 (11:46 -0400)]
Unwriteable directories are errors

Make the script and app match the documentation.

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoEVP_PKEY_METHOD accessor functions.
Dr. Stephen Henson [Mon, 20 Jul 2015 21:05:10 +0000 (22:05 +0100)]
EVP_PKEY_METHOD accessor functions.

Functions to retrieve the function pointer of an existing method: this
can be used to create a method which intercepts or modifies the behaviour
of an existing method while retaining most of the existing behaviour.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRT3754: check for NULL pointer
Emilia Kasper [Tue, 1 Sep 2015 14:31:55 +0000 (16:31 +0200)]
RT3754: check for NULL pointer

Fix both the caller to error out on malloc failure, as well as the
eventual callee to handle a NULL gracefully.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
9 years agoRestore SSLerr on PACKET_strndup failure.
Emilia Kasper [Thu, 10 Sep 2015 12:47:04 +0000 (14:47 +0200)]
Restore SSLerr on PACKET_strndup failure.

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
9 years agoRT3992: Make SCT #ifdeffable.
David Woodhouse [Wed, 9 Sep 2015 19:29:44 +0000 (15:29 -0400)]
RT3992: Make SCT #ifdeffable.

This code does open-coded division on 64-bit quantities and thus when
building with GCC on 32-bit platforms will require functions such as
__umoddi3 and __udivdi3 from libgcc.

In constrained environments such as firmware, those functions may not
be available. So make it possible to compile out SCT support, which in
fact (in the case of UEFI) we don't need anyway.

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoAdd a simple test for the new rehash command
Richard Levitte [Wed, 9 Sep 2015 15:36:21 +0000 (17:36 +0200)]
Add a simple test for the new rehash command

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoMake sure the temporary error log resides in a well defined location
Richard Levitte [Wed, 9 Sep 2015 15:29:06 +0000 (17:29 +0200)]
Make sure the temporary error log resides in a well defined location

If a test recipe does something like this:

    indir "foo.$$" => sub {
        chmod 0500, File::Spec->curdir();
        ok(run(app(["something"])));
    }

we get a problem, because we were storing the temporary stderr file in
the current directory at all times (so while inside the 'indir', we
would attemp to store it in "foo.$$").

So, change our ways to always store that temporary file in the exact
same location, defined by the environment variable RESULT_D, or
failing that TEST_D, or failing that $TOP/test.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoFix warning about mixed declarations and code.
Dr. Stephen Henson [Wed, 9 Sep 2015 16:28:17 +0000 (17:28 +0100)]
Fix warning about mixed declarations and code.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoPACKET: add PACKET_memdup and PACKET_strndup
Emilia Kasper [Tue, 1 Sep 2015 16:19:14 +0000 (18:19 +0200)]
PACKET: add PACKET_memdup and PACKET_strndup

Use each once in s3_srvr.c to show how they work.

Also fix a bug introduced in c3fc7eeab884b6876a1b4006163f190d325aa047
and made apparent by this change:
ssl3_get_next_proto wasn't updating next_proto_negotiated_len

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3993: Fix error found by VS2008
David Woodhouse [Wed, 9 Sep 2015 03:24:36 +0000 (23:24 -0400)]
RT3993: Fix error found by VS2008

Cast and then negate, don't negate an unsigned.

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoRT3969: Add OPENSSL_SYS_UEFI
David Woodhouse [Wed, 9 Sep 2015 02:51:17 +0000 (22:51 -0400)]
RT3969: Add OPENSSL_SYS_UEFI

This provides support for building in the EDK II reference implementation
of UEFI. Most UEFI firmware in existence uses OpenSSL for implementing
the core cryptographic functionality needed for Secure Boot.

This has always previously been handled with external patches to OpenSSL
but we are now making a concerted effort to eliminate those.

In this mode, we don't actually use the OpenSSL makefiles; we process
the MINFO file generated by 'make files' and incorporate it into the
EDK2 build system.

Since EDK II builds for various targets with varying word size and we
need to have a single prepackaged configuration, we deliberately don't
hard-code the setting of SIXTY_FOUR_BIT vs. THIRTY_TWO_BIT in
opensslconf.h. We bypass that for OPENSSL_SYS_UEFI and allow EDK II
itself to set those, depending on the architecture.

For x86_64, EDK II sets SIXTY_FOUR_BIT and thus uses 'long long' for the
64-bit type, even when building with GCC where 'long' is also 64-bit. We
do this because the Microsoft toolchain has 32-bit 'long'.

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoFix rehash/c_rehash doc and behavior.
Rich Salz [Tue, 8 Sep 2015 02:21:38 +0000 (22:21 -0400)]
Fix rehash/c_rehash doc and behavior.

Both now warn once if directory isn't writeable.
Both now warn on file-write errors (multiple times).
Update manpage to describe both program and script correctly.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoFix uninit warning. Remove unnecessary casts. Nothing to add is an error.
Ben Laurie [Mon, 7 Sep 2015 17:33:09 +0000 (18:33 +0100)]
Fix uninit warning. Remove unnecessary casts. Nothing to add is an error.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoadd support for apple os/x
Rich Salz [Tue, 8 Sep 2015 01:39:44 +0000 (21:39 -0400)]
add support for apple os/x

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoFix a few tests that depended on the wrong algorithm check
Richard Levitte [Mon, 7 Sep 2015 23:23:49 +0000 (01:23 +0200)]
Fix a few tests that depended on the wrong algorithm check

test_ecdh and test_ecdsa are made to depend on no-ec being false.
test_hmac is made not to depend on algorithm at all.

Based on a contribution by Alessandro Ghedini <alessandro@ghedini.me>

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdjust the general fill-column in doc/dir-locals.example.el
Richard Levitte [Mon, 7 Sep 2015 22:59:50 +0000 (00:59 +0200)]
Adjust the general fill-column in doc/dir-locals.example.el

Having a general fill-column of 78 may look nice at first sight, but
if the edited text gets indented a bit afterward (such as with git
comments in 'git log'), it suddenly turns not so nice on a classic 80
columns terminal.  A fill-column of 70 will serve us better.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdjust the verify_extra test recipe to its executable
Richard Levitte [Mon, 7 Sep 2015 14:26:04 +0000 (16:26 +0200)]
Adjust the verify_extra test recipe to its executable

The verify_extra_test was recently changed to take its parameters as
arguments instead of having them hardcoded.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoGH391: Apple port
Rich Salz [Mon, 7 Sep 2015 14:08:14 +0000 (10:08 -0400)]
GH391: Apple port

Also make internal functions consistently return values, and
add a comment documenting them.

Reviewed-by: Ben Laurie <ben@openssl.org>
9 years agoMake sure that 80-test_ca.t finds all the config files
Richard Levitte [Sun, 6 Sep 2015 23:09:23 +0000 (01:09 +0200)]
Make sure that 80-test_ca.t finds all the config files

This recipe counted too much on being called with test/ as its current
working directory.  That's a mistake on, for example, Windows.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd a recipe for the new null pointer test
Richard Levitte [Sun, 6 Sep 2015 14:04:15 +0000 (16:04 +0200)]
Add a recipe for the new null pointer test

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoChange the 80-test_tsa recipe as per changes in testtsa
Richard Levitte [Sun, 6 Sep 2015 14:03:30 +0000 (16:03 +0200)]
Change the 80-test_tsa recipe as per changes in testtsa

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd a recipe for the new pbelu test
Richard Levitte [Thu, 3 Sep 2015 19:17:31 +0000 (21:17 +0200)]
Add a recipe for the new pbelu test

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRemake the testsslproxy tests
Richard Levitte [Thu, 3 Sep 2015 18:54:01 +0000 (20:54 +0200)]
Remake the testsslproxy tests

The testsslproxy tests turned out to be useless as they were.  They
were really just for show and the results were ignore.  Now they are
changed into a more veerifiable test

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoSmall fix in OpenSSL::Test
Richard Levitte [Thu, 3 Sep 2015 17:41:40 +0000 (19:41 +0200)]
Small fix in OpenSSL::Test

Be careful when shifting in a function argument, you end up changing
the caller's value.  Instead, when it is an array, make a shallow copy
and shift in that instead.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoIncorporate recent changes that were originally made in test/testssl
Richard Levitte [Thu, 3 Sep 2015 17:39:58 +0000 (19:39 +0200)]
Incorporate recent changes that were originally made in test/testssl

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd documentation for the new testing framework
Richard Levitte [Thu, 3 Sep 2015 10:00:28 +0000 (12:00 +0200)]
Add documentation for the new testing framework

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd a recipe for the new gmdiff test
Richard Levitte [Thu, 3 Sep 2015 07:24:01 +0000 (09:24 +0200)]
Add a recipe for the new gmdiff test

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoCorrect test name
Richard Levitte [Thu, 3 Sep 2015 07:23:32 +0000 (09:23 +0200)]
Correct test name

Some tests were copied from test_jpake, but the title wasn't changed
accordingly.  This might seem like a small thing, but it does affect
the log file name...

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRemake test/sslsessionticktest.pl into a recipe
Richard Levitte [Fri, 28 Aug 2015 01:07:24 +0000 (03:07 +0200)]
Remake test/sslsessionticktest.pl into a recipe

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdapt the libssl test harness testing scripts to new testing framework
Richard Levitte [Thu, 13 Aug 2015 17:38:59 +0000 (19:38 +0200)]
Adapt the libssl test harness testing scripts to new testing framework

This involves adding $TOP/util as perl library in test/run_tests.pl.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoCheck the validity of MINFO
Richard Levitte [Sun, 9 Aug 2015 04:52:50 +0000 (06:52 +0200)]
Check the validity of MINFO

MINFO may be an old file lying around, which might have
00-check_testexes.t produce incorrect results.  To make sure this
doesn't happen, check the variable VERSION in it against the same
variable in the top Makefile.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoBetter method of skipping all the tests in 00-check_testexes.t
Richard Levitte [Sun, 9 Aug 2015 03:35:57 +0000 (05:35 +0200)]
Better method of skipping all the tests in 00-check_testexes.t

Before trying to read MINFO, we have no idea how many to test for, and
because skip expects to get an exact number somehow, it's better to
use 'plan skip_all'.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRemove special x509 test conversions
Richard Levitte [Sat, 8 Aug 2015 09:45:54 +0000 (11:45 +0200)]
Remove special x509 test conversions

Following the commit from July 2 that removed netscape formated certs,
it is no longer necessary to have conversion tests for it.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd a few missing tests
Richard Levitte [Sat, 8 Aug 2015 09:33:10 +0000 (11:33 +0200)]
Add a few missing tests

test_clienthello
test_packet
test_verify_extra
test_secmem

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoPush the line buffer filter on the out BIO on VMS
Richard Levitte [Thu, 30 Apr 2015 17:52:36 +0000 (19:52 +0200)]
Push the line buffer filter on the out BIO on VMS

VMS files are normally record oriented rather than stream oriented.
This means that every write() will create a new record, which is seen
as a line of its own, regardless of if there was a \n in there or not.
bntest uses BN_print, which prints out number with more than one
write(), thereby dividing up the numbers in several lines, which
greatly disturbs the post-bntest checks that expect to find a full
formula to calculate on one line.

So, for VMS, we need to push the linebuffer filter on the out BIO.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRework 00-test_checkexes.t for VMS
Richard Levitte [Thu, 30 Apr 2015 17:38:47 +0000 (19:38 +0200)]
Rework 00-test_checkexes.t for VMS

Unfortunately, a file spec with character range globs interfere with
paths on VMS, and are therefore disabled.  Rework this test to collect
a list of expected tests and a list of all recipes and compare the two
using grep.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoDocument OpenSSL::Test and OpenSSL::Test::Simple
Richard Levitte [Thu, 30 Apr 2015 12:30:15 +0000 (14:30 +0200)]
Document OpenSSL::Test and OpenSSL::Test::Simple

For OpenSSL::Test, it meant rearranging the code to better suite the
structure of the documentation.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoChange OpenSSL::Test to be an extension of Test::More
Richard Levitte [Thu, 30 Apr 2015 06:51:24 +0000 (08:51 +0200)]
Change OpenSSL::Test to be an extension of Test::More

It became tedious as well as error prone to have all recipes use
Test::More as well as OpenSSL::Test.  The easier way is to make
OpenSSL::Test an extension of Test::More, thereby having all version
checks as well as future checks firmly there.  Additionally, that
allows us to extend existing Test::More functions if the need would
arise.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoNew feature: STOPTEST
Richard Levitte [Wed, 29 Apr 2015 19:51:25 +0000 (21:51 +0200)]
New feature: STOPTEST

When the environment variable STOPTEST is defined (with any value other
than the empty string), the test machinery in OpenSSL::Test goes into a
different mode that will stop all testing at the end of a failing recipe.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd version numbers on some modules we use.
Richard Levitte [Tue, 28 Apr 2015 18:39:09 +0000 (20:39 +0200)]
Add version numbers on some modules we use.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoHave 'make clean' clean away the log files.
Richard Levitte [Tue, 28 Apr 2015 15:59:06 +0000 (17:59 +0200)]
Have 'make clean' clean away the log files.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoTone down the requirements of a test that will go away.
Richard Levitte [Thu, 23 Apr 2015 09:11:14 +0000 (11:11 +0200)]
Tone down the requirements of a test that will go away.

00-check_testexes.t was a way for me to check that I didn't forget a
compiled test app.  The way it worked was to require MINFO to be present.
Considering the need for this test has diminished considerably at this
point, I might as well tone down the requirement, and have it skip the
test (and not fail it) if MINFO isn't present.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRemove old testing scripts out of the way.
Richard Levitte [Tue, 21 Apr 2015 19:10:01 +0000 (21:10 +0200)]
Remove old testing scripts out of the way.

For now, I'm moving them into Attic/.  They will be removed later.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdapt mk1mf.pl and helpers to the new testing framework.
Richard Levitte [Tue, 21 Apr 2015 18:09:36 +0000 (20:09 +0200)]
Adapt mk1mf.pl and helpers to the new testing framework.

With the new testing framework, building a test target with mk1mf.pl
becomes a very simple thing.  And especially, no more need to do the
amount of hackery in unix.pl we did.

Also, some tests need a working apps/CA.pl as well as rehashed certs
in certs/demo.  So, move the code creating those files so it gets done
regardless, not just in non-mk1mf environments.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoSimplify very simple test recipes further.
Richard Levitte [Tue, 21 Apr 2015 17:29:01 +0000 (19:29 +0200)]
Simplify very simple test recipes further.

Very simple test recipes easily become tedious, so they might benefit
from being made as simple as possible.  Therefore, OpenSSL::Test::Simple
is born.  It currently provides but one function, simple_test(), which
takes a minimum of two parameters (test name and program to run), with
the optional third, being the algorithm to be checked for before
running the test itself.

All recipes with that simple thing to do have been rewritten to be as
minimal as possible.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRemove test targets from Makefile, have it use run_tests.pl
Richard Levitte [Sun, 19 Apr 2015 21:49:30 +0000 (23:49 +0200)]
Remove test targets from Makefile, have it use run_tests.pl

Also remove recipes/00-check_testalltests.t, since it will lack the
information from the now gone alltests target.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoIgnore the log files
Richard Levitte [Sun, 19 Apr 2015 20:29:46 +0000 (22:29 +0200)]
Ignore the log files

The new test framework produces a lot of log files (one for each
test).  Git doesn't need to know.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd recipes for misc other things we want to test
Richard Levitte [Sun, 19 Apr 2015 20:26:12 +0000 (22:26 +0200)]
Add recipes for misc other things we want to test

Note that this required a change in constant_time_test.c, as it says
"ok", which interferes with what Test::Harness expects to see.  I had
constant_time_test.c say "success" instead.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd recipes for the larger protocols
Richard Levitte [Sun, 19 Apr 2015 20:24:17 +0000 (22:24 +0200)]
Add recipes for the larger protocols

This covers the certificate authority commands, the cms and smime
commands, OCSP, SSL and TSA.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd engine and evp test recipes.
Richard Levitte [Fri, 17 Apr 2015 18:16:13 +0000 (20:16 +0200)]
Add engine and evp test recipes.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd recipes for tests related to certificates
Richard Levitte [Fri, 17 Apr 2015 18:15:22 +0000 (20:15 +0200)]
Add recipes for tests related to certificates

Some of them make use of recipes/tconversion.pl.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd asymetric cipher test recipes
Richard Levitte [Fri, 17 Apr 2015 18:13:58 +0000 (20:13 +0200)]
Add asymetric cipher test recipes

Some of them make use of recipes/tconversion.pl.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd a helper script for key file format conversion tests
Richard Levitte [Fri, 17 Apr 2015 18:10:24 +0000 (20:10 +0200)]
Add a helper script for key file format conversion tests

As tests are done until now, there are a few scripts that look almost,
but not quite the same.  tkey, tx509, tcrl, tpkcs7, treq, tsid and
probably a few more.

recipes/tconversions.pl is a helper script that generalises the
function of each of those, and can then be used in a general manner
from test recipes.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd the encryption test recipe
Richard Levitte [Fri, 17 Apr 2015 18:07:13 +0000 (20:07 +0200)]
Add the encryption test recipe

This tests all available openssl cipher commands.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd recipes for individual block ciphers, stream ciphers and digests
Richard Levitte [Fri, 17 Apr 2015 18:04:19 +0000 (20:04 +0200)]
Add recipes for individual block ciphers, stream ciphers and digests

These recipes all correspond to a compiled test program.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd math tests recipes
Richard Levitte [Fri, 17 Apr 2015 17:57:55 +0000 (19:57 +0200)]
Add math tests recipes

The math recipes are among the heavier, but also quite important.
For the BN test, we have previously relied on bc to verify the numbers.
Unfortunately, bc doesn't exist everywhere, making tests on some platforms
rather painful.  With the new recipe (recipes/10-test_bn.t), we rely
on perl's Math::BigInt and a homegrown simple calculator (recipes/bc.pl)
that can do enough to cover for bc.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoGroundwork for a perl based testing framework
Richard Levitte [Fri, 17 Apr 2015 17:44:48 +0000 (19:44 +0200)]
Groundwork for a perl based testing framework

The idea with this perl based testing framework is to make use of
what's delivered with perl and exists on all sorts of platforms.

The choice came to using Test::More and Test::Harness, as that seems
to be the most widely spread foundation, even if perl is aged.

The main runner of the show is run_tests.pl.  As it currently stands,
it's designed to run from inside Makefile, but it's absolutely
possible to run it from the command line as well, like so:

cd test
OPENSSL_SRCDIR=.. perl run_tests.pl

The tester scripts themselves are stored in the subdirectory recipes/,
and initially, we have two such scripts, recipes/00-check_testalltests.t
and recipes/00-check_testexes.t.  recipes/00-check_testalltests.t will
pick out the dependencies of "alltests" in test/Makefile, and check if
it can find recipes with corresponding names.  recipes/00-check_testexes.t
does something similar, but bases it on existing compiled test binaries.
They make it easy to figure out what's to be added, and will be
removed when this effort is finished.

Individual recipes can be run as well, of course, as they are perl
scripts in themselves.  For example, you can run only
recipes/00-check_testexes.t like so:

cd test
OPENSSL_SRCDIR=.. perl recipes/00-check_testexes.t

To make coding easier, there's a routine library OpenSSL::Test, which
is reachable in a perl script like so:

use lib 'testlib';
use OpenSSL::Test;

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoPACKETise ServerKeyExchange
Matt Caswell [Tue, 4 Aug 2015 20:22:31 +0000 (21:22 +0100)]
PACKETise ServerKeyExchange

Process the ServerKeyExchange message using the PACKET API

Reviewed-by: Tim Hudson <tjh@openssl.org>