Latest update.

This commit is contained in:
2019-01-30 02:25:21 +09:00
parent 87e37412f8
commit afcfc266de
110 changed files with 2906 additions and 1475 deletions
+38
View File
@@ -123,6 +123,43 @@ static int test_ASYNC_init_thread(void)
return 1;
}
static int test_callback(void *arg)
{
printf("callback test pass\n");
return 1;
}
static int test_ASYNC_callback_status(void)
{
ASYNC_WAIT_CTX *waitctx = NULL;
int set_arg = 100;
ASYNC_callback_fn get_callback;
void *get_arg;
int set_status = 1;
if ( !ASYNC_init_thread(1, 0)
|| (waitctx = ASYNC_WAIT_CTX_new()) == NULL
|| ASYNC_WAIT_CTX_set_callback(waitctx, test_callback, (void*)&set_arg)
!= 1
|| ASYNC_WAIT_CTX_get_callback(waitctx, &get_callback, &get_arg)
!= 1
|| test_callback != get_callback
|| get_arg != (void*)&set_arg
|| (*get_callback)(get_arg) != 1
|| ASYNC_WAIT_CTX_set_status(waitctx, set_status) != 1
|| set_status != ASYNC_WAIT_CTX_get_status(waitctx)) {
fprintf(stderr, "test_ASYNC_callback_status() failed\n");
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 0;
}
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 1;
}
static int test_ASYNC_start_job(void)
{
ASYNC_JOB *job = NULL;
@@ -279,6 +316,7 @@ int main(int argc, char **argv)
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
if ( !test_ASYNC_init_thread()
|| !test_ASYNC_callback_status()
|| !test_ASYNC_start_job()
|| !test_ASYNC_get_current_job()
|| !test_ASYNC_WAIT_CTX_get_all_fds()
+54
View File
@@ -0,0 +1,54 @@
/*
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <stdio.h>
#include <string.h>
#include <openssl/buffer.h>
#include <openssl/bio.h>
#include "testutil.h"
static int test_bio_memleak(void)
{
int ok = 0;
BIO *bio;
BUF_MEM bufmem;
const char *str = "BIO test\n";
char buf[100];
bio = BIO_new(BIO_s_mem());
if (bio == NULL)
goto finish;
bufmem.length = strlen(str) + 1;
bufmem.data = (char *) str;
bufmem.max = bufmem.length;
BIO_set_mem_buf(bio, &bufmem, BIO_NOCLOSE);
BIO_set_flags(bio, BIO_FLAGS_MEM_RDONLY);
if (BIO_read(bio, buf, sizeof(buf)) <= 0)
goto finish;
ok = strcmp(buf, str) == 0;
finish:
BIO_free(bio);
return ok;
}
int global_init(void)
{
CRYPTO_set_mem_debug(1);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
return 1;
}
int setup_tests(void)
{
ADD_TEST(test_bio_memleak);
return 1;
}
+22 -18
View File
@@ -9,7 +9,7 @@ SUBDIRS=ossl_shim
""
-}
IF[{- !$disabled{tests} -}]
LIBS_NO_INST=libtestutil.a
LIBS{noinst}=libtestutil.a
SOURCE[libtestutil.a]=testutil/basic_output.c testutil/output_helpers.c \
testutil/driver.c testutil/tests.c testutil/cb.c testutil/stanza.c \
testutil/format_output.c testutil/tap_bio.c \
@@ -24,7 +24,7 @@ IF[{- !$disabled{tests} -}]
INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=main
ENDRAW[descrip.mms]
PROGRAMS_NO_INST=\
PROGRAMS{noinst}=\
versions \
aborttest test_test \
sanitytest rsa_complex exdatatest bntest \
@@ -42,7 +42,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=main
packettest asynctest secmemtest srptest memleaktest stack_test \
dtlsv1listentest ct_test threadstest afalgtest d2i_test \
ssl_test_ctx_test ssl_test x509aux cipherlist_test asynciotest \
bio_callback_test \
bio_callback_test bio_memleak_test \
bioprinttest sslapitest dtlstest sslcorrupttest bio_enc_test \
pkey_meth_test pkey_meth_kdf_test uitest cipherbytes_test \
asn1_encode_test asn1_decode_test asn1_string_table_test \
@@ -300,6 +300,10 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=main
INCLUDE[bio_callback_test]=../include
DEPEND[bio_callback_test]=../libcrypto libtestutil.a
SOURCE[bio_memleak_test]=bio_memleak_test.c
INCLUDE[bio_memleak_test]=../include
DEPEND[bio_memleak_test]=../libcrypto libtestutil.a
SOURCE[bioprinttest]=bioprinttest.c
INCLUDE[bioprinttest]=../include
DEPEND[bioprinttest]=../libcrypto libtestutil.a
@@ -375,27 +379,27 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=main
DEPEND[servername_test]=../libcrypto ../libssl libtestutil.a
IF[{- !$disabled{cms} -}]
PROGRAMS_NO_INST=cmsapitest
PROGRAMS{noinst}=cmsapitest
SOURCE[cmsapitest]=cmsapitest.c
INCLUDE[cmsapitest]=../include
DEPEND[cmsapitest]=../libcrypto libtestutil.a
ENDIF
IF[{- !$disabled{psk} -}]
PROGRAMS_NO_INST=dtls_mtu_test
PROGRAMS{noinst}=dtls_mtu_test
SOURCE[dtls_mtu_test]=dtls_mtu_test.c ssltestlib.c
INCLUDE[dtls_mtu_test]=.. ../include
DEPEND[dtls_mtu_test]=../libcrypto ../libssl libtestutil.a
ENDIF
IF[{- !$disabled{shared} -}]
PROGRAMS_NO_INST=shlibloadtest
PROGRAMS{noinst}=shlibloadtest
SOURCE[shlibloadtest]=shlibloadtest.c
INCLUDE[shlibloadtest]=../include ../crypto/include
ENDIF
IF[{- $disabled{shared} -}]
PROGRAMS_NO_INST=cipher_overhead_test
PROGRAMS{noinst}=cipher_overhead_test
SOURCE[cipher_overhead_test]=cipher_overhead_test.c
INCLUDE[cipher_overhead_test]=.. ../include
DEPEND[cipher_overhead_test]=../libcrypto ../libssl libtestutil.a
@@ -438,26 +442,26 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=main
# programs are forcibly linked with the static libraries, where all symbols
# are always available.
IF[1]
PROGRAMS_NO_INST=asn1_internal_test modes_internal_test x509_internal_test \
PROGRAMS{noinst}=asn1_internal_test modes_internal_test x509_internal_test \
tls13encryptiontest wpackettest ctype_internal_test \
rdrand_sanitytest
IF[{- !$disabled{poly1305} -}]
PROGRAMS_NO_INST=poly1305_internal_test
PROGRAMS{noinst}=poly1305_internal_test
ENDIF
IF[{- !$disabled{chacha} -}]
PROGRAMS_NO_INST=chacha_internal_test
PROGRAMS{noinst}=chacha_internal_test
ENDIF
IF[{- !$disabled{siphash} -}]
PROGRAMS_NO_INST=siphash_internal_test
PROGRAMS{noinst}=siphash_internal_test
ENDIF
IF[{- !$disabled{sm2} -}]
PROGRAMS_NO_INST=sm2_internal_test
PROGRAMS{noinst}=sm2_internal_test
ENDIF
IF[{- !$disabled{sm4} -}]
PROGRAMS_NO_INST=sm4_internal_test
PROGRAMS{noinst}=sm4_internal_test
ENDIF
IF[{- !$disabled{ec} -}]
PROGRAMS_NO_INST=curve448_internal_test
PROGRAMS{noinst}=curve448_internal_test
ENDIF
SOURCE[poly1305_internal_test]=poly1305_internal_test.c
@@ -514,14 +518,14 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=main
ENDIF
IF[{- !$disabled{mdc2} -}]
PROGRAMS_NO_INST=mdc2_internal_test
PROGRAMS{noinst}=mdc2_internal_test
ENDIF
SOURCE[mdc2_internal_test]=mdc2_internal_test.c
INCLUDE[mdc2_internal_test]=.. ../include
DEPEND[mdc2_internal_test]=../libcrypto libtestutil.a
PROGRAMS_NO_INST=asn1_time_test
PROGRAMS{noinst}=asn1_time_test
SOURCE[asn1_time_test]=asn1_time_test.c
INCLUDE[asn1_time_test]=../include
DEPEND[asn1_time_test]=../libcrypto libtestutil.a
@@ -530,7 +534,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=main
# redefines some internal libssl symbols. This doesn't work in a non-shared
# build
IF[{- !$disabled{shared} -}]
PROGRAMS_NO_INST=tls13secretstest
PROGRAMS{noinst}=tls13secretstest
SOURCE[tls13secretstest]=tls13secretstest.c
SOURCE[tls13secretstest]= ../ssl/tls13_enc.c ../ssl/packet.c
INCLUDE[tls13secretstest]=.. ../include
@@ -574,7 +578,7 @@ ENDIF
next if grep { lc("$name.h") =~ m/$_/i } @nogo_headers_re;
$OUT .= <<"_____";
PROGRAMS_NO_INST=buildtest_$name
PROGRAMS{noinst}=buildtest_$name
GENERATE[buildtest_$name.c]=generate_buildtest.pl $name
SOURCE[buildtest_$name]=buildtest_$name.c
INCLUDE[buildtest_$name]=../include
+9 -5
View File
@@ -87,17 +87,21 @@ static int test_dtls_unprocessed(int testidx)
/*
* Inject a dummy record from the next epoch. In test 0, this should never
* get used because the message sequence number is too big. In test 1 we set
* the record sequence number to be way off in the future. This should not
* have an impact on the record replay protection because the record should
* be dropped before it is marked as arrived
* the record sequence number to be way off in the future.
*/
c_to_s_mempacket = SSL_get_wbio(clientssl1);
c_to_s_mempacket = BIO_next(c_to_s_mempacket);
mempacket_test_inject(c_to_s_mempacket, (char *)certstatus,
sizeof(certstatus), 1, INJECT_PACKET_IGNORE_REC_SEQ);
if (!TEST_true(create_ssl_connection(serverssl1, clientssl1,
SSL_ERROR_NONE)))
/*
* Create the connection. We use "create_bare_ssl_connection" here so that
* we can force the connection to not do "SSL_read" once partly conencted.
* We don't want to accidentally read the dummy records we injected because
* they will fail to decrypt.
*/
if (!TEST_true(create_bare_ssl_connection(serverssl1, clientssl1,
SSL_ERROR_NONE, 0)))
goto end;
if (timer_cb_count == 0) {
+1 -1
View File
@@ -1,5 +1,5 @@
IF[{- defined $target{CXX} && !$disabled{"external-tests"} -}]
PROGRAMS_NO_INST=ossl_shim
PROGRAMS{noinst}=ossl_shim
SOURCE[ossl_shim]=ossl_shim.cc async_bio.cc packeted_bio.cc test_config.cc
INCLUDE[ossl_shim]=. include ../../include
DEPEND[ossl_shim]=../../libssl ../../libcrypto
+16
View File
@@ -219,6 +219,22 @@ my @smime_cms_tests = (
"-CAfile", catfile($smdir, "smroot.pem") ]
],
[ "signed content DER format, RSA key, CAdES-BES compatible",
[ "-sign", "-cades", "-in", $smcont, "-outform", "DER", "-nodetach",
"-certfile", catfile($smdir, "smroot.pem"),
"-signer", catfile($smdir, "smrsa1.pem"), "-out", "test.cms" ],
[ "-verify", "-in", "test.cms", "-inform", "DER",
"-CAfile", catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ]
],
[ "signed content DER format, RSA key, SHA256 md, CAdES-BES compatible",
[ "-sign", "-cades", "-md", "sha256", "-in", $smcont, "-outform",
"DER", "-nodetach", "-certfile", catfile($smdir, "smroot.pem"),
"-signer", catfile($smdir, "smrsa1.pem"), "-out", "test.cms" ],
[ "-verify", "-in", "test.cms", "-inform", "DER",
"-CAfile", catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ]
],
[ "enveloped content test streaming S/MIME format, DES, 3 recipients, keyid",
[ "-encrypt", "-in", $smcont,
"-stream", "-out", "test.cms", "-keyid",
+12
View File
@@ -0,0 +1,12 @@
#! /usr/bin/env perl
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
use OpenSSL::Test::Simple;
simple_test("test_bio_memleak", "bio_memleak_test");
+5 -20
View File
@@ -6,7 +6,7 @@
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
use OpenSSL::Test qw/:DEFAULT bldtop_dir bldtop_file/;
use OpenSSL::Test qw/:DEFAULT srctop_dir bldtop_dir/;
use OpenSSL::Test::Utils;
use File::Temp qw(tempfile);
@@ -15,21 +15,17 @@ use File::Temp qw(tempfile);
BEGIN {
setup("test_shlibload");
}
use lib srctop_dir('Configurations');
use lib bldtop_dir('.');
use configdata;
use platform;
plan skip_all => "Test only supported in a shared build" if disabled("shared");
plan skip_all => "Test is disabled on AIX" if config('target') =~ m|^aix|;
plan tests => 10;
# When libssl and libcrypto are compiled on Linux with "-rpath", but not
# "--enable-new-dtags", the RPATH takes precedence over LD_LIBRARY_PATH,
# and we end up running with the wrong libraries. This is resolved by
# using paths to the shared objects, not just the names.
my $libcrypto = bldtop_file(shlib('libcrypto'));
my $libssl = bldtop_file(shlib('libssl'));
my $libcrypto = platform->sharedlib('libcrypto');
my $libssl = platform->sharedlib('libssl');
(my $fh, my $filename) = tempfile();
ok(run(test(["shlibloadtest", "-crypto_first", $libcrypto, $libssl, $filename])),
@@ -57,17 +53,6 @@ ok(run(test(["shlibloadtest", "-no_atexit", $libcrypto, $libssl, $filename])),
ok(!check_atexit($fh));
unlink $filename;
sub shlib {
my $lib = shift;
$lib = $unified_info{rename}->{$lib}
if defined $unified_info{rename}->{$lib};
$lib = $unified_info{sharednames}->{$lib}
. ($target{shlib_variant} || "")
. ($target{shared_extension} || ".so");
$lib =~ s|\.\$\(SHLIB_VERSION_NUMBER\)|.$config{shlib_version}|;
return $lib;
}
sub check_atexit {
my $fh = shift;
my $data = <$fh>;
+1 -1
View File
@@ -5593,7 +5593,7 @@ static int test_shutdown(int tst)
if (tst == 3) {
if (!TEST_true(create_bare_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
SSL_ERROR_NONE, 1))
|| !TEST_ptr_ne(sess = SSL_get_session(clientssl), NULL)
|| !TEST_false(SSL_SESSION_is_resumable(sess)))
goto end;
+37 -10
View File
@@ -25,18 +25,28 @@
# include <fcntl.h>
#endif
static ossl_inline void ossl_sleep(unsigned int millis) {
static ossl_inline void ossl_sleep(unsigned int millis)
{
# ifdef OPENSSL_SYS_VXWORKS
struct timespec ts;
ts.tv_sec = (long int) (millis / 1000);
ts.tv_nsec = (long int) (millis % 1000) * 1000000ul;
nanosleep(&ts, NULL);
# else
usleep(millis * 1000);
# endif
}
#elif defined(_WIN32)
# include <windows.h>
static ossl_inline void ossl_sleep(unsigned int millis) {
static ossl_inline void ossl_sleep(unsigned int millis)
{
Sleep(millis);
}
#else
/* Fallback to a busy wait */
static ossl_inline void ossl_sleep(unsigned int millis) {
static ossl_inline void ossl_sleep(unsigned int millis)
{
struct timeval start, now;
unsigned int elapsedms;
@@ -835,8 +845,12 @@ int create_ssl_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
/*
* Create an SSL connection, but does not ready any post-handshake
* NewSessionTicket messages.
* If |read| is set and we're using DTLS then we will attempt to SSL_read on
* the connection once we've completed one half of it, to ensure any retransmits
* get triggered.
*/
int create_bare_ssl_connection(SSL *serverssl, SSL *clientssl, int want)
int create_bare_ssl_connection(SSL *serverssl, SSL *clientssl, int want,
int read)
{
int retc = -1, rets = -1, err, abortctr = 0;
int clienterr = 0, servererr = 0;
@@ -874,11 +888,24 @@ int create_bare_ssl_connection(SSL *serverssl, SSL *clientssl, int want)
return 0;
if (clienterr && servererr)
return 0;
if (isdtls) {
if (rets > 0 && retc <= 0)
DTLSv1_handle_timeout(serverssl);
if (retc > 0 && rets <= 0)
DTLSv1_handle_timeout(clientssl);
if (isdtls && read) {
unsigned char buf[20];
/* Trigger any retransmits that may be appropriate */
if (rets > 0 && retc <= 0) {
if (SSL_read(serverssl, buf, sizeof(buf)) > 0) {
/* We don't expect this to succeed! */
TEST_info("Unexpected SSL_read() success!");
return 0;
}
}
if (retc > 0 && rets <= 0) {
if (SSL_read(clientssl, buf, sizeof(buf)) > 0) {
/* We don't expect this to succeed! */
TEST_info("Unexpected SSL_read() success!");
return 0;
}
}
}
if (++abortctr == MAXLOOPS) {
TEST_info("No progress made");
@@ -907,7 +934,7 @@ int create_ssl_connection(SSL *serverssl, SSL *clientssl, int want)
unsigned char buf;
size_t readbytes;
if (!create_bare_ssl_connection(serverssl, clientssl, want))
if (!create_bare_ssl_connection(serverssl, clientssl, want, 1))
return 0;
/*
+2 -1
View File
@@ -18,7 +18,8 @@ int create_ssl_ctx_pair(const SSL_METHOD *sm, const SSL_METHOD *cm,
char *privkeyfile);
int create_ssl_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
SSL **cssl, BIO *s_to_c_fbio, BIO *c_to_s_fbio);
int create_bare_ssl_connection(SSL *serverssl, SSL *clientssl, int want);
int create_bare_ssl_connection(SSL *serverssl, SSL *clientssl, int want,
int read);
int create_ssl_objects2(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
SSL **cssl, int sfd, int cfd);
int create_test_sockets(int *cfd, int *sfd);