Latest update.

This commit is contained in:
2020-05-17 20:27:18 +09:00
parent ad9fce94c2
commit 3a6d64bb68
619 changed files with 13638 additions and 4698 deletions
+4
View File
@@ -151,3 +151,7 @@ works fine and can be used in place of:
The former produces a more meaningful message on failure than the latter.
Note that the test infrastructure automatically sets up all required environment
variables (such as OPENSSL_MODULES, OPENSSL_CONF etc) for the tests. Individual
tests may choose to override the default settings as required.
+42 -58
View File
@@ -1,4 +1,5 @@
# SSL tests
SSL tests
=========
SSL testcases are configured in the `ssl-tests` directory.
@@ -14,20 +15,19 @@ corresponding to the default configuration. These testcases live in
For more details, see `ssl-tests/01-simple.cnf.in` for an example.
## Configuring the test
Configuring the test
--------------------
First, give your test a name. The names do not have to be unique.
An example test input looks like this:
```
{
name => "test-default",
server => { "CipherString" => "DEFAULT" },
client => { "CipherString" => "DEFAULT" },
test => { "ExpectedResult" => "Success" },
}
```
The test section supports the following options
@@ -111,19 +111,18 @@ handshake.
If this is "empty" the list is expected to be empty otherwise it is a file
of certificates whose subject names form the list.
## Configuring the client and server
Configuring the client and server
---------------------------------
The client and server configurations can be any valid `SSL_CTX`
configurations. For details, see the manpages for `SSL_CONF_cmd`.
Give your configurations as a dictionary of CONF commands, e.g.
```
server => {
"CipherString" => "DEFAULT",
"MinProtocol" => "TLSv1",
}
```
server => {
"CipherString" => "DEFAULT",
"MinProtocol" => "TLSv1",
}
The following sections may optionally be defined:
@@ -146,14 +145,12 @@ The following sections may optionally be defined:
Additional handshake settings can be configured in the `extra` section of each
client and server:
```
client => {
"CipherString" => "DEFAULT",
extra => {
"ServerName" => "server2",
client => {
"CipherString" => "DEFAULT",
extra => {
"ServerName" => "server2",
}
}
}
```
#### Supported client-side options
@@ -202,21 +199,18 @@ automatically. Server certificate verification is requested by default.
You can override these options by redefining them:
```
client => {
"VerifyCAFile" => "/path/to/custom/file"
}
```
client => {
"VerifyCAFile" => "/path/to/custom/file"
}
or by deleting them
```
client => {
"VerifyCAFile" => undef
}
```
client => {
"VerifyCAFile" => undef
}
## Adding a test to the test harness
Adding a test to the test harness
---------------------------------
1. Add a new test configuration to `test/ssl-tests`, following the examples of
existing `*.cnf.in` files (for example, `01-simple.cnf.in`).
@@ -224,32 +218,26 @@ client => {
2. Generate the generated `*.cnf` test input file. You can do so by running
`generate_ssl_tests.pl`:
```
$ ./config
$ cd test
$ TOP=.. perl -I ../util/perl/ generate_ssl_tests.pl ssl-tests/my.cnf.in \
> ssl-tests/my.cnf
```
$ ./config
$ cd test
$ TOP=.. perl -I ../util/perl/ generate_ssl_tests.pl \
ssl-tests/my.cnf.in default > ssl-tests/my.cnf
where `my.cnf.in` is your test input file.
where `my.cnf.in` is your test input file and `default` is the provider to use.
For all the pre-generated test files you should use the default provider.
For example, to generate the test cases in `ssl-tests/01-simple.cnf.in`, do
```
$ TOP=.. perl -I ../util/perl/ generate_ssl_tests.pl ssl-tests/01-simple.cnf.in > ssl-tests/01-simple.cnf
```
$ TOP=.. perl -I ../util/perl/ generate_ssl_tests.pl \
ssl-tests/01-simple.cnf.in default > ssl-tests/01-simple.cnf
Alternatively (hackish but simple), you can comment out
```
unlink glob $tmp_file;
```
unlink glob $tmp_file;
in `test/recipes/80-test_ssl_new.t` and run
```
$ make TESTS=test_ssl_new test
```
$ make TESTS=test_ssl_new test
This will save the generated output in a `*.tmp` file in the build directory.
@@ -257,13 +245,13 @@ This will save the generated output in a `*.tmp` file in the build directory.
the test suite has any skip conditions, update those too (see
`test/recipes/80-test_ssl_new.t` for details).
## Running the tests with the test harness
Running the tests with the test harness
---------------------------------------
```
HARNESS_VERBOSE=yes make TESTS=test_ssl_new test
```
HARNESS_VERBOSE=yes make TESTS=test_ssl_new test
## Running a test manually
Running a test manually
-----------------------
These steps are only needed during development. End users should run `make test`
or follow the instructions above to run the SSL test suite.
@@ -272,17 +260,13 @@ To run an SSL test manually from the command line, the `TEST_CERTS_DIR`
environment variable to point to the location of the certs. E.g., from the root
OpenSSL directory, do
```
$ CTLOG_FILE=test/ct/log_list.cnf TEST_CERTS_DIR=test/certs test/ssl_test \
test/ssl-tests/01-simple.cnf
```
$ CTLOG_FILE=test/ct/log_list.cnf TEST_CERTS_DIR=test/certs test/ssl_test \
test/ssl-tests/01-simple.cnf
or for shared builds
```
$ CTLOG_FILE=test/ct/log_list.cnf TEST_CERTS_DIR=test/certs \
util/wrap.pl test/ssl_test test/ssl-tests/01-simple.cnf
```
$ CTLOG_FILE=test/ct/log_list.cnf TEST_CERTS_DIR=test/certs \
util/wrap.pl test/ssl_test test/ssl-tests/01-simple.cnf
Note that the test expectations sometimes depend on the Configure settings. For
example, the negotiated protocol depends on the set of available (enabled)
+5 -5
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -116,7 +116,7 @@ static int badkeylen_test(void)
return ret;
}
#ifdef FIPS_MODE
#ifdef FIPS_MODULE
static int ivgen_test(void)
{
unsigned char iv_gen[16];
@@ -127,14 +127,14 @@ static int ivgen_test(void)
return do_encrypt(iv_gen, ct, &ctlen, tag, &taglen)
&& do_decrypt(iv_gen, ct, ctlen, tag, taglen);
}
#endif /* FIPS_MODE */
#endif /* FIPS_MODULE */
int setup_tests(void)
{
ADD_TEST(kat_test);
ADD_TEST(badkeylen_test);
#ifdef FIPS_MODE
#ifdef FIPS_MODULE
ADD_TEST(ivgen_test);
#endif /* FIPS_MODE */
#endif /* FIPS_MODULE */
return 1;
}
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* Licensed under the Apache License 2.0 (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
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* Licensed under the Apache License 2.0 (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
+36
View File
@@ -0,0 +1,36 @@
-----BEGIN CERTIFICATE-----
MIIGTzCCBTegAwIBAgIEAJiW+zANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJO
TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMTowOAYDVQQDDDFTdGFh
dCBkZXIgTmVkZXJsYW5kZW4gT3JnYW5pc2F0aWUgUGVyc29vbiBDQSAtIEczMB4X
DTIwMDQxNjE0MDUyMFoXDTIwMDUxNjE0MDUyMFowbDERMA8GA1UEDAwISHVpc2Fy
dHMxEjAQBgNVBAUTCTAwMDA2NjYwMDEaMBgGA1UEAwwRSGVybWFudXMgQm9lcmhh
dmUxGjAYBgNVBAoMEUhlcm1hbnVzIEJvZXJoYXZlMQswCQYDVQQGEwJOTDCCASIw
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALs6G9LEt9nOBxjdyjD8nRH3mkDp
oltjjMB9USuY2jHy5TTEzCwQW6ohJuN6s+TbwQYvJns+keJKWB5d2u7EtEuiND1O
4QIkH2j044DYdeomcuZ3Tt56rptA9oJ2OGDvT0/PZOQlFzXcNkf+3Bo40Ppr372X
dam/6eOZ928b+pfTmUDOyMPU40hyJimi+hxnLuPPYhQipIpkpGXtyA9r9qBuXqja
I0Ramdi/+WuBch2NkvjWw36tMO4MREdF2cOxLXtiMMD5404bI68ugH6sJeg3pTWd
9fMzmoD4TH0eR2u5Ayn70fGiYY9xCdLckRas2R4txC4BvUHVYimrhsc/yekCAwEA
AaOCAvowggL2MAkGA1UdEwQCMAAwMQYDVR0lBCowKAYIKwYBBQUHAwEGC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XjQNBea4+f6Ig1usJOF/G1GR4znfBIWeB73ve5lZ19qwoJf2P
OgajStG2qgWMGPuCbsDQVQDIDWVd99C1/iTq9te3Ljp9A8baWQMcDLGifkzRFnWU
k+toRfZE5K4WmD+8GL7gp1We1egMuBvCO4z3uACcKWK5FKFSvLdhuOXf3jIe9T6+
xo4RbfzLaF9EjgcGeXdZvDYfu6TZv/ZW6yh3vAtRlxhhymHsA19Bl70k1Im1Xkuy
Um0W+wwXjUcRfiuXarWwbSZxOZZcSFjYQuiQlvUgWSEeiR0=
-----END CERTIFICATE-----
+3 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
#include "internal/nelem.h"
#include "testutil.h"
DEFINE_STACK_OF(SSL_CIPHER)
static SSL_CTX *ctx;
static SSL *s;
+3 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
#include "internal/nelem.h"
#include "testutil.h"
DEFINE_STACK_OF_CONST(SSL_CIPHER)
typedef struct cipherlist_test_fixture {
const char *test_case_name;
SSL_CTX *server;
+2
View File
@@ -22,6 +22,8 @@
#include "internal/nelem.h"
#include "testutil.h"
DEFINE_STACK_OF(SSL_CIPHER)
typedef struct cipher_id_name {
int id;
const char *name;
+4 -1
View File
@@ -15,6 +15,9 @@
#ifndef NDEBUG /* tests need mock server, which is available only if !NDEBUG */
DEFINE_STACK_OF(X509)
DEFINE_STACK_OF(OSSL_CMP_ITAV)
static const char *server_key_f;
static const char *server_cert_f;
static const char *client_key_f;
@@ -64,7 +67,7 @@ static CMP_SES_TEST_FIXTURE *set_up(const char *const test_case_name)
|| !ossl_cmp_mock_srv_set1_certOut(fixture->srv_ctx, client_cert)
|| (srv_cmp_ctx =
OSSL_CMP_SRV_CTX_get0_cmp_ctx(fixture->srv_ctx)) == NULL
|| !OSSL_CMP_CTX_set1_clCert(srv_cmp_ctx, server_cert)
|| !OSSL_CMP_CTX_set1_cert(srv_cmp_ctx, server_cert)
|| !OSSL_CMP_CTX_set1_pkey(srv_cmp_ctx, server_key))
goto err;
if (!TEST_ptr(fixture->cmp_ctx = ctx = OSSL_CMP_CTX_new())
+24 -10
View File
@@ -13,6 +13,12 @@
#include <openssl/x509_vfy.h>
DEFINE_STACK_OF(X509)
DEFINE_STACK_OF(ASN1_UTF8STRING)
DEFINE_STACK_OF(X509_EXTENSION)
DEFINE_STACK_OF(OSSL_CMP_ITAV)
DEFINE_STACK_OF(POLICYINFO)
typedef struct test_fixture {
const char *test_case_name;
OSSL_CMP_CTX *ctx;
@@ -494,7 +500,11 @@ static X509_STORE *X509_STORE_new_1(void)
#define IS_0(x) ((x) == 0) /* for any type */
#define DROP(x) (void)(x) /* dummy free() for non-pointer and function types */
#define ERR(x) (CMPerr(0, CMP_R_NULL_ARGUMENT), x)
#define RET_IF_NULL_ARG(ctx, ret) \
if (ctx == NULL) { \
CMPerr(0, CMP_R_NULL_ARGUMENT); \
return ret; \
}
#define DEFINE_SET_GET_TEST(OSSL_CMP, CTX, N, M, DUP, FIELD, TYPE) \
DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set##N, get##M, DUP, FIELD, \
@@ -519,7 +529,8 @@ static X509_STORE *X509_STORE_new_1(void)
#define DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, N, DUP, FIELD, TYPE, DEFAULT) \
static TYPE *OSSL_CMP_CTX_get0_##FIELD(const CMP_CTX *ctx) \
{ \
return ctx == NULL ? ERR(NULL) : (TYPE *)ctx->FIELD; \
RET_IF_NULL_ARG(ctx, NULL); \
return (TYPE *)ctx->FIELD; \
} \
DEFINE_SET_GET_TEST_DEFAULT(OSSL_CMP, CTX, N, 0, DUP, FIELD, TYPE, DEFAULT)
#define DEFINE_SET_TEST(OSSL_CMP, CTX, N, DUP, FIELD, TYPE) \
@@ -528,7 +539,8 @@ static X509_STORE *X509_STORE_new_1(void)
#define DEFINE_SET_SK_TEST(OSSL_CMP, CTX, N, FIELD, TYPE) \
static STACK_OF(TYPE) *OSSL_CMP_CTX_get0_##FIELD(const CMP_CTX *ctx) \
{ \
return ctx == NULL ? ERR(NULL) : ctx->FIELD; \
RET_IF_NULL_ARG(ctx, NULL); \
return ctx->FIELD; \
} \
DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set##N, get0, 1, FIELD, \
STACK_OF(TYPE)*, NULL, IS_0, \
@@ -538,9 +550,8 @@ typedef OSSL_HTTP_bio_cb_t OSSL_CMP_http_cb_t;
#define DEFINE_SET_CB_TEST(FIELD) \
static OSSL_CMP_##FIELD##_t OSSL_CMP_CTX_get_##FIELD(const CMP_CTX *ctx) \
{ \
if (ctx == NULL) \
CMPerr(0, CMP_R_NULL_ARGUMENT); \
return ctx == NULL ? NULL /* cannot use ERR(NULL) here */ : ctx->FIELD;\
RET_IF_NULL_ARG(ctx, NULL); \
return ctx->FIELD; \
} \
DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, FIELD, \
OSSL_CMP_##FIELD##_t, NULL, IS_0, \
@@ -557,7 +568,8 @@ typedef OSSL_HTTP_bio_cb_t OSSL_CMP_http_cb_t;
#define DEFINE_SET_INT_TEST(FIELD) \
static int OSSL_CMP_CTX_get_##FIELD(const CMP_CTX *ctx) \
{ \
return ctx == NULL ? ERR(-1) : ctx->FIELD; \
RET_IF_NULL_ARG(ctx, -1); \
return ctx->FIELD; \
} \
DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, IS_0)
@@ -581,8 +593,10 @@ typedef OSSL_HTTP_bio_cb_t OSSL_CMP_http_cb_t;
\
static char *OSSL_CMP_CTX_get1_##FIELD##_str(const CMP_CTX *ctx) \
{ \
const ASN1_OCTET_STRING *bytes = ctx == NULL ? ERR(NULL) : ctx->FIELD; \
const ASN1_OCTET_STRING *bytes = NULL; \
\
RET_IF_NULL_ARG(ctx, NULL); \
bytes = ctx->FIELD; \
return bytes == NULL ? NULL : \
OPENSSL_strndup((char *)bytes->data, bytes->length); \
}
@@ -732,7 +746,7 @@ DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set0, get0, 0, trustedStore,
DEFAULT_STORE, X509_STORE_new_1(), X509_STORE_free)
DEFINE_SET_GET_SK_X509_TEST(OSSL_CMP, CTX, 1, 0, untrusted_certs)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 0, clCert, X509)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 0, cert, X509)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 0, pkey, EVP_PKEY)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, recipient, X509_NAME)
@@ -815,7 +829,7 @@ int setup_tests(void)
ADD_TEST(test_CTX_set0_get0_trustedStore);
ADD_TEST(test_CTX_set1_get0_untrusted_certs);
/* client authentication: */
ADD_TEST(test_CTX_set1_get0_clCert);
ADD_TEST(test_CTX_set1_get0_cert);
ADD_TEST(test_CTX_set1_get0_pkey);
/* the following two also test ossl_cmp_asn1_octet_string_set1_bytes(): */
ADD_TEST(test_CTX_set1_get1_referenceValue_str);
+3
View File
@@ -11,6 +11,9 @@
#include "cmp_testlib.h"
DEFINE_STACK_OF(OSSL_CMP_ITAV)
DEFINE_STACK_OF(ASN1_UTF8STRING)
static unsigned char rand_data[OSSL_CMP_TRANSACTIONID_LENGTH];
typedef struct test_fixture {
+3 -1
View File
@@ -11,6 +11,8 @@
#include "cmp_testlib.h"
DEFINE_STACK_OF(OSSL_CMP_CERTRESPONSE)
static const char *server_cert_f;
static const char *pkcs10_f;
@@ -163,7 +165,7 @@ static int test_cmp_create_ir_protection_fails(void)
if (!TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, newkey))
|| !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0))
/* newkey used by default for signing does not match cert: */
|| !TEST_true(OSSL_CMP_CTX_set1_clCert(fixture->cmp_ctx, cert))) {
|| !TEST_true(OSSL_CMP_CTX_set1_cert(fixture->cmp_ctx, cert))) {
tear_down(fixture);
fixture = NULL;
}
+3 -1
View File
@@ -11,6 +11,8 @@
#include "cmp_testlib.h"
DEFINE_STACK_OF(X509)
static const char *ir_protected_f;
static const char *ir_unprotected_f;
static const char *ip_PBM_f;
@@ -240,7 +242,7 @@ static int test_MSG_protect_with_certificate_and_key(void)
OSSL_CMP_MSG_dup(ir_unprotected))
|| !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0))
|| !TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, loadedkey))
|| !TEST_true(OSSL_CMP_CTX_set1_clCert(fixture->cmp_ctx, cert))) {
|| !TEST_true(OSSL_CMP_CTX_set1_cert(fixture->cmp_ctx, cert))) {
tear_down(fixture);
fixture = NULL;
}
+2
View File
@@ -11,6 +11,8 @@
#include "cmp_testlib.h"
DEFINE_STACK_OF(ASN1_UTF8STRING)
typedef struct test_fixture {
const char *test_case_name;
int pkistatus;
+2
View File
@@ -12,6 +12,8 @@
#include "cmp_testlib.h"
#include <openssl/rsa.h> /* needed in case config no-deprecated */
DEFINE_STACK_OF(X509)
EVP_PKEY *load_pem_key(const char *file)
{
EVP_PKEY *key = NULL;
+1
View File
@@ -11,6 +11,7 @@
#include "cmp_testlib.h"
#include "../crypto/crmf/crmf_local.h" /* for manipulating POPO signature */
DEFINE_STACK_OF(OSSL_CRMF_MSG)
static const char *server_f;
static const char *client_f;
+3 -1
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* Licensed under the Apache License 2.0 (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
@@ -16,6 +16,8 @@
#include "testutil.h"
DEFINE_STACK_OF(X509)
static X509 *cert = NULL;
static EVP_PKEY *privkey = NULL;
+4 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -14,6 +14,9 @@
#include <openssl/safestack.h>
#include <openssl/err.h>
DEFINE_STACK_OF(CONF_VALUE)
DEFINE_STACK_OF_CSTRING()
static STACK_OF(OPENSSL_CSTRING) *section_names = NULL;
static void collect_section_name(CONF_VALUE *v)
+4 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -17,6 +17,9 @@
#include "testutil.h"
DEFINE_STACK_OF(X509)
DEFINE_STACK_OF(X509_CRL)
#define PARAM_TIME 1474934400 /* Sep 27th, 2016 */
static const char *kCRLTestRoot[] = {
+3
View File
@@ -21,6 +21,9 @@
#include <openssl/crypto.h>
#ifndef OPENSSL_NO_CT
DEFINE_STACK_OF(SCT)
/* Used when declaring buffers to read text files into */
# define CT_TEST_MAX_FILE_SIZE 8096
+2
View File
@@ -26,6 +26,8 @@
#include "internal/nelem.h"
DEFINE_STACK_OF(X509)
#define _UC(c) ((unsigned char)(c))
static const char *basedomain;
+2 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -254,7 +254,7 @@ static int test_cavs_kats(const struct drbg_kat *test[], int i)
const struct drbg_kat *td = test[i];
int rv = 0;
#ifdef FIPS_MODE
#ifdef FIPS_MODULE
/* FIPS mode doesn't support instantiating without a derivation function */
if ((td->flags & USE_DF) == 0)
return TEST_skip("instantiating without derivation function "
+3 -5
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* Licensed under the Apache License 2.0 (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
@@ -75,10 +75,8 @@ static int run_extra_kat(const struct drbg_extra_kat *td)
failures++;
err:
if (drbg != NULL) {
RAND_DRBG_uninstantiate(drbg);
RAND_DRBG_free(drbg);
}
RAND_DRBG_uninstantiate(drbg);
RAND_DRBG_free(drbg);
return failures == 0;
}
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* Licensed under the Apache License 2.0 (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
+5 -5
View File
@@ -111,7 +111,7 @@ typedef struct drbg_selftest_data_st {
make_drbg_test_data(nid, 0, pr, p)
static DRBG_SELFTEST_DATA drbg_test[] = {
#ifndef FIPS_MODE
#ifndef FIPS_MODULE
/* FIPS mode doesn't support CTR DRBG without a derivation function */
make_drbg_test_data_no_df (NID_aes_128_ctr, aes_128_no_df, 0),
make_drbg_test_data_no_df (NID_aes_192_ctr, aes_192_no_df, 0),
@@ -850,7 +850,7 @@ static int test_rand_drbg_reseed(void)
/* fill 'randomness' buffer with some arbitrary data */
memset(rand_add_buf, 'r', sizeof(rand_add_buf));
#ifndef FIPS_MODE
#ifndef FIPS_MODULE
/*
* Test whether all three DRBGs are reseeded by RAND_add().
* The before_reseed time has to be measured here and passed into the
@@ -876,7 +876,7 @@ static int test_rand_drbg_reseed(void)
if (!TEST_true(test_drbg_reseed(0, master, public, private, 0, 0, 0, 0)))
goto error;
reset_drbg_hook_ctx();
#else /* FIPS_MODE */
#else /* FIPS_MODULE */
/*
* In FIPS mode, random data provided by the application via RAND_add()
* is not considered a trusted entropy source. It is only treated as
@@ -1251,7 +1251,7 @@ static int test_set_defaults(void)
&& TEST_int_eq(public->flags, RAND_DRBG_FLAG_PUBLIC)
/* FIPS mode doesn't support CTR DRBG without a derivation function */
#ifndef FIPS_MODE
#ifndef FIPS_MODULE
/* Change DRBG defaults and change master and check again */
&& TEST_true(RAND_DRBG_set_defaults(NID_aes_256_ctr,
RAND_DRBG_FLAG_CTR_NO_DF))
@@ -1347,7 +1347,7 @@ static int test_crngt(int n)
crngt_case = n % crngt_num_cases;
crngt_idx = 0;
crngt_get_entropy = &crngt_entropy_cb;
#ifndef FIPS_MODE
#ifndef FIPS_MODULE
if (!TEST_true(RAND_DRBG_set_callbacks(drbg, &rand_crngt_get_entropy,
&rand_crngt_cleanup_entropy,
&rand_drbg_get_nonce,
+5
View File
@@ -155,6 +155,7 @@ static int dsa_keygen_test(void)
unsigned char seed_out[32];
char group_out[32];
size_t len = 0;
const OSSL_PARAM *settables = NULL;
static const unsigned char seed_data[] = {
0xa6, 0xf5, 0x28, 0x8c, 0x50, 0x77, 0xa5, 0x68,
0x6d, 0x3a, 0xf5, 0xf1, 0xc6, 0x4c, 0xdc, 0x35,
@@ -244,6 +245,10 @@ static int dsa_keygen_test(void)
goto end;
if (!TEST_ptr(pg_ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL))
|| !TEST_int_gt(EVP_PKEY_paramgen_init(pg_ctx), 0)
|| !TEST_ptr_null(EVP_PKEY_CTX_gettable_params(pg_ctx))
|| !TEST_ptr(settables = EVP_PKEY_CTX_settable_params(pg_ctx))
|| !TEST_ptr(OSSL_PARAM_locate_const(settables,
OSSL_PKEY_PARAM_FFC_PBITS))
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_bits(pg_ctx, 2048))
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_q_bits(pg_ctx, 224))
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_seed(pg_ctx, seed_data,
+3 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -20,6 +20,8 @@
/* for SSL_READ_ETM() */
#include "../ssl/ssl_local.h"
DEFINE_STACK_OF(SSL_CIPHER)
static int debug = 0;
static unsigned int clnt_psk_callback(SSL *ssl, const char *hint,
+2 -2
View File
@@ -123,10 +123,10 @@ static int x9_62_tests(int n)
TEST_info("ECDSA KATs for curve %s", OBJ_nid2sn(nid));
#ifdef FIPS_MODE
#ifdef FIPS_MODULE
if (EC_curve_nid2nist(nid) == NULL)
return TEST_skip("skip non approved curves");
#endif /* FIPS_MODE */
#endif /* FIPS_MODULE */
if (!TEST_ptr(mctx = EVP_MD_CTX_new())
/* get the message digest */
+26 -10
View File
@@ -8,6 +8,14 @@
* https://www.openssl.org/source/license.html
*/
/*
* We need access to the deprecated EC_POINTs_mul for testing purposes
* when the deprecated calls are not hidden
*/
#ifndef OPENSSL_NO_DEPRECATED_3_0
# define OPENSSL_SUPPRESS_DEPRECATED
#endif
#include <string.h>
#include "internal/nelem.h"
#include "testutil.h"
@@ -64,8 +72,10 @@ static int group_order_tests(EC_GROUP *group)
goto err;
for (i = 1; i <= 2; i++) {
# ifndef OPENSSL_NO_DEPRECATED_3_0
const BIGNUM *scalars[6];
const EC_POINT *points[6];
# endif
if (!TEST_true(BN_set_word(n1, i))
/*
@@ -97,11 +107,11 @@ static int group_order_tests(EC_GROUP *group)
/* Add P to verify the result. */
|| !TEST_true(EC_POINT_add(group, Q, Q, P, ctx))
|| !TEST_true(EC_POINT_is_at_infinity(group, Q))
/* Exercise EC_POINTs_mul, including corner cases. */
|| !TEST_false(EC_POINT_is_at_infinity(group, P)))
goto err;
# ifndef OPENSSL_NO_DEPRECATED_3_0
/* Exercise EC_POINTs_mul, including corner cases. */
scalars[0] = scalars[1] = BN_value_one();
points[0] = points[1] = P;
@@ -125,6 +135,7 @@ static int group_order_tests(EC_GROUP *group)
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 6, points, scalars, ctx))
|| !TEST_true(EC_POINT_is_at_infinity(group, P)))
goto err;
# endif
}
r = 1;
@@ -152,8 +163,10 @@ static int prime_field_tests(void)
*P_256 = NULL, *P_384 = NULL, *P_521 = NULL;
EC_POINT *P = NULL, *Q = NULL, *R = NULL;
BIGNUM *x = NULL, *y = NULL, *z = NULL, *yplusone = NULL;
# ifndef OPENSSL_NO_DEPRECATED_3_0
const EC_POINT *points[4];
const BIGNUM *scalars[4];
# endif
unsigned char buf[100];
size_t len, r = 0;
int k;
@@ -548,6 +561,9 @@ static int prime_field_tests(void)
|| !TEST_true(EC_POINT_is_at_infinity(group, R)) /* R = P + 2Q */
|| !TEST_false(EC_POINT_is_at_infinity(group, Q)))
goto err;
# ifndef OPENSSL_NO_DEPRECATED_3_0
TEST_note("combined multiplication ...");
points[0] = Q;
points[1] = Q;
points[2] = Q;
@@ -558,11 +574,10 @@ static int prime_field_tests(void)
|| !TEST_BN_even(y)
|| !TEST_true(BN_rshift1(y, y)))
goto err;
scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */
scalars[1] = y;
TEST_note("combined multiplication ...");
/* z is still the group order */
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))
|| !TEST_true(EC_POINTs_mul(group, R, z, 2, points, scalars, ctx))
@@ -593,10 +608,8 @@ static int prime_field_tests(void)
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 4, points, scalars, ctx))
|| !TEST_true(EC_POINT_is_at_infinity(group, P)))
goto err;
# endif
TEST_note(" ok\n");
r = 1;
err:
BN_CTX_free(ctx);
@@ -803,8 +816,10 @@ static int char2_curve_test(int n)
BIGNUM *x = NULL, *y = NULL, *z = NULL, *cof = NULL, *yplusone = NULL;
EC_GROUP *group = NULL, *variable = NULL;
EC_POINT *P = NULL, *Q = NULL, *R = NULL;
# ifndef OPENSSL_NO_DEPRECATED_3_0
const EC_POINT *points[3];
const BIGNUM *scalars[3];
# endif
struct c2_curve_test *const test = char2_curve_tests + n;
if (!TEST_ptr(ctx = BN_CTX_new())
@@ -888,6 +903,8 @@ static int char2_curve_test(int n)
|| !TEST_false(EC_POINT_is_at_infinity(group, Q)))
goto err;
# ifndef OPENSSL_NO_DEPRECATED_3_0
TEST_note("combined multiplication ...");
points[0] = Q;
points[1] = Q;
points[2] = Q;
@@ -899,8 +916,6 @@ static int char2_curve_test(int n)
scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */
scalars[1] = y;
TEST_note("combined multiplication ...");
/* z is still the group order */
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))
|| !TEST_true(EC_POINTs_mul(group, R, z, 2, points, scalars, ctx))
@@ -929,7 +944,8 @@ static int char2_curve_test(int n)
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 3, points, scalars, ctx))
|| !TEST_true(EC_POINT_is_at_infinity(group, P)))
goto err;;
goto err;
# endif
}
r = 1;
+70 -13
View File
@@ -29,6 +29,8 @@
#include "internal/sizes.h"
#include "crypto/evp.h"
static OPENSSL_CTX *testctx = NULL;
/*
* kExampleRSAKeyDER is an RSA private key in ASN.1, DER format. Of course, you
* should never use this key anywhere but in an example.
@@ -765,7 +767,7 @@ static int test_EVP_PKCS82PKEY(void)
}
#endif
#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODE)
#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODULE)
static int test_EVP_SM2_verify(void)
{
@@ -1005,7 +1007,7 @@ static struct keys_st {
#endif
};
static int test_set_get_raw_keys_int(int tst, int pub)
static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx)
{
int ret = 0;
unsigned char buf[80];
@@ -1022,17 +1024,34 @@ static int test_set_get_raw_keys_int(int tst, int pub)
if (pub) {
inlen = strlen(keys[tst].pub);
in = (unsigned char *)keys[tst].pub;
pkey = EVP_PKEY_new_raw_public_key(keys[tst].type,
NULL,
in,
inlen);
if (uselibctx) {
pkey = EVP_PKEY_new_raw_public_key_with_libctx(
testctx,
OBJ_nid2sn(keys[tst].type),
NULL,
in,
inlen);
} else {
pkey = EVP_PKEY_new_raw_public_key(keys[tst].type,
NULL,
in,
inlen);
}
} else {
inlen = strlen(keys[tst].priv);
in = (unsigned char *)keys[tst].priv;
pkey = EVP_PKEY_new_raw_private_key(keys[tst].type,
NULL,
in,
inlen);
if (uselibctx) {
pkey = EVP_PKEY_new_raw_private_key_with_libctx(
testctx, OBJ_nid2sn(keys[tst].type),
NULL,
in,
inlen);
} else {
pkey = EVP_PKEY_new_raw_private_key(keys[tst].type,
NULL,
in,
inlen);
}
}
if (!TEST_ptr(pkey)
@@ -1052,8 +1071,10 @@ static int test_set_get_raw_keys_int(int tst, int pub)
static int test_set_get_raw_keys(int tst)
{
return test_set_get_raw_keys_int(tst, 0)
&& test_set_get_raw_keys_int(tst, 1);
return test_set_get_raw_keys_int(tst, 0, 0)
&& test_set_get_raw_keys_int(tst, 0, 1)
&& test_set_get_raw_keys_int(tst, 1, 0)
&& test_set_get_raw_keys_int(tst, 1, 1);
}
static int pkey_custom_check(EVP_PKEY *pkey)
@@ -1158,6 +1179,29 @@ static int test_EVP_PKEY_check(int i)
return ret;
}
#ifndef OPENSSL_NO_CMAC
static int test_CMAC_keygen(void)
{
/*
* This is a legacy method for CMACs, but should still work.
* This verifies that it works without an ENGINE.
*/
EVP_PKEY_CTX *kctx = EVP_PKEY_CTX_new_id(EVP_PKEY_CMAC, NULL);
int ret = 0;
if (!TEST_true(EVP_PKEY_keygen_init(kctx) > 0)
&& !TEST_true(EVP_PKEY_CTX_ctrl(kctx, -1, EVP_PKEY_OP_KEYGEN,
EVP_PKEY_CTRL_CIPHER,
0, (void *)EVP_aes_256_ecb()) > 0))
goto done;
ret = 1;
done:
EVP_PKEY_CTX_free(kctx);
return ret;
}
#endif
static int test_HKDF(void)
{
EVP_PKEY_CTX *pctx;
@@ -1583,6 +1627,11 @@ static int test_keygen_with_empty_template(int n)
int setup_tests(void)
{
testctx = OPENSSL_CTX_new();
if (!TEST_ptr(testctx))
return 0;
ADD_ALL_TESTS(test_EVP_DigestSignInit, 9);
ADD_TEST(test_EVP_DigestVerifyInit);
ADD_TEST(test_EVP_Enveloped);
@@ -1590,7 +1639,7 @@ int setup_tests(void)
#ifndef OPENSSL_NO_EC
ADD_TEST(test_EVP_PKCS82PKEY);
#endif
#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODE)
#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODULE)
ADD_TEST(test_EVP_SM2);
ADD_TEST(test_EVP_SM2_verify);
#endif
@@ -1604,6 +1653,9 @@ int setup_tests(void)
if (!TEST_int_eq(EVP_PKEY_meth_add0(custom_pmeth), 1))
return 0;
ADD_ALL_TESTS(test_EVP_PKEY_check, OSSL_NELEM(keycheckdata));
#ifndef OPENSSL_NO_CMAC
ADD_TEST(test_CMAC_keygen);
#endif
ADD_TEST(test_HKDF);
#ifndef OPENSSL_NO_EC
ADD_TEST(test_X509_PUBKEY_inplace);
@@ -1624,3 +1676,8 @@ int setup_tests(void)
return 1;
}
void cleanup_tests(void)
{
OPENSSL_CTX_free(testctx);
}
+27 -6
View File
@@ -130,7 +130,12 @@ static int test_print_key_using_pem(const char *alg, const EVP_PKEY *pk)
if (!TEST_ptr(membio))
goto err;
if (!TEST_true(EVP_PKEY_print_private(membio, pk, 0, NULL))
if (/* Output Encrypted private key in PEM form */
!TEST_true(PEM_write_bio_PrivateKey(bio_out, pk, EVP_aes_256_cbc(),
(unsigned char *)"pass", 4,
NULL, NULL))
/* Private key in text form */
|| !TEST_true(EVP_PKEY_print_private(membio, pk, 0, NULL))
|| !TEST_true(compare_with_file(alg, PRIV_TEXT, membio))
/* Public key in PEM form */
|| !TEST_true(PEM_write_bio_PUBKEY(membio, pk))
@@ -138,11 +143,7 @@ static int test_print_key_using_pem(const char *alg, const EVP_PKEY *pk)
/* Unencrypted private key in PEM form */
|| !TEST_true(PEM_write_bio_PrivateKey(membio, pk,
NULL, NULL, 0, NULL, NULL))
|| !TEST_true(compare_with_file(alg, PRIV_PEM, membio))
/* Encrypted private key in PEM form */
|| !TEST_true(PEM_write_bio_PrivateKey(bio_out, pk, EVP_aes_256_cbc(),
(unsigned char *)"pass", 4,
NULL, NULL)))
|| !TEST_true(compare_with_file(alg, PRIV_PEM, membio)))
goto err;
ret = 1;
@@ -1211,6 +1212,25 @@ static int test_fromdata_dsa_fips186_4(void)
return ret;
}
static int test_check_dsa(void)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL))
|| !TEST_false(EVP_PKEY_check(ctx))
|| !TEST_false(EVP_PKEY_public_check(ctx))
|| !TEST_false(EVP_PKEY_private_check(ctx))
|| !TEST_false(EVP_PKEY_pairwise_check(ctx)))
goto err;
ret = 1;
err:
EVP_PKEY_CTX_free(ctx);
return ret;
}
#endif /* OPENSSL_NO_DSA */
@@ -1231,6 +1251,7 @@ int setup_tests(void)
ADD_TEST(test_fromdata_dh_named_group);
#endif
#ifndef OPENSSL_NO_DSA
ADD_TEST(test_check_dsa);
ADD_TEST(test_fromdata_dsa_fips186_4);
#endif
#ifndef OPENSSL_NO_EC
+2
View File
@@ -25,6 +25,8 @@
#include "testutil.h"
#include "evp_test.h"
DEFINE_STACK_OF_STRING()
#define AAD_NUM 4
typedef struct evp_test_method_st EVP_TEST_METHOD;
+2
View File
@@ -26,6 +26,8 @@
#include <netinet/sctp.h>
#endif
DEFINE_STACK_OF(X509_NAME)
HANDSHAKE_RESULT *HANDSHAKE_RESULT_new(void)
{
HANDSHAKE_RESULT *ret;
+2
View File
@@ -15,6 +15,8 @@
#include "testutil.h"
DEFINE_STACK_OF(CONF_VALUE)
static const ASN1_ITEM *x509_it = NULL;
static X509 *x509 = NULL;
#define SERVER "mock.server"
+27
View File
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAoiNNxo5pwk1lD1em3madbpKz86GSYyGlQtd0ZhIX1tOUFo9l
Fex7n5Osv0A99pKb+7EKqB9Ghg6mJ29kIUUmLACnfZJ/q+U6s9T4zFrYyXweUNJv
QgbA2ojDPyVoRp2T1ekahPh4DpxPWNKfYECDRbrxkHMM3WiIqYFLU8hYvEMGSWRH
HbnS/vG7MTaVDkR8d0zixTOp0fST5c1UUTqppYlThac/BG1kk3hyjIjz5o7lspfX
3s/eAYgT9GhYHL6Uy4o4OqCleR39aVc0dMrrjb7hsmX6ecNwqJOE5AHHOG4Ti6Cb
weSOcdH5PRFzdpao5rlTErsFHlUSTca4mfVeWwIDAQABAoIBAQCUYAZevBjgbP8c
qTPVtsY/WBVB0Qwrl7CqmIy2k7wpJfoRIyx4ga8n+3ZMlredm9EO5ZdA/04EhAdd
czyIjcU+42JjMduQLPgpda4xJLnauLDteYXDQHbgBePXN55TcQTG7skMAm2rwTOD
r0uWQ7Nd7pP9gqu1OmJF7EJI68D4llCU1FrOrliwSDzHWP3p4QmCW3M9PQJ68xw1
gE7X1QflROGivcFoRgcgeoJDzpxveGvPbEn6Q+05/FMRVxjqWhpxdZ9/SL7iRz1e
45T+P9a8OLgTyErT3Lp/f/vuHA1tlbAYumhSnxXsb+nHi80aDcImOrNQHAp076Ik
bkZ1NpOxAoGBAM3Ulgi2hUPdoAMFtHZF8eBHRzn+4uTfY2s33wObiUJQ8VbGDeJY
ifCfOwLThiAXAqktrs7ItwWDYmzd5xPYGQeWoKcBEoZ+dvaaOe8H7TCMnjB3R3i1
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_OF(X509)
static const char *certstr;
static const char *privkeystr;
+5 -5
View File
@@ -48,9 +48,9 @@ static const OSSL_PARAM *p_gettable_params(void *_)
return p_param_types;
}
static int p_get_params(void *vprov, OSSL_PARAM params[])
static int p_get_params(void *vhand, OSSL_PARAM params[])
{
const OSSL_PROVIDER *prov = vprov;
const OSSL_CORE_HANDLE *hand = vhand;
OSSL_PARAM *p = params;
int ok = 1;
@@ -77,7 +77,7 @@ static int p_get_params(void *vprov, OSSL_PARAM params[])
opensslv = provname = greeting = NULL;
if (c_get_params(prov, counter_request)) {
if (c_get_params(hand, counter_request)) {
if (greeting) {
strcpy(buf, greeting);
} else {
@@ -119,7 +119,7 @@ static const OSSL_DISPATCH p_test_table[] = {
{ 0, NULL }
};
int OSSL_provider_init(const OSSL_PROVIDER *provider,
int OSSL_provider_init(const OSSL_CORE_HANDLE *handle,
const OSSL_DISPATCH *in,
const OSSL_DISPATCH **out,
void **provctx)
@@ -139,7 +139,7 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider,
}
/* Because we use this in get_params, we need to pass it back */
*provctx = (void *)provider;
*provctx = (void *)handle;
*out = p_test_table;
return 1;
+1 -1
View File
@@ -205,7 +205,7 @@ static int builder_limit_test(void)
for (i = 0; i < n; i++) {
names[i][0] = 'A' + (i / 26) - 1;
names[i][0] = 'a' + (i % 26) - 1;
names[i][1] = 'a' + (i % 26) - 1;
names[i][2] = '\0';
if (!TEST_true(OSSL_PARAM_BLD_push_int(bld, names[i], 3 * i + 1)))
goto err;
+32 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
@@ -9,6 +9,7 @@
*/
#include <stdarg.h>
#include <openssl/evp.h>
#include "testutil.h"
#include "internal/nelem.h"
#include "internal/property.h"
@@ -383,6 +384,35 @@ err:
return res;
}
static int test_fips_mode(void)
{
int ret = 0;
OPENSSL_CTX *ctx = NULL;
if (!TEST_ptr(ctx = OPENSSL_CTX_new()))
goto err;
ret = TEST_true(EVP_set_default_properties(ctx, "default=yes,fips=yes"))
&& TEST_true(EVP_default_properties_is_fips_enabled(ctx))
&& TEST_true(EVP_set_default_properties(ctx, "fips=no,default=yes"))
&& TEST_false(EVP_default_properties_is_fips_enabled(ctx))
&& TEST_true(EVP_set_default_properties(ctx, "fips=no"))
&& TEST_false(EVP_default_properties_is_fips_enabled(ctx))
&& TEST_true(EVP_set_default_properties(ctx, "fips!=no"))
&& TEST_true(EVP_default_properties_is_fips_enabled(ctx))
&& TEST_true(EVP_set_default_properties(ctx, "fips=no"))
&& TEST_false(EVP_default_properties_is_fips_enabled(ctx))
&& TEST_true(EVP_set_default_properties(ctx, "fips=no,default=yes"))
&& TEST_true(EVP_default_properties_enable_fips(ctx, 1))
&& TEST_true(EVP_default_properties_is_fips_enabled(ctx))
&& TEST_true(EVP_default_properties_enable_fips(ctx, 0))
&& TEST_false(EVP_default_properties_is_fips_enabled(ctx));
err:
OPENSSL_CTX_free(ctx);
return ret;
}
int setup_tests(void)
{
ADD_TEST(test_property_string);
@@ -393,5 +423,6 @@ int setup_tests(void)
ADD_TEST(test_register_deregister);
ADD_TEST(test_property);
ADD_TEST(test_query_cache_stochastic);
ADD_TEST(test_fips_mode);
return 1;
}
-1
View File
@@ -27,7 +27,6 @@ plan skip_all => "Test only supported in a fips build" if disabled("fips");
plan tests => 12;
my $infile = bldtop_file('providers', platform->dso('fips'));
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
# fail if no module name
ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.cnf', '-module',
+2 -2
View File
@@ -1,7 +1,7 @@
#! /usr/bin/env perl
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# Licensed under the Apache License 2.0 (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
@@ -1,7 +1,7 @@
#! /usr/bin/env perl
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# Licensed under the Apache License 2.0 (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
+4 -1
View File
@@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
@@ -28,6 +28,8 @@ my %cert_expected = (
"cert-1023line.pem" => 1,
"cert-1024line.pem" => 1,
"cert-1025line.pem" => 1,
"cert-254-chars-at-the-end.pem" => 1,
"cert-254-chars-in-the-middle.pem" => 1,
"cert-255line.pem" => 1,
"cert-256line.pem" => 1,
"cert-257line.pem" => 1,
@@ -43,6 +45,7 @@ my %cert_expected = (
"cert-misalignedpad.pem" => 0,
"cert-onecolumn.pem" => 1,
"cert-oneline.pem" => 1,
"cert-oneline-multiple-of-254.pem" => 1,
"cert-shortandlongline.pem" => 1,
"cert-shortline.pem" => 1,
"cert-threecolumn.pem" => 1,
@@ -0,0 +1,6 @@
-----BEGIN CERTIFICATE-----
MIIEcjCCAyegAwIBAgIUPLgYY73GEwkikNCKRJrcbCR+TbQwDQYJKoZIhvcNAQELBQAwgZUxCzAJBgNVBAYTAkFVMWMwYQYDVQQIDFpUaGUgR3JlYXQgU3RhdGUgb2YgTG9uZy1XaW5kZWQgQ2VydGlmaWNhdGUgRmllbGQgTmFtZXMgV2hlcmVieSB0byBJbmNyZWFzZSB0aGUgT3V0cHV0IFNpemUxITAfBgNVB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QriOUVTTkqBP1xUimKSTaNaZ8KAnC7thxxZHxsNa45a6AouPSzyAOPZQgCJW83OIFxvWsdYU1KvP1wmoi1XC9giSQ/5sLPu/eAYTzmY+Xd6Sq8dF8uyodeI2gFu3AzC28PVKeUriIGfxaqEUn+aXx5W+r8JTE6fQ9mBo9YxJBXG+OTIFgHR27q2dJwqK9c=
-----END CERTIFICATE-----
+26 -8
View File
@@ -16,14 +16,22 @@ use OpenSSL::Test::Utils;
setup("test_rsapss");
plan tests => 5;
plan tests => 7;
#using test/testrsa.pem which happens to be a 512 bit RSA
ok(run(app(['openssl', 'dgst', '-sign', srctop_file('test', 'testrsa.pem'), '-sha1',
'-sigopt', 'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:max',
'-sigopt', 'rsa_mgf1_md:sha512', '-out', 'testrsapss.sig',
'-sigopt', 'rsa_padding_mode:pss',
'-sigopt', 'rsa_pss_saltlen:max',
'-sigopt', 'rsa_mgf1_md:sha512',
'-out', 'testrsapss-restricted.sig',
srctop_file('test', 'testrsa.pem')])),
"openssl dgst -sign");
"openssl dgst -sign [plain RSA key, PSS padding mode, PSS restrictions]");
ok(run(app(['openssl', 'dgst', '-sign', srctop_file('test', 'testrsa.pem'), '-sha1',
'-sigopt', 'rsa_padding_mode:pss',
'-out', 'testrsapss-unrestricted.sig',
srctop_file('test', 'testrsa.pem')])),
"openssl dgst -sign [plain RSA key, PSS padding mode, no PSS restrictions]");
with({ exit_checker => sub { return shift == 1; } },
sub { ok(run(app(['openssl', 'dgst', '-sign', srctop_file('test', 'testrsa.pem'), '-sha512',
@@ -41,8 +49,18 @@ with({ exit_checker => sub { return shift == 1; } },
"openssl dgst -prverify, expect to fail gracefully");
});
ok(run(app(['openssl', 'dgst', '-prverify', srctop_file('test', 'testrsa.pem'), '-sha1',
'-sigopt', 'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:max',
'-sigopt', 'rsa_mgf1_md:sha512', '-signature', 'testrsapss.sig',
ok(run(app(['openssl', 'dgst', '-prverify', srctop_file('test', 'testrsa.pem'),
'-sha1',
'-sigopt', 'rsa_padding_mode:pss',
'-sigopt', 'rsa_pss_saltlen:max',
'-sigopt', 'rsa_mgf1_md:sha512',
'-signature', 'testrsapss-restricted.sig',
srctop_file('test', 'testrsa.pem')])),
"openssl dgst -prverify");
"openssl dgst -prverify [plain RSA key, PSS padding mode, PSS restrictions]");
ok(run(app(['openssl', 'dgst', '-prverify', srctop_file('test', 'testrsa.pem'),
'-sha1',
'-sigopt', 'rsa_padding_mode:pss',
'-signature', 'testrsapss-unrestricted.sig',
srctop_file('test', 'testrsa.pem')])),
"openssl dgst -prverify [plain RSA key, PSS padding mode, no PSS restrictions]");
+2 -2
View File
@@ -1,7 +1,7 @@
#! /usr/bin/env perl
# Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# Licensed under the Apache License 2.0 (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
+2 -2
View File
@@ -1,7 +1,7 @@
#! /usr/bin/env perl
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# Licensed under the Apache License 2.0 (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
+17 -1
View File
@@ -16,7 +16,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/;
setup("test_x509");
plan tests => 10;
plan tests => 11;
require_ok(srctop_file('test','recipes','tconversion.pl'));
@@ -68,4 +68,20 @@ subtest 'x509 -- second x.509 v3 certificate' => sub {
subtest 'x509 -- pathlen' => sub {
ok(run(test(["v3ext", srctop_file("test/certs", "pathlen.pem")])));
};
subtest 'x500 -- subjectAltName' => sub {
my $fp = srctop_file("test/certs", "fake-gp.pem");
my $out = "ext.out";
ok(run(app(["openssl", "x509", "-text", "-in", $fp, "-out", $out])));
ok(has_doctor_id($out));
unlink $out;
};
sub has_doctor_id {
$_ = shift @_;
open(DATA,$_) or return 0;
$_= join('',<DATA>);
close(DATA);
return m/2.16.528.1.1003.1.3.5.5.2-1-0000006666-Z-12345678-01.015-12345678/;
}
+2 -4
View File
@@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
@@ -7,7 +7,7 @@
# https://www.openssl.org/source/license.html
use strict;
use OpenSSL::Test qw/:DEFAULT bldtop_dir/;
use OpenSSL::Test qw/:DEFAULT/;
use OpenSSL::Test::Utils;
my $test_name = "test_afalg";
@@ -18,6 +18,4 @@ plan skip_all => "$test_name not supported for this build"
plan tests => 1;
$ENV{OPENSSL_ENGINES} = bldtop_dir("engines");
ok(run(test(["afalgtest"])), "running afalgtest");
-2
View File
@@ -80,8 +80,6 @@ plan tests =>
unless ($no_fips) {
my $infile = bldtop_file('providers', platform->dso('fips'));
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
ok(run(app(['openssl', 'fipsinstall',
'-out', bldtop_file('providers', 'fipsmodule.cnf'),
+2 -2
View File
@@ -1,7 +1,7 @@
#
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# Licensed under the Apache License 2.0 (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
+13
View File
@@ -142,6 +142,19 @@ Ctrl = digest:SHA1
Input = "0123456789ABCDEF1234"
Output = c09d402423cbf233d26cae21f954547bc43fe80fd41360a0336cfdbe9aedad05bef6fd2eaee6cd60089a52482d4809a238149520df3bdde4cb9e23d9307b05c0a6f327052325a29adf2cc95b66523be7024e2a585c3d4db15dfbe146efe0ecdc0402e33fe5d40324ee96c5c3edd374a15cdc0f5d84aa243c0f07e188c6518fbfceae158a9943be398e31097da81b62074f626eff738be6160741d5a26957a482b3251fd85d8df78b98148459de10aa93305dbb4a5230aa1da291a9b0e481918f99b7638d72bb687f97661d304ae145d64a474437a4ef39d7b8059332ddeb07e92bf6e0e3acaf8afedc93795e4511737ec1e7aab6d5bc9466afc950c1c17b48ad
# Truncated digest
Sign = RSA-2048
Availablein = default
Ctrl = digest:SHA512-224
Input = "0123456789ABCDEF123456789ABC"
Output = 5f720e9488139bb21e1c2f027fd5ce5993e6d31c5a8faaee833487b3a944d66891178868ace8070cad3ee2ffbe54aa4885a15fd1a7cc5166970fe1fd8c0423e72bd3e3b56fc4a53ed80aaaeca42497f0ec3c62113edc05cd006608f5eef7ce3ad4cba1069f68731dd28a524a1f93fcdc5547112d48d45586dd943ba0d443be9635720d8a61697c54c96627f0d85c5fbeaa3b4af86a65cf2fc3800dd5de34c046985f25d0efc0bb6edccc1d08b3a4fb9c8faffe181c7e68b31e374ad1440a4a664eec9ca0dc53a9d2f5bc7d9940d866f64201bcbc63612754df45727ea24b531d7de83d1bb707444859fa35521320c33bf6f4dbeb6fb56e653adbf7af15843f17
Verify = RSA-2048
Availablein = default
Ctrl = digest:SHA512-224
Input = "0123456789ABCDEF123456789ABC"
Output = 5f720e9488139bb21e1c2f027fd5ce5993e6d31c5a8faaee833487b3a944d66891178868ace8070cad3ee2ffbe54aa4885a15fd1a7cc5166970fe1fd8c0423e72bd3e3b56fc4a53ed80aaaeca42497f0ec3c62113edc05cd006608f5eef7ce3ad4cba1069f68731dd28a524a1f93fcdc5547112d48d45586dd943ba0d443be9635720d8a61697c54c96627f0d85c5fbeaa3b4af86a65cf2fc3800dd5de34c046985f25d0efc0bb6edccc1d08b3a4fb9c8faffe181c7e68b31e374ad1440a4a664eec9ca0dc53a9d2f5bc7d9940d866f64201bcbc63612754df45727ea24b531d7de83d1bb707444859fa35521320c33bf6f4dbeb6fb56e653adbf7af15843f17
VerifyRecover = RSA-2048
Availablein = default
Ctrl = digest:SHA1
-3
View File
@@ -24,9 +24,6 @@ my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
my @types = ( "digest", "cipher" );
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
my @setups = ();
my @testdata = (
{ config => srctop_file("test", "default.cnf"),
-1
View File
@@ -28,7 +28,6 @@ plan skip_all => "$test_name needs TLSv1.3 or TLSv1.2 enabled"
if disabled("tls1_3") && disabled("tls1_2");
$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.cnf");
use constant {
MULTIPLE_COMPRESSIONS => 0,
-1
View File
@@ -30,7 +30,6 @@ plan skip_all => "$test_name needs TLS enabled"
|| (!disabled("tls1_3") && disabled("tls1_2"));
$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.cnf");
my $proxy = TLSProxy::Proxy->new(
undef,
-1
View File
@@ -32,7 +32,6 @@ plan skip_all => "$test_name needs EC enabled"
if disabled("ec");
$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.cnf");
@handmessages = (
-2
View File
@@ -32,8 +32,6 @@ plan skip_all => "$test_name needs EC enabled"
if disabled("ec");
$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.cnf");
@handmessages = (
[TLSProxy::Message::MT_CLIENT_HELLO,
-1
View File
@@ -28,7 +28,6 @@ plan skip_all => "$test_name needs TLSv1.3 enabled"
if disabled("tls1_3");
$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.cnf");
my $proxy = TLSProxy::Proxy->new(
undef,
+1 -1
View File
@@ -11,7 +11,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file srctop_dir/;
use OpenSSL::Test::Simple;
setup("test_ct");
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.cnf");
$ENV{CT_DIR} = srctop_dir("test", "ct");
$ENV{CERTS_DIR} = srctop_dir("test", "certs");
simple_test("test_ct", "ct_test", "ct", "ec");
-3
View File
@@ -26,10 +26,7 @@ use platform;
my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
$ENV{TEST_CERTS_DIR} = srctop_dir("test", "certs");
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.cnf");
my @conf_srcs = glob(srctop_file("test", "ssl-tests", "*.cnf.in"));
map { s/;.*// } @conf_srcs if $^O eq "VMS";
-4
View File
@@ -24,10 +24,6 @@ use lib srctop_dir('Configurations');
use lib bldtop_dir('.');
use platform;
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.cnf");
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
my ($no_rsa, $no_dsa, $no_dh, $no_ec, $no_psk,
$no_ssl3, $no_tls1, $no_tls1_1, $no_tls1_2, $no_tls1_3,
+2 -2
View File
@@ -1,7 +1,7 @@
#! /usr/bin/env perl
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# Licensed under the Apache License 2.0 (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
+2
View File
@@ -10,6 +10,8 @@ setup("test_includes");
plan skip_all => "test_includes doesn't work without posix-io"
if disabled("posix-io");
delete $ENV{OPENSSL_CONF_INCLUDE};
plan tests => # The number of tests being performed
5
+ ($^O eq "VMS" ? 2 : 0);
-3
View File
@@ -30,9 +30,6 @@ plan tests =>
(undef, my $tmpfilename) = tempfile();
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
ok(run(test(["sslapitest", srctop_dir("test", "certs"),
srctop_file("test", "recipes", "90-test_sslapi_data",
"passwd.txt"), $tmpfilename, "default",
-3
View File
@@ -23,9 +23,6 @@ plan skip_all => "No TLS/SSL protocols are supported by this OpenSSL build"
plan tests => 3;
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
SKIP: {
skip "Skipping FIPS installation", 1
if disabled("fips");
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* Licensed under the Apache License 2.0 (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
+6 -2
View File
@@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
@@ -27,7 +27,11 @@ my $bldtop = $ENV{BLDTOP} || $ENV{TOP};
my $recipesdir = catdir($srctop, "test", "recipes");
my $libdir = rel2abs(catdir($srctop, "util", "perl"));
$ENV{OPENSSL_CONF} = catdir($srctop, "apps", "openssl.cnf");
$ENV{OPENSSL_CONF} = rel2abs(catdir($srctop, "apps", "openssl.cnf"));
$ENV{OPENSSL_CONF_INCLUDE} = rel2abs(catdir($bldtop, "providers"));
$ENV{OPENSSL_MODULES} = rel2abs(catdir($bldtop, "providers"));
$ENV{OPENSSL_ENGINES} = rel2abs(catdir($bldtop, "engines"));
$ENV{CTLOG_FILE} = rel2abs(catdir($srctop, "test", "ct", "log_list.cnf"));
my %tapargs =
( verbosity => $ENV{HARNESS_VERBOSE} ? 1 : 0,
+1 -4
View File
@@ -599,10 +599,7 @@ my @tests_tls_1_1 = (
);
push @tests, @tests_non_fips unless $fips_mode;
#TODO(3.0): Re-enable these PSS tests in a $no_deflt_libctx build once we have
# support for it
push @tests, @tests_pss unless $no_deflt_libctx;
push @tests, @tests_pss;
push @tests, @tests_tls_1_1 unless disabled("tls1_1") || $no_deflt_libctx;
my $server_tls_1_3;
@@ -1,7 +1,7 @@
# -*- mode: perl; -*-
# Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# Licensed under the Apache License 2.0 (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
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* Licensed under the Apache License 2.0 (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
+2
View File
@@ -19,6 +19,8 @@
#include "ssl_test_ctx.h"
#include "testutil.h"
DEFINE_STACK_OF(X509_NAME)
static CONF *conf = NULL;
static OSSL_PROVIDER *defctxnull = NULL, *thisprov = NULL;
static OPENSSL_CTX *libctx = NULL;
+4 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -20,6 +20,9 @@
# define strcasecmp _stricmp
#endif
DEFINE_STACK_OF(CONF_VALUE)
DEFINE_STACK_OF(X509_NAME)
static const int default_app_data_size = 256;
/* Default set to be as small as possible to exercise fragmentation. */
static const int default_max_fragment_size = 512;
+344 -12
View File
@@ -37,6 +37,10 @@
#include "internal/ktls.h"
#include "../ssl/ssl_local.h"
DEFINE_STACK_OF(OCSP_RESPID)
DEFINE_STACK_OF(X509)
DEFINE_STACK_OF(X509_NAME)
static OPENSSL_CTX *libctx = NULL;
static OSSL_PROVIDER *defctxnull = NULL;
@@ -655,7 +659,6 @@ end:
return testresult;
}
#endif
/*
* Very focused test to exercise a single case in the server-side state
@@ -767,6 +770,7 @@ end:
return testresult;
}
#endif
static int execute_test_large_message(const SSL_METHOD *smeth,
const SSL_METHOD *cmeth,
@@ -1477,7 +1481,7 @@ static SSL_SESSION *get_session_cb(SSL *ssl, const unsigned char *id, int len,
}
static int execute_test_session(int maxprot, int use_int_cache,
int use_ext_cache)
int use_ext_cache, long s_options)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl1 = NULL, *clientssl1 = NULL;
@@ -1520,6 +1524,10 @@ static int execute_test_session(int maxprot, int use_int_cache,
| SSL_SESS_CACHE_NO_INTERNAL_STORE);
}
if (s_options) {
SSL_CTX_set_options(sctx, s_options);
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl1, &clientssl1,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl1, clientssl1,
@@ -1764,12 +1772,12 @@ static int execute_test_session(int maxprot, int use_int_cache,
static int test_session_with_only_int_cache(void)
{
#ifndef OPENSSL_NO_TLS1_3
if (!execute_test_session(TLS1_3_VERSION, 1, 0))
if (!execute_test_session(TLS1_3_VERSION, 1, 0, 0))
return 0;
#endif
#ifndef OPENSSL_NO_TLS1_2
return execute_test_session(TLS1_2_VERSION, 1, 0);
return execute_test_session(TLS1_2_VERSION, 1, 0, 0);
#else
return 1;
#endif
@@ -1778,12 +1786,12 @@ static int test_session_with_only_int_cache(void)
static int test_session_with_only_ext_cache(void)
{
#ifndef OPENSSL_NO_TLS1_3
if (!execute_test_session(TLS1_3_VERSION, 0, 1))
if (!execute_test_session(TLS1_3_VERSION, 0, 1, 0))
return 0;
#endif
#ifndef OPENSSL_NO_TLS1_2
return execute_test_session(TLS1_2_VERSION, 0, 1);
return execute_test_session(TLS1_2_VERSION, 0, 1, 0);
#else
return 1;
#endif
@@ -1792,17 +1800,32 @@ static int test_session_with_only_ext_cache(void)
static int test_session_with_both_cache(void)
{
#ifndef OPENSSL_NO_TLS1_3
if (!execute_test_session(TLS1_3_VERSION, 1, 1))
if (!execute_test_session(TLS1_3_VERSION, 1, 1, 0))
return 0;
#endif
#ifndef OPENSSL_NO_TLS1_2
return execute_test_session(TLS1_2_VERSION, 1, 1);
return execute_test_session(TLS1_2_VERSION, 1, 1, 0);
#else
return 1;
#endif
}
static int test_session_wo_ca_names(void)
{
#ifndef OPENSSL_NO_TLS1_3
if (!execute_test_session(TLS1_3_VERSION, 1, 0, SSL_OP_DISABLE_TLSEXT_CA_NAMES))
return 0;
#endif
#ifndef OPENSSL_NO_TLS1_2
return execute_test_session(TLS1_2_VERSION, 1, 0, SSL_OP_DISABLE_TLSEXT_CA_NAMES);
#else
return 1;
#endif
}
#ifndef OPENSSL_NO_TLS1_3
static SSL_SESSION *sesscache[6];
static int do_cache;
@@ -2089,6 +2112,148 @@ static int test_psk_tickets(void)
return testresult;
}
static int test_extra_tickets(int idx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
BIO *bretry = BIO_new(bio_s_always_retry());
BIO *tmp = NULL;
int testresult = 0;
int stateful = 0;
size_t nbytes;
unsigned char c, buf[1];
new_called = 0;
do_cache = 1;
if (idx >= 3) {
idx -= 3;
stateful = 1;
}
if (!TEST_ptr(bretry) || !setup_ticket_test(stateful, idx, &sctx, &cctx))
goto end;
SSL_CTX_sess_set_new_cb(sctx, new_session_cb);
/* setup_ticket_test() uses new_cachesession_cb which we don't need. */
SSL_CTX_sess_set_new_cb(cctx, new_session_cb);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
/*
* Note that we have new_session_cb on both sctx and cctx, so new_called is
* incremented by both client and server.
*/
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
/* Check we got the number of tickets we were expecting */
|| !TEST_int_eq(idx * 2, new_called)
|| !TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_int_eq(idx * 2, new_called))
goto end;
/* Now try a (real) write to actually send the tickets */
c = '1';
if (!TEST_true(SSL_write_ex(serverssl, &c, 1, &nbytes))
|| !TEST_size_t_eq(1, nbytes)
|| !TEST_int_eq(idx * 2 + 2, new_called)
|| !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes))
|| !TEST_int_eq(idx * 2 + 4, new_called)
|| !TEST_int_eq(sizeof(buf), nbytes)
|| !TEST_int_eq(c, buf[0])
|| !TEST_false(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes)))
goto end;
/* Try with only requesting one new ticket, too */
c = '2';
new_called = 0;
if (!TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_true(SSL_write_ex(serverssl, &c, sizeof(c), &nbytes))
|| !TEST_size_t_eq(sizeof(c), nbytes)
|| !TEST_int_eq(1, new_called)
|| !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes))
|| !TEST_int_eq(2, new_called)
|| !TEST_size_t_eq(sizeof(buf), nbytes)
|| !TEST_int_eq(c, buf[0]))
goto end;
/* Do it again but use dummy writes to drive the ticket generation */
c = '3';
new_called = 0;
if (!TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_true(SSL_write_ex(serverssl, &c, 0, &nbytes))
|| !TEST_size_t_eq(0, nbytes)
|| !TEST_int_eq(2, new_called)
|| !TEST_false(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes))
|| !TEST_int_eq(4, new_called))
goto end;
/*
* Use the always-retry BIO to exercise the logic that forces ticket
* generation to wait until a record boundary.
*/
c = '4';
new_called = 0;
tmp = SSL_get_wbio(serverssl);
if (!TEST_ptr(tmp) || !TEST_true(BIO_up_ref(tmp))) {
tmp = NULL;
goto end;
}
SSL_set0_wbio(serverssl, bretry);
bretry = NULL;
if (!TEST_false(SSL_write_ex(serverssl, &c, 1, &nbytes))
|| !TEST_int_eq(SSL_get_error(serverssl, 0), SSL_ERROR_WANT_WRITE)
|| !TEST_size_t_eq(nbytes, 0))
goto end;
/* Restore a BIO that will let the write succeed */
SSL_set0_wbio(serverssl, tmp);
tmp = NULL;
/* These calls should just queue the request and not send anything. */
if (!TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_int_eq(0, new_called))
goto end;
/* Re-do the write; still no tickets sent */
if (!TEST_true(SSL_write_ex(serverssl, &c, 1, &nbytes))
|| !TEST_size_t_eq(1, nbytes)
|| !TEST_int_eq(0, new_called)
|| !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes))
|| !TEST_int_eq(0, new_called)
|| !TEST_int_eq(sizeof(buf), nbytes)
|| !TEST_int_eq(c, buf[0])
|| !TEST_false(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes)))
goto end;
/* Now the *next* write should send the tickets */
c = '5';
if (!TEST_true(SSL_write_ex(serverssl, &c, 1, &nbytes))
|| !TEST_size_t_eq(1, nbytes)
|| !TEST_int_eq(2, new_called)
|| !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes))
|| !TEST_int_eq(4, new_called)
|| !TEST_int_eq(sizeof(buf), nbytes)
|| !TEST_int_eq(c, buf[0])
|| !TEST_false(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes)))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
testresult = 1;
end:
BIO_free(bretry);
BIO_free(tmp);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
clientssl = serverssl = NULL;
sctx = cctx = NULL;
return testresult;
}
#endif
#define USE_NULL 0
@@ -2590,8 +2755,11 @@ static unsigned int psk_server_cb(SSL *ssl, const char *identity,
#define MSG6 "test"
#define MSG7 "message."
#define TLS13_AES_256_GCM_SHA384_BYTES ((const unsigned char *)"\x13\x02")
#define TLS13_AES_128_GCM_SHA256_BYTES ((const unsigned char *)"\x13\x01")
#define TLS13_AES_256_GCM_SHA384_BYTES ((const unsigned char *)"\x13\x02")
#define TLS13_CHACHA20_POLY1305_SHA256_BYTES ((const unsigned char *)"\x13\x03")
#define TLS13_AES_128_CCM_SHA256_BYTES ((const unsigned char *)"\x13\x04")
#define TLS13_AES_128_CCM_8_SHA256_BYTES ((const unsigned char *)"\x13\05")
static SSL_SESSION *create_a_psk(SSL *ssl)
@@ -3524,6 +3692,113 @@ static int test_early_data_psk(int idx)
return testresult;
}
/*
* Test TLSv1.3 PSK can be used to send early_data with all 5 ciphersuites
* idx == 0: Test with TLS1_3_RFC_AES_128_GCM_SHA256
* idx == 1: Test with TLS1_3_RFC_AES_256_GCM_SHA384
* idx == 2: Test with TLS1_3_RFC_CHACHA20_POLY1305_SHA256,
* idx == 3: Test with TLS1_3_RFC_AES_128_CCM_SHA256
* idx == 4: Test with TLS1_3_RFC_AES_128_CCM_8_SHA256
*/
static int test_early_data_psk_with_all_ciphers(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
SSL_SESSION *sess = NULL;
unsigned char buf[20];
size_t readbytes, written;
const SSL_CIPHER *cipher;
const char *cipher_str[] = {
TLS1_3_RFC_AES_128_GCM_SHA256,
TLS1_3_RFC_AES_256_GCM_SHA384,
# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
TLS1_3_RFC_CHACHA20_POLY1305_SHA256,
# else
NULL,
# endif
TLS1_3_RFC_AES_128_CCM_SHA256,
TLS1_3_RFC_AES_128_CCM_8_SHA256
};
const unsigned char *cipher_bytes[] = {
TLS13_AES_128_GCM_SHA256_BYTES,
TLS13_AES_256_GCM_SHA384_BYTES,
# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
TLS13_CHACHA20_POLY1305_SHA256_BYTES,
# else
NULL,
# endif
TLS13_AES_128_CCM_SHA256_BYTES,
TLS13_AES_128_CCM_8_SHA256_BYTES
};
if (cipher_str[idx] == NULL)
return 1;
/* Skip ChaCha20Poly1305 as currently FIPS module does not support it */
if (idx == 2 && is_fips == 1)
return 1;
/* We always set this up with a final parameter of "2" for PSK */
if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
&serverssl, &sess, 2)))
goto end;
if (!TEST_true(SSL_set_ciphersuites(clientssl, cipher_str[idx]))
|| !TEST_true(SSL_set_ciphersuites(serverssl, cipher_str[idx])))
goto end;
/*
* 'setupearly_data_test' creates only one instance of SSL_SESSION
* and assigns to both client and server with incremented reference
* and the same instance is updated in 'sess'.
* So updating ciphersuite in 'sess' which will get reflected in
* PSK handshake using psk use sess and find sess cb.
*/
cipher = SSL_CIPHER_find(clientssl, cipher_bytes[idx]);
if (!TEST_ptr(cipher) || !TEST_true(SSL_SESSION_set_cipher(sess, cipher)))
goto end;
SSL_set_connect_state(clientssl);
if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
&written)))
goto end;
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_SUCCESS)
|| !TEST_mem_eq(buf, readbytes, MSG1, strlen(MSG1))
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_ACCEPTED)
|| !TEST_int_eq(SSL_connect(clientssl), 1)
|| !TEST_int_eq(SSL_accept(serverssl), 1))
goto end;
/* Send some normal data from client to server */
if (!TEST_true(SSL_write_ex(clientssl, MSG2, strlen(MSG2), &written))
|| !TEST_size_t_eq(written, strlen(MSG2)))
goto end;
if (!TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))
|| !TEST_mem_eq(buf, readbytes, MSG2, strlen(MSG2)))
goto end;
testresult = 1;
end:
SSL_SESSION_free(sess);
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
if (clientssl != NULL)
SSL_shutdown(clientssl);
if (serverssl != NULL)
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test that a server that doesn't try to read early data can handle a
* client sending some.
@@ -5518,6 +5793,8 @@ static int test_pha_key_update(void)
static SRP_VBASE *vbase = NULL;
DEFINE_STACK_OF(SRP_user_pwd)
static int ssl_srp_cb(SSL *s, int *ad, void *arg)
{
int ret = SSL3_AL_FATAL;
@@ -6060,6 +6337,7 @@ static struct {
const char *srvrciphers;
const char *srvrtls13ciphers;
const char *shared;
const char *fipsshared;
} shared_ciphers_data[] = {
/*
* We can't establish a connection (even in TLSv1.1) with these ciphersuites if
@@ -6072,14 +6350,29 @@ static struct {
NULL,
"AES256-SHA:DHE-RSA-AES128-SHA",
NULL,
"AES256-SHA",
"AES256-SHA"
},
# if !defined(OPENSSL_NO_CHACHA) \
&& !defined(OPENSSL_NO_POLY1305) \
&& !defined(OPENSSL_NO_EC)
{
TLS1_2_VERSION,
"AES128-SHA:ECDHE-RSA-CHACHA20-POLY1305",
NULL,
"AES128-SHA:ECDHE-RSA-CHACHA20-POLY1305",
NULL,
"AES128-SHA:ECDHE-RSA-CHACHA20-POLY1305",
"AES128-SHA"
},
# endif
{
TLS1_2_VERSION,
"AES128-SHA:DHE-RSA-AES128-SHA:AES256-SHA",
NULL,
"AES128-SHA:DHE-RSA-AES256-SHA:AES256-SHA",
NULL,
"AES128-SHA:AES256-SHA",
"AES128-SHA:AES256-SHA"
},
{
@@ -6088,6 +6381,7 @@ static struct {
NULL,
"AES128-SHA:DHE-RSA-AES128-SHA",
NULL,
"AES128-SHA",
"AES128-SHA"
},
#endif
@@ -6104,7 +6398,8 @@ static struct {
"AES256-SHA:AES128-SHA256",
NULL,
"TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:"
"TLS_AES_128_GCM_SHA256:AES256-SHA"
"TLS_AES_128_GCM_SHA256:AES256-SHA",
"TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:AES256-SHA"
},
#endif
#ifndef OPENSSL_NO_TLS1_3
@@ -6114,17 +6409,39 @@ static struct {
"TLS_AES_256_GCM_SHA384",
"AES256-SHA",
"TLS_AES_256_GCM_SHA384",
"TLS_AES_256_GCM_SHA384",
"TLS_AES_256_GCM_SHA384"
},
#endif
};
static int test_ssl_get_shared_ciphers(int tst)
static int int_test_ssl_get_shared_ciphers(int tst, int clnt)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char buf[1024];
OPENSSL_CTX *tmplibctx = OPENSSL_CTX_new();
if (!TEST_ptr(tmplibctx))
goto end;
/*
* Regardless of whether we're testing with the FIPS provider loaded into
* libctx, we want one peer to always use the full set of ciphersuites
* available. Therefore we use a separate libctx with the default provider
* loaded into it. We run the same tests twice - once with the client side
* having the full set of ciphersuites and once with the server side.
*/
if (clnt) {
cctx = SSL_CTX_new_with_libctx(tmplibctx, NULL, TLS_client_method());
if (!TEST_ptr(cctx))
goto end;
} else {
sctx = SSL_CTX_new_with_libctx(tmplibctx, NULL, TLS_server_method());
if (!TEST_ptr(sctx))
goto end;
}
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
@@ -6153,7 +6470,11 @@ static int test_ssl_get_shared_ciphers(int tst)
goto end;
if (!TEST_ptr(SSL_get_shared_ciphers(serverssl, buf, sizeof(buf)))
|| !TEST_int_eq(strcmp(buf, shared_ciphers_data[tst].shared), 0)) {
|| !TEST_int_eq(strcmp(buf,
is_fips
? shared_ciphers_data[tst].fipsshared
: shared_ciphers_data[tst].shared),
0)) {
TEST_info("Shared ciphers are: %s\n", buf);
goto end;
}
@@ -6165,10 +6486,18 @@ static int test_ssl_get_shared_ciphers(int tst)
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
OPENSSL_CTX_free(tmplibctx);
return testresult;
}
static int test_ssl_get_shared_ciphers(int tst)
{
return int_test_ssl_get_shared_ciphers(tst, 0)
&& int_test_ssl_get_shared_ciphers(tst, 1);
}
static const char *appdata = "Hello World";
static int gen_tick_called, dec_tick_called, tick_key_cb_called;
static int tick_key_renew = 0;
@@ -7385,10 +7714,12 @@ int setup_tests(void)
ADD_TEST(test_session_with_only_int_cache);
ADD_TEST(test_session_with_only_ext_cache);
ADD_TEST(test_session_with_both_cache);
ADD_TEST(test_session_wo_ca_names);
#ifndef OPENSSL_NO_TLS1_3
ADD_ALL_TESTS(test_stateful_tickets, 3);
ADD_ALL_TESTS(test_stateless_tickets, 3);
ADD_TEST(test_psk_tickets);
ADD_ALL_TESTS(test_extra_tickets, 6);
#endif
ADD_ALL_TESTS(test_ssl_set_bio, TOTAL_SSL_SET_BIO_TESTS);
ADD_TEST(test_ssl_bio_pop_next_bio);
@@ -7420,6 +7751,7 @@ int setup_tests(void)
ADD_ALL_TESTS(test_early_data_skip_abort, 3);
ADD_ALL_TESTS(test_early_data_not_sent, 3);
ADD_ALL_TESTS(test_early_data_psk, 8);
ADD_ALL_TESTS(test_early_data_psk_with_all_ciphers, 5);
ADD_ALL_TESTS(test_early_data_not_expected, 3);
# ifndef OPENSSL_NO_TLS1_2
ADD_ALL_TESTS(test_early_data_tls1_2, 3);
+2
View File
@@ -11,6 +11,8 @@
#include "ssltestlib.h"
#include "testutil.h"
DEFINE_STACK_OF(SSL_CIPHER)
static int docorrupt = 0;
static void copy_flags(BIO *bio)
+3
View File
@@ -81,6 +81,9 @@
# include <unistd.h>
#endif
DEFINE_STACK_OF(SSL_COMP)
DEFINE_STACK_OF_STRING()
static SSL_CTX *s_ctx = NULL;
static SSL_CTX *s_ctx2 = NULL;
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* Licensed under the Apache License 2.0 (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
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* Licensed under the Apache License 2.0 (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
+3 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2012-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -19,6 +19,8 @@
# define strcasecmp _stricmp
#endif
DEFINE_STACK_OF(GENERAL_NAME)
static const char *const names[] = {
"a", "b", ".", "*", "@",
".a", "a.", ".b", "b.", ".*", "*.", "*@", "@*", "a@", "@a", "b@", "..",
+2
View File
@@ -16,6 +16,8 @@
#include <openssl/err.h>
#include "testutil.h"
DEFINE_STACK_OF(X509)
static const char *roots_f;
static const char *untrusted_f;
static const char *bad_f;
+9
View File
@@ -360,6 +360,8 @@ static int test_WPACKET_init_der(void)
unsigned char testdata[] = { 0x00, 0x01, 0x02, 0x03 };
unsigned char testdata2[259] = { 0x82, 0x01, 0x00 };
size_t written[2];
size_t size1, size2;
int flags = WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH;
int i;
/* Test initialising for writing DER */
@@ -370,6 +372,13 @@ static int test_WPACKET_init_der(void)
|| !TEST_true(WPACKET_memcpy(&pkt, testdata, sizeof(testdata)))
|| !TEST_true(WPACKET_close(&pkt))
|| !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xfc))
/* this sub-packet is empty, and should render zero bytes */
|| (!TEST_true(WPACKET_start_sub_packet(&pkt))
|| !TEST_true(WPACKET_set_flags(&pkt, flags))
|| !TEST_true(WPACKET_get_total_written(&pkt, &size1))
|| !TEST_true(WPACKET_close(&pkt))
|| !TEST_true(WPACKET_get_total_written(&pkt, &size2))
|| !TEST_size_t_eq(size1, size2))
|| !TEST_true(WPACKET_finish(&pkt))
|| !TEST_true(WPACKET_get_total_written(&pkt, &written[0]))
|| !TEST_mem_eq(WPACKET_get_curr(&pkt), written[0], simpleder,