Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3917)
A script that just runs a program looks like this:
#! /usr/bin/perl
A script that just runs a program looks like this:
#! /usr/bin/perl
use OpenSSL::Test::Simple;
use OpenSSL::Test::Simple;
simple_test("test_{name}", "{name}test", "{name}");
{name} is the unique name you have chosen for your test.
simple_test("test_{name}", "{name}test", "{name}");
{name} is the unique name you have chosen for your test.
A script to start from could be this:
#! /usr/bin/perl
A script to start from could be this:
#! /usr/bin/perl
use strict;
use warnings;
use OpenSSL::Test;
use strict;
use warnings;
use OpenSSL::Test;
plan tests => 2; # The number of tests being performed
plan tests => 2; # The number of tests being performed
ok(test1, "test1");
ok(test2, "test1");
ok(test1, "test1");
ok(test2, "test1");
sub test1
{
# test feature 1
}
sub test1
{
# test feature 1
}
sub test2
{
# test feature 2
}
sub test2
{
# test feature 2
}
Changes to test/build.info
==========================
Changes to test/build.info
==========================
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 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
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
for (j = 0; j < strlen(cbc_data) + 1; j++)
printf("%02X", ofb64_ok[j]);
printf("\n");
for (j = 0; j < strlen(cbc_data) + 1; j++)
printf("%02X", ofb64_ok[j]);
printf("\n");
}
static int test_bf_ecb_raw(int n)
}
static int test_bf_ecb_raw(int n)
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 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
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
int main(int argc, char *argv[])
{
printf("No DH support\n");
int main(int argc, char *argv[])
{
printf("No DH support\n");
}
#else
# include <openssl/dh.h>
}
#else
# include <openssl/dh.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#include <openssl/e_os2.h>
#ifdef OPENSSL_NO_ENGINE
int main(int argc, char *argv[])
{
printf("No ENGINE support\n");
#include <openssl/e_os2.h>
#ifdef OPENSSL_NO_ENGINE
int main(int argc, char *argv[])
{
printf("No ENGINE support\n");
}
#else
# include <openssl/buffer.h>
}
#else
# include <openssl/buffer.h>
do_handshake_step(peer);
return;
}
do_handshake_step(peer);
return;
}
if (!TEST_int_eq(peer->status, PEER_RETRY)
|| !TEST_true(test_ctx->handshake_mode
== SSL_TEST_HANDSHAKE_RENEG_SERVER
if (!TEST_int_eq(peer->status, PEER_RETRY)
|| !TEST_true(test_ctx->handshake_mode
== SSL_TEST_HANDSHAKE_RENEG_SERVER
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 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
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
for (i = 0; i < len; i++)
sprintf(&(buf[i * 2]), "%02x", md[i]);
for (i = 0; i < len; i++)
sprintf(&(buf[i * 2]), "%02x", md[i]);
- * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1999-2017 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
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
BN_bin2bn(dmq1, sizeof(dmq1)-1, NULL), \
BN_bin2bn(iqmp, sizeof(iqmp)-1, NULL)); \
memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
BN_bin2bn(dmq1, sizeof(dmq1)-1, NULL), \
BN_bin2bn(iqmp, sizeof(iqmp)-1, NULL)); \
memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
- return (sizeof(ctext_ex) - 1);
+ return sizeof(ctext_ex) - 1;
static int key1(RSA *key, unsigned char *c)
{
static int key1(RSA *key, unsigned char *c)
{
unsigned long l;
while ((l = ERR_get_error()) != 0)
if (ERR_GET_REASON(l) == RSA_R_UNKNOWN_PADDING_TYPE)
unsigned long l;
while ((l = ERR_get_error()) != 0)
if (ERR_GET_REASON(l) == RSA_R_UNKNOWN_PADDING_TYPE)
- return (1);
- return (0);
}
static int rsa_setkey(RSA** key, unsigned char* ctext, int idx)
}
static int rsa_setkey(RSA** key, unsigned char* ctext, int idx)
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
* Copyright 2005 Nokia. All rights reserved.
*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
* Copyright 2005 Nokia. All rights reserved.
*
int badop = 0;
enum { BIO_MEM, BIO_PAIR, BIO_IPV4, BIO_IPV6 } bio_type = BIO_MEM;
int force = 0;
int badop = 0;
enum { BIO_MEM, BIO_PAIR, BIO_IPV4, BIO_IPV6 } bio_type = BIO_MEM;
int force = 0;
- int dtls1 = 0, dtls12 = 0, dtls = 0, tls1 = 0, tls1_2 = 0, ssl3 = 0, ret = 1;
+ int dtls1 = 0, dtls12 = 0, dtls = 0, tls1 = 0, tls1_2 = 0, ssl3 = 0;
+ int ret = EXIT_FAILURE;
int client_auth = 0;
int server_auth = 0, i;
struct app_verify_arg app_verify_arg =
int client_auth = 0;
int server_auth = 0, i;
struct app_verify_arg app_verify_arg =
if (no_protocol) {
fprintf(stderr, "Testing was requested for a disabled protocol. "
"Skipping tests.\n");
if (no_protocol) {
fprintf(stderr, "Testing was requested for a disabled protocol. "
"Skipping tests.\n");
* if PSK is not compiled in and psk key is given, do nothing and
* exit successfully
*/
* if PSK is not compiled in and psk key is given, do nothing and
* exit successfully
*/
goto end;
}
#ifndef OPENSSL_NO_PSK
goto end;
}
#ifndef OPENSSL_NO_PSK
#else
case BIO_IPV4:
case BIO_IPV6:
#else
case BIO_IPV4:
case BIO_IPV6:
+ if (ret != EXIT_SUCCESS) break;
- if (should_negotiate && ret == 0 &&
+ if (should_negotiate && ret == EXIT_SUCCESS &&
strcmp(should_negotiate, "fail-server") != 0 &&
strcmp(should_negotiate, "fail-client") != 0) {
int version = protocol_from_string(should_negotiate);
if (version < 0) {
BIO_printf(bio_err, "Error parsing: %s\n", should_negotiate);
strcmp(should_negotiate, "fail-server") != 0 &&
strcmp(should_negotiate, "fail-client") != 0) {
int version = protocol_from_string(should_negotiate);
if (version < 0) {
BIO_printf(bio_err, "Error parsing: %s\n", should_negotiate);
goto err;
}
if (SSL_version(c_ssl) != version) {
BIO_printf(bio_err, "Unexpected version negotiated. "
"Expected: %s, got %s\n", should_negotiate, SSL_get_version(c_ssl));
goto err;
}
if (SSL_version(c_ssl) != version) {
BIO_printf(bio_err, "Unexpected version negotiated. "
"Expected: %s, got %s\n", should_negotiate, SSL_get_version(c_ssl));
BIO_printf(bio_err, "Unexpected session reuse state. "
"Expected: %d, server: %d, client: %d\n", should_reuse,
SSL_session_reused(s_ssl), SSL_session_reused(c_ssl));
BIO_printf(bio_err, "Unexpected session reuse state. "
"Expected: %d, server: %d, client: %d\n", should_reuse,
SSL_session_reused(s_ssl), SSL_session_reused(c_ssl));
goto err;
}
}
if (server_sess_out != NULL) {
if (write_session(server_sess_out, SSL_get_session(s_ssl)) == 0) {
goto err;
}
}
if (server_sess_out != NULL) {
if (write_session(server_sess_out, SSL_get_session(s_ssl)) == 0) {
goto err;
}
}
if (client_sess_out != NULL) {
if (write_session(client_sess_out, SSL_get_session(c_ssl)) == 0) {
goto err;
}
}
if (client_sess_out != NULL) {
if (write_session(client_sess_out, SSL_get_session(c_ssl)) == 0) {
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
if (CRYPTO_mem_leaks(bio_err) <= 0)
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
if (CRYPTO_mem_leaks(bio_err) <= 0)
#endif
BIO_free(bio_err);
EXIT(ret);
#endif
BIO_free(bio_err);
EXIT(ret);
BIO *s_ssl_bio = NULL, *c_ssl_bio = NULL;
BIO *acpt = NULL, *server = NULL, *client = NULL;
char addr_str[40];
BIO *s_ssl_bio = NULL, *c_ssl_bio = NULL;
BIO *acpt = NULL, *server = NULL, *client = NULL;
char addr_str[40];
+ int ret = EXIT_FAILURE;
int err_in_client = 0;
int err_in_server = 0;
int err_in_client = 0;
int err_in_server = 0;
if (verbose)
print_details(c_ssl, "DONE via TCP connect: ");
# ifndef OPENSSL_NO_NEXTPROTONEG
if (verbose)
print_details(c_ssl, "DONE via TCP connect: ");
# ifndef OPENSSL_NO_NEXTPROTONEG
- if (verify_npn(c_ssl, s_ssl) < 0) {
- ret = 1;
+ if (verify_npn(c_ssl, s_ssl) < 0)
# endif
if (verify_serverinfo() < 0) {
fprintf(stderr, "Server info verify error\n");
# endif
if (verify_serverinfo() < 0) {
fprintf(stderr, "Server info verify error\n");
- ret = 1;
- goto err;
- }
- if (verify_alpn(c_ssl, s_ssl) < 0) {
- ret = 1;
- if (verify_servername(c_ssl, s_ssl) < 0) {
- ret = 1;
+ if (verify_alpn(c_ssl, s_ssl) < 0
+ || verify_servername(c_ssl, s_ssl) < 0)
if (custom_ext_error) {
fprintf(stderr, "Custom extension error\n");
if (custom_ext_error) {
fprintf(stderr, "Custom extension error\n");
goto err;
}
# ifndef OPENSSL_NO_NEXTPROTONEG
end:
# endif
goto err;
}
# ifndef OPENSSL_NO_NEXTPROTONEG
end:
# endif
err:
ERR_print_errors(bio_err);
err:
ERR_print_errors(bio_err);
BIO_free(c_ssl_bio);
if (should_negotiate != NULL && strcmp(should_negotiate, "fail-client") == 0)
BIO_free(c_ssl_bio);
if (should_negotiate != NULL && strcmp(should_negotiate, "fail-client") == 0)
- ret = (err_in_client != 0) ? 0 : 1;
+ ret = (err_in_client != 0) ? EXIT_SUCCESS : EXIT_FAILURE;
else if (should_negotiate != NULL && strcmp(should_negotiate, "fail-server") == 0)
else if (should_negotiate != NULL && strcmp(should_negotiate, "fail-server") == 0)
- ret = (err_in_server != 0) ? 0 : 1;
+ ret = (err_in_server != 0) ? EXIT_SUCCESS : EXIT_FAILURE;
long cw_num = count, cr_num = count, sw_num = count, sr_num = count;
BIO *s_ssl_bio = NULL, *c_ssl_bio = NULL;
BIO *server = NULL, *server_io = NULL, *client = NULL, *client_io = NULL;
long cw_num = count, cr_num = count, sw_num = count, sr_num = count;
BIO *s_ssl_bio = NULL, *c_ssl_bio = NULL;
BIO *server = NULL, *server_io = NULL, *client = NULL, *client_io = NULL;
+ int ret = EXIT_FAILURE;
int err_in_client = 0;
int err_in_server = 0;
int err_in_client = 0;
int err_in_server = 0;
if (verbose)
print_details(c_ssl, "DONE via BIO pair: ");
#ifndef OPENSSL_NO_NEXTPROTONEG
if (verbose)
print_details(c_ssl, "DONE via BIO pair: ");
#ifndef OPENSSL_NO_NEXTPROTONEG
- if (verify_npn(c_ssl, s_ssl) < 0) {
- ret = 1;
+ if (verify_npn(c_ssl, s_ssl) < 0)
#endif
if (verify_serverinfo() < 0) {
fprintf(stderr, "Server info verify error\n");
#endif
if (verify_serverinfo() < 0) {
fprintf(stderr, "Server info verify error\n");
- ret = 1;
- goto err;
- }
- if (verify_alpn(c_ssl, s_ssl) < 0) {
- ret = 1;
- if (verify_servername(c_ssl, s_ssl) < 0) {
- ret = 1;
+ if (verify_alpn(c_ssl, s_ssl) < 0
+ || verify_servername(c_ssl, s_ssl) < 0)
if (custom_ext_error) {
fprintf(stderr, "Custom extension error\n");
if (custom_ext_error) {
fprintf(stderr, "Custom extension error\n");
goto err;
}
#ifndef OPENSSL_NO_NEXTPROTONEG
end:
#endif
goto err;
}
#ifndef OPENSSL_NO_NEXTPROTONEG
end:
#endif
err:
ERR_print_errors(bio_err);
err:
ERR_print_errors(bio_err);
BIO_free(c_ssl_bio);
if (should_negotiate != NULL && strcmp(should_negotiate, "fail-client") == 0)
BIO_free(c_ssl_bio);
if (should_negotiate != NULL && strcmp(should_negotiate, "fail-client") == 0)
- ret = (err_in_client != 0) ? 0 : 1;
+ ret = (err_in_client != 0) ? EXIT_SUCCESS : EXIT_FAILURE;
else if (should_negotiate != NULL && strcmp(should_negotiate, "fail-server") == 0)
else if (should_negotiate != NULL && strcmp(should_negotiate, "fail-server") == 0)
- ret = (err_in_server != 0) ? 0 : 1;
+ ret = (err_in_server != 0) ? EXIT_SUCCESS : EXIT_FAILURE;
long bufsiz;
long cw_num = count, cr_num = count;
long sw_num = count, sr_num = count;
long bufsiz;
long cw_num = count, cr_num = count;
long sw_num = count, sr_num = count;
+ int ret = EXIT_FAILURE;
BIO *c_to_s = NULL;
BIO *s_to_c = NULL;
BIO *c_bio = NULL;
BIO *c_to_s = NULL;
BIO *s_to_c = NULL;
BIO *c_bio = NULL;
if (verbose)
print_details(c_ssl, "DONE: ");
#ifndef OPENSSL_NO_NEXTPROTONEG
if (verbose)
print_details(c_ssl, "DONE: ");
#ifndef OPENSSL_NO_NEXTPROTONEG
- if (verify_npn(c_ssl, s_ssl) < 0) {
- ret = 1;
+ if (verify_npn(c_ssl, s_ssl) < 0)
#endif
if (verify_serverinfo() < 0) {
fprintf(stderr, "Server info verify error\n");
#endif
if (verify_serverinfo() < 0) {
fprintf(stderr, "Server info verify error\n");
goto err;
}
if (custom_ext_error) {
fprintf(stderr, "Custom extension error\n");
goto err;
}
if (custom_ext_error) {
fprintf(stderr, "Custom extension error\n");
err:
BIO_free(c_to_s);
BIO_free(s_to_c);
err:
BIO_free(c_to_s);
BIO_free(s_to_c);
OPENSSL_free(sbuf);
if (should_negotiate != NULL && strcmp(should_negotiate, "fail-client") == 0)
OPENSSL_free(sbuf);
if (should_negotiate != NULL && strcmp(should_negotiate, "fail-client") == 0)
- ret = (err_in_client != 0) ? 0 : 1;
+ ret = (err_in_client != 0) ? EXIT_SUCCESS : EXIT_FAILURE;
else if (should_negotiate != NULL && strcmp(should_negotiate, "fail-server") == 0)
else if (should_negotiate != NULL && strcmp(should_negotiate, "fail-server") == 0)
- ret = (err_in_server != 0) ? 0 : 1;
+ ret = (err_in_server != 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
static int verify_callback(int ok, X509_STORE_CTX *ctx)
}
static int verify_callback(int ok, X509_STORE_CTX *ctx)
}
static int app_verify_callback(X509_STORE_CTX *ctx, void *arg)
}
static int app_verify_callback(X509_STORE_CTX *ctx, void *arg)
printf("cert depth=%d %s\n",
X509_STORE_CTX_get_error_depth(ctx), buf);
}
printf("cert depth=%d %s\n",
X509_STORE_CTX_get_error_depth(ctx), buf);
}
}
ok = X509_verify_cert(ctx);
}
ok = X509_verify_cert(ctx);
BIGNUM *p, *g;
if ((dh = DH_new()) == NULL)
BIGNUM *p, *g;
if ((dh = DH_new()) == NULL)
p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL);
g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL);
if ((p == NULL) || (g == NULL) || !DH_set0_pqg(dh, p, NULL, g)) {
DH_free(dh);
BN_free(p);
BN_free(g);
p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL);
g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL);
if ((p == NULL) || (g == NULL) || !DH_set0_pqg(dh, p, NULL, g)) {
DH_free(dh);
BN_free(p);
BN_free(g);
}
static DH *get_dh1024()
}
static DH *get_dh1024()
BIGNUM *p, *g;
if ((dh = DH_new()) == NULL)
BIGNUM *p, *g;
if ((dh = DH_new()) == NULL)
p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
if ((p == NULL) || (g == NULL) || !DH_set0_pqg(dh, p, NULL, g)) {
DH_free(dh);
BN_free(p);
BN_free(g);
p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
if ((p == NULL) || (g == NULL) || !DH_set0_pqg(dh, p, NULL, g)) {
DH_free(dh);
BN_free(p);
BN_free(g);
}
static DH *get_dh1024dsa()
}
static DH *get_dh1024dsa()
BIGNUM *p, *g;
if ((dh = DH_new()) == NULL)
BIGNUM *p, *g;
if ((dh = DH_new()) == NULL)
p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
if ((p == NULL) || (g == NULL) || !DH_set0_pqg(dh, p, NULL, g)) {
DH_free(dh);
BN_free(p);
BN_free(g);
p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
if ((p == NULL) || (g == NULL) || !DH_set0_pqg(dh, p, NULL, g)) {
DH_free(dh);
BN_free(p);
BN_free(g);
}
DH_set_length(dh, 160);
}
DH_set_length(dh, 160);