Latest update

This commit is contained in:
2019-05-28 23:10:56 +09:00
parent 64d458de91
commit 9a23f88dc2
49 changed files with 24989 additions and 223 deletions
+5 -1
View File
@@ -50,7 +50,7 @@ IF[{- !$disabled{tests} -}]
time_offset_test pemtest ssl_cert_table_internal_test ciphername_test \
servername_test ocspapitest rsa_mp_test fatalerrtest tls13ccstest \
sysdefaulttest errtest gosttest \
context_internal_test aesgcmtest params_test
context_internal_test aesgcmtest params_test evp_pkey_dparams_test
SOURCE[versions]=versions.c
INCLUDE[versions]=../include ../apps/include
@@ -350,6 +350,10 @@ IF[{- !$disabled{tests} -}]
INCLUDE[evp_kdf_test]=../include ../apps/include
DEPEND[evp_kdf_test]=../libcrypto libtestutil.a
SOURCE[evp_pkey_dparams_test]=evp_pkey_dparams_test.c
INCLUDE[evp_pkey_dparams_test]=../include ../apps/include
DEPEND[evp_pkey_dparams_test]=../libcrypto libtestutil.a
SOURCE[x509_time_test]=x509_time_test.c
INCLUDE[x509_time_test]=../include ../apps/include
DEPEND[x509_time_test]=../libcrypto libtestutil.a
+73
View File
@@ -0,0 +1,73 @@
/*
* Copyright 2019 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
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "internal/nelem.h"
#include <openssl/crypto.h>
#include <openssl/bio.h>
#include <openssl/bn.h>
#include <openssl/rand.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/ec.h>
#include "testutil.h"
static int pkey_param_types[] = {
#ifndef OPENSSL_NO_DH
EVP_PKEY_DH,
#endif
#ifndef OPENSSL_NO_DSA
EVP_PKEY_DSA,
#endif
#ifndef OPENSSL_NO_EC
EVP_PKEY_EC
#endif
};
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_EC)
static int params_bio_test(int id)
{
int ret;
BIO *mem_bio = NULL;
EVP_PKEY_CTX *ctx = NULL;
EVP_PKEY *params_key = NULL, *out_key = NULL;
int type = pkey_param_types[id];
ret =
TEST_ptr(mem_bio = BIO_new(BIO_s_mem()))
&& TEST_ptr(ctx = EVP_PKEY_CTX_new_id(type, NULL))
&& TEST_int_gt(EVP_PKEY_paramgen_init(ctx), 0)
&& (type != EVP_PKEY_EC
|| EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, NID_secp256k1) > 0)
&& TEST_int_gt(EVP_PKEY_paramgen(ctx, &params_key), 0)
&& TEST_int_gt(i2d_KeyParams_bio(mem_bio, params_key), 0)
&& TEST_ptr(d2i_KeyParams_bio(type, &out_key, mem_bio))
&& TEST_int_gt(EVP_PKEY_cmp_parameters(out_key, params_key), 0);
BIO_free(mem_bio);
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(params_key);
EVP_PKEY_free(out_key);
return ret;
}
#endif
int setup_tests(void)
{
#if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC)
TEST_note("No DH/DSA/EC support");
#else
ADD_ALL_TESTS(params_bio_test, OSSL_NELEM(pkey_param_types));
#endif
return 1;
}
+81 -1
View File
@@ -47,6 +47,24 @@ static int get_cert_and_key(X509 **cert_out, EVP_PKEY **key_out)
return 0;
}
static int get_cert(X509 **cert_out)
{
BIO *certbio;
X509 *cert = NULL;
if (!TEST_ptr(certbio = BIO_new_file(certstr, "r")))
return 0;
cert = PEM_read_bio_X509(certbio, NULL, NULL, NULL);
BIO_free(certbio);
if (!TEST_ptr(cert))
goto end;
*cert_out = cert;
return 1;
end:
X509_free(cert);
return 0;
}
static OCSP_BASICRESP *make_dummy_resp(void)
{
const unsigned char namestr[] = "openssl.example.com";
@@ -131,7 +149,67 @@ static int test_resp_signer(void)
EVP_PKEY_free(key);
return ret;
}
#endif
static int test_access_description(int testcase)
{
ACCESS_DESCRIPTION *ad = ACCESS_DESCRIPTION_new();
int ret = 0;
if (!TEST_ptr(ad))
goto err;
switch (testcase) {
case 0: /* no change */
break;
case 1: /* check and release current location */
if (!TEST_ptr(ad->location))
goto err;
GENERAL_NAME_free(ad->location);
ad->location = NULL;
break;
case 2: /* replace current location */
GENERAL_NAME_free(ad->location);
ad->location = GENERAL_NAME_new();
if (!TEST_ptr(ad->location))
goto err;
break;
}
ACCESS_DESCRIPTION_free(ad);
ret = 1;
err:
return ret;
}
static int test_ocsp_url_svcloc_new(void)
{
static const char * urls[] = {
"www.openssl.org",
"www.openssl.net",
NULL
};
X509 *issuer = NULL;
X509_EXTENSION * ext = NULL;
int ret = 0;
if (!TEST_true(get_cert(&issuer)))
goto err;
/*
* Test calling this ocsp method to catch any memory leak
*/
ext = OCSP_url_svcloc_new(X509_get_issuer_name(issuer), urls);
if (!TEST_ptr(ext))
goto err;
X509_EXTENSION_free(ext);
ret = 1;
err:
X509_free(issuer);
return ret;
}
#endif /* OPENSSL_NO_OCSP */
OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
@@ -142,6 +220,8 @@ int setup_tests(void)
return 0;
#ifndef OPENSSL_NO_OCSP
ADD_TEST(test_resp_signer);
ADD_ALL_TESTS(test_access_description, 3);
ADD_TEST(test_ocsp_url_svcloc_new);
#endif
return 1;
}
+1 -1
View File
@@ -16,7 +16,7 @@ setup("test_evp");
my @files = ( "evpciph.txt", "evpdigest.txt", "evpencod.txt", "evpkdf.txt",
"evppkey_kdf.txt", "evpmac.txt", "evppbe.txt", "evppkey.txt",
"evppkey_ecc.txt", "evpcase.txt", "evpaessiv.txt" );
"evppkey_ecc.txt", "evpcase.txt", "evpaessiv.txt", "evpccmcavs.txt" );
plan tests => scalar(@files);
File diff suppressed because it is too large Load Diff
+11
View File
@@ -0,0 +1,11 @@
#! /usr/bin/env perl
# Copyright 2019 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
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
use OpenSSL::Test::Simple;
simple_test("test_evp_pkey_dparam", "evp_pkey_dparams_test");