file_path
stringlengths 19
75
| code
stringlengths 279
1.37M
|
---|---|
./openssl/test/quic_client_test.c | /*
* Copyright 2023 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 <openssl/ssl.h>
#include <openssl/quic.h>
#include <openssl/bio.h>
#include "internal/common.h"
#include "internal/sockets.h"
#include "internal/time.h"
#include "testutil.h"
static const char msg1[] = "GET LICENSE.txt\r\n";
static char msg2[16000];
static int is_want(SSL *s, int ret)
{
int ec = SSL_get_error(s, ret);
return ec == SSL_ERROR_WANT_READ || ec == SSL_ERROR_WANT_WRITE;
}
static int test_quic_client(void)
{
int testresult = 0, ret;
int c_fd = INVALID_SOCKET;
BIO *c_net_bio = NULL, *c_net_bio_own = NULL;
BIO_ADDR *s_addr_ = NULL;
struct in_addr ina = {0};
SSL_CTX *c_ctx = NULL;
SSL *c_ssl = NULL;
short port = 4433;
int c_connected = 0, c_write_done = 0, c_shutdown = 0;
size_t l = 0, c_total_read = 0;
OSSL_TIME start_time;
unsigned char alpn[] = { 8, 'h', 't', 't', 'p', '/', '0', '.', '9' };
ina.s_addr = htonl(0x7f000001UL);
/* Setup test client. */
c_fd = BIO_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0);
if (!TEST_int_ne(c_fd, INVALID_SOCKET))
goto err;
if (!TEST_true(BIO_socket_nbio(c_fd, 1)))
goto err;
if (!TEST_ptr(s_addr_ = BIO_ADDR_new()))
goto err;
if (!TEST_true(BIO_ADDR_rawmake(s_addr_, AF_INET, &ina, sizeof(ina),
htons(port))))
goto err;
if (!TEST_ptr(c_net_bio = c_net_bio_own = BIO_new_dgram(c_fd, 0)))
goto err;
if (!BIO_dgram_set_peer(c_net_bio, s_addr_))
goto err;
if (!TEST_ptr(c_ctx = SSL_CTX_new(OSSL_QUIC_client_method())))
goto err;
if (!TEST_ptr(c_ssl = SSL_new(c_ctx)))
goto err;
/* 0 is a success for SSL_set_alpn_protos() */
if (!TEST_false(SSL_set_alpn_protos(c_ssl, alpn, sizeof(alpn))))
goto err;
/* Takes ownership of our reference to the BIO. */
SSL_set0_rbio(c_ssl, c_net_bio);
/* Get another reference to be transferred in the SSL_set0_wbio call. */
if (!TEST_true(BIO_up_ref(c_net_bio))) {
c_net_bio_own = NULL; /* SSL_free will free the first reference. */
goto err;
}
SSL_set0_wbio(c_ssl, c_net_bio);
c_net_bio_own = NULL;
if (!TEST_true(SSL_set_blocking_mode(c_ssl, 0)))
goto err;
start_time = ossl_time_now();
for (;;) {
if (ossl_time_compare(ossl_time_subtract(ossl_time_now(), start_time),
ossl_ms2time(10000)) >= 0) {
TEST_error("timeout while attempting QUIC client test");
goto err;
}
if (!c_connected) {
ret = SSL_connect(c_ssl);
if (!TEST_true(ret == 1 || is_want(c_ssl, ret)))
goto err;
if (ret == 1) {
c_connected = 1;
TEST_info("Connected!");
}
}
if (c_connected && !c_write_done) {
if (!TEST_int_eq(SSL_write(c_ssl, msg1, sizeof(msg1) - 1),
(int)sizeof(msg1) - 1))
goto err;
if (!TEST_true(SSL_stream_conclude(c_ssl, 0)))
goto err;
c_write_done = 1;
}
if (c_write_done && !c_shutdown && c_total_read < sizeof(msg2) - 1) {
ret = SSL_read_ex(c_ssl, msg2 + c_total_read,
sizeof(msg2) - 1 - c_total_read, &l);
if (ret != 1) {
if (SSL_get_error(c_ssl, ret) == SSL_ERROR_ZERO_RETURN) {
c_shutdown = 1;
TEST_info("Message: \n%s\n", msg2);
} else if (!TEST_true(is_want(c_ssl, ret))) {
goto err;
}
} else {
c_total_read += l;
if (!TEST_size_t_lt(c_total_read, sizeof(msg2) - 1))
goto err;
}
}
if (c_shutdown) {
ret = SSL_shutdown(c_ssl);
if (ret == 1)
break;
}
/*
* This is inefficient because we spin until things work without
* blocking but this is just a test.
*/
OSSL_sleep(0);
SSL_handle_events(c_ssl);
}
testresult = 1;
err:
SSL_free(c_ssl);
SSL_CTX_free(c_ctx);
BIO_ADDR_free(s_addr_);
BIO_free(c_net_bio_own);
if (c_fd != INVALID_SOCKET)
BIO_closesocket(c_fd);
return testresult;
}
OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
ADD_TEST(test_quic_client);
return 1;
}
|
./openssl/test/casttest.c | /*
* Copyright 1995-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
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
/*
* CAST low level APIs are deprecated for public use, but still ok for
* internal use.
*/
#include "internal/deprecated.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_CAST is defined */
#include "internal/nelem.h"
#include "testutil.h"
#ifndef OPENSSL_NO_CAST
# include <openssl/cast.h>
static unsigned char k[16] = {
0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A
};
static unsigned char in[8] =
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
static int k_len[3] = { 16, 10, 5 };
static unsigned char c[3][8] = {
{0x23, 0x8B, 0x4F, 0xE5, 0x84, 0x7E, 0x44, 0xB2},
{0xEB, 0x6A, 0x71, 0x1A, 0x2C, 0x02, 0x27, 0x1B},
{0x7A, 0xC8, 0x16, 0xD1, 0x6E, 0x9B, 0x30, 0x2E},
};
static unsigned char in_a[16] = {
0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A
};
static unsigned char in_b[16] = {
0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A
};
static unsigned char c_a[16] = {
0xEE, 0xA9, 0xD0, 0xA2, 0x49, 0xFD, 0x3B, 0xA6,
0xB3, 0x43, 0x6F, 0xB8, 0x9D, 0x6D, 0xCA, 0x92
};
static unsigned char c_b[16] = {
0xB2, 0xC9, 0x5E, 0xB0, 0x0C, 0x31, 0xAD, 0x71,
0x80, 0xAC, 0x05, 0xB8, 0xE8, 0x3D, 0x69, 0x6E
};
static int cast_test_vector(int z)
{
int testresult = 1;
CAST_KEY key;
unsigned char out[80];
CAST_set_key(&key, k_len[z], k);
CAST_ecb_encrypt(in, out, &key, CAST_ENCRYPT);
if (!TEST_mem_eq(out, sizeof(c[z]), c[z], sizeof(c[z]))) {
TEST_info("CAST_ENCRYPT iteration %d failed (len=%d)", z, k_len[z]);
testresult = 0;
}
CAST_ecb_encrypt(out, out, &key, CAST_DECRYPT);
if (!TEST_mem_eq(out, sizeof(in), in, sizeof(in))) {
TEST_info("CAST_DECRYPT iteration %d failed (len=%d)", z, k_len[z]);
testresult = 0;
}
return testresult;
}
static int cast_test_iterations(void)
{
long l;
int testresult = 1;
CAST_KEY key, key_b;
unsigned char out_a[16], out_b[16];
memcpy(out_a, in_a, sizeof(in_a));
memcpy(out_b, in_b, sizeof(in_b));
for (l = 0; l < 1000000L; l++) {
CAST_set_key(&key_b, 16, out_b);
CAST_ecb_encrypt(&(out_a[0]), &(out_a[0]), &key_b, CAST_ENCRYPT);
CAST_ecb_encrypt(&(out_a[8]), &(out_a[8]), &key_b, CAST_ENCRYPT);
CAST_set_key(&key, 16, out_a);
CAST_ecb_encrypt(&(out_b[0]), &(out_b[0]), &key, CAST_ENCRYPT);
CAST_ecb_encrypt(&(out_b[8]), &(out_b[8]), &key, CAST_ENCRYPT);
}
if (!TEST_mem_eq(out_a, sizeof(c_a), c_a, sizeof(c_a))
|| !TEST_mem_eq(out_b, sizeof(c_b), c_b, sizeof(c_b)))
testresult = 0;
return testresult;
}
#endif
int setup_tests(void)
{
#ifndef OPENSSL_NO_CAST
ADD_ALL_TESTS(cast_test_vector, OSSL_NELEM(k_len));
ADD_TEST(cast_test_iterations);
#endif
return 1;
}
|
./openssl/test/asn1_encode_test.c | /*
* Copyright 2017-2021 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 <string.h>
#include <openssl/rand.h>
#include <openssl/asn1t.h>
#include "internal/numbers.h"
#include "testutil.h"
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wunused-function"
# pragma GCC diagnostic ignored "-Wformat"
#endif
#ifdef __clang__
# pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic ignored "-Wformat"
#endif
/***** Custom test data ******************************************************/
/*
* We conduct tests with these arrays for every type we try out.
* You will find the expected results together with the test structures
* for each type, further down.
*/
static unsigned char t_zero[] = {
0x00
};
static unsigned char t_one[] = {
0x01
};
static unsigned char t_one_neg[] = {
0xff
};
static unsigned char t_minus_256[] = {
0xff, 0x00
};
static unsigned char t_longundef[] = {
0x7f, 0xff, 0xff, 0xff
};
static unsigned char t_9bytes_1[] = {
0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
static unsigned char t_8bytes_1[] = {
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static unsigned char t_8bytes_2[] = {
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
static unsigned char t_8bytes_3_pad[] = {
0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
static unsigned char t_8bytes_4_neg[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static unsigned char t_8bytes_5_negpad[] = {
0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* 32-bit long */
static unsigned char t_5bytes_1[] = {
0x01, 0xff, 0xff, 0xff, 0xff
};
static unsigned char t_4bytes_1[] = {
0x00, 0x80, 0x00, 0x00, 0x00
};
/* We make the last byte 0xfe to avoid a clash with ASN1_LONG_UNDEF */
static unsigned char t_4bytes_2[] = {
0x7f, 0xff, 0xff, 0xfe
};
static unsigned char t_4bytes_3_pad[] = {
0x00, 0x7f, 0xff, 0xff, 0xfe
};
static unsigned char t_4bytes_4_neg[] = {
0x80, 0x00, 0x00, 0x00
};
static unsigned char t_4bytes_5_negpad[] = {
0xff, 0x80, 0x00, 0x00, 0x00
};
typedef struct {
unsigned char *bytes1;
size_t nbytes1;
unsigned char *bytes2;
size_t nbytes2;
} TEST_CUSTOM_DATA;
#define CUSTOM_DATA(v) \
{ v, sizeof(v), t_one, sizeof(t_one) }, \
{ t_one, sizeof(t_one), v, sizeof(v) }
static TEST_CUSTOM_DATA test_custom_data[] = {
CUSTOM_DATA(t_zero),
CUSTOM_DATA(t_longundef),
CUSTOM_DATA(t_one),
CUSTOM_DATA(t_one_neg),
CUSTOM_DATA(t_minus_256),
CUSTOM_DATA(t_9bytes_1),
CUSTOM_DATA(t_8bytes_1),
CUSTOM_DATA(t_8bytes_2),
CUSTOM_DATA(t_8bytes_3_pad),
CUSTOM_DATA(t_8bytes_4_neg),
CUSTOM_DATA(t_8bytes_5_negpad),
CUSTOM_DATA(t_5bytes_1),
CUSTOM_DATA(t_4bytes_1),
CUSTOM_DATA(t_4bytes_2),
CUSTOM_DATA(t_4bytes_3_pad),
CUSTOM_DATA(t_4bytes_4_neg),
CUSTOM_DATA(t_4bytes_5_negpad),
};
/***** Type specific test data ***********************************************/
/*
* First, a few utility things that all type specific data can use, or in some
* cases, MUST use.
*/
/*
* For easy creation of arrays of expected data. These macros correspond to
* the uses of CUSTOM_DATA above.
*/
#define CUSTOM_EXPECTED_SUCCESS(num, znum) \
{ 0xff, num, 1 }, \
{ 0xff, 1, znum }
#define CUSTOM_EXPECTED_FAILURE \
{ 0, 0, 0 }, \
{ 0, 0, 0 }
/*
* A structure to collect all test information in. There MUST be one instance
* of this for each test
*/
typedef int i2d_fn(void *a, unsigned char **pp);
typedef void *d2i_fn(void **a, unsigned char **pp, long length);
typedef void ifree_fn(void *a);
typedef struct {
ASN1_ITEM_EXP *asn1_type;
const char *name;
int skip; /* 1 if this package should be skipped */
/* An array of structures to compare decoded custom data with */
void *encode_expectations;
size_t encode_expectations_size;
size_t encode_expectations_elem_size;
/*
* An array of structures that are encoded into a DER blob, which is
* then decoded, and result gets compared with the original.
*/
void *encdec_data;
size_t encdec_data_size;
size_t encdec_data_elem_size;
/* The i2d function to use with this type */
i2d_fn *i2d;
/* The d2i function to use with this type */
d2i_fn *d2i;
/* Function to free a decoded structure */
ifree_fn *ifree;
} TEST_PACKAGE;
/* To facilitate the creation of an encdec_data array */
#define ENCDEC_DATA(num, znum) \
{ 0xff, num, 1 }, { 0xff, 1, znum }
#define ENCDEC_ARRAY(max, zmax, min, zmin) \
ENCDEC_DATA(max,zmax), \
ENCDEC_DATA(min,zmin), \
ENCDEC_DATA(1, 1), \
ENCDEC_DATA(-1, -1), \
ENCDEC_DATA(0, ASN1_LONG_UNDEF)
#ifndef OPENSSL_NO_DEPRECATED_3_0
/***** LONG ******************************************************************/
typedef struct {
/* If decoding is expected to succeed, set this to 1, otherwise 0 */
ASN1_BOOLEAN success;
long test_long;
long test_zlong;
} ASN1_LONG_DATA;
ASN1_SEQUENCE(ASN1_LONG_DATA) = {
ASN1_SIMPLE(ASN1_LONG_DATA, success, ASN1_BOOLEAN),
ASN1_SIMPLE(ASN1_LONG_DATA, test_long, LONG),
ASN1_EXP_OPT(ASN1_LONG_DATA, test_zlong, ZLONG, 0)
} static_ASN1_SEQUENCE_END(ASN1_LONG_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_LONG_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_LONG_DATA)
static ASN1_LONG_DATA long_expected_32bit[] = {
/* The following should fail on the second because it's the default */
{ 0xff, 0, 1 }, { 0, 0, 0 }, /* t_zero */
{ 0, 0, 0 }, { 0xff, 1, 0x7fffffff }, /* t_longundef */
CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
CUSTOM_EXPECTED_SUCCESS(-1, -1), /* t_one_neg */
CUSTOM_EXPECTED_SUCCESS(-256, -256), /* t_minus_256 */
CUSTOM_EXPECTED_FAILURE, /* t_9bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_3_pad */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_5_negpad */
CUSTOM_EXPECTED_FAILURE, /* t_5bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_1 (too large positive) */
CUSTOM_EXPECTED_SUCCESS(INT32_MAX - 1, INT32_MAX -1), /* t_4bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_3_pad (illegal padding) */
CUSTOM_EXPECTED_SUCCESS(INT32_MIN, INT32_MIN), /* t_4bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_5_negpad (illegal padding) */
};
static ASN1_LONG_DATA long_encdec_data_32bit[] = {
ENCDEC_ARRAY(LONG_MAX - 1, LONG_MAX, LONG_MIN, LONG_MIN),
/* Check that default numbers fail */
{ 0, ASN1_LONG_UNDEF, 1 }, { 0, 1, 0 }
};
static TEST_PACKAGE long_test_package_32bit = {
ASN1_ITEM_ref(ASN1_LONG_DATA), "LONG", sizeof(long) != 4,
long_expected_32bit,
sizeof(long_expected_32bit), sizeof(long_expected_32bit[0]),
long_encdec_data_32bit,
sizeof(long_encdec_data_32bit), sizeof(long_encdec_data_32bit[0]),
(i2d_fn *)i2d_ASN1_LONG_DATA, (d2i_fn *)d2i_ASN1_LONG_DATA,
(ifree_fn *)ASN1_LONG_DATA_free
};
static ASN1_LONG_DATA long_expected_64bit[] = {
/* The following should fail on the second because it's the default */
{ 0xff, 0, 1 }, { 0, 0, 0 }, /* t_zero */
{ 0, 0, 0 }, { 0xff, 1, 0x7fffffff }, /* t_longundef */
CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
CUSTOM_EXPECTED_SUCCESS(-1, -1), /* t_one_neg */
CUSTOM_EXPECTED_SUCCESS(-256, -256), /* t_minus_256 */
CUSTOM_EXPECTED_FAILURE, /* t_9bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_1 */
CUSTOM_EXPECTED_SUCCESS(LONG_MAX, LONG_MAX), /* t_8bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_3_pad (illegal padding) */
CUSTOM_EXPECTED_SUCCESS(LONG_MIN, LONG_MIN), /* t_8bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_5_negpad (illegal padding) */
CUSTOM_EXPECTED_SUCCESS((long)0x1ffffffff, (long)0x1ffffffff), /* t_5bytes_1 */
CUSTOM_EXPECTED_SUCCESS((long)0x80000000, (long)0x80000000), /* t_4bytes_1 */
CUSTOM_EXPECTED_SUCCESS(INT32_MAX - 1, INT32_MAX -1), /* t_4bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_3_pad (illegal padding) */
CUSTOM_EXPECTED_SUCCESS(INT32_MIN, INT32_MIN), /* t_4bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_5_negpad (illegal padding) */
};
static ASN1_LONG_DATA long_encdec_data_64bit[] = {
ENCDEC_ARRAY(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN),
/* Check that default numbers fail */
{ 0, ASN1_LONG_UNDEF, 1 }, { 0, 1, 0 }
};
static TEST_PACKAGE long_test_package_64bit = {
ASN1_ITEM_ref(ASN1_LONG_DATA), "LONG", sizeof(long) != 8,
long_expected_64bit,
sizeof(long_expected_64bit), sizeof(long_expected_64bit[0]),
long_encdec_data_64bit,
sizeof(long_encdec_data_64bit), sizeof(long_encdec_data_64bit[0]),
(i2d_fn *)i2d_ASN1_LONG_DATA, (d2i_fn *)d2i_ASN1_LONG_DATA,
(ifree_fn *)ASN1_LONG_DATA_free
};
#endif
/***** INT32 *****************************************************************/
typedef struct {
ASN1_BOOLEAN success;
int32_t test_int32;
int32_t test_zint32;
} ASN1_INT32_DATA;
ASN1_SEQUENCE(ASN1_INT32_DATA) = {
ASN1_SIMPLE(ASN1_INT32_DATA, success, ASN1_BOOLEAN),
ASN1_EMBED(ASN1_INT32_DATA, test_int32, INT32),
ASN1_EXP_OPT_EMBED(ASN1_INT32_DATA, test_zint32, ZINT32, 0)
} static_ASN1_SEQUENCE_END(ASN1_INT32_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_INT32_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_INT32_DATA)
static ASN1_INT32_DATA int32_expected[] = {
CUSTOM_EXPECTED_SUCCESS(0, 0), /* t_zero */
CUSTOM_EXPECTED_SUCCESS(ASN1_LONG_UNDEF, ASN1_LONG_UNDEF), /* t_zero */
CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
CUSTOM_EXPECTED_SUCCESS(-1, -1), /* t_one_neg */
CUSTOM_EXPECTED_SUCCESS(-256, -256), /* t_minus_256 */
CUSTOM_EXPECTED_FAILURE, /* t_9bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_3_pad */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_5_negpad */
CUSTOM_EXPECTED_FAILURE, /* t_5bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_1 (too large positive) */
CUSTOM_EXPECTED_SUCCESS(INT32_MAX - 1, INT32_MAX -1), /* t_4bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_3_pad (illegal padding) */
CUSTOM_EXPECTED_SUCCESS(INT32_MIN, INT32_MIN), /* t_4bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_5_negpad (illegal padding) */
};
static ASN1_INT32_DATA int32_encdec_data[] = {
ENCDEC_ARRAY(INT32_MAX, INT32_MAX, INT32_MIN, INT32_MIN),
};
static TEST_PACKAGE int32_test_package = {
ASN1_ITEM_ref(ASN1_INT32_DATA), "INT32", 0,
int32_expected, sizeof(int32_expected), sizeof(int32_expected[0]),
int32_encdec_data, sizeof(int32_encdec_data), sizeof(int32_encdec_data[0]),
(i2d_fn *)i2d_ASN1_INT32_DATA, (d2i_fn *)d2i_ASN1_INT32_DATA,
(ifree_fn *)ASN1_INT32_DATA_free
};
/***** UINT32 ****************************************************************/
typedef struct {
ASN1_BOOLEAN success;
uint32_t test_uint32;
uint32_t test_zuint32;
} ASN1_UINT32_DATA;
ASN1_SEQUENCE(ASN1_UINT32_DATA) = {
ASN1_SIMPLE(ASN1_UINT32_DATA, success, ASN1_BOOLEAN),
ASN1_EMBED(ASN1_UINT32_DATA, test_uint32, UINT32),
ASN1_EXP_OPT_EMBED(ASN1_UINT32_DATA, test_zuint32, ZUINT32, 0)
} static_ASN1_SEQUENCE_END(ASN1_UINT32_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_UINT32_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_UINT32_DATA)
static ASN1_UINT32_DATA uint32_expected[] = {
CUSTOM_EXPECTED_SUCCESS(0, 0), /* t_zero */
CUSTOM_EXPECTED_SUCCESS(ASN1_LONG_UNDEF, ASN1_LONG_UNDEF), /* t_zero */
CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
CUSTOM_EXPECTED_FAILURE, /* t_one_neg (illegal negative value) */
CUSTOM_EXPECTED_FAILURE, /* t_minus_256 (illegal negative value) */
CUSTOM_EXPECTED_FAILURE, /* t_9bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_3_pad */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_5_negpad */
CUSTOM_EXPECTED_FAILURE, /* t_5bytes_1 */
CUSTOM_EXPECTED_SUCCESS(0x80000000, 0x80000000), /* t_4bytes_1 */
CUSTOM_EXPECTED_SUCCESS(INT32_MAX - 1, INT32_MAX -1), /* t_4bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_3_pad (illegal padding) */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_4_neg (illegal negative value) */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_5_negpad (illegal padding) */
};
static ASN1_UINT32_DATA uint32_encdec_data[] = {
ENCDEC_ARRAY(UINT32_MAX, UINT32_MAX, 0, 0),
};
static TEST_PACKAGE uint32_test_package = {
ASN1_ITEM_ref(ASN1_UINT32_DATA), "UINT32", 0,
uint32_expected, sizeof(uint32_expected), sizeof(uint32_expected[0]),
uint32_encdec_data, sizeof(uint32_encdec_data), sizeof(uint32_encdec_data[0]),
(i2d_fn *)i2d_ASN1_UINT32_DATA, (d2i_fn *)d2i_ASN1_UINT32_DATA,
(ifree_fn *)ASN1_UINT32_DATA_free
};
/***** INT64 *****************************************************************/
typedef struct {
ASN1_BOOLEAN success;
int64_t test_int64;
int64_t test_zint64;
} ASN1_INT64_DATA;
ASN1_SEQUENCE(ASN1_INT64_DATA) = {
ASN1_SIMPLE(ASN1_INT64_DATA, success, ASN1_BOOLEAN),
ASN1_EMBED(ASN1_INT64_DATA, test_int64, INT64),
ASN1_EXP_OPT_EMBED(ASN1_INT64_DATA, test_zint64, ZINT64, 0)
} static_ASN1_SEQUENCE_END(ASN1_INT64_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_INT64_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_INT64_DATA)
static ASN1_INT64_DATA int64_expected[] = {
CUSTOM_EXPECTED_SUCCESS(0, 0), /* t_zero */
CUSTOM_EXPECTED_SUCCESS(ASN1_LONG_UNDEF, ASN1_LONG_UNDEF), /* t_zero */
CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
CUSTOM_EXPECTED_SUCCESS(-1, -1), /* t_one_neg */
CUSTOM_EXPECTED_SUCCESS(-256, -256), /* t_minus_256 */
CUSTOM_EXPECTED_FAILURE, /* t_9bytes_1 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_1 (too large positive) */
CUSTOM_EXPECTED_SUCCESS(INT64_MAX, INT64_MAX), /* t_8bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_3_pad (illegal padding) */
CUSTOM_EXPECTED_SUCCESS(INT64_MIN, INT64_MIN), /* t_8bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_5_negpad (illegal padding) */
CUSTOM_EXPECTED_SUCCESS(0x1ffffffffULL, 0x1ffffffffULL), /* t_5bytes_1 */
CUSTOM_EXPECTED_SUCCESS(0x80000000, 0x80000000), /* t_4bytes_1 */
CUSTOM_EXPECTED_SUCCESS(INT32_MAX - 1, INT32_MAX -1), /* t_4bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_3_pad (illegal padding) */
CUSTOM_EXPECTED_SUCCESS(INT32_MIN, INT32_MIN), /* t_4bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_5_negpad (illegal padding) */
};
static ASN1_INT64_DATA int64_encdec_data[] = {
ENCDEC_ARRAY(INT64_MAX, INT64_MAX, INT64_MIN, INT64_MIN),
ENCDEC_ARRAY(INT32_MAX, INT32_MAX, INT32_MIN, INT32_MIN),
};
static TEST_PACKAGE int64_test_package = {
ASN1_ITEM_ref(ASN1_INT64_DATA), "INT64", 0,
int64_expected, sizeof(int64_expected), sizeof(int64_expected[0]),
int64_encdec_data, sizeof(int64_encdec_data), sizeof(int64_encdec_data[0]),
(i2d_fn *)i2d_ASN1_INT64_DATA, (d2i_fn *)d2i_ASN1_INT64_DATA,
(ifree_fn *)ASN1_INT64_DATA_free
};
/***** UINT64 ****************************************************************/
typedef struct {
ASN1_BOOLEAN success;
uint64_t test_uint64;
uint64_t test_zuint64;
} ASN1_UINT64_DATA;
ASN1_SEQUENCE(ASN1_UINT64_DATA) = {
ASN1_SIMPLE(ASN1_UINT64_DATA, success, ASN1_BOOLEAN),
ASN1_EMBED(ASN1_UINT64_DATA, test_uint64, UINT64),
ASN1_EXP_OPT_EMBED(ASN1_UINT64_DATA, test_zuint64, ZUINT64, 0)
} static_ASN1_SEQUENCE_END(ASN1_UINT64_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_UINT64_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_UINT64_DATA)
static ASN1_UINT64_DATA uint64_expected[] = {
CUSTOM_EXPECTED_SUCCESS(0, 0), /* t_zero */
CUSTOM_EXPECTED_SUCCESS(ASN1_LONG_UNDEF, ASN1_LONG_UNDEF), /* t_zero */
CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
CUSTOM_EXPECTED_FAILURE, /* t_one_neg (illegal negative value) */
CUSTOM_EXPECTED_FAILURE, /* t_minus_256 (illegal negative value) */
CUSTOM_EXPECTED_FAILURE, /* t_9bytes_1 */
CUSTOM_EXPECTED_SUCCESS((uint64_t)INT64_MAX+1, (uint64_t)INT64_MAX+1),
/* t_8bytes_1 */
CUSTOM_EXPECTED_SUCCESS(INT64_MAX, INT64_MAX), /* t_8bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_3_pad */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_4_neg */
CUSTOM_EXPECTED_FAILURE, /* t_8bytes_5_negpad */
CUSTOM_EXPECTED_SUCCESS(0x1ffffffffULL, 0x1ffffffffULL), /* t_5bytes_1 */
CUSTOM_EXPECTED_SUCCESS(0x80000000, 0x80000000), /* t_4bytes_1 */
CUSTOM_EXPECTED_SUCCESS(INT32_MAX - 1, INT32_MAX -1), /* t_4bytes_2 */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_3_pad (illegal padding) */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_4_neg (illegal negative value) */
CUSTOM_EXPECTED_FAILURE, /* t_4bytes_5_negpad (illegal padding) */
};
static ASN1_UINT64_DATA uint64_encdec_data[] = {
ENCDEC_ARRAY(UINT64_MAX, UINT64_MAX, 0, 0),
};
static TEST_PACKAGE uint64_test_package = {
ASN1_ITEM_ref(ASN1_UINT64_DATA), "UINT64", 0,
uint64_expected, sizeof(uint64_expected), sizeof(uint64_expected[0]),
uint64_encdec_data, sizeof(uint64_encdec_data), sizeof(uint64_encdec_data[0]),
(i2d_fn *)i2d_ASN1_UINT64_DATA, (d2i_fn *)d2i_ASN1_UINT64_DATA,
(ifree_fn *)ASN1_UINT64_DATA_free
};
/***** General testing functions *********************************************/
/* Template structure to map onto any test data structure */
typedef struct {
ASN1_BOOLEAN success;
unsigned char bytes[1]; /* In reality, there's more */
} EXPECTED;
/*
* do_decode returns a tristate:
*
* -1 Couldn't decode
* 0 decoded structure wasn't what was expected (failure)
* 1 decoded structure was what was expected (success)
*/
static int do_decode(unsigned char *bytes, long nbytes,
const EXPECTED *expected, size_t expected_size,
const TEST_PACKAGE *package)
{
EXPECTED *enctst = NULL;
const unsigned char *start;
int ret = 0;
start = bytes;
enctst = package->d2i(NULL, &bytes, nbytes);
if (enctst == NULL) {
if (expected->success == 0) {
ret = 1;
ERR_clear_error();
} else {
ret = -1;
}
} else {
if (start + nbytes == bytes
&& memcmp(enctst, expected, expected_size) == 0)
ret = 1;
else
ret = 0;
}
package->ifree(enctst);
return ret;
}
/*
* do_encode returns a tristate:
*
* -1 Couldn't encode
* 0 encoded DER wasn't what was expected (failure)
* 1 encoded DER was what was expected (success)
*/
static int do_encode(EXPECTED *input,
const unsigned char *expected, size_t expected_len,
const TEST_PACKAGE *package)
{
unsigned char *data = NULL;
int len;
int ret = 0;
len = package->i2d(input, &data);
if (len < 0)
return -1;
if ((size_t)len != expected_len
|| memcmp(data, expected, expected_len) != 0) {
if (input->success == 0) {
ret = 1;
ERR_clear_error();
} else {
ret = 0;
}
} else {
ret = 1;
}
OPENSSL_free(data);
return ret;
}
/* Do an encode/decode round trip */
static int do_enc_dec(EXPECTED *bytes, long nbytes,
const TEST_PACKAGE *package)
{
unsigned char *data = NULL;
int len;
int ret = 0;
void *p = bytes;
len = package->i2d(p, &data);
if (len < 0)
return -1;
ret = do_decode(data, len, bytes, nbytes, package);
OPENSSL_free(data);
return ret;
}
static size_t der_encode_length(size_t len, unsigned char **pp)
{
size_t lenbytes;
OPENSSL_assert(len < 0x8000);
if (len > 255)
lenbytes = 3;
else if (len > 127)
lenbytes = 2;
else
lenbytes = 1;
if (pp != NULL) {
if (lenbytes == 1) {
*(*pp)++ = (unsigned char)len;
} else {
*(*pp)++ = (unsigned char)(lenbytes - 1);
if (lenbytes == 2) {
*(*pp)++ = (unsigned char)(0x80 | len);
} else {
*(*pp)++ = (unsigned char)(0x80 | (len >> 8));
*(*pp)++ = (unsigned char)(len);
}
}
}
return lenbytes;
}
static size_t make_custom_der(const TEST_CUSTOM_DATA *custom_data,
unsigned char **encoding, int explicit_default)
{
size_t firstbytes, secondbytes = 0, secondbytesinner = 0, seqbytes;
const unsigned char t_true[] = { V_ASN1_BOOLEAN, 0x01, 0xff };
unsigned char *p = NULL;
size_t i;
/*
* The first item is just an INTEGER tag, INTEGER length and INTEGER content
*/
firstbytes =
1 + der_encode_length(custom_data->nbytes1, NULL)
+ custom_data->nbytes1;
for (i = custom_data->nbytes2; i > 0; i--) {
if (custom_data->bytes2[i - 1] != '\0')
break;
}
if (explicit_default || i > 0) {
/*
* The second item is an explicit tag, content length, INTEGER tag,
* INTEGER length, INTEGER bytes
*/
secondbytesinner =
1 + der_encode_length(custom_data->nbytes2, NULL)
+ custom_data->nbytes2;
secondbytes =
1 + der_encode_length(secondbytesinner, NULL) + secondbytesinner;
}
/*
* The whole sequence is the sequence tag, content length, BOOLEAN true
* (copied from t_true), the first (firstbytes) and second (secondbytes)
* items
*/
seqbytes =
1 + der_encode_length(sizeof(t_true) + firstbytes + secondbytes, NULL)
+ sizeof(t_true) + firstbytes + secondbytes;
*encoding = p = OPENSSL_malloc(seqbytes);
if (*encoding == NULL)
return 0;
/* Sequence tag */
*p++ = 0x30;
der_encode_length(sizeof(t_true) + firstbytes + secondbytes, &p);
/* ASN1_BOOLEAN TRUE */
memcpy(p, t_true, sizeof(t_true)); /* Marks decoding success */
p += sizeof(t_true);
/* First INTEGER item (non-optional) */
*p++ = V_ASN1_INTEGER;
der_encode_length(custom_data->nbytes1, &p);
memcpy(p, custom_data->bytes1, custom_data->nbytes1);
p += custom_data->nbytes1;
if (secondbytes > 0) {
/* Second INTEGER item (optional) */
/* Start with the explicit optional tag */
*p++ = 0xa0;
der_encode_length(secondbytesinner, &p);
*p++ = V_ASN1_INTEGER;
der_encode_length(custom_data->nbytes2, &p);
memcpy(p, custom_data->bytes2, custom_data->nbytes2);
p += custom_data->nbytes2;
}
OPENSSL_assert(seqbytes == (size_t)(p - *encoding));
return seqbytes;
}
/* Attempt to decode a custom encoding of the test structure */
static int do_decode_custom(const TEST_CUSTOM_DATA *custom_data,
const EXPECTED *expected, size_t expected_size,
const TEST_PACKAGE *package)
{
unsigned char *encoding = NULL;
/*
* We force the defaults to be explicitly encoded to make sure we test
* for defaults that shouldn't be present (i.e. we check for failure)
*/
size_t encoding_length = make_custom_der(custom_data, &encoding, 1);
int ret;
if (encoding_length == 0)
return -1;
ret = do_decode(encoding, encoding_length, expected, expected_size,
package);
OPENSSL_free(encoding);
return ret;
}
/* Attempt to encode the test structure and compare it to custom DER */
static int do_encode_custom(EXPECTED *input,
const TEST_CUSTOM_DATA *custom_data,
const TEST_PACKAGE *package)
{
unsigned char *expected = NULL;
size_t expected_length = make_custom_der(custom_data, &expected, 0);
int ret;
if (expected_length == 0)
return -1;
ret = do_encode(input, expected, expected_length, package);
OPENSSL_free(expected);
return ret;
}
static int do_print_item(const TEST_PACKAGE *package)
{
#define DATA_BUF_SIZE 256
const ASN1_ITEM *i = ASN1_ITEM_ptr(package->asn1_type);
ASN1_VALUE *o;
int ret;
OPENSSL_assert(package->encode_expectations_elem_size <= DATA_BUF_SIZE);
if ((o = OPENSSL_malloc(DATA_BUF_SIZE)) == NULL)
return 0;
(void)RAND_bytes((unsigned char*)o,
(int)package->encode_expectations_elem_size);
ret = ASN1_item_print(bio_err, o, 0, i, NULL);
OPENSSL_free(o);
return ret;
}
static int test_intern(const TEST_PACKAGE *package)
{
unsigned int i;
size_t nelems;
int fail = 0;
if (package->skip)
return 1;
/* Do decode_custom checks */
nelems = package->encode_expectations_size
/ package->encode_expectations_elem_size;
OPENSSL_assert(nelems ==
sizeof(test_custom_data) / sizeof(test_custom_data[0]));
for (i = 0; i < nelems; i++) {
size_t pos = i * package->encode_expectations_elem_size;
EXPECTED *expected
= (EXPECTED *)&((unsigned char *)package->encode_expectations)[pos];
switch (do_encode_custom(expected, &test_custom_data[i], package)) {
case -1:
if (expected->success) {
TEST_error("Failed custom encode round trip %u of %s",
i, package->name);
TEST_openssl_errors();
fail++;
}
break;
case 0:
TEST_error("Custom encode round trip %u of %s mismatch",
i, package->name);
TEST_openssl_errors();
fail++;
break;
case 1:
break;
default:
OPENSSL_die("do_encode_custom() return unknown value",
__FILE__, __LINE__);
}
switch (do_decode_custom(&test_custom_data[i], expected,
package->encode_expectations_elem_size,
package)) {
case -1:
if (expected->success) {
TEST_error("Failed custom decode round trip %u of %s",
i, package->name);
TEST_openssl_errors();
fail++;
}
break;
case 0:
TEST_error("Custom decode round trip %u of %s mismatch",
i, package->name);
TEST_openssl_errors();
fail++;
break;
case 1:
break;
default:
OPENSSL_die("do_decode_custom() return unknown value",
__FILE__, __LINE__);
}
}
/* Do enc_dec checks */
nelems = package->encdec_data_size / package->encdec_data_elem_size;
for (i = 0; i < nelems; i++) {
size_t pos = i * package->encdec_data_elem_size;
EXPECTED *expected
= (EXPECTED *)&((unsigned char *)package->encdec_data)[pos];
switch (do_enc_dec(expected, package->encdec_data_elem_size, package)) {
case -1:
if (expected->success) {
TEST_error("Failed encode/decode round trip %u of %s",
i, package->name);
TEST_openssl_errors();
fail++;
}
break;
case 0:
TEST_error("Encode/decode round trip %u of %s mismatch",
i, package->name);
fail++;
break;
case 1:
break;
default:
OPENSSL_die("do_enc_dec() return unknown value",
__FILE__, __LINE__);
}
}
if (!do_print_item(package)) {
TEST_error("Printing of %s failed", package->name);
TEST_openssl_errors();
fail++;
}
return fail == 0;
}
#ifndef OPENSSL_NO_DEPRECATED_3_0
static int test_long_32bit(void)
{
return test_intern(&long_test_package_32bit);
}
static int test_long_64bit(void)
{
return test_intern(&long_test_package_64bit);
}
#endif
static int test_int32(void)
{
return test_intern(&int32_test_package);
}
static int test_uint32(void)
{
return test_intern(&uint32_test_package);
}
static int test_int64(void)
{
return test_intern(&int64_test_package);
}
static int test_uint64(void)
{
return test_intern(&uint64_test_package);
}
typedef struct {
ASN1_STRING *invalidDirString;
} INVALIDTEMPLATE;
ASN1_SEQUENCE(INVALIDTEMPLATE) = {
/*
* DirectoryString is a CHOICE type so it must use explicit tagging -
* but we deliberately use implicit here, which makes this template invalid.
*/
ASN1_IMP(INVALIDTEMPLATE, invalidDirString, DIRECTORYSTRING, 12)
} static_ASN1_SEQUENCE_END(INVALIDTEMPLATE)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(INVALIDTEMPLATE)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(INVALIDTEMPLATE)
static int test_invalid_template(void)
{
INVALIDTEMPLATE *temp = INVALIDTEMPLATE_new();
int ret;
if (!TEST_ptr(temp))
return 0;
ret = i2d_INVALIDTEMPLATE(temp, NULL);
INVALIDTEMPLATE_free(temp);
/* We expect the i2d operation to fail */
return ret < 0;
}
int setup_tests(void)
{
#ifndef OPENSSL_NO_DEPRECATED_3_0
ADD_TEST(test_long_32bit);
ADD_TEST(test_long_64bit);
#endif
ADD_TEST(test_int32);
ADD_TEST(test_uint32);
ADD_TEST(test_int64);
ADD_TEST(test_uint64);
ADD_TEST(test_invalid_template);
return 1;
}
|
./openssl/test/verify_extra_test.c | /*
* Copyright 2015-2022 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 <string.h>
#include <openssl/crypto.h>
#include <openssl/bio.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#include "testutil.h"
static const char *certs_dir;
static char *root_f = NULL;
static char *roots_f = NULL;
static char *untrusted_f = NULL;
static char *bad_f = NULL;
static char *req_f = NULL;
static char *sroot_cert = NULL;
static char *ca_cert = NULL;
static char *ee_cert = NULL;
#define load_cert_from_file(file) load_cert_pem(file, NULL)
/*-
* Test for CVE-2015-1793 (Alternate Chains Certificate Forgery)
*
* Chain is as follows:
*
* rootCA (self-signed)
* |
* interCA
* |
* subinterCA subinterCA (self-signed)
* | |
* leaf ------------------
* |
* bad
*
* rootCA, interCA, subinterCA, subinterCA (ss) all have CA=TRUE
* leaf and bad have CA=FALSE
*
* subinterCA and subinterCA (ss) have the same subject name and keys
*
* interCA (but not rootCA) and subinterCA (ss) are in the trusted store
* (roots.pem)
* leaf and subinterCA are in the untrusted list (untrusted.pem)
* bad is the certificate being verified (bad.pem)
*
* Versions vulnerable to CVE-2015-1793 will fail to detect that leaf has
* CA=FALSE, and will therefore incorrectly verify bad
*
*/
static int test_alt_chains_cert_forgery(void)
{
int ret = 0;
int i;
X509 *x = NULL;
STACK_OF(X509) *untrusted = NULL;
X509_STORE_CTX *sctx = NULL;
X509_STORE *store = NULL;
X509_LOOKUP *lookup = NULL;
store = X509_STORE_new();
if (store == NULL)
goto err;
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
if (lookup == NULL)
goto err;
if (!X509_LOOKUP_load_file(lookup, roots_f, X509_FILETYPE_PEM))
goto err;
untrusted = load_certs_pem(untrusted_f);
if ((x = load_cert_from_file(bad_f)) == NULL)
goto err;
sctx = X509_STORE_CTX_new();
if (sctx == NULL)
goto err;
if (!X509_STORE_CTX_init(sctx, store, x, untrusted))
goto err;
i = X509_verify_cert(sctx);
if (i == 0 && X509_STORE_CTX_get_error(sctx) == X509_V_ERR_INVALID_CA) {
/* This is the result we were expecting: Test passed */
ret = 1;
}
err:
X509_STORE_CTX_free(sctx);
X509_free(x);
OSSL_STACK_OF_X509_free(untrusted);
X509_STORE_free(store);
return ret;
}
static int test_distinguishing_id(void)
{
X509 *x = NULL;
int ret = 0;
ASN1_OCTET_STRING *v = NULL, *v2 = NULL;
char *distid = "this is an ID";
x = load_cert_from_file(bad_f);
if (x == NULL)
goto err;
v = ASN1_OCTET_STRING_new();
if (v == NULL)
goto err;
if (!ASN1_OCTET_STRING_set(v, (unsigned char *)distid,
(int)strlen(distid))) {
ASN1_OCTET_STRING_free(v);
goto err;
}
X509_set0_distinguishing_id(x, v);
v2 = X509_get0_distinguishing_id(x);
if (!TEST_ptr(v2)
|| !TEST_int_eq(ASN1_OCTET_STRING_cmp(v, v2), 0))
goto err;
ret = 1;
err:
X509_free(x);
return ret;
}
static int test_req_distinguishing_id(void)
{
X509_REQ *x = NULL;
BIO *bio = NULL;
int ret = 0;
ASN1_OCTET_STRING *v = NULL, *v2 = NULL;
char *distid = "this is an ID";
bio = BIO_new_file(req_f, "r");
if (bio == NULL)
goto err;
x = PEM_read_bio_X509_REQ(bio, NULL, 0, NULL);
if (x == NULL)
goto err;
v = ASN1_OCTET_STRING_new();
if (v == NULL)
goto err;
if (!ASN1_OCTET_STRING_set(v, (unsigned char *)distid,
(int)strlen(distid))) {
ASN1_OCTET_STRING_free(v);
goto err;
}
X509_REQ_set0_distinguishing_id(x, v);
v2 = X509_REQ_get0_distinguishing_id(x);
if (!TEST_ptr(v2)
|| !TEST_int_eq(ASN1_OCTET_STRING_cmp(v, v2), 0))
goto err;
ret = 1;
err:
X509_REQ_free(x);
BIO_free(bio);
return ret;
}
static int test_self_signed(const char *filename, int use_trusted, int expected)
{
X509 *cert = load_cert_from_file(filename); /* may result in NULL */
STACK_OF(X509) *trusted = sk_X509_new_null();
X509_STORE_CTX *ctx = X509_STORE_CTX_new();
int ret;
ret = TEST_int_eq(X509_self_signed(cert, 1), expected);
if (cert != NULL) {
if (use_trusted)
ret = ret && TEST_true(sk_X509_push(trusted, cert));
ret = ret && TEST_true(X509_STORE_CTX_init(ctx, NULL, cert, NULL));
X509_STORE_CTX_set0_trusted_stack(ctx, trusted);
ret = ret && TEST_int_eq(X509_verify_cert(ctx), expected);
}
X509_STORE_CTX_free(ctx);
sk_X509_free(trusted);
X509_free(cert);
return ret;
}
static int test_self_signed_good(void)
{
return test_self_signed(root_f, 1, 1);
}
static int test_self_signed_bad(void)
{
return test_self_signed(bad_f, 1, 0);
}
static int test_self_signed_error(void)
{
return test_self_signed("nonexistent file name", 1, -1);
}
static int test_store_ctx(void)
{
/* Verifying a cert where we have no trusted certs should fail */
return test_self_signed(bad_f, 0, 0);
}
static int do_test_purpose(int purpose, int expected)
{
X509 *eecert = load_cert_from_file(ee_cert); /* may result in NULL */
X509 *untrcert = load_cert_from_file(ca_cert);
X509 *trcert = load_cert_from_file(sroot_cert);
STACK_OF(X509) *trusted = sk_X509_new_null();
STACK_OF(X509) *untrusted = sk_X509_new_null();
X509_STORE_CTX *ctx = X509_STORE_CTX_new();
int testresult = 0;
if (!TEST_ptr(eecert)
|| !TEST_ptr(untrcert)
|| !TEST_ptr(trcert)
|| !TEST_ptr(trusted)
|| !TEST_ptr(untrusted)
|| !TEST_ptr(ctx))
goto err;
if (!TEST_true(sk_X509_push(trusted, trcert)))
goto err;
trcert = NULL;
if (!TEST_true(sk_X509_push(untrusted, untrcert)))
goto err;
untrcert = NULL;
if (!TEST_true(X509_STORE_CTX_init(ctx, NULL, eecert, untrusted)))
goto err;
if (!TEST_true(X509_STORE_CTX_set_purpose(ctx, purpose)))
goto err;
/*
* X509_STORE_CTX_set0_trusted_stack() is bady named. Despite the set0 name
* we are still responsible for freeing trusted after we have finished with
* it.
*/
X509_STORE_CTX_set0_trusted_stack(ctx, trusted);
if (!TEST_int_eq(X509_verify_cert(ctx), expected))
goto err;
testresult = 1;
err:
OSSL_STACK_OF_X509_free(trusted);
OSSL_STACK_OF_X509_free(untrusted);
X509_STORE_CTX_free(ctx);
X509_free(eecert);
X509_free(untrcert);
X509_free(trcert);
return testresult;
}
static int test_purpose_ssl_client(void)
{
return do_test_purpose(X509_PURPOSE_SSL_CLIENT, 0);
}
static int test_purpose_ssl_server(void)
{
return do_test_purpose(X509_PURPOSE_SSL_SERVER, 1);
}
static int test_purpose_any(void)
{
return do_test_purpose(X509_PURPOSE_ANY, 1);
}
OPT_TEST_DECLARE_USAGE("certs-dir\n")
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(certs_dir = test_get_argument(0)))
return 0;
if (!TEST_ptr(root_f = test_mk_file_path(certs_dir, "rootCA.pem"))
|| !TEST_ptr(roots_f = test_mk_file_path(certs_dir, "roots.pem"))
|| !TEST_ptr(untrusted_f = test_mk_file_path(certs_dir, "untrusted.pem"))
|| !TEST_ptr(bad_f = test_mk_file_path(certs_dir, "bad.pem"))
|| !TEST_ptr(req_f = test_mk_file_path(certs_dir, "sm2-csr.pem"))
|| !TEST_ptr(sroot_cert = test_mk_file_path(certs_dir, "sroot-cert.pem"))
|| !TEST_ptr(ca_cert = test_mk_file_path(certs_dir, "ca-cert.pem"))
|| !TEST_ptr(ee_cert = test_mk_file_path(certs_dir, "ee-cert.pem")))
goto err;
ADD_TEST(test_alt_chains_cert_forgery);
ADD_TEST(test_store_ctx);
ADD_TEST(test_distinguishing_id);
ADD_TEST(test_req_distinguishing_id);
ADD_TEST(test_self_signed_good);
ADD_TEST(test_self_signed_bad);
ADD_TEST(test_self_signed_error);
ADD_TEST(test_purpose_ssl_client);
ADD_TEST(test_purpose_ssl_server);
ADD_TEST(test_purpose_any);
return 1;
err:
cleanup_tests();
return 0;
}
void cleanup_tests(void)
{
OPENSSL_free(root_f);
OPENSSL_free(roots_f);
OPENSSL_free(untrusted_f);
OPENSSL_free(bad_f);
OPENSSL_free(req_f);
OPENSSL_free(sroot_cert);
OPENSSL_free(ca_cert);
OPENSSL_free(ee_cert);
}
|
./openssl/test/provider_status_test.c | /*
* Copyright 2020-2021 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 <stddef.h>
#include <string.h>
#include <openssl/provider.h>
#include <openssl/params.h>
#include <openssl/core_names.h>
#include <openssl/self_test.h>
#include <openssl/evp.h>
#include "testutil.h"
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_PROVIDER_NAME,
OPT_CONFIG_FILE,
OPT_TEST_ENUM
} OPTION_CHOICE;
struct self_test_arg {
int count;
};
static OSSL_LIB_CTX *libctx = NULL;
static char *provider_name = NULL;
static struct self_test_arg self_test_args = { 0 };
const OPTIONS *test_get_options(void)
{
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "provider_name", OPT_PROVIDER_NAME, 's',
"The name of the provider to load" },
{ "config", OPT_CONFIG_FILE, '<',
"The configuration file to use for the libctx" },
{ NULL }
};
return test_options;
}
static int self_test_events(const OSSL_PARAM params[], void *arg,
const char *title, int corrupt)
{
struct self_test_arg *args = arg;
const OSSL_PARAM *p = NULL;
const char *phase = NULL, *type = NULL, *desc = NULL;
int ret = 0;
if (args->count == 0)
BIO_printf(bio_out, "\n%s\n", title);
args->count++;
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_PHASE);
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
goto err;
phase = (const char *)p->data;
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_DESC);
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
goto err;
desc = (const char *)p->data;
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_TYPE);
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
goto err;
type = (const char *)p->data;
if (strcmp(phase, OSSL_SELF_TEST_PHASE_START) == 0)
BIO_printf(bio_out, "%s : (%s) : ", desc, type);
else if (strcmp(phase, OSSL_SELF_TEST_PHASE_PASS) == 0
|| strcmp(phase, OSSL_SELF_TEST_PHASE_FAIL) == 0)
BIO_printf(bio_out, "%s\n", phase);
/*
* The self test code will internally corrupt the KAT test result if an
* error is returned during the corrupt phase.
*/
if (corrupt && strcmp(phase, OSSL_SELF_TEST_PHASE_CORRUPT) == 0)
goto err;
ret = 1;
err:
return ret;
}
static int self_test_on_demand_fail(const OSSL_PARAM params[], void *arg)
{
return self_test_events(params, arg, "On Demand Failure", 1);
}
static int self_test_on_demand(const OSSL_PARAM params[], void *arg)
{
return self_test_events(params, arg, "On Demand", 0);
}
static int self_test_on_load(const OSSL_PARAM params[], void *arg)
{
return self_test_events(params, arg, "On Loading", 0);
}
static int get_provider_params(const OSSL_PROVIDER *prov)
{
int ret = 0;
OSSL_PARAM params[5];
char *name, *version, *buildinfo;
int status;
const OSSL_PARAM *gettable, *p;
if (!TEST_ptr(gettable = OSSL_PROVIDER_gettable_params(prov))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(gettable, OSSL_PROV_PARAM_NAME))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(gettable, OSSL_PROV_PARAM_VERSION))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(gettable, OSSL_PROV_PARAM_STATUS))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(gettable, OSSL_PROV_PARAM_BUILDINFO)))
goto end;
params[0] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_NAME, &name, 0);
params[1] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_VERSION,
&version, 0);
params[2] = OSSL_PARAM_construct_int(OSSL_PROV_PARAM_STATUS, &status);
params[3] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_BUILDINFO,
&buildinfo, 0);
params[4] = OSSL_PARAM_construct_end();
OSSL_PARAM_set_all_unmodified(params);
if (!TEST_true(OSSL_PROVIDER_get_params(prov, params)))
goto end;
if (!TEST_true(OSSL_PARAM_modified(params + 0))
|| !TEST_true(OSSL_PARAM_modified(params + 1))
|| !TEST_true(OSSL_PARAM_modified(params + 2))
|| !TEST_true(OSSL_PARAM_modified(params + 3))
|| !TEST_true(status == 1))
goto end;
ret = 1;
end:
return ret;
}
static int test_provider_status(void)
{
int ret = 0;
unsigned int status = 0;
OSSL_PROVIDER *prov = NULL;
OSSL_PARAM params[2];
EVP_MD *fetch = NULL;
if (!TEST_ptr(prov = OSSL_PROVIDER_load(libctx, provider_name)))
goto err;
if (!get_provider_params(prov))
goto err;
/* Test that the provider status is ok */
params[0] = OSSL_PARAM_construct_uint(OSSL_PROV_PARAM_STATUS, &status);
params[1] = OSSL_PARAM_construct_end();
if (!TEST_true(OSSL_PROVIDER_get_params(prov, params))
|| !TEST_true(status == 1))
goto err;
if (!TEST_ptr(fetch = EVP_MD_fetch(libctx, "SHA256", NULL)))
goto err;
EVP_MD_free(fetch);
fetch = NULL;
/* Test that the provider self test is ok */
self_test_args.count = 0;
OSSL_SELF_TEST_set_callback(libctx, self_test_on_demand, &self_test_args);
if (!TEST_true(OSSL_PROVIDER_self_test(prov)))
goto err;
/* Setup a callback that corrupts the self tests and causes status failures */
self_test_args.count = 0;
OSSL_SELF_TEST_set_callback(libctx, self_test_on_demand_fail, &self_test_args);
if (!TEST_false(OSSL_PROVIDER_self_test(prov)))
goto err;
if (!TEST_true(OSSL_PROVIDER_get_params(prov, params))
|| !TEST_uint_eq(status, 0))
goto err;
if (!TEST_ptr_null(fetch = EVP_MD_fetch(libctx, "SHA256", NULL)))
goto err;
ret = 1;
err:
EVP_MD_free(fetch);
OSSL_PROVIDER_unload(prov);
return ret;
}
static int test_provider_gettable_params(void)
{
OSSL_PROVIDER *prov;
int ret;
if (!TEST_ptr(prov = OSSL_PROVIDER_load(libctx, provider_name)))
return 0;
ret = get_provider_params(prov);
OSSL_PROVIDER_unload(prov);
return ret;
}
int setup_tests(void)
{
OPTION_CHOICE o;
char *config_file = NULL;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_CONFIG_FILE:
config_file = opt_arg();
break;
case OPT_PROVIDER_NAME:
provider_name = opt_arg();
break;
case OPT_TEST_CASES:
break;
default:
case OPT_ERR:
return 0;
}
}
libctx = OSSL_LIB_CTX_new();
if (libctx == NULL)
return 0;
if (strcmp(provider_name, "fips") == 0) {
self_test_args.count = 0;
OSSL_SELF_TEST_set_callback(libctx, self_test_on_load, &self_test_args);
if (!OSSL_LIB_CTX_load_config(libctx, config_file)) {
opt_printf_stderr("Failed to load config\n");
return 0;
}
ADD_TEST(test_provider_status);
} else {
ADD_TEST(test_provider_gettable_params);
}
return 1;
}
void cleanup_tests(void)
{
OSSL_LIB_CTX_free(libctx);
}
|
./openssl/test/destest.c | /*
* Copyright 1995-2023 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
*/
/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"
#include <openssl/e_os2.h>
#include <string.h>
#include "testutil.h"
#include "internal/nelem.h"
#ifndef OPENSSL_NO_DES
# include <openssl/des.h>
/* In case any platform doesn't use unsigned int for its checksums */
# define TEST_cs_eq TEST_uint_eq
# define DATA_BUF_SIZE 20
/* tisk tisk - the test keys don't all have odd parity :-( */
/* test data */
# define NUM_TESTS 34
static unsigned char key_data[NUM_TESTS][8] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
{0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10},
{0x7C, 0xA1, 0x10, 0x45, 0x4A, 0x1A, 0x6E, 0x57},
{0x01, 0x31, 0xD9, 0x61, 0x9D, 0xC1, 0x37, 0x6E},
{0x07, 0xA1, 0x13, 0x3E, 0x4A, 0x0B, 0x26, 0x86},
{0x38, 0x49, 0x67, 0x4C, 0x26, 0x02, 0x31, 0x9E},
{0x04, 0xB9, 0x15, 0xBA, 0x43, 0xFE, 0xB5, 0xB6},
{0x01, 0x13, 0xB9, 0x70, 0xFD, 0x34, 0xF2, 0xCE},
{0x01, 0x70, 0xF1, 0x75, 0x46, 0x8F, 0xB5, 0xE6},
{0x43, 0x29, 0x7F, 0xAD, 0x38, 0xE3, 0x73, 0xFE},
{0x07, 0xA7, 0x13, 0x70, 0x45, 0xDA, 0x2A, 0x16},
{0x04, 0x68, 0x91, 0x04, 0xC2, 0xFD, 0x3B, 0x2F},
{0x37, 0xD0, 0x6B, 0xB5, 0x16, 0xCB, 0x75, 0x46},
{0x1F, 0x08, 0x26, 0x0D, 0x1A, 0xC2, 0x46, 0x5E},
{0x58, 0x40, 0x23, 0x64, 0x1A, 0xBA, 0x61, 0x76},
{0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xB0, 0x07},
{0x49, 0x79, 0x3E, 0xBC, 0x79, 0xB3, 0x25, 0x8F},
{0x4F, 0xB0, 0x5E, 0x15, 0x15, 0xAB, 0x73, 0xA7},
{0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF},
{0x01, 0x83, 0x10, 0xDC, 0x40, 0x9B, 0x26, 0xD6},
{0x1C, 0x58, 0x7F, 0x1C, 0x13, 0x92, 0x4F, 0xEF},
{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
{0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E},
{0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
{0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}
};
static unsigned char plain_data[NUM_TESTS][8] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
{0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
{0x01, 0xA1, 0xD6, 0xD0, 0x39, 0x77, 0x67, 0x42},
{0x5C, 0xD5, 0x4C, 0xA8, 0x3D, 0xEF, 0x57, 0xDA},
{0x02, 0x48, 0xD4, 0x38, 0x06, 0xF6, 0x71, 0x72},
{0x51, 0x45, 0x4B, 0x58, 0x2D, 0xDF, 0x44, 0x0A},
{0x42, 0xFD, 0x44, 0x30, 0x59, 0x57, 0x7F, 0xA2},
{0x05, 0x9B, 0x5E, 0x08, 0x51, 0xCF, 0x14, 0x3A},
{0x07, 0x56, 0xD8, 0xE0, 0x77, 0x47, 0x61, 0xD2},
{0x76, 0x25, 0x14, 0xB8, 0x29, 0xBF, 0x48, 0x6A},
{0x3B, 0xDD, 0x11, 0x90, 0x49, 0x37, 0x28, 0x02},
{0x26, 0x95, 0x5F, 0x68, 0x35, 0xAF, 0x60, 0x9A},
{0x16, 0x4D, 0x5E, 0x40, 0x4F, 0x27, 0x52, 0x32},
{0x6B, 0x05, 0x6E, 0x18, 0x75, 0x9F, 0x5C, 0xCA},
{0x00, 0x4B, 0xD6, 0xEF, 0x09, 0x17, 0x60, 0x62},
{0x48, 0x0D, 0x39, 0x00, 0x6E, 0xE7, 0x62, 0xF2},
{0x43, 0x75, 0x40, 0xC8, 0x69, 0x8F, 0x3C, 0xFA},
{0x07, 0x2D, 0x43, 0xA0, 0x77, 0x07, 0x52, 0x92},
{0x02, 0xFE, 0x55, 0x77, 0x81, 0x17, 0xF1, 0x2A},
{0x1D, 0x9D, 0x5C, 0x50, 0x18, 0xF7, 0x28, 0xC2},
{0x30, 0x55, 0x32, 0x28, 0x6D, 0x6F, 0x29, 0x5A},
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
};
static unsigned char cipher_data[NUM_TESTS][8] = {
{0x8C, 0xA6, 0x4D, 0xE9, 0xC1, 0xB1, 0x23, 0xA7},
{0x73, 0x59, 0xB2, 0x16, 0x3E, 0x4E, 0xDC, 0x58},
{0x95, 0x8E, 0x6E, 0x62, 0x7A, 0x05, 0x55, 0x7B},
{0xF4, 0x03, 0x79, 0xAB, 0x9E, 0x0E, 0xC5, 0x33},
{0x17, 0x66, 0x8D, 0xFC, 0x72, 0x92, 0x53, 0x2D},
{0x8A, 0x5A, 0xE1, 0xF8, 0x1A, 0xB8, 0xF2, 0xDD},
{0x8C, 0xA6, 0x4D, 0xE9, 0xC1, 0xB1, 0x23, 0xA7},
{0xED, 0x39, 0xD9, 0x50, 0xFA, 0x74, 0xBC, 0xC4},
{0x69, 0x0F, 0x5B, 0x0D, 0x9A, 0x26, 0x93, 0x9B},
{0x7A, 0x38, 0x9D, 0x10, 0x35, 0x4B, 0xD2, 0x71},
{0x86, 0x8E, 0xBB, 0x51, 0xCA, 0xB4, 0x59, 0x9A},
{0x71, 0x78, 0x87, 0x6E, 0x01, 0xF1, 0x9B, 0x2A},
{0xAF, 0x37, 0xFB, 0x42, 0x1F, 0x8C, 0x40, 0x95},
{0x86, 0xA5, 0x60, 0xF1, 0x0E, 0xC6, 0xD8, 0x5B},
{0x0C, 0xD3, 0xDA, 0x02, 0x00, 0x21, 0xDC, 0x09},
{0xEA, 0x67, 0x6B, 0x2C, 0xB7, 0xDB, 0x2B, 0x7A},
{0xDF, 0xD6, 0x4A, 0x81, 0x5C, 0xAF, 0x1A, 0x0F},
{0x5C, 0x51, 0x3C, 0x9C, 0x48, 0x86, 0xC0, 0x88},
{0x0A, 0x2A, 0xEE, 0xAE, 0x3F, 0xF4, 0xAB, 0x77},
{0xEF, 0x1B, 0xF0, 0x3E, 0x5D, 0xFA, 0x57, 0x5A},
{0x88, 0xBF, 0x0D, 0xB6, 0xD7, 0x0D, 0xEE, 0x56},
{0xA1, 0xF9, 0x91, 0x55, 0x41, 0x02, 0x0B, 0x56},
{0x6F, 0xBF, 0x1C, 0xAF, 0xCF, 0xFD, 0x05, 0x56},
{0x2F, 0x22, 0xE4, 0x9B, 0xAB, 0x7C, 0xA1, 0xAC},
{0x5A, 0x6B, 0x61, 0x2C, 0xC2, 0x6C, 0xCE, 0x4A},
{0x5F, 0x4C, 0x03, 0x8E, 0xD1, 0x2B, 0x2E, 0x41},
{0x63, 0xFA, 0xC0, 0xD0, 0x34, 0xD9, 0xF7, 0x93},
{0x61, 0x7B, 0x3A, 0x0C, 0xE8, 0xF0, 0x71, 0x00},
{0xDB, 0x95, 0x86, 0x05, 0xF8, 0xC8, 0xC6, 0x06},
{0xED, 0xBF, 0xD1, 0xC6, 0x6C, 0x29, 0xCC, 0xC7},
{0x35, 0x55, 0x50, 0xB2, 0x15, 0x0E, 0x24, 0x51},
{0xCA, 0xAA, 0xAF, 0x4D, 0xEA, 0xF1, 0xDB, 0xAE},
{0xD5, 0xD4, 0x4F, 0xF7, 0x20, 0x68, 0x3D, 0x0D},
{0x2A, 0x2B, 0xB0, 0x08, 0xDF, 0x97, 0xC2, 0xF2}
};
static unsigned char cipher_ecb2[NUM_TESTS - 1][8] = {
{0x92, 0x95, 0xB5, 0x9B, 0xB3, 0x84, 0x73, 0x6E},
{0x19, 0x9E, 0x9D, 0x6D, 0xF3, 0x9A, 0xA8, 0x16},
{0x2A, 0x4B, 0x4D, 0x24, 0x52, 0x43, 0x84, 0x27},
{0x35, 0x84, 0x3C, 0x01, 0x9D, 0x18, 0xC5, 0xB6},
{0x4A, 0x5B, 0x2F, 0x42, 0xAA, 0x77, 0x19, 0x25},
{0xA0, 0x6B, 0xA9, 0xB8, 0xCA, 0x5B, 0x17, 0x8A},
{0xAB, 0x9D, 0xB7, 0xFB, 0xED, 0x95, 0xF2, 0x74},
{0x3D, 0x25, 0x6C, 0x23, 0xA7, 0x25, 0x2F, 0xD6},
{0xB7, 0x6F, 0xAB, 0x4F, 0xBD, 0xBD, 0xB7, 0x67},
{0x8F, 0x68, 0x27, 0xD6, 0x9C, 0xF4, 0x1A, 0x10},
{0x82, 0x57, 0xA1, 0xD6, 0x50, 0x5E, 0x81, 0x85},
{0xA2, 0x0F, 0x0A, 0xCD, 0x80, 0x89, 0x7D, 0xFA},
{0xCD, 0x2A, 0x53, 0x3A, 0xDB, 0x0D, 0x7E, 0xF3},
{0xD2, 0xC2, 0xBE, 0x27, 0xE8, 0x1B, 0x68, 0xE3},
{0xE9, 0x24, 0xCF, 0x4F, 0x89, 0x3C, 0x5B, 0x0A},
{0xA7, 0x18, 0xC3, 0x9F, 0xFA, 0x9F, 0xD7, 0x69},
{0x77, 0x2C, 0x79, 0xB1, 0xD2, 0x31, 0x7E, 0xB1},
{0x49, 0xAB, 0x92, 0x7F, 0xD0, 0x22, 0x00, 0xB7},
{0xCE, 0x1C, 0x6C, 0x7D, 0x85, 0xE3, 0x4A, 0x6F},
{0xBE, 0x91, 0xD6, 0xE1, 0x27, 0xB2, 0xE9, 0x87},
{0x70, 0x28, 0xAE, 0x8F, 0xD1, 0xF5, 0x74, 0x1A},
{0xAA, 0x37, 0x80, 0xBB, 0xF3, 0x22, 0x1D, 0xDE},
{0xA6, 0xC4, 0xD2, 0x5E, 0x28, 0x93, 0xAC, 0xB3},
{0x22, 0x07, 0x81, 0x5A, 0xE4, 0xB7, 0x1A, 0xAD},
{0xDC, 0xCE, 0x05, 0xE7, 0x07, 0xBD, 0xF5, 0x84},
{0x26, 0x1D, 0x39, 0x2C, 0xB3, 0xBA, 0xA5, 0x85},
{0xB4, 0xF7, 0x0F, 0x72, 0xFB, 0x04, 0xF0, 0xDC},
{0x95, 0xBA, 0xA9, 0x4E, 0x87, 0x36, 0xF2, 0x89},
{0xD4, 0x07, 0x3A, 0xF1, 0x5A, 0x17, 0x82, 0x0E},
{0xEF, 0x6F, 0xAF, 0xA7, 0x66, 0x1A, 0x7E, 0x89},
{0xC1, 0x97, 0xF5, 0x58, 0x74, 0x8A, 0x20, 0xE7},
{0x43, 0x34, 0xCF, 0xDA, 0x22, 0xC4, 0x86, 0xC8},
{0x08, 0xD7, 0xB4, 0xFB, 0x62, 0x9D, 0x08, 0x85}
};
static unsigned char cbc_key[8] =
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
static unsigned char cbc2_key[8] =
{ 0xf1, 0xe0, 0xd3, 0xc2, 0xb5, 0xa4, 0x97, 0x86 };
static unsigned char cbc3_key[8] =
{ 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 };
static unsigned char cbc_iv[8] =
{ 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 };
/*
* Changed the following text constant to binary so it will work on ebcdic
* machines :-)
*/
/* static char cbc_data[40]="7654321 Now is the time for \0001"; */
static unsigned char cbc_data[40] = {
0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
0x4E, 0x6F, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
0x68, 0x65, 0x20, 0x74, 0x69, 0x6D, 0x65, 0x20,
0x66, 0x6F, 0x72, 0x20, 0x00, 0x31, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static unsigned char cbc_ok[32] = {
0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68,
0x1d, 0x26, 0x93, 0x97, 0xf7, 0xfe, 0x62, 0xb4
};
# ifdef SCREW_THE_PARITY
# error "SCREW_THE_PARITY is not meant to be defined."
# error "Original vectors are preserved for reference only."
static unsigned char cbc2_key[8] =
{ 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 };
static unsigned char xcbc_ok[32] = {
0x86, 0x74, 0x81, 0x0D, 0x61, 0xA4, 0xA5, 0x48,
0xB9, 0x93, 0x03, 0xE1, 0xB8, 0xBB, 0xBD, 0xBD,
0x64, 0x30, 0x0B, 0xB9, 0x06, 0x65, 0x81, 0x76,
0x04, 0x1D, 0x77, 0x62, 0x17, 0xCA, 0x2B, 0xD2,
};
# else
static unsigned char xcbc_ok[32] = {
0x84, 0x6B, 0x29, 0x14, 0x85, 0x1E, 0x9A, 0x29,
0x54, 0x73, 0x2F, 0x8A, 0xA0, 0xA6, 0x11, 0xC1,
0x15, 0xCD, 0xC2, 0xD7, 0x95, 0x1B, 0x10, 0x53,
0xA6, 0x3C, 0x5E, 0x03, 0xB2, 0x1A, 0xA3, 0xC4,
};
# endif
static unsigned char cbc3_ok[32] = {
0x3F, 0xE3, 0x01, 0xC9, 0x62, 0xAC, 0x01, 0xD0,
0x22, 0x13, 0x76, 0x3C, 0x1C, 0xBD, 0x4C, 0xDC,
0x79, 0x96, 0x57, 0xC0, 0x64, 0xEC, 0xF5, 0xD4,
0x1C, 0x67, 0x38, 0x12, 0xCF, 0xDE, 0x96, 0x75
};
static unsigned char pcbc_ok[32] = {
0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
0x6d, 0xec, 0xb4, 0x70, 0xa0, 0xe5, 0x6b, 0x15,
0xae, 0xa6, 0xbf, 0x61, 0xed, 0x7d, 0x9c, 0x9f,
0xf7, 0x17, 0x46, 0x3b, 0x8a, 0xb3, 0xcc, 0x88
};
static unsigned char cfb_key[8] =
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
static unsigned char cfb_iv[8] =
{ 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef };
static unsigned char cfb_buf1[40], cfb_buf2[40], cfb_tmp[8];
static unsigned char plain[24] = {
0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73,
0x20, 0x74, 0x68, 0x65, 0x20, 0x74,
0x69, 0x6d, 0x65, 0x20, 0x66, 0x6f,
0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20
};
static unsigned char cfb_cipher8[24] = {
0xf3, 0x1f, 0xda, 0x07, 0x01, 0x14, 0x62, 0xee, 0x18, 0x7f, 0x43, 0xd8,
0x0a, 0x7c, 0xd9, 0xb5, 0xb0, 0xd2, 0x90, 0xda, 0x6e, 0x5b, 0x9a, 0x87
};
static unsigned char cfb_cipher16[24] = {
0xF3, 0x09, 0x87, 0x87, 0x7F, 0x57, 0xF7, 0x3C, 0x36, 0xB6, 0xDB, 0x70,
0xD8, 0xD5, 0x34, 0x19, 0xD3, 0x86, 0xB2, 0x23, 0xB7, 0xB2, 0xAD, 0x1B
};
static unsigned char cfb_cipher32[24] = {
0xF3, 0x09, 0x62, 0x49, 0xA4, 0xDF, 0xA4, 0x9F, 0x33, 0xDC, 0x7B, 0xAD,
0x4C, 0xC8, 0x9F, 0x64, 0xE4, 0x53, 0xE5, 0xEC, 0x67, 0x20, 0xDA, 0xB6
};
static unsigned char cfb_cipher48[24] = {
0xF3, 0x09, 0x62, 0x49, 0xC7, 0xF4, 0x30, 0xB5, 0x15, 0xEC, 0xBB, 0x85,
0x97, 0x5A, 0x13, 0x8C, 0x68, 0x60, 0xE2, 0x38, 0x34, 0x3C, 0xDC, 0x1F
};
static unsigned char cfb_cipher64[24] = {
0xF3, 0x09, 0x62, 0x49, 0xC7, 0xF4, 0x6E, 0x51, 0xA6, 0x9E, 0x83, 0x9B,
0x1A, 0x92, 0xF7, 0x84, 0x03, 0x46, 0x71, 0x33, 0x89, 0x8E, 0xA6, 0x22
};
static unsigned char ofb_key[8] =
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
static unsigned char ofb_iv[8] =
{ 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef };
static unsigned char ofb_buf1[24], ofb_buf2[24], ofb_tmp[8];
static unsigned char ofb_cipher[24] = {
0xf3, 0x09, 0x62, 0x49, 0xc7, 0xf4, 0x6e, 0x51,
0x35, 0xf2, 0x4a, 0x24, 0x2e, 0xeb, 0x3d, 0x3f,
0x3d, 0x6d, 0x5b, 0xe3, 0x25, 0x5a, 0xf8, 0xc3
};
static DES_LONG cbc_cksum_ret = 0xF7FE62B4L;
static unsigned char cbc_cksum_data[8] =
{ 0x1D, 0x26, 0x93, 0x97, 0xf7, 0xfe, 0x62, 0xb4 };
static char *pt(const unsigned char *p, char buf[DATA_BUF_SIZE])
{
char *ret;
int i;
static const char *f = "0123456789ABCDEF";
ret = &(buf[0]);
for (i = 0; i < 8; i++) {
ret[i * 2] = f[(p[i] >> 4) & 0xf];
ret[i * 2 + 1] = f[p[i] & 0xf];
}
ret[16] = '\0';
return ret;
}
static int test_des_ecb(int i)
{
DES_key_schedule ks;
DES_cblock in, out, outin;
char b1[DATA_BUF_SIZE], b2[DATA_BUF_SIZE];
DES_set_key_unchecked(&key_data[i], &ks);
memcpy(in, plain_data[i], 8);
memset(out, 0, 8);
memset(outin, 0, 8);
DES_ecb_encrypt(&in, &out, &ks, DES_ENCRYPT);
DES_ecb_encrypt(&out, &outin, &ks, DES_DECRYPT);
if (!TEST_mem_eq(out, 8, cipher_data[i], 8)) {
TEST_info("Encryption error %2d k=%s p=%s", i + 1,
pt(key_data[i], b1), pt(in, b2));
return 0;
}
if (!TEST_mem_eq(in, 8, outin, 8)) {
TEST_info("Decryption error %2d k=%s p=%s", i + 1,
pt(key_data[i], b1), pt(out, b2));
return 0;
}
return 1;
}
static int test_des_ede_ecb(int i)
{
DES_cblock in, out, outin;
DES_key_schedule ks, ks2, ks3;
char b1[DATA_BUF_SIZE], b2[DATA_BUF_SIZE];
DES_set_key_unchecked(&key_data[i], &ks);
DES_set_key_unchecked(&key_data[i + 1], &ks2);
DES_set_key_unchecked(&key_data[i + 2], &ks3);
memcpy(in, plain_data[i], 8);
memset(out, 0, 8);
memset(outin, 0, 8);
DES_ecb3_encrypt(&in, &out, &ks, &ks2, &ks, DES_ENCRYPT);
DES_ecb3_encrypt(&out, &outin, &ks, &ks2, &ks, DES_DECRYPT);
if (!TEST_mem_eq(out, 8, cipher_ecb2[i], 8)) {
TEST_info("Encryption error %2d k=%s p=%s", i + 1,
pt(key_data[i], b1), pt(in, b2));
return 0;
}
if (!TEST_mem_eq(in, 8, outin, 8)) {
TEST_info("Decryption error %2d k=%s p=%s ", i + 1,
pt(key_data[i], b1), pt(out, b2));
return 0;
}
return 1;
}
static int test_des_cbc(void)
{
unsigned char cbc_in[40];
unsigned char cbc_out[40];
DES_cblock iv3;
DES_key_schedule ks;
const size_t cbc_data_len = strlen((char *)cbc_data);
if (!TEST_int_eq(DES_set_key_checked(&cbc_key, &ks), 0))
return 0;
memset(cbc_out, 0, sizeof(cbc_out));
memset(cbc_in, 0, sizeof(cbc_in));
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
DES_ncbc_encrypt(cbc_data, cbc_out, cbc_data_len + 1, &ks,
&iv3, DES_ENCRYPT);
if (!TEST_mem_eq(cbc_out, 32, cbc_ok, 32))
return 0;
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
DES_ncbc_encrypt(cbc_out, cbc_in, cbc_data_len + 1, &ks,
&iv3, DES_DECRYPT);
return TEST_mem_eq(cbc_in, cbc_data_len, cbc_data, cbc_data_len);
}
static int test_des_ede_cbc(void)
{
DES_cblock iv3;
DES_key_schedule ks;
unsigned char cbc_in[40];
unsigned char cbc_out[40];
const size_t n = strlen((char *)cbc_data) + 1;
if (!TEST_int_eq(DES_set_key_checked(&cbc_key, &ks), 0))
return 0;
memset(cbc_out, 0, sizeof(cbc_out));
memset(cbc_in, 0, sizeof(cbc_in));
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
DES_xcbc_encrypt(cbc_data, cbc_out, n, &ks, &iv3, &cbc2_key, &cbc3_key,
DES_ENCRYPT);
if (!TEST_mem_eq(cbc_out, sizeof(xcbc_ok), xcbc_ok, sizeof(xcbc_ok)))
return 0;
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
DES_xcbc_encrypt(cbc_out, cbc_in, n, &ks, &iv3, &cbc2_key, &cbc3_key,
DES_DECRYPT);
return TEST_mem_eq(cbc_data, n, cbc_data, n);
}
static int test_ede_cbc(void)
{
DES_cblock iv3;
DES_key_schedule ks, ks2, ks3;
unsigned char cbc_in[40];
unsigned char cbc_out[40];
const size_t i = strlen((char *)cbc_data) + 1;
const size_t n = (i + 7) / 8 * 8;
if (!TEST_int_eq(DES_set_key_checked(&cbc_key, &ks), 0))
return 0;
if (!TEST_int_eq(DES_set_key_checked(&cbc2_key, &ks2), 0))
return 0;
if (!TEST_int_eq(DES_set_key_checked(&cbc3_key, &ks3), 0))
return 0;
memset(cbc_out, 0, sizeof(cbc_out));
memset(cbc_in, 0, sizeof(cbc_in));
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
DES_ede3_cbc_encrypt(cbc_data, cbc_out, 16L, &ks, &ks2, &ks3, &iv3,
DES_ENCRYPT);
DES_ede3_cbc_encrypt(&cbc_data[16], &cbc_out[16], i - 16, &ks, &ks2,
&ks3, &iv3, DES_ENCRYPT);
if (!TEST_mem_eq(cbc_out, n, cbc3_ok, n))
return 0;
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
DES_ede3_cbc_encrypt(cbc_out, cbc_in, i, &ks, &ks2, &ks3, &iv3,
DES_DECRYPT);
return TEST_mem_eq(cbc_in, i, cbc_data, i);
}
static int test_input_align(int i)
{
unsigned char cbc_out[40];
DES_cblock iv;
DES_key_schedule ks;
const size_t n = strlen(i + (char *)cbc_data) + 1;
memset(cbc_out, 0, sizeof(cbc_out));
memcpy(iv, cbc_iv, sizeof(cbc_iv));
if (!TEST_int_eq(DES_set_key_checked(&cbc_key, &ks), 0))
return 0;
DES_ncbc_encrypt(&cbc_data[i], cbc_out, n, &ks, &iv, DES_ENCRYPT);
return 1;
}
static int test_output_align(int i)
{
unsigned char cbc_out[40];
DES_cblock iv;
DES_key_schedule ks;
const size_t n = strlen((char *)cbc_data) + 1;
memset(cbc_out, 0, sizeof(cbc_out));
memcpy(iv, cbc_iv, sizeof(cbc_iv));
if (!TEST_int_eq(DES_set_key_checked(&cbc_key, &ks), 0))
return 0;
DES_ncbc_encrypt(cbc_data, &cbc_out[i], n, &ks, &iv, DES_ENCRYPT);
return 1;
}
static int test_des_crypt(void)
{
if (!TEST_str_eq("efGnQx2725bI2", DES_crypt("testing", "ef")))
return 0;
if (!TEST_str_eq("yA1Rp/1hZXIJk", DES_crypt("bca76;23", "yA")))
return 0;
if (!TEST_ptr_null(DES_crypt("testing", "y\202")))
return 0;
if (!TEST_ptr_null(DES_crypt("testing", "\0A")))
return 0;
if (!TEST_ptr_null(DES_crypt("testing", "A")))
return 0;
return 1;
}
static int test_des_pcbc(void)
{
unsigned char cbc_in[40];
unsigned char cbc_out[40];
DES_key_schedule ks;
const int n = strlen((char *)cbc_data) + 1;
if (!TEST_int_eq(DES_set_key_checked(&cbc_key, &ks), 0))
return 0;
memset(cbc_out, 0, sizeof(cbc_out));
memset(cbc_in, 0, sizeof(cbc_in));
DES_pcbc_encrypt(cbc_data, cbc_out, n, &ks,
&cbc_iv, DES_ENCRYPT);
if (!TEST_mem_eq(cbc_out, sizeof(pcbc_ok), pcbc_ok, sizeof(pcbc_ok)))
return 0;
DES_pcbc_encrypt(cbc_out, cbc_in, n, &ks,
&cbc_iv, DES_DECRYPT);
return TEST_mem_eq(cbc_in, n, cbc_data, n);
}
static int cfb_test(int bits, unsigned char *cfb_cipher)
{
DES_key_schedule ks;
DES_set_key_checked(&cfb_key, &ks);
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
DES_cfb_encrypt(plain, cfb_buf1, bits, sizeof(plain), &ks, &cfb_tmp,
DES_ENCRYPT);
if (!TEST_mem_eq(cfb_cipher, sizeof(plain), cfb_buf1, sizeof(plain)))
return 0;
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
DES_cfb_encrypt(cfb_buf1, cfb_buf2, bits, sizeof(plain), &ks, &cfb_tmp,
DES_DECRYPT);
return TEST_mem_eq(plain, sizeof(plain), cfb_buf2, sizeof(plain));
}
static int test_des_cfb8(void)
{
return cfb_test(8, cfb_cipher8);
}
static int test_des_cfb16(void)
{
return cfb_test(16, cfb_cipher16);
}
static int test_des_cfb32(void)
{
return cfb_test(32, cfb_cipher32);
}
static int test_des_cfb48(void)
{
return cfb_test(48, cfb_cipher48);
}
static int test_des_cfb64(void)
{
DES_key_schedule ks;
int n;
size_t i;
if (!cfb_test(64, cfb_cipher64))
return 0;
DES_set_key_checked(&cfb_key, &ks);
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
n = 0;
DES_cfb64_encrypt(plain, cfb_buf1, 12, &ks, &cfb_tmp, &n, DES_ENCRYPT);
DES_cfb64_encrypt(&plain[12], &cfb_buf1[12], sizeof(plain) - 12, &ks,
&cfb_tmp, &n, DES_ENCRYPT);
if (!TEST_mem_eq(cfb_cipher64, sizeof(plain), cfb_buf1, sizeof(plain)))
return 0;
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
n = 0;
DES_cfb64_encrypt(cfb_buf1, cfb_buf2, 17, &ks, &cfb_tmp, &n, DES_DECRYPT);
DES_cfb64_encrypt(&cfb_buf1[17], &cfb_buf2[17],
sizeof(plain) - 17, &ks, &cfb_tmp, &n, DES_DECRYPT);
if (!TEST_mem_eq(plain, sizeof(plain), cfb_buf2, sizeof(plain)))
return 0;
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
for (i = 0; i < sizeof(plain); i++)
DES_cfb_encrypt(&plain[i], &cfb_buf1[i], 8, 1, &ks, &cfb_tmp,
DES_ENCRYPT);
if (!TEST_mem_eq(cfb_cipher8, sizeof(plain), cfb_buf1, sizeof(plain)))
return 0;
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
for (i = 0; i < sizeof(plain); i++)
DES_cfb_encrypt(&cfb_buf1[i], &cfb_buf2[i], 8, 1, &ks, &cfb_tmp,
DES_DECRYPT);
return TEST_mem_eq(plain, sizeof(plain), cfb_buf2, sizeof(plain));
}
static int test_des_ede_cfb64(void)
{
DES_key_schedule ks;
int n;
DES_set_key_checked(&cfb_key, &ks);
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
n = 0;
DES_ede3_cfb64_encrypt(plain, cfb_buf1, 12, &ks, &ks, &ks, &cfb_tmp, &n,
DES_ENCRYPT);
DES_ede3_cfb64_encrypt(&plain[12], &cfb_buf1[12], sizeof(plain) - 12, &ks,
&ks, &ks, &cfb_tmp, &n, DES_ENCRYPT);
if (!TEST_mem_eq(cfb_cipher64, sizeof(plain), cfb_buf1, sizeof(plain)))
return 0;
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
n = 0;
DES_ede3_cfb64_encrypt(cfb_buf1, cfb_buf2, (long)17, &ks, &ks, &ks,
&cfb_tmp, &n, DES_DECRYPT);
DES_ede3_cfb64_encrypt(&cfb_buf1[17], &cfb_buf2[17], sizeof(plain) - 17,
&ks, &ks, &ks, &cfb_tmp, &n, DES_DECRYPT);
return TEST_mem_eq(plain, sizeof(plain), cfb_buf2, sizeof(plain));
}
static int test_des_ofb(void)
{
DES_key_schedule ks;
DES_set_key_checked(&ofb_key, &ks);
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
DES_ofb_encrypt(plain, ofb_buf1, 64, sizeof(plain) / 8, &ks, &ofb_tmp);
if (!TEST_mem_eq(ofb_cipher, sizeof(ofb_buf1), ofb_buf1, sizeof(ofb_buf1)))
return 0;
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
DES_ofb_encrypt(ofb_buf1, ofb_buf2, 64, sizeof(ofb_buf1) / 8, &ks,
&ofb_tmp);
return TEST_mem_eq(plain, sizeof(ofb_buf2), ofb_buf2, sizeof(ofb_buf2));
}
static int test_des_ofb64(void)
{
DES_key_schedule ks;
int num;
size_t i;
DES_set_key_checked(&ofb_key, &ks);
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
memset(ofb_buf1, 0, sizeof(ofb_buf1));
memset(ofb_buf2, 0, sizeof(ofb_buf1));
num = 0;
for (i = 0; i < sizeof(plain); i++) {
DES_ofb64_encrypt(&plain[i], &ofb_buf1[i], 1, &ks, &ofb_tmp, &num);
}
if (!TEST_mem_eq(ofb_cipher, sizeof(ofb_buf1), ofb_buf1, sizeof(ofb_buf1)))
return 0;
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
num = 0;
DES_ofb64_encrypt(ofb_buf1, ofb_buf2, sizeof(ofb_buf1), &ks, &ofb_tmp,
&num);
return TEST_mem_eq(plain, sizeof(ofb_buf2), ofb_buf2, sizeof(ofb_buf2));
}
static int test_des_ede_ofb64(void)
{
DES_key_schedule ks;
int num;
size_t i;
DES_set_key_checked(&ofb_key, &ks);
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
memset(ofb_buf1, 0, sizeof(ofb_buf1));
memset(ofb_buf2, 0, sizeof(ofb_buf1));
num = 0;
for (i = 0; i < sizeof(plain); i++) {
DES_ede3_ofb64_encrypt(&plain[i], &ofb_buf1[i], 1, &ks, &ks,
&ks, &ofb_tmp, &num);
}
if (!TEST_mem_eq(ofb_cipher, sizeof(ofb_buf1), ofb_buf1, sizeof(ofb_buf1)))
return 0;
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
num = 0;
DES_ede3_ofb64_encrypt(ofb_buf1, ofb_buf2, sizeof(ofb_buf1), &ks, &ks, &ks,
&ofb_tmp, &num);
return TEST_mem_eq(plain, sizeof(ofb_buf2), ofb_buf2, sizeof(ofb_buf2));
}
static int test_des_cbc_cksum(void)
{
DES_LONG cs;
DES_key_schedule ks;
unsigned char cret[8];
DES_set_key_checked(&cbc_key, &ks);
cs = DES_cbc_cksum(cbc_data, &cret, strlen((char *)cbc_data), &ks,
&cbc_iv);
if (!TEST_cs_eq(cs, cbc_cksum_ret))
return 0;
return TEST_mem_eq(cret, 8, cbc_cksum_data, 8);
}
static int test_des_quad_cksum(void)
{
DES_LONG cs, lqret[4];
cs = DES_quad_cksum(cbc_data, (DES_cblock *)lqret,
(long)strlen((char *)cbc_data), 2,
(DES_cblock *)cbc_iv);
if (!TEST_cs_eq(cs, 0x70d7a63aL))
return 0;
if (!TEST_cs_eq(lqret[0], 0x327eba8dL))
return 0;
if (!TEST_cs_eq(lqret[1], 0x201a49ccL))
return 0;
if (!TEST_cs_eq(lqret[2], 0x70d7a63aL))
return 0;
if (!TEST_cs_eq(lqret[3], 0x501c2c26L))
return 0;
return 1;
}
/*
* Test TDES based key wrapping.
* The wrapping process uses a randomly generated IV so it is difficult to
* undertake KATs. End to end testing is performed instead.
*/
static const int test_des_key_wrap_sizes[] = {
8, 16, 24, 32, 64, 80
};
static int test_des_key_wrap(int idx)
{
int in_bytes = test_des_key_wrap_sizes[idx];
unsigned char in[100], c_txt[200], p_txt[200], key[24];
int clen, clen_upd, clen_fin, plen, plen_upd, plen_fin, expect, bs, i;
EVP_CIPHER *cipher = NULL;
EVP_CIPHER_CTX *ctx = NULL;
int res = 0;
/* Some sanity checks and cipher loading */
if (!TEST_size_t_le(in_bytes, sizeof(in))
|| !TEST_ptr(cipher = EVP_CIPHER_fetch(NULL, "DES3-WRAP", NULL))
|| !TEST_int_eq(bs = EVP_CIPHER_get_block_size(cipher), 8)
|| !TEST_size_t_eq(bs * 3u, sizeof(key))
|| !TEST_true(in_bytes % bs == 0)
|| !TEST_ptr(ctx = EVP_CIPHER_CTX_new()))
goto err;
/* Create random data to end to end test */
for (i = 0; i < in_bytes; i++)
in[i] = test_random();
/* Build the key */
memcpy(key, cbc_key, sizeof(cbc_key));
memcpy(key + sizeof(cbc_key), cbc2_key, sizeof(cbc2_key));
memcpy(key + sizeof(cbc_key) + sizeof(cbc3_key), cbc_key, sizeof(cbc3_key));
/* Wrap / encrypt the key */
clen_upd = sizeof(c_txt);
if (!TEST_true(EVP_EncryptInit(ctx, cipher, key, NULL))
|| !TEST_true(EVP_EncryptUpdate(ctx, c_txt, &clen_upd,
in, in_bytes)))
goto err;
expect = (in_bytes + (bs - 1)) / bs * bs + 2 * bs;
if (!TEST_int_eq(clen_upd, expect))
goto err;
clen_fin = sizeof(c_txt) - clen_upd;
if (!TEST_true(EVP_EncryptFinal(ctx, c_txt + clen_upd, &clen_fin))
|| !TEST_int_eq(clen_fin, 0))
goto err;
clen = clen_upd + clen_fin;
/* Decrypt the wrapped key */
plen_upd = sizeof(p_txt);
if (!TEST_true(EVP_DecryptInit(ctx, cipher, key, NULL))
|| !TEST_true(EVP_DecryptUpdate(ctx, p_txt, &plen_upd,
c_txt, clen)))
goto err;
plen_fin = sizeof(p_txt) - plen_upd;
if (!TEST_true(EVP_DecryptFinal(ctx, p_txt + plen_upd, &plen_fin)))
goto err;
plen = plen_upd + plen_fin;
if (!TEST_mem_eq(in, in_bytes, p_txt, plen))
goto err;
res = 1;
err:
EVP_CIPHER_free(cipher);
EVP_CIPHER_CTX_free(ctx);
return res;
}
/*-
* Weak and semi weak keys as taken from
* %A D.W. Davies
* %A W.L. Price
* %T Security for Computer Networks
* %I John Wiley & Sons
* %D 1984
*/
static struct {
const DES_cblock key;
int expect;
} weak_keys[] = {
/* weak keys */
{{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, 1 },
{{0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE}, 1 },
{{0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E}, 1 },
{{0xE0, 0xE0, 0xE0, 0xE0, 0xF1, 0xF1, 0xF1, 0xF1}, 1 },
/* semi-weak keys */
{{0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE}, 1 },
{{0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01}, 1 },
{{0x1F, 0xE0, 0x1F, 0xE0, 0x0E, 0xF1, 0x0E, 0xF1}, 1 },
{{0xE0, 0x1F, 0xE0, 0x1F, 0xF1, 0x0E, 0xF1, 0x0E}, 1 },
{{0x01, 0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1}, 1 },
{{0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1, 0x01}, 1 },
{{0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E, 0xFE}, 1 },
{{0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E}, 1 },
{{0x01, 0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E}, 1 },
{{0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E, 0x01}, 1 },
{{0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE}, 1 },
{{0xFE, 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1}, 1 },
/* good key */
{{0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF}, 0 }
};
static int test_des_weak_keys(int n)
{
const_DES_cblock *key = (unsigned char (*)[8])weak_keys[n].key;
return TEST_int_eq(DES_is_weak_key(key), weak_keys[n].expect);
}
static struct {
const DES_cblock key;
int expect;
} bad_parity_keys[] = {
{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0 },
{{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 0 },
/* Perturb each byte in turn to create even parity */
{{0x48, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF}, 0 },
{{0x49, 0xE8, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF}, 0 },
{{0x49, 0xE9, 0x5C, 0x6D, 0x4C, 0xA2, 0x29, 0xBF}, 0 },
{{0x49, 0xE9, 0x5D, 0x7D, 0x4C, 0xA2, 0x29, 0xBF}, 0 },
{{0x49, 0xE9, 0x5D, 0x6D, 0x5C, 0xA2, 0x29, 0xBF}, 0 },
{{0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA3, 0x29, 0xBF}, 0 },
{{0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x39, 0xBF}, 0 },
{{0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBE}, 0 },
/* Odd parity version of above */
{{0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF}, 1 }
};
static int test_des_check_bad_parity(int n)
{
const_DES_cblock *key = (unsigned char (*)[8])bad_parity_keys[n].key;
return TEST_int_eq(DES_check_key_parity(key), bad_parity_keys[n].expect);
}
/* Test that two key 3DES can generate a random key without error */
static int test_des_two_key(void)
{
int res = 0;
EVP_CIPHER *cipher = NULL;
EVP_CIPHER_CTX *ctx = NULL;
unsigned char key[16];
if (!TEST_ptr(cipher = EVP_CIPHER_fetch(NULL, "DES-EDE-ECB", NULL))
|| !TEST_ptr(ctx = EVP_CIPHER_CTX_new())
|| !EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, 1)
|| !EVP_CIPHER_CTX_set_key_length(ctx, sizeof(key))
|| !EVP_CIPHER_CTX_rand_key(ctx, key))
goto err;
res = 1;
err:
EVP_CIPHER_free(cipher);
EVP_CIPHER_CTX_free(ctx);
return res;
}
#endif
int setup_tests(void)
{
#ifndef OPENSSL_NO_DES
ADD_ALL_TESTS(test_des_ecb, NUM_TESTS);
ADD_TEST(test_des_cbc);
ADD_TEST(test_ede_cbc);
ADD_ALL_TESTS(test_des_ede_ecb, NUM_TESTS - 2);
ADD_TEST(test_des_ede_cbc);
ADD_TEST(test_des_pcbc);
ADD_TEST(test_des_cfb8);
ADD_TEST(test_des_cfb16);
ADD_TEST(test_des_cfb32);
ADD_TEST(test_des_cfb48);
ADD_TEST(test_des_cfb64);
ADD_TEST(test_des_ede_cfb64);
ADD_TEST(test_des_ofb);
ADD_TEST(test_des_ofb64);
ADD_TEST(test_des_ede_ofb64);
ADD_TEST(test_des_cbc_cksum);
ADD_TEST(test_des_quad_cksum);
ADD_TEST(test_des_crypt);
ADD_ALL_TESTS(test_input_align, 4);
ADD_ALL_TESTS(test_output_align, 4);
ADD_ALL_TESTS(test_des_key_wrap, OSSL_NELEM(test_des_key_wrap_sizes));
ADD_ALL_TESTS(test_des_weak_keys, OSSL_NELEM(weak_keys));
ADD_ALL_TESTS(test_des_check_bad_parity, OSSL_NELEM(bad_parity_keys));
ADD_TEST(test_des_two_key);
#endif
return 1;
}
|
./openssl/test/quic_ackm_test.c | /*
* Copyright 2022-2023 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 "testutil.h"
#include <openssl/ssl.h>
#include "internal/quic_ackm.h"
#include "internal/quic_cc.h"
static OSSL_TIME fake_time = {0};
#define TIME_BASE (ossl_ticks2time(123 * OSSL_TIME_SECOND))
static OSSL_TIME fake_now(void *arg)
{
return fake_time;
}
struct pkt_info {
OSSL_ACKM_TX_PKT *pkt;
int lost, acked, discarded;
};
static void on_lost(void *arg)
{
struct pkt_info *info = arg;
++info->lost;
}
static void on_acked(void *arg)
{
struct pkt_info *info = arg;
++info->acked;
}
static void on_discarded(void *arg)
{
struct pkt_info *info = arg;
++info->discarded;
}
struct helper {
OSSL_ACKM *ackm;
struct pkt_info *pkts;
size_t num_pkts;
OSSL_CC_DATA *ccdata;
OSSL_STATM statm;
int have_statm;
};
static void helper_destroy(struct helper *h)
{
size_t i;
if (h->ackm != NULL) {
ossl_ackm_free(h->ackm);
h->ackm = NULL;
}
if (h->ccdata != NULL) {
ossl_cc_dummy_method.free(h->ccdata);
h->ccdata = NULL;
}
if (h->have_statm) {
ossl_statm_destroy(&h->statm);
h->have_statm = 0;
}
if (h->pkts != NULL) {
for (i = 0; i < h->num_pkts; ++i) {
OPENSSL_free(h->pkts[i].pkt);
h->pkts[i].pkt = NULL;
}
OPENSSL_free(h->pkts);
h->pkts = NULL;
}
}
static int helper_init(struct helper *h, size_t num_pkts)
{
int rc = 0;
memset(h, 0, sizeof(*h));
fake_time = TIME_BASE;
/* Initialise statistics tracker. */
if (!TEST_int_eq(ossl_statm_init(&h->statm), 1))
goto err;
h->have_statm = 1;
/* Initialise congestion controller. */
h->ccdata = ossl_cc_dummy_method.new(fake_now, NULL);
if (!TEST_ptr(h->ccdata))
goto err;
/* Initialise ACK manager. */
h->ackm = ossl_ackm_new(fake_now, NULL, &h->statm,
&ossl_cc_dummy_method, h->ccdata);
if (!TEST_ptr(h->ackm))
goto err;
/* Allocate our array of packet information. */
h->num_pkts = num_pkts;
if (num_pkts > 0) {
h->pkts = OPENSSL_zalloc(sizeof(struct pkt_info) * num_pkts);
if (!TEST_ptr(h->pkts))
goto err;
} else {
h->pkts = NULL;
}
rc = 1;
err:
if (rc == 0)
helper_destroy(h);
return rc;
}
static const QUIC_PN linear_20[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
};
static const QUIC_PN high_linear_20[] = {
1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008,
1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
1018, 1019
};
/*
* TX ACK (Packet Threshold) Test Cases
* ******************************************************************
*/
struct tx_ack_test_case {
const QUIC_PN *pn_table;
size_t pn_table_len;
const OSSL_QUIC_ACK_RANGE *ack_ranges;
size_t num_ack_ranges;
const char *expect_ack; /* 1=ack, 2=lost, 4=discarded */
};
#define DEFINE_TX_ACK_CASE(n, pntable) \
static const struct tx_ack_test_case tx_ack_case_##n = { \
(pntable), OSSL_NELEM(pntable), \
tx_ack_range_##n, OSSL_NELEM(tx_ack_range_##n), \
tx_ack_expect_##n \
}
/* One range, partial coverage of space */
static const OSSL_QUIC_ACK_RANGE tx_ack_range_1[] = {
{ 0, 10 },
};
static const char tx_ack_expect_1[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(1, linear_20);
/* Two ranges, partial coverage of space, overlapping by 1 */
static const OSSL_QUIC_ACK_RANGE tx_ack_range_2[] = {
{ 5, 10 }, { 0, 5 }
};
static const char tx_ack_expect_2[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(2, linear_20);
/* Two ranges, partial coverage of space, together contiguous */
static const OSSL_QUIC_ACK_RANGE tx_ack_range_3[] = {
{ 6, 10 }, { 0, 5 }
};
static const char tx_ack_expect_3[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(3, linear_20);
/*
* Two ranges, partial coverage of space, non-contiguous by 1
* Causes inferred loss due to packet threshold being exceeded.
*/
static const OSSL_QUIC_ACK_RANGE tx_ack_range_4[] = {
{ 7, 10 }, { 0, 5 }
};
static const char tx_ack_expect_4[] = {
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(4, linear_20);
/*
* Two ranges, partial coverage of space, non-contiguous by 2
* Causes inferred loss due to packet threshold being exceeded.
*/
static const OSSL_QUIC_ACK_RANGE tx_ack_range_5[] = {
{ 7, 10 }, { 0, 4 }
};
static const char tx_ack_expect_5[] = {
1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(5, linear_20);
/* One range, covering entire space */
static const OSSL_QUIC_ACK_RANGE tx_ack_range_6[] = {
{ 0, 20 },
};
static const char tx_ack_expect_6[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
DEFINE_TX_ACK_CASE(6, linear_20);
/* One range, covering more space than exists */
static const OSSL_QUIC_ACK_RANGE tx_ack_range_7[] = {
{ 0, 30 },
};
static const char tx_ack_expect_7[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
DEFINE_TX_ACK_CASE(7, linear_20);
/* One range, covering nothing (too high) */
static const OSSL_QUIC_ACK_RANGE tx_ack_range_8[] = {
{ 21, 30 },
};
static const char tx_ack_expect_8[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(8, linear_20);
/* One range, covering nothing (too low) */
static const OSSL_QUIC_ACK_RANGE tx_ack_range_9[] = {
{ 0, 999 },
};
static const char tx_ack_expect_9[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(9, high_linear_20);
/* One single packet at start of PN set */
static const OSSL_QUIC_ACK_RANGE tx_ack_range_10[] = {
{ 0, 0 },
};
static const char tx_ack_expect_10[] = {
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(10, linear_20);
/*
* One single packet in middle of PN set
* Causes inferred loss of one packet due to packet threshold being exceeded,
* but several other previous packets survive as they are under the threshold.
*/
static const OSSL_QUIC_ACK_RANGE tx_ack_range_11[] = {
{ 3, 3 },
};
static const char tx_ack_expect_11[] = {
2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(11, linear_20);
/*
* One single packet at end of PN set
* Causes inferred loss due to packet threshold being exceeded.
*/
static const OSSL_QUIC_ACK_RANGE tx_ack_range_12[] = {
{ 19, 19 },
};
static const char tx_ack_expect_12[] = {
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1
};
DEFINE_TX_ACK_CASE(12, linear_20);
/*
* Mixed straddling
* Causes inferred loss due to packet threshold being exceeded.
*/
static const OSSL_QUIC_ACK_RANGE tx_ack_range_13[] = {
{ 1008, 1008 }, { 1004, 1005 }, { 1001, 1002 }
};
static const char tx_ack_expect_13[] = {
2, 1, 1, 2, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
DEFINE_TX_ACK_CASE(13, high_linear_20);
static const struct tx_ack_test_case *const tx_ack_cases[] = {
&tx_ack_case_1,
&tx_ack_case_2,
&tx_ack_case_3,
&tx_ack_case_4,
&tx_ack_case_5,
&tx_ack_case_6,
&tx_ack_case_7,
&tx_ack_case_8,
&tx_ack_case_9,
&tx_ack_case_10,
&tx_ack_case_11,
&tx_ack_case_12,
&tx_ack_case_13,
};
enum {
MODE_ACK, MODE_DISCARD, MODE_PTO, MODE_NUM
};
static int test_probe_counts(const OSSL_ACKM_PROBE_INFO *p,
uint32_t anti_deadlock_handshake,
uint32_t anti_deadlock_initial,
uint32_t pto_initial,
uint32_t pto_handshake,
uint32_t pto_app)
{
if (!TEST_uint_eq(p->anti_deadlock_handshake, anti_deadlock_handshake))
return 0;
if (!TEST_uint_eq(p->anti_deadlock_initial, anti_deadlock_initial))
return 0;
if (!TEST_uint_eq(p->pto[QUIC_PN_SPACE_INITIAL], pto_initial))
return 0;
if (!TEST_uint_eq(p->pto[QUIC_PN_SPACE_HANDSHAKE], pto_handshake))
return 0;
if (!TEST_uint_eq(p->pto[QUIC_PN_SPACE_APP], pto_app))
return 0;
return 1;
}
static void on_loss_detection_deadline_callback(OSSL_TIME deadline, void *arg)
{
*(OSSL_TIME *)arg = deadline;
}
static int test_tx_ack_case_actual(int tidx, int space, int mode)
{
int testresult = 0;
struct helper h;
size_t i;
OSSL_ACKM_TX_PKT *tx;
const struct tx_ack_test_case *c = tx_ack_cases[tidx];
OSSL_QUIC_FRAME_ACK ack = {0};
OSSL_TIME loss_detection_deadline = ossl_time_zero();
/* Cannot discard app space, so skip this */
if (mode == MODE_DISCARD && space == QUIC_PN_SPACE_APP) {
TEST_skip("skipping test for app space");
return 1;
}
if (!TEST_int_eq(helper_init(&h, c->pn_table_len), 1))
goto err;
/* Arm callback. */
ossl_ackm_set_loss_detection_deadline_callback(h.ackm,
on_loss_detection_deadline_callback,
&loss_detection_deadline);
/* Allocate TX packet structures. */
for (i = 0; i < c->pn_table_len; ++i) {
h.pkts[i].pkt = tx = OPENSSL_zalloc(sizeof(*tx));
if (!TEST_ptr(tx))
goto err;
tx->pkt_num = c->pn_table[i];
tx->pkt_space = space;
tx->is_inflight = 1;
tx->is_ack_eliciting = 1;
tx->num_bytes = 123;
tx->largest_acked = QUIC_PN_INVALID;
tx->on_lost = on_lost;
tx->on_acked = on_acked;
tx->on_discarded = on_discarded;
tx->cb_arg = &h.pkts[i];
tx->time = fake_time;
if (!TEST_int_eq(ossl_ackm_on_tx_packet(h.ackm, tx), 1))
goto err;
}
if (mode == MODE_DISCARD) {
/* Try discarding. */
if (!TEST_int_eq(ossl_ackm_on_pkt_space_discarded(h.ackm, space), 1))
goto err;
/* Check all discard callbacks were called. */
for (i = 0; i < c->pn_table_len; ++i) {
if (!TEST_int_eq(h.pkts[i].acked, 0))
goto err;
if (!TEST_int_eq(h.pkts[i].lost, 0))
goto err;
if (!TEST_int_eq(h.pkts[i].discarded, 1))
goto err;
}
} else if (mode == MODE_ACK) {
/* Try acknowledging. */
ack.ack_ranges = (OSSL_QUIC_ACK_RANGE *)c->ack_ranges;
ack.num_ack_ranges = c->num_ack_ranges;
if (!TEST_int_eq(ossl_ackm_on_rx_ack_frame(h.ackm, &ack, space, fake_time), 1))
goto err;
/* Check correct ranges were acknowledged. */
for (i = 0; i < c->pn_table_len; ++i) {
if (!TEST_int_eq(h.pkts[i].acked,
(c->expect_ack[i] & 1) != 0 ? 1 : 0))
goto err;
if (!TEST_int_eq(h.pkts[i].lost,
(c->expect_ack[i] & 2) != 0 ? 1 : 0))
goto err;
if (!TEST_int_eq(h.pkts[i].discarded,
(c->expect_ack[i] & 4) != 0 ? 1 : 0))
goto err;
}
} else if (mode == MODE_PTO) {
OSSL_TIME deadline = ossl_ackm_get_loss_detection_deadline(h.ackm);
OSSL_ACKM_PROBE_INFO probe;
if (!TEST_int_eq(ossl_time_compare(deadline, loss_detection_deadline), 0))
goto err;
/* We should have a PTO deadline. */
if (!TEST_int_gt(ossl_time_compare(deadline, fake_time), 0))
goto err;
/* Should not have any probe requests yet. */
probe = *ossl_ackm_get0_probe_request(h.ackm);
if (!TEST_int_eq(test_probe_counts(&probe, 0, 0, 0, 0, 0), 1))
goto err;
/*
* If in app space, confirm handshake, as this is necessary to enable
* app space PTO probe requests.
*/
if (space == QUIC_PN_SPACE_APP)
if (!TEST_int_eq(ossl_ackm_on_handshake_confirmed(h.ackm), 1))
goto err;
/* Advance to the PTO deadline. */
fake_time = ossl_time_add(deadline, ossl_ticks2time(1));
if (!TEST_int_eq(ossl_ackm_on_timeout(h.ackm), 1))
goto err;
/* Should have a probe request. Not cleared by first call. */
for (i = 0; i < 3; ++i) {
probe = *ossl_ackm_get0_probe_request(h.ackm);
if (i > 0)
memset(ossl_ackm_get0_probe_request(h.ackm), 0, sizeof(probe));
if (i == 2) {
if (!TEST_int_eq(test_probe_counts(&probe, 0, 0, 0, 0, 0), 1))
goto err;
} else {
if (!TEST_int_eq(test_probe_counts(&probe, 0, 0,
space == QUIC_PN_SPACE_INITIAL,
space == QUIC_PN_SPACE_HANDSHAKE,
space == QUIC_PN_SPACE_APP), 1))
goto err;
}
}
} else
goto err;
testresult = 1;
err:
helper_destroy(&h);
return testresult;
}
/*
* TX ACK (Time Threshold) Test
* ******************************************************************
*/
enum {
TX_ACK_TIME_OP_END,
TX_ACK_TIME_OP_PKT, /* TX packets */
TX_ACK_TIME_OP_ACK, /* Synthesise incoming ACK of single PN range */
TX_ACK_TIME_OP_EXPECT /* Ack/loss assertion */
};
struct tx_ack_time_op {
int kind;
uint64_t time_advance; /* all ops */
QUIC_PN pn; /* PKT, ACK */
size_t num_pn; /* PKT, ACK */
const char *expect; /* 1=ack, 2=lost, 4=discarded */
};
#define TX_OP_PKT(advance, pn, num_pn) \
{ TX_ACK_TIME_OP_PKT, (advance) * OSSL_TIME_MS, (pn), (num_pn), NULL },
#define TX_OP_ACK(advance, pn, num_pn) \
{ TX_ACK_TIME_OP_ACK, (advance) * OSSL_TIME_MS, (pn), (num_pn), NULL },
#define TX_OP_EXPECT(expect) \
{ TX_ACK_TIME_OP_EXPECT, 0, 0, 0, (expect) },
#define TX_OP_END { TX_ACK_TIME_OP_END }
static const char tx_ack_time_script_1_expect[] = {
2, 1
};
static const struct tx_ack_time_op tx_ack_time_script_1[] = {
TX_OP_PKT ( 0, 0, 1)
TX_OP_PKT (3600000, 1, 1)
TX_OP_ACK ( 1000, 1, 1)
TX_OP_EXPECT(tx_ack_time_script_1_expect)
TX_OP_END
};
static const struct tx_ack_time_op *const tx_ack_time_scripts[] = {
tx_ack_time_script_1,
};
static int test_tx_ack_time_script(int tidx)
{
int testresult = 0;
struct helper h;
OSSL_ACKM_TX_PKT *tx = NULL;
OSSL_QUIC_FRAME_ACK ack = {0};
OSSL_QUIC_ACK_RANGE ack_range = {0};
size_t i, num_pkts = 0, pkt_idx = 0;
const struct tx_ack_time_op *script = tx_ack_time_scripts[tidx], *s;
/* Calculate number of packets. */
for (s = script; s->kind != TX_ACK_TIME_OP_END; ++s)
if (s->kind == TX_ACK_TIME_OP_PKT)
num_pkts += s->num_pn;
/* Initialise ACK manager and packet structures. */
if (!TEST_int_eq(helper_init(&h, num_pkts), 1))
goto err;
for (i = 0; i < num_pkts; ++i) {
h.pkts[i].pkt = tx = OPENSSL_zalloc(sizeof(*tx));
if (!TEST_ptr(tx))
goto err;
}
/* Run script. */
for (s = script; s->kind != TX_ACK_TIME_OP_END; ++s)
switch (s->kind) {
case TX_ACK_TIME_OP_PKT:
for (i = 0; i < s->num_pn; ++i) {
tx = h.pkts[pkt_idx + i].pkt;
tx->pkt_num = s->pn + i;
tx->pkt_space = QUIC_PN_SPACE_INITIAL;
tx->num_bytes = 123;
tx->largest_acked = QUIC_PN_INVALID;
tx->is_inflight = 1;
tx->is_ack_eliciting = 1;
tx->on_lost = on_lost;
tx->on_acked = on_acked;
tx->on_discarded = on_discarded;
tx->cb_arg = &h.pkts[pkt_idx + i];
fake_time = ossl_time_add(fake_time,
ossl_ticks2time(s->time_advance));
tx->time = fake_time;
if (!TEST_int_eq(ossl_ackm_on_tx_packet(h.ackm, tx), 1))
goto err;
}
pkt_idx += s->num_pn;
break;
case TX_ACK_TIME_OP_ACK:
ack.ack_ranges = &ack_range;
ack.num_ack_ranges = 1;
ack_range.start = s->pn;
ack_range.end = s->pn + s->num_pn;
fake_time = ossl_time_add(fake_time,
ossl_ticks2time(s->time_advance));
if (!TEST_int_eq(ossl_ackm_on_rx_ack_frame(h.ackm, &ack,
QUIC_PN_SPACE_INITIAL,
fake_time), 1))
goto err;
break;
case TX_ACK_TIME_OP_EXPECT:
for (i = 0; i < num_pkts; ++i) {
if (!TEST_int_eq(h.pkts[i].acked,
(s->expect[i] & 1) != 0 ? 1 : 0))
goto err;
if (!TEST_int_eq(h.pkts[i].lost,
(s->expect[i] & 2) != 0 ? 1 : 0))
goto err;
if (!TEST_int_eq(h.pkts[i].discarded,
(s->expect[i] & 4) != 0 ? 1 : 0))
goto err;
}
break;
}
testresult = 1;
err:
helper_destroy(&h);
return testresult;
}
/*
* RX ACK Test
* ******************************************************************
*/
enum {
RX_OPK_END,
RX_OPK_PKT, /* RX packet */
RX_OPK_CHECK_UNPROC, /* check PNs unprocessable */
RX_OPK_CHECK_PROC, /* check PNs processable */
RX_OPK_CHECK_STATE, /* check is_desired/deadline */
RX_OPK_CHECK_ACKS, /* check ACK ranges */
RX_OPK_TX, /* TX packet */
RX_OPK_RX_ACK, /* RX ACK frame */
RX_OPK_SKIP_IF_PN_SPACE /* skip for a given PN space */
};
struct rx_test_op {
int kind;
uint64_t time_advance;
QUIC_PN pn; /* PKT, CHECK_(UN)PROC, TX, RX_ACK */
size_t num_pn; /* PKT, CHECK_(UN)PROC, TX, RX_ACK */
char expect_desired; /* CHECK_STATE */
char expect_deadline; /* CHECK_STATE */
const OSSL_QUIC_ACK_RANGE *ack_ranges; /* CHECK_ACKS */
size_t num_ack_ranges; /* CHECK_ACKS */
QUIC_PN largest_acked; /* TX */
};
#define RX_OP_PKT(advance, pn, num_pn) \
{ \
RX_OPK_PKT, (advance) * OSSL_TIME_MS, (pn), (num_pn), \
0, 0, NULL, 0, 0 \
},
#define RX_OP_CHECK_UNPROC(advance, pn, num_pn) \
{ \
RX_OPK_CHECK_UNPROC, (advance) * OSSL_TIME_MS, (pn), (num_pn),\
0, 0, NULL, 0, 0 \
},
#define RX_OP_CHECK_PROC(advance, pn, num_pn) \
{ \
RX_OPK_CHECK_PROC, (advance) * OSSL_TIME_MS, (pn), (num_pn), \
0, 0, NULL, 0, 0 \
},
#define RX_OP_CHECK_STATE(advance, expect_desired, expect_deadline) \
{ \
RX_OPK_CHECK_STATE, (advance) * OSSL_TIME_MS, 0, 0, \
(expect_desired), (expect_deadline), NULL, 0, 0 \
},
#define RX_OP_CHECK_ACKS(advance, ack_ranges) \
{ \
RX_OPK_CHECK_ACKS, (advance) * OSSL_TIME_MS, 0, 0, \
0, 0, (ack_ranges), OSSL_NELEM(ack_ranges), 0 \
},
#define RX_OP_CHECK_NO_ACKS(advance) \
{ \
RX_OPK_CHECK_ACKS, (advance) * OSSL_TIME_MS, 0, 0, \
0, 0, NULL, 0, 0 \
},
#define RX_OP_TX(advance, pn, largest_acked) \
{ \
RX_OPK_TX, (advance) * OSSL_TIME_MS, (pn), 1, \
0, 0, NULL, 0, (largest_acked) \
},
#define RX_OP_RX_ACK(advance, pn, num_pn) \
{ \
RX_OPK_RX_ACK, (advance) * OSSL_TIME_MS, (pn), (num_pn), \
0, 0, NULL, 0, 0 \
},
#define RX_OP_SKIP_IF_PN_SPACE(pn_space) \
{ \
RX_OPK_SKIP_IF_PN_SPACE, 0, (pn_space), 0, \
0, 0, NULL, 0, 0 \
},
#define RX_OP_END \
{ RX_OPK_END }
/* RX 1. Simple Test with ACK Desired (Packet Threshold, Exactly) */
static const OSSL_QUIC_ACK_RANGE rx_ack_ranges_1a[] = {
{ 0, 1 }
};
static const struct rx_test_op rx_script_1[] = {
RX_OP_CHECK_STATE (0, 0, 0) /* no threshold yet */
RX_OP_CHECK_PROC (0, 0, 3)
RX_OP_PKT (0, 0, 2) /* two packets, threshold */
RX_OP_CHECK_UNPROC (0, 0, 2)
RX_OP_CHECK_PROC (0, 2, 1)
RX_OP_CHECK_STATE (0, 1, 0) /* threshold met, immediate */
RX_OP_CHECK_ACKS (0, rx_ack_ranges_1a)
/* At this point we would generate e.g. a packet with an ACK. */
RX_OP_TX (0, 0, 1) /* ACKs both */
RX_OP_CHECK_ACKS (0, rx_ack_ranges_1a) /* not provably ACKed yet */
RX_OP_RX_ACK (0, 0, 1) /* TX'd packet is ACK'd */
RX_OP_CHECK_NO_ACKS (0) /* nothing more to ACK */
RX_OP_CHECK_UNPROC (0, 0, 2) /* still unprocessable */
RX_OP_CHECK_PROC (0, 2, 1) /* still processable */
RX_OP_END
};
/* RX 2. Simple Test with ACK Not Yet Desired (Packet Threshold) (1-RTT) */
static const OSSL_QUIC_ACK_RANGE rx_ack_ranges_2a[] = {
{ 0, 0 }
};
static const OSSL_QUIC_ACK_RANGE rx_ack_ranges_2b[] = {
{ 0, 2 }
};
static const struct rx_test_op rx_script_2[] = {
/*
* We skip this for INITIAL/HANDSHAKE and use a separate version
* (rx_script_4) for those spaces as those spaces should not delay ACK
* generation, so a different RX_OP_CHECK_STATE test is needed.
*/
RX_OP_SKIP_IF_PN_SPACE(QUIC_PN_SPACE_INITIAL)
RX_OP_SKIP_IF_PN_SPACE(QUIC_PN_SPACE_HANDSHAKE)
RX_OP_CHECK_STATE (0, 0, 0) /* no threshold yet */
RX_OP_CHECK_PROC (0, 0, 3)
/* First packet always generates an ACK so get it out of the way. */
RX_OP_PKT (0, 0, 1)
RX_OP_CHECK_UNPROC (0, 0, 1)
RX_OP_CHECK_PROC (0, 1, 1)
RX_OP_CHECK_STATE (0, 1, 0) /* first packet always causes ACK */
RX_OP_CHECK_ACKS (0, rx_ack_ranges_2a) /* clears packet counter */
RX_OP_CHECK_STATE (0, 0, 0) /* desired state should have been cleared */
/* Second packet should not cause ACK-desired state */
RX_OP_PKT (0, 1, 1) /* just one packet, threshold is 2 */
RX_OP_CHECK_UNPROC (0, 0, 2)
RX_OP_CHECK_PROC (0, 2, 1)
RX_OP_CHECK_STATE (0, 0, 1) /* threshold not yet met, so deadline */
/* Don't check ACKs here, as it would reset our threshold counter. */
/* Now receive a second packet, triggering the threshold */
RX_OP_PKT (0, 2, 1) /* second packet meets threshold */
RX_OP_CHECK_UNPROC (0, 0, 3)
RX_OP_CHECK_PROC (0, 3, 1)
RX_OP_CHECK_STATE (0, 1, 0) /* desired immediately */
RX_OP_CHECK_ACKS (0, rx_ack_ranges_2b)
/* At this point we would generate e.g. a packet with an ACK. */
RX_OP_TX (0, 0, 2) /* ACKs all */
RX_OP_CHECK_ACKS (0, rx_ack_ranges_2b) /* not provably ACKed yet */
RX_OP_RX_ACK (0, 0, 1) /* TX'd packet is ACK'd */
RX_OP_CHECK_NO_ACKS (0) /* nothing more to ACK */
RX_OP_CHECK_UNPROC (0, 0, 3) /* still unprocessable */
RX_OP_CHECK_PROC (0, 3, 1) /* still processable */
RX_OP_END
};
/* RX 3. Simple Test with ACK Desired (Packet Threshold, Multiple Watermarks) */
static const OSSL_QUIC_ACK_RANGE rx_ack_ranges_3a[] = {
{ 0, 0 }
};
static const OSSL_QUIC_ACK_RANGE rx_ack_ranges_3b[] = {
{ 0, 10 }
};
static const OSSL_QUIC_ACK_RANGE rx_ack_ranges_3c[] = {
{ 6, 10 }
};
static const struct rx_test_op rx_script_3[] = {
RX_OP_CHECK_STATE (0, 0, 0) /* no threshold yet */
RX_OP_CHECK_PROC (0, 0, 11)
/* First packet always generates an ACK so get it out of the way. */
RX_OP_PKT (0, 0, 1)
RX_OP_CHECK_UNPROC (0, 0, 1)
RX_OP_CHECK_PROC (0, 1, 1)
RX_OP_CHECK_STATE (0, 1, 0) /* first packet always causes ACK */
RX_OP_CHECK_ACKS (0, rx_ack_ranges_3a) /* clears packet counter */
RX_OP_CHECK_STATE (0, 0, 0) /* desired state should have been cleared */
/* Generate ten packets, exceeding the threshold. */
RX_OP_PKT (0, 1, 10) /* ten packets, threshold is 2 */
RX_OP_CHECK_UNPROC (0, 0, 11)
RX_OP_CHECK_PROC (0, 11, 1)
RX_OP_CHECK_STATE (0, 1, 0) /* threshold met, immediate */
RX_OP_CHECK_ACKS (0, rx_ack_ranges_3b)
/*
* Test TX'ing a packet which doesn't ACK anything.
*/
RX_OP_TX (0, 0, QUIC_PN_INVALID)
RX_OP_RX_ACK (0, 0, 1)
/*
* At this point we would generate a packet with an ACK immediately.
* TX a packet which when ACKed makes [0,5] provably ACKed.
*/
RX_OP_TX (0, 1, 5)
RX_OP_CHECK_ACKS (0, rx_ack_ranges_3b) /* not provably ACKed yet */
RX_OP_RX_ACK (0, 1, 1)
RX_OP_CHECK_ACKS (0, rx_ack_ranges_3c) /* provably ACKed now gone */
RX_OP_CHECK_UNPROC (0, 0, 11) /* still unprocessable */
RX_OP_CHECK_PROC (0, 11, 1) /* still processable */
/*
* Now TX another packet which provably ACKs the rest when ACKed.
*/
RX_OP_TX (0, 2, 10)
RX_OP_CHECK_ACKS (0, rx_ack_ranges_3c) /* not provably ACKed yet */
RX_OP_RX_ACK (0, 2, 1)
RX_OP_CHECK_NO_ACKS (0) /* provably ACKed now gone */
RX_OP_CHECK_UNPROC (0, 0, 11) /* still unprocessable */
RX_OP_CHECK_PROC (0, 11, 1) /* still processable */
RX_OP_END
};
/*
* RX 4. Simple Test with ACK Not Yet Desired (Packet Threshold)
* (Initial/Handshake)
*/
static const OSSL_QUIC_ACK_RANGE rx_ack_ranges_4a[] = {
{ 0, 1 }
};
static const struct rx_test_op rx_script_4[] = {
/* The application PN space is tested in rx_script_2. */
RX_OP_SKIP_IF_PN_SPACE(QUIC_PN_SPACE_APP)
RX_OP_CHECK_STATE (0, 0, 0) /* no threshold yet */
RX_OP_CHECK_PROC (0, 0, 3)
/* First packet always generates an ACK so get it out of the way. */
RX_OP_PKT (0, 0, 1)
RX_OP_CHECK_UNPROC (0, 0, 1)
RX_OP_CHECK_PROC (0, 1, 1)
RX_OP_CHECK_STATE (0, 1, 0) /* first packet always causes ACK */
RX_OP_CHECK_ACKS (0, rx_ack_ranges_2a) /* clears packet counter */
RX_OP_CHECK_STATE (0, 0, 0) /* desired state should have been cleared */
/*
* Second packet should cause ACK-desired state because we are
* INITIAL/HANDSHAKE (RFC 9000 s. 13.2.1)
*/
RX_OP_PKT (0, 1, 1) /* just one packet, threshold is 2 */
RX_OP_CHECK_UNPROC (0, 0, 2)
RX_OP_CHECK_PROC (0, 2, 1)
RX_OP_CHECK_STATE (0, 1, 1)
RX_OP_CHECK_ACKS (0, rx_ack_ranges_4a)
RX_OP_CHECK_STATE (0, 0, 0) /* desired state should have been cleared */
/* At this point we would generate e.g. a packet with an ACK. */
RX_OP_TX (0, 0, 1) /* ACKs all */
RX_OP_CHECK_ACKS (0, rx_ack_ranges_4a) /* not provably ACKed yet */
RX_OP_RX_ACK (0, 0, 1) /* TX'd packet is ACK'd */
RX_OP_CHECK_NO_ACKS (0) /* nothing more to ACK */
RX_OP_CHECK_UNPROC (0, 0, 2) /* still unprocessable */
RX_OP_CHECK_PROC (0, 2, 1) /* still processable */
RX_OP_END
};
static const struct rx_test_op *const rx_test_scripts[] = {
rx_script_1,
rx_script_2,
rx_script_3,
rx_script_4
};
static void on_ack_deadline_callback(OSSL_TIME deadline,
int pkt_space, void *arg)
{
((OSSL_TIME *)arg)[pkt_space] = deadline;
}
static int test_rx_ack_actual(int tidx, int space)
{
int testresult = 0;
struct helper h;
const struct rx_test_op *script = rx_test_scripts[tidx], *s;
size_t i, num_tx = 0, txi = 0;
const OSSL_QUIC_FRAME_ACK *ack;
OSSL_QUIC_FRAME_ACK rx_ack = {0};
OSSL_QUIC_ACK_RANGE rx_ack_range = {0};
struct pkt_info *pkts = NULL;
OSSL_ACKM_TX_PKT *txs = NULL, *tx;
OSSL_TIME ack_deadline[QUIC_PN_SPACE_NUM];
size_t opn = 0;
for (i = 0; i < QUIC_PN_SPACE_NUM; ++i)
ack_deadline[i] = ossl_time_infinite();
/* Initialise ACK manager. */
if (!TEST_int_eq(helper_init(&h, 0), 1))
goto err;
/* Arm callback for testing. */
ossl_ackm_set_ack_deadline_callback(h.ackm, on_ack_deadline_callback,
ack_deadline);
/*
* Determine how many packets we are TXing, and therefore how many packet
* structures we need.
*/
for (s = script; s->kind != RX_OPK_END; ++s)
if (s->kind == RX_OPK_TX)
num_tx += s->num_pn;
/* Allocate packet information structures. */
txs = OPENSSL_zalloc(sizeof(*txs) * num_tx);
if (!TEST_ptr(txs))
goto err;
pkts = OPENSSL_zalloc(sizeof(*pkts) * num_tx);
if (!TEST_ptr(pkts))
goto err;
/* Run script. */
for (s = script; s->kind != RX_OPK_END; ++s, ++opn) {
fake_time = ossl_time_add(fake_time,
ossl_ticks2time(s->time_advance));
switch (s->kind) {
case RX_OPK_PKT:
for (i = 0; i < s->num_pn; ++i) {
OSSL_ACKM_RX_PKT pkt = {0};
pkt.pkt_num = s->pn + i;
pkt.time = fake_time;
pkt.pkt_space = space;
pkt.is_ack_eliciting = 1;
/* The packet should be processable before we feed it. */
if (!TEST_int_eq(ossl_ackm_is_rx_pn_processable(h.ackm,
pkt.pkt_num,
pkt.pkt_space), 1))
goto err;
if (!TEST_int_eq(ossl_ackm_on_rx_packet(h.ackm, &pkt), 1))
goto err;
}
break;
case RX_OPK_CHECK_UNPROC:
case RX_OPK_CHECK_PROC:
for (i = 0; i < s->num_pn; ++i)
if (!TEST_int_eq(ossl_ackm_is_rx_pn_processable(h.ackm,
s->pn + i, space),
(s->kind == RX_OPK_CHECK_PROC)))
goto err;
break;
case RX_OPK_CHECK_STATE:
if (!TEST_int_eq(ossl_ackm_is_ack_desired(h.ackm, space),
s->expect_desired))
goto err;
if (!TEST_int_eq(!ossl_time_is_infinite(ossl_ackm_get_ack_deadline(h.ackm, space))
&& !ossl_time_is_zero(ossl_ackm_get_ack_deadline(h.ackm, space)),
s->expect_deadline))
goto err;
for (i = 0; i < QUIC_PN_SPACE_NUM; ++i) {
if (i != (size_t)space
&& !TEST_true(ossl_time_is_infinite(ossl_ackm_get_ack_deadline(h.ackm, i))))
goto err;
if (!TEST_int_eq(ossl_time_compare(ossl_ackm_get_ack_deadline(h.ackm, i),
ack_deadline[i]), 0))
goto err;
}
break;
case RX_OPK_CHECK_ACKS:
ack = ossl_ackm_get_ack_frame(h.ackm, space);
/* Should always be able to get an ACK frame. */
if (!TEST_ptr(ack))
goto err;
if (!TEST_size_t_eq(ack->num_ack_ranges, s->num_ack_ranges))
goto err;
for (i = 0; i < ack->num_ack_ranges; ++i) {
if (!TEST_uint64_t_eq(ack->ack_ranges[i].start,
s->ack_ranges[i].start))
goto err;
if (!TEST_uint64_t_eq(ack->ack_ranges[i].end,
s->ack_ranges[i].end))
goto err;
}
break;
case RX_OPK_TX:
pkts[txi].pkt = tx = &txs[txi];
tx->pkt_num = s->pn;
tx->pkt_space = space;
tx->num_bytes = 123;
tx->largest_acked = s->largest_acked;
tx->is_inflight = 1;
tx->is_ack_eliciting = 1;
tx->on_lost = on_lost;
tx->on_acked = on_acked;
tx->on_discarded = on_discarded;
tx->cb_arg = &pkts[txi];
tx->time = fake_time;
if (!TEST_int_eq(ossl_ackm_on_tx_packet(h.ackm, tx), 1))
goto err;
++txi;
break;
case RX_OPK_RX_ACK:
rx_ack.ack_ranges = &rx_ack_range;
rx_ack.num_ack_ranges = 1;
rx_ack_range.start = s->pn;
rx_ack_range.end = s->pn + s->num_pn - 1;
if (!TEST_int_eq(ossl_ackm_on_rx_ack_frame(h.ackm, &rx_ack,
space, fake_time), 1))
goto err;
break;
case RX_OPK_SKIP_IF_PN_SPACE:
if (space == (int)s->pn) {
testresult = 1;
goto err;
}
break;
default:
goto err;
}
}
testresult = 1;
err:
if (!testresult)
TEST_error("error in ACKM RX script %d, op %zu", tidx + 1, opn + 1);
helper_destroy(&h);
OPENSSL_free(pkts);
OPENSSL_free(txs);
return testresult;
}
/*
* Driver
* ******************************************************************
*/
static int test_tx_ack_case(int idx)
{
int tidx, space;
tidx = idx % OSSL_NELEM(tx_ack_cases);
idx /= OSSL_NELEM(tx_ack_cases);
space = idx % QUIC_PN_SPACE_NUM;
idx /= QUIC_PN_SPACE_NUM;
return test_tx_ack_case_actual(tidx, space, idx);
}
static int test_rx_ack(int idx)
{
int tidx;
tidx = idx % OSSL_NELEM(rx_test_scripts);
idx /= OSSL_NELEM(rx_test_scripts);
return test_rx_ack_actual(tidx, idx);
}
int setup_tests(void)
{
ADD_ALL_TESTS(test_tx_ack_case,
OSSL_NELEM(tx_ack_cases) * MODE_NUM * QUIC_PN_SPACE_NUM);
ADD_ALL_TESTS(test_tx_ack_time_script, OSSL_NELEM(tx_ack_time_scripts));
ADD_ALL_TESTS(test_rx_ack, OSSL_NELEM(rx_test_scripts) * QUIC_PN_SPACE_NUM);
return 1;
}
|
./openssl/test/x509_time_test.c | /*
* Copyright 2017-2021 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
*/
/* Tests for X509 time functions */
#include <string.h>
#include <time.h>
#include <openssl/asn1.h>
#include <openssl/x509.h>
#include "testutil.h"
#include "internal/nelem.h"
typedef struct {
const char *data;
int type;
time_t cmp_time;
/* -1 if asn1_time <= cmp_time, 1 if asn1_time > cmp_time, 0 if error. */
int expected;
} TESTDATA;
typedef struct {
const char *data;
/* 0 for check-only mode, 1 for set-string mode */
int set_string;
/* 0 for error, 1 if succeed */
int expected;
/*
* The following 2 fields are ignored if set_string field is set to '0'
* (in check only mode).
*
* But they can still be ignored explicitly in set-string mode by:
* setting -1 to expected_type and setting NULL to expected_string.
*
* It's useful in a case of set-string mode but the expected result
* is a 'parsing error'.
*/
int expected_type;
const char *expected_string;
} TESTDATA_FORMAT;
/*
* Actually, the "loose" mode has been tested in
* those time-compare-cases, so we may not test it again.
*/
static TESTDATA_FORMAT x509_format_tests[] = {
/* GeneralizedTime */
{
/* good format, check only */
"20170217180105Z", 0, 1, -1, NULL,
},
{
/* not leap year, check only */
"20170229180105Z", 0, 0, -1, NULL,
},
{
/* leap year, check only */
"20160229180105Z", 0, 1, -1, NULL,
},
{
/* SS is missing, check only */
"201702171801Z", 0, 0, -1, NULL,
},
{
/* fractional seconds, check only */
"20170217180105.001Z", 0, 0, -1, NULL,
},
{
/* timezone, check only */
"20170217180105+0800", 0, 0, -1, NULL,
},
{
/* SS is missing, set string */
"201702171801Z", 1, 0, -1, NULL,
},
{
/* fractional seconds, set string */
"20170217180105.001Z", 1, 0, -1, NULL,
},
{
/* timezone, set string */
"20170217180105+0800", 1, 0, -1, NULL,
},
{
/* good format, check returned 'turned' string */
"20170217180154Z", 1, 1, V_ASN1_UTCTIME, "170217180154Z",
},
{
/* good format, check returned string */
"20510217180154Z", 1, 1, V_ASN1_GENERALIZEDTIME, "20510217180154Z",
},
{
/* good format but out of UTC range, check returned string */
"19230419180154Z", 1, 1, V_ASN1_GENERALIZEDTIME, "19230419180154Z",
},
/* UTC */
{
/* SS is missing, check only */
"1702171801Z", 0, 0, -1, NULL,
},
{
/* not leap year, check only */
"050229180101Z", 0, 0, -1, NULL,
},
{
/* leap year, check only */
"040229180101Z", 0, 1, -1, NULL,
},
{
/* timezone, check only */
"170217180154+0800", 0, 0, -1, NULL,
},
{
/* SS is missing, set string */
"1702171801Z", 1, 0, -1, NULL,
},
{
/* timezone, set string */
"170217180154+0800", 1, 0, -1, NULL,
},
{
/* 2017, good format, check returned string */
"170217180154Z", 1, 1, V_ASN1_UTCTIME, "170217180154Z",
},
{
/* 1998, good format, check returned string */
"981223180154Z", 1, 1, V_ASN1_UTCTIME, "981223180154Z",
},
};
static TESTDATA x509_cmp_tests[] = {
{
"20170217180154Z", V_ASN1_GENERALIZEDTIME,
/* The same in seconds since epoch. */
1487354514, -1,
},
{
"20170217180154Z", V_ASN1_GENERALIZEDTIME,
/* One second more. */
1487354515, -1,
},
{
"20170217180154Z", V_ASN1_GENERALIZEDTIME,
/* One second less. */
1487354513, 1,
},
/* Same as UTC time. */
{
"170217180154Z", V_ASN1_UTCTIME,
/* The same in seconds since epoch. */
1487354514, -1,
},
{
"170217180154Z", V_ASN1_UTCTIME,
/* One second more. */
1487354515, -1,
},
{
"170217180154Z", V_ASN1_UTCTIME,
/* One second less. */
1487354513, 1,
},
/* UTCTime from the 20th century. */
{
"990217180154Z", V_ASN1_UTCTIME,
/* The same in seconds since epoch. */
919274514, -1,
},
{
"990217180154Z", V_ASN1_UTCTIME,
/* One second more. */
919274515, -1,
},
{
"990217180154Z", V_ASN1_UTCTIME,
/* One second less. */
919274513, 1,
},
/* Various invalid formats. */
{
/* No trailing Z. */
"20170217180154", V_ASN1_GENERALIZEDTIME, 0, 0,
},
{
/* No trailing Z, UTCTime. */
"170217180154", V_ASN1_UTCTIME, 0, 0,
},
{
/* No seconds. */
"201702171801Z", V_ASN1_GENERALIZEDTIME, 0, 0,
},
{
/* No seconds, UTCTime. */
"1702171801Z", V_ASN1_UTCTIME, 0, 0,
},
{
/* Fractional seconds. */
"20170217180154.001Z", V_ASN1_GENERALIZEDTIME, 0, 0,
},
{
/* Fractional seconds, UTCTime. */
"170217180154.001Z", V_ASN1_UTCTIME, 0, 0,
},
{
/* Timezone offset. */
"20170217180154+0100", V_ASN1_GENERALIZEDTIME, 0, 0,
},
{
/* Timezone offset, UTCTime. */
"170217180154+0100", V_ASN1_UTCTIME, 0, 0,
},
{
/* Extra digits. */
"2017021718015400Z", V_ASN1_GENERALIZEDTIME, 0, 0,
},
{
/* Extra digits, UTCTime. */
"17021718015400Z", V_ASN1_UTCTIME, 0, 0,
},
{
/* Non-digits. */
"2017021718015aZ", V_ASN1_GENERALIZEDTIME, 0, 0,
},
{
/* Non-digits, UTCTime. */
"17021718015aZ", V_ASN1_UTCTIME, 0, 0,
},
{
/* Trailing garbage. */
"20170217180154Zlongtrailinggarbage", V_ASN1_GENERALIZEDTIME, 0, 0,
},
{
/* Trailing garbage, UTCTime. */
"170217180154Zlongtrailinggarbage", V_ASN1_UTCTIME, 0, 0,
},
{
/* Swapped type. */
"20170217180154Z", V_ASN1_UTCTIME, 0, 0,
},
{
/* Swapped type. */
"170217180154Z", V_ASN1_GENERALIZEDTIME, 0, 0,
},
{
/* Bad type. */
"20170217180154Z", V_ASN1_OCTET_STRING, 0, 0,
},
};
static int test_x509_cmp_time(int idx)
{
ASN1_TIME t;
int result;
memset(&t, 0, sizeof(t));
t.type = x509_cmp_tests[idx].type;
t.data = (unsigned char*)(x509_cmp_tests[idx].data);
t.length = strlen(x509_cmp_tests[idx].data);
t.flags = 0;
result = X509_cmp_time(&t, &x509_cmp_tests[idx].cmp_time);
if (!TEST_int_eq(result, x509_cmp_tests[idx].expected)) {
TEST_info("test_x509_cmp_time(%d) failed: expected %d, got %d\n",
idx, x509_cmp_tests[idx].expected, result);
return 0;
}
return 1;
}
static int test_x509_cmp_time_current(void)
{
time_t now = time(NULL);
/* Pick a day earlier and later, relative to any system clock. */
ASN1_TIME *asn1_before = NULL, *asn1_after = NULL;
int cmp_result, failed = 0;
asn1_before = ASN1_TIME_adj(NULL, now, -1, 0);
asn1_after = ASN1_TIME_adj(NULL, now, 1, 0);
cmp_result = X509_cmp_time(asn1_before, NULL);
if (!TEST_int_eq(cmp_result, -1))
failed = 1;
cmp_result = X509_cmp_time(asn1_after, NULL);
if (!TEST_int_eq(cmp_result, 1))
failed = 1;
ASN1_TIME_free(asn1_before);
ASN1_TIME_free(asn1_after);
return failed == 0;
}
static int test_X509_cmp_timeframe_vpm(const X509_VERIFY_PARAM *vpm,
ASN1_TIME *asn1_before,
ASN1_TIME *asn1_mid,
ASN1_TIME *asn1_after)
{
int always_0 = vpm != NULL
&& (X509_VERIFY_PARAM_get_flags(vpm) & X509_V_FLAG_USE_CHECK_TIME) == 0
&& (X509_VERIFY_PARAM_get_flags(vpm) & X509_V_FLAG_NO_CHECK_TIME) != 0;
return asn1_before != NULL && asn1_mid != NULL && asn1_after != NULL
&& TEST_int_eq(X509_cmp_timeframe(vpm, asn1_before, asn1_after), 0)
&& TEST_int_eq(X509_cmp_timeframe(vpm, asn1_before, NULL), 0)
&& TEST_int_eq(X509_cmp_timeframe(vpm, NULL, asn1_after), 0)
&& TEST_int_eq(X509_cmp_timeframe(vpm, NULL, NULL), 0)
&& TEST_int_eq(X509_cmp_timeframe(vpm, asn1_after, asn1_after),
always_0 ? 0 : -1)
&& TEST_int_eq(X509_cmp_timeframe(vpm, asn1_before, asn1_before),
always_0 ? 0 : 1)
&& TEST_int_eq(X509_cmp_timeframe(vpm, asn1_after, asn1_before),
always_0 ? 0 : 1);
}
static int test_X509_cmp_timeframe(void)
{
time_t now = time(NULL);
ASN1_TIME *asn1_mid = ASN1_TIME_adj(NULL, now, 0, 0);
/* Pick a day earlier and later, relative to any system clock. */
ASN1_TIME *asn1_before = ASN1_TIME_adj(NULL, now, -1, 0);
ASN1_TIME *asn1_after = ASN1_TIME_adj(NULL, now, 1, 0);
X509_VERIFY_PARAM *vpm = X509_VERIFY_PARAM_new();
int res = 0;
if (vpm == NULL)
goto finish;
res = test_X509_cmp_timeframe_vpm(NULL, asn1_before, asn1_mid, asn1_after)
&& test_X509_cmp_timeframe_vpm(vpm, asn1_before, asn1_mid, asn1_after);
X509_VERIFY_PARAM_set_time(vpm, now);
res = res
&& test_X509_cmp_timeframe_vpm(vpm, asn1_before, asn1_mid, asn1_after)
&& X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_NO_CHECK_TIME)
&& test_X509_cmp_timeframe_vpm(vpm, asn1_before, asn1_mid, asn1_after);
X509_VERIFY_PARAM_free(vpm);
finish:
ASN1_TIME_free(asn1_mid);
ASN1_TIME_free(asn1_before);
ASN1_TIME_free(asn1_after);
return res;
}
static int test_x509_time(int idx)
{
ASN1_TIME *t = NULL;
int result, rv = 0;
if (x509_format_tests[idx].set_string) {
/* set-string mode */
t = ASN1_TIME_new();
if (t == NULL) {
TEST_info("test_x509_time(%d) failed: internal error\n", idx);
return 0;
}
}
result = ASN1_TIME_set_string_X509(t, x509_format_tests[idx].data);
/* time string parsing result is always checked against what's expected */
if (!TEST_int_eq(result, x509_format_tests[idx].expected)) {
TEST_info("test_x509_time(%d) failed: expected %d, got %d\n",
idx, x509_format_tests[idx].expected, result);
goto out;
}
/* if t is not NULL but expected_type is ignored(-1), it is an 'OK' case */
if (t != NULL && x509_format_tests[idx].expected_type != -1) {
if (!TEST_int_eq(t->type, x509_format_tests[idx].expected_type)) {
TEST_info("test_x509_time(%d) failed: expected_type %d, got %d\n",
idx, x509_format_tests[idx].expected_type, t->type);
goto out;
}
}
/* if t is not NULL but expected_string is NULL, it is an 'OK' case too */
if (t != NULL && x509_format_tests[idx].expected_string) {
if (!TEST_mem_eq((const char *)t->data, t->length,
x509_format_tests[idx].expected_string,
strlen(x509_format_tests[idx].expected_string))) {
TEST_info("test_x509_time(%d) failed: expected_string %s, got %.*s\n",
idx, x509_format_tests[idx].expected_string, t->length,
t->data);
goto out;
}
}
rv = 1;
out:
if (t != NULL)
ASN1_TIME_free(t);
return rv;
}
static const struct {
int y, m, d;
int yd, wd;
} day_of_week_tests[] = {
/*YYYY MM DD DoY DoW */
{ 1900, 1, 1, 0, 1 },
{ 1900, 2, 28, 58, 3 },
{ 1900, 3, 1, 59, 4 },
{ 1900, 12, 31, 364, 1 },
{ 1901, 1, 1, 0, 2 },
{ 1970, 1, 1, 0, 4 },
{ 1999, 1, 10, 9, 0 },
{ 1999, 12, 31, 364, 5 },
{ 2000, 1, 1, 0, 6 },
{ 2000, 2, 28, 58, 1 },
{ 2000, 2, 29, 59, 2 },
{ 2000, 3, 1, 60, 3 },
{ 2000, 12, 31, 365, 0 },
{ 2001, 1, 1, 0, 1 },
{ 2008, 1, 1, 0, 2 },
{ 2008, 2, 28, 58, 4 },
{ 2008, 2, 29, 59, 5 },
{ 2008, 3, 1, 60, 6 },
{ 2008, 12, 31, 365, 3 },
{ 2009, 1, 1, 0, 4 },
{ 2011, 1, 1, 0, 6 },
{ 2011, 2, 28, 58, 1 },
{ 2011, 3, 1, 59, 2 },
{ 2011, 12, 31, 364, 6 },
{ 2012, 1, 1, 0, 0 },
{ 2019, 1, 2, 1, 3 },
{ 2019, 2, 2, 32, 6 },
{ 2019, 3, 2, 60, 6 },
{ 2019, 4, 2, 91, 2 },
{ 2019, 5, 2, 121, 4 },
{ 2019, 6, 2, 152, 0 },
{ 2019, 7, 2, 182, 2 },
{ 2019, 8, 2, 213, 5 },
{ 2019, 9, 2, 244, 1 },
{ 2019, 10, 2, 274, 3 },
{ 2019, 11, 2, 305, 6 },
{ 2019, 12, 2, 335, 1 },
{ 2020, 1, 2, 1, 4 },
{ 2020, 2, 2, 32, 0 },
{ 2020, 3, 2, 61, 1 },
{ 2020, 4, 2, 92, 4 },
{ 2020, 5, 2, 122, 6 },
{ 2020, 6, 2, 153, 2 },
{ 2020, 7, 2, 183, 4 },
{ 2020, 8, 2, 214, 0 },
{ 2020, 9, 2, 245, 3 },
{ 2020, 10, 2, 275, 5 },
{ 2020, 11, 2, 306, 1 },
{ 2020, 12, 2, 336, 3 }
};
static int test_days(int n)
{
char d[16];
ASN1_TIME *a = NULL;
struct tm t;
int r;
BIO_snprintf(d, sizeof(d), "%04d%02d%02d050505Z",
day_of_week_tests[n].y, day_of_week_tests[n].m,
day_of_week_tests[n].d);
if (!TEST_ptr(a = ASN1_TIME_new()))
return 0;
r = TEST_true(ASN1_TIME_set_string(a, d))
&& TEST_true(ASN1_TIME_to_tm(a, &t))
&& TEST_int_eq(t.tm_yday, day_of_week_tests[n].yd)
&& TEST_int_eq(t.tm_wday, day_of_week_tests[n].wd);
ASN1_TIME_free(a);
return r;
}
#define construct_asn1_time(s, t, e) \
{ { sizeof(s) - 1, t, (unsigned char*)s, 0 }, e }
static const struct {
ASN1_TIME asn1;
const char *readable;
} x509_print_tests_rfc_822 [] = {
/* Generalized Time */
construct_asn1_time("20170731222050Z", V_ASN1_GENERALIZEDTIME,
"Jul 31 22:20:50 2017 GMT"),
/* Generalized Time, no seconds */
construct_asn1_time("201707312220Z", V_ASN1_GENERALIZEDTIME,
"Jul 31 22:20:00 2017 GMT"),
/* Generalized Time, fractional seconds (3 digits) */
construct_asn1_time("20170731222050.123Z", V_ASN1_GENERALIZEDTIME,
"Jul 31 22:20:50.123 2017 GMT"),
/* Generalized Time, fractional seconds (1 digit) */
construct_asn1_time("20170731222050.1Z", V_ASN1_GENERALIZEDTIME,
"Jul 31 22:20:50.1 2017 GMT"),
/* Generalized Time, fractional seconds (0 digit) */
construct_asn1_time("20170731222050.Z", V_ASN1_GENERALIZEDTIME,
"Bad time value"),
/* UTC Time */
construct_asn1_time("170731222050Z", V_ASN1_UTCTIME,
"Jul 31 22:20:50 2017 GMT"),
/* UTC Time, no seconds */
construct_asn1_time("1707312220Z", V_ASN1_UTCTIME,
"Jul 31 22:20:00 2017 GMT"),
};
static const struct {
ASN1_TIME asn1;
const char *readable;
} x509_print_tests_iso_8601 [] = {
/* Generalized Time */
construct_asn1_time("20170731222050Z", V_ASN1_GENERALIZEDTIME,
"2017-07-31 22:20:50Z"),
/* Generalized Time, no seconds */
construct_asn1_time("201707312220Z", V_ASN1_GENERALIZEDTIME,
"2017-07-31 22:20:00Z"),
/* Generalized Time, fractional seconds (3 digits) */
construct_asn1_time("20170731222050.123Z", V_ASN1_GENERALIZEDTIME,
"2017-07-31 22:20:50.123Z"),
/* Generalized Time, fractional seconds (1 digit) */
construct_asn1_time("20170731222050.1Z", V_ASN1_GENERALIZEDTIME,
"2017-07-31 22:20:50.1Z"),
/* Generalized Time, fractional seconds (0 digit) */
construct_asn1_time("20170731222050.Z", V_ASN1_GENERALIZEDTIME,
"Bad time value"),
/* UTC Time */
construct_asn1_time("170731222050Z", V_ASN1_UTCTIME,
"2017-07-31 22:20:50Z"),
/* UTC Time, no seconds */
construct_asn1_time("1707312220Z", V_ASN1_UTCTIME,
"2017-07-31 22:20:00Z"),
};
static int test_x509_time_print_rfc_822(int idx)
{
BIO *m;
int ret = 0, rv;
char *pp;
const char *readable;
if (!TEST_ptr(m = BIO_new(BIO_s_mem())))
goto err;
rv = ASN1_TIME_print_ex(m, &x509_print_tests_rfc_822[idx].asn1, ASN1_DTFLGS_RFC822);
readable = x509_print_tests_rfc_822[idx].readable;
if (rv == 0 && !TEST_str_eq(readable, "Bad time value")) {
/* only if the test case intends to fail... */
goto err;
}
if (!TEST_int_ne(rv = BIO_get_mem_data(m, &pp), 0)
|| !TEST_int_eq(rv, (int)strlen(readable))
|| !TEST_strn_eq(pp, readable, rv))
goto err;
ret = 1;
err:
BIO_free(m);
return ret;
}
static int test_x509_time_print_iso_8601(int idx)
{
BIO *m;
int ret = 0, rv;
char *pp;
const char *readable;
if (!TEST_ptr(m = BIO_new(BIO_s_mem())))
goto err;
rv = ASN1_TIME_print_ex(m, &x509_print_tests_iso_8601[idx].asn1, ASN1_DTFLGS_ISO8601);
readable = x509_print_tests_iso_8601[idx].readable;
if (rv == 0 && !TEST_str_eq(readable, "Bad time value")) {
/* only if the test case intends to fail... */
goto err;
}
if (!TEST_int_ne(rv = BIO_get_mem_data(m, &pp), 0)
|| !TEST_int_eq(rv, (int)strlen(readable))
|| !TEST_strn_eq(pp, readable, rv))
goto err;
ret = 1;
err:
BIO_free(m);
return ret;
}
int setup_tests(void)
{
ADD_TEST(test_x509_cmp_time_current);
ADD_TEST(test_X509_cmp_timeframe);
ADD_ALL_TESTS(test_x509_cmp_time, OSSL_NELEM(x509_cmp_tests));
ADD_ALL_TESTS(test_x509_time, OSSL_NELEM(x509_format_tests));
ADD_ALL_TESTS(test_days, OSSL_NELEM(day_of_week_tests));
ADD_ALL_TESTS(test_x509_time_print_rfc_822, OSSL_NELEM(x509_print_tests_rfc_822));
ADD_ALL_TESTS(test_x509_time_print_iso_8601, OSSL_NELEM(x509_print_tests_iso_8601));
return 1;
}
|
./openssl/test/ecdsatest.h | /*
* 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
*/
#ifndef OSSL_TEST_ECDSATEST_H
# define OSSL_TEST_ECDSATEST_H
/*-
* NIST CAVP ECDSA KATs:
* https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/dss/186-3ecdsatestvectors.zip
*
* sha256sum e0d9bee3f760ca3fabb82bd43dd04c13ee64ca9e0b719c6ea64fd52c9f0dd929
* 720 KATs from the SigGen.txt file.
*
* There are also 4 X9.62 KATs; two for prime fields and two for binary fields.
*/
typedef struct {
const int nid; /* curve NID */
const int md_nid; /* hash function NID */
const char *msg; /* message to sign */
const char *d; /* ECDSA private key */
const char *Q; /* ECDSA public key: Q = dG */
const char *k; /* ECDSA nonce */
const char *r; /* ECDSA signature (r,s) */
const char *s;
} ecdsa_cavs_kat_t;
static const ecdsa_cavs_kat_t ecdsa_cavs_kats[] = {
/* prime KATs from X9.62 */
{NID_X9_62_prime192v1, NID_sha1,
"616263", /* "abc" */
"1a8d598fc15bf0fd89030b5cb1111aeb92ae8baf5ea475fb",
"0462b12d60690cdcf330babab6e69763b471f994dd702d16a563bf5ec08069705ffff65e"
"5ca5c0d69716dfcb3474373902",
"fa6de29746bbeb7f8bb1e761f85f7dfb2983169d82fa2f4e",
"885052380ff147b734c330c43d39b2c4a89f29b0f749fead",
"e9ecc78106def82bf1070cf1d4d804c3cb390046951df686"},
{NID_X9_62_prime239v1, NID_sha1,
"616263", /* "abc" */
"7ef7c6fabefffdea864206e80b0b08a9331ed93e698561b64ca0f7777f3d",
"045b6dc53bc61a2548ffb0f671472de6c9521a9d2d2534e65abfcbd5fe0c707fd9f1ed2e"
"65f09f6ce0893baf5e8e31e6ae82ea8c3592335be906d38dee",
"656c7196bf87dcc5d1f1020906df2782360d36b2de7a17ece37d503784af",
"2cb7f36803ebb9c427c58d8265f11fc5084747133078fc279de874fbecb0",
"2eeae988104e9c2234a3c2beb1f53bfa5dc11ff36a875d1e3ccb1f7e45cf"},
/* prime KATs from NIST CAVP */
{NID_secp224r1, NID_sha224,
"699325d6fc8fbbb4981a6ded3c3a54ad2e4e3db8a5669201912064c64e700c139248cdc1"
"9495df081c3fc60245b9f25fc9e301b845b3d703a694986e4641ae3c7e5a19e6d6edbf1d"
"61e535f49a8fad5f4ac26397cfec682f161a5fcd32c5e780668b0181a91955157635536a"
"22367308036e2070f544ad4fff3d5122c76fad5d",
"16797b5c0c7ed5461e2ff1b88e6eafa03c0f46bf072000dfc830d615",
"04605495756e6e88f1d07ae5f98787af9b4da8a641d1a9492a12174eabf5cc733b17decc"
"806ef1df861a42505d0af9ef7c3df3959b8dfc6669",
"d9a5a7328117f48b4b8dd8c17dae722e756b3ff64bd29a527137eec0",
"2fc2cff8cdd4866b1d74e45b07d333af46b7af0888049d0fdbc7b0d6",
"8d9cc4c8ea93e0fd9d6431b9a1fd99b88f281793396321b11dac41eb"},
{NID_secp224r1, NID_sha224,
"7de42b44db0aa8bfdcdac9add227e8f0cc7ad1d94693beb5e1d325e5f3f85b3bd033fc25"
"e9469a89733a65d1fa641f7e67d668e7c71d736233c4cba20eb83c368c506affe77946b5"
"e2ec693798aecd7ff943cd8fab90affddf5ad5b8d1af332e6c5fe4a2df16837700b2781e"
"08821d4fbdd8373517f5b19f9e63b89cfeeeef6f",
"cf020a1ff36c28511191482ed1e5259c60d383606c581948c3fbe2c5",
"04fa21f85b99d3dc18c6d53351fbcb1e2d029c00fa7d1663a3dd94695ee9e79578f8988b"
"168edff1a8b34a5ed9598cc20acd1f0aed36715d88",
"c780d047454824af98677cf310117e5f9e99627d02414f136aed8e83",
"45145f06b566ec9fd0fee1b6c6551a4535c7a3bbfc0fede45f4f5038",
"7302dff12545b069cf27df49b26e4781270585463656f2834917c3ca"},
{NID_secp224r1, NID_sha224,
"af0da3adab82784909e2b3dadcecba21eced3c60d7572023dea171044d9a10e8ba67d31b"
"04904541b87fff32a10ccc6580869055fec6216a00320a28899859a6b61faba58a0bc10c"
"2ba07ea16f214c3ddcc9fc5622ad1253b63fe7e95227ae3c9caa9962cffc8b1c4e826003"
"6469d25ab0c8e3643a820b8b3a4d8d43e4b728f9",
"dde6f173fa9f307d206ce46b4f02851ebce9638a989330249fd30b73",
"04fc21a99b060afb0d9dbf3250ea3c4da10be94ce627a65874d8e4a630e8373ab7190890"
"326aac4aacca3eba89e15d1086a05434dd033fd3f3",
"6629366a156840477df4875cfba4f8faa809e394893e1f5525326d07",
"41f8e2b1ae5add7c24da8725a067585a3ad6d5a9ed9580beb226f23a",
"a5d71bff02dce997305dd337128046f36714398f4ef6647599712fae"},
{NID_secp224r1, NID_sha224,
"cfa56ae89727df6b7266f69d6636bf738f9e4f15f49c42a0123edac4b3743f32ea52389f"
"919ceb90575c4184897773b2f2fc5b3fcb354880f15c93383215d3c2551fcc1b4180a1ac"
"0f69c969bbc306acd115ce3976eff518540f43ad4076dbb5fbad9ce9b3234f1148b8f5e0"
"59192ff480fc4bcbd00d25f4d9f5ed4ba5693b6c",
"aeee9071248f077590ac647794b678ad371f8e0f1e14e9fbff49671e",
"04fad0a34991bbf89982ad9cf89337b4bd2565f84d5bdd004289fc1cc35d8b6764f28c81"
"63a12855a5c266efeb9388df4994b85a8b4f1bd3bc",
"1d35d027cd5a569e25c5768c48ed0c2b127c0f99cb4e52ea094fe689",
"2258184ef9f0fa698735379972ce9adf034af76017668bfcdab978de",
"866fb8e505dea6c909c2c9143ec869d1bac2282cf12366130ff2146c"},
{NID_secp224r1, NID_sha224,
"c223c8009018321b987a615c3414d2bb15954933569ca989de32d6bf11107bc47a330ab6"
"d88d9b50d106cf5777d1b736b14bc48deda1bc573a9a7dd42cd061860645306dce7a5ba8"
"c60f135a6a21999421ce8c4670fe7287a7e9ea3aa1e0fa82721f33e6e823957fe86e2283"
"c89ef92b13cd0333c4bb70865ae1919bf538ea34",
"29c204b2954e1406a015020f9d6b3d7c00658298feb2d17440b2c1a4",
"040e0fc15e775a75d45f872e5021b554cc0579da19125e1a49299c7630cb64fe462d025a"
"e2a1394746bdbf8251f7ca5a1d6bb13e0edf6b7b09",
"39547c10bb947d69f6c3af701f2528e011a1e80a6d04cc5a37466c02",
"86622c376d326cdf679bcabf8eb034bf49f0c188f3fc3afd0006325d",
"26613d3b33c70e635d7a998f254a5b15d2a3642bf321e8cff08f1e84"},
{NID_secp224r1, NID_sha224,
"1c27273d95182c74c100d85b5c08f4b26874c2abc87f127f304aedbf52ef6540eba16dd6"
"64ae1e9e30ea1e66ff9cc9ab5a80b5bcbd19dde88a29ff10b50a6abd73388e8071306c68"
"d0c9f6caa26b7e68de29312be959b9f4a5481f5a2ad2070a396ed3de21096541cf58c4a1"
"3308e08867565bf2df9d649357a83cdcf18d2cd9",
"8986a97b24be042a1547642f19678de4e281a68f1e794e343dabb131",
"042c070e68e8478341938f3d5026a1fe01e778cdffbebbdd7a4cd29209cde21c9c7c6590"
"ba300715a7adac278385a5175b6b4ea749c4b6a681",
"509712f9c0f3370f6a09154159975945f0107dd1cee7327c68eaa90b",
"57afda5139b180de96373c3d649700682e37efd56ae182335f081013",
"eb6cd58650cfb26dfdf21de32fa17464a6efc46830eedc16977342e6"},
{NID_secp224r1, NID_sha224,
"069ae374971627f6b8503f3aa63ab52bcf4f3fcae65b98cdbbf917a5b08a10dc76005671"
"4db279806a8d43485320e6fee0f1e0562e077ee270ace8d3c478d79bcdff9cf8b92fdea6"
"8421d4a276f8e62ae379387ae06b60af9eb3c40bd7a768aeffccdc8a08bc78ca2eca1806"
"1058043a0e441209c5c594842838a4d9d778a053",
"d9aa95e14cb34980cfddadddfa92bde1310acaff249f73ff5b09a974",
"043a0d4b8e5fad1ea1abb8d3fb742cd45cd0b76d136e5bbb33206ad120c90ac83276b2fa"
"3757b0f226cd7360a313bc96fd8329c76a7306cc7d",
"1f1739af68a3cee7c5f09e9e09d6485d9cd64cc4085bc2bc89795aaf",
"09bbdd003532d025d7c3204c00747cd52ecdfbc7ce3dde8ffbea23e1",
"1e745e80948779a5cc8dc5cb193beebb550ec9c2647f4948bf58ba7d"},
{NID_secp224r1, NID_sha224,
"d0d5ae3e33600aa21c1606caec449eee678c87cb593594be1fbb048cc7cfd076e5cc7132"
"ebe290c4c014e7a517a0d5972759acfa1438d9d2e5d236d19ac92136f6252b7e5bea7588"
"dcba6522b6b18128f003ecab5cb4908832fb5a375cf820f8f0e9ee870653a73dc2282f2d"
"45622a2f0e85cba05c567baf1b9862b79a4b244e",
"380fb6154ad3d2e755a17df1f047f84712d4ec9e47d34d4054ea29a8",
"044772c27cca3348b1801ae87b01cb564c8cf9b81c23cc74468a907927de9d253935b096"
"17a1655c42d385bf48504e06fa386f5fa533a21dcb",
"14dbdffa326ba2f3d64f79ff966d9ee6c1aba0d51e9a8e59f5686dc1",
"ff6d52a09ca4c3b82da0440864d6717e1be0b50b6dcf5e1d74c0ff56",
"09490be77bc834c1efaa23410dcbf800e6fae40d62a737214c5a4418"},
{NID_secp224r1, NID_sha224,
"79b7375ae7a4f2e4adad8765d14c1540cd9979db38076c157c1837c760ca6febbb18fd42"
"152335929b735e1a08041bd38d315cd4c6b7dd2729de8752f531f07fe4ddc4f1899debc0"
"311eef0019170b58e08895b439ddf09fbf0aeb1e2fd35c2ef7ae402308c3637733802601"
"dd218fb14c22f57870835b10818369d57d318405",
"6b98ec50d6b7f7ebc3a2183ff9388f75e924243827ddded8721186e2",
"041f249911b125348e6e0a473479105cc4b8cfb4fa32d897810fc69ffea17db03b9877d1"
"b6328329061ea67aec5a38a884362e9e5b7d7642dc",
"ab3a41fedc77d1f96f3103cc7dce215bf45054a755cf101735fef503",
"70ccc0824542e296d17a79320d422f1edcf9253840dafe4427033f40",
"e3823699c355b61ab1894be3371765fae2b720405a7ce5e790ca8c00"},
{NID_secp224r1, NID_sha224,
"8c7de96e6880d5b6efc19646b9d3d56490775cb3faab342e64db2e388c4bd9e94c4e69a6"
"3ccdb7e007a19711e69c06f106b71c983a6d97c4589045666c6ab5ea7b5b6d096ddf6fd3"
"5b819f1506a3c37ddd40929504f9f079c8d83820fc8493f97b2298aebe48fdb4ff472b29"
"018fc2b1163a22bfbb1de413e8645e871291a9f6",
"8dda0ef4170bf73077d685e7709f6f747ced08eb4cde98ef06ab7bd7",
"047df67b960ee7a2cb62b22932457360ab1e046c1ec84b91ae65642003c764ca9fc1b0cc"
"2233fa57bdcfedaab0131fb7b5f557d6ca57f4afe0",
"9ef6ebd178a76402968bc8ec8b257174a04fb5e2d65c1ab34ab039b9",
"eef9e8428105704133e0f19636c89e570485e577786df2b09f99602a",
"8c01f0162891e4b9536243cb86a6e5c177323cca09777366caf2693c"},
{NID_secp224r1, NID_sha224,
"c89766374c5a5ccef5823e7a9b54af835ac56afbbb517bd77bfecf3fea876bd0cc9ea486"
"e3d685cfe3fb05f25d9c67992cd7863c80a55c7a263249eb3996c4698ad7381131bf3700"
"b7b24d7ca281a100cf2b750e7f0f933e662a08d9f9e47d779fb03754bd20931262ff381a"
"2fe7d1dc94f4a0520de73fa72020494d3133ecf7",
"3dbe18cd88fa49febfcb60f0369a67b2379a466d906ac46a8b8d522b",
"04b10150fd797eb870d377f1dbfa197f7d0f0ad29965af573ec13cc42a17b63ccefbe27f"
"b2a1139e5757b1082aeaa564f478c23a8f631eed5c",
"385803b262ee2ee875838b3a645a745d2e199ae112ef73a25d68d15f",
"1d293b697f297af77872582eb7f543dc250ec79ad453300d264a3b70",
"517a91b89c4859fcc10834242e710c5f0fed90ac938aa5ccdb7c66de"},
{NID_secp224r1, NID_sha224,
"30f0e3b502eec5646929d48fd46aa73991d82079c7bd50a38b38ec0bd84167c8cf5ba39b"
"ec26999e70208af9b445046cd9d20c82b7629ca1e51bdd00daddbc35f9eb036a15ac5789"
"8642d9db09479a38cc80a2e41e380c8a766b2d623de2de798e1eabc02234b89b85d60154"
"460c3bf12764f3fbf17fcccc82df516a2fbe4ecf",
"c906b667f38c5135ea96c95722c713dbd125d61156a546f49ddaadc6",
"043c9b4ef1748a1925578658d3af51995b989ad760790157b25fe0982655648f4ff4edfb"
"899e9a13bd8d20f5c24b35dc6a6a4e42ed5983b4a0",
"b04d78d8ac40fefadb99f389a06d93f6b5b72198c1be02dbff6195f0",
"4bdd3c84647bad93dcaffd1b54eb87fc61a5704b19d7e6d756d11ad0",
"fdd81e5dca54158514f44ba2330271eff4c618330328451e2d93b9fb"},
{NID_secp224r1, NID_sha224,
"6bbb4bf987c8e5069e47c1a541b48b8a3e6d14bfd9ac6dfaa7503b64ab5e1a55f63e91cf"
"5c3e703ac27ad88756dd7fb2d73b909fc15302d0592b974d47e72e60ed339a40b34d39a4"
"9b69ea4a5d26ce86f3ca00a70f1cd416a6a5722e8f39d1f0e966981803d6f46dac34e4c7"
"640204cd0d9f1e53fc3acf30096cd00fa80b3ae9",
"3456745fbd51eac9b8095cd687b112f93d1b58352dbe02c66bb9b0cc",
"04f0acdfbc75a748a4a0ac55281754b5c4a364b7d61c5390b334daae1086587a6768f235"
"bf523fbfc6e062c7401ac2b0242cfe4e5fb34f4057",
"854b20c61bcdf7a89959dbf0985880bb14b628f01c65ef4f6446f1c1",
"a2601fbb9fe89f39814735febb349143baa934170ffb91c6448a7823",
"bf90f9305616020a0e34ef30803fc15fa97dffc0948452bbf6cb5f66"},
{NID_secp224r1, NID_sha224,
"05b8f8e56214d4217323f2066f974f638f0b83689fc4ed1201848230efdc1fbca8f70359"
"cecc921050141d3b02c2f17aa306fc2ce5fc06e7d0f4be162fcd985a0b687b4ba09b681c"
"b52ffe890bf5bb4a104cb2e770c04df433013605eb8c72a09902f4246d6c22b8c191ef1b"
"0bece10d5ce2744fc7345307dd1b41b6eff0ca89",
"2c522af64baaca7b7a08044312f5e265ec6e09b2272f462cc705e4c3",
"045fad3c047074b5de1960247d0cc216b4e3fb7f3b9cd960575c8479fce4fc9c7f05ff0b"
"040eb171fdd2a1dfe2572c564c2003a08c3179a422",
"9267763383f8db55eed5b1ca8f4937dc2e0ca6175066dc3d4a4586af",
"422e2e9fe535eb62f11f5f8ce87cf2e9ec65e61c06737cf6a0019ae6",
"116cfcf0965b7bc63aecade71d189d7e98a0434b124f2afbe3ccf0a9"},
{NID_secp224r1, NID_sha224,
"e5c979f0832242b143077bce6ef146a53bb4c53abfc033473c59f3c4095a68b7a504b609"
"f2ab163b5f88f374f0f3bff8762278b1f1c37323b9ed448e3de33e6443796a9ecaa466aa"
"75175375418186c352018a57ce874e44ae72401d5c0f401b5a51804724c10653fded9066"
"e8994d36a137fdeb9364601daeef09fd174dde4a",
"3eff7d07edda14e8beba397accfee060dbe2a41587a703bbe0a0b912",
"046dd84f4d66f362844e41a7913c40b4aad5fa9ba56bb44c2d2ed9efac15f65ebcdf2fd9"
"f8035385a330bdabec0f1cd9cc7bc31d2fadbe7cda",
"7bb48839d7717bab1fdde89bf4f7b4509d1c2c12510925e13655dead",
"127051d85326049115f307af2bc426f6c2d08f4774a0b496fb6982b1",
"6857e84418c1d1179333b4e5307e92abade0b74f7521ad78044bf597"},
{NID_secp224r1, NID_sha256,
"2b49de971bb0f705a3fb5914eb7638d72884a6c3550667dbfdf301adf26bde02f387fd42"
"6a31be6c9ff8bfe8690c8113c88576427f1466508458349fc86036afcfb66448b947707e"
"791e71f558b2bf4e7e7507773aaf4e9af51eda95cbce0a0f752b216f8a54a045d47801ff"
"410ee411a1b66a516f278327df2462fb5619470e",
"888fc992893bdd8aa02c80768832605d020b81ae0b25474154ec89aa",
"044c741e4d20103670b7161ae72271082155838418084335338ac38fa4db7919151ac285"
"87b72bad7ab180ec8e95ab9e2c8d81d9b9d7e2e383",
"06f7a56007825433c4c61153df1a135eee2f38ec687b492ed40d9c90",
"0909c9b9cae8d2790e29db6afdb45c04f5b072c4c20410c7dc9b6772",
"298f4fcae1fe271da1e0345d11d07a1fca43f58af4c113b909eedea0"},
{NID_secp224r1, NID_sha256,
"1fa7201d96ad4d190415f2656d1387fa886afc38e5cd18b8c60da367acf32c627d2c9ea1"
"9ef3f030e559fc2a21695cdbb65ddf6ba36a70af0d3fa292a32de31da6acc6108ab2be8b"
"d37843338f0c37c2d62648d3d49013edeb9e179dadf78bf885f95e712fcdfcc8a172e47c"
"09ab159f3a00ed7b930f628c3c48257e92fc7407",
"5b5a3e186e7d5b9b0fbdfc74a05e0a3d85dc4be4c87269190c839972",
"04897089f4ef05b943eeac06589f0e09ccc571a6add3eb1610a2fc830f62ba3f6b3e6f0f"
"062058b93e6f25b6041246c5be13584a41cae7e244",
"5b6f7eca2bcc5899fce41b8169d48cd57cf0c4a1b66a30a150072676",
"f12c9985d454ffbc899ebbbb6cf43e3debcac7f19029f8f2f35cce31",
"12fcb848adbd8b1b4c72b2b54a04d936e4a5f480ae2a3ea2e3c1baae"},
{NID_secp224r1, NID_sha256,
"74715fe10748a5b98b138f390f7ca9629c584c5d6ad268fc455c8de2e800b73fa1ea9aae"
"e85de58baa2ce9ce68d822fc31842c6b153baef3a12bf6b4541f74af65430ae931a64c8b"
"4950ad1c76b31aea8c229b3623390e233c112586aa5907bbe419841f54f0a7d6d19c003b"
"91dc84bbb59b14ec477a1e9d194c137e21c75bbb",
"f60b3a4d4e31c7005a3d2d0f91cb096d016a8ddb5ab10ecb2a549170",
"0440a4ab1e6a9f84b4dedb81795e6a7124d1cfdfd7ec64c5d4b9e3266683aa32a3c2fc06"
"8e62626f2dafce5d7f050e826e5c145cd2d13d1b27",
"c31150420dfb38ba8347e29add189ec3e38c14b0c541497fb90bf395",
"bf6c6daa89b21211ea2c9f45192d91603378d46b1a5057962dafaf12",
"cb6b237950e0f0369323055cd1f643528c7a64616f75b11c4ddd63c7"},
{NID_secp224r1, NID_sha256,
"d10131982dd1a1d839aba383cd72855bf41061c0cb04dfa1acad3181f240341d744ca600"
"2b52f25fb3c63f16d050c4a4ef2c0ebf5f16ce987558f4b9d4a5ad3c6b81b617de00e04b"
"a32282d8bf223bfedbb325b741dfdc8f56fa85c65d42f05f6a1330d8cc6664ad32050dd7"
"b9e3993f4d6c91e5e12cbd9e82196e009ad22560",
"c8fc474d3b1cba5981348de5aef0839e376f9f18e7588f1eed7c8c85",
"0466f49457ed15f67ed4042195856f052fe774077f61cebcb9efddc3653a6e3f3423eec7"
"308a69eb1b0416d67cc3b84d24f251d7cbdb45c079",
"5e5405ae9ab6164bb476c1bb021ec78480e0488736e4f8222920fbd9",
"7b7beaf9f696ca1a8051527478c4c075ab45aa4768937886dbf38618",
"93d4cf110a37c5a6f15c4e6024822118539e860dee2f60b8c3f462f6"},
{NID_secp224r1, NID_sha256,
"ef9dbd90ded96ad627a0a987ab90537a3e7acc1fdfa991088e9d999fd726e3ce1e1bd89a"
"7df08d8c2bf51085254c89dc67bc21e8a1a93f33a38c18c0ce3880e958ac3e3dbe8aec49"
"f981821c4ac6812dd29fab3a9ebe7fbd799fb50f12021b48d1d9abca8842547b3b99befa"
"612cc8b4ca5f9412e0352e72ab1344a0ac2913db",
"04ef5d2a45341e2ace9af8a6ebd25f6cde45453f55b7a724eb6c21f6",
"048d642868e4d0f55ee62a2052e6b806b566d2ac79dbde7939fe72577379505a57cd5690"
"4d2523b3e1281e9021167657d38aeb7d42fc8ec849",
"ec60ea6f3d6b74d102e5574182566b7e79a69699a307fee70a2d0d22",
"2fd7fcbb7832c97ce325301dd338b279a9e28b8933284d49c6eabcf6",
"550b2f1efc312805a6ed8f252e692d8ee19eaa5bcd5d0cda63a1a3f0"},
{NID_secp224r1, NID_sha256,
"4cc91f744ac858d3577e48813219aa3538dd813b186b42d1e6218376f07cc1cc448ddd6b"
"37240e98bf953f49cf54d65c12878b33c0bf6eb1c60254f0b6fa974f847e53abc56773ee"
"f6f29885dfc619e6a48fc15a667ca94001a0c945b6357a53221b0f4b266181456b0d2d25"
"e90708777f1a6f85971c00140c631c1991e0fd06",
"35d4bbe77d149812339e85c79483cb270bdac56bbf30b5ef3d1f4d39",
"047924b1d7f5920cce98e25094e40f2eb3eb80d70b17e14b3d36c3671c26c5af35f71e61"
"858582b7cc2b41790597c53ee514ffdf7a289d108c",
"751869c1d0e79eb30aae8fbfb6d97bfa332123fd6b6c72c9cd3c1796",
"26bb1b92b0f01e94eba5fa429271371db527ce857abba13bd1103f64",
"836aba9c63e1252c2b2d72a21e6a41b82241ebe32647e7f814652bcb"},
{NID_secp224r1, NID_sha256,
"58f43cc1924de4bc5867664adbc9d26b4f096a43aca47c27c52851b006dc2a658919ef9c"
"e5b5ac48372703be15ac51631c2bd84b88f479f113b0569a9a09e230ec1e8e573474c607"
"5284d3e57d973829af35325d9e7dab4a5f9b065155bbcaff3642a82ef4c9b9e127d3575c"
"050721653da3b087d3fa394192897a5519527d19",
"2c291a393281b75264c9b8817af684fa86a1cdc900822f74039dc5d6",
"0418cb5826ad60e6696bf07655032a3749f6577ca36da3ccd6e66a137c194e14820fe02d"
"784fd1363ff7a30399518309765bd3f4412d646da2",
"e2a860416229dfd3f5a5cc92344ca015093a543943a0d8f73bf2b2fd",
"00e300c1ef4a8c4ca5da6413856f8981db49de29bdf03f32ffc3ceab",
"f250f18a51ba5f63e1584097841099fa6ae4e98ee458c061d1d5aed7"},
{NID_secp224r1, NID_sha256,
"113a2806b052fde683ee09453098e402204155afb3776fd1cad3a9103421d327eab8f9ec"
"0dd050ffcc83f93b34ea707705fabeccfe43ab1a71c95298fd3ec769d99ead1066950eee"
"677d225816e0faad19cf69e1b35d16771689e2092cafe16d7c0dd7b0db73fffb8d0f3eae"
"d83004dd21e753530ec939c89ba25578fa5f785b",
"831ea25dbeda33d272a1382c5def0e83929170ab06a629eed6ee244b",
"04076518e393940d42dfd09819409d66966d8c9189c83d554a9cc8a08244d0ceaf4c0f50"
"e46bea4a52e30423ce3ada19edd363ac5694c65cb8",
"6be6dd9f6a083915ccba54626caf12d246d3aece0a7eda7d8d85599c",
"ff1460946e06fb6f5d35e8d2625ca70ffb9b45308e3fabf6ad8351b1",
"6029aa3990918e8cb8a388d53b0772e5cdfff49c3405fe0d3a95933a"},
{NID_secp224r1, NID_sha256,
"64cbfc8f2e2149a31b3e8a80c4a552f6c62aaeb7990b6e0ee55500a9d17be04213406578"
"caf315951086dff5c2af3b5ce17d425d185101ef26f86396ba3a129a4f3f8e2dd595f59e"
"fb6c0f5c2dcc394569d7268695e9ac7daa84203f1f1895f1f9e4b514a5c9cd23baa63454"
"710144fe735ad9b8f42d8c43267aa434a26d7e5f",
"70f74c7324ef137318b610ead8ddc5b964e0eed3750b20612fc2e67b",
"04279649e2a2918e683520cde3fc98b0ae58a7100e8de35e7c9cc797b6aa4de6be34be61"
"f02880139787b9038f4554a8ef1c994b887c2974b5",
"8e984864f86f7a2a73f3edda17dbccd13fac8fa4b872814abf223b1b",
"3b18736fa11d04e27e2614cda03a63ec11a180f357b0b3192920d09c",
"2f0f3dbd570727b14fbb29155538e62c930dd51c4035275c1365dc60"},
{NID_secp224r1, NID_sha256,
"a10a11c8e30fff118d371daf824f16c08200b83ea059436466a4611ccac93b2dea2de8c1"
"006f946196aef7fe9b0c251a391b0340f21797798278b412ff2b53842eec6450728e2bca"
"062f8337a2c204b9ea04ff660cd4d4db559f2f11c4d8ef199021339fcc82396f7a93926c"
"f5f247e37d8067fe50692de54f102bd5ab51925c",
"026be5789886d25039c11d7d58a11a6e1d52cb1d5657561f2165b8a8",
"043fa617c50b177da1a2bdb98b780ad21ad1195c4bd24465f6187de3c9e3fd8d8876dfd0"
"3a4a4e31a1acad3a08d983826d286c250c4e5620c1",
"0128b8e3f50731eb5fcc223517fc0cf6b96cd1d2807eb4524bc46f77",
"3a6b633f96f3d0b6d54f7fb29ac33709e4f0dd8fa0e51606ed9765ca",
"63e8c119dfa51784decd864f6911f2210a80f8f02d472d88df10d119"},
{NID_secp224r1, NID_sha256,
"b3f720bf566ffa369259f4361959ae0641d2755ec264a4c4349981df2b02563275b2b9ad"
"b5aee47f7a456760a971991ffed6b17809bb9694138d1677fa916123795239353158fc6b"
"22d10f20d26f5d2dcd8c56c44373eea5b93067dba2d7c5318dac2e9e8714873cb1b37f58"
"c011fd14fa1e535554efe05f468bfc8e11cd8b99",
"e79c18d935c2839644762867aa793201f96a3cde080c5968412ce784",
"04b7ae1e992b1c7fde1141f40bd913358538ca0f07f62b729f13cea327811252d12120e0"
"4805fc171a439d382c43b68a21e1a0bdf5e4ec1da4",
"7abedab1d36f4f0959a03d968b27dd5708223b66e0fc48594d827361",
"d35047d74e1e7305bb8c1a94e8ae47cb1591c3437a3e185e00afe710",
"d9c425c9d5feb776ac8952e6c4eee0ecd68aef2f0e7bff2e49c9185e"},
{NID_secp224r1, NID_sha256,
"0a398a46df7ccc48d1e7833f8bbc67100f1ef77a62dc78bbc115b2a662f9591fbaaa91ad"
"3d788e2fdd1b3164e45293d4f5686c151296901768028ac80ded4bf89c647ad35f0c7c4c"
"b318c0c757c1d83c44d850e5fd4677281b3f13b1ee54de79c8c042813f9d3312dcc6111a"
"68299cb7e829557d7f3d96e702f65aefc6499415",
"0d087f9d1f8ae29c9cf791490efc4a5789a9d52038c4b1d22494ad8c",
"04cd95cf8fb1cd21690f40d647f2353672a1076cc6c46bddaad2d0fc56934262f74d9ee0"
"f8a2754f64cb7415923d64bf00c94a39b52803f577",
"557d0e3995dc6377b3911546dd7aeaeec62a6d8f2af6a274382fc37f",
"56df0ea6afdcc232ceb41729eec00cf906b69b6e28423a36d3c92cc5",
"f4f70fd948c9a147f55317fdea7b8a84c33e721014552d5800d63edc"},
{NID_secp224r1, NID_sha256,
"8c33616821a6038b448d8918668977fcf1ef5aa0cf7c341837b39bbcc9bca875a3757f4b"
"392630e9995b9bbe4eb66978b877586adaa02f99d2344dae082a7603351d8ffcfca081ab"
"403cd0acb90d078dd1d0789c2eb3185c62bff2d9f04cd38e509e3b83c12ed0a5c6808fc4"
"2f7ba5b06acdc496c8ad9be648ee6a4505f8560f",
"0830aebb6577d3a3be3ba54a4501c987b0e0bb593267b9bbadb66583",
"04b88652020e083ccc1c43dc83d1881884dd4c7e3b4e3460b344b1ea6422b69b517f86d7"
"c26dc37c0f8feb4bb07fe876149fbcc3334fd2805b",
"e4f4a3280574c704c2fde47ca81ec883d27f2c5a961a294db7cda9d2",
"b30b8a0079d9a134b5e1618c2ac63e3fbe0e95866b9dbc5f423f2707",
"3dc36746610271ef66e0aa52cc2ccadc5c9b08dc769e4dc4f6538c11"},
{NID_secp224r1, NID_sha256,
"94d56535fd4edfe67a0daa6579f9d53bf6b7b8830ae2aeb62892ff59f18756ddf2811b44"
"9c7d20d65d54f8507de4e7c50eaa084830637812aa4b250a4d61ab67845be36e4a41cdc0"
"a70f8d6e3a63d4514f0dc197e6486015046a316153d5f3a3a4a0ae1ed7ea5fa55e12e73d"
"333333685c02e0eb636234ea7e6d4b76b4b76b5a",
"2acc9b97e625263e8e4cd164302c7d1e078bfcdd706111a13ccda5b2",
"04ce1a06f82df874dded37cca03b56c0648e4e8917ecd40ee73ee61588ceb6177b8f1ac7"
"c5c6e6e1f7737cc3026952ee392badd2cd7af32f9d",
"e401fa80f96480d437ed4f61a783888062ec33d530b188fd48016a6d",
"28674f447c4742e4087bbccfb522fbad4e18b56031d2ce8f532b078a",
"a5a7a13d15b423dd17771f73cea98d89dbffa846cc209b45c0e29b76"},
{NID_secp224r1, NID_sha256,
"5d8ebdf9eb28b47bdafaa36bf0b66a9eaf99b6c83959da4f2b1151b4f4ecd28fb115a64c"
"0cb9491093a7e9b9c53ec423e4c72e7765bb9c818da0e8c428667e44474a71db4867130c"
"77c40bfd8544b2d7b9d6464d2b8e6a48482153256a32437c3a747231f51134dd14c70340"
"7e31146a6fcde23bededcf16950486e90ca69ac0",
"f4e873d4fb944fb52323406f933815092b7672221de4d1c45917f3fc",
"040dc2cdddb990341adb1de73f02d87fc3822485a659a15145f4251d5fcf78b2a83c7352"
"eda1af2c74e1804ea04b35f76c04e89d90281dc2bb",
"5d1476c682a64162fd2fdc82696fc8cab1469a86f707ea2757416e40",
"82982b38ed465138df4018d7cfb835edcb591cb57446ca49d163782b",
"8ef1d7b326cabee7f7ab95b7b98d3c27a069c0fd95a1599c0ccb422b"},
{NID_secp224r1, NID_sha384,
"25e4416695f77551fdce276355528ccf1ddc2483821c5d22d751d50111ca2fadc6593b52"
"c74f4b5957494f1df25b0b2f86950d0d19229ec6506fee8581d2dd09d48418b146ff16bd"
"84a17ca0dc83b1888eb407376da6c8a88fa1e60b8c2a2471dfde4b3996ef673d5bde3d70"
"c434dc9f2488e9de16ae657d29e5e59ec922a1ec",
"62c572ee0d6f81b27e591d788bfc2f42b5105d2663078dfb58069ebd",
"04bd6ba605639b98fa8113a16a3bb004ddfaec901c98a931206165f4a5a3190b10ef39e8"
"8abd60b2293b4707512b45c6c5ed5794cc11454427",
"0f0bb1e428bcdebf4dc62a5278068efc0f8ce75f89e89b3630f102b2",
"aac0ea27e129f544abcc77f110e70bbdd5aa3e425dc39d5e8887025d",
"10e5dd06aee6b8419a04aa33d9d5678b0039c3acc3c4b61fe106bfdc"},
{NID_secp224r1, NID_sha384,
"9164d633a553deccf3cbd2effccf1387fa3177cd28c95d94a7d1a3e159c5e5c027758cc2"
"6493301b2f4d141d8d07a5fe5fead987ce5f30abeafcb48c302afc6c2309f0e93d9b6818"
"cbb6972d222cb7b01302dfe202ae83b89f53150ae4a0e2b8fc0fd1091f19b4ab2e6ab213"
"ab322d04f2c5f57113bfad3c5675227237abf773",
"e2f86bf73ba9336fa023343060f038e9ad41e5fe868e9f80574619a3",
"04f5d5346f17898ea6bbdfff19c216a8757a5dc37b95315f5481628381ae61fd172ac8b7"
"a4f13870a932dece465834cbd4f50bbcfb802c824e",
"35724ac043e3b44b73b5a7919cf675190306d26aa67c27c28c873534",
"535147c265af138eec50c7fb570bcc8d2e6f675597b0fcc034e536bc",
"743812c188a1dddf9fb34b90738f8b2e58760d6cd20ccceb1bb9c516"},
{NID_secp224r1, NID_sha384,
"019df05929321ecea7ee1de4f412aba1c8d3c24437db04b194a68a0a59dd871be10bd3a4"
"be6edf551350ea49fc7155a4d887e1221486291abe77a30633a4c4f7868fe2df24311cba"
"0c73804883954460e122387ed414111ff96ff1aebac8b6a6491d8a0d16e48a63bf3d027c"
"0f68ee4a4b234d73b412196706af8ea022b4dcef",
"b0a203438e2586d7575bc417a4a798e47abc22aa3955b58fc2789f17",
"04dc5d217862a1e5b00c95affa9d8b925a72b9beaeb7a86dc397e788d85f05f8e976ae1e"
"b1036eca6d683a82850795bf9127dee5f8b2859445",
"408e9c8b1f33136d6ddb93ff3a498bc09d4eee99bf69cdd5af0aa5a2",
"1b5a964c8b1fc634c6e2b82322499df1d7f0c12a4d2a77723c816ab8",
"cf54599a36ca064fae0aa936de5266f87704409d22a15d28c01b7f2a"},
{NID_secp224r1, NID_sha384,
"5d09d2b1d3fa6e12c10d8b26dc9aabc8dc02bd06e63ff33f8bb91ede4b8694592a69e4ed"
"4cdf6820069e2b9c7803658949e877ffe23bf90bcf5ce1409c06c71d86885a94048b05ac"
"0ec9db193e489a5a2bfa367caf6aa8ecdb032be366174343f6875d2fe1785e8d77334f5f"
"469cec64998e08d3303e5c9a1923b34fdc105d65",
"efcfa50fad6fb2065f9a55f28c0c42fa24c809ccb19b6fc6d8ffb085",
"0461521a0cfb72be77ba33cb3b8e022743cd9130ff49e97093b71aa178ce0819aedaf6fc"
"e639d0e593f8ab0147eeb6058f5f2b448231584ea9",
"d1eea821f286eae6ebc1f61b08f9ad4323a3787e94af4c32cd31351b",
"b37caaa71103752ac559f9eb4943324409ebfa8b585f684dcaa5c411",
"7c28e7619e2944ab4b7be022878c8052ebdf2cae5dff4f976c49686a"},
{NID_secp224r1, NID_sha384,
"50f6dfc81c6cf189e0a310f992907fe93356cee9dea9a41c7671a8daf3f4cfe0c459ce61"
"22c1e731dbf7593419d7114cb73b46956158a982c5d52c72f43f0f822046093c69aeff1f"
"7e4cd8af00ba655c5baa2e7b6a400b4be1f6fd51b3e4cfb35a69c80a28c5cafb771b6c2e"
"52e0aeef0e3fd045e8d40745f3f8b74fd969f816",
"61a17816937987764cdc064dc7b5b4f5b16db1023acdfe25902957dd",
"04a7e975c0a8f87c683bb8e31bc160843a7b69c945f4850bd60e1c08c08930a454dcc2aa"
"13bed7ea89368b2c9d689d816b2acf4e52585ee9c4",
"44b1fdec2629f9075f89c134ac28ff19bfddaa9db02a5d7f853582b4",
"b0f5635d8bc9c53a1d54a3ec63de59ed66e6b2358d4ab79755414326",
"67c68fe265c7e5aba4232deeafb88545a2aa266fb9f2c2bb3f3ae8d2"},
{NID_secp224r1, NID_sha384,
"e90129ac6672c85bb7b6b18e9dc199c96c81fd65034b53c77818364d512366fb9cd1bc7c"
"82404c451e561fc1ed916c0948f6ac561b33a1ccca093f07684b8c2bafa9e966377bd208"
"556018a5bafb9edcecf70498c7140fe9c8cf3ad8b8c3b0aa489df797944465047465415b"
"b0e24333235fcdd59a98829a3941eaaf62033e82",
"79d5367314ec664aa0f6ca36f95549502a05bf8400bf532d669fab8d",
"043191f0237102dac159032ab2dde53cf56c9ec827b5caddfe9e83c02ab496b1bdcca443"
"4ac0d0d91ea38ff3bc33f9f54095bfe17796d5a9e2",
"da529c52f5cc1f435d873109cd991d6cd7e1631d9ff1dd9521dd5db6",
"8e0ac63903f4921755430572c3f08bc272790639bdf1009fe2a9a714",
"6278c841a2d0a270791fe54b36c49d426d67907aa4e4f59c8638ad97"},
{NID_secp224r1, NID_sha384,
"3c9a483c9bee33b601549c592a82e95b4319b1e74b777877f0971bcb4273716b268e8f99"
"f876e42f942f4cf08284896bbc1ffbf094ac0956c3cedfc3580cffa8c74fc6db29a371f2"
"da2d05edb9185ece741fe0d3fabfe9d5b4d373755ebed13dc6840cfa3283b9ea46ec8b95"
"c434f253ae86998182e9cc0e95ee64f323fc74b0",
"1320eedad4745121793a7eaf732b0b4498f7cb456cac8cf45a1f66f0",
"049fdd99906ab77fd29e9021bde947d05a7a9eb153612269bfb0899bc9681b65b9ac8e4c"
"2899bb622dafb253b7bf5a6e38e5f6595f997c291a",
"66ed8d8934633f4125f593cf1b1d3745c4db1f15dde60cf46ca1c7f2",
"80199485a3a96447b39f7679cd47412a78675ba17dcbd10465dc5b48",
"a251fd9f136a3cb0dd0bc80659ae032e4a761ba7045da0034553fb8c"},
{NID_secp224r1, NID_sha384,
"bfc073fdda63c5fccaa0ca8770c293e8154e7aec56128bbac4fdbd541d602216ebf7ca1e"
"02b514d6e396f20683802ba3f334310a9226576926e3bb19ceee27738d13377cbafeb09d"
"091043501702a07aa31d1f29d50ddc55adcf16ffd40578e734a4e6cb6535f26ad48e0c62"
"ad90e79720000e87d419e92dca3e11f943655b03",
"e18821329447d3f65ba7279e96bd4624ffa1b32b90f6e8331b1e876d",
"0446c9ed837232c47022df2f1a1578fbe65ac9f2e81c98a74cc22ea31a6fc5e9568ae62b"
"31412a0b0b367242e9fd7e518c83aa06a069e1d90d",
"a4c1eb402a2fb3af26e0e14a3d2fc8ed3bc1a8b2475270356a79fdd3",
"d478b68733d8ad44be46766e7b66af782fbdc7ff7ed0b191176da98a",
"5eae9160ccf71fd1d359d89cecce72ef8afaeee2365f6ba828aa450a"},
{NID_secp224r1, NID_sha384,
"08079955d1a1f33728128c73673ec9f21a6ce138dcab5adc4dc068e6ab57314b9fbd8b01"
"3123b2fdafa9524fbdd0288777a233de8055cccfad83046ada6a19f01c47817496667bba"
"8fc8b9456fc0e044a562d931dab1adcb66af8b66325bdf28d83ded3e2937958ccd19da54"
"0d70ef2c189f55a506c9c0d63406394c5bd3823b",
"f73e030d5a696b358986d3efaca121cf71f775f8835a21e6135145d7",
"049ca2c6ea87ac8dd3a23a5b4010841a7c8af309038882ae44634bcf55b0a347dbd5ded3"
"b8702ac5a457e8b32bd4de06fd315095fa1b7d5fe1",
"e3cc786c1288ea567836c51d6d69dd0cab5c015987d936ccc3a4beb3",
"f1234da71761b7a0f49e661a419d2a739bdc4544bf87690e3d2f96db",
"096d16bf8020c3d3c233894ad8eb81206010e62c6e692a215e088fd4"},
{NID_secp224r1, NID_sha384,
"23900b768f6cd42b8a8df0dcbc9cb5daec8de36b9d5c619adcc1ba2b649103d5af123746"
"cdf19c3fd0665a6fb9338156182aa06181e3c6e37ce56979612af2927440424f89cef43f"
"c754854b8a5c43370808cf5f9929cf47712512ce2f8a2a20d2e9f568c2848b27dfbe0914"
"2843c83905ffa5da3b15501761b03dbc2c5398b6",
"7a0789323f8741c157a1753ae165ecaf8e8b03a60561f8b80cee467c",
"04101271a9addd4bd1f19d00bf116c8524f52cefd598e85dc381597acb2f17d14f4d8ccb"
"28b216553718152ba7c104646d8eca986dd9ddea39",
"d169f04f05b60c625cda864d187938863964dab7bb3b9dfc04b05519",
"e4a51be686a764b709da23ab48b1985e153c6ee238d945e743907afc",
"118a8f1ffe3cd556ce6345bd1a398dd9cc3729b7fd6d8af9bfd82f40"},
{NID_secp224r1, NID_sha384,
"1eb28c0bcdd18f73e347f957ece15b4cc83a771b0877e1feaac38e24028fb38ccea8b54e"
"e017dc7c3d5a1327bc6f40b294aa65d7dc487f278846cd101ee84202f14b38aa2c275046"
"aa2577f65ebaea41cd383e8def2fd0b4444dcf426fa75c4082cd7fa035cdb1e0d34a3c79"
"d42130f5b0273eae75bc701dda3aebe7358f41b5",
"78e795d0edb11fd9e28dc26b21e751aa89bea0d87932ef11c95c0e18",
"049edd544107977134bf6360d43ccabb3c94d627c03963c0a04b439627ece4c61d319a0e"
"41f3de7863e7c355bac94395aaa74cdb5f74a87a5b",
"36f7c0f76808b826a0a974a1fd6e155e00a73f1d34674a8f88be405a",
"3e319444438bc2cc92f323ea842cb402b3c3c2448c89869ef7998edb",
"3420cc38f058f41c31e71f4b1ad488f801111c73541de69fcee60695"},
{NID_secp224r1, NID_sha384,
"efab51855407438fd5c250670366bca3c026ecec4a59394f00d8a4b51746d0c456436665"
"6d507e3e13e62fe7abeb976b8859895848dbaecf6582f1898ea06f00d4247702ed9721bd"
"375aa83ae4c67c2eaa6e080777ea5ecf2cf787d785389560ac91cf63a52f0373c3185e18"
"a3b8a466e21b61a239f1b77624eb1acacc76c4e1",
"bee02d8bc5bffb3fd3b4c9d6f686409f02662d10150d1e58d689966a",
"048848f964c847fe9dddc774618d4588c9cd56bbe588d7b1fb369c8bfaebbb699fbd0dc0"
"8859fe9132285fe20dff3b9d561c0640b6e0717607",
"59f1450d857b40e5552a4b8cd4ab0df2f01716635d172c1106840f21",
"a206d8398a16a991bc217f77f23c6f648384f254f255a8a876404444",
"eb1169cb5b1423dc0bfaffe565ae57f986e00de06405e3e7b605862e"},
{NID_secp224r1, NID_sha384,
"31c29ca10279a417f0cc9b1382cf54dbfdfc89f2e6ef08c403c11f580cbf8674b141ed1a"
"417563282d99a55fc616d836421cde9424815c95e7fb7668bf3f137b29937f14882d74e0"
"34b732d78d91af7721aac4950734f5fa5d4b4d35534974f8cab6d2e6dca75ddb57e99148"
"c8a59df9fc5bcd723e546e8356f671cf2f65640a",
"dc0ddf6e501418bb8eafc5d7ccc143369e2aa441df8fc57d5f94a738",
"04063a5d632f4144376e14cfb03ad8ccf1489b613acd184d20dff66545e77727f057b043"
"d8a0f7458196b72e92d11f85b0891c6aaa9d915f58",
"ff0e5cae2671db7a1b90e22c63e7570bdd27352d45bac31e338debe0",
"5bc0b4998481ecbd3b6609184a84ca41d69b08c37138097f559259f8",
"0df8828eb1ca85e46405b94e1a2972c34c5e620a54e2f640f04aecc5"},
{NID_secp224r1, NID_sha384,
"8db476f92e332519c1a0ece5d8deded6efbd2d8e8784eea0a6b4c3b4296c35f5f8de4317"
"e5c1627b91fb1973fee86c06e4992aa5a20cb7475c8808ff1da354d07a488dffa7838c6e"
"c1e3f99e3acba831f27bee8434eeda3eb36d0c6df3658883cd40068b1bed841310f6eb38"
"d4a3d07d85848770ff7933c054cd8b34662660b1",
"229d89b2fcf8441ffc95ebb2ac2ef156e25825782044b2b8bd6a3e01",
"04de616848d8044a44789ef1ba3a6dd66fe9257ddc57f7534e59a701be26cbf74a6d25e5"
"b34b96d30f327abd574cff7f7dbe6686573a7d6c5c",
"3b18ca6ec8e8e255ac88f64302745ca0b73ff94b2b2d48be95b4aaee",
"fa94fd8b827c06115c1eefd50afc02ce5926ee0e789667783c01c34b",
"edf766a66973cfc33e4159966c07321a7f6549c3c60e8586ef41402b"},
{NID_secp224r1, NID_sha384,
"fcb272c828fe8fd3c6f8de9410c7b6e2b36717c1b0e5e359e9109bd7fc378978aa98182a"
"9d99961898ed88999b050d3b64d1457d7a899d6d273b9f4dde2aafa36d76329d62509043"
"c338f265fc4c7d938459b7fa3b230a9f6cb632b61489546bb4181a5ad7f0d7369b8caced"
"48eb374b075b2b325bc86add0f3b680cd9e80acd",
"97d747068147c0393a0bb5c159e2c9f1bd538f6204823294883abe28",
"043858a576eef2ce24d01766997fb81b3f3f78b6104cd188610be221d795ffc677ac7bfe"
"3e0bb4cffb17355a964c8356a807151b3cba5d1f4e",
"c1a2ec1ef16cfd5107c892790daefbed061be78bd8576696b60f64d5",
"18c908541843fcdac99b9ff6bb397f3f8094d16b42670216e4eaa2d7",
"c107a8a508ff57c5d4f78f86cc37e129c864d1c44ed5e73909613b74"},
{NID_secp224r1, NID_sha512,
"7522492bdb916a597b8121f3e5c273b1d2800ef8c1db4f7dcbae633b60d7da5193ba53a6"
"3d7a377b351897c3b24903ae1cd1994211b259be3e6ae2cbc8970e4957fdf782c7d1bc7a"
"91c80c8ef65468d4ef35428f26e2940ae8b0bd9b8074236bf6c00d0ebe83f9ddb2ade0f8"
"35138d39f33b59f244e0037c171f1ba7045a96f5",
"ba5374541c13597bded6880849184a593d69d3d4f0b1cb4d0919cbd6",
"04ac635fe00e8b7a3c8ef5655bdfb7f83e8532e59c0cc0b6534d810ffa1d067aebeba66e"
"79b28ecfe59ac6fdf5e1970dc3a84499c9d90cd8e2",
"187ed1f45c466cbafcd4b9577fb222408c011225dcccfd20f08b8d89",
"f83d54945997584c923c09662c34cf9ad1e987da8bfd9be600e7a098",
"4ff2dba9dba992c98a095b1144a539310e1a570e20c88b7d0aa1955c"},
{NID_secp224r1, NID_sha512,
"61097114ff855c3e34a62d9b853f8982d35f29cfa4a89893badbca7849e5fb437a1a38d6"
"451bf0ca5a0d528e352b8e4b57f2ea359a7fc8841d49dd3e570f9b016f14156b0bbc4be8"
"22e260bd147ec081454969e11cb0034b7450ef4deb7ed6edb977e2f4ed60121aa095fb0a"
"b40240dc329ecc917f5c64b4410612af065ee9dd",
"1e27187134d0a63542adf4665fba22f00cfc7b0a1e02effe913ceedc",
"04ecaea8ceea55c3bd418fd34a4ff2499e25e66a104eed846bc00c31d23933a356ab1f2d"
"abc303ff0a5d076131e77032e6f502336883bf78a7",
"34cb597deae9a3b1cada937abcd247161b19b2b336b20e2e42ae01f1",
"58177ba46fb291490b39368774accf72736412c1fb5ee0f27b9b1e02",
"58337d78b95a080bfcabb5809bee012501b4da84b8ef310a4628f11c"},
{NID_secp224r1, NID_sha512,
"dd09ae6c982bb1440ca175a87766fefeacc49393ff797c446200662744f37a6e30c5d33b"
"a70cbd8f12277fd6cc0704c17478bbab2a3047469e9618e3c340a9c8caaff5ce7c8a4d90"
"ecae6a9b84b813419dec14460298e7521c9b7fdb7a2089328005bd51d57f92a1bcbeecd3"
"4aa40482b549e006bbf6c4ce66d34a22dda4e0e0",
"0905b40e6c29bfcbf55e04266f68f10ca8d3905001d68bb61a27749b",
"04d656b73b131aa4c6336a57849ce0d3682b6ab2113d013711e8c297626328335ffc2029"
"afbfe2a15cc5636978778c3f9dab84840b05f2e705",
"dc82840d147f893497a82f023d7d2cbf0a3a5b2ac6cc1b9b23e504be",
"583af080e0ec7c1ba5a491a84889b7b7b11ccfe18927c7c219b11757",
"b23700035349df25d839f0973bef78a7515287de6c83707907074fa6"},
{NID_secp224r1, NID_sha512,
"37a73e2774d3b274db426c89b945696daa96035031f72cea01894b24508c7f81961ec254"
"d36ed6a0f448e11cf7950af769dc6cd2c47e52c6caf0ea92c270974f0214b4db436c36a6"
"0fb722060a6bb544462a82e1714f5906ec32886f7d59ebf289541c3a00ec1e004892ef2b"
"1286a0194f55d083c6ec92c64b8fd1452e1c68ba",
"afbaede5d75e4f241dd5b53220f3f5b9c1aa1d5d298e2d43236452dc",
"04fe83e59fc8ea8b939355d3258fe53a64d45f63031a0716b7cc416173f151d23060f1c8"
"56eb7f1f58be72a7228c3af89e43b56e9695b558c7",
"0fbbe7b40136c81a8fb894498d5502157a1cf5a89d0643de92cd38f6",
"24f3f457c7b72b7e759d5a8afbf330e31c5d8d2e36f92c0e79c5d87d",
"36fd1193def34f12a960740fd79fb38bf2b480726ccad540eb42cdf8"},
{NID_secp224r1, NID_sha512,
"9dc2046ffdc6804544db964481abe5d2d276a2a9eeec4c7ad40215b1de23561d402db69b"
"d0f6eec2254711eea4487c64d9a6b62c3ebaf5ffa8db6e7e3a6e17154d126967a47a853a"
"6f8339bdca9be306a13c7f992ded7619b0da59909a49b1e0930360e05b47f18628a36d69"
"b2f87f2bfddd6a5d4a72f84dc76dbdd43f3a6a35",
"950b07b0c2b7539a21b5135bfede214733f2e009647d38d8b21d760c",
"04f43d13bbfcee3b724063b3910fea49fd591b81e86fdb813b1a492d0c6b4c8d6fa5dc66"
"1889e3cf5ec64997a78222837885f85d2fe9b684fb",
"83e110d0d1e700d2f36543028737d2a2f1474aa3b4b28998a39e4793",
"2685265bc878e85d10ab13293dec190881a57c4a467f8fc2170432ea",
"80a347bb49036522369339bd6485a967cdda818915d8eb947302fcf9"},
{NID_secp224r1, NID_sha512,
"d9c6847fce688c5e7525a1098b545cb6c15dcd21a02761fc82fc664372a667390680135f"
"91c01a2fa5430c634b1a6d1cd6002d8aa021e7bf5956a7901c2f81bc25d502ba5f55a55f"
"30c0323dc68205cbefec0538e68654e7b327ac1743641896c3e740d8f66f400902b304ea"
"faa4e0d8cffae140536f0922444cc3216a675697",
"015bd9f5dfef393b431c3c7fced24385d861ccb563542574a5d2a9bc",
"04e868690641e2cda13b289a6c5d2fb175940396044d9cf27b4f2240af4c78c9abdf2b7f"
"c67ed4497001d7bcf1daca1739dc14a661f91d7c40",
"e2374350f47c08f3c1359d4edf87e61d1ba4e7dd1540d8d9062efa79",
"e12dc088d2bc032bb214c77d0e0fb749fc8e61ebe1ed72996f1084b6",
"0ab58aa31e0bba5fbc76855e6549f1036fba0a589aeab978ab01b8fb"},
{NID_secp224r1, NID_sha512,
"69df8a01b66f04930efd2012ff2243874f256ca8758145d2a9e4ecc84d0dbdbd0dc494ae"
"06db0ccbe819918137c90957114558580d6623efbafdd342b38dad9f08708084d32f874f"
"ba04782ce26aaab78de2102ad171f8a8f2b30b5bd3d55fdac5fa3acd6f7def7e61c25339"
"38572b331ba6d1c02bd74bfdbf7337ade8f4a190",
"0a3c259df933247445acffb6d8265b601d597fb9997dc2a1eb4deef4",
"04e67f4385a9da54253cc371ee9bc6739ae6385a4b87669c7baf0c460d2bb00b6ddd7b67"
"d9ac5653ec04ca8529fbf16f815c04da3c2e58e82d",
"8bf5859665b6a23e6b05a311580f60187ba1c4ae89e44877fb48af66",
"653675fb993c3fa9e57b32e33029ec230b966e8077c72c1ec90ddefc",
"792723bf87e315147cd4303de7f1dfe95cd7658ebb95c38c1a196140"},
{NID_secp224r1, NID_sha512,
"927524982b8d60777c1105c86fac05f634abf58c73f84fb95d81ba0b86e1e43592c4fcad"
"2e395a40fbe7005697d86088e2fb3bb7287eb3f917d4f2dc281f5cbe65d05b4f9623bca8"
"49b10a03beca6aa2056a12ebb91cf257ac448c5e9a78f8349a6a29b17c8978bef43a443c"
"bb8a149eb23f794844fc41693f2dbb97181444be",
"a1c8ef463f9e7e3dd63e677412f87cf9ea4ac9a6a2dae629da5b9916",
"04400e5cd4b315ceb309545cd3277acb70bdae2073fda6ad896ea14b27fbe1d2466cd2e1"
"16f38248bd5cabaa6cbe6c4a2694d998abd7b0c991",
"82f55a25d3ed6e47c22a6eed0fa52ed0818b87d6ea7950281dfefc09",
"16305a46a3f6f9e216ef8f6a6f5f0760d064a885657c864e1c1ea035",
"58fd97050bfbca6f87e64e1458c4ad80bae26e280356da344ad3b25d"},
{NID_secp224r1, NID_sha512,
"5f9042283561e7f19a436d01c7ef5a950a6d77ede5629cd7e43c0a5d58e8c5673c37945a"
"453291d12938253c71dbe12c8b022ba7276eda6be034ef5ec1ec77dbd1e08f0d7b8e7725"
"b7ec671c075e008a20f77f4ab266f97079b0aa6337df59a33b881954084057b21f294dd1"
"4bcb0869a4a6f1f597955ec7bf9d19bb3537a66a",
"fa511dbf6fef7e5e9c73e4555eb75d435f7884322d9faf5d78cacc0b",
"04e8dccd706c31f895f2f261ab979cbab51b8ae28196bcc12a42046380ec246be8e71ea3"
"859cb717a59990fe22e4b76858ff49becd70739a01",
"a37d665fe4314aa4cd03eb8e6a1f366b43e11fdb419c96b48f787b62",
"05e4909bcc172ab4140be291aad4660e375032bce2d762b6269ba764",
"e347a1c9d3670690e1d8d1d4cd9579848f442199c10526488da5cebf"},
{NID_secp224r1, NID_sha512,
"c2ae5573d3bf396523bfb703db8502fd0760cd1be528f6ddbfb95aad399e0b19f3bd9e0f"
"abdb05d49e3f893dffec5b627c9c2f7ad5f32e92e4e27a38cb5c28657657377fdfa1b66c"
"d7ac3d15c6d49df92d284db99f69744f37dc7cb4e7d52920fdb200a7942623a7057ba82e"
"467dcccaa5da416b48510d8364446a6a5e2a5aa8",
"a58bd53646400a646f0e4208320dc679a9664d1c6bfb27fdc8eac7ea",
"04e22e0dc4ecd96eb0071b72ba4b4988bf784f3fe73cb81bfb93d9ac4fb3e213e518bee1"
"367a4fb3703b9008bac9d95a1fc4aa61225fff9f3c",
"42c5b6f87d3bb1ed74f5ee8398d8f8c61e9e50ffa7a1da12d39893f9",
"5c0e5c6f057de1e99ef5d237a60d7a07fa9a42b120a82f573d9fb7b2",
"2fffc0bf550bd2f650fed085a84501cacfa6a1bb984df1f9237eaa59"},
{NID_secp224r1, NID_sha512,
"03c1a1cd30a039d0dcb22fee2450a7fa79495a0d0f4f43d2de4d75bce003c0334a8860f5"
"c164dbd94888a9f751235a3e570d31070e3e1293a7be616af7176600585d36ac01360015"
"7d2569d491da4b8a3bf3630c26e0b9925412189f50b0ae6f04c86477932e2ecd8c354610"
"6ae1ebc684cc3adb27ed665eddece886adea4ce3",
"64bd4452b572cc95510ac2e572f41136299ff17f6e8448f4ffb571d0",
"0492521fa25c2e034d127e0921efdb167f0b2ff8b20504487ed87fa264e72c770e37375a"
"d7dc2c4e63e5701826f6606f6ffb9461ee61b4e872",
"eaf76ee4d7e00d13d8a6d03dffd07ad9a8bb6dc8176c9f93059b1b7f",
"cf5058e2a6cf5e61a138b013eb292f38a1b9f07239ae5941dbce8919",
"d14198621650d985d270bc997da6e78588fd0ef843b874c66a3de3c3"},
{NID_secp224r1, NID_sha512,
"888f6d9bc7c86c0079fbfd42d8c08d6958f40f6e570fb0b1f03d2f8f8a63df4fcc87b379"
"a222cf835820a999d34996e08961f13b86b075e7fd1c303cd3baa44de42168561589012f"
"7e5300da4f8bdf470c07119a5d9f7ba7293568cd7c6a1b7fc1e41cda40bed7d46e5a28af"
"67ae2aabfefe67a86a1c601e6f5ee543e09bd7b6",
"7f3edb710df9d982f486233d0c176aa88f5a0ee81efa9b8145020294",
"04e7611e013e7b43ff5b8b57ad83333bffcc9e469ad23070b5791dc5947784da0a11dbe1"
"6208c6e0b6d5029e71fbec4dffc9fa046d3eeb71c9",
"94db7ef9a232593091eb9a74f289529c7e0d7fef21f80b3c8556b75e",
"a971f45bab10b1d16d7234ca8e4ec987da20d9e867f28aa063296e23",
"e38c538d65a7e1a28fd3ec53f015a7e5beb60e9d309f1e3ba4b2c3d2"},
{NID_secp224r1, NID_sha512,
"48453340f1317769e6ee6e103153714365731163dc18f84e9f2fa4b120f9c5a9645ee2f9"
"b66c84c26d95912b422b009b64af96aa418b2427a4209f2e7513ba8e43ec8cf20b34e752"
"9b22eb1199545afe9a9f7d9bcb320aec9ee0162f91c0d1dd9674c9c284f25199c5e109f6"
"f84d7ed0d269cc6413edb81bc2c83e37d644d8b9",
"b569f8296ff1d9cc01fffd9919016e5730c1858bdb7b99527153751a",
"04242f34959516a4706172f7dede23110efa314bff22eb320ab88feeff45e3227710900a"
"8acfc9bcce728119d042f64ca40876c2b380ee46e0",
"ae61523866a8f43e6cdd42ba27a34ed06527e8a5842901a64c393f76",
"c2732a4e0815f9f785500e80147e9486994446beccf8a6a352b97585",
"6ecaece6487d7920e398f7f951ab7c7aba5832dabf03704106ad1244"},
{NID_secp224r1, NID_sha512,
"4bdfd3b91d83108409ad765b256e0c9b9937ecf647f8e6f9fc807e2e72af8246178b3fe0"
"46b4ea10170450d71a4eec790ecb05f03d7077341de26c4db7eeae24d55c9a9093e837df"
"db38168fe8230cb9605825a1282fecd741989bfcdb34678fe077477927f66bd26d003e5d"
"da22043341a14dd31841ba483ad5ce2701e0f68e",
"41a4dd8eee39232b728516e2f21e66011e7426a6b25986c3ffa237e4",
"04c32988171caab178bf50dc7310bc7f604df5a9d19a8e602519c72d8af8985d112ad9de"
"05969e5364d943c1cc5cd198359f4c62b19da0e117",
"827d4999da81fa920c8492ccc1e2d5cdafed9754cf7382a859952071",
"89c61da7422ccd676baec07e2185c12e947a2374eede87847304be6c",
"2685379624717ea28422e8d001c090405a130b4ef9f1ac726c3ca502"},
{NID_secp224r1, NID_sha512,
"e6cdee8558bc1eacc24e82f0624ce8d02cc8d925b4dd3dec3a72f4a4e0fb76076bfa3ef2"
"e2c33bdd7c27b322bdc09bbfee8fe46f75dbd7bbd2af09690b7137943efe21706e0a1b6d"
"3089540fc58d85ddb55ea836616db573e36c521be008893f40a0a7c349602cc178ea43be"
"59d31ec6449e7ff2c5379379f7d7645134df1bc3",
"67fa50569257c8cc89ac0325db4902003a62f30b917f53e4035a7e04",
"046773a0436a9c42635730413b19aa4166f08c69c0e5002953da42253b555138290b093b"
"f2fe79acda9131d920cd1e7ac43fb8775776cd713c",
"557cb45fd3a30b3bdbf08c56eabbd4478736024aaa52bf8448096453",
"8e92cf7a674aa5f7542dd95c695589a05747431692edd04804299b8f",
"af4908b41f8180b71a6ff10fd51f3d143147af6ddddf7534d3284ed9"},
{NID_X9_62_prime256v1, NID_sha224,
"ff624d0ba02c7b6370c1622eec3fa2186ea681d1659e0a845448e777b75a8e77a77bb26e"
"5733179d58ef9bc8a4e8b6971aef2539f77ab0963a3415bbd6258339bd1bf55de65db520"
"c63f5b8eab3d55debd05e9494212170f5d65b3286b8b668705b1e2b2b5568610617abb51"
"d2dd0cb450ef59df4b907da90cfa7b268de8c4c2",
"708309a7449e156b0db70e5b52e606c7e094ed676ce8953bf6c14757c826f590",
"0429578c7ab6ce0d11493c95d5ea05d299d536801ca9cbd50e9924e43b733b83ab08c804"
"9879c6278b2273348474158515accaa38344106ef96803c5a05adc4800",
"58f741771620bdc428e91a32d86d230873e9140336fcfb1e122892ee1d501bdc",
"4a19274429e40522234b8785dc25fc524f179dcc95ff09b3c9770fc71f54ca0d",
"58982b79a65b7320f5b92d13bdaecdd1259e760f0f718ba933fd098f6f75d4b7"},
{NID_X9_62_prime256v1, NID_sha224,
"9155e91fd9155eeed15afd83487ea1a3af04c5998b77c0fe8c43dcc479440a8a9a89efe8"
"83d9385cb9edfde10b43bce61fb63669935ad39419cf29ef3a936931733bfc2378e253e7"
"3b7ae9a3ec7a6a7932ab10f1e5b94d05160c053988f3bdc9167155d069337d42c9a70566"
"19efc031fa5ec7310d29bd28980b1e3559757578",
"90c5386100b137a75b0bb495002b28697a451add2f1f22cb65f735e8aaeace98",
"044a92396ff7930b1da9a873a479a28a9896af6cc3d39345b949b726dc3cd978b5475abb"
"18eaed948879b9c1453e3ef2755dd90f77519ec7b6a30297aad08e4931",
"36f853b5c54b1ec61588c9c6137eb56e7a708f09c57513093e4ecf6d739900e5",
"38b29558511061cfabdc8e5bb65ac2976d1aa2ba9a5deab8074097b2172bb9ad",
"0de2cde610502b6e03c0b23602eafbcd3faf886c81d111d156b7aa550f5bcd51"},
{NID_X9_62_prime256v1, NID_sha224,
"b242a7586a1383368a33c88264889adfa3be45422fbef4a2df4e3c5325a9c7757017e0d5"
"cf4bbf4de7f99d189f81f1fd2f0dd645574d1eb0d547eead9375677819297c1abe62526a"
"e29fc54cdd11bfe17714f2fbd2d0d0e8d297ff98535980482dd5c1ebdc5a7274aabf1382"
"c9f2315ca61391e3943856e4c5e616c2f1f7be0d",
"a3a43cece9c1abeff81099fb344d01f7d8df66447b95a667ee368f924bccf870",
"045775174deb0248112e069cb86f1546ac7a78bc2127d0cb953bad46384dd6be5ba27020"
"952971cc0b0c3abd06e9ca3e141a4943f560564eba31e5288928bc7ce7",
"a0d9a7a245bd9b9aa86cecb89341c9de2e4f9b5d095a8150826c7ba7fb3e7df7",
"b02a440add66a9ff9c3c0e9acf1be678f6bd48a10cbdec2ad6d186ffe05f3f2a",
"a98bea42aec56a1fcecec00a1cc69b01fcbcf5de7ac1b2f2dcc09b6db064f92b"},
{NID_X9_62_prime256v1, NID_sha224,
"b64005da76b24715880af94dba379acc25a047b06066c9bedc8f17b8c74e74f4fc720d9f"
"4ef0e2a659e0756931c080587ebdcd0f85e819aea6dacb327a9d96496da53ea21aef3b2e"
"793a9c0def5196acec99891f46ead78a85bc7ab644765781d3543da9fbf9fec916dca975"
"ef3b4271e50ecc68bf79b2d8935e2b25fc063358",
"7bbc8ff13f6f921f21e949b224c16b7176c5984d312b671cf6c2e4841135fc7f",
"04f888e913ec6f3cd8b31eb89e4f8aaa8887d30ae5348ed7118696949d5b8cc7c108895d"
"09620500d244e5035e262dea3f2867cd8967b226324d5c05220d8b410c",
"21c942f3b487accbf7fadc1c4b7a6c7567ce876c195022459fa1ebf6d04ffbaa",
"2e6cc883b8acc904ee9691ef4a9f1f5a9e5fbfde847cda3be833f949fb9c7182",
"2ac48f7a930912131a8b4e3ab495307817c465d638c2a9ea5ae9e2808806e20a"},
{NID_X9_62_prime256v1, NID_sha224,
"fe6e1ea477640655eaa1f6e3352d4bce53eb3d95424df7f238e93d8531da8f36bc35fa6b"
"e4bf5a6a382e06e855139eb617a9cc9376b4dafacbd80876343b12628619d7cbe1bff675"
"7e3706111ed53898c0219823adbc044eaf8c6ad449df8f6aab9d444dadb5c3380eec0d91"
"694df5fc4b30280d4b87d27e67ae58a1df828963",
"daf5ec7a4eebc20d9485796c355b4a65ad254fe19b998d0507e91ea24135f45d",
"04137c465085c1b1b8cccbe9fccbe9d0295a331aaf332f3ed2e285d16e574b943bd3e8d5"
"a24cd218c19760b0e85b35a8569945aa857cbf0fd6a3ce127581b217b6",
"343251dffa56e6a612fec7b078f9c3819eab402a72686b894a47a08fd97e6c23",
"775e25a296bd259510ae9375f548997bec8a744900022945281dc8c4d94f2b5b",
"d87592ceab773ae103daebbb56a04144aaccb1e14efc1024dc36c0e382df1f70"},
{NID_X9_62_prime256v1, NID_sha224,
"907c0c00dc080a688548957b5b8b1f33ba378de1368023dcad43242411f554eb7d392d3e"
"5c1668fad3944ff9634105343d83b8c85d2a988da5f5dc60ee0518327caed6dd5cf4e9bc"
"6222deb46d00abde745f9b71d6e7aee6c7fdfc9ed053f2c0b611d4c6863088bd012ea981"
"0ee94f8e58905970ebd07353f1f409a371ed03e3",
"8729a8396f262dabd991aa404cc1753581cea405f0d19222a0b3f210de8ee3c5",
"0482b1f1a7af9b48ca8452613d7032beb0e4f28fe710306aeccc959e4d03662a355e39f3"
"3574097b8d32b471a591972496f5d44db344c037d13f06fafc75f016fd",
"6de9e21f0b2cacc1762b3558fd44d3cf156b85dbef430dd28d59713bfb9cfa0b",
"a754b42720e71925d51fcef76151405a3696cc8f9fc9ca7b46d0b16edd7fb699",
"603924780439cc16ac4cf97c2c3065bc95353aa9179d0ab5f0322ca82f851cf2"},
{NID_X9_62_prime256v1, NID_sha224,
"771c4d7bce05610a3e71b272096b57f0d1efcce33a1cb4f714d6ebc0865b2773ec5eedc2"
"5fae81dee1d256474dbd9676623614c150916e6ed92ce4430b26037d28fa5252ef6b10c0"
"9dc2f7ee5a36a1ea7897b69f389d9f5075e271d92f4eb97b148f3abcb1e5be0b4feb8278"
"613d18abf6da60bfe448238aa04d7f11b71f44c5",
"f1b62413935fc589ad2280f6892599ad994dae8ca3655ed4f7318cc89b61aa96",
"04e0bbfe4016eea93e6f509518cbffc25d492de6ebbf80465a461caa5bdc0181593231ee"
"7a119d84fa56e3034d50fea85929aec2eb437abc7646821e1bf805fb50",
"7a33eeb9f469afd55de2fb786847a1d3e7797929305c0f90d953b6f143bb8fc6",
"96d1c9399948254ea381631fc0f43ea808110506db8aacf081df5535ac5eb8ad",
"73bf3691260dddd9997c97313f2a70783eacf8d15bdfb34bb13025cdfae72f70"},
{NID_X9_62_prime256v1, NID_sha224,
"a3b2825235718fc679b942e8ac38fb4f54415a213c65875b5453d18ca012320ddfbbc58b"
"991eaebadfc2d1a28d4f0cd82652b12e4d5bfda89eda3be12ac52188e38e8cce32a264a3"
"00c0e463631f525ae501348594f980392c76b4a12ddc88e5ca086cb8685d03895919a862"
"7725a3e00c4728e2b7c6f6a14fc342b2937fc3dd",
"4caaa26f93f009682bbba6db6b265aec17b7ec1542bda458e8550b9e68eed18d",
"04e3c58c1c254d11c7e781ad133e4c36dd1b5de362120d336a58e7b68813f3fbee59760d"
"b66120afe0d962c81a8e5586588fd19de2f40556371611c73af22c8a68",
"c0d37142dc8b0d614fad20c4d35af6eb819e259e513ddeac1e1c273e7e1dc1bb",
"25dd8e4086c62a40d2a310e2f90f6af5cb7e677b4dfdb4dc4e99e23ea2f0e6dc",
"90ad62c179b0c9d61f521dde1cd762bfd224b5525c39c3706f2549313ddb4f39"},
{NID_X9_62_prime256v1, NID_sha224,
"3e6e2a9bffd729ee5d4807849cd4250021d8184cda723df6ab0e5c939d39237c8e58af9d"
"869fe62d3c97b3298a99e891e5e11aa68b11a087573a40a3e83c7965e7910d72f81cad0f"
"42accc5c25a4fd3cdd8cee63757bbbfbdae98be2bc867d3bcb1333c4632cb0a55dffeb77"
"d8b119c466cd889ec468454fabe6fbee7102deaf",
"7af4b150bb7167cb68037f280d0823ce5320c01a92b1b56ee1b88547481b1de9",
"04cb3634ec4f0cbb99986be788f889e586026d5a851e80d15382f1bdb1bda2bc7551e4e4"
"3bc16fb114896b18198a1aebe6054ba20ed0c0317c1b8776158c0e6bfb",
"98edd59fafbcaee5f64e84eb5ed59fff45d14aabada47cee2fa674377173627a",
"261a1cdb0fd93c0fb06ea6068b6b03c330a12f621a7eba76682a1d152c0e8d08",
"7ca049bad54feee101d6db807635ffb8bdb05a38e445c8c3d65d60df143514c5"},
{NID_X9_62_prime256v1, NID_sha224,
"52e5c308e70329a17c71eaedb66bbee303c8ec48a6f1a2efb235d308563cd58553d434e1"
"2f353227a9ea28608ec9c820ed83c95124e7a886f7e832a2de1032e78dc059208f9ec354"
"170b2b1cab992b52ac01e6c0e4e1b0112686962edc53ab226dafcc9fc7baed2cd9307160"
"e8572edb125935db49289b178f35a8ad23f4f801",
"52ad53e849e30bec0e6345c3e9d98ebc808b19496c1ef16d72ab4a00bbb8c634",
"047cca1334bfc2a78728c50b370399be3f9690d445aa03c701da643eeb0b0f7fa83f7522"
"238668e615405e49b2f63faee58286000a30cdb4b564ac0df99bc8950f",
"8650c30712fc253610884fbba4a332a4574d4b7822f7776cab1df8f5fa05442a",
"a18194c7ac5829afc408d78dde19542837e7be82706c3941b2d9c5e036bb51e0",
"188ead1cdf7c1d21114ff56d0421ffd501ab978ef58337462c0fa736d86299af"},
{NID_X9_62_prime256v1, NID_sha224,
"d3e9e82051d4c84d699453c9ff44c7c09f6523bb92232bcf30bf3c380224249de2964e87"
"1d56a364d6955c81ef91d06482a6c7c61bc70f66ef22fad128d15416e7174312619134f9"
"68f1009f92cbf99248932efb533ff113fb6d949e21d6b80dfbbe69010c8d1ccb0f3808ea"
"309bb0bac1a222168c95b088847e613749b19d04",
"80754962a864be1803bc441fa331e126005bfc6d8b09ed38b7e69d9a030a5d27",
"040aaeed6dd1ae020d6eefc98ec4241ac93cbd3c8afed05bb28007e7da5727571b2dda1d"
"5b7872eb94dfffb456115037ff8d3e72f8ebdd8fcfc42391f96809be69",
"738e050aeefe54ecba5be5f93a97bbcb7557d701f9da2d7e88483454b97b55a8",
"8cb9f41dfdcb9604e0725ac9b78fc0db916dc071186ee982f6dba3da36f02efa",
"5c87fe868fd4282fb114f5d70e9590a10a5d35cedf3ff6402ba5c4344738a32e"},
{NID_X9_62_prime256v1, NID_sha224,
"968951c2c1918436fe19fa2fe2152656a08f9a6b8aa6201920f1b424da98cee71928897f"
"f087620cc5c551320b1e75a1e98d7d98a5bd5361c9393759614a6087cc0f7fb01fcb1737"
"83eb4c4c23961a8231ac4a07d72e683b0c1bd4c51ef1b031df875e7b8d5a6e0628949f5b"
"8f157f43dccaea3b2a4fc11181e6b451e06ceb37",
"cfa8c8bd810eb0d73585f36280ecdd296ee098511be8ad5eac68984eca8eb19d",
"04c227a2af15dfa8734e11c0c50f77e24e77ed58dd8cccf1b0e9fa06bee1c64766b68659"
"2ce3745eb300d2704083db55e1fa8274e4cb7e256889ccc0bb34a60570",
"2d6b449bb38b543d6b6d34ff8cb053f5e5b337f949b069b21f421995ebb28823",
"5e89d3c9b103c2fa3cb8cebeec23640acda0257d63ffbe2d509bfc49fab1dca6",
"d70c5b1eeb29e016af9925798d24e166c23d58fedd2f1a3bbdb1ef78cdbfb63a"},
{NID_X9_62_prime256v1, NID_sha224,
"78048628932e1c1cdd1e70932bd7b76f704ba08d7e7d825d3de763bf1a062315f4af16ec"
"cefe0b6ebadccaf403d013f50833ce2c54e24eea8345e25f93b69bb048988d102240225c"
"eacf5003e2abdcc90299f4bf2c101585d36ecdd7a155953c674789d070480d1ef47cc785"
"8e97a6d87c41c6922a00ea12539f251826e141b4",
"b2021e2665ce543b7feadd0cd5a4bd57ffcc5b32deb860b4d736d9880855da3c",
"04722e0abad4504b7832a148746153777694714eca220eced2b2156ca64cfed3ddf0351b"
"357b3081e859c46cad5328c5afa10546e92bc6c3fd541796ac30397a75",
"b15bbce4b382145de7ecd670d947e77555ef7cd1693bd53c694e2b52b04d10e1",
"9d086dcd22da165a43091991bede9c1c14515e656633cb759ec2c17f51c35253",
"23595ad1cb714559faaecaf946beb9a71e584616030ceaed8a8470f4bf62768f"},
{NID_X9_62_prime256v1, NID_sha224,
"9b0800c443e693067591737fdbcf0966fdfa50872d41d0c189d87cbc34c2771ee5e1255f"
"d604f09fcf167fda16437c245d299147299c69046895d22482db29aba37ff57f756716cd"
"3d6223077f747c4caffbecc0a7c9dfaaafd9a9817470ded8777e6355838ac54d11b2f0fc"
"3f43668ff949cc31de0c2d15af5ef17884e4d66a",
"0c9bce6a568ca239395fc3552755575cbcdddb1d89f6f5ab354517a057b17b48",
"044814d454495df7103e2da383aba55f7842fd84f1750ee5801ad32c10d0be6c7da0bd03"
"9d5097c8f0770477f6b18d247876e88e528bf0453eab515ffab8a9eda3",
"d414f1525cdcc41eba1652de017c034ebcc7946cb2efe4713d09f67c85b83153",
"84db02c678f9a21208cec8564d145a35ba8c6f26b4eb7e19522e439720dae44c",
"537c564da0d2dc5ac4376c5f0ca3b628d01d48df47a83d842c927e4d6db1e16d"},
{NID_X9_62_prime256v1, NID_sha224,
"fc3b8291c172dae635a6859f525beaf01cf683765d7c86f1a4d768df7cae055f639eccc0"
"8d7a0272394d949f82d5e12d69c08e2483e11a1d28a4c61f18193106e12e5de4a9d0b4bf"
"341e2acd6b715dc83ae5ff63328f8346f35521ca378b311299947f63ec593a5e32e6bd11"
"ec4edb0e75302a9f54d21226d23314729e061016",
"1daa385ec7c7f8a09adfcaea42801a4de4c889fb5c6eb4e92bc611d596d68e3f",
"04f04e9f2831d9697ae146c7d4552e5f91085cc46778400b75b76f00205252941dbd2671"
"48174cd0c2b019cd0a5256e2f3f889d1e597160372b5a1339c8d787f10",
"7707db348ee6f60365b43a2a994e9b40ed56fe03c2c31c7e781bc4ffadcba760",
"5d95c385eeba0f15db0b80ae151912409128c9c80e554246067b8f6a36d85ea5",
"db5d8a1e345f883e4fcb3871276f170b783c1a1e9da6b6615913368a8526f1c3"},
{NID_X9_62_prime256v1, NID_sha256,
"5905238877c77421f73e43ee3da6f2d9e2ccad5fc942dcec0cbd25482935faaf416983fe"
"165b1a045ee2bcd2e6dca3bdf46c4310a7461f9a37960ca672d3feb5473e253605fb1ddf"
"d28065b53cb5858a8ad28175bf9bd386a5e471ea7a65c17cc934a9d791e91491eb3754d0"
"3799790fe2d308d16146d5c9b0d0debd97d79ce8",
"519b423d715f8b581f4fa8ee59f4771a5b44c8130b4e3eacca54a56dda72b464",
"041ccbe91c075fc7f4f033bfa248db8fccd3565de94bbfb12f3c59ff46c271bf83ce4014"
"c68811f9a21a1fdb2c0e6113e06db7ca93b7404e78dc7ccd5ca89a4ca9",
"94a1bbb14b906a61a280f245f9e93c7f3b4a6247824f5d33b9670787642a68de",
"f3ac8061b514795b8843e3d6629527ed2afd6b1f6a555a7acabb5e6f79c8c2ac",
"8bf77819ca05a6b2786c76262bf7371cef97b218e96f175a3ccdda2acc058903"},
{NID_X9_62_prime256v1, NID_sha256,
"c35e2f092553c55772926bdbe87c9796827d17024dbb9233a545366e2e5987dd344deb72"
"df987144b8c6c43bc41b654b94cc856e16b96d7a821c8ec039b503e3d86728c494a967d8"
"3011a0e090b5d54cd47f4e366c0912bc808fbb2ea96efac88fb3ebec9342738e225f7c7c"
"2b011ce375b56621a20642b4d36e060db4524af1",
"0f56db78ca460b055c500064824bed999a25aaf48ebb519ac201537b85479813",
"04e266ddfdc12668db30d4ca3e8f7749432c416044f2d2b8c10bf3d4012aeffa8abfa864"
"04a2e9ffe67d47c587ef7a97a7f456b863b4d02cfc6928973ab5b1cb39",
"6d3e71882c3b83b156bb14e0ab184aa9fb728068d3ae9fac421187ae0b2f34c6",
"976d3a4e9d23326dc0baa9fa560b7c4e53f42864f508483a6473b6a11079b2db",
"1b766e9ceb71ba6c01dcd46e0af462cd4cfa652ae5017d4555b8eeefe36e1932"},
{NID_X9_62_prime256v1, NID_sha256,
"3c054e333a94259c36af09ab5b4ff9beb3492f8d5b4282d16801daccb29f70fe61a0b37f"
"fef5c04cd1b70e85b1f549a1c4dc672985e50f43ea037efa9964f096b5f62f7ffdf8d6bf"
"b2cc859558f5a393cb949dbd48f269343b5263dcdb9c556eca074f2e98e6d94c2c29a677"
"afaf806edf79b15a3fcd46e7067b7669f83188ee",
"e283871239837e13b95f789e6e1af63bf61c918c992e62bca040d64cad1fc2ef",
"0474ccd8a62fba0e667c50929a53f78c21b8ff0c3c737b0b40b1750b2302b0bde829074e"
"21f3a0ef88b9efdf10d06aa4c295cc1671f758ca0e4cd108803d0f2614",
"ad5e887eb2b380b8d8280ad6e5ff8a60f4d26243e0124c2f31a297b5d0835de2",
"35fb60f5ca0f3ca08542fb3cc641c8263a2cab7a90ee6a5e1583fac2bb6f6bd1",
"ee59d81bc9db1055cc0ed97b159d8784af04e98511d0a9a407b99bb292572e96"},
{NID_X9_62_prime256v1, NID_sha256,
"0989122410d522af64ceb07da2c865219046b4c3d9d99b01278c07ff63eaf1039cb787ae"
"9e2dd46436cc0415f280c562bebb83a23e639e476a02ec8cff7ea06cd12c86dcc3adefbf"
"1a9e9a9b6646c7599ec631b0da9a60debeb9b3e19324977f3b4f36892c8a38671c8e1cc8"
"e50fcd50f9e51deaf98272f9266fc702e4e57c30",
"a3d2d3b7596f6592ce98b4bfe10d41837f10027a90d7bb75349490018cf72d07",
"04322f80371bf6e044bc49391d97c1714ab87f990b949bc178cb7c43b7c22d89e13c15d5"
"4a5cc6b9f09de8457e873eb3deb1fceb54b0b295da6050294fae7fd999",
"24fc90e1da13f17ef9fe84cc96b9471ed1aaac17e3a4bae33a115df4e5834f18",
"d7c562370af617b581c84a2468cc8bd50bb1cbf322de41b7887ce07c0e5884ca",
"b46d9f2d8c4bf83546ff178f1d78937c008d64e8ecc5cbb825cb21d94d670d89"},
{NID_X9_62_prime256v1, NID_sha256,
"dc66e39f9bbfd9865318531ffe9207f934fa615a5b285708a5e9c46b7775150e818d7f24"
"d2a123df3672fff2094e3fd3df6fbe259e3989dd5edfcccbe7d45e26a775a5c4329a084f"
"057c42c13f3248e3fd6f0c76678f890f513c32292dd306eaa84a59abe34b16cb5e38d0e8"
"85525d10336ca443e1682aa04a7af832b0eee4e7",
"53a0e8a8fe93db01e7ae94e1a9882a102ebd079b3a535827d583626c272d280d",
"041bcec4570e1ec2436596b8ded58f60c3b1ebc6a403bc5543040ba829630572448af62a"
"4c683f096b28558320737bf83b9959a46ad2521004ef74cf85e67494e1",
"5d833e8d24cc7a402d7ee7ec852a3587cddeb48358cea71b0bedb8fabe84e0c4",
"18caaf7b663507a8bcd992b836dec9dc5703c080af5e51dfa3a9a7c387182604",
"77c68928ac3b88d985fb43fb615fb7ff45c18ba5c81af796c613dfa98352d29c"},
{NID_X9_62_prime256v1, NID_sha256,
"600974e7d8c5508e2c1aab0783ad0d7c4494ab2b4da265c2fe496421c4df238b0be25f25"
"659157c8a225fb03953607f7df996acfd402f147e37aee2f1693e3bf1c35eab3ae360a2b"
"d91d04622ea47f83d863d2dfecb618e8b8bdc39e17d15d672eee03bb4ce2cc5cf6b217e5"
"faf3f336fdd87d972d3a8b8a593ba85955cc9d71",
"4af107e8e2194c830ffb712a65511bc9186a133007855b49ab4b3833aefc4a1d",
"04a32e50be3dae2c8ba3f5e4bdae14cf7645420d425ead94036c22dd6c4fc59e00d623bf"
"641160c289d6742c6257ae6ba574446dd1d0e74db3aaa80900b78d4ae9",
"e18f96f84dfa2fd3cdfaec9159d4c338cd54ad314134f0b31e20591fc238d0ab",
"8524c5024e2d9a73bde8c72d9129f57873bbad0ed05215a372a84fdbc78f2e68",
"d18c2caf3b1072f87064ec5e8953f51301cada03469c640244760328eb5a05cb"},
{NID_X9_62_prime256v1, NID_sha256,
"dfa6cb9b39adda6c74cc8b2a8b53a12c499ab9dee01b4123642b4f11af336a91a5c9ce05"
"20eb2395a6190ecbf6169c4cba81941de8e76c9c908eb843b98ce95e0da29c5d43880402"
"64e05e07030a577cc5d176387154eabae2af52a83e85c61c7c61da930c9b19e45d7e34c8"
"516dc3c238fddd6e450a77455d534c48a152010b",
"78dfaa09f1076850b3e206e477494cddcfb822aaa0128475053592c48ebaf4ab",
"048bcfe2a721ca6d753968f564ec4315be4857e28bef1908f61a366b1f03c974790f6757"
"6a30b8e20d4232d8530b52fb4c89cbc589ede291e499ddd15fe870ab96",
"295544dbb2da3da170741c9b2c6551d40af7ed4e891445f11a02b66a5c258a77",
"c5a186d72df452015480f7f338970bfe825087f05c0088d95305f87aacc9b254",
"84a58f9e9d9e735344b316b1aa1ab5185665b85147dc82d92e969d7bee31ca30"},
{NID_X9_62_prime256v1, NID_sha256,
"51d2547cbff92431174aa7fc7302139519d98071c755ff1c92e4694b58587ea560f72f32"
"fc6dd4dee7d22bb7387381d0256e2862d0644cdf2c277c5d740fa089830eb52bf79d1e75"
"b8596ecf0ea58a0b9df61e0c9754bfcd62efab6ea1bd216bf181c5593da79f10135a9bc6"
"e164f1854bc8859734341aad237ba29a81a3fc8b",
"80e692e3eb9fcd8c7d44e7de9f7a5952686407f90025a1d87e52c7096a62618a",
"04a88bc8430279c8c0400a77d751f26c0abc93e5de4ad9a4166357952fe041e7672d365a"
"1eef25ead579cc9a069b6abc1b16b81c35f18785ce26a10ba6d1381185",
"7c80fd66d62cc076cef2d030c17c0a69c99611549cb32c4ff662475adbe84b22",
"9d0c6afb6df3bced455b459cc21387e14929392664bb8741a3693a1795ca6902",
"d7f9ddd191f1f412869429209ee3814c75c72fa46a9cccf804a2f5cc0b7e739f"},
{NID_X9_62_prime256v1, NID_sha256,
"558c2ac13026402bad4a0a83ebc9468e50f7ffab06d6f981e5db1d082098065bcff6f21a"
"7a74558b1e8612914b8b5a0aa28ed5b574c36ac4ea5868432a62bb8ef0695d27c1e3ceaf"
"75c7b251c65ddb268696f07c16d2767973d85beb443f211e6445e7fe5d46f0dce70d58a4"
"cd9fe70688c035688ea8c6baec65a5fc7e2c93e8",
"5e666c0db0214c3b627a8e48541cc84a8b6fd15f300da4dff5d18aec6c55b881",
"041bc487570f040dc94196c9befe8ab2b6de77208b1f38bdaae28f9645c4d2bc3aec8160"
"2abd8345e71867c8210313737865b8aa186851e1b48eaca140320f5d8f",
"2e7625a48874d86c9e467f890aaa7cd6ebdf71c0102bfdcfa24565d6af3fdce9",
"2f9e2b4e9f747c657f705bffd124ee178bbc5391c86d056717b140c153570fd9",
"f5413bfd85949da8d83de83ab0d19b2986613e224d1901d76919de23ccd03199"},
{NID_X9_62_prime256v1, NID_sha256,
"4d55c99ef6bd54621662c3d110c3cb627c03d6311393b264ab97b90a4b15214a5593ba25"
"10a53d63fb34be251facb697c973e11b665cb7920f1684b0031b4dd370cb927ca7168b0b"
"f8ad285e05e9e31e34bc24024739fdc10b78586f29eff94412034e3b606ed850ec2c1900"
"e8e68151fc4aee5adebb066eb6da4eaa5681378e",
"f73f455271c877c4d5334627e37c278f68d143014b0a05aa62f308b2101c5308",
"04b8188bd68701fc396dab53125d4d28ea33a91daf6d21485f4770f6ea8c565dde423f05"
"8810f277f8fe076f6db56e9285a1bf2c2a1dae145095edd9c04970bc4a",
"62f8665fd6e26b3fa069e85281777a9b1f0dfd2c0b9f54a086d0c109ff9fd615",
"1cc628533d0004b2b20e7f4baad0b8bb5e0673db159bbccf92491aef61fc9620",
"880e0bbf82a8cf818ed46ba03cf0fc6c898e36fca36cc7fdb1d2db7503634430"},
{NID_X9_62_prime256v1, NID_sha256,
"f8248ad47d97c18c984f1f5c10950dc1404713c56b6ea397e01e6dd925e903b4fadfe2c9"
"e877169e71ce3c7fe5ce70ee4255d9cdc26f6943bf48687874de64f6cf30a012512e787b"
"88059bbf561162bdcc23a3742c835ac144cc14167b1bd6727e940540a9c99f3cbb41fb1d"
"cb00d76dda04995847c657f4c19d303eb09eb48a",
"b20d705d9bd7c2b8dc60393a5357f632990e599a0975573ac67fd89b49187906",
"0451f99d2d52d4a6e734484a018b7ca2f895c2929b6754a3a03224d07ae61166ce4737da"
"963c6ef7247fb88d19f9b0c667cac7fe12837fdab88c66f10d3c14cad1",
"72b656f6b35b9ccbc712c9f1f3b1a14cbbebaec41c4bca8da18f492a062d6f6f",
"9886ae46c1415c3bc959e82b760ad760aab66885a84e620aa339fdf102465c42",
"2bf3a80bc04faa35ebecc0f4864ac02d349f6f126e0f988501b8d3075409a26c"},
{NID_X9_62_prime256v1, NID_sha256,
"3b6ee2425940b3d240d35b97b6dcd61ed3423d8e71a0ada35d47b322d17b35ea0472f35e"
"dd1d252f87b8b65ef4b716669fc9ac28b00d34a9d66ad118c9d94e7f46d0b4f6c2b2d339"
"fd6bcd351241a387cc82609057048c12c4ec3d85c661975c45b300cb96930d89370a327c"
"98b67defaa89497aa8ef994c77f1130f752f94a4",
"d4234bebfbc821050341a37e1240efe5e33763cbbb2ef76a1c79e24724e5a5e7",
"048fb287f0202ad57ae841aea35f29b2e1d53e196d0ddd9aec24813d64c0922fb71f6daf"
"f1aa2dd2d6d3741623eecb5e7b612997a1039aab2e5cf2de969cfea573",
"d926fe10f1bfd9855610f4f5a3d666b1a149344057e35537373372ead8b1a778",
"490efd106be11fc365c7467eb89b8d39e15d65175356775deab211163c2504cb",
"644300fc0da4d40fb8c6ead510d14f0bd4e1321a469e9c0a581464c7186b7aa7"},
{NID_X9_62_prime256v1, NID_sha256,
"c5204b81ec0a4df5b7e9fda3dc245f98082ae7f4efe81998dcaa286bd4507ca840a53d21"
"b01e904f55e38f78c3757d5a5a4a44b1d5d4e480be3afb5b394a5d2840af42b1b4083d40"
"afbfe22d702f370d32dbfd392e128ea4724d66a3701da41ae2f03bb4d91bb946c7969404"
"cb544f71eb7a49eb4c4ec55799bda1eb545143a7",
"b58f5211dff440626bb56d0ad483193d606cf21f36d9830543327292f4d25d8c",
"0468229b48c2fe19d3db034e4c15077eb7471a66031f28a980821873915298ba76303e8e"
"e3742a893f78b810991da697083dd8f11128c47651c27a56740a80c24c",
"e158bf4a2d19a99149d9cdb879294ccb7aaeae03d75ddd616ef8ae51a6dc1071",
"e67a9717ccf96841489d6541f4f6adb12d17b59a6bef847b6183b8fcf16a32eb",
"9ae6ba6d637706849a6a9fc388cf0232d85c26ea0d1fe7437adb48de58364333"},
{NID_X9_62_prime256v1, NID_sha256,
"72e81fe221fb402148d8b7ab03549f1180bcc03d41ca59d7653801f0ba853add1f6d29ed"
"d7f9abc621b2d548f8dbf8979bd16608d2d8fc3260b4ebc0dd42482481d548c7075711b5"
"759649c41f439fad69954956c9326841ea6492956829f9e0dc789f73633b40f6ac77bcae"
"6dfc7930cfe89e526d1684365c5b0be2437fdb01",
"54c066711cdb061eda07e5275f7e95a9962c6764b84f6f1f3ab5a588e0a2afb1",
"040a7dbb8bf50cb605eb2268b081f26d6b08e012f952c4b70a5a1e6e7d46af98bbf26dd7"
"d799930062480849962ccf5004edcfd307c044f4e8f667c9baa834eeae",
"646fe933e96c3b8f9f507498e907fdd201f08478d0202c752a7c2cfebf4d061a",
"b53ce4da1aa7c0dc77a1896ab716b921499aed78df725b1504aba1597ba0c64b",
"d7c246dc7ad0e67700c373edcfdd1c0a0495fc954549ad579df6ed1438840851"},
{NID_X9_62_prime256v1, NID_sha256,
"21188c3edd5de088dacc1076b9e1bcecd79de1003c2414c3866173054dc82dde85169baa"
"77993adb20c269f60a5226111828578bcc7c29e6e8d2dae81806152c8ba0c6ada1986a19"
"83ebeec1473a73a04795b6319d48662d40881c1723a706f516fe75300f92408aa1dc6ae4"
"288d2046f23c1aa2e54b7fb6448a0da922bd7f34",
"34fa4682bf6cb5b16783adcd18f0e6879b92185f76d7c920409f904f522db4b1",
"04105d22d9c626520faca13e7ced382dcbe93498315f00cc0ac39c4821d0d737376c47f3"
"cbbfa97dfcebe16270b8c7d5d3a5900b888c42520d751e8faf3b401ef4",
"a6f463ee72c9492bc792fe98163112837aebd07bab7a84aaed05be64db3086f4",
"542c40a18140a6266d6f0286e24e9a7bad7650e72ef0e2131e629c076d962663",
"4f7f65305e24a6bbb5cff714ba8f5a2cee5bdc89ba8d75dcbf21966ce38eb66f"},
{NID_X9_62_prime256v1, NID_sha384,
"e0b8596b375f3306bbc6e77a0b42f7469d7e83635990e74aa6d713594a3a24498feff500"
"6790742d9c2e9b47d714bee932435db747c6e733e3d8de41f2f91311f2e9fd8e02565163"
"1ffd84f66732d3473fbd1627e63dc7194048ebec93c95c159b5039ab5e79e42c80b484a9"
"43f125de3da1e04e5bf9c16671ad55a1117d3306",
"b6faf2c8922235c589c27368a3b3e6e2f42eb6073bf9507f19eed0746c79dced",
"04e0e7b99bc62d8dd67883e39ed9fa0657789c5ff556cc1fd8dd1e2a55e9e3f24363fbfd"
"0232b95578075c903a4dbf85ad58f8350516e1ec89b0ee1f5e1362da69",
"9980b9cdfcef3ab8e219b9827ed6afdd4dbf20bd927e9cd01f15762703487007",
"f5087878e212b703578f5c66f434883f3ef414dc23e2e8d8ab6a8d159ed5ad83",
"306b4c6c20213707982dffbb30fba99b96e792163dd59dbe606e734328dd7c8a"},
{NID_X9_62_prime256v1, NID_sha384,
"099a0131179fff4c6928e49886d2fdb3a9f239b7dd5fa828a52cbbe3fcfabecfbba3e192"
"159b887b5d13aa1e14e6a07ccbb21f6ad8b7e88fee6bea9b86dea40ffb962f38554056fb"
"7c5bb486418915f7e7e9b9033fe3baaf9a069db98bc02fa8af3d3d1859a11375d6f98aa2"
"ce632606d0800dff7f55b40f971a8586ed6b39e9",
"118958fd0ff0f0b0ed11d3cf8fa664bc17cdb5fed1f4a8fc52d0b1ae30412181",
"04afda82260c9f42122a3f11c6058839488f6d7977f6f2a263c67d06e27ea2c3550ae2bb"
"dd2207c590332c5bfeb4c8b5b16622134bd4dc55382ae806435468058b",
"23129a99eeda3d99a44a5778a46e8e7568b91c31fb7a8628c5d9820d4bed4a6b",
"e446600cab1286ebc3bb332012a2f5cc33b0a5ef7291d5a62a84de5969d77946",
"cf89b12793ee1792eb26283b48fa0bdcb45ae6f6ad4b02564bf786bb97057d5a"},
{NID_X9_62_prime256v1, NID_sha384,
"0fbc07ea947c946bea26afa10c51511039b94ddbc4e2e4184ca3559260da24a14522d149"
"7ca5e77a5d1a8e86583aeea1f5d4ff9b04a6aa0de79cd88fdb85e01f171143535f2f7c23"
"b050289d7e05cebccdd131888572534bae0061bdcc3015206b9270b0d5af9f1da2f9de91"
"772d178a632c3261a1e7b3fb255608b3801962f9",
"3e647357cd5b754fad0fdb876eaf9b1abd7b60536f383c81ce5745ec80826431",
"04702b2c94d039e590dd5c8f9736e753cf5824aacf33ee3de74fe1f5f7c858d5ed0c2889"
"4e907af99fb0d18c9e98f19ac80dd77abfa4bebe45055c0857b82a0f4d",
"9beab7722f0bcb468e5f234e074170a60225255de494108459abdf603c6e8b35",
"c4021fb7185a07096547af1fb06932e37cf8bd90cf593dea48d48614fa237e5e",
"7fb45d09e2172bec8d3e330aa06c43fbb5f625525485234e7714b7f6e92ba8f1"},
{NID_X9_62_prime256v1, NID_sha384,
"1e38d750d936d8522e9db1873fb4996bef97f8da3c6674a1223d29263f1234a90b751785"
"316444e9ba698bc8ab6cd010638d182c9adad4e334b2bd7529f0ae8e9a52ad60f59804b2"
"d780ed52bdd33b0bf5400147c28b4304e5e3434505ae7ce30d4b239e7e6f0ecf058badd5"
"b388eddbad64d24d2430dd04b4ddee98f972988f",
"76c17c2efc99891f3697ba4d71850e5816a1b65562cc39a13da4b6da9051b0fd",
"04d12512e934c367e4c4384dbd010e93416840288a0ba00b299b4e7c0d91578b57ebf883"
"5661d9b578f18d14ae4acf9c357c0dc8b7112fc32824a685ed72754e23",
"77cffa6f9a73904306f9fcd3f6bbb37f52d71e39931bb4aec28f9b076e436ccf",
"4d5a9d95b0f09ce8704b0f457b39059ee606092310df65d3f8ae7a2a424cf232",
"7d3c014ca470a73cef1d1da86f2a541148ad542fbccaf9149d1b0b030441a7eb"},
{NID_X9_62_prime256v1, NID_sha384,
"abcf0e0f046b2e0672d1cc6c0a114905627cbbdefdf9752f0c31660aa95f2d0ede72d179"
"19a9e9b1add3213164e0c9b5ae3c76f1a2f79d3eeb444e6741521019d8bd5ca391b28c10"
"63347f07afcfbb705be4b52261c19ebaf1d6f054a74d86fb5d091fa7f229450996b76f0a"
"da5f977b09b58488eebfb5f5e9539a8fd89662ab",
"67b9dea6a575b5103999efffce29cca688c781782a41129fdecbce76608174de",
"04b4238b029fc0b7d9a5286d8c29b6f3d5a569e9108d44d889cd795c4a385905be8cb3ff"
"f8f6cca7187c6a9ad0a2b1d9f40ae01b32a7e8f8c4ca75d71a1fffb309",
"d02617f26ede3584f0afcfc89554cdfb2ae188c192092fdde3436335fafe43f1",
"26fd9147d0c86440689ff2d75569795650140506970791c90ace0924b44f1586",
"00a34b00c20a8099df4b0a757cbef8fea1cb3ea7ced5fbf7e987f70b25ee6d4f"},
{NID_X9_62_prime256v1, NID_sha384,
"dc3d4884c741a4a687593c79fb4e35c5c13c781dca16db561d7e393577f7b62ca41a6e25"
"9fc1fb8d0c4e1e062517a0fdf95558b7799f20c211796167953e6372c11829beec64869d"
"67bf3ee1f1455dd87acfbdbcc597056e7fb347a17688ad32fda7ccc3572da7677d7255c2"
"61738f07763cd45973c728c6e9adbeecadc3d961",
"ecf644ea9b6c3a04fdfe2de4fdcb55fdcdfcf738c0b3176575fa91515194b566",
"04c3bdc7c795ec94620a2cfff614c13a3390a5e86c892e53a24d3ed22228bc85bf70480f"
"c5cf4aacd73e24618b61b5c56c1ced8c4f1b869580ea538e68c7a61ca3",
"53291d51f68d9a12d1dcdc58892b2f786cc15f631f16997d2a49bace513557d4",
"a860c8b286edf973ce4ce4cf6e70dc9bbf3818c36c023a845677a9963705df8b",
"5630f986b1c45e36e127dd7932221c4272a8cc6e255e89f0f0ca4ec3a9f76494"},
{NID_X9_62_prime256v1, NID_sha384,
"719bf1911ae5b5e08f1d97b92a5089c0ab9d6f1c175ac7199086aeeaa416a17e6d6f8486"
"c711d386f284f096296689a54d330c8efb0f5fa1c5ba128d3234a3da856c2a94667ef710"
"3616a64c913135f4e1dc50e38daa60610f732ad1bedfcc396f87169392520314a6b6b9af"
"6793dbabad4599525228cc7c9c32c4d8e097ddf6",
"4961485cbc978f8456ec5ac7cfc9f7d9298f99415ecae69c8491b258c029bfee",
"048d40bf2299e05d758d421972e81cfb0cce68b949240dc30f315836acc70bef035674e6"
"f77f8b46f46cca937d83b128dffbe9bd7e0d3d08aa2cbbfdfb16f72c9a",
"373a825b5a74b7b9e02f8d4d876b577b4c3984168d704ba9f95b19c05ed590af",
"ef6fb386ad044b63feb7445fa16b10319018e9cea9ef42bca83bdad01992234a",
"ac1f42f652eb1786e57be01d847c81f7efa072ba566d4583af4f1551a3f76c65"},
{NID_X9_62_prime256v1, NID_sha384,
"7cf19f4c851e97c5bca11a39f0074c3b7bd3274e7dd75d0447b7b84995dfc9f716bf08c2"
"5347f56fcc5e5149cb3f9cfb39d408ace5a5c47e75f7a827fa0bb9921bb5b23a6053dbe1"
"fa2bba341ac874d9b1333fc4dc224854949f5c8d8a5fedd02fb26fdfcd3be351aec0fcbe"
"f18972956c6ec0effaf057eb4420b6d28e0c008c",
"587907e7f215cf0d2cb2c9e6963d45b6e535ed426c828a6ea2fb637cca4c5cbd",
"04660da45c413cc9c9526202c16b402af602d30daaa7c342f1e722f15199407f31e6f8cb"
"b06913cc718f2d69ba2fb3137f04a41c27c676d1a80fbf30ea3ca46439",
"6b8eb7c0d8af9456b95dd70561a0e902863e6dfa1c28d0fd4a0509f1c2a647b2",
"08fabf9b57de81875bfa7a4118e3e44cfb38ec6a9b2014940207ba3b1c583038",
"a58d199b1deba7350616230d867b2747a3459421811c291836abee715b8f67b4"},
{NID_X9_62_prime256v1, NID_sha384,
"b892ffabb809e98a99b0a79895445fc734fa1b6159f9cddb6d21e510708bdab6076633ac"
"30aaef43db566c0d21f4381db46711fe3812c5ce0fb4a40e3d5d8ab24e4e82d3560c6dc7"
"c37794ee17d4a144065ef99c8d1c88bc22ad8c4c27d85ad518fa5747ae35276fc104829d"
"3f5c72fc2a9ea55a1c3a87007cd133263f79e405",
"24b1e5676d1a9d6b645a984141a157c124531feeb92d915110aef474b1e27666",
"04b4909a5bdf25f7659f4ef35e4b811429fb2c59126e3dad09100b46aea6ebe7a6760ae0"
"15fa6af5c9749c4030fdb5de6e58c6b5b1944829105cf7edf7d3a22cfb",
"88794923d8943b5dbcc7a7a76503880ff7da632b0883aaa60a9fcc71bf880fd6",
"6ec9a340b77fae3c7827fa96d997e92722ff2a928217b6dd3c628f3d49ae4ce6",
"637b54bbcfb7e7d8a41ea317fcfca8ad74eb3bb6b778bc7ef9dec009281976f7"},
{NID_X9_62_prime256v1, NID_sha384,
"8144e37014c95e13231cbd6fa64772771f93b44e37f7b02f592099cc146343edd4f4ec9f"
"a1bc68d7f2e9ee78fc370443aa2803ff4ca52ee49a2f4daf2c8181ea7b8475b3a0f608fc"
"3279d09e2d057fbe3f2ffbe5133796124781299c6da60cfe7ecea3abc30706ded2cdf18f"
"9d788e59f2c31662df3abe01a9b12304fb8d5c8c",
"bce49c7b03dcdc72393b0a67cf5aa5df870f5aaa6137ada1edc7862e0981ec67",
"04c786d9421d67b72b922cf3def2a25eeb5e73f34543eb50b152e738a98afb0ca5679627"
"1e79e2496f9e74b126b1123a3d067de56b5605d6f51c8f6e1d5bb93aba",
"89e690d78a5e0d2b8ce9f7fcbf34e2605fd9584760fa7729043397612dd21f94",
"07e5054c384839584624e8d730454dc27e673c4a90cbf129d88b91250341854d",
"f7e665b88614d0c5cbb3007cafe713763d81831525971f1747d92e4d1ca263a7"},
{NID_X9_62_prime256v1, NID_sha384,
"a3683d120807f0a030feed679785326698c3702f1983eaba1b70ddfa7f0b3188060b845e"
"2b67ed57ee68087746710450f7427cb34655d719c0acbc09ac696adb4b22aba1b9322b71"
"11076e67053a55f62b501a4bca0ad9d50a868f51aeeb4ef27823236f5267e8da83e14304"
"7422ce140d66e05e44dc84fb3a4506b2a5d7caa8",
"73188a923bc0b289e81c3db48d826917910f1b957700f8925425c1fb27cabab9",
"0486662c014ab666ee770723be8da38c5cd299efc6480fc6f8c3603438fa8397b9f26b33"
"07a650c3863faaa5f642f3ba1384c3d3a02edd3d48c657c269609cc3fc",
"ec90584ab3b383b590626f36ed4f5110e49888aec7ae7a9c5ea62dd2dc378666",
"13e9ad59112fde3af4163eb5c2400b5e9a602576d5869ac1c569075f08c90ff6",
"708ac65ff2b0baaccc6dd954e2a93df46016bd04457636de06798fcc17f02be5"},
{NID_X9_62_prime256v1, NID_sha384,
"b1df8051b213fc5f636537e37e212eb20b2423e6467a9c7081336a870e6373fc835899d5"
"9e546c0ac668cc81ce4921e88f42e6da2a109a03b4f4e819a17c955b8d099ec6b282fb49"
"5258dca13ec779c459da909475519a3477223c06b99afbd77f9922e7cbef844b93f3ce5f"
"50db816b2e0d8b1575d2e17a6b8db9111d6da578",
"f637d55763fe819541588e0c603f288a693cc66823c6bb7b8e003bd38580ebce",
"0474a4620c578601475fc169a9b84be613b4a16cb6acab8fd98848a6ec9fbd133d42b9e3"
"5d347c107e63bd55f525f915bcf1e3d2b81d002d3c39acf10fc30645a1",
"4d578f5099636234d9c1d566f1215d5d887ae5d47022be17dbf32a11a03f053b",
"113a933ebc4d94ce1cef781e4829df0c493b0685d39fb2048ce01b21c398dbba",
"3005bd4ec63dbd04ce9ff0c6246ad65d27fcf62edb2b7e461589f9f0e7446ffd"},
{NID_X9_62_prime256v1, NID_sha384,
"0b918ede985b5c491797d0a81446b2933be312f419b212e3aae9ba5914c00af431747a9d"
"287a7c7761e9bcbc8a12aaf9d4a76d13dad59fc742f8f218ef66eb67035220a07acc1a35"
"7c5b562ecb6b895cf725c4230412fefac72097f2c2b829ed58742d7c327cad0f1058df1b"
"ddd4ae9c6d2aba25480424308684cecd6517cdd8",
"2e357d51517ff93b821f895932fddded8347f32596b812308e6f1baf7dd8a47f",
"047e4078a1d50c669fb2996dd9bacb0c3ac7ede4f58fa0fa1222e78dbf5d1f41860014e4"
"6e90cc171fbb83ea34c6b78202ea8137a7d926f0169147ed5ae3d6596f",
"be522b0940b9a40d84bf790fe6abdc252877e671f2efa63a33a65a512fc2aa5c",
"a26b9ad775ac37ff4c7f042cdc4872c5e4e5e800485f488ddfaaed379f468090",
"f88eae2019bebbba62b453b8ee3472ca5c67c267964cffe0cf2d2933c1723dff"},
{NID_X9_62_prime256v1, NID_sha384,
"0fab26fde1a4467ca930dbe513ccc3452b70313cccde2994eead2fde85c8da1db84d7d06"
"a024c9e88629d5344224a4eae01b21a2665d5f7f36d5524bf5367d7f8b6a71ea05d413d4"
"afde33777f0a3be49c9e6aa29ea447746a9e77ce27232a550b31dd4e7c9bc8913485f2dc"
"83a56298051c92461fd46b14cc895c300a4fb874",
"77d60cacbbac86ab89009403c97289b5900466856887d3e6112af427f7f0f50b",
"04a62032dfdb87e25ed0c70cad20d927c7effeb2638e6c88ddd670f74df16090e544c5ee"
"2cf740ded468f5d2efe13daa7c5234645a37c073af35330d03a4fed976",
"06c1e692b045f425a21347ecf72833d0242906c7c1094f805566cdcb1256e394",
"eb173b51fb0aec318950d097e7fda5c34e529519631c3e2c9b4550b903da417d",
"ca2c13574bf1b7d56e9dc18315036a31b8bceddf3e2c2902dcb40f0cc9e31b45"},
{NID_X9_62_prime256v1, NID_sha384,
"7843f157ef8566722a7d69da67de7599ee65cb3975508f70c612b3289190e364141781e0"
"b832f2d9627122742f4b5871ceeafcd09ba5ec90cae6bcc01ae32b50f13f63918dfb5177"
"df9797c6273b92d103c3f7a3fc2050d2b196cc872c57b77f9bdb1782d4195445fcc6236d"
"d8bd14c8bcbc8223a6739f6a17c9a861e8c821a6",
"486854e77962117f49e09378de6c9e3b3522fa752b10b2c810bf48db584d7388",
"04760b5624bd64d19c866e54ccd74ad7f98851afdbc3ddeae3ec2c52a135be9cfafeca15"
"ce9350877102eee0f5af18b2fed89dc86b7df0bf7bc2963c1638e36fe8",
"e4f77c6442eca239b01b0254e11a4182782d96f48ab521cc3d1d68df12b5a41a",
"bdff14e4600309c2c77f79a25963a955b5b500a7b2d34cb172cd6acd52905c7b",
"b0479cdb3df79923ec36a104a129534c5d59f622be7d613aa04530ad2507d3a2"},
{NID_X9_62_prime256v1, NID_sha512,
"6c8572b6a3a4a9e8e03dbeed99334d41661b8a8417074f335ab1845f6cc852adb8c01d98"
"20fcf8e10699cc827a8fbdca2cbd46cc66e4e6b7ba41ec3efa733587e4a30ec552cd8dda"
"b8163e148e50f4d090782897f3ddac84a41e1fcfe8c56b6152c0097b0d634b41011471ff"
"d004f43eb4aafc038197ec6bae2b4470e869bded",
"9dd0d3a3d514c2a8adb162b81e3adfba3299309f7d2018f607bdb15b1a25f499",
"046b738de3398b6ac57b9591f9d7985dd4f32137ad3460dcf8970c1390cb9eaf8d83bc61"
"e26d2bbbd3cf2d2ab445a2bc4ab5dde41f4a13078fd1d3cc36ab596d57",
"9106192170ccb3c64684d48287bb81bbed51b40d503462c900e5c7aae43e380a",
"275fa760878b4dc05e9d157fedfd8e9b1c9c861222a712748cb4b7754c043fb1",
"699d906bb8435a05345af3b37e3b357786939e94caae257852f0503adb1e0f7e"},
{NID_X9_62_prime256v1, NID_sha512,
"7e3c8fe162d48cc8c5b11b5e5ebc05ebc45c439bdbc0b0902145921b8383037cb0812222"
"031598cd1a56fa71694fbd304cc62938233465ec39c6e49f57dfe823983b6923c4e86563"
"3949183e6b90e9e06d8275f3907d97967d47b6239fe2847b7d49cf16ba69d2862083cf1b"
"ccf7afe34fdc90e21998964107b64abe6b89d126",
"f9bf909b7973bf0e3dad0e43dcb2d7fa8bda49dbe6e5357f8f0e2bd119be30e6",
"04f2a6674d4e86152a527199bed293fa63acde1b4d8a92b62e552210ba45c38792c72565"
"c24f0eee6a094af341ddd8579747b865f91c8ed5b44cda8a19cc93776f",
"e547791f7185850f03d0c58419648f65b9d29cdc22ed1de2a64280220cfcafba",
"4782903d2aaf8b190dab5cae2223388d2d8bd845b3875d37485c54e1ded1d3d8",
"dfb40e406bfa074f0bf832771b2b9f186e2211f0bca279644a0ca8559acf39da"},
{NID_X9_62_prime256v1, NID_sha512,
"d5aa8ac9218ca661cd177756af6fbb5a40a3fecfd4eea6d5872fbb9a2884784aa9b5f0c0"
"23a6e0da5cf6364754ee6465b4ee2d0ddc745b02994c98427a213c849537da5a4477b3ab"
"fe02648be67f26e80b56a33150490d062aaac137aa47f11cfeddba855bab9e4e028532a5"
"63326d927f9e6e3292b1fb248ee90b6f429798db",
"724567d21ef682dfc6dc4d46853880cfa86fe6fea0efd51fac456f03c3d36ead",
"0470b877b5e365fcf08140b1eca119baba662879f38e059d074a2cb60b03ea5d395f56f9"
"4d591df40b9f3b8763ac4b3dbe622c956d5bd0c55658b6f46fa3deb201",
"79d6c967ed23c763ece9ca4b026218004c84dc2d4ccc86cf05c5d0f791f6279b",
"2ba2ea2d316f8937f184ad3028e364574d20a202e4e7513d7af57ac2456804d1",
"64fe94968d18c5967c799e0349041b9e40e6c6c92ebb475e80dd82f51cf07320"},
{NID_X9_62_prime256v1, NID_sha512,
"790b06054afc9c3fc4dfe72df19dd5d68d108cfcfca6212804f6d534fd2fbe489bd8f64b"
"f205ce04bcb50124a12ce5238fc3fe7dd76e6fa640206af52549f133d593a1bfd423ab73"
"7f3326fa79433cde293236f90d4238f0dd38ed69492ddbd9c3eae583b6325a95dec3166f"
"e52b21658293d8c137830ef45297d67813b7a508",
"29c5d54d7d1f099d50f949bfce8d6073dae059c5a19cc70834722f18a7199edd",
"043088d4f45d274cc5f418c8ecc4cbcf96be87491f420250f8cbc01cdf2503ec47634db4"
"8198129237ed068c88ff5809f6211921a6258f548f4b64dd125921b78b",
"0508ad7774908b5705895fda5c3b7a3032bf85dab7232bf981177019f3d76460",
"acd9f3b63626c5f32103e90e1dd1695907b1904aa9b14f2132caef331321971b",
"15c04a8bd6c13ed5e9961814b2f406f064670153e4d5465dcef63c1d9dd52a87"},
{NID_X9_62_prime256v1, NID_sha512,
"6d549aa87afdb8bfa60d22a68e2783b27e8db46041e4df04be0c261c4734b608a96f198d"
"1cdb8d082ae48579ec9defcf21fbc72803764a58c31e5323d5452b9fb57c8991d3174914"
"0da7ef067b18bf0d7dfbae6eefd0d8064f334bf7e9ec1e028daed4e86e17635ec2e409a3"
"ed1238048a45882c5c57501b314e636b9bc81cbe",
"0d8095da1abba06b0d349c226511f642dabbf1043ad41baa4e14297afe8a3117",
"0475a45758ced45ecf55f755cb56ca2601d794ebeaeb2e6107fe2fc443f580e23c5303d4"
"7d5a75ec821d51a2ee7548448208c699eca0cd89810ffc1aa4faf81ead",
"5165c54def4026ab648f7768c4f1488bcb183f6db7ffe02c7022a529a116482a",
"ebc85fc4176b446b3384ccc62fc2526b45665561a0e7e9404ac376c90e450b59",
"8b2c09428e62c5109d17ed0cf8f9fd7c370d018a2a73f701effc9b17d04852c6"},
{NID_X9_62_prime256v1, NID_sha512,
"1906e48b7f889ee3ff7ab0807a7aa88f53f4018808870bfed6372a77330c737647961324"
"c2b4d46f6ee8b01190474951a701b048ae86579ff8e3fc889fecf926b17f98958ac7534e"
"6e781ca2db2baa380dec766cfb2a3eca2a9d5818967d64dfab84f768d24ec122eebacaab"
"0a4dc3a75f37331bb1c43dd8966cc09ec4945bbd",
"52fe57da3427b1a75cb816f61c4e8e0e0551b94c01382b1a80837940ed579e61",
"042177e20a2092a46667debdcc21e7e45d6da72f124adecbc5ada6a7bcc7b401d5550e46"
"8f2626070a080afeeb98edd75a721eb773c8e62149f3e903cf9c4d7b61",
"0464fe9674b01ff5bd8be21af3399fad66f90ad30f4e8ee6e2eb9bcccfd5185c",
"f8250f073f34034c1cde58f69a85e2f5a030703ebdd4dbfb98d3b3690db7d114",
"a9e83e05f1d6e0fef782f186bedf43684c825ac480174d48b0e4d31505e27498"},
{NID_X9_62_prime256v1, NID_sha512,
"7b59fef13daf01afec35dea3276541be681c4916767f34d4e874464d20979863ee77ad0f"
"d1635bcdf93e9f62ed69ae52ec90aab5bbf87f8951213747ccec9f38c775c1df1e9d7f73"
"5c2ce39b42edb3b0c5086247556cfea539995c5d9689765288ec600848ecf085c01ca738"
"bbef11f5d12d4457db988b4add90be00781024ad",
"003d91611445919f59bfe3ca71fe0bfdeb0e39a7195e83ac03a37c7eceef0df2",
"047b9c592f61aae0555855d0b9ebb6fd00fb6746e8842e2523565c858630b9ba00d35b2e"
"168b1875bbc563bea5e8d63c4e38957c774a65e762959a349eaf263ba0",
"ef9df291ea27a4b45708f7608723c27d7d56b7df0599a54bc2c2fabbff373b40",
"66d057fd39958b0e4932bacd70a1769bbadcb62e4470937b45497a3d4500fabb",
"6c853b889e18b5a49ee54b54dd1aaedfdd642e30eba171c5cab677f0df9e7318"},
{NID_X9_62_prime256v1, NID_sha512,
"041a6767a935dc3d8985eb4e608b0cbfebe7f93789d4200bcfe595277ac2b0f402889b58"
"0b72def5da778a680fd380c955421f626d52dd9a83ea180187b850e1b72a4ec6dd63235e"
"598fd15a9b19f8ce9aec1d23f0bd6ea4d92360d50f951152bc9a01354732ba0cf90aaed3"
"3c307c1de8fa3d14f9489151b8377b57c7215f0b",
"48f13d393899cd835c4193670ec62f28e4c4903e0bbe5817bf0996831a720bb7",
"0482a1a96f4648393c5e42633ecdeb1d8245c78c5ea236b5bab460dedcc8924bc0e8cbf0"
"3c34b5154f876de19f3bb6fd43cd2eabf6e7c95467bcfa8c8fc42d76fd",
"efed736e627899fea944007eea39a4a63c0c2e26491cd12adb546be3e5c68f7d",
"cf7fc24bdaa09ac0cca8497e13298b961380668613c7493954048c06385a7044",
"f38b1c8306cf82ab76ee3a772b14416b49993fe11f986e9b0f0593c52ec91525"},
{NID_X9_62_prime256v1, NID_sha512,
"7905a9036e022c78b2c9efd40b77b0a194fbc1d45462779b0b76ad30dc52c564e48a493d"
"8249a061e62f26f453ba566538a4d43c64fb9fdbd1f36409316433c6f074e1b47b544a84"
"7de25fc67d81ac801ed9f7371a43da39001c90766f943e629d74d0436ba1240c3d7fab99"
"0d586a6d6ef1771786722df56448815f2feda48f",
"95c99cf9ec26480275f23de419e41bb779590f0eab5cf9095d37dd70cb75e870",
"0442c292b0fbcc9f457ae361d940a9d45ad9427431a105a6e5cd90a345fe3507f7313b08"
"fd2fa351908b3178051ee782cc62b9954ad95d4119aa564900f8ade70c",
"4c08dd0f8b72ae9c674e1e448d4e2afe3a1ee69927fa23bbff3716f0b99553b7",
"f2bc35eb1b8488b9e8d4a1dbb200e1abcb855458e1557dc1bf988278a174eb3b",
"ed9a2ec043a1d578e8eba6f57217976310e8674385ad2da08d6146c629de1cd9"},
{NID_X9_62_prime256v1, NID_sha512,
"cf25e4642d4f39d15afb7aec79469d82fc9aedb8f89964e79b749a852d931d3743650280"
"4e39555f5a3c75dd958fd5291ada647c1a5e38fe7b1048f16f2b711fdd5d39acc0812ca6"
"5bd50d7f8119f2fd195ab16633503a78ee9102c1f9c4c22568e0b54bd4fa3f5ff7b49160"
"bf23e7e2231b1ebebbdaf0e4a7d4484158a87e07",
"e15e835d0e2217bc7c6f05a498f20af1cd56f2f165c23d225eb3360aa2c5cbcf",
"0489dd22052ec3ab4840206a62f2270c21e7836d1a9109a3407dd0974c7802b9aee91609"
"ba35c7008b080c77a9068d97a14ca77b97299e74945217672b2fd5faf0",
"c9f621441c235fc47ec34eef4c08625df1ec74918e1f86075b753f2589f4c60b",
"a70d1a2d555d599bfb8c9b1f0d43725341151d17a8d0845fa56f3563703528a7",
"4e05c45adf41783e394a5312f86e66871c4be4896948c85966879d5c66d54b37"},
{NID_X9_62_prime256v1, NID_sha512,
"7562c445b35883cc937be6349b4cefc3556a80255d70f09e28c3f393daac19442a7eeced"
"cdfbe8f7628e30cd8939537ec56d5c9645d43340eb4e78fc5dd4322de8a07966b262770d"
"7ff13a071ff3dce560718e60ed3086b7e0003a6abafe91af90af86733ce8689440bf73d2"
"aa0acfe9776036e877599acbabfcb03bb3b50faa",
"808c08c0d77423a6feaaffc8f98a2948f17726e67c15eeae4e672edbe388f98c",
"04b0c0ad5e1f6001d8e9018ec611b2e3b91923e69fa6c98690ab644d650f640c42610539"
"c0b9ed21ac0a2f27527c1a61d9b47cbf033187b1a6ada006eb5b2662ed",
"1f6d4a905c761a53d54c362976717d0d7fc94d222bb5489e4830080a1a67535d",
"83404dcf8320baf206381800071e6a75160342d19743b4f176960d669dd03d07",
"3f75dcf102008b2989f81683ae45e9f1d4b67a6ef6fd5c8af44828af80e1cfb5"},
{NID_X9_62_prime256v1, NID_sha512,
"051c2db8e71e44653ea1cb0afc9e0abdf12658e9e761bfb767c20c7ab4adfcb18ed9b5c3"
"72a3ac11d8a43c55f7f99b33355437891686d42362abd71db8b6d84dd694d6982f061217"
"8a937aa934b9ac3c0794c39027bdd767841c4370666c80dbc0f8132ca27474f553d266de"
"efd7c9dbad6d734f9006bb557567701bb7e6a7c9",
"f7c6315f0081acd8f09c7a2c3ec1b7ece20180b0a6365a27dcd8f71b729558f9",
"04250f7112d381c1751860045d9bcaf20dbeb25a001431f96ac6f19109362ffebb49fba9"
"efe73546135a5a31ab3753e247034741ce839d3d94bd73936c4a17e4aa",
"68c299be2c0c6d52d208d5d1a9e0ffa2af19b4833271404e5876e0aa93987866",
"7b195e92d2ba95911cda7570607e112d02a1c847ddaa33924734b51f5d81adab",
"10d9f206755cef70ab5143ac43f3f8d38aea2644f31d52eaf3b472ee816e11e5"},
{NID_X9_62_prime256v1, NID_sha512,
"4dcb7b62ba31b866fce7c1feedf0be1f67bf611dbc2e2e86f004422f67b3bc1839c6958e"
"b1dc3ead137c3d7f88aa97244577a775c8021b1642a8647bba82871e3c15d0749ed343ea"
"6cad38f123835d8ef66b0719273105e924e8685b65fd5dc430efbc35b05a6097f17ebc59"
"43cdcd9abcba752b7f8f37027409bd6e11cd158f",
"f547735a9409386dbff719ce2dae03c50cb437d6b30cc7fa3ea20d9aec17e5a5",
"044ca87c5845fb04c2f76ae3273073b0523e356a445e4e95737260eba9e2d021db0f8647"
"5d07f82655320fdf2cd8db23b21905b1b1f2f9c48e2df87e24119c4880",
"91bd7d97f7ed3253cedefc144771bb8acbbda6eb24f9d752bbe1dd018e1384c7",
"008c1755d3df81e64e25270dbaa9396641556df7ffc7ac9add6739c382705397",
"77df443c729b039aded5b516b1077fecdd9986402d2c4b01734ba91e055e87fc"},
{NID_X9_62_prime256v1, NID_sha512,
"efe55737771070d5ac79236b04e3fbaf4f2e9bed187d1930680fcf1aba769674bf426310"
"f21245006f528779347d28b8aeacd2b1d5e3456dcbf188b2be8c07f19219e4067c1e7c97"
"14784285d8bac79a76b56f2e2676ea93994f11eb573af1d03fc8ed1118eafc7f07a82f32"
"63c33eb85e497e18f435d4076a774f42d276c323",
"26a1aa4b927a516b661986895aff58f40b78cc5d0c767eda7eaa3dbb835b5628",
"0428afa3b0f81a0e95ad302f487a9b679fcdef8d3f40236ec4d4dbf4bb0cbba8b2bb4ac1"
"be8405cbae8a553fbc28e29e2e689fabe7def26d653a1dafc023f3cecf",
"f98e1933c7fad4acbe94d95c1b013e1d6931fa8f67e6dbb677b564ef7c3e56ce",
"15a9a5412d6a03edd71b84c121ce9a94cdd166e40da9ce4d79f1afff6a395a53",
"86bbc2b6c63bad706ec0b093578e3f064736ec69c0dba59b9e3e7f73762a4dc3"},
{NID_X9_62_prime256v1, NID_sha512,
"ea95859cc13cccb37198d919803be89c2ee10befdcaf5d5afa09dcc529d333ae1e4ffd3b"
"d8ba8642203badd7a80a3f77eeee9402eed365d53f05c1a995c536f8236ba6b6ff889739"
"3506660cc8ea82b2163aa6a1855251c87d935e23857fe35b889427b449de7274d7754bde"
"ace960b4303c5dd5f745a5cfd580293d6548c832",
"6a5ca39aae2d45aa331f18a8598a3f2db32781f7c92efd4f64ee3bbe0c4c4e49",
"04c62cc4a39ace01006ad48cf49a3e71466955bbeeca5d318d672695df926b3aa4c85ccf"
"517bf2ebd9ad6a9e99254def0d74d1d2fd611e328b4a3988d4f045fe6f",
"dac00c462bc85bf39c31b5e01df33e2ec1569e6efcb334bf18f0951992ac6160",
"6e7ff8ec7a5c48e0877224a9fa8481283de45fcbee23b4c252b0c622442c26ad",
"3dfac320b9c873318117da6bd856000a392b815659e5aa2a6a1852ccb2501df3"},
{NID_secp384r1, NID_sha224,
"39f0b25d4c15b09a0692b22fbacbb5f8aee184cb75887e2ebe0cd3be5d3815d29f9b587e"
"10b3168c939054a89df11068e5c3fac21af742bf4c3e9512f5569674e7ad8b39042bcd73"
"e4b7ce3e64fbea1c434ed01ad4ad8b5b569f6a0b9a1144f94097925672e59ba97bc4d33b"
"e2fa21b46c3dadbfb3a1f89afa199d4b44189938",
"0af857beff08046f23b03c4299eda86490393bde88e4f74348886b200555276b93b37d4f"
"6fdec17c0ea581a30c59c727",
"0400ea9d109dbaa3900461a9236453952b1f1c2a5aa12f6d500ac774acdff84ab7cb71a0"
"f91bcd55aaa57cb8b4fbb3087d0fc0e3116c9e94be583b02b21b1eb168d8facf39552793"
"60cbcd86e04ee50751054cfaebcf542538ac113d56ccc38b3e",
"e2f0ce83c5bbef3a6eccd1744f893bb52952475d2531a2854a88ff0aa9b12c65961e2e51"
"7fb334ef40e0c0d7a31ed5f5",
"c36e5f0d3de71411e6e519f63e0f56cff432330a04fefef2993fdb56343e49f2f7db5fca"
"b7728acc1e33d4692553c02e",
"0d4064399d58cd771ab9420d438757f5936c3808e97081e457bc862a0c905295dca60ee9"
"4f4537591c6c7d217453909b"},
{NID_secp384r1, NID_sha224,
"5a3c80e608ed3ac75a6e45f6e94d374271a6d42b67a481860d5d309cc8b37c79cb61f171"
"6dc8aa84cb309ef9d68eb7fc6cf4b42333f316a5c30e74198c8b340926e340c5de47674a"
"707293c4aa2a1a2274a602f01c26b156e895499c60b38ef53fc2032e7485c168d73700d6"
"fa14232596a0e4997854a0b05d02e351b9d3de96",
"047dd5baab23f439ec23b58b7e6ff4cc37813cccb4ea73bb2308e6b82b3170edfe0e131e"
"ca50841bf1b686e651c57246",
"04de92ff09af2950854a70f2178d2ed50cc7042a7188301a1ea81d9629ad3c29795cb7f0"
"d56630a401e4d6e5bed0068d1e6135adbd8624130735e64e65ecbd43770dcc12b28e737b"
"5ed033666f34c918eb5589508e4a13b9243374a118a628dd0b",
"f3922351d14f1e5af84faab12fe57ded30f185afe5547aeb3061104740ecc42a8df0c27f"
"3877b4d855642b78938c4e05",
"38e181870cb797c1f4e6598cfd032add1cb60447d33473038d06df73919f844eddd16f40"
"f911075f8a4bacc0d924e684",
"a58dd1ca18aa31277de66c30c3bb7a14b53705ce6c547ed2cb0e336f63c42809422efffc"
"c722d1155f2254330a02b278"},
{NID_secp384r1, NID_sha224,
"e7d974c5dbd3bfb8a2fb92fdd782f997d04be79e9713944ce13c5eb6f75dfdec811b7ee4"
"b3859114b07f263846ae13f795eec8f3cb5b7565baff68e0fdd5e09ba8b176d5a71cb03f"
"bc5546e6937fba560acb4db24bd42de1851432b96e8ca4078313cb849bce29c9d8052586"
"01d67cd0259e255f3048682e8fdbdda3398c3e31",
"54ba9c740535574cebc41ca5dc950629674ee94730353ac521aafd1c342d3f8ac52046ed"
"804264e1440d7fe409c45c83",
"043db95ded500b2506b627270bac75688dd7d44f47029adeff99397ab4b6329a38dbb278"
"a0fc58fe4914e6ae31721a6875049288341553a9ac3dc2d9e18e7a92c43dd3c25ca866f0"
"cb4c68127bef6b0e4ba85713d27d45c7d0dc57e5782a6bf733",
"04324bd078807f6b18507a93ee60da02031717217ee5ce569750737be912be72da087ac0"
"0f50e13fdf7249a6ae33f73e",
"b2752aa7abc1e5a29421c9c76620bcc3049ecc97e6bc39fcca126f505a9a1bfae3bde89f"
"b751a1aa7b66fa8db3891ef0",
"f1c69e6d818ca7ae3a477049b46420cebd910c0a9a477fd1a67a38d628d6edaac123aebf"
"ca67c53a5c80fe454dba7a9d"},
{NID_secp384r1, NID_sha224,
"a670fda4d1d56c70de1d8680328043b2b7029633caf0ee59ffe1421c914bb937133d5a0f"
"9214846b2e0b350455a74c4ab434c56de65a17139bb8212bf1c76071a37536fa29348f87"
"1dbb26baa92eb93d97e923a6d2ffd9be25cbc33075e494e6db657bd8dc053fe4e17148d8"
"cf6e2058164f2b5766750eb01bbe7b361cdb848c",
"dabe87bbe95499bac23bc83c8b7307fe04be198f00059e2bf67c9611feaffb2c8f274f6a"
"a50eb99c3074186d8067d659",
"04c2aa0a695125279705917e02a4f258cade4c3ff9140a071414babf87764f426f7f36ff"
"da9d5f3394375d24864235476f8f9808da0ce0227cf453f9e456f557db9752e23b45cce4"
"baad5fee3844ddd7e1112bcec01ea9d67c7a76f3535bd0cb58",
"65a0305854033cbc6fe3ca139c40ca354d45801ecb59f4a923c251dc6b25d12d452d99b5"
"d6711fdb5efac812aa464cc4",
"c7fc32997d17ac79baf5789e4503f5f1a8863872bc350a91f12dd3ef8cf78c254e829217"
"809e8e00b6b8d4d85be3f1fd",
"1422e1838a22496df93486bce1142961dbd8478ae844b8dda54e210afdae0d9e930d587c"
"91bb600b0bde7237186d94e6"},
{NID_secp384r1, NID_sha224,
"7843f918fe2588bcfe756e1f05b491d913523255aa006818be20b676c957f4edb8df863c"
"6f5f8c15b3b80c7a2aa277b70d53f210bdfb856337980c406ea140e439dd321471407f37"
"4f69877b2d82367eed51e3c82c13948616dcb301d0c31f8f0352f2846abd9e72071f446a"
"2f1bd3339a09ae41b84e150fd18f4ba5d3c6bfa0",
"df43107a1deb24d02e31d479087bd669e2bc3e50f1f44b7db9484a7143cdca6a3391bddf"
"ea72dc940dbce8ec5efbd718",
"0476bd4be5d520471162cb5c36f80038301b325f845d9642204a84d78b3e721098932827"
"bf872bde0a9f86383953667d29415116b8b878f896a5aa4dbbdc21076f27135d8bbcaaca"
"02489ef639d742bd63f377da0c8e8ab36ff19b4a7cc5d4ceb4",
"798abad5a30d1805794540057388ee05e2422901c6335f985b9d4447b3ef75524751abfe"
"ab6409ad6bf77d4ae3014558",
"98744e5c6742fa5118a74a70db4957647a3cc12add4e876b45974a6a8707809f871daadb"
"fc0b865e01624f706b65f10c",
"9e256e8da8eff5a0c83baaa1ef4f7be798eba9543bf97adb0fff8719f5406ea1207a0cf7"
"03d99aa8f02169724b492273"},
{NID_secp384r1, NID_sha224,
"caa83d5ab07febbd2e0fe2d63738b9b7b8752594bea7aaf50345b3d2f316653a8c9222f2"
"b7877b64679e9573e81461a426029e45b8873a575094a1d572e0d32a9f0a9c6bcb9a2868"
"543b7d8bbe4a69a09e7321f05f8366cced1b72df526f895b60aed2c39c249653c7839538"
"770d4e5f47d3926ec0d168ab6a1af15bf1dca1f7",
"ea7a563ba2a7f5ab69973dca1f1a0d1572f0c59817cd3b62ad356c2099e2cdca1c553323"
"563f9dfbb333b126d84abc7f",
"04cf4717c5f5de668b785f06bdc9845df5a09e4edd83f4669756407cbb60807305c632bc"
"49f818f4a84b194369aa07736f7391e4982af8a2218f704f627d01f0508bfc8304992a2d"
"598a420bf2eb519f33bd7caf79380793733b3dba0cc5e2b9d8",
"7b9606b3df7b2a340dbc68d9754de0734e1faeb5a0135578a97628d948702235c60b20c8"
"002c8fcf906783e1b389e754",
"0d680010bed373287f9767955b5d2850e150b6713b49e453eb280148e45230c853d99ea2"
"d2f8fcbd3ddcba19aeec0af1",
"64329763a930ab5452afdb0557fef16ff71810d6343dfc9c6ae18905c3d274db6554cdc6"
"9d6078a1ca03284474a94f30"},
{NID_secp384r1, NID_sha224,
"594603458d6534974aeeafba919c4d0f4cb6843a3af41204bbb88aeb2fca2772d305163d"
"ba863da050aabedbaf89db521955d1715de95bbcef979ecdc0c976181ece00355385f8a8"
"f8cce127c9eac15ce3e958a3ed686184674ec9a50eb63271606ee7fdcb1323da3c3db8e8"
"9cad1fb42139a32d08abcfbf0d4ccfca18c89a86",
"4cc70cb35b3ddeb0df53a6bd7bd05f8ff4392a2db7344f2d443761484b3a468a4ee3d1a8"
"b27113d57283fd18b05f7829",
"0440e1fe21df34bb85a642a0abe819ebd128f7e39b84d8dcc4a9a599b372fb9588da1484"
"600ec28b1297bb685f9ae77831f3aa69ada57879fdcbe8df19cefabc308add7d03b17b1f"
"ac2f7783fece6a8dfe20bc36f518692677d96e3f730a67a671",
"8eda401d98f5688c34d8dbebcd3991c87c0442b0379154eaa2e5287dabe9a9e34cfc1305"
"d11ff68781df25d5611b331d",
"ff2d772786e159448bba26afd8c3281941a4cb0c56fec6f5cccb4c292c4ee0f7af9bd39b"
"be2d88148732585e104fdb30",
"07a1d890770daa949a17797dca7af3e8163da981ec330c03d63d1a8312c152be6a718163"
"205ffa08da7dcc163ba261f4"},
{NID_secp384r1, NID_sha224,
"733252d2bd35547838be22656cc7aa67eff0af0b13b428f77267a513c6824c3dbae53306"
"8b6817e82665f009560affcfe4b2ddb5b667a644fc1a42d24f24e0947e0dc50fb62c919b"
"c1fe4e7ded5e28f2e6d80fcf66a081fb2763526f8def5a81a4ddd38be0b59ee839da1643"
"eeeaee7b1927cec12cf3da67c02bc5465151e346",
"366d15e4cd7605c71560a418bd0f382fd7cd7ad3090ff1b2dfbed74336166a905e1b760c"
"f0bccee7a0e66c5ebfb831f1",
"04a143f277ab36a10b645ff6c58241ea67ffdc8acf12d60973068390f06b4d8f4d773b10"
"c1ebf6889b1cfa73ebb90f6ca17a17cad29bb507b309021f6f92cb5c10ba535f4a3e317f"
"cc68cfd02d3ccd269f465169c73d30ff308f5350d881b08aec",
"dbe545f920bc3d704c43d834bab21e40df12ec9e16a619a3e6b3f08760c26aae6e4fd91f"
"ad00f745194794b74bb1baee",
"cdc39b12bba30da66fe9554713c05880ddc27afa4d2d151440f124c351fb9496dc950465"
"16b0921083347d64369846ac",
"797d0344e49f9ba87a187c50f664e5015d449e346b1a7bd9427c5be559fc58173651880d"
"5aadf053f81899d3368d6181"},
{NID_secp384r1, NID_sha224,
"5a182bd174feb038dfae3346267156bf663167f713dea1ce936b0edb815cd9b8c8e4d411"
"c786ba2494a81442617255db7158b142e720d86c9b56680fb9efd4298cdd69079a281534"
"94c42a24251c7ad42ecf7e97eabc1b3997529b2a297cbad2474269b87a0b1e385f2d7f8b"
"6eb8d1cd75eaf7e91d1acbecd45d7b2bfbbe3216",
"e357d869857a52a06e1ece5593d16407022354780eb9a7cb8575cef327f877d22322c006"
"b3c8c11e3d7d296a708bdb6d",
"04ce9a2185a68d6094aa5849a6efe78b349946f7380f0c79aa9664246cfcc71a879e90ad"
"78a0474f58644c6a208168150e8354fa47673cb3e07d446521345706c5515584b2602f92"
"1c3b9c44dded9e2c3f90ce47adb36d7e5f9f95a8c5ad8af397",
"1e77367ac4e10924854d135ad2f2507f39e2bafdbce33ff256bcbe9a7329b8d27185218b"
"cc3550aafbe3390e84c77292",
"df3182d49ad70959fb0c95bc7312750ce70fc87f1a328d39d9b29ac05d31305ce7209d6c"
"24d13225d9567b489f7a187b",
"d812b05abab0e96de13291e1f0da6479444ed5cd9d959b76f6cb43d394769035364f7c83"
"1a104dc7b5bd9b4a8e64df64"},
{NID_secp384r1, NID_sha224,
"aaa99fb1c71340d785a18f6f668e898c25cf7a0ac31d13c5b388b7233408493a5a109af6"
"d07065376b96f4903df7aba2b2af671a18772bb0472490d1240cde28967680727dd4acd4"
"7e0308920a75da857a6eeedee5b6586d45dff3d8a680599665aa895c89dd7770b824b7de"
"e477ac5e7602d409d3cc553090c970b50811dbab",
"745a18db47324a3710b993d115b2834339315e84e7006eafd889fb49bd3cc5a8b50c9052"
"6e65e6c53bddd2916d14bead",
"04f692578c6f77531210aef55c9e004ce3b66cf268c6900dde31a8bbb76e7562e3fb7624"
"2de34ca330d2501030aa11946640965833b28de926c46de060aa25beaeda98f8415a6b1e"
"3564aa77870cf4c89bd4fde92c8f5d9bf0eb41721586859d8e",
"11b9b36720abcac084efdb44c9f5b7d039e3250cb1e9c47850189ba3cfc1489d858b2a44"
"df357772b61d919c7e729c0f",
"02b252c99820cf50e6ce060ab55bd4f682276e29b4ae4197417432e6a7bfb8cf0bac89df"
"e105456af805d822cee77696",
"8e248bbf7d7028d63177e565c9d1666ee5be4d1ffbfffc9c7814b0cd38f74b98f3f2cd59"
"be42b9f132bfe5ee789cd96c"},
{NID_secp384r1, NID_sha224,
"1fadfa8254d3a0b82d137cfdd82043d5dc1fef195d5297b09cc5cfb061f59c933451c0dc"
"2a11b4037f34f88dacb803251f8880c4b72585c3c196e6fb23484ca43a191f8e41b9b9a3"
"7e2e6fcaab6738c3c62d1c98e1c620bb788b7b51a04f998a510efdba0d3418622fe8ce20"
"3b3fcd553b9b4206365a39031797ad11e49745ec",
"93f20963ea5011ff4f26481e359309e634195f6289134087bd2e83eee008c962780a6797"
"84ee7ac6acda03d663ed27e0",
"040edcde3533ea019e18f1a3cd97b7962e8823dda36c389f8f9287549f796d11376392b8"
"a01c7a80f127a8f75795e04f5463d7c458dccfc02f5148d755d59f9bbc8e3c3ea3490877"
"7928440747795955741296abcdd5386676419ed8049fedb489",
"3ad308faf04c42ee5ac69d36bc0aa9a96aacf55ea0f27dac4f52e088f023d206340a6324"
"874ffad169ff80624de24c96",
"209b72f9aae72c4339813573c3a8408a9e0be641ca863d81d9d14c48d0bf4cd44a1a7985"
"cff07b5d68f3f9478475645b",
"f6292e599b22a76eda95393cf59f4745fa6c472effd1f781879ad9a4437a98080b0b07da"
"dad0c249631c682d2836a977"},
{NID_secp384r1, NID_sha224,
"9ecb6f5ed3ba666a8536a81ef65012c2cb8b433508798d84708abb06dfb75503886f7838"
"4fb8c7a4d2d49ef539d9b8a0b60938c7f07471dda91f258b0d99691b38a8403a2bb3f956"
"bdfd09baba16d9b6877097a9b6213481b47a06e139d23ec7abad5668d21f912fdb70d31b"
"b9adf9b3ce80e308252fa81a51674f88d02db72b",
"f175e6ac42fd48ec9d652c10707c039c67c4cc61d8c45a373dcda6e4ca6c53e947e49c24"
"e01b48e7cdf92edfe6d316a1",
"04a40c64f595491ce15790a5a87fbe64c1800247b42acd08fe5257700719f46afc8acce0"
"e4ede0517a312092d5e3d089cdd565df9dc2f381cc0c5d84f382a43a98018524c0b4708a"
"44b3e2817f9719f29fbf9c15803591ed9b4790c5adaba9f433",
"812dcaa6d4f9a43ccc553288065d13761581485aa903a500a690ccafbd330ba4818c977b"
"98c4bb57f8a182a1afacfae9",
"d000f18d3e4c162ff0d16f662e6703e7a6f5bff7a333ed266fa4f44c752415946c34945c"
"342c20f739677186b1d80ab3",
"ae7f1271c89e0aaa238710d039ea73a69110cc28fcf426f2fe6754b63a59e417fa84f903"
"cf7dccb5468b43ff083bbfd5"},
{NID_secp384r1, NID_sha224,
"e55bfca78d98e68d1b63688db12485578f36c489766f4d0bfaa0088433ff12133aaca455"
"805095f2e655940860958b3ead111d9070778ee3bbf3e47e43d9eba8b8d9b1fdf72f793f"
"cde2bcaa334f3e35fa2cca531ea7cf27fe9ccba741e38ac26129b2d612bf54a34e0ae6c1"
"66c0fef07fcd2b9ac253d7e041a500f7be7b8369",
"46c4f0b228b28aaa0ec8cfdf1d0ed3408b7ae049312fb9eaf5f3892720e68684cc8ad298"
"44a3dc9d110edf6916dfb8bb",
"0413ddec844731b7e30c467451df08ca11d6c581cb64abd8a257671cffd26f5ccad4df7b"
"9ee8924047a88a5d2d7567609cd74ca94f590fd1d13e190cc1e03c3da6c3faab15c7dda0"
"34af3deefee8aeec3628fa8b1978c54cfcd071baa319a46ec0",
"2a9dd520207c40a379cd4036adef9ee60fa8bc8c0d39b3ad91850ac93fd543f218b16885"
"81f23481a090b0e4c73792ac",
"94e08cca20fe3866f643f53ec65faf3f2b4d80cd9bcc8ff8f88bb28da9eada324fc2d048"
"908dd3d08a9e0ebb547731bc",
"8e6f82c4d3069b14f4c844b4ca133a9503493265c9f77a7d4775eda67de76798a23dd7ea"
"48e0ac3c337dd62bf058319d"},
{NID_secp384r1, NID_sha224,
"02c6b3c83bd34b288d96409162aa4ff114e9d134bf948046eb5ebcc0c7fe9dfceadda83e"
"d69da2fac00c8840f6c702a3fc5e6959d70f7e8af923e99e4937232ae3b841ffefd2e62f"
"ab3671a7c94a0281b8ea5bc176add57c5c9b6893fe7f5d48ce7256b96510810c4e046168"
"a3c5be9843b84d5268a50349b3444341aa5490dd",
"1d7b71ef01d0d33a8513a3aed3cabb83829589c8021087a740ca65b570777089be721a61"
"172b874a22a1f81aef3f8bb6",
"048d2721370df8f097d5a69396249a315f6037dc7045b3da11eacae6d43036f779d5de70"
"53d101768b42cc2b1283a3aaeaa046039ae662141f9954d278183eaa2e03917fe58583e3"
"2d344074d59d60caa5b0949c53066525d5cca923e2f201502e",
"d1b25ad25581cad17e96f1d302251681fee5b2efbb71c3c15ff035b2145d015d18e0e52d"
"c3187ab5a560277b3a3929b0",
"d836f52b14c7391744868daa2d5cf27eb9380b9b6176195573d5b04842e9f2fc3794d6cf"
"877feafee63d11b05f6a6bee",
"8b89042fef2c04d4bd6c9d66a06a010514321d623a5f8d57ba5ac3686872eaabca9e0ba2"
"d058ae7028e870acf03ca32d"},
{NID_secp384r1, NID_sha224,
"94f8bfbb9dd6c9b6193e84c2023a27dea00fd48356909faec2161972439686c146184f80"
"686bc09e1a698af7df9dea3d24d9e9fd6d7348a146339c839282cf8984345dc6a51096d7"
"4ad238c35233012ad729f262481ec7cd6488f13a6ebac3f3d23438c7ccb5a66e2bf820e9"
"2b71c730bb12fd64ea1770d1f892e5b1e14a9e5c",
"cf53bdd4c91fe5aa4d82f116bd68153c907963fa3c9d478c9462bb03c79039493a8eaeb8"
"55773f2df37e4e551d509dcd",
"043a65b26c08102b44838f8c2327ea080daf1e4fc45bb279ce03af13a2f9575f0fff9e2e"
"4423a58594ce95d1e710b590cefe9dcbcb2ec6e8bd8ed3af3ff0aa619e900cc8bab3f50f"
"6e5f79fac09164fb6a2077cc4f1fed3e9ec6899e91db329bf3",
"df31908c9289d1fe25e055df199591b23e266433ab8657cc82cb3bca96b88720e229f8df"
"d42d8b78af7db69342430bca",
"6770eea9369d6718e60dd0b91aee845ff7ed7e0fcc91675f56d32e5227fd3a4612bbcb15"
"56fe94a989b9e3bcc25bb20e",
"c43072f706c98126d06a82b04251e3ecb0ba66c4bb6cd7c025919b9cc6019cdc635256d2"
"a7fa017b806b1e88649d2c0d"},
{NID_secp384r1, NID_sha256,
"663b12ebf44b7ed3872b385477381f4b11adeb0aec9e0e2478776313d536376dc8fd5f3c"
"715bb6ddf32c01ee1d6f8b731785732c0d8441df636d8145577e7b3138e43c32a61bc124"
"2e0e73d62d624cdc924856076bdbbf1ec04ad4420732ef0c53d42479a08235fcfc4db4d8"
"69c4eb2828c73928cdc3e3758362d1b770809997",
"c602bc74a34592c311a6569661e0832c84f7207274676cc42a89f058162630184b52f0d9"
"9b855a7783c987476d7f9e6b",
"040400193b21f07cd059826e9453d3e96dd145041c97d49ff6b7047f86bb0b0439e90927"
"4cb9c282bfab88674c0765bc75f70d89c52acbc70468d2c5ae75c76d7f69b76af62dcf95"
"e99eba5dd11adf8f42ec9a425b0c5ec98e2f234a926b82a147",
"c10b5c25c4683d0b7827d0d88697cdc0932496b5299b798c0dd1e7af6cc757ccb30fcd3d"
"36ead4a804877e24f3a32443",
"b11db00cdaf53286d4483f38cd02785948477ed7ebc2ad609054551da0ab0359978c6185"
"1788aa2ec3267946d440e878",
"16007873c5b0604ce68112a8fee973e8e2b6e3319c683a762ff5065a076512d7c98b27e7"
"4b7887671048ac027df8cbf2"},
{NID_secp384r1, NID_sha256,
"784d7f4686c01bea32cb6cab8c089fb25c341080d9832e04feac6ea63a341079cbd562a7"
"5365c63cf7e63e7e1dddc9e99db75ccee59c5295340c2bba36f457690a8f05c62ab001e3"
"d6b333780117d1456a9c8b27d6c2504db9c1428dad8ba797a4419914fcc636f0f14ede3f"
"ba49b023b12a77a2176b0b8ff55a895dcaf8dbce",
"0287f62a5aa8432ff5e95618ec8f9ccaa870dde99c30b51b7673378efe4ccac598f4bbeb"
"bfd8993f9abb747b6ad638b9",
"04b36418a3014074ec9bbcc6a4b2367a4fb464cca7ec0a324cb68670d5c5e03e7a7eb07d"
"a117c5ea50b665ab62bd02a4914ea299c30e7d76e2c5905babada2d3bb4ee5eb35a5a236"
"05cdb0d5133471a53eb9e6758e49105a4eaf29d2267ba84ef2",
"935eeab3edeb281fbd4eead0d9c0babd4b10ff18a31663ee9de3bfa9ae8f9d266441158e"
"a31c889ded9b3c592da77fd7",
"738f9cb28f3b991335ef17b62559255faf75cad370a222464a492e27bb173c7f16b22100"
"ada6b695875c7e4b1a28f158",
"bc998c30e1491cd5d60dc7d1c38333165efe036b2a78db9b8f0e85ee68619cfba654e11a"
"e5ca5ee5a87099c27cf22442"},
{NID_secp384r1, NID_sha256,
"45e47fccc5bd6801f237cdbeac8f66ebc75f8b71a6da556d2e002352bd85bf269b6bc7c9"
"28d7bb1b0422601e4dd80b29d5906f8fcac212fe0eaaf52eda552303259cbcbe532e60ab"
"d3d38d786a45e39a2875bce675800a3eaeb9e42983d9fd9031180abd9adccc9ba30c6c19"
"8b4202c4dd70f241e969a3c412724b9b595bc28a",
"d44d3108873977036c9b97e03f914cba2f5775b68c425d550995574081191da764acc501"
"96f6d2508082a150af5cd41f",
"04c703835d723c85c643260379d8445b0c816fe9534351921e14a8e147fe140ec7b0c4d7"
"04f8dc66a232b2333b28f03deec5d0bb054053fd86c26f147c4966757aa04b00513a02d4"
"27b8d06c16055c607955efdc518d338abfe7927c195dc28588",
"c80f63e080650c8a21e4f63a62ec909adfb7d877f365d11ee1cb260baf112eb4730c161c"
"1d99dba98fc0d5bbd00dc97d",
"81de2810cde421997013513951a3d537c51a013110d6dbb29251410bcb5ba001a9686b84"
"90f1e581e282fd2ed0974b22",
"9cab0bbaffe91c7677ec3dd1f17060211a3cc0be574cbca064aa8c4b66ba6e64f3d80e83"
"da895042ca32d311c388d950"},
{NID_secp384r1, NID_sha256,
"c33ff63b4e6891e00b2349b3f2907c417ca355560544a91e24a7a0ee260d6850aeded29f"
"c0176b6039ca6187e8333391047cceaf14b1077df8f147dad84d36b2dac5666dc2f69dc9"
"b58b88cc73956efdb3b47f91831d5875051c76b0c4e9fc087012a1f03eeee85d6745b46a"
"a50bd9cb0110c2c94508765cec162ee1aa841d73",
"d5b72cbb6ec68aca46b9c27ad992afd8ffa02cb3067b234fcfa6e272e3b31be760695ff7"
"df988b57663057ab19dd65e3",
"04135a6542612f1468d8a4d01ff1914e532b1dd64d3627db9d403dc325651d3f82b0f6f0"
"fd1dbdeca2be967c4fb3793b5fcbbd40f6d3a38d0dfb64582ff4789d7b268241bc0c36de"
"2884bccfaeeff3b7b2b46a30bb35719804e0d11124b4e7f480",
"9da6de7c87c101b68db64fea40d97f8ad974ceb88224c6796c690cbf61b8bd8eede8470b"
"3caf6e6106b66cf3f0eebd55",
"17840911ecdf6ae0428b2634f442163c2c11b8dbf0cc7a5596fbe4d33e3e52f9d99e99ad"
"169867b1f39e89c9180cedc2",
"dd7ed67e480866d0474379ea4afff72870746f4feef2153be42f13bf472b1613d7faa5c0"
"abb7f7464070f94d7cf3f234"},
{NID_secp384r1, NID_sha256,
"f562f2b9d84b0e96a52532c3b43c39c8018c738bd8dc3797a7de7353971b2729d522d696"
"1b1f2e4df3f6a4bd3653e6d72b74fc0dba92ab939c4b542e994e5db6dd8ed4f56f651e69"
"9052e791237ae1f552f990ad156226ae8f7bf17fcbfa564f749604f97e9df0879d509857"
"47d981422a23040fe52f5ec74caf1d4aaad8a710",
"218ee54a71ef2ccf012aca231fee28a2c665fc395ff5cd20bde9b8df598c282664abf915"
"9c5b3923132983f945056d93",
"0401989ff07a7a452d8084937448be946bfedac4049cea34b3db6f7c91d07d69e926cce0"
"af3d6e88855a28120cf3dba8dfeb064e029d7539d4b301aabafe8de8870162deffe6383b"
"c63cc005add6ee1d5ced4a5761219c60cd58ad5b2a7c74aaa9",
"c5d39b436d851d94691f5f4aa9ef447f7989d984f279ae8b091aef5449ac062bcc056774"
"0f914624ad5b99fc32f9af0b",
"07d5b1b12877e8cb5e0aa5e71eeeb17bf0aa203064c7e98b3a1798a74dc9717252dc47c7"
"f06aaf1d5fe15b868323bbb9",
"69428cf101a7af5d08161a9fd7af212e02e33b6062aebdce4c96bf3a0684b5394cb902ca"
"7c2dec6e2f01f40c4576009d"},
{NID_secp384r1, NID_sha256,
"ace953ae851f571d71779aa120915f27450b236da23e9106f8d0756abdd2586193794122"
"8d225d5fb1aa1b1ebf759b1e326aeb3b6cd0cd87edd2ab9f6a7ad67b63d2c501d6a550ed"
"b2e7c9d216cc8af78dd33546af64d00abed4d0d2cfc5c9a7b5a055dbe8f7547902d185cf"
"46937314832bc5c602419a82ab83dbd9d3bd5aff",
"e6ab171f6937c000e144950801ad91023ae8e8476856c2592d9f7d5bb7180fd729211803"
"d39a412ead6c0be761cfa5d1",
"0438bc42b8c9d8866d09b214398d584b1b24a488dfacc3420d1e9506aa825b19fdf1ba74"
"e7b8f547f47b571467fe8c4d1f5179d62668d3f6a7ab5c8e3761a685e12008fb87d0529a"
"97645f65cfb5364376c1b6682e0ffcddd0bcd995c41d013ad3",
"05e9718aea9669c9e434f73866da5f252dec6d24c47a1c4ee3233450b6ec626de9746ebe"
"095b285558dfc89fc1b622fe",
"df9bab9dd1f22ec6f27116f38831cb2089aa78aa8c073024a0faddd9a48e810a5e8e2cad"
"d80fbf8dbd6088c71fe30b5b",
"1e0e8718567d12d18558c57f9e87a755c309e4ffb497335a3adfc8d7475ce8fd882d5dc3"
"3a8f5a16274b7ad74bb7862a"},
{NID_secp384r1, NID_sha256,
"9635ab832240be95301bedb94c5aec169eedc198cbbdfedcf41e9b586143d829b4597a6b"
"2a81902828332825fd84a785f187a3894e21bd99d22c4f94dcf34453fc052f15ec64d144"
"7c932cb38fcdd30b7be851963409c11881438cbaad7e96f9efbde317f2235d66af804477"
"a5dfe9f0c51448383830050ecf228889f83631e1",
"14acd516c7198798fd42ab0684d18df1cd1c99e304312752b3035bed6535a8975dff8acf"
"c2ba1675787c817b5bff6960",
"0429909d143cf7ee9c74b11d52f1a8f3ebd4a720c135612ca5618d3f432f03a95602ee75"
"a2057e1d7aab51d0648ac0b334404b6c5adffbadfa1b0380ae89fed96ec1ca16cc28661e"
"623d0f1c8b130fbaa96dd7257eae2bf03c2d3dcbc3dbc82c58",
"7f623c103eaa9099a0462e55f80519c565adaeffcb57a29993f3a8a92e63a560be8f0fb9"
"d23dc80bff1064bb41abad79",
"932ab291950c16b2b19a8036cd2e905714c6229cb190a73b3ea49c48dd8e76063a453c7c"
"3267a57597d2973678216296",
"d17d4c5ddbb9c27beebf526f113b416c8abfad53d11c4224813c7f351ba41a77dd4e77d6"
"e4a65bef2c9f62cc37a469a5"},
{NID_secp384r1, NID_sha256,
"d98b9a7d4fe9d0fd95de5056af164a8b7882cd34ab5bde83a2abb32dc361eb56a479a3a6"
"119db3b91dcad26a42d2206749567f0d97c34a981a91fc734921821a429f6a53401743a5"
"c406ba9d560f956203abc9d1f32f1a13e7d7b290f75c95fdbf857ea597021461c06a3aac"
"fa554ede3d69e4ff03bbbee5b7463ec77de2b3b2",
"2e780550984f3a00cb1e412429b33493c6eb6cd86d12f9d80588c247dcf567bd04296d2d"
"4b24b889d9c54954b7f38f57",
"0437dac42ef04663238443ef33e8addee2e78c40d50a1751913a7f5c37d1f23a26c7f86e"
"16055c788b8ca9554f06b2f2efbbed1549652904e3d00c39b01cc0460dbaf3185e6190c2"
"705677a9701de1fe56dff4f4d8418ee15059ff8fc36800982d",
"b788ca82811b0d4e4841765c71eafaa1e575378beedcd3860d8b92db3d070ac5aef7c425"
"067860fbee6c50cf0c642bbb",
"7292b3851870daeb2555a8a2fb198ead78739fcfb75327e5c32a82c6b77d58983e5ad548"
"ccb75dcf9411039c9576d9b9",
"a378c61802d9f1dd062b6e18f16416a954018f77df4df95ad1b983570377d5cfce4cc786"
"1759e802c52f81abc4f49aac"},
{NID_secp384r1, NID_sha256,
"1b4c754ac1c28dc415a71eac816bde68de7e8db66409af835838c5bb2c605111108a3bf1"
"3606ed5d8ade5ed72e50503e0de664416393d178ea4eec834d8d6f15039847b410080fd5"
"529b426e5aadd8451c20ebd92d787921f33e147bcbeb327b104d4aab1157fc1df33e4d76"
"8404b5ccb7110055c2508c600f429fd0c21b5784",
"a24d0fe90808aecc5d90626d7e6da7c9be5dfd4e1233c7f0f71f1b7c1c6fd318fafe1855"
"9c94718f044cf02ed5107cb1",
"04ec8ae1fb9bb88589d27d6f27d790392853396f37bc0c381631d85800fc668eea0886bf"
"1c6cff801147df19778d5b16041e1a8336c1e2506f8ee388b55cc648ae73b9295ea78467"
"979d2affb364536fad28120f51ec62a67cbb6ce7784780389f",
"755d025509b73cf1ea8817beb772ad150b4c17a52378be187daffe3db0158921e5e552d1"
"ca3c85df28519939f3cb794d",
"23ff2ffa62bbd427d49995d9c9950116e0d5a06ef076a4553448bc109e6482c5e87d4c83"
"3bc88de0bc722bc98cae2e61",
"9aea13d487c3ea6917e16374caafcf0321c12a80d28902dd8cd81909bb04b8c439e2491e"
"504756742d0d0bfb15a9c34c"},
{NID_secp384r1, NID_sha256,
"3cd8c053741dd9f974c6c5dbf8a1e5728e9b5eafb1cbcfc3452f5fbbda32a8c7564dee15"
"7e8d902c52514361da6d972934a56b3276e2a9379e328e24282e0db697c5bc29090fc489"
"ec46b7b188325dd4e96494c250de0f4a89fe2ccf919eaefcfb50c288113e6df92714feb7"
"f46e0822478c796d0f4ff3447a32997e892693ce",
"1c172e25732555afee7ded67a496f3f11babc0875898619f4519c29321e201e8ba1149f2"
"c20b48e5efba235d58fea7c3",
"0413e9e2c8bbcfe26e8f5f43c86268c5980ee693236a6b8777f3a7323718baa21005b482"
"d08aafc6fa6e3667d91353544c9ba181b3ee505be030f87ecd249b00670a791489b42af0"
"4976013483ff95b630c91c01e95757e906129f2f9b4ce719a8",
"08aec9a9e58bdc028805eb5dc86073d05fff1f5fb3fd17f510fc08f9272d84ba7aa66b6f"
"77d84fe6360bd538192bf01a",
"2b4337c3dfbc886ffad7858ae2480cb62227e12205a70361c42f1a5ca9e658ee30fc3cf4"
"030d85bd065edad83b99821f",
"2550cef8574bf17fb3d6b0c9d04ab266962bac3621bac233ff2e4989712d2a4a07171c0a"
"ebd3040cd6a32c3bd3efb8b5"},
{NID_secp384r1, NID_sha256,
"ed955dda6d9650124804d3deb6aeef900e520faf98b1ef6f14efcada7ca2433f09329b70"
"897305e59c89024d76e466b28fe02cb2a9b12e2478c66470259d7c282137a19e5a04ffad"
"ea55245c0f34a681593fedc42931d8b3321b3d82e9cc102cd00540ad311ec7bd8c9d06db"
"21bea4ca3dc74d98931ae0d40494aefc2345132c",
"5b96555dbd602e71d4d5d3aee19fd1ea084ee23d4f55c10937056762bc2015cbded2e898"
"a487f5482ab7e1e971245907",
"046e14c17bb831b0112d7f3543c5fd17c78379a516c9e0539b03b8b4bfdead2820343fc8"
"4b0382807573ded6c4d97b70037f60021d2de77546db666721c9aec84c3e2ba8de0ba774"
"43600dc77e6839bbf9316271adb22d4cb47d08f745ecb1dafd",
"7ad6f4ffd2b429ba10c6f112f800cacf1ad508cf8eba880893bb9659c1ddaaec57dcdc09"
"3a114500460d457bdde324f2",
"faea950ca513806bc59028c638d6302ffc86978c3ff1f06db015dd7c4777050186cb8dd8"
"71f5e926e1416539c1939c2f",
"2c592240eabb8a1f9878e1b5c9d5d3ced7b3a7ae571f5a86494ed2ca567a36eb72e7bea8"
"934bded29594bccf67ca84bd"},
{NID_secp384r1, NID_sha256,
"ce395b001da2a58e49691605d44af4206306f62f561bf2394060d2a5591a350277166bed"
"043819035f1e60b5b3fb5ae113ddd0473f8ef6b2b050c472c2a264e1d8b3ca82a4f158c4"
"0f2d78d9ce5e5ea6de243f2e1f13f47f6c6f403b270912c81c636be35b396ca58468b3fb"
"60aa83911d61441a0528d973bc31f965d4059080",
"8df9c3c710a25192f3dea970910bb3784e3509874cccf4334823eb9f7a8d05b067f2d812"
"d61e878e24b093089a0b8245",
"0492c9e32b20cbe6d4ed0727c6c942cf804a72031d6dfd69078b5e78ebce2d192268f1f5"
"e2abce5aaf1f8d6a35f136837fd5167905fa7689e03b9fb1487c566f62b36f2bc1c4a2bf"
"b6a836113b5c8d46f7c1ca51b628b14397fbc06ec9a07f4849",
"258dd05919735cd48627c9fe9fac5c252604aa7c2ae0460d7c1149cd96b7bd2ba195ad39"
"3bf392a2499f06aead5ba050",
"413793bcce52eda0f5b675a8d687cce86d5c9e1659b38a89e96246b5e05f8b0934d17dbb"
"a3b2ea44c838aa5fd87125d1",
"ce7309fc2d6e3438818a1a29a997410b025b0403de20795b97c86c46034a6b02afeed279"
"aeb06522d4de941bfdf50469"},
{NID_secp384r1, NID_sha256,
"ffefe316455ae4ffdb890bb804bf7d31424ea060ecacff419d0f7134ff76ad434063c0ec"
"0f8bb7059584d3a03f3625bb9e9f66ace1a47ac4b8f3e76fc7c420c55edb1427d1fa15b3"
"87ad73d02b0595c4e74321be8822752230a0dcfb85d60bfa186da7623a8ec3eb1633f0a2"
"94b23ae87216b14ccee9ef56418dcfab9427371e",
"6002cb01ad2ce6e7101665d47729c863b6435c3875de57a93f99da834f73e3e6e2b3880e"
"06de3e6bd1d51ea1807ab0d7",
"04e4216e1a20af8e8e3e74653ac016545001066e53e64af679ad1c85841bb475aed3e00e"
"ad052ae9955f48d675ff4ace568804c17641be21d4c6386902c9c5c888af25d97ca38370"
"3ea4a85cf93bbab360c0bbd2993374da499a303778650270b9",
"6b9507fd2844df0949f8b67b6fde986e50173713ac03df2edf65cb339859321cd3a2b9aa"
"b8356f95dec62460ab19c822",
"018891f6381ed358b422f79a299cf0789cee783ba388af4d82cbbe17f3709751b7fd9400"
"e9702820c28b9afc62fdf489",
"aef73bd590802b2fd2a65c4f7fec89f9b24ecc199a69254785925f334cd1977c5e1f858b"
"d9830d7d7d243ea707b1af0b"},
{NID_secp384r1, NID_sha256,
"304bccb718b3a9e12669913490cc5bcc1979287b56c628fad706c354241e88d10e81445a"
"2853e3fc32ece094ba1abc3fdcab61da27f9a0fca739371049fed462ee6b08fa31cde127"
"20f8144a6f00ce9b1a7a6eadd231f126717074b4efb5c72ce673ca5859000a436f67a338"
"d698759f12c461247c45a361fb6cb661fdbe6714",
"d8559c3543afc6f7b3dc037a687bad2630283757ba7862fd23ed14e2151a4cf5fed3d249"
"268f780e0b96b6b46274a2d5",
"045f94223918f2ec9f0a08342cb99e724881c92453957c59672860f69daac01b660331a0"
"f5845e50f1f27766b219c89e7ed76d83396130d10d1168d76c7fc83742ffffbe66d9f4da"
"4ca3f95f5ad6dac8cc7bb65d16d317d37aa99fdbf30ec7439c",
"4ad5a92b5b8e170b71c8a7ed419dc624c7680004562b8d16a37b6e639f581ce81d5f0d98"
"cce44d54c4e7136229148340",
"f7baa6a5488ab462ea59aa31a36402b15880c68110b6069f51ede0c3b52a7b1e5bf926fd"
"be95768931b7d5f87058835c",
"28b1c4ef448a432f7c91b98b0c6471691e888211b6af907369a8930859b8cdb2e94f466a"
"44f4e52f46df9b0d65e35de6"},
{NID_secp384r1, NID_sha256,
"64f9f05c2805acf59c047b5f5d2e20c39277b6d6380f70f87b72327a76170b872bfe4b25"
"c451602acfb6a631bb885e2655aee8abe44f69c90fb21ffde03cef2a452c468c6369867d"
"fd8aa26ac24e16aa53b292375a8d8fbf988e302bf00088e4c061aa12c421d8fe3cbd7273"
"b0e8993701df1c59431f436a08b8e15bd123d133",
"b9208cbfd186ddfa3efd5b71342ae1efb01a13ebc4c2a992a2cbee7254b7846a4252ece1"
"104b89d13d835911f8511224",
"04166e6d96cb60d916fd19888a2dd945a3306ff0d7b0a5e30729f47d3dac3de2be3fd5cd"
"7437e9a80d6c48cf960d2d36f8e6b2b70f131092ae210f29cc6bad701318bddb31bddf92"
"1695855c6208941100d0cee5d10799f8b835afe3ea510e8229",
"da706ab5f61531f2378b3c0a2b342108cd119eadaa88b859df64923bccfb0ec2393fd312"
"826f65c15a6587d1d460015b",
"d9124c42858080c62400e4d4d8136304e03d910cbe9b9b3487f4d27c7e0540a314d34bef"
"8c850045c8746ca631c11c42",
"bbf6424a3b70166fa799f49e918439d515327039258ef9bd88435a59c9c19659f8ec3c86"
"60720b0c08354ff60e0f5a76"},
{NID_secp384r1, NID_sha384,
"6b45d88037392e1371d9fd1cd174e9c1838d11c3d6133dc17e65fa0c485dcca9f52d41b6"
"0161246039e42ec784d49400bffdb51459f5de654091301a09378f93464d52118b48d44b"
"30d781eb1dbed09da11fb4c818dbd442d161aba4b9edc79f05e4b7e401651395b53bd8b5"
"bd3f2aaa6a00877fa9b45cadb8e648550b4c6cbe",
"201b432d8df14324182d6261db3e4b3f46a8284482d52e370da41e6cbdf45ec2952f5db7"
"ccbce3bc29449f4fb080ac97",
"04c2b47944fb5de342d03285880177ca5f7d0f2fcad7678cce4229d6e1932fcac11bfc3c"
"3e97d942a3c56bf34123013dbf37257906a8223866eda0743c519616a76a758ae58aee81"
"c5fd35fbf3a855b7754a36d4a0672df95d6c44a81cf7620c2d",
"dcedabf85978e090f733c6e16646fa34df9ded6e5ce28c6676a00f58a25283db8885e16c"
"e5bf97f917c81e1f25c9c771",
"50835a9251bad008106177ef004b091a1e4235cd0da84fff54542b0ed755c1d6f251609d"
"14ecf18f9e1ddfe69b946e32",
"0475f3d30c6463b646e8d3bf2455830314611cbde404be518b14464fdb195fdcc92eb222"
"e61f426a4a592c00a6a89721"},
{NID_secp384r1, NID_sha384,
"d768f41e6e8ec2125d6cf5786d1ba96668ac6566c5cdbbe407f7f2051f3ad6b1acdbfe13"
"edf0d0a86fa110f405406b69085219b5a234ebdb93153241f785d45811b3540d1c37424c"
"c7194424787a51b79679266484c787fb1ded6d1a26b9567d5ea68f04be416caf3be9bd2c"
"afa208fe2a9e234d3ae557c65d3fe6da4cb48da4",
"23d9f4ea6d87b7d6163d64256e3449255db14786401a51daa7847161bf56d494325ad2ac"
"8ba928394e01061d882c3528",
"045d42d6301c54a438f65970bae2a098cbc567e98840006e356221966c86d82e8eca515b"
"ca850eaa3cd41f175f03a0cbfd4aef5a0ceece95d382bd70ab5ce1cb77408bae42b51a08"
"816d5e5e1d3da8c18fcc95564a752730b0aabea983ccea4e2e",
"67ba379366049008593eac124f59ab017358892ee0c063d38f3758bb849fd25d867c3561"
"563cac1532a323b228dc0890",
"fb318f4cb1276282bb43f733a7fb7c567ce94f4d02924fc758635ab2d1107108bf159b85"
"db080cdc3b30fbb5400016f3",
"588e3d7af5da03eae255ecb1813100d95edc243476b724b22db8e85377660d7645ddc1c2"
"c2ee4eaea8b683dbe22f86ca"},
{NID_secp384r1, NID_sha384,
"6af6652e92a17b7898e40b6776fabaf0d74cf88d8f0ebfa6088309cbe09fac472eeac2aa"
"8ea96b8c12e993d14c93f8ef4e8b547afe7ae5e4f3973170b35deb3239898918c70c1056"
"332c3f894cd643d2d9b93c2561aac069577bbab45803250a31cd62226cab94d8cba7261d"
"ce9fe88c210c212b54329d76a273522c8ba91ddf",
"b5f670e98d8befc46f6f51fb2997069550c2a52ebfb4e5e25dd905352d9ef89eed5c2ecd"
"16521853aadb1b52b8c42ae6",
"0444ffb2a3a95e12d87c72b5ea0a8a7cb89f56b3bd46342b2303608d7216301c21b5d292"
"1d80b6628dc512ccb84e2fc278e4c1002f1828abaec768cadcb7cf42fbf93b1709ccae6d"
"f5b134c41fae2b9a188bfbe1eccff0bd348517d7227f2071a6",
"229e67638f712f57bea4c2b02279d5ccad1e7c9e201c77f6f01aeb81ea90e62b44b2d210"
"7fd66d35e56608fff65e28e4",
"b11db592e4ebc75b6472b879b1d8ce57452c615aef20f67a280f8bca9b11a30ad4ac9d69"
"541258c7dd5d0b4ab8dd7d49",
"4eb51db8004e46d438359abf060a9444616cb46b4f99c9a05b53ba6df02e914c9c0b6cc3"
"a9791d804d2e4c0984dab1cc"},
{NID_secp384r1, NID_sha384,
"b96d74b2265dd895d94e25092fb9262dc4f2f7a328a3c0c3da134b2d0a4e2058ca994e34"
"45c5ff4f812738e1b0c0f7a126486942a12e674a21f22d0886d68df2375f41685d694d48"
"7a718024933a7c4306f33f1a4267d469c530b0fed4e7dea520a19dd68bf0203cc87cad65"
"2260ed43b7b23f6ed140d3085875190191a0381a",
"de5975d8932533f092e76295ed6b23f10fc5fba48bfb82c6cc714826baf0126813247f8b"
"d51d5738503654ab22459976",
"04f1fabafc01fec7e96d982528d9ef3a2a18b7fe8ae0fa0673977341c7ae4ae8d8d3d674"
"20343d013a984f5f61da29ae381a31cf902c46343d01b2ebb614bc789c313b5f91f9302a"
"d9418e9c797563e2fa3d44500f47b4e26ad8fdec1a816d1dcf",
"fc5940e661542436f9265c34bce407eff6364bd471aa79b90c906d923e15c9ed96eea4e8"
"6f3238ea86161d13b7d9359d",
"c2fbdd6a56789024082173725d797ef9fd6accb6ae664b7260f9e83cb8ab2490428c8b9c"
"52e153612295432fec4d59cd",
"8056c5bb57f41f73082888b234fcda320a33250b5da012ba1fdb4924355ae679012d81d2"
"c08fc0f8634c708a4833232f"},
{NID_secp384r1, NID_sha384,
"7cec7480a037ff40c232c1d2d6e8cd4c080bbeecdaf3886fccc9f129bb6d202c316eca76"
"c8ad4e76079afe622f833a16f4907e817260c1fa68b10c7a151a37eb8c036b057ed4652c"
"353db4b4a34b37c9a2b300fb5f5fcfb8aa8adae13db359160f70a9241546140e550af007"
"3468683377e6771b6508327408c245d78911c2cc",
"11e0d470dc31fab0f5722f87b74a6c8d7414115e58ceb38bfcdced367beac3adbf1fe9ba"
"5a04f72e978b1eb54597eabc",
"041950166989164cbfd97968c7e8adb6fbca1873ebef811ea259eb48b7d584627f0e6d6c"
"64defe23cbc95236505a252aa141ef424b5cb076d4e32accd9250ea75fcf4ffd81814040"
"c050d58c0a29b06be11edf67c911b403e418b7277417e52906",
"e56904028226eb04f8d071e3f9cefec91075a81ca0fa87b44cae148fe1ce9827b5d1910d"
"b2336d0eb9813ddba3e4d7b5",
"c38ef30f55624e8935680c29f8c24824877cf48ffc0ef015e62de1068893353030d1193b"
"f9d34237d7ce6ba92c98b0fe",
"651b8c3d5c9d5b936d300802a06d82ad54f7b1ba4327b2f031c0c5b0cb215ad4354edc7f"
"932d934e877dfa1cf51b13fe"},
{NID_secp384r1, NID_sha384,
"00ce978603229710345c9ad7c1c2dba3596b196528eea25bd822d43ca8f76a024e292177"
"03dd0652c8a615284fc3edcc1c5ad1c8d5a8521c8e104c016a24e50c2e25066dcb56596f"
"913b872767e3627aa3e55ec812e9fdac7c2f1beade83aef093e24c9c953982adf431a776"
"880ae4583be158e11cdab1cbca3ad3a66900213d",
"5c6bbf9fbcbb7b97c9535f57b431ed1ccae1945b7e8a4f1b032016b07810bd24a9e20055"
"c0e9306650df59ef7e2cd8c2",
"042e01c5b59e619e00b79060a1e8ef695472e23bf9a511fc3d5ed77a334a242557098e40"
"972713732c5291c97adf9cf2cf563e3fe4ad807e803b9e961b08da4dde4cea8925649da0"
"d93221ce4cdceabc6a1db7612180a8c6bef3579c65539b97e9",
"03d23f1277b949cb6380211ad9d338e6f76c3eedac95989b91d0243cfb734a54b19bca45"
"a5d13d6a4b9f815d919eea77",
"abab65308f0b79c4f3a9ff28dd490acb0c320434094cef93e75adfe17e5820dc1f77544c"
"faaacdc8cf9ac8b38e174bef",
"11b783d879a6de054b316af7d56e526c3dce96c85289122e3ad927cfa77bfc50b4a96c97"
"f85b1b8221be2df083ff58fb"},
{NID_secp384r1, NID_sha384,
"54a255c18692c6162a46add176a0ae8361dcb8948f092d8d7bac83e160431794d3b98128"
"49bf1994bcdcfba56e8540c8a9ee5b93414548f2a653191b6bb28bda8dc70d45cc1b92a4"
"89f58a2d54f85766cb3c90de7dd88e690d8ebc9a79987eee1989df35af5e35522f83d85c"
"48dda89863171c8b0bf4853ae28c2ac45c764416",
"ffc7dedeff8343721f72046bc3c126626c177b0e48e247f44fd61f8469d4d5f0a74147fa"
"baa334495cc1f986ebc5f0b1",
"0451c78c979452edd53b563f63eb3e854a5b23e87f1b2103942b65f77d024471f75c8ce1"
"cc0dfef83292b368112aa5126e313e6aaf09caa3ba30f13072b2134878f14a4a01ee8632"
"6cccbff3d079b4df097dc57985e8c8c834a10cb9d766169366",
"c3de91dbe4f777698773da70dd610ef1a7efe4dc00d734399c7dd100728006a502822a5a"
"7ff9129ffd8adf6c1fc1211a",
"f4f477855819ad8b1763f53691b76afbc4a31a638b1e08c293f9bcd55decf797f9913ca1"
"28d4b45b2e2ea3e82c6cf565",
"7c26be29569ef95480a6d0c1af49dc10a51a0a8931345e48c0c39498bfb94d62962980b5"
"6143a7b41a2fddc8794c1b7f"},
{NID_secp384r1, NID_sha384,
"692a78f90d4f9d5aee5da536314a78d68c1feabbfe5d1ccea7f6059a66c4b310f8051c41"
"1c409ccf6e19a0cbd8b8e100c48317fe8c6d4f8a638b9551ce7ee178020f04f7da3001a0"
"e6855225fb3c9b375e4ed964588a1a41a095f3f476c42d52ffd23ce1702c93b56d4425d3"
"befcf75d0951b6fd5c05b05455bdaf205fe70ca2",
"adca364ef144a21df64b163615e8349cf74ee9dbf728104215c532073a7f74e2f6738577"
"9f7f74ab344cc3c7da061cf6",
"04ef948daae68242330a7358ef73f23b56c07e37126266db3fa6eea233a04a9b3e491523"
"3dd6754427cd4b71b75854077d009453ef1828eaff9e17c856d4fc1895ab60051312c3e1"
"db1e3766566438b2990cbf9945c2545619e3e0145bc6a79004",
"a2da3fae2e6da3cf11b49861afb34fba357fea89f54b35ce5ed7434ae09103fe53e2be75"
"b93fc579fedf919f6d5e407e",
"dda994b9c428b57e9f8bbaebba0d682e3aac6ed828e3a1e99a7fc4c804bff8df151137f5"
"39c7389d80e23d9f3ee497bf",
"a0d6b10ceffd0e1b29cf784476f9173ba6ecd2cfc7929725f2d6e24e0db5a4721683640e"
"aa2bbe151fb57560f9ce594b"},
{NID_secp384r1, NID_sha384,
"3b309bb912ab2a51681451ed18ad79e95d968abc35423a67036a02af92f575a0c89f1b66"
"8afe22c7037ad1199e757a8f06b281c33e9a40bab69c9874e0bb680b905d909b9dc24a9f"
"e89bb3d7f7d47082b25093c59754f8c19d1f81f30334a8cdd50a3cb72f96d4b3c305e60a"
"439a7e93aeb640dd3c8de37d63c60fb469c2d3ed",
"39bea008ec8a217866dcbdb1b93da34d1d3e851d011df9ef44b7828b3453a54aa70f1df9"
"932170804eacd207e4f7e91d",
"045709ec4305a9c3271c304face6c148142490b827a73a4c17affcfd01fffd7eaa65d2fd"
"edfa2419fc64ed910823513fafb083cda1cf3be6371b6c06e729ea6299213428db571193"
"47247ec1fcd44204386cc0bca3f452d9d864b39efbfc89d6b2",
"3c90cc7b6984056f570542a51cbe497ce4c11aeae8fc35e8fd6a0d9adeb650e8644f9d1d"
"5e4341b5adc81e27f284c08f",
"d13646895afb1bfd1953551bb922809c95ad65d6abe94eb3719c899aa1f6dba6b01222c7"
"f283900fe98628b7597b6ea6",
"4a9a38afda04c0a6b0058943b679bd02205b14d0f3d49b8f31aac289129780cdb1c555de"
"f8c3f9106b478729e0c7efaa"},
{NID_secp384r1, NID_sha384,
"f072b72b8783289463da118613c43824d11441dba364c289de03ff5fab3a6f60e85957d8"
"ff211f1cb62fa90216fb727106f692e5ae0844b11b710e5a12c69df3ed895b94e8769ecd"
"15ff433762d6e8e94d8e6a72645b213b0231344e2c968056766c5dd6b5a5df41971858b8"
"5e99afbf859400f839b42cd129068efabeea4a26",
"e849cf948b241362e3e20c458b52df044f2a72deb0f41c1bb0673e7c04cdd70811215059"
"032b5ca3cc69c345dcce4cf7",
"0406c037a0cbf43fdf335dff33de06d34348405353f9fdf2ce1361efba30fb204aea9dbd"
"2e30da0a10fd2d876188371be6360d38f3940e34679204b98fbf70b8a4d97f25443e46d0"
"807ab634ed5891ad864dd7703557aa933cd380e26eea662a43",
"32386b2593c85e877b70e5e5495936f65dc49553caef1aa6cc14d9cd370c442a0ccfab4c"
"0da9ec311b67913b1b575a9d",
"5886078d3495767e330c7507b7ca0fa07a50e59912a416d89f0ab1aa4e88153d6eaf0088"
"2d1b4aa64153153352d853b5",
"2cc10023bf1bf8ccfd14b06b82cc2114449a352389c8ff9f6f78cdc4e32bde69f3869da0"
"e17f691b329682ae7a36e1aa"},
{NID_secp384r1, NID_sha384,
"cf4945350be8133b575c4ad6c9585e0b83ff1ed17989b6cd6c71b41b5264e828b4e11599"
"5b1ae77528e7e9002ac1b5669064442645929f9d7dd70927cb93f95edeb73e8624f4bc89"
"7ec4c2c7581cb626916f29b2d6e6c2fba8c59a71e30754b459d81b912a12798182bcff40"
"19c7bdfe929cc769bcc2414befe7d2906add4271",
"d89607475d509ef23dc9f476eae4280c986de741b63560670fa2bd605f5049f1972792c0"
"413a5b3b4b34e7a38b70b7ca",
"0449a1c631f31cf5c45b2676b1f130cbf9be683d0a50dffae0d147c1e9913ab1090c6529"
"a84f47ddc7cf025921b771355a1e207eece62f2bcc6bdabc1113158145170be97469a290"
"4eaaa93aad85b86a19719207f3e423051f5b9cbbe2754eefcb",
"78613c570c8d33b7dd1bd1561d87e36282e8cf4843e7c344a2b2bb6a0da94756d670eeaf"
"fe434f7ae7c780f7cf05ca08",
"66f92b39aa3f4aeb9e2dc03ac3855406fa3ebbab0a6c88a78d7a03482f0c9868d7b78bc0"
"81ede0947c7f37bf193074ba",
"e5c64ed98d7f3701193f25dd237d59c91c0da6e26215e0889d82e6d3e416693f8d58843c"
"f30ab10ab8d0edd9170b53ad"},
{NID_secp384r1, NID_sha384,
"d9b5cf0b50416573ff3c63133275a18394dd4326be2041e8d97e6e4e3855a4a177e9d26d"
"fd223fe8aa74564edb49bd72de19916fb6f001f44530d5c18e2c332bce1b7415df5927ec"
"e5f3824f34d174b963136b53aef1fb78fb0c06a201a40b2db38e4d8216fc1e392a798c8a"
"b4b3a314496b7f1087804ebfa89bf96e9cdb80c0",
"083e7152734adf342520ae377087a223688de2899b10cfcb34a0b36bca500a4dfa530e23"
"43e6a39da7ae1eb0862b4a0d",
"0470a0f16b6c61172659b027ed19b18fd8f57bd28dc0501f207bd6b0bb065b5671cf3dd1"
"ed13d388dcf6ccc766597aa6044f845bf01c3c3f6126a7368c3454f51425801ee0b72e63"
"fb6799b4420bfdebe3e37c7246db627cc82c09654979c700bb",
"28096ababe29a075fbdf894709a20d0fdedb01ed3eeacb642a33a0da6aed726e13caf6cf"
"206792ec359f0c9f9b567552",
"ee2923f9b9999ea05b5e57f505bed5c6ba0420def42c6fa90eef7a6ef770786525546de2"
"7cdeb2f8586f8f29fb4ee67c",
"50ef923fb217c4cf65a48b94412fda430fac685f0da7bd574557c6c50f5b22e0c8354d99"
"f2c2f2c2691f252f93c7d84a"},
{NID_secp384r1, NID_sha384,
"9e4042d8438a405475b7dab1cd783eb6ce1d1bffa46ac9dfda622b23ac31057b922eced8"
"e2ed7b3241efeafd7c9ab372bf16230f7134647f2956fb793989d3c885a5ae064e85ed97"
"1b64f5f561e7ddb79d49aa6ebe727c671c67879b794554c04de0e05d68264855745ef3c9"
"567bd646d5c5f8728b797c181b6b6a876e167663",
"63578d416215aff2cc78f9b926d4c7740a77c142944e104aa7422b19a616898262d46a8a"
"942d5e8d5db135ee8b09a368",
"04cadbacef4406099316db2ce3206adc636c2bb0a835847ed7941efb02862472f3150338"
"f13f4860d47f39b7e098f0a390752ad0f22c9c264336cde11bbc95d1816ed4d1b1500db6"
"b8dce259a42832e613c31178c2c7995206a62e201ba108f570",
"7b69c5d5b4d05c9950dc94c27d58403b4c52c004b80a80418ad3a89aabc5d34f21926729"
"e76afd280cc8ee88c9805a2a",
"db054addb6161ee49c6ce2e4d646d7670754747b6737ca8516e9d1e87859937c3ef9b1d2"
"663e10d7e4bd00ec85b7a97a",
"fcc504e0f00ef29587e4bc22faada4db30e2cb1ac552680a65785ae87beb666c792513f2"
"be7a3180fc544296841a0e27"},
{NID_secp384r1, NID_sha384,
"0b14a7484a40b68a3ce1273b8a48b8fdb65ba900d98541c4bbd07b97e31bcc4c85545a03"
"e9deab3c563f47a036ff60d0361684ba241b5aa68bb46f440da22181ee328a011de98eff"
"34ba235ec10612b07bdfa6b3dc4ccc5e82d3a8d057e1862fef3def5a1804696f84699fda"
"2ec4175a54a4d08bcb4f0406fdac4eddadf5e29b",
"ed4df19971658b74868800b3b81bc877807743b25c65740f1d6377542afe2c6427612c84"
"0ada31a8eb794718f37c7283",
"0433093a0568757e8b58df5b72ea5fe5bf26e6f7aeb541b4c6a8c189c93721749bcacecc"
"f2982a2f0702586a9f812fc66febe320d09e1f0662189d50b85a20403b821ac0d000afdb"
"f66a0a33f304726c69e354d81c50b94ba3a5250efc31319cd1",
"d9b4cd1bdfa83e608289634dbfcee643f07315baf743fc91922880b55a2feda3b38ddf60"
"40d3ba10985cd1285fc690d5",
"009c74063e206a4259b53decff5445683a03f44fa67252b76bd3581081c714f882f882df"
"915e97dbeab061fa8b3cc4e7",
"d40e09d3468b46699948007e8f59845766dbf694b9c62066890dd055c0cb9a0caf0aa611"
"fb9f466ad0bbb00dbe29d7eb"},
{NID_secp384r1, NID_sha384,
"0e646c6c3cc0f9fdedef934b7195fe3837836a9f6f263968af95ef84cd035750f3cdb649"
"de745c874a6ef66b3dd83b66068b4335bc0a97184182e3965c722b3b1aee488c3620adb8"
"35a8140e199f4fc83a88b02881816b366a09316e25685217f9221157fc05b2d8d2bc8553"
"72183da7af3f0a14148a09def37a332f8eb40dc9",
"e9c7e9a79618d6ff3274da1abd0ff3ed0ec1ae3b54c3a4fd8d68d98fb04326b7633fc637"
"e0b195228d0edba6bb1468fb",
"04a39ac353ca787982c577aff1e8601ce192aa90fd0de4c0ed627f66a8b6f02ae5131554"
"3f72ffc1c48a7269b25e7c289a9064a507b66b340b6e0e0d5ffaa67dd20e6dafc0ea6a6f"
"aee1635177af256f9108a22e9edf736ab4ae8e96dc207b1fa9",
"b094cb3a5c1440cfab9dc56d0ec2eff00f2110dea203654c70757254aa5912a7e73972e6"
"07459b1f4861e0b08a5cc763",
"ee82c0f90501136eb0dc0e459ad17bf3be1b1c8b8d05c60068a9306a346326ff7344776a"
"95f1f7e2e2cf9477130e735c",
"af10b90f203af23b7500e070536e64629ba19245d6ef39aab57fcdb1b73c4c6bf7070c62"
"63544633d3d358c12a178138"},
{NID_secp384r1, NID_sha512,
"67d9eb88f289454d61def4764d1573db49b875cfb11e139d7eacc4b7a79d3db3bf720819"
"1b2b2078cbbcc974ec0da1ed5e0c10ec37f6181bf81c0f32972a125df64e3b3e1d838ec7"
"da8dfe0b7fcc911e43159a79c73df5fa252b98790be511d8a732fcbf011aacc7d45d8027"
"d50a347703d613ceda09f650c6104c9459537c8f",
"217afba406d8ab32ee07b0f27eef789fc201d121ffab76c8fbe3c2d352c594909abe591c"
"6f86233992362c9d631baf7c",
"04fb937e4a303617b71b6c1a25f2ac786087328a3e26bdef55e52d46ab5e69e5411bf9fc"
"55f5df9994d2bf82e8f39a153ea97d9075e92fa5bfe67e6ec18e21cc4d11fde59a68aef7"
"2c0e46a28f31a9d60385f41f39da468f4e6c3d3fbac9046765",
"90338a7f6ffce541366ca2987c3b3ca527992d1efcf1dd2723fbd241a24cff19990f2af5"
"fd6419ed2104b4a59b5ae631",
"c269d9c4619aafdf5f4b3100211dddb14693abe25551e04f9499c91152a296d7449c08b3"
"6f87d1e16e8e15fee4a7f5c8",
"77ffed5c61665152d52161dc13ac3fbae5786928a3d736f42d34a9e4d6d4a70a02d5af90"
"fa37a23a318902ae2656c071"},
{NID_secp384r1, NID_sha512,
"45db86829c363c80160659e3c5c7d7971abb1f6f0d495709bba908d7aa99c9df64b3408a"
"51bd69aba8870e2aaff488ef138f3123cf94391d081f357e21906a4e2f311defe527c55e"
"0231579957c51def507f835cceb466eb2593a509dcbee2f09e0dde6693b2bfe17697c9e8"
"6dd672f5797339cbe9ea8a7c6309b061eca7aef5",
"0a3f45a28a355381a919372f60320d6610cfb69c3e318eb1607db3cadfc42b728b77a6a9"
"e9e333de9183c58933daf60f",
"04832cbb7061a719a316e73dbad348fa67cd17c33f40b9000a3d3b691a2a2cd821052566"
"717c3ead01089b56086af1366f1e15a048d1dce642d9ebcbfac7f92b1bcee90fd0240cc7"
"9abd29e32e0e655c4ee1fd34fb88178bba92aca100e7794ed0",
"2a78e651623ba604c42cf094fc7d046629306f508853427ba091448800d1092c041bb232"
"3035fc9d19a8d44950f7dcc3",
"0db0cc9a2bda8dd7e565ad36f91b1c5756d78164dc8a72a5bee4b6bc45ea38c7a16b01d0"
"5b1893d4e06b62db24c30385",
"abd383edaeda7d0b8de1b54fcd3c28874fed62ab266f1f84c8ba796a7b54e5e0695fdb43"
"ce7fe90ed00fa468d87bca64"},
{NID_secp384r1, NID_sha512,
"4672fce0721d37c5be166bffa4b30d753bcf104b9b414db994b3ed33f36af4935ea59a0b"
"b92db66448b3f57dad4fc67cef10ce141bf82c536be604b89a0bc0e8bca605b867880049"
"d97142d30538fc543bd9d4fab7fdbe2f703815cdb6361beb66acff764bc275f910d16624"
"45b07b92830db69a5994857f53657ed5ca282648",
"2e408c57921939f0e0fe2e80ce74a4fa4a1b4fa7ab070206298fe894d655be50e2583af9"
"e45544b5d69c73dce8a2c8e7",
"04a2b24a5ad4a2e91f12199ed7699e3f297e27bf8b8ea8fbe7ed28366f3544cd8e680c23"
"8450f8a6422b40829d6647b25c2732be0075536e6519f6a099b975a40f8e0de337fa4d48"
"bd0762b43f41cab8deafdef9cfbb9973e457801e3bf9c93304",
"b10b6258afdde81f9c971cc1526d942e20cafac02f59fee10f98e99b8674636bff1d84a6"
"eaa49c0de8d8cfdc90d8ce84",
"be428a8de89a364a134719141ee8d776a3a8338f1132b07e01b28573d8eaf3b9008b6330"
"4c48821e53638b6141f9660b",
"866181dbef5c147d391bed6adcee408c339982c307adc718c2b9ab9e5642d8dedc36dd64"
"02559a3ab614c99c1e56b529"},
{NID_secp384r1, NID_sha512,
"9ae48fdd9bfc5cb0f4d4761e28b2073bda05a3e3fe82c212e66701dc4573cc67a829b0f8"
"2d7520b1bf11db0c6d1743822bbe41bb0adbd7222aa5fae70fbd1a31f2d4453a01c81e06"
"4d775388468be96f6063f8673b7b8d4455fe1bd4c801ad5e625a015eaa4a1a18da490d2a"
"f8642201eaba3c611cbd65f861d8e19ca82a1ee6",
"1c285da72a8eb1c3c38faab8d3bb4e68dc95c797082b9a3991a21c1de54759071ecf2265"
"fb1eff504ab24174bc6710cf",
"0411acb1b5cc59a4f1df1913a8d6e91cbdafb8206dc44aff7d9da45906b664fc33194d99"
"35a82aa4d62f39618897c86025832ed0b9575fff52a3603bfe89f312751b4c396da98324"
"117a61b3f525d27b2266f6cfb22be07e50b6874435e380ed62",
"2513075e02cc7fb3cff7b7adde46da31c5493749b5cf02758bd5b098a838bfd4d5e4c7fb"
"8268bdc37e219c30efebe878",
"b3d638b3be45f14f170da5bdc22d2114deac93ab340a25b3af2b5c18584bb9147e00dc6c"
"67a2274f79aa4838793eb63f",
"876112bdca2c725eb2f6dbd76d07710a31f0c16d38430cb0817f320a25a9ecfec8a66137"
"d0304612ae29a6a484fd3319"},
{NID_secp384r1, NID_sha512,
"817d6a110a8fd0ca7b4d565558f68b59a156744d4c5aac5c6610c95451793de2a756f774"
"558c61d21818d3ebeeeb71d132da1c23a02f4b305eccc5cd46bd21dfc173a8a91098354f"
"10ffbb21bf63d9f4c3feb231c736504549a78fd76d39f3ad35c36178f5c233742d2917d5"
"611d2073124845f1e3615b2ef25199a7a547e882",
"9da37e104938019fbdcf247e3df879a282c45f8fb57e6655e36b47723af42bec3b820f66"
"0436deb3de123a21de0ca37b",
"04722d0ea6891d509b18b85ca56f74deb5c3030d2a30433824123d430d03c99279572c3b"
"28ecf01e747b9db8acc55d0ba37e2605ea7092214f366f3639037bffd89fe103c646e990"
"839d3a1ced8d78edb5b9bc60d834fd8e2a3c17e920bdae023a",
"c8c18e53a9aa5915288c33132bd09323638f7995cd89162073984ed84e72e07a37e18c4c"
"023933eace92c35d10e6b1b6",
"6512a8a2be731e301dcf4803764297862bbfa0ac8daed64d8e98b34618ecb20520fc5d3c"
"f890b7783edf86e7ea407541",
"4ff10301f7b4168fae066361376007c1d7aa89a75c87719d0b54711ffef5ef3726f3eef8"
"4f7ebc025c110bde511b17f6"},
{NID_secp384r1, NID_sha512,
"464f10ec6fb229a51db5fd0e122f2cb8a9a022117e2987f4007bf5565b2c16aba0714e2e"
"3cdd0c100d55ac3017e36fc7501ad8309ab9572aa65424c9eb2e580a119c55777676ec49"
"8df53ef6ae78fd8a988130ee0e6082bf1ef71cd4c946021018a8ca7154d13b174c638912"
"613b0bdb9001c302bf7e443ad2124ab2c1cce212",
"0661ab3bf9f7bef51bec7dff758de289154557beb9ce18cc4b8cc09a871e8322af259cf1"
"88b593dc62f03a19e75f7f69",
"04b4f100558043858efa728082d9b99ad5192b59b0947434f5ba7ff2514508a6d71ba54e"
"7221c31cb0712103272b3f6fa434f6df4eeb2da11498044635067c2715ed15ae251c78ff"
"b9030d87909ea8539b66394e93109ca54c0406cf99960c3e93",
"84a87137edb6894f96c5a8e94a3765162034feb84dfea94e1c71411170c285a80321ec79"
"99e25861844143209804882c",
"4dc9d1b949b36e3c3847ac1c7ed114e1bc9cbe76119cf6fcd3f1b69ee6ee54e3255f1bb2"
"88fe2f8bd6d4049a21793c27",
"56a561d647b62ccae1e6df818b1a6fbde66c82ef0ff69ee415f183e7daf76be22630c7e0"
"2cd3fd729dfa490f26824584"},
{NID_secp384r1, NID_sha512,
"4e3e0fb96320ddccde8b463c273654c4f7164920b1d63430921d2e808dee403e6420eedd"
"a0a557b911d00736a4f8798dd4ef26673efd6d190988ad4929ec64f8685cfb76070a36cd"
"6a3a4bf2f54fb08a349d44642b6f614043fef9b2813b63457c76537d23da7b37310334f7"
"ba76edf1999dad86f72aa3446445a65952ac4e50",
"66e7cfdeb7f264cf786e35210f458c32223c3a12a3bc4b63d53a5776bc9b069928452484"
"f6241caa3781fd1a4109d4db",
"043c7682de540ab231daf21bf9fc80bda6abf7e17dcc79d476c7b7c3bd4d42d386877fd8"
"ba495c1b0333e04fb5fd2a15050a1582e4f4d72abea9d3476aff8369c41261f0c5dddf2c"
"a82e10f7a163f73df09473d9e5e2552187104e4cc7c6d83611",
"2fa266f5cce190eb77614933ca6a55121ad8bae168ff7a9043d96d13b5ca2fe70101ff9f"
"e1e2b2cd7413e6aa8f49abde",
"e7ecda9da0c52d0474a9f70094dc8f061d7d6a22210d3b69a7be8f389aa666f256322099"
"b87d16ad35357ea856574dba",
"ba348eb40a2830ec5a1130264ac0a8675420b1ae243e808a778135809ece21f42c0c8811"
"66321102b4f02df4c5c7ed9d"},
{NID_secp384r1, NID_sha512,
"c466b6b6baf7e6ffa876ec06105e2d43534e0517c07b1c4c9fb67ba81ce09525a7721ec3"
"c290f2b1f65b6463d41598e7a25b2238501629953a5ca955b644354fb6856733a2e5bb8f"
"5bc21a0c803493f5539f9fb83aab3dba2c982989c2270c61ab244b68bfe1b948d00c2ed9"
"75e09c29b5f8a7effcad8652a148cc880d503217",
"92c2f7ee64af86d003ab484e12b82fcf245fc330761057fec5b7af8f7e0a2d85b468c21d"
"171460fcb829cae7b986316d",
"04ca43a306479bf8fb537d4b9ff9d635bbb2a0d60d9e854d5b7e269d09d91f78c6b90b61"
"6e4c931629453645a2bb371e14356c4d7f10e690614eaf7f82ba0f9dc1aad98130c0ad9f"
"e353deec565cc04bef789a0a4242322e0058b46cd02f2de77d",
"6ec81fb74f8725ba225f317264460ee300cfd2f02092000989acbdad4799cf55c244a65c"
"557113328fe20282e6badb55",
"cd7a4309bcebc25a8e10899fe2eda5f8b2dbcf329cd2f3d65befd67393e83fba2f8a67a1"
"5c01a6ac8314f9f5e87a9dca",
"6dcfc0426bc148e67e91d4784e3d7e9bc3b7ce3676be62daa7f3f55dfdff6d9dc735b5e3"
"e0bbd0785db1f76f7ac065f3"},
{NID_secp384r1, NID_sha512,
"feac892b7720af80b3c9eede51e923f18d3d0c5de4c31f4aa75e36df7c7c2fd8f4177885"
"1a24b69e67dccb65e159dd5c383243bad7cfedcc5e85c8a01c34b0b94ba8e07e4c024c09"
"d279b3731e8b62f9562d3c4f5042567efe42a9d0eaaabab28bc6f11232fc8ceaaf4518d9"
"f3b2bebf020294496b7f6b879e69503f75fecd3d",
"15347caaad1067f1848a676bd0a8c52021ae604b79d02775a0459226e0391a3acd26653c"
"916fcfe86149fb0ee0904476",
"04e5a0463163964d984f5bad0072d45bc2059939e60a826ccca36c151460ae360f5d6679"
"f60fe43e999b6da5841c96e48a30f2dd425a3fa2c95d34124217250b39e3b4a14f3e6e41"
"5ae8e5b0409eb72f43f78b64d0ce6f2d49980d6f04cd1391db",
"1a2d224db4bb9c241ca5cab18920fad615fa25c1db0de0f024cb3ace0d11ef72b0568854"
"46659f67650fdff692517b1c",
"87b4de0fb21df38dfc9a4b1e350da67547e307f55b5b9dd6615e408afe7c3553a6e02722"
"847367439e636074faa2182b",
"375d965753b9ed6c6c08576726f8308c2f8dbd2737824464e71265d47907e26f615bbeb8"
"203ec617520d4ecd1851dc44"},
{NID_secp384r1, NID_sha512,
"cf2982e3bf174ce547741b969403cd11e9553067e6af8177d89511a0eb040db924530bdb"
"a65d8b1ff714228db0737c1756f509e1506014a10736e65be2f91980a73891496e90ff27"
"14a3601c7565cdcef5a395e2e0e1652f138d90d61eaa9cba993b823245647f6e07cec9b8"
"b4449cd68a29741cd1579c66e548ca0d0acf33aa",
"ac1cb5e59bda2eff3413a3bab80308f9fb32c595283c795de4c17fdae8d4647b5f108fd0"
"801aee22adb7db129283b5aa",
"04bc6b1a718284803553c173089c397870aaaecca579bb8e81a8cfa12473cd2057567fa8"
"726a19ed427cc035baeec2c55114f82997d1129b669f0015350e47ad561b1b13441af4fb"
"44656f15ed0c5706984d66655accc52f2e943eef39cb1cdc21",
"8053a46e875f446056b06d4318fa3e8977622de7207cbf0996bf35b0e9b19aaa507f642b"
"cf0be9f048f1af09806f6946",
"a994eb15b64114ce8a9342d18b5edda96a6d76314a5ac03da723699177d352a4a9f3b712"
"1b11a91e43a6af4025da51d6",
"8183ae33a888e99aa76882da0a6705ad102f2bbd9572fad0d2e4d6d70151970469e00c52"
"20e59c14724d771c1384b302"},
{NID_secp384r1, NID_sha512,
"bf9fdd4107ef5a6070108771ac9eee4f0c8043bf0d04db772a47294f4137e2439d94b337"
"114b074e57e0cb78d0ccf352a2833e9788ee2a1a9ffeacd34f38fcefb86653d70c7dadd4"
"cf6548d608e70acdef6c7530974b92c813798add659752a8c72b05e1ad9c65c21834ce6f"
"be49d8a1426b5a54270794436d284364fac6ec1a",
"205f1eb3dfacff2bdd8590e43e613b92512d6a415c5951bda7a6c37db3aae39b9b7ec6ed"
"d256609e75373419087fa71f",
"04c9f1f63a18c761b077a1ec35fbb2de635db9b8592c36194a01769b57728c7755d4c79b"
"3d5b97a1a4631e30c86d03f13cf8c4a38770054d5cc9bb9182e6d4638242c4fd16e869ac"
"22e44c4b9402d594e0c6f5df6a9a7de32a4893d9f6588f1950",
"ecd395c5d8b7d6e6b2b19644e0d2e6086c912c6a0f5b8ed4b94b7290b65852c9741ce8ee"
"b08d8751ead8a183e17d76c6",
"e81331d78b438b0b8d98c1be03385ba5d614af182f1677f259126cc3de7eaac6c19b02be"
"955d936b6bf9c27c6796e6f0",
"17c2b7a8e0fc93909762aa9f86f9561e759ecb88f02337b2018363be6095d9e4324a6d32"
"96046686624b5efad6b52878"},
{NID_secp384r1, NID_sha512,
"5d634fb39a2239256107dc68db19751540b4badac9ecf2fce644724401d6d632b3ae3b2e"
"6d05746b77ddc0c899878032248c263eda08d3d004d35952ad7a9cfe19343d14b37f9f63"
"2245e7b7b5fae3cb31c5231f82b9f1884f2de7578fbf156c430257031ba97bc6579843bc"
"7f59fcb9a6449a4cd942dffa6adb929cf219f0ad",
"e21e3a739e7ded418df5d3e7bc2c4ae8da76266a1fc4c89e5b09923db80a72217f1e9615"
"8031be42914cf3ee725748c1",
"040f753171922b5334f3dd2778a64ce2da8295121939beae71ad85e5344e893be0fd03cf"
"14e1f031adec098e0c4409449c45c10a0ffc0eb2f1cec5c89b698061108313ee7d449ad5"
"80efad344f0e7cf35be8a18fca620f112e57bdc746abdace55",
"d06bea06b25e6c30e866b1eb0657b45673e37b709013fb28fd7373afc8277cbc861354f8"
"21d0bd1927e52ec083a0f41f",
"e8d4a31dd0e7d2522be62a32608e744c3775ceb606dc897899f0c73f1a40ce9a8be854cd"
"506e65cd81fd7fa2c616cb7b",
"8151b681b6b6046d3c36f332d06d9ba7751e740631cdb759f88c50a25a8e950d5023df8a"
"15c77243743733c4feaf21d5"},
{NID_secp384r1, NID_sha512,
"c9b4ff721b3e886f0dc05856ffff0aabb64a8504b1746a47fdd73e6b7ebc068f06ac7ffa"
"44c757e4de207fc3cbfaf0469d3ac6795d40630bcafe8c658627e4bc6b86fd6a2135afbc"
"18ccc8e6d0e1e86016930ca92edc5aa3fbe2c57de136d0ea5f41642b6a5d0ddeb380f245"
"4d76a16639d663687f2a2e29fb9304243900d26d",
"93434d3c03ec1da8510b74902c3b3e0cb9e8d7dccad37594d28b93e065b468d9af4892a0"
"3763a63eae060c769119c23c",
"04a52c25f2af70e5bc6a992ecef4ea54e831ed5b9453747d28aec5cffb2fcfee05be80c5"
"cbab21606b5507aa23878adee12cf2a9afeff83f3041dc8a05f016ccae58aa1a0e0dc6be"
"9d928e97f2598c9ba5e9718d5eb74c9cfb516fd8c09f55f5b9",
"13d047708ae5228d6e3bbada0e385afdb3b735b31123454fdf40afe3c36efed563fd2cce"
"84dcc45c553b0993d9ca9ec3",
"a0203f6f2c456baac03538ed506a182e57a25151802cf4b2557613b2fb615ebd4c50ddc5"
"05f87c048a45bad3b2fc371c",
"0eab56457c4080400fa3af124761d5a01fef35f9649edba8b97d22116386f3b8b363e97e"
"f3f82616d5d825df1cf865ef"},
{NID_secp384r1, NID_sha512,
"db2ad659cf21bc9c1f7e6469c5f262b73261d49f7b1755fc137636e8ce0202f929dca446"
"6c422284c10be8f351f36333ebc04b1888cba217c0fec872b2dfc3aa0d544e5e06a9518a"
"8cfe3df5b20fbcb14a9bf218e3bf6a8e024530a17bab50906be34d9f9bba69af0b11d8ed"
"426b9ec75c3bd1f2e5b8756e4a72ff846bc9e498",
"e36339ddbe8787062a9bc4e1540690915dd2a2f11b3fe9ee946e281a0a2cbed426df405e"
"d9cb0eca42f85443efd09e0c",
"04a1ffb4b790d1593e907369b69de10b93cddbb02c6131f787422364d9d692768ef80979"
"70306cce16c97f2b10c538efa7d0692028601ea794d2563ffe9facc7273938fab47dd00b"
"8960be15549a9c2b3f8552583eb4c6cd212fe486c159c79153",
"2226f7329378cecd697f36ae151546643d67760856854661e31d424fae662da910e2157d"
"a9bb6dfbe3622296e0b5710c",
"20dcc25b67dd997621f437f65d78347fb57f8295b1b14453b1128203cda892bcfe726a2f"
"107d30975d63172e56f11d76",
"51cff592cbef75ef8321c8fa1e4229c4298b8180e427bee4e91d1e24fc28a729cf296beb"
"728960d2a58cf26773d8e2e2"},
{NID_secp384r1, NID_sha512,
"dbd8ddc02771a5ff7359d5216536b2e524a2d0b6ff180fa29a41a8847b6f45f1b1d52344"
"d32aea62a23ea3d8584deaaea38ee92d1314fdb4fbbecdad27ac810f02de0452332939f6"
"44aa9fe526d313cea81b9c3f6a8dbbeafc899d0cdaeb1dca05160a8a039662c4c845a3db"
"b07be2bc8c9150e344103e404411668c48aa7792",
"5da87be7af63fdaf40662bd2ba87597f54d7d52fae4b298308956cddbe5664f1e3c48cc6"
"fd3c99291b0ce7a62a99a855",
"0454c79da7f8faeeee6f3a1fdc664e405d5c0fb3b904715f3a9d89d6fda7eabe6cee86ef"
"82c19fca0d1a29e09c1acfcf18926c17d68778eb066c2078cdb688b17399e54bde5a79ef"
"1852352a58967dff02c17a792d39f95c76d146fdc086fe26b0",
"1b686b45a31b31f6de9ed5362e18a3f8c8feded3d3b251b134835843b7ae8ede57c61dc6"
"1a30993123ac7699de4b6eac",
"9dbfa147375767dde81b014f1e3bf579c44dd22486998a9b6f9e0920e53faa11eed29a4e"
"2356e393afd1f5c1b060a958",
"e4d318391f7cbfe70da78908d42db85225c85f4f2ff413ecad50aad5833abe91bdd5f6d6"
"4b0cd281398eab19452087dd"},
{NID_secp521r1, NID_sha224,
"58ec2b2ceb80207ff51b17688bd5850f9388ce0b4a4f7316f5af6f52cfc4dde4192b6dbd"
"97b56f93d1e4073517ac6c6140429b5484e266d07127e28b8e613ddf65888cbd5242b2f0"
"eee4d5754eb11f25dfa5c3f87c790de371856c882731a157083a00d8eae29a57884dbbfc"
"d98922c12cf5d73066daabe3bf3f42cfbdb9d853",
"1d7bb864c5b5ecae019296cf9b5c63a166f5f1113942819b1933d889a96d12245777a994"
"28f93de4fc9a18d709bf91889d7f8dddd522b4c364aeae13c983e9fae46",
"0401a7596d38aac7868327ddc1ef5e8178cf052b7ebc512828e8a45955d85bef49494d15"
"278198bbcc5454358c12a2af9a3874e7002e1a2f02fcb36ff3e3b4bc0c69e70184902e51"
"5982bb225b8c84f245e61b327c08e94d41c07d0b4101a963e02fe52f6a9f33e8b1de2394"
"e0cb74c40790b4e489b5500e6804cabed0fe8c192443d4027b",
"141f679033b27ec29219afd8aa123d5e535c227badbe2c86ff6eafa5116e9778000f5385"
"79a80ca4739b1675b8ff8b6245347852aa524fe9aad781f9b672e0bb3ff",
"06b973a638bde22d8c1c0d804d94e40538526093705f92c0c4dac2c72e7db013a9c89ffc"
"5b12a396886305ddf0cbaa7f10cdd4cd8866334c8abfc800e5cca365391",
"0b0a01eca07a3964dd27d9ba6f3750615ea36434979dc73e153cd8ed1dbcde2885ead575"
"7ebcabba117a64fcff9b5085d848f107f0c9ecc83dfa2fa09ada3503028"},
{NID_secp521r1, NID_sha224,
"2449a53e0581f1b56d1e463b1c1686d33b3491efe1f3cc0443ba05d65694597cc7a2595b"
"da9cae939166eb03cec624a788c9bbab69a39fb6554649131a56b26295683d8ac1aea969"
"040413df405325425146c1e3a138d2f4f772ae2ed917cc36465acd66150058622440d7e7"
"7b3ad621e1c43a3f277da88d850d608079d9b911",
"17e49b8ea8f9d1b7c0378e378a7a42e68e12cf78779ed41dcd29a090ae7e0f883b0d0f2c"
"bc8f0473c0ad6732bea40d371a7f363bc6537d075bd1a4c23e558b0bc73",
"0400156cd2c485012ea5d5aadad724fb87558637de37b34485c4cf7c8cbc3e4f106cb1ef"
"d3e64f0adf99ddb51e3ac991bdd90785172386cdaf2c582cc46d6c99b0fed101edeeda71"
"7554252b9f1e13553d4af028ec9e158dbe12332684fc1676dc731f39138a5d301376505a"
"9ab04d562cc1659b0be9cb2b5e03bad8b412f2699c245b0ba2",
"1dc3e60a788caa5f62cb079f332d7e5c918974643dca3ab3566a599642cd84964fbef43c"
"e94290041fe3d2c8c26104d9c73a57a7d4724613242531083b49e255f33",
"12592c0be6cce18efb2b972cd193d036dcb850f2390fa8b9b86b2f876548bc424fb3bc13"
"c1e5c415fa09d0ecfcae5bf76fb23e8322d7eecb264a2ae6d20ef50d405",
"11bc9713be88e3b9912a3e5f5d7b56f20573e979b1a75d04ce339f724bddffa4665d2599"
"5fe24d32507d8a07c5e10169f5338ef2827737f7b0291752b21237217e3"},
{NID_secp521r1, NID_sha224,
"7ba05797b5b67e1adfafb7fae20c0c0abe1543c94cee92d5021e1abc57720a6107999c70"
"eacf3d4a79702cd4e6885fa1b7155398ac729d1ed6b45e51fe114c46caf444b20b406ad9"
"cde6b9b2687aa645b46b51ab790b67047219e7290df1a797f35949aaf912a0a8556bb210"
"18e7f70427c0fc018e461755378b981d0d9df3a9",
"135ea346852f837d10c1b2dfb8012ae8215801a7e85d4446dadd993c68d1e9206e1d8651"
"b7ed763b95f707a52410eeef4f21ae9429828289eaea1fd9caadf826ace",
"04018d40cc4573892b3e467d314c39c95615ee0510e3e4dbc9fa28f6cd1f73e7acde15ad"
"7c8c5339df9a7774f8155130e7d1f8de9139ddd6dfe1841c1e64c38ea98243017021782d"
"33dc513716c83afe7ba5e7abef9cb25b31f483661115b8d6b5ae469aaf6f3d54baa3b658"
"a9af9b6249fd4d5ea7a07cb8b600f1df72b81dac614cfc384a",
"0c24acc1edb3777212e5b0bac744eadf4eda11fa150753b355bf96b189e6f57fc02284bb"
"22d8b3cd8bba7a09aae9f4ea955b382063425a6f8da2f99b9647b147172",
"183da7b8a9f9d5f08903359c1a2435b085fcf26a2ed09ab71357bb7634054acc569535e6"
"fe81d28233e4703005fc4bf83ce794d9463d575795aa0f03398e854cefd",
"0b3621145b9866ab7809139795cc30cd0404127a7f0fafa793660491009f6c53724fdb0b"
"1ffbf0fd51c131180b8a957fe66e76d2970247c024261c768dee9abbfb9"},
{NID_secp521r1, NID_sha224,
"716dabdb22a1c854ec60420249905a1d7ca68dd573efaff7542e76f0eae54a1828db69a3"
"9a1206cd05e10e681f24881b131e042ed9e19f5995c253840e937b809dfb8027fed71d54"
"1860f318691c13a2eb514daa5889410f256305f3b5b47cc16f7a7dad6359589b5f4568de"
"4c4aae2357a8ea5e0ebaa5b89063eb3aa44eb952",
"1393cb1ee9bfd7f7b9c057ecc66b43e807e12515f66ed7e9c9210ba1514693965988e567"
"fbad7c3f17231aacee0e9b9a4b1940504b1cd4fd5edfaa62ba4e3e476fc",
"0401e855c935139c8092092cfa733db1292530506eeb2bbb1687f9602c36d97a6714e998"
"892d5d3b842d1896a6ece9d549e9792881a256256137b3dff180c96cc5d07b018d83b6e9"
"3cd287311f7bf7c1d7f9eeabcf0b69c12f2d8f40e333e81e956d968532a37a4c04d76187"
"4df293b484cd7053b03fdbc2fdcd3b4c412d6f272fb7c93fe6",
"1d98619bdc04735d30c222fc67da82c069aea5f449af5e8c4db10c1786c0cb9e6f2cc0bb"
"66fa6be18c485570d648dafcd0a973c43d5c94e9a9dacbd3170e53fa2a0",
"0bf47fabe107ce0ec03e2ad60a79b058e1bebb18568b6a8cdbe86032e71aa30c15766105"
"b2ea952cfa79bcab046df601159f96e179bbcf252dc68ac73d31481fdae",
"1f918fec69cd07d90f9d892b7117e7519c3224947f4262f1fd97077dd5386a6c78aeddff"
"3ee97e59ea353f06029f1336f0d6ef5c0f4b17ca59343a55319b7bfc3db"},
{NID_secp521r1, NID_sha224,
"9cc9c2f131fe3ac7ea91ae6d832c7788cbbf34f68e839269c336ceef7bef6f20c0a62ea8"
"cc340a333a3002145d07eba4cf4026a0c4b26b0217a0046701de92d573d7c87a386a1ea6"
"8dc80525b7dcc9be41b451ad9f3d16819e2a0a0b5a0c56736da3709e64761f97cae2399d"
"e2a4022dc4c3d73c7a1735c36dbde86c4bc5b6f7",
"179fa164e051c5851e8a37d82c181e809a05fea9a3f083299b22684f59aa27e40dc5a33b"
"3f7949338764d46bfe1f355134750518b856d98d9167ef07aac3092c549",
"0401857cc7bbed20e87b3fd9a104956aa20c6502192910e0e7598410526ebfe1c99397b8"
"5189612a60c51fb8f4dd5cb08a8cd2e702563062dcb043410715c5323a004601fce8d135"
"284310d2f38c216030634b32cd223222f0d9d8d2b7c55477c4b8b74fc6c96a6092f34b05"
"ca44d3633a5037c2166c479a032bb4f949f89fc1ba5236d07d",
"16d9704c0cee791f2938bb2a8a595752a3635c2f557efeecefd719414b5f2aaf846080f5"
"82c76eae7a8fddf81859b49d0131c212524d55defa67dca1a9a28ca400f",
"1c9a4e51774384e8362876a87c572e6463a54413c7c6252c552ebb182f83e45ace436ade"
"4ca373d8a7216e83efb62c8b41c4d5132a0afa65078f16d189baca39187",
"1e92a7dd5fea29a666398e1df5775cbb5664fe6943fe4c1d2bba516b7543c84df584458e"
"53919c4ffab579a26fb3c892a5d1a77b0a07428c89350f8b559e627b014"},
{NID_secp521r1, NID_sha224,
"14c69f8d660f7a6b37b13a6d9788eff16311b67598ab8368039ea1d9146e54f55a83b3d1"
"3d7ac9652135933c68fafd993a582253be0deea282d86046c2fb6fd3a7b2c80874ced28d"
"8bed791bd4134c796bb7baf195bdd0dc6fa03fdb7f98755ca063fb1349e56fd0375cf947"
"74df4203b34495404ebb86f1c7875b85174c574c",
"13dabca37130ba278eae2b3d106b5407711b0d3b437fbf1c952f0773571570764d2c7cb8"
"896a8815f3f1975b21adc6697898e5c0a4242092fc1b80db819a4702df4",
"0400bc2aebf40cd435bc37d73c09d05f2fd71321111a767c2b0d446f90dd4a186839c694"
"ceb734e027e7ee948f0f63e4d3f1656d3d543df23c342a599306909b34710901f4c98ac0"
"3f0718e58d5d1762c920445b11dbdd60ec7f60095809204e14965a4ecb0be6fea06adbac"
"8ba431d6f144c75c199225df2a619a34be99897125b3a10af8",
"0401187c8b89945a1e48cda9ee52167789f4121e67482a7ac797899f5d3d2e623aed31e4"
"adae08a8d43e69028fa074d2650317cbc765f6ed191cf0317b4bae57881",
"1e572afed754016fba43fc33e352932c4db65efcb84e2bd159b40fc5925893b161effc40"
"240be28d8c07154d2615f605c6f0451b976522d95afd37f46602df7a12a",
"030370c1c5352c2b663ac1858b42f69545b2f58ed5b2c007f303726977d3c756b5d644ec"
"6788f94c886f78269aa190a3d8d1ae10e4fd24d937c4556fb9e1953fd6d"},
{NID_secp521r1, NID_sha224,
"8d8e75df200c177dbfe61be61567b82177ea5ec58e2781168d2277d2fd42668f01248ca3"
"eb29ffa2689b12ae40f9c429532b6d2e1f15891322b825a0a072a1c68fa09e78cfdef3e9"
"5ed6fdf7233a43cb68236560d49a3278f0b3f47cb08f475bd9ab2f60755ea4a1767de931"
"3b71a1b9ea87ef33f34682efbda263b0f8cc2f52",
"198681adbde7840d7ccd9cf1fb82056433fb4dd26bddf909af7b3b99da1ca2c05c8d4560"
"ecd80ba68f376f8b487897e374e99a9288ed7e3645cc0d00a478aae8d16",
"040057ce3777af7032f1f82308682e71fe09f88bf29dacd5018a725e1caa4b1e2bfdd894"
"fe618f9266f31ba089856dc9c1b70e4a2faa08b4b744d1aafcd5ae99e2c7360199bcfef2"
"021bc5890d7d39ec5dc0c26956801e84cae742cf6c50386eb289b6e97754dd25a94abf81"
"f1cb1b36935b5eb29f4b32a6516d2ff6a7d23064a0daec94b3",
"19d2d74ad8ee2d85048f386998a71899ef6c960b4ab324e5fd1c0a076c5a632fd0009500"
"076522e052c5c9806eef7056da48df6b16eb71cdf0f1838b0e21715fce0",
"18ecacbcffd5414bbb96728e5f2d4c90178e27733d13617e134ec788022db124374bbaa1"
"1e2c77fe3f38d1af6e998e1b0266b77380984c423e80ffa6ff2bcafd57a",
"1c727f34b6a378f3087721a54e9796499b597ecf6666b8f18312d67e1190a8a66e878efc"
"2367b551267494e0245979ef4deed6d2cbf2c3711af6d82ccfeb101a377"},
{NID_secp521r1, NID_sha224,
"10631c3d438870f311c905e569a58e56d20a2a560e857f0f9bac2bb7233ec40c79de1452"
"94da0937e6b5e5c34fff4e6270823e5c8553c07d4adf25f614845b2eac731c5773ebbd71"
"6ab45698d156d043859945de57473389954d223522fbafecf560b07ef9ba861bcc1df9a7"
"a89cdd6debf4cd9bf2cf28c193393569ccbd0398",
"08c4c0fd9696d86e99a6c1c32349a89a0b0c8384f2829d1281730d4e9af1df1ad5a0bcfc"
"cc6a03a703b210defd5d49a6fb82536f88b885776f0f7861c6fc010ef37",
"040164ac88ed9afe137f648dd89cdd9956682830cac5f7c1a06d19a1b19f82bb1d22dfee"
"fea30d35c11202fed93fd5ce64835d27c6564d6e181287fa04a2d20994986b005cb83669"
"265f5380ccefe6b4f85fdf0049e6703f6f378a0b2e52ed0fbbcf300afebb722f4ed48e38"
"19cb976c1d60e2ba05646b478f6dfecfbae730e9644c297f00",
"189801432cba9bf8c0763d43b6ec3b8636e62324587a4e27905b09a58e4aa66d07d096db"
"ce87824e837be1c243dd741f983c535a5dd2f077aac8beee9918258d3cb",
"0917723f7241e8dc7cd746b699ab621d068dd3a90e906aaf0a4862744b96fd4e5ccdb9c7"
"796c27f7196e693d06ec209464c3ea60ad6313e9b77cceaa14767e6651c",
"0957b0ecdc3668f6efa5d0957615bcfffd6419c5e57579b74f960f65ae3fb9e8284322ff"
"710b066f7e0959ac926d3cf9a594bdb70bbec756c96910b26a2486dee9e"},
{NID_secp521r1, NID_sha224,
"80aad6d696cbe654faa0d0a24d2f50d46e4f00a1b488ea1a98ed06c44d1d0c568beb4ab3"
"674fc2b1d2d3da1053f28940e89ba1244899e8515cabdd66e99a77df31e90d93e37a8a24"
"0e803a998209988fc829e239150da058a300489e33bf3dcdaf7d06069e74569fee77f4e3"
"875d0a713ccd2b7e9d7be62b34b6e375e84209ef",
"1466d14f8fbe25544b209c5e6a000b771ef107867e28ed489a42015119d1aa64bff51d6b"
"7a0ac88673bbc3618c917561cff4a41cdb7c2833dab5ebb9d0ddf2ca256",
"0401dc8b71d55700573a26af6698b92b66180cf43e153edadb720780321dbb4e71d28e0a"
"488e4201d207fc4848fe9dd10dcabec44492656a3ff7a665fe932445c82d0b01920b1633"
"1b7abeb3db883a31288ef66f80b7728b008b3cc33e03a68f68d9e653a86e3177bbc00014"
"fa5ea4c1608c0d455c2e2ac7bd8ab8519ebf19955edf1baf8d",
"160d04420e0d31b0df476f83393b1f9aff68389cc3299e42ef348d97646f7531a722b66d"
"dfb9501bbb5c4a41d84c78be7233b11489bceb817d23060e6017433fab8",
"08077aabd0a342f03f912007c586cfedfc63f93d1118f720d5b62b3ce141a60f86f111df"
"d8fc2e31a6778981f1a5e28f29a7369bd7897bb41240c8d3a9c170e0ee0",
"00abc75fc154b93840579457820957e89d1260fee0a4b9bb1946f61ca1e71afd76bb5e10"
"77b3e38ceb39d1fac5ef8b217c4110617b3ad118e02b3fcc2a39ef38613"},
{NID_secp521r1, NID_sha224,
"8a7792a2870d2dd341cd9c4a2a9ec2da753dcb0f692b70b64cef2e22071389c70b3b188d"
"ea5f409fb435cbd09082f59de6bc2ff9e65f91b7acc51e6e7f8e513148cb3c7c4664f227"
"d5c704626b0fda447aa87b9d47cd99789b88628eb642ed250312de5ba6b25f3d5342a3cb"
"b7ebd69b0044ee2b4c9ba5e3f5195afb6bea823d",
"01a99fcf54c9b85010f20dc4e48199266c70767e18b2c618044542cd0e23733817776a1a"
"45dbd74a8e8244a313d96c779f723013cd88886cb7a08ef7ee8fdd862e7",
"0401912d33b01d51e2f777bdbd1ada23f2b1a9faf2be2f2a3b152547db9b149b697dd718"
"24ca96547462e347bc4ef9530e7466318c25338c7e04323b1ba5fd25ea716200bbe9b1e3"
"a84accd69b76b253f556c63e3f374e3de0d1f5e3600fc19215533b2e40d6b32c3af33314"
"d223ea2366a51d1a337af858f69326389276f91be5c466e649",
"14fafd60cb026f50c23481867772411bb426ec6b97054e025b35db74fe8ea8f74faa2d36"
"e7d40b4652d1f61794878510b49b7b4fe4349afccd24fc45fec2fd9e9e7",
"18b1df1b6d7030a23a154cacce4a2e3761cc6251ff8bf6c9f6c89d0a15123baef9b338ad"
"a59728349ce685c03109fcde512ed01a40afd2ca34e1bc02ecf2871d45c",
"0a399f9b9e21aeddf450429fec2dc5749e4a4c7e4f94cee736004dcc089c47635da22845"
"992cd076a4f0a01d2cc1b0af6e17b81a802361699b862157ad6cad8bd1d"},
{NID_secp521r1, NID_sha224,
"f971bcd396efb8392207b5ca72ac62649b47732fba8feaa8e84f7fb36b3edb5d7b5333fb"
"fa39a4f882cb42fe57cd1ace43d06aaad33d0603741a18bc261caa14f29ead389f7c2053"
"6d406e9d39c34079812ba26b39baedf5feb1ef1f79990496dd019c87e38c38c486ec1c25"
"1da2a8a9a57854b80fcd513285e8dee8c43a9890",
"1b6015d898611fbaf0b66a344fa18d1d488564352bf1c2da40f52cd997952f8ccb436b69"
"3851f9ccb69c519d8a033cf27035c27233324f10e9969a3b384e1c1dc73",
"040110c6177ceb44b0aec814063f297c0c890671220413dbd900e4f037a67d87583eaf4b"
"6a9a1d2092472c17641362313c6a96f19829bb982e76e3a993932b848c7a9700f6e566c4"
"e49b2ee70a900dc53295640f3a4a66732df80b29f497f4ae2fa61d0949f7f4b12556967b"
"b92201a4f5d1384d741120c95b617b99c47a61e11c93a482d6",
"1a88667b9bdfe72fb87a6999a59b8b139e18ef9273261549bc394d884db5aa64a0bc7c7d"
"38a8ef17333478d2119d826e2540560d65f52b9a6dc91be1340cfd8f8f8",
"015f73def52ea47ddb03e0a5d154999642202e06e6734ac930c1dc84756c67bbb1cca9f2"
"1f92d61bfdb2052c5dd2833349610f68139393d77250a7662ef7bd17cbe",
"155c744a729f83b27d1f325a91e63a0d564fe96ff91eaa1bad3bff17d2abffa065d14a1d"
"20a04dd993f6ed3260b60bcc6401e31f6bc75aaafe03e8c1a9cd14d2708"},
{NID_secp521r1, NID_sha224,
"ec0d468447222506b4ead04ea1a17e2aa96eeb3e5f066367975dbaea426104f2111c45e2"
"06752896e5fa7594d74ed184493598783cb8079e0e915b638d5c317fa978d9011b44a76b"
"28d752462adf305bde321431f7f34b017c9a35bae8786755a62e746480fa3524d398a6ff"
"5fdc6cec54c07221cce61e46fd0a1af932fa8a33",
"05e0d47bf37f83bcc9cd834245c42420b68751ac552f8a4aae8c24b6064ae3d33508ecd2"
"c17ec391558ec79c8440117ad80e5e22770dac7f2017b755255000c853c",
"0401a6effc96a7f23a44bf9988f64e5cfafdae23fa14e4bee530af35d7a4ddf6b80dcd0d"
"937be9dd2db3adcda2f5216fecbce867ee67e7e3773082f255156e31358c2f01e7760190"
"dfbe07ec2df87067597087de262c1e0a12355456faba91b2e7277050d73b924e14c0e93b"
"8457a8b3e1f4207ce6e754274f88ad75c000d1b2977edc9c1a",
"18afea9a6a408db1e7a7bb1437a3d276f231eacfc57678bfa229d78681cbe4e800e60653"
"32a3128db65d3aa446bb35b517dca26b02e106e1311881a95b0302d15e8",
"01c49b3c1d21f1678bdbe1ac12167e95e06617190bdee1a729c1c649210da19e2e210f66"
"89e1310513bfe2ac6c0f4ee5f324f344b31b18df341eaadb826d07adc9b",
"129d4931ba457443012f6ffecd002f2abc3a4b65a58fee8457917ebcf24b29a1d3055b7f"
"c62939a74ebb0c3582172ee7c3c75e0b2fa2367c6e04df63a7a91d593ad"},
{NID_secp521r1, NID_sha224,
"d891da97d2b612fa6483ee7870e0f10fc12a89f9e33d636f587f72e0049f5888782ccde3"
"ea737e2abca41492bac291e20de5b84157a43c5ea900aef761006a4471072ab6ae6d515f"
"fe227695d3ff2341355b8398f72a723ae947f9618237c4b6642a36974860b452c0c62026"
"88bc0814710cbbff4b8e0d1395e8671ae67ada01",
"1804ab8f90ff518b58019a0b30c9ed8e00326d42671b71b067e6f815ac6752fa35016bd3"
"3455ab51ad4550424034419db8314a91362c28e29a80fbd193670f56ace",
"0400a79529d23a832412825c3c2ad5f121c436af0f29990347ecfa586ce2e57fd3c7e062"
"4d8db1f099c53473dbc2578f85416ad2ac958a162051014fb96bf07f9e1d17017c0750f2"
"6df0c621d2d243c6c99f195f0086947b1bf0f43731555f5d677e2d4a082fb5fe8da87e15"
"92a5fa31777da3299cede5a6f756edf81c85b77853388bb3ab",
"042d7c36fec0415bc875deb0fab0c64548554062e618aee3aa6670ffd68ab579fe620d3a"
"9316357267fd3111c0ed567dca663acd94b646d2ba0771953cd9690ef42",
"0d01dfbef126febbdfa03ef43603fd73bc7d2296dce052216e965fed7bb8cbbc24142bfc"
"ddb60c2e0bef185833a225daa0c91a2d9665176d4ad9986da785f4bfcf0",
"16627e2614dbcd371693c10bbf579c90c31a46c8d88adf59912c0c529047b053a7c77151"
"42f64dcf5945dbc69ff5b706c4b0f5448d04dd1f0b5a4c3765148bf253d"},
{NID_secp521r1, NID_sha224,
"924e4afc979d1fd1ec8ab17e02b69964a1f025882611d9ba57c772175926944e42c68422"
"d15f9326285538a348f9301e593e02c35a9817b160c05e21003d202473db69df695191be"
"22db05615561951867f8425f88c29ba8997a41a2f96b5cee791307369671543373ea91d5"
"ed9d6a34794d33305db8975b061864e6b0fe775f",
"0159bff3a4e42b133e20148950452d99681de6649a56b904ee3358d6dd01fb6c76ea0534"
"5cb9ea216e5f5db9ecec201880bdff0ed02ac28a6891c164036c538b8a8",
"04012d7f260e570cf548743d0557077139d65245c7b854ca58c85920ac2b290f2abfeccd"
"3bb4217ee4a29b92513ddce3b5cbf7488fb65180bb74aeb7575f8682337ef50175601862"
"30c7e8bff0bffce1272afcd37534f317b453b40716436a44e4731a3ec90a8f17c53357bc"
"54e6ff22fc5b4ca892321aa7891252d140ece88e25258b63d5",
"14b8a30f988cefdc0edec59537264edb0b697d8c4f9e8507cf72bc01c761304bd2019da1"
"d67e577b84c1c43dd034b7569f16635a771542b0399737025b8d817e1c3",
"0fc50939ebca4f4daa83e7eaf6907cb08f330c01d6ea497b86becda43dfcad47cb5c48f5"
"eb2cc924228628070bcd144088c449a7873242ba86badf796097dbecd6d",
"0ccb6463c4301ba5c043e47ed508d57dd908fd0d533af89fd3b11e76343a1cf2954ce90b"
"0eb18cbc36acd6d76b3906612d8a0feec6ebed13d88650ed9c708b28a11"},
{NID_secp521r1, NID_sha224,
"c64319c8aa1c1ae676630045ae488aedebca19d753704182c4bf3b306b75db98e9be4382"
"34233c2f14e3b97c2f55236950629885ac1e0bd015db0f912913ffb6f1361c4cc25c3cd4"
"34583b0f7a5a9e1a549aa523614268037973b65eb59c0c16a19a49bfaa13d507b29d5c7a"
"146cd8da2917665100ac9de2d75fa48cb708ac79",
"17418dfc0fc3d38f02aa06b7df6afa9e0d08540fc40da2b459c727cff052eb0827bdb3d5"
"3f61eb3033eb083c224086e48e3eea7e85e31428ffe517328e253f166ad",
"04000188366b9419a900ab0ed9633426d51e25e8dc03f4f0e7549904243981ec469c8d6d"
"938f6714ee620e63bb0ec536376a73d24d40e58ad9eb44d1e6063f2eb4c51d009889b920"
"3d52b9243fd515294a674afd6b81df4637ffdddc43a7414741eda78d8aa862c9cbbb618a"
"cec55bb9a29aac59616fc804a52a97a9fc4d03254f4469effe",
"1211c8824dcbfa0e1e15a04779c9068aed2431daeac298260795e6a80401f11f6d52d36b"
"cee3cfa36627989c49d11475163aa201d2cd4c5394144a6bb500bbaf02b",
"1d59401b8ac438855d545a699991142685077a409de2418c7ccfe01a4771b3870e76287a"
"9654c209b58a12b0f51e8dc568e33140a6b630324f7ef17caa64bf4c139",
"143af360b7971095b3b50679a13cd49217189eaee4713f4201720175216573c68f7ac6f6"
"88bfe6eb940a2d971809bf36c0a77decc553b025ed41935a3898685183b"},
{NID_secp521r1, NID_sha256,
"8ab8176b16278db54f84328ae0b75ef8f0cd18afdf40c04ad0927ed0f6d9e47470396c8e"
"87cde7a9be2ffbfe6c9658c88b7de4d582111119c433b2e4a504493f0a1166e3a3ea0d7b"
"93358f4a297d63f65a5e752f94e2ee7f49ebcc742fa3eb03a617d00c574245b77a200338"
"54d82964b2949e2247637239ab00baf4d170d97c",
"1e8c05996b85e6f3f875712a09c1b40672b5e7a78d5852de01585c5fb990bf3812c32455"
"34a714389ae9014d677a449efd658254e610da8e6cad33414b9d33e0d7a",
"04007d042ca19408524e68b981f1419351e3b84736c77fe58fee7d11317df2e850d960c7"
"dd10d10ba714c8a609d163502b79d682e8bbecd4f52591d2748533e45a867a0197ac6416"
"111ccf987d290459ebc8ad9ec56e49059c992155539a36a626631f4a2d89164b985154f2"
"dddc0281ee5b5178271f3a76a0914c3fcd1f97be8e8376efb3",
"0dc8daaacddb8fd2ff5c34a5ce183a42261ad3c64dbfc095e58924364dc47ea1c05e2599"
"aae917c2c95f47d6bb37da008af9f55730ddbe4d8ded24f9e8daa46db6a",
"09dd1f2a716843eedec7a6645ac834d4336e7b18e35701f06cae9d6b290d41491424735f"
"3b57e829ad5de055eaeef1778f051c1ee152bf2131a081e53df2a567a8a",
"02148e8428d70a72bc9fa986c38c2c97deda0420f222f9dc99d32c0acba699dc7ba0a2b7"
"9ce5999ff61bd0b233c744a893bc105bca5c235423e531612da65d72e62"},
{NID_secp521r1, NID_sha256,
"c4bc2cec829036469e55acdd277745034e4e3cc4fcd2f50ec8bd89055c19795a1e051ccf"
"9aa178e12f9beab6a016a7257e391faa536eaa5c969396d4e1ade36795a82ebc709d9422"
"de8497e5b68e7292538d4ccdc6dd66d27a3ece6a2844962b77db073df9489c9710585ba0"
"3d53fa430dbc6626dc03b61d53fc180b9af5dea6",
"0b65bf33b2f27d52cbfabcadce741e691bf4762089afd37964de1a0deda98331bf8c7402"
"0a14b52d44d26e2f6fa7bcddbe83be7db17a0c8a1b376469cf92c6da27c",
"04010038bb9a7aea626de68c14c64243150e72c69e2f8a1ab922bfbdaa6f33d24fb4542c"
"0324357b0dd640bbcd07632ecd253f64ca2bfbfbf3de9b24fffd0568ab82da00faf867d9"
"5308cc36d6f46844a0f535dc70f9768eed011a2464d2f308fa1d8e72c3616aec7e705169"
"08183ffce7fdd36984a15f73efaa3858c2edf16a784d40e6c2",
"14aeb96c57d99677a1f5e4588064215e7e9af4027bfb8f31ff6126dbf341b8e6f719465e"
"4273e91ba32670feca802549808322b7ee108bb20653cf20f93284d365f",
"075ead62edf7d86c5d1bc2443d1aeb5dc034fd999e6ea012cef7499d9d050cd97d262095"
"884e9fc89a42e15bd3dee80fe3c1ba10f4caabc4aabb86347023028b663",
"129a992a6ff66d41948d11fa680f732b1a74315b804c982805190ed9d2fae223f2b14998"
"0b9241998cdea0c5672595a8a49d5186a0ef7a46c0a376f925bdda81726"},
{NID_secp521r1, NID_sha256,
"1c1b641d0511a0625a4b33e7639d7a057e27f3a7f818e67f593286c8a4c827bb1f3e4f39"
"9027e57f18a45403a310c785b50e5a03517c72b45ef8c242a57b162debf2e80c1cf6c7b9"
"0237aede5f4ab1fcaf8187be3beb524c223cc0ceff24429eb181a5eea364a748c7132148"
"80d976c2cd497fd65ab3854ad0d6c2c1913d3a06",
"02c4e660609e99becd61c14d043e8b419a663010cc1d8f9469897d7d0a4f076a619a7214"
"a2a9d07957b028f7d8539ba7430d0b9a7de08beeeae8452d7bb0eac669d",
"0400fb3868238ca840dbb36ecc6cf04f5f773ea0ab8e8b0fdcf779dc4039a8d7146a4175"
"04e953c0cb5e7f4e599cc2c168deda8b7f16084b5582f89f2ece4cae5167f701f90b5c15"
"eeda48e747cf3ee8183166a49dbfac6161cbd09d29d40a6854f4c495e88a435892a920cd"
"aad20d41985890b648badd4f0a858ffcbd9afdfc23134ede18",
"1f875bbf882cd6dd034a87916c7b3ba54b41b2ea2ce84ebaf4e393fcf7291fee09dec2b5"
"bb8b6490997c9e62f077c34f0947fe14cec99b906dd6bf0b5d301e75ca1",
"07aa70425697736b298233249f5d0cf25c99e640c9ff88035ef1804820e1bfe7d043755f"
"02d7a079494f7fa6dc26740c4e6b7b430c63f29c67bbd3a5c88d2f0e8d1",
"0e0d42e4ff11cf5be37a9fda348514d5097a662f214687cbfb28ff42d635b13029871ca4"
"f464bb1fbce02d5da4d5fb61b2a071844259fc863d136197bec3a61e7c7"},
{NID_secp521r1, NID_sha256,
"adb5f069b2b501a3ebb83d4f1808eb07710ac4a7b12532996855a20bcc54b2f76812915f"
"632163c3654ff13d187d007152617cf859200194b59c5e81fc6cc9eb1ceb75d654050f26"
"0caa79c265254089270ccd02607fdcf3246119738c496dc3a4bd5d3be15789fc3d29a08d"
"6d921febe2f40aef286d5d4330b07198c7f4588e",
"17c3522007a90357ff0bda7d3a36e66df88ca9721fb80e8f63f50255d47ee819068d018f"
"14c6dd7c6ad176f69a4500e6f63caf5cf780531004f85009c69b9c1230c",
"04013a4bea0eed80c66ea973a9d3d4a90b6abbb5dee57d8affaf93390a8783a20982eba6"
"44d2e2809f66530adeeee7f9a1da7515447e9ba118999f76f170c375f621f7012f9dfaee"
"40a75d8442b39b37a5c19ea124b464236e9b9a31bae6780cfd50f7ea4a700154b5ea0fee"
"b64e9b35a1b0e33e46900cca1f34d13bb17e5017769841af27",
"18388a49caeda35859ef02702c1fd45ff26991998bd9d5e189c12c36cdae3f642ddd4a79"
"561bd1d3e1cd9359de8f5c9e1604a312d207a27b08a6033f2741794ced5",
"15c6264795837dfea19f91876455f564f073c5c84a3c9d76e67872ae0447ba0d4850d872"
"1302b25bec7ebfedd2721de140b2f3dead547042b24b0876117e7093cc1",
"060eb74236c189a28ed20bd0822eb22d75f7d97c9043a3c8e3f6d4c90bc8ca02ac4d37c1"
"171c799a1c7dfd2fcbf83406b5e48c051e0fbf0fd937bfe6c3db4e18154"},
{NID_secp521r1, NID_sha256,
"f253484d121d1ce8a88def6a3e9e78c47f4025ead6f73285bf90647102645b0c32d4d867"
"42a50b8b7a42d5f6156a6faf588212b7dc72c3ffd13973bdba732b554d8bffc57d04f816"
"7aef21ee941ee6ffb6cce0f49445bd707da8deb35dca650aaf761c3aa66a5ebccddd15ae"
"e21293f63061a7f4bfc3787c2cd62c806a1a9985",
"0c4dad55871d3bd65b016d143ddd7a195cc868b3048c8bbcb1435622036bdb5e0dec7178"
"ca0138c610238e0365968f6ddd191bbfacc91948088044d9966f652ff25",
"040014858a3b9bd426b678fdcf93fc53d17e7a9e8fe022442aaaba65399d12fd3a6a3819"
"58fb0f07ac6088f4e490506ec0f1ab4d0dbd461126f7eb46ff69cfa8bd88af018c18ce29"
"ecc6d79d26a2de0cd31c4b32e84b5e90f6ba748f86c5afbd89618aceb9079460cbd1a826"
"1ed5476973e61bf1d17ea78b022387443800c9247d21dde550",
"05577108f4187a173e5c29e927a8fc8f5ffd37e184254a6e381ff1018955aec91a35f300"
"85e8cee6a7555c10f9efdce26d62f2b4b52dfdbaeafc3a30983e2d50d5b",
"0344375ae7c804cbe32ced7a20976efae5d9c19eb88b6e24514d1d0cfb728b0f4601098b"
"18b2e98f42b5222dd5237d4d87767007bf5acb185c5526d72047e2cb1a1",
"02de4cfa908c73c1102d6fb7062baf54a056a9517701e036c9c51e09899d60051612d593"
"48945f845dffebec5aa395b2fac7229929033615788777306ccad96d0a3"},
{NID_secp521r1, NID_sha256,
"33bab1c369c495db1610965bc0b0546a216e8dd00cd0e602a605d40bc8812bbf1ffa6714"
"3f896c436b8f7cf0bed308054f1e1ff77f4d0a13c1e831efbd0e2fcfb3eadab9f755f070"
"ba9aeaceb0a5110f2f8b0c1f7b1aa96a7f2d038a1b72e26400819b1f73d925ea4e34d6ac"
"af59d0a461a34ce5d65c9c937a80e844e323a16d",
"03d4749fadcc2008f098de70545a669133c548ce0e32eec1276ff531bcff535331445557"
"28ad8906d17f091cc0514571691107350b6561858e90dbe19633aaf31bf",
"04010fe5986b65f6e65d13c88c4d2aed781a91026904f82129d46779bdadaf6b733c845a"
"934e941ab4a285efdea9c96ecc9dc784d87e4d937b42c337b3a9cb111a96000077853768"
"a2a4d6f596f57414e57ec60b76d3cd5ece8351cd1f335ebcb8801a3d91fb82c65caaeb5c"
"31eea9918367bb5906863ff3ccaf7a6cee415e0d75c15ac2e0",
"1fbb4de337b09e935a6dc6215ffcfcb85d236cc490585e73251a8b8bac37cfa36c5d1df5"
"f4536d33659be1e7a442529a783452f7efda74a4f661b6a127f9248aaf7",
"09d8f10eeff6178594c89d6e8184f9502117384813243ddf9ccf3c8eac5dc6502c472dfc"
"1487a5caffc569f7dedd14a8ebcb310e9bacdb79fb6655aba026cdf87f2",
"0f74236c7915d638708d17c9f10e39dda358faf9bbb821d8dcda0d151aac143bfb165ad0"
"a23a65cd3de532e32cad928728f5ae1c16f58fc16577f3ca8e36f9e708b"},
{NID_secp521r1, NID_sha256,
"08c8b7faaac8e1154042d162dca1df0f66e0001b3c5ecf49b6a4334ce4e8a754a1a8e4da"
"f8ec09cf1e521c96547aed5172ef852e82c03cddd851a9f992183ac5199594f288dbcc53"
"a9bb6128561ff3236a7b4b0dce8eaf7d45e64e782955ee1b690ce6a73ece47dc4409b690"
"de6b7928cbe60c42fc6a5ddf1d729faf1cc3885e",
"096a77b591bba65023ba92f8a51029725b555caf6eff129879d28f6400e760439d6e69ce"
"662f6f1aecf3869f7b6057b530a3c6ff8ed9e86d5944f583ee0b3fbb570",
"0400fdf6aed933dba73913142ef8bdcd4b760db8500831cd11d7707ab852a6372c05d112"
"a1e7fbc7b514c42142c7370d9f4129493cd75cc6f2daf83747078f15229db600ef91dffb"
"3c43080a59534b95ca585ee87f6145f6a0199b2b82c89f456d8bd8e6ac71c78039c08177"
"184484eb2ebd372f189db3a58fab961a75a18afec1ee32764a",
"13aa7b0471317a2a139c2f90df1c40d75e5a8a830fbaf87030fffdb2ef6f2c93d1310c9e"
"d7fe9d7bcd4fe46537ff2495bc9c4f0aaff11461f5e4bebbfbce9a8740a",
"1c7a21800962c91d4651553633b18612d931bb88bff8b743ed595b4e869437e50f8e84fb"
"f334c99061db123a1c40b73b07e203790561a37df65a660355ba2017d78",
"1301e1782559a38f1ca0eebe9bed0f5c7c33103d506a24f8a688f500ee1fe37f97b66853"
"19279e82e6fe43cfd823ccbc123309974cffa76c4f8d41ec02a3cbc45f1"},
{NID_secp521r1, NID_sha256,
"ba74eed74282811631bd2069e862381e4e2a1e4e9a357b1c159a9ce69786f864b60fe90e"
"eb32d8b72b099986fc594965a33285f7185b415df58fead7b8b50fc60d073680881d7435"
"609ad1d22fd21e789b6730e232b0d2e888889fb82d6ad0337ab909308676164d4f47df44"
"b21190eca8ba0f94995e60ad9bb02938461eee61",
"015152382bfd4f7932a8668026e705e9e73daa8bade21e80ea62cf91bd2448ebc4487b50"
"8ca2bdaaf072e3706ba87252d64761c6885a65dcafa64c5573c224ae9e6",
"04000b8c7c0186a77dc6e9addd2018188a6a40c3e2ba396f30bbd9293dba2841d57d6086"
"6b37f587432719b544d8bf7eb06d90a8c0dc9c93b0c53d53b2f667077228ca01dd2e5c73"
"ab908ae34f701689f1cd3cf5186d3a2bc941e208bf3ef970e5e429ee9b154d73286b2e5d"
"a423e75b7c7b78c7bdf915da92279db43265a0cdefca51f86a",
"0d03506999f5cc9ec3304072984a20a9c64a22ad9b418495ca904f4bbddc96e76d34672c"
"b52763339d3f3bc5b1701c00a675b972797e3a086314da1a8d338436566",
"085406c0ff5ec91f598bb579ad8714ad718c3e133d5dcc2e67c5d2339c146b69919cac07"
"f3bc2bda218f4c7c8be04855e2ca6fff7fbdc4fc0fda87c8c3081cad4f5",
"1b45f2066e583636215ae135afc202b8bf3f301eccff2e1c0198b9aeddf695fa8179488e"
"7b622fc307f601e2f6551815117cc836bb09ef888f8e64a45d9c84ad30c"},
{NID_secp521r1, NID_sha256,
"dc71f171a28bdc30968c39f08f999b88dc04c550e261ecf1124d67f05edeae7e87fe9b81"
"35a96fe2bc3996a4f47213d9d191184a76bd6310e1ee5cb67ea7fc3ef6f641a0ba165198"
"040fa668192b75a4754fc02c224bd4a74aade5a8c814adf151c2bfeda65165a04ef359e3"
"9847c84e312afb66d4cd1db50d41ef3fe5f31296",
"1750ff0ca0c166560b2034bc5760fe0b3915340bc43216e9de0c1d4a76550e8b2036e8b8"
"74230f8d29354aed43e183610f24fd4abd4b0be2f111dae942bd7a121f7",
"0401b4b8947192a7c0166c0e0b2791e217370836283e805f3ee11cfb78445aba3c5bc39f"
"e594e01916617ad59e7c8e740d8f2d07d88905d3f33bd5e51aafd4943c5dc601175d1172"
"32836c28e717ce2a55e59f4ec550effde30d18e3d99e42c6aa2283c7b3e7f2f6ff1fca60"
"5dde78c3a5bffa689347b4c93f51ba59a1787bb7d5e43861dc",
"023645023d6bdf20652cdce1185c4ef225c66d54f18632d99ccf743bf554d04c214c88ce"
"52a4f71ec75c899ad1b3c07c34112ca20b55c217ff1d72c9528e2774ce8",
"1e933f68ce0f8403cb16822b8e0564b1d39a35f27b53e4ae0bcdff3e051759464afbc349"
"98ba7c8a7ee34ef6c1aaa722cffe48356fd0b738058358d4c768b3186c1",
"0a67368a305508ce6d25d29c84f552a4a513998990fef4936244f891a2909c30d5fdc9e8"
"a267ecbf3c597138f4a08f7e92bee57d5420eadd700fee864bf78b2614b"},
{NID_secp521r1, NID_sha256,
"b895788d7828aaeace4f6b61a072ffa344d8ea324962ba6dab5efda93f65bf64a0f2ac6d"
"5721d03ee70e2aef21cdba69fd29040199160e3a293b772ffb961ed694a8dc82800dab79"
"367a4809a864e4aff6bc837aaa868e952b771b76591c0bb82249034e3208e593d85973d3"
"fea753a95b16e221b2561644535c0131fe834ae7",
"023048bc16e00e58c4a4c7cc62ee80ea57f745bda35715510ed0fc29f62359ff60b0cf85"
"b673383b87a6e1a792d93ab8549281515850fa24d6a2d93a20a2fff3d6e",
"0400ba3dc98326a15999351a2ec6c59e221d7d9e7ee7152a6f71686c9797f3f330d31501"
"23620d547813ba9d7cc6c6d35cc9a087d07dff780e4821e74ad05f3762efd6018b051af9"
"824b5f614d23ecadd591e38edbfe910ad6cbebc3e8a6bec11ea90691c17deb3bc5f34a4a"
"3acd90b7b10f521f6ee7b3cfbfdc03b72d5a8783a4a77c3e4c",
"06099d2667f06c58798757632d07d8b3efbe9c1323efb0c244be6b12b3b163ba1b7cf524"
"6c98dcc0771665a66696d687af5f28ed664fd87d5093df6427523d4db84",
"10dc80ea853064a2ba5a781f108aca3785c5ec0aa45aa05ba31d4de671170797589e863d"
"54a3a986aadf6f670277f50355713dfb27d4ec7e348f787910b3cd668cd",
"018572bfad4f62e3694d1f2e6ffd432faed2e2b9d7e3611a07138212f1e79e6c394839f7"
"cfae96bc368422630016fb9346681eadc5f9699e7331c3b5fde6d65e4c6"},
{NID_secp521r1, NID_sha256,
"2c5bd848c476e34b427cfe5676692e588e1957957db7b5704492bd02104a38216535607f"
"5d092dc40020130c04a3aaf0f1c52409834926d69a05d3f3188187a71d402a10ba34eac8"
"629b4c6359b1095f30f710219298bf06b9f19bfc299981d7e251ca232a0a85338a7e0246"
"4731d1b25d4a1f68baf97064516590644820c998",
"02b8b866ce4503bb40ffc2c3c990465c72473f901d6ebe6a119ca49fcec8221b3b4fa7ec"
"4e8e9a10dbd90c739065ad6a3a0dd98d1d6f6dcb0720f25a99357a40938",
"0401b8c7a169d5455f16bfe5df1ba5d6ec9c76e4bad9968d4f5f96be5878a7b6f71d74bf"
"ac0076dd278bc4630629f3294646f17d6b6c712b0087e2c4d576039cfdc8b9018faffd54"
"22dfd1b61432fa77b9a288b2b7d546656c0dcca3032179e6f45ee3cf61d6a447fc51731c"
"b54457343a41569fcf78cef42895f4da5efcb14ea1fc065f8d",
"0ac89e813f94042292aa1e77c73773c85cf881a9343b3f50711f13fa17b50f4e5cb04ac5"
"f6fc3106a6ef4c9732016c4e08e301eefac19199459129a41a7589e0628",
"05bc7a253a028ee8b7253979b8d689d41d8df6fae7736341f22e28b6faf0cbbdebbd2ef4"
"d73e56d2021af2c646dc15539a7c1e1c4dc9c7674808bd7968d8a66f947",
"0fd71575837a43a4cf1c47d0485cfd503c2cf36ebcea0fdef946ad29acb7fb2e7c6daf6b"
"4eb741eb211081aed6207d02569f1518988f275ad94c7fd4735cb18a92e"},
{NID_secp521r1, NID_sha256,
"65a0b97048067a0c9040acbb5d7f6e2e6ac462e1e0064a8ce5b5bbf8e57059e25a3ef8c8"
"0fc9037ae08f63e63f5bdb9378c322ad9b2daf839fad7a75b1027abb6f70f110247da7e9"
"71c7c52914e5a4f7761854432fa16b2a521e7bcaee2c735a87cad20c535bf6d04a87340c"
"229bf9af8647eedca9e2dc0b5aa90f7fea3cdc0a",
"0a43b32ad7327ec92c0a67279f417c8ada6f40d6282fe79d6dc23b8702147a31162e6462"
"91e8df460d39d7cdbdd7b2e7c6c89509b7ed3071b68d4a518ba48e63662",
"040172fb25a3e22c2a88975d7a814f3e02d5bb74cfb0aaa082c5af580019b429fddd8c7f"
"9e09b6938f62e8c31019b25571aaceef3c0d479079db9a9b533ee8e1670abd00ff551622"
"3b6cc7c711705f15b91db559014e96d3839249c5c849f2aced228a8998177a1e91177abb"
"b24b57a8ea84d944e0c95da860ae0925f1b40c0e1b7c9e0a46",
"0383eda042e06c0297fbd279a2ad40559c5c12ad458f73458eebcc92b308d3c4fcec20a5"
"b59f698e16fa6ea02dba8661b6955f67c052f67b0a56460869f24cfdf7d",
"1b9c35356b9d068f33aa22a61370dae44a6cb030497a34fb52af23c6b684677370268f06"
"bb4433be6795a71de570088aec17ce0c9933d2f76c7edce7f406f62fedd",
"06f07ea453cfa20ad604ba855332f62834657b0b795684d50c1562a675456e37f4dae45f"
"0df47d8e27e47bc9ce9c9cbba1554c5b94b0b17401b73c8d0c0902c6cc4"},
{NID_secp521r1, NID_sha256,
"d6e366a87808eea5d39fe77cac4b8c754e865a796062e2ec89f72165cd41fe04c4814806"
"8c570e0d29afe9011e7e7a2461f4d9897d8c1fa14b4ff88cab40059d17ab724f4039244e"
"97fcecb07f9ffeec2fb9d6b1896700fe374104a8c44af01a10e93b268d25367bf2bef488"
"b8abcc1ef0e14c3e6e1621b2d58753f21e28b86f",
"03c08fdccb089faee91dac3f56f556654a153cebb32f238488d925afd4c7027707118a37"
"2f2a2db132516e12ec25f1664953f123ac2ac8f12e0dcbbb61ff40fb721",
"040193301fc0791996ca29e2350723bd9aa0991ddbb4a78348ee72bdcd9ed63ce110ba34"
"96f2ce0331b5c00d4d674c1b70114e17ce44a73c3e16bab14ed1ee924202e400aea9b288"
"cfb2933ec0a40efa8e2108774e09b3863b3193d0dac6cc16ccaa5bd5f9ce133aec5cd3b6"
"2cbaeec04703e4b61b19572705db38cfaa1907c3d7c785b0cd",
"0d0e90d5ee7b5036655ad5c8f6a112c4b21c9449ca91c5c78421e364a2160bbac4428303"
"657bc11ea69f59fb0fe85a41b8f155a362343094456fd2a39f2a79e4804",
"1a8c23a2965d365a4c2ffd0802ae8b3a69c6b84a1ba77fd8a5f2f61e8ec3a1dcb336f136"
"e2a997252eaa94caf9b5ad6c9ecff5bf33abf547ca84985bb89908a11d7",
"1cc42a2dd97aa42b9df5ea430e0d4cb13106dd6da6e8c9315c96ed7b052db365bbde6960"
"c9a965954a4398c18ea7db9593bbfc3c3b6b3466ff806fccac3de6424ab"},
{NID_secp521r1, NID_sha256,
"f99e1d272d0f5fb9c4f986e873d070ec638422bc04b47c715595e2cf1a701cdf88bc6c4b"
"20085b357bad12ccba67cac8a5ca07f31ba432f9154ff1fadefd487a83a9c37e49fb70a2"
"f170e58889cab0552e0a3806ccfa2a60d96e346851d84b7de6d1a4b8cf37567dc161a84f"
"13421e3412457d4bc27f6213453c8519a2d7daa2",
"0969b515f356f8bb605ee131e80e8831e340902f3c6257270f7dedb2ba9d876a2ae55b4a"
"17f5d9acd46c1b26366c7e4e4e90a0ee5cff69ed9b278e5b1156a435f7e",
"0400fc7ae62b05ed6c34077cbcbb869629528a1656e2e6d403884e79a21f5f612e91fc83"
"c3a8ac1478d58852f0e8ba120d5855983afd1a719949afa8a21aec407516c300aa705da6"
"459a90eaa2c057f2e6614fb72fc730d6fdebe70e968c93dbc9858534768ea2666553cd01"
"db132331441823950a17e8d2345a3cab039c22b21bfe7bd3b9",
"19029260f88e19360b70c11107a92f06faa64524cfbd9f70fecf02bd5a94f390582a7f4c"
"92c5313bb91dc881596768d86f75a0d6f452094adbe11d6643d1a0b2135",
"07f2158e9b9fa995199608263969498923cf918fdc736427c72ce27ce4a3540dce2e8e5e"
"63a8fc7ba46f7fa42480efbf79c6ed39521f6e6ec056079e453e80a89d9",
"08e349eed6f1e28b0dbf0a8aeb1d67e59a95b54a699f083db885f50d702f3c6a4069591a"
"faa5b80b3c75efb1674ebd32c7ead0040d115945f9a52ee3a51806cad45"},
{NID_secp521r1, NID_sha256,
"91f1ca8ce6681f4e1f117b918ae787a888798a9df3afc9d0e922f51cdd6e7f7e55da996f"
"7e3615f1d41e4292479859a44fa18a5a006662610f1aaa2884f843c2e73d441753e0ead5"
"1dffc366250616c706f07128940dd6312ff3eda6f0e2b4e441b3d74c592b97d9cd910f97"
"9d7f39767b379e7f36a7519f2a4a251ef5e8aae1",
"013be0bf0cb060dbba02e90e43c6ba6022f201de35160192d33574a67f3f79df969d3ae8"
"7850071aac346b5f386fc645ed1977bea2e8446e0c5890784e369124418",
"040167d8b8308259c730931db828a5f69697ec0773a79bdedbaaf15114a4937011c5ae36"
"ab0503957373fee6b1c4650f91a3b0c92c2d604a3559dd2e856a9a84f551d9019d2c1346"
"aadaa3090b5981f5353243300a4ff0ab961c4ee530f4133fe85e6aab5bad42e747eee029"
"8c2b8051c8be7049109ad3e1b572dda1cac4a03010f99f206e",
"1a363a344996aac9a3ac040066a65856edfb36f10bb687d4821a2e0299b329c6b60e3547"
"dde03bdbd1afa98b0b75d79cf5aac0ef7a3116266cadf3dfbd46f8a4bfc",
"1ff097485faf32ce9e0c557ee064587c12c4834e7f0988cf181d07ba9ee15ae85a8208b6"
"1850080fc4bbedbd82536181d43973459f0d696ac5e6b8f2330b179d180",
"0306dc3c382af13c99d44db7a84ed813c8719c6ed3bbe751ead0d487b5a4aa018129862b"
"7d282cce0bc2059a56d7722f4b226f9deb85da12d5b40648bf6ec568128"},
{NID_secp521r1, NID_sha384,
"dbc094402c5b559d53168c6f0c550d827499c6fb2186ae2db15b89b4e6f46220386d6f01"
"bebde91b6ceb3ec7b4696e2cbfd14894dd0b7d656d23396ce920044f9ca514bf115cf98e"
"caa55b950a9e49365c2f3a05be5020e93db92c37437513044973e792af814d0ffad2c8ec"
"c89ae4b35ccb19318f0b988a7d33ec5a4fe85dfe",
"095976d387d814e68aeb09abecdbf4228db7232cd3229569ade537f33e07ed0da0abdee8"
"4ab057c9a00049f45250e2719d1ecaccf91c0e6fcdd4016b75bdd98a950",
"04013b4ab7bc1ddf7fd74ca6f75ac560c94169f435361e74eba1f8e759ac70ab3af138d8"
"807aca3d8e73b5c2eb787f6dcca2718122bd94f08943a686b115d869d3f40600f293c1d6"
"27b44e7954d0546270665888144a94d437679d074787959d0d944d8223b9d4b5d068b4fb"
"bd1176a004b476810475cd2a200b83eccd226d08b444a71e71",
"0a8d90686bd1104627836afe698effe22c51aa3b651737a940f2b0f9cd72c594575e550a"
"db142e467a3f631f4429514df8296d8f5144df86faa9e3a8f13939ad5b3",
"02128f77df66d16a604ffcd1a515e039d49bf6b91a215b814b2a1c88d32039521fbd142f"
"717817b838450229025670d99c1fd5ab18bd965f093cae7accff0675aae",
"008dc65a243700a84619dce14e44ea8557e36631db1a55de15865497dbfd66e76a7471f7"
"8e510c04e613ced332aa563432a1017da8b81c146059ccc7930153103a6"},
{NID_secp521r1, NID_sha384,
"114187efd1f6d6c46473fed0c1922987c79be2144439c6f61183caf2045bfb419f8cddc8"
"2267d14540624975f27232117729ccfeacccc7ecd5b71473c69d128152931865a60e6a10"
"4b67afe5ed443bdbcdc45372f1a85012bbc4614d4c0c534aacd9ab78664dda9b1f1e2558"
"78e8ac59e23c56a686f567e4b15c66f0e7c0931e",
"04ceb9896da32f2df630580de979515d698fbf1dd96bea889b98fc0efd0751ed35e6bcf7"
"5bc5d99172b0960ffd3d8b683fbffd4174b379fbdecd7b138bb9025574b",
"0400e7a3d30d5bd443549d50e9b297aaa87bc80b5c9e94169602d9d43d6d0c490c0bed8c"
"c2170288b106bdbf4c9f1ce53fd699af0b4c64b494b08520e57dc01ab9a8b001d81056d3"
"7aec8a75d588f6d05977416e6f24ad0117a7f4450036d695612e7bc2771caed80e580314"
"eebc88c8fc51c453f066e752481f212b57165d67f8a44f375a",
"046639c5a3ec15afae5e4a7a418ac760846512d880c359bc2c751b199ce43b10887e861b"
"14127809754dbea47f6cc0140d2817e3f5b9a80ce01abd81f81b748433a",
"0f913de91e19bd8f943d542ae357bacc942a0967abc9be6c06239a379db8cc733fa50013"
"e0b0f088bce9d630262feaa33b30d84f91bcf5ce9976e4e740fcb112f84",
"08a73a5c9c24235e0d9cecaac653f68ce5a6fb186ce67fa058d6ddbbd4d0a8c4d194e571"
"148e8ad6c8882b4e33d2f60fb23dd7d07a1ae60864e8277918f592b3dc6"},
{NID_secp521r1, NID_sha384,
"6744b69fc2420fe00f2352399bd58719e4ecdd6d602e2c80f194d607e58b27a0854745bf"
"d6d504de2eb30b04cee0f44af710dd77e2f816ac3ac5692fad2d1d417893bb0edba2707a"
"4c146a486f8728ca696d35cc52e9c7187c82d4bdb92eb954794e5ad15133f6bfea1f025d"
"a32ada710a3014cf11095b3ff69a94d087f17753",
"00a8db566bd771a9689ea5188c63d586b9c8b576dbe74c06d618576f61365e90b843d003"
"47fdd084fec4ba229fe671ccdd5d9a3afee821a84af9560cd455ed72e8f",
"04004f5b790cbe2984b71d41af5efed6c6893d15e13f31816d55a9c2926a104eee66f1ad"
"a83115d1388551218773b8b9d1138e3e3f027bb4392c90c14fd232580b4a1100660eb160"
"e9bfc8c5619e70e948e238c6fd37739bc1bb657b8e8436e63628f91992be7e63d9a73596"
"23a1340642777b22026feb51116a6c50c54c3589b9bd39b6cb",
"1e7b5e53571a24bd102dd7ad44a4b8d8a4e60e5957bc3c4e5d3c73109f55233f072e572c"
"7892f425ba5e64d3cb7966096bb34a47e26cd5b3e3b44108b310d9f681b",
"1a88bcd7e2bdff6e497d943dde432fb3f855a7177c466319cb53b701230c299db0302762"
"69685857d1e3f28110e690f2f529c8d18115eb381f313bc891d92ad278e",
"146f1984ea879274dfd5e86ad92e564a4de081523ddbb1c397b8f9595911ef2e6501bc08"
"1584d5340f7aa47e1af036234ac6f27a5ac31f78dd3b0ff1a62693c630d"},
{NID_secp521r1, NID_sha384,
"16001f4dcf9e76aa134b12b867f252735144e523e40fba9b4811b07448a24ef4ccf3e81f"
"e9d7f8097ae1d216a51b6eefc83880885e5b14a5eeee025c4232319c4b8bce26807d1b38"
"6ad6a964deb3bdca30ee196cfdd717facfad5c77d9b1d05fdd96875e9675e85029ecbf4f"
"94c524624746b7c42870c14a9a1454acf3354474",
"1a300b8bf028449344d0e736145d9dd7c4075a783cb749e1ec7988d60440a07021a25a3d"
"e74ea5e3d7bd4ab774d8ad6163adae31877ef0b2bd50e26e9e4be8a7b66",
"04005055b9ad726ba8a48219b0ecbfffb89f8428de895b231f676705b7de9f2022d9ff4e"
"0114ebb52dea342f9bf76b2fb060c020e29d92074ebb1fbfe5290a58c8bc1000415af7f2"
"0a6e945315adbf757316bb486c80780a0a3a15b4b9609f126d7341053a2b726ab63cb46f"
"eee527b0bf532b32b477e5671aea23d9b3c3e604b9029954b5",
"05a2e92717bb4dab3ee76724d4d9c2d58a32b873e491e36127985f0c9960c610962ca1c4"
"510dba75c98d83beebdc58b1d8678e054640951d11db1bd2d8a4ab8476b",
"104a78ce94f878822daaf00ee527fbdbf6cceb3cbb23a2caa485e4109466de8910252f92"
"379ab292cac8d1eda164f880c0067696e733fc8588a27703a3e1f5b8f1f",
"1ffe23e8ab5a31668a81161a234ea14879771fe9866f8872eb6edb672e0fe91d2bb75c97"
"67a2dfbac7c15c802211236b22ea41ecd055a0b8b311ffc4255f86d5c67"},
{NID_secp521r1, NID_sha384,
"a9824a7b810aa16690083a00d422842971baf400c3563baa789c5653fc13416111c0236c"
"67c68e95a13cec0df50324dcc9ae780ce4232607cb57dd9b2c61b382f0fa51fd4e283e2c"
"55ffe272597651659fbd88cd03bfa9652cd54b01a7034c83a602709879e1325c77969beb"
"fd93932ce09a23eae607374602201614ff84b141",
"06a253acd79912a74270fc0703ed6507ab20a970f2bc2277f782062092cf0e60ae1ca1bb"
"44dec003169bc25ef6e7123dd04692f77b181a6d7e692e66b09d35a540c",
"0401f15c6b1df156fdd8381cd7446e039435e445f8f36f0247475058da0e371bf72753f6"
"e39f98066bc79370b038c39687ba18e16cb118fe6538b7568c5403c251f6b7012d2b4f46"
"b854eeae75f1c63f55b76bf0c604d47f870c28a50ecdeb52bba1dd9a0ff12e680804ff86"
"4111207652da7dd10b49edf66bb86be00bc06672de91982457",
"165faf3727e42fd61345cfa7b93e55fb4bf583b24bdc14ce635b6c99dbd788012f14da9a"
"210b677c44acdd851e672f1a48188d6b8946c0efeebfe8a597ba0090a2c",
"1ad9463d2759abd568626548578deefdcd8b2d050ce6d9c7ed05feca20167484b86e89bd"
"cc936fd647e0f8aedd7b6add2b8cf13ff6ff013c2b5540c6c56fda97a0c",
"1645a7d0e11015256cfb034adca198695eea6aedd44d9fbf496850ccfed950f43fffd8db"
"f41e113f2d3837d8a5dd62b2ed580112ff05800b1f73196e5576810e15b"},
{NID_secp521r1, NID_sha384,
"90d8bbf714fd2120d2144022bf29520842d9fbd2dc8bb734b3e892ba0285c6a342d6e1e3"
"7cc11a62083566e45b039cc65506d20a7d8b51d763d25f0d9eaf3d38601af612c5798a8a"
"2c712d968592b6ed689b88bbab95259ad34da26af9dda80f2f8a02960370bdb7e7595c0a"
"4fffb465d7ad0c4665b5ec0e7d50c6a8238c7f53",
"0d5a5d3ddfd2170f9d2653b91967efc8a5157f8720d740dd974e272aab000cc1a4e6c630"
"348754ab923cafb5056fc584b3706628051c557fce67744ee58ba7a56d0",
"040128a4da5fc995678e457ceb3929adee93c280f851abe900fa21f4f809dafad4e33b38"
"1e0cd49ce8dd50e2e281cea162bfd60a1d6a1c0ee2228e6a011e171b559ab8006eb0917c"
"d72256992c49ea527f6bb0315f13d8047794a0f1da1e93737703b1c2a74a00441ef3b47b"
"6a2ff789c49ae32d91cabe7b29247aeec44f6c40a76597a2ca",
"03269983a5c2bcc98e9476f5abf82424566b1f08b17204d29e310ece88f99eb677a537f8"
"6fe2529e409cfef2c12929644100099e0de2f27c0f0ac11105a4dca935b",
"1a5257ae1e8187ba954f535b86ff9b8d6a181a3b95c250d090cb4e9c3bfbd03aa64696a7"
"6c569728ef67780d6338d70ce46da40b87a3e49bfe154b93930890dfa93",
"05b6ccdfd5c63c7db76d3a0478064a2a376e0e050cb093be795a72a549247c2e4adba918"
"3145c63d46479dbbdcf09986a6f64c09c7e16abc4853f6376c9558b014a"},
{NID_secp521r1, NID_sha384,
"09952b1e09995e95bf0022e911c6ab1a463b0a1fdd0eec69117b34af1103c720b5760021"
"7de7cd178fef92de5391e550af72a8dcf7badf25b06dd039417f9a7d0f5be88fcd4e9655"
"931d5b605452a667c9d1bae91d3476e7d51cff4108f116a49966fb3a7cff8df1c09734ce"
"5620faf2dccb3dc5d94e7e9ac812da31f6d07a38",
"1bcedf920fa148361671b43c64e3186e1937eb1bd4b28cbd84c421472394552889bc0550"
"9aa732ef69d732b21b750523fdfd811f36467690fe94e01e64c9d5cbbe9",
"0400d33c151d202a5d4d831348e940b027ee32e4b0b9b48d823a05c67ff3bdaee0189fc6"
"680565f352c062e99968afc643208b4f9c7af185b861658a88c4ad0fcc8ba200e4441ddb"
"546468ad8ffa6074f137edfbb81e82e0e7d8f05c4c54598aa996a9cde54cb371f642bfdd"
"4ae7eca5b769696030027129a4183da93567ad142a2dff5183",
"046e619b83aac868b26d0b3cbfab55e630e0b55c461985b5d00f94ff3a5ce90ff412cebf"
"46bbd84550d2031d573ca27d924624428360708c8d8491c29eb01d30f2e",
"08427c0f0ac0263472cd423c0fb554bf3c851b9c775c566ab0f6878717bd57665830767b"
"05b7789c5c0b078195bd943dc737325552d32877ecb04a7c41bd07cd80c",
"10bb6652d6a624c40a7dd06828f15774130d02369ceb1a7d03b553e16e17b7fa5b5401f1"
"5885d5e4fc2e55c0c7a1b97871ab02f76386b93a16aa6e7eb65debac6dd"},
{NID_secp521r1, NID_sha384,
"0bb0f80cff309c65ff7729c59c517d50fc0ed5be405ef70cb910c3f62c328c90853d4473"
"530b654dda6156e149bc2222a8a7f9be665240e2fbe9d03f78a2356af0bacd1edb84c480"
"1adc8293a8a0bd6123d1cf6ba216aca807a7eb4dca76b493eb6e3dbb69d36f0f00f85622"
"2f24d9b93ec34c3b261be2fca0451c00571928e5",
"03789e04b3a2a0254ade3380172c150d2fad033885e02ea8bea5b92db3f4adbab190ae42"
"3080a1154dfedec694c25eab46ce638be3db4e4cba67bc39f62d6e7db2d",
"0401dbc2cf19627bdccf02432b1761f296275230c150cdde823ce3141ec315d7d05e16b2"
"c29e2a67491078d5316883e933d85b4b10d4f64c477d3c4e0442dc928983a2007562e720"
"807dd118d3d8b265b3abc61a71fce43e3dce0e7b5ae18b7a4cb01ecc00d39c1f22e150a9"
"a8728997e502144f5b3f6fa9b4cb8a4136212b082ca394e3f6",
"0fbccd8d7804bdd1d1d721b5ec74d4ba37603bc306f9fce2ec241853d8e07334e6b4b12c"
"4ecca0c54bd71193dd7146507933a20737c5f3e15085830fab9b30ca57b",
"181915a3998d8fa214f9715f4ca928d09c36de168dc15c6970a8a062b5cea2dc969b2437"
"ca17b684f78a1fd583aad8e6c762c8f4ab0c91b86a497145e3ca440d307",
"15a6c18c5c77f5470b27d061eafdc26b78561941a3b2ab0f5c81d40899fc053c3d9ed12d"
"7d61e298abbae470009c7b2157731c58d7b16a66fa5abaf5e8a1b8ed394"},
{NID_secp521r1, NID_sha384,
"7efacf213382ce30804e78b7256854d759147dba9729c51b2759465715bf2c421034c23d"
"c651c13d6cce95f71fe6a84dfbee5768163ac5789ac0474c5ddf4115684683c5f7c204b3"
"3b8bcc0c03ac58f66cef2f53b721fe2fac91ad841126101a88f512a7c2ded38549d9f050"
"d4b7961dda48a1489f026c5d111701762418cfe3",
"124700aa9186353e298edefc57bec0c7d0201cca10c1d80dd408d5d71040592b0ac59fac"
"dadfa8712445f5977ef8d4854022720c3f02d60e0732dbb2f171fcf1490",
"0400c80fc4cecae5d53348524ddba6a160b735c75b22fdb39af17e2a613d09246e3bb0fd"
"3f2978577f6db5d2118e05c7898024808f8eb8e021d7969cdcf7fc981200bb01a880c939"
"43fd446d4b3923b574d2221c1bb7b645fb5534dda60e827b497666ff586b77921f7e7f60"
"5147947194cffd2fef0678880b89cc0bc7fb74fa96d4b112d7",
"01a05238d595ded5c61d3bf6fde257dbf13095af8a5cb3a2e579e8e4c550fe31d12b71cc"
"2dbcb295e6c4fd0fb8c22d1b741c097cc59d826ced1a8771f09983143c4",
"132762bc81e9922a8d642e3a9d0218affa21fa2331cfcb9e452545c5981c64a8f7e4cc8e"
"68056023b2aa78bead59061d19c7f646c931163a91e544b106b3be8de9e",
"0c3a1b0b000c3169984132add51d611e2cb7069a262a6983d2ae72b459c36e6469509bdb"
"0f473600b8686700b08910779dee9ba83f82e755d4a4ef5f124eb09397f"},
{NID_secp521r1, NID_sha384,
"28edff8b9d85f5f58499cc11f492abdfab25e8945975bbaeee910afa2b8fc1295ec61406"
"309ce4e09f4ab4f462959fc2a2786802466eb26d3b01be6919893ae75d0fdc2dc8a82e66"
"2550f9fce9627dd364188aaba5c6faa1b2d8a2235adfa5ad0dc140f88a2b2f103f5690e8"
"77d07fe8fd30d02d2b2729bd3d8eb5b23a21f54c",
"1f532d01af885cb4ad5c329ca5d421c5c021883bd5404c798d617679bb8b094cbb7e15c8"
"32fb436325c5302313ce5e496f9513455e7021ffad75777a19b226acfa1",
"0400c0bd76b0027b85bdd879052220da1494d503f6a4bb972105a48ae98e7dda8c2d9fd9"
"336f5646385b961ef68e8464e3a95b00f96614b1a408ceaa2c87b077b6a8fb017eb7eb5c"
"78db7819af92e8537d110d9f05a5e24f954f4dde21c224d4040f059ec99e051702f39041"
"3d2708d18f84d82998c61847475250fb844b20082cbe651a6b",
"14e66853e0f7cd3300ebcae06048532e19cbb95bee140edc1c867ce7310637651445b6df"
"eb1d99d2e32f2ffb787ebe3fe35032277f185d3dad84f95806924550abe",
"0c5b3a57161098e2e8e16e0a5ae8ecf4a14df14927eea18ed4925d11dc429dda14515932"
"3ba970174b194b9b4608a8fa2373b7a825c5e8bd80574e49698285c2c82",
"1a0c038a51796158b42eb5b0dac37aff9ab93b903a47e06ebbdd15946e4bcc9a3b3875b1"
"8cf6294c33fc6c3693cef04ed1a43d08951e664c760e2cf3fb4e47490d2"},
{NID_secp521r1, NID_sha384,
"bae2a8897c742fd99fbf813351cd009d3f2e18d825ca22e115276484bce8f82f8c7c0c21"
"dd2af208404d8ef45bb5a6c41693912b630897d5246801bf0775aa9bbac8be98cb861d17"
"2c3563dc59e78a58ed13c66dea496471b3ad0eeae8995293e4ab97373edc1837ffc95ff1"
"cc0c1e90e64ea8680b2ca5f1e09bf86b99b343b6",
"11abf508bca68a85a54bc0659e77efad3c86112c9db04db2883e76144aa446918bb4bb07"
"84b0b6a0e9aa47399fe3de5aaecfd8894a0d130bb0c366c40d9d5050745",
"04005c0ea363a3a12633ea39d564587ebdd3a22a175ef32b9ebfc7311304b19cb3a62b5a"
"dc36f6afb6a6f7fabbf810ee89fdb72854fefd613e7798e9b9ff5938ea54c600bd06a85e"
"47b885c08124b55a3fcc07ca61647cda6efbfdbd21b24d1ea7a4c7300d46cd798e76063a"
"a979adef6f0698b15e5b7ae8a2ab39ab4f50b2d20614db6317",
"19cadb8c7eb10565aa4567e0709873918720f0e4b42b4817afb0b0547c70cd1100229dea"
"e97a276b9c98ea58b01d4839fee86336d749d123b03e8b1a31166acc110",
"0667448a8bbef1c810d40646977dc22f3dfb52a4d80928ded5e976e199cbed02fbd5a085"
"46756ece14548d721a6eb380d0e1a71ad0660dbcac6163c776eedd3e249",
"0ae7f0a238daaddb7fb4a1707fe5132daf653f8e19f732347134c96f1dd798f867c479a4"
"a4609a568a15b61afed70790adbde13ac5f68c468d0230852c1a2c22581"},
{NID_secp521r1, NID_sha384,
"d57a26a9593e72bfc87322524639bcaae5f2252d18b99cdaa03b14445b0b8a4dd53928f6"
"6a2e4f202fb25b19cad0eb2f1bfda2ab9b0eb668cdcd0fe72f5d9ef2e45e0218590f7ab9"
"d2c9342202610c698bc786cce108a7d4a6730a13e9ea1b470e781f1237d3f84f44abde80"
"8516975546bd89075ef9a9732bfd7ee33b6f4399",
"18dbf520d58177e4b7a0627674d220137983f486dd2fd3639f19751804e80df0655db6af"
"d829cdf75238de525e1a7a9f048049b593dd64b4b96cc013f970c05ea1f",
"04018b872690c37995be324ddb5c2bd5462841bb062f8e63da248a853de79c3d6bb9a2eb"
"1e6933afda0998ca43491cc807b08ace2d5336a43d0ab50563a2d3d98755f00002ff3122"
"1aa32aa6546f35e8fe5b9361f938362a5e89e77ae130ba8bce3729e912dfac35a2fd21ef"
"e84b45b8be2a340850e4b574e1885b35c2afbe196b57c6cf4c",
"098faeb73054639cb2e4442cd68e7b3a13f4b3f397a7b26f303afa40789f8ddd3d918f1c"
"e4f0be53c8cb69c380744e2297d7fc01e2b3daef4ce64dd3a2644234753",
"09c0e7649f814f70a8416cb78bc4601472a363fe97f5c587305778169677860dd97f87b5"
"ab07c3a953bc4615fc34634509d6a25621bdded33ed42446d059509c190",
"120b90e1cfb8a1b5e530df7b17d1128bc051ca4f1a65dd9c9d9d3c59d2f00c7c1e994c52"
"b8671d40294b4d574d2c04475d5bebeacd3a0d3870a54dc7a4805614f40"},
{NID_secp521r1, NID_sha384,
"8fdcf5084b12cfc043dd3416b46274e021bbed95d341d3c500c102a5609d3a34de29f8fa"
"9f0adb611a1f47a97ad981f8129d718fc0d6c709eab1a3490db8d550f34eb905b9e00663"
"543afc5bc155e368e0bc919a8b8c9fa42093603537a5614927efa6be819ed42ececbf1a8"
"0a61e6e0a7f9b5bc43b9238e62d5df0571fea152",
"002764f5696aa813cd55d30948585f86288ae05aeb264ca157cd09e1d09a10515a849b07"
"91b755ccc656a34707be9e52f5762d290a7d2bcd6de52c600ff862eaf4e",
"040127279c88719dc614db387f102e55104ea1c704ac7f57f3bca936f728439b76556730"
"dd7cde2ac1ad0a4c2c2f036ab6f00cf34cb87ea36113571f300713044106d20134a0786c"
"31f5f2291b83c50fb579ae4c620b95e5a8bdc0c7e1ee6b996c89d764f1b20403e7faa203"
"f397425ada297045dd8ba0e4b155d4900da249e934faab7991",
"08bffb0778cbb06466cecc114b9e89ca243a2b2b5e2597db920bc73a8bbcbe3f57144ad3"
"3409ef7faaab430e13f4c42d304d11347360c84972ca20b1539cce3a288",
"1f8f504e64a502e51e7c129517931c3b71f0d8a63b19cfe01ff7c951c6525249608b3ef5"
"d00061d77eb6b3d69581adeaa3732c773bbb9b919c3e7c71fdc09f44d06",
"058044fc64b340604ffd02a5b2918d76fd6fb59ea895feab7aa218e6f1e8c8f226eb9ee3"
"45ef8140183a69272582005077b008006aab11597e808d7ff1e8382c924"},
{NID_secp521r1, NID_sha384,
"00669f433934992257bed55861df679804107d7fa491672574a7624949c60049b0533383"
"c88d6896c8de860704c3e6a6aefce83efa57c4d57e9ab253da5d15e1f53ab6dce218b592"
"772ab0bc01fee8e63368e85c0639301456fe2d44cd5396a7f2b22761cd03b80eba7883ee"
"de8249a2f5db2183bf00550c5c002f45a5e4fb31",
"1b0c9acd3eeb618b4b0de4db402206f0f29adc69d7ad324b6db6601b351f723ac8fe949e"
"eacd34228649bf0126276e5aceb0137d00c30dd858aef2d6b6449de2e89",
"0401811c8884486aaa083ddee1c51cb6e861cb830bd5eaa929f72efadbbd1286566ae7e7"
"ba7fde7e02529900d35ee64591652d28798bfc1bed0d192602a9cf5a7d22e3006d7fc9dd"
"494816cfd29613d4689af67f7d0a2e6fbad5d4d6e0130189172a1ab601c5ca71deaa8bfc"
"b5a190d49da191672ff6fc048e146cb902acec5eae6d87e60a",
"1fdc4f108070af3c66c9ba7b6c1f2603a19ceb4760399df81228cfc7eafde1082b5a0716"
"a3ff82fbe84726f14dd0db3376ca184a78c3c60679bab6cd45f77f9b9ce",
"1ec310339ff056faeb341c4499c43782078b04be1725ae9a6cdcb6011c46d1a4eb3d75c3"
"58225e4ec142fd1cd344186f5eb597f7ba559ddfa954824365d5b6edaec",
"005b679a33fdb7e04834f071cd0ac514c04add9f2614ab9bbd9b407b1420fed3f3e02a10"
"8e7e279899e43dcf64ae4083c289a87cd7d2103bdc036a95d36800ac7c6"},
{NID_secp521r1, NID_sha384,
"4be81dcfab39a64d6f00c0d7fff94dabdf3473dc49f0e12900df328d6584b854fbaebaf3"
"194c433e9e21743342e2dd056b445c8aa7d30a38504b366a8fa889dc8ecec35b31300707"
"87e7bf0f22fab5bea54a07d3a75368605397ba74dbf2923ef20c37a0d9c64caebcc93157"
"456b57b98d4becb13fecb7cc7f3740a6057af287",
"181e1037bbec7ca2f271343e5f6e9125162c8a8a46ae8baa7ca7296602ae9d56c994b3b9"
"4d359f2b3b3a01deb7a123f07d9e0c2e729d37cc5abdec0f5281931308a",
"0400cfa5a8a3f15eb8c419095673f1d0bd63b396ff9813c18dfe5aa31f40b50b82481f9e"
"d2edd47ae5ea6a48ea01f7e0ad0000edf7b66f8909ee94f141d5a07efe315c018af728f7"
"318b96d57f19c1104415c8d5989565465e429bc30cf65ced12a1c5856ac86fca02388bc1"
"51cf89959a4f048597a9e728f3034aa39259b59870946187bf",
"09078beaba465ba7a8b3624e644ac1e97c654533a58ac755e90bd606e2214f11a48cb51f"
"9007865a0f569d967ea0370801421846a89f3d09eb0a481289270919f14",
"19cf91a38cc20b9269e7467857b1fc7eabb8cea915a3135f727d471e5bfcfb66d321fabe"
"283a2cf38d4c5a6ecb6e8cbee1030474373bb87fcdfcc95cf857a8d25d0",
"1cf9acd9449c57589c950f287842f9e2487c5610955b2b5035f6aacfd2402f511998a1a9"
"42b39c307fc2bcab2c8d0dae94b5547ddccfb1012ca985b3edf42bbba8b"},
{NID_secp521r1, NID_sha512,
"9ecd500c60e701404922e58ab20cc002651fdee7cbc9336adda33e4c1088fab1964ecb79"
"04dc6856865d6c8e15041ccf2d5ac302e99d346ff2f686531d25521678d4fd3f76bbf2c8"
"93d246cb4d7693792fe18172108146853103a51f824acc621cb7311d2463c3361ea70725"
"4f2b052bc22cb8012873dcbb95bf1a5cc53ab89f",
"0f749d32704bc533ca82cef0acf103d8f4fba67f08d2678e515ed7db886267ffaf02fab0"
"080dca2359b72f574ccc29a0f218c8655c0cccf9fee6c5e567aa14cb926",
"040061387fd6b95914e885f912edfbb5fb274655027f216c4091ca83e19336740fd81aed"
"fe047f51b42bdf68161121013e0d55b117a14e4303f926c8debb77a7fdaad100e7d0c75c"
"38626e895ca21526b9f9fdf84dcecb93f2b233390550d2b1463b7ee3f58df7346435ff04"
"34199583c97c665a97f12f706f2357da4b40288def888e59e6",
"03af5ab6caa29a6de86a5bab9aa83c3b16a17ffcd52b5c60c769be3053cdddeac60812d1"
"2fecf46cfe1f3db9ac9dcf881fcec3f0aa733d4ecbb83c7593e864c6df1",
"04de826ea704ad10bc0f7538af8a3843f284f55c8b946af9235af5af74f2b76e099e4bc7"
"2fd79d28a380f8d4b4c919ac290d248c37983ba05aea42e2dd79fdd33e8",
"087488c859a96fea266ea13bf6d114c429b163be97a57559086edb64aed4a18594b46fb9"
"efc7fd25d8b2de8f09ca0587f54bd287299f47b2ff124aac566e8ee3b43"},
{NID_secp521r1, NID_sha512,
"b3c63e5f5a21c4bfe3dbc644354d9a949186d6a9e1dd873828782aa6a0f1df2f64114a43"
"0b1c13fe8a2e09099e1ed05ef70de698161039ded73bcb50b312673bb073f8a792ac140a"
"78a8b7f3586dffb1fc8be4f54516d57418ccc9945025ce3acf1eb84f69ceee5e9bd10c18"
"c251dbc481562cd3aae54b54ab618cb1eeda33cf",
"1a4d2623a7d59c55f408331ba8d1523b94d6bf8ac83375ceb57a2b395a5bcf977cfc1623"
"4d4a97d6f6ee25a99aa5bff15ff535891bcb7ae849a583e01ac49e0e9b6",
"04004d5c8afee038984d2ea96681ec0dccb6b52dfa4ee2e2a77a23c8cf43ef19905a34d6"
"f5d8c5cf0981ed804d89d175b17d1a63522ceb1e785c0f5a1d2f3d15e513520014368b8e"
"746807b2b68f3615cd78d761a464ddd7918fc8df51d225962fdf1e3dc243e265100ff0ec"
"133359e332e44dd49afd8e5f38fe86133573432d33c02fa0a3",
"0bc2c0f37155859303de6fa539a39714e195c37c6ea826e224c8218584ae09cd0d1cc14d"
"94d93f2d83c96e4ef68517fdb3f383da5404e5a426bfc5d424e253c181b",
"1a3c4a6386c4fb614fba2cb9e74201e1aaa0001aa931a2a939c92e04b8344535a20f53c6"
"e3c69c75c2e5d2fe3549ed27e6713cb0f4a9a94f6189eb33bff7d453fce",
"16a997f81aa0bea2e1469c8c1dab7df02a8b2086ba482c43af04f2174831f2b176165879"
"5adfbdd44190a9b06fe10e578987369f3a2eced147cff89d8c2818f7471"},
{NID_secp521r1, NID_sha512,
"6e0f96d56505ffd2d005d5677dbf926345f0ff0a5da456bbcbcfdc2d33c8d878b0bc8511"
"401c73168d161c23a88b04d7a9629a7a6fbcff241071b0d212248fcc2c94fa5c086909ad"
"b8f4b9772b4293b4acf5215ea2fc72f8cec57b5a13792d7859b6d40348fc3ba3f5e7062a"
"19075a9edb713ddcd391aefc90f46bbd81e2557b",
"14787f95fb1057a2f3867b8407e54abb91740c097dac5024be92d5d65666bb16e4879f3d"
"3904d6eab269cf5e7b632ab3c5f342108d1d4230c30165fba3a1bf1c66f",
"0400c2d540a7557f4530de35bbd94da8a6defbff783f54a65292f8f76341c996cea38795"
"805a1b97174a9147a8644282e0d7040a6f83423ef2a0453248156393a1782e0119f746c5"
"df8cec24e4849ac1870d0d8594c799d2ceb6c3bdf891dfbd2242e7ea24d6aec316621473"
"4acc4cbf4da8f71e2429c5c187b2b3a048527c861f58a9b97f",
"186cd803e6e0c9925022e41cb68671adba3ead5548c2b1cd09348ab19612b7af3820fd14"
"da5fe1d7b550ed1a3c8d2f30592cd7745a3c09ee7b5dcfa9ed31bdd0f1f",
"10ed3ab6d07a15dc3376494501c27ce5f78c8a2b30cc809d3f9c3bf1aef437e590ef66ab"
"ae4e49065ead1af5f752ec145acfa98329f17bca9991a199579c41f9229",
"08c3457fe1f93d635bb52df9218bf3b49a7a345b8a8a988ac0a254340546752cddf02e6c"
"e47eee58ea398fdc9130e55a4c09f5ae548c715f5bcd539f07a34034d78"},
{NID_secp521r1, NID_sha512,
"3f12ab17af3c3680aad22196337cedb0a9dba22387a7c555b46e84176a6f841800455238"
"6ada4deec59fdabb0d25e1c6668a96f100b352f8dabd24b2262bd2a3d0f825602d54150b"
"dc4bcbd5b8e0ca52bc8d2c70ff2af9b03e20730d6bd9ec1d091a3e5c877259bcff4fd2c1"
"7a12bfc4b08117ec39fe4762be128d0883a37e9d",
"15807c101099c8d1d3f24b212af2c0ce525432d7779262eed0709275de9a1d8a8eeeadf2"
"f909cf08b4720815bc1205a23ad1f825618cb78bde747acad8049ca9742",
"040160d7ea2e128ab3fabd1a3ad5455cb45e2f977c2354a1345d4ae0c7ce4e492fb9ff95"
"8eddc2aa61735e5c1971fa6c99beda0f424a20c3ce969380aaa52ef5f5daa8014e4c83f9"
"0d196945fb4fe1e41913488aa53e24c1d2142d35a1eed69fed784c0ef44d71bc21afe0a0"
"065b3b87069217a5abab4355cf8f4ceae5657cd4b9c8008f1f",
"096731f8c52e72ffcc095dd2ee4eec3da13c628f570dba169b4a7460ab471149abdede0b"
"63e4f96faf57eab809c7d2f203fd5ab406c7bd79869b7fae9c62f97c794",
"1e2bf98d1186d7bd3509f517c220de51c9200981e9b344b9fb0d36f34d969026c80311e7"
"e73bb13789a99e0d59e82ebe0e9595d9747204c5f5550c30d934aa30c05",
"12fed45cc874dc3ed3a11dd70f7d5c61451fbea497dd63e226e10364e0718d3722c27c7b"
"4e5027051d54b8f2a57fc58bc070a55b1a5877b0f388d768837ef2e9cec"},
{NID_secp521r1, NID_sha512,
"a1eed24b3b7c33296c2491d6ee092ec6124f85cf566bb5bc35bffb5c734e34547242e575"
"93e962fb76aee9e800eed2d702cc301499060b76406b347f3d1c86456978950737703c81"
"59001e6778f69c734a56e5ce5938bd0e0de0877d55adeee48b0d8dfa4ac65fd2d3ce3e12"
"878bac5c7014f9284d161b2a3e7d5c88569a45f6",
"18692def0b516edcdd362f42669999cf27a65482f9358fcab312c6869e22ac469b82ca90"
"36fe123935b8b9ed064acb347227a6e377fb156ec833dab9f170c2ac697",
"0401ceee0be3293d8c0fc3e38a78df55e85e6b4bbce0b9995251f0ac55234140f82ae0a4"
"34b2bb41dc0aa5ecf950d4628f82c7f4f67651b804d55d844a02c1da6606f701f775eb6b"
"3c5e43fc754052d1f7fc5b99137afc15d231a0199a702fc065c917e628a54e038cbfebe0"
"5c90988b65183b368a2061e5b5c1b025bbf2b748fae00ba297",
"161cf5d37953e09e12dc0091dc35d5fb3754c5c874e474d2b4a4f1a90b870dff6d99fb15"
"6498516e25b9a6a0763170702bb8507fdba4a6131c7258f6ffc3add81fd",
"14dfa43046302b81fd9a34a454dea25ccb594ace8df4f9d98556ca5076bcd44b2a9775df"
"aca50282b2c8988868e5a31d9eb08e794016996942088d43ad3379eb9a1",
"120be63bd97691f6258b5e78817f2dd6bf5a7bf79d01b8b1c3382860c4b00f89894c72f9"
"3a69f3119cb74c90b03e9ede27bd298b357b9616a7282d176f3899aaa24"},
{NID_secp521r1, NID_sha512,
"9aace26837695e6596007a54e4bccdd5ffb16dc6844140e2eeeb584b15acb2bbffd203c7"
"4440b6ee8db676fd200b4186a8c3e957c19e74d4d865ada83f80655323dfa3570907ed3c"
"e853b6e8cc375ed2d758a2f5ad265dd3b47650517a49b3d02df9e0c60c21576378c2b3a0"
"8481eec129b2a75608e13e6420127a3a63c8a3f1",
"0a63f9cdefbccdd0d5c9630b309027fa139c31e39ca26686d76c22d4093a2a5e5ec4e230"
"8ce43eb8e563187b5bd811cc6b626eace4063047ac0420c3fdcff5bdc04",
"04014cab9759d4487987b8a00afd16d7199585b730fb0bfe63796272dde9135e7cb9e27c"
"ec51207c876d9214214b8c76f82e7363f5086902a577e1c50b4fbf35ce996601a83f0caa"
"01ca2166e1206292342f47f358009e8b891d3cb817aec290e0cf2f47e7fc637e39dca039"
"49391839684f76b94d34e5abc7bb750cb44486cce525eb0093",
"01e51fd877dbbcd2ab138fd215d508879298d10c7fcbdcc918802407088eb6ca0f18976a"
"13f2c0a57867b0298512fc85515b209c4435e9ef30ab01ba649838bc7a0",
"11a1323f6132d85482d9b0f73be838d8f9e78647934f2570fededca7c234cc46aa1b97da"
"5ac1b27b714f7a171dc4209cbb0d90e4f793c4c192dc039c31310d6d99b",
"0386a5a0fc55d36ca7231a9537fee6b9e51c2255363d9c9e7cb7185669b302660e23133e"
"b21eb56d305d36e69a79f5b6fa25b46ec61b7f699e1e9e927fb0bceca06"},
{NID_secp521r1, NID_sha512,
"ac2175940545d4fbab6e2e651c6830aba562e0c11c919e797c43eff9f187a68a9e5a128e"
"3e2a330b955a3f4577d3f826529ad1b03d7b60f7ad678f005053b41dc0f8d267f3685c6a"
"be1a0e9a733c44b2f3ca48b90806f935141c842e3a6c06a58f5343d75e3585971a734f4a"
"e1074ce5b54f74bd9342f4bbca738d260393f43e",
"024f7d67dfc0d43a26cc7c19cb511d30a097a1e27e5efe29e9e76e43849af170fd9ad57d"
"5b22b1c8840b59ebf562371871e12d2c1baefc1abaedc872ed5d2666ad6",
"04009da1536154b46e3169265ccba2b4da9b4b06a7462a067c6909f6c0dd8e19a7bc2ac1"
"a47763ec4be06c1bec57d28c55ee936cb19588cc1398fe4ea3bd07e6676b7f014150cdf2"
"5da0925926422e1fd4dcfcffb05bdf8682c54d67a9bd438d21de5af43a15d979b320a847"
"683b6d12ac1383a7183095e9da491c3b4a7c28874625e70f87",
"1c1308f31716d85294b3b5f1dc87d616093b7654907f55289499b419f38ceeb906d2c9fe"
"4cc3d80c5a38c53f9739311b0b198111fede72ebde3b0d2bc4c2ef090d2",
"00dbf787ce07c453c6c6a67b0bf6850c8d6ca693a3e9818d7453487844c9048a7a2e48ff"
"982b64eb9712461b26b5127c4dc57f9a6ad1e15d8cd56d4fd6da7186429",
"0c6f1c7774caf198fc189beb7e21ca92ceccc3f9875f0e2d07dc1d15bcc8f210b6dd376b"
"f65bb6a454bf563d7f563c1041d62d6078828a57538b25ba54723170665"},
{NID_secp521r1, NID_sha512,
"6266f09710e2434cb3da3b15396556765db2ddcd221dce257eab7399c7c4901359251129"
"32716af1434053b8b9fe340563e57a0b9776f9ac92cbb5fba18b05c0a2fafbed7240b3f9"
"3cd1780c980ff5fe92610e36c0177cabe82367c84cee9020cf26c1d74ae3eb9b9b512cb8"
"b3cb3d81b17cf20dc76591b2b394ef1c62ac12ee",
"0349471460c205d836aa37dcd6c7322809e4e8ef81501e5da87284b267d843897746b330"
"16f50a7b702964910361ed51d0afd9d8559a47f0b7c25b2bc952ce8ed9e",
"04000bbd4e8a016b0c254e754f68f0f4ed081320d529ecdc7899cfb5a67dd04bc85b3aa6"
"891a3ed2c9861ae76c3847d81780c23ad84153ea2042d7fd5d517a26ff3ce400645953af"
"c3c1b3b74fdf503e7d3f982d7ee17611d60f8eb42a4bddbec2b67db1f09b54440c30b44e"
"8071d404658285cb571462001218fc8c5e5b98b9fae28272e6",
"00eb2bd8bb56b9d2e97c51247baf734cc655c39e0bfda35375f0ac2fe82fad699bf19895"
"77e24afb33c3868f91111e24fefe7dec802f3323ac013bec6c048fe5568",
"14bf63bdbc014aa352544bd1e83ede484807ed760619fa6bc38c4f8640840195e1f2f149"
"b29903ca4b6934404fb1f7de5e39b1ea04dba42819c75dbef6a93ebe269",
"05d1bcf2295240ce4415042306abd494b4bda7cf36f2ee2931518d2454faa01c606be120"
"b057062f2f3a174cb09c14f57ab6ef41cb3802140da22074d0e46f908d4"},
{NID_secp521r1, NID_sha512,
"3de9e617a6868dca1a1432d503f923535da3f9b34426b2a4822174399c73b1c1ee673114"
"10a58c17202ac767844b2024d8aa21a205707d93865693ac25a24fc87034fa3a7a7e27c3"
"344cb03b87602c15180a5fe6a9dd90cd11af4a0f150207bf2d83f55b12c088adae99aa8c"
"fa659311b3a25beb99056643760d6a282126b9b2",
"07788d34758b20efc330c67483be3999d1d1a16fd0da81ed28895ebb35ee21093d37ea1a"
"c808946c275c44454a216195eb3eb3aea1b53a329eca4eb82dd48c784f5",
"0400157d80bd426f6c3cee903c24b73faa02e758607c3e102d6e643b7269c299684fdaba"
"1acddb83ee686a60acca53cddb2fe976149205c8b8ab6ad1458bc00993cc43016e33cbed"
"05721b284dacc8c8fbe2d118c347fc2e2670e691d5d53daf6ef2dfec464a5fbf46f8efce"
"81ac226915e11d43c11c8229fca2327815e1f8da5fe95021fc",
"0a73477264a9cc69d359464abb1ac098a18c0fb3ea35e4f2e6e1b060dab05bef1255d9f9"
"c9b9fbb89712e5afe13745ae6fd5917a9aedb0f2860d03a0d8f113ea10c",
"07e315d8d958b8ce27eaf4f3782294341d2a46fb1457a60eb9fe93a9ae86f3764716c4f5"
"f124bd6b114781ed59c3f24e18aa35c903211b2f2039d85862932987d68",
"1bcc1d211ebc120a97d465b603a1bb1e470109e0a55d2f1b5c597803931bd6d7718f010d"
"7d289b31533e9fcef3d141974e5955bc7f0ee342b9cad05e29a3dded30e"},
{NID_secp521r1, NID_sha512,
"aa48851af7ef17abe233163b7185130f4646203c205e22bcc2a5a3697bcab998c73a9ffe"
"1d3ea0b7978ce7df937a72586eb5ca60b0d939a7d1c115c820171c89c8116b7e2c7b98cf"
"0f14e4c4df3cb2f319ad3ab0ea25ff14526ddc037469f000bf82100acd4cdf94feb4eba4"
"ea1726f0569336604a473aee67d71afebb569209",
"1f98696772221e6cccd5569ed8aed3c435ee86a04689c7a64d20c30f6fe1c59cc10c6d29"
"10261d30c3b96117a669e19cfe5b696b68feeacf61f6a3dea55e6e5837a",
"04007002872c200e16d57e8e53f7bce6e9a7832c387f6f9c29c6b75526262c57bc2b56d6"
"3e9558c5761c1d62708357f586d3aab41c6a7ca3bf6c32d9c3ca40f9a2796a01fe3e5247"
"2ef224fb38d5a0a14875b52c2f50b82b99eea98d826c77e6a9ccf798de5ffa92a0d65965"
"f740c702a3027be66b9c844f1b2e96c134eb3fdf3edddcf11c",
"1a277cf0414c6adb621d1cc0311ec908401ce040c6687ed45a0cdf2910c42c9f1954a457"
"2d8e659733d5e26cbd35e3260be40017b2f5d38ec42315f5c0b056c596d",
"0d732ba8b3e9c9e0a495249e152e5bee69d94e9ff012d001b140d4b5d082aa9df77e10b6"
"5f115a594a50114722db42fa5fbe457c5bd05e7ac7ee510aa68fe7b1e7f",
"134ac5e1ee339727df80c35ff5b2891596dd14d6cfd137bafd50ab98e2c1ab4008a0bd03"
"552618d217912a9ec502a902f2353e757c3b5776309f7f2cfebf913e9cd"},
{NID_secp521r1, NID_sha512,
"b0d5d52259af364eb2d1a5027e5f7d0afe4b999cc5dd2268cfe76f51d2f17b541bdd7867"
"e23a1bb897705153d9432a24012108979c6a2c9e2567c9531d012f9e4be764419491a52e"
"ae2e127430b0ab58cb8e216515a821b3db206447c235bf44ee304201b483b2a88844abaa"
"18bca0147dfff7e502397dd62e15524f67eb2df2",
"13c3852a6bc8825b45fd7da1754078913d77f4e586216a6eb08b6f03adce7464f5dbc2be"
"a0eb7b12d103870ef045f53d67e3600d7eba07aac5db03f71b64db1cceb",
"0400c97a4ebcbbe701c9f7be127e87079edf479b76d3c14bfbee693e1638e5bff8d4705a"
"c0c14597529dbe13356ca85eb03a418edfe144ce6cbf3533016d4efc29dbd4011c75b7a8"
"894ef64109ac2dea972e7fd5f79b75dab1bf9441a5b8b86f1dc1324426fa6cf4e7b973b4"
"4e3d0576c52e5c9edf8ce2fc18cb3c28742d44419f044667f8",
"1e25b86db041f21c2503d547e2b1b655f0b99d5b6c0e1cf2bdbd8a8c6a053f5d79d78c55"
"b4ef75bff764a74edc920b35536e3c470b6f6b8fd53898f3bbc467539ef",
"1dce45ea592b34d016497882c48dc0c7afb1c8e0f81a051800d7ab8da9d237efd892207b"
"c9401f1d30650f66af8d5349fc5b19727756270722d5a8adb0a49b72d0a",
"0b79ffcdc33e028b1ab894cb751ec792a69e3011b201a76f3b878655bc31efd1c0bf3b98"
"aea2b14f262c19d142e008b98e890ebbf464d3b025764dd2f73c4251b1a"},
{NID_secp521r1, NID_sha512,
"9599788344976779383a7a0812a096943a1f771ee484d586af1a06207478e4c0be9c200d"
"42460fe837e24b266c8852d80d3c53cc52ffb1913fc3261145fc6da575611efd16c02605"
"9a2e64f802517ffd1b6b34de10ad2909c65c2155e8d939b8115400c1d793d23955b15f5d"
"1c13c962ff92b4a815cee0e10f8e14e1f6e6cd38",
"1654eaa1f6eec7159ee2d36fb24d15d6d33a128f36c52e2437f7d1b5a44ea4fa965c0a26"
"d0066f92c8b82bd136491e929686c8bde61b7c704daab54ed1e1bdf6b77",
"0401f269692c47a55242bb08731ff920f4915bfcecf4d4431a8b487c90d08565272c52ca"
"90c47397f7604bc643982e34d05178e979c2cff7ea1b9eaec18d69ca7382de00750bdd86"
"6fba3e92c29599c002ac6f9e2bf39af8521b7b133f70510e9918a94d3c279edec97ab75e"
"cda95e3dd7861af84c543371c055dc74eeeff7061726818327",
"1b7519becd00d750459d63a72f13318b6ac61b8c8e7077cf9415c9b4b924f35514c9c28a"
"0fae43d06e31c670a873716156aa7bc744577d62476e038b116576a9e53",
"183bddb46c249e868ef231a1ebd85d0773bf8105a092ab7d884d677a1e9b7d6014d6358c"
"09538a99d9dca8f36f163ac1827df420c3f9360cc66900a9737a7f756f3",
"0d05ee3e64bac4e56d9d8bd511c8a43941e953cba4e5d83c0553acb87091ff54f3aad4d6"
"9d9f15e520a2551cc14f2c86bb45513fef0295e381a7635486bd3917b50"},
{NID_secp521r1, NID_sha512,
"fdde51acfd04eb0ad892ce9d6c0f90eb91ce765cbe3ce9d3f2defe8f691324d26b968b8b"
"90e77706b068585f2a3ee7bf3e910528f7403c5af745a6f9d7ba6c53abd885c3b1be5834"
"15b128f4d3f224daf8563476bd9aa61e9c8518c144335f8f879c03696bddbe3ac37a8fbe"
"de29861611feaa87e325e2f60278b4893ed57fb0",
"1cba5d561bf18656991eba9a1dde8bde547885ea1f0abe7f2837e569ca52f53df5e64e4a"
"547c4f26458b5d9626ed6d702e5ab1dd585cf36a0c84f768fac946cfd4c",
"04012857c2244fa04db3b73db4847927db63cce2fa6cb22724466d3e20bc950a9250a15e"
"afd99f236a801e5271e8f90d9e8a97f37c12f7da65bce8a2c93bcd2552620500f394e37c"
"17d5b8e35b488fa05a607dbc74264965043a1fb60e92edc212296ae72d7d6fe2e3457e67"
"be853664e1da64f57e44bd259076b3bb2b06a2c604fea1be9d",
"0e790238796fee7b5885dc0784c7041a4cc7ca4ba757d9f7906ad1fcbab5667e3734bc23"
"09a48047442535ff89144b518f730ff55c0c67eeb4c880c2dfd2fb60d69",
"1d7ce382295a2a109064ea03f0ad8761dd60eefb9c207a20e3c5551e82ac6d2ee5922b3e"
"9655a65ba6c359dcbf8fa843fbe87239a5c3e3eaecec0407d2fcdb687c2",
"161963a6237b8955a8a756d8df5dbd303140bb90143b1da5f07b32f9cb64733dc6316080"
"924733f1e2c81ade9d0be71b5b95b55666026a035a93ab3004d0bc0b19f"},
{NID_secp521r1, NID_sha512,
"beb34c997f905c77451ac392f7957a0ab8b23325bd5c63ca31c109ac8f655a1e3094240c"
"b8a99284f8091de2ab9a7db2504d16251980b86be89ec3a3f41162698bab51848880633e"
"0b71a38f8896335853d8e836a2454ecab2acdcc052c8f659be1d703b13ae1b090334ac50"
"ab0137ddb5e8b924c0e3d2e5789daaef2fdd4a1e",
"0972e7ff25adf8a032535e5b19463cfe306b90803bf27fabc6046ae0807d2312fbab85d1"
"da61b80b2d5d48f4e5886f27fca050b84563aee1926ae6b2564cd756d63",
"0401d7f1e9e610619daa9d2efa563610a371677fe8b58048fdc55a98a49970f6afa6649c"
"516f9c72085ca3722aa595f45f2803402b01c832d28aac63d9941f1a25dfea01571facce"
"3fcfe733a8eef4e8305dfe99103a370f82b3f8d75085414f2592ad44969a2ef8196c8b98"
"09f0eca2f7ddc71c47879e3f37a40b9fecf97992b97af29721",
"0517f6e4002479dc89e8cbb55b7c426d128776ca82cf81be8c1da9557178783f40e3d047"
"db7e77867f1af030a51de470ee3128c22e9c2d642d71e4904ab5a76edfa",
"1c3262a3a3fb74fa5124b71a6c7f7b7e6d56738eabaf7666b372b299b0c99ee8a16be3df"
"88dd955de093fc8c049f76ee83a4138cee41e5fe94755d27a52ee44032f",
"072fd88bb1684c4ca9531748dfce4c161037fcd6ae5c2803b7117fb60d3db5df7df38059"
"1aaf3073a3031306b76f062dcc547ded23f6690293c34a710e7e9a226c3"},
{NID_secp521r1, NID_sha512,
"543c374af90c34f50ee195006d5f9d8dd986d09ad182fcbefa085567275eee1e742bfe0a"
"f3d058675adeb5b9f87f248b00a9fbd2aa779129123a5b983f2f26fc3caf2ea34277550c"
"22fe8c814c739b46972d50232993cddd63a3c99e20f5c5067d9b57e2d5db94317a5a16b5"
"c12b5c4cafbc79cbc2f9940f074bbc7d0dc71e90",
"1f0ec8da29295394f2f072672db014861be33bfd9f91349dad5566ff396bea055e53b1d6"
"1c8c4e5c9f6e129ed75a49f91cce1d5530ad4e78c2b793a63195eb9f0da",
"04009ec1a3761fe3958073b9647f34202c5e8ca2428d056facc4f3fedc7077fa87f1d1eb"
"30cc74f6e3ff3d3f82df2641cea1eb3ff1529e8a3866ae2055aacec0bf68c400bed0261b"
"91f664c3ff53e337d8321cb988c3edc03b46754680097e5a8585245d80d0b7045c75a9c5"
"be7f599d3b5eea08d828acb6294ae515a3df57a37f903ef62e",
"0ac3b6d61ebda99e23301fa198d686a13c0832af594b289c9a55669ce6d6201138476901"
"3748b68465527a597ed6858a06a99d50493562b3a7dbcee975ad34657d8",
"0cef3f4babe6f9875e5db28c27d6a197d607c3641a90f10c2cc2cb302ba658aa151dc76c"
"507488b99f4b3c8bb404fb5c852f959273f412cbdd5e713c5e3f0e67f94",
"0097ed9e005416fc944e26bcc3661a09b35c128fcccdc2742739c8a301a338dd77d9d135"
"71612a3b9524a6164b09fe73643bbc31447ee31ef44a490843e4e7db23f"}
# ifndef OPENSSL_NO_EC2M
/* binary KATs from NIST CAVP */
, {NID_sect233k1, NID_sha224,
"f23f784fe136c9fc0d169503d361e9c6148b0f1fbdcae0a97fae1af7033ddef25cb7489c"
"9963cfcb009a8cbfe44a8510a64a073eb1deae4c324ceb9302008c92c69b2dafcc9077fd"
"3cc3c7c119edc3ced36d176ceaa55ac036bf7f07f6fa215e8bb8196e59a5e1c9af4f98b9"
"0ab4970885bd7015fa26a09e03c7cf6b4b23d929",
"04c1d414696cc3657dd9df73ace56eda2636769ce7082e064c260be45a5",
"0401f228c0a75b057eb07fe7ce8223ed4163148c1fdab61e0f787271f836a900cdfa5655"
"d96ffd5ffb6027bfaa04da7b5d8fbdbb6202c8bb79f056ce43",
"058f8511089fcd59324469f6736b92693afe26bd4719e198f1f2287dc5f",
"016bafefb4933ffd00bd1db6d6c4fac8a06375603adc0aa2a5664083ff4",
"03bcb84b8f1990cfc7b88f2b8cc817105cd8e150808e7c87b310cdc47e3"},
{NID_sect233k1, NID_sha224,
"400bcb297552bb37f2f8135a9314a35f5126788bb6fa4dc74152731ff64c5dab4b902103"
"d85443dec20e16b1d6629930cdc2bd183d4099f0e96295a63c2fe266f5e9d050c401a868"
"1b4a438efe53cbd8f2f43e2a31e9f88926a9c82917d873f6e8cd5ff5eb8c1ca36126b0bf"
"c8c2b0e85a7c9e7a45f1875ca9c82019ebedb729",
"027cb1d84865a16992476c9e353283d5d6a40c349a8e9179d1b1f403531",
"0401191227d064176f4ab020faea61330df5eb59163ecb4ea59c23e6f1f6c8012dbfbf85"
"b3624b9f56446f840602f9b839bab1368295b3ae919cb07c07",
"01a41af270269be052a62a9879638e3432a1479b05776ce61f45c0c361b",
"041a5f1d28b70bfa2925b9428ab8bac9fa174d88ae27d754824c7d16ead",
"044d359065672b3d3dfe8389fbc6fc751ca6a46820626c466174fb9b922"},
{NID_sect233k1, NID_sha224,
"5f74d4b35c49fa454c97c05fdb6b9f6822cf1a2295f15bd766dbcb413d77c910bd8f4147"
"e8f317fac2300fa21cb80134d1b6f8ae8e50518c1f648a28506e419f5a6e8f05abffdb3d"
"d2587606c7e9c223ecff4f46b121216730ea13202b59128a7616bb2fd23a7e4a5aa08641"
"cc07b669641313febfc88d64d99447353dae3f06",
"031b443f46c4b5224237fac1022ee1570173f664aba0c84dbaa4246bdc1",
"04005f57b0e5f2e175006f4058cbb4ca9a0cac912c551ef1b94e97498fcc5a00f3a554d0"
"77b751478f8a2b7c2a9cf15effed958e0ac1a9e3db1e023c5f",
"07ff6ef3026c5a960e632beeb7313b3bca0baec76cea1fd9b82cedc3245",
"0099741698549c32a4e86aab6194527cea703ff869849c538a938585a83",
"02ad706c6f5dcff512498d84f1877eb997dfbe9b3d13b339917632d3cb1"},
{NID_sect233k1, NID_sha224,
"8f92096876d9f81bcd992369d42d0b5877ac969004d17c8627c58d8b8b7bbf7a37e8cb6a"
"fa962b9b043bbbaa5bef4a5ee38d8bd31cb5866b828265a2f4102a616f87009cd346fcb8"
"af5519fb577c60d8792472232f33dc615655e53d2b715b15a2697b492f108b7906e1e359"
"7c6911f8cc30c7121ae338a6b747ec368f8e4a36",
"048f6ca29f35f253a4962734357c995920967b9eeff1ba5fd2080bfede5",
"04012b7ca7c21292f8795b2fbfd63a28c5a4ec8c850d6240f973c903bc817001be9855e5"
"c5a5064c27d1862010b2fd0d7be5a0180c861a288ceac89d6d",
"07dcb9725323fd7668991ce9a907b7129d53fae9016e253c53d057d195d",
"0498c4fca6ed7c2998347b464d3e562a74b0e4f3a6c1dc453aaa61bb710",
"03a77a13f011404d5c5341dcd2ca44dc2b08f21f09f524045c281fb221e"},
{NID_sect233k1, NID_sha224,
"3d275dbde44494c45fc15fe89e2ae32aa26426a17e923e895c7941a5582fb95df4d49873"
"ab1bde358017f336b911b886b626b744806ab8113418473c441f1964159ded1b12122d53"
"ac56573167588e4b55f36b8bca8c67823883a51fb6e7f204d1c6b07ea49b577bfab9ca6b"
"8d51f72268b022e3a4db6f9d265ee8382f9b7b66",
"019b940eabbe682f961d9f3d90432e347fef3910e641656825d775705b1",
"0401efcc9f4576047c43eab1c13e0547b1c5ec1cd2afd2345fda72b5e1b50f00c7b5968a"
"f47e58f4ec15c0cd82ccd0b9f5bfde06c7f86fe5cd0105d693",
"03f783a94d1de73e4593f5d6d02238cfa0486e3ddf2bc0b95a528038e3c",
"013c467531f3f6508534ad072edb210e4182ce5a798d8a46674e92a0b4d",
"0685982aa8e2f3e46ecc03e00e7323f3b891da437235cfe9800139ee8d7"},
{NID_sect233k1, NID_sha224,
"d2fa68e1f7dad02916b12fa38f1849d6d409dbad0344438520b4dd9b77d62d39ac9ae3cd"
"eab03ccbcfd4de703c6e798873671731c108f322b9f2a68145e3e210c9b15b879798e5c5"
"3c5022742e9819b99edabb2f44d89ae221f7a99dc84421a6905695ff91928db608f86174"
"5f17584d56e34b75c47281435b1b0b34e490692d",
"07a884b22e29fa9fe945e9ba13c0df8d786dc87cef0f77f069e182dd56c",
"04011e831647d0ffd53d75e44abceda753ab470b3cc93b457590617d925a19003db5bd0a"
"ecd6504d904bcf9dcce131abd239aeadb9a64a9811eac823cc",
"00241b763c6245b83afe61762b161c41467ef35b7f27a9c1066f02babd3",
"0514adca3481ac5f99287e6e966a5c223296b07a9456eb582ec5568688c",
"07ff6a2f7cb1d2594a11d8d0adb6fe50b4e740f025e7b4333ee26163d92"},
{NID_sect233k1, NID_sha224,
"3830f75cf9df4eb2998c7c1b5fe11c1476bcf849c3a8fa7d3d0b5bc2292e5d07465ab8cc"
"9381c575d909e509c5dac49c78817c04e4bef18bd51bb09aa5897f21634633a5ce6d20bb"
"4638cb6c3927351eaec7b62cf4a33956916045c392f325adafb10a88a5f86d7e41dd7790"
"8fa7284210071c22aa40ef40da6339c02da05392",
"05da61f881d5a0dc085bb93764f584352882923cd237d878220ec624c1a",
"04018d740441eff1f785a14d04da4ba69540cbb469780ffd36e1dfae4f1de2018072ab30"
"e999ae26b872ef46a9a0604296d02c08fba9477d9e03f0f75d",
"000f95c5678fd08dda790cc60bfa578118f8687228a2ef5f31e71a6884b",
"074a6599b8cab75e0cf752e3f41288fbc673d52074950edb14f76524949",
"03523804351e3224e816cd4fb7191f332585f68053ddb32a85cc0fadc03"},
{NID_sect233k1, NID_sha224,
"65b9fe15e6c35d453caa6bad39ee78a720a04b60d8a0a0f049186d2f777e48ae2d657e17"
"4df53edb7beb9f7d8f21904ed674add0cda5b62a7308de76c324a144021e8c6d387daaba"
"4ce48bf7dfe9c8aeee2c64e434ece1fa5ddcafcf3e5d0013a1eeec1742a00d384cc2ec0d"
"7eda83bb4dccfb0e57045ebfc27a4f404d03da37",
"03fe9f04647f6d82b13ec1ae5a8c2e49bc66b05649ad778eb16149ad83a",
"040158eecc6b8918e7813ef990217c603b28ed1774c740382a8af5c9af613301bbffeccd"
"41107c7e6f83e24c822d634a7ec064fae125dc8a3ecc4fc9b3",
"07731edfb3ef523a165a1b5817ab2805a5cf88043c98ea2393898e19551",
"01fa44fa18ebafee6f419fdb9de0e8365520617558b57e9ee89f2c8fc88",
"053f1b2da4cabad04fea1111d525f341417587823fce71e5bfd2353c2f1"},
{NID_sect233k1, NID_sha224,
"d26521fd41eb5d46ece6836e188bf9cb1b461d011c41e002a935d256654d01725378e845"
"920ec4a7fd3f379df54772493df50d312c7c6aa4e909e7b83f2442c3a5e85c37d68aa015"
"098ecfb0a5e077370f4576f4bc63bf37e1dee06d780a3b6949af5e21c2a0960fcd20821e"
"f5f17bebf5fd5b3bdda260842cbbfad45667287a",
"05ebce648ace4cd555413de6a456fc487d14bf4b0b9a72311ef480d2f26",
"040020b46ecbdc36b4dc01111932090ba185eab2cdc4fa89775f2a6177c5920104cac1c8"
"00103c79642321a216bcfae497b037b29888cf9f70c507114e",
"027733120626e564b06ba71c4946c9c8bfae43f88511ec6352d2a52f407",
"0592de5184510e6ecb7be8a011f862470b918354a1ad82458cf716137fe",
"010a9c5fb6e4b70571a35c56744b57baf0108728bea2bf639af1960d1dc"},
{NID_sect233k1, NID_sha224,
"b778c021b1a92c41dbd09963da07018075d73e54d62df5c2b7bf8abe137151650d1c1c6a"
"bce7eebd8f32e8c3e6d1433773f257bb3ba4a4fb6a02c0db1e47d03c27d3a90898ebd192"
"7c21df24c4c5443ca5b81f8ef2cc0f5e8b3d08f472bf07085df737adaedec63d99acd77b"
"87ba98225f198b791124ac2d9b191cb9251b4b00",
"056653c2f85593f789a926ba49fa3da9d7f946d8f1020508c5a527ce813",
"04010d65f6f5415dd86a83bb10118abfc1b1670a1664eb6dae99fb68b85019012c1e673e"
"575086ec1e76b90d59c2cbd2727f726f88298552b678ba7e60",
"021e26c098c9f9da9c782857fe640ff6abb21caf20a093f2277845bd10d",
"01d67cbc8209494dca1a74cee5d9894f98f03728214f7bbdac29b0c0e78",
"02215f758fcf0d8dd603e79658a8061ab45bfe6d854e52ea7074fd5654e"},
{NID_sect233k1, NID_sha224,
"ec14e07f615960015a489ef999e308b42a4c571473b9bd64b433dabd9a1b1ad02e33eee9"
"100064405175928a94543a80f440040afa2965b4e5f95f768e7fab6d3c0a5f5e1bf1df78"
"22f78384e80f2955ea85f044ac60537d895747979f935bb0cd3673193c4a32dd7803e48d"
"7daf70a71bc2aa97236615b6411e28fc9a652145",
"049a91d320783cc70a5952c32036cfc75d41f1aa84127db2dc759fb291c",
"040190528df8fc3ae4db6e12930f176ec9c833d1668ac5808f1046366445a401f647d55c"
"e80b18a9add47fd1a8e4aa725297d9da03246f5c1ce503dd56",
"01eb80e2596d6c01431e7a4fd9e22903ea85547a31d675ff157a789a137",
"04523776d88199ebac2f96f9faa434bd81bde770ad4458ef126fde9198a",
"054665f31f92f8897482d34fcb63141a7539577037c84496167e9d3389f"},
{NID_sect233k1, NID_sha224,
"89c645339ad0eb850e4e2fe583cee175b35feb02ed7541d7e9aace24cdd3939584f73ad3"
"9526de6399c86b36de77a018e2c70b532bd0f032f9137d10480acc30c49f9baaa86f9df0"
"033b77e98b485bf7a69cb5c281e527d3ccd1fce2415f0dda4a268ce68a0a34b16afda54e"
"d922cd6810ac8dc766df2a3a6c5e55972e9786fc",
"016a20016602fc7088a60469843e1d29ad67e3c3cb9500b1e2a00d4050a",
"04004f157541dc3a8bc8a2ad4dfb3933039b67e331b7353a2fa9ede322f4ad01348a7b8c"
"9495bcbecd556870715faf3d543cb8f2368805473bca17b82e",
"01df1ee39217d7f0d838e8b2d30a1159d8003b06e50a00d637edf08d6d1",
"045d16826bbc425637e7a05b826bc907f7453c70141d1bbd2cda63dd490",
"01ae1703cf179dfd1d5407ba2b7324cc7cac15235ee9c3756177444e122"},
{NID_sect233k1, NID_sha224,
"ace14c4b101d2d8453c2bc22b756af016b5de537df9c3e639d208ad04ae0bf6232dc90b9"
"0c33228dc85de956db771ffde05fb4d0b15e4f218ed2771d703ae5bf981252a5bcd60c16"
"f14483131a481cbe04dc0adb1fb8aa32cb48bb5008e8a8e5c7b7465be2fd7afbc811cf5e"
"a6293b1a464669b49f55f57b93a8707e6042fda6",
"00ba922149bada2551b7be1c3df076f3f97ce93c13c50c285fef3f42363",
"04012daff2cfab994b9d1d1ba73bd2f8e7883b2d92f760b0d16351ec125fd40115666f7c"
"65b95ec2d713c5ab1a3eeaaf0f931b1859733416c3c778aa2a",
"07fc7c9503fabba0972e0e8892ec6331e0812c6452d211c5561fde79048",
"06477ec9d8d8d45418b9efe7ae47c0863ff94c43d8f392c079b870a7cf4",
"06b5a5d020b3d980b9d7880130802435ddb4e7362e36a70d193f18a7fe6"},
{NID_sect233k1, NID_sha224,
"cec2ba0d1772c87e87d5bbbd67220692bea4301aa1a66e8dbdd7e651d45c26dc2a0d45cf"
"c32c34d76ae3e1c61db7b0fe1863457b93937d929e6ece7462ebd16adfd708353d6f7c27"
"aafe06593c76da7149b0cc574a4290b0d8fe219f3eada7082aca38dba3f78ed0d5942d09"
"5fa5556fc8bcef331ff0a6d5d1f4e6c51d4ff5af",
"02d635e12a58cc6dea44e71e87c37f91e8d08659f0b7955d24f65ab55ba",
"0401dd33d8224ffe63a32f2de5d4fcb0e5f1fca7ca2ade5b35ffbe75cdc65800bfbe9dfe"
"13f99258c787af82631ce2133dc73207c579b29869c7463943",
"04ef333049c575d6688aa04f87a6162185e4a57bb752a7f903e3aff86ff",
"01ade04af08ea1c1877779fbf6335156b1a1437f3e449f07458d700c67e",
"010fa82467d39e5ad51cda8fcedc72ee6a78dccd0c90544814e53ba9cb4"},
{NID_sect233k1, NID_sha224,
"ffa13cd0f51ae2643d5d4edecb493ddd653e9faddcffc370e7e958abf726a5d67a2ab36c"
"ef42ea8ebe22a6f01b9c31f6ffad01e6894487d979acb5e618f765ac0ec3550ac5dbbced"
"e8f9fdbe52fbaba5c087ff382b6d7a09b2b5084227d324d98ff98793040884799b96d2ca"
"593201f4414f18c43b51c53c5e5059e0641aca02",
"0073883e5064e06814fc4de32e15f7a6cf825d2daf6eb1df8c83e25d80a",
"04000d3c79d627ee0d2d88f2de2dd082112c20dbc5ed66089454f7b8fd9f8101a2580e77"
"9753bcb023acba1b0852492b989c767f664c7047de8e6689fb",
"020231e05166271f47a91dd883c580ee313e9a07195ae511f0ee62173ec",
"0303eb4a0df97577c4cff531b3f54aa282e76669c0c5ebf4c9779c9bb82",
"0692432a7dfde09db7743f08130b3d3327dd98cbdc323627603518f70d7"},
{NID_sect233k1, NID_sha256,
"c73e3dbac9513d0361dabe94071faf03a11cba18c06d131a172d5f0125b01a5eeb6055bf"
"72c7106fe3f4be3bd2b1771cbe7f85366dccfbc3bac20538510c3f51179cc540ddafb2f3"
"b05a0d276899674ab1d7d8fb4f6838f04e4f9e26b8c6af31540f63f4953c85840af4c57d"
"fa78c704f637dfc8dd750fe45e2c1e149986d127",
"01532271bfae8d4dfe60f69b88d3006d58e28aacfa701861cde8d624db6",
"040041c1ca965338976b4c45c28b1cb64836b3b4d3e7ba2b1323ea26fbcca201a177d042"
"fba7903007db122eabc459e37c2c7fe82e42752b267fafe4b0",
"06a54894825644901baf2ec3681ce5aaf93a18757d93ec9cbce7ccd9d65",
"03edb77fc7686b520493604db18fc69edb4cad8195a958e27ef289c4bac",
"004337ecfac57abb9271909aa43ff4e32851df7818dcd87216d051189c0"},
{NID_sect233k1, NID_sha256,
"d00dcd0f3212a3167403abed91c20e76f5e7a7678a4fd970f944d11e6a8cd149d0aa6fd3"
"164c5a74c0f55193a4fa3d8ba6f99cabed10544625a7bd92b3e0b46edbd4a269bbc10518"
"c5268c3910a2aea567ccd32d4c7a0cbef09ea42c20b636d1f711d220e23dacdb9d1146e0"
"494401349749e5ed88e38295232a7effbae3aed6",
"0550406c0db882c6aee6cf3b6baf377375208c3e90cc44a067cee43efcf",
"040073348eaa8f2885fca3baf31830a2b28bfe983e3046418561f62ac5d24700033de5ae"
"e6d0bd4de286f1de1e80bf72e5e17083032bd4dc24577b6d2d",
"05c0e7ad0f9bbd522c862326a5734a766423fff7efbe57c51c315fa574c",
"02103f1a0200883850b6476c7d7e7d2b3e2f60923d028ee6f8227b1ec48",
"007cbbc3c6295ceafb3d9cf8411f85a045b11ef8472c5ed45346d26192a"},
{NID_sect233k1, NID_sha256,
"3d36221f87157ca4db84884b8666660c4e2b6af330480c516cded9f3bfe132543626a39b"
"b6aed1964eb5c33ea0b95b9841665417679fceb95d199d55accfce35dd3f2283c1a7ced5"
"7d0c4b9ebe3da6e1ff2f979b6440db27caf9f6a4bbfa47e20d29ae304f4d0551fce9cc40"
"97eb2fbedb9b24680bb17d207bdccdbe799d5b0d",
"0257dc63752920b6854d6c2d1cca68589a38418c3d036e73760a12214ab",
"04011a42e9f66ecf030d0446cfb751136347d4df0ee4e031058ebdcc04df8000fb7161fa"
"c8cc5ad7bc4477a39350e419776f76f184e28abce886ae9cc5",
"00391d36c4044896ddcd68604d5f677d1df298f46abc00eb12f1165e8a1",
"04e19bdc6755a603085b66355256bce98d5fdd49b4f06b628e3e185574a",
"07697b29ce5546de969c9c4bbb5ea65f712d6cda3410f3dbfa0cd5b1a8c"},
{NID_sect233k1, NID_sha256,
"033d82a42d0eddf58fbe3e91ddff7190e3f9fc2b1e2eede977d2c0473b358b5fce1f981c"
"a6f88fd61ce2f79e453e3a2b77d1baab2b970ed28d5dcff58873a620e195085e61c4b848"
"0d829525a1a944e8a4b63352f0291f0311f1f98ceb262804beec1c74947618f8e3b06786"
"6255878c2502966cefcdda4f5fa2b13d92ce7840",
"029025352297a7be850f8852411c09259b83219135e0e8949c1bd5b94c1",
"040184345e37f07077cc8df5947c1b1fcd8404b3c31586d6ebd91b240cf42b019dbc9091"
"a5d282fd6e62c34676a06a425e098567b990c47e61ef14d77e",
"02b2663a449ead3f8cce2459e04cf84333376624d994fd9312401ae57f1",
"03af223fd3a6b6b240e59dca83ce2477a577494438ddee3fd09632ea67f",
"0606576d89f2094572f0bbcb58a15d9a4bf10ae3667d4e35cdd8da32102"},
{NID_sect233k1, NID_sha256,
"671a7c81b64b2919722d7b258bdbd90165bb757b53106e0af03d0eef27452942f40cf52b"
"c95cc7f6567df2613cce795f8bcfc723b2735efc35375c001d37c58480d89343697146b5"
"24835df3dbd333f7c06c98e36d3c4592ecd1f34ab57c341bb0f4c785f5b8372775f74b4b"
"ce60763fad1788e77ea158d735a64861320b36c6",
"02dc82d0e69e498528925c0e62a13fda9af8cefd047c10c3ffc2e41da3e",
"0400e5463926235ce53a85b489c3c278320ed986003962a5fc7ad4cbab0d9f01453e6edd"
"e95670a4653186ebd8246c28a94dd84f5a669bd3293176f1f0",
"034a8dfbbdc98bb1d9b175600bffd866306dffadcc4bbb6f24e7f918da5",
"03cf1407445cf1a619a280e139242056c23c58979f0b3f0aa7e1fc074e2",
"02e55f27593f2c76fafccb71493f14daf50073b35cc85f002528cc6d691"},
{NID_sect233k1, NID_sha256,
"0ef677f4799298f4aab73b7393598041f56e902ced1726af49657b6601a06186212e3ee8"
"cd4bd33b760dfa2ea3c38884f94358d51dd479f2ccc8b0b352fa4e44fcfdcfbb24919d04"
"e6ee1108527b8e8d60e8d1b467c30c18c5455e5835d483161d3fc26b4a67d6df9e3ddd93"
"31247cb18450188752a1ca219f3396a872cb13d8",
"041535fff5d279bcd744b04e643458ce20b81df8a9e01b1181d52bb14e4",
"040021e1227457be78e49db22335139a136ba290d34871f90ab5e6a8db6ac100df43b381"
"a4d757864c39ce8d0b64d6a32e9e8be30f92a10a252d46a2e2",
"03019bd459b34133dc7331caa8976bee67f76db3a45b1793cb545e26c68",
"0025611bd4e3473aaea85228b2bf37eb1b4458d8166012aa098d9c1cab8",
"07acd38506e984fb7f1607b50837018f9b4246623dcfc9d7aceb486e76d"},
{NID_sect233k1, NID_sha256,
"9290df0cc50c3cab6655f3a6de1f4cf613d9bc06ea7c99f38038369ff2fadefa57a3c7ae"
"7940c1b98bb1d03503cc271f7a891bf38eec93c31dcec7892dfd2e1ab337bedde3e5325e"
"d8d9cb7fa3096f6fafc3beb3a66cba66ba826d1032debfb4908cc9dded8c0099c85072da"
"ac4373fbc428fcaa9a6da02181ebc33f0cf926fb",
"000ecfe580a624df66c25e87e7689fc3b471d205970ff9ab51a64aa12ed",
"04002ca7b9c98bb8106ae14a87d5f9f7ae1f99a5524992116e68af89da6daa00a2fbee76"
"9eec313cf3c8519d3f96167477f0f06dcc470408e3f637b6c2",
"044f065c49bb7ff0772d628104bc2e222f1fde42aaa8b9345d324d7f936",
"046301f3f07922d338d5b7d82104597fc50941e4bc0a15ab5e0408f9fa1",
"03495e335905b4842b97f00b344313ca7d6a4ff60cfeaa5d589e0a31782"},
{NID_sect233k1, NID_sha256,
"855c7be75fda372f062709827f333630acf28954a62a5193ff675f0dfeb63f32bca418f7"
"cbdb346bf388d62315b19a592267ca407120db93d4e3d7125b867c4c4670b7a57a76f617"
"34cead2caf2425eb9ff0a63293e8cd6defc9648257b401463f4533a2425e0024f1ea9336"
"5eeee3c6da20d25928602ec8b426f9b39f97f3fe",
"013c72c73358ffa168423149ecdd897f0a5f75a641de008649f00134944",
"0401c70e1b6c01477f95e718f193e13c093b101e9f16024082ac699ed6ebb601f8013a88"
"264266cb5cc5bd38e477fe0a1aa49ae4a5ff94cb58439a7c1b",
"07ad8a117f34bf2fcf7d689b8124e08118e28ebd172f8c220d57d3f0b88",
"012bc7d380192f2efe55625e39927ef799993af9451c662b562a239dfe7",
"035961b27e88d6731220f70e96d555f63853d14149df7bf6d24fc29441d"},
{NID_sect233k1, NID_sha256,
"9c896f800281812ed57d31623d563377a5c725cec84313472b90e73f77d400f5d4fb2362"
"55741b73d46f7e5254d04099bec274db8a9af5fc7cc220d42cc172cbd3c3595c49ff74bf"
"aab7b5e46c90855b611f74753ccdbbabf92e011d52e9ba753b83ed2a251a632e1bd5c6d3"
"46e38e743950c8ce0f394a837028575fa44bcc26",
"00ac60e2e70b7c4cda64071c7738f68773c94df9456a8ec3bbb468fa7f8",
"04000109614a2ca27b7a749e53777e0f3ee2f57013ee83ea539ada6d98d8a9005668f4b2"
"7213a8a024455b398de2cd7635cb620d7401f5deb4fa9ab2f4",
"00098489f0966e27555268a94378b7b8685ac610fb0964694aae9aa716d",
"06d151437a0aac232a472af038b0fac095d224ce0e5487510e30c31d605",
"0563dbfd021c1b77f980530d0120e93c9ee4f1f092a268bd8aba7d3110e"},
{NID_sect233k1, NID_sha256,
"139a14ead998d1a962fa47c47ef2953aa136bd912fe940709b8c560bc2a0c4bf8f3aab30"
"a8e21b7d5f487d30b0097e3da723f11b5cb4e8c5724f5a2fe0d68ee4bacbb85e5eacf180"
"94d2a8ec4506cf8497836a4a905059a998ea750adc54c27c69cbd0b0c1f9743a62f3d988"
"f3fa0a9865a73fc071f526623085a2ef12838888",
"060bf720052e8b9508a801340c213cf53bbecf4975faee63d4b44fc647a",
"040196e37671def44b35c9e8c719130389b40c7ebc0ed5ae354dc73e0c40c700d3fa0a45"
"a3cc5dfb61085290f6d18d710ad5d0d3ab31ce65b0e6915a72",
"0729c7e1de10e92634857a65a2ed75103df6bd4bf63b1ad6383c37a0435",
"06808491ffebf088476de7daf541bca3fd943d4c2089b848a130abdc0d3",
"02c0dcfff06a07e928c15a1fc2aceaa4b4dd6fe8eb67ccd4d01240f249f"},
{NID_sect233k1, NID_sha256,
"cf4a8e754b23d0fffc1c5c80b0cb11deeaba3064b315bc2cee96db5b9881baf90d30af4b"
"69066f757b3020706def77a5fc1632d96bafba22a9c8cd3b52d535d941b3c7cc02b7fe6b"
"51639d5e2084478ab3a29d2f5e0e16639fc2833a47b58e2c3fb5b2ea1830fe2ff68e571a"
"8f281617a23d9a28db1c64ddfb1083d055030e5a",
"07cf3c216592febd8630a478b5b3e3a605084020322adb13ac0a626bc7b",
"04008eee2ea13a08d4e4d71ecd2547f6d80b8f88879c9edfab5a675831fef2005117c0d8"
"a0442ad7b95cac1a984dfb9efbb7eb3c3866955da60e6cea8a",
"038de0be25c23cbde9ed9fb259cd9a06b69bf15dafed723970dfcb91307",
"051c9c5fe50eb81a11c8e7b2db145c6b5dbff2c51def56f4981774c357c",
"053887c6cc2f21bff461c9182c17f634ee2b301c3cc4af0bb1d3075f74e"},
{NID_sect233k1, NID_sha256,
"ae64030d4af9b36c8d3a6af0aff34e5ab201df04274691fb420b7d5c40c401ed7f3ade96"
"065d34f2490d17943e27156e7bed83cd7222d0d5a73d167855fbe7ff6c3ed87f20986ad8"
"bbbd80fed5f9705c6c783b423f641d40ff1f367f9648af5a79ea3cea0236997558bd9dcb"
"011ea4dc64d61ea1e1f85b4f696ed586bc7705be",
"061eda5999e5a9ed4485d2a0ac5510549b76ca37df858ea5d95aeed571b",
"0401642d56359cc0a5f261fdc405030d45b0d6f9c08a182d354bf2687dd9d5011bf0dcbf"
"62749a99e4b02b284aa7a6479b59b363d25319a5315423a589",
"03094fac5381a1b31e53f43a537d9e22ebe6bd2c149f2f69d792bd56f53",
"053c8c4f9a30e0500e01100bb97c00ce98f5cc6578686daa1bdbd679373",
"047086a88ea014f06d6345608bd0a6010e650b9f6f984b6efea9a4fb277"},
{NID_sect233k1, NID_sha256,
"94a9d9cd9efa3e4ccf2a37f904dd9cab5624ec9393cf8816ea591c5e70cccd2f105388ae"
"133708fb974998ae61d218c71785f9eb808d1c28d953cc7eed00dd9854b6b4568c5ed5ee"
"3df3b58a1e04c64f1c87fee4365ec9aa41b08a6bae234dc43a0bf2f61420acdb891a40f1"
"7f246972afee75a4c0b249dee0fc8f9b9c8a243d",
"07e7e73171e4d2f2989dc024757c186485435b82544a448f5cfca05f281",
"040181c8cf579d9259020461184979757b097d5a94245a2b9a1f8a6931ee0a014baf1b76"
"1a0af3dd9c0521c6489f9a778da824283c94087698daa7cf78",
"02b57fabe6b866fd25ad8802c6b02b680c137ea9b623457b35a24d5a5f3",
"07421dbfa83859354345b9c3f1ce6242605094d924a4d38c7bd952e3910",
"05ee48a3a5119bb3433b53a625101492216421ce67fc04dacf947ec600e"},
{NID_sect233k1, NID_sha256,
"4db998df7b90678b8aa4ec6233c9b4629800ad1f3e2cf8f7afcac62fc6982dcb290e4458"
"7015eca8dfe77dbb4a80f9bffe75b11e961e70deed14555db6dae47d49e73004f000eb86"
"77c18f7e8234bf0a5a104266167a05ef07152e7acc2f0368b37efe69c0c2feb51eedf733"
"8cf9ed398f066cf1f66bacd89ab9376d41da35a2",
"05f7270764a0444c7159d2db867930fdb0fb9fa6b8fc80ca02e11753095",
"04006806c7164a09e11629e16608b7312d9d988acefa626fe8e34e03203d11019c4200c9"
"522618dab8a16e217beb3011599ed6cc09291fe9d451f0cf02",
"04a8958c80481a18c6e0893da9ab2d48fa6ae30a0f1d0512196e658eba0",
"01d301da51eccd15e09ce0bc2d0bdcb215a43ed13792084e2969260d46f",
"031f96a2f322d27d0bef23ba7c457fdc45a6e612f7d13e9277d36c8def3"},
{NID_sect233k1, NID_sha256,
"dbf9b8a4ae316bd2df0c80db1cb5d7038364a2634925ff957d7c03511b57d486274b2ecf"
"191746827c325a14dc94daacd66ad86d369e3f598f176c4f0eadec7e9edd13e34043efbe"
"0a801b75b8186b4a6d89ceae4fb250ab570d65b6dd7c04382738fe3f6f6c867a7d84b35b"
"20720cb0036a5d81a87126f236833831d9ff00b1",
"0179b924afa4acf30ecbe2b3c12de533a1f9675687876a7e5e5ddc8e03b",
"040175bf95ac8e768727d3b4a74c2b8a04b221247a3b8386ddf35fc39976ad0122f32f94"
"1066150c151b9db92b86f86a10cab0828a77e4f0d5c4026540",
"0210c75a63699b424585f65497c6e46988c28eff3e0977e3ade599581dc",
"06087e46c0677e3ca64a0cf030236583935d0dc03c896685dc6e446d9e2",
"0252e42b8f03b085f38c6849bd420837d985c9fe14750a654b584c4cc5d"},
{NID_sect233k1, NID_sha384,
"986d9e5d636526f4deb7545c037fe81b09c74496ddb8e42e61650c74b6fe348593f0cf8f"
"8eca5e839baf62f17bf6ad96ec0c71dc44fdf11259dbfe7499157e402f6bd50769723541"
"50723afb632799a990c44cd0a4fa9609ec4db133e3b4700be3ea4a338e8ba1873d345e80"
"163ed60d0de274d7617a8382980bc2138b0a2a01",
"02c9eb4d392d7f2eef606e1861183acb1fc753d666225f0f154d9eda147",
"0400d58fd7b5aa570b1c4b2190ec413fbcc9ef44d33ef191b6e23abcb386900173e85377"
"bdd8dac58222cd1d0f7ed98d73d6fb6c2eaf34819b08ececa9",
"064f9fb13784c99185f334700ccfcc4ff60b7f4d613c3de6dc5d1b8dd5a",
"03bff54e3610ade656bbe002867168db1b521c49225eb9662950b01955c",
"01da3fd8c08d8e17692059c669da3c7c4c146df6d3cbeaf34598d28eaae"},
{NID_sect233k1, NID_sha384,
"68d0be2883598bfb1433886aff118349157708690380c42b8919859d96db069c7fde6e11"
"7a3669f2cff94a0f1b66b27b09e3f1b24d26299e11552a084be428446f3174da2e041465"
"5bdceb38e58fcb065b6661190862db39c6545dead34a03584632e988d0459659dc7c7c78"
"d4d00fc2aa10465cf24b2410f14e2a62173c9962",
"024661c89b77b2c743cc175a6130904461138ddc4ef771ffb9fc2c8679a",
"040090383de7ca48f1e71a43845565a9f0c53d2c9f8c2e0f6c4ec7eb6437fc0167658227"
"2e7ebc9fd56e1010a570d744ae4fa70eed3e6eeaeb0e0eda7c",
"05cc5b36c7300a1cc3f624e9e663861b4e296f7e7a27e8f8f0a2d54eecd",
"039c6f5b484411c434ee161ebeda7aa21b7bb26bde0301d9ff92921337e",
"02aaae737aedecfd5d53af56ef154ac6430a45ff03a3495a34a5fe0e97e"},
{NID_sect233k1, NID_sha384,
"f0ba0407485fecd7337f4b22236533a926cc744a5f06dd08276750196f1bf7ea7984278f"
"789f92dd07e36895a8bfe297ea43d4a1177c0368900e3b969d3083cbe626f0e27e7ab38e"
"185c923dff46d9ba187b2acb9cf4b23ec8eedbb8044b96b5263d956e50cd6240c66d5d96"
"517130c743752404ed09473f05d0004dc5971ff5",
"0065e20e5ce534576d7c17616cd4ede3bf4f500894850723bcc9f895f4b",
"04001413f6dd5349e94311f1d25e400b69c0f0ea446294eba4bbeb10278b850066a05055"
"d856621161d4f0e33dac82e5c0cd91ed8aa56e9abba9ec80cb",
"07377147b59dba008ed0e6b366e511f94c7f7c9088615c6d46f46736b97",
"05515a6bdfde3b4b78489194d39f4bb439f58a6b3c3f9e16c8a71590b14",
"00778f79083d11efc8ff959f607c4cee7cc8f38b855028ea248fe291adc"},
{NID_sect233k1, NID_sha384,
"3827276694e413c886129c452c9a66e7d09dee84f5f09bf34e4baa308b4627e096c7d45c"
"f6ef45ba1d9a4019a60399feec10fa80e333e2aff1251c85ca48574d9b9e1affb9666828"
"dff5afcef3edaf5e8cae823505a0c73afe76c1bf130399fb06b092ba34ab0ae15ac6c682"
"f9ee8479b065ce75b57213b8aae0f55e4e386de5",
"014c85f66fbbd653f1e4e590cffe62c343ba6062df4b271fbd02e5d42f7",
"04018930b4a59a1c0e92febe650347c49e29a4e83cb8c507e30ad835dbc94b00a237bcd1"
"30235e34b4439293f15e7a3913d659089e38e5619fa52e3c0c",
"03c1f8d076fb4fbea91a97800607b2db3fb5a45149c0d30dce79f07e963",
"04b9d2c66d8cc55b64f3f62dc629ce8e50ae0bad8a4d14e8b6567fc87e4",
"00b9dfdbeecb061a455dd052258f3828d4b7174af972c65bd0043a9776f"},
{NID_sect233k1, NID_sha384,
"d1afb8965b48d66b9acb1ece674d9548f83395275f2d8135554cfcc7ceb96450d850dd87"
"4529433883709483d0743798db5e0dee955a4f30ba328c7934b8dd9207f3c336cf89141a"
"175ebe23d2faed629eb4236a8aea8300604c3eb7704512f240fda66acedf1494a85058dc"
"6a31bf9531958c332b93cfe5545046876c6b99e0",
"030ac7a78593b570b29f6d3d267abb6ba7e5870ee1c8ee4f1ab2f141051",
"0400a409e90eb4314f95967607ea3de9817a0fdb439cf406135262624e7fac004b1dd719"
"434e8dfa5861887736f32ecd635878ed4b9e290c423da09059",
"027c4987ff872fe499039b4432dc889960ea8e3f07be42e36a5827b3964",
"06829b5e02b5849689d152ceacdddbfa8f68d782b3ae8da23ea48b1acbd",
"03dba0d2b4400495ee098325ae4450b32b83689349e82a69b799dac2cbc"},
{NID_sect233k1, NID_sha384,
"4f95b71669fdfe5dc46d4b951b085e099de349fc740535175337127910acf24e9a0e4b2f"
"23196ad23880da47b740d77d74fe9bcfdcc44dd7d8d1a181ac290de5cf4da22d5034cda3"
"d8020bcc776dde8cef1786c9ce4d2c2cfb035da61406af745efb7ef1a55f2eccc5000319"
"cf1d6380963025dcea641cfd15a3106751fec286",
"06d7516aa040f7d559cae248e485834e8d9bb608279ed4d4f7e1dbcd2b3",
"040127a92888fdac8d4ba9c0243c9aca516bcb431911254bc2cf51883623a100606c30fb"
"b9958fb1140643f32c5dd582c2319f71bff197d58ba3e598bb",
"01104b6ad82327b0445e75cff0efa1281d266a9dfe4019ba2ed22dd6976",
"01f247b2850463e362ff8879054d3459b2cbae84b9d4bc005a2ccf4736b",
"05b3dbdf04758d546e54c43ca5973bd8ceba646a4dd5d17ae5d2f8ec516"},
{NID_sect233k1, NID_sha384,
"2ad9e17780c824c4f2d1e1cbf19ab85638f2f71cb4fa3518f08085b8b358f54d4f08394a"
"5ac29cbb3cab828c5f07f41eec51e6cd61a5f2cf44dbfa46834370cebdeb328fd3bf681e"
"61011b5c2ebc8945ac7a2a8467606051008b15c89390e111999255bfe28634ce9bc2850a"
"2b55a4af1c4c2f94403c78aba1ebc87386ab7b32",
"0137050d7b455f43a8dc2516cfff5a91062c1a2727b27df41488f3dcf18",
"04015ccc90a5f3906469e3ecf7a70c429f5b50fd0ce74065d41f1bd6dccc1f00fe5611b8"
"b1b35a907bc188ad2b1fb7507d1043d148283911af3ad782e9",
"04881e879d7c76eb2ee61fe1844567316d7efaef047b96979e6dceb7858",
"03799e90bc64cfd7d0246a7fc89a4d8ed0399277cab2af40fa2ec8196d8",
"067e8728f4d8398e4e1c25775620865bcc2d4cfe635a1f4c6b7306f6d9f"},
{NID_sect233k1, NID_sha384,
"958773c37d3eba003aa5c489f72118b3022c52b93399e9d8001695664918b86893f4922c"
"7b6e55b1855ed0fd1d8de5dc61af403ad660fec60d7c44bd0102c069957ed804d0d416fa"
"cdc1a95355ef58554606579ef89b1842f1055cfa2ae118abbc485356824cc09dddb77d06"
"71cb3011b33bc86cac526e3f6bb3293c7bdca1ff",
"001fd447b33a2ee3595b9f885c290d241422afdd74c3dc4981955a7e9ad",
"0400e706408803188263cb149428c60de57ac757f0776e5b27a2d5a859f58c0153b5e13f"
"17f0178cd90427f7d608a5659b9e03effebc89da65d59698d5",
"0339300c00cf7e8c6195ffb71e509613018e6a417782e4f52704026a510",
"0227c80e36e3571e1c783358c9ffed237b251332e8ed05a8d3b454c53b5",
"0679a32cee8ae001a18d9a9d0ed7e99e5ae67ffcd54de7b48c62e76ac8c"},
{NID_sect233k1, NID_sha384,
"9cb2c496b1bc7f040228571e005e7e936e48e8f469e295edf914f5648701249a20bff6b9"
"8b5e862603dd9f12bb71c160aafe9df02e2e383e9b8a9a9d700f4425ce408feabbf754be"
"543f52204c849fed6c9d3e36e03dfbd9e35c18d7bb2295f1c484a66e73440a0a5aece5fe"
"80b9ade9321ef18cde3eb2db15e4b18e788b0441",
"06a061e10b4a6e7001d95411cb31bdea9c84670a59ed61b14fbbb05c8e7",
"04000ad2b726b805919cabc90d058c78896d2dd8a78484c1fec5bd5fb0e07b007e048ddb"
"487f667633d6d030338ded21a2ac5f65373ddcfe1e4a3424ae",
"013b4a86b70f0e4de6efdafd7ecc993f0d6f231b3d743ee5adf82db1515",
"0541c2d3b2c6f0655dd415e327f0ef07b03356f8047117c41e704169698",
"00300f45026200b8cc84fd564778281bd1d7e03727c242a249d9ad33338"},
{NID_sect233k1, NID_sha384,
"9a4bc0a029e97742ed3bca207d5912cb568e4403cda106b00247520ea02008b14c041b8c"
"9b976294252da835f4ff27456039d79d90315abcb0b9b6958a22352672e229665457ec79"
"571ca80447c8ff2a86e6af3dabe7427c8bdcae65e3c6746a56079ce2cf8d22235180f466"
"46a21cd9e86032cfad874cb9c67f882fb037a13f",
"027ec31ca31acb4d2fbacb49fc085f1261b0042cc755cc97f9b199e7a37",
"0401d521f7abc2fd3b0a10732ed641cc1b7fdd7b49cf61909b215220c5253e0019e9095c"
"67af1b89ae6c486c4f9889c3f2994743eafe55bd9eafe438d9",
"0151aa44fd97be14578d68f87dbb884c960ab59d950c392e607ecae6bac",
"07be427f46958538004186d52aa50a0f83d184a9d2f4da2974163854eec",
"029d4ea73ab5b336ed44556f6944e734e531a5c71dc6c929e7253323906"},
{NID_sect233k1, NID_sha384,
"8d89e22cf802dc68ff22d43c436c79311e705ff6fd845e77c880f399f403e6d5e9e2b355"
"11553c978171189e288cb2200fd95f84ec5ee9865c0eb9190aff6dacf783ef200e82027f"
"a992741876456472bdf27f2bd8ee55db15408c957a120eb64cd24d299818726a73fbb069"
"7eba726a326719765735b37a2dcff0c853c906bd",
"04c6f4d88e5a4f4f83196f2dda9dcf2a66eaf94d50c851f59bfcea1d876",
"0401e2677c1305f545472e373615d195d1f7a315f592e26fbbf44c4255805001638140f4"
"8bad525625a87d0e537db5500f034e71e60e8a8c48eea04108",
"02185d8ec6f35d5c3f965cd00597d93caf45bbe186d4128bf877ec304eb",
"075199f4d8af090e4666754a7dac0c1599c207735c0f54c9f11e305727c",
"008cadf59a224f812d64c2f492e7ad4a923f3463b878dffc75eca5f8fb2"},
{NID_sect233k1, NID_sha384,
"aa1bf5a79e5339fb9ef6c2817bd95725551d064bc5064d6586c5a879901adf808dc2ef7c"
"78ec3b434b84569988db58b5e8e9782b1cbc2cc7c9b68e66f32d4ac4ebe7e75b345f654c"
"7b8a5e650acc9f170f75b7aaa3957cce248cc69cf93faf8d72abc6fc1cfa9ae2d18a7b31"
"ce720147e88e84f6563b2197882fe302449ac5ce",
"01aa169ea84365c22981bb766bfdad27e373440850569957544b0f9332a",
"0401f97d91302c70798e2278348e36bbe01587e0031ac3c422141e3d4c150400a95108f6"
"b7ff41546c98f4ea4d1b587a3280e49c6cd0d33abdebf9a1e7",
"03c9efc0f72d88168c2b1f7fa1c6e275839303c2bddca136dd19ef446c9",
"0639d1a1066465b4b2f443cd9677cfe3bf5bb33e3e9b14cab2d37f4a859",
"04582792ba78f782f112711ceaf36f5f0774b92a6fcaee327d687658835"},
{NID_sect233k1, NID_sha384,
"475664d5e22cbe0da0d0289ca9a666a37270dc71c81cffac91f6229fa39315c1d55f7e0a"
"89b6a7a07df7d391dbdf8fb7af63d2da46ecc3b60110dbcd842da97f98d2b67f562b0364"
"ef8e1c589519024177c8ea079794f271f6d35554c0e9d0a39062383c95721b72f4e74eaa"
"fb6fbfbda02cb670a7c4c94f67b8ebc6442e84e3",
"04a665b92c0c33a3f8b9eb4b0ec061d40b603de36c87096455102ffe57b",
"0400f0ac5238553f0cd74e6f34f7f82563cb01138e5c9bac6d5e7b8b7ad4fe01903e9fd8"
"a5a2aa32913b18bddef20667061f919f8d61a5b3c814ba4aab",
"070ef25950a795b5e22fe4cf5402f49029c5d97cf9f57f0806c0bbb5855",
"01248dcf1993ac2eeacd062f853ebb4b2072357e728f0589258399ea95a",
"069800eb2e2b3a9162196dbaaf67cab4ae123ea817f223acb6e889f6d7b"},
{NID_sect233k1, NID_sha384,
"9e5397d94465390a82a3c07e3ebf21b515776d18b4463aa5810e6b2f96ca61e92d13e034"
"fa853c3fa45411f51f79df6f799a2c6906e6a5b7896a4576a4464f9e0be2b529a43e1f50"
"3fb640d79db6b68f3a3a7deac1b5832fbe86673784ff6db1f8438f7dd332cdd1e7ad9df8"
"b6731aad1b6a72bde52e6bc62d80b8da57822c48",
"00531540d94823e19ab2b95cbc6e7492e1effcbabce875de6ba96f53aa9",
"040031ba225249916a5380235220b9657162eef43d59ccab507639e19bcd6c0062e85d61"
"366a73b62255c741a065708701c8fa024a15401a4cd58640b0",
"05375df0a23646e8033ec9e3ad269e7167a663b97b4f52cf18fbb5f50f4",
"05bdf7d643ffde5ea191553a9c99eb42fba9a8b6e2013dcc520298d224d",
"06cdd9e0d58bd4c5cfe66589ed7c7d15331f3e164dff562b6971af1a41d"},
{NID_sect233k1, NID_sha384,
"3cc4c4192f317e52df6f8cefba6d4cd823c942aaee11b9a0ef5de5c2d181073b7085a558"
"05e9554def8dc13eb978e7396044d4f4a14be2c7605998c062095c929b9c23b2b1b2fa73"
"dd19a0c0af44ca4789f9841fa62dee8a5f91b3cc4b3264f5f67334c3f0772b30bd7431c3"
"fbbf1f34318ce1889b6e8a76ce6d42079a451e56",
"022a89addd8b85809e87e0aa2c038593ec277054842854de1197833a51c",
"04008e760b282d0ae4eeb2fcbbfdec851468fd8e04c4dec71fc2d5d3a98a1300849a56b9"
"b0b0a1ede6b9f9522685e7ace3baa57f72709aba705814d138",
"05515b025d6196ffdc8bf275479d72b29a752eb3e70ebf07d4c4e7bf74d",
"041902f9b7bc81d3a88066b03e4111ad8ff4d99dd868d5608d1f43eead4",
"059adb96af9f404d2f04d89fb39cf38ba5689f47bda749ae9aa1ecb097a"},
{NID_sect233k1, NID_sha512,
"72cdef5bdf710978e0aa334b86b8ff4a58630da314eabe98b4d611aab56f55c526983d54"
"d19bbbf9ddba30a84b18aa0bae9f9503e9b222f842f084db83aa39625403213ca321cc0d"
"9c8a136c826e6ea4ec108b913dd0a9ce9d5b8c7e3af53c3876e56a2037ebd6d99f037a09"
"7111c837647bedfe4c494e4288ed6427c15969e3",
"01df252a11ff97b4421b3a2361db94e908e8243cd50d9179f9e03e331f1",
"040129f011fd5fedf3526f0437ae800a110435db907af60e16912d58523202008026ed86"
"afa7ec80277f322dfc8cf693089968ed9ceb8c95c930415a23",
"04fce14bc83be6f862f06680a32e9a51d1a569fdf1d9b10a89eb9fef4bf",
"04d7b8d19dd9cabc3c2245a9d2c8431c3151eeb6f49676a865e78c26c2f",
"0373e69da1fe35ce41ff344447fa7ffe6fc71e28dc68244372745739fc2"},
{NID_sect233k1, NID_sha512,
"8e4eb88c0b2d525b2c58b8e00f32def90e6dd382301de49e0ac053dbc6b61afe926d8519"
"3e2c4948f7402a3d7c614cb2c58e060362b0516a1ba4a7425f1b3d09aa20d4c3c8993a38"
"7a3248aeec51e6efa8f558dbdcfcaa13ee08413227c8351e3107e9a3e3ac124224aaea91"
"bfe50c11c1c8ae582e718f50bc5d5c06076517d6",
"01d7125c299ebd0dbcc050f07de931c7ad0450af590d0a2d0228a66ac5d",
"04013ebde8790a113bdde87c11ccdcbc39e354b193d772921b86657f53f74a00aae910b0"
"e22f1a2505f55fef2eae47ab6d47db6e49190a5469b4b6dce5",
"0113d1737bee59f9f477f71f77a0ac1aea86aa67002c34a1b31c421cd7c",
"066f9871da9a22f07c9b2a44fb6c01ac74ba17649cecc33b729afcb488b",
"037fad90c288510d0cd8e99e5d930f4fe197df779dfd6088da48986c601"},
{NID_sect233k1, NID_sha512,
"370fdd80f330311dbb3959666001bba61cdacf20f72f78953d946fa6cba02d24b5003f54"
"52d535609e489b9434f192011f99f918defe877d51349870e7e75502f61145f7c261dbd2"
"a0840926d824ebe9be3c5a77a3a84340aea930378367ed3615a47e3f792c7773f83f91eb"
"ea718a05fc62e9ed1d78629b2c27ae44fe8f8d4e",
"021238e66119844b146d40e48341f522f6ac2f9c8a0b33aaf95a3099a41",
"0401dc3ac1ecb670f867337b752cdbf48bed9f32589366f7c6ba7424af1d6601e3a38ded"
"8148bf45484ab6b77e0beff759812493347e32d2d54a322a2a",
"03626adf8e70506e74ea27ce740f7eed1c8b37d50415be6a2681c67ad2b",
"07a9c9056b51f1fe3e7733c6f54ed96662aa7f5a08a961f91fd6d0276df",
"05e7600e9fda45bb966fbbb5a9404af961058a128824b6d84d9d47ebdbf"},
{NID_sect233k1, NID_sha512,
"f86c4433787c3ec3cb1663389ccf53d62f9425274ccef05fd14b1b8fef676208867764eb"
"98d16d006ee6ebdc27b8d9a8ddd303d941fdd82b630694cdc698bbe6bd52441190783428"
"6c94b24ee199fe6d646064277f244b7df3ea2d9d52a9dc6a33d7c8d6dbc919da0fa987a6"
"7621ef0829e48310e0ea2bb86fedcf4effc0b94b",
"015e1bdfdacd87c42ed439f3e243abf27fd42e54f3ebdfb47f60dbae5fe",
"0400fb7fa51c1a96baab65fc85c3b769ac84ca7b63a1fe9f507a2ee0c49395005d450aed"
"449f8f1aeaa9df0131f696c2bcd4528808d2f52b6a73f72811",
"070ca3f5dc30c70e576e2d2b30935b05b6e68598eeaafa1bfcb9e156e05",
"07e3cdc4207456773aa52b44156801b316a7ac850b3a9e717a9ae7fcdb0",
"07ad6de3ba8730ac887f045cae80fe2fb5237a8594e7125c4792d478594"},
{NID_sect233k1, NID_sha512,
"4117d593aa92e3eae1124ec7482737cd3573fe5f0f2a5051a7ce86946a2abb9e47a0c6ea"
"75b262689b0b486476d2ab09a20efc2fb921419b1811b51a2e15891ae9e45a17ab4b96c6"
"65c6c423fc00e2d66df5804a164f0f3c958df6f25d7da6829b1fe162a0a8cf130858c83f"
"3555d6ad627db70cb41303cc6380f7b3fed2563e",
"00e09410548c17bbbf28a68c3963a52d39743a4f1ac28e6dfe7a6ede281",
"0401f5f36a21a3b7fc5ea37528566da695922d7d9b7e6800af9c1a00f68242003df4e2ba"
"0c8648cb1fa19663f31786b850e6b80068b8c007f41de08608",
"03c0a2a4bea270eaf66adfb297c0e3213254cd87b11edcd90cfcd6f3104",
"07b684e337d6778f84bdb7a6835e91877b41d6af4b76311258fbb8339d8",
"064a0c22057a858b153ecdf4d275cf5523dacafdfcb46423b5613c85691"},
{NID_sect233k1, NID_sha512,
"882ecaff3ec8f4023df5397167f238869f78a5c499be19aea85c7486e73f66f0e08e71cf"
"85f3f1b6f6a70796bf46a18e6b555a0a87c2088640ca73051b3dd59ebfef922be0372208"
"fce602d8001681297b285701dbbe24ccb42541b5db4aac1a1c7f407e11c83db15b38cdbc"
"25e930fdc6558f64d9503e214571a435d890169b",
"049f5bea6e72d98579b78cb07d89f64503f8759dd7a73cd73713c120428",
"0400974dcd68cd85117f363812a0473e972c89551e31c74c8d99f1073eaafc00f306c905"
"1cf3b84803307beb3dc0d34a9758a4f535100e846462a49053",
"022a5564b468e706762e3ff934aa22d9aea0bf2b116b61182c9f7be19fe",
"02e050afb84e1b0591fb64d46dd7d4a939552d68bdb4213f16c5d7ec5ec",
"063225df0057d5368b2e103eb2181ff5760e6b2a9c13c83da042722c3e4"},
{NID_sect233k1, NID_sha512,
"99b3b8f876f8359bd6369ce84f9261581c52d744b90261a1427ab9e447e6d833b6b3e89a"
"f8dc770f1dd55692d01c8bbc4277a729fddfa7cbdb2ec99133201dde44ac691a77904ca8"
"16feb0a1aaacbb9fba85048bc63d73506eb908ecd697caf582747051a3a38ac8930c9a43"
"65f407ed94ca7f2d26913c53f4c010c7ed9d7ca4",
"005eaa818690d1ca4838f0bc667be5721d178c3869884260fb230277c3b",
"0401f7b3b50167cb2ff7482240bade95f2850a02805742e6e29eabf7f9ad3400f8038a8c"
"ffa0f798a01e333251996662bc3c0ee56d94c392269b63edb7",
"064d518f7b8c87325d8edfd42a52793d87ef8db283606dd676be8584562",
"07128123004a515e277dd5b571e31bbc877cc966e27ed5b2ab2c16e881b",
"051d70485148996ec30f92097e4a12b5edf804e03e312072336bd912268"},
{NID_sect233k1, NID_sha512,
"8c1a83023930a85c5b2f9930521b8b8963d5523a3323d87f862a17d3505ccee01246ee10"
"29b8b8c2b608772c4096d1e914cb398f027d91184a8e94e4feeae121eabb504a2a35c8bc"
"9294edd15ddd979946c14c792ad787dc2d4deffa284830fc90b3f8c0ced6a99fc6de7c41"
"b9ed261402a6b3d702ff86a9392731ecc37430c0",
"0603d89cd2f741d734587e77554fe6bbb1e5739d5ff73084d4de8ed69c4",
"040122f2b7802917e4164ac2f54033621c78cbc7040217e5ded6b9217f95bb01f867df74"
"3e73806957066c2ab45c04bf1af158e146a9d1eda9e974e0d4",
"076850b8ca9e454bdb320da624c0dc63e14ad279185e4f8c9e49905666c",
"04bc63bafd5bad022fe5db246680a0a0ccd0b50ff50482d3849c92eec7e",
"07b6d8a8446ddfc64392af0aa1763d45877023c0be9ec78db47efd3c366"},
{NID_sect233k1, NID_sha512,
"f3c9dedd7115339dd3ede7d8d06a44de66bf80b4888ab7bc386cd40a92789042440a13d2"
"cc90dbcacca5feeec1e0e3c51724146e2c4904ed6b05c7b4e9b49d7f458ada695c5d2fc3"
"6f1193329b87c1268aa38eda9151430aa0bc004e5d2a61b9390accfc699f2efabfec785e"
"b34f52b1beff1e4c5492e922acc348667d2a3986",
"07977b3aba53616dac27b4d74930da23966a88ad98f1769674789c0be3d",
"0400aa61b4bd2fa9c61914ae306d69d3ade7d6cf621399e5791dda8a054dcd012e8d9274"
"d5593f5074c49ca34a7e2d64f9d9ccdf42df6087134b811762",
"03b8ee56bebb59207e107bb0c16938cab707e425f38b70f0bc918fc1b8a",
"068502a3e5e51f5481aad31eb6614152f4957eef1becfe3a297b023a94c",
"07b6b43be63aa79c10876179703b69caf9b03c5401b999a3c5be4737999"},
{NID_sect233k1, NID_sha512,
"d878c4ee0bd6c84652d7f9e68df7b90cc78776d8d1b60f3e4d7465032bf401f1527ca7bf"
"d4a3dd916e13e93fadaa5e5f20c9f47d12f8fc922a9a3aaeeeef294c221ca1adf7df85b8"
"88faec8002f17ff202da1be837827619904121167bee2d2cd694a263d9a99062cada3399"
"dcbfcb283597a96ebec129c65e0850ec4cb4e2d7",
"050cd20e7eabd29008cc977d0a17e1195d79587b8f15ac2447e15daafc0",
"04001ff23ff4ea1f30663b17d8f1c67ea37b8c5df7009d0c0301db483803a400ec6bde92"
"921b83d4d84be8a67a23e1718e575101b93d9a800550a20e7d",
"041ba36d2e810e47c3de583772e9b5908c257b2aec232d855669d4dae2e",
"079e96ed1dfc4e31774159ef311805b5f8001203cf37a72921efaf5cbe5",
"00b8abcd623b17357f65ac365301a8823365ab948ae3f7fc6a4a0b8ab5d"},
{NID_sect233k1, NID_sha512,
"ac3c118cc9cbc8eb3b74d8ccc9ecbd81d1996fb25ca43c8a43bffeb244f722b93c9e9692"
"41d45d5b81fda0b399f1e3623687190e428dae077e54cad1eff75ec2f7fbb9434bf71683"
"3421bc2634885677579c237340f76787b2eb19b446d56c0f2206099b81493349f4db0eca"
"d0e2dbe85dbff7d7070abb3d3b12ef0cec828af4",
"02dbb24fcaf9f3cd5d50d209937f0e2d134fa20ee3c9c2f1fff3dfbf302",
"0400a07240c52e385ecf75525201f9810859123bfd8ce04a5e8f4dc4ec88b2009bd81119"
"6ca9ac45b28031b9f65f9a5c4ec497d995f7dec6eb06dd2874",
"05785beb1ff70c7bea89b1fa14be09332ef94b09eebcc9fb1150bfe0d55",
"05279bb1b1ad8174e88bec4c723d65eda768c1d08d1c64c332a240a284f",
"015a90383c2c40ddcf721067b3435915a843f9c4708cc133fd1ee53f442"},
{NID_sect233k1, NID_sha512,
"700313698cdfdcf0044ca07bf9e5f0702ece7cc66e35decb28d5f8cb7e7e5367a95cc172"
"8a90cc9a53a2b5fcd4702028b742538e9b386f5d8b4a2411579ed9553021a95bd00a73f0"
"3c4184a6145aaa367e3af76659d677fe7a2e98f9ddf4aa20eb8d1a1db72c3f5590598801"
"be7ebf44255fd7376d89d998b7068bd1296fdc38",
"0047142197d3d43fa46545b547968680ec81688589d1ec8d7c7e90eb969",
"040179450d83cd6dd1609830ec78011143eb64d2d1509ed1adfa085a58d786003ee40673"
"ac564c6b5732868d0f8a57727150a23c484228890d768dae54",
"064f8892245a198c9c819152edc168e69dc7b562ef1f54dcc1960cc7db1",
"0293f2f989fb6b6e7cf304faf3f63eef61ab89a626cf8152e15f38bf93b",
"04948643075cea6413b1c88a9bf11aa176611f56d027f2b165d00d46e87"},
{NID_sect233k1, NID_sha512,
"0374673e1a685bdee55504ce3cd333f70084dd4ae685464a16924eccea34531663fda602"
"29166478b30193459a3113253cd6494dc26154156252dc6e822552c7c04d790eb9f8fcef"
"2ea8dd79e72f881f7f20fff93cd73ad303c0918ec27c6486c4da61f82bcd55422d16650c"
"c68bfd4b0132c1e7075bbf17dad919095860d445",
"031352b49ecde5434aac05f898e6ce4337304845d748f114c14319fe97f",
"040187ae6bc9167d9c69ce5544ad650055cb9a4e69c1772322d5722e68e7e000042187e9"
"d11a921adafc694b5cc8da9226ddad1b65f764274954b17333",
"0761189e63fc0c3b5db92b281e5a4bc0d6fdb30bd14f8e69ca85a211bc7",
"0453560e6e725a2bfe0383884ba3b3dd0816d8522d9e0762f781f6b6340",
"01aaec4bd98c765e4830de6593280779d1222918d4acf08c8fc3d0aa351"},
{NID_sect233k1, NID_sha512,
"8b237085f135d6e94592f8d855ca397c8c1028236a3b412adefdac888245874f586d0695"
"0ee18118f751bfe26f4c31465ec34b578caa44cf1b7109ac4f6eab7f97ff9699b34271df"
"035d3bf58a2ed4bcbf7577cf8e5792b1945ebb9389b680baeb8518c8fdc5540e192aa4fd"
"e0eed0d7c82be2e362b286f582d65752c8db7038",
"0176f124c24e4420f6e726a6ca25f09dfa0c5a37e5bf879e7bdd36c3b65",
"040098c37cbd44aac5d5c749524b840fd849652349fb3e02cc8f8fd0a237900151a9a88d"
"a407ae41e52b3dad1ea6031c7a36bd834007c0cb1e2c2f2f0f",
"022e299985cf289f2fbe2b1b270fbf12ba818cd2b506f642e659cd541bf",
"0686ac0c09f90a077cb446c910e07fdf23e845487d0333efc65b9b84147",
"01688b18cb42082bea69f18511b0fd9fa35da83d738763cf13ef92a119b"},
{NID_sect233k1, NID_sha512,
"e3a086ec15574f7017b3cd5f5a47ab7a73980f11074333490dfe9f8ad8926f9ea7c82271"
"aaa74e77133b1025b0b22a6900fbb71251bb6549341a23d194e79d03462cdad52ee0d1b6"
"f5d0d14e1136026961fa3467ccf0864bf7ae3fcc3b68cb35df7324bd9bbe58fc8aa9f63c"
"19feedf19d935b71bf5981c74fb2a487f84e453c",
"0755c48c3dbaf71042c58cb137f3632e3cf9d90b7b9a58fd378feef3d19",
"0400bd9a720553afbfc5349e4a65a21fed0444c30304f7018ec1ff6fc8d1f90109a1d6b9"
"cc4fbd0e888d0a2b6883fd06a5da347c0d4f7882fd29eabcf0",
"04fedf8785c6648798748504b1c9b6a066ab6606bc9a69534f93e908f4f",
"001e71744a1b683858444da0d270f43b0d5644424f2b38ef48a639685b3",
"07ff8199ffe723abacf1947a828e8596dc49ce655319087e4aca6ca34ee"},
{NID_sect283k1, NID_sha224,
"ef90f85fbda05e693006e4c64e1dac56223becaf0890f73b5274e6e289a5a1de2c141b82"
"5c24d595b3fd18ca855b5c1aa60dac6b5356275b11be670692cdbe5f282f93ac7b2e410a"
"96cb9e9f80defcde98f3449f99e192bfd62040421a0ab8f99acb85369f25e5efbf81439e"
"fa8a5e1d9cf781355a0f47b037b09fe4086389a0",
"1e846c830a8ec04e8572d1a9d2df044ab47352fb346f67403a3bf87243871b164511c53",
"04012e43e20941f2641154bb66a56f2e0428a7ad22d607fb8af658df0b382bedc7d5ae22"
"cc022f226cd65052071066963b112aa302973fe2b5fdd7bb827d13da7634dd2fb9e3852d"
"db",
"03a76f87ede2b5d40a0f10e15e90e29198fc3a03943efea39ddf7afc37ed4e18832af8b",
"1be2c776c707098438fbd0561de578e4b9449f955a25626f2fbea257fc578ffa1bbbb70",
"1aeef69983da1a535b10a47e66d890c4413c7a8cd6a2511a1a670a4c573d4808f46e23a"},
{NID_sect283k1, NID_sha224,
"a3ebc17c867cc9c7c28797f6364f6574b80c7ec5b2d8e1542a6f5db8568c15032f92cfbc"
"eefa3fe4ee654f690b0455ee5d38dd84bb8665ffc1ff8c849bdbc4aa0ddfdbbca4eb3797"
"2fcbcee8cecc1aae21ec736ef61781716b60247b7551ec4e552d0b59a53cec5964c67cf7"
"988787cedf769eabcc9cd5243f58034d96f0e43d",
"101c5ed48231a56ca0ea85eb45de0e395e6df2efd4987a226ae36489dd8b2dfbf7c465c",
"0407011260f504d809baefb54af48c890f94fa5984c8bf228baa4b6ea14d46372390d1a8"
"ac02bbfabb680659aa2611435c4058ed773467a41cdda8250f3490e4f491f1bbae452c5c"
"36",
"12a3c7f0b3d64614ff97133873d75c7c1406e316e8cf60d22139dba462055baffe6c8f5",
"0a9933496d60716a39e1c3f3bf22a7da546eafebef80dc6f25d0c109ecbc430fdb3e80a",
"0be56197a0098b022a7914c10f40207da58403d6c7d04edaf7efc96de740cd71f67e0de"},
{NID_sect283k1, NID_sha224,
"60269efa4d0ffafbbc655f6f00578eadce7fc0a7eb7db923dca49b6f2bf3e13f7f829cc6"
"133e022c3c92143c075ab9ced0531a91e6e79848194ab98bb852f40c84e7aebe71fb8bc0"
"fd1f97ed5bb6bad6783d8dc048df42738e841d978456e055e1b8a781dfecfce2218701c7"
"af77e7894ccac5bfff360aab0b6136b978bc39c4",
"019679dc589440b11f82b3716e5b2a2bd42c3b1c83e88a28e304cf5148877faf760b4de",
"040743ae04e4b07d154ca0749a011c97a31ac68d8e1da3491f331136873598896e5320dd"
"cf0776c05891c27fd912267ac166bc9acbaecbf80ccdd887aded2d7b8c2a4a5d139833aa"
"d3",
"099ad7fba5284e406f6cf200a39e398aa0426448c09b95e691f653d6096a63adbd39965",
"0285a82340d9a6d96ed9ad0fd0916216fd20edf979df41a55835ef8fafa00d242ef6f11",
"0a8548b405c171d2a428507f7adda4944bade7cda6dc580b1d3f94e15d7e10f0a08e008"},
{NID_sect283k1, NID_sha224,
"59d704d5b1f3a0605f1497f22f71b8f45b26138bc86371f00a4517554e7f6e7fa5d35189"
"fc656ce68bd2cb8510fa3e3c3df815dfdd749b2b6ac997d443f3954c7a927e138b579801"
"ffd035cea90840733e7884ccfe43d8d3a4a26b430673274aae312abe4ac1e1d7c67b7358"
"0fedf2d8de46572493c9205ebf0e8b4d75ccc88c",
"1703c21fb1e09f8947e12fddf166fda6f685221fbd803d75a0ae377a54a1e494e6c5e7b",
"040767564e13ae544dab22c3763c5d330a5571e07ff8f2f5ba3fd729379709b1fb184f99"
"0c027f9e5efbd1ff6ac53a6174670eb463b12f70a603354e25c577ea292b13b8e5f022ac"
"9c",
"10d875acb4d0dc211a82e78c0249e74de16768003b53830bf5648cf911fef6a57f8f048",
"02af92243b9dadcf21561ce32ca0744810478f8d5be8e0f83d9632ecd8e86ff467268b6",
"1f6c50fb3bdea228a6b623be9e2ea2c371dcfeb0e604ef1029b6766c43b193d86c02f27"},
{NID_sect283k1, NID_sha224,
"12c8fdba3bc5f68e13f7ff8e7bee876fa68a970afc6924314dae0c2482763ced8d4752ce"
"c29ea288d350acd8a06c69289ae41ad345a1b88bcccaac903f2bff39015c289a8ad60860"
"6bfd65270a7bcdb5fb10c89bbc2d16dcb91fc9735d66103f6b1f3575622cf4d820929031"
"5b033ee1f79968939410f465a2d37add46af2d59",
"071de8eb14cbfb88e61b908990ce08b81e624ef4f2cd9cdf3dd7ca9097d5ffed9ae9a71",
"040136d50e1aa8203a0cd2c2d545b81d00b95c6b43b74b1fba3a6402abf756d38087affd"
"49046bec77240de7bde85ca4345f27c6df341c72a4eccd2cd495e86376c183ccb34f271c"
"d6",
"1d80734927505d8d4818b3bdf1aa2e5c557e5f717a5b3fb856ca9a2161bfd74a130ee38",
"07894bf10885a698899b118f57e7da22222e3d187a0aabfb99fac0ce0e134b6b44a5f90",
"07b4a87592004d6ef8345415064b4b4672db2943c7e6098a9e6d59ee3324847e753703e"},
{NID_sect283k1, NID_sha224,
"26013a3ddf687bb2f37d9700923906f118d5cba5d8ed5113a0e3e84cff00918125108f74"
"f4b243e351aa5d07fa7c6ece29f5700f23e50286447883d2a058c3258a12e4ed8770cabe"
"627ebea7ef6e8c77811ed7d9a19c53287093e39226236587ddbc63b7ad5e7ad9895c64d1"
"d03ee432d45a067afe27d4cca920ae88a7a68db1",
"1d156eb15762ed00c4021884adbfc2426e910b18a5bc474268196f4b74e593a8f38702b",
"0400a99b45860615d7caab2f4e9bc01196a61f52f95c6c7fef615a4746d48553692d5fcf"
"13056f81a0088dec1382f8a3a863901d3443c8792cd13ce13a8f63b02d107b66d9d23bc4"
"92",
"1999524ce9525d85b562fd13634fd9ac50fb76d83b9d72d6976d6fbc47af7e1f354eee7",
"067748d49389c9b87a85b518f84f41b18f52569ba531985b8fe5e1f0cf9cffa958da3f0",
"00c44a583c704f69160c6258332f3121b022759b163c74c7c96058fa8e3a9928afee948"},
{NID_sect283k1, NID_sha224,
"c4dbf70b9a2165e7279122460d05ceb8e43e03fbe2ae7c314007fe2b1d8567cac727a10f"
"ba5cbead0ddb167d387da8e8f3d6bc0ad851cc32885809d07a776fd4a95a979fe3833610"
"af89df0f454d9edfabe12495a118fe83add5eabb2acf54ba7ba7c4be20fc77478c0a0f07"
"26c4e60317422a612a234a7567648603b63f1c12",
"17d6eb1219cab8577168be86b61f372b27ca70fb1f1a767947895c185344e966db17aea",
"04065d8e43a290a6957230501509b95a208a6c37ddcacd1e882d97c73c38b2a256caef5e"
"8b002169cefa6ce170ce20a0b5463f5bd146224e0813acff304307da88830b0777b86cd3"
"d2",
"1519e37a66b4e665b2e3e59b8e836869a886c879aa1ed47901a6c8a8f365efbc67fb410",
"1734a8bc9a13f51d921a297bc6b2d38610c20b32b0adfd5efdd01a4db5084f3b0697904",
"0f9f00b25a33b166f09e2a819dfda80d87f6a2419a7b4162e435ee02c0fc10a669df6d4"},
{NID_sect283k1, NID_sha224,
"b1d53b6af1face9b59af11c726b0099111d1adb3666209ba46b1744a528ed0f72be5a1b8"
"2423153b896384faebef0362343e2a4599803c08b8513708938aa8a498145fca1c63ba41"
"aff06d1a18aa2a045fce7fcd7e5552a2b98d0df97b6876f06a9cf52a7a40fb737996adda"
"97c3cedf7fe421235ac6951060eba9c0377e72a2",
"10ede9be6615b3b2a294d67da78127ffbf3a15bdba6f4fd78be7a60415b5d1a097c0cff",
"0406418eac385ce94c1982c216ffeb0b26f9c061ccdfd785ded75efc6a329385898331fd"
"a307d41f9cf1248a37fb8baea7f3545bbca707a903966019ad56e4dc810b6863e243968b"
"48",
"134ac4de6ed71106d11fa736960eef2873223aa87b1c5bf5c823de6c78092cba4726ec8",
"12a37587ddf224faaf8dab61210310792d4ccef650c98155a227bf468b7f323575115cd",
"10982c965331cf8529ef6adfe17dc3fde63dc2a557cab451d7c9408a089229e22b73d43"},
{NID_sect283k1, NID_sha224,
"e78f538b1ac21602b00a09e3db243ef4803b447329c94a1476cd91a88ff790da71421b60"
"092c8a6e55327c7982e7655eb1fd6e40fa9b9fd2f10107dfc585994dfc5bc2143d18794a"
"39f7f69ae679b27dd11ed22040d5e93aa83f71783525a4db0c3fd7b43e57dafd0033d531"
"7680df19c2ecaadcb37ef896c61a758a5e455206",
"14f237cface123b64e8578ff33f86bfd2a8181b9c81f36b9ca31e2a446f0d91dbbe2249",
"0407aa347c03d8845f1566bbc3fa1d66ecb41ed1dab0a402405d8300591a1f3078f9fa53"
"2c063bd10274437c2690ed6df60ea632f3d4faefcc07a72ae8d85c2f999bafd373053265"
"dd",
"0570bf3b42aa44c11603d94e14b524b8cb1363306196924082ae71021707c3138503031",
"10f7f4af1c1e3f9e8e0c95f991c348bce6725f60aa12ee7b398be64728242088a469a58",
"17145a39fa4dd237e31a98daf3974138638b9462a31b87ada3eade6bf7f597195eb28b6"},
{NID_sect283k1, NID_sha224,
"8a6ca8ec436d2c706fcbec6486b5665b21c174edee7ebe108211c388b1219a8224179f74"
"38e0bb7d6e41ac4a67337b52d4cd9a069fe6c88960ae20be29c8060efd7c62cb7a9a3713"
"6a250e68f253e7f27755df53ce7c570135641ad49b43507e5483e17b919cedffdc0d4913"
"b1d5e0ca0629876c0a551841a0fc2090d2857cce",
"08dbecb26587cb2ed7df2404e680fcfa5bf8cf6a58e87a350a1600211b3c844ca86daa5",
"04066610ce348821a77e8a6eb74a675ad9312b2622ad2e1e6d8dcd0be8b27d8384844a72"
"340014c15776bbd144c0c24bf419237db9401fb7f97a7c4c0ef50a9afd27c3964088f796"
"43",
"0204586a9314bc14bef8ccce8b9ca3874572b375d01c6b4a41c743c16502a27e91a9fb4",
"0fabfeb17bb8c1a57af7af81d99cfb7b0ecbf4e5e4a6ed483aee4be8ee4c70c2ef23941",
"08071e162dfeb068e3cad256c3603e07ae48b35f1bafdb726cf4ce32844e1a2181f23f9"},
{NID_sect283k1, NID_sha224,
"95bee02b423d2c6e60252da4632f693a2d8f6597b4f9c6e356f670c3a9e4e80063e92fac"
"b6421d0325b99dc150464ed2ec1d0bac72a042b35d56d33d2fda686a75d582d475652221"
"8b4ddd25ed45503d90d3d185cba6cf0ac211b22aa4e1318a8316c369186f7130446dafad"
"64f7966f5414f43af37a87127534060a23c6165f",
"191badec2d28cbbe62c072c6b57eb5d4644d0c0b3283951bb66096cd15edd43a1bbde53",
"040020224b00428031056ed370147c51e68ffc02e7fe269ca15b22310a2974d383c6c83f"
"cc01686568fc4768158e75b4ef0427d8e262cd0638801ab158311749e0f432d5b69a667f"
"0d",
"03b1b6ca5e627f00176b599b68fe54e1b5a272c323a06b55e4871875c0e729c4c79326a",
"1ade251b9360a6ca1b48c2fce0768a01193a415bd23956fee1e5c4c5076b3571abae082",
"0adff25020af4e2b4908a33ce1d75c793934921267b6c4a0542924300fce40fc0031021"},
{NID_sect283k1, NID_sha224,
"ccd7f7c0e04d1ef9a3c5617d77480bc624beed6582bc28e9e3a369b12144fcd96b735ee4"
"1713f4173b64b28c6102d82dcfc7876e06e76fc497d1d238bf6d85bb5feca630bbd0c0f0"
"fa7c0c72e28e9259087698973ac66244bc6e69c04deb22eaeaee7b20da239ab6333576f0"
"1349c76f594498620933b8969450ac2bae66db8b",
"0ff5e3d66eb57fd35ba4472effd6e7a016ca461e39000a7125e99080f6ab6ef4380dd7a",
"04019d8c1d9aca39de0e627981d21e35a628c35fd4096aaa86f61625fcd078f0400f615c"
"d5052ba2854ccd64407f6779c5e259917b251c9e34ec0d95c05488f30802b82cf4b25b53"
"89",
"16c9cabed653c57676ee46c8912cbc507b246078834f1667d0708e4c666346299c1fc03",
"12ac0ec9501ac91a2b57220e9c00ec6e815399ede94a658c36f9e89bbf1674316d65dc4",
"0c9480160c4e9db4e82b4ad26cb79e083e9e2056e68a2ea554aca45802bbb188389bc4f"},
{NID_sect283k1, NID_sha224,
"65e9124a2606c8784c9489add2999f4cbe6186395df20838d653b263a207ec46995d2685"
"b55d1874e7ef05a6a3bb5b60a7be6751ad568cef1bcea2debfc494d1e2ece0dc8028c88f"
"1b2c6e4ee26b639c5e81f6448bd25b73ec4608a8e8cf4e0155c29b6f0a62781493b03bb7"
"384c9808529d5f87da6564ae196a365bd282f46f",
"1f3591eec4a8a3fe6ae6debe230d238a6b73cf3791cb735add1abee64239bb100f15166",
"040483e7e2b8f7ff95b86008c3042ab83a4b6a48f15ce1cedbaf3b586b56ab606e6f23a4"
"ef0287cbc8c609426f1665976e8120afb8de96b43978762ed44bea5aa1418b9af6922c60"
"66",
"08165da5f5427b38c447382c8dd0940c3bddf8f048185e6cad260031f7c0a2ffb83027e",
"09034633dbd735cec6208bb6f4455b295b7d730c9301bbd1c0e9f101399f2b3425a13fd",
"0204ec149b416ca3467e92194449cf2ca0f41ca1fde79145f3af856085b298149a3253b"},
{NID_sect283k1, NID_sha224,
"e793c60fc725fd537d5fd38e9b4fb52e268722ae6bde5a058de8d20db301f5e8d8e1ad85"
"532198835a04b76f27ca3c972be5617a55677cffa8219eb64fe53ced242efe1b88999097"
"9227dbaaa15ed39d3b6be8c5a3237ebe12bd96f333d947f80048463d3859e34f865d83fa"
"f03894c2243a06cc96788ed952e606c2d8948271",
"05af03cdb45961e7ff35fb0146904ddd6c2bfd3cce814073d3aa56eaa9f13b4f7423926",
"04070bf676b9b0db558eeb8bb94a1248bcb599d1e8975ee13cd37dcb78af19307d1b7e57"
"d506ed9bf30c627062b99ff9d05ca03441b6194c34364cbe7b73b46ec9716ad8a9970cbc"
"99",
"192c7b1fa8f221edecbeaa51447818474dd9fc89e962e8e87400938ef0dff432a6c4b86",
"1df1a4f9578e9cae8102aab5eac70eddbabe4ced99b5bab1b1dee59c41b81e392968c14",
"0f2b1319335ee497fe3ebf1891a71cded59704365774e1ed9950f79100e70950783bc7c"},
{NID_sect283k1, NID_sha224,
"a57682d21cebb48190199e9f57493696eae3a59acd22f64d5ef4729decf6c2615b326817"
"a6bc118bb7234bebfc7276dd998838c009a7348e46431574638dadc48538d6048d572e50"
"d9c5974d2049ebe1837dd857bcd1447b1514b62808a4e7a88162ae1bb08a0f6d3db6f258"
"74c6cd0cd4ca6333f1bd57bd192ef67e4616d182",
"1ec9710ada06e6270720692a06d488ae2ba863b905dd2fc323e7ce68dedacb35fc8c7d8",
"0405cda72b5b068f70b3c431def41b8ca1d4381e8c2fdf0821cfc17eceadf5e3eabf7987"
"b7079ae508354fe31899cda71e01cbc80e5192d24f1f13c954208d2ab8412802407ae376"
"3f",
"04f7b9372a8fed536396f0b87d4b20494786bdb8db77200c1aac1896486a05d3c940cb5",
"072ecde2a8f506f0fef273c8915a9edc29e440d48fc6cefb50e7117492fb4a13e123bed",
"0010dbd6229d770c468f5d8bd20edd6928bd8824b7fc2b10dc45fbd3242191e7557b984"},
{NID_sect283k1, NID_sha256,
"f646e7334e191c2bf0056d3bfd23f03ef7f0777b923f962519a8399d311b8f68414c689c"
"a34b96871fae99eb7ea534fcd83e788e56eeef817cbfe33677283c736b99bf6a626f9515"
"291e842bf99f694e4e8aa7c9911c591a87d5f112b3d96b064594e2b368e6d1bf1a1cd343"
"d54916a66da22c26355266aa2884120fffb8b94d",
"0668de088c6913640fbefbe6d2c44ab26e481802dbf957044a4957c3c5d0a0fde331501",
"0400d3a50cb9d347cfe45d2a313813fec8b928a9b1defca6ff4b89c4787717f275c6b733"
"7f0762e47b0669f625c39c74d50e2b46875ef366b7c3b005c16ede69a2fba161faf6b3d0"
"db",
"0b24bf54795fa02eb9527f21ead5497a6db2bcc7849a16d206239f830df313dfb7a2716",
"0852d8b6fe93b0b36af5d99530eed08669eb9a25972fbea59f32dafe88b722bada98ab5",
"0e5b08d410f2252f724dfcecaedb37b92a6c09cde646ff6237007f4199068f945ebebe2"},
{NID_sect283k1, NID_sha256,
"a2d7e69ea381d3edfde4664c56c4cb140d01cc4425df757975cedc995b89640dc016ab41"
"9b137ff25a6a6d64a309b23890439d2ba157262393cf93d15ca1b1ffd19373ef12367f88"
"98aaf56d5544c2f019a4854f69b3d8d320e03135bb7b675e588a5c3fe4b703938fa0f964"
"916501297cee2fd04af767155c7739419f9dbb7b",
"0e6af57cf47de1e6f07041eb5e1a413fb7ddd82f8c7f7ce957eb28a118004930bec4dbd",
"04021e31c4e4d412a261e40483b9106bbc1b0d7e7414e53d7b9fd84175229c8cefbbf6de"
"fc046ff2dc601dd407883af7dc71a6ef4286cd3b1b6ccee4fd861865bff8fb38ad51b63d"
"49",
"08f9e2113d0b223c04e678e8ebdd3aab4816681a9ef08b18a38afecc57d79c971421469",
"0d2c9113a18bd51008fd327a55c214c9584b6f1b816cf3b95e7346080da2cb07dcef8aa",
"19167051872759c36ba9eeb5d620cafd3289e8b7660fc847ff385b5143b3aca38780639"},
{NID_sect283k1, NID_sha256,
"7088f60e9375ec6a42f705f851fc76cc833c4dcbb3352adcce9f59197c1b7121e7aa661c"
"4f8ad9f4ef280af3a2981e90c01291f7d1cf7d3ae2d96b37fe6975e11b7c6c02b8ef044d"
"1470b1a26b9c72e8c4e7b1dd83c8acc9542e2fc7d211b87841dcceea2ab8128d0ff7bb62"
"2b60faa4a89ea7008f7d55f8f9de675bc4596fd8",
"19f9b63fde8c6aa6177f2a38981505d04f8ac62bcc21007b05615d028cfe851ab9cbbc6",
"0405a3e567b227869f948180547c2713703c90698dc04864140d22b24bdf81b3996829ac"
"a505b2ba535040afed0bf6f9d850713e54013729bc6dcbaa336ebbfb9c461f7ac61af480"
"01",
"051e20545a0a98dc3fec59e4ebdf101c6aa2768f344c1e19424c1eaae4aaf7ffeb5205f",
"05fb3329f63587e8febcdec49f92de88366a9f75d0b9a0f374dadc6e7a62b833753e990",
"12edfabf1ce434c850b58804f1f31f8afb20fbb36ee69b68668e231e4c04fa75e658478"},
{NID_sect283k1, NID_sha256,
"ffd6044ab991849939e8a29184b4d0ac3e07acb63c7e6b886df9e8254073fa800d5910b9"
"fe34fceb547565a2344eed4de394ce2251ed51ec882ee9207eb7340464c742d9d140fa09"
"64f6bcb1efcc2d13919af4f727953de41b20728ab975c1ae0ce784865f23ed1325c68daa"
"95ed5c932893610179be94f13b9a4149f09833b3",
"17704c1f436beb52f7ec97192e23e206ec09f9e8986e06bef71467c192bad6f0066b3c2",
"040329294a36ceae2b2c56bb6e21e52ec32af11aca9ab7785be9c2d79652e7960c0cf7a8"
"ae0658a89a48fb95cb7028252fa9792d91b989d7cef3fda8ba9c8e4ffaf19269f2a69f0a"
"24",
"0aa8d2e210ae40ba1f9f051ad85d37f7cdea43aad890ef802519cc5773e9a0984fe5d6b",
"1908e3a2740fa04ec0b23c964c4c3cca51c4603e7553461dd02f8319a7ca2ca09d0aef5",
"12d7860d7b438df4653fe40fb9e986cb035b1384464e061bc4ee3bb29aec74d16b0a694"},
{NID_sect283k1, NID_sha256,
"c9f81c9ff7d80011fd41f2de97a6c1e6a22cc2da7b2b9e4c50e1354c3e139b44529ac786"
"ce795fc501dcbf11a935d4728a7bba44b4e86b5e5990fed4d3e24fa5ab6f303e1842918f"
"156e00dccebed6897c852207ae5941c630014a41696882066c2b296d39cd8658cb5830ee"
"e78e29a00335a99a0ba90722ceca5a2e9a99a2c6",
"0c7d1ac8faa689698f5c6325a3b3f35e7730bdbddabd0693f2bfdc5c838bd62f84508d4",
"040095a930071ce56f28a79a66b751283c756c4f2566ebc2a10770ca60cced6914bc9a0d"
"77046f70021e7a949c7f55b059d4c8e81ee23b13809a35932d83b8398fc8684c5a90f3ec"
"71",
"038ae832c25dcd30c1ee3f5fbe84bd8779c876c0641907695aa598132b0e581ea528332",
"0eb27c86d3ca86ef53aef0465d257e6b681f891a6357cfbf51260dc6e35a82799de0e97",
"0e8207959e8be94e7407543df80d38d9e662106ed68e1456dd1826602c5b73f27ddc901"},
{NID_sect283k1, NID_sha256,
"a60de761eb32490184dc1d29e21fa33889295ca587b994746874c7289eb9c83e9c7bacbb"
"4066c761a06b65ecd78d701bd41f305cd7eb258c630f3febfbb0a367ad16737b146fd793"
"dab23562e8001cd113135b1c981d1ca23eb3be0fe3e24fe3fe1089caf9fd8f4f0d1f90dc"
"c7dbea4a9e2357793b65daf342b8e6d109c6dd10",
"1a173d158866db0ec665ee632b5fc397893f6a44ee17c348e7452800aadd8ce676e7fdc",
"0406a9369a93e0b5165ac6e692db035495c5cdd6df243d9756098385ad616374ac1e1efe"
"e2032f72a02c36954cd8221126e4eaec02668f454214e4508cf72b6d945e14d9b7c5d404"
"c8",
"0200713a78f58c755db4897f9b7e52057a087816a07fc388d66d34ea9e0bcf2f47e182a",
"11a26ee24610e705a42329f86aaa80d78934b4bbf19314f06eec46067d85c8377e04d91",
"077e35add124574e98e0056bbb106cd28ba8c3bc0c47063ceebbbf2684983a2a0061950"},
{NID_sect283k1, NID_sha256,
"2cd0320cc73120ef13e83c8144b270c9a1f2049a9250ef7ee83ccc7584025140a51e2227"
"a5ebb824deff55b3affcda63ecb1fd3f337c67c08054dc82fdace0c4bb9cef1bea9dd792"
"635f655363d05903cd6b5ed50ee669bcd8157509366cd85aa40d19593265da26e5641590"
"ccf04672a6df52badd4b99964a8643d9687b499d",
"05523cfacf4ed3b74ebc30f608292e45173001d80cc801f729c5f71fc213b243f041ad5",
"040410751ae7d8bb2295f584ba3d55eda41a80b8520b02bb4e5ca669a1003d6f2829e0a0"
"1e05fe16244f76f0c8b24bd3ca3b53c697097e3ab0e2b44962ea534a655d6c7d80b857c2"
"1e",
"0a634f4cef0ba37c9ab211c57fe6574c67933280c91c8b175fa4164755bcde867fe1772",
"0b9f6946a578ee38433e98478a4c31b67e838939cbf128f023090c4848471482fd1dec7",
"157159e15a2d16da2e913c5ef00833a8e5513ee4e7d6cdc849fd822c59886d0ca3695ec"},
{NID_sect283k1, NID_sha256,
"a743d8337bdefc4753f937e869a36439da1f8c75e1278c3f6a4a969d93787dac93293818"
"b1cbef5b8636e1a6cb3acaac1e15dbe0841c8001512b689292f3f4805997ae26ff52f7fe"
"1842512a020c448ed01af2a061f3638689446ed5f6bed9fc70726ce4104bc11142de6387"
"3fa7039830223e8f152996388417c48e0c1fa81b",
"09f6bd008c04b8823ccc3ee7d5aca535c211f35e9d9e7cfaec518b98647fbe6d28283de",
"04070019957dac0e9be0fce6abdfc00ca737096ba2d2bea9ba570acab6d73eae2132d7eb"
"060559545f82741ddd1cbb9dab0cd06454fda8abbd9d1eca752e57ec05498b14e4189f1b"
"9e",
"0fe407c226fb15bc63d37cc9840a1a1fb0ac4fc2939fbbcb6e1236831379d367669ffd9",
"0e96e301bf1193dfdd2815597e016e0a282d6e8f9d1d67a7f7e7d05288594f1ea92584e",
"07488687f13c3a2b9ae90536db7868f2bde1529ccdc0c84eb85c53ea979228d1fda7c94"},
{NID_sect283k1, NID_sha256,
"6a7a3ad614a3a09d2dc5a80204815d0c6471057acc0fa73f3cbbf1801902c3e1cba3c113"
"4a79a8ce61994a94a5afa85ae1a44b2cdcf5153f8625713c872da36aba0afcc5c2f26636"
"dc3f60e04c256a5b023e20e2e7a3f7305bd5b3033fcf05368589f19021f8c9096a886799"
"04b657bbe5b9bee67d6e53d176fce1de9e54c64b",
"150d2812505c82584201e93f6e0cb875d29dc7bd99d9c0f98e0ed20128886e67e1f1071",
"04012c7750172bea15487a05580891aed51bf81548f4b65c51c6c54b990bae8857a20115"
"b003db9e7a17dc8b24ff080d80842f0488f17f7d43a40ce6ffad52c65f5a875b4b33efe3"
"fd",
"0c5c52dfb50b210ae13c2f664d958b2491bfa91ced638f925941234bcc4d66de1eeeb73",
"03887a270eeb515a59a7387d8acbb4e72dcdf13f317a6a93ace5cc98d69a79c64a9e7ea",
"0e922b2d021cd71e213bdb36ce3ebf56a34617d4dcca30fc05f238a1c097e38d7cbcf91"},
{NID_sect283k1, NID_sha256,
"65bcd77a3ab345cc99b9c1300755288102a6ccf140bc7d1ad25df246ef01fd57a8614b35"
"2033b88cc6ffffe5b38b99ecf03baa365ab5529d6751a3c020d0198561969aade0909143"
"4d84ffe13b46df043d0a61e20a08e9c32b646771fea1b29e202d40aae1c7079873c3af49"
"4ecf6ef5eda855736c9338b4a5c29a086a8266fa",
"1b3fb9e1ff70f94bc9d7742ea535ca982215af3df381b5ebdf1db40c7c849a7978ceb98",
"040769a897a443c41ae7a8c1e45290ef39c40887ab8f4aa3f9ee8f3096921222ed7de457"
"39072621bfa30973da61fb6d363d66db25daf818ce79dd3268ac0520fc99ca7917fa3a23"
"60",
"03fa84ee38587f9c848b65b07c47551e27f15e7a87ed0ab705c99c8b7a4ee9e86a8e4ea",
"11b214ebe67eda2bd6e84c33be05c4373d2536e2cccf152e56b1569cc96d261e50910cd",
"0e100646cbffa016664bb57c1a67108645238573867c0b595c46e6053f844e5482a993a"},
{NID_sect283k1, NID_sha256,
"ed1acc360d02ee6c36bbc223d91bc1d2009a3e8f8dfc4c3796cd8555b0d2b46716f4c805"
"8bf34c2d4954e098274ab9c2cbacff46a0578a14e77fe104196cbc6d2753e3bb5422b8b7"
"9fd004ac0aa920eea94925c016ece16ed4dea916fd92563ec65692a61b28ee84bef00071"
"20bb1e31bb75b8ecf68406a71af9a18b4edf5320",
"147fa46fccf0805d14c1b84ea59bb8b8283d54ca0ceefb29b5585e7141340c55b7232f7",
"0404ace4c65ce07fe5ec22c560bc553bd791434a691c2d865c52b5e38d541ef191ef4190"
"67076250c829de137b6549d22a12f196629d9d34cdd83758e5daf45fae41872c9b15190c"
"e5",
"18c4f89cc022236a0da6105f19c6661a8325d36fa285e3ca71c1a4af3dccb016cac186a",
"0271b421fd572de8a71d1b18ad2325bc0fb58cabaabacc1f015ee6b14bec49762f1f8ce",
"12e679010ccb143b7de0c3f6c82cf99a961a4f154be6c87abb111cde2d721d864d7a1bf"},
{NID_sect283k1, NID_sha256,
"2debdb95a21d72b69c545988727366a42b819ca6398a82129c5e3772aea93fac0aae9a27"
"b11969ff0ffb9dc0301132ca2452cd863316cf24ae7696422d4dc68e37316161abc146e8"
"6f04b72d9a27a350d8545cca245b2be43c33bb822dd813d13e08a718f784845df8a4ef49"
"b02529871ec76bb3fc1ba31089359f2ede73e767",
"0fae097ea56b35a517be5480802f450eb832b244558d0cc922cd4a5b40b84d02ef11216",
"0404f6bda2dcb9560174ffa54f13fa5edf17bebd41399a1dce1fe13e82a2b487eddfe25a"
"19076dd375f2c5f24c342a8e2491271cebf5b97ac666aacecc8d693a85ebd2a93eaccd40"
"59",
"05e3a67091b9e10c7fd20fd70d51162e5d78555059802d0c3b133f49b89f37be6a119ad",
"0ddf93ef8797571af3cc9a66660c569445a2b5384f95a12d680c570694bce49bf2264cf",
"02f50d68bda006b88798d87c232f5ed1796c841074f063da03a471e0c00f08b10f410b3"},
{NID_sect283k1, NID_sha256,
"e4e0c6c8fc01244abf81e139c961b6a6e2d95de5dff1083e8a48b40e3e5b9ed909152c92"
"b1cf2263179629cdf76ae553b58bb2e9223ce4f9ffb5f170f5f0c5ec97294c34a7529a89"
"7e9397f71198cbcd68bb4055cb8cd6b690290761b3b73303f82788379df145358afe28f2"
"997d191d968929b7a4b9a0f6228797dfaa17c613",
"026cd72e6ae19b3f4c53493fba1e8082a8df1fb7da6dc111b47a41f713f49b33f618d0c",
"0401c411f5e298c9b61023fb26765cf4132cc78ed77c07c3e815fd43032cdf0ae8b8920f"
"96035647b4c0807b287014043560d70c9b14651cddff4bdf6d44ead5e87720294ff89544"
"06",
"10e9bc449e8480474afffd20b8acd6dd08344981c4a6cc789c5338ad7e486c526d6c4fa",
"0e81594f1064e018aa3504bac75946d77f9e745673043417a47c0c82488e224cc4104d7",
"111bf8635b1bc3f6cb7f9b685077b38d67160d143ede2bd8b6ae93327d7f55c5317f00f"},
{NID_sect283k1, NID_sha256,
"04710947b7c90855ba4e59107b919d4a1df22b503c5c4c33b286b6b08e451e6fbef8ba40"
"852f9f0ee62c9217abe6156bed46ad6f0e25f70f528f3a73d099338c578bebd6879d810e"
"6e173c2b0af1f7caacb3531ff0e6a7856e4c84db355d110febdb21c683223eb5990ef203"
"8d462ddb7962bc0feea5f850954943d53041f66a",
"198e13c7d95bbbb6e226688719639bda988867764ffa9b029018b5547850daecf58fe1f",
"04030b511d719217c485866273ffe2996a19e0a670b7a3fb077944a21f63ca2f22fe5a52"
"4a03a4d9a808e8d77c9dfcec6d033139fc33e67d7c8dfd7329c895bfb77f565391c37c8d"
"8f",
"1721f1ad4adf3c32614feb7f8df3374e24f76a32e27854a57dcafcbaaa3082b13e461ce",
"14b2622432adcfed7c2ecd2b52e43be7f611680ceb4bedbfa9dd9af54532911a07440de",
"0ece991128b10399188b18933c0d185e85d111ad401baee5ac376b84c523f130f70fee2"},
{NID_sect283k1, NID_sha256,
"c62d07bb1ef756b6b2fad355c66b5be086b6dc387b37cbc4a63c841dba3fce65b09d3de8"
"f239e3649382d172f065b78f8a53e0283cf345de06b4ee0b4b7d8611bfce92a7d993b193"
"8419afe817611bc6df3ef74191e7e39ca2339fcb5b5cfee3166d09cd52a1a7d3779722ae"
"c328d326a11bbafb6aa417920225ac453146b9b7",
"19098a39956747de24ded56435fa1e6c30cc2b8088fe9a75f5d07b2f5939c7a60db64ad",
"04068cf5a2023753717d89d12d6861c8411e6081c3158339573dc5598b1700148d00b39d"
"c5076a22dcd4ff4f062eeff83a58d2ce6a1808af8733ae254f5157efa8ea35a85cc74469"
"2b",
"142e4907ce239cdaba562d1fa7305bacff05a75e2927800c7b7ea322b47c9ea47846e12",
"104620d752b73379e1e5d35e5b24a793d7a309685c00f8bdb97bba9876999ed9c763d0b",
"059cab3abb0738d8af4ea6dcbfca6d0ef11b6e591ca109b040347d7d4736724953cd9fa"},
{NID_sect283k1, NID_sha384,
"e4d8d49c9bc566261d9134d5e237d9cbd6b67d2619a9bd06b7c9c139e091aa10682cbede"
"114e1d4777d9cd67a16b7d64278e99eed62bbf25ec5a5a8fabcb0a3468b0e73fd02ac653"
"3e04b1110d29da3e34f33eaa228b78341b357a5d892a61beb2168c3bd5e66bffe3f2080a"
"1e246f55a41ebf9d579e188d16991aa060460d6a",
"1636bd2be121e07ee83ac5e880cfdfca6a56f2b9d0badff003e872348368c7c2cd96b6c",
"040007acf46ab68744a9baaa33ebf6be20c1c093242b0056bb9885d93a4a9bb4640f17b2"
"ef015415c1b671e98f00c1fa364bd69cf998c0ae140485159b0a341994a4e27000e108f4"
"fb",
"0d0d4886c3500bff68455c41f5840d0313f33ac0155a693d27c66fbdb12791c2b5f8552",
"0256b8ff7d37fff7dcc8cc4461984a9bd9661643fd3a68d07fd30d426d10b8c7f4dfa34",
"1f516f8ed4372780380a798d2da04d691aec379483bc0d10560ca79edaab453d3e77585"},
{NID_sect283k1, NID_sha384,
"2d1358fdffc14630fbc421b443d3c22ba10ef34f15c6c5bb3c73a9b8714e4c411de69b9c"
"d6628fe2eba5efc4862af66ff916505023e0514f564164b389ea422d0f1beb92adcd65ba"
"f43556614eba25e43852ba65af78f62d64b36696519ef8284ef7316ea52c365b99f63a39"
"e6701f81ad520d7445cfc0113c38ecdad4bf5b7a",
"15e5f555119c19b055b15b0c0d2813068bfc184f864e250b202384f5728bbbda1cb0f5a",
"04013cae2f0c3ba04d039c42cae27de4cf5842a3e24be35d7a3cc7f05083f02951cbeaa6"
"3b05d69ad5b7d64d6b19772a1794562b1fa5c2fea03909bc509e7d47b0e8144acb3c26fd"
"dd",
"1b881d95b7de9aed9fb5ff0085ca4da2fbd413b9b947066c98aa0257142c9000bbb30e2",
"176f9e3c9e9f98b2f5f352ca74310badf9f598f4d42cd2b26e5ea0999ae31e3c678fad2",
"1f2dba4e17470cdf7e1815d30771f352807b38080d44465f86044f5969b017c9059daf3"},
{NID_sect283k1, NID_sha384,
"d6336faa5c3e838f4fa58626eb353d4cff9ba8f0aa0e6c3d0d850e8b22f5b0f047afc977"
"67f1afe2040b85d4e401ba688a4da7a0caca7fac450899092c4fea789231ba9b07782010"
"720f45d16d353798867dd7fef4a324520014ad5cb32684ec50cab742b750e05db040ff51"
"140e8d740f6774a059feeb493b10d8ac722f23fa",
"190c8f17bdd38669e345440d2c7631d67cee9c6548c4e7b9452377adb9303430efeda0e",
"0403235a8b7981b3ff376b6b0959a42cb56631fbb9f82f1694b9e273e6b7131e758fa0d3"
"700444e5747420d7f5ffd6119ef43b998d4ea4a58da13ff6fe7f241ccdfd4b6fd33aa93e"
"3d",
"0b2a690793107257d7bdc37c492eca48c4c9650ba0d657e6eb62042b16169fbe27f8984",
"168a83fcc67e0c155f1fa2329363729872e254f2e0c3ef85f3b3c84fa3406de4191b6e8",
"18c0f8e6b486e6d7d16b4103506d74bb2021232c0b1638858295a63ca35e0d6d26a6266"},
{NID_sect283k1, NID_sha384,
"07384a3f650bd270b14ca388a441af201b7767a2d47e9033f50cefd3af8257ecb38f5267"
"e141cbbb2ab7327d8fc78cf27198ca3543d39553e178390bf1b921618432ad895e4f8153"
"783a7ac22f4ca3cad4560e64f1ee4a7bcad05df98ea49a3847dc2143b27c243e48be59c8"
"69a547988e2205358e8db98b635ca21b745df4d2",
"0dbbc2a0409ca58a9e39e33b95fdd15080443c1dbdb5874bee991bd1b127047f08ec9f3",
"0405a687605e54e49e3c40fc5ee8fc014a62d72e8595280a66ce7d367aac2df4d16b98de"
"b3030abd03dfc224f459dccd1606287cc30016be317c6207532a0725c957ca5fde692a9c"
"43",
"16bc5aa29cea64ce3297172f36fe4ce820c943908c21c9967697db0cd93bb8a12e42348",
"1b1fdf26a6eb2d736b8c1ab165af2ac31a4c206c5410f61ac7805a68992dbd62b457708",
"14e9a22ce703d942a4fe2e84a4c1c1b44538a33fbfe904bfbb17af6490d372acae4668e"},
{NID_sect283k1, NID_sha384,
"824f26dcb4ce0ca020982814d5c727e629cbeeaa818c49668f8f6d743f0d0ad362b24cba"
"c48027898f386889ca5411d7d1f9afc69493b1d9ae4d7b695c9fa0a30bb59e6be2cbff79"
"231767e96cd8bba349fa2f97955d56f05430ab4ebd007064e3d5add94dfe255b6deff196"
"50883ce9966e1a2affaf84d9540f65c87ab1f936",
"05495e6c59ca1873f36b756579632fd47f9fb95b64f52589d70f2739aa6a3bf8cf8c198",
"0406df40d8259be64c8ac64a28359290bd52e843f330a68c2b605ba4f777d7bd7a798e93"
"440458667cd7021b291c3415d64f9b054db71d3fe20f232f2a2286aede89ddaf1ee8c68a"
"a0",
"138f05303ea63bad47c4c9a9d43c52c264725a668db5b631d9892daa1b71f62656cbf73",
"05e35c1f3b30b43cc9d60bf8779f3b31e053de0a390da50ea676dc9722a17ef00d68aec",
"1691ecfb826fef1ea0895242129cc3e9a14e1f84fac49d62ffc0a3455ad9c97becd5980"},
{NID_sect283k1, NID_sha384,
"07de1e4bb9be15a710a74806d4447b093bc08ed04392d1bd5abb414f5f4b4d9d43520d0e"
"46fc81c2a97e71086b28e53242449ed37fd7ed1c5772dbabc430fcf82ad20437b38eac15"
"820421e51912325c872894452c3f8a10ddb040b35308e583c155c3707b52df467c4945f4"
"e1071126ed46611a3253c297f5cbca9e27f58448",
"1724987c9b698519b6c225cf1261b77d0300045e5fd774dcbf13f285e6bd74512cb7edf",
"04046adc9bd5f0cc0d8bc64f4ba491eae3b7f6fb4229bf94b804807c6137787adc0fed4b"
"2f041375e2c89da41af84529811ce7aef26b983ea8add6e37c32f2b00bd47f23f25e5fe1"
"94",
"02ea4ed0e87687a50dc3acc7f4c089040ddd367d1a3f470a711501ccaad63c201b87ea6",
"1be198a1b6e91453018513902f0a8a085c76a2798a2a0538ede30dab65afb6b9b0496d7",
"16342f87a813780aec006ee218a615c4e1c78c0c759d48d4094639b5b4c32a9658c4d9a"},
{NID_sect283k1, NID_sha384,
"1edbbbe71057bf7d0bfda922be21a3a4dff57b017ebf6fa99651246cd173bdc9b11eefd0"
"48ea599c1f98e907932aa04f64ed0a007831f30daf186c88807400970904d6090b2cf181"
"e0f65f03b4234aceeb420867812562e47f452152bb1ddaaa48487170d06e47c5e9a7c0fa"
"a4fe494663d2fec22f7665ceffffc214b21c6b8f",
"1a5489091cfd51a0970508ee3e8449081ed175928ff8386592c83043a7911bbc2f8778b",
"0400aa1562c94bd16a3f8a1d6c465908ce3b83ba6711e7d8b0b9353d3c55d13dee213aba"
"700103a789854f63a139e31348f1b2608f1e71c88b5d42809f2460642ff46a470ad85735"
"43",
"18435a6d3bc02b3019e1b156ddd6f3e1bb9c5af70d1a2cd2089e677cbacc21624ec8947",
"031f561b668aeeb4df43a3a34716c4e67232f56959104b7237b26e3c95dd40e15eb076b",
"0f2ddb6e6d18a7393425c16b3e5a5aa232cc48198d63e46a601cd3ed221a8427178a0bb"},
{NID_sect283k1, NID_sha384,
"db5cf1de38a5187af11c1f0f19a36db52f8417de997229e83072fb51a3b7152a3b383e99"
"19c1b8427582e53d4e7e25433d46cdf01492021c237ea0a87d38c71634743115a6b2aba6"
"6d3faa8003158340a5078171e0bd55a6e5d8c7fb2631a31c1204e1479bbfe79ac70d5e58"
"23af502922a900576f0088a33e42ec3e26c0089e",
"1a45ecda0788fbd7cb7a716dcf4c6e83d4148bf63ed58078690ebd238c00329c462590a",
"0407a1e2fb4e8e79e3946086fa65042362418db0dce51541121c73972a435aecb99f6340"
"23006bb02df9899ac3f207732fa7cdbc36a60c17592af7ce06b8df4255110e26a02b2318"
"00",
"1c986f88ba3d5109c0afa2c213dda8df462282f024cc8efc758a5342a0de91c40452443",
"1efbd9e0d912e170c9c55bfbdfa6106fea4a4e013e7dc26628a1aea4f6b806a51866003",
"0b1347f4f85adef612f5c3a436cfa59eaced5c7cfdbb69444936d71812a2ab2461bbb5b"},
{NID_sect283k1, NID_sha384,
"4adaa850eec8272d25d76600aacf2cf66e754f6c5efa65c55a2a31b7bc69437d9a7e47c6"
"f51c5da93895a45221f5f92c2e20ee6a95eed3cc7249688261a35d82872284900eb54dd1"
"df6024ec48963ce43e8ed8b8cca8ed22beee8f0aadeae53726cca05443316537840ab824"
"cd1b595f36064e9a19333748d4f4972178e7f5ae",
"11461776c33f20b176dc8f2b0cb2446a9b69e55b6c7bc7457a7fb4639116b452b79661a",
"040043ba7157559659954ac58b44f19262bef9e3a00829c70af66d07cef08ad899d7f8ec"
"2301e8dd9c947b5a6decd1a26fc5d0eecc9605d22abda747fca038571bb37036d9034e80"
"61",
"18b231de7fc499b461afed9b80f4405bc005011865cdfeb25570b7c0ff79b6ae94b6ce9",
"0fb203f47a4e2e9365ce070ee7fd4540f3f7e9ecf69b4400eeded0f5a7bf6e5a5c6d004",
"0e635dc65233f27b8350db22b90a3b8611e6fd1b3e0f515e42fe8788b1376079816308e"},
{NID_sect283k1, NID_sha384,
"11d212a99c39fb5e4ca0096bbe6c81ae1490e1b8e07374b4e773bee4fdd24a3c13d65391"
"9db663d2c32aa4db140c4ae2d472d4f878946e527ad33b3dc93012d97458f96cb622ddb5"
"6f1ce7c2474ad0d5291dc35545de47b7053d137a8e79dabe06757ab53e26eaf751111bd2"
"7690e57ffdab5337eb6f81889e9d1b1ac729012f",
"025a65f627db2b4d6cf83c5b0c00265b9b63f7656c5e3382139e4992bcdf3cab502844a",
"0405a35e7e0b914a3e01ce3a885192d2ecd27418e09898631de122db0c48e8b58658720f"
"cc0009eab47197d5f56927848855b6ff96db7c36f810ee7c89b305ef780ba8c993d65537"
"ab",
"18516ceafb61cf2c7e7c511a8918bfe394c7fb2fbc40fb3052e156cd4020fc674684f84",
"1892ac13b86ad00e38ce2427c8c78c93b08605a75ca22b3658132dcf9d9df7c4b5540a0",
"0437b33615c16a85ccb8c4769ee7c5f94122d31e2b5fe66291b401fd90257ebefe33818"},
{NID_sect283k1, NID_sha384,
"9e4ec74c09528fdf3153a0f6955f20c70915ff524b2e19c991ec4c5b41ea9185e3e876a0"
"2ed6f27c9b3479dba951bee8680c4c99be1a626808114408856994be7444ccbd5ef9859f"
"a479b1050bb836034e20c531b4d618f5843fe1d4b613a731895b489a2363f3f5397d5ff9"
"64cf037e9b11e3ff5e1c3d403e5a46b8387c1241",
"173b28fc29f10245221a907778708b3ee62e0480aa9051d4c3eb4e8d552e6aad5509943",
"04024bb9bdef975af892ddc1bbd31314926a9c81f8f1864829edafdfe2744e793c100c04"
"83028ddde61b4361ced9c391c86c28ece9b902c48d14c61684962007dfd69d0468dfd65e"
"7f",
"199af64f79ebbc5b789d4676a07c224e4f6fd33285e5a555ac90cf65d0b669bc58ced4f",
"137d746d515b90890a413685bd9b26a1c05efee4c11a4b40bb621c9fa2580c46c20a687",
"1647f70ab7c68a0f522420893a466940ccf79067b323d940369f8b8694ccc3fc0daccad"},
{NID_sect283k1, NID_sha384,
"5fe8253d2134c434cb0866796013722e82184638b024a5a30938039929ccd8415c71f71f"
"239c5c5a81f7a9cb493dde209f189bcf766c17c6d9589cd0c7de7f07ff9f24d2320669b5"
"89d084f8a8ea71127b9760b7355b162616afb34bcdcd416f1a062035102e29b70069b2b4"
"dbf70179b8d60bc2ee5a455efd40194533bf560a",
"0624616adcd45e1fdc6cfeab2b17230d73d91fe0b39f4664f3c6891554f9b8e238257f7",
"04010917ef84bd5c0b36c97cb5586d3057a34f2827f239cab2af2e6081c5bdffd48dccb0"
"b2078ab47fe1bd3e28055c688c78e617ddcf6c5060123e9d65c562df2e94cac973ab3b18"
"07",
"0795e229185bc1b3d6d69b08189fdd7a822cd18ac55971e4b35e51838bf12eacbc50e2e",
"185483378a162b8edd6a12f44e3aa4ff829630fe3a1c9ccc66e34775f69bb6a94282489",
"01662cde6cd497be7966a0a77b0626ba3c4b82e20bb3f2e839178a31aaf440aa0e059cd"},
{NID_sect283k1, NID_sha384,
"db49891838fe23f0530abd4a4fbba5ea970afa5747f6a0a10d2cf4d841581ea2178705c1"
"203f00cafec91d0a72d25448072c9cf7d7ca5580b39f8589ec63128faa95cb0689574a6b"
"ebd515049a1eb9699922cde0366b5cd58aa8f3d3e847706896f7e1cac667fbfe94b2eca9"
"e7be79a810806ca4bf53f219bb30532ca2254c11",
"199757ffaa2c59e198d66824eaad37cc42d49b2e241b6a60382d05e425e800eaaf32470",
"0406ad18bdb3e51cc053f56b9f9c35e2d6eaecbc9749f41a9ffbf54634838d7745ca0648"
"9005dd77c42b31aebbbb46277176df08d81919ee0d9ddf14c3e4c0cccb207bf649c48fc8"
"b9",
"109d6332ceec5ea211f642a746a6ce055986b4a2feeed7e847904f7f411bf8361318d92",
"1a49fe690a34151056d290790a6bfa7b70958e69e9baeb30c55efc61dc5dc4934f2fc95",
"1710a4ba5b404d65f66a8fca2751a920224db0cc0266f7b0bc054069ea4cc51b1f017bb"},
{NID_sect283k1, NID_sha384,
"29d385d09c1142a7c181fe4b6e6132e414c15aa8605b44208c0399464613b966edcc2d46"
"cf203a3f85d943d8eae658695dac74366224a0d0348083bec0106f5eb8809ae8d07f792f"
"dd7c48fb1a25d5ef3bb9acd40b20c61c821024a9acb2ede321bd2d0dda849c22d76f421c"
"bd8d51565d3c4266f666455ca1c0c3777aa44107",
"06e51381dcf21050aef2e9b97e35303cf3bd91956854ecf9b6b9827871d2efbe8201c5e",
"04052fee805d7938b8b97459b9fcb4b80cbe29f20a9aaebc07ac019539a4a966c5ee4175"
"1d078aaae02974de6530f285b4bbe87fd5d0c9a2ecfde5fdc9a3303e4b988f673c778004"
"bc",
"0b426ebda6628125d73efd84e6bbab6c4c8fcf7fa29ffb3c8d6b0a861dbf81cd18d088f",
"1270045e963b59e4a4f1237c2240a5b26a7ba8e28ea01326fbec00e5d95d40e859d88b3",
"1d721477ee1df1388e1b7f92c048e5759c060ce1291098a2fa647974a62a258a189b4cd"},
{NID_sect283k1, NID_sha384,
"774c1cb8fb4f69ecfb5c7857d46415568d88f1f9f05a4bf64a1e1ff6d64aec16e1d09292"
"010d1f067c68dddbcde06ea49be2ad3838053f0b9c0c2383edc451ef0188565118e7b3c6"
"6a4fa372b96633dc8a753106283b02d0322df273d58cc9bd061ec219f1e1a9c8ca1400e5"
"e39c1b2c254273377dc98a1a2c44e5c2a5b89167",
"018adcc22cb9a2db64bad3d60f1608c353e091637b948914115ebd43679904f955c8732",
"0400630bdd8937e961d5396f9ea5310123a340ba316fbb7d79bf8573f27a0065c6fd6f88"
"900737a0ac1116e0e2979f973cd705588a71cec5e2a9f22e7e81fc61a4375624f55a6182"
"bc",
"10a0c04762d02f9d3014bbff287864743426cee14daa43b22149ce73d1ba609c0ba6be6",
"0ac29b041a6b95f9ab685470f50445d416df5f7ee06313185794f2b542fcc00606bed69",
"00a4241b97b6ccf0dcd533a15867f5889349ec353395d47e31c9eb6b8785736b3e285cf"},
{NID_sect283k1, NID_sha512,
"c406aa4295f85c854b4db2de5a7a2defae53a319866921a3673af5b48c85ef22f6eb4cef"
"892c790d8e64530fc20c729b2821b5f5e515560b1ac764106560c3a6a05657e34cd6dead"
"fe2884bd288cef4ca92e1f25adde7d68a30fb0a1b3678156ced62e466718e68e9d67099a"
"d82613b8d06bdda1a7b867c2455422818ae9eeac",
"1898276f159c10d92d8d4b6ae214d68c72792a4b5f1f79936ca3c063dc8d9a88be439e2",
"040394cf9bb273923c88be7a1c49412ab8599e0cc5509926102c122326bc0b34243f7d1c"
"f3072330906f47e8fe95f63d0f0aca1115e77fc702a923c32a16505bcd9021da05fd9cf6"
"3b",
"058772fbb30227a136de616ace4a0334be0996d60e9772ae9bf672b7c38fe3ee1b24f98",
"10e0cd3fccd1728e99e2294efd6dd4797b6492ad95a789aab7fbd177475a047f1e5d38f",
"0c5e0b2d1991718355be14bc57e2d6ff9fa63e0812b9adae69f64da610cc6cbe36fe4c5"},
{NID_sect283k1, NID_sha512,
"cb2809152f8258660933472c06ddcdb65f6d5221fa29d5b0efec9c2a7914dbbf9ce0a468"
"ce146fb333d26f510a87a6bb01bf8816756a1b5df81c5f65360957cae84ba038e37e8877"
"7580e91c34e2f5aef4fb55af7b81ad28aeba05e0b1c64a15381a6719fd2c16e38a441516"
"e1b394952d984baf9e051b1dc1bda2e12f8ba5b8",
"12ff37c808c3cc029a9cfbb67a5ed21f3bf362b49270d4ed0f1e38fad25ebd79f112a50",
"0400cc00fb36bf62e777a9f6048761e53633b92866158200c43900db95aa1342b5760290"
"90055d7e57221ad939f5639282cbfc203114ee69baab4fdf194f4d2a937d8a57b70b54a9"
"07",
"163d8eec726d01a1bbb19995777919f68689f7c2920f3549fef966593c4fb012a5c3a1e",
"0cbf5c3bf1ee58869e1d3c15a05c23217f1c252da97f79334bc79efe3f5c62164669ac9",
"1fd51644f471ea497b0560b65fdfa2fd0a6cef469021303f97753d22ce1993d1ae5b96f"},
{NID_sect283k1, NID_sha512,
"e060af96d4a7fe512bbf26be9a27bb6a8ff37547d4a7bbbfa710db24cffcfc760dac120f"
"89f642880db2df6307f9ea5441d5932d49762d182b29d8e7fb067a61ab0df622f75cecc9"
"17e27d0326085d34581e052c85f50a37713e27518aed7c4434f86970e00a0a4b8503989e"
"72614131b7164c1bdc82d2b6aeac0787f9838476",
"02b8c1fef9c6def32b5f4127273ce384b6add4aecec957c1662f52334f5ee97f49852d4",
"04036a4fe1d77bc431012d25ff49fb5468f975353be70e7507d71966a0ef433df51dc323"
"24058d705cc883a690641f0ab85af4959ef4258a7ba9cde36dab77c125a1de1d39536658"
"4b",
"0865f59502382b324e1dbd75db150f342336fb19145fb43a733971da555ac5828a3457f",
"1ccb2e56c02cbe8038bf78dea256704ee6e51054668ba8c2ba11aef4ac6f9320d46ee8d",
"030e662c0e7d47cb3b835c63599d0c9c2e77ca47dbecd7ac834c2babeb039eb630cd0ef"},
{NID_sect283k1, NID_sha512,
"d235c31f0a82957a087c7597673970aa39321d4c2640685a03df8388b5eae4825d1fee29"
"926f416d5e62a2e9ca1ea7cefffd31607e750fa9675983608e0f8dc895371b190574d065"
"c5c0c23ffdaf49e65362914363a3fffbc2c1bb487cbd4f69ec22dda5c7dc3bbab805c81f"
"aa85787cc176bc0e5703924f395d8c9e7e7701e2",
"0afb1c45e9a9f02942b8e04da4b815498454dde6643de186625a98b3c1c6993abc8bba4",
"04002fed49c59e9d5c09202a5dc29d8dd527a870a180feded66ea6fc94ee094122ae9765"
"6b03620820bdd5910037f5877649be38db3571a9c6ac632602d2013d0d5abe1f00133f6c"
"de",
"1fe749d9916f11100af525ee343b3b74a493f92339e432a482dc8e86ffb5affc4630037",
"120f6f13331cd4d1a5b9707483c74dc0722452062cd4534e94cf40840d22ae263244a51",
"0bc2e37a481478f879de612cf4a833f7e12b8df33f5b0d6ac5f5aa431678ff053e2bc1a"},
{NID_sect283k1, NID_sha512,
"1a2559777a5fd8f269048feda82c4d9fceca95803f84a813789d6ed070422240e443789c"
"5231d63d5268ddebc060dfb99c4eff2ff115d2984d8bbc5c05314562ea6864fd543e7e0a"
"3b8572c017d8ae3563027d79bbe164d40a5bab354720e45094b9b26391ceb55339592fc2"
"f10b97dc9c2649f7227648f5cd2fc46d78d31c0e",
"0ff537d73a4da0ae3a4894016b71dccef3bc886f3d24a5abb7dd96cf8fdcbdf0fdc5e51",
"04001bd0537dfb29f727f91fb469c31164e1bb0ee192a5b89b880f3fa40e3e5437f0d2f9"
"e106df9bab2f9198494094a63f2ea091f60108449f0741806400694a93702f61fb0351a8"
"1e",
"0bbc511c6e1772ca6cd1cd308126c18c5db498055a4b3f1cb0dba3285f6d38b083e647f",
"1ba756f3c89b732398b90bfa2f92b2a77159c530a8020b75cdb9697c6d75c18d36040b4",
"18207cf326bfe97d657ac4197ee5c20c75431ee552681a92a5815db0d984fe597700bbf"},
{NID_sect283k1, NID_sha512,
"658c0d3f764bbc952fa55a258bac16a5bb5184bfa76cee06baf9ee6b9ac3f116e08bb240"
"6b1dd4be487b057f3b29c2043ebc33019b2017c4deccb86f50ff15fc9248ea5fb6426112"
"0b1960525aec3cc18827c23291722c5add8a3761ff8516c61956c62b8cbb13f3d92bf3eb"
"45a70704c01bb3625d21c38ffa83a6db086ee968",
"16000d2e879906d1040b32eb6ba3caff700e5565871ac75f10c5c15b509964bbe5e14c7",
"0402ba89255d1c89e42518662611e2efe3b5e3b8043926ae9c43974ee2986185269246a4"
"3302b87762b9ada81bde958d1f9b81246f49098695391ba3b4b3b9ac5727f19fe42fd079"
"46",
"14e837476e628007b2df21b5035a39c24cd4869bb52dbbe13c9666ddd8a7e3eeae29f65",
"1b5091fc755c0f908ee13ef9bee40dd16a5710befd1e265a312e595842d52cc135fd722",
"0fa25f43c3c074d702e45d216e3704d942e9d67b3c0728645ac6c53b9be7300061e5fe5"},
{NID_sect283k1, NID_sha512,
"4f10001e3517c2c1f973b555f4827681e096d860c4db08f1f4aef8000c9c24bebe59f8bf"
"3d7d3cac959a1a5477bb0ea43f2e746b5d14ed48a58ef35484b0ac786d2fec669f945e84"
"6ad73e6b77a9e47012a951b398941566330d89125eb3c1fbb2f06adb951ff5f047d102fd"
"f28b5cadb4a3e1a10412eb3474d2ed5c3fce78f5",
"019528d505bf0584628d0214bc857150a929d3f59619bf8f3acab545fff0977c9bcdc97",
"0400cc8863e1443e61fedc61abaff87d80450345489728d78c333b36fa28d8754a29cf3b"
"a100205ae70c35396c07f9f96aa7c59cf8a28aa2a365b4a1b68e7414d8c4ae5220c8bae9"
"ae",
"13d555426101fa3c239b7830fe0b6cf08a1c01f9a991f806c84baae20daddf5dec8f868",
"0af8bd9856dfd783217cf81b09b464614aa824b0298f35308e6427c679607853eb66c7d",
"0e6c1933d6ce25d0a00effbaf1db2cb2542cbe7521330c34286cf3bdffc20c001cd7722"},
{NID_sect283k1, NID_sha512,
"c43ec3c3232cae59bdea7cfaf18a4672035dbd2b8b6b1b44ede376b36cc2d8baeb921e41"
"6aa177f5977da8bf1d713509e5251278b6622790056271715cd5feac58bee5baf50b216e"
"8eb886279c5a384cdb696470275b7487fe9ac4c506706f6b0f9809d1ccb102546a4297d2"
"017c2a8df9f02f30d3d1bd9aebf6a92a02e0d202",
"067795ce117bc0a389397fc22a01cfd9422cfbfb5aa44131938a8c45e48e1d5a718539c",
"04007924de08acfae6260009cc2f02daa2fc2a809e6ab4cd8858a9e9c2c15b17e29f1bc5"
"ee004f36cc2d36df63474a579b96f6e59b890782ad8fa865efd80abd798ca2938bacbf82"
"12",
"1bf3242e75f8331fe70113ec8e14ad0814850bb8cb262c7d0a44ca69de52d32dfcabd0c",
"145148d59c5be2b6d39dfa33e904c161456822ec0ad64b9dc52befbd6496c9303fc062f",
"0b75c3c404d694e086c0f5aafd534e7d8596601f675b2fac9384fca6084711e35149f9c"},
{NID_sect283k1, NID_sha512,
"9b7d675a3d2cdeb280ea28289b5fc2a3ef6b535ebee8ad242fb031e2e1f364e8ee806568"
"b2f8627c5a5b4f51f4f65c71acdc1152c08b9211b81907b551e0ff47f5a6aca45dcfa06f"
"09bf195d19d7b165b52111b601fbd97b192f62465f8ba20773b1599c8041e91448eac7a5"
"763ca0628f40768324c5304e1119ca6a1fdb0778",
"19269dbfe4184249952a651a507584746c5b62c64cb3b17e0158aaf4d086a4afb0330c1",
"0406c60a475f2a3635fa523e1b138edc36f51e94a34e75989c2cacdf8949115d96f11ae7"
"520494d5e23ba9071b3e52c58b1d0740cf90cee7b084b9ef7a4a7be8aa47ce7b3d97c8c5"
"1d",
"111f4dc771b6ce5cc2f42172d3d70fe77c73683bdd2ea331ff711b7e9d8c3e4f2d7d6cb",
"027f224c01847c52ebc180ae81009923ae3453be1e0d94b5c2934603577f36653ecfccb",
"1e7b771631e5e72b7ddfb9c73f684b93270269ba4216cf3926e43b2ceb49756e7e7e0e6"},
{NID_sect283k1, NID_sha512,
"f4a08daf8f66ce57a986f14b918099bcadcc4308bcde7c169ce8536a40d94a928cfc0968"
"180a2c2a242c59df73ff79a03687998c421cf9a0e661630378779a4744ae2a6cd24ff61d"
"7fcd6c11a4c8bcaf358075e96f864df0998ee98ee393b37bb38747b70bb7a208740959b4"
"5174a60153ee566e0f62528e9a5e4466186fa650",
"03835814de0d6441cd80a44e40350cc8bd62ffcc81e939a4410bb9c9259e30463c453b5",
"0405ce9f6c979bc1d6bc41f41095b7677cc184da8918265a7f0e5b9dbece2ca9e0667cfb"
"ad039a395aeaa04f5168de809164285974d306e474a610d89fd401c375c9b73f0d23dbbc"
"f0",
"0b714d734d063aa81a389be69c56dcc23bcced3517e330572f79c769645e7dd2fd55c20",
"0e4d4494f91e79f2b1d1c0e22ebf744ef448f57c951f1b5f4da3592fe60008ab00f5f7e",
"02edaa4d8731b598c24b993dc5bb4888ea3c2dfe2807daf88170982667e69b76a8ecfe0"},
{NID_sect283k1, NID_sha512,
"864647405c70939fdb4c026bcad53218ba1d438d82c9138f0f0ecac815dbfb242307cca5"
"2c84826cf6556c51082a23f14252dfaea43ba229f7493db2bf8ae9cdb0228dab9e25cf38"
"5b504b92cca94f813acceaa1f18de851b8936c4dfe9e4e17002f02dded6b4c231ea5e614"
"ab46fcdd637b8c6193e8d0c2df1b3d883b97e1e8",
"0aee83dbed3b703cb6e60d51e373eb20e298ac005fa6a572d02fa1e6da0345558ad2a46",
"0400dc25760af992a8ecc108373281bd0d246f95933ec943f6346c1b2b941a03b33951f6"
"2206e35f02d225ba11d2ed7ea392898f78ca0deb2a47871eba6cd2be7440a410d910097d"
"e2",
"1df142187f8b27f4888075a3784aebe0fb7d80b0b6d3497a7adbb88cb6bd26cb82109c4",
"05a530bf1135ea6d599928cb0383f5d391d19be333b1577ee4eb6f2a78b54e4aac0e09b",
"06f3033cf392f698d1a1141cabf138c411f4e20687920f2915e17e805e8657a887c7953"},
{NID_sect283k1, NID_sha512,
"c87c8f3ad5c28a027b28ae5021dbe8d425f74181d519451f1fead7a1f9dd102fa6785b14"
"7b610610cb59bfa91fa363bb79ea602a7d7e1439f874c5dce748e5c320560c2d9676f3a9"
"48754c72b6db249478b7e19c9829ab4de2e344535d3e0b7c20c272f82556a280ef491524"
"b255c4fafb9c8ecb87b0149ddd9d7bf6159e3337",
"17b65c66514019ff935e9d571a4e68e9ee4463b7b9a754b93f4f7741693f4399879fa8a",
"0405bfb704629596ed05096783e49864a11874f319b4020917f1ba700ddb0606e6e72c17"
"93069194592be64c33c2f63771af0e4100d060e9750031048002680541815b311ba8f7ff"
"a9",
"171b5c698175300b95dfd5ed8d3fd7cf4e19105ed7193b6013103555808743501ee8c46",
"13f001f287dd5c7ad9af8d0105b47caed66ede41dc1e121a602610ce20e41af91cbe586",
"1433d5263d5233c40c0ca526b3657fcce8cb88ee65105b5f5ec82b26e12bfff11c8812a"},
{NID_sect283k1, NID_sha512,
"ac7da7611e2ade20aad64b418a16e02e79ab4894d758550210eb10013a9b5533132be701"
"f8843c840807c4167c38d21dff168d3baa65d5bcf285b73dcbb75819f8d7a20a849de335"
"e19bae2aab2ca560b93d340731f291599a5b28afd7737460d291105cbba6d0290e836f6f"
"6c1113d1b2faf90ac5de7c64e25206d79380a4ed",
"17d2071f39ba35515a8ec977ddd36ca15983e15bcda626f15af61d87d58114f4c80a8be",
"0406f09c255fdaf78d7d341fde4586526fcdec34a28448c7fe65685a67b6c33564ce9249"
"a3024ae4483fcbe3f823a7ce53db96ef2f6c68670e107e68cee4f358dfa844112d6b2144"
"e1",
"1403078da10f55724fe7b56dfc55990507307386ba82ca8f6340d33769ab1f6ca894bdd",
"0a54a35767a1cc77b2332b04694404fe5a31ed8851ccc2abfa5542b0f5acd9be9b1f02e",
"0577e0a1937172a6d45177c2b328d72f75a08a8a774a31151b89fd451d531348695d870"},
{NID_sect283k1, NID_sha512,
"5757c472fa2f81430dd920f39b61066a28c870b80e6c96f822f8f19b398c3574d159cc22"
"120454dcd7e97be8211916e4bc8db365b2dbb99a6e597d06e6645046a0abdccbd06741e9"
"c0eedf33cb78d78a540c2a390719acc498331e694e6b0118cf4f787b51c7b7237458a614"
"9d6dbd0a08bae8097e919f970fde920485e9a0ac",
"11504659e12235855fe55220287a101e511d39a627f8a0d414446385d4a88f31507fe74",
"040192fb9bcd157c7ef385d48470c3173ccf1ef9650da7d680d8473d45ab2064a073232a"
"c3014ddf872b711157d121b0a61b88a7eeb7cd260f1f82ec5f62fa2681e28c7f2640e305"
"e7",
"17e10962721f041946bb5ffcce724c9f284b1c8970f974a069c36dd4391adb8cecb8bde",
"1546450d25e2536aa14b8751e3b3e7eeec8a6c1cd967ba0f03e6bfe64c0a59072280636",
"0159c8d6499fcfe8ac7b2e84990a714d7888d883c16c016c4b165f36d62c3493afa67f1"},
{NID_sect283k1, NID_sha512,
"e350383d04af0f4081bf09b95d1d53040e7acc64e56b13b653df31dd119617b800e0cdfe"
"b935dfa5d94f1d7814688d8ce41021810958759cec76560e1e5c0581456acd1a02016584"
"9b2203f1c11d318d816697f36a86b59f160faeac7dba71682d3c031d0d547725ef69cbaa"
"28345512e38b75ab011911d8924b2d17a857a96b",
"16e4cbabb03215767249ba2a608708b78d7387be9e77f5efd2462467fa05e8dcde2c036",
"040112b7ea5d21df8ce52772a1b76a52ef6f0da62cb7718a467a034618b7ce701a05cd24"
"670649e0ad181437b4eeec87e202d8fab1c240f9dd9b31311284c24d89160b1895be5413"
"19",
"120e4bce412311d3e7adb36dc11d4cc1da8a4b9d6cd5219e772b3dc2b2b8ce08833748f",
"1ff2d53a8e6c1c23807eee681156a146e8f2cc1a8c262850dc69dece31860bf094e7f73",
"1e8906c0bf2a5f922ca271def90d704a1425e5cacc64bc5761b000c7df0f8f9fab51f2c"},
{NID_sect409k1, NID_sha224,
"f153cc61981a46d8a47d17d29ec157fa93fcf644beb84558db7c99c57fb131dcbc5b6558"
"1ced5ff0b29bfdc66ff703ecdd4290f7c353c02a3e6d6867f33f3dccd1a0b6752b8a35fa"
"143f8921a5078af9c85b212564c5b795da9858c7955095938fcd10c21e35e1abe905e84c"
"8b4bc05f2a06091ce876d9519b96951d08c7ac9e",
"011c6528939672bed3e8c905b7ba594c3ce95f37fb28044f210cccd01dfdb42c10e8e1a0"
"b5d6fc757834ca7f08e98cbc52b0edd",
"04000b570ec1fd09d7b4d102f83cf37129d94c9cf2f982b702c5d1172bae2df558008518"
"493c08dac6f76a6646156f123c4f33e79800e3cfe1aafbf25a5a4536d6c0cfe13a540b4a"
"3c97d4e7bc6c0346addb4b0c32dce089a7a5385e8a3e67606b45e2062c642bbbad",
"027cecbe83853037cf46aa98e1e1e552a96af0bb24e57756d8239fea5d769b51b83f195b"
"7801b562259ee644ab4047764d130a0",
"06a1601e07dfdff9d3b4ffdbff124b717403490853099fb4a00ea98f84ddd64e908f99b4"
"0a2ba6ab88b2491a8d948fcc2f207db",
"0741d27c0dddca3641b56ba1e9bacb0da1fcee46b9e33ecc6990b98cf0db74668ef1009a"
"50e5d55f80e6642ea48689a529c8a08"},
{NID_sect409k1, NID_sha224,
"258c91524423b5c876432b1930c7b07b56eb5e3945f1e2296a4e5bfb9b9123f800ad195d"
"6104641b1f1970bca553c2032f83d17252e52403a9381c1fc18eaffdf026f7537aa27d84"
"c5e3d6e39e651a92a41139cec5181fe794457f556b390943093be719acd23fa1ddf7ff0a"
"af0479484a381a309b4f681af74bf97caef08c22",
"07e3b714496dd118d8f3f597961eec5c43d0265bf85723b0b9b0616977e0acc2cf686cb6"
"afa6cdc19114e27ab000e762dfe467b",
"04007dea0ceb73b9bfaff7147a36436cfa7955eab02ce7fe9b60dcff3e088c5c9281be59"
"07de3e06ebb2e21dce8bf3ff85feeed50001cfa9b30af20612666e5df798f91eb4647d8f"
"5e1747c1b18adc6b73a848d987434c56d13ad78b775c4096e9f20d4878bbd9572c",
"028a8353c05129dcaa7caf0343130bf2e2186b9cb5ed0a27a565e1c24eb882617cc299d4"
"86be76fe0f8f3c52678b6992288d7c8",
"034299ca2aaaad51f12c90e8205da305523713516ba6e7d245eed8ef94a1b2409b98ae93"
"476aed6c9b9aef50406860b4e490db6",
"01a1adc76c65d77ea686d769dcd007c0101b4cdd0934402fa47dac22f8ecac28fc05c2f6"
"763a6781655ed5e7d84c41157255a4c"},
{NID_sect409k1, NID_sha224,
"a16a0d6fd57240fe88c7c36b9f7f9040cfcaa9afc4beeb8300818c5f90cce73b819a12c3"
"1d42af33146399cdfa4ed4954d068dbb0f1f342269dd29f1fe357e7224304b67b0f924b7"
"94780fe7e6aa9dfa3380252fe7177b43e7b1789718949b9ec1b943c83ed4399491482f0f"
"59d2cb8050ab6f8b5854d76c50651428cd29c40a",
"0182d1e937b037bf7f84144f7d4c94c935269c9aae7d500aa459a7a0ec113b232dcf2829"
"08eee4c84b8106cd38cdc41db3f89e1",
"0400bd4f1ee6a967123d70d488dbf0fb43aa5e93dee5794b4492277fe559776f74075485"
"0477e275cee9f1c375403a4933dc9869200191a544b98ba954cc6e060ba26a52fecbd1f0"
"dc7c15381004cccb799a9f7960a3cedd02d36fcaeb0ceb844bb4683998d776dc5b",
"07904af733742716366f8ba07086f924697ac8a01bb4895bdb5715081ee89eaeafbff4ce"
"c44eb0ce14e774dba71bb9b091d2594",
"0723b2068957c4f2ac1df69378fc013797a3b071de30b514c3e610002dc8bfced32bd2f9"
"e8f692b653e736696cf818b0ecc1e10",
"058455b8f9abd5fcc28a4ef839ac0245c3feda1fdcbc3c171b6928c6abc931e8b0ec3438"
"2d63e414657e9319d2965fdc9eb74cc"},
{NID_sect409k1, NID_sha224,
"d02ff569828fd1add21f6bd1c50cbdcd09222e458ee79fd5dfdba3cbb84e9d926fcf196c"
"ccedece77d5aa17f8c8cbf3a9facf0f02c71d5c1c8aeda9d75f6fd7b6f2c5c70dff992ef"
"6e02c438fb3c66da5a503b3c39acbe2a069da457595b542190d818015d462670b0807c40"
"1e36b1bfe05baff3a8ccf8d1f5f8de7840e87993",
"07ed09428f460724c8a5225a31151e031d9949493fff5703369c401762345d002c4ce424"
"294baab22d9e71edc4f854510cf0e6a",
"04007fcd003a8cde5503f5582a42738738ac7efc6cdb3813a00c072fc114006be9881c0a"
"881ca35988dcfb8088f3d07a03943cf23000e7041e666c1bed3b80a691ecff60ad4afe3a"
"544ce58030bbbcc130045e2c611d65f322ec78aff6757cb5df8ad54ee8a09616ea",
"02828c8c4bb1722b0f03262de32ca8a605c4046badb20d8eb9f19aecc5c69f199aa48d09"
"b61f285254425cb4bb5e0763dd471bb",
"06c99d796c5d4fa21c5cb7cee0b7570edc9d7e9d7c3604f5ca3766b17e44bc71d8a74ac2"
"68b8713cc2ea0adc3dc1971c062b4a1",
"075962e0ccbda2280e502559f48c8d37704964f67f8cd3b443b89be740976f1bd929c175"
"560fc8cfb282661c0fa792a5b200401"},
{NID_sect409k1, NID_sha224,
"57befce973b225cfce7f996fa5a1a43acd160681b88a87b7de04544eb7b6a719718f1ca7"
"f559b6531bfc18fca3836d2be7f7a6e48387b7579a6845796d30e46f0dda9d82680f8c96"
"c5f0989741adef9762c3db763cae2699cb6c112543635e20ed5cfb4b55ca2ccb32d2d139"
"36085a8ff95ed658a54be73f80c912ccfe5f0ca0",
"0390f05b9619c27b800e99aeaf61ef7f6249367d5cfaeae3c7b523a8b29153eb8a77132f"
"6c4412545a842d6deb7b7aea7e2bda5",
"0401cbcfc492a2a6bb8a7341df67ef2bcdcd706afabad5e7ed1d63387ad9b0dbc47ed17b"
"82de6de936752632e43c393a93fc5cec0e0111768994b2dfe9677d9dbc45d4b55fbbafda"
"aa2b2638ba1605c35301fa557d628a87d0a7febcad9f8eb4b51fc9c807652579f6",
"00b8d236a9f8edba7b5207b4c7848807b933b214fa25cfc5a0e73f750d30051264bb9f67"
"02837b0f65a451d4ef24f047ec4e9dd",
"076bd4755427fda22a0f177624477c59de12a12621aac274b980b5e1ce5dc700591eec13"
"dc5bb48c5c8643de287a07a48a6a7fd",
"065a5b0a00548bcd7f59518f122d79c7552ca6097f3867604b462201add5f326807f0e87"
"79f2177f277e5ed25253885ca81220b"},
{NID_sect409k1, NID_sha224,
"4277ba40cb462860ca722cb4ee71c61836d2ceba18bc91f3fad7dea478972c6da0ebc028"
"15eaaada1d1a5e93d7ab353855ccfdfc94a5742fe18daee2328871e06c1ab0a9a989d123"
"9df2d2d27f96c415e7ef9a941f06c6790675361173cc229aac7045f49eaca207f59c4976"
"19ba32e932b5c1c6576812ee5b146e2cc7de5e62",
"007d18652732596add3db31f7a0ce6020d03f3df58131b0c7c633faf619b8210cd309d6c"
"0c4083aef1a1b6d2a756adad0bfe344",
"04015ad0682962b4dfc8901a0dc77d548ed616286733cd9b3ede937cdf4401ab8b3e3516"
"d466ba43b6ab5356c4e72845767d55d27c017e4de3288ed44b48e7c47b16e2afb513c976"
"3d5bf4cbf9a357c128c94a758e3ff946957df461531def2b8d8411b81f45f0c2dd",
"01a896c30fcfdbe583d6b0119f467f47758ee01d4d601eb698f444ed0f76515c2b8053b1"
"1ae7abd0eef7aa61145a53d12d560d7",
"053b1cd57dfdd8d1802f3e295e450a155c366bdc2bd222d18a4d08369c25e53f1f633958"
"b22d80755ecaf8362d548b28dff1ba8",
"069339fc6058762a99576a96e76f75275f848102bcbc281e59fda26c98fc48a3f1061755"
"e80740a233e03287f510f4549bb1874"},
{NID_sect409k1, NID_sha224,
"57ff6792ed4b12220d179bc0ea57ff217f322c85bd3676a681d32d7e4a3e0c8e891fd267"
"df17caba5992f68c35ff670b60b4bbdfff82404f6ed996c30539bc395120f97d4d7a652e"
"aee82bd8f9360bf8bb73748b8bbda9f9480eb54f7eaf2609d4259329e8a5ea020521e7db"
"d3ec56f23c849932cbdf2875f5d5c774a9d6b0c9",
"02a91244ea4623b63403dba807d60b914ca3b901a2523244c322f2f11251446d3f15e869"
"d086ebecfa1a39ce304e8b5c8de23e2",
"0400b7ad8f0a52ec21e54e28ef603d76652dbfecc7dd2427cfaaff3d280f0d1f62187d77"
"effcb433b5bd44c3d0c0d26c38d3f5930e0080641bb0163130be4444f79c500ceb8d6a9b"
"2cac42d21d31b2fb29da075bd41c6613f278944adfe92d3c99d494be9d4714e9b6",
"070125c89a1262a88f22e874c55ed149de6d961d6abaab2d13db9174e3cecb8f49752995"
"7058a0afe5361ddf9d3a5a3b923c7ef",
"01a28cfad13969c6449e5a0f879e01ef7dc1cdcd0bc77d20f3989c588a9cad12a4b52743"
"c12f4f6e2154ad963bf234ec96263f5",
"066d7f0b364a640c6c620e3d030448d155cffc9ffd46a6adfa1c13e1b01892463a472446"
"5aba3eb07009fa604f3af18109cb72b"},
{NID_sect409k1, NID_sha224,
"f85113eda64478f460b60f8084220134933de049200a5f37884da7901471542e26690a5f"
"abc3cbf9e679ade71b6e54d869bc136c3d34cc4a9efcafb777abf046b5ae5429136112a9"
"a36a475121eb1f33f1f43481286fc1ada98a41064a1fa38c89e99a93065bb2a119348a9e"
"452497fd5a0d2b83a66b09da9f47a0583732adf4",
"0068c56c6b5d50d1d4e13d3837d8c5e8ba2f825e121b63e97603fdfe78bb6899600ff0dc"
"87b6b3b6868ad0d2f62b7b7a31603ff",
"0400d9a4f5992308013573f97864c23b98d276975d80cd6455e9f0d8a62d6674f3aee3d2"
"7dec15903da4e9d5908cebeb765ee02c80001f61189caacb05dfb982bcccd603a769d0e1"
"be8f9223288b5426e7f88854356fe825f11a88918085692f33b0f4c61ab09a861f",
"02ea7f0d81fbe3d4c865ff5315d1cc38f9e9a8653fc91dbdf445b62fe09b30ccddf50878"
"3ad87c8a48a6ccd5c9e817fe2977f90",
"02d7847479c16c4cba834ce5962724f185be06cc04a9a8d710cc72e6063a7b64fbf2694f"
"5b62de65d3d347d34c0dbfd5a4d93b7",
"069e32bb19d20e873d0e62b306db4d5663576e4b2fe75e8ec79b7a63f38c8f1007a817ce"
"30612e8578d48c63b04b1d34904010f"},
{NID_sect409k1, NID_sha224,
"42811e9ee6dc509572e1cddbe5baf00afeb0c5c13e3755b922eee9e210001676082bc9ed"
"c3d78db2b5bebea7a2c0cd2b369226c2b8f83b28f33fb513407ab9d287d14b112d6c3be2"
"493805ace5cf6fd366d03cfb28f4ce3f0f060880db64d6962e997463ba7c05b6fcd1e66b"
"abe4b94afc5c2d38c7050c69571d27b66ef0090b",
"03c88084f8b78446db431bd6e240a0c050813d2a763675b0ea869cbe183df697146cf29c"
"03479af3d34587a95cd257027fbeed8",
"04015a09436de00d8d129e297ea60e04b704c0a8183d64a77d1c527189e25e21d6bb62be"
"8ef5eb2dbd833e5f9c7d5c3e69c9c018820001c32ba376d2e9de28fca644b0d567ce1f4e"
"f0aaddb2adec6213d03bc8cc99f9140005bed3cb6c3c0f5533275734aaec47404c",
"0132f4763959863a32919eb591799ffb8613797bd0b617c73654ec9eb32e2fb86631b66e"
"28e1b4cc4aeba65ba8c75aa1cfacd73",
"05fe0ccbd430d9459e0093cfe2c1d1d3edff8c1ae7111299d2e04f414c46ed2cc88ce9cc"
"9e23e187e87ef551de993f52214d609",
"0557acfe6347baafe031dc16032c45559693e2793d9b6d372670b09757c6f4a3e5ae5e55"
"264137d1859c8d9f8f03c25de409bf9"},
{NID_sect409k1, NID_sha224,
"b38f76ede7441ae0887e689d556f43155b38dab7cde487ce9ef9a46f2957c830d4d28006"
"873fe2368197a6931f6fcaad755102686a457a7edccc8d344e2d2a9162e3d71d41c09a02"
"2539ae6d404955a6ad748231aee1f974d4f159940532fb3b1fa0254bfc5805d2fc686968"
"56fadea386c542d3cefd1be3af04ca595e54be25",
"051af7b63bf3297ae20517faaa1552f4fde65819dbbff6a52721611e5b7dc1242ed6e697"
"68cdc37ea8cdfd1a5971f06b84b5803",
"04009cd1280a2a79b182ddbd1712dbfd12cee3345a89636d7673a5fc3e1e51400603176e"
"27d538e90005625aacf5cadcc8a8c25532008b5aabedce498476b4c65ab3cdc81f819c2d"
"b670a7236c0357a86f9087b83e7568cc6e5139fb92f81975756d7dc4f48be87df2",
"00bba308a3eee9e3ab6d2482bb728bf44cde9eedde15af7300c57c2c1e6fed2ee4e404ae"
"ee3923e7871a2ff4ba6df64f9d01a87",
"07a9e69664b7b81edc5d47c014696d194b2ca4705b2e79af692b285ec476169d041dd9ee"
"f20f7d496fc49b8597574d2602757ca",
"01521d7cf6aeaf1c8dd54a7776cfac02967983083770346d9768a2629d606be90d58ea82"
"377413a0fcc3e4e66f05a0d05d933ef"},
{NID_sect409k1, NID_sha224,
"356dc86cef7979148e995fc5abe2b14a7d5e4e42c9b3509b4363bb80c581a66f4e7e4aa5"
"3a4bfd37f9a7eccf75fdd726f348f6a3f779e6599f61bd1d668517f40453b39bcf35db08"
"52a6a6218198f52b7ceda2ec55fca5abe8e5d93af9a42b9ae4de9530c5870211bacc27c3"
"9aa094013db703de2fd3121f08d7e97dbd4e8946",
"03d65bdec48972d03811b78150a06956eb22d337dbec5416bbd8185a6322cd8c0ff80002"
"10dbd1326422289071cab65175f5d10",
"04000c9c1bb0a80c4b4863d78003e21ee60fc553ff72968c165f6eb6940250a6cb7d545c"
"6aed3760e42370df79b0d37c2d1433c486001a9d994828ac09a86c18b9758b3f6b91a577"
"5931a7a6e4d8b052204c972b993a3b420eb8ff7e91df77253a9f5847c5968b5636",
"0156d12708324cd30037753c78225d183723d3f15930f23bae854f121094bfffb5d7dece"
"1fca93bbe7457a2237760aef3db8e3f",
"071466e80e2a7cd8e6cb6dfde259a08619f880a71899c58bd4cd33c29f7b321d26953372"
"0101f2ef70f5b8e8f05c9cbe1ebc303",
"077330e08712ad709f855d92355cfb7d565efd806c6a853712916f7c943bfc79e496366d"
"eba79ef7491abad23086db341f339e5"},
{NID_sect409k1, NID_sha224,
"06fd39a50bf25e89f1071ff81fec5d1e35b6dd68990414ee403dfdebb792627b6a4ae3d2"
"236c159e4441ff90b61ec87b1592c538515f0486b19e58583394a05e6411e69b4285d6d6"
"589982ac0eeb2c912c4948789cad741183663fc070943389d4e9a1150b8f6088fc506059"
"15e9e24b2d98a1f539024770e4820e14ae42ea8e",
"01f1a8b5f35dbbf82c102df550c72216a243f986f0325920f6186a16d1da74228cc02be6"
"024c7411160c183c923c743354f9438",
"040157ae8d90fe2416f70a7ce0669acdc0b5064ba650cb5416e59e6672e45b591774ebb2"
"f793c3a58e953da1ac08272d0b949e7b50006d49b9784f8423812967b857e25dc3af1312"
"a6ff29579f6acb6e155b6848ffac6fbce51bd2d41a22ef955f690e2487a4bbff00",
"04cc45e00847818397c6abb3d176cb8bd77814abfc253e3b0d799dff2c3e09a5195ed5e6"
"232873f2783c8e670b52a839e06bc30",
"067b418a5395216b83ab00d5568eeb62ae0693af2b0e4d052c6feb70562dcc06ef852002"
"687099dda114477871b924775e8460a",
"061d1e4d713689b2036272ad41571759b52a78e0f8a84d1f3a277aaa33ad558f0b71f3c5"
"a99d403e49df1afab66059db20f9f32"},
{NID_sect409k1, NID_sha224,
"6daaa41150ea252a3e966a338377307d909b95080e006f13027f2be5059d9208930c5a32"
"9994c0b794ef50eb059bc6c215f68cf42260bd410f9bd86d2ad5ab7179c7c92de4a93a5f"
"6aa17de5aefea815e7c0b78a8cc53c21dc4dee037b29c9df4e12343109283ffd5d8a3b81"
"fba1b5e95506c7e01ac056c86dd0ee23bc21af0a",
"031dc621200cd174193d95e9092ffb86189c52cdbb9ed937593f2cde7c4a0264b9100e1b"
"8407336c8dfb5520d28a18dc4e39a89",
"0400904bb904d50bff09bae5dd21f425c808b41001ac917b022f7e1cda6e46504781a69b"
"aab4a6f0f100c4fff9ced26f871159cd30015cc300b0efbac707635c72bf855de4290f1b"
"8b70c16f9bd0cb771ed5c760ada04d0ff648f118d64e0aff6a6de16def15cf7437",
"07e32b1fc1cebeec3d84f56a67c8ea2b78723e7010a725ca4745e849e573e8e4a4ce11d1"
"af4ee508b80fb5336de3cb53161bf44",
"071cd81dfbacbb67be5903cbcbe402c0420adfa9d14148bea600b178fd06278572d34eb4"
"6d857085a2a4f48cd4ee9109d607dae",
"0347b1029e67a6ea2a45af1f7410dc951db813eabfd3c7f3e2c294b81e1c54fa8c98569e"
"fc580b68007bfa316424ac6eb353ac2"},
{NID_sect409k1, NID_sha224,
"6378dd1c12c5197b57d47dc46a67949bdd1e0809004e94d49b0234126a08ad5bf8723ebf"
"d132145813136d8b7dd096f56c34248f09a65c34f60c2f80f9a51b3795f3d2518b11aaea"
"f6dd45a323794080b78f85d629e5fa719b6ab0b14c78cd908befeaef0dbfaa08cec9318b"
"bcb376d48b11b68735c9554a45293db5e9239ae1",
"016e6750245a88340b0f0665b890459f8038e9b1366f2fc1326245a88d4c523ec94429f2"
"1869ce3dbf75126e58f77241c99efaa",
"04010184fd47e8e1e4d534ca1cf67f15bc8a80921b07e251c22eb88f25395e08d7a92837"
"74aed204fb5c14aa13c63a94ee691b4ff401252ad972bb8c0b286c222f42f7d42ca6561b"
"ac5e517921bda53e51043f13e711da8a813bb6880678e4d6a16820bab819d62e59",
"07f18539d00152f5b9a75d4f114812b87024e8a8f9c9a8d12139d0a74d87986f4305bde6"
"0375918ff2dfdb88b6deda640e17364",
"0735a15e7bd1f69f4e90739d42ae239a8e9238ad28b63ce291b57cb5b99922fbd5dbb7f7"
"4fcc23117243efbd036eded6ee0f28b",
"07bb3dc77cdd4138a02e2d5fd4f6ff8516b4c95b8255c629132ea8705c399fc60f8fb660"
"ed3aae52db283aabc3626a5559dfe85"},
{NID_sect409k1, NID_sha224,
"b898d0f9bd80e083fa541f457d14d853bba55b120424a95e1d9511c8833f48444329e034"
"9d68204c4b4581ef1c4dee23ed0a4445727a72e1e6cde422f7c10ae132a3fe681f9d741f"
"da263e73f7cdf10759467c9d76164086abf6780ad474772771eee22d195339bb8f6235e0"
"d992bbe282b13ce4fe01417f507a2c4fa155e108",
"0788fabdafeebb72f6385301e30024b56639e629a400f9c50d402cfc9b5817844f06a451"
"fbda29c7ece41dc9ffcfc625fe0ff0a",
"04009b2c36d221d18189e1617cb2f2ddcd64cdf8a42ba6acc55f04e9722b11588f7fa861"
"a3940820d9dabbab631d7fd4106c60f37e00da099cdb10dfe2d7c0a16ed332b459e7be31"
"f44b0b2d595dc948f0b073ac4e439f24f215fba5ed50aef3702731d6561eee1986",
"00581369aca680beb705f52b6bef075de83ad29034c3d6b2949b551a0bbd100897a079b4"
"9d41d5030e1a6950fdb14d70dbbdb41",
"04f62415c99c8e6750f9c41c31cf050eb58f61f62eb0b0023d61dfc30e7879d4f5a87e88"
"faf55522631a29fb69d16e15c354323",
"06df238f34b5ae664860b43ea11defe3120591cfa371367096006c03e83d372bfb70da6f"
"789665136b7dd1c59894a2fc5038c4b"},
{NID_sect409k1, NID_sha256,
"dbe04561ea8579672a2b3afa94426a3cbc274b55263989d41a778bcb082da797d84d930c"
"a847a481789524940701cd5f1d11b460bdac0bffb0b3a3abe1ab689c519700de85a0a571"
"494ba0cfc3c865450eba7a9e916b7fa9df55e8a1c246c992e6a0b44b78274e008472bed8"
"d8411633e6520e1a906c5d0c8aafd572fe6f1f64",
"01b8dfd64563dc219d6eeb53f2e3ad1d771140d0960b211dc1f757af5e297dc7548d6133"
"ddb574711d466688f80dbd65a7bbcdc",
"0401ec530638ea0663cd3a9b237dd66402adf50d3094391f2343d7d6c52c1d14145c2454"
"64a3b771e4b1894462fbfaf440e53eef7e018349e244b24c8353811c29a60d8e02caf195"
"a424aeafdfd0361846d5ce5eb83da1901700f00fcb85a0c2543b49a8a3ccbac157",
"026a26cd09c9329cd45ceb4c798846dd81af67759794f5cadab84de19a835f8a0ae49b12"
"853b1e92822477a73891f85acce4216",
"04d83a5f9dad246717135bec6e386ec6b73be9ea6d1a17334ea2003a723d510914167d13"
"6254d6cb64b16ef7eec5044b8f2ba28",
"03e81601d0c66b507a491c530075edc5b09d770633a4c2355b3b1c7df9b200ebc7dcb706"
"be1696aab70d4c6e1c4a7e532284670"},
{NID_sect409k1, NID_sha256,
"48a8300820fea2ad83c83f7d6b24192715329c3f159d56644e11ed25efcbd3d31600a813"
"b909812987b97d1087e74a63b4494cc031c63492b6615e9d6e5b36f62cb2ef88b9f73659"
"5800de465789f43811165a5fc093ee6d776008739de8de2a84e878748641be8bd52e5b89"
"1c4145f52bbd46644852a43108e93d86352b2a3c",
"0422131829608ff730c24ddf7e8b4a2600eaa9681eaf45432daa7d41fe2fb488fd0199d4"
"31a1ed823801ce21f4f01a4dd4248ca",
"04006ff24eb0ab812303bdc9a23719caa789eb75775e686b9511bf6e07d60447d1601a48"
"ae7f3041cef5aaf3ed2adb6feb422fbc54009a351fdc9422a81ebef5407d0d74b52a348c"
"af3cf6e1c6c2af722c408941de154619a1d54bc23a9dfc0c4964f3936d62daa6a4",
"0313ec63c34ed325d770664aed3bfd1a16eb636516eb686e806b0acf6f0d117998b30fd5"
"2068a36f03d0db3ec13e6989c6f196a",
"0088167f96d807bdd61e65fadaf0c56b623db42b831909d12641e4d00e7bca6077b36cfa"
"759fcbbf087c31f294f20a09e0bdc96",
"01cbd06232b4c73cdd13208dd254ebf9351745ee6196e3a94b9213e931f141e4cc71f3d3"
"18a67e7b8060e11e88783fca0be41cb"},
{NID_sect409k1, NID_sha256,
"276e3a986ce33256014aaa3e55cc1f4c75fe831746b342eadb017676b0cba7c353b3a2b5"
"54522c12e6aeaf1364cd2eb765a404b3d0aa61258194a30219d76d2bfa98ad20e7e91756"
"cf65e50d7914157f283f2ba3930c0ad3a97532cc747b1cb9c806fff497f0322025a3d02f"
"f407fc7b5808585b91d95523c9d5864efdf7d983",
"0095ae8e4c7e55eb5da01acc05ecfe72a4dcd8ec152f1c8dc165014f70eb4e4a7861aeb2"
"b96c418b2d4db58659e76184e013a49",
"0400a3987d7262dc30e8ec11458ff7091ca993bc61f142ee535d544a2c88a47f96011076"
"19617a5e65cdd6d5e1a034aaa22304434201fc8af29d5134ca9baf92041b6d6aefabccac"
"a4013c55c1581ac05db6141290235ea09650a289907785d282cef1b9efb381ae66",
"066015a77c99015ed6983bb379772bd90e03b9c010e695853ebf8e461a20fc12b20bdda4"
"7eef856f162dfbd9fd4fc1ec49105d3",
"067c49b96e5bfb6a6d625346c3ecff13b8c8b7e59c764b73b256ac970aa4056460000e59"
"9a8195f2d235a75cee8e5634acfa7ed",
"03ce25ef1af0784645f0579da381542f5b8aef377e5b79193314f84853e2a07a4f1aaa4d"
"8210f3a3c249a879cfa3ea8af43a929"},
{NID_sect409k1, NID_sha256,
"6a4fc1827c3a7256faa8ec6a0f3d23559d6949f8cc20e7f76111dc4ebd59213951cbf0ea"
"dacaeb8862d6baa0cb298645e4314b1c303bd0d5e9893304d4b7fbd36ab05fb6a5edc3fe"
"f763e3a4124d61539eb616b359c5cb55b5e2bec50c91dd95fc39ddf521aa854216eb5a70"
"7819fa6f067b316a17a3b146e7cc2dd517f7d63f",
"006f2075bd730f34df111ebda919167b1d3358ada32cd6747cb3353bcfb814a77ac70cd5"
"1b31a0e538539453bf9eaf9d8b384c9",
"0400bbc153deaec0bcc36c03d24afd20dacd9e78d104d94c279278d04b597ccccae43cd3"
"e64c9e1e58fb5408f376dd7827ede9dc3a015ae0d803acf12d9d3fd41f74357b1c93cec0"
"480f2e586d0e18f15e569d27d3d106e192ee0c1c570351eff1f463dc07d3bea933",
"0314330098250e38145d11a48f5043190c6b44f8572ae57cf83b1f3c4c03ce38b90ed5e1"
"57464c2613c82943d78c938fcde89d7",
"0160b20c370ef4b9cca3f7dd3c23f70efe6bd80751ca021731bdfb0f45ae07e5f2144c77"
"795aafdb0c3a92ebbef75fb2d334dee",
"045188dd2402ad36ae4278a9910648ed5e71d64737651c133aa89850e3bef2207d58ba41"
"69e471a4737962f5fafd50a37a28e1b"},
{NID_sect409k1, NID_sha256,
"4b088199bd8c94775d8ee508377d672dbf50f6d2c7370e99821ec8f9387492fb2eebdbea"
"473ea18465565f79e2af418555f10c4a527e05a9e20c9c00b807dc8b350cd4ccc2d87e91"
"f66addf02ce4f43597aa258ac6fbe9365cc2c8e8bbe5c884abc929710e8423cd6722a8f4"
"73bb55804159a92a3d8b6661a536b4fb9293bb0a",
"03887d284e9ad17d38bc6da9d83c192a434c509340a7f233cebb032b09ab7c4c6e8730b4"
"a80844898616c9abcd16b753c6bb4c5",
"04012a6d5c5690ebf14ecfa54ac97b73e88e16e757c34c6bbfdc9a3a119f298860d330af"
"295756dec41eedeadc5257b202451faa06019f40ff28bb72af659d5319286fe21f018199"
"52d471ce2433ade745042a47c2dae798199c364ceb99029c2dd5cf57ef5daa2b00",
"035945b45221300f83c5fafbaf0645a7386e209d025b3e1dc367819728f630663fb732b2"
"51a019e08dde0f64dd3f60a10065c50",
"00c323c86e8cc548123d1337936d4be948bd4bce4631a2194c2bf04e1fd714df2c90e368"
"1e41a21d58d9567a5df9fc478dca8e8",
"0493d3f4d22cf8517c301f15bde52cef17c05fed2482f3ef15cdbe32c5f0975e054d45b1"
"3faf906896201942f29e5693bfbb229"},
{NID_sect409k1, NID_sha256,
"848a13465ddcfb2dc14f7bc0db0756832c22dde1e31e4d8b3ae0dd1aafbdf15e954889e9"
"5d3bdfd6e5ebb6171fad62592c23277a89e8ba53978c9b1afedfef7e1c3f6d9f31077530"
"460b47834b30bbd84a4da601be988738aa815d3d7e72043243a5288751ee08b4815a017f"
"b5d9bd55833698a0d526b1ed79da35ef0fac93da",
"02ea5430610864257c9dc393c3addcd0d8d5bc8aab1067643b08857210464428aa85cf1a"
"e6c743fd2682255d4c8eaa46ca21e73",
"0401e502d3f47823ac7207861855fe6f6aad1fa4f2149bff2643b079da23fb270599f744"
"669b3c8ceb4cb0989aabd43d26d93c814600cdcfc138451bb59f34dc82b8128088b5ae0c"
"b8a77dce1895d5ffdfc8b4be24a206b9856954508b82b80d0163b276683489074a",
"0426b90275d720d19c6ef5c8c74c568a636257740530e3ad10de0d518c4eaad8bc58cf45"
"06cf5cdf7f2b03edd1caadb28fa3787",
"0123ad87c094c4ccfe4346dadad54a6b1ee1bffaa1b7b9094fe2e6ae785a2b77ce3f5e56"
"8e43e8b7fa997206262645f56078657",
"00d56cd5cc64736ff7ea0d9840916b1e1c94e11611f93b1b11c2ee98c79d92a8af1a560c"
"9938dc4bdd0b84252e259ae5669d1c3"},
{NID_sect409k1, NID_sha256,
"d1850545c04ea65528849973c220205c35eae98826d169348970d1420b4d872ce233af1d"
"aa9e62f6a562544ae3a0633a954a493e9766dd5d87e47486559fdf86229a7c9e1726de21"
"895abdcf2422d438f4ad98d88b45c56742694ad5e11894253270997c049f0f419842482f"
"21c792fbe5613e2defecd485585f1835b6f4c578",
"062c757c92eaef41f5d81169ec4968145b5aa2bc1d2a3a5fd000634777748ecb93677b3d"
"a12e3be33272a8f0a52300f4a5a37c4",
"040139660fb8bbba59e8f4e95e5ee5b97227220f0e1b293901fedcc6dab86e7c5a9d20c1"
"a097ee2e926a934cce679fb8dcd8d2ed6c008ac510ddf735184e8fa9693da264194fb78d"
"a5d1cdc0bf5faadb33950ca191fe233eb8dac8adcbfe15b4f7c09d5ddeef6bcd1a",
"026868bf1764993d650aaebf117521cd146ea20067cc14a5843f726a3d68e41c3fba82a8"
"3d406b2275b3459748b3bd1a8d32f1a",
"05b17d13ae4d9535d062a2653bae4d15b9b859a87c33e175adc3ef04781bced888f3e93e"
"9804b2251a40b9344c0f8c6bd5be0ba",
"01ec3322c5beba4423b13a0528c71739a6b39f7b0e0e58a8274a8386167cadef51e5560a"
"3e9d97447e3d3c06288459fe6569345"},
{NID_sect409k1, NID_sha256,
"421c9784d6fd507c82904e1054edf9bdd1efb58a0b211340086069ad38b7b0dd15c2345f"
"a8767ef71254ed1bd5c35f742b1d3f4765ff9007a5477ba9e5d3d5a5cb5fab4efc1cad73"
"701d4776c6c4343f42b5d94a9eb78ae428dfe5fbdd8e6ece09d5b75cf4346cf27db85635"
"2225ab04e6ea56661554fbc39916accebecb3935",
"048a313c0c11489939fc0cffc6ccb9f179093c4e13141b92dbbaac441b7ae878c9d41206"
"6e95615174a24692555cbbe904a14cf",
"0400677c2d364fa86b8b0c79af754e675ea3e806d5583e62087e01590b824d2730e31326"
"591167f02bdd29f8178787c4e1ba9d249600e7f78c423baeebf6defe9feb8ada8874ceca"
"b083ca2e71d9d8a3fbe846eda69262a1f5b4a3baccaaa4f2cc87220edb1fa6b6bf",
"012b8df87dd935775b80c62ed6c76974fa5772939a9e7372cb74e033fbae4f78d75b8bfb"
"b82240cf91009b5bef4d63ded04cbc9",
"000590a9e8de60b5cb181a1c11c2f6115c66b05e71e0c558ae203ee18e54de68016f4c7e"
"d2f01cb0cbaf1bdc45218c0fe2b1552",
"0521844eee9168a501e235de5fd19c84f052445fb0e68bba687ace45d8630070ddd3b730"
"34d1d65788a51acf91273fd187a24ed"},
{NID_sect409k1, NID_sha256,
"7910bab15b6429947655e33a67f41b76f1d7b71534f8904d6a0472c2faded038565272d0"
"b5f51aa915e0d624e9ff48d50ebfa2f09324864f26c29ab73eb39b436c5c459c7cff4d2b"
"62992e3489cb4ddfc05d7366b161a463aa1b782641d93507de43c8cd0a0a0a9d1c644f45"
"54e3edaf7fd794248110ca9387e73ae5d00d299e",
"046e2adfe5d3549e1e6fa1fe69a7cbb4ac9b111c8903d544268f8318b0b47d4b78fe3e56"
"eb5e639ad5382e7cd5bd4b2c3e70ef6",
"04012902439be50c97aae7b40328984934d6c843415f76f3821c8e8323aba96ee41359e2"
"ce5ad3179063ea5e2c7deeda4d728d585201eb59fe96b269cc973b1fe1f3720aa9aa6ec4"
"cf303c5cccbaaebe6ef7c9f5356ec5e76b26b09479d9831d9f5aa41ae1d61f4c47",
"031893aef1baee0e21b50cff7002435b058d73dc4d8301ffdcf1e0c315d18c2b16f282e5"
"b294dc88369b25e2a1a19abffb578ab",
"039281ef10b9a2664b755a2db67b3c410276a424edf7681a5c97244eaac5826368a8095f"
"1b9b76f8e490e2783694d5bcf3565ea",
"039edd50721dd35d1704167e8cb609f309b9ed73d3c1eece181f9582aabc647c5ec8bd25"
"8e5802fb0647372e4c3929cf59ae2d5"},
{NID_sect409k1, NID_sha256,
"e6fc96e060b956c25d50ad25443f3c30a12d199a47451a49ce88307201dfb15ed816982e"
"8888a28daa92eaf3c5584ca6ab2ca9e14577f84396de2e0ac214b24a2279f5e7b344fb73"
"87e9afc8f0a2b77a4d024a20ce6183499b17096947444bbb753d9b39e5c694239d28f9c4"
"54bb05468d17ab564ee6cea3741747ccb7f108af",
"0480103fd6180a431c837643566706e2b9597de0a1346a224d176a5b2c54aa4d064418ed"
"654a5d39f4773fb509f86473ebb373f",
"0401d39e2772ff3d26c5936ab347bd5a2940ece42b1964f030c59ab453acd7f44716ba9d"
"88f0828de1a4e730ab27fe1859915818c60140b1b66b0a87de29ba2cfa799d944b3b898f"
"e7ac43de68b01fb41464506e2f014e0d11bbc0c24996428c93bc1a5ecee5956bb2",
"06e9bd0290548d35168f7db7fc292bc161a7710b78ac49ec6a42c9423afea1310597e597"
"8b22b4dfa192489323b2317e4714d37",
"055dbf88b6221dff098345226d59d396b6773611ca6e747d26d5d758760d830693df0f5c"
"602859f9caffd0dc3790dfa08c527c2",
"03e679447b622c4b06871f2337f5a24150e76efcef9698c6fd463867508e9d7b803667c3"
"2989a881c98a90998944c070aa58b17"},
{NID_sect409k1, NID_sha256,
"c8a8a0d41f35537e6fd523ee099eb45e1ad6ab54bed4d3e315e20227db03292e39dc1a91"
"bab439c0d20e36e7fea6ef08983f390a6b5551ac3b4f1895220b2867fab95552cef9bd87"
"02962839bd9b2c72772640e7d3be3c5889d226acbefdcb448432bc503e5a5fe7ae9ae769"
"6c720a799f9882c64ae0385f656074dd8a6821f5",
"013c489e8311c6bef02c8f58903b2ba2a98a27cb935d75a30d320af9a14fa3cbc6adcce0"
"9235a9eaf333dd05f4b2f1694985dc4",
"040046a1c0e7753cb499d19b2805df770ba54f1c6e03611c302c73c72902867c51c1cf9e"
"d154b8f30f72002421029de7ba2d8fad22002aef9c34c7c8216a805a58dd88185f404930"
"86213cb4c85e4d226bb5e892aa37be353d9123e9900f8b0790a43d55a19d78c48a",
"0491dcc881731112ad5e9e1df459c27381a7bf8270f97743466e178bf5ca903971b362b7"
"3fdbef8a75d4292e63e225396c7b32f",
"048425b76147427b8b1969bba3809dd70f0fda24cfb0e92509a7824f027b61cd38441a69"
"1efe213f3c331da8c82f94bbde511d9",
"00df36683f22e9e86c88097d75409ea297d391550440e4327f67b7af1b09141a0e7a1db4"
"0c4b0bf4d60376a6636dbeeff0b6b91"},
{NID_sect409k1, NID_sha256,
"3407cd6d2845197cd7414a30fc3df7184da204222ffd65c4d16a12cadabf603de8043ea1"
"4f5e6ddcc22d3572dc06dec1a23cd924e1847ae285ecf01754e2d1247876431eb98e897e"
"47412a2330bb32990f9714122109e94b38f82cfdbbf2eeb4c6f88f5dbf9f0ccb47939df8"
"be321dcd9bfd9bb99cac9f94885fee7d443fbd87",
"02419bd2200f8e1d87db848b0379741685e680d9affe693eed49d82931030b6cb05d21a4"
"965f4e1df2045c8513a8f574ca9f2e7",
"0400641a6ac72455ceb142e00d6854acc5f8b86db7bb239a5054c1ed48dffb6d050458ff"
"ea8adb68613ad3cf5977ea7330268abaa201a954ab7d62796e5aed370285d3bf91ddd34e"
"ff3b995d04967db41c2171cb2157d85032c998795ed476c891702d63ff0108f45a",
"02e9928f427a86c4491a47b31454ea7d497435af81c07bc96fa61f4507494fbe4ffc1fff"
"a8faadc2a44c7e69c4f976661750f8b",
"01e8ff4cb8c58fa48aaf61488cc4118df90e8c06cbd88234cc920e5795597ffdc0ab967f"
"a7461082a49de56f02f84cd9d564316",
"06e77ac43fc7af3c126f997fe15011fa87a27479fbd5af48e28ccc2c1bedb6c0695291dd"
"67beeec3f17cbfecefbea46b6325fdd"},
{NID_sect409k1, NID_sha256,
"ad43f8440071285d01fd79244907803601aff4bc5d14c77483a87cd742144d41c68269d7"
"6c9a83c09d2178bbcbdf99f927b378497ffdc907a75a3b0ad019e69758dfffa480871eb6"
"e1e17c8539373de611a557fad120d0bd147f8debe5f09a02e56fb607e9c1253ed592071f"
"042e42fee39775b407225a2b86a950d81bb7d7ef",
"0722951879a65bfcb414e11712ee9431eeb32319e0ff28601112f89276ffc2b96eb65c7f"
"d77d023f09914a53e2aae2c84652bad",
"0400a0304caec1b68b34c822a2a031145677fe515dda977f6932ea2a3291c6bb4fe8f297"
"b7d3c632f9b3806a8cd26e32403c27fc7a00012d4c3231898a4202f3f251802c690353ae"
"9cc28ae5089e259149bce444d31a38927dcb42ed613d4818e235884749057ebd02",
"0331611e81d3e6e3a24cc829c1cb9087a8c6f64c286e5f1acfb1ba764eea5ca55be544d3"
"cb95fb98407fb6c8f9eb1b3f7ae7386",
"056901f11ec69f91b31f7f41f7856752568b7d34ff3af1a2259fe15ae0b01391eeaffb62"
"9976525fce5d182663b7b23a8001bb3",
"04e89c3155afda2e64c749536392554cc299b70020362e6701e3a649f0a63ae5a5da4efe"
"d5c73b5e8098c0cf47d6f4c45c6fab9"},
{NID_sect409k1, NID_sha256,
"d61a3765229dcd0b4fa6c57280f851ec2bd54d3ee2436935cd6d94e0120d0844adda1639"
"95fbc4cd9d7275da859ad8ebf30af9efbdcfc31c7c9ef42bce9011d37cf9d15fb018e117"
"bbc102f7d05750e5072f73d02c2f45509a55627a78cbd9082cbf36807759d1fe2ecbb92a"
"b30cf28434941712d38bdd100955d611987b5968",
"03f5b5a772d24bd5454bf26759dbd433fcc7bae4f5c593664c4d75da0cdf9430d7d9162b"
"ce3d7f6e13a344259da5a7d6a1635bb",
"0401ca1441b1f6e13138880196e69743206ce09c439a507a11c0fed069d4ed23676b27a3"
"a337c976c276809ae725229c9001708742013c47b14e3069af070869c12f0f39e35a6f33"
"4d98210d33c9da01ac80057911f5a392fb5c8cafeea01c1953e97d47e744160243",
"01484461d02c0337e8113e51aa7d46330f57d423b79b580a544d372524a853db9dac0c0d"
"16f733b273bf888271135a5162e70f2",
"0256d7ab133904a792987f8cea69e8e3cc674cd3c577f40ef6f12b31f52ac6366a2a3ea2"
"b2272c7bab8be00ca0d17989b6801a5",
"020d82cb9b3b1f25d993fc18b7303db4cfab91c03a97b249176f9bb2aa5ae7f589c74060"
"d25058c7acb6de1e888ff44481185b1"},
{NID_sect409k1, NID_sha256,
"1f3c23636414ced48fab6763eed5b22537968e6bf08c178b3d31fb1f6ea773c697975970"
"1d94bc1bee7c354272811edec58eff50c93331b22723d460e56dbee90466b894354777b2"
"3b13a37d15a84c762caca70c01518bf34d0c2f072145d274b3b6c932b48bd815fe81161d"
"8507ffbc2f783bd212c29b2887af6d2ffa9d2b4d",
"046bb4a141c9099d531dd23ac440eff1f5b10f7cf34920b6b702311d490d25344c665ed5"
"211d401def24986c8094165d10f8934",
"04013db47ac0e33af0cc7d74f6ce647fd80cdc1849b15c349bf501c95893be5a440f85b9"
"b029713339fb888d7a93632ea4e0bd813601f26f7009cede02e054d6499c9280794184e2"
"12e3e1091032fe0e3c189de26d04aa8a5909569017cf06ac2a20acf579ca81f3fd",
"046e55a908f13441bab63e5327ac346781399d5a9035a72aa21df708b814b67e420b455e"
"1410014cb53e6ab00f526ceb396bcf6",
"06db7a7b03d6a85069a943fcc332cb8c54ac978810374b12eaed4a5fa5342c8eabaec238"
"bfc6107fd03d75dc2c6d258c218a186",
"010a4115161765dd0c22a0915a0d8cc01905de91d3f08c6d2d85a6a92e1dc00904f3be67"
"fef000ce19f57157deb9afba7582b59"},
{NID_sect409k1, NID_sha384,
"ec69f2937ec793aaa3486d59d0c960ee50f640a9ce98a3becffc12d6a6c1c6c2f255d37d"
"29f9b4d068373a96beadac98fd5203a9f229bfc70bcd449640165ae5128e3f8d057769e2"
"8356e73e35d8e9af7876f608390090892c67391ddfcc1c332aa61efbf72d54bc615998b3"
"be8ab0a9d372784bea48c9fab244482c75cb2de3",
"06f2c6e9ea8109223d9a349fce14927618fc4fa95e05ecf9aba1546619eaeaca7b5815cc"
"07e97ae8cd1e9973ac603f84d838393",
"0401f5a9824584cbb0d5ed57f677caf62df77933ce19495d2df86855fb16456a50f157d1"
"8f35ff79b8a841a44ee821b36ea93b4f4001a88299000c07a9ad0e57c22fa8f15218cd90"
"ea1de5b8c56d69506ad0fd12b513ffbd224cb6ad590b79c7677a8eda47a8bdc484",
"042325aded3f71fc3ff0c84106f80a10af08d76d5e710a35d462e880e015a36d06359957"
"3ce2044537b9f62b51ed4fd2ed8b860",
"0667c74ee2d632aed13cad47e0b46a5176940652d7da613e4965876e7e22d89994bdeadd"
"6b5d9361c516fd51a4fb6b60b537e9c",
"026a01220a1166a4d0172428753e98caf0aaac5b0a09c5a3f11b2645d243991d141f59d6"
"cc502ac44b70e7c48d6b0d7b6ec4869"},
{NID_sect409k1, NID_sha384,
"70e11efc78d7f079ae41ac3c31c96d3220f4abfe23814a2a4a78d9b1a25e838c3408bd41"
"6062e4b0a5cdadf0c6e16a11e00f59711b417751f5e4b43ecad99efbdb2a81c91a034e89"
"edc94eb552c3eba62808563cdf64453a1db07daff8742aea4a9fa738e1322da316b26dbc"
"a2954b2bc0de6da7518d28e6677dec6ba8af4285",
"004212b7fd913d794fc6bb33e0276e349c052c969ecbf6afc89b28f75a599a9242acf74d"
"ec9f374361ba296ba42a38407f9b7d6",
"04019220ebacedc60762877881262c0c3dc0c8a709fe2ea16cdaad3b680d7cc8aae8617f"
"0acc9b5c9861ede651481f39927a24ecb2018afd77bc7fe54266275fcadc0fe8d4c0dba7"
"a1264c79bc31479f4bcd02245cde991791a7b7e65fbfa907457fb6d450c0985ae4",
"04c01ff477786304b24cb9c95ed70ba376ed6e4f6b3ab2f99ac575c92d3801e7f43bab07"
"2268705d61d3e2fd881f754b9c84235",
"00987cf8ef2b382fb25a6a542e688aa96c098f5d16be0c7d46e961b4a4152c372cc06839"
"93843bf5a04f81e6068843582fca48c",
"036fba32f80cd2e66bf31baf87616027c5b107f72f11fc766b42e2774e29e10e860577c0"
"d3a27a3b49754e6a189680b7a638408"},
{NID_sect409k1, NID_sha384,
"d922fa515e3bed60b517a2d37cafe4c041e5ab4b5c8d8d4011bf9fc4013dd8abf7add71f"
"cfde5e71d6abe76bd0f749e960cbed55711c87b5629a2c39cff48ed7d0feaf5cc4765e57"
"6a4959521f9a45fcba0dc65ae618826447e02ce6e1cab5ce8d6c96c3211adbb0660de7df"
"7453f3aa726016941d00d8ee536cc106a603d126",
"06baeebb5ffc89c94c3e8b37b9b0904e7c4b251d204894655bf3b1235710215c29820b9d"
"401c9ca7df1404d2d62d708aafe208a",
"0400a0b2a185ad7ddcaa0d8d21b643a14948d3552e25875506d64e236a90d274ad1ca678"
"e628acc208bfe6b56c02df9f5a36aa94ec00fef210c7137237da8ecfc2f069cb9390c132"
"d1c6ce961f2bb3ca925ee727c967f8a46727c8811c94ef66f20836c661a5cd1c59",
"02185be104ad16abfe4fb83de5db067d37ca58510b786b109514debef56cceb4dd6ebe53"
"b25127b85faf9c28b56d6586c26d60e",
"0404831192b4bd453c0a7e850815ac3fad88c7a2da27d29e83ca6f22213635a366018ac0"
"038b1fb1e4c512cac15b614fb69b3e2",
"06f677c361547c91428d0e200dd00777262a138afcd828238d132c56b2c232e2b446cc69"
"3fdc4013f05ce7021aea5b5b2f1b34f"},
{NID_sect409k1, NID_sha384,
"4f64d0f6bfc542a0d4347576935bd68ca88524ead03b8d2c494061d0658e6c3e14576b5b"
"cea5f2f992f54cfb52b5c7cf1dfc517205e0454510eef1b7054a8cd06ab53ed2468193f9"
"8ff0dd62faf076549ab2a270f259276d5729996c120792c6f466a74ab65035bf38ff2c05"
"5b43e2a8b8e2449a2375ddbfc18242157bd905f8",
"008e5f66ba53e7caad1feda122a80c32c82d2c32a7237b8ee8ead44ea8f2f01d77c7056b"
"9dd60b92d051f060da8532c1fd0e8f4",
"0401a3d020a0c7e3f3fe5b3d9fa6b6148cd0c481b4f9e14dc85aeffff35e62545654fc31"
"3f930ca2e33dced28ec28d0fce6ceaeaa2013c1ac166c3c088e8a4a9d44556e3344e52e8"
"741ed1a8b526a45268086e2fe54c24d398553d509439ad4957454eb68af594e683",
"0095caaf063abba5073aa7123b2c0e1666d29bfdfdfb0c484e18931d756ed0845ea15dee"
"1e9abcbbe4576113a8806aab9476b16",
"04d6e33001933221e9eaa78da5874f639749c7396dae90f2da4ccfca15b50ee9e50521cd"
"84d78a098e0c383fab0186b3dfe1b3e",
"001e17cc7baa3e9ff4d882da970caf7d55b4e0fb7f0cdaaaa8290fe2fc9cc31d51b34b5d"
"cc825bf6799ce22fc95382d46f3f98c"},
{NID_sect409k1, NID_sha384,
"7047d478ec5282d55db8c19c97af10951982d908c759ff590f27d57e2664f08d526cbb2b"
"fde39bdbb1aa3dca5a8d3feb50b868be6651f197abccc9d8040b623de367e2ea1d20ecd3"
"02afb9e273f4be9f3f64f2c2eb3f92d5e0e375db6549da2a589f0604bc7146562ccefd15"
"995a7c4208f640e7a17afbca69cda4e173380523",
"04ecb22b44e809f89b16abb10be062c89b41ee34e110403e42a20ce59a99afdc22f6f6dd"
"a56e1d9d1b8ce1d057f390db111def3",
"0400dbb4a6ed11f36eb78417269c1b1e9725eba1666591afaffb5582c8b4d5bee1d73922"
"b0164a05bf21a12052171abbdd3130555201eb385afe8588ceaac9f39a5cb4455e02bca4"
"8f3d2242730e0f9e06ff1db24344379f96356531676cd5af234a120f4b61f7e041",
"01cc97a718ebeffed4ca7a9a4389d6b0fafb73ab000463b68b5580267aec203b6231cfb5"
"afbf7ad8192f0947c7f40d9e060ab32",
"021a29f56c31227daf0dc5dc919434978943b80f4b18748bb5f7d6702153b966a0a4af6f"
"209ecfa3aae0e4f32a1b7c6ae58a55f",
"06921b2e2ab81517a0785c4ac3be3d7d4b4c917d7a1e4313b123ae96056a2a4a66d9e008"
"19d8c1cca5bc0d75e4e05477c1fcbff"},
{NID_sect409k1, NID_sha384,
"1a8384b4771a410663e56eb36c5d9ede8d161a8fb0e31d3f74bcb017b9e31232bb2e2f4c"
"65a2d85bcd1cedd93ef08d4bb4af0095731574ab3f2762788a1ba3bf0ee46684da8d9dd3"
"84432fee99ed3c69213d790a5d81b351063eaf2bda71ca4868ac36be1b571024a8bf0903"
"9b347fa996d5d161078314e24b7d073e05cb3d48",
"051f9500c15ae73d6d479b9f3d2caccc2039d8d03820befc2aae3bbaf65d59bd9cb3c4e3"
"aa8bed5b3acb70a5566047ffad80729",
"0400ee8ca7f55225760c515bae053ebbf4ab23567f95c7091fee2acfff079eda297ec6a7"
"e9d526e12e5976431f9d7e52a2318ddcd80185e2c17705a2555fbb8afbe8e41ced8ace95"
"c83e198be3c7dcdeac8c2c5bdd988800f1194e553bd0348ebe6c29c16f35d50895",
"073f96451cab2d3ca9810e265b3461e0fbe7f32fd6702f06891b97969b133eafd68e53b5"
"26b5e32b0d06ab61ecd75e1bbb21b7c",
"067d55e709f6966cb2082d8021a313850c53305a3bcc926b6f9a122181665328fdc8e05a"
"88de812357be85d22c61c919876fec3",
"063d5ee4a63b1fae39f266a9f826754f5bca4d7bd414dedd16858b5c6ac2d4162e28ab57"
"215c6713320d3d6960f6b55e3f1897b"},
{NID_sect409k1, NID_sha384,
"43513d6dd8bb0af7a6f5a2b35f99957d335a48d54f2c4019ce9518b35441d4935518976a"
"b1df37110b5b53532cd9e2c66d9f87ae7f683d7efdbe1775a6c15eecee84c6f879999d07"
"06f6779dc158c111fe8d7201983883bc8334f51dec60004eb1087347bfdab20f8f2f2605"
"56681e05fdbb8a6139857fd3bb2df5bc1f2dc143",
"00cf01dc4462cca764f4f8cbef48c51980737b9b98d1384b8de9f4c733829db7718a9b5e"
"aa46a8475c2144fe4454cb8eeb0a443",
"0400806457fbb7fc577497c937600c5a9c4df2c20cf7dad4510e5ad617fb2849bfe6956c"
"3efeab6b805cb7b63bf5d1c94e5ddb456e00915071cee2094efdcc155f893da8d83d9a5c"
"234d0f04f738b7af5b8fddaf1d3aa152fc11894a13caee0009bc106a64323e9dda",
"024968902b50febf13be11821d0d316f2daaa07737af45ce2e855aea6ed58f226d2279eb"
"e4295c5d7674104bff75b899609561a",
"0549f18f1d654f26ca134df4707694e5d9b3693bb34ab5123ce4d9e4c2b2d9756ddad957"
"a4169fc9bcea29944903080f6f5d01b",
"021887355c6360bc4ee59f1badb5325763e9428e60b31a7abed06ef03bff0b1265662d60"
"4dd2e0140c355c70fce1b56ab143201"},
{NID_sect409k1, NID_sha384,
"752300bc5066d0efaf807183a41725e349907b7339d77c79921ead3c685b616b0eb97e70"
"8f3880fce0136c510c8cb53b22cb424af6f1c34633600939a0647c02d8f9601f9416f1d2"
"4a51657241fb559c25dfba91402cea43bca1a13718b3945b048725f3df560e6717cfc6eb"
"d894e29bff1e0c7763f15b8ea93e67385f059598",
"063a9a565497974c6dd459bea0d1196d74f263f333c31b7e8591499960e1cd79e2ef4cc8"
"709f6d54713f873b16e7b0be42f71c8",
"04018872e9d9410dbde671fc050ab88101f01d146a72d62b630b29790b20fc02cb62cd0e"
"bb5b453a46c60ec2d2c66de8715c32057801b6af51db1c42b743b89be0900d23f7da80b1"
"5f2e7a2a965c7bc13800bf58589560af4697f873b6155194badf5a19a653e63da3",
"01d3278e6e78386146fc15006258d7a62a1345db3c2e44fb8d3bf8101727bef254a9fbff"
"157072326a85b5ef4e17c5b0212bedd",
"07bd5b54d9c6d6f9c87f4a66472be2c4bb7f521ae56c1dd71781d95440b0a151d206ddf6"
"27e5ed3f9c7df2fc914a78454e97616",
"075e39ff66ab0e0d1b46f9679b95d10b692874d45fd6898c569aac28a53569646bb29f85"
"56e529ef83a15c574ad5e1c82878154"},
{NID_sect409k1, NID_sha384,
"f620603489944769c02e2f902c2299dd5f32b5fb463c841b7e1fc0249a85d2c31684bd3d"
"aacd97de8291c5d39e84d6e59d3dde1b30c181bfe8d31b8d8e080bd191690a67fa00024a"
"c8c1b10981b40d4f88789ecc58fc69b15417fff34834e23453bb9933a43d08afab74d056"
"f366b40ad167b51ee5f008db151a12b467d3eaa2",
"041074dc186193d30aac7cc6d269b938ab40b257d095e54ba79967a377a91b8f73671470"
"cd07f0a3d1db7cf0a31ba9070625e43",
"04018fe9848dc599a759d90530480a6f11d052d2ce21a7275769ba02a61658c3b69ecc54"
"6aa6599e6699353ee1d65ce533c69fb2180192b9c41bfeb2af4f29dcd1c43d3fe72a070b"
"5d085d070acdb8c02f0dba00c9471df1dcca1006709676bc08b8ddad97310e25bc",
"036447681292dc781f7f4ed60126945354ad1df5987266038c5049d698b2ae12965b6fc5"
"8f3e944c4751406087859973d8afcd2",
"0541c22a6cb984cafddb3269ba3ee56af64cb36d03b7cd1693b112a7df20f0422219f85c"
"6820130ad53ef69fb66f3326bb863a9",
"00fa66b163ec3582760b048ba9a0fba9443d7e908b67d749d732ac9b6e89c1fcbc6d3ff4"
"e02a43ee41414b15ead0cb83749e0a9"},
{NID_sect409k1, NID_sha384,
"5575f610762b42ce4e98d7bcf45a7a6a0d66ec7f27d6b8b17f1961249d905bc7e58e2ce0"
"806d467f106b16285dce4544c72666d08b5e2276cd0c4e13187cbda8aecf57b1855afedf"
"8fad39ee4fe009f204e60bdbec79b123456ec2d85631d382b8a2f2c7634af3992e4707f7"
"b4215e2c9d3b0aa8fb08267953883a4213669d33",
"010820db54ccf0226161aeaee79cfd2797f87702b4ee91adf8543b3c9e79579d0df8a889"
"e366ec1e0718e039b87a37c24d620e9",
"04002eb4e313f158ba7497130e2d64804ac45a7db207c55d41f39979e0303dd2641c8105"
"0fb7f24f2fd2485b90f60985cbb15d56be00a190fb6c81c104164578da6bd4f2b193cd11"
"935e1f87f14e824c2bf8c82c39f0be1a6de3dfc6dd68af8cb14f6a78f38773a7ca",
"0118e911f676f004fe581d1855e5795e5f4ddb33fb8d409d557aeea87895b7c23a513ca0"
"010f98b3a63f2c65da5e3b6c37cf5f0",
"060c7f7c47c16b294867cee3e65eac8fc828229a5d3adf8e68e14dee620e9d4e7b78c8b9"
"02b5042b5f19c94e621c52836c95ba8",
"008d036087b23319553faf835b793c73204cdbe2c1c2463e74de8f404e66ff15ce9384d2"
"6149e7300ed1a109afd1f915edef912"},
{NID_sect409k1, NID_sha384,
"81cf067411dde2d0ab04fe5fa1e28e6975cdcc571588de60a35bd956a535fbbda4affd08"
"03d244f3f7e6902a2c9a7ef2488691b6bef7f8ffb33be09ccae4c5285265e4957f7928ea"
"5cbabd6823297f59a7cfc9939a49f26bde74c4c69e2d38c1efbacbcfdef0112138431580"
"72be84ed3c1781f67a0e2d4e9ba76a585c17fc0a",
"059d2a06e8bfd5e14a9bc8777958b85be5e97af892d2cdeb0ecbd2d5017952b5042349db"
"5fedba2e26e7b85bbb31ad313d99434",
"0400af276952a1216ac88ca7a194f5b27b7c98c78c42f852dfc1a2cd4c1a477ed16eebfd"
"c90f613b6e264576a35c45f49aef8a564c00639625074b69346dc6c617d624d63ce415a3"
"6154a817f4e18c59a3b09e01589407077b19bbbdd57b04ef8fc2cc23c673d52910",
"002728f7e9b4772ab790af0be9ed5b3eab697c4710249169d2a5782ab3797b8fa21bf8c1"
"de659e3060af5a286353402ab982320",
"02a7027c6f94cc236dc8cbae35f9c38102a663b84f66143e2fbf9a152b1a6478bd803bf3"
"171f933f63509d539a54dd348002ef5",
"0549ecf85ca1bae6d9f0038dcef90c93121a654552780f5583a7d44a73a9360c6799e76a"
"632bc8907ce4626c0439f1518e3a250"},
{NID_sect409k1, NID_sha384,
"8ea18387940035cff2f37278d321b344231075db43c7fa7fee9bd3fdefe5e8f03e7af9de"
"afa1022eb108e19ec11fae34536a4fbac2e8c8139a081a997c080cbe8f3e2d2a72ff26ed"
"cc5338b21372fa1498e439e4d9bb12d51cc539f859047957b1b1f1fc30b90231eb06b365"
"a4d404a1fd5a0e5cef171fc95b04d0b557d78ebf",
"0405590893cbbe18f4ad99df28b5f9d17f8f1882269aff0b7eee9392859d68927a99c942"
"a3075269ddec6d69c0df2d76ab9d801",
"04006ce67ace45a9cfa0cb45e8e1d0eeb44e94bd7527fed6b563f1069140a3f36e010f85"
"e1ae5ef14d626c78465cae43230090baa601a66a58d87621b63ca662130ea342db029acc"
"2d99bf76cf6ec4e53ba71bde4b00e508d332081055a65fc6f44a96f4e947d729dd",
"0035f09e0c15b41c958596ad3f5c4bd4a3685ac94f19fb97503fb5fa29115cb18fdff4bd"
"104535847ff36650b7461550dacf2a3",
"051775fe1503ce80b3d581ea3e5ba761665568ce0eb7d6a7163d8d025d76002ca7bcf6d6"
"88b6477ae85d09c0d4017aba5ea8019",
"035cbe69edfb6fb99c9e45240b7a587c3805ab2ed6b0399c7dd8dd76187363b2ba1def66"
"b2c3dae4bc2e40d164bf0f4837798d8"},
{NID_sect409k1, NID_sha384,
"6a253c1aa17b2b1e6624afc8e7456d366ef5b1bd78e740538260f395481148a64da0b6a5"
"8cd53d7e06c691beae1a616547cd95c4d259a371e51c2c0e334c8a5311ae31e4c7af3256"
"86ff9f7a36f731010ee1a9b8a29169ceac36a060dd23611dc9713c615424888bb574ad5f"
"5755d7311bd169336ae986c977a394bf16487c4e",
"062bbb4f565aa0f23b88ab9029d33b995729d10fcfc33ba7c4051e2fbc72f15636a834e3"
"ebfe604b927cdfc89f53c57f36890db",
"040125242acf14c7e08e9f2f0194f734841758b1eea1e37ba80b9855a14100a5f0b57bc5"
"2a0200cb640121d96769e9cabc45362f5600dcf52cb899470943a37d260aa85fe83c3869"
"c862001021660ad09b4d73f7739ad331b3566bffad590534207c6db9acf98399b5",
"06095b4ed8d51e37f6c723648af4cd4585d9d250d7519139f58a93c75f197c4bbd1142da"
"59769a5fe178415c677caed1c3da667",
"041b212a54d4396ddea2898dadc363ac3ec5385c9b3b8ef1ea17c3d2f751d4f791372385"
"48ad759b5e1700d7d78072df3bf84e3",
"0149242afc524b0c3583037da153f539aad85aa0c19c6c70852e3c3923df8c3abd0189a2"
"abba872932eee2e6f45e02f98e810bf"},
{NID_sect409k1, NID_sha384,
"0f91d0f0139faf3b90a3d4bebd7e96ff6bb6f90f6c68321fb392637d8ab2a60d649a7b73"
"64ee6e4e274e1a8d342caee36cc11c56c54247fb0a8e8ef81ac4322b454dc9a195dc5456"
"7bf47ec8d4fa4cd32e76d78ea2d08bcbce3edbb68fd8597e56d5a9f2df4e47b2701046df"
"89615961db601bd8204584a6a6cfbb627e2a1190",
"03fad7031cf8810544a3e4bd1382c0a2e22c5a9fe4804ce67b27591fc516ee81dbac841d"
"399327168aa6abd79e2b5ef85df1528",
"0401ef0f918c683be57eeab95d5d1850bd492ace7f4b37785863647774a028e963ee2c0e"
"ea801838aa8217fad75c5780f1c36e8d4c01d5dfc69bcad46bde5539c58ebc89e1db2a3f"
"65069ed963280cc2cf228b2568bd53c6e0e164d6b63a5d3c2b8e3be9d5139a62ef",
"00eb16d784e2aed724cf1e4b72fe76b00dc80948c07f9c7524eb0e83bc59c12a8ed16fa7"
"ff21dffb8bbaa82925848a19c93884b",
"04a07e79b4f771363ad4c46cde0aadf3df4a233740a89168c97b54559029c51dc2c79b7c"
"c94a0e4e3d2f94e376fe47993da28bb",
"0360f559d37a777119b2aeebf00cc17e2edf04a2cbdf74366f5d34368d2eb2c92958e4dc"
"2b7453d5a509407a4d4643cc0235f57"},
{NID_sect409k1, NID_sha384,
"50c17c1fe4dc84648e5c3c3ab8f7c971d4c58d8d56d2b5ddd92e35e6792111ed8dac7644"
"ac8a07ca8bb4e38e071aa47b22ffe495e9083f9bf781ac1b5fba571862c909c7aaa7b8d0"
"5ddfb7ef61c99700de734d5658f44ae9fc908c85a2dac8e7f854d6d24be805fcd7f873a9"
"1252985c5c73129c60177ba8fd99daa87b25a073",
"03db41b4f637fe7977c90e4f1a21799baaddd1826c667102414877138436cfae1b995984"
"2b8097b5276f15f2b982ee59df263c8",
"04018eb25bbdeb41c5d14edc675fcac8a523acbfadd6456632bd593ab5f694a7734b163a"
"ceb6e6b3d8ed83fa1cf7b5adb9871a6626014975abca1cb769a243936e65123167e53527"
"9197a37d8c92c7b138f31cad4e95c5f62b06f438f94c1a61634b34be7b96f09fbb",
"055fce73c9c385f007256253281c6b9d0930d127939026495d0a30f25f77fdb6b334043c"
"39fad4223852f7101fce72746ea205c",
"01d7c26e0236afeac032fc5f3dbffc8c03b04417b514adc26d6a4f697b4e87a008d5ae97"
"544a274c25ff66b98111d7c651c9381",
"07954191fad321e7f2de95a87d5a9c4527e658ef85faa6622d5f34f8bc2b84c881ededbe"
"0281456e9b70eaf7a207e253d216533"},
{NID_sect409k1, NID_sha512,
"3583a3226e2dc463a462fefa97024e6e969c1b13bdc1d228e2d7823d9f7c09012390c253"
"5baf086588000e908309090daac6e6d2b06d2ede6fae838ed47f30b5b481185f607a3586"
"f6dea47c8f84e9d3b96d5b0ebae2462fde1e49d84d36658e87dccf5e30c0937feefd8862"
"dcdb1a1ca373f6ae41641502ac54df6633a8cec1",
"065b76c6093d9c49591293471286df1a4444e60d9d06cfa114e175afb5f119d2abeb273b"
"0596019a0ec5db5b5869f2cc827b364",
"0400266321fd15bf6b1af862496f467069819e3860f74a07825e68f3d023985bfbb838a4"
"9b6a41b6515cacf404ebf12ce0bd3d6d70001593c7a8e629599e63d3282cbea780235182"
"77e6731fe8d88cbe525ded554b51a7f8803ab9e330f210619dd07df8f67e1066a4",
"035682af873829e16b72bb86f3ee99b5d9f052e4a631b07f87d3b361c8d8260a877231db"
"cb3f4d461b4a1d4467824a26a5a6414",
"00a483dc2dc6408c256fdf63b04d71d3c58a08db7167da217f466cbbfb2d68444c10e87a"
"9a1bb04efd71135c00226e58414d407",
"078acfad2f2492f74b0281d53e4224c7544588ca9ceaeb16bf759b20c2f3d3ed69c64615"
"c247213d51800569dc8b00078de68ef"},
{NID_sect409k1, NID_sha512,
"60ca58462d53d074b370127132f4e59f5eb8d15594dc721a94286afd082a8934e52462c9"
"c1c3910f8b50d7aa3671dafa5972958d876d7992467b2fee3795a6f9d8a7bd3003a8582e"
"a8c003aa1e02c08ab6804d85bcfa13a815d75c938671f0af0706c68bc70a6155708ca755"
"cac2fbb68b2952208d63e0e2e3d816f04c61bc03",
"07e9993f3fc1fdc4c376ef77ecded96006ac1159740bd1b2dc6ae3d97e15a67383f1fc93"
"1e460b9af3fe14a54e47919667ed06c",
"040189b82003b546f94c066963239c7a590e064b88bb4548678853545920e413f2be3212"
"5e40efb82d2c9582d2d8269c1d408a7ff0011583b267727ba6c1e17a244ba7acdcd83698"
"6089860ee312b6dc2d88a984b1fa232eb0419730db8fb94a5e077009c1d55979bf",
"07574dbe04e1ac2bb34e40f32d6f6db364a95cc5770b79888d72b74bd4dbce9fd91136e9"
"e1152424d76688dc995bbf2bea34175",
"009e42a63b41877e200829356a2191fbb6f2a9a234be58c76b0852e4f348ca61e7492f90"
"a37feb8b95a6dd6df9d1a2e61c63b4b",
"01499fdcc804fee8193de080b085b7513eb8022503de5f64dc12c04c0ba24af30e30f63f"
"0e3eac2c82eb20c6672336f8732ec5a"},
{NID_sect409k1, NID_sha512,
"c749f9bb92ca9957ca6d0124206ebf65e860ff38a225e241950bf4526cef3f4fa9184ec8"
"3f71f813fe852dc08eca6b45b14fc7f2c6a19296529bfda007efe9d0d26492de2a902b45"
"ed39603e22f0a763dfa5deadd97ef6feb859d860baa2cfd1d066c0be0f9f4e0e2fafa69c"
"c51b12e814ad2e33b0acc0bcbe1df8cf018dcd4f",
"00c11e2979498695c660a2bdfd105b115bc4ff8664ea15cfb40c725406c6fc9a13027bd1"
"d72ffff6258f29e4e19b845243444a7",
"0400904a9bfebc23607c7c89b7aa89315343852cb894f54fe42ba4225285e58c6bc318b5"
"5691aa6a6ef22eb11f44cbda89f157d7a8019cc1826280e54832b455f0ce0cf89bdb62e9"
"73a8e819fb776b1a202b4f207b8baf9072929c9e3f6a8ff996d6d529de899b024e",
"070fe023c9341df9348f08882bef47bd8dd7f13db7215d1cd52cdbe7919031a62455ca96"
"9a8cc6db0a05a0b4befb47c142c4f34",
"035e7130d59d92ff8c4f264fb2c346e052bc305c7f57549a0fe43cc7cdac6aadf2ce1939"
"222decef4e1f900e3c2fb2c52bf53f5",
"0008d5ec1ed2091309ac11eb88157ba5122bb9b5c858a46769a130f7a941818445664ac7"
"8325e0b6d2a11bc89d08fe0e87a5bcf"},
{NID_sect409k1, NID_sha512,
"4de8414780ea20f7943b1f1adae5e3962d96e828fee43bdbf2831bd71bd25df2976a3be3"
"7a7a667c7fbe1200de578920090d131a750c9bc09bd95b261234ea8cc25423c4ddfff565"
"6d6b32da6e2f6f530e6673a8660aeca31273bb9a3a21bbd7031a2fa71ba37c004d3d1c64"
"b2c0798783e47b2efe1a208959ac16e35d444245",
"068dfc23c6635bd1fa1076dcbd456ad6e8df7ce7c1370fe275803befc4ffad007fd062a6"
"1cf1d50b93aeb9afe1aab47a65af82a",
"04005591f8cb59ccea17bfbcb74e69f05218d16175f0547ab95f507ef8d7426c077b52b8"
"2dcd06baf6eae7a66bc72422236e589e420126a01d5c2331a2d00949e07ea9242ebb50d8"
"30b0aaa74bce841d4e43bbaa9e9aaa01ba25db7a8a2f4d72977c0f016f625cdebb",
"070682c9659089a703dd9fcdf2f3fa0c1d1ef5fae3f8f1b3dda55d9b611770244f892689"
"8c904f6952c1847d287bca21db4dd59",
"02734111e3b736ae795929f835701bf290dd50c0fd625738ab2769242c1403197a3f4dc2"
"9ca618c2e292c6bec6dccff71adb698",
"0755292cc5363fa74e0193a806879d3a275b4beebc97250fb230efbb8364b2a30098c048"
"8bcc6e20449622d6a5fd2ae24d7abe0"},
{NID_sect409k1, NID_sha512,
"a081d54232f84bb19dbd52ec3812748e2e6486f6cf1b177b27929504ca878036547eb435"
"31bb5b3edc81bfe105370427e92831d2239cca0106d031d9fa8da9cf89c6fb6401377d59"
"36b6329ccad854e5567181b8f16a37c35f333eaa0ffe91d727d183fbab935fdac2d5670d"
"afb3fba59e4fa2df1746c58dd8360fa08af7f4e6",
"040807fb888e1d9fd33604546656a493629d94d4a0a9de2608962225ed158167f9e2438a"
"be2d12a11e2adb6c2b66ed78215b0b1",
"0401787c0e6c55acd69bde9b0a84d6022796d5b5c60fe5357bc0fa4386c16f61b38bfead"
"b6cfebee7e7701bde24418b8b5642afefa00d9579d271ba3d5e2327eb863cfdca3970700"
"55b97714e385ffc2fc23528f696dac1a4d0e535641f6c876f1819f2672a8c31cdb",
"010b8f5356d8a029659492c444876f1d274b82681d4f600cdb5fb2afde13598ddb71676d"
"9ed86e83351c70678886e8237a865d1",
"0304f43f9705d189f47ee09a079494030b0756993a93e4c6ee6b5e664f63431f99e50574"
"7c24377e5930f13492483e6cd06ebdc",
"0580d4707c97f0330f908042a6cb2a2b313f07bab34774ee03bbee63a4ff881b68def47c"
"d300fb49deb49829bf486d1efad39b8"},
{NID_sect409k1, NID_sha512,
"ea60266f1538565b3ff42fa4bbfe319be070329059c52c8bc04a7da2824f209c1145a05e"
"551ea59ded8ca8439c328f6907da4e81d658937df614be98c7b8648818ea80ef40e49aaa"
"4431f4a211d62acf2611f5d60c446b2b25745078c643859be1b12b3141a09ab765dd63ea"
"1f2a2df015eca0840087a5db378c4c4cce76cba7",
"033bda0a02badae08fe40c239b9d59e5bfe1c4d4b9b7a5acda6790bfd77ad08dde5e93a2"
"da80ec54a7f88146d72218bbb88aa10",
"04002dec536832c8acf007daa66a47e4eeecfb6991a359f8c412299ef56c6ca2faaf18c4"
"db708493e84786a7837ab74c5fe0644cee00906c8f603b579cc2384e0803d31d577f7c91"
"c55406db3b2db91bbca323fdf3cb6d010617ad1aae7bf414c4d974f22e6f05af53",
"051e8d027e62db2397e4a807d98a24455a76eff6dc259ada89e794dec1484b44724894ee"
"ba842f60b73287642570460896dbe77",
"031769e6777444095d934d05dcdf82405c43ae91ad5fa9201568ae2aba25712717f1af2b"
"8f49f6eef373237bd70c34889d0d271",
"0023498aa50ee095f33a4081bfd70a9484089c85fc7a4569f560ed67243745c823cc0217"
"d29e2938f06ba9c8790650d10fa5b1e"},
{NID_sect409k1, NID_sha512,
"82f38c9405ef0d26bcdd5b3fce4fb0060c3095f61403418e17c337933f0563c03691fabd"
"32ab5e896c593439e7492a9970ae325c67196d9e83fe0f9780409a930326f7e6efae035e"
"f8c321cb9ad12461edd5cde66c04739fe079db65406b3c2d22f2d04b1a4335285513d4ce"
"b901d2ca2ad10c508302266c2cd6079ff14eff4b",
"04ff431769d26b8837d3e1295f5464fe82be29edefba76323e92078a6483ea0daa962215"
"49102509a1bdcfd46a5a2e5de10c39f",
"0401beb74d427d849705cf26e26312446f27a7c5ff26ea9dc1aadca763254fe53a622de2"
"9cba4fa81ee2f9e0319e752f72be46cc7e008dfcda35a00ab77c3c47dbc05b0678cf561f"
"575369507097833e86e523dec879e0ae9583b4261f7a73c9dbd417accd4ae6688f",
"005aff3ad332af23e0dc38c16853252825076d602ed4c6d947be751af5dff3f59611e616"
"6c31740b5e5a167260adf2a5466289f",
"035c4e8e1858b9694cfef3e864ed959638ba309ba2066a28fb9d0e02a66cd4c187dc6fd8"
"ca5fabe68acbc2074168157b685aa6c",
"04ec2db89645018f9845b7ae31b8418a767e3570d401f41db18e424fe861bf09114d7860"
"6a056617613447d125a283be5bdb6ae"},
{NID_sect409k1, NID_sha512,
"d8506fab4f681ba4ae86066aed447571eba4fe04e6585fe3be6af2ab1000a3da68c5b0c7"
"11a85ddf3a40cb7c8944eef81f2094650459e14f5b848e6add7e580b0198070f873eb3ed"
"5d0728eabd92bc1398764b94cbb4cdd7cc2027b9762dd10782658cd9e8a5022ac062fec5"
"35d892198c8a387b3d2b6f7c92b1af6ab7dd9e4a",
"03f85ca1169ca7e9df44cbc6bc7d2868c9d94e8f8b699a42ca492dca0914eb5789a90322"
"18dcef7f95f959c9554a1cd83360439",
"0400aa3c77dd4324258bebe7da5338c772d3496e3fd0e57f455459542f1a1c5b47692f51"
"c3815c9549d0c23fdc1ff610fff6847ea8005e626d6aeb86dc51f3b359b10862cd33ac99"
"27e38127f7f17426f2369d62132a2a62fb6b8354c5ca0b3e5c7c87117b4f777a0e",
"0495099cc73c9930333ae3f9d0b7057d7c70e2bc7c805c0c6a44404739b3fb68f9fafa53"
"033b54b7ad7bfaf4bbf7baba0dd5a0f",
"005612fe87c6a3a164d269da902aa43c5a4e0333770ea6334f05750be3f31ee758d16929"
"1e15b1540d40b60d1bda279599f254e",
"011a633bbc058550a597585bbc9f33099eb517795600b019255f649493d4a6dd533be8b0"
"965d9f9d9698677491bf929198ff34a"},
{NID_sect409k1, NID_sha512,
"b3f30d34f252a4c26f396079e773142bf61c0981d912333ade3de4e27cbc72cd8a16b318"
"07f0c46116f87accb854487d83ec8c6a61565e6fca145eab70048245db08616779d7047d"
"b63aabd90dd15acbb05eaa510072c151c0518f1b34582b95f43ec7b9484b2993c176de79"
"e84566764467f72392ef31619426d159c91816d4",
"03a97deb36d68f81f50c8829d412ee5de7f9d775633cb69c09dac558182039e275fc2582"
"40517a7c4aa592e364765321f27cb12",
"04013f0f4c16a47ec3a46e7a088c1b6a63ef61eaea46aa9b2c532d8df84dbf64991bdc2c"
"81ced3635e562d1403dbcf6aab2f8aa9da003aaded3b99a454b820fed989dbf6430ddcda"
"67db58e356397d06aa137fbdb365ec43994abd9c0a9fadd2887da9539bb4ab3c44",
"06620ad14a5835b9e9e104607c317cc599416683a60ed8865acf78ae1e861246567cf9d9"
"1f759c2d4c82cec835a4784d3c231f4",
"068faabcb7c716fd73f129ebc6625f5b4660a88e47dc7dbcebab321051a61e46b74409e2"
"b0af420e1671ef4efe04973c43471ff",
"06851e5da033da0f28a89dbbdabe93ef11331c55cc03d5b096c0522370be681241fbe71d"
"1349f219ce57761c85fbe208ac36a36"},
{NID_sect409k1, NID_sha512,
"0fb13b7c09467ad203852738eda5ddd25b17d330e82c279630b0e1f0c86681f67f6e537f"
"b00da9419114973c8559306de58b0387d86e52d821d982a60769d2f15fd5ac2ee6dc55d8"
"ac04ee247282cb2866b8cb8b4d7b4b6cfb33bfefdff09a73d727193e5fb939ff66ac5fcb"
"644a44f9083a790888cc538c5eb435243c6a34a8",
"03b1da0ffed24e1a3b5ba22bd684337f6b08053591620541bdad50c761d66201a2cf21a4"
"cc636426456525b598e96baf97d9851",
"0400116a1790e621272b56cb4579ffe6ab629a2d077b779b73e039d74f58c476283c110b"
"b18b9c9ed63de7288dd678064de68b7df60122b43afccb88982f2e07ff35468178572bd7"
"2b644322d9e1ee68f78880169a83a5bb88c6c994762a7e8d80e09333487ac30fa4",
"06d7a24f0fcad549e9c36dbc70ce264a75eb37b74db98b1f6a824ad1e5635be9818f45c7"
"544927807dc0fb3bb5fd38556e8656e",
"0232339b50bdb772d15f2cb8973f6dd9397af45cebb69adfc089bb802e9c4029dfb2078a"
"8a26d7197de10638ce512e5904ccc5d",
"056add03244174966d53105c570e8fa660ae8c5d53316a24cd26f24e29e4b7459f4c9dae"
"f07442247b63665f97a3c07d91a8706"},
{NID_sect409k1, NID_sha512,
"f9b8124281628cf4e1da0cb4f021c8d19d815644cd80c7c8de4cc62722904ec4cddd26cc"
"4891f30b15098a25ba6923c6abf4774deb6e1883fbb409862f94467e75a725e7154be860"
"fd58347577c83adbf18535c54b102220197afa062cc1c84f6094490ce488af4a08d2c5b8"
"08a2572e18a59de96c87162f88413795351cedc1",
"040bac7e0d3b54c7753c79d43469e310d876015d948fac4e3a9765444754476af72330e8"
"8d79ee6119697aafac8435ab5690754",
"0400bd4fe8daffe47bfdfc43deca20b15da7c999084bee8983c62e3dd33740143c38d8f4"
"32cbacea51e6f53994265b2d8f4c393f6e006d88c33c31f4e143b13bedd5738bc1191fe6"
"815a099fb7b44617fdeb08daa0cb74edab7f9a8c67ac1e9c0f0fb21a9f02ef4b6b",
"020f2f6fcb3e471d47f21fb15301784f7cf3632dad3627a9ebfce587c0097871eca580bd"
"a051b100f991aa6de5edd3a7684e839",
"014f8884b5107e9ee5cf6f5d137ec9d59a85a6fa0431053d58a1400fbf0d518e8910179d"
"a1160de2c6cc8ea8ba8f3af8e0e1f6a",
"019aa8d55c8d876989f9b9559db0576f91c4610dc9187c74aae2d4f212cd94d90dd81ee4"
"483d88d866aec1ed469c5e3eed7d90c"},
{NID_sect409k1, NID_sha512,
"4e3cd6100520db050af0daa69fe3cfe6603a223d4f2a6318fc5836db8640d4c7fb80bb78"
"1302036d2d6fb8e552b4eaef3133b98ba2d36b9ef0b86243b0391413c73d48ecbf1d1917"
"0f1b3b781b35ffd316afb1d55d1dda8e91eed5553780cb2714a93e7ece698b832e853e25"
"89c5ba2b8a997bbbbf625071ded66762af8cad42",
"025b7eb3bdefba3c5134438caf968f615b315204f348006f82e8d61057a8a8a853230cf0"
"500f9d0b8c1551a59b9184862dd2ed9",
"04017d2029cb711e52df416c54b63a95a66602a1d15c3761d91071964e0128c91ea766b3"
"d409f72d9fbb5161a459c3fd7990f87d8801e71a9c66a4d4dcf199aa329e44b99f80640f"
"c760fa7326f29c273aa13b153df5277feb3c049e407630173fdc9f735d7aee4e10",
"0575aade2692534b5a1a17d36c36973d24dc501c75c3b0b497a3d2fec80c67be7107988e"
"47199d4863044fe9176762497b5aff3",
"024c6004fa92cad446b8339917f517f04d22db47b3f9bdb83d863dadb5431866ce21b13e"
"780495bd66152ab33eeff8830cf8538",
"034aa568aca7be851d276d2235e42b6624df1cce2b97f6413dd3fc506f0f18483f95f911"
"feb0eb220415ac593f2c93dca0808fb"},
{NID_sect409k1, NID_sha512,
"5411708381a65bef4381c9e13a04cdd5ba0c15829f7f25ccadf695f635384d8e4704cb56"
"2741747831b33852567f42fedbd190d2980f1bc921ce01c17d659d4bdd7eb787b3927fce"
"e659dd3b65132496c687f2249272a473d46326e66b3cb78dafbb522390162c168f73bdec"
"88adb145e6afecd561979846ea4c8cee38dc1686",
"0673b3a2985c95904732632e5d988d8d437a60db13215bb6aa880b348f011c609a1e8604"
"61427a8cf0d622abc47f910f5c97ffa",
"0400c4f1c0cdc44d867ed38d093eb967bfe285df897868c83ffcc0c53463e3852a1b2039"
"506d9508bf01d0d79ae537e42fa2070a5e00c2bd9343041c2c4100c5d795ef355c796a6e"
"a7954cd729e11063b14a27fc2c3a9ffdb3647613b44238eee17d9cc49e8c5dfbe0",
"019a9509f5f6d947532638a3c80782b556c553edaee9ade91e457f7b5d2c9055572fb116"
"f52cf4d3a2a0eca72fcb32b2f58e952",
"02def440e968d17d9904c5640619af2f447f74b7c067537db4a15be87df4fe68f4489704"
"7fa8af146462ceed4beae36d54e1aaa",
"013d5b00fef639c556d66420090c2cab1edc57b7257dc35addd62a5337300e94ea7ee116"
"e06b744da1b575d90da81e8ae2cd424"},
{NID_sect409k1, NID_sha512,
"23757fa60fcabf543e603d8b31ef0cc99b3ed16b4816a84e01dbfc858872fcb79fd03d2f"
"8a1d4f28c25dc42a39e20c34f81ebccda1682ee9bd22fe323e7f8ea90cf4a2a6ebb634cd"
"1153cdc35f7306f28a2efd822bf23131baa1543d0ed5ab4c8168d3199983fbee117085f9"
"0550ec3ffa2b06070d3add1d707fc2593285ff58",
"00db7dcac414010b816236cad584dabeaec1da76c97182d1b62f87bb7fe2946a64d10430"
"571b2b29ccf2ef72c969a9f045f1f3b",
"0401f2a6cbb9c1fabc8db2848c74d918312267888d822b7dfd1634a543dcca4be7c99723"
"9f6281d1d8b5da9adc694706b7b19cfb0c01bde57a2ac15f4e6b26a373a624588a3379c8"
"eec758f3c68695e2eb1856075d90085f43283d982526c5e57913cca5e2b4169f8f",
"05a3d856ad1d6164993cc59e70f8551e2408da92c7e6cd52df51b37dc22e9ebc42fbe6b8"
"3c332eedffd4086a382056175ad7009",
"0489b0344ae4278a0376dcc64ef9ba8595bc2fd62ad22d42fb431d2863d8ca353cd9e59d"
"e4ac10108fc247d6ee9ef643f6bdb3f",
"06aa27335e15dc910515385764387798cd4a9b4cd6d99d7c42e07fc04e2bfedf8dfaa7bd"
"a396f88253357d3e2545e895d9aa3b8"},
{NID_sect409k1, NID_sha512,
"b976314d2f066f8893307a726f450dcf2cf865c170e90e6908ce9787eec48e1e2119a731"
"b2bec3c12fd4e6282a393774251bcaef91af6ce57c63a8b45bedd72ab862cd169b7c84b8"
"f6a72084ff823a96f2f8eff3483a7ebfabdabf0998377c5a6836d88135cf61c65a0ca7ca"
"57727da68047dc635c17ad13731035fe9a6402af",
"04717efef16e1ae267e155aa1daabafc68515aa391dfeb73c13d01f3132bd22c984228dd"
"dc4dff4c39979e7585acd3f730cfcfa",
"0401526c58a3de46c95cb0527869f7d637f9441cb5504e6a01f339907c6df3d079361a41"
"571cf0a0f11996028a41682dab5decf78601581903be8a19bf8bde1d89bee0d436f061ca"
"1a3ddded4b7793fbc32ff852671103f34e16d469eacdbfa457643d1b18dd1c4107",
"05c846bf61c068b421efc472469ab1ff8d9f34847ae0065ba6f4a000be53727b3fcf97a7"
"80362566e13ebab84b9ed5f0cbbc225",
"00aa138e742ae81eafa820632f31e87bdcfce6b909d85805e46d87d1cdb8b968907470c7"
"ef5806accbf6245628c70d264fdd95d",
"04df507115384327f7b8311dfd1227c19a6124cb9bb5901bed45d8d5ca45db0903f53e7b"
"bf136350e66bf2b4f3d978f8bc546a5"},
{NID_sect571k1, NID_sha224,
"964ad0b5acc1c4db6674e86035139f179a9d5ec711b5bae57d2988456bb136d3aade7ac9"
"ef10813e651ae4b9602308b071d75a934a6c012eb90c5eb9b2947b50fc97b1d36c5bf9eb"
"13a7b06c94212c3dcdab402a563262298defff62b836ead1f78f9d20713710fb48115cc5"
"045ba15140fbb4bdf516e4150d830d02cf30963d",
"19cf4f4d06825499949f9e0b442586fe1bfe3459813a2b92cd8de0f775a4735e02655702"
"ead8e60824180761808d9e816d60bdb0238e1e8039ca7bb63c92e1cf8433ef447e64ead",
"04007b9cb1728cba80367b62872a986e4fc7f90f269453634d9946f79b1fedf42ca67af9"
"3e97ee0601bb3166e85357e8b044e39dcc19e608eaaa8a0066ffc48aa480c0e1e8d5569c"
"bf0580858ab9223c2b2ea58df506d703d64b387a78ef43846894e7a2e47c02252bd2c1e3"
"d21ada7c21d50a08cef0f9a189c4e850c058cc57c37918251b5aaaff2321d7355b6b5556"
"44",
"0726d5e317f888dddc94c73acb14b320ff509908052868f8c6b14e531ca467c1f7c82874"
"76674efd0d636ca94c24a69d15210bb43a368a11d3453d69ca80430cbfb8b6e45d8f21a",
"04ec6205bdd8f7eab414110ed620dd3fbbda4cb3ad9e5559a114ca9344782847621961a3"
"577cbbe43d94eff6ffc8dd7dd09c049239f026a928301ffcddcc910bf196853edc86d31",
"16535b1af98a75b9bc0f122ca3ce23a01800fa33b43584a94fd8a8d6f40077eb739f07c9"
"f0e179a157a28023735fc8da2e2ebbee5f7308925900e657fae7c3b321f14fc45346f89"},
{NID_sect571k1, NID_sha224,
"baddec4794effa668cde267016dda67bc70b847919a9aa595f93ba9dc27354399ef7a607"
"fbead31e57a8ce698beabb10f313d393980425e67cf95be45d512f00e950c0c5409573dd"
"c3d556f23daf056259ee8914e860562a674311452fed780b3e0317a7fe93baa81fb98df3"
"ae4328b28ad0ac8f8ea33efe24faee658ad026f6",
"098521a732e72ed945a549afc92318fef7156ed1d1ed9bab93b581478cb2339eb32bcef7"
"05c9bf61cf2873ddbadff8ff3806740a2e30ce67d1807a8179dfd5d952e6f8a583baf81",
"0401e09410bf4f84d53a2abf8d106fc64e643edefaea263dc98c308aea16ec75f083b3e6"
"b442ab261226c59ca5fa622db68f5cb5f2d1d465b01d0048554b0ccbf67c0aaf934d2365"
"f60361e5b43d313a62c7b3897c7db8a42116127138a1009f0bf9892981fb4fd6ae231b89"
"40e7509f96e2a49285143010dfb4516ff810a91a4d9d2974c522ff343e93e8aad00aaa78"
"b9",
"128056de96666acd09b93c5db7ba1b8fabf57251ec480d42b702940b5847d2a59b04eb51"
"01bb3990c3ae2a41181f19a2afcf08424f8b922a95df6b292b1856dc4a9dbb1c717ba5d",
"163483a7e0d1012695ce0c113ec8fae3694bccd40fc038d4038f81bd39e71c969cc7f0af"
"8313a9fdd3d028ab24a43279569dcba73fd78ad74897964ae715928b1cf7fcb779b12af",
"10aac6929432a6bc7e12ffa86e4d2421e0535fc44a1160fcfbee477c29a987e783a7f753"
"eb2278ce08954c7e90284d2ce7c42de103a9c59d8e4c459b457688ad515cf156cfc56f8"},
{NID_sect571k1, NID_sha224,
"7ef7138fc657492d229054f8a50dcafcfcd1dc06f1c16640af3f658907e2969248b54416"
"066eb119adbfa23b8dc578aef18bba79610b9cc109394b900a25e55a779230bb858b2ddd"
"9499a7775d392328db9177aa9571c2f61dd52010b48502154e914a0c55a54edcc04a6713"
"cf7bda8744a893926118b09df877d1a4f3d95e8c",
"0336fb21549e397a190beac38a1ee10f0551952da15f71e11dfda415e5ee08da2356f114"
"d450c661f52b2b32cfc7b9be61732672691a079f0927989b7e9f4efe6095a242155b641",
"040316800fa2d8f8f3f9aa87ffb628dd7b2f63d4d8389ee86ed41bd4c3eecd3f3836ba92"
"e2ff7ee5626213f9ddb41b43561c5dc0bcc3df0a872e4b8026c09c7b52b89b4975a43f60"
"b00207f956df58f75286232967dc1d3e6507634f45c0014c48b42868fecce5b9434463ab"
"fcd2b3722a7f5ed25607270148466f6ffad6a8c86e538640ece80e84f7368d33c68807fe"
"d6",
"1517b3524b6d43dcf3964f7c35c89bf14dd1542c37606452e2035ff0bd0cd1edd6d7b801"
"ecb1f573e957131c0b3f30d5006f6e4748a11b9db10fad41961f4ae53e848c6dc6e1a52",
"1ffd4865dae7387ed797c5ffe58a929cffeab521e48284bd7d4427d5856e9d2582b91363"
"f1d353a0ab1aabfc132a778a516d4033c64cbc991d724115d72ff8e94ab4f95a9514843",
"10f010aaf1bb714042fb8cf06a9501dfd1ffa598d6b3e68e7addefe00e18f3a5db8414d6"
"25e374d9ae70bea43b57c6be4a590c28e50a548cdb2e30dd9d6e3ed1d9cdada9f8b0049"},
{NID_sect571k1, NID_sha224,
"d58e1ff1d49a471d0567ecf8f29173dab5fe5f6184ab4cdd095c231fa7b82551f99a4829"
"94a46c3d8ebc07297fc9e952a5dee7d5f199b119f6f8b250f8fba45701ac252db725e75c"
"4da27ad77d59a4eac448e54a277986740dfee6596811e59afc9755e53d24b826c09e497e"
"29e69a22bbc85be11763064e9ecad7ae66458ca0",
"0e287ebfd9ba294128cbd484fc5121d271cd33e685bb1804f09b40aaacf64b5a9f2cde9b"
"30a4a02d3a9bda97d92f46bb8787b3c61f280b1e1a0680f1f0679d3bb34d53725d62e52",
"04052903a7afc17cce078b4b658766a67f2f75ac04e296757fd762fc05d6a7b4e4151598"
"a872eb4618efcd06c43cdc3e54f437c0ef1b091ab5e4927d3ab4227fb24d4413e0327abb"
"840385e808bee8dad1a1b84d644aa29fec324dac2242709421479fa7a712d18b54db5977"
"8724ccaf4e51a27da090c6dd0b7967024db0a8684944b77295c9624ce3aba24ff48c86ac"
"85",
"15e8cb22e371965801d99407d96200015ba58fd7eaea52c03269d8a374fc7aef17fbfd44"
"80d29b781292e179936a68ed175802f34043018ed1d6b5a4df667d859cd2ae53ed3cfcf",
"0d3a57af73b7504ef18c03ed2c52aefe1d1a3f0e27f78c11d45e9825647d5ff6e97af51a"
"5e366e52e01e5e832e4264a1d5b6967cd9debda59c955568e4c8bf804d843a49a0c5401",
"064fd7ecf4470f07b4df3b3046041e49f310a463210571606f00a1915c5220a27bb7a28c"
"d0bcdbe374651aac06d4d9e017e31879b7819301eabfe3a7afe4b53f75ccc465815b4cb"},
{NID_sect571k1, NID_sha224,
"4949ba765c14c31f68ee0ca26bb42ba2edee63537de4a6f5c42bbd862c21288d6ff48145"
"260365193c6fd2b56dfb014da26b8a483776b717c6874f627c9a622154b824565b23e178"
"240f53ee9748c45759ba5c035b584df0f09504e95eb9bce0301653aadb860bb25e6ea6b9"
"606e0ec3bdb8089e6aa0d5763d331757490715f9",
"149de496fa8f88b2741864d0c35b3df666b87179b7bd06cd426a45f13bc87ea9f50dea85"
"e1fd02a532630e0e3a231cc3e7fbb7c7ba85b40cff1124e72c677c6a3ea6aa40ffc64b7",
"0400bb610e4308e229e4b4ddddff5c4633ef2ab40bf74514433bd068c7d59a6260ac7936"
"6dcdc039d5585e660a4cbee990a2cb55a99ea3d26dd9df856b0f3ee5b968bcc349240a9a"
"2d03e3ef4be63fde6ca09f12f8220e1d9b5016f267ca5aa09a2dca8a0e0feda9647fe0e1"
"f7ecae7147a10ff893f69a4f74172c6e9a62f0c5bd96d49b47379c9c84f5ef8e59dea104"
"bb",
"1cffdb963c2c8b8609809e998075299776b44d2808df509773f310124b5f318d7431f1ef"
"8b38fac5cd5580348abc41e6e6396767f4780656361dc9a71dcc8e7c9239d6eec5cdb94",
"0982b9989c92e1a5d25dce832bd8a3f602f0eaea69abcfda285cb3841fe3f019503e6faf"
"8a693712380a48a6af8844b6bd718f0edf3b57662a4fe82ee28d036ecc4cfc7310871c0",
"1678bec58d69def3fe35a64810b27fd06bc29d165593990f6f42c4c7676fd5d4a965fc92"
"cf20ab8616c7ac7b4b308ce6290c5e8b4edf6859fd6f6f01878f2601e22acaeb5ce1f36"},
{NID_sect571k1, NID_sha224,
"5bc63e5c50b1650f0ed4a599960f1e4e11f6c151b2123fd71d9e3c44662312a74b685429"
"0628e20b30eaba81555acb2fb49b640bdab2528619c7fcad0f2a2880c7ea232d427d7c93"
"5fba2313370fda8863a7e7e203d63ea15d0cfa083e716ce6068c63fa616ddc225c9e413e"
"694cdf6b355cb1293af5d6cdea51168f5634e878",
"17605d7c5873d870462375d741b4bc6375f3d47f7f5e9d998917adf2137a81e63b66917b"
"3dda8968930c4b850f2270eb3187fc756e2beeaa67fe0d73053e6cc0ff0004a21250551",
"0400d8ac3e76c25cdf4902426569763f4ae0638ebb1fbcee6e12a4e0b89d6d451cf420d1"
"0441a0a9984710dcac13bfd7ba70370afdfb58e2d982ac367e178f6834b4cd2d232e7f24"
"6e012b5fd5b686e58df08b695fc333937eafad6006be5a7bfb1426206102a79bc32fd9ef"
"46e19869448fed0e917fe059b76c8b5a9c403c3921ad07e6c19ca7bbfeff5491b22f8bb9"
"61",
"09179b3ea906137dcdbb97b27f3690bbe3bc4f1f57c46ed60b8503cae97602717a0724e0"
"55a5c52199ae3f08f1586b87fbbe514667d2eef2fe44092f3c916976c7b71eed67e8fb5",
"05b28342703c83ec2df898458fea6f71030e4e9c567d140ab09cc95df29ccfe199837cd5"
"8ed00d07241988bf3c863504d065ebbeb8ed11cdcb02da0a945ff38ca58d629f76832f1",
"01442a5606791569749b5a9f20ba8eaaedd1a2ceaab2ef55d5d41271ba23f6a5b6a33c76"
"763fc99b291b07283122596a3331fcc9ac038447f3e0cb54872c140300fea65d7809191"},
{NID_sect571k1, NID_sha224,
"610f6633718e49d232b3798654095e2efa0de11f41258b27aa01956480c870d901efa77e"
"109d5f95f1f5101d3c90fc51312d9b3019d2e42e0067eed7b457dc7fbe5466923b62c83d"
"7347e4dada571b57813bb9c21d5e308519b8eedb7a7706508ad04aa69698e03636eb30fd"
"9fb363ef3a185756494ee01175b16847f5b68076",
"09214dc2da0967912c31995cb8f5bcf4bfa832c5a2d3610f3a9857e5eee7c77100d599d9"
"ed003b4106013155dffd6c48859b846e45e0ddbc5fe24f4891c9b2df51407e9cddbd974",
"04064376a92c1227c1c479260c7497147760c103bfa5be95ca1593f29a851daf2e5c3a5c"
"73c1fe3e6e2506fcea710254ab5eb2daf8aaefc19cbce7b1c4afbaa2fcda1ef85750fc0a"
"3e070638482e5c7c17a82980b863cde11294c0df717bfa4b9f884cbbbbf80a64dd2cc7c7"
"d89ed21e10561260d372da2fb726de71863f0f60e8ad0fa5e74fb5d29bae0cbe8ad6b32f"
"6b",
"0621176102c6ebc2c810eabab9f60feb71083c07751c66f719370713ec2de9ee3957bba8"
"d768b076885db1f226a9d37588abf1b141d81b70f0af711c52edd30e92e34a1d3ed214f",
"1a21d460ae85d0703b4b10a2f77547e45135048ffea590ce86e0a1c049f8a4aa7b395f72"
"3b7480cc84e33f4772df8f181f3919f3c0b0b4f276b0f855174103a2f7bd757584425cf",
"0b56bbdf6e2be1b9e754f9b48b3ba9a13403c17c5cfcc4910112704aceea9a34209df406"
"ee40e0a10cbc26d03839f95e775e80ec5e29b156fa277a5ac68abd99c7005ea6ba2695b"},
{NID_sect571k1, NID_sha224,
"c548f0546cee0c0400401cd540a0aa9377f27ac64492e6baaf38e794db4df83e64ca3d83"
"b67bbb46a6c269c04c2725287cce0dee984a0d468c9ce495a7e554a6835d72c7493bfe88"
"dbd5a044a148c89001b8087fb03e57c2b7212d0b175d616333a9affd8a1802dd49ba9be3"
"ab6c6d9f99a5578d26cc4707a5860c6c804d69ce",
"042f2682e9ac8b76f3c0880e12c292524601dce9ea6982dcf68bfdb0d3fbfb50dc9229e5"
"4149ef09b95bbf624eb04ce1427077f30d8536be9f69970ddb449ca22ab8368d2689ed4",
"040116135b273ef876453b9c4c39e4be5a815874857f4a72602f0d03b4ecd9a4ad73b906"
"00c71111e317df0782fc92e6ce2b194c204340bc11e68cc22ced38e99f90dbaf0f917e97"
"0d036dfa65a6e9d0ba521ade7daa2f6b01e1d14fbe7b5abd29ae71c4eff66c390914bf46"
"f09f4ab8a06dc0fad6fa257a85f993d6829b5e0add5086b8fe2ecb8027d08eec1bea981c"
"c4",
"0bf116711b31ca347d41a6cee5aa13a74e042ffbf79d2ae9448598e6950d721b3773ae6f"
"25d7b49ca9dbcd62feb011d5d556bb9f8a55a7acc9a3a166a4169351bc31a293db68eed",
"11dcb7f4103e814439df22764f776a74aa86ce9717585712b224803f0ff193d5f541d941"
"42812c726b75e8c2c37f2a4c33db6af118af73d3ec4fda49cfc911fef1eda9a470ff200",
"15fa4ada3a6e95164aa8972f14ab7572a3b898feb6cde160b8f25094f67343d35e6efdfa"
"b18793f77e09e5a42f56bae747b2b66fa9fe1e4a97e5e05ca743c058b1024cc848393b8"},
{NID_sect571k1, NID_sha224,
"9431c6c5237f6b4b35682a0c32f68752035c8b295a1763c5dbdfd73466cea64a00ecc113"
"56d02d2a9211dc54548f5db1651e4471898402c887fbf45005a3bda271df0158c98319d4"
"d6751b8ca6b07100182957d5fe0d97c4e2294406f83e9afcae4850bb089f2252490417b5"
"afd8f07f4c795fa84c9c7cdcce26bd97273c0072",
"17ed9a9c75cf66528428e85b0f019e3488af8b893b12023ff1b4ca9c3691b74e594539af"
"a0f4d7c3863d15399b862f15e27bb077392d6bbd546ddfd46728c75177338466eb2f4ff",
"040760779389124c702686d8d7c25dccfa74fb333317bdb414965d2c271ca5e687c4cca5"
"7e6f6149e1714551761abd4d651e7b04451d8be8e58c0c9e361fe0c6771e3d547d6ac3e8"
"cd052d5725d14b9aef93b83d638377f5a19e3cd6e3584121fdfc2c3ba1a588491d7e9892"
"be081c9e7585a15b37a9cd4c204054dadf06a9f4ebe98f95f6554941982faf109c2af98c"
"65",
"104ba3049a642d9b49c4302e9173a9efaf215b67e060c5e9673521641c9c2a5b14bad25a"
"448e46faf73810979a3a50104ec8c5230a909ae588213161fbc10381d7c75b35c84046e",
"1bf3e89fb0beb1ab854a5513278dbd8b9c6b05c94ab67145ceb1ffcd93d1a2aa374db46e"
"f327043518a7f272b957dbbf9d6cbd6708f4c89f05865932b7e816b12a59647d972f6e5",
"13a8c121c9c170b244ae3a55aa2d53f4ae5af91b1f72c066207e3f52e44723bd4ae419d2"
"4821b83648cd64fa70536605912a5a9319dc446a6b2b639cb99ed2485271acafc2bc988"},
{NID_sect571k1, NID_sha224,
"417cd5f60416f17081d2c70e9a510114e08be83573bf9deae75fbc3095dffc8a7f7325f6"
"1f9d6565381710eda871388cb17619e4448836076338ee309a2bba5f737319002e259b4a"
"875cce1bb97996101c9a7abe0278dcac203a712f0809eb3c4b85a9c380550ab0bbc5067a"
"8edfa78abf03c09b5c08f21714e1022ebfcada4a",
"1bcc09b3f2f1d26ab9955bff7e8c0f85c8a61293511a196b53d7963f4a4503849c96fb4d"
"aa68c9852ad9185e01a35f0bf298e34a09ec352cb6da34f89a1f23e8ea27712a8f43aa7",
"0401326341764a4aea222e7413a4a6f7bdc0c35ba246e3c68728ce06bdb19f2e1b9102ad"
"d88a8511130ff48c0cbe4012ab52de93329670a319f6b1e7e7dbf177667d4a98d3891ec1"
"4707a4aaa73713bf8fb3907d49e5653cf82a9587518c2f8269cd1e556a3be3589dad4c23"
"8e4c80681e141be93c318f0efddee3e378cd46512d778b9033dc8706bb843a3c3546e76e"
"4a",
"13412a98a2c14a9672ecd42db9c079a689b147ad91869c3d45a7046aa9dfd3f31edb43ce"
"6b84e9edcd7e3ac6b96d89f13878cf5befb052a6f8a4e5577bdf916adb10d908d5e99b0",
"11c8a92044a30be397007a71d9af3e4222556a10f3a07a1521c1bcef73b4ddb94fefdebb"
"a5944d5bd91313560718a8f520bb5cd5666539756a5e9b66a1b2d18fde5ae72e61d584c",
"1ea510e23ccc7596db529dfbea78c99fc78ae53da32ad7c7bdb1df01039310988ea60182"
"8fdfc59a0cd237110cfee9de8711c073be44dd4d04bca4b1cbec278b1a9ef175d93f70e"},
{NID_sect571k1, NID_sha224,
"eced8c412a153a643ccd69596389f83b6a36880286f8aeede503452bef8305942d95734f"
"b5733f37ffeceb1c2dae7b1396c3323de11089082745c28a1756f784423fa7ad68bbfbf0"
"d93ff8b7ad62220500df6d6895788402c1f5c69c06dd9ef55e2401cf297184e411be87c1"
"bba657f847208c0e750f94a3df92f253b377b4da",
"0ec52fc3d9c272ca80623e06b15c35f349b13548ef7ee400bbfa04196850b3b8cc7b2392"
"38c827f9b0a3160cd97969ce21d66752791f5896e0385b0527d4d77e4b9fc70f04d73b2",
"0405cd2e63dcd48fc793c18776d030398dfe3f8b6978eec6d23f49240581fe1e141f6674"
"98421f4c40a9430587fa282441a78bb641894cb79d929c299f1aede218a0078c247f7402"
"5200cd2843ca87d98f6336c0adb97bbb9c5293a03e5b86d5534e2849ebbd73dff837ffa4"
"88fad7d134908234d0d7fdac8c7fafb4729ecf0516c42995fc9337f60db2f36eeac69a4e"
"42",
"1c40a15fca0c959852afcb4ca6cbcc99fb680950c64ba18ae5388bf783052b6ef3730b1f"
"b1487189ad983b6a68bcfbb707466092da52ea8893d8bc4898eb133fd771e78379b9c13",
"14485cb1caf1527350587d6695ee3df2b21c13084df0c093ca5109d7c192e7e5df2232ed"
"e11dbe5ff2f46b13dc2dedb709a0fc1641c1f32857040147599d8f179fea6b2f2417646",
"1a16ebf12c11d2d0a64b7ea124623ffdfe2650fc9603ded571e76dbd7e3b27cd32fcb709"
"e2ba04aee0e8e1b942a4e829cd0c9683aee67eec27d4244a2cefc36f84f7de209e22a62"},
{NID_sect571k1, NID_sha224,
"30e83ea39a92036e22b7bed7639eab5e5be1d00c20b4a9b9afa9a0d1653369cbef363c11"
"9cc6f921c8f84663949c8b8dc9b743ac2b1861a480476e9b64c8f333f34b6fa0e1ddf09d"
"49618ee4f3c1f46751b5595f0aea413d4ca46f3c26b974b112cbe99c813a96a4423764c0"
"69454946f213c5f066ec38108f947abeeeb02fb8",
"06403de7627de22d1dcf6b8da5af62f9ec59ec065cc1ca1311bb98aa439a6d5985619b17"
"c17a70f59e17cf180ea6828ef57f5f1f8ef05680a9fc12ab7faad5af61e4e11fb45d341",
"0405575c329d73f261ab6897153d7261f87e9730eb5dad49c05d782cb02e483fac4a9ddf"
"f31d2fb695a62cdc44edef6398be8f4f84aea1d63d0b3a771fe91889dfac4780063d2583"
"250183e63ee783abbd00547567bb99e9b578ad8ce63d229db41c6877534487568c423d4c"
"389154af9627708d8d8f863597bc668e88f9412b21a6696d07bba06fe7aef93b26950c69"
"ed",
"0e751a4918643ba3e68bd9406a4386e876d0d66342aefb4ef75bc4dcb8cb2e2d9f8378bd"
"02c388c776535ba85d24b206f5bef4b2f23a1c99fe2f2e8ea201009ca468e5b2e21dcda",
"0ad6792fdff4c621219549834cf03808645171d944088f5a6d3cf1bd826b5588544a32f2"
"31e8428a03ec02d6c1c1243fb6b79b1cc6d732be5be8f2cedf03c1e5588822eec559b7c",
"178b64bc5f9fcedab17822e831fa52d49ed10afef1c5912893df4bd8dc960b474ed25883"
"ddc343341b696fdebd06e177f234ea45553cc83920a8c799ada2deccf1ddf1dd9aed863"},
{NID_sect571k1, NID_sha224,
"3ed244dc16a5cb292db4b1433b0ca3226913f07377faa20c6c1402cb4d026de808ca74a6"
"d4ecdd7c4e662105bff6edb9fae0117c50aa053aef677c0750c7a446edbb879110030758"
"912e8fa666489d702d8fceb719963b24a256429bbcc869a1f4ab9de9db89263e3684d4da"
"a1df2ed94bb59dde2abba63793e5f82aa2e4db83",
"01fb980aef64254aeb9bb613ff2fc6967503db4bc1f337882f1566cbeb57489cf32e34f3"
"10549f41cba1b951f487453c29753a184e33330e90d4b973d2e406c99a239a5c3f96233",
"04036ea761ccc71ba55aeab229aaf874a7c2d1ec15d821401e2988dccf02798c4e7bea80"
"d9fb8d30be213fc80475a17f45d60c53249b66858d29c73e73117162934dd71096d74674"
"2e049bc28f4d45d29c3560915698d03271028f56c29f0ead0608cb72dd0b62490f95bbd6"
"7145a6c0adff0d6ef396b4deea6a5e2a33f242bf17e907b136c039c127d6012c88b76aab"
"3d",
"0ed404ee6b59ffc445b16f11b9b1471249443f8a7309ad8a662b7cb44c94866828c906fd"
"64784c699cd29d3d972e5db3d42157452630f14536eca23cbbdd1d37e199e5a586fc352",
"1056938496df511d745f2cb88acad279ec2d58bb36498fcd8139d426d596de6d145b765a"
"5b3e8366845fceae91d14075356a32515134e577937ce2af7e732b4e89a9164d083adaa",
"0d5156c776f2184babd69c1f200b8bd94289d45a2f8b7cd8e8afb1455e8901d8c3ed14b7"
"a23b0976b85a22b86f3ccff4ae91e286f696f39646188b675895684f33f0368098fa7ca"},
{NID_sect571k1, NID_sha224,
"40343935d9423ad30f3fb1832bb08a5d20ddb3a55b59057cd275320db4a5835471c96cfb"
"7d67f41ef860cf5879897b8dcf307bd1a52a6226847b768ea38ff1858f59e64cd635b51e"
"6863773cc6c64b363ec47ca39266422406264668415c189e2f92447ac4c63ee5d74e95d1"
"e6af05016917ad237f482ea0b02aecadd370a8bb",
"1d96dc09dfaf602789c1dffa5c9ba130832badcf180429660daadf4cf1be5cca92fe9713"
"173861670eebfe3a0ba25bcc76aecac60a756f07b69687e05c7e25984a39556469f62b4",
"040452b1cd70e3c88bec1fd0e4b8f8e9bd5f844ffc12f3d6769eeb1c9ea90e5996199086"
"82eb5e43b1d6eea63ba9353fb64b59d6549d19cd95f2f54156c81fba53aa0dc91244e7ab"
"8b020926ca366dc657d133f0ff9149738738ce68f3cc2f61dad590e2502e8fea714b8954"
"3f43d97b46b7075c58375efa379cde208ce769a16be9a377a111a8ac51459840a223f346"
"95",
"1dfd064dbe64c25a832faea1819cd836d22583fc40b2ecbc19b1f5173c25f33ca8cb7f30"
"bcd619ef73a4c14c46e610c8996059612728f508bf7db7ab3191ad61955e8b1ba409692",
"03cbb0ae5f7c0978ad8c10c4ff099767465ed6fefb7358f3eb58a79366707107cc88b305"
"661526f2972bd16923375dd898ae72e81f290b86cf9a4dec086d7ef04d7a7bba5087f8e",
"09f77a86f0da4e35c395978603cbb9c4dcccf126b7cc924cf62732593bb1aff0dabb6d58"
"321debad4410dbfa1fb8fe249bfc336db7669e4ee13485ccf8dbde01ca4cdb9acfe5e74"},
{NID_sect571k1, NID_sha224,
"274567f8841183e68c4f6c6b36c5a52fb0e88492e4076b9cd768bf571facf39dad6affeb"
"68941ee326ee461ce1f33c26e4bfb3c9e0cae8241fbcc14cc69c1af68701fd0be3def1e8"
"7b7d52b682ebbe1cc225c1bd177b0886e3698a06d0e410a1f92c9bdf7239189f6acde0d0"
"653815a72987671b415d1e8a70e685d6e5b14c33",
"09d98b32c8eacd135ffb8e13223690ef02c0c1f29ea8b4da193502c8cb3f39f9eed608c0"
"2fd457f2fb685ec4595e8fc8f388d26778d225d2b18c9bc8b199d8b65c0d1a6af33854a",
"040775560724ab7d98407e20af12b03634a757037f8b3854957e11900d58460ca20d93ef"
"06436921f8d4481ff9123a9eff3973e17d441511df3cd88d0d6dfc8016d2cbfb89633784"
"6303082aa4a81d4e6f0ffc94511327202f2baed72c08026e05a288eaaeaa36a1a4961f40"
"0b4712ce68778ff38be43adc2222a986ef0fecde62f861575842429816c8fc77797af018"
"c6",
"1f4acd3430931ecba5e9d986c6712467526ed94a0bfff36135da3ba7dd9870ceb38fa0b6"
"58dd391ce658774c6725360dc20e5ef41daa9cf52fa863840ca91053e7287ed29ac69f5",
"0502abe544fc3262663524cf88a5bc256b20829b7bed3e2779f559506adce3c4f3a89e18"
"bfd31819f78ae3809d9d0710c6591b2fc90039328678aed9df2fae38a74b66f69295d82",
"0b2f055248d9633cafa4db3b3cef0b76ee02f6bda3d508e19c68870e76a02c69dd1013a0"
"3fd741e854cb34f815432bf48138203177141be7209e957f4db1a958fcd45421a213c98"},
{NID_sect571k1, NID_sha256,
"d9c99b8da92d3c2e40dea3c4025dc37770e867c4d2746c4d726b6de24250591a586c166c"
"88acb8ed340e161d4c81b9d14c919a1b06f1feb22c5ce5fca2693bdaf4994ac72c8983c8"
"7f331473fd094eccb3d5f3528e69d487562fb5a65c150a8217192f8aabfa7adcfd0b6916"
"d5000248fbbddf1ca2f38e3d9ed2b388998b7cfc",
"04d873ac744c4f68bb044783ad69e1a733cb8b8f483f2695bbd90c4211282036ad7914a5"
"3b25c3e890c6824643cffbdc4138d7ff457e3fbb99387494eb5cf2bdf1ad243a3a1e644",
"0404644456a4e5c543af7a086640fa9ff6627c2d9f17066d255c3e805db31fb1ba895682"
"e94f6ab96d6ca449b0c3f76bfd6593d182f422689b31d9dc3bc0b70df210a96d19af9ec2"
"ac01d38f8572a06ce22c1586a8329f9421414b334352f1e8b961f7e0732ee01e838eb975"
"bfb2f62132bbfd9acc6ef8899b4fd388c2b59e564fc3670da7a008ca016de678d6dded13"
"7c",
"0b050aa7266201a42dbee063ae2a21398ee1d2a190de9fbbce2468836e416b3ec18d7340"
"c81fd2a5283713f9aba33e8cbb105eaa2abbf0b687fe2713921bcbc02a4b77df21f762f",
"08351115714bc8f29b84a6e3f0a23bdc219d4271a9ee18bdab54c3acc9cb3468beb1f89b"
"0f981da5aa7d7ec7ad451bc5e91bc98440fe20f5877a4e73614820b9ab6f2bad3e2e609",
"0c64baaeed68178f5a1d8f095b0932fb73f9a02462df5e8378746ecf17d05971a0a287d5"
"a8e0317db055b02d4f4b5864597d0f9a9cb1ae68577dcaf7db09c55bf3d3575197295c9"},
{NID_sect571k1, NID_sha256,
"d2b88a01fa17703c99e5b867c645e98feec0d6d1afaa20a97b5fce9c23f0594460142af4"
"e36a5739b8d26d3ba35a0263caa5429b4abba157f359fce701c43372500fd2ae1bc2ed80"
"bfcaf8cab7016ff93d4a27f565b7e67fe7dde22bf02c48be12114fbff2421517c825019c"
"0ccc72d927bef156140d7f0e9b6ee37af78c3efa",
"18d2eb947297a054f8a789771dd875b12b26ef057fb91235dff3b062916f85aab3365609"
"bd2a38a861439c8514e33f174c198139354e63766942f605107cb1b9709b782622b295a",
"0403f6454f1dd032a925c6bc3e1c62892c1dfaa700d3badf83f07c1185c31ea817641865"
"a129572f3351340fec331f5ed466db7bea3ffa9723c951b518ce6f3c9263a7bd6866c8b0"
"b40188877b68c10cd6ee543cc5638bf0f82db25b9327b2d81269dc61250eecb976d6568a"
"9df29277836b97973e3615e0a4345e610b33909c2340a23c61dcc6e2baf2bc363a333818"
"02",
"0ec6af799d92ab52c51cebda61ab642d4876f374edb17253a1de3e880048355e58367096"
"d3bc0402e4b93fa6a6c8d55c529b9fd68a27962c19274393ebe1bd0b1197a28125275bf",
"095c42b3ef01c0f9ab96693526e903ef3ccf0d843776089d15e77093fa9d010872d65cee"
"1801f821bcce747ddc5875eaa462b00424e6cdf0995b87c6cf33c37d4463848a6ad7fee",
"0c4f0edd4b2dff4f9fd1fea5addef6d483bb51c27bf5c7aa13f9482243e5ed5571bbe0a6"
"58543c69b731de56b6b34de27795095b3676375cb4686b45d48010fe8c941208cffded3"},
{NID_sect571k1, NID_sha256,
"a704a1428cc894f958774368979fe075353b56790555386e3b043dc6a2919b94a11c7f85"
"883f46b4d47b324d349c28c667bf9a000daaca1d7191f2a0fd97a4867aa9f72422134a69"
"0625408a9ea4b723704690b69152655f9e9dd5fa3dd94814d97dd4f13e85c3f9bca76949"
"1c2461fbd17e28afac00bfa81371d5039013da8c",
"0594fc0b7a5cc0216d2e78eeeb6394c8225de795f4b73bec48b2f4ede185ba622b59a16d"
"d3eedf8cf2c94f2ccd6dcd205f64c97cf1b7f1e34129e94b5129502909f43940dba0746",
"040271cbd3e0d73ac19b975559450d686ed67eeaab4175435b2801e8989966d7c5ba81ee"
"7d749e43dffa12efba820462bdb274a57d04cd7e92c180cdf555686c78aad58444d5f171"
"2907c407b46e93d4c2b12c967cd3e41320ea8535a2ff24372a5791fac9e95865e14d545d"
"d3627dcb4aad2350db248ef49469ff4d59a879a84a19d1c0e5d7ad3db432af927c88aa5d"
"48",
"1e730d50a9747c7c1ce2918fda7575bb81a74757cf9625d0f0619aab7f1eb6954dbaab74"
"9e573290406e599eddd7d3376dcb3fb98c116ed7b65729dd04ece3eab1d7b4bed52326c",
"00d59ebcfb30d7b27c87d56ec2fc9286b04b39e68dc49b395f374e19647bcc58f2fdce1c"
"0dc815cb2aad55cf863a4786efd6c3a0ce56c1d92aa20a19245e74550c17fdaf7a08340",
"134e80d63c9b328e02ebafb75eabf0fafba886f48b25206cca9086e03658ce2047c94a52"
"22a206c6c5a57ddb8f59c5ba1408fc56668066fef4557124c430cbd1267455e0b31a8bb"},
{NID_sect571k1, NID_sha256,
"f8a87c4acadee27a908718461e3b45060ae4ebb009b10a15926460bf219cb7e75dc3a993"
"fb9a741b94e2fd71615c50f6df958568f452b2cc284f0516816bc0d2e2d45f663155660a"
"26326f63f4aa42a6e1cc8462a2ec620a365257ec042f55e4047b62af689592a1a072553f"
"f174dd629a4f51837780ca232cf479a68c1ebdda",
"0f000631106c5851e8ae0802b01e7a8a8540b427a8a3956a1d36f0600be89318032320cc"
"420931d825cc964e823745c60aad3437ebc1c91d32004472e9677605fb708e5a71a0d83",
"04034136cc7b8e2dcade5cbb9b3d0e0857c485ee791f862273749b5d3757d072bbeccdd8"
"eb81c67fa6927c1aa54d823193c370fc596d0d903214d7967b905292f4b96549b3dbc9b4"
"7d056f69b42b29ea82b9f2fc377e874b58ee785010bb7f5814907fb5531789606810b716"
"13a36035cd257864e414fe0e6ea353f398745df87ccf25b3a25cce1c78f61f5039d66241"
"e6",
"009781f5d960870a289cc20f6b1af56602e5e12d9a7353e81b89a90b0a9675686f155111"
"57d9fb70b82e8b2e25534f8ad22e14ed518e62a88f1ae21c56d4ab7763808851762d3ec",
"0f3eba5ddbb8c127419fe5e8cc1aae2239bfbcd2ab43a006020b96c9e7db832fb09e0bc8"
"87aaf24848491d4de935b78141f426875f7dcf2937748afb303ec5eebd01b6a82a8c4df",
"17acc35bd81cf24f983072585ee1e096459b408da909fd82b5ea86b77154ecfbffa7fe97"
"271f50b67ca3c29ce704b28186b831300db0aa0dd6147d2d160e4aff14348ba76e6f711"},
{NID_sect571k1, NID_sha256,
"10b5438294a77c7e517ecfe8f8cd58d75297b14116aa93e574996ec4acb21837e6297cc0"
"e7e7b5861e862062f192f2206a01b1caf42c6d7181d02c7d62b76c2881f8479449b02d32"
"c6f792714d8f70f0c75e81c7d9abb996be87f5ad9a01fe42b75855558d5f00df392b62ae"
"0d258f3f67dbeaf07208952e679a2c573aca941b",
"1023997206341c6147c536d034a9c38b4012035dc2c9b7ef0bb9cfe65e7d788296f055d5"
"08a1fd957b2dc7f9eb10c27790f15f30d81670945e54a508c57b70b46b4a09f4c769289",
"04066bd3f503cf42a20cea4a55cab75940907f38fac7fb024c55245f02d72d80336574a7"
"2fb248b1b61e3205b31489ed789ee78d88e487db3f5a1cd48efa1487916b8707e72e4be7"
"e6010b6e4330af0270abeccf0901dad2f8f64f4993ca93a7c5281dfd71c6ec405f9a9bd7"
"8008fd22fef76fb79e20a571df16c4d97244c7356e3ad16cc489d3a9b2e3fdcd5f23b48e"
"26",
"09137bd8436dd126924943e8599c87f64564297117766580e6344aa3c02056c811fb996f"
"264ac4f8f0cb33eaed5ef8f120d43a1d2b3e5e34697765ff9db4b4683ce5c1596d74723",
"03b684a66e92d352847f63196181160db3de7a304b6e43679340eaa9fc828322b5b9c16a"
"1772c981ff0febb474488daf998d4acd867e78019b61804bb675a98cef24fdad088afcb",
"02649a94d2bc243e997bdf27be7d6364459c38845c3bc8d1c8b549ad4689c8a4b4fd5519"
"3ac769b1da607dc96458e2f6abc602bb4048cf6b0933da6785795d04d10f22e439748a8"},
{NID_sect571k1, NID_sha256,
"d83a52d43216fdb16b1b40469863ca8eff4df9fa358deccb5ffd18b3e22a9d654aedc98f"
"3dbdc4f5b4e56b4299e25d8a5a38d01b34eb93de382df1ae4d1c7f966e84b84c393d167a"
"ecc6f1192c4b42cae83748b1ee3d9147ce7de74cebd122695b455e8082f86e3e488fb0f5"
"1b3b7edcd579940d1cb9d045296e5e38f201b7ef",
"11ebf320ecf6a908ea5b868afb8e22246ce84e743e1076d6185ec65dd79043380708bf8d"
"a4ba802c3b93b8d15509bb7d7de9dc29f1e9fb0f0f2cb97a26698f955b1f7ef668122be",
"04038b2760315b0999f9629922bcdff65cfdee4938d4aab8cc3d200aa9c1db843fcbfeb9"
"da10afbf10280110c49f0c18f15c2aac4f39af35a79557c68eb6cf6afaab973538b98b0a"
"6c07da55796396e919f9b5967608af06bd01e8870354317e76bcb8597a379129e35bcb69"
"bbf6b38911a03c3076f7fbbe9b179e078b442c604519e330282f6f6c21aba515d6d73c02"
"57",
"1c219274e54a4c5e1e1aee3bf805a7002bbfe1c030cd4c8a1617dcea2a14b1d537a64cb0"
"7c5a1385edd76f3e4ea9a38e38b458d2c7bf8eb56a57fd33166bf59a8af2e9639106929",
"08677167a7ea1aec4de76d1c5effdb5a1655965850bd6498aaa4fb3fa50f213fa4d99caf"
"4145b4ba87e34797babfe614dce6ac21d9c13dd0fcd9802b1414aa92dfa18318c7e57eb",
"048d6161a3739fbb3ee1c223bc82a46255d10a86a605f6c8e1934b13f1a8662f30f8e95f"
"53848119c61f08037ee5a2440c8faa11a6b1800078ed476b2a3f4cfdb25367c8dc2989f"},
{NID_sect571k1, NID_sha256,
"eddf5553ed4db6e8ce72cbcb59fb1eb80671c884ebd68e24bd7abe98bb1f40806de646f4"
"d509be50a3fabfa85c5630905ce81abfad8a55f4cd80208afffb9056bc67d9dd7f4660a5"
"f924af2a3745eec2daec39a3fe36131fe9eea444b92d31f6a125f12125159ba095f89968"
"a7028549466f41ad45668a861f671050d2a6f343",
"0746d5c824d78f42a1fd63d8fcca61f154ba3e75788b7a0b87f53e5420e23a935b02eaf6"
"7bace8dd8a8e7c1caee30154c2428e0a437cf12e235f41c416f92fb54528865fd4766d1",
"04063645fd3810e2458d15b43287f329c354b07324c0707f19847c544f129e4de1799996"
"f805fab7dd356567970e10eb21d875e8ee7bbce56c666511f9b4a4cca986683e937d6f0b"
"3e0595485c9a7f2a97fa7f8453df13b75682931fae10f3441042199fedba91a58c105df5"
"7b83d2a3911a2d34a2d41e451d0d2549b0a0a65b42aca40aaa618c252baec171da7937d8"
"12",
"0674788e75eb9d5ceaadad9fae036f129178fde1a584d73cf284acae3b4cbcc208ae7a5d"
"35aa473f4e1201c19ee5bbe685ff9218a8e2188f3428ab45bf09b6b600fcf81fadd8d69",
"060d6dc42329687012a93ffc5b846b4dce3df46ad12eb61437832f81f4fcdea7392582fd"
"75e701e106e5b83521759da6a22a21addb63b73783592d3f29347f3d484e05c19db148e",
"197f3b2d4f3e10425f4cb60dd1ae84fd8c87f62a2cc822342d5f0be4f0841623227c5cb0"
"f8bf83fef483a061e30ecac86cea0210036083a99fa1247b49e19a7f401a815cb68ab3b"},
{NID_sect571k1, NID_sha256,
"3db94335f6d1a125309622c0a9d71bde1da09371f0285a93bd0aac255fa8f10a56074e0f"
"6057f1b1aecf2d86a2319590ead96a2ad1336fe844e09339b456be32374ba2e659fbe9d0"
"f2cdd83444d117d2ce3204ce4b4294dd05405634b84747ffb4227160c4e5c2c9da9815b0"
"c6d20f55705f16cdbaa13d107ae666d707ccbe6c",
"00670e72ac2de50dd2cdd975a6cdab10ac45e37ef7a28c685d77447051496b5e161f8b1b"
"93f6c7f32fce8ea05e94ed35fd7cb28c44bf51ea29cbaf5aaa31d6abca30a89430323dc",
"04054db4acd0815aa7ebec4f7661d80465c64f1fd4147507549352bc07dfcc6041ad309b"
"fb1434b60f73b3d61ebde91f849004d55257e98b6ebbbeeabe960f9429a55a36ff75c112"
"4e05b6f36f76b3b3c780b6a70bb8ea150e9cd6895ff6a6765a3516acbb4f5efa91434def"
"52dd0ab81f618ff28db10fcf39264be8e7ea76e06516335ac5ae33ba5393080f11418911"
"0c",
"0f74a0ec1a7496043d78891e308c82b4660606642ea669e4406683d44b79dd6e6a1b8102"
"92bcd6a9f59bcc2e590518bdf2e9224755654026d85cf2a3d9768d909278448f0d63fe3",
"047d808febc1065646e6a5608d62d1445d922084487a64e9ced5fafff2977eb3a7e29984"
"230946e3fc77a766820747122fdbbb9100c591ad7c9dd29d07efa2e8a43357e3c47762d",
"04dd6c8ce75bf2792ef227cd5a3102d30a9a31690ff5c21354f8dac9f826c86ebfaa0465"
"3f0ead103b1c8ea59f0a78f5d4e8eab597ec6c028ebcc57f4ce4103ac14579bd6e15166"},
{NID_sect571k1, NID_sha256,
"69166ba40768d0a3930325405edfd85f3272f7b8e600b0b319f070274c91f9f03d0e6ec4"
"bfc7b4445e91b87cecabfecf5e77c7301ee3c6b0affca2fa02c92216698705eb75443eec"
"c25438db2d2fb4b24f4195d6b9c05c53e0868d3e58477100607ffdc31b18c40b4ad7202b"
"b034e58653daec0f6b33c024d42a3fc84bd8f86b",
"0369a3bb96f884983c23281bcd04e24a3e5f6359f81e3c8e46f3f6b865eb6bdf98a630e9"
"0646275c587e41b546d3ca7688cc207afda15cf9b25cf83bd6ad27908647f3f9de59de7",
"0400eb02f6e741b3f83a9dc50853828b8a6e0861ffc644162515a264730c662ba388ac0d"
"705f8b36f5388894df5c1bbc3582c85de141abb7712caadd2d616da589bdffdd9258808a"
"4105dbf831f450da6f8e503c19a7788c1317ebe556a458e2bfbf3137f986c9c966a14ca9"
"0344be1b76457159c9d70f13af7fe0013cf605010a8a3b84bc0fe187c7d93e4cfb2639de"
"57",
"0ce22f7f2f01355280ba2d2cda06a55771e66f598bf79c65171e08a98f1d954e4beb3ec7"
"7ab06ee60c5fd156a7098023558e3d630641579cc179739bda6d860f8ba1d5ef717ebb2",
"0ae86b40d10ca45c20bdb3db55a6dc12e9b75754679eccb44c40fa57351c23c062282e1d"
"a9e1703176e4b8f7f224982f2474494772a20269c43a18a7a03fd12d8ebb975b83ade0f",
"15ff7b34c3316d9e7ee3d7b48ebf97d98453ca32f3fc67fd08761d93cf34cfa5a2314fd0"
"752d263c3eb7cf842aeac395d41ad3c04c1a9d3808b4fb7489e880d130c35a26b702952"},
{NID_sect571k1, NID_sha256,
"f64cb668b72f1e6dd026a478505c0eb33446ae9a2993bc7648aaed02e172fa9a0e05eeec"
"61e756ba246c1dad7e85d3f01baf734b1905c5bbd1b08d833c2cf1e079eca75b866d705c"
"407eea8618d23ebbaf269c7185984b3bd4117ecfb295ee6b47eecc8d3a78bb96552f6be3"
"14656f91caff793838226662c75cd7804b6bef79",
"026717b039df834855511815d5665ff9b654facab469390ae257b7f0eb4dfe66ea0dc037"
"242ed0c13bf229b8f7ff26da9b55fe4750d3451c62804aad493c179ae45d08ece5af085",
"040191a6d1ab9cdda2d593d5598a966efff829c04c421804c2297e658adc5c9a6092e146"
"b25c730ff7ee65cb9812ac9ea0c18dc6b60deda948b4b7568e8b8e14411a6969d7764652"
"ae03744af98387421d958b26971d21928b73bbf5b0f0ef183e9f606d0348fa715f153a60"
"b6c7991dcefead2ebb875d0c1dbd3665dc42a241c565ea0fb0e6349b4319c3de633883a5"
"16",
"0dcd28cdfe9028a4a6df1d41019bc58e4a1540ca94b717d258f2afe8bec560f3028e15ec"
"1e8bfd422415961516659fa2b006256745e85e488c359e8cbc94cd2592bbb892a19c45e",
"07ba5911415a3d21a3d98b400f61eb63ddda689bfff0c8c3ab83668b1e4bf8a703c853d3"
"585b8bdc29aa2fdc41d5e7534850f4656ec949f0a13fd18295b662c9829723e5a7fe3a1",
"1b027e38283d74c962fe0e7b58dfbf5e21ce1d9c91651bc98284008f44fddfe4cec94419"
"94e690d72a8ff3ba2b538718aa678e7de046b653403f3b7c064ee07c9c3c6d23e1b068f"},
{NID_sect571k1, NID_sha256,
"51ee0b98eb6a3e3c1afcb35a33697c048dbf61374629ac5702a57801fafbea4d6fa5a26c"
"9d1b79d1c58257ac0106387fab2d4a1b7f8c0dadcbe7c830613531b3c209bc17f792bdba"
"1c1fae1b7528aac53dc86c2094b40194577325c05d2258303a2d17c854e7449489c43991"
"b6877a50692a6340a528a6b188440ac0cddd4c4b",
"1d642f2d393ed4abea37173e4a79534af87adf534ead4a0a1c46fb047619221e3577e6b8"
"bcc776114d01159c736ab78af3e53feac339d7afe58be8e7a8ed290f1dad960f1b5de94",
"04023d1ea50229b70b46578df6904fd528e9930985426eb2f1ce10eecbc0c16583959483"
"80c4047d67bc4072be2a2624d62a301da41a5265f040642d1937fbbb7cbd205e1db85b86"
"850625c82ccff6047b1ef4b08f1913f7366c4f6c0312c21e5ab01b598d1a9618cf5c22cd"
"dc64a4732b477dd5c06e332b846c8015a2e5a195326bca46c29cedcc2f24d37ebdb7c2ea"
"ee",
"0c9066831d61a4192ad9de23efcaf578a5d5774960a2b3e3e292e0decaef62d1701b86ec"
"6183d8e17a699d418ef9d084b982c97a55bd76c8b038ac5c639451096ca4d331f070ad8",
"005778acb38b1961195d38463abd9c19d9e07dcd997f19676633fa3c44caa44ad1a9bd63"
"435f3138ad8f22a731e749a81161c5448eb462fcbcd69ec2255cc2923ac697ed319316c",
"1a1aa90113952608dd17dbf391ed56231ecfa7d649f3274774ed2b6034a2207c05c6d8b6"
"cec480ae27b58495a50b1e5b74a17ce6cf2e43aa273c2b813c0e6c79976882b7e4b1c93"},
{NID_sect571k1, NID_sha256,
"feee50aeacaccb6b1c3d95c6524044edb78322ee836d8159c4a4c2cc6982480567c4c6cc"
"4806a564876622266e1ebd45f2f4be851b79da025bd57d0e6acce1ec1c8c255eb89713a1"
"e4897d4ee0f7a248b9d4bd3ad5dc0e57f60ebfb65691e164bc908956a019083e923cfd33"
"dcf37c735af3462768a1e14a8051d7aee74d5228",
"08cb70be29e83f697a3e2f67d86f1c1ec9a163b5335cb4a06004b6634948bf60b8ad9df9"
"b27d2bedc4975265ce44a7884e57082d521320ca4372d38fc77b18d3fa05ad8aa5c43d6",
"0404c042bde9e90b38b48e60551d832a7c80377a81e8c5b010d0e491cf765c432b5edb07"
"71aaa5f672edf3ba108dc71459d245ad60f3884b8cf33f8cf797f36b20e4be39c8389e66"
"b4075f2454c41c0323ee1a640755077d36a65be7c2a014db36719ec217e21a9c004bae5b"
"efb499bf6be67e82d3da70475abf9dfb751c84c409fe838cf1c6ae109d27f24d75c02cc5"
"b3",
"186f16dfdd7a71f20a5e634ffc465356914bb52286d3d5ac00f3ebc02497112fcd592e1e"
"cb2ebbc819e07ea092e465e66f3e58da7a2ddd41c8787f57c135ba4c168539b4743c3a5",
"1c2140d294fafe3d9effb33ce73bb7e5485c93c7aa9d33b7535c7053831a1dbe79075713"
"794c87e52bc887ded969d2dfa6a1e2630cff96760310e04cd2a75be6fa020a12fc84d3b",
"110aa165707b7de1b3a8e05e4502701abb5ade0a27deb04fd93c6eb24ed2b67ade6c49d7"
"8e874d25247e948f704d3c5b925f84c5b07c9b289c4f8507e75d0f8927c6dad6dbce885"},
{NID_sect571k1, NID_sha256,
"b115f7370d6a93a90fd9dfdfb292956be34b61992ce1fa5627c5e928d74bcdeea66d4040"
"c473306a0070fa8363c4303bea32f73ea3639b5c6676fa5a1d68a2cc1f91f00580d7453a"
"23ae70af4cb1f1657aa82c5b305374effe5d67d559e46a6cee6360503d21070506f1af30"
"bb000d2f2f85caa6465810f89968f33abae81cb3",
"1eef463771f9c6285f3257691dea0844687606d4dd00b6020517f190891cc1be97cfad21"
"d147ed8881b5a6e19b22ceeae30e1132476325f2de0e9af2e14c80b8c780a9d2d6c96de",
"04024de3ebe03d2d91b88794a77635aae6743e597410ae10c356a51e3af88fa7f9c4d648"
"c7d1fdb887c8313914ed554eede282b24a2e66aeafcc0cc96907bb2f3877eeb97df491be"
"f301ce1f9fd4d7d3870997f34f54f2ba8f08ac94ea94f74a766f2dbc02e4d5149802e313"
"5a2d762e3b8abb01461968f1e88cfc8c7fda49c099e392e80d57f0c14de9c4fa1eea2573"
"2b",
"026b545702baa340fb6d1bc2bb96f7fb1a77a2428cc122ea380a258c747d4e0625bbf4e3"
"dbc2ca2f15bcfea92f2417cd5d22f2bb5f38a9ba313b3bded506d3e570dcbcb86c2debd",
"091c162d040a12f08a416296a43501d92e2ecd6be302b5e1754b9ec119fb8a572626c509"
"855c7c868a07b263f66070ac986f95e4c83150a5a492d5ea8a7f8ebf556c17ad2bcc996",
"00c217fee7bb202d6399f6b1ae4e5811d9361573ed4fe1b3fe5d474cf06d0236d59dd358"
"0145dc0bc7632c721b6463c69490a67d1be1fae99e34318af6df939f9f7f36a9bb8d5e9"},
{NID_sect571k1, NID_sha256,
"726782eb0d9720daa64e4a77b5d8dd67a1a193f15eb6b5162e3d89c925ba63b7c7e1c4bf"
"c8d6f11915b0e14d16ab53ab015317bd5958b0beb6074199e05181915496575768d026c2"
"3e92e06016598de008c3718aaabcda8b68bebca0a73ecfc7327e8d3646106b7d114dabc4"
"6cfe56265c326ee56fd2ca87abb5bed8f997c735",
"13bd452b0880b101df1aa65724fb60d5d85b37ed5419027481661a3617e0fb37bda1151b"
"9b5b41f908ba832011f7850b75a07b678e5b8cb35c5fc8b94a625e4398cd5ada2b04cc9",
"04031d88b62d2edd5f6ed29258c143bbcb3d29413afd8f86873698a9efb8d2021186415d"
"301599232989a0df5ea91ca222c5781314f200c708de30751feadc277d50e64842dd355b"
"a501c76f19ceb1be48f5540265b8b018da62fc225cc0d2d1675bf7df71456cc8e35b002a"
"220e2e80691600a2c1ae31e980d0cd22b4741c25bfbd413f10b375a4d8adf70a65c48ff0"
"06",
"1b9235221a6df49e39b4cde6650e994f624fcb5084daaa62aef54bc154949f4da9074636"
"c44f50ea40da1a3f01bf67e9b62a725ac0537a4e37ba33fdea8ba8b2286bf82901a933b",
"01dffcb5b5eb23694da4978419110ed2bc7961c571a2e68daebe21e598c8b483b34f3178"
"978708db6d78455cc1fb4f73c5ab7607cbb4f05d4d008c7bbeac88562fdaf7a370ba394",
"057018fc97d7b16d69af2b7dd4a859f09dc178a6025e1bd6839ec7c75c0383c59eee7079"
"fe61aa6bfb3e2c780d4ac0ee074e6b13223c239aa60ea1187ca4937864f89e2c65056b9"},
{NID_sect571k1, NID_sha256,
"1c2418243fcd89c6382b7c3b2a8c341f26d08174a9e9296c4a5c98c5793a0fa48dce51e3"
"0811a96b515aa22bf9af89a43de06d696be1e531c5dece1f69fa6ecb7f20be063c602a16"
"454ddafb14385ae3f8246c3f989d0566e06e7ed1864502896ea19df8393259c4dab3b338"
"0a4a80b4103cbef4f38cb69198b7cf74ce94883b",
"1288141ec2244e4bb3f62daf4ee588aed09ce22be55e3d42e9085a947c1f8cd16533635d"
"170bd64ae0b417346fa4670c25d41387acb2a8e14407a1931d9f7c5358a14eca40974bb",
"0407ccb7b12a7d6997ed2a11eead3278a3f45ea284dfda8e17f6d926ddd6881a44d02a0f"
"7504dadbbcb0cbd6b85c113aa0d3b4efef1ca151cc38cab1aa8360a6d22e3d6fbc0ed980"
"d3031b85dc2d2096bbba6c465629ea09ae3421cacc5581770ce3479070f23b3aa938333c"
"7c691d9cb93a4533b2ce389ae34dbebe8f333cef530abe17cd21448f701608febd42d9bd"
"c0",
"1e411ab53c48cfc1ef9eda97002dc9181a78352de13fbee3bed86cb00c10e7406033fa0e"
"a97b50764b0eb2dc6eb8ea83e47bb3150ecb9437179c124f15fac6ac19b0c8bc324f171",
"14420d78f2f9f1010018848b0442ff6e6203c1dc06a4d523802190f462ed3c11c7aa7678"
"bd03ba27df01cacf4121309551877d3a2bbcfee116c59926daafce55a4e0a7d69c5c938",
"16de0b369c28ffa0bd6ed8802a503929cebb5c0a4bf0c0e99b14659b48aabfd08bcb64bc"
"2e39855d7d514d7525b3c4dfd2244f37019b5f86254cdda599bb144c8fdbaad5525cfad"},
{NID_sect571k1, NID_sha384,
"1de4b642ec7220c64b91561caed7832044d6e811ac909f3b199cceb0d8a7db91bcdc8014"
"12044f5c34b355b95a2c6170fe497f6d5259bc20715a38cb0341c88e93029137e94d895b"
"ab464bca6568b852340a5c5d6a225475f6eefe2fc71ffa42f857d9bab768ccaf4793c80c"
"4751a5583269ddcfccf8283c46a1b34d84463e61",
"01fe06b94a27d551d409b0eb9db0b163fadcf0486e2a6074bafe167f9a3b4ce8ac11f42c"
"f72f9a1833a126b9473163d29bca2ad139dd1a5e7fedf54798bf56507326fae73a3e9a2",
"04038d4dce42bf8fffc39a5b6583a1a1864de288ef8479449d599115bfa35b37954ab288"
"ffbe81e69d58693e2c8c81639df12e4b36f62b2ab042e92a0715b518c63d0ec630051d4b"
"e1059c72c0bfb0ea1ac5e2fdd4fc380d08037a3d0eeed4990ff02e6cf5a16817ea598085"
"e28f8269da86c547e7b34e16a06724ee73776529c5b5dea4ce3321fb168827ca1cbdf885"
"6d",
"0a3b18c8c9f17badd123c674869ff428d533d2ecb8c74f9784220be7a90dda591003df52"
"59c5dfb612ac7398aa04cc9e82863eb0cbe66b6e7f45dd15dad252f74a538d5f4354c96",
"09c368c80f697c1718c55482b2c6c5c0edd7257a3a53f7193515629aa40a9716cc889d41"
"c120516b54f3a106a171082364886e5d3a1e9482a103f072988f61de68f034d658bd976",
"0e782ef47b250f40c56e3ac4de112347174bd59fd4cc991a2b538ca90cdb222d048fec62"
"e2773492a1d327152d1d6591740706fe2f8e1d65de888d47fdf173b2645813ac0fc3078"},
{NID_sect571k1, NID_sha384,
"70279be7d7ac72a32606642ecd81b5d4d0f95fbc3c0b07d85c16adf2788601e44dedb8e5"
"5e0f9e0b4ca3ca35f5be7511b0e69224a05204af67aae11ce154af6d594d47f6e3142ad1"
"83969544aa95cae1edf42bc699137f60178c12b10a67698e37ab9f3edbfb3acdf1b3513d"
"62fe3db33b16cbb4e1f9dfe732c107f9d0c953f6",
"09cdc7e4945c485a41728f83d5188f539e372ff4fe38fffcaacbcb4522428e4f93ef4972"
"556f4398fe17bdd885768f0fb5590df495badc794d4d274e22f2f4a2535555922fa43f9",
"0403c6f046aa3007ba7f883bc1e0bb43a9a0a1daecdea3e2b6c10b2481d11a834af241d6"
"0cad7cab27b677c9ac11f2e5b5226c0a3de13029229af00e5a092340af9b230e0ed992ac"
"f406326ffcd62e1a68b63ac680a743130b1440bbcd3966207dbc8a8f4336eb6a7986aa53"
"cfa4fd7bf363b30706b4fae01568020b41caa70ee3d51db982de66b0ee39777da3fecf5b"
"01",
"0c717523a308418eeb2aeb816346b74149d56b9620774cab582f01681bec73adb779bcc7"
"462fff35685a4e1e114c8fba474c68fe2650344fc9cf610908966a9dd1779f76bce0cdd",
"0061067f377bff6a9be30c9c79d8abb7f54cc8f09eaacdc190beb27b1e6d297cd32b043b"
"31feb49958745b78e42ac074b8722e1a7653bf03611d87c44fd3891ae410b23a2140b83",
"00edbe756a5dc78c8a29baac9e2059154294e3adac9a5adeb7b27ac6e4d4086821cbd554"
"67266946ed8f6f03abff35b59434afe84067c1daa1e0bb62ee7c56b85e7f831eea99047"},
{NID_sect571k1, NID_sha384,
"4d7e0ad520445b6a5cb46b7c77fbd367614044ae6004494c2b3a89089287e2836c73b799"
"cd8c90139eac427ebe335804c3788f3728ffb8edd7f49a4bcc76a9e24ce3c2299cea88c0"
"4645b82033115380f81b0c1d823e470631008d350cf0c0dba1915519985b8a389ccd8c80"
"9dbd5bb5051a79e631916e0d052d9b6cca18e0ef",
"02bc753d007c4491cfb8ce0a6c96455acd16d37e02c982db216b8cc1afd6d10c6be4e15a"
"3988b8b8b86b2b5b59a5c1939889024849317f27ee08a06bd8e7524d4ad83a1de208564",
"0400ea922b09e902ce3847f14d3b3afc5562dddf15811cb2e7b9e06e1b919d795f8451a3"
"dffcb92b418d30bbbd1a7ccf827ea0f1f6554387fa2fc51755799040133d7a655c7800b7"
"1301f12439a0c0df9f6ef08e89eb1a62e2cedafc0460030810b2483ad9427c48dc061e46"
"40ebbd9b4a398841c863a6e3d510e5c66934d66b317b1640bd05018a35677c6ac2c78397"
"06",
"0385f9caee4731627276875dd8d725fe79626c18841562e8a13fa7531c7be9adca565c22"
"459d519d643ea22478d7c51b4c286920b050bfa54ab7d42966e389c485b52cdb4fa1a0e",
"02ac84262fd121bbec43e81021c0f0610fd2fc0b26d66581ddaa78714ce58be469652838"
"51241d792ad6bc79af39f09d2d4bda83996ab41f1fd206b8293cdb6c4eb9d96f39efa25",
"1d9c9bc330adeee8f58ebfe8c1ba401d4433efa04a44185b0e8e20b634691bfe058770d0"
"74289e636af3e96c118edf31d72b5766c30f6fe84ade42f284fc7f2707bf27b3a309638"},
{NID_sect571k1, NID_sha384,
"d49903f38b5c9b17542310425e59377f61f5b4f4740cd97371ee2116083f7758e69e7e2c"
"1b0950ec6b76f96e3c91c721d6f2843afde8c7505a559c8a64bca2e665aa1131b75bdf86"
"fb5b90581c7d3b61c2cff88f3fccf356ddf5ed282e27727be061b6925c51ea7f1a495f47"
"1dc8a5ca1a88bbe29e92338d3c9361460398965a",
"02082c6e61d0d72f040905d8c1c20d47b029f41ec68d6cbf43ce97c3b2a0a770557a33cb"
"803c432cfbd3958fda30ec1bba77a6613c318597a85ad02b26c44bb77ca96d9cc1194ea",
"04059ff339d505b307e05adb45aa314d47f2450e1b1aad840b5550a67c11940d0e786547"
"55a8e28fb651e12e48c66cc1ce0338114bc1ffb00965b342ef3a3caf495f1d73a69c3f3d"
"170724e9474e6de57b9f8cbf6f6bb4f73f5769e6cb0e006a34c2510b379995c9e054cc49"
"81c709ca85a3aebdf29090ca07dce5bd3c313c6153b551012d72a8f84600350e8754bc4a"
"bd",
"18d65ca6c2ef1fb32dddfb9ad4603e03c7cb1791a9ec7b41266cb68b6048aa111f5971f3"
"cbef3f0dbb9ce409b59c31cc59bd6f100ee5247f8c36f26ca77cb252331fc3be7346b5b",
"12853f9d695b8ac4431c1ccc8498f3fc4916eb6a5e66b3795a3693f3f5a29ad13e58dcda"
"ca5774f1f295e2d2d3c63c69abbcd9f388a3383371028fdcc8bd77f7554d6aa3f0431e8",
"0d1c324afdf01ea19e9453d2b7397584d773716d6a08b6e38f9a9fb104122ecfcc9de7bf"
"1e5a6cfd52a08b7cecb002ebc21798d474f035fe7d4554bf632f237bce14aad88b47d4d"},
{NID_sect571k1, NID_sha384,
"0e3f4afc3e7b25c1bf2d98098a5a87db1224d9bb45adc6e434732b8722a708ab80a1f3f6"
"ef3c5aa70d2e1dad3e4416b12cc59171f05736c4b58bd084602c344f2f0bf3cfdcfe04c6"
"4e87597a99de23ded64b33607f7c273ec321f6462518715b11e91361e89ce5415bfc2ef5"
"20bfec378244a3bd2a4b9b6b3d68815f2f75baf6",
"0e298c93351323e2c5304015a4878997ae4e79d1c32f1dc64262e534d4f2c4b3e222356f"
"fce746763373fdfb936fd330d3214a18c07f1205b20c9a941331cd676040ba1fe3dbce7",
"0406ee4952a83477d89ea05ae63d5169cb0f7c7ff22f15728c6d69dfb30d1f28158e2667"
"f9342cfd9b32f2fd537dad47c190d82f72c03043f2a9c5d97cd09d07ed4c35b961040425"
"54026d5935dcebc0ed5a07b7ffa50de3c8aac309dddb61b8c560230379696d81d72bda3c"
"819c46387e7f026b384bb0f7b2ca90c402bb67b5e37d343cc21a8d1a0f822dbb2766030d"
"73",
"12d23969d230e0e2712f96b11e196202dd3e6ac755c824f92b9c765e3fc808d4e7236c8a"
"3c06ca2c8272c7ac953fdb936db30d892246cbdcb7f98c43177e1c30afcc162af511364",
"022f6dff5bc1eac1ef568588e2e512103cf56ebcb610e124a125fb004064a28291c19e83"
"ea08171bd1b14ac729392c7c46354e795d63e3bb087fd100642465efd817b79924408a1",
"1785e1fd773446e3b90b8704cc2723b8da2f99d1d699e817c3c4622015d178b0cebc19b3"
"a6dd972f75eb3828a386973c0a5e67ca192d69f1a84c825d1253f1062a990c3f1a947c7"},
{NID_sect571k1, NID_sha384,
"8fe32671f6927272fd3cd8dd4e34d44d27fac8c88b41bf9a48039e914990bf06d1633b38"
"b9200ce1c2a275b9c55498e5da2d0707322c3ea0a0fd7aff598fb801628264e13047c800"
"8153e8595a0dc95d54e70b882ac2ac9314d2b78e7b93922da818d7075215e354708994af"
"66958954c92c074d132dbb2488e5a531c755a8e2",
"104f4ad56594c5cec2a988c5596d73adaa5a81802b40110dbae698ddb1f0b271fd1479c3"
"8abcdb9b234e69cd0da8a0328d2135c287d5b130a09fa0b899058e7800eb2dfcee95c1a",
"0404e8151aaf2aa6a6159622baad134be41c404982bb0101e820eac8f0a52166546c5392"
"7d9b419604e9b025757eaffac526d4fbebde5fba0841c6812dff2e9bab5054d4074a125f"
"fa04413639ad72d6eba870e1760c71966544f3f881f88880fdef1edeff47cf6c235e8dfe"
"f1eb1d8df51f9c48b985912f1f70b61fd3d4b859e052887560872fe6e95db0f435778d5c"
"4c",
"0cccd1bf3424d8bb0513fda3db93e81bd34175d84aefafd26b37eda9e767618247bdc94e"
"d2b1882bcae4c83eafc30a7a4a80806fda10a5e70b8827287eed8eac2721939a63c2175",
"05b1460e856548287683dfbb93efc869e80333a9ddcf292e2fa3b3c8d430563a01340685"
"c6db1059aaa8b298c8db9e8281f36e3a9664faa17f413cb439ef24cbdc1a4d58872ff6b",
"0c6faac191c95738f7c6ad0eceb035e5d22ae85e4bd0e27f2e65ab293717c0491be3d1b5"
"ace80f4cb4bac7e33258706010c2aa48d84c9e39c95e30805fa7669c42bad84386f7754"},
{NID_sect571k1, NID_sha384,
"a8fa01136a0a78313a5d160c32fe5d1805eeb3730c18ca0c47818e82c48eb4c9e5b2dfe3"
"ee5facef9ec59b68f4e6f3213f77fba9f8ba06dcde546ae348d343233883894f4423331b"
"536f62373a495852977a51cb192cfbec04b5582b4ece69f345979e234de32da7a120138a"
"057a7119735c4cb19099bf48bb202e7ffac04def",
"0c4989bf33b3136bcb4ba67906eaff2bcbc6567635aa4b057acb7353ee87ba3cb4cb9838"
"f8f679729d5c6ed98e6c4199cf58605f009c6873a1b8321f83cd3c0973b7a3cfd9dbaa5",
"0403871c7781f2b4f653f0d49a224576bd1e5363d5171bd21da89f590f49fc212d8a57ac"
"8a140d923c2949ca287bea803afd763f15f909c099a07297e8ba1b37c70e1e8f0fd1fe9d"
"1c05806bd5b4858ba0814da2167d232d55bb5c41ea0a36fb28a0a151c1b79b22cb16613c"
"cd9dbf92174e42578ef88f4da6eb44918acf427fb7e4022da3376243e75410ba6ae012dd"
"fe",
"0a9eb767077886c48bc54503a0d2d62f0192d3581bd9ec253107092c22f68a15293d7c3e"
"7aff56282f0cd35e86a2b3c55c9eec079201d99b5f49946780ce6aa18b225c2dfd72cf8",
"03eec6ffb390ecb2af4f5ca17fa8a7fd6938667b319f0f61e5c7523efb77afccddddb511"
"4ca8c461b1c28dfe7eb85ab156e24e891cc6f9511d703e8b3c8443d04fd8de80f5d65f9",
"10cf3156cf71dafea6a0d6abbd503d72b13e6a684076ac900f390059cf3fc325966b3548"
"b58e14a82bf291d9689783b899db7d4baba524b0b63d31f9900a84fbabc2ccad95742f3"},
{NID_sect571k1, NID_sha384,
"ba2d83b21c783d6ef2f3b7b10e910a418a9b9f49ae0fd37990335b3a3d15627846c9a12a"
"1f31a3d0e062ad1bec5650606ed4dd06c30e50c1e8761a29f4ea1a20f74635d5dac22e5b"
"787ac10f4ee82b338a641484f91771c128c84d31cdab0a6b9616078c898665655ee9dd4a"
"e73d33b94bf091b064928b959623aa71ff73b4db",
"1a96f2ad56e31397e236cafc108087479c9823589a5fbc3dc7488d0e5d1199cf245d7f21"
"f524cc0e8b47feca14c93fb760e631434a91188b32965053942f3bd39b3714f9d6f1a11",
"0400195bfb66e20ae295cd22d59b27b3880a890fc44ef5c720b568bf7f72266293841dcf"
"0572063a96c62736d9d4a9cce31b10c03016305a409858a79070477d3e989481ec555c81"
"460491122a199176e2492e07fae4ddbf02d2a40a21bbd99b8f742b546db2018cac27fb4b"
"1c03cff55f61b7caf13b0f3b097ffc8e1549eacab89225e0cf1e96b268eab7f9a1a69258"
"f1",
"097e28225aee5bc9a970a150502dd14bee900d3b040b0da9cb52f5824e66af46a991bbf6"
"423fe1e089cba47593af555b07b45e47b0f4141b0412ddf6e91153213c5b8645ae7bab2",
"1439928b55917e93d59341532cd1f9d09de1f6e0d9a04514bd4b692603f2cfb75a579301"
"b39b8cd92fbfc8832839691c23e0ad3efd3b4c7c3e9a366c1554c6dd13c50dd087b3055",
"1fb432e72be6fc524a7106b21d03fa71852c18c67edcb8b265db3b144214e7e6d10caad9"
"1f81616e03ae7913fea1e8d11e90d54b17705e8d04c8c20f0f4f46f117cc423ca178ff5"},
{NID_sect571k1, NID_sha384,
"ea2d5f4e9797bfc2f33f0fccaf530db2bdf8abcec00f09a0338eefdba318221ec0e050ca"
"d1a85c3f76b784c6e8c18da2b062f333eeff18b7b781e67d6d0a4368b8231a892e0f4103"
"012348e5df53ac745e4d34e2cd1ee9369f97d4801ff485fc144b2007008036bbc07cb1c3"
"02a00054b54f3713919191e1d5052978c9c2895e",
"0c08ed8e0e0f8b0d0714b46a2164b933f8147692f18da97e5a108c44d5a5cf221cb50536"
"e41832b83bff4026c6df156386235cf5e3e9a67b7cf9b2fa7707c5e0ff33a91601b8e34",
"0402d516bdd1914c83aec1cb242710ed79efa61cbb31dcf8d238d8f5e089158b2ee2bab4"
"07e01996a1621b1a869a98227c12296cc2a71c1ef2d0f26bd6614f2ac77008048abeedaf"
"cf0151474bef5965c455eb95ca2ffe1d589107dc251d22635f4a9fc7270358b64e4d2b81"
"666b60c4a5c49902b0fa9963197b22f90a09cab97007842816f64fc49e351710db849800"
"32",
"01125bde6086753b3bcf29b7d5a4fb0a8abffa6503b4f0b39960eba226062bdade57e4d7"
"3e8c1621792626203e83fd5c231a53b0ce10890881460802788d481f233466060f73359",
"199a1e40229786b966592ae6e275874ace23d5605d0c3371a4f9eca7ce4858927958bc1c"
"2780e9f2f79767c1c72117c79c408f972006841cb621837ac002cc6510e0432d99a1f64",
"17f4e5e23e494ef149e4abce2d8a1ab10e3e6c2cc93998fc63baed6565ed350b220b2828"
"55e2824f398ae76b8679201b43450f62237f6fec643ea659e6c86abc24a63d82d9bf219"},
{NID_sect571k1, NID_sha384,
"b2293b0a09f41decd9d8e637b1b08c2efe612f33c9c0beebb6e05033c6103b958f8aacd1"
"25d7c810b4c287349f5f922d2c6ed554be597fb8b3ba0e5a8c385ed8ae70d5ae19685298"
"f20e8d844fb5ad98db12ba7e5f45baed9045c3e86b3cac9bd55b614b82fd075954fc59bf"
"c6124cbd68edae988596575f379d8921b594c75d",
"144090a0ee38cfa21fabcc24d35139a99656911ad4f6dbffb77dbe74e7993edfa9fd63d2"
"c4f6bbdbc8ec21ba13c9f4a3576b5d6e3abeab5af5ac81b1f2bb6d4c42dde645d854d9c",
"040208729b3c7abadfc221cfad8be642588d5d1c20989fea731cfccef25886905e4b1e61"
"cf9548d89c24f5706f5243dc8aa7d5b2675c2c6d2755ce6a12e5b12c28a2cd9c597b7dac"
"b303db73ee445ffc0f6c77467f3add3b1e97061117e221687f5589a030f5248bb959bc2e"
"d98c9fb66da8679dea3949b77652dcf83ab9c50a00f6a9c22bd8d16e093b2deca4b0c759"
"6a",
"0adcadb26626eb9f8db9ae98c6808840b65d6f886a3f0c45f0b993a8bc62bb5c08dcd879"
"40dfef4f220f5e50234fba3a55e7127fcbb967ff78ce4fd6938a9bb653747116541cb85",
"18f7fb6ee028c3dd754d6e7b687560fa269b5a5fabb1d98529e0a27dc66bdb1ed79b7b5c"
"64fb71e767d9497b9255f26b8150b9903caedb25f51594f5b7ec2870515f701bd68faf5",
"09ca9519388402d5d96dd9ef2d4ebfd0ebcfa58bf8c1970d04851b2409671c9d5e4aa833"
"555df374469a4d277aab93b8df8d553399908c930f81c2d9769f1b30a13f61c02b16852"},
{NID_sect571k1, NID_sha384,
"acce54270252e7d9e983c08c993cd6b7e3caf482a9149036afe4665bd3d0662a68180471"
"87872862d5718b8ac063477f693caf1a9baa8bdf2f36d411a796f2b46ab56f66bc949242"
"29f8264016d6769c85d9bbb7d6bb042fefdb8fde1be026b86af2017aacfe38c97309b468"
"9b23fff94f1de880064f1d3ad9d74dc804c41f41",
"1df26b672b2e3617b6b6c631d3c6be0cb49c0a690de49643e0f416215bcdaefc03fa9c70"
"8471f1d87476d58c8f147517ec8a14aa945ef001fa01984d5c3d81f7083ea500558fef4",
"040767ca8fe8f3a7addf01b230b99499b33c83db95db05e1956fb1891fed60406865291d"
"79b0daca0c307a3ec8b1bf2ac2cbab728c6ec65c013e01775ee21a29305e9403f72883a1"
"3800acfb786b09e5185dbd8abf831d12967107dc57a040d7c800d904b530eed1e19a8e52"
"e653fe8bb824cc424d7254532d0fee62e8ee7ce8e871cbf6e4ca3bc040444585b9a4e397"
"cc",
"13e5e47048122c8301258c638bc0f00f8f9646cba927335535f68f4f4f51f23ac5398ecc"
"21eb0bfe8fa6a2084e11fe67587bfa791cfbe2527797a4d98046f9df37662cb7e86a5a7",
"164b3500ad14063101b6c5ebabba53dc5acb4d6771d3b05a505e6a67727ca8ff73d996e1"
"329c0f6d8f738237ee0f0be415003e2db515ef93931e09bdd853b9497826929eac9e9a8",
"06b65511990c061a6d2a97fe2a5053c775ce2bc5471865abb7261d0436a04b79baf41a0a"
"852a57600cd4c6a114b3a8466f721a684aac2592640bc149980545daa271fa9b146f2fd"},
{NID_sect571k1, NID_sha384,
"e25274ded4840df0d71d3369007118f002b83e2d375c78f7e29ade067db15cce21842611"
"f3f015db2efec57da77cb9d16eb1e00a8c1444d48dfda569e29fca1ebf40a22fc646a9fd"
"44460f0e473bde487634bfbdac2c312f66a1c2982c6fe76c54ac72b6c8cc9345e47cb319"
"a974b3cc4bb40634df74b4ad7e18adfa9a71ddd5",
"189918b832e9fa30161fdd927bfc267f6405335df3d66d225e17173af52a671138883bcb"
"94c4403ca3e001fcf09ef4c6488934d6775af2b1da30a8f331579af2d0fbb530298d8f9",
"04053e6b43c0551f32b7b34467d188985600c5c0ed12448f2e763609f40039f92002bc8e"
"70d8dd3e337c3507fc996a1557d5f2fb3132507e49ce653482cdc86f6ca5903b77fa1619"
"d904a9ac78a2c23be0841b96cdb1d55862e4854b530f1fa3f469ba9f7185e3f91c28d03c"
"27d9666345bdbc7a44764595b303f49cc43bc2d0e944862913d280273cfd00e15b6b55f8"
"5b",
"0b47a185140b583c330c64a10d50748e019134bacf153cb4a23753f140a4d607d5771a8f"
"0f535f9c35baae5ab6c37a55f38acd12f15be18d5bd9662383b30e4d0ce487e8cb553e9",
"1a2ae62cc9560590177aa544945377ff6ab1b34e7e32a25140f99996c130e17001563664"
"7756a5e8522c936eb1389c206ac74c012941269165f3772373047521f69510c7f3e6acf",
"1d86f4a6ab2bba7f6305c2df754652bad40d7c273ba2aadfbbe65c07ede4ac0e65fc0a37"
"a0139a6ecab296f58c6c2532701bb008bd9e1ecac2771d9384aca094537fcab47f3ef06"},
{NID_sect571k1, NID_sha384,
"d8a4aed87c316012482819b03a1d91691f2ad11a2f46082497ea8f64880d686891f7da55"
"0b2ac17199c657d4eb9d04d5cb8eaa180f743b87d23b1c86103f9e9bb60f4e19f0ff9d16"
"0f180aed7735130c03adb62502e69be5c624ed7bda2301f30580ae0921b02e103a638f56"
"23c02c186e3bfe6ff134c762a2bcac1f879a9353",
"0bdcc175eca3a399b944eb0334ff33c4fd130999c8ac0e7b52ac5b774fbad53ccc3a3102"
"4f5262b2eecfeb2104b14bb244307effe3dbe8ed25686dbf46a42c4b6f8e34010ad826a",
"0407ab1a9279a8408828c2bd21ae6c643ad82633d636d36fd91498cfee49c8a635313f56"
"993d02cc46da3f5b78fd243516cd23c14a4c8d79cf27dfcb05f52f0cee59cad5646a9389"
"b80799beb1ada93a48819ab70b74c36d2dcc3c5cca1f7a57ec58e643924c3ceb7a90c9cd"
"9bf7ec762a2c428d16ef431a45cd5d069cd828601f903cb0a28182af2392b5ad12ac3a24"
"c6",
"04ad8d2759df82dd70ebe9f3402d3d533a1b4635dfd0024deeee52b32373550f550b9fd4"
"126aaa6c3a9b1f352c40c86e13f78e259abb17f85f0041e0cca9e2ae59f4ee3ba2fbc83",
"1cf9ce41dd5dbc3bee9f46f82e4bef10cefe79a87e8e00d002097045b9acd46364560e0f"
"d27b0be6655e73b5cff272c8764b4c80ce0e1c91a94b8d05209a28b553f589ee2fa1b11",
"149fe587b144c37df2c48c2b7749c509421cfebab734003e51383cfb773c3ef5a24fbac0"
"255cb807f5b95607121c5848d3f9656227b61d5a14042351de084d9b88745be242b6158"},
{NID_sect571k1, NID_sha384,
"acbaa5ffc4eee0850075c0e502a70cc7a897a919f5e7bca4e798385601a26f411fdae546"
"6ba9f6b6d8d7f819a749b799fbf4a3bda9105063e74914e8583ed8b31ea4d22164bee6f1"
"4bf53afca269b901c80cb3265be32ffd4ca4bc4ddb83e11eff82ead6d75dc4aec8e5c67f"
"35d58a8a156cd1c0351abdccc0c5396c8fbe6920",
"007ab5a55a1d8ecb7f5dca2afdf9ef465569a4b0374716f604ad42a6e0271e934b09655e"
"8e2529784b69b2894bb399b02aeeae30e9e7ae70a2a8e56b9e775bd978a04c728e3951e",
"0402df88e368c8162c1dcea5ceee3a4c52cfc8d6121eb81c31236ba26dfd1874c61586d2"
"daacd96cb5ebc7053be57641bf53bf2651cfacf370cf470db86e1470bf285c7166c197e0"
"94030067763f9fa6a9082ea16dcbf53c2b6f11c9ba1817198e5a4e189dd98141ab682ba4"
"de0b3f873ae54efc080a2a03f755efeba3c0ade8ea67228b1a5a11d730302f1eb7c6bc37"
"37",
"0d3dd75ec61e0f87737812fe1ac86ba336b1512bb9f7ceac2c7d1a5b4d5dbafca57a5209"
"028cef9468ebdacb2a35988531baa094a1c901d9650f2c5d8e03a1621fb33ea85e2b506",
"184a98dec91b9afe52d4dd6b2d9f2d7e3c42e8e614332080aafd2621136ac7965beb4e8f"
"97b222c1b2e5448b79534db4e710331a2f877f8fc2a9259129f0b24d24289495da22542",
"0fa384a04c4b0b0745abea373aabc09404a6037f302e234e7a2840ff39c2b86ae37c814e"
"8bf3f3f7cf743748f2b88d02d66a3adef2028de94013c07075fb73f00555aa900337149"},
{NID_sect571k1, NID_sha384,
"9a57b63a4f418404e8f5dcf3052b9bc04a4f6d2c33bde8651506d9cbc5542ffb9023292d"
"ea463111fb78913ccdcd182faabbff9164219b8900c7f9fb394f7d9678f77b18f8d58526"
"ec64d7c1328953b983a7c416583e05a069cd76aefe26e5f5687b70abfbf9f58f052dc086"
"3b4fc3bef805cc3bb05bf76a83235af9d6adfe66",
"1e7d4da72b1d82e17a066fe387f2a0a7fa4c60ab993ee09710531789186077f2f32b42dd"
"da497d5fb57356383e1f96973df043307f0b6519430c3f0d40d62954032872fceb7dce9",
"04037c59e95132f0027f661511d1bedc3018bffa62aad7f44d7370f5b169d683882fca3d"
"d0c4260fa8f72a47a44fb0fdcf0d7776ff0632378022bdd223753c66f98dc04904344ac7"
"4102d7f19468b8e4f32eeeaabd6e402a35f38dbb9f2476cf07881d8bcff170b0a6e1ff8c"
"b1bfdcaff734a32ae9bf34a909ae7fee689e3f1ae777812a45dd46ce13fe648016353c6b"
"b7",
"18ad70fb9c5673e5a39b3a1655ff76eb84519555a6cd88e86a26f9448a54f04516c2449b"
"ab3f75e74a8d15c69926ac43fe01ebbe7e1c97e73870e3cc4c0ca431cf614f35659e3eb",
"12abdbfb2eb08e326289fdf5615057d912749db4f17848c1ac73bf6a51fbe3e1b2732d4e"
"b656715a6c459c6c3065b67b577f21b8eaca7d657c3b3171e8a4849f55024c69487e50d",
"09609da5049092e0aa8ebcf10c204de54c968b09b9bfb3eff90b80bc675d557967b35f52"
"e459f37fd198a83a858e5d7f9f5aff8b2ef7272b236dba5857e88515ed471a60bf6da49"},
{NID_sect571k1, NID_sha512,
"97b79c76d9c637f51294369e0bb52c4189f2fd3bd0607f91834aa71b3555605a89ff68e8"
"4fb5bda603f502f620e14e8b0c7affefafa2f0b303009ee99653ae4550a05315e551dd12"
"a4d8328279b8150d030b03c5650ed4f8d3ba7c3a5361f472f436b200b321e7863c771e20"
"ddd7bdf739c51de3676f953a5501e4477aed1bd8",
"15b7271d4319db5743119c8103a7d4c6d57e9c62f3eb93762156d2ebd159980aa57cea94"
"8e416717d715a2e458851f1b2e9ad4172bbcc53861db29c3ee0ba8e82617a5866170847",
"04003a5b9559b2058299161770166766aa65e151ac6a22a90205afd27de5eb99c5b1db36"
"9ad52f09141d3bf08884b96414c283b2669ec2a2a60c960a2f03d425dc4c229c0bb369d9"
"0f0024f3a9cf3dd257043dceefe6617a98e222e1cc820f3e19e63c64fdcf7ce8d9c7af73"
"23c9aaaef4df02e498597581082fa3767c8a38f508f4ca2c1eed6f298dc8142668a00274"
"90",
"0c585e425ae4a34f9b7b9205f095ea07599716f1eab1a8bbd934219ad760c4606ebbeb06"
"cbfd3952e045a040b8ce20603aea4f965d1b6e87eac7a61672823fb2de7767e3466c730",
"129162cce6fb05e1fc8630ec6c3a16d108bcd251719d89631497177e6fe6d1373f114ad9"
"dde6e04a4ee0b4747f91c78703012e5a058c132d54f2ccccfc0f9326b27d60322b497e4",
"140163edb5f3c4b49228e4614bfc6da9f73674eab82678ad9947b2a635f733dbce99ce32"
"09f613e2a75e62ed84db4d7d13de6d789b7cfedc0cb6a028d8316db8831db66c91791c5"},
{NID_sect571k1, NID_sha512,
"564ad0e37c9c37a60872a4780a723d08d1159ddc77bd834d74c1025cdf3cbd5338c3fc07"
"a904fcad9b979b2a2ceb1a0139af35e5112305fd662a57af6312624b9bdd3a64849f95f5"
"9a46ca8feb2ed56f87f258518947474c1729275c4d89b7dd286ed65f286cbac76002cc63"
"b92a73ab6bd13c4adef282f32297e441bdd8fd36",
"07219ea7917d174a5386df985d0dca798ac9f8e215ab2f0003aee929a2dbd91e37fedead"
"0ed95b1e8aabcf516bdf54337b4aff7ace4c6b3179f2e919a49db50a41c9d4d58d4f636",
"0402fd7f6ea770e0a6f1eeb3318b6b609c0e76ffeaa34e75f56910e8f658b70940cd7a59"
"18328473b279f882816955b2e3702c22e0b3e03863f8d99c64f3a2c9d1c68f59a28eaf25"
"ad06c2cca84218aa019326cadae9639069dd27df4d1e95a4c8e7d7cb426e70e2d38650b3"
"82e325dc3835afa719145d16a29e4ff67de37ac8949641f0d140072f59718450a6699732"
"06",
"03413376b32f18385cced4549e231e514eadfe05fffa0b252732f5c88d13d9c6e0c35be3"
"dbf72029be5e4573b8f8829f6efbf58a12b5c161bb7055d1944eecc93f82c12c5c56d9e",
"1c45c25f3e8eef9b92142f12e4119842122ed7672fdd82c14b3c34ade3243a4c50495c06"
"b5984d0260376c4fa44c60b2e34b0084066d693943071bb663a44884927352668efcc62",
"08cdac0f4498173bf4e59de98ac9a26fc2c752cfea7a5b75141d4e1d019e25d70a717ac3"
"ebb82884436ebe1007b0488c4ff29fa31fdf02f77fd99535c99b69c9d4e5f432516da77"},
{NID_sect571k1, NID_sha512,
"072ed5b14754fddaf54e20da42432df49bef38f4a3b1841b2db457ff86c44880727aca94"
"5770adb41269df41fc17f6a687bcaffaa45a3e59070526ed53b8dc3b78cf9a80a85461ea"
"f4b477e44d5ec4c2bab9c05aa747a5a520b35fd09e8b44539d060ba1c3470267e0dda111"
"b15dbb587614a46e1e477127f963a16cf3a43ee5",
"0bc623152253da24bf8d752bd78aedf7d5f6a2f889453ccdec14e10753335ea8bea83fd1"
"81a1f3680ed50f2324fbeaadae160cc85831750e021f3e44121ea1b1efc29a7d0069479",
"040003f3a6cc6964ab2f6da95c0a2a7b75afe4f77faff16fa28aa67809afd9495cde1f5d"
"ce079ec4e15ec8c1a2095a12e8adc409fe8729d865f50ff31ee75d7d807afd2c15cb142b"
"e9076b15c1ce931ba06dd56dd8e4f544425fba4f37f951a188c8e7eb13a2850c93b8ce60"
"f10b3783647a2d053e2764a957656a184a385e95c2013685d4954a2b2aa20e4a15dbc43b"
"78",
"1e091f4febd694879f78e83842572280daa48db65c463e66d9a7ea57b82fda531f116800"
"530a03cef2cf7e5be5eeb6e420213ff757c27b8e8a94513e417f4acc62adc02a76a4fdd",
"0264c499f7daa6ccaaf191d3502e86458ef088c9bf2ad989851c221364b24a1a3f4404fb"
"d0eb44a41938ac6ab67002faba0bdde7f44ffe6bc10def8317c4e2807c3ca711cb6cd33",
"1b91c18fc55635c5e3cff70503e7a49572ba52b11bac193230c88d6eb65eff6b2d9a01f5"
"3ab0eb34f5e208538136811157f872a8255b4d249b6ffe021b0c0763cde4d7a7e72b0b3"},
{NID_sect571k1, NID_sha512,
"e660dbdf3e61af39b83b95d3f1970f66d616f03273f7dddb98f768452b21cd39604a31cf"
"80590d4a5e4b0d4917519e10fd325dd4ab7a52d70d154506329baefe0d5816f514ae1094"
"83122b4fa8fa1ebd7fdf1fc4e21e8d278a50c05d81c8f489596633d949c6c8fea96fe914"
"30c01522a5afbd5042be8aa47da04581b2bd21cc",
"0645947d981d258f2954558c31022a3b6ba5fa7b675312f794cb61bfff1d9ce87267e4a1"
"dacb7c8fc58624d31c85ebe22f80d26a620fed5df5bf38515e0903f0b69a606048197d8",
"0402d03e05c4b555943fd69a299249e7148e99633b286da69bbcda64e7b06ce9321d62be"
"ad7b8d095a68d9a3ab9e9cf1aeb1d8c4904a073c21806830451a79fe7a907b32df15ea45"
"67023cba4f6f1815cbe1934734a901206596c6f482011f6cb6d452329f9412d2ef456642"
"9e7d35f2d247eaa7849ee141bb16914b64920fffe6b7923cfb19759fed6e1f80d6c40a0a"
"e5",
"18955bb752f0af7d7aaccd0628dcf1f52d836fb91dc78b0fecf21ff5992d9c1f891f0eb3"
"c139803b88736ce10ba4733a523854c4ae9ac35421beff9b20e0c8daf90bece46737579",
"110a428aa96277c9a13d4529f58ecc57cd7209a7340b4a78694dd9ec800f36c9c306221f"
"a110e0b3fd65b9dcb67307b7d7678997a3143c04ba96d72be83a1cd6b01ef22acd0f82c",
"0b7ae2da5cd36006a92a5b2e6369afc2728a93edc845ccb1500e551be361f8658819f7d3"
"eb82ad41d7f2beea1a1cab6f103238a6025acbf03a2b08339841694022c17db8c6c6886"},
{NID_sect571k1, NID_sha512,
"8c9acbdc431565feae60e08bc7da113e12372ed373f1e1fdd581f98c8a7b0c79ac4aa42c"
"7ffbc963fb4970fe26c5b5dd314b7051fe971c1186ebcb5650f7f7011a924de893f06961"
"b8c75da7bff331847feead4abd2e8b9d6ecbedac18f4eac207b948e6e4215e4d5cb483e5"
"c66ce7ad788cb89604d3a3e051539094079e7bdb",
"14cf93ca69d94ee8fbea0c8da9d76aea092b73073d8f5385b65c6dd4d567fe86bc2cfb8e"
"8be890c3c6cd9abf7dc3a17eaecee3d7a9455887863e496c48dc3e47821bd3d825b6bed",
"0403dfd1fac02ac4bd3e3017a3d94f29575238937824f80ba0b2eec185ce8c641e9fc721"
"94323c779dde8c4fd6e748e09d66e82c82add75106a0e1739f2b977d40ecd3cb15a1eca4"
"2006a73dd31226adba7ed8d08476b5af10a806fe8de72251400a83f6c9f6edf5e0cd6bd1"
"fa8f3595c3ab32b4c4548729c455e4eaf83230e1335cf181cfea6b6bfa6cd4ad75ac3278"
"cf",
"176972d9402d5d6c9753532e5ea907f256a872c100f87bd390c4d610bc00c408a97bd55d"
"ff2de1ef2fa8b9716e33a5a39bb6ed2ab541848685040656ad0468b360f42c3742c1fd0",
"00be28427524a3b0979cd82fea407463647a77ac45c489744a9998b545a13516abb9213a"
"b0d89a2f5f872d927ad48dfa502de95524f94f34b174933f3faa7b554a1c2c3a688a0ed",
"1d49594454516c1876f23f2ba0b1fa4dd8bee028bed5524b7635a2df5b8459f4832b3db5"
"f6074cf07c169cbfd9099a85ec2f5c42043c5b851c81a71c87affba34b11eda67e0ab69"},
{NID_sect571k1, NID_sha512,
"53ef87d6ac7b9698f40b3ea9f3442e7b64207b140b7f66f73fb7d5f8f98452d30a4e493b"
"6c0e3268371e88e612b818d4d847f032ed4983817d020411a52d81fd2a17b58ebdec199d"
"817c2a8ba77042bbd747a6fd4bcc7e844ea829fd8461b389aa0b5957d92962b6d4e86385"
"a8fbca90b8fac40944607117e9a4ef6dccb8fc1e",
"033feeaaaa28f16bfaf5ea9c7319cf4561ba4fc55327a8477b6cd58ef6ccad3962ee1f3e"
"db243f3a04e7e49c8e23509fa2d63252adb186b8bc7e9255cd61fa9bc45242d42da3a68",
"0406fc62c39bdd41ef7083ae10dad59e38dad217c55864a55a6a80bffe2f5e7da977d79d"
"b9ed8c9ac22d6f096129a0c680ac93fd77da4ad96e292a19b48454f91c93a3132559fecf"
"07066f1f737ad3af3df674637aa5efbb844bbc441966bae73973481628e5c2c67cb74553"
"a7c8f2c5fc478edd8265bd6c99d6ce122a245e46fbfc21992b950f04cbda5eb220261316"
"c5",
"0a5b86b76f98310a25111cc3d1b0b70fd0c20208cd0bfd8007cb569a187c3a97edd8e716"
"aac938900c3ad8ed3a0d091a18555ab532b50f25184454d84af2beafadf754862b8ec74",
"0de2eade32f537727eeb82dce610b48106b277d15d8fbdb77cd312ab9983ab21bed05f05"
"186a5cb2b530ba72c8c68b768c26d942f9224c6e6b9e7827c48e129833cb679c70aeb29",
"15e4fb92190bbf8dcf7548057d1bd5e5ec54a6edf54f6b88f50e96ac87ed7a7b7c0fe1e1"
"174ba3e822fb7e7c083948296cdcdcfbdc4bde036a07f84d210001ded91c554ace71efe"},
{NID_sect571k1, NID_sha512,
"dca1b7a9a313ead11c2d54739d9017ae27f9d08b3544e418aee862bb57e427636cb6aedd"
"a28e10f12aa15d2355f4f8ef112a86fec5dc46e6acef693cb8fc37c3e4885f3be3d3ab31"
"ea4d73a0de904e95c7135a149f77b621d642f9bd8ba192d39cfc58b6f19a797c4f3b4f3a"
"87054298e3ce5eda0ff7f44f8134c9a108285dfa",
"05613dfb53149bf5fdc4e08ccc1c752b0b66ab43aef2d008ed40f3df40fcbb2938d2c41e"
"3ea2dd4428aeba9059a97efe5593119673866a19d27a2ee37dd357e22b6bc849e7e22cc",
"0407ef12ccf6b64c7ca64b5da45937281ec770ede572b9a8eb685f3614bc358ce550195e"
"74666af9bb54379c1fe1304b76430d1e51a9976bba02e5781154c9bc187a31201ad99cb4"
"8e043d4ca20f06b26d75be1454e96f0568bd740165a2bc6e5b8429d557a79666bb7b9cfa"
"597d392cc5b8ecd180c37f9fe2088d7908e59ff644ab05568d974ab42ec9e01676e1b241"
"69",
"10b4b67007af35942216e9aab1d6561bf7684f334a80c7d909a6154cfde8ef06a148af10"
"4d534d7dda59b5cec7949de4086ae669edcc4d68b88347d2445edd3037525c97564ce78",
"15bfb47a27c6970fbb3256410d5c2f6c04eb308569a966790636899fdb3122f9e3015455"
"c4b50a6bd8cf519afc22ea845794f51e6994214feacf48322af48590d02cc9812960917",
"090c61f6c64381845491dac81d5273d58c59d9cfeed214527a52c8f23b0146431692a25c"
"bfd77abba22d4bc61ef24093c593c827ef645853bc8deef7c3b07bae919152b90c17f4d"},
{NID_sect571k1, NID_sha512,
"aff61d62c8f5c31bbb7d0a64a6ac589e918bbf2f13e7ad13abb9ac26405e267249a7c992"
"2139bc28140833e10976b87e91cf28285274b2b48b63d24ac94c85c70fafa78f8ad05955"
"c0ce6c02b841ee196dab12306e3e3d6138371217e2b474f7e67a80bbb78a47e374ffe2c9"
"f86292e471c551da50d46e7b5c8331029f369767",
"11b92c8b72b86c51903387a65aa206988d443d1988253329ad3a89c902ff1ef8cf73b7f2"
"e4aaa352443bcb833712d94c3e637ec12cbe4c2d4606878576b17fae1512fc77785b737",
"04022440b63bb4557996b63faf19d9f391c5085cdc2cda3755622a6cedc676222ceb5a56"
"ec36e220e507973c0f07e4b2e2d565a69967804ad311f0658a9854b1eddfb5270f4a86b7"
"69050199c9e443555123f153249cf7256dc3e82c5d8cb611adca0cd4fbb0a9a90296bfa7"
"70c1b0c0b43e4363b0227273a9ec9f00ecf83afc605b0dd2e5e24f739dd0b4ef6bb11950"
"a0",
"0e5ebd85f5fd9a9a81067fdf51b1906023e68672d160ddcedeb35787688dcdc314359ff5"
"347907b685a718ce38a69be17de292eaef189fb9ee8c63271bd6818904cd246503dd227",
"051387b0d057985dce86cb962bbca7d9a047f70d96c20539ae7d6b7cb8bffff606f03b83"
"15f15a53049c6c1c227f86d395c2217d32aec32bbd406c790a6cd2706775ed8a0ba1ebe",
"0c7f3b7e4a8b65a58c1280110f6c2486cd2d2df7d48b49074e98accdfca4a72fa7d43bc2"
"5c6576279f4a70f22c98135ba79158bcc3452940963b556304da8e1ae88973d827bee32"},
{NID_sect571k1, NID_sha512,
"721017294f17ef351e41256b57a64a79f3636628c4bcbe676ac9a2d96076b913dc4b246c"
"9945183ec9bd2d251441b5101eac44e2fa1bef59dec03ccd7fa5accf3b7d094d68dcf78c"
"8de4e2f19f56bf0dcb3b66b9421ec3f8b353b9fd74feb2e9affe0bf9aa421b6f03eeba3f"
"fd58fba56b3ebd094880e50de01ee62a108a24cf",
"0c3c90d5ce4375a08b85575faa78ee6bbd9e5571ce5a90582042617b807339c282cdc3b0"
"03d82006264b1c08c20af4ad4549fbde53d262facb98d923d81b8eb6093374b6a1e84cb",
"0401d900b4f64c07cb959049f2bfa18012f9bc2dccec5a73e9a48a9d5d65499e31ec4a16"
"15c4c50177c032d388263eba1a90e07ea68f081e10272e88a41389bd2626961b646c76ed"
"8e05c094fedfb5b118accd64d5d46ca2ed92b3123a62042a556ffee9e3bf709092fff882"
"31a26917d368db51d1959ad3285c7faac16ca57677651b070aa0abad96f07d35c5fb8a0e"
"e0",
"14d4070307cd269cc1a3c048ec0847edbff46f64c1ba5b734d8a800e50a0a02af57cf247"
"50d292e2c247ef1b860a9d7b5069a32f5b0546fe9e019e04af62316eb79507281fbef6d",
"1cda7f743c47ae93a9fa533145feab4c46252afabe3d54990663b5891b4979c645ccaa05"
"c744420ed6fa235952f370f5aa187250d7b069aea1123f19f0f18da18fde98100ff6ff0",
"180b4163f2eba6e3769d8345dd8cb003ea120164442efa885eda5bacd75f8d705b7f1bae"
"2976f67cdfe984430e36f93455ee7528fa6febfe92e42a002da165c63dba8fc589e7851"},
{NID_sect571k1, NID_sha512,
"e2d1f33681759adb7954bb5248b0db3c3885fea0d4c1c0c226eb1e6d2d3ef1b9ac281a0f"
"1c2fe5175b67114b6a501e2426d1454bd5790dcbc4c232cf06b017de8a9bb39e6033f1ed"
"b5003e8de3b44cc3d6150c3c952afb442952483cc688908337b7c1a8b5c9da70937ccfa9"
"8b2b0098c530ff848010b8e8ee0a8d65283481a8",
"10f184c16228d9034271332178ed485d10b6aa76003efc160d63fea26fbbdf5552205ac7"
"df0d8c852a1210cf0ba512f20b798827b36ad56b12a826fa7dc1db45aed264ca6822659",
"0402637543ed8a11271bbbabb2cf72999f65df0104758c2fd6fbf3e1c5132ff1c1111fa5"
"504ee86bed8f219d5025f8ae07055a7849314d2d439408ea2b2ddc40320c57f5d41255d0"
"a6014e360137ae33ce6930b844d42bcda4050b25f349e9e19fc4fe82f5e4f73cf9bb5021"
"2ea875a5735faaa1d5494f1685d6c8177448dbf356b408ffc2ba0726c9befb9de9f0cebe"
"32",
"1146574a96394c82972eed1ab7ec98bd08f27653c565f0626fecb431ee4fc6f830554df3"
"5fa62b5f82eaad49524d3d4b0598cc7a2181ce9860e271812373d21be9536fc181c3f12",
"0dbf465de2c5242fb527f6e4a4188adb96a2030ed8417cd9431365173f569bfdd3e420f8"
"6947da10a703370d7f38dc43e2249a2476690829545992645c9c83d82af8adae893780d",
"1499782e0163f80de68e3a580ed08fdec8d6552ec69f186a74be89480be28a0df6acdf7c"
"65a72f115f8a59fbc28bb94af64cb3bb3cab20bd25265237a010370d9a5c781c1e26f3c"},
{NID_sect571k1, NID_sha512,
"414fc5d2bd56b30040e105cb891788792da595583b11b8fcc7320f40dbf64d9263532dc5"
"7344dd17573c95eedf851668b5d552e8796af205f3a0043af1a829fabc2e93d9af9091fd"
"d9e0fcbcc9d6d9ec960aa60e4e2964c29a2f375400366480e513f63d124db7745847310e"
"69a38c8455e4e602056a6a4a14a8694155e0a9bf",
"181baf9d497159f837cba58a11ca435c442e5ca792ea559bff9f6a1f562c05bf6bb5914a"
"fbd1bcaea75b35f88bdd832314b249a5298622c89462344d3f28a44ba3d059df432fc71",
"0406f3915f884e250034db97327470197d13f0716d1d810e43055757460dc252f5281717"
"b3ef3fdd51085e65a0e073e78b697a21bc33137213981fc05d9b34caf7dca7a4f99be785"
"96047a96ab5ebec6201b7c65ce7a6e70effeaeea1c095a0172e9e2c7bfc88f7b05ea5750"
"76caeab189f810258373cff2484f4fb9c8167989f61aa61ae27113b5140c95f7faa505d2"
"d0",
"10e9e6047651362accc816389b26ea6befb0e34fe7363126f8c4ff9333266f46d63c4d45"
"075480da9ebdd0f8da7224b470d914ea1d68cd821f563b574bdeffdd0b3ed73ecb9133a",
"00e36644cf0861f45b333092d44fdd99f56e89bf3607f75a06920dfab0ccb1831208296a"
"a2431bdb75c5d50f15bbea2e13d185db6d7175c221858fd2b22afbeca7431c290b15d3f",
"023ee3b9ce817eb0a6733c85062cc3bc5f1ae62bdf3a74e3ec704baab05784dbb5ed01a6"
"a2a73c80a3e754c013ba886108d9eed2bc210f29a4774bfe5508ecd876ab47a8527c530"},
{NID_sect571k1, NID_sha512,
"3b592cc8972a4782870e079b82a50f84b4c2d8ca90bd500d1ce5678982e266c391c556d8"
"162ac3aab967154d072dbc0ba1dab5545cf2651753dee2881eca5abd412fe624bf3f9d17"
"d33692d21ce23ad15ccffdfd250cb1949e73c9e40a64ebebb03852e92692dad1d7baef97"
"fe109f35b7a492b343d4b643a4a7b1723eaecb64",
"083fae86ab96bce99a53e50b7eecff38e4e25b21c4b0f6a4986915de245eae24f16b6a00"
"a4db159ebc27f5a6a072da94ab6be5bf75f5eb3f75c4452bf4ea7014392eb1e02706fb4",
"04078003779e0287bee54df31f64c58951df7999b48b647a6bac416f844485a4cd7a53a6"
"4170f9d2d31fdef0194a0c262b90e5bd33a1782d2ad56c210cf80abb5fb118cffd71ad79"
"c1073f89ebdf0e255205a7525cc12b7e1c58303ac3b3417183179c216ab8e47f33d0af32"
"38e3ae64d418ee89ef3a2cb4bc67a1d2fb1923947b9dbf3f4fa39ff82327d0ce3db24d23"
"24",
"13d126fc4033f537b00a81372031026f6a7a2062863a68e36c6909c548833d1a8f5fb5fe"
"25c7d9f2c65b1dfa974630204f71e96d657095b93cb54b00cb88f32adc08eeff4036654",
"09be9f4bcd7b8ef111337fb665379509b8b17a2212a80d5fecc685f1f362c45f930acaef"
"9df47c33c6028cf7aae424264575b4635a11edd6b005ad26cf2021051501fdd1b77d2dd",
"0dd196343ef76bec527c5929e02fbd5d02d5b0a4b5f2c8561978e600856de56d42943f1d"
"74cb81b67010bae98de0efddfcddea5d354c60c1fa76138801f6cdc5bc932c136309b6c"},
{NID_sect571k1, NID_sha512,
"0079a02cbab3dc02601fcb5c8607d555beef7cd71a66911ab6514a4ae21c5a9c0e166f8c"
"f5fb198ec5a49a96e17cf041f35f00406b79270ebfe56dc6b8417d2529fd625686ffbc8f"
"69685aefa2fd30a937c02f25b48be4679e6fde821de928b33b12470867def874bb8c7c80"
"38ab6594346a2c44b39210d3610994ba60a05e06",
"1a663efa7bf4d8479bc535fad71e9b5e4f4281aec55967baa008ba17ac2f89cc3398d305"
"73edef29d590fddce8cb157f655e92779f59e7a18d0327d02e7daf4c1216143b3688fed",
"0406b4bb31856dc516be60a0d2d9f42508738edd4f925eca9c72a13cf136720867babb38"
"622fe97df70a1edb35735365f34c74baef9aca539aa1dfdead3324f41a16ca69bdf86b43"
"f706c4a91d3fac9e7647a6aec6e4369158bdcca2275866bcdc5a09b2f0f1eba10551da96"
"13eeb1e8d3233316b62a5f4641d6aaf669b975dfc511f2437d43c9eebe53c5115fb4741b"
"80",
"0a843d0cf776878fa9ceb163d7aaebd29ba3aea0808c3459036b258b99ccae4e2444bc32"
"11b5898c0769b7d7e036c07803497e13803132b3c6301412af3be8eb4a853e939a247a7",
"00356e282c096fe1690fdac4c0c66eda155ec42356dfc4783cff0160e1d76b33a99442d4"
"ee0e3f6e1c5bde4a16c8e18bd18f98a178c3fa4a560d8fb8b4b1d72663576f8baf8672f",
"0c5018c1383fc3847819726e1e940028892e1abd164b413293fe50f219f2059105218e4e"
"3b952b912a3258c4ae52dcc03ac5f027fdfa448a8d58e3aa5c21e790b3b47bdfbf21175"},
{NID_sect571k1, NID_sha512,
"88573bd94ef50459814806efa868ebf92b066fbc2f7a4be9d2fa06b9dc1a72f72d783a6b"
"cbc107b18a6314511bff217037a2252e7a5cd34cf9d5b2fe9c7846931f0133b2e95876cb"
"800dc4ed7c4a4e4cc4f1195acf99fb0ec224b1f8fa8af71f72d390eca9d6be3879032a31"
"8734a63fec336c79035a43f70271def10c4955d3",
"0088d1a2c0219696a94337cd56516252b74139ea0733b17fdcbf7692c3e5f6c3989e5da2"
"aaed7468e65a5d578571928ca273ec3b6aa72cd196f560f05095cdc8346e5d31c4c2e0c",
"040357801cec0888461ffde22d83afa9ca008ac88518f4b09074d29a846f5900e024a8e5"
"947bc25ed0e5c980a58fd5e9aadfbfab31db8bec575fe886deda80134d91b3de96254653"
"020710806c7ed33f6879374c59ea144326f5948980c8013144345c5070122c0ddb7e18e9"
"f752eadf2a9b0854dfb7d9b2f0d80ff0ba46197ce6017885939e9f59b642a8fa41639ea7"
"5e",
"16940f69013026bafb6f400c037272176b04e35e9f1563d382dc9982968a186e3e152577"
"5d27150b34b8ce5e70b537f0149ce1a521d056b52e75da7e39ee8a529ed987c70b8234d",
"199058e36449ee1a3388d7357c9c1020b2e4c02144aea14b041bc584a752c94fb6e47495"
"9b24bd2c0c104f5ecfe223ebdede672298c29195033aaad5db1852ce4dc3185ba2409a6",
"11f3defd9b442378c461e2c68b239d2e4afaed691238c5ac4e0be46ebd461639a60176f9"
"884133900f988e2d730d34df5e2bd8a14681014c0a213f8d233b3c50ae3064fc38d1a19"},
{NID_sect571k1, NID_sha512,
"d0e02045ece6e338cc8ab41d4a064c982ccb1748c48fc2fe0a6f10bdc876094358a6a90a"
"45facec798a83cc95c6795cf0f0d7c66b77e22cb114c1432bfdaa1485ff35b6a58107cac"
"3b7e58cb4f6c87c68db60b751e78f1fdfa54b8923b98caad0a4f31226956d065c083ace5"
"f1e9e91944dcca51879d782e40358d58ca758750",
"16cc8a0fd59455ed8d4de561fd518df2e008f7dfaa5f7f29ac2489a411e233917b43eb3e"
"be2596fc824be58871949545e667dbcf240dfb5e0c615ade0179d9ea2a1b1ebb8ab9384",
"0402477e678793593e2abe837961895c7ecef71af1feb882ff27cfbabfa0ba3ed771b792"
"23e7b2d2388efd371d5c325854cd60e48484f818e1a8146fbb780cd6ce06ba63c0db67df"
"8a001b696114838bb972ec6d536abd809d3a436650191c43b2bfeefab2b400d5921a7eb7"
"8e307266acc190e05f3869017f0a66f886bd6556c58aafb1042478cc768a4f86758e9f4c"
"32",
"1e1b851bb95d2913d6d35b756d49fba6f4c127dbed80fe4068260cab89c1d42f7a6843f7"
"31e83b379ccd8a4915d2e29550f3f6ccde607cd0b066dd5fa41ac2bf37bdcfc26cd4d04",
"10d4291346685fe070b267edad91154df83664dc115f058ea036c712929634d53662586b"
"b50cb6473c2170db5d4ee43be0c50532015937202e193d15d5189870691ba65aead7f3e",
"0b2a15f1ef00204bcfb5108d8f1da96ac3297aa041074b68989ff5b6b276380de7887753"
"fe3d416ba691ba0b2ad7fc065ace02815b2323fe17f6445b0fa66dba5d99d8e7d557cd5"},
{NID_sect233r1, NID_sha224,
"f1b67fde01e60e4bb7904d906e9436a330c5cb5721fd4e0a3c75b83dade868736bb1d21c"
"fb1b5c6407c373e386ee68ec2239b700e763728eb675a153b8ac44cf2a87be85fe8ed668"
"3430cf4b7d718891cbf8d583d0a37cc952cc25fe803a7aa4fda80f05541a2f1f2601cdd0"
"c095f7110f2a84f7d641b8531572269b21cbe77b",
"056673197bfeea9bd7a8b820b4ae51a50411bf118a692bb9ed3d304da53",
"04003489be62e53910c20cb508de019c3e326f65051f26749944b4454f156a00f775ac38"
"baf19499675725e8190aeea16f52346b1c890d9583b38c7521",
"0a6c9914a55ef763913273b062475fd0188eb2d5af9c8c1dd97cb3cefc3",
"08601a42d7f7eb047e8ed9820ddce665c7277f8ef38c880b57109b7160d",
"026d6f50f0508953657df5d753c595ffb8e1c19f8d092f8ce8db54f76d0"},
{NID_sect233r1, NID_sha224,
"1d496d96b533c632ed6a91f6e3653cdffaa5b8cc0008b35e49b2dd52fe261105c2ec7ee7"
"1a4ad5d51fdc3d36d688a3b7ccb3b3b0c3a65be17b8d8aa172e3005cfbf37a2d1b1a6e26"
"8c090c6f318e7e96f9ec9b9f5a8fbcc7558d89e840f7e76e44bed91c26ca48e6f5cbc253"
"ca2fe8cb81c484cabd24070e488f9c00cd96ad4f",
"0468f01d483144e514ec257f2e5fdee28a927f2adb19714c1f3524dd0d3",
"04016b3cad89cc42b80bb730431963526e26ae3b415b421575dfb6ed973e1701acaf7de0"
"6e20262efae01fc80969cdc1a281f68e8c8bc0d2d4fbba3a3d",
"04d261304678301985f5bb3f6ae465f11c9fe0e5031b31f194969252703",
"0878a87b2867c03f55726ea2a6db822788f4aa4e9ef609997940ee8c8b6",
"03545153f0554a8f55301d4b948043de3057cace62c8032c8ef8a11dbf8"},
{NID_sect233r1, NID_sha224,
"723400655027f474446843645757f7e2cd466bf97275067b4bc4c9d79bb3b19b2421835d"
"69db916f24b77c381fa771fc1e7a19d2b4d09411ae55acccc615b16fd24705762b441ab6"
"7083a921fd4ae569ce0de69449aa96f5b977ac7dc022fdc8335656853796f54b3fbd1185"
"77f98920624eb0a00204f1ef83827245c06646cc",
"074052d027f05465a8083a59cdbf32600224e1f563f653b34314651517f",
"04006999290db440eb5b3291bd4bb4a1af6386654fc4d275ef136c0e03dbca01fed0b1f9"
"284e488c7fa2a010766c340bc25dc132c7679c2598e423c3c6",
"06e38460379ac3fb13f64d4de654d4fa30bd8178da0bfc29fab2a1e2e39",
"01b18bafe55e5c24fa2df4c09112b44d24e78dd09557349ceb1b916d280",
"0ad7cfa003267a6b7a99894f75720cedc9cbf820d355a6b840709f42f62"},
{NID_sect233r1, NID_sha224,
"155860cb31a142082bcc0bad828d747e916392d21f1873b3a3c1d28ca3ff9d45ddb66a71"
"2e3856b6afd07c8d2b2a7badab296a9775b03f6fec0befa2d8d6d00fe3938df244ab46e8"
"36a3e686c8b4f918da49f0bb3940bba34a9aa22c7caf02df7758b0de01d9f47af6146344"
"b9be3842d9c055eaf0fb399cd8db95c544a62d8a",
"01856e7544223f55f80de72a6ef3822fa8fbd68eb397d06e2d76ddd35e0",
"0401a117e52f09080625f85fbaad8ebe0d3ad410f034242bf48365e88ff7350008b8bb79"
"58d191265901a3f15b2919142505efeea13df6e42da8b0dc1d",
"0aa106ad1461353865706bee9aa092b00fcf1b0108ecc1266ad5d8b6579",
"0bd6fcf49029df32fe0fa47f39cb9428d95d00a84a5afb392d7b4b365e0",
"0b17734befefebf03d1c79e59c12ed3c57e7d120dfd993bf276de559588"},
{NID_sect233r1, NID_sha224,
"cbd6e305cc9f0dc90caee6e65a74582e9357bd25c78e33a7b14e1ac7e9397ff4466f192f"
"b432143e6df6d61a0ab808ec0a361a6d95a357a38cd3e241fe03ed883ccc364b248ee2a0"
"8702110745c2688bdcefa33c1a45b9c8b200e45cddf3e3f66b8d37eff07fbb3366ea1558"
"ef304085613c56707095724b3e134c7a7d3f8dbf",
"0860aa2b589f2defc617be73e191502e5d9952bf60547fef19eeccbca26",
"04006abc5619422b7d548c612e54df0385c293632d4d97c21e2e15ad98d0c5006c36c072"
"603681c1b03f6a023c8e987f39d931bc2a200eff82239ee38f",
"084fb252dae9a96a44212d18e15cc52d179cd5e3392ab9da57d04cd5a9d",
"037cd554e7815699f033ca9187ddb116777ef847b92353f613152c4216b",
"05f806dd062043420dd056998bdb9822b3177406a536d766c4aacdeee81"},
{NID_sect233r1, NID_sha224,
"812a218ff1ee1472c189f63386e5b8ab341671c3a4dad27a8c6249d1c0f9a29338b471b6"
"179f17a078b6504e804ac55ca3b13e68a623041bc1a092ea2adf3fa1124bbfeb161e6d7c"
"483433f1548763b84da00352a6386e1339f674d45dab13898147ede468e0e01d2c4e0ed6"
"6b395a16cc3ded3e952ac739205f35a83376cbce",
"0d0dec052a00ccebd0c0c5d9a08272f75744a2582cec7ddd924a2b022b2",
"04016bb8c3d319b93731f1055756e57bd56d50b6b9ffbe42735925cf6f7675009dad7b87"
"a749df130b45d9cac8011101c15abb7e64bd4fbdd94107fa31",
"04098547601430c723ebcb04b23e0f1ce8b1f79ff7ed3d05ba130922b01",
"070ea6221c0d62930b019faaa856ad2c84c3989ec54040bffc42d8dadb8",
"0aa20fc58beae8ccc880e7fcb48a471faa5baeb36bbe5aee71ed9f8adb9"},
{NID_sect233r1, NID_sha224,
"0204b1fca831919e89e108cf140b3770f531a696b1d9a4d1fb68809eb10afccc257cc90c"
"d36717c02b2f3d6d3d1d8a93cc5c48aa7ab9f9fddfe121ce9143376535a0c65e247c6558"
"eac49fd1d6d1bf431ba918c471cb3d536ad485ec51f6471a340ac75f160c4c54cd3ffb9d"
"cc123124b42df1fd2eaa005e3377c5d2d55938c6",
"08a017d717d6d1213f2b74c53281b07258738c0c7db649ea1ac46b9a3b6",
"0401eb379e27de6c04c5320cbc18e79ed9e8993710ac70ce823f1ab5762b6700f5521926"
"45d350361762aae79ffba39c33c2c5c0df208219f1b339016a",
"00e4822b2cffa327a8396301b21554da6fa52f418d67114bd58e850d935",
"0d64dbdadb4ada2d3a8892049f7fda3c733030522b44cd72ab850b77bd0",
"06fbae2d8e4fc04abd8a6e9cb011974ac851ec108e38f9c72603f7a04fc"},
{NID_sect233r1, NID_sha224,
"2033eb48756638cb56e2cc39a3e775cfa11fce86cf71f04487dcdbc7f262bc8350a30ced"
"54d1fcb697b28a6e96f88f782947c997872307ed963e1d68985f756435af77f57755cacb"
"b4c6b50ed419deec9f39f0a549a13e54254fa0a5832dba2d943ad4aed8688889a2dd29dc"
"b4ea12abd6a6c50eabcb3981c3a0c1ca5f0b9629",
"01b56c14442b084cfd22aeef0f8028ec57c8b571c9fc1e43de05c45e47f",
"0400d450c533b13b211b8c91dad0738402a5c811460426ee2f35ae068f2c12015e1c9f9d"
"398925c619f8aa0bac746eb7907d3d510814cea185a7efe771",
"0dca09773730a2758b7f4d9257a8e6bd942c141e46bde5ca54a79468c4f",
"0379773ebb7a2860f3422d8f8f714b234e5abd8860defb19c659c9c6179",
"0cb9272a27661604425ab84632f586048483b9f9cb80b9697898e745117"},
{NID_sect233r1, NID_sha224,
"2986ab1cfe8873009e932dc68d4727d77ccbbf378e43fe4aa7c54416346b036b89c0aad1"
"b82977c9fbc39a00f1dc916c0561d8dd70298c02b6cbfe572e0ef2058641e841c6875e85"
"15f3c1082765e046c90c956d984b76e0e8e6eb433ce26c1757ac5b13422479141971c201"
"02e9621d18f51096ae3173c2753facee2862d66e",
"05afce37c5594586ac46a34ae291f591eacb9880a7de92701977f447fbf",
"04002a069ef14f2989d2b715c5006642ba966cc84df88bbc27e713e15c47bd00f001f60b"
"8a8102a971faa2c42d3ea9cec37b49c7e6ec0cae9f7fb35713",
"09756db630ed9b708bf1ab8aae6a7559bc235c4e9f4002ed26e2f019aa1",
"06b9b2c1d214373647d9a2d24ba69741218064004614368915d5cfaacaf",
"090dd607329c27483fe43b7be137c3f51c23217c939baae40b53e65af2f"},
{NID_sect233r1, NID_sha224,
"aabf5aa90ceef91c2155f90660adbcb0eedb996f5242cee15468ae217058ebeaad8cd4ff"
"8cdc754a8ab85ba43c59fbab6386686fad5e27ad3848fe52191c7e4b203720841501792a"
"625aef2acb6e36493b792fa55f253effca682946ad8c77e01f44e92ec3c258d0dd98d318"
"3f4dc4a0bd3eca183794abd6232a6f9e4add8f57",
"00696df05dc7a54a9908a73eb18416a155cc8df4ab26032539d86eae537",
"04008f9f494ddf8d0030746a8c0b8d215dda6cc2724f411a7ea407629294c301ea2e9f85"
"f06412d29c677aecf624a83c2fbd86482dc0d564906a91d97d",
"0d62b06628d3884f0a329a7b6b4f832fabea4ebc85ee03e63f2967e7810",
"02e39824f272d4b74810594810957963c777207217e53a672010605b9de",
"0e64bc44af64b6f879f0d32f814acfbb98795ef7b2f246b3f91cacb55cc"},
{NID_sect233r1, NID_sha224,
"29ff209eabbde02b10b3fd559671fa53e418750c32c4a18d31cc0186d1077581bbefb877"
"0ed079f536e866414a07431ae6633955bf42a2389b6f8a565d6e4ffb4444336e00300938"
"76a26d4e3106e9ac697788e41f8a21c755eeb86a7c60f18e5e1069f16408a4c375a6a68d"
"42959f2fab7ac09736c7b37c80c05897d8566ce8",
"05ca31e88c5b2e96e433af2023a66095161710628e7bfa428944d6676b8",
"04008232d4bbe25536ea7f83c145a8d2b1cd72c383eefc2adaa1ce72c7dd9a0100b738c6"
"f1551b3240293ee8e8ec29fad0cc485ffc2cfded96b68162bb",
"0df9e1b418ca1d41d749ee998446ba1cc54bc8bf72eac6f30929b40b5c9",
"0d4248e0bb60fe46abf7bdb2effe804b9d394d8a5514a5791e149d435d3",
"0b89a459fb99cccebda754c4b2ae264c9aef7b5b610427f42c35dbe7d3a"},
{NID_sect233r1, NID_sha224,
"97765d876c80819f4004a36d09ccba78e600efc71eb7e869d3a00f658d2ace6769c7ab1e"
"f590f41fb070aa8e08615e138df45ffbb6473d4a86ba5fdf17dd6dc9ea9ee19c0332563c"
"99e6a3451c211d286d69102b47bfa6e07d468d9bde82e5c2063fb1ebbbed6086f542cf68"
"ba46d4f214634afb1146dd5a6f3d50912ef5b824",
"0ef8fe84727a2ad8bf4e646ef28a492adfaf785a3a2ba6e6f985c649a8c",
"04003435eb25ce9891a78c120098992c666940103eefd80d9bd64f1d4ba37b00ddd6a4a0"
"1e443c92afbc247f634b85f1c858a2aaad35a26f57ad4c9126",
"09753a236759eb32e13f19b9d2ad06f7b4db4ac7b1df96813463d0cd557",
"08408fc46149dcce0753d7cae0f50c8c5fcc97acf7a1a02a9f68c0b80c7",
"0b5ffba104acc6d0cba87523382ff928859718122c4d0d2298e74985d89"},
{NID_sect233r1, NID_sha224,
"21cf768d087d1e4eaa8a05e2008020e243116206d675c09be42ef2bc93617ecbb0575c87"
"3c6510ede9979215531b62126552738862fc4323d487992754e39d8f0d7e111e165ff254"
"200e05082f59a57ef649bccaef6f980094fad3b7ef93bceb161760e200f0a2e396fbb6b6"
"142dc84d872311bf932b84616b22231747937d58",
"03edb94b8c62f9af30c14a790c0f5d65e362a21cd8569b9725916d534c0",
"040065133691b888cd2513964b5a905ed9334cff6367e25c09db1743045d5801408e1ac7"
"21bfe2198086c1834d484b6e5692c037e09928cff87f4b5a88",
"01d8f800ba05d8173b0f1bb3aac0aff68c6b24cf98c28f5a69b0b5a52cf",
"097c07d4352e39e1878c42fe97ebd4c3ba5098706879fad9be4bb2dc2f7",
"0bc669db3a488e613665cd26da7927c6b6a073ba6b0951c00d22ab1ffd1"},
{NID_sect233r1, NID_sha224,
"7b8e58eecdab3e40212bba6bf284f9379265b3d2baec3e4625aa08d0ced851da193c292e"
"c793dab42732c07b4e94d8b19c83aed796a7e3a6c2b954a7a9a1ff9b2bd4ca62592c8b68"
"f709f1ad38a5c8033ebb3f33d176945bfc68e9ef2b0cee2d45a13ce89d238a33c09ce2c0"
"c63c4233aba5717b85c4c161dd7648a41a5e39d8",
"00a7519be62562318da1b67d22cf8e720353d22641e0cee11c7a352bb93",
"04013b63dd8ca9044a3e518a67999a781a5b62994b6e20454003a9bdb8715c01a2f9bfaf"
"528b7f5bc8c3b02eccb71666c83e4a598b4077de999d90fe27",
"0992ba1a8331bc4d88be7dee06f96098bc2ea56668f345e187f32f38171",
"0c55b45bc7bc3092ffa82234b06ad45525b45f8904011f1bd6cd356f0cc",
"0e6163e70ab56d43fa27211b98b48f1cade127237bec1c6556020d39990"},
{NID_sect233r1, NID_sha224,
"f8f268d2b04fe47e5052c8d0d653787384b9654f0bd2138a6f52b80713feeed452b976a9"
"0eea4edcfbb62d04f3eafe172ddebd7cdc3701ecd6008e3d82e8eb217b13b5228839f610"
"75159f3bd1e1409c08903874b6dfee2789dd72c208ae769ec8c7d52552a2b1fd73dad24d"
"e8b571f88e2184d0ee7d063a121187f97e746f2f",
"0264022fd7dc2328a6436b522793ad9406d7a586667a0daaf1bce927338",
"04012d7e7f8519a7e357510adfca2f50182dc5fa12fb2a77409fb781ed500d00ceaa9a22"
"b7ef9febd8a9962ce21d83fd2a2a938b9d7a78d669dd233974",
"026fb8fa6e746106500dd29ee32bbd03b94302ec3a123356b23b3055e51",
"0f416418f7aa4d437e7606afedf961b968a67d9a1524d60fe3f6df4d3d0",
"08d3afc975a8147fa8230fef4b16e3024180a9768702038f955357ce8df"},
{NID_sect233r1, NID_sha256,
"d288768cbd066fad4bb2500b5683fa9e4eaedfb3dbb519b083f6b802efda0a022355565c"
"5fc6babeccb22f3adbbda450ce5d633193d1431e40c0fe631a295cf85965cd3f5937b318"
"66bd6a5300eaef9941daf54d49832acfceed90e572ef34ccc94eacd0fd6b903fee3c572b"
"963d21e2881656a214d2a4c125778dbe3bbeebca",
"0da43214e2efb7892cc1ccde6723946d2a8248a6b4d6c8872fad525ec3b",
"0400db09738bf0a0dd777f67e82be50dc8c2d8e91598bc0b8d4486f67c04a5008ef463e2"
"f37ac7c3d276676cbedf17ae11e767ec577da7ccd90cde3b74",
"0249cbd55e307a0fd10a0c70b1c0d5e2416f4d7f144779ddc11911f4a08",
"04d1c99f9d486fb92b132d68c0173df891ca757572f7acc03cb41d46bbf",
"07de2deeb58d55d65fb37f600d916cfa49f889f02ef53dcce412703d1c9"},
{NID_sect233r1, NID_sha256,
"bf0ab46e0a756c11229b0ea961f8d57218be5b00ab8b0e91d7664cdf5e0341c412c0e992"
"d26ab12115197db39df2d1a6e18ed26a91be461432a2dfc21d98cb16003e339b0b0b1f10"
"0e4e6f4824ddac5442f22a1fac26326ed8a89cc91343d7223986d485cc8c64424e84d56b"
"e536c57e4dc5faee459b1958efd79e07e90a9811",
"0aeafa49d776b61f6a30d66ff64bd40dd8d79891dd5293c1b5cd3b46a7c",
"0401ba1b87b16122e6939da5dcadb8902177a9f9ef09194c8695008b80b588008f51ee5c"
"ea1f4fc9c44c70df57326ff121268bf4e02cd9b2626fe7c1ed",
"09d640ede5bb60b9aa78e393ed453b1643f6dade4aa20e994db53e81fac",
"0277bbfb7479077d5fb6813670fbc7f46055718199550130b122a7cb8b3",
"0f8dd350bc0bd2d84cdd374c56ff2341de4102269a1e80df7e35969d4cf"},
{NID_sect233r1, NID_sha256,
"c7b1eeb7c19eb16e7f42b61d79e421b71de797a6cab4e0baee522fee7acdb533f7bbf585"
"5316544e1b82b4f2a18ad0a2311e7622549332122171f32fc62a90e408207e0fb90d1b05"
"2821dede9c41b15b6e07d84d5d7b9e31e6396a8ed229fb6232b3051298dc5321aa589f4e"
"289d27169f14c8cc93644916d9b72dbc92c43488",
"0e95db309f4305b621f51f93588a2678cb19aad0932f365fa0aaa3a3895",
"0401177eefc44b6070e2c41537e75c91e2f08908c0d950bc90cd2f4720b33500f751312d"
"de55b1bcabf31665deb6c12d043d5ccc89800622a557a7ed37",
"00015798ef57a771d62d194389817c93de1b225398fcc0d2b81d94054a0",
"0eef7161a167f69a6c89b0f173db2c4a7033b5d801c0d89642ce65e377b",
"04043f8985bbe0221fd595f9355c33e1930b5e10a1452e81c31259e1e3d"},
{NID_sect233r1, NID_sha256,
"a738eb074e1f277dc665118ca055e6328059ab26da188c16f56384c566e43df8cff3d2a1"
"0d2d15c3c1406de8f734b20be5dd1ce937a4289f0ddfd7bddabd03586556eb8233b8feef"
"edaa1f49bdec6d45fd562c2a83fa9fcfc2013bdd77900857199e51fa9c7cbeab925ba8f6"
"c3c5fae46bf8e9c574b302f1e5f9c44400152a78",
"0d4319cc8e409b8755880827f3200d3f0f1c64d6356fe74eb1f5aa42499",
"0400bf65953f2d08477f7fd0428c31125184e3bad4d5da00c91991949e056200f1669d0d"
"116817d625128ae764b3fde956432552d24d98f08a12925afc",
"05e8704febc38bb8ea76f3c6433c1f0421dc5e5af959723a5a2f0e9a970",
"0307c0b838c65d1a47792cb367253bf7c9f627435f1c7ed74494b318446",
"00031a9b35e935be6620243f4878a38d4e617fb25f7a4883893366f39cd"},
{NID_sect233r1, NID_sha256,
"b28103d77e5457c42e026e713ea6ff03722a36512da17197140117442a976f9e2139c54a"
"759fc26af5811b455e5a0d3a95362d9939c1e738045be9237b469ae2106ceed7e7842b44"
"cc0a475d5af6d781e32ff1dd1f4e1833dbc7f82b27dc7e1562d0e29213fd8911105104a7"
"a16f665b926aa137f70d868c90e72f8ee2c95b64",
"09e556c945052e5954915c773b2d47970c521fcc99139269c3ef46093b7",
"0400db68c16ffe64bede4a849812df0b8e202f74500cb7d5349aacf7f3f0260084b5892e"
"a74835e96e9dfb1bb201a4dcaf32da25dc00dca019d806f5c9",
"0d0c9e0b6d4526d5f6494d2c72f812fb8d26e17c7a44f6b5e3f9e684cad",
"0a379ac253f3aaf94cc49e91fe3f2908107a9e1a4d102e02395eb18cf08",
"0854c2f6ecbfe95cfd14045faf71ad47561e365c1dd5f515d8817c3198e"},
{NID_sect233r1, NID_sha256,
"463d04c84521ae671bb35c0a7acb3ae509b1b0470f39b8fe7ae5f3c9fbadbeb2bcc3a87e"
"284cbdff07407a351f7ba743aeac50c4a1fef7375b90eb4af8ea2df040776bbf3e4389e7"
"a80bea40530842642b9895ab9ef5ac8ed6c9ce7917d7b3ebcf80b801da845943313988c1"
"970e7748cc306f914c37414f8247d648b580000f",
"0becc76f8a77615c4f92ae1f91645bf5bb908e75ef22fd544aae63a3c8e",
"04018cd93bfe8fc8ceef2b9be14fa947b60fb122f5099cb5bcfad0cdc601e8016de11e67"
"3011e30f6fd92025a60d7938412ac63b19d23e45bbf53c6c4a",
"04e75a7b92c42ba0581eb1201fa5b3fb2ac82460e953c26ce6bc60e145f",
"067bad23ecac0883d218b1368d822b3bf9b82453c0e5f3e336777c6a507",
"03788a331249463533384a61c47232aee6f057634c37560ee25895b2a03"},
{NID_sect233r1, NID_sha256,
"8b2379b5553ae7db6023cb010e26ae91322bc3f94dbaa369481936f90a886e5d3827d995"
"ccf03ca59f46805fbac0337d31a8f117cc7044218a934d5bf507090e7e21178a7162c8fc"
"b39111e6967803dbf9d752f3ae737ba024d0f4f7627e08be58efbe997a164106bfe37f67"
"d2f19c0fcc7a6c7eebd96a72582a9c7bdf881896",
"020572c2a3dc3ea430cd8cde9d642081c21658e8bda165550cd9a5d37d9",
"04016117486794f14d171dfc3ccffef0396cc9fe5aa45d6d39ce0f252c416801b6a12fe2"
"adb279dbbefa4eafa273a2ddbafb2c6401067a5ef5e859fdcc",
"0edc8d0b64496da309b10630e9e5917c9a807ccd7cc7bab14360873eeab",
"0e1fdd3b7849806fe587ad93aef737ba0472409b7239981f0d325785fa2",
"0829449a0c39071a832664e8148e762efc36fda9e030e0d062458728273"},
{NID_sect233r1, NID_sha256,
"3090bf7373731cc44c00372c1ac59280b0f36e627ccf763fa68a7be37bb0ac8cbd4f70db"
"54fc652566c78ad268f78f015e4bb1e41516fa56ac303a3bb4a52e1fe897d8338db5a6e3"
"7cad685e704b994504bd231c7dec0002dbd907a7ebfa809833e32eb23fffdb44fe4a18e1"
"1fa19d67356cfd703cf39a75b1a290b8a7c73afb",
"0769cfbf2dd8248ea1e0ac9b275c9d6ddcf923fe762079b9ed62ccbaa89",
"0401aadeee0e31ba9505da3e195d883643d260dac9fe5e86102c8ed7f88eef00d925bd5f"
"d700fcdec60cef9c9fdd304faa102d9d721b4f21291f8c96a4",
"0f2e203410107c075e25c4adc2f55dcc277883d679ea307df7d52060fa3",
"02fc0975c2e70328da4a0ad2b8bd344a8171c2c500c55b1c92270230c27",
"08871b6791f7d03796a3aa537fa820f0eac8f2463c9f918468e7588b784"},
{NID_sect233r1, NID_sha256,
"c37389cbe3f46eeebdda343e354ccd543e96b0c2a87e057aa6b9c4895a403de706d658bb"
"c9066c140e50fef4b56af2db1f42efb70b8021254649983f1e11d04d6b10169d5a1c2093"
"b6ab89227b88a30537c776bb7575749c3ed87bcb29effd8e4f17915b4d5dff6cab9678d8"
"8f33abead1e73dbdc5c3307ff3d3b2d5fd7bfa83",
"040ea4a37b388f0cc464f7e2bf92173107b268ff77a8acf5f517b4ec0e4",
"04008acee84d29638a7285654d20f8e0653c7386140aba0bd2fc157d51764301482ba5eb"
"b82ba46654aa1eaa6a5f01e030177318921a0c99fa3f6eee9f",
"0a6fbf938e9cdd009c838196ffeb61f7f545f7e7e9a6cb18d1f595a87b1",
"096a80172a7b3b65c0a8acfa8b89cedf9cb19f6eaa5d38436c300b7c0f4",
"0b7bb96ddfc9d1324bea96836c557cf88d6ede9a93ada8fbfdfcfe56244"},
{NID_sect233r1, NID_sha256,
"8884def8c3b9c5f856b9c2352c85ea71aae3c8d0e84ca74e70e404a21467159fc9826548"
"d16dd1ec5a75dc2c23ca37b30312f25e1194e0f9385a0499db34c855412bbf58979ffce7"
"fc3afeb7b8dbf9898df44023200d809f520db99eae315b5cf85674fab008a20340fae8f6"
"974034fd3e55bf08c5522a460680218f9757e368",
"037fc7898df9b37b5390537352f5c0b8de22659166c19d7d4df31c3938d",
"040198674b40d2a68ed94d5b2c51102393d1332404f75187130669b9de0df9013ee77d85"
"4a60f1aa74041ef1fb58727c09f13039bb4b33a818dfe9af2a",
"0cf92eebec59605b1d45848f5d06e93ff2767dfa282929208ba801a9fec",
"0f7bd93dd4df06219fb974a4e85030840c7d4877f131adccbd98cbd25de",
"0c2c4a864459488eb5498a06b0b56ce7fc98fb29b1eb9b6238da8cc8f52"},
{NID_sect233r1, NID_sha256,
"f1fc154d469433f56c2bd42aa52237a4a4bfc08fb6d2f3f0da70a62f54e94e3f29c629c8"
"37e7adf0474fa8f23251b9b349a16848942c0d9cf5db1d0fd99527020dbe21cf0b94a9aa"
"21f376bf74da72d36f87b306b0696771efa7250c6182b426a4500ac14de4a1804b38db8d"
"4f3beefb8c9bb619ac82cb63fb37c2e1d22951f7",
"05d5069425e7a9925d2cfc6360a708147b2c1b55ede243591885147ef3b",
"0401f35f161ce0963dca70066b3a6de2a74ea1941a27cdfabd9e433d8084c701d5d9cca5"
"b741b2321d8511a777fcc2515c99ff8d13ff20266a163c94b9",
"01b9c83d36ada7e9367790ee850163ef4420104e0dd3299ef6d65191d7c",
"0dca4e804bf74aa496c15025acb4232c637c9b81e9e26d6f2065d6be21d",
"012014f77a4ddb7b266abf2c65a653988ee6f913e700f3f83f3e78c88ab"},
{NID_sect233r1, NID_sha256,
"885cd348f7983a0721f96c0e866821223d3e5a95178b16d18652b4062b1b2278aed6f54a"
"b06f7e37ae6ce1020aa3eb812d215194bcd212302da5b971fd86aee1dcb23057dbedb569"
"bd0bbef80df538da69ae2358cb03bb77c64d3ead475c8c5ae5bfbdd75684b421a26f1a7b"
"0c37548fa32d805acdc91230dd70a48232a12846",
"0ffe3e7b82ca62b96e057ee072a4718ca20a6cc9a3e51e4fe8ed7b4b9f9",
"04010f774adc83c1893894855366f1db1962bc697b8e1d047a01a08b12da4a0078c6ff63"
"4d5dc8ffc4d8b1a53bbf94046023095a8c2b41618c4330a4de",
"005a4a50de4e97280d6ed1324214d91b271deb649a2dae18d21a0182022",
"04bc8ba9ffbca81b5f19f0d8b1306900ee642bc5cd9a9dc9867a4531b04",
"0353567acc062b83459017c70cff4f3b8ef0925032b51d7300261408549"},
{NID_sect233r1, NID_sha256,
"ca3b0e2f1c7db4e73c699f06e432bb0f63705ba66954bec4a259bf31c161bb4861476e2f"
"2f7dde9d841d1ea6bd0990cc793cd7a10432e38735c3eeda7a0d786e8821239bdd6c4972"
"c96c2cf68ec5b935391f963a50fe16af2719c9029943b539ff0f1f5645962a6ac46c75d2"
"037fa0c7cd46deadcdfc66e1ddcaada3a376acbf",
"007a9cb5ce27c763646de414ca2a4dcdb774d69ed2bde7a817baddbc9de",
"040086d4ac1e3d54f7c154c5370f5c9a2d22cbe8f794df68974706bdc9172c017770a2cc"
"ac923423137731a14e97f6ca65a8cb3642eceb4e70c78ee929",
"0538b86e0a899281ab56d28f40bf3b7435f9a57e334a3269233766049a6",
"007ceaac3aa0e260c371843104f5cb91a057741b38889ee796e69f920e9",
"035eedd44b036b843deadb8e8df9d96b16e719ba350a634553457ae71a1"},
{NID_sect233r1, NID_sha256,
"4b0a31b746763beee77cecd318b90acf50fac4172cf4bfb354e5a440f651cb89d7a515e0"
"9ab19e9850803ab9167c2aee3b395a5da10dc9aff799d73756dfb0a9961d93bc32f15a96"
"bf13962a03d5bd42ddc8b5928def7fc48fb063f42866fc5f96cf88fe0eb125b7c01906ad"
"6a7fdade28ccb0a421ceff50ae03a974671b2c27",
"0c03fa9e38dc1c697f70bc6381f2bacaf860bb5632fc837f728da959ac9",
"040195f386c7efe108fd1d580f0a77031e180e45a23911ba983217207a904b01a6837095"
"a64f71ec53ab1c0d9a3a39d69a514065d83f1af26870e41741",
"0d4f48085b367787a614b57c06ee8018b2e95e989c2e8cf355e71db1091",
"0391710f815babf07b6287b7aab8b9d2ce04bee2a144f4d4a46fd17cf77",
"0ef29cbd771b8a6f414ecb73b7937ffe0a108593ffc6899f28d4030a9eb"},
{NID_sect233r1, NID_sha256,
"3011d42792b21c0f1719faf6f744d576f72c5fdfd22b1a520d0e8d47e8c2b06823d853b1"
"3c9fa039fa30a6f2e3e27bb2100c6a35f55703806bbf0f79b09d0f629f8042ec63fa0406"
"2f15f2edb92b19237980005566f02bb12a40b4ec66e4ba6c599d928b33f72d7437c0e399"
"a8e6a9068d1fef24917fc4f9ab5464ea6684dde9",
"087dba00e3fe4802e01718017510094924496bd2785d4ac1a352c530473",
"0401198518db2d1255aef955b9b80471aba60cf6d8fd1feae6d8e048ab140301833332a1"
"16214e4d9fb37c8e0ab7552b87348434a67a0c41f73972dc9c",
"0378578acdfa572b1de4e032158b28bcf00ab7dbaf07b0e772c39603216",
"0be2cb45d527a7685139290f1098de975b69957fff2c5c29059ce417950",
"06abf4afdcd2990121723b94ab8145d01cc4917cd70416620ef100c67bd"},
{NID_sect233r1, NID_sha384,
"05a5d3a3b79f4e51b722e513620c88092a9bb02408f5f52a32e782fd4923f4fd3094fc55"
"36caf4b645d830260eba91b5173f3833dd65600fb9e246aec968b1f6ebdfddb4059fb2de"
"7e636ed60bb7affdb74aefd158e54485d5f26be373cf944c6570daf8fd7e4b77fad57300"
"667d6decf5c65db99ab8763bb4ecbb09fdf47e3a",
"05a387e7affc54a8fbb9157b5ebd400c98e2d7bd5c3e095538987d4f8d9",
"0401a97224cafc063967b25cd1a43283daa5411f3eabe9386b8b14c9768c29002cefaec5"
"141bcb084cbc9aebf28fc59780897ad1424fd439eb43eb911e",
"0fb7ec3804654b9c3675f7b3c427f6d01f83872e96de2742e59c93151fd",
"0808d829d78e65eea47122c92f8c2cbf5a8d6717a057ef1659fb6f8cd3c",
"0ef338e09dac0b12fa6109d15924efb694a0b672afb4ef05f4e6f2f7b88"},
{NID_sect233r1, NID_sha384,
"247a101c8196eb93a440280650ad463795690bc620e46e8118db6900a71eb493d03fbcf2"
"f73a79bb47aa8e2d8c87ef70e4cfae36fae5c45fe247d8cd0f7d0718dad106526945014b"
"4f3bec324897d8e1fa2f457b8a68e61873b7fa0350fde3b87b7b001c13953c2050a24f71"
"fb77eb455053e49200ebcbba7299485c0f1a40db",
"0adae709a930d6f5a5c0e3d8ef4aab004d741d23f0ffb8287f7059890c0",
"0401541eaf3dca942957c48d693d2eaf2a456646d2fb3eb8df1779b917a9b00097379582"
"76dc31852e57063119f1d2d061616b6a2fd35b4a1a3f046954",
"0390d5ed395f8ee3478c2765525c235587dbf5bb2316df3a1e8c664185b",
"0ebcc4f84bf2deb9b3d669158998fc96d7516580675e24348ca58d70d2c",
"0b99462b85e6ce6b46e5aca221250ac9de7ccf3e63b38919b61700be866"},
{NID_sect233r1, NID_sha384,
"a16678c71976a3ce3362ca379b3272b92e8ca7085b43752473db34e4d6b61eeed3875f49"
"f3328366fc9d0644824e0104817de458e4c1036636b18b83dbaf063f2f99818959224906"
"571c7b28873d9c702360888df151e9ad1a7003e6130033203acf8a69889be6ebd90816f2"
"abf0764f10be68653b1e56766ecc3150bef8b042",
"035d391411e6d679751092c4ea5a079c591e77ebdcb57c1d9006ae70d90",
"04001298e6f1612f90dbd2eedadfa8ecce22dff1da2d1cf057c41bd37d4b060073136a1c"
"af7dae2aaaac571a900135a51ef031643e9d5f01934333b864",
"09e343003670f61db85aedc0249db21953d232bc45488c3d6ceaa6072bb",
"04ac435e88f8e487b9b217e7d68fbba9bdea0b9685769878818f25e661c",
"074d8f4dd58c922d7e79f30950bd54c10c1cc52ae3b8d00b675c8e501a4"},
{NID_sect233r1, NID_sha384,
"bc2f080a7f0b69a6b142b8f3fb481a43bd71d07418df4f3b802568073c1a8d35729ad197"
"f34a4e941a6dd511c63f201d1f6c34a1b66545bd5f43508c10bda1d6ef60ee5bdd25dde9"
"75e50c61f76cd36d50ee3bd8dfa2dff59524db9ef12f1e28d109b552cb42f021963f559c"
"843476b5c889fc567b7840297c5a480e18c221dc",
"084e79093f1947d6ab9cf399782436e36ef87c59a4c090930c9a74ddb10",
"04008e756774def210e2d6f76d6e4b0b43d86adca0880f017abfc911bafb5a0147e6a20c"
"1aad897829339630c5edd327ef9a7e40795630504318cb71d6",
"0ce780ea99a344d67de7921feba6ae062817101068266d5d1a140d2b49e",
"0fb2474b854b8e5d6920ed90e69b5b386a1b26a947b1cf28a13f7c5d3ac",
"072722017a67ea6754873f833fc51318d41d6ef598d3ec2d3e0eb5bf41d"},
{NID_sect233r1, NID_sha384,
"ea71cede8b63ddc5648eb244184bae265cd65d50f77a9e25ff93f02b132487c08732544c"
"b88936d4fff7c0fedb39685822dd1c9be1158f647c605c9bb5f6a1ae34722fa08882c14b"
"36b6c93cab33c9a269c7c10f755b6453ed045ea3e56f29e95a9404ba189a0b4884812039"
"2b4dcac43148b706c3d9e4c03db410cbe5dca3da",
"079b6be015b8006f86fd81c2792bec6b42c08bee2d295cf9dc214c326ab",
"0400e24338d5e33ad12d41eb623ad0905f64d5b75835fec4e693eebf9bba100101b4297b"
"5b62fcca7c61637a2a57365e911d3bc7eb0fc7adb0a9dc7bad",
"0f06b001e5f874d16632e3c8d49f13d70f48ed4eecaff9d3b741f9d02e6",
"0de16d8fd7bb1783a2cc4b9ac1563eff3f87e4e6d75e6a32a4aed1ecb02",
"040bdb1197ee8ee51e4ecccb8d42dd985913809c131aa9224049425a052"},
{NID_sect233r1, NID_sha384,
"319b41d16e18059a1324c37161c937e882192cd949c420ce9c59208a0ac208ebb06f894a"
"7fd78df2a3c5f23f25dee6595d3dacb25a699f115dd482ccd36fc54ba29dda279335424c"
"86b07a1b1fa76a5411bcecaf4d37065b229cdce0bac75b666c6626ec37a716e9841be93c"
"907f87453ad91d36846561f284421a89013b88c3",
"0ca9d751a060fde64336cdc88122819f4b3cd1b4e7df42d495197787894",
"04009549785f4f9c71f20133f5a1d409b244df55445beec404cf8cd4d2cadb01b246647d"
"7570f052840d4cc01182d1dc3bf357b25e5966434e1c3c2a30",
"09e99fe741cb23f7eb039f5df8414d069b5c2e3c144dcd6cbc6da56ef43",
"0cf00f519c18e7a0fcc84c1e338158399f16929ad89842ba97a4afb5bf2",
"05854ee1a6aa5a6a74bec0b4696e80aa275210183c86f45dde7002d7ae3"},
{NID_sect233r1, NID_sha384,
"aebeee215e7b3d4c3b82db243a47506ffbf2263f6fe9de5b69286e8649d9218367c36ba9"
"5f55e48eebcbc99de3e652b0fecc4099714ee147d71b393de14a13e5044b1251e40c6791"
"f533b310df9e70a746f4c68c604b41752eca9ce5ce67cdc574a742c694ada8f20b34d0eb"
"467dce5566023f8533abfa9688d782646420c77b",
"01dde4b2d49338a10c8ebf475b3697e8480227b39bc04253a0055839e9e",
"0400504bd3a97baf9852d6d46ef3db78ee7555db752120d020cd056b1b4e50018dd305f6"
"a15e91fa46d2a6d30f2ec8fbe2baec491e26d9a2ac81155c85",
"03b78d2772b8ce01a00ffe2e6be2f9e2ca2c89ea3b29bec6d6cf31afe33",
"0c0c51fba155f98900eaa2d2935acd615e917f9dd979dc8d92f1d6e00c9",
"08c8354f95e24ed13d8ff3755e1122dbb4117c76b21b3bdc7f4dd856f8d"},
{NID_sect233r1, NID_sha384,
"8d353a6b6f35590baef59b638914d3e934d0145b045d221d846517ceddc8ff5e3d28826d"
"3459f8ce1260f705e80923f39abc73d5949aa7aa8ad1734be0e992bff0c9a8f4cc9bdfa4"
"30d4cf52e29d3737b0cd3231b72b16e15e1a9040b832e4a920b4a1d94c4964ac6c8abb75"
"bbbdb10825f882ae44c534c7154c446421a04d87",
"02c8bea2803fd746c874fa110a716538c179c82712f38d33d0f6d037e7a",
"0400a034560353561cde19db89dbcad5c9dcb74e239efc604e86ff38a0577e0185e0b02c"
"48be2e90c916a7c8ef2b41a57ea8d4f21d8cd3a0878a03875b",
"02e39f851c57643bd799c4f3b2fcc5eec8ff7f9e9e279efa647f969cc6a",
"09b2ad7efc7ed60d9cd3dedbd4159b1e05f05ce5ec2d2cdf7a0e0657482",
"03fcbd4ace6a140c8bfebe36ff30848966bb0d3eec323cc8ddda55faf00"},
{NID_sect233r1, NID_sha384,
"847f134b90f10ba3636ec24f36a94111f26d58428fda5bba4501e58c7bb55809f52320cb"
"e9e0df55af1e40bbac9f3eaa26a55d78b60621d4356d090d98363662f406367601eaa9eb"
"9568b1a1b319730bad7bf6a7ddf1b45eb6922faf8d065c540b671c50df758ebf8c4aca6f"
"01878e5e0012dd038c58833e2b13ebdb9a9f3fc3",
"0b9119b3b4b30cbfb98ddf0a4f6953417e515fcf0e5a94e83ebc1d1d14d",
"0401be65d340f7e99067bbbf961c2b357e1fd47a74393cae5f93a40c5dc28000c04cd8ca"
"3ee253b99e44ee6bc0e52d2f016b16f59c738b9f2bd8c1b9d8",
"02c851ba0123ff0543808931ab3857b5c15d7c10c343f232913f6e0c92e",
"0ba2b33550878e223cacb80e45e382dae84e76bca5a2ef8371b84d08572",
"08c370f82506e97cc15837f59e9779448decbd87bde0a463bc14b18edca"},
{NID_sect233r1, NID_sha384,
"99d23950493bdd931915e9f9b65e4cd1329866c0071a19d4f7d6fd190689275b7b10fc07"
"503dd1c27a4da274dbeb3aa5cb0e71e9b7b03fc2697729b7be913756e6760098951d7015"
"df181cf14b1e0b954e6260276af553e3e59907794b863e941950718ef154669c5c262946"
"ba120892e0239e05910c2194f712db46e37e53b7",
"0f4ab2a573f3771d1e4222e251faf14e06cefed544e804c299c9a8395f5",
"0400b1f973d6495d277e24320622b9b99fccef8eb5c1c6952f35b82d4479ef0161dceea4"
"d3c9caa4f640f51b37fcbd5b8932642a94c8e7aaed5db17fdd",
"034ff28a5ed6958514c603b3af5a991e2e9b4cc2c0a7aa73ab2d70bd05d",
"01abe4a7b27395a37089f91eab27ccf29001ced1bb3348a6f919d466477",
"057449e55d3f2a4004d647ad6e8fbbd516adbb4de40b1a872ad8ecf67e2"},
{NID_sect233r1, NID_sha384,
"7bef2487bc2bbbcbcc1570bbd4ed437c0dbcbbf63f666a3355aec49ea6ef593da25aefe9"
"ae0d94db50692475425dee3c88cdea975794ac69142c25732f3541457d68d9101c8be069"
"f2b515aadadea2019dc7abefa6c12cb3f76d9f4b5e46546f77eaf636aa8f232913092211"
"1151a4df913d18b7cf9d0308f01ad84d878adde7",
"0f4649cf30d4a5269296a45977de2652cb06d3ca2aff4475bb24517b927",
"040100ddcc8e09ba2122a6535c6a0a2dae83abf9e17687b5f6aae7ec6a2df10048f55873"
"60ee251925b7ed02de82307ba219a707705623727f98346a26",
"0a38b2bd0e9a5044db19d4312ec88d19ce1a9bf0eede8c357f898b0bc67",
"0d0ebabc8761ea215808a2c3035b14b614f64be0c2741b3d7789a8659ff",
"0f9e742bdca44c11bcab196f910c0d887e90f250817ee7027f6df8207a0"},
{NID_sect233r1, NID_sha384,
"87c717eef6dd3c7434b2c91de05723783bef603d170f654b49a04b067b077c405d2d757c"
"e780101b930196ca4261efcfbd3fc1ebb762cc0eecf101072988aca508c41581936526d3"
"f337053000dcf77b16172492c5d654c6612bbd2523a6ad5966d7091697a29ce882fe331f"
"79a7eb59e5a3fe536263083cc59b8133bfd33c1d",
"0cca24ad914c24c011f41f80d27ea41caf41fcc8dc9dc6dff5248b2b474",
"0400175b73db13324a678b8afe086944a7ad257cd33fe9538c59b9177d1064016a98ac9e"
"0ff59de1ad94b50f8c709ccf4342f983c7530be64c3f1548fc",
"029c83def3a5c386b0bc3cf2663b8f4b02f26c6e3e14fcb17e9460087f3",
"061df783609ceb355aba3b1753d38f42434bd75c8354029966e7a788be0",
"01e8a093f53a1d73d5a994b97f2b2f210125ecd3dcdf77c68ea3199856c"},
{NID_sect233r1, NID_sha384,
"9bf48c2aebf473b3a4a928b3b6a4d2fb7e9193c9e60bc2067f9f03083a8cc7b892bdbf05"
"601118bcc34dd283e7be996bf19b0bd36727eb9d65276b6517bf0c77ae0a9091e7a9e461"
"82a2586eb22324939801034e5ba94ba30d1bde7d8fed51eb71036fab6224f8ff30a00842"
"2efcff7ea239ff23b9f462777e62b41b396c5dc5",
"0f5e12d536ef327e3b0ba65ac5fc3f7f4880f5968f3340eb8868c1d47da",
"0400b2910f5de9475486b3975ce91c02187e8803e68586f3a1df14df67648e00f28af536"
"3ed851c42daaa810afa1fd0d2e001da7764671fd44fb6737c5",
"02a018753965bdfda98512c7f9da3e9235a4a77aab9804437b652182347",
"0b6fd02b2d84b7baf1a5eb592cde667ed6d4c2c821ca336027a72d9abdf",
"02253faa5935885945121a374010b2257123cd5db4c54a2aa0e08c8197b"},
{NID_sect233r1, NID_sha384,
"716d25519ae8f3717da269902be4a7566d6f62b68cd0faae94bce98c8a4ac6f66215ebac"
"5407d6f64adf9d53f79f02e50921b6f0e8c805926a839443d30d9294eaa802faa7c5471d"
"81fd1db148cdc621a8dd0c096e06fb0b71943337d5325e1bca77062684873fe904ed9012"
"474ceae5b138e079f941a665a995026d13d7eed9",
"08c30d93536b8cb132277645021775d86c2ba8f199816c7539d560ac6de",
"0400d69332763cf533d48e56065e1b5255790f8c0eb23471fac9b945e6219500292df8c7"
"7d9a6803f60bf0722ed57ae2aa3bc816403b000fe2940e02dd",
"050967928d6089da5b16c88b7927de210325c8d8f5e727fa1ba3bd95b5e",
"02434697cb5c2ad95721943154bc81e2ae16332fa6629788f505bbc1522",
"09a5a6792b1b9c2e200ace5a3d50c04f69084dd9222c021ef5fce14d4b6"},
{NID_sect233r1, NID_sha384,
"01e76755007b2ee5ac9e1d4c8adabad6d0f9c1c08ac6e2622b7c1ead89bd3ad0921b9525"
"b49a780a262fe8fc0904a80391717ad7cac9607de55f7c744af8a132ec45ce79723f4a4a"
"8c8b9ef658b360bd3890df164c9f1cd74eafb74feea251a34514ff2a57ae7a6d4bec2067"
"cbf6ee4fdaabf13721bf9ae178b9034ac5e9665b",
"0fa3f15a506ccf7b50bbbad0a54d3223f5a95eb54f0d1f4e5d0cc21469b",
"0400e797527d57fb3a18c71d1e82e7935e37e719439952d4b972f0c1e0c83500a345bef4"
"c5015e97a148b8991bed4b7ef48947b12f316b5621e94d49d5",
"075afdc12d4d50a7495f5a7d309696dca23e9356a0cab11c3b3d7b8c54d",
"0960ef460000fe8c761038bab7e29d665100494d0874b6556862c2808aa",
"08d3c004426dde6c18b1c9ae00a44ac947e36755d8c40eecf47bfa963fe"},
{NID_sect233r1, NID_sha512,
"e95abeeb2c51a8cb75ab74253dbe130b5560cd52e2a63d501d26e1458aa568aca6694be9"
"1eee5fdfcf582c47c1c727084ee2b2c810281cf9b095808bf7e7c668eff00a6e48b06df3"
"fe6a445e092c24d5687d7d89acc8063275caac186c441bc697b2f67aa71b03294e1adeb7"
"e557c296dd91304ba0587cda3c984619f1eb4f2b",
"06400a4830889115aa88b860b3fb65905b01fd126c4aec2785518c2543a",
"0401a2051662c1681bbbf6bccbd33c44c7c7fc80b81a1bce14caa36a73f7a8011583d3ba"
"8f22080488471d8103f868100a97af94809b58bff1435b16a9",
"0ceac6e5d10c55888b9ecab8d3f6ada7f4d0bde2f109699157d194efa42",
"0c148f2337008ccc3e61501dc5df3ec95d3596d97eae96a7ab085a915d8",
"036d1debebaaef50243005e25c791b9674cd6fa986dc3d32e089fbfb2ec"},
{NID_sect233r1, NID_sha512,
"bb8d8515365d240b2071daef0d80558fd3d0e059be9f6abb7b7a0a5f47e2ddca7d1b3b51"
"01d5c583143258520ce8db0a87f877a395615c9bf879ef46f2f20f68bbc9706f82781fad"
"69019396b27f292cdc70fff1772e90205a2225f80889f9daece1d03914d8776ac5bad24d"
"8fb190ba10a2ca17768b918c2e079d83734eb372",
"0c7b73c324250f14fac0edc941f79bdbc6933ee8f64bf94b847bee5eef6",
"0401af7266ee56bf0518f2875d4f4d9ec508a01769d9c1fd0a885a48bbd80c0084167ada"
"99502475478465315bf8163870a9ec1b43f15d68f0304ab03c",
"03badc9b8098c3b4d7e943a2365093028b579519031a8643b50c0f81eec",
"07ad4fc96c21963395f56eb63e1b0b4d2c93d827626e7bd4448697ded97",
"0e7504e6a9f662472e3e6f18a40f7645922fad2ef7313d600a5a6ee314d"},
{NID_sect233r1, NID_sha512,
"cd8b2403435fac9caeffa21b55eaba52d7efee0f89df7142340cdffeb89556303ca01a80"
"0429397e2ff6c746743b6bc60a87133274282d4cac02e4ca90ad95d80c93b84163b96296"
"f67d40b2a1124b2b6534ab6b60fdee312fbcdf468d0e84eb85fce4ff360136bb31ced399"
"8d29cfaa3ae685e638ee272058f123c4f35f8b6b",
"03db7f28e161abf52ab0adc8c4c8544fc989af081303b8688f22b7b2eb7",
"0400ab94312e53832265b929f3d529bec33dbcc5c17b969e0afbe2d559ec3901d53b2c1b"
"e229e2c224e6e9fcb8bb0f044f3f9f5677c60bc9454f36eb06",
"034a8f980896284fe6d28b0b49703f1384d799e3f11a04b1e62da12965c",
"0e374fb355f30d7e427bc5db99ed76a914d6e286099c72f28c07302c741",
"08d5ffd41f8a1fd3de6c433635fddcfc2b21809d91496ac17571afbb856"},
{NID_sect233r1, NID_sha512,
"4bb08eeb202564efb5bda40777d71f1bcc4c7c10b611e803e5c570876f3e319e9e2bc2d3"
"2031c56a32fc0d1fcf620d4e4377d881e9e1695bcdb78acba370b849115b86c1c4b83edf"
"a03299da8e7fd14c7cadb81a8e4911c8e427e32c8c9b67e317575331967cf58085cff0c0"
"d48ee0b8e7dc0b49687bb1c70c703a5dad08ec81",
"07e9d2fdd017d6da6029e88f78927d9ac9437f542db1f1fa99e32bfcf1a",
"04018429bf08752aa470a8f0801170a7ab96adfb168ee8212d76ab0b994e460072a5071c"
"e308d7daefb3e8f4da4681842ffe0f35dd8b071f0775c83f82",
"0a0f330e011d34714875500b70c881ff6b1c9e96da930eef75ec78ac120",
"0439bcdb86d40e8f64db5dbead95d85d6a771d811480c5765ffcbf75422",
"06c01f64e2812d18b0946ea4e6599e8cfca0a2b606c3c35c803ef2cfed3"},
{NID_sect233r1, NID_sha512,
"0bce683d835fe64e6484328aa13e18b0956f6887b5e4442fce36ff09aed015889794e79d"
"a8aa60b4be565c78685674c51e1e7ac60db6a763c777198a56e382a03aff8b40862f961a"
"e23e8b8683b76a5577769422418972ab0049119382edde9e752b42e8b93f403c1ef8665d"
"7ce8530ce4ed9ebf6d397827cba6b7645e177231",
"0c94052760fc74c2b405ee4dd5dd2a7d38ebc16df9cc32df706075450b5",
"0401d2a5ee02d97f82ea9c8833b825cc57b0cb51d3f2a2cfa7577eba676eca0149c68d98"
"d0e9cb242962326a26164f3e3cb6d81b51f281474b0f8d333b",
"0fdd3ade90da682676d40008cebeadb9b2378d8a821e9e9428018cdc768",
"0f6d244daea95002daff2ff6513da694eee58f8b6c2d47ad121be87559a",
"0b04788fbb5655a053d0fb7a38c39e1fef68ff17860442ec8b8ad049842"},
{NID_sect233r1, NID_sha512,
"a6defc770426daad4dafba3bbd2a69881334f7c31269b297e440926db54cdad3fd7ad200"
"f5ada2b72ad221ad99a06ecac9c2563a8deed89f0d0896991d1a652f6fa282affefbdb1c"
"1985652300d1792725071631d75a182b683a48448063c7d2563ec3d430e0fd3acea33a35"
"cd38ec0b5b07af96af71d0bfcd879d9864ededf3",
"04076b93487c2da8aeaeb4725fb53b7b41b465315335c18c6ca041175b4",
"040158755fd290910498f6c8eed83bcebcd1fcafef4878c860da118efa250c01781fdae5"
"01c2c147eca2c6c809d9428fff2f853b57c7d6add70fcfaa0e",
"07debe933553ba3420aa06e1bc52a1653f8a19b59c0bc9c47212389442e",
"09e09c6d96e33c845535468ec7f5b79cf30123538011d0b5ffd935d168f",
"0963bbae921317666f5852759e9ebf05cd026a5d9f026942835ff0daeb2"},
{NID_sect233r1, NID_sha512,
"7803cdf4758c199962b62943f475c6c31356f5d9b997a12e21146a2399cd0dd3b97a860b"
"2ce639e2801571599136d4a8cdbfb12fd1a5ce22374991e090533ff42823a2c58d2076b7"
"72814eea7fd7a1fde68263ef912681c72c7aa3e5a7cc44ee8c65e72228b7631e600121ea"
"35bfbbc783b6ae3c0c8f80198ada218be533760b",
"076ddd73ee4fc1f5e6766e229cc7236cdfce312417ea291f7c3328d5ab1",
"04015185e029c0d4eb5102e0fe900ef3c921acc744feb44570a288015d090800ed56bf93"
"394a434cd84b521040d40452bb39755da5e273a05e8c0ba792",
"084e9e4a9c84a602c18bbb6b183d06969c8b8538e2ff901f1c2794d5eb5",
"0fde8e9b1959477ddb3423661df1e7182e4b583849d6d17fafd7dc5406c",
"01a12bd30e9c8b74912c670c0845ff5ecc77f29797160bd4992efa61f4c"},
{NID_sect233r1, NID_sha512,
"e789461e1dad0b6e21abeb6ae2e96385549d1bae39415188c8f833233da6a3328144c97d"
"db36e0ff4d9e19d84f869e79e609c51b32de59892fb0446dd28cc164a3e53534c950d26f"
"87fb74e682db2038cde778bde06c3ee2eca2a077d8fcc2b0332e352e0e7e6487444a8ad6"
"0e78ff213b16fda9faf374dc6d27b7a3c4c6d196",
"07e1f8988ad804aae7d09a99be19384cc599e7652c02c391542be74b17b",
"0401fa4751e507740a7345e06a8964022fc6caa901cf0c2077a2c0fb86be8a00683c593a"
"0bcd123d958deb6b430d49d5a2386d44706f4149dc526ad896",
"01d288de55b90dbe72cd8f1f86a3ffbc2902f4b5f0cf4e641d32aec6f20",
"0048d16d87dbf4fb8e994dd874c10d5d16846b9ce2cbd43d09df62ca970",
"0e2ee47f422095d629c188df97e2839fc6239b9e2dc26baf8161b037236"},
{NID_sect233r1, NID_sha512,
"9b58c145d1b6c887f2b25fb672cd49c3a1117224be697c15182d4048be92968a6500f8bc"
"f747fcf33145c13a8d72e891a6e0c4c7310c2b62f3181bf586fe32f1ecf4feee8c2c8bf6"
"c2bfdf9d5f88981ce080095c93e49a772d8e7b59f9cffccec3ca2f212ef4c6748f64e224"
"f4f098334d83108bf6f8c7b43c5eb549f1526897",
"09b2292b0244c2aabe8b43d95039984d504ebe05eaff318760e4dee739f",
"04012618d89f50b7f83ac470705dbe9ed81beb03929732a3f2aa7a636eaf59015f0f70c8"
"08e053b112a8c32ee422aac2b926c5b6a279a787fddf819990",
"0fb38174a83ceb9236fec8ea39be2b3c77c3dd2cf42d140e27838202d08",
"084941856a387a56022727f81a939d77d12b01dab603ea0cdef6d9cd6c0",
"0bb9fc30595f94d664a590ed4f163e4526809819baf96bbee629ff86bd9"},
{NID_sect233r1, NID_sha512,
"52310a901fe9681a23dd6e02f12974d57f2c4f653322d9a0ff8b338cc6c2bd9f4765c90c"
"6b3c9fb17df3f492e67d204e39d81a8fdeb92c852a1dcc6151ed6c63049037235c6751c9"
"a902748163a567b714725b4d3995e0edbde03215c645b1a1da3147f7406245432800c50f"
"823a1f991c863427ff4c68e4e16d1b106ee40dd9",
"07ca463b50fdd92d9163f1c2bdfce2ee45ba1437b79162e3e959b814cab",
"04008eeeb146216c73ccff0096e1100008f8b1f3f0c5754c0abc4ed39f7f63018c9228b1"
"1888edd66b2e661284f583a0e8d3c3e922932cd9fc1568f959",
"0025291ec0dc2b0c709c5e69695980564552545c2497636b814aa049ccd",
"098dc98457ce6e69f77123d5d2460ff569786dd60fe07e847ed5bc14da9",
"0cd320afad2a4247fea5b74d78dc3df8967ab3159b4c8b191814d368dc2"},
{NID_sect233r1, NID_sha512,
"ff419c011601cfaf833067cf28dbe6e935ebeddf8b5111a97f6eebf3bb28376334f329cd"
"877a134b074790a073db766efe018fce666a34650cbac285ae856fb6b3b8b96877282bc1"
"1cd9f9c8e510ed1f69bc2725a44a1d2b35de1edfd8bc9d20c7525ab0bbc27662a7cfc1bb"
"d1e0f4fce5b88411521e3893e027cc8c73acdabd",
"0c3844750f63fe0c2e930bc38fe88522f4e72a2fd0db9778ade20e939b3",
"040075acb00b5999f8b272a15a2cbdf8cb630dc3eeb1e78e58f58e467396f2016711aca4"
"24ca335878d273eca75d804d3f009a1f3628568530ef265eaa",
"0a63e7a20d100f14b8b709f0a6c383166c2151a36dc471f061b0f20dac6",
"04063be9d8e4f0f9afe0c79374c69b36910b5d2b1010e0f4db2e4cd23da",
"06a6eb90659aa79e4a2360ea9ffb99a415175dac6c3efef104bef6fd57e"},
{NID_sect233r1, NID_sha512,
"05a89c4824c5de66587875011e704bc6e06e991ba8f3aed331cfffe55aa266a08c729f77"
"b8d082dca4d286b2d451ea838d726cc2cf298fddf2d7376714c5e37b64506f353917caec"
"525a1209391449c078c5197a371feade74f8fc8a1a1d67576edfda13c14ad324342fc0b0"
"9277941dc072ec0d39434ff1cb91fc59478fcde7",
"0a3bea235dea86506be4476eb7999dcb8e584a34238c4a894ad6823b93f",
"04014093a072c21c44d1c4beddc5c8dd9a2845db0935bbb4e1c4edb0aee032013286ed58"
"4deb744c9c35d7ae7eb9cad1c7ba2b670642de0399b230716d",
"078eda19f0cced2f84c1a7b354e5a79bec035b8bb279473f32d60f5d17f",
"0964e817f0cdc251eede4157a9bd830c476627c3f27d2931b4f593b0178",
"08dbf34e597ae06ad92b13900a4944e54a5bf0f16f586baad157da6dc96"},
{NID_sect233r1, NID_sha512,
"13e6b5241365d9d0ef9e8b05cabb3248afd221ec02eab92284b98bda3d9272184bfe5251"
"d35705defba5085381430e99b33a3ab77d7870e5102757d065862372df2434a25556b76e"
"54ebc39d4e6c3aba5cd6acf0c335756f7d9385c1068d4cfa37526a9a58c0ccc7f87a8189"
"176c5d4f201499236058ec061357dcdb5acdba40",
"09a367cd1cffd8dfcca179e167ea437ee48e9b6f42559dda9224701d3f6",
"0401052d751901f6f8e61858d3b15eb59dedd21e4e997531ef65622d5750290112737be6"
"7ec621509d73cd613d7b448035397fa66eb881f90a6d531ea4",
"0d8dd8f1cab623ba6a4e840962fb31de97a4d14aa6dd34dd21154105030",
"0a8276d0f069f34c60b26a55d47df69e4c9ae2981afc59e14b5bfcaa498",
"09351c4b3a06b839eb2e9f450d9c3d15efa45509886ea3f2610ee1dd156"},
{NID_sect233r1, NID_sha512,
"139a1a5090b97afb8fecfff8745efacf7dcf91a4393a7b629564e598d58d5be39c05c583"
"0d4c8ca85d29e9e2c31ad0447864e867d0ef4788ac734f8d871daebceda98d449308c2af"
"be97724c3af8a468f1925065f39e52ba4b7d15728a744b1252a20476dcfff7bcb82aa72c"
"209e72abb3c24419bc26191390ffed340c1b9c6f",
"046f4ad2522e78b9b35297d28f361fb0ce82306322aedc119251d8241be",
"0400b976c53a966e0834d5f6bc3af10a5f12cb6d16cb2303a3c6cee7d35f2201a1097cb5"
"6662265f4f2f52df375d70af086264752477c34c6af522f1ec",
"06a0d21e5aadcb0c9e3f9fedd2d896b0236dc90e33778fb114e970122bc",
"068063fe0a31b7e7925cf8959c3486985d98f58224d5f67cd0218af192b",
"0f11a22ced98173040062ff9e69d1b2a1b5a939eda0a6944e96fc62fa4a"},
{NID_sect233r1, NID_sha512,
"3315e5cda5f252e3291b61e493ab919c20a8af1286d9660cfa2f5ca38b6defe19ebecf82"
"0787fe692d04eae8a5f5d37abfb593309569cedf45efd0cecef6951b718924c8380ba52e"
"8ab8c9bfb2261ed5f01cc5a5f9fc5fcdd269a0f122c597afdd9a836cf8f96838c3e8962c"
"1788c3ce4128719b3ef4fc88569643dcad6da16f",
"0ac82137e9c7a5ecfb8b1a7df9ab50732934566a392a6c8915ee8ca8144",
"04000f7f835f8223fa6c49eaf6650e33dc9d09e1d2bb098925d908606570b2006e659ce8"
"623767e8214b076d7588746bfdcbbed59b75bb19477366cc78",
"080655784e3e31c6a498a63d4d84f7e5a353a66641ca17d4e223441bb1d",
"07faf31d1d31ef4edac1c63072350536df84c417e0ef808c6be39617e74",
"089023aeb53ddd3e475d11c53479863739e62dd64348646581012784689"},
{NID_sect283r1, NID_sha224,
"067f27bbcecbad85277fa3629da11a24b2f19ba1e65a69d827fad430346c9d102e1b4452"
"d04147c8133acc1e268490cd342a54065a1bd6470aabbad42fbddc54a9a76c68aceba397"
"cb350327c5e6f5a6df0b5b5560f04700d536b384dd4b412e74fd1b8f782611e9426bf8ca"
"77b2448d9a9f415bcfee30dda1ccb49737994f2d",
"299ff06e019b5f78a1aec39706b22213abb601bd62b9979bf9bc89fb702e724e3ada994",
"040405030ce5c073702cffd2d273a3799a91ef916fcd35dfadcdcd7111c2315eba8ca4c5"
"e3075988c6602a132fa0541c5fda62617c65cfa17062a1c72b17c975199ca05ab72e5fe9"
"c6",
"2af633ac1aee8993fc951712866d629b43ed4d568afa70287f971e8320fe17b69b34b5d",
"165ce308157f6ed7b5de4e2ffcaf5f7eff6cc2264f9234c61950ad7ac9e9d53b32f5b40",
"06e30c3406781f63d0fc5596331d476da0c038904a0aa181208052dc2ffbdb298568565"},
{NID_sect283r1, NID_sha224,
"44adcb7e2462247b44c59608cbe228ada574ecb9f6f38baf30e42b589fb9b157bb0560e5"
"a2aa5523b71cc0d7f583b502bec45d9b8352f29ee1842f42a17a5b16136feaa2efa4a0ae"
"306402940ecd6b71e57d1467c98e7960de2a97f88b43487e4f4016af1292381d70c18c7e"
"6eed99a14cdeb5b3caf73688658e4c5b54c81e08",
"09c2804f8cab768248fb3fff8a055b3f4585c00de5c1615a19f9425b9432ea09afba8f2",
"0402570ff62b03a5124f08f752aa71ddc57944cd94197fd286d5a2a107b116d7b8ff1b04"
"21037714d9abe9aa0a9668fce89a3fcd5cf2e4548102a181a777c9b3f1008ac6e8d3a31a"
"2f",
"0dab5ef658ae3e2ce2bc5c88a8b8022a0ca5eb8524815ffae414327e3afaea5fcb8a7cf",
"2d99f82d92c9554722bb793988af0fd0bea776c5608f5939db7c8634eeb24ffd381dbef",
"27ceb1d01ec9a3ec0e74d79e08024359e117488020de6458fbbcad28b173918fc7d129c"},
{NID_sect283r1, NID_sha224,
"cffee6252c7eb6d91d8fe100a1e62f0ad9f862d78ca2b747a6c17b8c9ea8980dc239b3b6"
"73310e6e7483582399163e39d889abc1a613fe77849ebc09b4f7f4fe0688b8a9869ae918"
"a88294c7ee199be50ee9460db14725ae70b449d0cb48f30e7d817ec02c0cd586119341db"
"a0b74f0279330807cfccc99c8c340b72c1764a45",
"2e625a6bc6d0ce7c06231de827068bdb0abc8ffb57c82b35ee3a0f873b9473905974d34",
"0400458bf39974812a4e0964c31f40083300454104c0d65f22c5688bfff3c256b7ea9589"
"000738dd33e32b9af93ade2dddf4147187a9270543afdfd66a0f2a53d6d3d815ef59795f"
"60",
"0a9388815c528fdadcc5d3b125c7a38db57fa8c163ba795ee00e8e307bf760619e705c9",
"2481571400ecf9dd31dbd9c905fa1006cd5bc7afae759da3312ead8d5a7dd0c25a37ab9",
"13952fa427d348b6347b9e93d4cb2c4cae3429dbea6aafd1e58d5a34805098722b3b8da"},
{NID_sect283r1, NID_sha224,
"d058ab5dc07228253707ef224897ea0fcd09c3d5cc91fdce9e03c1c59c53fb4596be2ed9"
"29c7455e67ac7f4891aed3eb06ad88f2c4aaaabff045b959f900d1019d706b6052637585"
"1bb891494e99995928e4cd51c9616aa651ec77bd7e398916bb9ed3156391bf7fb1e29181"
"e2b011dae2edaf803607def2ac6b194929a57f45",
"376ac24e1b86f8a55c052d92a0bdc6472fa03acdcdbccbf7c321ec0ccd97aa0a66b4181",
"0407247c755b23bddf944e29348da82495b4f61d02a482c6111d8698cc77e8dda4c341f2"
"0b00f8c199138e1f4f8344facd90ac62d55f3c9a15ba7a672ce40241aa26419af790cf7d"
"d6",
"25d07c7afc5a335c2bd7863c1965a48c12f2687b2a365a7c2700b008ee8a0e8e35a68a1",
"23fc2837a879b79e470305088acf596eb0159edc2008478cc4c3841a1bd66fab34bbb5e",
"0a909b83bf77e74511063366ea1d1308a8a544864783459a60fb2669785ab1af8f4cb06"},
{NID_sect283r1, NID_sha224,
"c86f2cc7ab5df5cf1a236fd83792769474cef464032800ffe98a44cf29dbfb6f24088160"
"eb31a11a382ff2a49f3e05e983462f5304272f96c0a002b69af3d233aebe867ee63fa466"
"66760a6889d022c18645b491f8d71b6a3b6b4ef058e280cf625198715b64b025bf044944"
"5d3dd7e1f27153926e617bd2c96638345431d1ed",
"2b50a6395fc02b9ac1841323de4520292f913519bc0d6a471aa28021322fc4dbcd7b802",
"040696d5ac4bc40e679524e246210b7bb0f93ccfe7dc506ba87be3fd018f829c93e62ad1"
"d8065953e01d9db8fc5d64516d864a33aa14af023e601d69875ac0f7af92a1e78aff0e47"
"5d",
"0aa25b43329de4e7739fd9134e4f4b3d68a64e55af47a2f6ccf71f518f19059b68d34cc",
"1338a5dda5fa09667604a6a7666b0e54e6b688b98b31c25d037ddf55ee6bee7565dad09",
"00aec025232c16e778f90785ded5348f3d5345b8344b2a762480383777328e0a0b11cb3"},
{NID_sect283r1, NID_sha224,
"c1328d8d2e5b6ffc850a9600bd6482518ddd9cee3fc9140febb72bcd444b0cd7e8074587"
"d51b62cce4b3d4f34ad3355353fabe363369cf790db2df9fdac3a0ec4757e2dfb3b683ea"
"a3e26531691ce765742e1c0bdc0e1028d347b6085fc459df0989c6a144271454eaffe413"
"cae2ad7c8b2371fd2df1afffe56df727009765a2",
"24e5889722f6c35e18ca47effa9e415b1ba790066a91fb3c9f7b001ce28fc732b09bc23",
"0407d4a57e6aaec6b51dce5408f6a7fbe9ba9d55f5abe2da55fcf015ca25dd74eb61c155"
"6c02123390178b2992059151afb51ac652b364f562c65451eccc65d968e9e7210921c93c"
"9c",
"320d2a7f48cf3583e8d7e712b330d40ddbe4b6c128be5a43d72bf57d4227603762de7f0",
"09806a8e70742c6c4a9ee6f77fe7a36489e1fe8c442ddf9cdcfa61f019ab9b41241d949",
"061fda247ba7c198aa532906bc01d509088d6c2ba0f14ca3ecc5ba36f3595db1df3e64c"},
{NID_sect283r1, NID_sha224,
"7176b7013ea27e94281977eacb976bb31c753bf80fa09680a29128a6fc15234f79f0e990"
"0aff3217ce9be72c378042c6c34fced0158740073d1a985fa25987fb218002e425868fda"
"5a47de51abfd04de34e2b8634cebfbdc98e80f93d94096193eaa82dc8778fc23f3765c7a"
"cdad94fdaa272df0ff0f28190c10a462ee78ac92",
"056d15b81f40b6378588a5efe43e21b95e18120d514bfdda0e7759a1d0766a8a35ce5ac",
"040306cb78fa576bdd2f43cf7b71d7e66a98b850d87ac087dd2e1ff62596a2e8d4cfff13"
"4403b1e3b12db842e00c2faef04d3e39cdb71546e4e3ecf21eacb6131c3501fa30edcc0b"
"70",
"1e8969d6cad41a40d8306d2a8db3290d547106eb59f661e0d0eeb163044a92aee4483fc",
"06786637c3bd5a95eba5ce015f151d99845255175ebb9e593d912c75cc45723612c4ed5",
"384471c17c45ddcf62b588993835bb913be88f7a8e46e52e211972ffb3b7768410bcb7a"},
{NID_sect283r1, NID_sha224,
"4c3642ba040a9955b9d50dcd1c936688c17c363854358afa8ca49c6abd906dfdc4d89bb4"
"cab0bbc363fb5b74e1f004d4b09ec9dfeed4c0bfb482a9061a1f487a3d79195ff7b65a05"
"04bced3a28db0ebe8fcf8ab1ee4a3ae91324d15d890ac4c479144dd5538d2e36d3a58776"
"9ee9cd2d5c6f85a03362a022fe0efc4a3902b71a",
"12fb2fb5bf5f7e42a500154823a174ba2d05af71e3b0cf47fab46e673ea1822f1563def",
"0402414d172d74a6281169835d18bfaae91f1f1cdfa9ed451884466e63160ecdd4a2c790"
"6f02d892bb19b47a4fd9d851d3b101ba99acf6d11345596635cedd5d7557427a2896a913"
"c9",
"20786f42d77195bea5761f86dbed8b452f858b447d2f3775ba2a4865d738122363b50e3",
"334507412368f08bd0992a5d56581ea7139e8adc88abe4bd80dfeefdc7a37a481b18609",
"0fd8404df06a02618cdbf6c28610d5dfac9907635d9e5f2887f11a7f18cb8b7ac95b5d5"},
{NID_sect283r1, NID_sha224,
"e471f39c18b081362adc7da47dec254dab8d765f005ac574640d78c14222639245563912"
"d942f3be212ee3cef134407334c8fe3602fa0e1629de5331643d76715dc1b0ffcebd484d"
"86c5211be4b285a31688b205fa988e6c15b36daf396ccdcc209c7dde2a732f5c31c84c7e"
"a041408ebf15e56632583af0131bd7f531b5fc45",
"30096c54fd480647e017f8cdbbdef292e799f054e3279d228b09816a757566a744a8266",
"0402d4b28fec18cd888017fd5a27a375131bec3aa7195c0a4f255eeb3616437079e356a6"
"cc027c607dcf0b068418eaa7de8da6f9707650e8d95aec571f7ec794415fc175061b4515"
"19",
"36880905a376faa594978713c2de1a90c8e27baee65bc60b1fa6508fab5abf843f66ecf",
"295193f1c64181bdf749987bbc8ff2a188126131f8f932bb8ca952ffa201f109762e18a",
"381c496b4035bba880225dcfe74fcf101103e38f9518d9427c74a5ec86ebf8f7183694e"},
{NID_sect283r1, NID_sha224,
"8a93fe53e83075c4025228540af7e96a588520da34e3eadeb99a4ab2f3dbbb8f85fe63a3"
"b86c1f4ec912e665ca05b43e869985eae3791b91205afb1380e16c25b74e6793fa63e4a5"
"5dcf25dc22d03f09deddeb9042b620434111afe08c5657c7d754af66ad91a1b5423301b1"
"e8e6389a1404060d1b6a99fe0f89598482979e42",
"0a1b7e9c8c2dc25b494b5ef3195b294e41cd3c2c35235ab42542bd3e2a52d5826662bf9",
"0406232063dbb66a56e2a92dbdfd9b3c136eade9c214d831691d9b49c56a3962d20f14b8"
"a901b47b85bc223fde1918abf6308b74dff7f3e686af9c9d7a1855a1b77984d258c1f9ae"
"da",
"29b4221eebe151fe758218138535d81182c991c3b7fed93f9a6117e98c1c2f97e546937",
"1f8040fad671e2f32a1094413ee955ea5426bc906b8e034d87d7408e63db173b05afbfa",
"22a353c431a9e9315ff69facfa4e15f6e6ee1be2750472823db31b49b17fc759e6b94db"},
{NID_sect283r1, NID_sha224,
"e193a8ef6f454ca1aed38bb67aca6d08280d421b196d89938c0582b7cde74dafd71716f3"
"818940af412d4a7ff3960a8517aee108ae03576b68ee7557d35e6f1ab823d124de7243dd"
"02b542591f62c80d822608572889573e4c9dc62f99d68e07800da6f83cb6f5e03d1f2ac1"
"5f90e38b4f25e0a75e354e4b60cc81c0bbe81d39",
"059b1a8fb84530bba7a607ee88310e31bc6ea6a6881603567a1081a05a3a9ff87e719ef",
"0400b9a71aa3cb4cff37586b1e522b0e332ad5962eec3dfeffcef3851976baadf611ae52"
"2606b1bf0b43b406b5edc6782fd391d9fb070fa3570d3cd5b2b66d7a95dbc45ccb162617"
"2c",
"00a77307da9845ec4572a24c9e74a17b76b6393da87a9d7b1b8456235473ff39d243ec7",
"36721835be490b5ffc4a42bee3c6d231417f7038c367efd9ecaf7fb3618ae8492906de0",
"237833bcc3e4a721e2079e579d1aaf2519c01cc238056fe0c0990dac7fe50e75eaf6f96"},
{NID_sect283r1, NID_sha224,
"8a99b9db191f6cabc88b430bc2293e6774d5180f019d871839289e25aec29379f14606e7"
"42190b7aa062e3b29fe0254146d9614856c5140c7315015abb98ac00da2c7e33cbcc82c2"
"4b797366f12767322c4381454d9d1eeaedb616b0ea5c66d1422da459f18081f4f966d05c"
"e279c6ee69b1bf94b8388d38d4b770d9ed69025f",
"30ddc2c7a4ce300cc2b75f0f977033f16c1f8bb13aae3d494c381f9a6dc8622499ae4df",
"04047bdfd7c77ae0c53e327c15c30d90ab1c9b670fe2241dc0ffa939fec3cf6d3c1f493f"
"3a06a286aa2310a4d0468b62f3144a9da2e66d15bf86f60045824278e8986ff87a276119"
"20",
"38afc3d11c66eba3441a5ea298fa593eec57b84ea29973c306ac9d46bb8d8e2f4c8b049",
"06c830f6c0be99fea4712f1c75f5a4e439800dcf062a16d93135c3255d3cd04bef5bc7b",
"1eddfda0d0e02d382ae243e604f76939dc21f3ce106243b2d20aa562b78e620fb456428"},
{NID_sect283r1, NID_sha224,
"5c437b331831530aa94623b1736f00b986172699f0a02a5e5df0008bf25341787e2e6604"
"6f2c929dfe0058c3cb89fc5bebbe1025bb1edd1ee31522ed568e7b5b4ca3991afdc76a68"
"cbc2c4f81863e27fdaf6a564fab2c6354e5c657de81390f8a4132669fd24a48580c716b5"
"b7961a9c091f614d11cf45dfdaec8946a54a11d8",
"07899928922fbfdb5407517725edf231d15a8b62d90b7fb6d8c8d20424850dc44f797ed",
"040614257f54514cf37df2cd78850658a85ee362764ab8186423aa0f9a1ff486557f8f16"
"7f03ceae9d1370df045d20f576931ca63bdba8885f463d5c82e5edca5116ed3d2c2b0c48"
"61",
"3395493478e69e6e1088166f622a4f9ec7feb998aa552b54bcf0fc67c06079f45a14993",
"3f31ad171dd59c9deb21851e631f223584b17f72a6807d5239ae31373512def954d5ebe",
"28f095ae43ba5bdd899573ce6823eccd8e127c6c03cb59dff43c087ca24e1ce5504d1ed"},
{NID_sect283r1, NID_sha224,
"91aa08567d8da4c90684dc06068f69deae240212842ff1786f04ec41b40d9187aa92c764"
"01f9fcedced62876a34df82ad7c1e63b68bb2a972257ea8542bda6a7f1a020c9b122943b"
"6d651abda8b8d322a8fb762eee376daa2d3637a71ed6c4f5cf96f61c0da2d6e1dda3370d"
"80e51da2cbd8aef3267168c67359523faf910dfb",
"2a2af63d1171930758bd3e5bfdac62cca1a83a3b55a49b3f80cf0d9ee4b2082757beac0",
"0407dd6fd0868ec478e7e5c08965fa4f1efe8db4d0c04f0b6c63b5dfa397607a0d9d5ce9"
"09054ff4fba9058179a2c61951fb4955cb637b01267f8f08b3aad614738c562f602d498f"
"04",
"179482dddd033e8849abfd4991304137044d7433d7bf858a794340ea1cd66e736b821fb",
"071f4cb000ca1c51c698c867a78961e6d7defbd60109f79d1d165ed045a653ddebabd10",
"1e2975f4a1fce0b3b0e13c3f50005fa664ee9319cf774d2e107c406d36158bcecb0e5bc"},
{NID_sect283r1, NID_sha224,
"eb5297bf408c1a55e400a20a3c10acbc5c2bc6d6ccfcc0941fb7a6fd4d2834415a6df86c"
"3a6c4b867d1215aeb8222153da8cbbb1576c92c07ca2c36d8f243fd911f9a057e39ee258"
"32454e28d7ed52a8d04169b9b9677a16b32d5d211b8573a8986e9bf36d7206417ad2771d"
"aa11bc21fd7ee1029b65ff7c9b2705a6dc9cf9cb",
"35994e89e13916ad82608f74a639e6aceb756ff913aec440519946d6434af9a60a6af49",
"0401f7805dfc9f90d4f8a1b241dc9d68aa41cb77b63d530cb3733cede23bb87ee5118e5b"
"be01c3f1aa3a1218de78a94ee8f88d3f787fdc68674e31792d919dbca681a6db1dabe89b"
"61",
"2116684a4307c67a3d8c1014b33b928a962a8daf86c4031b0c1d47315d74bad7dab2aad",
"33cab952e9382dc074d666f1f2ab2bd72ba394a404ce2fd02a6f7a4dc096d713827c94b",
"33b2886738d882146c0cd715701fe4e8b94b0d28c73a6b79d2899391119ba910bcbe3be"},
{NID_sect283r1, NID_sha256,
"f415d0adcd533dd8318b94560f86732c262ad2c6dff9dc83e2435543f429a2158cd2fbab"
"0d96c027f71008c4895ecc644c2ceaefa80937f6cc6338d15d36e459a16bd9387a361a6d"
"800acfd834ad5aecf442e30b70f5bfa164747cf9f89325b80976052a83a5e896c00c54f8"
"1472b14329cf23bec10a8e693005de2a506ba83d",
"29639da33f48e4fb0d9efdf50bba550e739f0d2476385cba09d926e789191b6fb0a73ff",
"040770f9693777e261db9c700eb1af0b9e9d837ce5eabd8ed7864580bfb7672ced8ffca5"
"98068aef01c8126889204aaca8f3ccb089596f85e2aca773634bc5775ee4d27c77f2af83"
"e7",
"32a930fdb1ba2338554a252d1bf7f0169d18750a4ec4878d2968c5e735f98b9d0c25edb",
"30cd65f1097d3fa0d05e1d6072675f1377a883b683c54b8a1f4960f90d68f3ee8c7bd98",
"15c61ddf43386a2b8cf557760200ac06a480797e21c92e45e6a311e1a508b03c4d9632e"},
{NID_sect283r1, NID_sha256,
"b178d86c9335b85e02178fc4551769db589ab91d823fac219c7e14e2f029753b20396238"
"9476723832f8d9631dd7764e6dd35da290afa42a794476f5c7727b3688aced848dabc995"
"4201578cc7b25801710931f45cba1199d3788d64dc0188412e70723fb25b8ecb67183581"
"50c4037b5b81466dac1686cb5270bb1c72d34bb1",
"0583a7ecbf2a975a32d07428d27ac82e5dc13d1466c4fdfc1e6a05a8d9a289f1010617d",
"0403775ec793ee4bff15027c70d9bb5dedfb7d2e41af8895faddddd4589cc5a00bd222b3"
"bb0300f7cd572d82f2f0a2d99a83977ed2034e03fdd76a0267455a524bd8199424ae5b81"
"ca",
"1e58b1f66c927f4ae16143856d67193d889debdac8eb03936f1b36d550c2f2639e13f8f",
"0f897dbc8ea12f4370fcd08e8700e5e4c68dff97495f401d01b782f2ebbe259bc0dcf25",
"3c32424fdcca39f411663284658b8f0c1f950f0cea4354f02f4b359f18e3fefac0976e1"},
{NID_sect283r1, NID_sha256,
"c8bfe9fa7c848531aa2762d48c153cd091100858aa0d79f994fd0e31b495ec662209a9c8"
"761cd1d40c3d8c4262cf4dc83c4a2549a5cd477726ab6268b4b94a78b1c4a7e700812872"
"d7f41912a723dd9abc305420ea1e1fb1fee41bf643f3a24abd6e8fbf6fde2475e2905277"
"24a6f99fd75374bf7cb01b34d3e60d8db33c4de1",
"0f817ab1b49131fb9bbe8c112c25a36f064efa85de7506fb9cd29d81b326bf276277f7f",
"0402b3a06e07fce1848494d3227ff77d1c43f4ec3c037ad73ffebfebeeae87d3bff7f7e5"
"9a075df52e6a34229266ff28b1c217538ae23b3912e4bae8de5cad9b57b7c1c9ca8aabb2"
"e8",
"0ac57fbb899193b88fbf4ff2c502af72943b133e8d40459a833275212f6644f566f5c58",
"3e13307d5fc2b7ad24e9422355150578c78e1c99a6f9a24f9ca2e8bc6856936c5c4af2d",
"05e8b77b580cdacc2660e6f8a1877d93c5983d135d63ca0e0b06aa8daedf855c9f661fa"},
{NID_sect283r1, NID_sha256,
"9a5f563d0f9fd1f31f3a822de628ae970954f4e71292492d727109036491c29e66b9b0f2"
"c90c26abe94c08502f5e923a9ddaf6a7d91e9541ce90d0a49f03ce4e4769753d5b7d922e"
"1ceaac4b4cfa4262732a09550aa076b8ff9d46a50fa17de17e3b6bd606698464d116fcd5"
"f1ae11bf45b0c48d3b738427cb47b0d1272b03cc",
"2782af76ffebf3e2bfc0576b70e4f4bb87c762e2bb230d278ce776310a14f5b678f29af",
"04000dc21b3be7efaba5c7f9f22591327f0f97083d4d844415d3148d227931256d026ec9"
"d401276f1d9e131f13bb129a1192fa24602fb508c9679ad2124e49c70a891777cd601955"
"fe",
"0255972b5329863f380de945574793beb0430dc416a8f2543330a125ce8d69f72dbdddf",
"25bcb54e188aef6e362a62fd88daaacc8e697dceadc8a6b6f804ce4a36856c8da6de97b",
"1e12e18e1e281606c16ed1f49804f8cfb33c29b0ae92c072d5c41ee3e6836cf1813d722"},
{NID_sect283r1, NID_sha256,
"3d6b065721da9de82cb33ec2c27107eb399b1e69ac8fa51145ed4147e20d72e27434104e"
"76af988a3bc94f55e36677a05182fe2376dbe38195fc6a30673a4dca87336c7304f3f31d"
"49216fbdfea00fd1e105d8b0c13ab11f8892e0045e915c17dfaab07b24ed21b06af5a8ca"
"d4f45fbee5a25bb6e87466a7bc422c0bb896440b",
"31b827b88f14d3822244809096157df3c0aa99da90c00cd9f0b18dfe306f6881834e6b6",
"0407b3ed076a2901ab2625bf05fa6db10a8c156412fd2d26741738f5eeb6a91891575269"
"4606a8cc2061352c36f264d23dc2857fbe02af34397ae5130c582e885f50f2c112f141c0"
"7f",
"0b36f5d6da409c4a27f38ff9686cbf5f4714f4e17234fbee6e6deec97c9f0d4c585d42d",
"356911114c9ff9ae4f3a4fcc5379c987b9d298554cdd39ce124f04707e7fd1ea25231e9",
"13c0a321c4c5a1e89dacddae38a9b3dda32a20627e53dcdf28ee26a550797c255eefe6c"},
{NID_sect283r1, NID_sha256,
"d125f0e2e6135567adec9e77da2afc6862e28d618416632ced829d14ee8b61116da59dfb"
"44098a40a0b927731125617e3d2f32cfbd1546a6e758c1ab6597e75db07add52ecb61d37"
"da2e9ed04df95b36ac249f4cbd794cb561655cbbe4b34834c497b3d392d78ed0db8db683"
"aff0076fb6e43acba3fa2b91210cc6cf3fa594b0",
"27da4916f1c471cff80bfa14d12aa10270fc3b26caed010c0111f6e5a40d914a3927763",
"0407d8202c88fb915446c521884fb756375a2b8d178f6a87306c1c8b67b926e830c8285c"
"150224dcebb8a7c46902532870ff855c780b2884dbce2956cd34dd6ffef8dc365b967534"
"49",
"3fcb1e759418e4539f9be76354cc1914ccf9a111338890eef723431925fa132ebad8695",
"0d4d4f23408db58a72495aaec6dc335ce85309fedccb6ade053c23347abdc9e77a81aa1",
"129b6b322573dcc79704d08921cb54f31c571573da78cb09d0aab40c4036ee8f195d88a"},
{NID_sect283r1, NID_sha256,
"b380f97687ba24d617a42df1b14e5506edc4b62dfec35ed9fd886bb769832cec7f9adae1"
"0c21b7cd9152588797b4efc6b2b30a873d3f25e683ea9be070dd69731949a51121e534fa"
"bfa3a2eae0ee90a454182248bedf2595cd47ad08614177d58f7a773f5023b538f5f56868"
"2c83fb60e3fb1aa859948d01bf7b214e7f2dc719",
"10608eb51dc0ee97d6e488a23c582ecf0ea1df9a24db77094d87b3fb6ca98507280a934",
"040399b3e571caecdfa1efb243323159a45618702600b870954cd614e494bccd70e381f6"
"8a02e2fc57721a500611badf48fb435a6e399cea356d281e853f55ef2cf9fc5f70dc8b3d"
"a2",
"0a8045b4f55115dedd8d742545f9f2bd6e5ab81cdbd318747aebfe9f74b0cbc964b6040",
"2d022631bb7e05d316a1b130faaca5af5eac67dd25ad609e6e2a067ff74fd4ba534db2b",
"04595f184068433962d250394680701fbd2e2bd613a47e5de68fa1eb83cb08fb425571f"},
{NID_sect283r1, NID_sha256,
"3f9ec57e4228e1a6ec49df02c58d756515305e48763ba1dc67298be9a1548576c28c82b4"
"e9b3f62357d9b3c522b16d5c496a39effbdc8290edd2cadc0019e6b9fae1e61238b13b62"
"65ad2ff413a5a0684babdb0013e7632051455e6fd943815213c555dba96cba8911e006bf"
"ddec6c3353065004538f37e48df9e339498d85c6",
"123f9eb8babed548df08cc3afc1d3b3bbed52b538d4654f2088fe76062fbea75b85a560",
"0403b2e980ae7a847394720a9cb982fc1e41f9381b0f2e08b87fdff1bf891b9637cb2248"
"5e04a367d593edfaa4e17113b6b1ea3ad185b3155b1bcbd9f00f4482e509b43bf7eb67a4"
"48",
"2adaba166d703d4d2d431a26200acea7fb47216fd04882f91c5730a55c349770d58a452",
"2c83e6a7b4fd48e1ba4fda8ed7891425213764078926d8862d0eb64765ee2900b3deccd",
"3561a949d583b7de9263d07ac427bc175b75dc52f43f3ebedf996218c94e51684ed5f9f"},
{NID_sect283r1, NID_sha256,
"bdbd7b7bf3337bd9d21a3c6db379f95408c17e49dd394e94737ceae889f45dc0ff5d48ca"
"dc53703a16b5589939506b548f8dfd34c577c084f372166cbea320c8fd07c809b211e074"
"9ea639e68f890affa1569b66bd763c7c710989e491011371eb1d93ed9479ff0216b7f79c"
"901a2023e2cf80b565d1c0517e73117190cd2f02",
"06a18e626452111922e02e31d662f4301319946a204ae8a34f06b91dd1b5b96456365e3",
"04077c1fbe6a645b85fa0316ae412e8dc558c7c066d9aba900650749eb7b14a149ee57a2"
"5901b2f3002ff4936653412c8ccb8a67dcae18d78dcf6dcaaa75061013d2134af2c3fa0e"
"69",
"21bf4ca10d03a93d4675baa26285aaa554836bd0bab6e7fe42600ffe9137d5e304847e1",
"20702aa5b5cb45cbe8025b4ddda0a42a1ab746117d45382d018b2055b62791ad91abf54",
"12c31f9bdc096236d3ec46c4e6cdbcea47e4fba0e28d4df0fbc19e8740ce6dc0577b242"},
{NID_sect283r1, NID_sha256,
"436b288512ea57bc24f84fdd117da9dc1858bae8c11637f99295d88fa9d05e3c053a2584"
"a6fe200ad190b3077d9a1608f660349dda405066c1562f6897ef69b6b674d6bc11fa470d"
"0b96a7cf8f6e098c9ac03b0ef415aa045867ac7c11d16cee78ecf08850ccabf70f761682"
"b561d0d0e4a889d840dc74932648ca2fb58259f7",
"3307fd717015b12a2dc76ada21442ac1d97519f66898b214c2ea317ab0f0905e819e4e9",
"0404ff9b8d60ed177df635a3953c0f5f5c0254224bc48d34329136706d6e8fa1b16ba091"
"6a02e50ef73f43ea9a5ad07c6bd68a82b7239534e195ee929aae7788c073dbe9e968c282"
"8b",
"14d8339f610b348f4639ac20dfe2b525517218f0c71b1908d407603b25f19971a1b5b4d",
"2acf3dc4e3569e5038fe97920de626ddb36bf213afa0f939785dec8319eb8321234c574",
"01db40fa416527266a3949211fd9fec158412c447c392ed6a7c7f159a1129da864d33be"},
{NID_sect283r1, NID_sha256,
"672faa156dc188bf16bf8933d65e091c633f294486049ce96a4a403dca28a149f4f840e8"
"bef47412285363e9e89006614b013a41baad9885f1d9980cc897ffbd5f8a7d0e63feaeb4"
"2c07776efb307ed680ba1cebf470dd9bd8a2a9efc2b1daa569524394f9a50398add1a5bd"
"2f7c263f9e63c2d49461acf98444fd23341ce78d",
"14f9f412e3c7d770626e800d43cfcbba3ae6aec8563af748e8a97b67d244334b6e6d2b3",
"0402293b37c84e7514564635e517bbdb9bda0b4a41217ca64c38e94a4bd00753255b4cc3"
"890088c10bd909964ecfe10c373214544c6f60ab85b8f5545afb0fd2ac03d036db7ea9e6"
"7a",
"19b21a4d73012dd2a2ec3ee280a9b855b89e6ad53438431cdb5d2cec0e5ba21300e9bd6",
"3baaac69d182bf1a12a024dbc9a52ba244a654716e2756c36ddf8ca634129cf9d2b23b2",
"13ed92730d0a6d75f2a4a56b39f82d063e1be988dc58f0ba5f553fa88b6510116005727"},
{NID_sect283r1, NID_sha256,
"4321334cc8ee44f1cb392a4b280a95561809dd3639ddf43b6e11cb73067597988d95b864"
"3d86c76c3c6b932d9262b9b8b55a04fba0666dd8b8ff1e8fdf799ae3945b6e30d3af3966"
"f1a6d634d5e012710d66cb447fc3375130968a2e1e647780aada2609d87247c90338dd71"
"c3bcc3902311caba27d5d4ea4d73ccea960d4bfa",
"3091a6a8bdac1e43542dce752694972e734dca31c061c7d1000754296d0748055db3f09",
"0405c0761d01020a30c478617313c67008a1332a0e6f295c5a9f01b3411eef585a9dafc6"
"9300eadfc6f7bb9986b0dd221b77b54287042ae8d1ae5788706b79a354fe785c66145bfe"
"81",
"0afb2e2e29b26a686368b127e38c2f5726fd55a13e9f87cf00e831d3fe19d9511d07e81",
"2685f634a8c16ee79acf62b7a1fb3acaec0db47c6ff5f2c97a804e9550494b128b2287b",
"12b545bd76b8d2cdfc5452291d5e4748a5e981c400daeb65c20812a65bbe936bc613219"},
{NID_sect283r1, NID_sha256,
"2087e22094570d39fa937f15a3ef0601709a66666344186a33b487d041793fbb9709a95a"
"f250b1df0762ea98e911aeb3ff1fa19f0aca53fd4179e454e0e91636e55cc5b17cad9e15"
"75c82ad265dc34c4a66b7a31ecb9ef9dc756f2ac1d9dab35369a6bad4a0f47e629daab91"
"addc6d297d1e5d81477b3966d8c3b607ed194d88",
"1195921b91353db9bcd00510efffe009c94f6bd8d790f5fb3e5a0101c9ca5d21c6ef2eb",
"0405dd8aa95e24c054d508bc5081546677b9a8e8dad40d3f8a184af7cf07cdb09ffa2e04"
"9805032f208dc3bbad6aaab63211e13e17656c750c6c2a6e3caaf55a7c30ae5ba241d864"
"1b",
"3223c6439db7255e89c28aeb046e906ba79f4e9b8222ba5ec201b964d3666301f74967b",
"0fb7e194dae6420ac447e7d4f882da3c4859f53a948833a0a08f918acbe03c2e915d1eb",
"2336f1206b46b3166b28918bdc1c817b22ab16b355030cfd635ab3dade20d2dbde08b6a"},
{NID_sect283r1, NID_sha256,
"15c7bca449a73b03bbfa783f5a91ca0b7916889a5d99d541e2e8593c3b176a5b634ba20b"
"34407fbd94ae1c1398f5313cab7402f3bcd7ad277a8c66d09a6df5dd086b20a0a3823fbb"
"b80980cd86bd13e527eee15656cc977103e80113539e26695addd9eef6a1f56986168d9a"
"53f8b5de833f8962c3826cca106ae9e8c00208d2",
"29dc20446e9abacb43823e12a83737b46e6e577466b5a3925e0f9d496824dadb4d4b50c",
"0404b3c1d41d8172ba15fc92d9586f29716821ea82274ac8e4fb3452ccca3e34925f1e73"
"6c023e22cec962d759bc659841f259de954911aa289e9994bd76a30149a73711bc41b299"
"04",
"0931ef56f08c379d1ddce0649f45ec21eccf3dcfa178616f45b200a06f82172b91bffe1",
"178348d533217543af694c8d3cee8177e22740b657bc6ce6df9e57f0c1f14fc9407c440",
"3eb25dc4ed42495b54679653ab1cd4d61c854207994a7318026afdfd44c89cda9247388"},
{NID_sect283r1, NID_sha256,
"d12fbb82ee7a57eaf76b63fd6bc6c0a65c85f135f019d43ff7bc295cad15d53729d904fe"
"d63d69d3ffe8b82c0ebaf0399e2717ece40e011f710b5db46aa457c23b85545953398b81"
"4816a1e7a8ab5b0b14c4a0451b0bda9d0d2ec4a374bcaae208b7fe8056bfa17d6b7ffd4b"
"a2e9179f49b9cd781b0c06f6ce3eec26cd428cb6",
"3b9b77d19a42e9a555da8ab70aa5638890b2ed21daefa28ca6323fc658662dabcbfaf52",
"040632fdf8ebbb755c960ebf8fa5d6b679416e488faeeb021c0782352279a7ae00eed330"
"94041aa517eff6854ba04e2de6794848823e53ca580353f2b25e45fd4efd3a369cf80fbe"
"57",
"2450beeca6f1ebac3e82e3aa3239a5031f54ffe65fa6a45e2bf2ccbda448a2cf6988141",
"28664212774e23b6513f73a9b2da97f5eeafd10efe742e314f6913a6d0c0e3e581cc6cb",
"025bc733edffbc1330689e7aee0dc121b64a72dff19e1d7c5990206d6daae5bae75d0b9"},
{NID_sect283r1, NID_sha384,
"eab0a37915c6b43b0d1e3ef92e6317b3afc8b8301b22f6059da8271fc5fe0e419ca6097d"
"aba213915855631af64e10d8382d70599d903d1535e25cbf74da3a12ba2f13c33a8562e0"
"db03edce791f1d39af8850fd1feff0eb25f9ad0a86dfab627b96e65831bffc5f6d9693d2"
"0493bc9dd6eb3e9325dea50b055768e8aa30d49c",
"0b9f8f3e89e9c1ef835390612bfe26d714e878c1c864f0a50190e5d2281081c5083923b",
"040542ea231974c079be966cf320073b0c045a2181698ae0d36a90f206ce37fa10fb9051"
"8607e6eccfe1303e218b26a9f008b8b7d0c755b3c6e0892a5f572cdc16897dcf18433f9a"
"10",
"31789e96e2ae53de7a7dbc3e46e9252015306d88af6bd62508554f89bb390a78fdbaf6b",
"0fba3bd1953a9c4cf7ce37b0cd32c0f4da0396c9f347ee2dba18d636f5c3ab058907e3e",
"15d1c9f7302731f8fcdc363ed2285be492cc03dd642335139ba71fbf962991bc7e45369"},
{NID_sect283r1, NID_sha384,
"fdb93afd5dd1e3eaf72c7ea9a6cddb07fc2054499ffe152cb2870163eee71ace5bd420b8"
"98cb4fa80ea53fbbaece2a1eef6427b632320e9c97e38acb16b62fdbf6585b54fabf0a70"
"3307ca50f86387bed1815a05b0c8991e0743d10cdf49c8facfd7ddeb8d4a7b706b5a29e1"
"d00ac88b0ee88b3153185495ac8388cc70104154",
"3a30a1c15b9ed71e102341f97c223a9b5ea3e6a335861c3cf407ef691a18cc639dbe74c",
"04040937b263c87461eb5d409008255d4e14c54d7a86d6e3eaf2ad9c559f7a6b9d258254"
"2b07562e3a04f22ad37a1df0250215c163b45a6bd04a4b96c30fe2e2b7ded5486b172ef0"
"9d",
"13e745c76b33e6e91f47f8423653b0056014841f4df890121655ac2044f3a6d58b9e213",
"22467497bf1b5d29476f24aaf5f88d905be7900406c64033913fc88601c62063a924456",
"19cb024c7d6be51d15337a207e66fb0e473956932faf6d755393dd5a899bf63610ff887"},
{NID_sect283r1, NID_sha384,
"c78e35d1a5b1bbb0ec21e7ba7b7c74c859d88f3e100e40ae34128cf093885dae4e87cd09"
"f3239dd8e79e25305220880dd352a650225d9bd193b9b84e488c458b0b5fde1af941c0c9"
"fdf952d2fa41f665918dccae27ab7923da4710f8c27ac8ed424992568dd6f0a6c3ecead2"
"1650ed162e0292104eef3c2d8551be866a88d279",
"083330123cc64c11888c1fd388629d0b329a50ef31a476b909a182c930ff02d0c389b93",
"0402e3a3e712676bede22893a8911ad6a683306e86487d24585bd6fe4f2657281f0bae2d"
"c80773889a95e9bd579be379fbf84dc8d26d47335253356e5b01c09eb8ed57474d6c0b04"
"91",
"0d630f20623e93c274239200393cc552d03da6bb9e74f4a44a518e2642e84e761dff7a9",
"27b8997fb98ad04488f5dc8ae5dc88b2a3231fca76d7320550c74cc540110c0cee5d8fc",
"1824f1050e85d527847faff236b7195965e7b93343ebac889b23425dc27226d50a5266c"},
{NID_sect283r1, NID_sha384,
"e05435f695997229cce314e50065f3c5f71981988dddccaae6efb81f936b22cb48813f50"
"6d1edf5ebd69b0be34f278592c5935f0f6db0cca1ef9d62834fbf3c4c03f4da0596cb4d6"
"7b7b767e85dde7b7c6fbef7d89babe6f97b876b33594a9e36ab87079861ee556fb03274a"
"d4af527342a4794192b8933f28c6220f954c77de",
"1dc2b656c207eabc9e0d6272099babca8d149c9c4258b779c2f06de75f76d77505271c0",
"0402b03407b65809825a32ab50f1b556a65c3bbbd65cfcec898514637ce606182517fa1a"
"4d021c97e293ec74dee17c89b962356b7bd50c7b23fcc30ec7fdd0a629d11373e28380a8"
"c8",
"2d0dc9317a2af5a7d0a23c00d126b7fae4c06bda0a5c50462ba26bddf575adb091d0e50",
"211c396875b5dc71ba87ff2483b0ffbff60cc3656132fda7422a81964f1bfbcb5ecca23",
"0a0ed7bf1ca853b9b19924c706eff373b97585b692b4b535ad71cc4362073caf8f61a3f"},
{NID_sect283r1, NID_sha384,
"0f9f36477076c4b5a7d1ceb314a397fb14646695b0803e36e98908c8a978770269f165a1"
"fed8f4b655d4efd6ad283d7f5d51b6e1e302d360e8ebf4e887c7523a757ffd55384e114b"
"bfc6b7a0ec8511079507b919065ca018573418f9e394854c5704227772161707b4d0246e"
"bceb91192f0eb2ea994ce61fd98a6d14cc8246c5",
"0081772348ff2d7a3fd57fe703555ab2e14f5d203c4cf0292f944e827e884d95f3b1d83",
"0403f7174e88ffa8bc0a770fffa4bc30a436fce331dbe7154f6e2fc0cdd09e76840f089b"
"3f0561e6aa3feffb2033ea716ae94b9a7402bccfed1fc4a137cb96fcdfe4685314f73a8b"
"b5",
"3a8c40754ef7ddd0e289b2cdac5e06c72dc3d6ae9d0351d9295aedfd6f0e88809674bae",
"1443b46c0e6bce31642dcf3037e25b6ba2b42daa9a83f5c0bbfb2487ce717c37b91f46b",
"3f59d5a925fe19c795b4992c265a3c61b2452237eb34efb9aba30208ce07d1ad47e2279"},
{NID_sect283r1, NID_sha384,
"1d38b1c342b6611dbaf412a66c1c0b8397692755f576df33b31c2bd12b7f0707cc423376"
"391f7b00aa4e7b7fe54532e2b39c3c5284b9c8ccce48eaf9308ed338992f1d4ecde6cbe3"
"52e46339d7d602942158387881d9b493fd40cc59d4f9b53ee4191d42352c6f7bf32c331f"
"0c5afbd44a92901a4b713c7cf6ccddf7de4cc6e4",
"1eb6bf2ca1b5ffe6f6a795733eaeed12de6e87c53571e702635b9dbd0d96b47df4a005b",
"0400e64dbc1a08acf6ff0e820593cad79a46e3bd818ddef5ca0960fde799abacc7b840ed"
"db06115d3de2bdd011ad053550471368581a5f125eb0d32090646fe4407980a42988e551"
"aa",
"3b28fc6d0e4a7fc449b811b78900fb9f89885f4d4f70cb5a2b3d4f8ab87bd5448f4bfd2",
"2601923909c8c953087b0c0acda57d8c01f814dc9722171d8409d0acd2fa4d9c1314693",
"3eb316cacba93bd473a4b4acae4f2b5a5b2ac9856519032e63a0c718698956e8f35673b"},
{NID_sect283r1, NID_sha384,
"3353ad05ef90e9762bcfedd6ef44a1e8ea0392ebef30cffd48ae620f3e567e1cd44882d5"
"14e7c6759200d4bcab18afd3038c3d3f8c50f7bba32a04eee5a4b1cfb8c349939e4efe0a"
"46fd047d02ed000d8fa1b98b0af5586f120d9ad174b3aea33905b979ece1eb3660b1e070"
"c8821b32df41904ad68bbd8ed247aabd94066f16",
"3b2a3e65e5a306bf8e3955b60e856dfa9bf68c1275a678ca056207a0ec67c96eb3f8309",
"0402c542cef892b06372af7d9c321ed5309995c1cbbf1a466e70bd30f3856ab7c5d18f4e"
"3d02a8acdc12a7cc0b54f4dec9cf61c484a5cf86c4cf6cb5ed615479123ef1c6ecbb6c7a"
"e4",
"09bb5e49188621466440a0841b007525000c2203d9821f4c6afab63ac2b97cb5e2e3dcf",
"00a09da1c4bedff47945898f4f4ee9a0857bb56be535544aff9d729ae44e23d678fc71f",
"2390be08ba0861b32ca35ba27a0c8dd1a4e96d28cb007133a096b52afa0126bf2a2abee"},
{NID_sect283r1, NID_sha384,
"e7ec162185fe9a5803c6b03d98041422315ccdac67e48fbd07a1ef3c5661158710abc679"
"1bd0a75d56791b4ac0e7695d53c5989d9fa6a3b037583b2a80d2b154b024f1c36b63548b"
"e9afe1d51f2f68b2ba94d4ca1e69a35ac10e15ba72242aac20f7526b12ff9d3cde9a9bfd"
"70d55adf9bd92c66d092d7d08e9764c84bf7f329",
"1fd4d1af0bb7c79ed5fea7bb45574e46534387bd916649485ef15207352d7302e81dc01",
"04077057d3f93011440a78718a3cfded73e4196e7fde96e794465c51be8b679f912c10ed"
"cf059873441c590c43e0f00f80afad5b0166f94b62214ea45da29174874e44356b29eda6"
"b9",
"3f224b35737e78ec5bc9b081a601d8fe19e33b4787449d3353d2ad225358211cf9f7f0c",
"1a7bfe92c30ed1af478282786bdf7b5b89cd0fdba5e534bdf13899dab5af108803d73f6",
"2ba14810de4f5cf48b56e94bd6c439d230dfced3cb698c77627f59faff0ac5a42c43067"},
{NID_sect283r1, NID_sha384,
"87c8f2e3f4fdebce0ca9300fc1ebcaa934f51a12b6b8f2cb6bb6eb77965468663044afeb"
"2a1334cb5a81e74b8427267f8b34b5e9ff0cf157a9f18be2b1942e32ca61dc23ea13c3f9"
"fcfa16df8fe05e067938b6994982676463fb12842d4ec532cb904cf222aa805dd0d86ab9"
"a33a83e294c6d81e8dfa273835e62e9041dc8ff6",
"20380b1136b5283e9b7f54b7535ebda33b129ceb177bf5d3d07b1daed5edd9fb3862530",
"0405e7d0931db006c6abe04671d1aede760f2b1ac5c866570f8e5a24ed356fdab49cc5cd"
"ea07004920fdb0a744cc545068bf82bc5d7a46edf9265fd7c5979b9559f5421c9a98f6db"
"89",
"3cfbb1204caf6011fceb8d4be987d9a41b81bcdd95b94919b220647d0e7a18feef4cd01",
"07096beda28c20d2e62d9b0750142d3d21b54c38c7fad1ed65e4f9b386f3dcfcc43a3c2",
"3d0af02aa39e329e4c39f2a1d6797f0e3d14554dedbcab9abbd158273a3c7116225abab"},
{NID_sect283r1, NID_sha384,
"2ac53e8a50c4afe3b38904255b7cbf150c5f79dc15932dc0ac9aa631521f68a0d4b6bc5a"
"04d55c99a36531fd4886a23a8d99f262ecd2a9feea925d7a96ebe9b6979a207b7f9378af"
"be404fc8e959b0333572a2c911f8743c0ba64eebc7ef12fe5435d2cb0e5091ae518b6e42"
"33489efe3c16c6f21abf4e2c6808b733914e5a7d",
"19f815b98836948e0a0dc9c30828c31b13e175f1e79f23d084ae1bbe64823f4866214b5",
"0405109d8ce934972f5520101730d0a14b99213ea17772e3e7637d622a5de13fd2ffe3bf"
"fa0502927e0c7baedc4bb3ed2bd1b15fd2d06dd43424393b246dd530d5d8598b56dfcb3c"
"b7",
"10359d5cd8a9b7532c9902bbf1cb83d0d34bf37e73e7c0f5729b62a10bd4d8faa0f53a3",
"3503410a6feec71fde2feb14375d50f99ff9a2c8bef47e676bcc6c3045efa9948891ab4",
"159b1f65fd566ecfdc08b87e4ecf99ceea3088a750e2c3c9d868bb432de6a61f289d06f"},
{NID_sect283r1, NID_sha384,
"0b201469cac4c078f587edecdcdb6efd5752cb4a3f43ab540463c4d908c27527aa3592f2"
"f9acad85dd94a3c056bd28618317ebdf2e7dd6c5ad26fa3c31dd8e5c50c60418d91c93bc"
"bb59ec1adb1db791f485ded78a5cdcddd23dd1cfa4f13443468d8a5f2d648059b9c4470d"
"0f4fe7733d56a28a2c24456b6923703ef32cf0b8",
"01854e954654e726cf4bebc0e5a840e8809fd716059211c6ffeaed36829808363164684",
"0407a6e7c542860e815d3fa24fbaf99989e8b9c812b08399056ae4f9a850a6711a7385b6"
"2200dde6bff33891a64744dce6456600f5a6a11049906608e77f8afc38b922972c805af2"
"58",
"2c9cfd376903122625c7fdca50e93d4c216f0c7d07f33b3b51e54e666e13b67dc89d290",
"18321f9ee35d47648060213df1275ae89c2ec7d17abe8093d8a431ced23aa61d3f8df4f",
"09e5a05a62b006a7787c97be38df6fb9fbc1433aa2241b5a788fa727229a18e07d7a8aa"},
{NID_sect283r1, NID_sha384,
"fc5e4dddf4c4a328b685035ee79069770fbebcc56c14e31afb4bbcdd5220e025f31eba79"
"4fd6c05e64f19678dab33ce4f084bc32790392f14bf35669d75b6466b4214ec30d58ca90"
"ae285c9058f5804a1fc9d7a995958f2a0e84ee52e8a78b601bec04ab607ffc2091749cc5"
"48c6754ed14e2e5f92315bdacaa7a12823ef76bf",
"3548f8020819588b3202f4c1ac62eaec6a47c2a19b2900c5a3cf5b4ba5804231141c647",
"04038563f2482a399bf1c13f42f8b85ef64a3599c22da9688b97530718bfefdabca3ae86"
"3705c4aabf6d8a90af345008d5a244d0671cbe1afd08000c4eb37702a9bcba6dbc058ba6"
"da",
"32649876d776117003305f0ec9cdab5cd84bbdc747d3dad5d8d54a8fdc84d519d50df45",
"1f5160851981772c502088eef209f7f89a7c8ab35e630d16330bec7723e398fb37c84b1",
"073a7333a7037e1257d4d70be87c30bef770f9d728dd7e2615d47b399ec650aedc867c4"},
{NID_sect283r1, NID_sha384,
"284cad790e6207e451a6a469cee3befc3ec43e047cf91b9dff1485718aa29de36a43f7c5"
"1eacd8589f0c3a96ec18e8ccfa92941b50b2132e3612d5b45e16f60d411d1c53e373e1ba"
"451352e28970ada9dcb9802102518a385dc571dcf6900971b00346098a58042e0d1d129b"
"d6801fa640a895a458a45b31318fe63ebb30c6e3",
"3cc4505005c41142308f1489226b7b542e2e7f24f1d3089ff6b92a4b0013f490ad52e60",
"040280b77ddc6648d9cc3f5557d406ea2a089c8179d4320781b2eb76ab07fcafd2535b91"
"de005f23bf4171aabbf0fd50049aa017c0dae70b065964c685bc03b958cee2fc3249149d"
"31",
"2ef488215648524f6caf85233736eddcd9d1d838c6a2799c3a68580492d40f9800bd119",
"3e8e13db22c97281307edd4037f0a75d2c70a070614e94e02c860f36a53aa738fa0db2f",
"356f2651b51a6be0c697300a8c2641bfaa1795397eac208385c3729248e36baefc173ae"},
{NID_sect283r1, NID_sha384,
"6d46e57abea9d115deda48b69fe8e0b36144df2f6a659509ce1b514c8cc4769d46e5f71d"
"f2a084f1db4a22fdd3ef0c2f90394f2898ce291b9f279c0664aa01419f5f6bee1fc12998"
"71b27ecd57a5ac548f99d01871b8c238a6b46044c953b2e78e22346a0c7663af4db62799"
"038ffb5c21ee512e26d01e70a4ed967377ab8405",
"144a2fc8e0aa63506e14e4307df36416f963dd9da78655832f5b991af8c3eb97df78efc",
"0403fe8867b560bfb21dda517b8f4d50578a11e1d0ab7ed4ab3796580d31bdf710e8e222"
"8405a302baa3795e2d132c55d90858d14d4b17aea0ab70632b135f94bb23112d163357f8"
"ca",
"0b5225132f19419715170f5a3f26919b4127a05b4f0406f895af1e4bba95786daf95259",
"0651d17b00ed9a06bfc6a913883b5cdf51bd5f2dd22307cc5ad3bb545f623516232bb6e",
"01128d4784fc0fc050af0b97f859616d764b22f40734ba65aa15e2cf80e7bba3d15f42f"},
{NID_sect283r1, NID_sha384,
"dd750b39bd8753f4e473c4484e2b36ce2da7576813ebe05861c339ffae1d029bc793173e"
"d394091c00685ad82f0550cb21ed1c68f0c27cb7396922239cfb886647af204e88a9101b"
"7453a8ab662e270b87a8a13f2fe61d695597382cabeb781933bebfd7d0dcd33f77266e43"
"e32d937f2dc89f67525e522977ce73e9ad36c8e1",
"24ffeaf139043ff25a395e4c560c7680c1c2155191378917eb25194136b4a69597dc277",
"0400402bf61c0e36385e5fa8371a553ed8652466fdc3ed9d4a3ce1bcc567d1f451f6703d"
"d104dbea6f67e1117116f30fe42e84383768b0da770f8a2b4cd8a4fec330a0034554a138"
"08",
"3e4e78f012eaf1778c086a3bbd9e996da0ddde651236ebdb6348062f56b36f63a901561",
"1e2312720f6fbf44d7a6449a7f30019c38e69f2e6424d4bd1054f40798e9fe58d080b86",
"379d1b610a976730dfdf3300280f1c61109ad13c788e8f8f9a8d5e0130ca9482ee417da"},
{NID_sect283r1, NID_sha512,
"4736e59fe5812f63737eed57a570182c065538abd9fb0a1c9c2059199e7052ba57d84b5f"
"a1cda2ad9f216610361ce1dfb9334816b6bea509283756a03aaae2e5b0597f492d078b6b"
"015a40c9785dcc5d2ae266176980db04f5cffef40e16661a50ef871c5f531d73fd5d114f"
"a19bae9dd2da4267a131fc31849da38c2b78d1af",
"1d1f2e0f044a416e1087d645f60c53cb67be2efe7944b29ac832142f13d39b08ac52931",
"04010b2d7b00182ee9666a6a2bf039c4358683f234ae41a9e5485fd6594e3daa880c0dfe"
"0f00a419b2f40e573dc2dae4b22e6f56e842e50d631b6126153178585bd05a8b9e6e87e4"
"c8",
"3e4d36b479773e7a01e57c88306404a46b6e62bf494b0966b4ed57e8a16169b9a1bbfe3",
"30513169c8874141cdf05a51f20273ac6b55fe12fa345609a2fede6acbeb110f98471af",
"33fd50b214f402deed1e20bd22eba71b156305e4f5a41ab9374b481ee344ab3f27f4bcd"},
{NID_sect283r1, NID_sha512,
"e573fa7d4bf5a5601e320130de91f4ad87eb7ca6b8998488afcef69c215b0cccd221b8b6"
"6eb0af9d699af9ad6c4b4a580e82941f31e4c0a9bd83995dd076c5ac9bebb34481061e7c"
"b1b26f6e8c6b26ee4bdf9887f7ae2eb9fad3115a21dcc96acce85d23a040c0ebbe0a56e7"
"5714dbfa803d6e279b2f4280bcb993f96ba321e1",
"1337362609df74d25f7adee382225e6a04dd6ee4c6b45fa31499ce9edb0ec046325caf9",
"040287b288ce6f65fed9f95c99fa4b8c1aaf6de65ca563df30ac67c1066d2ba2f5a554e0"
"9c025567fe183dd400d256c333da92dda2e364afe84492ede9fa0e913ca7f12069b5a44b"
"48",
"31b84ec438302155f2e84dd118c0d8479267f8d19c8c5d96d21177e20b23e0180dd6d33",
"08133e49644044bf9ba3b4c8bdc3973647d650c58fae4a7ea5a5fffabafed56e759010a",
"1d8cc410cd04b188418b20cebc8f66ab0dc29a42f9067aa2926dbadee39abce79deb396"},
{NID_sect283r1, NID_sha512,
"7862864d0d78b44e2a28af44a0a16d8e9b1b8c4b794db0410c0a863ba011018ef43e1e11"
"f2fcda2f56fdb2a69cc817df425c9cb3b458922ba00d710190cae16d61af3c304a42fbb3"
"d0c4a74a297253fccd70aca414865b41f68b01c561be281265fa89f63f975d3101334886"
"e85929a5a47fa8dc459b663548faf8ed7484958d",
"1be00aa0afdfe92e24a2536594d4b41701ad4dfb223aab35ff49310bdba7566057fe8ac",
"04013583d8cd163fdef7c11e91f36c1d3eb2f7957d219244db883708a7c5777611b00668"
"1207a1f4df45073b838277d8da7daa7147b0f10aa98b5ec02fbbf97c89ee17f3a7ab4f3f"
"27",
"26b42f369ff9b2740147914a2698cf1ec9bab44caa3b5f05957ceb9a32073729aef0fc3",
"37640dcfa11483b3754ea027f5f239500894dda4f4c8308f0623db256eba2113c41ae61",
"2096767a1f8210b175334fad61b4c7fb4e2d6c7811b5d22521af7750f101077e2fd4e44"},
{NID_sect283r1, NID_sha512,
"e73c96d1a84cf7cc96065b3c6a45db9531cd86a397e434072a38d5eeb9a90f62bf5d20ba"
"e22b926cfe967647d2bbb5dd1f59d6d58183f2cf8d06f4ac002ead026409ca6a1f868b40"
"6c84ff8887d737f65f9664f94801b2cd1f11aec336c0dbd4ec236d1cc4fc257489dc9709"
"dfa64eae3653ac66ab32344936c03eeb06d5852d",
"12ad0aa248db4fbc649f503e93f86104cb705d88c58e01d3ae0099590a69aa006aa7efb",
"04008d262f57f9528d55cc03c10bd63ded536bee9ecc617221d9892ae1a75b7cdee175cb"
"330754e40e8823e89fe23dd2748fb74e9e93c3b33f188f80377a32bc66f6a92da1804c04"
"cd",
"2405a351a3bf9a6dd548e8477452c4d9d719e32762754cd807a90abddd3ad380e197137",
"28c5d807ea1c3ddb7f2c90f3af644c5d6a2757336ae46c2c148752a2fc150e8183cfd83",
"397c8c52fd67b99792229194a787518db5be8e8c291b1a30e105b00f108ce41f8ec8fa9"},
{NID_sect283r1, NID_sha512,
"a73fb0aaec838d011110d49c5e94395ce07408917bacf7689d2cfe0948c582214b263c6b"
"80e0a55f1e159086817605723740569eeaa1bae96b979679165c5c35ef2142525e943e59"
"5e6b4b160acd7ebe41de19775346363f779b1f80b6d5f0785b92a648028e456af8496102"
"d19dc6526247a654bdae3368f075fa9ee92b2f4a",
"2cfbb8f340cae8e2e2322829148981cd9e509b0c65497fd8d9da5dee9dcfd39b0f7556c",
"040260bb17da74429f049f3a7eb73fea9cbeb5b14ce553d7772a365376d0114ed2ef3087"
"d005889e41bca54c09be20dd406a6e1f11f9d31d720e0c4e2e88f381ba89a97f12fa9faf"
"f0",
"3fd7cb455cd97f7f9cb888444f39569114589612b108657ac59178ffe31a33569c9f0bb",
"048a10915fd3bf9ffab1cb13632359466ccc539128cd98c6273d5d8d26c64d57520394a",
"2d0f67f9baffbb34094c5fce36f47cb73a537ff984c89e38d073678c21148056bdd6893"},
{NID_sect283r1, NID_sha512,
"eda775984c7c9f7db47af30dab314d070fb77e9b623baa6b73e2cbda800f167b20fdc2e7"
"219391efacf908f4ceed9b9b6bd3541b52ea087177e18c97391214758cf6455311fad336"
"ab56cfdce57a18add8cf85b0a0bd6fa7297dbaa34bfc8585b0f06a0aae055186658c227e"
"19cddb65de88d260f09f805c2e8854dcc524189d",
"070e82a1f3fa6158d15b7346dd56150faee5c98c9d07c996e01a06dc9b211b12ff62d60",
"0403d3ca5fe316a0820e84a8bb5d231bb14c810a87c7392d7f960e7cecacc56c337f88b0"
"ea027ac0ded5633a98ec5734db9de1399c83a181d522037266d856c83e5c8047c4eff2c4"
"e3",
"311b23487750c3c4b23b28424c33328c39d6f594d2a9b459a883508b985d8aca039a2b5",
"1465736c3c9e30e895b1544690e05108ca221cf2352ee4af1b5ee4130029a82b277b076",
"2819b94dca3a58cc5a96790871640fe0fae38883de6fb4712126c1c1cbfcb0c005c5af0"},
{NID_sect283r1, NID_sha512,
"a4a13e0bfa761b9bf37fade6570d41c161e20558874911ff3bee38e5649849b159beccf3"
"21c6bc7243f99c01a2fadbab9e157e9952ca65d8ea676c74fdc976d00501c626b8465c6c"
"f0e4fd1a7d1260aea987161b821528b0b423e62ecc5193a0a49442b0c3e4ec9c4786a3a8"
"6b199c07dd3a17033d430d2c83c100f54e0a7c31",
"0b471bbc5f7a07996e370da4a09e71e2119ab3a562a273f079401951fbe4df39a4493da",
"040333e9d5e077bc64d022e49d5d207385a19282aff1b73b307523b0f861b4ce4219308c"
"8205414e431f3b90a2d4a454d073cdd81f8b224180ac4139104166ec33ab33d079dd147e"
"bf",
"3e431c39ef6f4b7674a1bf414460b58998ed7aa5b1af7ddab746cbcd2ed9f42ae3827d8",
"151df78c0f453d396d71528032933566e176eb7f6910fa9df2e9b2f5ebb6038777ef209",
"08a1c4a1e21cc63fc15a78f0a11a1bc7a59a5a31f57091a12896fa670dfdc05c04053b7"},
{NID_sect283r1, NID_sha512,
"7ceda7a7248640f7055309ae712c19d741375d6a7e0608e07f0135bb830dc3e8863ee9e7"
"a75331a5e1bd38c42cdd484d4f45a26c2c1d4e05ce0d0ca941f4e94ecc6b371102f31633"
"629e9861de558bcb6407d66eb91f1062ac0e0409db68b9f2855296a7f42fc92359a7dae1"
"6c73fd2dddea52bd866a4d501aedd8fe3b3ea733",
"3c65cf80bfb507dff52f9bf2f93df0642020d41619b3990009409e7210fd7130ac44ffe",
"0403beb5b9b8785c5601093086b709c0a05955be42eca3d217e625349e5a875efa82d75e"
"d4007cd4e64475d628e6f562f0ac9c3f91075626063a52c2b621796e557799ab2f1ebf8d"
"bb",
"16212ce91eed7153fef806d2561912be1d988410641d5eb72d586cd4e6782deae4538a0",
"26ea04dded2cbeca81e75503932982c7fb5cc7d38a45a3fff8c4ed7f844dc759d8da302",
"061d3756e3da1c7816f0d72a8c84dd1f3b93624b631f5051c801af4e472fcf82d896c18"},
{NID_sect283r1, NID_sha512,
"609815edfd58c0e26a4b06dded831d2f33466a130754b96d8d7c3b4d99fd4b0789ec719b"
"c25338d0ae8c5880560c02687d352d77c291e406eae865c3b26d00f2e63dc644ce7e01d6"
"e96ceeac8bc1eeb257d36cbb25d89b5fff6e30b6051506a0ae54cfaf6214f30985d54cab"
"78f708029c1fc0175bc58e888db89dea8d300abc",
"0f4d33a9c7e6744ab3c441828bf0f1866ae1c042cc54abc754e3801263a96cbb3955dfc",
"0404b925b97bbe67adbb6e918acbcae0ced8dcf11d012e1a97875b750bbb7d01945bd64d"
"f304591cc9caabc0db8fe9047e6b1f8d850ac4389fe67bb84f6846b631dc3524c8dbe6a0"
"6d",
"0483aefcad5e382351125b333dcede8ef50914b1d1f1843b075f242acba18c290c742cb",
"1fb791c288e2cd52d3837c56b02fc99f53a6ee27ad6dd9c0a31ca08d8fa64eefccc5c87",
"0a041ca35422d8985c1c706dcb0b8ece64b65285bd0a934cdb41fc08223885147281869"},
{NID_sect283r1, NID_sha512,
"82d8ebba707b72655497320200ce719520c1ae7f46f38122958fd99322c25c9f4d4344bc"
"b77a6658df0eece5df163412ecdca58475d56b0c2d14a0361e4cef458df146925d473a43"
"692b15e9bbec550f1bde3444f2a5b2ecb55d2abd273ae999f16a32333529d94455e485ca"
"4585e6b07bedbfc2bd1eb766abf0d28bdb1ae6ec",
"3a4824bdcea6a144d85f1b194431724cc49849b6cb949b4766d641ae95477d1ec3d1464",
"0402c9eb36eca01dc2fe921933f4cebe8046b3679abed80d2f8fbcf8f254bf17be3d551a"
"56034c836aa4e946425fc9f49f3f62e33d8a0afd320292a34d0ef8bde8ad79a10e3f95f2"
"f1",
"23d8725af57d835018e8737fb4e8b2eed3ec5a83fda137c710fc1df875416ff82fba90a",
"0d9f57ba8b6a9a1cbba67adfbb938211ed2d267468f79ad39ea1eca7271d135bb67c18c",
"0f09a600d97c69ab521bd1ed6bcf0c0f69255c334e0aea06c68bba81d53e810cc553c9d"},
{NID_sect283r1, NID_sha512,
"9c6fce18a6a96349b10c9f2f5f1505c8ab727a650b44bc0782a5f39fcb48b45fc7c1b821"
"80d5f229b8abfc807071f931d333d265fc940c93fae7520d8d40ef59d7c6e3678c6a2ecd"
"e52b6a8827b1ffc6ed269cb9832feb20e593a7e3d4708309342875199eb2ffceba7ecd70"
"7b122516c815e83e27872eda812e3ea52ee3c4a8",
"27ba543ea785df1d53d4ae4c1bd0a3a994cddf0c25d2b4e8ff17ea7aa00619e858da1a5",
"0407d375a9e78ccee85fd795e3fe6bc07f50af3456edda1ab00303f6de6b5b02fe09859c"
"63008d0d54ab9a239b5ff955452b32bfd2372fe095751bea4b56d52f79b4fda0fa635f57"
"f9",
"00ee7010af4a517502cc5d5433d98916f6750e8a9009ea04b8132268673d4a02a3e2031",
"3c147b66efa47a842eb90371eeae907f0c813ca0937e488da95ff8ee16d389f3ab902ff",
"01469d005eacd9ac84a140c93ed0aee09083a4822730a28df35058cad29267eacf03968"},
{NID_sect283r1, NID_sha512,
"5eac15a64c7653d125605869012b8f036804817aedacbb5a5248a595ee0c12329f91e817"
"9c187192d3ed0d4ca2e202d8d4d9c93ad3f3ed931121c193af5b47a8a5dc39775b6c2d70"
"2708e5134f77a31bd62eaf87e39e6fd3f2b9f782c3057e162dd53b3addf92bf0ab99835c"
"7f6649abd1c5322a1ebb2ba313df9464a74c14d3",
"0708d0907d14dcd5f40e2903e1e90e48a0ffaa6d4d9b84ca14df4e985c294f74eb9f2d2",
"0406fb0fe1c3d5bfee5399c98518bc3ff135e0c351243fa0540717a9b1f7990eb8cf4359"
"7f05212fd4d6a50c08cd99ee5988103fa639b1123c878d416cc553639bdcee1f8e927bdc"
"8f",
"151465f40204d76f3bfc2e4052549869c19da82c678c332f536ef24567ea034358866c8",
"0803d3e8c876d46a9198f2f769faa76c4f66bc5ff4298b9640ccb8e67ff8d10f86342c4",
"00da3344354114d163d14d4c288785adbf9a8b31371c6e4420383c80ba0a430019c6acf"},
{NID_sect283r1, NID_sha512,
"df735a7e60bc267b18f313ad56bff830be5ef119baf43ce27c6368ff1dd89f010afd4f48"
"740b11c12101c5903bfa71d6cb3d6462cf875bbd55a570ffedf3564088dfe8c8d3148231"
"b78b5adaa6c53696737d4704daa59eab8d986fc6e519e81540f201e77b923a6a4af65d71"
"73635b3b19b2023022186a7b8e869e1ed51717ab",
"21fb0a6b94080da8b8299b87457dc09d21bc430ba5f3359d92aacc1151be9941739567e",
"040179831c55ead3d11844fea2e18d25cd4d658822e626550aef1afe37d88aadbcc9bfd6"
"66075f8087d759ede340157667c1bb12be272b8318aedf2e8f8b487f4bcd12a50ca66f92"
"81",
"37833e9aab843a6b967264fdb705b419ed63fbb09c12170491019acc7c21b9ee28a00ba",
"1c9601440d109a3f4eb69a1a669bdaab9f4222a34a04ace8ae313b10bbb66811bea7d5b",
"3d2f9ad7595dcff69b65f035ce600f2667f8499d3bd25f789d3f3c1bf83d2855f68eafc"},
{NID_sect283r1, NID_sha512,
"bb107b0eeaf175a786a61db923bc6d51dad5e922e85e57536118e032167b197b1a1f62d9"
"bbcde04922fde781665c1094181c16ac914cf6fbbfb27bb8346b2134f05c55a8c6b9b481"
"273758e380666d6e22c28577c29446cecc5c3df9ed9f1be060ca55ab2b7fda36a147aeb4"
"6df0275bb923e0876b703452fab42f6b7ad2ceb0",
"2c80151f91301fb6b0c7685bd172f20515b46bf94dbc4160d0720fbaedd40ec00084447",
"0404a62b0c9749ae9ff00dc1d50d2b4a4941741abfdf13c8e416549ea27fc26b14f191f2"
"4302c9cdab7c6512c322bd200167eb9657f8e8c84864b57480a80a3c6efbaa289ab8cbe4"
"d8",
"3df951f8c4490fc7c2d50a72a93e0e82c5a20be8d91afd890d6846bfd146169ab58b382",
"1f2accc7f7c4b5f877e12cc17b227e1ba110577c9f4e1785e6dacd8491bc6017129d798",
"27a167e6f2b43ce9663b810ed4f8ef15029fb6f2be2ddf25c014d844953f501d1dcf6d6"},
{NID_sect283r1, NID_sha512,
"f47e49ae30b09b7666600b7a95e81b0afa1553da5e01fd917e4ce1b58dfaddb8dc8c03c0"
"f5591f533610deb6a7bb5faf5dd1ec4103a587a1a4c58a110a706b0f301a5c408b3d984c"
"210d5b4a0b347d2b5447271f25b527b3c7864f7cdfa735dfded47c63b723fa0f0413c57a"
"24ffde9a95c35f743f892ab1ed1df704cde82d9c",
"1538abd7ce8a6028d01604b1b87db3aaf720e04220edf4d1d28c2d731aa25f509e58f2f",
"0403076b5c3a12b8a2e1368c7e3458458dd7ba6c5a6dda8c82cc6b30d1ef767d36e01520"
"7f0369c7a80cf01e9f32c08f9924db08a7d0dfa5e9a8e0e29b57f5eea8506841e6e3da04"
"f0",
"3f0052ba6ae6bd7a7aeb077a764d21caced6b241f63616ae4e4f0d98d2bfc0e44dca592",
"01281bc0bd36ba1f3e1c262d98ddf4e9bf1d80dbf97db02089fdf1d2e625abb5733ec3d",
"076db2215d9f33054efb397c449f05db198d38a24749f046ee20032f5899dc142052e37"},
{NID_sect409r1, NID_sha224,
"f2380acb0d869d1cf2e25a6bd46ebe49d1c9270624c5507be4299fe773749596d07d10f7"
"c2be1c0b27e86f27b4a6f8dff68cfe5c0b4c58dad1b4ebec7bd00ab195fdd635d9fa8a15"
"acf81816868d737b8922379648ed70022b98c388ede5355e4d50e6bc9ec57737d8843fab"
"da78054e92777c4b90466a5af35dd79e5d7a81ce",
"0beb0df3b0e05a4b5cf67abef2b1827f5f3ada4a0e6c3f23d698f15a3176cb40e85bf741"
"c9fbc78c9e207fa7302657527fd92fb",
"0401da1761981a65cb5c77ec50ebf7acc11eaf44bdd2f70242340ec26ffada7a4b5f661e"
"13d6e7ad341cd7dd1ca491cb7a0b580be3019ba11e4c4f2f5507d6bd2aa2f96b03510a03"
"d5f8c38bcc8acd08080d9effd1f8ae5a5586603b2e112964514c831bf786b2fcb2",
"091e575fc79444fd2d9021bc267a1a076438d73464726bd0fe4ac2884a374e71bd462b15"
"16b3e97c3202854bd0a286214b9e92c",
"057ab9d5cf4d18f05eaf17d3b5a4af96c3eda8ee48acf5e02eefdfe2f542cde32a37c04f"
"285794ddccbb14383a645db040bda81",
"05275de4157b32723366a0d63831e6512241e3e4416f3af02e22da8faeabbddd76116030"
"4927a71cfff4d6e8937347c9b78cd3b"},
{NID_sect409r1, NID_sha224,
"22a97fc0a9694dabc6f274ab52eb592dbbe8beeb646ebe6cef60eff341a13017eef980ab"
"a6d24ab3afd976e2f6a84cf652654d4a54a36b2f2f62fab8858f8b0479a48fe9f47f8fd5"
"a4a1f3141a91cbca186507b2bbfef5e4c4d2df525f04ef7c4720fb443ccad540f03a2be4"
"68d88c9545d1dad579fd7cbcd103bbebc9e9f961",
"0504865a30984a9b273d1bc289d734d10e0aa56e93ab14720f1a42a27d8cc932cb8804b9"
"63175de6fe57d8eafa8ab7ea0592dfa",
"04002de5872c40a79d5238722fcb94d5158009e28fb41ea012e92028dc3c87855fba71f5"
"0e6d0dff709867de185f9a9671e7a91e2f00fbf607f69609ae96982bda3f0317fe46ad1e"
"0207030fdca702cd97fb5d5732f3abab24b10669875a64bd2a74c8603897c78d22",
"032d0f950d10d028db6e9115e9944e7c768e2da731df49dc9128bf145a747662de08cbe0"
"517fca6fa185abdfcc4e3ab604e196f",
"0e7d16daa689ddeb08074285f5293bd9f1c051ca5589e69e4b62c32af110b6f3981d9624"
"df15c7cac0ddd62aee9c41c7b6d690b",
"02f6bdcc551aef0e4e8da2df38288dcc29fe600de2f8b6cd8149f88146150790915148f0"
"69372151c3bdc4d719526eff252e610"},
{NID_sect409r1, NID_sha224,
"af36c04af0e3fd64bf52dedf52fb788d2d1bd67fe05d98880cc7ad3c20436abf02f637fc"
"ec209fbf888903fdec8682717299f8a4386768153b7faeb6581db57fb9aaf4615b4ea8d9"
"24198fdd158363a1f40312527d6bd14c13d19985b668c6b88a7548104b1ff057d07082ee"
"a421f50062a315bc3866378f2d2d634f03fbc0cf",
"0cc08a4ea5ebe32027885a8c212870e7c45b6c610117994d6a42a284c05199414a3a0e8e"
"6645ac5c2ebf21c505a601f69c62b85",
"04009d2beb607f2bab64451327e1dc67f04f7569ffc0c67b410c6db06dc04edddb1362ce"
"8d8b8220be77c447640e7d0c676e5ad1d500ab813e800e75b6012faea43be56fe9d5a22c"
"d46fb1f4f1ba65eab19f75f2ce9d8187e4940fddc485c42cd18d40d47415a80b02",
"0cfcc307f847eb696f16af32502690711ffbaa2e60e75f80cbcf7704152d5eeb9ddeb701"
"952dd58fefb159926a83245fefa6196",
"068d1c646dca56393caf3239d9fb30d1dc56f991a8dfdbc0a7b69d273aec69a53056d955"
"3e105c7917e522ffe446cbea23227c8",
"01db30aceed2b126cf45163b9d878a6590e9ac8284a31ccb0faeba2202679f181eaebb66"
"4b5537f408b693800f24da590082dfe"},
{NID_sect409r1, NID_sha224,
"6bd6f52a6204b60f37929aeff28c87ef61ddeecc231e52a7772275f9329add899c130956"
"f8c50ac2698aad3654fdb49b74a6427a62a11eca0a8ee8b719b8c0df7b9f0bb0af5fef49"
"18a8c83367d29fddd04b6a1ecad904471e5b59c8fe3cdb06b4f8f96419518dda960845d8"
"3c49a49f1b1f2fd1d2682a9d60c25fe3ce982cf7",
"07156ef0a74ee1119532a2a7e8c02be1559c3c21897af9d5b34553c3d0feca4a8d5929d1"
"945df824478e0c0b92a6fac8c84f639",
"04001df419310cf133408e9bdb32fd85f8f0950263e1886f2e2e108a596e7e76153ec47b"
"f9b33f69c1128dfbf52557f3c382de85f1016a15517a811c77cc67ec4fe2bcba1290e498"
"1880c071318aee28e30854692ed2d6bfb71e6e74fa97af750889ae8d010189733c",
"063f127c38160e85acdd4d5dee1db1c32cd9da6075b2d2f46b010636e374e0262a045339"
"4aaa8bbb5fe7b2dbcbcd62ad601cf51",
"0250cf50d52a5950999b9c0ddef219218f76dd9f22a2213def9ba98d258c2f8359d08d0e"
"fc208e23ea3614c9e27b2e4576b9c12",
"063479550873dea8a3ec0306ffa9252739c34c87bbac56d3d9138764347d5220bea9c27d"
"6a308dc2ec53724d6d3ac4862d1735a"},
{NID_sect409r1, NID_sha224,
"0eb8de25f63abc9cba16823270e9b6f3fdedf0fb90f6652a34688970932e3ae98f6d3bf0"
"fefc5f247f72960a6975bff1f1acc2188a1775fe8974b2bb2b4c8d226ceb735113a14009"
"e8ce66d58808fada4e6f697fd016829913352c0f659b6be354a067df00cf74919580750a"
"a6064f21264d89dcb28b3b2d4d699115c36d1310",
"0a95c7abffa92e2c637611ccba66ff9d2ab121b40a85c5b71454cb0dca1f098ce1be8d9e"
"a4933d1a91bcd270c5a33687835d6e4",
"040048e6b8614c0c7156dc41884e17e36ef528a493c28c9e6275c3454d83beb939ccc749"
"52732c18424ba21b8ea9c528966c692141000ef9efe1145029d8d60d14dcf079d43e3cea"
"0e18010f680bddc2729ffbff9a981cef2cb595a69142b25a0a39863a929adb635a",
"0f43af45b0dd631bfe38d85979ff1612140b9cf80b4504857df17279d9d8ea12d5bcd292"
"0fcec81326f15832df6774b9c4bf5b9",
"099f403ced566fde4d9755258445b6d6c2a4e234f99425aaa78ef118321f8579fb513ccb"
"b71cc2732e31668a6a6bb0fdc7f4018",
"0d8568971a4f219d6d3d8bea6aecb4bf7de53886d2e6bbb0f71d054c63768c34d4d18830"
"00019c59168fbb32f4317330084f979"},
{NID_sect409r1, NID_sha224,
"cad58ca7a3b9967dc0ab62a43037764f8074ef9177d60bd98f623d693333971c24a575ed"
"03cb61f4dc2e3d6285fb1204502a540f3c0bbbf23f5bbbd1544f322ce35d949d8b1d8ede"
"b82e90927ac67ad49c91007056bf5096bd690d15ac00e1874fe33293d8003a4a2b094078"
"cf09af799dde384143350c54a99e1f99cc31f2d1",
"02c438b07c6e0685d1f94a4bbafc013f8f21265d893f54e54c3ac2071606ad1ffacace0b"
"8367aad724b1d9508c65ce52282e397",
"0401fca66bdddefcc3c2072ea32f026c975a2c392dd7ed7e93e94a810e1125ec161bed69"
"8d8305830eb66fca5eeb71934ab3fd79b10189c22a2c9f1fd7624f805fdf4faeeb931709"
"d745a3feaa3cf04824f5fa58bbda144d4e96d83ce1e3282bd5fc9c50bcd68f5408",
"09230aa7b58505e2dc2f205b70a09cb9f4d8272f465b7380195ede0f7770af2a33f7623c"
"310a0520e7436835cfcaf32467f154e",
"013d0e70d8f4b1563efbd3c46feee15b88358562f769046f39df6d00477815e6b8763c02"
"3807eda87a86338c7b64214784fa2cb",
"0662f43fabd03a0c05ebba700203fa2188e16504f8655bfd0fd090b109e68220122dff7a"
"6cbb8bae08612e0d516e9f95ac15368"},
{NID_sect409r1, NID_sha224,
"281ce2643799bbfacc7d5993683a4fa656040517854f3c2dc7c4f8848dc305382e34e894"
"d433caf12d8b493020a6a08d1fa05b08bf6c53127ad5f33bbe75b9db0615e3dd94408d02"
"8dcf3cb7598f6e7cb4c787681dabac7cba2cc06fccb7506fece6c7c1c1bf622d525ae973"
"7085ab4ac578905950002024f30159cf0d99f50c",
"09e8658f8f9e6cd98c0f4f0fd20d64d725653aeba339504def17f3ad12a63dc6157d8080"
"4e5f43f4ff48fc5573fde2c615ed31b",
"04015088531d914113a25f1598ba1d3cc611e27ea92ce8dc807fe8d446db14ef62ae2f06"
"c293bcdd739f916cfedfc481fd941b4feb00a9135dc1b0384e7169fb4648973559e50831"
"9235a3f41ba174d5f58307448671cf22a3649168495c36b0bced09ac6df98f14db",
"0d398fbed52228fe16d32a6ef539e4ee3858a1df327bec999ca25cdbc357de5a75903909"
"973bbb0a5d0269862a74623a38da515",
"0e38910abb3d84b2b26ed17d2124f4787dc5612942e98521d9f94baac3d14159eeef9e09"
"b9b20c807b479ba84640730a4ced4c8",
"0e370e575302ab0d8d08d5270fe89ba524b5bf21e43e70c4d335ec1525ff5696ced37f0d"
"e17e109fd833e5d179bcd4df42d7882"},
{NID_sect409r1, NID_sha224,
"0c061da1a16f2be130ae3b20b89745e840bee09633fb49671db28ec9a051545f57ee07e2"
"410ae7ebc61c9af79868d3047705bfc64ac0c04ef0b286e579b650c7165443631e49e6a5"
"3c84cefa5625b1e1035a6ed89b8e839540040151132a937666524265e099272c1849f806"
"db0fdf2be64960d5b5853965099459968e5beb32",
"0c4c13f65eacce85a51881caa6f82d9e48ec2ac574947d2751823a7f072d38bd9da0cdf3"
"0b6f19084a6d291052e7bbc2e1349e1",
"0400af93430dd77e6016d1b076a52126a729f77e34bb3db11328d9edd56e29a7a09a7b6a"
"54f72076fcba886ea78ab6ad81de43a82101419e1bc339c03a8b4413ff009d76f9a19e20"
"1876ebbfbb3dc771b7df07bc19eb893ce23e40c679d7909c33af2bcd7d6306c0bc",
"0889be0918e7ef34d3ed226f967301a10fc30111b3559e37f5fa5a57dd5c73ff672c5279"
"d096c5b04c68b71d55e549d019281a5",
"0a4bddba9b7a402b584ceb82a54baab61e81973b7347e6dc9e3ce0f1e50dc21c9569d8ec"
"f8a7da97c38e92e52636eb13d3b4c02",
"063c7291656466f7bd647073a50f410a2cd9e8c938aa1fd3b28ddc1cbdd7b78b757689dd"
"661f5173f79896780ac3fdd4f3171ac"},
{NID_sect409r1, NID_sha224,
"74ac2e1303297efc3ed8e624722df505df55b7f33964cc0d270604cc48b58205d8a11952"
"232a8feb0079baa30d7d33660268b56a5a3dd90105f0703abef8f6636a99bc63bd47d9df"
"100351bee32d8205dab0dbd2af36fd173409ff8d1fb7b24570f3c1e968458f58aea5aa2f"
"46731ee91ffd6d3a060af6b3d5020daf1362af3e",
"0da591461791ae7847e6d8dd8df46a63d3021644abe9520e158406c96540d8fd82ecfb1c"
"3f6f5cfd7688c7656cc3e3dc94e586e",
"0401f48c95301956c62e2fd931df49953519b88ec3915c8de495dcb4ccba97bee023b1a6"
"cd9a66dca29aeef8f4f1117eb954e47cdb010db6bf78cfeb92d29a922c4b05daa3cdff39"
"17ba6978fe738296956ed141c749a938ca9f8f13f711aec930e0f1948ce7daf9f6",
"00576a91862cd63acc067563626977fee6f074d5726cf4f68e80d25029d4b8efe5ea8457"
"45c45e4cd42879e52854c3f385a10b1",
"0806435400248ec38a6d362e8b2cafc3f3bd46ba5baf538cd97683f76a733ba2b4ca85fa"
"7d13b99f4076e7616e68d66f05ebd8b",
"00ecae395fb324b4366f238f0df22d011bde5db6b0cf4189e3ad47101067ba87336ca47d"
"637f09f7a40a1bc64de8c4aef7f497c"},
{NID_sect409r1, NID_sha224,
"2afd17344552ccc577b0118caeb7dd56a0766e25f84df17c0505f9798931374b48df89a4"
"8c64e199108c36e00c0bf00a97ccde55787bb97c6765601765ab5417f3e75e35a9fe5e0f"
"85a721d9f08440ed617afcdc200b318940a1e496040a6ad9090476b0fb4fcceee77b3fea"
"11de09e7fb14853d1fff8ab12d66c101257e2d4f",
"0b5eb943f0dd390b737510e2bb703a67f2dd89dc9f6dca6790bc7a260cb2d0fb8e1a81ad"
"6009ed51010e7686d5b48233c6c1686",
"04001ac00da454bc329f7c13950c848392cb4f31594fb7837f0986f61601fe244eca3db6"
"c4f92accc2fbd1a4b8597b70e72d88b103009a364065a9f67a0aa7518b75a0b4a9140787"
"a67f852fa31342d6275c14713d484dec3116b9dbbb8af1d4945639997ded09cbc7",
"049176093dcde8549f95a8f1d1c87230046fd4b18a73243c3599815d4df8387a843bc8fe"
"1fd67f3c6bbe394547e11866f41acaf",
"09d7c4ddee55f61c5c4c2ac6efbba6164900344004976381c7b18c1de541a97cb58e14d1"
"4b6e433c4eb6d4bfe6d3e0a4e457469",
"0a9acf355bad544b3b120522365bcaa1e1dc6f1d3df1e30d3beb94f639e26147a81d154a"
"684bbafac965bc39974c505fd0f811d"},
{NID_sect409r1, NID_sha224,
"174b2b083541f8284645a810801e72631a11bd7bb805f684a7159e055afc44357f2c80df"
"2b7853678d34a04144e0ede2327d03db6df23769ec41194a8d9d86af74d51c5bc11ea878"
"c6a80689af71d3fdaf1c651003385332a512e03dd040c33d9c328ca89ec7ee9026bbacf3"
"0a7f3a68e0d894fb9f7100ffbc64bf17679dedd1",
"09cc63f32152284fca27ab2837bf1343144336a1fdf15b9727c47e877ac69ac9cf4c97b4"
"bf42f1ab10d73de8597a554ed099efa",
"040044e655ad66ca9af330c33bc6d00ccbe4533a4c6a44a3f23c921b62eeec8cc1918e19"
"956f3ed848fed93a7fd7ddea57096d1f23003a71b221c85607821cd864af6f533f216b64"
"1ceae104b8e16dbfdfe7edcb2cf9ee0dc1679b696149ff42a051c51c861a3c7530",
"0db9bfe4c2e659006d31a7b44eb7bcd6dd23810f27c74dd587ab9af23aa5962dd18aef1e"
"95da4ebf4aabfd558cbf72d2951bd44",
"0c3b91bf0794eca7faf227c4ee4085eac6d6918803242bff4da9c5dbac2e23fc32a4d4a1"
"92d7737be22810812558f820b0a2c13",
"03120a558c0edb58ae7ba36e886084801e7604558238c85a199af6c9e7506ea4e748791b"
"04f3a92354a4f1407837d87faab66ad"},
{NID_sect409r1, NID_sha224,
"758df71a952cdcffdc417b9fffdfb57582ab5c5473a8bdf0c2101953b023b77824263353"
"dea0e2ede1f800a5757ec6ac0e1e4e3ab5a4cd85567d2d19acc6b7069a6e7368401cba2b"
"6e642373654bec0ddd19fbf032794c15b7ef7e714e13e36875262c01e77766ed53cbcf73"
"5936dc9b33eaf2152a396349c82ca0297dbae4a5",
"09950355e8667bea8bbe3a2c4988436ab5394551b375e27fdc0c1a1d1b07ae957932f428"
"f1aca0a486e54cd0b5bb0a5c5650641",
"04002f623f81fb9a299b71ea8c58d5bd7d89e7be66ed8cfd7370de515eaceac903644383"
"38a3fcf9981f1b6f0b30bc61c4b7c15791016130b7c4061422d70b21251fa9c3d4e9636f"
"5a08cea794a0fddf74ff5ab1b750cce0f2768d54fb2fb75e2851c2296b39c0ddd2",
"038e8c70cd35591012f45f27980095c4bcbb3bd36bec594927968d3747618c7f5810ea9e"
"0a126e4d3e1e08185b031dbe0b37e5c",
"0cf957d59b03aed0e48189d2b9256b5472c8a48b4911f9cec14adce5c6b4aa22d093a116"
"364bcae01c1a739a4023da12a29c058",
"04cc2c22b243064758f52264ed84e757ff67c4f6596edcfe956b70f777d865d01e529f0a"
"8a9a6e1895168780ab60950a62d2d2c"},
{NID_sect409r1, NID_sha224,
"b96d9f66b2000e9408d602096f032b112f0e05ea874229ab9daf6e05bee49b4722e4f2d8"
"bf2eeaab9dad94438c76b7cc64dcbb59cb4e03f9ac70487a1d24d8d6b72d7462fe738a17"
"edf381d52179b3acc0c0177c113eb4d10e8e78041deac1d56abda0ddf892edb8be956d28"
"5e7236bc6794168f8a180f622dd5f2b9e690c275",
"0a995493d6971c2d7e8fac3da9f8c0b5afd877cfb94924cfecc167f9d87002136ab253e3"
"a4f9ddf5c9c99bb1dc1af0c6a3a3c4c",
"0400ac0e558dbca0fa6f013b7282e02717e91eb73304b4f7ac5e04f12f55824c441faebe"
"5bb5af82189044827007bffb1e2655794101178bb726242c718b416b21cdc9fd90b31ba6"
"a8350f9b4ce3a188b1b5dffd0e8894ae6a417c4d74c920fda585624eed4c1d3f99",
"0d581293ab1e509baa50852bd3f21f6493cc524a2c16206e461e320c7f2c1c201b9d2a1d"
"d4207227592a6457670a67cb72eeb58",
"022624cbbae5214d2c29e273c334b9ea78e10c7efff3611574d5fdf6f67a81472b606e02"
"36aa47106097b9147fc1b56d062966e",
"08895d107ba789d88a17c30a537402591ed788206487697a72f69285ee5eb4f03cdad6c2"
"604e174ef4b9bb919d8b39bee6231c7"},
{NID_sect409r1, NID_sha224,
"e7ae60ac55e6ba62a75d5328bbc15269d4638764169de0bf0df043d15f9152bed909b1fb"
"8c7a8d8e88ac4f552c1092b62db00958a3a827f64896f6de4bbd8fa5258d6c36e3904d82"
"d3eacf6eedba50b0242eb6b01212288448c3a9821c4fa493869c01149ff1850e8115cf9d"
"e1618cb8744626b1951d1de305745507c8b21045",
"070daf435cdc26ad66c3186267ad12d10f28d32d863f950cbfcf042fe9dfce553750ad09"
"8f82f7f1650c1126b3e4451bee6e11f",
"04019b41af3b557c274cf117d501ce7ccd04d8bff2dfc737d7efcd7888f2dda24737a678"
"8f16b3b6cd589d3f65bd95194799d65659011983077a2c371fcadbf47b10494f6ffc7ca8"
"873b3d812c45a87c48e1b49edacc0ac37e5038cf1aba20360b74c0903c23a62331",
"043fb8cb87591747d12f4897dfbbc79644b87907bdefdbd7ff0f6f2e7970c7d40bb2fc08"
"c17443d029a92487869f640607af460",
"05ea3493a8c04723de9de2cbd523481e3a8593ae8f010ecbd5add6db5a82d9b13ee7d24e"
"cb417419639d0e9f4e68d14f6799829",
"0a9bbaded0a2894e384184e166bc06e1b2fabdc70536caeb3d0cd46b955743cfa8ac6edd"
"03760d1b613fb445367734fa4270139"},
{NID_sect409r1, NID_sha224,
"666b0dc2ddffaa7ffd57ea3b2768f02d4b77c16fa007c6d1918400d195f068cae2dcaa69"
"817e6e4c70d5b29c5598efe2d957bd12d0fafdcf5ac52dee80a2d46e77fc18cce2a49bfd"
"787ff77b942c753974d22434742bdb494590d17c42af725b1309e54566276af3bcfbf5e1"
"74d3cf191b85903faafa1583282c97e66c5da6c4",
"0f8121980dfbe9ad0bf92383c7cab95fb72d5caba96e1de7772c6a179e85414802fbb86d"
"725401451329287305570ec7fdd873a",
"0400c62f4e7eaf3f1bbae71734c86b8a40ed1297b9ba1151729f9363824425193e8605c2"
"bcd6094aecc9d7ef2a41aa6b12877291cd01882a45555b68596dbc8bb093dbf1aab9900c"
"f46653c58f5656f3688fbc72c5236297be2f0586a4031279b9014f2d3655adef41",
"0b4b5b19922bf6a34a00454374589f9c89745eb194b0352061a79401e23c0c0e1fecd759"
"7b5a7cc1c463b76cce7ab921867de00",
"0f1fcb80a4fb49348fb326e808d8ed8c21c376f0713429a22bfe16d68cab0295b21d4402"
"9083769761c4fb853662d440eba4cfa",
"0252a94a40008cc2c1a69113d8e14e989e7fe13918a2852de6930973a91784eb35e20d8a"
"e150a88c459167f8ece998cbf6c5eb7"},
{NID_sect409r1, NID_sha256,
"3e967cbc2bd936e0b6125dc5cf885735bdcd2d95b2f764de6931c4578ac8e0e87abdf963"
"75481df67dbe1b6c43537e84ec62bfca6672cc5f3ea4125abd4a4119edffe04e42411d33"
"8e8b10abb1f1f818c50a9631a3f89feb5be5367bdcb0a8a82c96a427ba6ce99f9631d441"
"1a2b7f5b14d32cb3901dc9d285e4cf5508940942",
"047682b2e3bcb5800a531858e8137692a9b1ee98ea74e929ce4c919c26ae3b3f1d4122d0"
"7fd9a70d8315fab727ccb67004187a3",
"04017ffffc1d2009e844f8e625a3bf11749a8b4ea0b0fe3532d124112edddf72d518ef57"
"7f160962b88ee38b11445fdd356a26bcc500ca356fa8e90325aafb1826a694a55a80b2af"
"52e70ad8d507d48946392da8b9fa27b8ff6927fe5130c69809d9a2c4b1d7eff309",
"058edc8f3665ff9166af55e69aab9d468f576bcc8f652e950082a48224b4923cb9396ed4"
"ae06f05bcf7797352035484fdc501fe",
"09b46600fb3b8204d4cb63ddfaad1482dd8cf8652f63c926895b8b8ebfe27295c052b3bb"
"81dddd8687f4864f258a433010c89d0",
"0832f7674eea791b5f17db7cf9e2ab13253d870c6ab46ad01cdda30e78db8b8f51fd377d"
"d55ec7786ccc92b17364a3c17ad5be4"},
{NID_sect409r1, NID_sha256,
"ca1c90012eba4e7c5f01d8cb3814c58f48c03a16be6ed86934014365eee547070b870d1d"
"26a872cfd28b60d9ee0a66dea223e9eaa90ee28076188d6091f26f665684f4b486af7066"
"9555db9058d485c677b2a34d4a98aa8d6f43bf6f44aff2a23c5d765e98f0438ab81be058"
"5a5be29daece5d4116f44ce6062753a3ddc505f3",
"040cd1a06233ac27f3ddd108de7c6c0982793ee620d71982697713be9fd5143658929924"
"cc88747a680779bb00da8a44e1e7d3f",
"040164e518a6719b1ad61a38a214ebb06dfb0553bc760799e668b1d0d098ae3f06dffd9b"
"84c16de90db19043d72bed2601fda14b1d018e022ceb850eb1db59e6cf63c4a7c73bea0b"
"70448a7dea77d5ee8a2e1a36cbc46454bacd5954792de82f3ec21ca6a509b0c7aa",
"04a936fccec003bd9e8eb45d27c0eaedbd452e6fe99abaa62cbd0739bcf259cfb6884d1e"
"60b82522c6146f081663f6f863576c9",
"0dec1635f2698d4666df2c217fbe3e644d27592c5607a5549c877257cba7bee29a8cac75"
"a044e72d039747d0d18de1c34acf072",
"0138493216ffc3b8aa2e0c26f4fafaccd6609e6b15f767da7c907db64b5181bfdb447d73"
"ede786144c70ddce7df7eff46dee4f2"},
{NID_sect409r1, NID_sha256,
"a54c4351ebdb075d6a42a787647390f864b2bbfd8bb3d0e0ea9d767200fa344d1a9ff091"
"bddb186acd69bcaecd767068efe4d752d185bfe63f6674279d0e7192d2077c400bbc0d55"
"99ee28507c1253f05eae0687b965a015e1f3a292b4650106765266f5c95b77ad2d82a6a6"
"e012f233169eb6b8d83576901cfd4a927c54d7f4",
"01ca6f752aae4eb7fc9c73a08d6fbd96bfde5030d759a2507bd45b6e1d1487e53abbe98f"
"ad4f41976364e0a1d830910ccf97abc",
"0400f6b7220bd24652572b37a0ff25e75f72d583c71c159857482ca9944b956a117a6b2f"
"f96614898757b8a587e3c2b78d9943003d0118fe425768bbf3a4acade281c41c745c9ac9"
"46c2f8b95d65787fb6b64deb71e6b38fd8c721e01c87efc7c2a6d8066fe3b35a0c",
"04963aa161b5ffbe5d7e5058f0b1457ca1b9cd61d731a0470beefe5f8998904cf4594f98"
"dcb41283f66e2b07c5c5d6a6c587826",
"0abf824d43d993107b552d7ded13f49ea0ae7bb845e56ad7e53cc5f9d64f99f9f250e430"
"5ccd9f6594c92defa7f6860fab1c349",
"090a541f1844357f618e5ea34c0398ccbdab0cb363e266980ad304dfd675bc81c0345a4d"
"723fbcc76ab5ed4cb0ba0af1b71bcd9"},
{NID_sect409r1, NID_sha256,
"6723dbddc8720feeb75e2a061b7fc49079f999fbc79ec8a8e01ab8d35b438b7049da5a23"
"c49a58101742791f84f45d5f5cf551cd7de6926a0e2c4ffa1e378f038da597368c62df8c"
"d8349bf046de46d02183dc05b3a3575f5f232dd2970057200e2c9cb60eaa6b4d72f8b73d"
"4d40b98d1cc801d1a69cb5ed780a75a4064623b2",
"0fb9b1a9597d216028902abf743d25944258b48c9762d4589fe660396130b75f6006cacf"
"de60f6204463cb8c18b032de1dd68d2",
"04019b07f7f4ba100aa9e749bcf93a2c9955c442730c5e1f6f72c1b1d132b780d92f414a"
"533282f7b66677c8cc8a3d5ba8b3cd3cf7006ec6e9c495ccf600f8c19597e9cfdb639406"
"b04f57a29dcd1a7a843c2c44e8321bb8508953e9c0503f77d36bdef24d5d39f85b",
"0757f6acf74eb02b7ff3161b476dfd8349854154186c959179f11b9a15da3dface40ae6e"
"d771096e053976866433382e640283a",
"08fe276e7f63ce5f85fce19d1739a8a9986cd3c3fbe26fd59324efd98826f9db3b228321"
"b3ad1d96145ca23cc02616d9e9d7aa6",
"016e06de8e3e0abf4a4f52bd2f827ca4c57412adcce3271fb4014069713f3723a038bf56"
"0788d8dd48430d3b30faf15ad9c0d69"},
{NID_sect409r1, NID_sha256,
"ed53cec5e5500d62d38c829002916c657674ede4439c6f405ba672327ec677490e656bdd"
"698f114c2ab5e6a1fc94a1a8d64466cfe9eaabd23a8b5c37f76a3c0decdef73b3e7b751c"
"bf3b0817f4079560b5ea34cead88ba374201236bffc48eaf289bbaa4e828afa7d732473c"
"228ad00588c9b443d65b998f21c3d7a9e9196c08",
"032109202d754da290c266f74f47805a06e6b5c3f721a72fc97a3bffeb8887e0c642d49a"
"6bd034847d0a5ba09239c5dfdf0772d",
"0400f4dc8b94dfe0a27d4d41399005b242c3e5b14bc7cec55ff3a1561c894d73f365fa8f"
"a2ccde1fd7bf3760b96ab2db78d2d50b03013ac66e95c335b71fd1a98f101a392dd4696a"
"806239fbdd0708acc69333febb48d4b649f14f42841d66ce03f1fb557a361c12c1",
"0b010ef786c13ece3a10eaff79b93ef3899aa385dcc1914e16abba90de0ca6389d664082"
"fa727fa7c7907dc4c88bd621e6124c1",
"0488b8956c5999c317830206fc8b9f6760845c31bc4ba77584925dfe25c05a1e7d298a62"
"e9748c7278eba622713df59accdd78c",
"082701053ddfaa376c99cc42ad4587d84a358d9d8a9533888cc382623114aef51170de77"
"ecf64af02e09bee203851abb22f5d11"},
{NID_sect409r1, NID_sha256,
"13829401bd41e9fe01329e9f5a002f90f1a6ecbf25fc63e7c1345f265ff02e496230f706"
"c6ab377ea52d8707b54f8fc5c7f089044e2bec1dfc66a07da76ee12fb9ea0697d87706b0"
"ebf677600bd2fe117f6cdefb8bd636a1b6b97549ee78f992c24acdf3a946053f06fd012a"
"9c703efb8bd929a66aa74b05d61bff0395232b00",
"080536e820fac59b3203aea928475043b2576446619001647e35693a9e65d15236c3cbc1"
"2e1bbe0eb305973535c882b70197a92",
"04016d7448c0afe992f8c59b19d6cec64d8fc5b10026a806760bbdbbf0012063f46d31e5"
"21a34771f826669c4d1ddd58d3aa13ebc901a3742a6f231546f0704345b9b83c72d50365"
"22449cf60c1b3bdfa4c8d36e499d4ce62e6e7bb05c6132bed1ae44eed17414d2da",
"042753a515e607cf9992dd1f249820dafe53993b59b1e57d8f2f9100f609cc15713d27f5"
"dff4007e078d6da1061ddd36c169c21",
"07eeb1cc19ac45f52c0b63ff8ecf4f4f35958e86cc3e3a071a35446d490a426b48b6c287"
"027b003488573a4834a06dad48520c3",
"01410d85f3f2adf065b60a126170c43e34e0883338118cd33b0b3eafea1d142480b236ce"
"49d35fefd1ce4ad3d25e0cc9268b1d2"},
{NID_sect409r1, NID_sha256,
"e696acdfcc96a6c088069b7595ea9516a36d8fe04dedeb789fbd965db0cc64b7017a8210"
"15f6210b6989e515def5a9605fec0d337e4ac59f3101a505168bf72ab6d98ec62a71d2f9"
"4071fc05b95e98d4efc59fedc138e3e49c5d0b44d1f48f7b1e7c1944ee189b242950d2bc"
"804d31c7eeb45283c84638f043ab9533976433a4",
"0b05e5f0dad9583ea18fb8fc4d8c75fd2e3cf9e92cdd9b737485c953620d345006c31c28"
"8b380258b6500b84f729ce6730e5303",
"040157c083ad9789966905c212dcfd7c049a8ba3863fd4886e4b118b3f06445fb0d4745c"
"2a8a1193dc68915722089d0d382253b67500867e8efb575800f834c978ee2ecf0f84f72e"
"75dbbac86926b73fab8b47f38eee17a63baa02e3edb9d4f6b2fd2afc88b6de36bb",
"0c72eb08acb1d422999ee8d51f9ddef9f897dccfafd886998edd3ddf30a638dbd0ed59d6"
"8885ce242fb838f022bccd4f3b5f854",
"01f4dddcacb088f6e24d331e8b111e390735a41e1fc29da8f5ffdbf7342f4b9056786f2a"
"67159d1e57570bd69d69235ec562416",
"0809840df1ef8fce9b2edf8f970c07bdb5fb755e9d5bacd7996275c4f890173142c39299"
"ce9eeb51d21a32acfc7761d5a2cd7ef"},
{NID_sect409r1, NID_sha256,
"4058b9a8cc15ac148909eb97fa32aafbb6077b168dde91a411dbc973df7db056dc57ff78"
"f0abcb70f70f800bd752197d681f44df4a7817c0e7f60f8f65489ecb6167c14b525e91fd"
"2cc5d8b80ba380a83d031d5827c8b1262c687c90ef0e62723d9b565557f9f6fed0db48f3"
"799274c2cd60a14303406c35802cba6261121296",
"0be1d277813e79051ca1611c783d66003ef759b9e104f32298017fb97667b94dcee1ce80"
"7dc6b4d62416e65d4120523bf6a4edc",
"0401fed0171b5b3c6d9092a6592944680a08a0d4f99f08a3ad1c22b5bbf11c0e4ab3cdae"
"9526b0ca2b1bbd961362faccd5caeb1d3701ae7d57db848e5c86c31f542f1995c76e916d"
"ea9aba882865febca630bc6a10ceb6732bd5f07f51bf2f37ecae7b7fbbca618ae0",
"09e3585213c6d6706524e3c8e753a2eb0edced626498eacd842d44a73c602d801a079f94"
"b781ae1ac5d44209e8e3c729ed4e820",
"01098d98cf83c705515494cdef8c3f50ea8316d95b3ca5f9a1296f09021de57930184ee4"
"b9f563aebf5fd0d5abc0885cd24c0f2",
"0d9706f4474a8fb0c701505516699025fde546a21a3fe519a173a3ac01f683d40b4db264"
"2330bcdfe188693b15a476cd9339ae7"},
{NID_sect409r1, NID_sha256,
"e793237d46e265ab84ba9929b196405faa3b0e4686e8693567e53f68e6991e5767797467"
"7682a2510c4c35b1968a90b32c4941af7813775c061c008a60f9f671cf7419c94253d610"
"6b61e65034497f2d273a5058379bd986e3d917f708f0a2bebdba150f6d78a3af9c722a24"
"30ab0f4bad602e91e18aaf258e3785fee78e4502",
"073c807bd7e07379782ab790720de4ae5106f16d34e80ed70da5b1594e660c9b775db940"
"66b93e74f855f57d88b6ecc6228aace",
"0400301526b630ac3fca5085f633deadec27af353233e6f241772c7fdbfa42e47a04b0d3"
"ae38c04eef2109390a71fa9fda652343cf0137eacd97a8449ce83f19a13a248af52e512c"
"fab3e2ce1ceb789874cb08757dd9e47ac21b5c0846498d8d7cd90122c437602d52",
"09245ba1873114ee2a3e642c5b15049a3566a2f003cb3d25250028655fba98203feef5f3"
"07a9f4c77f232976d83723f2621eaa6",
"0c8136d4b998ca0544ca1430abf55601f259aac7756c75d1371de63d1471053c789833c5"
"cc257e323a71f80e21783df4efa169a",
"0e2ecc6f0a418bee5de7c2418c4ad85d981b18048f94865821de696488ee19291912ae7d"
"a1cf5fe9708e2beb18e6cad4e3f7849"},
{NID_sect409r1, NID_sha256,
"ffb8bc80e7619a562d8506eba7658bef0c25ace3dc1d01bdc2ef00933d4fa07b80364e5e"
"5826074edd46a707dbc3b0ab19eec7ea8990839d7fc0a80b70661204c52bcbef57c1a7bd"
"c861c10766033a82dafbead283d911a9502d5f9ef0a39d35ef26f3616212d4bafcd413ff"
"d18b424fe09b48ba02ca5d97ec996205cd49d22e",
"0a68379b2296a6c944ad5dacb593b302d8ef0b05873ce12bbc371d705f308c739d21f343"
"349524aa72f05341e64f7435daef112",
"04007fa0f698535b011833dac1ac96f3739ecf0c29f7fc1f8bd635f4f98daa70a3931061"
"1ef51b2fdc8b37eee3573dc34cd2528d3900be1a9dc30dabee3403da4f2dac6622e6fb84"
"96e72f3f17c169e7b554efd84ac655e727ae9520feaecc752601d5391270cf0cfc",
"0630547017103c3f97de48ab6b942db94b2db9ed7dab0391ea9e71c1b788c547abc90088"
"de5b3e36c9ee4280bb454c7c3710999",
"0916aac91ad329d6f330cb051941c781b9e59bfbfe45c4d4f6ce0d1aca982e1c612952bc"
"ea06784c57c121b14cc0dcca783d0c2",
"06a83d93f9bb81c61ac290906d74e2d3b964c39b4e96370f19cfb4a55a3f7901bca3deef"
"4bb79ca6a798fb9b3a9b0137c5a9324"},
{NID_sect409r1, NID_sha256,
"946bde90a5b903dd281a51d7fa93d80f3fed07eaf50c18fe9fac5acf67326bb18effa314"
"4e25c151efc006a50a274ec6c6a5d573051c4e2d117ceb0fa125acad07a10fb6534a8e5f"
"5b3da2a1136779c51377bf76c3a4a93c0c6158f729f2293e414fcb952c9509f228c804f0"
"adc1daa327a8991d48ccf4f3957c5f8ccbe3ad4a",
"026046bbb269ddb1ec14ade56175482343a21b7c265026cef3c7d6a1ae0f6a68166b9e6c"
"49a6e733ad2ad64df7137ef230038fb",
"0400d09d8118519f9d00df7514d2ff99483473f680b750604580b61017513870a3cf1c40"
"3495cba488309e2c084079d53139a3695300d25e41038c18e4ba6f4e9d14f210b71f27b8"
"ef2c1d4cdd5f63edf8fe11d548d070177e9ddae382fed2b163ff2b58546f10a99a",
"0d6b0e5d83155a035248ccea95feb0b4d1af818e5ac6d5f41f1a255dd8b482a94de0f4e0"
"37b10339d1805dbb6b22af6ba834219",
"08059524790304a37f2a0d57bb2b93cec79a827b1fdc9ce2d7dfd4d277e0f71844d33531"
"4a30bbec5598a399e197a852b5528dd",
"0e7870e2a0ed16cf340a04fed4d2048e4e231cb8918345e1852bcd3e30413a2219864851"
"121a34fc98dd99976e2b20cf1d1bf2e"},
{NID_sect409r1, NID_sha256,
"07f3fe1369ebfcbcacd66675bd4ab22edbbff72e68709cb57d4f590e49440f01691f490c"
"58b5117bd24aa2fe2101b59c61c417c918ea08ea34bbb9b8aa17491ae5d9329affe894f4"
"2d7586017877fae3ce35bb80c97f92a004380374ec91e151995166e14ac00505fd1fa810"
"cf02981bacbcebf5f81b2e633d3a3db6737890f4",
"0bbcda66978ea526f7bd867c3303b625f11b94dd9ee6e2c2f8688ff07f2bba83c662949d"
"47ad47fa882cb7d203a7f0ef5dbc52a",
"04004cf5bc624553e833ffbee05ab863e5def062e0d57c28e71d758d6ffd3839504d7ed9"
"d3b1a040bdce8e187ae0b4ca23aa565b0100fc1a15b4f273737eb92a56928395f6518e05"
"bf946afb65ebca3787f7f8bb3d946dfd26c4831cfd171b4c66c2237409ebf224d9",
"0a2cd205d957a20c79699e91684cd22746c476a79245f11e7cdf7e6b74f07cf2fd9eea65"
"eda97e8994aaf51942e15695545abc3",
"0aa1da120fc19523e8162e6018e4ee053eb680ebc7e31d00db34f7b177c74c5e6ea344bb"
"a3c39ab7ebcd92996a1c156180b7dc9",
"071aa4588741208344b323642fe03f1cea73865ba645169df9c84bdbf7488829b83b8da1"
"72f1927de1c8cc318ede545c748c782"},
{NID_sect409r1, NID_sha256,
"3a1cb13438e3bac9ad4ab1d319e90e2c9f118dcf1eb54d6333c674a665d41451f93cd4a9"
"334cd057a44c010edb668254517a63700a31eb0ca474c84873e486f2f8e158a1a7735362"
"ea0cff8ef17d959ffd851b21a91412709b3c729474d2cb40f6ca0e397030eb2611b40291"
"6e4b656f0fd868247d80be3ce33d52054b7661f0",
"09be3dd3442e0330750f0a6252bf9cb317f32f942ae516a4038dea2c40ca6484fb33611b"
"ef016cc64baf166c122e87c15466fd8",
"0400f05a6fdbe6f80c0f5ef3322d8accda4b9ae28c91b6198b888be713afa5e652e907e5"
"ca9aff5fe77b6546115b4c732bbd4010fd000923d07aeb8c947688e7d3dcb16ca69440e2"
"a89539a41b8fbb797523d3b766b46d257b87472f5084992422cebdc4e45556f5e4",
"094fe051a13ea8dbc89c4cc5511881a48ef5554de265f0badf8741ae5027eef25c617bb6"
"a3f454a992fc68f5a548903809de09f",
"0162687730f0ab2f57e348476d1fa4eaf13199ee44f44dad5807bbea4e5ba79e92556f28"
"7cacbbf1fdec9a8b78f37e78e52dc1c",
"01acc734e2d0c81a56ee8c0465661c365edae56228ca43184ea1d7503da3d38e7607b159"
"0f59f5190e5c7264cd0d7a39be71069"},
{NID_sect409r1, NID_sha256,
"e58e7b881a563d54772125b2863718690a5276c93d9e1c5feabbdb5d6f7c7293ff0f8980"
"5b53663bb417fdd46874b8e6a466e7e3ff6737930a0662af1d5879b071b0dc4d014778df"
"f26a2eca5992e763bf4c4698c382ac947215aa116515876008a56e5bf547857049c38a2d"
"3737ed3393705fd346897c3beb80caab88e5b8cf",
"0ed321fa283c662e87eaab99b7715e6cdc9b42e14fa5bbe2c56fdfb381369191a42da7e5"
"74839f90a85577485f19446fccaf6cd",
"0401bbb34e6bfb1c1335c48e8b44cddd8a46486fad4313581df216002b382db1d58adcae"
"74af0d38445cac2f6cd9e2b439d106f5950084473a5da9f910b4807ec5ff450be353a187"
"af6ace821b18e096c47752b6336dbedfc4b481e356e689fd9c03ffcdbf3e4ea39f",
"06ae69e55ac1f7b0f844f5ee0b583e652e0e5bbfa4eae85c59eea1485148e34f4d33c9dd"
"d7ac071a28ac0a6191d5ed03e88bb86",
"0c3509b6c0356e4a30a82fa7411d1fe17ed190b7eebf9310c44fd568494c894a4f4a1a09"
"e58a4d030d47227e54f7220f3f79f4d",
"0d44ccff47d9fe82627393c03f882d4b98633961a897381ce8b2cd18f38d69742802d18e"
"6c988a23eb425b294f2c1b84cf42cd1"},
{NID_sect409r1, NID_sha256,
"8889ea1da1cbed98963941f6ac24f47253ff6af52de920765214f2024aeb04f7ad469368"
"30a8eb04d95aba64ed7cda6ef242f454b67bc2de38a46b6524bd5c96739c4b580e89829a"
"61a8249ec8dc27a50f43b8554cfb6f4fa4ca6875983d4b60a1c6b49f32ddff6fac0cafb6"
"4d55c6f594b195c207a9bd920dcf20e0080920bf",
"0396b805073f3c3b552b1024dcf35559ac44f255b688871a3c6657f727a4b09f3806cbb7"
"5d26a00ae1728be632387e804775a8c",
"04009957f897a17241eec5b8415ed7ec1bde5df11583255e0a8136d076d72ef377ab3f55"
"3d6f56c054332a24098aed6d12878abbd301f58eee295765e8a55e388e235e833bc5cdc5"
"d51a1d98e13429bcb7891b25487b7fd8ed804b1856cb6071cc28756bf00924bf1e",
"021959970a6ad070d1ac518493e309289f3d9d6e2a8933bca715f53cee4ab9000ba2d014"
"7282495e15e63f258dca87a5db7eaca",
"0d1ca34413341c115f780e647519547602e0361ed4d70402f42d735353696eac6e4024ed"
"2eacf9577252d40c27297e9389d1f7e",
"08cd5bd43794b32d5bd2ccf7ae4deafffa0e0deb92b1eef9d3ef807d456e459f92e9f106"
"27b7e7574ebe3c2faa858bd3e62e187"},
{NID_sect409r1, NID_sha384,
"55053af9370901e38622734a5bc5589f6a20e258627f381fb0c366f3dbe58394e5997e97"
"8eb7ebbc530f6e6186f48294149b8594fb551c31c50521a8c4d67e5862921695604afb23"
"977b6a69b21abe75966fdd11bfbdb6b51ab0a474c5fa07c4de7872a3bd81acc417655090"
"558dfcd5af449b3347e61fa9e839bb9457de64c1",
"0a8fe323f6736bcabe971c7d964e75dece70cb54561da48a11c40027ebddb23e41c7b486"
"00f569500fe8ea2abebdf480171dde4",
"040020f2dfee967949643b6cb8a3810524044a4b873a4984e9795e4dd7976536a2d748b8"
"cc636ef5c8fc92aba5677c4a0951a3332700956ec5433d73162c9683558f0dfe8870cfe6"
"6575f2c34c765372c7c3bc3b291e95c4e3665e4ec5e72131975f0b1f5f30b0c844",
"013f26e13d43ba05e01f92457374fe2ad1ccf94ebf22334447f9360f7f9748bf3665ec30"
"58ff6184fbfdbf7de9e1e2131cd3991",
"013c4c290cf89789bd6dc523deffa20c94e92e88a76eebe88457e30cddb066c7a43aadeb"
"0493b264cdae67532db7dadf879d991",
"043bb7a8db3d79938beedcd6ce02f375e26ce807a2afd4fc446f372fb09a69fb34734df5"
"dc8f6393f86577a8d29014494379624"},
{NID_sect409r1, NID_sha384,
"c4264330534a6c2bbd8a3b757e0912558302ce302f835ad8c5474993832fd30036fdef40"
"b10ee37293e871db5b0b149654f9e543e22111f9709ef45732125f713c031ccfbc9a2f3a"
"ba160c241d27be4dab87ab2fa9a795752ab2daf20f9d06a98d90d01c07133adfe83cb11d"
"5176525e1bba6a9ba70ea48b224d46ddd8103f65",
"0105938ba9f25034da3e032dee121bdb192ac2128b50a2ed4bca042e96cfaf4660c9d35f"
"3e67bafd4c99f9447e6dc408e0c4471",
"0400f1a9243920d7cc26741eb828bb55e34c140b0e52837792ed6274a9aa6b5534cdc5c5"
"96a1141a746dee380c0d9c2f77094c36ef01393ed8c609751550ffd077347712f3b27a86"
"9cfb1b532c5b19c381365ae5dc8fbffcb2182777a17690616d71c66524017d861b",
"0fc52aa8c590aa28c5353568c9dc69734adfae840f1e0642b57863dc7f4faa37bf3ca789"
"a3d7afb32c57f66a61780e253f50af4",
"0c45b1629bbf3273c0e785a28cb8187ef387502ac4438a3372a5c72206a15d7c5ecf9203"
"ecfd7e0ac910b6ceee3be50c6664f81",
"0a0c2d31a47ad5f9dc2d42dc36714cdce47666f6e2f05ce0e7136f166647540d1e5fbdc7"
"c9fa0def8962f44f2f8bc9addc10057"},
{NID_sect409r1, NID_sha384,
"3236f1ad164e1b25d828f5202e3513c80c72a577aa9af56f041fd96cf5a3363f4b827723"
"b1511a2f16360e32eac90ac55f4ee1146791420ef9e2af333c17d157b00e43992ef6f2be"
"2d2f211361e468413dd93fb69232f0a0d110bc5fff361c0410344aa0636bf809062c73a7"
"ac7c142063912b6ad7e1626fd2a384f35faffaad",
"0ce11677ca818537dbaeb880fc967dc8bead203a2538a55e756679c4a9e7975b9b3e6aba"
"4e6c6eab4152d0c0939027e9b0bd92a",
"040023c78eda396efa28c92b120c4ca1e19dc6c467234f9f73701d8966bd0826c20122af"
"5f7c9ad5a5b855b6dc517c22131fb0b5af01ea47619f91ed4a010dd49ece7ec78c5e9829"
"7220b4c239ff4a8c29aaec008011acbf7e4f985c02311ca703bf4ce4ba43412ecd",
"0dae763fced0e498e3efa1c6c412a25774c9bd6cd4bce25ab0a7266705cdd54040ec55bd"
"7e6708e71b09ffe9c19af9a1ed9c878",
"0a70694fe5da7646184b23b4b434bca1b754257b8e7fa9994dce4a7a92b7ec8c7f8cc69f"
"18d17915c6bbca24f6621f9563f7c35",
"009e6ba97ac2be8537afe7f8f8b9cde8841323b5cc63cf2ed46a7913096ff8d96040296a"
"1bf9aad691b60e1f18233964a421fe1"},
{NID_sect409r1, NID_sha384,
"6c400ed098d8369dab6fde3553afbbd4d47836d0d12dd16015f15cb8d067a39391c85ca4"
"e78c62b8b72c1592349ff8dc52db8ccb7fd80c085fae456dba6f4a2378e184dd59238c92"
"cf04e40d43a66b342d2a1325a0bab12b1ac857f0564c27b35e6abed02ff5bbbdc3770ddb"
"b2ee0513df48bcba925da6d61583076cd3129603",
"05a239ae0f40d76d8d3589f1662b5ca12176a4b2784faa8339b54e96a1e1294433a4d83b"
"f904196f939bd8b33bdb4be340ec703",
"04009d03b7985647027a17c06b30ce9fa1b43d0484195f584fc347f7003802613b524cb5"
"641db3425ab4b3839e12c012853ea8384300818f5e270baf5a771627b098a6f9ad8a8262"
"e331c299fa0722a0df6ca09bdb9c92d22d72a73567cd5497d06639aa47349df207",
"0c22251c73998a3a49b3fc65acf01438941a8885d1c5072a5d41d779af70c044153fed40"
"80151b524af402a4e8ede4448b717d4",
"02d3a7ebe5de23e0e601c6e41616bf2a9a7fb6193fef8e3f0a7fb8128a925f7bec383366"
"9d1a304652b7bb1af5186b2f612da1e",
"0b7bb17155068a8d9b3412d04d407556ee133e1a704ec5da87ed19dfde60517501af345e"
"2e744d35d844f8ac8ad08b13b17c498"},
{NID_sect409r1, NID_sha384,
"039a149eaef2de30b0ae457b376ce6fbf88afd4cfdec02d3c5e00400d3b0484c1cd6ba74"
"db5de65d6f2fe39871349b30fdf1ef29bcbb9e182eb3ec5629d07d98354a5dfa82d7f0db"
"3dd10d1510c0dce086848a198893ca5ad24a663494f0596b4eee86199ea85e7e8f2f76e7"
"a6bd4a052c54287f61b391f1e52f96b606151c34",
"0077390c62ac41aca995640fde0c79c76f4ea8a8dbb22323ed812bee837ab8798c5d0ba9"
"76c7aa634d4b1c2c155de2709e7352c",
"0401a9357770270c528f2af991c447bed86194d458f693a871ca38f271a9e6a566f5b9ba"
"3ef3d2f9bde959e42934c95867b280e9d1001f3a0516fed36d3622fae3f44d87c4bc67ce"
"e0a995cea242e530451d43781f2ebd163f6f521497fd7a1a6c7b93d33b77083a5c",
"02555cc113c8516d741b47ca41f53ed07d509845f140dfe7dffbd01a3f751ea9f22e12c9"
"39a2ecb1827c0e56b1b1c5459b66aa2",
"0e88333875a507520d0b62b35146e37e7ce4e2f2478a61adfcbc6e1aa9fd0195a4960c63"
"3d9d6aa9a79323b7ee00ab802768436",
"094595255e8862d14980893c095608113737f42b05b561771f56ac1d54eb521bcefeb392"
"8917c07c1bae74cb9aa80dbd34962d0"},
{NID_sect409r1, NID_sha384,
"08617d04fffd6644c40f7dd57919f7dcf3c888f4147535d12ca658302305bb8e220bb17c"
"cdc480254004b9035b357120580882ef86aa5a061b2850100285b7d61588a664dd4f5394"
"f5478e68a80f610c9204d056009c1c9e902161eda33ef61aa902e96b6f094a9f05313569"
"2182943d38b9763055a38739a2a2d133c5dbee89",
"08bf23b09fbbed1b55769907aafb97f4759cec98649b2c9da5157517d4f85bb70157076b"
"5e4aaa7a940af042302f8be06a84ab6",
"0400883c31c474333f74ab2b86f3eac865c4b2b54975ce19c5cfd23682d041ef3deaa43c"
"9f9e2c194ccd3add6677de31fc9e07dfad00a5a36b54f4eea6b300491ca22054280b3f09"
"b202b2a6b55df9e3271c763b6d8360a330c16f936d69fa463bc0c4071707c9cf95",
"0812c83aa9dc4139f8c3f7c55509f9e10e6cceed30e16afc028b1904b4d260ed0e77acc2"
"6e711a7a8e24c75fd780ed893c0bbca",
"0fce07c6f791a05de29609b59d55b7062e82fb554341b2b2a8187baecb9c95b01ca5dbf8"
"ac88c60babe10af2edf5985b35e10db",
"02bd026a3e45ac439647a483261107829411c1b4a9ab603c080b92f605cf742754b65498"
"1460cf7aa72b5186b59d224dd015314"},
{NID_sect409r1, NID_sha384,
"34c959f549a307f21b850ae105f41299b8bc94fc292aefc61aefbe0a1bf57576ba8d9b80"
"caac635e4edeb22530163fa9629665fcd43959f68eee32482f1845a78ed7278e6e43d09e"
"d6fedf465001afc0d61f1d2e1d747623e82a762576b879c7024e34f43104593cdd691d53"
"bccaeb8f212dc29bec6bc94cf69d0a8491db124a",
"0082ad05d19b8e16f80e53a4cccf6869ab5128c5e622ed146fa8555985ccd2aa3b9957dd"
"374586115d4d75b1c01cf98ecfc3646",
"04004428d05366b0a46e6578fc7528d185a3f85da06c4179e9c9055dc0a7fb4afbc53c94"
"954f268e36d2ba8731882bdd27d9684c810136ba6048ec672601987e9b7402fea24f88c1"
"a94717ed5a83794add0f31680592d6cafdec147dfbc400e73a6ba1d23d4cb0d707",
"0c00c897edea7bbfe1913e3da303d64d0d657a83c1eac9c111722b17c65391f2cf67b782"
"19e748ceb269d6c65f01e92e6952979",
"0624c5bcfd8e0ef22ee6b34a8b26bc051912cabac102cbf56c364a743e8150195fc55a3f"
"ec90a8fabed5eacc1799b565745bfd1",
"0cddd4937da8176ddf0de7f52a4babb1f6fccf861533f796a487f35d060ad9ed4435e5a6"
"7166782b53c20bc06fd1b36c265c1b0"},
{NID_sect409r1, NID_sha384,
"514f4de08a6f49edbb6797c9dad6d33bfa367cc1a1b58a5becfe646c7f3352d5c5d95f74"
"56e7112c4ddc746b9076b9756ae3916c07bbe6d3823895774a42d25d44b3309d18bfe7e3"
"ccb1f85dacfec1654778c19e2981a853c1f40a7eafd16d331093110698c957fe9f1d8658"
"2706a6885543248b944bb70cdf9d2ea89190cb02",
"0af7e581aa4f9be5815f0c447e39de00da9194eee5e5f609668b9b69930b5b48a948614c"
"2250260d1917f0ebcb00ebda4bb52f8",
"040044703e0b49437315a64e397085ea2ba3f2e2c383b168f31a922e5916d590344906bd"
"2a911074b7481aae7f3f8f4807b110f2e1005a13607a3bb89a2a88e27d5eb5cac4eb498d"
"34e6ea861c80271ed0c73e1fa893adce0c1982b8a8af6a0249796e5276d369c3f7",
"08e7fcadc844456f14ce9354b218d519d86c0c5211d62904c937d6fbe8cb16264d7d41d9"
"8a15e9f73a636ac3739770738d6b46d",
"07aebfd1681bd5a2f995ad4a709e8681da742649c0530684fac251494263e98d67247e1e"
"4fc174b409e7e24a7b055500920cc82",
"07b83b9b5133aec165316021472307b8b481e6381754a9d0b4f9d683c2ee7cac94ed4d8a"
"72cef61fa1f6349b6c4a54ec38975cf"},
{NID_sect409r1, NID_sha384,
"4e5d16cb1dcaa1abab1e371e1de02f31ef4e0944dfe1fdec45ab64326435b2af9aaf1a6e"
"d8fdf1a6ab1182bb53a844c7cfd66da30aec0d41757f5988ada0017c4ca752597a9fd363"
"7668bc1a92bb1556553f28d66805bb47f1ef91908ce098d452872da9800e77e1fbd43ffb"
"0ed6fe6a62185d4be73ae96c9241b82cefb2da22",
"06d14107b08354e6a41d7d7d50c004419db8bdc50db43428df5e86084551237223c498bc"
"e71a17e25695bc438c5c09e009c60e2",
"040088c1517355cd417a698b648508fd07a457ac13a49d1bad17dbfbc9735ee58343316e"
"3eca570bca130c753e17a69fe5bd7baff301397a697d2113d94daefe6be491ed3edce944"
"9c707a57af3a164d172cafece564d686fe0d25725c2919c60889af4d0354b05117",
"0f3bb2dd9eece25c56159f501af8b619a8c279d7ecbc08ee2af6b82ead80375e9c07227b"
"73a10918d8c89d1a2b12cb76427a7b4",
"0407b224d8d9c0f11a8e09ac8d654dc6e1119e2c2804510a84ec61f9017899f9613e37d8"
"166e0fcaae16c3cc11e9f739968c687",
"08c2bd7d02c4c537a308fa40db786ec64fbc2dd4c142b18cf9bcad66199afd4f44cbf221"
"adb3837e84173d174e9c0d534720ad3"},
{NID_sect409r1, NID_sha384,
"e29e75269754ec1194270f5c9e8267dfdd8c696008b5ebc92bb840981fd065672f07f6a0"
"f1b19841adfc51b478371e1a0db9c3346a9f0a4ccbdecb7040191a00ddfd0a8faa0e69fc"
"f544319c0155d02797eeef99fabbc55078f9d852927c23fd931685424249b87ed0c70a4a"
"3e2d3b9a2f92830e7d8f7650c0bffa8f8986b7d5",
"099d96d2dc9c79549f031bd5346cf6a8544c312a3fbfc560dc8e378efdfe025b0e6e61e0"
"9c04c8bf4133396f993b0906c33dd30",
"0400883e00d72c60f22ab085a90901ba3e8a510f19c3d62dcb3ee5066e0be094cceb30bf"
"bed7068d0bfdf634a53e2fd002dc9e454d0194baa5d7ae2399965fc4009ea83273676e66"
"a56fd35a5939c26ccaf85633adf78b33dbed6da305979077418c625354c7fb6283",
"0c213540a452c4f2ef275dd844402dd5ea590f7df41ad35523edff09b7fbb096f8ae8a4b"
"aee95428fee03a9e6f6a14ceb90e289",
"071779b477245007ba1ef5f05446c4a08d1c2eab550db9c053e4588c9935f07ba87764f0"
"fce14d4a7b982ebba89cb056aad8cec",
"08174bb56cc85ebe7bca1de1f44cf93cf478d7fe59001c5947c66b837bd3a6d116f99dc4"
"f9acb4f378b0321228518e1ba0057e2"},
{NID_sect409r1, NID_sha384,
"1a538eb447c18494ad5a5ad27be67fa60eb2c5cb2404eec1dbd7244cd802b17ca5497e77"
"9d5f779b981b165dab53ad19fd7bf2ea7dbb9b4baea782a43d758202f147e59d6b6b8ed5"
"4f4ea084bc18519943f6894d603e253ba3e8e339a6933bc3a0a47126087038e1c813c3f2"
"997aae321b7c95a802b4b73fc7db95897b7c91e3",
"049f347dfd361a65910e97fcefbf60013a54837f2ae657d65e02397f59dc6bca27704fed"
"3affdc3d833fdc621cc5e5f99b92a63",
"04017942b58d42da750a366d7e4cf4cf465c856cd911e5352b50bc8a12704c1ac6ad54f9"
"465e4fc5402b373d8bd4e4f8519341f133010abcea49c66730ddad7734eb1311b2626b75"
"ebbb299a28c9d60937e6833a9b3dda052379fbcf7875f18680924274fa1764158c",
"0134c70f031648bf470ccca4ec19c837051bf700c851df564ef3ceb99d7d41439293bcea"
"0c656c0e5361db92a03def51d7e4f26",
"06c0f9935abc5034a8b0a05e8d04de699b5916cb367e834f13642f0003510bfb68714be7"
"5c9e35b5e593eba45fe151d1df56d40",
"0930baf426b33eb4afbed64869a22712591db11acee7c4d3a221a1e98048f05900fe1481"
"6006854cb90631de5797f91176fdcd7"},
{NID_sect409r1, NID_sha384,
"7502c755bbd385079a4001b8cd653287dc3054f3b57de19d0ff8f63c0308c64c56f03511"
"7a8971d43654f89b52e923947e4760ac72be073136da70c5ad7ca1658cc0a2d2a880d3a0"
"c0fe636fdb27b77ff260c4c1ef8a18da8e9fd777d732a37ae9906e6c4f381f0a3d941048"
"d5a1f6f2cb8593873fa4bb1621a44bc2bebfbcd1",
"0dd226de602af4e9f8e25784bd1bbd4cadb0a8aef525d5e2d57b9f3555feb698765672c5"
"099a7d6dd5faaded69d8d68b4804f26",
"04007ee34cc7a24e2e693f9409f52796427ed86fa71bf88c923db305ebd5a83bf3b6f761"
"2847f16d00f4a25614299a2df92bb693c301f63f177b54f8dd5c907ff318b66c2bfc1cee"
"09348c035a4413fa3cf5acde0db1c8af4fb8deaaf8a3a6f8f06b0acfd20c6f0049",
"0e19c21b05c82dd8c873e5f30c1e3aa9348327f959a4dbd9c741e233c649a426cf7bd9d8"
"e93232e496d0b93ce835f80fbcfdb2d",
"042a3907a480329a6169b439a6945cdbe8e4572779c43fa6cd1f15062559dae9eda27124"
"02ccbdf03d88a8a68b691f1f16f8f52",
"0d09fa4966d171a662a9ba6827fda830b5404f96f635edd8482ee009ec5c7b64a2a6c177"
"93993610ae8297efa9fe4c35ceb5001"},
{NID_sect409r1, NID_sha384,
"95eca932d03f1df2e8bc90a27b9a1846963437cdafc49116ccf52e71e5a434cdb0aad5ec"
"cb2b692ca76e94f43a9f11fa2bdf94fe74af5c40e6bfd067a719523eea6b4e65730365ee"
"498ac84c46e1588b9b954f1c218920cbf71b167fc977ee2a89429590f43bf637eecd91b0"
"ce3be2d66bac5847205f76c06b914a970f543e59",
"0b6fdbc9c8c76cb2b822a940d8675889ca6f5132429da795462381ce29313a23bc132976"
"fbeb346ed4c691e651028f873ce7971",
"040147647d267afb4bdadf54baa3f5131e79dae8103f5b2ddf70e4652f9fc5495123be97"
"215b811554241c53023a247936053288bd015205cd5bf0c5154b2dad8367e1b487689b89"
"8acbbf44f9ed67a37babbec739804dfe737b324ad663cd2cad79274344397099e7",
"07321d12d616dd2ee5f843d6ed7e92d18968b3a76c0e4ccc167790afabad1b7c0dd53d82"
"aacac93d98679b203bad88d5ef0cd75",
"0672c5607acc646c67456ee77f2c02117cabd241f728ace5117626bdf91662323e756543"
"8f46a3e25c048a8e2130e27fa1fa2d3",
"064aaebf9f2fcbc843ae1128eb6c7e7d1fce2b9901dae0f60afbcb08c7f2ea1b550e1599"
"47deb87dd8959921846e2923880db6c"},
{NID_sect409r1, NID_sha384,
"8ff68cb00d03e730dddb05fe0b2344689529096c3da6eeecaf097f22c7fa340593106b1f"
"6726f06b7ce7358edbcf801ead959438a42f94cdb467b3cd5b17fbbcf75739805f9eadc8"
"69c33c604cc58f81591b0b8bf4d42bd53a801f0f829a31af6c129fb4f20f1250f959754e"
"ff8c629b85a716b6a18465b6495798c0c5166c8c",
"0203d77fac64591eb9a18de20a9d5eacaa1c3ec58a5ecdb3008c2d642e197141d16b3a9f"
"dffe61429264f5b420f5e9926659a4c",
"04000f66ca09d15d0991b48ce7afde9a148565b73807e435ae0f16c14cd439454745f8ae"
"153786d7c40cce3f43a8aa4f0564cdcbc3000f4c919b7a97beba2559a8ad0f85dee40e8d"
"f28e23732d7de655262209a5170f94791e255e77e8c8cd64c8c9900092e0ff9d5c",
"0859bc752300d4ba5014e302aa4cd2a979b3097dcfde5c59f4bafc5bc8a99411174d2ef3"
"f7377df5a09269e3d9461be61801942",
"0691ea76acbd5e8137924bee13326ceac8231688af8595718e210bb857d6619c152e1fb4"
"6e03fa83bd6b5d81e2463f9260407eb",
"054df52eb86c679d8f8514a09f5a3062d2424cdc19fbf6927f744aaa8c444223f1c28ddc"
"84b1d135a886eb7ac7eab3c7b0a42e7"},
{NID_sect409r1, NID_sha384,
"01451c4f09720cd53377a5ed04c907a735477378ed960235a833049d6bad6e6e89958b4c"
"4249bf0f6d4f043530c9e5426deb0ec3a12b7feb4860757b41bf602ca95655155356ec35"
"a2db8e2657998f56529be4b714364f83a140846308a2973907ed7b08e935173ebbce5e29"
"afe1444cd51c92824ede960056439555e7e74450",
"057a2e6a59d4871c3d547690237dd9846d6d5dc4ec0678aafc9c8669af8a641eed67bfea"
"4b05fd6b3b5357ec4d0caf352691ea4",
"0400351aaee4207bdac826ba17e3b08dd7f94c0c8ba0d9829d7bf0eeee7e6375458b5457"
"bd787f0ff38564734b3a0412bbddd7c37100e09c4dfbc33d61d69b5a8517baf5e4e16149"
"20cbdd89bb05f0420be757253fb92308dfe1de8db822f57b67b393d8a70d989b26",
"0fbe560003dc220e4c966b21c874b828874a33a93bb69c49909376df67e5df1652fd91a1"
"d73c7733f26c121e7a3b2d1246c9a61",
"08b85cf3a14fdfc69cd42750baf362286940994479f6ed7ce1d87af12c5ae075b311754f"
"1d37d8ed10bea092bd3d9f7afd2f1e2",
"02360bc1f7a98cc87ee2a4feadb98554cce59aa0fbfc087747c7253e54c38815cf91c851"
"7f5692f95bc7c3a713fb6ac43a34f7d"},
{NID_sect409r1, NID_sha512,
"ccd494ca005ad706db03a3df6d5c6e876ef859ec77a54de11fe20d104377df1900b6b192"
"126c598944d19a2364b2ae87ad7fd32265d59e1f22be5833f20767793677b628f18e9619"
"f8ca32f3af3b41c31e87a98d1527e5e781bff33c1a8be3a82ea503e76afec5768d7f7dd1"
"f17dc98a9e7f92fd8c96fca0db518bd143d82e6d",
"00a3da7a6633608fcee9ce4253bbcec08d41ee6b00178ceb017de74e24d48fd89107c9f2"
"db3556063abe3cb011938f4b4871795",
"0400a6123b122d7d0d766897b15ba6b18b3a975d3d8058c9d359c6c6594cc0dc07d9ef60"
"33224b4aed63d319cc2747c0660e38897b01ab5fad5e78f380aeffca8d15e60731720184"
"ed456800967b2ca47d482957d38409ca07ea798bd892b529774e44080eb8510e6a",
"0da042642b3117f30ea5f4b354047b164bd128696b8c00cc6fcc767246daf7483284e411"
"009e05218246830940178cb4ebabf1b",
"0e4ce613e6976e9e1c30c0c93214a0a37f0632de85eaa25464b69a251d592560b2039fc5"
"9b15ed7045c29c268693d7c9e06d8ce",
"0ff3ad5ca70aac94facd842fecdf6a28afbceab80b549507954b7dea6da06d1facd11e0a"
"88e9c2a549e6971a08d1af75aba8363"},
{NID_sect409r1, NID_sha512,
"5719e50d939a8d74efb444eb5a77cda48cbb59e7f976cdb2ea2848bfc558718b39ce27b8"
"93c229db94bf77992222d1746f8f52f858f85124a28193ae0da039c53d484681785f3367"
"f6516fbb8a86560aea9e3428551facc98cdb1e9df8e2f37db823a7abc589f667b5c93c4c"
"47061400220a2014197d514217fc252cef5a2433",
"0384723c8b4a316b450d1fce0b2645912b8acaeb3cad50860cca43bdc0206ed5b3b60ebd"
"c29b3eda305d0d60eeaec261edc24d5",
"0400fb89d87ca4282ccd048606e4d321e7ca73244b4d0c9d3df87d54e038a14939138bff"
"33c81a9ddd64abdfd698bf103e45c96f97004ff7e1706688a53a5544f4ed0f3f5e1f0fbd"
"6f21174166d25a690f260766646cc6fb39020de9327199225e44f3d95c5984fda9",
"03a9f5f26eac81dc8ca0a17acc44322d43bfd18edcbafe24113f5e5fad0ef0a3db75ad1b"
"2422c7321593e41e76eb2a767a14268",
"0c311000c27539247059e4a8d789ed4db93fbaea021272a90045bf6fdd70f4f32cd1e195"
"b99ee6f03f4fb57c3a115ffeb459af1",
"00db8bb46fe0f99b4e6e1394a5db283e310b24d6006319986dd2c4cc169c775c89d4ad98"
"d0fdbc3c0bef6b7fb6b43ef21049bd8"},
{NID_sect409r1, NID_sha512,
"c84e5702a339259a61b5ba8ec1957f23ffc4f1eeef3a58f383d3731bbaabfcf49ce2ebb5"
"97960ac5115a2af1c62b193d4ab6c24433d5f168a1752e40145f19aeb6dee889a53a4fad"
"d13eef60e28fcc7ed6a9b8b0ca286c1b3d66a4b2c327a629d15c148049e3a0ccdccf05cf"
"22c31956014595e417060627c8125bd7c00f8850",
"0bd3136647572fef3de51b12e64b36460bd3a27dc660c164fc705417339cab21f9e1f9be"
"0f3da926df459c5ba58b701d306e67a",
"0400f45e18834d1933a2a26e95467b6db85d8c3da372e607907798745cd9847bb8f8b51f"
"996c7293b51550144f227933ba26722685005d8b108eb3591b164745d116c80afdd48701"
"87061c75af9b0c3e87dc8262586af14f4d6b1504d274c07c8e89247196d8ce8166",
"047a494645b99a3469369b72cc918708ebf453957b49ac4e209f2edd7a4861d014543754"
"e37e1d1a0f477951a0ac2b5826a470a",
"09de9e0147e1a268f80836d7db43779ce12e7947caa851d109273ba7e7dc7fc52c601f5b"
"f69cffd5adf0695cd7db8de2a64781f",
"0561aa76e1e9f2c1d4aaf6e2da143f67166f09199e1705b631d650528e94d643768cd611"
"467284a9f543e50520e3e738e5d56b9"},
{NID_sect409r1, NID_sha512,
"c90bf11d04a708e64b6f94d4cca64b92463eae878c377b188c82c1c5f05a038be20eca2e"
"18034d46f00d9a6fc73c4084981748ee9d2915d87aee4e2321f4f9e11c176f01281913e3"
"24700d9cb474b7134fcc408fb4a7006acd9e63d4578ed4c2729d8e0d01b1e6174a43a024"
"ad261eb644ae98979c3cdab75af357f6dbdf5db1",
"0495be0b0a9d357f6155fac008cec90442200bb842d89292fde38b7256e4117284a60249"
"b3101b3f19f778b680c0d1d7422b84a",
"04011119cd910d4e962f54c9776c9180e7eac2f71cb9748ace4b7dfd2d2b3caef4964c7a"
"55caa9763e008de600b727068eda9b98650000b48246cfb7c86e9dff4ba77a3a53dbb1ce"
"fa168026b8929c42c3b0251fee5746897916e50f07dfe8b57baab7964447a2fea9",
"0ad4ab5ecb84118c33a4b06d1a9f5d2c4f1f3dd1cf71af596eea771f851d0371d2d72593"
"c926d7b69b39cdf72931f6bb11d10cb",
"0e959201622673d81ca16ed94e9e5be3f38bb8db48f9c09a585aa31ff39f14128d79d604"
"a5f93c80aa961c85bbf99e276937f4d",
"083099697856c780936ac01aea5e3a4d9b6e183639cd200464a5cc05232df30ff5220dce"
"4e2af714c580d561b72dc4969166a6a"},
{NID_sect409r1, NID_sha512,
"e9b2a33906a1079280100039787377c2971c378b92e70a38ab41dc23979d6fb0c41e53a2"
"1b37632407adac6f212341cf6af8605b4978c85c9c16960e1674247f1795cd73b99ff28c"
"dca024f5078490513c77114c2f52288f5376872c331151d7b2c08f7794f2c1f9e0d849d3"
"2d73636f0aa899988ca561a76f74543b37cbf3a3",
"079626354dfc4eeeb51fcf232ee9e6b0130c9bd40f15ed45606bb7faeca8f359e0c3e18b"
"f12769254522fd4077eb24bd5454871",
"04007ad047bb38bde6ae2593e1e41c36b7efbce1e0ad08def9b23d25b7ea9aa336eaf102"
"17df16d32ada4af03dc193d44e6c77e67700d2b9466ecf321605b9f4f952812410800720"
"3ac32cfdc7cb87e1790ebf4bae497fb87011e0a81068e66a840d29583bb970e24c",
"0074548d1a3df580e45babda6096f4c78cd70945ff190d9da463fbb03a511c45d45dd1c4"
"6dc0b9521579fb506bf015f8b835680",
"09e04e9ffc2cafdefb600cf61e803eb78cb416304210165fa7c93c1bfefb02cd4a255512"
"622d524141de02c2cbd193991dcef67",
"01a7960232455f27768acd825b8ef91d4efacc38684d05a900a8512682ce19787033cd08"
"c1f2412b481b88ad02dacc0ddaa0ec2"},
{NID_sect409r1, NID_sha512,
"672db3fb8cc8e5f831be700498d3ab3aef14b7548e8011b21351215fb6dfa09460d18f52"
"c02c8815baf396d856a429bb9afd602a10c213af34db80447f4c06ab4bd28873c88eb963"
"9b199042d4b2cb13cc364f734fd4ab7bebede7dd4da63decc0cc1f84e34d760013f66d71"
"641073f16c08078880b67230f2d6c6bfe17d206b",
"0ab42bc7d0e3c23f8bcf928e25f9f027b56f270398a1d37bea0ee5426b944a9c9ba6d0d7"
"796899543feedb470f70b2ab148234f",
"0401415fe81100f208ec8afd5e882e5773a0c1d46e44627732900c7e1722cd77b3ae2443"
"8a8463bf571fd6bb422d7c583439c07cff019c3ef3688ed397640e873dcb20cee9755437"
"d0023646d05612e8c360717a2e80e80f2b85860d71f9876f3a68548da7099f601d",
"08b44ec25214602de46046b2c94a45f64e9d0903f6148dfedb76a80b8e6314e87bf7dce8"
"e73b14bb274a88fa39136a00537779b",
"00ec4c5bc88a959a1234413026700bf5d4287a0263fe75daa16693bf74cb5071a64eb187"
"78da0a31210347aaa33130602f6b597",
"0b6c29b9177e89880f3eee3aff204b866020b3bf77d7c31204af383d9770804660711a85"
"79a3f1ffe325f225fc7e7894ecc601f"},
{NID_sect409r1, NID_sha512,
"d7fd06b89226cfd66671ce5b4b656228c52d986afa7f6f30161680eb0c9cca177992a8a8"
"c40167a64165c518c55f678702125709361b536bd928567c97737bd750d0e2e6e0c00296"
"a6ca565f7c05cc8c54ae7a4e0c334c6a968fc18a959c18ebbd924457701316a4e999fb11"
"084520dac68dc2d69187134c40891af0355ba89b",
"07f7aa2216164ba689459ee5d5ca29e70ef75a5b2a4416ab588df1dcb9164330c0b405a9"
"d80c3acc41c19f58e24e17ecbc0fa7b",
"0401decae837c7258ea9d90314ac87c57aa6d49828787054cc068edc1955245271acae72"
"dce5c9cba422bee54f22e11810721c1ed50024cdc9e1b27e5d4bd024654df000bc9a0181"
"f7c0f4a90572c75e16b679f4362446993f9920e2244527801e8f6b1e9398bd8382",
"0463202dff25e6b9c633b60a3edcffc1a22031cff44dc1b0a5769214693ba02038fe5dcf"
"b4a48db7ec49b33068061616daf2fa9",
"08c06b72b73dc2655645892447fc0c0f8055838b194e8fad99fc6bd50774e1ed08313eba"
"4141018af33af95a3faa20b69bcc0bb",
"0958f104326df6008135bfbaf5c2980cba2833af1b4f04b5918bb51ab0a0df637d6a4af9"
"02a5e07db3022c134c72315f25972c2"},
{NID_sect409r1, NID_sha512,
"83b7e9d3ec638fef51d2885fff5490c94e2509c126608f82660e5fc523032f3e85d69d9b"
"76af145f6bd916dda35775abbb6d1902bf38880f8b9259822055c5b1bc726c51029972cf"
"7474cf2a812f3251aa71813476bff55598d079f075a40c6c41498bd865ce960c518bef75"
"a873b9d010965f342dc4b35ef5c5972efe6fdd18",
"021d84f070c6823a70f1a74225a472118c93ce9dc509aa6064051ca4574939dcfa96be86"
"2069424bdf1a23f62f2868326422e64",
"0400f568f018b0dc4400bca3e9e4b0e5bd5245f15dc7acbcf4360b0be2ea5abbb87a3cd7"
"6aa653d32858438051cbefbcc4feee6f6b01fdf1e1bd7a2d3825df14f8bf8d5de8250956"
"63c3014f2eeedb9bed3c3416d56f805b623f40b847090d6b4b3bd5abc98ea55e48",
"03344dc1cd950a9c3d039b6fb6af8c5745395d2a3343d86dc6670580e331d59f6c003436"
"7a6df52423a625d70292893961ceddc",
"0fb010ba41d651fcc854762fa1437262eadfcabb95b9502a40b50f20cb34fa19ec570dad"
"2e0521809ecdb2bff3f4e7055c02bec",
"05a9c2dc0c1f946ce33f2f434c156c236b09098365a7f31e238b4685e7cd8c86a0b2455e"
"5c83907167c1324bbb37e66e0b2768d"},
{NID_sect409r1, NID_sha512,
"c62c7bcc860f0e175128e1127dacf935ce62ae794cc4a0ce7966bceb023ac0498641d728"
"1fbc86f9ef470bbc77f608f83f8d0dd6299cf08f2cdacc7a9642e4246df131820220e5c0"
"5d0dbfceda7f16b86add4793e9b6244d96b5c07cfa23574ceb43e8e8b5483192a92b301a"
"a3b37702b8f94f0129d8af1617896b34990c9b02",
"0b6645344d17528968c719091b6e2072388881dc10bdb4c7fbf41906cadf3699b30f9c1d"
"bfb4796d009480664e6276c0359e5db",
"0400b164b075b80fc8b8ec785d5c2ef84d49f2f4d276546c9cf2e17ea4d367828e9aaab9"
"85c5cd0882204e293dba0359d47d9bdc0500a0c61f181d5d06ff20d0c41cf6d6cf7fea86"
"0075cdcbbab2efa0950e2276dafd4258a39c0fe4c45f3c04f76efa7d41392b4d34",
"0c497c621c5cd230fb1e4a4cb3af1cc9d8edf4af5c4af7f15c4ad0a8835b54de52d83bdb"
"3433808a67628912a85c5d00aa222c9",
"00b22e5773aca4d97d2da846c3947bf9cf2474101a6f0d39d31629a6aa2a4c3a77076a67"
"1e37aeb4cee0a94e82e914c8c553e04",
"06ccd79ab93e344e6f112c1e4a39e8505a2aaf5cf85595cadc6ddd1afb0b1583d9334cf1"
"c48f26e5baa38e05b6b52f9f12c141f"},
{NID_sect409r1, NID_sha512,
"b5bf38fd9e822925254418475a1ce762a94e336f12b156b1625a4574fee11ee472d537ef"
"94b4a4b1c0a73b0140d0b818cd06636653e6c07f0f100118242a7703756f1cb1119b3477"
"c4ced99cf45e07e83b7f2749c1a5f8d8c9272d221fe17f7c6a5fb0f8a16af46f232ce406"
"aaf565c6b2766a2f6528c82e74fa1c0a7fcfd49e",
"0f8c2f770cf5f8e1f900e996ecdcd84fcff5cd959777fd005d721a419123221a3237e398"
"34b270d37752470deaa6cea023c5058",
"0401f861984fa06f15b801216a1c33672cff43740f0f736b4f4abed5656a1bee33a2aec4"
"31680942f2b0b0dce9a9196b49263fe183018633f4e057bb6d70a434f919b9ce4b7d9e61"
"fbf46c1d9638100d77881755fe9829a69d696d555b1a26e25ac1a1c27b40f909a2",
"0bdd99022dd964306955c57b226aef036527eca481622618fa7395f53e60aa95a275f1f2"
"d6e7354d8b55d3e83c85819e818199d",
"02f1330f41a86c09205004215c24f42fe582da189906fb23fbcc52136fcb4970a33b8961"
"13eeabcec8151cf3b150eaf1ec2dd88",
"0439507edbd36ebe4fa5df34d220c1441e1a4175c9b0373fc85669facebb5bda7a4b415c"
"269a7add207b461525c6cc94b7f7b22"},
{NID_sect409r1, NID_sha512,
"6d3474770933ec01b76be789304b6fda423b12a0ae8c87a5ea8d7ee9f71300f39440e1c7"
"f5aa4b47c1a8628cfc3a490b15ef292a741344f40a8fcdd02cf3863bf3e32d53031f5037"
"03deab17fc52b3d4032f4e237dcc27231b85d3fd60b49ed7ee40c3344948d87c3f47564d"
"20a11d50e4e520bd16c8701694fc70901a5da625",
"0144adae951fe897d5812ee4a16c0be4c86c5e57e615c398f5768a1223a9be20fa82cecc"
"f8a16a31432bbfd17e594a4cd8a6a07",
"0400bce072255f7cbaf565f82db122e9c582ffcfbefadab6d79680b2506792028b200ca7"
"732a98322c290916c66c8a8ef77df6a2e501b4b6f65e678223bdbe5f8ecb68573ae3d7f1"
"11dac37d4fe3c0eb768c461187fc5859b13452381fe676257aa445bc7f38b4919d",
"0128c12479b7f0630374880b214aa26e4e8626deca57148a6c6a0e37a97e89da8acbadbb"
"fe7db28a0c5bd17303e1342af711f25",
"0a95124ec95e35747fb568e6659ff31867a4cb7c00985b36584201d1bac0775653e0a8b5"
"4cd9a9067ab3de434bc2cdf29ae287b",
"0257e5410a6f0bd94fb3b5b10500fb45b501a3734f0c718035a9a1516d2f88e10d1e38b7"
"0c791028e262e0c3128cb84e6064ea3"},
{NID_sect409r1, NID_sha512,
"92ba7aaf71f625f7a2e024058dc8739da3567c306da4a812ed9e1542b7d1e982c1608216"
"6a59720203f4524c3bd463a662c26a82ec7b4376545206e650eed0d3dd7909dfe3810981"
"393070d15c45dc4a75a8c5bdeba533cad1ec34fd20466a61e4cde3b25af9a80a9a54afdd"
"7de1cf2a74ba32d4ea0082a037775413c61a8d1f",
"0a51f065fb32c55bf4ff6f18ba9d488d35d9f8da593adb0ab1632533284e0adc43ccdbda"
"9d9507b9862ac63b5ae7b0f78b479bb",
"040080e2f7ef17a11ae66172cf1c18eab12aca4c2ae06b8106aa1066677a93538e3dca06"
"26e836249eb884a382c3b726736565c3c301e98d37a17ea736ae58eab093fa7dce3f1079"
"1ee9ef5ec00bfb27bf3c705dd633badc94642c385dcc276f9b1fd5e01dd76ce944",
"0d5cf7b3d28459db8dd69c314f6464f770c31f239a12656368c84c64693f23733661081d"
"20dca9bec9c9659a8124b57a71ffd55",
"072ba8c1b4bfeca62e96a5649e851e9a311d7685603a11c1c299f5ed8605adaf27cae656"
"cd31335a7ae363cbae5dc7a39512c1b",
"01bb9819d25a211548461de4ff973ffbf475230baa161558d9cb7ee6f2e682dad21a465f"
"c2ae058121224f8680296d30e3692cc"},
{NID_sect409r1, NID_sha512,
"b3fb9e48c333201324755a81f3ae5d4f0e2ae7cd24238fcc66d858e3aeb1ee03328660d6"
"399676eb1b7d8285ba571e214d935bb45516fccfab57b8eb4c3d5f1d7357c768eb7b5e7b"
"5710f599614bd4e92706eaba31f8a5e7e57af7ed13066af50b4540ccdc126b677789920c"
"ef8543907f0ba9dc92aae343d3425bd784ef483d",
"095351c0bc07acfabe6477fe85f97eab520dc96bdd58b44b036328ceadaa56a1904d2217"
"c5fd25155ff2aaf9005a3e2687fec81",
"0401c1311230cfdf5824323448c68ead5e5885ba540a21ff90b951f85d84d78e26da035b"
"fd99341b5901e1ebb18648a8dbb996fc9d0017a037929496e560cd1c936d9eb15f79fbff"
"737201dd880a69dfec31209faf5bd2846e3e664c668ad3d6500c5ed620f1bcc970",
"02234bafb54cad0d0d51f4b8508dbc8d014c303d90d21bc3f749ed7acc42f0335c5ab6d6"
"0002d3bb57cf07018e9c13b92c0a39f",
"04d0609f06320d69870a3e66f19cd46a2e0e3e13fb8b7785163a7b567bf2c0f437b4e30c"
"c67da288a3b34ce3110f6d87affe0f5",
"06c46d0248f7c309c1e5b80ac4b1459bf897e42f8f037031f5bbce0fde50af50cfdc4f60"
"d5ad3d1af152298cfe77dcab287874d"},
{NID_sect409r1, NID_sha512,
"9ec5f7d65082264b8a50be772c44277a73ed19199eb275fe5976f9799d8629fcb4a59a8d"
"55074cd2eb2a0e02062d3f7cdeb05e62931a24fd1aaf14c257944d1b42eebd52726d6fe2"
"81211b39038e52baae077ea4df89675d860d6ba5a0f998d049614201b872e134367acc90"
"066ac602e478ac3e43c3ddf4b0ca0aac1a68591a",
"050245c1682344fef23bd549ac8d1e8e44b2840c43eec1cecd33daa4e9ef6b53f496104d"
"7432e14248682cfd6f5b4853b65adac",
"0400d2f8fe524b2108e375c9603598b555d6c4c7724c7d11039178037b3a4dc82b66c3ae"
"ffcccd89cc34dc2b2f6695892323bdd80501f98df95fc1837ec4d5239cf55e97d6b489b0"
"a8d7bf12c1ccf95f689ad23e46dcf20dbb531f5179e754f0c29c8757a1dc67493b",
"0c683f98253406c6587d87c57991fe5caa3f43b451875859feeb81176b732f1c1eed0ee4"
"4d1905d41922878617e03dac53562a7",
"00cdc9bc7d670a1b6794fd7da82d2ad1a0e92b82ae32656ddec3aca4de75f407f20fe782"
"daa0004317fa3f12cefc48518298d5d",
"03ee7c75810c2c05946b53e2f24feaa697af35174402c069b9fb03d89d73964c997eca4a"
"5d6f9482cb23c8ce337a374ffc3e186"},
{NID_sect409r1, NID_sha512,
"61d657bf472676301503f6784b7286fb39fb4186bb88abf1edacb4a2693d0a1e2b77bbf2"
"758c84f2cbfd1753e20841b1cd4b456400d53f4d686e666943f9b6ffcdb77f510be97536"
"e9698fc84ae347d483bc8984548d1cf86b9b40d360f9c0dc5bd1c55868e26fce1460ba94"
"ef5e94eb63c9f0776a0f446c0cfd4106d9f36352",
"08d3b0277f0e9fe54581d3a9499ccd7f015c08339591326859af969d2a26284e3b3beac4"
"a0b74d324ce5cb5f38c7995e4e3a41f",
"0400ae18564ac04b54769e17df84aa54903df58decb870591dad73dbd712693d901f3f9a"
"d43a71f23b77705de2b4ec1c3bc616356f019810f92e80560979ac6e72bee505dcdef15b"
"4146185d2f8f5a955a4555523d982c34bbfc1326024410dbad3349e4c4e01c242d",
"0e52dea77fc59298cb06fb1401d11c662a04500f0470965c4cfaded13b339bde52f4fa04"
"c76a955faac16784f443b1ad9dfa0bc",
"00c917d487d2aae1651d76147de2a706a01c8b3d223afde7d20c9dd77cc2329bd3e0e4fc"
"01255b7c4ed1baae7d26667bc2e9ec6",
"0058c766fd514a405de91a4b9e99fc0b0146d954dc2e2decc2f3f066d0fe192832ad37a9"
"40949ca4e9abae0602248b3b56100ce"},
{NID_sect571r1, NID_sha224,
"8e14f713a2c427b1f79491033994f76acbead614d12e73ac6f3f518f2052a10c1273aabe"
"628ab38e0d3d5f8ff254802e9f44a51367bf80325b6fc39d907a37f731372864747b1074"
"9ea5cb3d3a83da39c21a7b02885a8c1770e4397cedc958e4baa21d5007569dc9dd1e45d2"
"181709d900a394454090badbd0cd9c2cd2369aad",
"0f42afce7f7b3d45f3f925ab29fc3882a89c9f585177887584703cf8bd8fc572e677adfa"
"55b402446fe1e90dc855358d92c3267c35be9674b40c2ad5ce8dbe6a533c44b0ad8d2b2",
"04063dbcfc2d9171a7cc1835c1f56ecadcb59aa6d5852fde264ab25603f06817a20f2787"
"446445be8b2ba05c70fa25d9b9e34d5374febffeb536facd3da52d43d69fa7af4d4792c7"
"9207686e0629de47916af19f9013f65fa3b5f9d196916cab2f765aff31adb5a959515e83"
"fe3e00e91843c532041ba15f047e978bf2fc69627bb5cd7f3ecd74cdf1a8d623c1efd23f"
"c0",
"3fae665eb7a54f51c522ad5721d9e2648f13f3d84e3d64c8148d59c662872b5cb7d911c2"
"7bf45884f2ef717d72bd0569d9901f2308d9a68d128c042effea148cc963a8252f1426e",
"1df705ef13ce900ed61babed02e121dacd55a881ae32bd4f834fa8e362d059223b29ff3d"
"b835fa2b2db8fdb98c21dda5ef744cf24d0a798f501afa3a720a238ebd4fe3976a179b8",
"1b1e98db422fd48f1dfa049f38865f8bf9ec5618fdbfb50f21cc838051a1493e4b1e4f9e"
"a81156481e5fd84124fbab740421173862c63920e3a833aebf0762e7b5b39a1591d27c8"},
{NID_sect571r1, NID_sha224,
"38b60d27ff08fb191811036dbfd5b39e1cc3427ff70efb67c851e9cb407f9fac6f348d28"
"9df98d055eec73299fcac068bd0fd9ffa3c5d244659e4f714a58d79f6727f323a7ee2636"
"9000e90e34e106f99f5ae2ae1b64ee89e5a1d304ef20c071a7773e9b977ed3d49f467d30"
"0a881c8371041394910f9c366942449045568f01",
"2f36613043cbf53ad36e2b38998bb867503359ae082d07d040e5a10a43e06ba9c91e7c73"
"308e41e2391b65e634f83b162cbdf4e7a44ad818fb93a978af00f06be06731d8c5886c6",
"0400fe1afd356670e1dc6bc195f9513f1dc6b03017416b5252c7b56153da538422e557d9"
"918298ba6c78283efa0288c0ac61298846a6f8adf74df21747cbe7c18a2b825a330e843c"
"d8018b7659f0a7e8e7ae5d636ea4d1d5f3a1f846d4bf3dfbd96c6ae874354db6faedf02f"
"75c4d1d8bd6a3b61e70ce58e38ea5de8cc16828f87a0667614f6640a3023b7f4aa93fba5"
"77",
"3fe351ff6ddf50752f7dfd8e5a72c9faad77dbea303fd97dc939eaad3aa7fed466fc8939"
"a7a6bb7abee63455284a5338e59dc067236dd699bdeeae1424d993a9c76fb2fe9595423",
"04a0e13a9fde9f2fef417199f8584d0f60b2f04aa6b7524cd2a2826d63043b2188ca977c"
"9567fc1ff292ed480dabc01589db8734c15aadb4ff54a552a7d9e66829fec1dc919dae6",
"01bc7d2c4ca9300d7a3001755ef25231d2852a7b9a3e91baf21f2a2bd2ff305be8a9de1d"
"1bcd7bd9eac4ce12ecf8a91c0a409726085382fb8d2428adf1b42b37b50c9e8e0535d7e"},
{NID_sect571r1, NID_sha224,
"21709eeaf9e1953822294a478dfacfb205fc25f447a73a76a32601c00784cbf2f9ebd41c"
"22721d70cdb3842dcaff4a4f208d41c0816990e421cc4b8538ac2f347cdd0aa2a39f1aa2"
"6ace8cb6a606b23f6244894d4594a0f6a5b8f6a695fd66e1a41e2eb6a377017177fec56b"
"b58c837e311cd04c5b50575faee32606b9636ec1",
"2e74948c46930cbcd9dbe2325539c7dfdd910f309fd610e6599d425aad9ae230a8d46819"
"70a14f2a71fd08030d0a40ff40dade7de1b06a80441bbf7e2fcf1809cff39c7ef88bf9f",
"0401b75f2d281592c288fe6d5479a4e21ef626471819850cbbdf814593bae7e6ce2a35a9"
"78aea354649d979f161543fd4c12dae0efcdc2d95e82ae5874b9c04a2143535097b8a17c"
"6800c7160c2efa3aea1d18afc1a00b47209dfc750a5317ddebff04bc4d181f238d339a76"
"90c24e55be2cb0c01719d34ec986a07727f2e412aa72434efef4d64ecf7c16e2e75ebd7a"
"d8",
"0d3ae3d8e5e01ad838a7cc9a4d9b3e41eaf9894aed1d1ba597458391d4a2ae38c5d6efdb"
"4d91761a415812d77fd9ceaebbf1ad49c282e693d71d89f0e2d1bbd94698a47f1f30890",
"1e2e9e2633885c85f70208de30ae9b7f72950e2de980607f6d0e73fc1fb2a4a8afc63882"
"06c11b081540bb528a94e5386ce77a2d5c7830fca19223d57c1efe7ac488e69ae07e660",
"1250d1b920324919ef81865513db461409f6f8ad82f658dbfccfae4425906da306ba10ca"
"c84cf5379b6c1d8b252f3c6f86439413c617deadfad38a234bf2b0050fdabf7719bcc9e"},
{NID_sect571r1, NID_sha224,
"3a131fabf3dc97334f212fce41c44300440d16de1d6060450875f7276f53c026e2a51168"
"1b5a8d75fc0d578546339542833145f7ee13c708df33e584445a75a5538829286480d339"
"be7c777c03c998a6d3f037b25799ab2d541021502a0b02a9b9c337a8b176c4f30e5b1864"
"85a6103b1d1563ad4ae73ca806a5e4daa92e9100",
"1b5fab1d36f6f6d559f65d8b01edba610620fc3a38307b1fb1c5bd63e7ffbd4a9098cb8b"
"df50975a873f5d047ee2b627b090897a7fb5f56d3f4a0f3528179e7c969926fc0d3b0e5",
"0405eb8c5a2bfc86aa9a82830d665296f74aeffa9c5b38750d0ff51d01c2dd0fb6f2209f"
"8ba89ff07297ab9b1b06168757f48cb6eee618a7b44f1b3902187c33208288f35a066659"
"2005334c203f4ee44fdfd5f99686b18696b3433f203dd148324dcfaa03a0a250cf606486"
"ef11ebcc1ed1839a76ad70909d835a4b30a014104a6ecbb284b33f50bfec33d8b5ede85a"
"c5",
"243889e7ad32076a3ea436356eb572c1b4ae402d0218d3ee43927eca0b4fc21a19926eea"
"35c37f09de4766f54e6079c34fb3c174afb953be1aac46d675bd300e717dfc2d0c3fae7",
"1d87b52dde9f502f02a502e7a331ca6dfc6204922fb94886efbe3013446d08240f6dba12"
"10a76eaf804562aa92a14d220d59b6310d6caea0274a5e1e8aa3c6b57f239191a71fe3d",
"2a5342df6908841b719f80ff905cee0ec3fd8be46396922c3f2f142393714b97128e0839"
"07a3a2343f0cf9aac73313279ed29eb44017e2a1cdd0fc86e4b7c536e9f7eb1bbd192a7"},
{NID_sect571r1, NID_sha224,
"679d85a762f2574b0b31b516270b7d33d5e166c83e91a0f48e0f3db20b52f42f9e6ee964"
"8cf58267ffe3b713723cf3df52b5fab5c14db1e7189f7cb7170bc6ec7cc71946745e152b"
"39180f828688a5b6c0b2957ab94283b90052a3c6e36843c391aa8810f9253b639a8d5a69"
"aec10070603ad7a99dcedb544858d057a1d66b89",
"383e70c71b431eedd4574f65d01fb0304f7744d668408c847f7899eae44770a7f3243109"
"740f177d7146a27748886b7b77ecf3792b512e8d8e37c3bf4ecef2b1253df7066498f01",
"040769dd91fad550980225877d98f7c86963c88be141f91f7a3f1607e0cc6dab767aaa6c"
"eabaf46b65a7c80b6a494b0dac1da5d2fc8c5b07ef7085ed1bbdf4273da3665a6517ea1e"
"5a0282fb94b4726472248f01ee43607f7ef969446313e849998fbf0058c8ad5e24457006"
"b84fc0460b74d86ca281caa174e69fbb68673e1d28ccba17eae045eabc1839870831246a"
"14",
"336909099a1540e6f69172d55e0c88a1afa99808005bf09cc803ae1e4e4fbeac2f77f984"
"bddb482f1f13e4430e25e36962b1a4cae00f1fcd7f2c7a17372c91673d8286f9829bbdc",
"290055d578012a5b7d88fe2f70581a0fff976756b4581875cf5db07e01f09c0bdf6ab70f"
"fb5839567583d53c68e31a27c3fde12bd4f1e1315af2f742746277b1fb1349141ed3043",
"1480c63c8b90c7b51e092597fd8391a237b07f0ff7dbf615e6bdddd5aa880db29c9b9add"
"5bde7e0e81d9a37f852c26f21d750cd2f95520d16da7404c2c3feee1489aff09f298d7f"},
{NID_sect571r1, NID_sha224,
"236152ad31ce2ffc0dead3c142cf6c770672cd2e75af4a82fda1a72e1c775cec9b481c6f"
"3e411644df7e7ee901c501405620af4b6e9667dfd46091788daa95ef2c6c9f5c240c06b1"
"5cb0df51f5f058d8a7934bd7845f007a35f99fa97200b20f3b5b14fbf1e372507f3b2f37"
"7e8d07d30fd3e222f398f26d8f428e320327f901",
"02261d4ead21f02fab19bbb0da8c272286704c8f0c6842ba47ded121e5cddef79fb34e6b"
"9694f725ca502949faecfb21e3cc062a2b4c654bd542d9a1fe8d97bdd0905c510aa0999",
"0403ef03980ea9b754b655948da63469fe526ff0ba2c0f572981d02f5693bff620b55b8e"
"9e9f9d553a78a0138072369775c7976f028631e65887cbed62fb447c9f41da86022f4b41"
"ef04446eed90f2716a7aedefa1385db9f5f803434517fcd80571adc9b7f086c9787b7630"
"6380a375668b05fbed30922746fecc0cc16f189dddab676516ed1fe4d02855a34a909753"
"89",
"0b309f6c53dee8a8956358df45e72126ec76266d38babff185d4db1d449c8fa9baa4b065"
"1af5f5b0aa70dee3dd55623060097e2f94ed12636961a7c0744b38f2f137bca239f974b",
"2b42395206ae79bd9df1c729856101ec3c4a719616701f836c9d69b542b59ce973d91951"
"853f89a0717abd4b929bc69e59cc379c941349dfb4f98d49f9dff572c614242fd370e56",
"1ecad482a8eadec6800a9d876a382125eafaa7bbd950fe5f0588126764126eb1b3844240"
"15c52ed6a335668506f25124aa78d98ec5739fe282af0c143c07da0fca53b9733e159b8"},
{NID_sect571r1, NID_sha224,
"ba3f02c4847fae035d747db246fe4e82fb9224ff9cf568a6ae548f5dc2befb2079541d2c"
"f9aaa6b18c281a05e7ddfcdbcefb25f41dd91cb3092b3343e16985e91c912215cd99ae4a"
"099baf628e33a7b277e3c36a13aaef85418fca99f64d73b789f23ecbb76c3095ade0a5f7"
"f34836a98c5be933b44a94a2eaa3f99b1d8e7937",
"316c78f289e1860bb623082be9d9238b88e38c5e978a868bb90f776235bdff4eff591877"
"b7f350cf14c40356922b2b6aa51d64990360b2b0e44d6941b5dd9492b4f4e1f42ca163a",
"0406f4137a2c63b6b79138027464135021b034f97bcb2493943df6be844f1657a97632ac"
"80541a3b43ccc828789517efdd9f86ba171c1262a07a6b337bdb0c8d5f018302a8046a1a"
"8c0425cf553554d18f6cc97f0caca2a7eebbf266d57030014273f701562d5b1444240b9d"
"22060ac9bebb37deec393cebdad21ec7f13fe5c7f1752b4261cc2feddeb737284a6eec36"
"63",
"1e0321344bf364f1ede39a49c8051f36875ad78e4b080ece9088111739041b121f3f334c"
"6e923777fd716a52be669d6e45f381da11262fb4d09ad66dea74ca115838e19fe94b7f9",
"04f24ec978c52ffc7675a09334a895e044eb8eaf04d26c094d7607b77ac4168a02a972f5"
"77880a0d0c73f218815e3a7a70c91c50734c08d374a15fb42fd13367dbbe08fe9c2d4b5",
"060740270df0e1fdfb8e829c9601b9901223b19d07e9d7d422b9bade88a50fd6d4ec9684"
"2afc45900a0107ce85ea6d083d66ae202dba3a32e50c7c3af951cac7acdc6f4c406740b"},
{NID_sect571r1, NID_sha224,
"6d0372b40559e075af56af853cbe18ba2d471b0fc8917764abcc69102b03d5bbe1fc1245"
"8215be66409c26c89f67c72a8933677a07f88993af6918acb074fa915fe883b24bc3d191"
"ff1b08852f07eda98977e70eba072d8bf189cd545230f59559ac05f1fa3f4e65886d0bc2"
"74a6e02e2399812b2bf91abae81e21279c5de996",
"2c1bc13f8320d97a82f3d9354e195481902214e16a4fd89332a0499208e91d50e5cabeb4"
"927ba030cb42f5bc53b10f500fa646a8c88508cb0d63ebfce5c4bd574c527d686c735ce",
"0402210791ca48aafed20de84ef9896a9c7584081f850b75884908c7b3dccc94e221401a"
"6ffd982f292a9d5f9c1d066ed493da948ac7e93977dabd7b820bfc0fd21cd8d99c072bb6"
"9c033574c6ce7da749ceb480b4e00bb1a58203bbbca5c16923992cc9767aba5483e4d46e"
"d39e71000a1fe920a4c1c211a14e63ace03635a2d77e72808e0664334890b819b3caff64"
"a3",
"2e3db2d82c4b9de2bc0dd0a93c1c5b385f75ad03d0da527a034da2876b42e43cd88dc648"
"33efef54af902d85c568bb8e71684bb16b28c32d80bb3e9911cb1b74be6ec520d99b381",
"065f4715e87ca3541ea695878ed5ccb7d2ea6eed5d6fc5ec29f9aa8deb4001cc7c06185d"
"6ab2dde4347344d44f8300a1e92513af4690d713762336d2e6a94d3324a224f06eeadeb",
"20104e0767530ce2f4351af4977b52339f34d13e458de0482bcd58ab38ee041c9adc7b05"
"650260d919b2648e2f820407fd60a8d6b4b991b86eaf29c2c4d12d3b0b45cac2ab22c5a"},
{NID_sect571r1, NID_sha224,
"bbfe66c82bc060bd14fd0e40769d9b3a026eb447550dd9f118c30d8448f725f8366edef0"
"42447962ba7f7f833b9e9094d0ff600714697e632626e7d12a592e040bdcee166dcda939"
"52323191021bd12f3b1647d0f25a41739994659dcbb19333ca30f46f539c6f0a5c354cda"
"8969a1eda572a309950c84c7607eb8ac20163912",
"13bd80eafa67663e75d7ae139bf285d2b9f1e03d8e32153c73e26d06e86d7acad22bde9f"
"121a3f1ea674dcc1fe67bc7f5398d5e92555056bc046a02b0ba86c2a0dfe32e91add5b6",
"0404c01fef7f2fd8ee61726af1a2d046c7ac67716403b99e021082e96d733368c6c64d04"
"6986fb01a6b55cc930517762387eb2fa4a8eda23c700d88065bced8595188760170881a3"
"290189bfdc8e7a710522ab5416182c9579ca255c5009e6ee6604ab033c1388639c0f7aad"
"84642290954db9f4f7fbffd17481eabed38151160457d68ebdfd8695b5035e4e6e06532c"
"0d",
"3c5868345c5314aad5ed3a74488a85b2f049396022cdd1de855a0b33c2877f72e871805a"
"f3ed8fd7e7a392c4ff63acac6a6f0c431ce7af680984e8c81d0350abe491a01f0f9268f",
"0c7e96b9e9a5935ccd51b901aadab6e01ebde44f57e6f0b84e7b58ab4f62ffc0f3f3f980"
"665c581ee3de233ee49d11599529348f1ad3d362837c041cf98192bb324f577e973e1c7",
"2226922271fe8307bf597742618ea9c1c271c22c25b49aaa7c9292a81ecce2a55250415e"
"a2ec8ffec54bf0508e64426cb9cd7177265fecc40e056e96cab661485e789f0c435b72b"},
{NID_sect571r1, NID_sha224,
"b35e9bf686717ce3b16a59963a32a2116130453b161a4e7ceb27b755856add836d779696"
"edcaee3b5c986523891c8836109d431e55c23afbca022437ad19e6777efabb6da3bba1f5"
"f44f905395b4cc7c9210590fd38da621582d059598e5e4569e904358e0dfc0dbfda4ce75"
"538aa97480912852bccd433a9b96c9c66e9597d2",
"30834b0a4284097cdda2ada6947c6c281f7290a49b56becefea1e2788ea3ef78fb968076"
"33c47c25138341768b241164ce0d42f7301728b928be2c047f2eb60fc2f844ab77306d2",
"04003a21f0d8e01a64b235cc455c291e3fec8de12682f05544de207d910c7c24c4cd56f3"
"354500d994380ebaa0b49a7604c6233a9aa24934c550c0e609f65fd4073cd6c1ee4170d7"
"7e067c83513e4acbdeb8343b3add40261edbf7c8fe0af7417264830edabfc40200283b92"
"484630741378b997c3f8bed7285decc6ef8633aa804b3846d3b4517e5ad836dbb1df4758"
"18",
"0031afb24fbc52b01480754837cd84a5165d5f2ad1a1d572b92ab546c049413806f0f523"
"9a77c751af4d57a84786ed1c11bc76123a82e7db3c0495b2fdc5fb9c8720eb7afb640c1",
"07a222cddfaea617f1190a0bd88af4d1983d2543dfba25c5036fe24529bbe2e382de89dc"
"1e36c1f6df59c8291d1c4277198084902e5619b64128c265bcf03b7d8cd6b663c225f11",
"1ca84c146ebbd16300b813621d503d8c754e4b11446d5ee31cbebc71f4b85ed09c5c94bb"
"dfc3570e8882ef790393234c5ee9e52f7d5b74ff4171d930af817eafc40ef203a1ce613"},
{NID_sect571r1, NID_sha224,
"57b5ae7e95c638b258d1e09b3fcb4341e203f5706862e199b103c8fdac72cbc5155e5cf8"
"b300a0b3fb0ce1f897c45f7aefcc528182f73dd450cd84d5fe9eadff3f704dc2a01b4e84"
"7c22df430efd1c66b0199f3e5b59348af5386962a5ef25204fd230b54d58d7fae801c086"
"f8f405d3d0aa7a9a9da15c22b868817cd897d853",
"0c81a79ced1eaaafc31b69a40d9939f4e484d625db6364a8e589b6b4d336d458b44287ea"
"6c6aa7661113fc07806b147ff98216fa0c08708dc9d651821b922741deda522b4e436ad",
"04025f9b767b8796466c1cc8a1fe6286d591c04a0d115133fc7910640032b898a5c86547"
"f57794e5aac0148996151d3ecbe0d5939dbff5722679ecff378e3f21bbf1354b1eb294d1"
"a30074c2b91ef3472e60426d2fe182ccc678aa0abb8dda15a428e4f6f1ac401b015b2b7d"
"83535a0a92770cff7666659e1cd33941bea1168cffde82db0ea83668c2d387e6f4bdf28c"
"c5",
"27b407a29553203b829a87eb25d6d140e41184634ae1c64c6ec38e9012d0b06a1f4ad987"
"7d7ac4236a22145095990233e6c102a0052ba18cf6e47e289cce4f2ca21514d8868bd68",
"02416e11fe2f8e4738ecff1710dc827f4e03c8e7f04a4f52e755f0c1676abbd122eb9751"
"ec1fdf6c7ba04b4e29f8dee52bff7e9e726e28cb3de6f9abf2dbf58c0519ccc7d70f076",
"0b96f107a26097a468c1d410bf90e223cd72c5ec98d4ee4ec2e32259d7670d7e7689e62d"
"36549086139f6111884530e20f908d7be1edab75180c81a70ece341f7eda6e4a43a5ad3"},
{NID_sect571r1, NID_sha224,
"daebfef74b452f039c999ba0528be3bd9e16deb5f46f6eae87b63db8b89952c949fd7db0"
"8311871eb2596865eed107aa065f030226ea675ee3256c31a3f85ddf4c21760582144e07"
"af208f33c5f47cc026db5403186a65a47940691ea2d74ffb1245676260ef5717dd879d8b"
"5b72d96f87fef5f762d4fd17454cb5ed83d8a11f",
"2f24670c0f77d2ca0266a743023d2c7413d56d0b5ec77b454ac59087efc4ea4d46179e10"
"278e4ba416ffd8c3f9786ed202faf8251c0ef5a9ea5371fbb35b7afe3d15a9cb4bad975",
"0402da72b8ae64c5ee717c33758ec26153a342936f9d41dcbb136590e1303b0e220ee84c"
"8a06b83d4d9fc924b8808de94dbd780cc8243bc4448efd27dfaa1572aae6abe574be6649"
"3903b3a95d962c48a81c48713247801e4ee630ec7956c9989023ba16f02f5bd1ef2edcdd"
"1c8d314be933225c64b7f8a80542b209b944e1f3fab95795ffa134e7e28e82307dc62c29"
"62",
"2bbb9abd2732994011c8d294c5342e8b1f7f3c1f5718187e9f75832604b43bf75abad5dd"
"c85e8d92cdc42656cc9f3349afad3f9022ccbb4937d9ffa9cf48314b604e82bda13475e",
"3986059f2e096a3675215698e23b53f471c578891f6d721a34a0d231d16348d5bf9853c7"
"9c4f4aa94642ad06cb7bfd11f724800cb5477636b6fc0586fb6efb8eb9bbef62329a884",
"2beda064eb3ffa1c3b5336613704b3bc3d4ff7b0e977df16477c7e33d480d678804bbdc0"
"8088186fbc4764be398a26c13f88bdd23e844be0d7ce598bb87c1b3430da02ae96b3767"},
{NID_sect571r1, NID_sha224,
"62af0493ae79d71b552c4647d1fb7ab2f282a91cd44aebd8ef344dfd77b521b0c0a3f72e"
"4513c8ecc0e4b84efef3df9482a07ccc1b740c571c5e69cb913740a792aa231b9dc87edf"
"b72bac188293c6c6e788cb3dff32e8f483f8f34e21ee7efec71302cc3bdbfa47908a135f"
"6ef3ff179dcef26d1a3987f7be967a6c0f799b0c",
"20985f2c6fe3ea04bdbab66a8b6167e5969c073b9d53cf3c77cebbf73f4dbf75e601620e"
"c9c3107bf3fbfc6c79f8f063409bf8fe1d14b19e323d857e23dc05157d270c7514137e4",
"040010712d50ba7752962b140cfb943d9e8dc3bfa497bfe81c42606f4da5157656fe2ba5"
"cfd33ddffa0f27fabef8e267688943514df45e642ee0454e05b49f7c00f5785777897d22"
"5b01a2c7db6595c6d4c55110210c564cf102739760e7f5a29706fcb2515d99ca00949d5b"
"4f291716d0aa1e3a47efb9632410f60e2fee1ada47171f902f632bee85da75c7f3c895c2"
"4e",
"2f26eaba6452e687af452d5e1208fa011e4c84ada92a38f0a204a254641c23ffe1c184fa"
"8bfaff047db590ab40accda408717e4f30811b75cf3a5877ef99279476ab924d92565bf",
"1280adcac1c79352635f4165f9c5c1b6e1e6e33bd74d781773f483f637462f80340f8d22"
"cb24c9db5e49ace95a676df3dde53c8721f672006382ff806410bfcdbceda50e53285e6",
"07dd52973ef30dbd480047732622fb1b695fe3cfd080264d2aa30a6ff3dab4ab362518c4"
"f3de4fae042fce78c0c8fa0e763eb187eae2ff8f2e79b3f38cc3c1aea897e1f28b71a19"},
{NID_sect571r1, NID_sha224,
"566f17851951777ebea3f8285610cd8ee5f882a68e7a4205e6fc9e2d66d210ee2505ee73"
"d6503169f7b903012d43e7e99efa493a8e6ef926b16b9ad8f52156840ab561fc6b680120"
"a88714fd66d1d0742189bf06c155e1138ee5314707173f7352e2cea0fc26e1553643f249"
"0428718e44afd8372cbb7bf5b88234318ebf4355",
"2b3d641607b8a141f876f6d285ee46aea543880e772dadd5dd83d595b9643191d9597218"
"e1d6adb081df133304037bcd2c05c24a54e6c4cca64fb2cc4569d6882315360059496d8",
"04042f2bffe25142ac6c1af26643b0f1c317b34950a8a0f112a0cd4ea4131303674328e0"
"bed5d9bc7ffcbb9712387cf67129365b4fa8a9e785b787c170463b24f6a7962c1e003c87"
"320070962ac4d3220f367f18caa7ceaadcb82fdba45cd2c034a97aab71f7f7546c09736c"
"b080c10d9a95a5f984aa4a3ed32d22636a7b3d5ab29c86d85db59f6f17ba29eb220bb141"
"b5",
"23d7021f5376e7b11be07288a0e47b4326c026df80d7e08c9a0fff11deccdadd479dad50"
"3ef2d4fa3f0ab2aada604b57fa7e09dbf5c8d493070b5faebb27cf68ad0b78bb6f3a9aa",
"3059720e7a2dfff03789e7a514f75f2af5ed18cf1568fa2a5354dcddc9d3c7a90605e9b9"
"a3d0d6fbfebddd615cdd52845ff922873079e06c4f349f7798410ee18e0c69045193668",
"1cc40209692cf5f8ed8b82372c95033e4199d378a28b9edcba516820ba21af1bcf5c5df2"
"ef4146b91fd37dff89ec8f9962eecce5c5e285d76a5f03eaf99fa132e98cc40ad66c296"},
{NID_sect571r1, NID_sha224,
"25155825fc4f9a1c4dd1db837008e7e2594a879052431f5bfc76d0d2565b8fa726008bef"
"aeddceef73f3c60fa2cdf6d9a70e56d27210bd013034b38861ae49640ef208d3fe294ac4"
"362f8eea44f58af3af8a9167a36b5acafb7ec95652d5885a0e08067ce1dfbb45a0c89ad1"
"acb53eb404bf88fa5c3c463a0f912b5a2522a0d9",
"1afeb5ca87c81025ddf09c2b2c5ee22ba0105c0e619b67a324467485bd839030d149fee4"
"4d8bac6f5902a1245a50c3437046b7c89a84116b2147cddc645b6d2fd24d68e8d53bf5b",
"040119c46988a79e3ae8833ef096b0a1e2886c4b114ccfe881886859abc031df2b1e7581"
"8c82be8c5abafcbc5d7b3b8344e98e3f413d737938845e6eab5aec7e507f7baf0d339a36"
"2f03190912dfb5a1a31fbbbb50784b18051489a3cc0f44c42c71d3a54886ecf40507c324"
"0395e8ced37b5253b915fdedd38f75bb26df2a0a8edba865f898a15f2d96f632f7f06388"
"64",
"1facccc127c856db1994c4d9e9c76de6bffff81a88d7aa0ca1645e250e07674fba734479"
"11c5b47a1aae815d5e96164854636d3168d0344b2d2d913127011b6434d5a5e545d3bcd",
"21da49326f39577ee9f65cee64006525de88a834365a00f4f8cfb9a01dcfd6349a3d06bf"
"95990a2c17b7e95cc0589714b7a795c7016b29bc844ae9031488ca354548976eed68415",
"3364def38a8ee3116cbd971794c859776107154234d8b198efb19655647bb9228c7c6be2"
"e703672f795ed37481e994b6764d0b7c1bbeb2bd1db90b34f460278a54bd480bf4e9adf"},
{NID_sect571r1, NID_sha256,
"29acb0fca27e2a10d7b9e7e84a79af73e420abdb0f80dd2665696638951b52dd39ca0281"
"66b47a3b6a2eaeceb1a11c152383f0bec64e862db1c249672b3770909f775b794e0b9b28"
"a5ec8635a996d912d837a5f22471b40ec2e84701a8804127a9f1a0b3c96ff654700bad31"
"67240c2518fb5dedcc1be9f56a807083e587bc56",
"32c97639b69c7cdbf419286d0a1b406d9b1f2886521a8b979a36118d2a368aace5b02dd8"
"c515f2041e6fb9f026d1e82e789dc826a56d2ef732b1bb0f49be2b696ab5d3d5694a2de",
"0400087ff1d8a4644edebd43c2d43d49e140940d215f272676fdfb72ccf58a12021de3d6"
"68f2766848044ac404fb45cf6e18fc6700f87aa53b4fac1e35e1731814f8a9d0233e2942"
"d7029fad3638177541d8392111064837bfa77b4455c21c5f7652e3fb302f4bff4a35b74d"
"e8aff3806538ef9ac86964cff755a81cb3002b6fb241ffcae8ac9621b8e034967d650836"
"ee",
"16a06e3d25873f6dae16bb2e569720ee9c6ae7b5ba36854c321a80be8b4be502b895e1a3"
"d161b001f6cbcf53d164b5485d8a5efa0476f581f9c79b3a291025be01a435e2fc5ded3",
"347138a43f3ed1a1a26f5f11549eb8a41f64aad302b6383879886216ebb6d08a4ce270d0"
"7a5bec6018eb313430ff017c1bbf78556436d9255e97aba1481f0f16b85e7320df79d69",
"28f35e1aeae288122b043deff9ac87d39478607da60cc33d999b6add6209f452f631c6ce"
"896afd92ab871387f5ea0eae5f6d5cf532e7a6ab44dcf44acb1fd1daafaf1ad5423d8e8"},
{NID_sect571r1, NID_sha256,
"c92d67cf6536f5046e15b02158da698bcbba4ff1e4e9e9c882cda67f817210402ef917ae"
"93682c9c3dd817b21b73c6c00b7bf92ea80ecbbef2e67f4f4379d078a2b0f297742b2bb9"
"c3fa3297a7e8079f488555bd37715eec92b4b1cbf897640ae8a1d2a0fbcee5423ab31a37"
"629f98630275e35094a896cc574be0a449bb1bc3",
"0f93672159276c5a293582b9f49607bbdb970112f6c63b2b3b5d32ad3c8240c86b1af13a"
"8dff6502c6b6a17712cfd988f8cd23a60693d64104143b3f91adb37f852e9e11a0ef110",
"04019dda59a839aa2ed28f69a62a3e3a753c6fc789fe0d8551bf59095f009d0327386e6d"
"f5437846c6803df2442e0359a367d04f117e3965397576d4287398b4b8c92ad278df4a44"
"7f04159ced60503f7cfcfcd587bb3608699f54693068101a838d575715de02fff81058d0"
"25dbdda430e176f60e423e6fcbba889914f6409ce51d51e89e4cd7bbde6d24404e5b043e"
"79",
"10dd216d4b3da2fa6a75de60f722f1f128776741cba002c055d1445581242a175318291f"
"ae313eea11fd905b20d26cec845f57a3d5bf23ae4dc93d886c0594f1cf7be4f59f3e3eb",
"128d5c00a48c7352eb980d9c80781f8abcfdc1ddae415b7ac94b4d85c3d7d4f7316e2b33"
"44ca50c6ae82938bc728e640e59e2d733f0c7f7025e66c15c81e98a845c1ed4843b589d",
"1ab59ce5e54bffc68fda96c920b839fe03d1976ab36978bedd973715ed631bfc8e3edd10"
"0043ac527aeb5ca121da848bce4ec9799f55b22454e9af32848943058b257e815b04056"},
{NID_sect571r1, NID_sha256,
"15413f614c4551e3b138b64f66d15f8964c40326a42b0afce820778eee4a88edb127fbf5"
"75da5263e5a2627b5461d311813ea868e6417615e7c4938313675009caac28bc7a2f4c0b"
"c37572d9bf36a3b1794294e09c0121ceecaa4b916df45b0dd31225415e6c87cfeeb092a0"
"08fce2c543cd62365779ae28f29fa02a15d9dcd5",
"3db080bc99c5fe7e06d5032167af56783cb423fae59fb5b3c6bce5fbedf56b7b39b17810"
"e48ea9a172881aa1f42f5e267349b60294d4a208b4437666b44abcfee5a1829e9467908",
"04059d1b3f680da784b49dde3b361eee819d67339447d7bdf7965550264eb63bcc7674b0"
"921f02e15d45466dee52b4c0a50c2bbbdf226af1662086476a9eb1236e3d4c2b6219af1b"
"db04e3466200dd6ecbc268cdc1937ac5123cbe33f32110cfdb8b7536987ddf5c9ef2464d"
"2334f315b9b489cf227a6300b6e054fe40d36c057a692f2fd3e762624069e2adefb65d24"
"d7",
"37fb32a902eae0c5d7cc9f9018a5d1a906a3d1b9adf5bfb696ff63f105cb2e736d9bc196"
"1677fc897fd3a9e9bedd370be6f25a03fad425b5a293c66180df78db33aec4a188d3db6",
"3aa8ab9fc9073429e52469088aea91f00cfba271b9dbb84818460883effa0c51d6a48c19"
"05d6f58d1312af073dc8735c29957f30324b467797acf86e028410de016338b972013ab",
"198a746411333172daef76359e7ad23035a0f5d14c283cb268828bd876b96b5f767e0c1e"
"2796def7a51429f39ab2332ac25d8e4f263f8dfb9c4c98da2ccc398fb3bb9a6b28ca28b"},
{NID_sect571r1, NID_sha256,
"9f901557451ae2f8ec79b6d4adc794cbfd9b2e6d28f19409532d91682820205308b41498"
"a4e1ca247a2baa8da93de95e3c0f7afd6ca46bafdbdcc6d3374a12684676a50988b86a96"
"0a82180648c8c1e38f8fd9af604c7be3be4b24799f4544ac96d6360cdb83d1d0847fda21"
"642934fd6cf65385b50d86d4656987901fb88d0c",
"06ee767f6f36bb8f364f324d8346455c899a49237d759003dd52cfa13b9baa4c71347b13"
"4b24ecaee32d247c34e3787a0c64bc5d299b55c86f64b47521d22f2c09db225b0c84cc6",
"0403f971125860f4598fa310eb7a8c6b4e0c31bb721fdc17ce6df9af557beded6006b8ea"
"b10ebe7f3c4f3d759d4a87dcfc1fb767ef87beb1f5c845e3f41503a33b28b2b5aa1644dd"
"1a03296062514d4e89d2105dda5bd65a315b9770c45afe4050d8c3d15001405b1e32be58"
"67ee90cafbe4e239dd44d030b4fda855182f1fcf80963c1300cb842459aaa8c282737187"
"6c",
"2b247e2dd0024f534ed2797110df6ea4ba166c34d91c94e43b045c0ff80f124bfec1cf3b"
"e3da7c58389d352c8c5c1bc2a2e876a7e56301b1e688a085ea0222697fc63141564365c",
"2858eadd14373aeca65ee5a2cbbaceae4b54a50e0941a696406dd86d05c07c5599379c06"
"6b2288d01b2a43c9ae34bcb8c36f59d490aa8d066fd3d7e539ebc620a7176507ccfb232",
"33c20d26dca20af2c56982fcfa6f085bc5c317d01f3b1dfe0ade1ef6e3e960b18b626d17"
"d6696c936f04090ecd9606c2a6ecea1cd1883bbbca8b3dce3b0acb2688fb2834aaf922a"},
{NID_sect571r1, NID_sha256,
"959fe5a19d7aea2ba611c7203e19f8e3f3cc101e03a98f91adfef602c424c580d5a86865"
"9368a930f9883d699fc633bd07f6cf8de474937db0bea86fa7cd140ec2f202663813033a"
"757b93bd72afba15be5e47a4eb93e8a666aa1c72c241ca3922547d63fa3732fec54afea7"
"ade84302e2f044275bb67433fb6b125b7913143c",
"38e2571d9f22309a636586d62863ed67a70538287f3ef88b88c3c2fa1a2900d48c342b6f"
"15c26b8e7fb4875cda4093b7de7ceda48fe1e2cc2975afe958040881de61f309931e48d",
"0405a221634ca85059543e2caf8bdf79c43bb78deb35e9c89e07d553bafb6b31750a1d85"
"ffa7689e528c11d8a3dae442b4fb2a4a21238d636eb04ccc04c8b5d794b0a213fe0480b1"
"d20225ff457b6cbc12d152b08025cdb7e1e921ee553add9cbf83228d678d5a9f5d3d1fb4"
"327a74c1dcb5d69a5b98f3ed1aebef0af09bd49d253a903636ef5a66844c500fa221470f"
"2f",
"3b4de49d57040141f3584ff596eda457e2835085d350b75391d90abe728723e1d1ac6413"
"979d4fc3eba98d72a01248e6510c722df15df876da881ad50539e4248facafcf311b464",
"00f259038b4d3d036bde101aab29f4558e88e604c62f967bc7a35eeacc6a56294268f8ab"
"00a34f9a0319b07754f502c98718e8b5c91093cdbff2c8496fd63d6fc2c50a35f87f423",
"2350d5406922e8822a91f7c95cfe8524f017a14cf7174ce534c60aeb351510d06ac20dc1"
"249129247b21c72c14b02b710c26c10899bcf995143aee632e294176e903645b660e998"},
{NID_sect571r1, NID_sha256,
"97b9688d9ed5101b8cfb19e84b89cd644262ca1c7ee18944e29ddd3b4cca78e06338b270"
"385b00a5e8b91ca5e628de3bba50e36ecc695b3ea737a9cf8b36871c473a54ba17819f49"
"e730c0f253b0c769aefa6c16366fd2dd612f330e95fb119fcf3bf7f3e254438c0ab635ec"
"04a8b2424a05b483ecf65b74a93636fbab7bf1d8",
"0c8f5736f1ae65592f3ca850f43d06441aaad8c03820f3b08d8a6db46488dcfb828459f8"
"b3f34af73cce8dc7a5e3834e085a64523d890028e194214cef4003210e6eb530005b01a",
"040667ce3db45b8772f717ce20755ffaba968aa1314d75c84073042436823fb54bf8dda3"
"4a6bb45a61d610745b1fc10eb0eef71c4f55b26acceb442d822d6e2a27761c73b740f472"
"89056035da1adaae894e361f5283b3ea07b7d9f64a298be11de9fb487c2479b120381f1c"
"60cefe5d32d37e4644ac86a170f82b1c4443eb71b940b21c7a016b559c6c79835532c276"
"fd",
"190468668989a607a3aa966cad071ca8e8eb152b0dfca9205bc9417a3d612ca1105c7b90"
"340b04acd96a5223658adda16bf6b598ea9f32a2f8d1b61c2c2bdc08d6a49de246240b3",
"291e1fb18edb7a93badd6fab6f56ee0d390f3b6d298e97312d5277358511fc7621534ac0"
"35f3518cb140fa4ad5ef7d889c0d5f3f52a4e4d06bc9f647f99695531f85a4b76cb1184",
"2d916734e02b0a98406bb5a9723486a7ed40bdd0b39c4cb802af4bafd519803d23c6bed5"
"9a80c256a14eb878229942f67e0b8159d5cbf24b719043171b3958fd669adfc72eb7289"},
{NID_sect571r1, NID_sha256,
"f08b250bf4a3980cb455338b3f4173723b3f44c97bacc9cf550149794a71426e398cb4a7"
"4bde141d8b7b4a72942f1c069676a9918e27792cb8f085ee037c78e3c468adea5123c4c6"
"4d8ca6a39f2f90140c5d2d80b669cbf0d1ccb466b18ded83a1d5f042c36188a04111c34f"
"f769abba9aedda40a87be1e24b700225e2078056",
"1ee68c3994adaaa9e0d61bfcd3bc1cdf198d3fbfe28a44e5dd518867ea04b20e795eadac"
"c48bfcf8e8216dceeaa069b756e8e99ed87b6b1d31154cc9310bc3b4555162a890b0c6c",
"0403efc83ad15d9bf889c9afbd769bdd1dc8925b0462c93868d85ca7554b540d8c3ef7b9"
"a63becc85981972eee8a70b7f948098ac050ad594ef2ec249cc3b557844bae9cb2cacbf3"
"97042a012b3a1d9e46cece4fc3460a2bedc9af4ce0289e95f69550eb3544f7c105b5769f"
"a52234ac88f9045ea5cdd4937664846d26deecf511ba6996ce4072e763e8ebdfe7096608"
"88",
"031df03a6cec2346b92d9ae7d3d983edf577d9a1bb88098f886f38536d8d8cf25def5772"
"6790604e674d036cbcb864bdedf8475ba9c850d510ef93b844c037e04348d5f48098c20",
"112dcafb63bb125d9610e59883df481bfde43589e46656b5952cdd72238cfbcfee79e916"
"5e3c9b89c9ffed12d303225ba2af19e00048e20e4edd3968807e4885003d148403321ef",
"2ded1456df54a24214d8c1d3fb314db52b046ca31458bed69bb3aeb6a9ece509ee521fb8"
"046ed43accc7e605440a09fd96db659c98a7dd606758c0c47e47acfa326b9ed73ba4b28"},
{NID_sect571r1, NID_sha256,
"1cabd16fc29d7d919622810dc8b23c770b790b98b119eeab1b20900fa94fc2ebaf76be4f"
"5eea91fc5276c5621c8677d4d117c4a5a782ee2ca1d5b0db997fdc8a05b6b3fbb833d7a7"
"b81c3c615c2a662929760a96feefcf89e46b563314c9b77c86bf34438458b43b694ceba7"
"41b97dfcdacc0ed57652ae62856ce10ed2690770",
"3a6fbf66ebc1365ea7699c72cdac2dd85907ec59cd26e2d18713354b619ccb83b7fc0db9"
"193aa8493c1855f1a83fd987cbbb65de17c59fbe79256aa5392f4eba045346e9ba26592",
"040559dd556241f9b11d0f91c5458ef6adb783f9f5051bc12cac9f0b214f836f7b149d00"
"ba8218e873410a50445da9fbf68673f3282d783988981fb221d0579341892ba6824e0cf4"
"a5005dd0e594ce41122882538e51e9bf29d159fcbb8b29b97c5546582390ad5c59c97527"
"1c58ba1e75d70c3898fea929ef7316ee830eeefbdc69bd80d7b0e8133b977cd573a3b422"
"ee",
"1c5a193179ab859ec1166575007c3cacb30d31f341a0e82ed6d4ddb32da909dce08acfa1"
"0fb14183258caa743010fac6f7d0fb1f8c8f55c246e49a97f2bf571129144c23de8d68c",
"2625d0bdf37396585d22811a12ae7e0c3f512ffdd0bf4d048379434af46c03c6067dbe7c"
"271c417ac5307123bf58a9f2064bd2b3a2d4b4efa3027959bfe63e13a851f46a21da6e6",
"13f16b211b314a7e9918f3254da2f1aceb5340713985610f03ec1d0a33ecf9217d61076e"
"b153d8f27aa31aed3c9b165be52f8d857de362b2c88db5dccfd708a996a46b76b4ebd09"},
{NID_sect571r1, NID_sha256,
"7bc8bbf5ebeacf40b3c82eb6eba5d994dcc6a3f2e12ef741f90f90e176d20c21e006ecda"
"f14cb5beef35bff46b2c374d9ee224516679b1a9e9255cd8ad8e60ed234f8ee7e0fc53c9"
"021488158217d4b4369cc597d6053746efa1e73340bdd73c1bd2eed57b92426fd4d278d6"
"a86e8be0f0a66ab3dfadefca8831b2f488636251",
"145748871a0b5c1cee628de04a12fd68ff2b154fda96e47afaa96389d66d22802968584f"
"6753d36618d49ed205260f09d3f5ccc2b27a34390ce58179b9834ff92a86d66ea0a97ca",
"0406cc7ce2782dd67cf1fc16f1b24ae46fd085b969d936fefc409a9bde354cfd33a154a3"
"113e837cfb88284d75a96f5fbe85274fdd0990af4a033a6c40b904a5e0f666e4d8b8bc35"
"3207adfea166087502657bf9e2c437beb2f62dab041553a06411f6c9dae83a2a2749a4e5"
"a2a36fbe23d40816b1b8d206b9f5cea20ef200b9150061ca22fee2076e31c88d60a006ef"
"4c",
"26c820dc92f97dbf545f51db7d5ba649333dde38eaa47d8a7edad9a3cf3e6780442db234"
"632458ff17e1d7b70019916708c128601ff547ac84dfb0173cf0a3c5d69ac96c3d7d395",
"338c88d1bbd0b93f3f1fe1ccfcbda65fa1667ec471730a40eda87f57b3eb63d979d8d6d8"
"19b974619799c90b09f33c051b8b522c3a1acede101857265ce1b58cc7eb5698049f494",
"3637bf89f9b66c7ebd8f91a8324eb70a510284b39f0f2e45578f26f5f1e4504ad70a3894"
"27f4d58960cbd918c2f8279de52096e25a1b0b0c3929fd5ef56bab6cde7c0d8e9d2fb30"},
{NID_sect571r1, NID_sha256,
"0cd2a45392871c0c262e7e6f036946354bb41f9c2187b8c4d399231280682f3e0a09731f"
"bfd52c76ee63b9828c2d731f4cefee0a8c46419c398205b2ff80c67d7756db300a0a8385"
"fa287dd37d9126f75998ae1cbab5136560592118db52fbf102b7ff0a1ed45b8a91a7d99d"
"13a0f7fd4366392264aa1248d7324901467457ca",
"3c71911d24ad19c20fc1d8a044d63c9bb417abc3778d7e6234c6af79b898cbfc2f278724"
"4708d2fe203be786edbdc4c9b12b413156b7b0bab0be8af895d191d853cd58aafe1ccce",
"0406cc47aa586a73acddbc91398ff5782457e6da2b10e265153c678789d3d7fcfc485b03"
"b089eb67e6d6955d5c8c7ed5f933d84853576e76fc60332e5f0a62c3ab23690317bf1b42"
"3e015604d94ab9f2ae1d74fe46b1a070160513709de2ba8e74fbf9922e9bbe7f6e743b25"
"701a13f73eae0db0c98dc80c5f8528e16610fcf18f60eda3357ad5878add2554a6befc9d"
"39",
"3681fcc5fc1f0d7d413abf2e44cb5cce9a4a252ec449ec4f550df4a172305eecc072454e"
"fe2040aabaf4fee58ed19c9090061d3c4835c5fec38996f013e5512c0147cb14a4f0fe7",
"0d3c26796bb86b1a20ed4935bc3824bcb9742513ce91a66dd523a3c0d8a5abe63488aabb"
"806b5b113e90d3f3c80e3ffa01ad051e6b0d4edfc641689953ed65fafbaf3e554be31ff",
"2e3129ff95b06c274f7ac08882dc1da6660269f3dbd21a3e48377a628f6d81326084bbb8"
"d32b794fcbde8e574f853636fbbaba480fb36960b0994210bea319a99a46e29b79217b3"},
{NID_sect571r1, NID_sha256,
"e97092625b09c9ae6e152e1cbee207d83361f34cb9b0e727c816a5ed851f12f91fbf88ad"
"9d4c8f9d07350f5d828fd8574eafc768bc72a2b18aaf4d2b48fb10f7c3431137b5185015"
"4de9706487d69a40a8f4cb2c799f48c5d8f518aff752500de93cbb94ab04ae1e0c7183a3"
"2d79a27291dd07b5fb6e6a4fab76e85c3a8607e2",
"18bd74698bac36ef11add6b3e3fad227ecd868f370ec04569462565d2f0af2340bf79348"
"6953a7b79ab04f0ab1f0e4fd16bf6b576cce677d543e73aa8edb0e50372f24ddfbff966",
"040231f891e63bc1c43377faa56c5799eb1c877954ca2cafdeb4883ae40bd78816ca5634"
"f48f5ef5c22dc7d3d0df208bab4149815274d7b134cadb700d166a5e3fc73e9be1bab725"
"220469ea29ef860adf24afdd386347763008ef6fe2488d902c4d513bc0183fc52742782a"
"6fe500d6b581902ccd4f9bf077f975bd5fa89bf240723b99f726c9fab4f953380745ff9e"
"17",
"1590570de563ea96eddd900e4a0a7efa2e4a0b389854e96af32bb7555f098a8cb52d160a"
"bcfbde65998c34f91338a40d40cc03e4a9a241d3b16b0e893d3f7ffdbf8912f35c7f538",
"32402fbee4831b16d762ea2cb218279f4db5e20bc8b6e2e53e89a2ef3646cfb0abbac361"
"16c8c708a1342db2fa0abd39d149e09db57aef65ad8092f37f7962f98c28331f0f20b64",
"2d1e38f40965e2697abc7df5896cf051ce5646f135d1ea0bb470a43250af8df0abf2a04c"
"a1e0f1f31013025b4136a8a6bdaa474bf50752c571f883829bc3a5482ec20e2b4a72c90"},
{NID_sect571r1, NID_sha256,
"ae6723b8df5d6ab5fcfaa22d32fdf106d211514cb1892c7c43ca6cd85c2532f85929c8a2"
"59ed251215063cf92e1502528d1e22d5cf67efa0b8ef21e8eb2f5dff881ba1433e8bcf2b"
"6af8742ecb2bccde081e534615a305562cc22d3398f61f277d8ca785842bda85d8a40438"
"d9bf1aceaedcfc22c85533794a69cfc320931d3f",
"335699bfd058ee2e6163f55d1816bf3669acea8b73be9c4ddfe775230925e6093cff7a66"
"813adf22222c8376faa106d85ac9f3c67929bc58d8986795b6d35d5b9fa546dceabbedc",
"0407995e02dd3d40f9bc2e6f4cb1c0d29923c9022169e64532d1b357f36264d18059c44a"
"8617a6f1136e72648c9051a27714a0dc833428762275a1b5635a3ad91e65d2713236c20f"
"5006167d5839cd4476a638c50db218979a93da44dbf97281d90daa8b9b530960c689279f"
"ff6c342af97880db1e9c5ae57b91d7be727fd1c6210ec59416d1b675f4dd666e0b121d14"
"4b",
"3f037ebe0e4c3910953e123becc09c0862490e7f590245c4cdf9ea5fce930a7d7ca5d17f"
"5689edae1ce706b90efdf84cd82e06e4ab95e9e2368db91d50110eb91cf44e50cdce2cc",
"2baaf025290897a5d68c5e63543256523fb086a6f1166ddfd3d50fb307e0f0cf78b5fa89"
"5f8b71944a7b67b8afe5f3e10f2d248aedf573860c42cd7aff258055ee7cce472e8efb1",
"0f4d239f5af023ff6c94ad7f66d43201c7e40262cd92467c4ab54be8d2b8e6577d143750"
"64fbd00a6327da62f03f75262392add0ec119d820205065aa6238433fadc8d1734b8481"},
{NID_sect571r1, NID_sha256,
"ee20c6b61886e02ed94359dff3559522ff550ca126fed4b2240ea7d999a182b7bb618c50"
"528fcbd261d5e497a991fbac0cf4c105c0f664d6a00a9001c1ed522962fb44dd4159677c"
"e8f1531019f86457c055c9cea6247086cdfe0442485cbbc4386ad002b4bd39a1a1877524"
"37f04569705cb7adc0c68f0fd059d946deb63f0b",
"2c3eaf801330b3f1b0504f2399f1d24455db29911f750c246ba0a134c3b59da8b3562911"
"197764699a92ea1d95a2aac587e24f743df1dad3e1cf7edf955203e24a0225717f8d2df",
"040703d69e2dfb13fb6e695b0b30b31d89c8789e8523a7eea15673aeb4f1909192c06c27"
"558eb55f0315f395b1f3ce84d9c304905cfda1d119bec33af9ade4420de2edbe75cc5460"
"e3075e35b2d6a8550969d49ac5d656afacf68d3a1dc6d17666f46ce3413c855b627f0891"
"912e373af2ba91211c20f067d66056e6bbc0814ff3921d944008b25d8772cc8d696bfe1d"
"09",
"0a9ebaea478893aa0e3bbfd5d007bcec5ad787d9bb5a8e9b8b79865c584966f0bf040d36"
"f62a8e97c123d2adb7f38eb49a86e9c2ce1294d04fef1b6fec7908c4ca1a70bd1699a9e",
"2d495eb5f6fb187a0ee1fa772ccefbb969e854abb445ec19ac3860f40ee65f53b92f6a79"
"7003574bccf0b9de8014ad4e5745ed264eb3ae88040ef6518809b4c66f691d496a85d51",
"1840b2977ff137f2a8f2f7c25e347cf1262fd128e008e30e4752315deb5231098c65e9a5"
"85496a9d6b5b56cd0b6d7dcb7150a077fd199be2d2de0262aa84dad414e100ac6162346"},
{NID_sect571r1, NID_sha256,
"734a9eb8288e32f5a67cc1d88704523ca2c68b798d90e188d871d9f50d2da2063baf1ee6"
"685c45832a1818aabc9afc0bc935e97969dc983a484f16d2bedb3c7c0b8221408be2480a"
"5562d5d1e5d8763d1e474bf2826aa93a68c3b870e3bf34f4941cf590d88e1f5a8cd782a3"
"3992213f3f6b4b4f6dbfb3c3c8f21f5eaf4ef609",
"1c3ff067497e5d387f31f0ecc9c67b3c0dd6ec8c81318c492aad83c9dec6c99e4fa47447"
"f6f7082d636c2591d0df940b947d0a4ae3778e2b7cc8fb92214638399def894ada276b8",
"0402e56655e37b3e753f35eedca95f8ec07b7a3d3e14e365ec041cd9003bdb78a7a8b8ad"
"277a67da5d63dcdeb0ee8d8efb68fe61aad9b1fbef4373ab13c44efacf68cc499faf5b5d"
"be047bbec643d74874b77f0fdbbd2df3f3ff0d35f4b3e1534b2c4d5c76b8cc51693a70e1"
"7d1d4cd64713c5c05966c826458fb5411ac840ab5998bf3cd64a0769c3e075259a70aaf9"
"4d",
"149848f4534eeeb45fc38ddeace59e8f83f0bfb4cfcd2b8b7acd0bf19303051a6a8fe75d"
"4cdec1be036645beb075c772aef4a58785c16d984eb43b9b0317446bc3b3abfe7ec2cb7",
"17eb68556224f995733077501ed295088cc1184fa3872f5f11e97cf67c7bc1febebd3120"
"6a406c4479b60246a517cada5859d4f1aeb98dfc108e96e9898c6e71e59e39b6284895e",
"22904497dc7a98fbe117e4427d74f4ecfc4e14d4467c99227427e3abb8d3dcc406f3704a"
"7783d822ec1118a1d91d5945d5b902a2ad325bcc9c17c68ddf8b5323df9c2bde392710d"},
{NID_sect571r1, NID_sha256,
"68e27cc72fec8f3f1f3882c6efa08efdf21d74d13be5171da35ef2855666ad2ea6919d21"
"dbc1cb6d296663dcbceeba2fe47a2c6507d3d4a67a61b55b0f81c93412d7e1fbe15a590e"
"342a05f55daa55f8591171303154e615e81189a523b855829a5c96621ad118f522e397e2"
"eea05c2603eeae6e3591215e29b2289bc384d8d4",
"04b4e04281b210fe78d516a5b69f878b7fa058941ee9ae8cc63b061d1eb9e12c3e0ecb87"
"17ff4623ff5bbbcdb53c48adbd9c69636506ab929c5507d7ebafae5654aad65a263e48d",
"040538049d071158c62f0102fb664a47431afe320474a173463819d5f83f6737b43880ed"
"378470d774d32ad59cd9d75e5bb06b118f1297af3f6fa910f40aaffe11e46cd56cbd29aa"
"5100a4a843af9841e2427357bdf26817656637bf4650e443ef303dd458ed092dca3cacf2"
"857d10aa190c256467ff834bc804f8557f6c3bdde89927a5f2bd55bb9d9f1f08a044cbc2"
"08",
"1191110485f56335f0e65fe04b9ad8fac1c3573cb4690db3e9f62086312d394b0e354890"
"c0f74e3df7c43e718ecf18caf6904e03bd6c0912f906de1d2bb4c49823bc6c0dbfe37f4",
"0dff371ac365cb7de248ddb2b2fdee624c527c6c1908dd287a294bb43a4be94c130bfa83"
"710b0655f21695dd91703acca64fe2e7927eaf9c2b9b230de8002798224f9505379bf34",
"2f30f31c863bdd68fae16f97fba756e033eada18cb0a23d7d4b2c9ea3c832e61b52185fc"
"d654d9eb281b92a9b102c3b17ebf02422a0e4a7a56a73974208371ef65434c38f4d7d1d"},
{NID_sect571r1, NID_sha384,
"e67cecedf35058b80787589514a9c81c6b9f4bced4260411d2af75bc46b8b2c962dc9d26"
"0dc99ebbf8ee64950766efc0e394184bdc8e2891d66bd3300ecc880e9d6a3d0eb6153223"
"78afc3dba89938704e9a8d0c949d4bae9838805c00377e3fe5ec6a1a98ad7eaaba6b5009"
"73dac48b26b7fb2e1b9889f8c387de535d4b2363",
"30f2849a713aeac95fde5ce3af853e9d070ee60709eccf35a076567be2c43f0fa34420b0"
"fc097ff577221275a3a56e759efc32183be2d76058a7d20e5dd59f00415114d73a15b8f",
"0406d4ed3cf180e0e307745faa49247f269c3fa0a69042b3b78ad645f43eaa50d479622e"
"27429a6b6b1889944f85975fec8018d3321ed38f6c7d91f2efc98467a027ba4a02c7f231"
"b405f2ebf6abf7d53fa32865a9b6ada9bee51c1fe26cad74dd6ef78f13872f340d641700"
"31becb5073001fbca373be4e32ac3425d705ee942e6c4e639bf72379e34776680a387a0c"
"6d",
"0da9d8647d0950f558a3831b47858168b3379656e603f2bd44046ac7546892d1a7318c5a"
"9873c6ff85683edd3881a0f1af5501d17939f0825ed37bfc9a2d95faf43d3be92b237ef",
"0fc7eaeef74806606fe51882c6928a06bf552d18dcc4d326d44a540abb728146657048b2"
"0e5fe2868beb5f04f32d43e9ac23a7f22c6bf325bca24f5e3161c868911ee61baa8a3c6",
"33d63693268f3762635373fc901fd72e525965ac17e2cc009177f03bd3524107b30e4c6d"
"80bbc4f87fb1f288ed56812994541fe063f1d91afa7213bed8be5693dc6c17ec9a0714f"},
{NID_sect571r1, NID_sha384,
"2baa1ac3f07e34b67b6af087400f261e138b070c8475378063286c16fa73578303380236"
"a4af2484ea01ba56c1c619f6ae4e5e6ac2594c8e5aae7e7f196f96fc5d0f507bebedd4d8"
"18e77b9120e5b4bc01c7ab6339e88b71d0886631cc7fd89659bf513faf149c61eb14d550"
"60c8dfc7e6e4c2b4ec8edaaa6bc36eca50a6feef",
"2ebb73d04e6e5361e20629e3ad119b33db5163ed91fd9a8aec4b774898784b6822a08992"
"118a8fe6013094bad0be1e9bf01b27c069e4335bff7e0abd28a10443818f6b825e9cef1",
"04001710eb0167e8c948d381e3a75aa1e036b70c414f69260aab434ee20b6724dd7393fc"
"487b5b3822e5e8065b06d0785a4a7be7193352d5b9eee66755ba106ba6e40f98a08c730a"
"0c06006f98fc25a641a7c6e67fedd37aaad77a9102be3e1e7d32dcb4c68029e623a42f4c"
"a7d1ea725bfd475756b80e18904107c460fc03b9bd68aa46f9dfbd60618670c4d9a68a32"
"87",
"1861e2a356a6fa8096418cde7fa17f1b893a7b63810f3fd807a82bf4c745aafdc4963eb7"
"a0ad0488a776e915b64d2b684e46d244703eb63b77835167908f2d6b06a2ed7b53f0717",
"046688e12d26cd96bb05d3f418d8ec34f4426f594acd2bfd8e9abd79405e612d60737007"
"440424bc4f546c54b7402d11880f68edd996f49277b729450f7dda5d05986b014b5244f",
"341a80e74f3a69b966ef81ae95dbdd60ed5a0446416653c4df431ff7c4b4272665a52337"
"9d76725e9fbe196018f0e747100084c823b95d7c7b1785d3623e52e9adbe773b81b49d3"},
{NID_sect571r1, NID_sha384,
"0e640581f573068d8ebd2899a6aaeed0bf987ee11e22b05d25e88e9a1c3451f45ee3800d"
"976f4603c18a041febef07a01086832a6f7ecd5d498d52e796a9d90758c87c36f4a5b704"
"a39c456aaee2d5278183d5815d619c193da9fbc427d701bab0874bded848cb4bb066f56e"
"119b637c78aeb6eaa387c41bec6cdd4bf7b2061a",
"1bfab717d6f6e16d9bc6e89d2ffac7cbe0f808cc8ca2eb515af7ecce5f3b230303775710"
"a21bd25c2cc4566bb53c78c78e3774a9f306c751cc6e149929e45eef60f56c1d2388c6d",
"0406935c3e8b58f7bacd045e745054c227687800ddd86d6e0c8b1e426f4df0e4b71feede"
"fa9172c43becebbeee8ee382a75396fc5f29ef3d2cc55f8afa9232038609b5034513b222"
"cf0138463efe3b32259dd90b759062f848deda84f2bcc0d687c410f1ad2dd745517c96c3"
"451432b1e490902208cabb68bb872ec493eabdf1f3b07595d23a54c53e512777abffb7fc"
"65",
"00025bd48e2dbbf1ed8bd9c1514303dc503dd0799c7815870b902249cd1d7368380853d3"
"6f7fdefad973700ded1e0d66950181b0aeac73eb622c880571315f09504ed26e28e85a1",
"1b9d6ccb19b208022d3a579a66957429682517e84a71be42fd571fbbd0247609d0b5b338"
"08189efb52d21e6421d3b08821d82900577791b1c54e239b0d908bfbcdc060cfedaefb2",
"3356320389ffde577496c5b46a0de6d53005f5ae3489c0d292c5f460a3b7adc5bd204bc5"
"0a3bcc8538e0f8319c79b9024b065223b7ed9b0f211c5c224d363f5bdfe04db97f99e19"},
{NID_sect571r1, NID_sha384,
"51a2a560ba226d629127ce1ea7e812219ceaddd23561256331458c9f11fe73990f21d0dc"
"d974a3773040090cfdc8e0f01692d951a0cbb60f8448a016c67abf46a9c150466ac77e65"
"6ea827b0ea7d1e77ea32071ba8314fc8a2edf69008f498bd1c18061d7d00f3340a7e2cd7"
"3e9766862378d8702e804a1870b442beb2d0aa14",
"00cc53bf7f1cad5e3dede4b4f4b082831604c92dd2b147869cdf1107259305b1d5035964"
"7f9f3d7d4e1e608865c65dc7c9ea46bc324dcb8423b554dc369d621743cbfb592b70eb5",
"04020187d7de90652caf1210703ef65cada3b88f978e14ce6055847be7127602ba7a5391"
"cef0fc9b009134105da7b09b49beb7ba2f961b84e6d66bd818ea99ec106c6e8428b17394"
"a60197aef36e47b571ccc0b41f948392d6061060063137d8c3b999ae507b76132fea1563"
"775be555616cb5816b9b19e42b34f9673aab833f4beb9d1a0848a4bbf2f6f44cd0398274"
"8c",
"08acd0f8f9660d21d62f391112908be73a4342767328d3375a8806dffd2598b6d77fcb47"
"93e69f2390389a78c2b11866cf0f03666a60ad088d2c77bbc49fff6efc5b7283d02bf36",
"1004bfb78dc0e4fc0f2624bec6893d717a476fc76bb5c1d94c1dbf157aab5d1dc80f98a3"
"aeabaac94d9cf9e26e1dd172f5d8fcd5b2d48cb3b7f0a4863813357b5cf8eae84478e44",
"30b1c8857977181d12c53cc2efc53a427801cde2890cf2ea2c99c6958b6869d0ac78ee2c"
"846c241362c885835af49c47d20c30f3cbfab27d9cfeaa6d858694bab059229e30bf845"},
{NID_sect571r1, NID_sha384,
"90eeecff0a2e37df318c441df220dfea013ef29774ee92a56b213e13a798858f31e52b6c"
"cb7599e7314f12b48a89884b113c1ba0526a54f3e9a33c940944319e084bff320cf5f391"
"c02c731c4c4f8b05afa273374a1705d6c85337782ba7d36b9c00767180cad6422c11c581"
"672ff631fa4c49d41b02481568ec87ea97220400",
"2b009530cb9d586e35dd8951ccb686833afb7a37ec253e547e85b253ba999f0f186b6d4b"
"a41091615fe57678e9801b4dc94fa683511da25637b2acc9fe60936be15af16234c4ee7",
"0405913ab6a2287d946b5b6d1e6c3d64117e085da7cf6388e333cf58d22494f4b067c684"
"dca770ddbcea5db73f048b296e9c17284a8912b3cb722d9eaa17b6b1209311fb8e8757cb"
"f50007124ac6c48ac56746563db247bcfe6b20215ccc5cfb1d43c923daa07d429c8f0513"
"bd1ff1180ef0f7927fa23fda1af25d20b22c935c426f9ccb402c358b57b812516c431117"
"79",
"27a80a19e9c320b57146845fcf97d6debcffbcae877c33c62aec62a3351ef40bd90ef4c2"
"ca39f9e51086931d82eec4ee7870365cb14e9c54ae735069801ef12c571bf1c7c1cf6e6",
"1de22c8984c593a0948164e6cc8631489133972482f6a7fb1c3c13f97e4584604930d369"
"224850a1d24f267f41bc6fca04ad79326aef61f0d429e0e1b9e9d9686ee10f2bc52b104",
"085c6b34687081e280a180cd0c4ffe95cebbb0ad6d3b20a7341e467812f88c23973701cb"
"f3cd2bcd2811415d0bf0cd9df229a88754f4cb0c225a2d11f57369a29edfd7b04639055"},
{NID_sect571r1, NID_sha384,
"d3740cad41e2e365d80ae81da97fdf06d8b6c278b505e34cb683fb55ddc5189da5435409"
"14c0accd405dbf0063f6222885fda4b316dad4a83fd03e8d7b7e936f87fc0a5b095defc8"
"a4b22fa97f00b394e672d5efd3e0a230c7e44dfeebda88641143502a400ed62e2a51f956"
"1e5d652a43d616f16699e875deb9610c77de8e1c",
"2cc2d0d7189cc8fb3565a039aee7633ddc00ff427cafad32fd2010b10fe249c9724d9178"
"5e7080203626038109158e3a61a3970aa3e51688aa7f5184b22f63af63f80d3540ec023",
"0405fe95a030efac2e5d9522680da58606e3e7544a317a3f24d726b69238367d30fa5868"
"64d8c143c3695126ce8dffbc7e7fb789f956dbf53aabbc38af988ce50f1fb30294ea3e2d"
"480193d1e745d82781ae5c3b3d2233e502959d6862fa7987c6416584504f65639ca76557"
"8378b75d3844df179cefdeccff3c4c43aeb8865063e176fd43a27c93e329f8d4f6fd5bad"
"21",
"02df3920fe4d328315353ff11b0264045248b32f48e860dc59d931ad65f39e97e3a683c7"
"b5c64b21c3fa50a9685fa11f49df9b14ddaae03eb02754b01e03f60fc6aef1e5d6d7d3c",
"1b91c4217b1580cfab56812c16bb5aefc1534ee8d049aa2e1d52a5bfc11519ff89f0d36e"
"a2bfdfce8b5d3cf1527dcf700c0208a70595e9ebe4feafd0eb597e05df54212fd6eca3e",
"21ce52440267fb16e713eabb8bf2d502c81939799f9d09cf48a50dce5da999f3b457dcd7"
"3c212d5d070056b1f373b07ad06e90d96febb7f8cdb4c423ef946f0799c038a3ee68ff4"},
{NID_sect571r1, NID_sha384,
"5eb53b5f92121396c5ff30e0c92da48db4fbbdbf27297f9bc82614ab78f7fd863e34096c"
"615a02e349d8bc7ae4b0700130704bedf32756b5ee6af10da1cd717d624fadc57a9aa6db"
"4a6c5d6254c0e8f8c3c0d4d03c264eeeafd52cac2c1968d9d85b106167a49d0ccdbefb20"
"bdc10a2555f8149203af52853169a02db94e5e2a",
"3d8936c00c131e38c6566d2464c4e207c878070bbf681695a6cd98cab2c6e80fe98cda80"
"c66a5cf584e90a071144dda59c07b8fc7bb42464dbee5b6f739b0f2ee5fdff7e5a4e7cf",
"0400fc3a8a320e816305772bd5116cec2795d58633a9f490be8a1a360f21d2aebed6038c"
"a4a5081288b6bdb1066307c26897ce38c24f8ccc98a63e371ff6b54f6016917b430c267a"
"f7069719c868d8fd25a38a7338811904e3330a7b2289a8384bf24f6dad5312160f0093bf"
"556fa061ca5e52d6676a8f1a3e4656740c82d3cddf0ac4f903ea885d42610bf1b45d9e57"
"a1",
"050da632cd7aa58340adeb20389a2cb9897b8ec944c47e7177da65d9386a9dec5d63be7b"
"b2d0f5b4943932e1fd7d87d5d7a80bc50a63dfd101a6a28005c894c6a6fa4c652dc519c",
"0e6152b9050127bf306662f6beee81d024492b91efe87a56e70596a4a72cd02dd2f10b97"
"0c9a69909f85bf4783dcd3c32505d7c148166ab43b503ab098b6d95ef09a7932359f60e",
"1f7d68d53ba161b61eeb17139eeae1587a6bd148e288c1f73a6bfb3a0d1f6dd8f9cdc27f"
"a9e8c7a681410500c097ad01f320303421f1239b4a9c4d5446562b5b3cb2fc45a6fe239"},
{NID_sect571r1, NID_sha384,
"5aced64f702a57ed7fabd045a40c967a485d2a70b0a5e82561d5141ef329469b2da5964a"
"34df203a980111a77adca376c643b9030aa74516f054648c1534d912ea66582adf3c655d"
"bd71ca55e47412315df5e2893e43b2e2dfe6e4dedf426f11846ebef34a99f5615460ce04"
"75f7bc54b4a4fd99e83c982097c3136ac6188a5c",
"3dc7de970bce28a943d7599f2a9010fc99435b93bc4ba884d42503ac2941aa63fd07db34"
"bcbb1127d56d6a4e277d6ca32051ea3467e376f74f98c3999d2f276b282ef8a28cf0cbc",
"0402066a50b9f961a58620f473fcf7d5eb635da47f4ce362f428669ea578d50d1c1513c1"
"45adcc03ba98f3d67bb422141c73e2f94ef9559ccfdc0be20eb206d3d114a5db302bd075"
"1f04437e655bd255e7f013d197210bed70c5c1a6cc1daccb96145c9c438c8a44b4074629"
"830d8df9914166c9378b33040d71918cdd0f47fa64b7c69f43eee0f34414b8f64882f90a"
"c3",
"3b2e20f4e258b7f0cf69a460fece9b4794a12a37c0f8e7aa6f4f51dbfaf508f6f1e0160a"
"b4388891efb09f0ca1f73178f0e8598750c9debd3ff856cb3a2872762ef9e16487a9513",
"2f265aa99ff806ffeacbf9ef7be575ce5300d3cfd4225b1835774ee075d7e530c9fdcd68"
"1584223f84a497119b4eb1fe34cd31d654c2fa262d7549acc251cece9530b26cfa3ab35",
"2c05ce4b35544bd1f20a68eae7f3483e0a0628dbb53f0466166257f69a7a110d2838a76d"
"204e7a955a8977508e65f2ef6d7deee13e4e2ec0f2b9a8b4bedc26b3502813b0334a1b0"},
{NID_sect571r1, NID_sha384,
"43c24aea343d4e088bea25be69a332c631275c36677093e057de69cc83a4c5e70ab270e5"
"a8930f55846f1a22ec10e03007dcf0942c6761e89c65c6a4f032eed97dc3a2c7f7ed1e82"
"552fe48828a132ba16c41f6bd82a49335428a24fa1679522000e6a1d12c646e0e4b4c584"
"398577ea9493bb334fa3cee8bfdb6c2e66f46436",
"2de6ee12eefa7a4a736484b19b42a513dfc059a060976edc3b0aa4b50e98d72df6506fed"
"0499ff8480986748e938289e54a5e86c0c29733a9bcf5985aa63d8a2b57933a04a8e8e0",
"040073fa1b62d469f2991d54f1472b60da87ba51be0a9dea361d417b91a4a75373695e9f"
"27b3c672322315d7b566b1f22b96c54adce3e958080fa8a02836955f6264dad3a87fd11f"
"060452c0a07ff65fff741c96851657a5afc7eeca239622e1260414ed736a04e487157c52"
"da98a7845bcf6f311e0f2e59bb92248b6d47dcb93da6f7e0af644b7aec7603a01950293d"
"8c",
"1c87653066057636f9a98a7c69a84e103df480a92739abc4d5ba53891591e3aaaef6ef3e"
"f5e89213abbf71af9c84d3b30898580e782f557a03694446492afb05ab801d7dd631c8c",
"086d539546c61e82d74319f0180411172acaf08b5296dc6435d4ed7bd50cf23d3a071deb"
"3be01f74408e64ad244f069cd41227ba127145df5a357489f944b61606ec75e8377db81",
"0a34d9975fbd601614d04aa41506b03fc15189ee8102c0431272d691a322f3e77bcfd19d"
"8bddd19b307012b6c6349f5ecf88b5a69e83588b0e18096117f207304b38c16a9a8592b"},
{NID_sect571r1, NID_sha384,
"e89210565959d93b483659e62cf41f0a0147ea23890c2f1a694c377a826165e363860e4b"
"084016cda878a43eb68465f81f397ecd50087a25215ce7c4ededa3552218071fa3acd7ae"
"380655fc8fa884998209ffc8a2c26f1ca19dfcfee455dad35a4e72caecd8da47eb9ee21b"
"889162f5d3032724abfd1a31e68612e18bfa9006",
"05468f0df2c9854f5f655743e79c750fd8812db28b096d97207bae7f5aafc6b6090c9c63"
"6ead9e0fde32a1ff8d539b53813733ca812b41b58ff85a941abe4f128d59fdf9847baa4",
"0406591750fbc104f82c213fe88aa620e8a960fd6140598e2e6282e0d5c5ecffd09d22ed"
"94166109561a7f4f694e171189056d8b300b54c8134485500effc7123aaa23862e897912"
"42005bf8ec10a9ac6a92c54e7fb2135e2aa4f84da571d33227bde0aa2e6c153207488223"
"5f3103d9a51e80b7a9a19067f35047ddc52462db7c634c291e8fc5eb2154f6913bd0846b"
"88",
"242308c430de514be1b9084a7e6c96894cd5615a7c71ea22316e539986e9702080ff6cee"
"f2980144c55d9749830c20c9ea90b93dfcdd28fd862b6a15748dbb3d982e4a275129c75",
"361e1b7a0f981bcc65480b370c5e09b1c2e2a67cf41646f6a3d829f663c0911589223740"
"0317601fcee78a04269411d267dad3e8fc6f069529fbdf0bcf9b5f13c9c6de1681e8b0a",
"2620c29f86cbf698cca5f79de364ae131345a802c0cccfaefdd7375dcc9ba6ccac91f709"
"43eb606506e51e2ced50491eb8f48769810b6dc178d56702838f1c2f0930f2a9e4f1db6"},
{NID_sect571r1, NID_sha384,
"48629ec97f56273599cd9903f8a84ac2ba74275b40e1e42fa47649568babe05cf63c8417"
"d828251acc2eec525b56dc9082b68d51b0c2bbaa7389fbee15d058cf482993b2bedc5a91"
"01f1afdc79989a812478245d191550109fc17215679553c508c84e3d4cfdea377088d09e"
"b214e6f92410facee4790beeecafe72b2e3ed192",
"3d3c6a7ab9450c94aa3b8a1ffb678e5b647af24cbfd66ee3944e6f264f406295b8037674"
"71fc67936fdfed1714b4b8761a07eec86543b7c4da6bd2fcb33fa8cda4077737f398e18",
"04042d536f1b15a22f4ba80066798d8d1c2704988eeb9423319c1850a1ae6bba4097307b"
"515640ed3112e93f1f6ae67c60a4b0d2b6634aa7038a60b52b2b447fd1651857b71711c9"
"75079eb18cc7493a1c7f2f9b621969b9ce9ee37fc0701f6cf56f5d5dc6efb13a384517a3"
"87f253aae1e93bb0a919b0c22e4d6cbc79b449b268a068b7eb2853324b96715d75b8c26f"
"27",
"23ce112d60a2f7c29d77d64acd9f587e0eb75ef8e739b8548e154681efc24243594eef5e"
"33d845b1e4e89bac56f2e9586e042e0fff38bcf79c73fc9aa5fc908261df5cd2c6cb821",
"3a770df8a2bc35e122c1bd551c38400be47f2499ff57618ccd01e14a2e35e87a67b0e40f"
"9a10eee7efcc3d37b474f2840fb8c24a9adf93734680ae6b25818369c8608a2f8f338f1",
"0728a4eae5f5638a51579e224a24ecd4c997001bb8681e23a7476fbf78b4fab84497000f"
"20c1e67e8a4e4116498bcee49ff00026009af31c1037172188aacd264fde8db15c97167"},
{NID_sect571r1, NID_sha384,
"aa3a9fe467b1ca638dd0622c9ea235a418b39b2e15ad81fee01b6892b240783d8db3c72e"
"16c13df8016dac6addbfb85232158325bd7432fca3b8bf5db3abd0b4c5ccd0999609dc42"
"199ca4680692a0805cdd68108bcb493a558ab507cec0a2782a9e976928985352edb2abc0"
"c07078b59d2fd86fda7fc76cfe573181d934c46c",
"01ce010ea8e6e1a0c26ab22eb90f0700dc73b232c429d36371e68e429792afb7223f1032"
"7708bcff779ea55fb5f22ad87aa054e84d10f5450f1bc9a89279062ea2173f55ab0f76c",
"0404b2b5acef5921e691f10ade81b91ba8e68e73b33a2494cf4ca6617707861f334eb07c"
"a96dfd681dd63f78102f8d792d66102117b739d477e431d9a3efd79bfcc18cea156db58a"
"0e07e421337d4cb7a98cf9c9c6fdf9fa242904d9906d8a6759ef64a82cbf923b2a57073e"
"a0eabd14aa4295bec84d50a1722fecad3e5f064bd3171facdfff45b170e49f185a3c193f"
"2a",
"326b62065b7c779dc398ee03a8332cfb940b0f24a7d3de4a90323d9e390ad3fb1f0036ab"
"f6f525d8d88ab6641302d10db447b78780d366f32ce36ae571e323124b21984c48aea7d",
"3d2b207b428829ed5100a92f7276e16978e374c734834b0d627cddf6aff5cab72dafefc6"
"c038a91426e35ee0f2c1acc11c55a34a89874100b89588aba7b02e19490e66eb49ef6ed",
"3259fef5c2a0779ae408b26e6c7d581fa973156cdb07c329dde0c12b6c498e7a94577719"
"865b7fcc0db078ba72a27bf338ec6b8aa41c15963538c329c55dee67833faebe3b643ad"},
{NID_sect571r1, NID_sha384,
"6c3937014361799f1461f652841b5137eb0dcaf01dd293298d002f27e9a770b9e1a30367"
"e35c04603881f0c814cf8ecfbe1619cc49cd516b1d60d27de37ed52a5e1cc300e2face46"
"69f308ebe6747255a3d386f16778e494a7cdd10b45171b2bfcdabd91b805bf24857708c1"
"b75e368edb2874321324f83a19154d3a1578c767",
"1e7410d012aeef02b3723346d24ebafd684c99087ecccaea1cf3735d52c4c81dda41812c"
"09f1e874dc964d858ca240a19963d5dc89451f5dd6764426ae41cb23f19cbfdca0fc562",
"040400a3bb3ff07a339ff98f7c45fe032cf42c0e25de8dee2934ce42dfb0c9894f4fce27"
"fef299b41beb8579270efc7b01c0663c3f72d7bdd9f6ff5186eca9c42d15faaef8784211"
"a5006fe998f7a0db06efed050d178865a2b7de6ca7c789cedff7f2158a5e07ac1d335ec0"
"dbd213fc9465399028fad8b7f4d2cd16fb8ceae4d3d53abefd2b4037efd7f7245296bfdf"
"9d",
"2bb0fb9c428e42482d5dbdb35157ad0fa713fe732dac8604c0194e3f9738fac5cf3874bd"
"863718712a3da45b7c4612c8685465ecaec0930d9fec32ab25818d2f25fad580009b698",
"1062386d3e77043298eb88be46bd4e6f33c83a7358926b30ca06a6b7139815f6e1630f73"
"d352a2cb9bc0619d08a89d4bde1636c74b6580543ed743073eec2ae0037bea2b3c9228e",
"1ceef759d804ff7de526559636d0bc7930c096c7b959f04f8fec5d7e96129fba14c8341b"
"0ed84a64c6cce7cd5b058fab7f44dcf3e714544c9b6f9c1d46ce512870deb51856e9dec"},
{NID_sect571r1, NID_sha384,
"12fea55ffda15db902aa6a4388b9807c89c193cbf75b5d2a4c95206fa43dedc45974c800"
"79933451bdc5b3ea015ed3ca2c54156dc61afb1bc82adefed1491302a48b9d3d2f474ab4"
"5343c611677d360515b93fb36da7a1c1b2341c9cce185c881c0beef33d43967134a190c0"
"9034ae3261f3295b79aebd3fe123616f73cf2089",
"2139839ce38eb879d266065dde5e5ea227244323b330e3ad5a0bc690f3c210f794cf18f0"
"d730693887548bfbc434f48ee10ed34cb41d52172b06e448df938170a5e17311cab8e88",
"0402ecf46b90616b534ea25cc9993942fd7576a1c4f2f443d3b1f56d4490bf0af669c9eb"
"9d110fe2a65609875e1a924bc4b9ed2ed2315047bbaeadaa1029b38a7a87dd8751d4128e"
"8002aec3a2f2557c7152a4907af68aa39485274f20927b2da70823440fbd09cbc308d46e"
"30bd6b705f615b7074fe5421ca36b4aa53861983eceae9a69649495952e75b0f060b5d26"
"e4",
"2e3412b61eb23d33ca2910dc25dd14c04d2c8b403d8077a72b9511d71ee9da6d7e1db093"
"b92287f8fb00aea0576f6712c56d80cc4e3554e0faa9c7d911e3d17682de831bf649bd9",
"06a3075efec81a86175cd1dc2bfe82e83aff1db640184a6a3ed7a0dcdef51aa0be0005c5"
"4ac05f9b65af265af7f2ec3d1d7c137184b0d695d701ff1aed194faf2efa98ce6c5e502",
"237d7ff92480fa7d6d1f5a0564a2608afe5e95ce2c29dd88853d1ad9d4d2beb8d1f0423e"
"db883faadd592394f52048bf2dc26d2dc19279477ed86621c7a5960ee3c3e2d345fda29"},
{NID_sect571r1, NID_sha384,
"c8395546842ddb545d8ea3db4efe970453dcb06025ac3b7a25aa5ef62070f3021b9a1fea"
"91ff7055b6c398073e7886a6f71afe53c82c47b71377dfe291972503bbeb25bd477bf0e7"
"adc8a5d3f8b34ccd0080d61e121214e1b29802b711cdd8a6bb2275a2395c467ec2c15719"
"52992e448d736d8bd70ee629c75b5e32b8323a00",
"274f70fe69e4dbb55c5d404e39f5196335047113087f8711f2f67f2be4964e4fbcb86568"
"0758df1c401cd677b0971654b7a6aeb7bee0d6d80ac0de14d4f46f356b2d5545c185aa6",
"0402b2321e0a1df083919628dd8b4c318b9ded8a3e660ce5585b21e46843228b4d32da76"
"5a3776c181654aad0ce90724bf85b01b051d236342b48d41a1dbda1e9904d659c98a039a"
"97020227182fcf099d46d9882c0b0f26b0595a2a3166248898df2f3fd27c78e7c0b8b59e"
"f0ed6745660c0dea1acb567f9d943928864dd1e94f8eb6b5b8473c0c91485643189cf679"
"d2",
"2f234066c936625fca10dd080cbbb1228c4d2054cbdeafc8a0a248c0d22807fc92c661b4"
"f69586ecf9469bc4c22895cc73ecf492fb2165a12b027194d409677e7185de24f6870a3",
"3a48daa8e379b3b2f377049a4d462530c9ea67019752f4af4b4192b02d6e028386dcb9ef"
"95c8019e90e09dfc8dff5e6f6812df491906ced39befedf16caef614d8c174e7ea95fc1",
"33f18738cb26d88c8c048c58a210c7be70c71636dc62c022df1bd7747d8c67bfcf5ff2fb"
"3990ed35becf6c77755ac62aed480df55efea578671bd8d50536a10e2c0192bd42d78e2"},
{NID_sect571r1, NID_sha512,
"10d2e00ae57176c79cdfc746c0c887abe799ee445b151b008e3d9f81eb69be40298ddf37"
"b5c45a9b6e5ff83785d8c140cf11e6a4c3879a2845796872363da24b10f1f8d9cc48f8af"
"20681dceb60dd62095d6d3b1779a4a805de3d74e38983b24c0748618e2f92ef7cac257ff"
"4bd1f41113f2891eb13c47930e69ddbe91f270fb",
"03e1b03ffca4399d5b439fac8f87a5cb06930f00d304193d7daf83d5947d0c1e293f74ae"
"f8e56849f16147133c37a6b3d1b1883e5d61d6b871ea036c5291d9a74541f28878cb986",
"0403b236fc135d849d50140fdaae1045e6ae35ef61091e98f5059b30eb16acdd0deb2bc0"
"d3544bc3a666e0014e50030134fe5466a9e4d3911ed580e28851f3747c0010888e819d3d"
"1f03a8b6627a587d289032bd76374d16771188d7ff281c39542c8977f6872fa932e5daa1"
"4e13792dea9ffe8e9f68d6b525ec99b81a5a60cfb0590cc6f297cfff8d7ba1a8bb81fe2e"
"16",
"2e56a94cfbbcd293e242f0c2a2e9df289a9480e6ba52e0f00fa19bcf2a7769bd155e6b79"
"ddbd6a8646b0e69c8baea27f8034a18796e8eb4fe6e0e2358c383521d9375d2b6b437f9",
"2eb1c5c1fc93cf3c8babed12c031cf1504e094174fd335104cbe4a2abd210b5a14b1c3a4"
"55579f1ed0517c31822340e4dd3c1f967e1b4b9d071a1072afc1a199f8c548cd449a634",
"22f97bb48641235826cf4e597fa8de849402d6bd6114ad2d7fbcf53a08247e5ee921f1bd"
"5994dffee36eedff5592bb93b8bb148214da3b7baebffbd96b4f86c55b3f6bbac142442"},
{NID_sect571r1, NID_sha512,
"b61a0849a28672cb536fcf61ea2eb389d02ff7a09aa391744cae6597bd56703c40c50ca2"
"dee5f7ee796acfd47322f03d8dbe4d99dc8eec588b4e5467f123075b2d74b2a0b0bbfd3a"
"c5487a905fad6d6ac1421c2e564c0cf15e1f0f10bc31c249b7b46edd2462a55f85560d99"
"bde9d5b06b97817d1dbe0a67c701d6e6e7878272",
"2e09ffd8b434bb7f67d1d3ccf482164f1653c6e4ec64dec2517aa21b7a93b2b21ea1eebb"
"54734882f29303e489f02e3b741a87287e2dcdf3858eb6d2ec668f8b5b26f442ce513a2",
"04036f1be8738dd7dae4486b86a08fe90424f3673e76b10e739442e15f3bfafaf841842a"
"c98e490521b7e7bb94c127529f6ec6a42cc6f06fc80606f1210fe020ff508148f93301c9"
"d304d39666ebe99fe214336ad440d776c88eb916f2f4a3433548b87d2aebed840b424d15"
"c8341b4a0a657bf6a234d4fe78631c8e07ac1f4dc7474cd6b4545d536b7b17c160db4562"
"d9",
"378e7801566d7b77db7a474717ab2195b02957cc264a9449d4126a7cc574728ed5a4769a"
"bd5dde987ca66cfe3d45b5fc52ffd266acb8a8bb3fcb4b60f7febbf48aebe33bd3efbdd",
"3d8105f87fe3166046c08e80a28acc98a80b8b7a729623053c2a9e80afd06756edfe09bd"
"cf3035f6829ede041b745955d219dc5d30ddd8b37f6ba0f6d2857504cdc68a1ed812a10",
"34db9998dc53527114518a7ce3783d674ca8cced823fa05e2942e7a0a20b3cc583dcd930"
"c43f9b93079c5ee18a1f5a66e7c3527c18610f9b47a4da7e245ef803e0662e4d2ad721c"},
{NID_sect571r1, NID_sha512,
"ba6be551bc60653192401ed8ff9e1acd9013d8811a7a1389528bf07438366f5772cd7aed"
"ad010c19c47622cec03a4d35b8003b39ed901b720629ab59de55a03c1ca50a62987f8da1"
"59e356245df58d5ae1936e65f3cd3acbe03ad1d0fcab4aaf2a7a947549ae776772201efb"
"c6fab1aebfa1d99994d4f43dc28f39c0f279b992",
"2a69bc1df069c6e89722521a63675f318252be629e7558f3716917998e660ac960b0b750"
"562846fe6c12ef492951e51e224754bab84a6eacd4147a5f26ae85ee4381bb14ec2a8c7",
"0404685c0358ca31883cdfd7d609afa8b1e47540a97f473e0ebe98b0aaaab9418877aeea"
"d3a26fb01a4725fda20e7223a4fe7de0df6891c0812555b8b146918d3b80edd11615d95b"
"77067c92736447946c7577965b613e18950d813a4df049a6000895f9dac34d73ea46a83c"
"6a4e7c83831af0d33026825664c44090953521175b9da2a7ac563a0fc5e13c85d34aaf49"
"f2",
"1700d9ac00a987ff3a1d0be4290979317fe60f4f8ce1e0e72a026fc89e28c0070b76ada1"
"4f7a1a66ac2e8aef17eec18b568ada4fd59c05414e55356fc17d9e5079e6cabfc1f220d",
"23a279662efec48f6cf8c7334862525b52ac37a9b03da6a063da2849f878015632427834"
"34fca02fa23e32249666ddc6f596e07750ed21de303f4f10de56f1d37101cb0826bb8bf",
"3b449467b150cba0d7c2b44280c5ac452f1217384ce121c979625d313394f6cef501b819"
"80a02567ca55da2bc313dc0754b5256b08d8e3b63ea033253b205cc5dcb014574b8e9a0"},
{NID_sect571r1, NID_sha512,
"295720a79ac8201f40a66b06ae5d970afb15f36582897eed25cd92edcd00f70ac8e31c55"
"6eed4375ea044c2e8b227a8e02c0a3e996c9272d52ac7b3ad43b80f217295dddc84b177c"
"f1e800ad08bf7fdd021fb2f49b54162092f8d628679c4ee335abbc90c027264c8b288c6e"
"16eca3172eaa297ba50626b00fe0a0ad3a9dbeeb",
"0d11ed1b78b22b3420df4ddc4acc7c2286d9569dd6dd88e0fa3ecae69bcced68bb81bbb4"
"ca6e9b54e67856e7fdf39155aa27aecb9cc827ccb9cdcf9ac633561b27d8eebfc261aee",
"0401868a1335058a69e3ce24ea4e6e8dc25851777bb28d3a5da67b741ec9c46e26f2d2ae"
"70a48c3e4feabb3b15b3c3ebd561f667ef3b95a587621de6073b9c8a904755566c5f7a3b"
"4206365a03c3f3066eca1af17bbbd08cd52e89f8095075b415cd4b82f3364cbff008fe36"
"42fe71e8a8c634ad0e5d9979251e6cedd42cb97c2203f743210051f5ee1b70c861d2a72c"
"00",
"075e49d2ff6f2aa8b44fad90446474ee0e72323a3c39e731b6c2b075cce0cb9d193bc335"
"6f8fdae0e0143603a57028836ee6451cab101a6eb550042cb41b5c4233d3ad3e87034d1",
"207a8eed0b87efe65ec558a0ccbecb13b9215e176abd93c1a4803fcae713927ece70ec6c"
"41c621357d78a13a950958871a52621f1de7ab74befd964a0e8f4820b84af3e0811bc67",
"2f02017714f54089652e02af36ac5165e44ac4a83747c805a9e003fde4bdb29561dcead2"
"c76b02c195074396a2dcc1b93a256c721716f8eeda8dae443c3eea446118fec3cebc4dc"},
{NID_sect571r1, NID_sha512,
"a9cff41c6dfdc4a12f31dc375a5455950077ae323d0b7a3d9a8dde73b76e9d7b94ddf9c8"
"8ae8e6c262d704052ac47681fc35adfc56c904baaa6e146eb653984369d76a85596cb744"
"941aa7b558c945ff2e81bd5ef7f00ecb4f43af23b4cea3bd4ba7b1899f1868a0c0ecfc62"
"ccb1d588955597ffbbaf34cab2838efc2b866669",
"2c36ef754b5bd065e9eadde684750acc52795be80f54dd3d7a7d743d968a18f7e404bd71"
"f8a76eb0395f396df5a7c2ff7e0ab6de35df34282fda6ee01fe5b9b68ecb4e378dbe32e",
"0404805e1a23b6eadcf91647b40903bc1fd3b9921861c942fc24d2c03d0544e7c01f004c"
"aeed04b5c4ebbce366a098a878c322cbebe7910bfb0f91b284ac1aef344152fc5831669b"
"7904f589ddb4da482ba1e9a59241b1dfbc7e9b9b69e8f69f8e90460ad58fdecc48a56842"
"ea6aa0537abec0a605ebfb713e588685a98f62e05a7d52082bfd57e3d68fb7851b37ec55"
"67",
"2f2002bdde0c0b0fd92e96abe76c0858e42fd7d94a181c711fc6753572539e18effa8155"
"cde7b1e9ceab2394f9eba874b7ea257d7c308c8ac08500f4944af5f33057650608db8fe",
"27f9109799bced42730faecdeea68259383a45033c6d5dc8d87adf994b46beb34177e013"
"700b13f1253cf756a8866218e9c8adc180f3c242c56b3de28405b36940d53c2aab24f1a",
"20a762ffb2f5a88b0e1356964fb558b555c424946109d16c7548f41a33cfe41da1f48327"
"6a27b188faf948a56670716ddf3b187570c9f514869c4492d7773d6ce453a075f9bc64f"},
{NID_sect571r1, NID_sha512,
"efa6c582d7fcf5e431aa89b3b00180c0e78efd7ccb0384d90b80e59a115a13e55001d951"
"528c42860132531c9b8ab29dda7a657c53c2ce96fd85549f6f1810e121eb89961295335e"
"aa0e40532d85814a4206e6fffdf9bff76599da9b2e71a22ed572910b0e3bae38ad72c704"
"2579f106739a8628dea5a745168bd918736e488a",
"19ffee50be5496507e3ef5c40ee88a49625e46d1dd1686a52b09ad4a8e3ee9ef364f953b"
"fcd97c52104eecb6138067192997cd4ebadaccb73c7b2560879289a46353a756b73cc43",
"04077dca410e722009ef11b37742c2c003ab3015d0ca0328a70d9d41aae04cb64f7746f1"
"c348b08458eb3bb1788f9ffe7d0570a9b689a9b7aca43e05400bace7630d598f5b484d13"
"c407291f74cddd9ff69470cf0d92afaaddcc4c8c274d4a7a64fd94292ddc8bf080606795"
"376bb725ab4d32c72ef77dff34cfedd34aff2f463d635bfcd7e1fd002d84383dc5bf8d5d"
"23",
"2ea37750fc3bbdeec100694068d55f92fdf35bff9ed49251c4b8bbfb2dec2dd4446999af"
"8848e05c7b819aeb1864430ab4e8c1d684e1cf78947a71b04d5ab8ad61cc7e3e4e24205",
"12ff1852eaff37fee997531039adb1fb2f9b4f4199670c022e8534625fff1fa93390ee9b"
"c7204ad2ba3efc2233260943f1d2381a3cc025b78c6d1f660a7bd6f42e5ed3c123055a9",
"1b4d8abb28ef1a9d77066921ed50eba64b8433cf00c66b8467269a4a914f568cdb86c766"
"a7a6a52437c5d98cfc9a2130dfaba20f3c2001f31bba7071647d51fb9fbd5fc67ee120f"},
{NID_sect571r1, NID_sha512,
"211acebfaf13bba33a9dd16722ec53baab92a140127d61372cbf1850f2fc894e942e25d7"
"80778235f880743953d04eca7a9205602e388172aec2abf35412b483490751f93b51239b"
"6701cb0aab14e5179b0d7f55d8586358381dd83e3e436bf69a6820317d1701750cb1fea1"
"293467ba589eec5f5779c2dbf2a9b8f28c4dc239",
"3129e96fd28c4198cc5242c1e3531a3979fae643d527044e98d7721aa56b5b4b45dfddfa"
"17a4115e10a2b4f46d92f81cbdd7e86e588a4c6d8c2b3a83f54cebcee1d1dd33e85d81a",
"04073a92abcc991e3f89d82c47fa0fec48e3e7c4d97e2525f8dc2d24da39f616af4a5a80"
"4d2603703f6db7cc9324c5b56a21009373f6605f561c8503394e7746e51273b5722ffbc2"
"3d00684c842f03a53a60cce087f4fcdbf23b7a28c48b6b6544f583342a65d97dd87037c6"
"fef176a1f00513713468273494a5be683b68c5e75bc08995fde763bb6f965da1acb7e894"
"f1",
"0165e52640fcaf8cbdbfe73cb8058c53045e7670aafb2def28d2c9eceb5ed1634b5339cc"
"47ba981eb6eb03ba714c7717e9ed5acc15c8f304702a0409bd4508015d4626cfc5484b1",
"27dcdf16b7156a7a05a752da28b5bd6b233e8a7c16eb7f9030f29c4352e6508f8424d1b5"
"ba789dac4152ac4812ff7975cce69908371a81a4d7d9dd70a8dabebdc4e3af27234f0d0",
"32a654a31f09a9803e502a1440c2bcf122780f4f47aa37e15991d9a548583fdca4880080"
"4712816b212cd3c657e6bd4cb7443a0288592541473c5086e1277250612c21346538374"},
{NID_sect571r1, NID_sha512,
"ee592e20e0a45c18089c2e41460e65a7d22ed9714379f095d43a308bdd383128aaa6fb24"
"e9d35fd28fc95c5b792ad75c980d2cdf0f460ac60b12c5919d3cb28dac4d488196be6c2d"
"fe462b1b0ce59f8501692255840f5215c0fd8b74b1996a267a5e3b22d2841cf0a0b6315e"
"f4ec7180f1c8494f4c07d5869c01fa2711739efc",
"3d723d2697cd07dd8444f992f2ab4a063db334034c25ea9be99fd7a1f495e3a644e5ea03"
"3a41264e0d24a911e55741d0cab80a0bd678eaec2bd1e60424d4491eb86d664900d907e",
"0400c7a229b5fb9fc774c1b6250f3bba2f0972d1aada7080641c014d012db0637a0656a4"
"3024ec0ea25ff70012646dc19eeb1033aebcc96a001ba876b2f5def6e198b8d4a53f7c7f"
"4a009228a68eafaac214fdfa19923a0c19629de31ac0967c9d02c53dbf221f9affb735d3"
"bad732f381f1ca414d70920231a78f742254d895a33ffab492f8e6094a542e77962a324b"
"a4",
"3b3724a5933353bb9ff5f742f59385e780caa517a963590b7fc89882bed95cf90ca6365c"
"e8b882f2d96e56bd866a5c437733b681308c570c51ec893ea95fede66c7aaf4561173f7",
"2a487c1fc29426e8e85f0a35c177cd168a444959b2f5cd4519b9edd52af3ea829cfe964a"
"c2b59198af8e2d3859ebdf9885ebf57bdf5767da1611d3958de286f91ef397230d65599",
"10fc01efcb22b982f992efb71887bc79c3f32a9088bc2011c269924cee0f47c36452399d"
"499f2933587081b872e9fd2191c20cd5cd94927839228ebcf22cf7acdf4608a2fa66310"},
{NID_sect571r1, NID_sha512,
"fffca41927debbd53455821441d9115db99fb31bfc69752a382f57bc7abe021f148346ee"
"29e17512c64b4918ab2391d12d6e5643bee6b5682885dc28177b292e23a37ff99b359b9c"
"f7578432af56e0ad1028a6cce7428980654c145af8daf09addbb3be11228d3c742defca9"
"d3b1667f48c63091fe3307ecf72667b02e008f24",
"1999ab45d66cd1d3a0fe6aa43bf5ef1e2a67637d53674f6fbbfb9b582be91fc42a12cdca"
"d94b50b0fc7ac55030de24a0b99fbc4314fa743ef4b5198bcc5f54d8b669fbed78e2e91",
"0400cbf3b0bb4a2e6c225aa922bea3b233da4661df5da7e0a1cd343a9b6655ee87fc60cd"
"763dee21eaa2b81c4dd5af6f4fadc3ceea643b37a6b17a6501e1b9b689fb0c4716911c1f"
"10014b5a9ae025f09066fffa6797ddf95f27eeade06b8ca5be5738f770362d5213c46ecf"
"ca58e3c60cb2bae1f8ab1bf0577c80b4fdad02819fc174cafb33df64fc0ec79713f7b252"
"09",
"253b533d3ad1c7095363e3fc80cb32471061e44dab3f9ae0ea6252f6ef169cee8badd3ec"
"cb77096ae9224f89baeee7e183058579680661655fb689419e36a61e8573de5ecb4cd09",
"3ba94f7682fb61de725a35caf1d4d799c4b05a1d1c44eb1c251dd8efab6b7d713c3fb917"
"776902a1bb202f9226558f4c1e75964349717e6dff938d0befea07a9ca1bbd429dd6318",
"226f43be8e24062180c726b5cb721cc04ffd3acd82183925523ff9e8631aecbec2c224d5"
"a291bb225f0da726d256aa822ee7cc2c7d69df3f2a5beb21132d91bea22e4c5db900cec"},
{NID_sect571r1, NID_sha512,
"a2f71619ea04f7057e6943c2cece8594b341ec3b96c3915d924f94ba13fd7aaeed41ffa0"
"e842ade414784f1ef825fcf2dbcf7bd8263b802def45f94de596aec0c121fc06558c7bb0"
"6b9f27a9bf56c42090b5dc344e82b69c4f528d33be166764a593483f6fda0cf56e6000ff"
"363ba220f5ea0ea2c3191615c7ae3bb4fa575324",
"2ce1cae0716205330d730e6bc6dbfb6b951dc83ee3b4a7dae75d057e32e8a46e22be75b5"
"f09135452b29c34dfe81a9be2e8dcd243fbd946a0ed14a832a7802e20cfe1abfd3d6e4b",
"04075971399fa621ce535144ec1d57f544d798a0a59207166c3d657e5a80ac00e8f5b643"
"448e3546064d68ae624aaabf36face3016561a248256ff9131950ab8b04710551e12222d"
"0c0224a50f321647f47de3db4fbe1bf1e3a3dce8a834312779f66037315e3326721e3fd6"
"3d4d6ef92b7ba1fa9aeb70f92e2a6701458ac8da49ac386491f2306adcd8dd781fe75e99"
"e1",
"0ad95aa69cf9f40e13f8a72ed6d93388168abc8001670ee4d95fb4b726b1f958205ab2f4"
"58df8bb9ccf2405680d0e6951abbb922cc11d47cfded93c0efdb70caf0c54e7ae96d7e5",
"09ce019161bf29eeaf323933045f59d2efc372904ba50c4a6602b8305234a851d95f06a5"
"b56193ad5d28488102ec25e3f421a5f5c4626b435b423d612e6ab60e0a4fe5d4952e2c5",
"04f7b7ac787b361c2bdfa767da9c22152e402184a7ac133f651fdcd928239215dc917401"
"122a6d41e78299b4235e085399e594465b7f8dbfaae9bf302d83470b4295ea06bb9bd1e"},
{NID_sect571r1, NID_sha512,
"b60415a831eca2cf60c79a334ef2f327a76d290846ee588d5d33d0a826bb0c7ec3e11dbb"
"384a7f89c8d180425dfae7463e0ea6497d2eec1dde112f1c1efccb532a2e2b66a28e2d36"
"d4252a4c3b12850d465fe21bddc441b92e6a7b0f67744f7f6e7812a0603211a26518b311"
"a5b190ed890ad852bed4f6ed13377cab3eebedf4",
"2c9d0fcfcee7e75c3245ba955ae04188b1033c55ec9c821d8de7685276bda3e9a93c3ae1"
"b003e5ea722913e7b169d67b1aa2dc8cd42adbd9368672a3f81a6817bf3e5529dcb0c8b",
"04019cba4c8ddadb596d7303331f2a22461849ebfbc78ea69277f72dcfe23d08397025ff"
"6691c61ed9958d68a9c5dd8a32048a89a2553afb9077ec43358763756b1473ab2cd8f25b"
"530319eeaa78444b7cc5d8cff4e9199ddd2c6dc7bd935a1be1d8b1c657dd5ac49bc92b0c"
"d91304ef44ddb7ecac05518301bfa0e533402043533f99549621e31dcc282a52186478df"
"2b",
"385e12170ed0b23c9c65ff7edd413145fd343dd841e85c498fae5f36e577641688999028"
"17d4dc39127010faa1da68000a511ac69f80708be5afe1631432f3bab7aaec2bdeb11b4",
"231ef400c6a3a0c7b26ba1b92341b72e138ca62d04ea2172854631c40c48081a18a57e9f"
"055748245d3e83d10d21af39935b0e50c9c86956ac46c1ea03ac4ae023d84b24f830973",
"24d37d67afafb0676cd7b5da2960cabfc804b0b3244b5e6739f8fe43d0841693d28c61b8"
"e76181f8aa24940d76fc5ea8ef3a95f72f67303e1ed85ad6e83cd2c44fd0e0f3f2f44f4"},
{NID_sect571r1, NID_sha512,
"5d15a08226cc74cf495be681b795d0bde26b19f29aca1a8c6ef77d50271ebdcb4e5fa2df"
"23961fe11620b1c6580183f6ebdceb2c09516c8127be576496fb71449bbbf0a9d3d1c48a"
"25024619b97c3e0d8b165897db96ae9758d13ac28441d7cbfb75b23cb423e0002046358b"
"b6d64779974a5995dfe54b398f95f7d64fc52d96",
"10c057bbaa44ef0f565edc288bfe66d4f6acd8686899359bca418ba89fb690429489a37b"
"d3c6c9f3a8714b2ca225868c6a45fee360e378a676f7ea39321790f32a4b005b81dce43",
"04043b1e7d7b2aee3563813a6692f0b4b61ba82b801697c3e23724a2fbab2af80a2c56be"
"55af41def0a90cbfce7a45ec61629906055a8b2a5013740e96859e580c444ae9f0ddf73a"
"fe06742f13244f1bf156d321eab2c3095ca548c3182c405187c3de2fbcb01d0e16e1fef2"
"46012c87d4d32378629a75b694572ec8583ae0cc813ac64f10bb05a9e52e4805590482f2"
"89",
"2b8076102a6448bd4c4e192e93cdb96ea9a6c7f6753818267ee9e67644df1a4a6c9ff64b"
"be9f64904648cc640fb7f0cce69f9e02878ee950b91ad559a9ec0ae15b676d933f1620f",
"1ad97f4997037adfe306f3859d550f9fd89bce8b566e657d5742feb17466b6b8d507d581"
"0a8cbba44d671b043ddb557df084bf5d1de74ef8bbd6a93690459fc16a17b80dd6c0f28",
"3262ef6e4175e7afe095d18157f67b3d12564d54954e9964e991c31bcfe1dee7e86b3549"
"1ce818400cc0f83b819f478f2f2c2d21c6c7a6be43938841559e09bce70b0d61fe51245"},
{NID_sect571r1, NID_sha512,
"9eca4bd88200baf61b901fca53dc1f1e7e3f83b94d58a6cc6a2adbc9b1a35fe3f8ec6178"
"7c76ed9a0d696167cd4fe46e1a0883fda564666131753c576a720125e0b712db1da02780"
"67cb899bdb14eec08737e864544663abb1d62f34a2114be07e8e3cf56e2d17099299ce6b"
"6d83b1a34e6153d7c6a32a72c7b1bf4583fcbcf7",
"2c182df7976ea93d996f3ba5d2221f3cb755cc7847bc3fe9e022fa4285046f5bfb426baf"
"a3580beea206de36f87593ae561b4b74a03fcd61fbd0e8d6fd5668f2148819a88a650aa",
"0406004b26a184ed710a5fb67e9d042f7fb9c8f5584b1f70a91b0b3be41c3fd2cd1a537e"
"962fdac8756df33f80fce2bb1bc7241d325bfc36dbaef7cf625918d589b6352fa7447189"
"10036a29b04a494abfe809d956c3cd6f84ea51a7fa28cb39a52f16137a13f72f0726a84f"
"6ae53ae24f5b468733f4cbfa0ce5bbbc1cc7b348fb996d33a45ff656a6a7557619f598a6"
"b7",
"2ab349232bcb4f4816b26bd0049e130fffc90ca0b9308edd50fb9055358a87fe798d0014"
"0b0ae01ed8b1f6bb9bfb726b253c3d4949ce9eecaa6c7fa84d1ef812669fa929f26be0f",
"0bbf2f9765b12742224ba7d064358c0305fb63e9b54a831e302a4546aa02cace798d82a1"
"88d2f536d78544c1571f481289d6ec69d117648026490e781f1eb9fca59bee05234ba7e",
"27e07ee0a1a99c90753cdc8c0291da25a82c116e62ec58b93f91086ac1cc039b35ce7d8b"
"53cdaa92a5ade65a7684b6e7ab79873dce33dcd467c39d0c764ee390b7fb25ca18912c3"},
{NID_sect571r1, NID_sha512,
"707450bd84141f3b61beb12ffa5ae89d812dd11badcdf6a88a2d50fc70e23f6d822ff447"
"7047abc58cdfa28f97ad7f4911ae0773c04ebed1f51bb2308cf6e5712c4aaed461edd698"
"7fdd1796aab70198276b601241f6a14225dce575830ff60f935fd9f567d1d210652e4710"
"922fa793da78c8fdc30c273cb08365c9fc887f50",
"2d3a65bbe133cc98cf0eb56ee1362195968b4eab960a1d55d8b762f1361fc21348d6f275"
"d4bea1de7158fb97c995e20b92a9c887a3e332d154667ad167acc632eb88a0ead6113a2",
"04034355b54d00c3df7c2762ee2982cb777491aaf78e550c4d2ff5d5a893416eb3517671"
"dbe522b8c553fd71edfe0306cd7628324f4f748091fc5d84ad8af33b896985674649a6f4"
"e507e322a04eb600a3faf3e045959f1e9f798e1c965ced40fd4c0383c0d4e79a96bf693a"
"91d7662780990d0c9dfca77a9bc0e13551d2ab35af8a153fa34ea903961fe66996ca053b"
"64",
"0a59ac1240bcefc52456486ce23b780cc92c8b89314b8442a6898c373bd0adc3725e3eba"
"c580546d1ec82ebfb2e04c608441d962d759ab5f5af1596c6623487e1347537a3c35bf4",
"0c47ef55d93ac36cee537160bbe39c3d4504184188533edfe589a5ab6e5a3e06ef413aa4"
"8710d304f0b2bc380fd69a34aa0b8e2e9466fd8a131cb056dffe4b809a59fd83e594483",
"2d8de1e8e2a52dd1be08435cda69e673b328573edeb1767849536e6f2d5fc8f18f7bfde9"
"36d8c32ecbfa97bf976133d65641320ca1c41e81c388fd6088884bbd89274b1976470fc"},
{NID_sect571r1, NID_sha512,
"d5ce9d59391cdc47ef942dd2a818d024ae3917deea8a5a4214e4db6a0c5e6b0936f3e632"
"fdb68a3f0006e05c44b7232013e1da5f877cd197f44fd6f60c1fd2378995e9a47534948c"
"5a09e33750f07a7165072ab38095373b07a50bc1391eb6b650ee13acd63d0352e7d9c316"
"95ea1ec6323f9b5f57b426ace56aa7fdbf419be0",
"2a920e8dc928acdd56e3655b2340d4371c793e66f67405fb7a90f31e9c4ef466cc44331d"
"1d2fe3ff7391d2576dc6640772166ef8c154a5ff1808f5dab2f03061070ec8b3f786c36",
"0405edc0fb974314e21ad40d73524d5620b7279084e3ecb9e58b06340ae53d2383efd206"
"b8b1eb3dd60c38f593efc05e2ba5fb8989472bac7db60fcada2d18d4108ab36e8c20cc71"
"0d00444cf65175f6bbaf647739cfd8407e7036fc6cc6208ccb9d776eb13e13b377136c68"
"3e108775d85b6bc5638926432a17344de965d45e042a0a8e0b63c7fc3a36fc15cf718f3b"
"af",
"35a0215892d0c52ece29559ebfa061011da8d597af6b3d1ee988ea4819be194c79a42681"
"476140738b1b5dc191485bd20c96c282ab38ddbc3987343155366b6a5d1ce7053efcd83",
"1a69a9a51f6b0dc196b2a8db2e8bf61764d4c65b038f43b5ed6b5dc2673971c32928606f"
"92b7caafb4dab3cd61ee724bba71a0d5c788cde4b96ef6b453f2a69126dafc20dbc7c82",
"13b5463636b8462cd9f479de8d114e29e7011489bcb9735ffe9ca0707a07df3c0aba0504"
"3eab387bfedd9fe982fbf04968f2be200e9e052cb4b02223b8579913d713acf94e7dc80"},
/* binary KATs from X9.62 */
{NID_X9_62_c2tnb191v1, NID_sha1,
"616263", /* "abc" */
"340562e1dda332f9d2aec168249b5696ee39d0ed4d03760f",
"045de37e756bd55d72e3768cb396ffeb962614dea4ce28a2e755c0e0e02f5fb132caf416"
"ef85b229bbb8e1352003125ba1",
"3eeace72b4919d991738d521879f787cb590aff8189d2b69",
"038e5a11fb55e4c65471dcd4998452b1e02d8af7099bb930",
"0c9a08c34468c244b4e5d6b21b3c68362807416020328b6e"},
{NID_X9_62_c2tnb239v1, NID_sha1,
"616263", /* "abc" */
"151a30a6d843db3b25063c5108255cc4448ec0f4d426d4ec884502229c96",
"045894609ccecf9a92533f630de713a958e96c97ccb8f5abb5a688a238deed6dc2d9d0c9"
"4ebfb7d526ba6a61764175b99cb6011e2047f9f067293f57f5",
"18d114bdf47e2913463e50375dc92784a14934a124f83d28caf97c5d8aab",
"03210d71ef6c10157c0d1053dff93e8b085f1e9bc22401f7a24798a63c00",
"1c8c4343a8ecbf7c4d4e48f7d76d5658bc027c77086ec8b10097deb307d6"}
# endif /* OPENSSL_NO_EC2M */
};
#endif /* OSSL_TEST_ECDSATEST_H */
|
./openssl/test/evp_pkey_ctx_new_from_name.c | #include <stdio.h>
#include <openssl/ec.h>
#include <openssl/evp.h>
#include <openssl/err.h>
int main(int argc, char *argv[])
{
EVP_PKEY_CTX *pctx = NULL;
pctx = EVP_PKEY_CTX_new_from_name(NULL, "NO_SUCH_ALGORITHM", NULL);
EVP_PKEY_CTX_free(pctx);
return 0;
}
|
./openssl/test/stack_test.c | /*
* Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2017, Oracle and/or its affiliates. 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 <string.h>
#include <openssl/opensslconf.h>
#include <openssl/safestack.h>
#include <openssl/err.h>
#include <openssl/crypto.h>
#include "internal/nelem.h"
#include "testutil.h"
/* The macros below generate unused functions which error out one of the clang
* builds. We disable this check here.
*/
#ifdef __clang__
#pragma clang diagnostic ignored "-Wunused-function"
#endif
typedef struct {
int n;
char c;
} SS;
typedef union {
int n;
char c;
} SU;
DEFINE_SPECIAL_STACK_OF(sint, int)
DEFINE_SPECIAL_STACK_OF_CONST(uchar, unsigned char)
DEFINE_STACK_OF(SS)
DEFINE_STACK_OF_CONST(SU)
static int int_compare(const int *const *a, const int *const *b)
{
if (**a < **b)
return -1;
if (**a > **b)
return 1;
return 0;
}
static int test_int_stack(int reserve)
{
static int v[] = { 1, 2, -4, 16, 999, 1, -173, 1, 9 };
static int notpresent = -1;
const int n = OSSL_NELEM(v);
static struct {
int value;
int unsorted;
int sorted;
int ex;
} finds[] = {
{ 2, 1, 5, 5 },
{ 9, 7, 6, 6 },
{ -173, 5, 0, 0 },
{ 999, 3, 8, 8 },
{ 0, -1, -1, 1 }
};
const int n_finds = OSSL_NELEM(finds);
static struct {
int value;
int ex;
} exfinds[] = {
{ 3, 5 },
{ 1000, 8 },
{ 20, 8 },
{ -999, 0 },
{ -5, 0 },
{ 8, 5 }
};
const int n_exfinds = OSSL_NELEM(exfinds);
STACK_OF(sint) *s = sk_sint_new_null();
int i;
int testresult = 0;
if (!TEST_ptr(s)
|| (reserve > 0 && !TEST_true(sk_sint_reserve(s, 5 * reserve))))
goto end;
/* Check push and num */
for (i = 0; i < n; i++) {
if (!TEST_int_eq(sk_sint_num(s), i)) {
TEST_info("int stack size %d", i);
goto end;
}
sk_sint_push(s, v + i);
}
if (!TEST_int_eq(sk_sint_num(s), n))
goto end;
/* check the values */
for (i = 0; i < n; i++)
if (!TEST_ptr_eq(sk_sint_value(s, i), v + i)) {
TEST_info("int value %d", i);
goto end;
}
/* find unsorted -- the pointers are compared */
for (i = 0; i < n_finds; i++) {
int *val = (finds[i].unsorted == -1) ? ¬present
: v + finds[i].unsorted;
if (!TEST_int_eq(sk_sint_find(s, val), finds[i].unsorted)) {
TEST_info("int unsorted find %d", i);
goto end;
}
}
/* find_ex unsorted */
for (i = 0; i < n_finds; i++) {
int *val = (finds[i].unsorted == -1) ? ¬present
: v + finds[i].unsorted;
if (!TEST_int_eq(sk_sint_find_ex(s, val), finds[i].unsorted)) {
TEST_info("int unsorted find_ex %d", i);
goto end;
}
}
/* sorting */
if (!TEST_false(sk_sint_is_sorted(s)))
goto end;
(void)sk_sint_set_cmp_func(s, &int_compare);
sk_sint_sort(s);
if (!TEST_true(sk_sint_is_sorted(s)))
goto end;
/* find sorted -- the value is matched so we don't need to locate it */
for (i = 0; i < n_finds; i++)
if (!TEST_int_eq(sk_sint_find(s, &finds[i].value), finds[i].sorted)) {
TEST_info("int sorted find %d", i);
goto end;
}
/* find_ex sorted */
for (i = 0; i < n_finds; i++)
if (!TEST_int_eq(sk_sint_find_ex(s, &finds[i].value), finds[i].ex)) {
TEST_info("int sorted find_ex present %d", i);
goto end;
}
for (i = 0; i < n_exfinds; i++)
if (!TEST_int_eq(sk_sint_find_ex(s, &exfinds[i].value), exfinds[i].ex)) {
TEST_info("int sorted find_ex absent %d", i);
goto end;
}
/* shift */
if (!TEST_ptr_eq(sk_sint_shift(s), v + 6))
goto end;
testresult = 1;
end:
sk_sint_free(s);
return testresult;
}
static int uchar_compare(const unsigned char *const *a,
const unsigned char *const *b)
{
return **a - (signed int)**b;
}
static int test_uchar_stack(int reserve)
{
static const unsigned char v[] = { 1, 3, 7, 5, 255, 0 };
const int n = OSSL_NELEM(v);
STACK_OF(uchar) *s = sk_uchar_new(&uchar_compare), *r = NULL;
int i;
int testresult = 0;
if (!TEST_ptr(s)
|| (reserve > 0 && !TEST_true(sk_uchar_reserve(s, 5 * reserve))))
goto end;
/* unshift and num */
for (i = 0; i < n; i++) {
if (!TEST_int_eq(sk_uchar_num(s), i)) {
TEST_info("uchar stack size %d", i);
goto end;
}
sk_uchar_unshift(s, v + i);
}
if (!TEST_int_eq(sk_uchar_num(s), n))
goto end;
/* dup */
r = sk_uchar_dup(NULL);
if (sk_uchar_num(r) != 0)
goto end;
sk_uchar_free(r);
r = sk_uchar_dup(s);
if (!TEST_int_eq(sk_uchar_num(r), n))
goto end;
sk_uchar_sort(r);
/* pop */
for (i = 0; i < n; i++)
if (!TEST_ptr_eq(sk_uchar_pop(s), v + i)) {
TEST_info("uchar pop %d", i);
goto end;
}
/* free -- we rely on the debug malloc to detect leakage here */
sk_uchar_free(s);
s = NULL;
/* dup again */
if (!TEST_int_eq(sk_uchar_num(r), n))
goto end;
/* zero */
sk_uchar_zero(r);
if (!TEST_int_eq(sk_uchar_num(r), 0))
goto end;
/* insert */
sk_uchar_insert(r, v, 0);
sk_uchar_insert(r, v + 2, -1);
sk_uchar_insert(r, v + 1, 1);
for (i = 0; i < 3; i++)
if (!TEST_ptr_eq(sk_uchar_value(r, i), v + i)) {
TEST_info("uchar insert %d", i);
goto end;
}
/* delete */
if (!TEST_ptr_null(sk_uchar_delete(r, 12)))
goto end;
if (!TEST_ptr_eq(sk_uchar_delete(r, 1), v + 1))
goto end;
/* set */
(void)sk_uchar_set(r, 1, v + 1);
for (i = 0; i < 2; i++)
if (!TEST_ptr_eq(sk_uchar_value(r, i), v + i)) {
TEST_info("uchar set %d", i);
goto end;
}
testresult = 1;
end:
sk_uchar_free(r);
sk_uchar_free(s);
return testresult;
}
static SS *SS_copy(const SS *p)
{
SS *q = OPENSSL_malloc(sizeof(*q));
if (q != NULL)
memcpy(q, p, sizeof(*q));
return q;
}
static void SS_free(SS *p) {
OPENSSL_free(p);
}
static int test_SS_stack(void)
{
STACK_OF(SS) *s = sk_SS_new_null();
STACK_OF(SS) *r = NULL;
SS *v[10], *p;
const int n = OSSL_NELEM(v);
int i;
int testresult = 0;
/* allocate and push */
for (i = 0; i < n; i++) {
v[i] = OPENSSL_malloc(sizeof(*v[i]));
if (!TEST_ptr(v[i]))
goto end;
v[i]->n = i;
v[i]->c = 'A' + i;
if (!TEST_int_eq(sk_SS_num(s), i)) {
TEST_info("SS stack size %d", i);
goto end;
}
sk_SS_push(s, v[i]);
}
if (!TEST_int_eq(sk_SS_num(s), n))
goto end;
/* deepcopy */
r = sk_SS_deep_copy(NULL, &SS_copy, &SS_free);
if (sk_SS_num(r) != 0)
goto end;
sk_SS_free(r);
r = sk_SS_deep_copy(s, &SS_copy, &SS_free);
if (!TEST_ptr(r))
goto end;
for (i = 0; i < n; i++) {
p = sk_SS_value(r, i);
if (!TEST_ptr_ne(p, v[i])) {
TEST_info("SS deepcopy non-copy %d", i);
goto end;
}
if (!TEST_int_eq(p->n, v[i]->n)) {
TEST_info("test SS deepcopy int %d", i);
goto end;
}
if (!TEST_char_eq(p->c, v[i]->c)) {
TEST_info("SS deepcopy char %d", i);
goto end;
}
}
/* pop_free - we rely on the malloc debug to catch the leak */
sk_SS_pop_free(r, &SS_free);
r = NULL;
/* delete_ptr */
p = sk_SS_delete_ptr(s, v[3]);
if (!TEST_ptr(p))
goto end;
SS_free(p);
if (!TEST_int_eq(sk_SS_num(s), n - 1))
goto end;
for (i = 0; i < n-1; i++)
if (!TEST_ptr_eq(sk_SS_value(s, i), v[i<3 ? i : 1+i])) {
TEST_info("SS delete ptr item %d", i);
goto end;
}
testresult = 1;
end:
sk_SS_pop_free(r, &SS_free);
sk_SS_pop_free(s, &SS_free);
return testresult;
}
static int test_SU_stack(void)
{
STACK_OF(SU) *s = sk_SU_new_null();
SU v[10];
const int n = OSSL_NELEM(v);
int i;
int testresult = 0;
/* allocate and push */
for (i = 0; i < n; i++) {
if ((i & 1) == 0)
v[i].n = i;
else
v[i].c = 'A' + i;
if (!TEST_int_eq(sk_SU_num(s), i)) {
TEST_info("SU stack size %d", i);
goto end;
}
sk_SU_push(s, v + i);
}
if (!TEST_int_eq(sk_SU_num(s), n))
goto end;
/* check the pointers are correct */
for (i = 0; i < n; i++)
if (!TEST_ptr_eq(sk_SU_value(s, i), v + i)) {
TEST_info("SU pointer check %d", i);
goto end;
}
testresult = 1;
end:
sk_SU_free(s);
return testresult;
}
int setup_tests(void)
{
ADD_ALL_TESTS(test_int_stack, 4);
ADD_ALL_TESTS(test_uchar_stack, 4);
ADD_TEST(test_SS_stack);
ADD_TEST(test_SU_stack);
return 1;
}
|
./openssl/test/quic_lcidm_test.c | /*
* Copyright 2023 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 "internal/quic_lcidm.h"
#include "testutil.h"
static char ptrs[8];
static const QUIC_CONN_ID cid8_1 = { 8, { 1 } };
static const QUIC_CONN_ID cid8_2 = { 8, { 2 } };
static const QUIC_CONN_ID cid8_3 = { 8, { 3 } };
static const QUIC_CONN_ID cid8_4 = { 8, { 4 } };
static const QUIC_CONN_ID cid8_5 = { 8, { 5 } };
static int test_lcidm(void)
{
int testresult = 0;
QUIC_LCIDM *lcidm;
size_t lcid_len = 10; /* != ODCID len */
QUIC_CONN_ID lcid_1, lcid_dummy, lcid_init = {0};
OSSL_QUIC_FRAME_NEW_CONN_ID ncid_frame_1, ncid_frame_2, ncid_frame_3;
void *opaque = NULL;
uint64_t seq_num = UINT64_MAX;
int did_retire = 0;
if (!TEST_ptr(lcidm = ossl_quic_lcidm_new(NULL, lcid_len)))
goto err;
if (!TEST_size_t_eq(ossl_quic_lcidm_get_lcid_len(lcidm), lcid_len))
goto err;
if (!TEST_true(ossl_quic_lcidm_enrol_odcid(lcidm, ptrs + 0, &cid8_1))
|| !TEST_false(ossl_quic_lcidm_enrol_odcid(lcidm, ptrs + 0, &cid8_2))
|| !TEST_false(ossl_quic_lcidm_enrol_odcid(lcidm, ptrs + 1, &cid8_1))
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 1), 0)
|| !TEST_true(ossl_quic_lcidm_enrol_odcid(lcidm, ptrs + 1, &cid8_3))
|| !TEST_false(ossl_quic_lcidm_enrol_odcid(lcidm, ptrs + 1, &cid8_4))
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 0), 1)
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 1), 1)
|| !TEST_true(ossl_quic_lcidm_retire_odcid(lcidm, ptrs + 0))
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 0), 0)
|| !TEST_false(ossl_quic_lcidm_enrol_odcid(lcidm, ptrs + 0, &cid8_1))
|| !TEST_false(ossl_quic_lcidm_enrol_odcid(lcidm, ptrs + 0, &cid8_5))
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 0), 0)
|| !TEST_true(ossl_quic_lcidm_generate_initial(lcidm, ptrs + 2, &lcid_1))
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 2), 1)
|| !TEST_false(ossl_quic_lcidm_generate_initial(lcidm, ptrs + 2, &lcid_init))
|| !TEST_true(ossl_quic_lcidm_generate(lcidm, ptrs + 2, &ncid_frame_1))
|| !TEST_true(ossl_quic_lcidm_generate(lcidm, ptrs + 2, &ncid_frame_2))
|| !TEST_true(ossl_quic_lcidm_generate(lcidm, ptrs + 2, &ncid_frame_3))
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 2), 4)
|| !TEST_true(ossl_quic_lcidm_lookup(lcidm, &lcid_1, &seq_num, &opaque))
|| !TEST_ptr_eq(opaque, ptrs + 2)
|| !TEST_uint64_t_eq(seq_num, 0)
|| !TEST_true(ossl_quic_lcidm_lookup(lcidm, &ncid_frame_1.conn_id,
&seq_num, &opaque))
|| !TEST_ptr_eq(opaque, ptrs + 2)
|| !TEST_uint64_t_eq(seq_num, 1)
|| !TEST_true(ossl_quic_lcidm_lookup(lcidm, &ncid_frame_2.conn_id,
&seq_num, &opaque))
|| !TEST_ptr_eq(opaque, ptrs + 2)
|| !TEST_uint64_t_eq(seq_num, 2)
|| !TEST_true(ossl_quic_lcidm_lookup(lcidm, &ncid_frame_3.conn_id,
&seq_num, &opaque))
|| !TEST_ptr_eq(opaque, ptrs + 2)
|| !TEST_uint64_t_eq(seq_num, 3)
|| !TEST_true(ossl_quic_lcidm_retire(lcidm, ptrs + 2, 2, NULL,
&lcid_dummy, &seq_num, &did_retire))
|| !TEST_true(did_retire)
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 2), 3)
|| !TEST_true(ossl_quic_lcidm_retire(lcidm, ptrs + 2, 2, NULL,
&lcid_dummy, &seq_num, &did_retire))
|| !TEST_true(did_retire)
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 2), 2)
|| !TEST_true(ossl_quic_lcidm_retire(lcidm, ptrs + 2, 2, NULL,
&lcid_dummy, &seq_num, &did_retire))
|| !TEST_false(did_retire)
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 2), 2)
|| !TEST_false(ossl_quic_lcidm_lookup(lcidm, &lcid_init,
&seq_num, &opaque))
|| !TEST_false(ossl_quic_lcidm_lookup(lcidm, &ncid_frame_1.conn_id,
&seq_num, &opaque))
|| !TEST_true(ossl_quic_lcidm_lookup(lcidm, &ncid_frame_2.conn_id,
&seq_num, &opaque))
|| !TEST_true(ossl_quic_lcidm_cull(lcidm, ptrs + 2))
|| !TEST_size_t_eq(ossl_quic_lcidm_get_num_active_lcid(lcidm, ptrs + 2), 0))
goto err;
testresult = 1;
err:
ossl_quic_lcidm_free(lcidm);
return testresult;
}
int setup_tests(void)
{
ADD_TEST(test_lcidm);
return 1;
}
|
./openssl/test/provider_pkey_test.c | /*
* Copyright 2021-2023 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 <stddef.h>
#include <string.h>
#include <openssl/provider.h>
#include <openssl/params.h>
#include <openssl/core_names.h>
#include <openssl/evp.h>
#include <openssl/store.h>
#include <openssl/ui.h>
#include "testutil.h"
#include "fake_rsaprov.h"
static OSSL_LIB_CTX *libctx = NULL;
extern int key_deleted; /* From fake_rsaprov.c */
/* Fetch SIGNATURE method using a libctx and propq */
static int fetch_sig(OSSL_LIB_CTX *ctx, const char *alg, const char *propq,
OSSL_PROVIDER *expected_prov)
{
OSSL_PROVIDER *prov;
EVP_SIGNATURE *sig = EVP_SIGNATURE_fetch(ctx, "RSA", propq);
int ret = 0;
if (!TEST_ptr(sig))
return 0;
if (!TEST_ptr(prov = EVP_SIGNATURE_get0_provider(sig)))
goto end;
if (!TEST_ptr_eq(prov, expected_prov)) {
TEST_info("Fetched provider: %s, Expected provider: %s",
OSSL_PROVIDER_get0_name(prov),
OSSL_PROVIDER_get0_name(expected_prov));
goto end;
}
ret = 1;
end:
EVP_SIGNATURE_free(sig);
return ret;
}
static int test_pkey_sig(void)
{
OSSL_PROVIDER *deflt = NULL;
OSSL_PROVIDER *fake_rsa = NULL;
int i, ret = 0;
EVP_PKEY *pkey = NULL;
EVP_PKEY_CTX *ctx = NULL;
if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
return 0;
if (!TEST_ptr(deflt = OSSL_PROVIDER_load(libctx, "default")))
goto end;
/* Do a direct fetch to see it works */
if (!TEST_true(fetch_sig(libctx, "RSA", "provider=fake-rsa", fake_rsa))
|| !TEST_true(fetch_sig(libctx, "RSA", "?provider=fake-rsa", fake_rsa)))
goto end;
/* Construct a pkey using precise propq to use our provider */
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA",
"provider=fake-rsa"))
|| !TEST_true(EVP_PKEY_fromdata_init(ctx))
|| !TEST_true(EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEYPAIR, NULL))
|| !TEST_ptr(pkey))
goto end;
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
/* try exercising signature_init ops a few times */
for (i = 0; i < 3; i++) {
size_t siglen;
/*
* Create a signing context for our pkey with optional propq.
* The sign init should pick both keymgmt and signature from
* fake-rsa as the key is not exportable.
*/
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey,
"?provider=default")))
goto end;
/*
* If this picks the wrong signature without realizing it
* we can get a segfault or some internal error. At least watch
* whether fake-rsa sign_init is exercised by calling sign.
*/
if (!TEST_int_eq(EVP_PKEY_sign_init(ctx), 1))
goto end;
if (!TEST_int_eq(EVP_PKEY_sign(ctx, NULL, &siglen, NULL, 0), 1)
|| !TEST_size_t_eq(siglen, 256))
goto end;
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
}
ret = 1;
end:
fake_rsa_finish(fake_rsa);
OSSL_PROVIDER_unload(deflt);
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(pkey);
return ret;
}
static int test_alternative_keygen_init(void)
{
EVP_PKEY_CTX *ctx = NULL;
OSSL_PROVIDER *deflt = NULL;
OSSL_PROVIDER *fake_rsa = NULL;
const OSSL_PROVIDER *provider;
const char *provname;
int ret = 0;
if (!TEST_ptr(deflt = OSSL_PROVIDER_load(libctx, "default")))
goto end;
/* first try without the fake RSA provider loaded */
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA", NULL)))
goto end;
if (!TEST_int_gt(EVP_PKEY_keygen_init(ctx), 0))
goto end;
if (!TEST_ptr(provider = EVP_PKEY_CTX_get0_provider(ctx)))
goto end;
if (!TEST_ptr(provname = OSSL_PROVIDER_get0_name(provider)))
goto end;
if (!TEST_str_eq(provname, "default"))
goto end;
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
/* now load fake RSA and try again */
if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
return 0;
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA",
"?provider=fake-rsa")))
goto end;
if (!TEST_int_gt(EVP_PKEY_keygen_init(ctx), 0))
goto end;
if (!TEST_ptr(provider = EVP_PKEY_CTX_get0_provider(ctx)))
goto end;
if (!TEST_ptr(provname = OSSL_PROVIDER_get0_name(provider)))
goto end;
if (!TEST_str_eq(provname, "fake-rsa"))
goto end;
ret = 1;
end:
fake_rsa_finish(fake_rsa);
OSSL_PROVIDER_unload(deflt);
EVP_PKEY_CTX_free(ctx);
return ret;
}
static int test_pkey_eq(void)
{
OSSL_PROVIDER *deflt = NULL;
OSSL_PROVIDER *fake_rsa = NULL;
EVP_PKEY *pkey_fake = NULL;
EVP_PKEY *pkey_dflt = NULL;
EVP_PKEY_CTX *ctx = NULL;
OSSL_PARAM *params = NULL;
int ret = 0;
if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
return 0;
if (!TEST_ptr(deflt = OSSL_PROVIDER_load(libctx, "default")))
goto end;
/* Construct a public key for fake-rsa */
if (!TEST_ptr(params = fake_rsa_key_params(0))
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA",
"provider=fake-rsa"))
|| !TEST_true(EVP_PKEY_fromdata_init(ctx))
|| !TEST_true(EVP_PKEY_fromdata(ctx, &pkey_fake, EVP_PKEY_PUBLIC_KEY,
params))
|| !TEST_ptr(pkey_fake))
goto end;
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
OSSL_PARAM_free(params);
params = NULL;
/* Construct a public key for default */
if (!TEST_ptr(params = fake_rsa_key_params(0))
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA",
"provider=default"))
|| !TEST_true(EVP_PKEY_fromdata_init(ctx))
|| !TEST_true(EVP_PKEY_fromdata(ctx, &pkey_dflt, EVP_PKEY_PUBLIC_KEY,
params))
|| !TEST_ptr(pkey_dflt))
goto end;
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
OSSL_PARAM_free(params);
params = NULL;
/* now test for equality */
if (!TEST_int_eq(EVP_PKEY_eq(pkey_fake, pkey_dflt), 1))
goto end;
ret = 1;
end:
fake_rsa_finish(fake_rsa);
OSSL_PROVIDER_unload(deflt);
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(pkey_fake);
EVP_PKEY_free(pkey_dflt);
OSSL_PARAM_free(params);
return ret;
}
static int test_pkey_store(int idx)
{
OSSL_PROVIDER *deflt = NULL;
OSSL_PROVIDER *fake_rsa = NULL;
int ret = 0;
EVP_PKEY *pkey = NULL;
OSSL_STORE_LOADER *loader = NULL;
OSSL_STORE_CTX *ctx = NULL;
OSSL_STORE_INFO *info;
const char *propq = idx == 0 ? "?provider=fake-rsa"
: "?provider=default";
/* It's important to load the default provider first for this test */
if (!TEST_ptr(deflt = OSSL_PROVIDER_load(libctx, "default")))
goto end;
if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
goto end;
if (!TEST_ptr(loader = OSSL_STORE_LOADER_fetch(libctx, "fake_rsa",
propq)))
goto end;
OSSL_STORE_LOADER_free(loader);
if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake_rsa:test", libctx, propq,
NULL, NULL, NULL, NULL, NULL)))
goto end;
while (!OSSL_STORE_eof(ctx)
&& (info = OSSL_STORE_load(ctx)) != NULL
&& pkey == NULL) {
if (OSSL_STORE_INFO_get_type(info) == OSSL_STORE_INFO_PKEY)
pkey = OSSL_STORE_INFO_get1_PKEY(info);
OSSL_STORE_INFO_free(info);
info = NULL;
}
if (!TEST_ptr(pkey) || !TEST_int_eq(EVP_PKEY_is_a(pkey, "RSA"), 1))
goto end;
ret = 1;
end:
fake_rsa_finish(fake_rsa);
OSSL_PROVIDER_unload(deflt);
OSSL_STORE_close(ctx);
EVP_PKEY_free(pkey);
return ret;
}
static int test_pkey_delete(void)
{
OSSL_PROVIDER *deflt = NULL;
OSSL_PROVIDER *fake_rsa = NULL;
int ret = 0;
EVP_PKEY *pkey = NULL;
OSSL_STORE_LOADER *loader = NULL;
OSSL_STORE_CTX *ctx = NULL;
OSSL_STORE_INFO *info;
const char *propq = "?provider=fake-rsa";
/* It's important to load the default provider first for this test */
if (!TEST_ptr(deflt = OSSL_PROVIDER_load(libctx, "default")))
goto end;
if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
goto end;
if (!TEST_ptr(loader = OSSL_STORE_LOADER_fetch(libctx, "fake_rsa",
propq)))
goto end;
OSSL_STORE_LOADER_free(loader);
/* First iteration: load key, check it, delete it */
if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake_rsa:test", libctx, propq,
NULL, NULL, NULL, NULL, NULL)))
goto end;
while (!OSSL_STORE_eof(ctx)
&& (info = OSSL_STORE_load(ctx)) != NULL
&& pkey == NULL) {
if (OSSL_STORE_INFO_get_type(info) == OSSL_STORE_INFO_PKEY)
pkey = OSSL_STORE_INFO_get1_PKEY(info);
OSSL_STORE_INFO_free(info);
info = NULL;
}
if (!TEST_ptr(pkey) || !TEST_int_eq(EVP_PKEY_is_a(pkey, "RSA"), 1))
goto end;
EVP_PKEY_free(pkey);
pkey = NULL;
if (!TEST_int_eq(OSSL_STORE_delete("fake_rsa:test", libctx, propq,
NULL, NULL, NULL), 1))
goto end;
if (!TEST_int_eq(OSSL_STORE_close(ctx), 1))
goto end;
/* Second iteration: load key should fail */
if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake_rsa:test", libctx, propq,
NULL, NULL, NULL, NULL, NULL)))
goto end;
while (!OSSL_STORE_eof(ctx)) {
info = OSSL_STORE_load(ctx);
if (!TEST_ptr_null(info))
goto end;
}
ret = 1;
end:
fake_rsa_finish(fake_rsa);
OSSL_PROVIDER_unload(deflt);
OSSL_STORE_close(ctx);
fake_rsa_restore_store_state();
return ret;
}
static int fake_pw_read_string(UI *ui, UI_STRING *uis)
{
const char *passphrase = FAKE_PASSPHRASE;
if (UI_get_string_type(uis) == UIT_PROMPT) {
UI_set_result(ui, uis, passphrase);
return 1;
}
return 0;
}
static int test_pkey_store_open_ex(void)
{
OSSL_PROVIDER *deflt = NULL;
OSSL_PROVIDER *fake_rsa = NULL;
int ret = 0;
EVP_PKEY *pkey = NULL;
OSSL_STORE_LOADER *loader = NULL;
OSSL_STORE_CTX *ctx = NULL;
const char *propq = "?provider=fake-rsa";
UI_METHOD *ui_method = NULL;
/* It's important to load the default provider first for this test */
if (!TEST_ptr(deflt = OSSL_PROVIDER_load(libctx, "default")))
goto end;
if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
goto end;
if (!TEST_ptr(loader = OSSL_STORE_LOADER_fetch(libctx, "fake_rsa",
propq)))
goto end;
OSSL_STORE_LOADER_free(loader);
if (!TEST_ptr(ui_method= UI_create_method("PW Callbacks")))
goto end;
if (UI_method_set_reader(ui_method, fake_pw_read_string))
goto end;
if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake_rsa:openpwtest", libctx, propq,
ui_method, NULL, NULL, NULL, NULL)))
goto end;
/* retry w/o ui_method to ensure we actually enter pw checks and fail */
OSSL_STORE_close(ctx);
if (!TEST_ptr_null(ctx = OSSL_STORE_open_ex("fake_rsa:openpwtest", libctx,
propq, NULL, NULL, NULL, NULL,
NULL)))
goto end;
ret = 1;
end:
UI_destroy_method(ui_method);
fake_rsa_finish(fake_rsa);
OSSL_PROVIDER_unload(deflt);
OSSL_STORE_close(ctx);
EVP_PKEY_free(pkey);
return ret;
}
int setup_tests(void)
{
libctx = OSSL_LIB_CTX_new();
if (libctx == NULL)
return 0;
ADD_TEST(test_pkey_sig);
ADD_TEST(test_alternative_keygen_init);
ADD_TEST(test_pkey_eq);
ADD_ALL_TESTS(test_pkey_store, 2);
ADD_TEST(test_pkey_delete);
ADD_TEST(test_pkey_store_open_ex);
return 1;
}
void cleanup_tests(void)
{
OSSL_LIB_CTX_free(libctx);
}
|
./openssl/test/evp_pkey_dparams_test.c | /*
* Copyright 2019-2022 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"
#if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC)
# define OPENSSL_NO_KEYPARAMS
#endif
#ifndef OPENSSL_NO_KEYPARAMS
struct pubkey {
int bad;
const unsigned char *key_bin;
size_t key_bin_len;
};
# ifndef OPENSSL_NO_DH
static const unsigned char dhparam_bin[] = {
0x30,0x82,0x01,0x08,0x02,0x82,0x01,0x01,0x00,0xc0,0xd1,0x2e,0x14,0x18,0xbd,0x03,
0xfd,0x39,0xe1,0x99,0xf4,0x93,0x06,0x2d,0x49,0xc6,0xb5,0xb9,0xf0,0x91,0xcb,0x2f,
0x48,0x54,0x79,0x7d,0xc4,0x65,0x11,0x55,0xf7,0x99,0xde,0x42,0x83,0x84,0xc0,0xf8,
0x88,0x89,0xa0,0xff,0xff,0x7d,0xe8,0xef,0x9e,0xbc,0xf7,0x1d,0x70,0x6d,0x3a,0x33,
0x49,0x28,0xa1,0xa3,0xe1,0x41,0xc4,0x8b,0x91,0xf9,0xf2,0xb6,0xe2,0x77,0x79,0x38,
0x7d,0x21,0xb3,0xdf,0x79,0x9c,0x5e,0x65,0x16,0x00,0x16,0x82,0xb2,0x36,0x46,0x21,
0xac,0xaf,0x86,0xc7,0xe3,0x10,0x44,0x48,0xfb,0xbd,0xad,0x4e,0x11,0x73,0x4c,0x25,
0xb0,0x8c,0x1c,0x1e,0x8e,0x58,0x50,0x5e,0x43,0x89,0xe4,0xd9,0x34,0xf8,0x3b,0xcc,
0x36,0x2c,0x1b,0xb3,0xb2,0x77,0x0c,0xa5,0x96,0xc1,0x8a,0x38,0xd4,0xe3,0x9c,0x2a,
0xde,0x49,0x46,0xc7,0xd4,0xa2,0x47,0xc9,0x0a,0xbd,0x84,0xd4,0x1c,0xbc,0xb6,0x19,
0x04,0x94,0x64,0xfa,0x8a,0x11,0x9c,0x5f,0x4a,0x4c,0x0f,0x58,0x81,0x02,0xbf,0xcf,
0x87,0x27,0x2b,0xae,0x8e,0xe2,0x61,0x7a,0xdb,0xba,0x23,0x39,0x25,0x44,0xdc,0x22,
0x75,0xc3,0x28,0xd9,0x12,0x33,0x84,0x32,0xd4,0x5d,0xd9,0x77,0xf8,0x04,0x90,0x38,
0x0a,0xec,0x84,0x93,0x43,0xce,0xe7,0x07,0x42,0x7d,0x2d,0xe0,0x21,0x3b,0x19,0x22,
0xa7,0x8f,0x50,0x31,0xda,0xd0,0x0d,0xd3,0x0b,0xdb,0xad,0xed,0x94,0x92,0xff,0x83,
0x06,0x7f,0x7f,0xd7,0x7b,0x42,0x5b,0xba,0x93,0x7a,0xeb,0x43,0x5f,0xce,0x59,0x26,
0xe8,0x76,0xdc,0xee,0xe2,0xbe,0x36,0x7a,0x83,0x02,0x01,0x02
};
static const unsigned char dhkey_1[] = {
0x7a, 0x49, 0xcb, 0xc3, 0x25, 0x67, 0x7a, 0x61,
0xd0, 0x60, 0x81, 0x0f, 0xf6, 0xbd, 0x38, 0x82,
0xe7, 0x38, 0x8c, 0xe9, 0xd1, 0x04, 0x33, 0xbf,
0x8a, 0x03, 0x63, 0xb3, 0x05, 0x04, 0xb5, 0x1f,
0xba, 0x9f, 0x1a, 0x5f, 0x31, 0x3e, 0x96, 0x79,
0x88, 0x7d, 0x3f, 0x59, 0x6d, 0x3b, 0xf3, 0x2f,
0xf2, 0xa6, 0x43, 0x48, 0x64, 0x5a, 0x6a, 0x32,
0x1f, 0x24, 0x37, 0x62, 0x54, 0x3a, 0x7d, 0xab,
0x26, 0x77, 0x7c, 0xec, 0x57, 0x3c, 0xa4, 0xbd,
0x96, 0x9d, 0xaa, 0x3b, 0x0e, 0x9a, 0x55, 0x7e,
0x1d, 0xb4, 0x47, 0x5b, 0xea, 0x20, 0x3c, 0x6d,
0xbe, 0xd6, 0x70, 0x7d, 0xa8, 0x9e, 0x84, 0xb4,
0x03, 0x52, 0xf2, 0x08, 0x4c, 0x98, 0xd3, 0x4f,
0x58, 0xb3, 0xdf, 0xb4, 0xe6, 0xdc, 0x2c, 0x43,
0x55, 0xd1, 0xce, 0x2a, 0xb3, 0xfc, 0xe0, 0x29,
0x97, 0xd8, 0xd8, 0x62, 0xc6, 0x87, 0x0a, 0x1b,
0xfd, 0x72, 0x74, 0xe0, 0xa9, 0xfb, 0xfa, 0x91,
0xf2, 0xc1, 0x09, 0x93, 0xea, 0x63, 0xf6, 0x9a,
0x4b, 0xdf, 0x4e, 0xdf, 0x6b, 0xf9, 0xeb, 0xf6,
0x66, 0x3c, 0xfd, 0x6f, 0x68, 0xcb, 0xdb, 0x6e,
0x40, 0x65, 0xf7, 0xf2, 0x46, 0xe5, 0x0d, 0x9a,
0xd9, 0x6f, 0xcf, 0x28, 0x22, 0x8f, 0xca, 0x0b,
0x30, 0xa0, 0x9e, 0xa5, 0x13, 0xba, 0x72, 0x7f,
0x85, 0x3d, 0x02, 0x9c, 0x97, 0x8e, 0x6f, 0xea,
0x6d, 0x35, 0x4e, 0xd1, 0x78, 0x7d, 0x73, 0x60,
0x92, 0xa9, 0x12, 0xf4, 0x2a, 0xac, 0x17, 0x97,
0xf3, 0x7b, 0x79, 0x08, 0x69, 0xd1, 0x9e, 0xb5,
0xf8, 0x2a, 0x0a, 0x2b, 0x00, 0x7b, 0x16, 0x8d,
0x41, 0x82, 0x3a, 0x72, 0x58, 0x57, 0x80, 0x65,
0xae, 0x17, 0xbc, 0x3a, 0x5b, 0x7e, 0x5c, 0x2d,
0xae, 0xb2, 0xc2, 0x26, 0x20, 0x9a, 0xaa, 0x57,
0x4b, 0x7d, 0x43, 0x41, 0x96, 0x3f, 0xf0, 0x0d
};
/* smaller but still valid key */
static const unsigned char dhkey_2[] = {
0x73, 0xb2, 0x22, 0x91, 0x27, 0xb9, 0x45, 0xb0,
0xfd, 0x17, 0x66, 0x79, 0x9b, 0x32, 0x71, 0x92,
0x97, 0x1d, 0x70, 0x02, 0x37, 0x70, 0x79, 0x63,
0xed, 0x11, 0x22, 0xe9, 0xe6, 0xf8, 0xeb, 0xd7,
0x90, 0x00, 0xe6, 0x5c, 0x47, 0x02, 0xfb, 0x13,
0xca, 0x29, 0x14, 0x1e, 0xf4, 0x61, 0x58, 0xf6,
0xaa, 0xbb, 0xcf, 0xa7, 0x82, 0x9a, 0x9e, 0x7c,
0x4a, 0x05, 0x42, 0xed, 0x55, 0xd8, 0x08, 0x37,
0x06, 0x49, 0x9b, 0xda, 0xb3, 0xb9, 0xc9, 0xc0,
0x56, 0x26, 0xda, 0x60, 0x1d, 0xbc, 0x06, 0x0b,
0xb0, 0x94, 0x4b, 0x4e, 0x95, 0xf9, 0xb4, 0x2f,
0x4e, 0xad, 0xf8, 0xab, 0x2d, 0x19, 0xa2, 0xe6,
0x6d, 0x11, 0xfd, 0x9b, 0x5a, 0x2a, 0xb0, 0x81,
0x42, 0x4d, 0x86, 0x76, 0xd5, 0x9e, 0xaf, 0xf9,
0x6f, 0x79, 0xab, 0x1d, 0xfe, 0xd8, 0xc8, 0xba,
0xb6, 0xce, 0x03, 0x61, 0x48, 0x53, 0xd8, 0x0b,
0x83, 0xf0, 0xb0, 0x46, 0xa0, 0xea, 0x46, 0x60,
0x7a, 0x39, 0x4e, 0x46, 0x6a, 0xbb, 0x07, 0x6c,
0x8c, 0x7d, 0xb7, 0x7d, 0x5b, 0xe5, 0x24, 0xa5,
0xab, 0x41, 0x8a, 0xc4, 0x63, 0xf9, 0xce, 0x20,
0x6f, 0x58, 0x4f, 0x0e, 0x42, 0x82, 0x9e, 0x17,
0x53, 0xa6, 0xd6, 0x42, 0x3e, 0x80, 0x66, 0x6f,
0x2a, 0x1c, 0x30, 0x08, 0x01, 0x99, 0x5a, 0x4f,
0x72, 0x16, 0xed, 0xb0, 0xd6, 0x8c, 0xf0, 0x7a,
0x33, 0x15, 0xc4, 0x95, 0x65, 0xba, 0x11, 0x37,
0xa0, 0xcc, 0xe7, 0x45, 0x65, 0x4f, 0x17, 0x0a,
0x2c, 0x62, 0xc0, 0x65, 0x3b, 0x65, 0x2a, 0x56,
0xf7, 0x29, 0x8a, 0x9b, 0x1b, 0xbb, 0x0c, 0x40,
0xcd, 0x66, 0x4b, 0x4f, 0x2f, 0xba, 0xdb, 0x59,
0x93, 0x6d, 0x34, 0xf3, 0x8d, 0xde, 0x68, 0x99,
0x78, 0xfc, 0xac, 0x95, 0xd9, 0xa3, 0x74, 0xe6,
0x24, 0x96, 0x98, 0x6f, 0x64, 0x71, 0x76
};
/* 1 is not a valid key */
static const unsigned char dhkey_3[] = {
0x01
};
# endif
# ifndef OPENSSL_NO_DSA
static const unsigned char dsaparam_bin[] = {
0x30,0x82,0x02,0x28,0x02,0x82,0x01,0x01,0x00,0xf2,0x85,0x01,0xa5,0xb9,0x56,0x65,
0x19,0xff,0x9a,0x7d,0xf9,0x90,0xd6,0xaa,0x73,0xac,0xf7,0x94,0xfa,0x8a,0x64,0x6d,
0xa0,0x01,0x42,0xe5,0x45,0xfc,0x53,0x72,0xb0,0x7c,0xe6,0x3b,0xfb,0x09,0x33,0x41,
0x27,0xbd,0x00,0xb5,0x18,0x87,0x62,0xa8,0x2b,0xfc,0xd0,0x52,0x4a,0x14,0x2d,0xaa,
0x36,0xc6,0xf3,0xa9,0xe3,0x90,0x1b,0x74,0xdf,0x0a,0x6d,0x33,0xba,0xf4,0x32,0x6d,
0xba,0x36,0x68,0x1d,0x83,0x36,0x50,0xc6,0x62,0xc0,0x40,0x67,0x0e,0xf6,0x22,0x00,
0x62,0x1b,0x76,0x72,0x62,0x5f,0xa0,0xdf,0x38,0xb1,0x1d,0x26,0x70,0x9b,0x84,0x64,
0xbb,0x16,0x15,0xc2,0x66,0xb9,0x97,0xd0,0x07,0xf1,0x4b,0x70,0x02,0x03,0xf1,0xd2,
0x03,0xdb,0x78,0x8b,0xb4,0xda,0x6f,0x3c,0xe2,0x31,0xa8,0x1c,0x99,0xea,0x9c,0x75,
0x28,0x96,0x82,0x16,0x77,0xac,0x79,0x32,0x61,0x87,0xec,0xb7,0xb4,0xc3,0xea,0x12,
0x62,0x1f,0x08,0xb8,0x16,0xab,0xcc,0xef,0x28,0xdf,0x06,0x07,0xbe,0xb0,0xdc,0x78,
0x83,0x8a,0x70,0x80,0x34,0xe6,0x91,0xe3,0xd3,0x92,0xd9,0xf4,0x56,0x53,0x52,0xb7,
0x35,0xf6,0x2a,0xec,0x4b,0xcb,0xa2,0x3c,0xc3,0x0c,0x94,0xa7,0x4e,0x1c,0x42,0x9c,
0x72,0x99,0x60,0x8c,0xfe,0xfb,0x60,0x57,0x75,0xf5,0x23,0x11,0x12,0xba,0x97,0xcd,
0xad,0x5a,0x0b,0xa6,0x1f,0x6a,0x48,0x2e,0x8d,0xda,0x95,0xc6,0x0e,0x14,0xde,0xf7,
0x22,0x55,0xa8,0x6b,0x25,0xdf,0xa2,0xab,0x33,0x65,0x56,0xfc,0x78,0x4f,0x62,0xdf,
0x48,0xdd,0xce,0x8b,0xe1,0x76,0xf4,0xf6,0x7f,0x02,0x1d,0x00,0xac,0xb0,0xb8,0x92,
0x3b,0x6b,0x61,0xcf,0x36,0x6d,0xf2,0x1e,0x5d,0xe0,0x7b,0xf5,0x73,0x48,0xa3,0x8b,
0x86,0x9e,0x88,0xce,0x40,0xf8,0x27,0x6d,0x02,0x82,0x01,0x00,0x77,0x6b,0x89,0xd6,
0x8f,0x3d,0xce,0x52,0x30,0x74,0xb2,0xa1,0x13,0x96,0xd5,0x92,0xf2,0xf1,0x6b,0x10,
0x31,0x0b,0xf3,0x69,0xaa,0xbf,0x4b,0x6c,0xcb,0x3f,0x6d,0x58,0x76,0x44,0x09,0xf9,
0x28,0xef,0xa0,0xe4,0x55,0x77,0x57,0xe0,0xfb,0xcc,0x9a,0x6a,0x2c,0x90,0xec,0x72,
0x24,0x0b,0x43,0xc5,0xbc,0x31,0xed,0x1a,0x46,0x2c,0x76,0x42,0x9e,0xc0,0x82,0xfc,
0xff,0xf9,0x7e,0xe2,0x1f,0x39,0xf3,0x3b,0xdb,0x27,0x36,0xe7,0xf5,0x3b,0xc2,0x23,
0xb6,0xd0,0xcf,0x5b,0x85,0x2e,0x1b,0x00,0x5b,0x31,0xaa,0x72,0x8f,0x37,0xee,0x56,
0x71,0xc4,0xfd,0x3c,0x8d,0xfa,0x5b,0xab,0xb1,0xa9,0x52,0x76,0xa0,0xe4,0xe3,0x78,
0x83,0x64,0x5d,0xd7,0x6c,0xec,0x9b,0x40,0x65,0xe2,0x0a,0x11,0x19,0x60,0xdd,0xce,
0x29,0x9f,0xc6,0x1d,0x0a,0xab,0x8e,0x59,0x25,0xc5,0x0b,0x9c,0x02,0x45,0xba,0x99,
0x74,0x22,0x1d,0xc1,0x57,0xca,0x50,0x8c,0x5e,0xdf,0xd8,0x5d,0x43,0xae,0x06,0x28,
0x29,0x82,0xf6,0x5a,0xa9,0x51,0xa2,0x04,0x1d,0xbf,0x88,0x15,0x98,0xce,0x8a,0xb4,
0x3b,0xe5,0x30,0x29,0xce,0x0c,0x9b,0xf8,0xdb,0xbf,0x06,0x9f,0xd0,0x59,0x18,0xd4,
0x0b,0x94,0xbf,0xe9,0x67,0x6b,0x9e,0xf0,0x72,0xc6,0xbf,0x79,0x8f,0x1e,0xa3,0x95,
0x24,0xe3,0xcb,0x58,0xb5,0x67,0xd3,0xae,0x79,0xb0,0x28,0x9c,0x9a,0xd0,0xa4,0xe7,
0x22,0x15,0xc1,0x8b,0x04,0xb9,0x8a,0xa8,0xb7,0x1b,0x62,0x44,0xc6,0xef,0x4b,0x74,
0xd0,0xfd,0xa9,0xb4,0x4e,0xdd,0x7d,0x38,0x60,0xd1,0x40,0xcd
};
# endif
# ifndef OPENSSL_NO_EC
static const unsigned char ecparam_bin[] = {
0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07
};
static const unsigned char eckey_1[] = {
0x04, 0xc8, 0x65, 0x45, 0x63, 0x73, 0xe5, 0x0a,
0x61, 0x1d, 0xcf, 0x60, 0x76, 0x2c, 0xe7, 0x36,
0x0b, 0x76, 0xc2, 0x92, 0xfc, 0xa4, 0x56, 0xee,
0xc2, 0x62, 0x05, 0x00, 0x80, 0xe4, 0x4f, 0x07,
0x3b, 0xf4, 0x59, 0xb8, 0xc3, 0xb3, 0x1f, 0x77,
0x36, 0x16, 0x4c, 0x72, 0x2a, 0xc0, 0x89, 0x89,
0xd6, 0x16, 0x14, 0xee, 0x2f, 0x5a, 0xde, 0x9e,
0x83, 0xc5, 0x78, 0xd0, 0x0b, 0x69, 0xb4, 0xb9,
0xf1
};
/* a modified key */
static const unsigned char eckey_2[] = {
0x04, 0xc8, 0x65, 0x45, 0x63, 0x73, 0xe5, 0x0a,
0x61, 0x1d, 0xcf, 0x60, 0x76, 0x2c, 0xe7, 0x36,
0x0b, 0x77, 0xc2, 0x92, 0xfc, 0xa4, 0x56, 0xee,
0xc2, 0x62, 0x05, 0x00, 0x80, 0xe4, 0x4f, 0x07,
0x3b, 0xf4, 0x59, 0xb8, 0xc3, 0xb3, 0x1f, 0x77,
0x36, 0x16, 0x4c, 0x72, 0x2a, 0xc0, 0x89, 0x89,
0xd6, 0x16, 0x14, 0xee, 0x2f, 0x5a, 0xde, 0x9e,
0x83, 0xc5, 0x78, 0xd0, 0x0b, 0x69, 0xb4, 0xb9,
0xf1
};
/* an added byte */
static const unsigned char eckey_3[] = {
0x04, 0xc8, 0x65, 0x45, 0x63, 0x73, 0xe5, 0x0a,
0x61, 0x1d, 0xcf, 0x60, 0x76, 0x2c, 0xe7, 0x36,
0x0b, 0x76, 0xc2, 0x92, 0xfc, 0xa4, 0x56, 0xee,
0xc2, 0x62, 0x05, 0x00, 0x80, 0xe4, 0x4f, 0x07,
0x3b, 0xf4, 0x59, 0xb8, 0xc3, 0xb3, 0x1f, 0x77,
0x36, 0x16, 0x4c, 0x72, 0x2a, 0xc0, 0x89, 0x89,
0xd6, 0x16, 0x14, 0xee, 0x2f, 0x5a, 0xde, 0x9e,
0x83, 0xc5, 0x78, 0xd0, 0x0b, 0x69, 0xb4, 0xb9,
0xf1, 0xaa
};
# endif
#define NUM_KEYS 10
static const struct {
int type;
const unsigned char *param_bin;
size_t param_bin_len;
struct pubkey keys[NUM_KEYS];
} pkey_params [] = {
# ifndef OPENSSL_NO_DH
{ EVP_PKEY_DH, dhparam_bin, sizeof(dhparam_bin),
{ { 0, dhkey_1, sizeof(dhkey_1) },
{ 0, dhkey_2, sizeof(dhkey_2) },
{ 1, dhkey_3, sizeof(dhkey_3) },
{ 1, dhkey_1, 0 },
{ 1, dhparam_bin, sizeof(dhparam_bin) }
}
},
# endif
# ifndef OPENSSL_NO_DSA
{ EVP_PKEY_DSA, dsaparam_bin, sizeof(dsaparam_bin) },
# endif
# ifndef OPENSSL_NO_EC
{ EVP_PKEY_EC, ecparam_bin, sizeof(ecparam_bin),
{ { 0, eckey_1, sizeof(eckey_1) },
{ 1, eckey_2, sizeof(eckey_2) },
{ 1, eckey_3, sizeof(eckey_3) },
{ 1, eckey_1, 0 },
{ 1, eckey_1, sizeof(eckey_1) - 1 }
}
}
# endif
};
static int params_bio_test(int id)
{
int ret, out_len;
BIO *in = NULL, *out = NULL;
EVP_PKEY *in_key = NULL, *out_key = NULL;
unsigned char *out_bin;
int type = pkey_params[id].type;
ret = TEST_ptr(in = BIO_new_mem_buf(pkey_params[id].param_bin,
(int)pkey_params[id].param_bin_len))
/* Load in pkey params from binary */
&& TEST_ptr(d2i_KeyParams_bio(type, &in_key, in))
&& TEST_ptr(out = BIO_new(BIO_s_mem()))
/* Save pkey params to binary */
&& TEST_int_gt(i2d_KeyParams_bio(out, in_key), 0)
/* test the output binary is the expected value */
&& TEST_int_gt(out_len = BIO_get_mem_data(out, &out_bin), 0)
&& TEST_mem_eq(pkey_params[id].param_bin,
(int)pkey_params[id].param_bin_len,
out_bin, out_len);
BIO_free(in);
BIO_free(out);
EVP_PKEY_free(in_key);
EVP_PKEY_free(out_key);
return ret;
}
static int set_enc_pubkey_test(int id)
{
int ret, i;
BIO *in = NULL;
EVP_PKEY *in_key = NULL;
int type = pkey_params[id].type;
const struct pubkey *keys = pkey_params[id].keys;
if (keys[0].key_bin == NULL)
return TEST_skip("Not applicable test");
ret = TEST_ptr(in = BIO_new_mem_buf(pkey_params[id].param_bin,
(int)pkey_params[id].param_bin_len))
/* Load in pkey params from binary */
&& TEST_ptr(d2i_KeyParams_bio(type, &in_key, in));
for (i = 0; ret && i < NUM_KEYS && keys[i].key_bin != NULL; i++) {
if (keys[i].bad) {
ERR_set_mark();
ret = ret
&& TEST_int_le(EVP_PKEY_set1_encoded_public_key(in_key,
keys[i].key_bin,
keys[i].key_bin_len),
0);
ERR_pop_to_mark();
} else {
ret = ret
&& TEST_int_gt(EVP_PKEY_set1_encoded_public_key(in_key,
keys[i].key_bin,
keys[i].key_bin_len),
0);
}
if (!ret)
TEST_info("Test key index #%d", i);
}
BIO_free(in);
EVP_PKEY_free(in_key);
return ret;
}
#endif
int setup_tests(void)
{
#ifdef OPENSSL_NO_KEYPARAMS
TEST_note("No DH/DSA/EC support");
#else
ADD_ALL_TESTS(params_bio_test, OSSL_NELEM(pkey_params));
ADD_ALL_TESTS(set_enc_pubkey_test, OSSL_NELEM(pkey_params));
#endif
return 1;
}
|
./openssl/test/pkey_meth_test.c | /*
* 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
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
/* Internal tests for EVP_PKEY method ordering */
/* We need to use some deprecated APIs */
#define OPENSSL_SUPPRESS_DEPRECATED
#include <stdio.h>
#include <string.h>
#include <openssl/evp.h>
#include "testutil.h"
/* Test of EVP_PKEY_ASN1_METHOD ordering */
static int test_asn1_meths(void)
{
int i;
int prev = -1;
int good = 1;
int pkey_id;
const EVP_PKEY_ASN1_METHOD *ameth;
for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
ameth = EVP_PKEY_asn1_get0(i);
EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
if (pkey_id < prev)
good = 0;
prev = pkey_id;
}
if (!good) {
TEST_error("EVP_PKEY_ASN1_METHOD table out of order");
for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
const char *info;
ameth = EVP_PKEY_asn1_get0(i);
EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, &info, NULL, ameth);
if (info == NULL)
info = "<NO NAME>";
TEST_note("%d : %s : %s", pkey_id, OBJ_nid2ln(pkey_id), info);
}
}
return good;
}
#ifndef OPENSSL_NO_DEPRECATED_3_0
/* Test of EVP_PKEY_METHOD ordering */
static int test_pkey_meths(void)
{
size_t i;
int prev = -1;
int good = 1;
int pkey_id;
const EVP_PKEY_METHOD *pmeth;
for (i = 0; i < EVP_PKEY_meth_get_count(); i++) {
pmeth = EVP_PKEY_meth_get0(i);
EVP_PKEY_meth_get0_info(&pkey_id, NULL, pmeth);
if (pkey_id < prev)
good = 0;
prev = pkey_id;
}
if (!good) {
TEST_error("EVP_PKEY_METHOD table out of order");
for (i = 0; i < EVP_PKEY_meth_get_count(); i++) {
pmeth = EVP_PKEY_meth_get0(i);
EVP_PKEY_meth_get0_info(&pkey_id, NULL, pmeth);
TEST_note("%d : %s", pkey_id, OBJ_nid2ln(pkey_id));
}
}
return good;
}
#endif
int setup_tests(void)
{
ADD_TEST(test_asn1_meths);
#ifndef OPENSSL_NO_DEPRECATED_3_0
ADD_TEST(test_pkey_meths);
#endif
return 1;
}
|
./openssl/test/asynctest.c | /*
* Copyright 2015-2022 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
*/
#ifdef _WIN32
# include <windows.h>
#endif
#include <stdio.h>
#include <string.h>
#include <openssl/async.h>
#include <openssl/crypto.h>
static int ctr = 0;
static ASYNC_JOB *currjob = NULL;
static int custom_alloc_used = 0;
static int custom_free_used = 0;
static int only_pause(void *args)
{
ASYNC_pause_job();
return 1;
}
static int add_two(void *args)
{
ctr++;
ASYNC_pause_job();
ctr++;
return 2;
}
static int save_current(void *args)
{
currjob = ASYNC_get_current_job();
ASYNC_pause_job();
return 1;
}
static int change_deflt_libctx(void *args)
{
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
OSSL_LIB_CTX *oldctx, *tmpctx;
int ret = 0;
if (libctx == NULL)
return 0;
oldctx = OSSL_LIB_CTX_set0_default(libctx);
ASYNC_pause_job();
/* Check the libctx is set up as we expect */
tmpctx = OSSL_LIB_CTX_set0_default(oldctx);
if (tmpctx != libctx)
goto err;
/* Set it back again to continue to use our own libctx */
oldctx = OSSL_LIB_CTX_set0_default(libctx);
ASYNC_pause_job();
/* Check the libctx is set up as we expect */
tmpctx = OSSL_LIB_CTX_set0_default(oldctx);
if (tmpctx != libctx)
goto err;
ret = 1;
err:
OSSL_LIB_CTX_free(libctx);
return ret;
}
#define MAGIC_WAIT_FD ((OSSL_ASYNC_FD)99)
static int waitfd(void *args)
{
ASYNC_JOB *job;
ASYNC_WAIT_CTX *waitctx;
job = ASYNC_get_current_job();
if (job == NULL)
return 0;
waitctx = ASYNC_get_wait_ctx(job);
if (waitctx == NULL)
return 0;
/* First case: no fd added or removed */
ASYNC_pause_job();
/* Second case: one fd added */
if (!ASYNC_WAIT_CTX_set_wait_fd(waitctx, waitctx, MAGIC_WAIT_FD, NULL, NULL))
return 0;
ASYNC_pause_job();
/* Third case: all fd removed */
if (!ASYNC_WAIT_CTX_clear_fd(waitctx, waitctx))
return 0;
ASYNC_pause_job();
/* Last case: fd added and immediately removed */
if (!ASYNC_WAIT_CTX_set_wait_fd(waitctx, waitctx, MAGIC_WAIT_FD, NULL, NULL))
return 0;
if (!ASYNC_WAIT_CTX_clear_fd(waitctx, waitctx))
return 0;
return 1;
}
static int blockpause(void *args)
{
ASYNC_block_pause();
ASYNC_pause_job();
ASYNC_unblock_pause();
ASYNC_pause_job();
return 1;
}
static int test_ASYNC_init_thread(void)
{
ASYNC_JOB *job1 = NULL, *job2 = NULL, *job3 = NULL;
int funcret1, funcret2, funcret3;
ASYNC_WAIT_CTX *waitctx = NULL;
if ( !ASYNC_init_thread(2, 0)
|| (waitctx = ASYNC_WAIT_CTX_new()) == NULL
|| ASYNC_start_job(&job1, waitctx, &funcret1, only_pause, NULL, 0)
!= ASYNC_PAUSE
|| ASYNC_start_job(&job2, waitctx, &funcret2, only_pause, NULL, 0)
!= ASYNC_PAUSE
|| ASYNC_start_job(&job3, waitctx, &funcret3, only_pause, NULL, 0)
!= ASYNC_NO_JOBS
|| ASYNC_start_job(&job1, waitctx, &funcret1, only_pause, NULL, 0)
!= ASYNC_FINISH
|| ASYNC_start_job(&job3, waitctx, &funcret3, only_pause, NULL, 0)
!= ASYNC_PAUSE
|| ASYNC_start_job(&job2, waitctx, &funcret2, only_pause, NULL, 0)
!= ASYNC_FINISH
|| ASYNC_start_job(&job3, waitctx, &funcret3, only_pause, NULL, 0)
!= ASYNC_FINISH
|| funcret1 != 1
|| funcret2 != 1
|| funcret3 != 1) {
fprintf(stderr, "test_ASYNC_init_thread() failed\n");
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 0;
}
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 1;
}
static int test_callback(void *arg)
{
printf("callback test pass\n");
return 1;
}
static int test_ASYNC_callback_status(void)
{
ASYNC_WAIT_CTX *waitctx = NULL;
int set_arg = 100;
ASYNC_callback_fn get_callback;
void *get_arg;
int set_status = 1;
if ( !ASYNC_init_thread(1, 0)
|| (waitctx = ASYNC_WAIT_CTX_new()) == NULL
|| ASYNC_WAIT_CTX_set_callback(waitctx, test_callback, (void*)&set_arg)
!= 1
|| ASYNC_WAIT_CTX_get_callback(waitctx, &get_callback, &get_arg)
!= 1
|| test_callback != get_callback
|| get_arg != (void*)&set_arg
|| (*get_callback)(get_arg) != 1
|| ASYNC_WAIT_CTX_set_status(waitctx, set_status) != 1
|| set_status != ASYNC_WAIT_CTX_get_status(waitctx)) {
fprintf(stderr, "test_ASYNC_callback_status() failed\n");
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 0;
}
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 1;
}
static int test_ASYNC_start_job(void)
{
ASYNC_JOB *job = NULL;
int funcret;
ASYNC_WAIT_CTX *waitctx = NULL;
ctr = 0;
if ( !ASYNC_init_thread(1, 0)
|| (waitctx = ASYNC_WAIT_CTX_new()) == NULL
|| ASYNC_start_job(&job, waitctx, &funcret, add_two, NULL, 0)
!= ASYNC_PAUSE
|| ctr != 1
|| ASYNC_start_job(&job, waitctx, &funcret, add_two, NULL, 0)
!= ASYNC_FINISH
|| ctr != 2
|| funcret != 2) {
fprintf(stderr, "test_ASYNC_start_job() failed\n");
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 0;
}
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 1;
}
static int test_ASYNC_get_current_job(void)
{
ASYNC_JOB *job = NULL;
int funcret;
ASYNC_WAIT_CTX *waitctx = NULL;
currjob = NULL;
if ( !ASYNC_init_thread(1, 0)
|| (waitctx = ASYNC_WAIT_CTX_new()) == NULL
|| ASYNC_start_job(&job, waitctx, &funcret, save_current, NULL, 0)
!= ASYNC_PAUSE
|| currjob != job
|| ASYNC_start_job(&job, waitctx, &funcret, save_current, NULL, 0)
!= ASYNC_FINISH
|| funcret != 1) {
fprintf(stderr, "test_ASYNC_get_current_job() failed\n");
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 0;
}
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 1;
}
static int test_ASYNC_WAIT_CTX_get_all_fds(void)
{
ASYNC_JOB *job = NULL;
int funcret;
ASYNC_WAIT_CTX *waitctx = NULL;
OSSL_ASYNC_FD fd = OSSL_BAD_ASYNC_FD, delfd = OSSL_BAD_ASYNC_FD;
size_t numfds, numdelfds;
if ( !ASYNC_init_thread(1, 0)
|| (waitctx = ASYNC_WAIT_CTX_new()) == NULL
/* On first run we're not expecting any wait fds */
|| ASYNC_start_job(&job, waitctx, &funcret, waitfd, NULL, 0)
!= ASYNC_PAUSE
|| !ASYNC_WAIT_CTX_get_all_fds(waitctx, NULL, &numfds)
|| numfds != 0
|| !ASYNC_WAIT_CTX_get_changed_fds(waitctx, NULL, &numfds, NULL,
&numdelfds)
|| numfds != 0
|| numdelfds != 0
/* On second run we're expecting one added fd */
|| ASYNC_start_job(&job, waitctx, &funcret, waitfd, NULL, 0)
!= ASYNC_PAUSE
|| !ASYNC_WAIT_CTX_get_all_fds(waitctx, NULL, &numfds)
|| numfds != 1
|| !ASYNC_WAIT_CTX_get_all_fds(waitctx, &fd, &numfds)
|| fd != MAGIC_WAIT_FD
|| (fd = OSSL_BAD_ASYNC_FD, 0) /* Assign to something else */
|| !ASYNC_WAIT_CTX_get_changed_fds(waitctx, NULL, &numfds, NULL,
&numdelfds)
|| numfds != 1
|| numdelfds != 0
|| !ASYNC_WAIT_CTX_get_changed_fds(waitctx, &fd, &numfds, NULL,
&numdelfds)
|| fd != MAGIC_WAIT_FD
/* On third run we expect one deleted fd */
|| ASYNC_start_job(&job, waitctx, &funcret, waitfd, NULL, 0)
!= ASYNC_PAUSE
|| !ASYNC_WAIT_CTX_get_all_fds(waitctx, NULL, &numfds)
|| numfds != 0
|| !ASYNC_WAIT_CTX_get_changed_fds(waitctx, NULL, &numfds, NULL,
&numdelfds)
|| numfds != 0
|| numdelfds != 1
|| !ASYNC_WAIT_CTX_get_changed_fds(waitctx, NULL, &numfds, &delfd,
&numdelfds)
|| delfd != MAGIC_WAIT_FD
/* On last run we are not expecting any wait fd */
|| ASYNC_start_job(&job, waitctx, &funcret, waitfd, NULL, 0)
!= ASYNC_FINISH
|| !ASYNC_WAIT_CTX_get_all_fds(waitctx, NULL, &numfds)
|| numfds != 0
|| !ASYNC_WAIT_CTX_get_changed_fds(waitctx, NULL, &numfds, NULL,
&numdelfds)
|| numfds != 0
|| numdelfds != 0
|| funcret != 1) {
fprintf(stderr, "test_ASYNC_get_wait_fd() failed\n");
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 0;
}
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 1;
}
static int test_ASYNC_block_pause(void)
{
ASYNC_JOB *job = NULL;
int funcret;
ASYNC_WAIT_CTX *waitctx = NULL;
if ( !ASYNC_init_thread(1, 0)
|| (waitctx = ASYNC_WAIT_CTX_new()) == NULL
|| ASYNC_start_job(&job, waitctx, &funcret, blockpause, NULL, 0)
!= ASYNC_PAUSE
|| ASYNC_start_job(&job, waitctx, &funcret, blockpause, NULL, 0)
!= ASYNC_FINISH
|| funcret != 1) {
fprintf(stderr, "test_ASYNC_block_pause() failed\n");
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 0;
}
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
return 1;
}
static int test_ASYNC_start_job_ex(void)
{
ASYNC_JOB *job = NULL;
int funcret;
ASYNC_WAIT_CTX *waitctx = NULL;
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
OSSL_LIB_CTX *oldctx, *tmpctx, *globalctx;
int ret = 0;
if (libctx == NULL) {
fprintf(stderr,
"test_ASYNC_start_job_ex() failed to create libctx\n");
goto err;
}
globalctx = oldctx = OSSL_LIB_CTX_set0_default(libctx);
if ((waitctx = ASYNC_WAIT_CTX_new()) == NULL
|| ASYNC_start_job(&job, waitctx, &funcret, change_deflt_libctx,
NULL, 0)
!= ASYNC_PAUSE) {
fprintf(stderr,
"test_ASYNC_start_job_ex() failed to start job\n");
goto err;
}
/* Reset the libctx temporarily to find out what it is*/
tmpctx = OSSL_LIB_CTX_set0_default(oldctx);
oldctx = OSSL_LIB_CTX_set0_default(tmpctx);
if (tmpctx != libctx) {
fprintf(stderr,
"test_ASYNC_start_job_ex() failed - unexpected libctx\n");
goto err;
}
if (ASYNC_start_job(&job, waitctx, &funcret, change_deflt_libctx, NULL, 0)
!= ASYNC_PAUSE) {
fprintf(stderr,
"test_ASYNC_start_job_ex() - restarting job failed\n");
goto err;
}
/* Reset the libctx and continue with the global default libctx */
tmpctx = OSSL_LIB_CTX_set0_default(oldctx);
if (tmpctx != libctx) {
fprintf(stderr,
"test_ASYNC_start_job_ex() failed - unexpected libctx\n");
goto err;
}
if (ASYNC_start_job(&job, waitctx, &funcret, change_deflt_libctx, NULL, 0)
!= ASYNC_FINISH
|| funcret != 1) {
fprintf(stderr,
"test_ASYNC_start_job_ex() - finishing job failed\n");
goto err;
}
/* Reset the libctx temporarily to find out what it is*/
tmpctx = OSSL_LIB_CTX_set0_default(libctx);
OSSL_LIB_CTX_set0_default(tmpctx);
if (tmpctx != globalctx) {
fprintf(stderr,
"test_ASYNC_start_job_ex() failed - global libctx check failed\n");
goto err;
}
ret = 1;
err:
ASYNC_WAIT_CTX_free(waitctx);
ASYNC_cleanup_thread();
OSSL_LIB_CTX_free(libctx);
return ret;
}
static void *test_alloc_stack(size_t *num)
{
custom_alloc_used = 1;
return OPENSSL_malloc(*num);
}
static void test_free_stack(void *addr)
{
custom_free_used = 1;
OPENSSL_free(addr);
}
static int test_ASYNC_set_mem_functions(void)
{
ASYNC_stack_alloc_fn alloc_fn;
ASYNC_stack_free_fn free_fn;
/* Not all platforms support this */
if (ASYNC_set_mem_functions(test_alloc_stack, test_free_stack) == 0) return 1;
ASYNC_get_mem_functions(&alloc_fn, &free_fn);
if ((alloc_fn != test_alloc_stack) || (free_fn != test_free_stack)) {
fprintf(stderr,
"test_ASYNC_set_mem_functions() - setting and retrieving custom allocators failed\n");
return 0;
}
if (!ASYNC_init_thread(1, 1)) {
fprintf(stderr,
"test_ASYNC_set_mem_functions() - failed initialising ctx pool\n");
return 0;
}
ASYNC_cleanup_thread();
if (!custom_alloc_used || !custom_free_used) {
fprintf(stderr,
"test_ASYNC_set_mem_functions() - custom allocation functions not used\n");
return 0;
}
return 1;
}
int main(int argc, char **argv)
{
if (!ASYNC_is_capable()) {
fprintf(stderr,
"OpenSSL build is not ASYNC capable - skipping async tests\n");
} else {
if (!test_ASYNC_init_thread()
|| !test_ASYNC_callback_status()
|| !test_ASYNC_start_job()
|| !test_ASYNC_get_current_job()
|| !test_ASYNC_WAIT_CTX_get_all_fds()
|| !test_ASYNC_block_pause()
|| !test_ASYNC_start_job_ex()
|| !test_ASYNC_set_mem_functions()) {
return 1;
}
}
printf("PASS\n");
return 0;
}
|
./openssl/test/safe_math_test.c | /*
* Copyright 2021-2022 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>
/*
* Uncomment this if the fallback non-builtin overflow checking is to
* be tested.
*/
/*#define OPENSSL_NO_BUILTIN_OVERFLOW_CHECKING*/
#include "internal/nelem.h"
#include "internal/safe_math.h"
#include "testutil.h"
/* Create the safe math instances we're interested in */
OSSL_SAFE_MATH_SIGNED(int, int)
OSSL_SAFE_MATH_UNSIGNED(uint, unsigned int)
OSSL_SAFE_MATH_UNSIGNED(size_t, size_t)
static const struct {
int a, b;
int sum_err, sub_err, mul_err, div_err, mod_err, div_round_up_err;
int neg_a_err, neg_b_err, abs_a_err, abs_b_err;
} test_ints[] = { /* + - * / % /r -a -b |a||b| */
{ 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ -1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ -1, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ -3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 2, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ -2, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ INT_MAX, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ INT_MAX, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ INT_MAX, 4, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ INT_MAX - 3 , 4, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ INT_MIN, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0 },
{ 1, INT_MIN, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1 },
{ INT_MIN, 2, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0 },
{ 2, INT_MIN, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1 },
{ INT_MIN, -1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0 },
{ INT_MAX, INT_MIN, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1 },
{ INT_MIN, INT_MAX, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0 },
{ 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0 },
};
static int test_int_ops(int n)
{
int err, r, s;
const int a = test_ints[n].a, b = test_ints[n].b;
err = 0;
r = safe_add_int(a, b, &err);
if (!TEST_int_eq(err, test_ints[n].sum_err)
|| (!err && !TEST_int_eq(r, a + b)))
goto err;
err = 0;
r = safe_sub_int(a, b, &err);
if (!TEST_int_eq(err, test_ints[n].sub_err)
|| (!err && !TEST_int_eq(r, a - b)))
goto err;
err = 0;
r = safe_mul_int(a, b, &err);
if (!TEST_int_eq(err, test_ints[n].mul_err)
|| (!err && !TEST_int_eq(r, a * b)))
goto err;
err = 0;
r = safe_div_int(a, b, &err);
if (!TEST_int_eq(err, test_ints[n].div_err)
|| (!err && !TEST_int_eq(r, a / b)))
goto err;
err = 0;
r = safe_mod_int(a, b, &err);
if (!TEST_int_eq(err, test_ints[n].mod_err)
|| (!err && !TEST_int_eq(r, a % b)))
goto err;
err = 0;
r = safe_div_round_up_int(a, b, &err);
if (!TEST_int_eq(err, test_ints[n].div_round_up_err))
goto err;
s = safe_mod_int(a, b, &err);
s = safe_add_int(safe_div_int(a, b, &err), s != 0, &err);
if (!err && !TEST_int_eq(r, s))
goto err;
err = 0;
r = safe_neg_int(a, &err);
if (!TEST_int_eq(err, test_ints[n].neg_a_err)
|| (!err && !TEST_int_eq(r, -a)))
goto err;
err = 0;
r = safe_neg_int(b, &err);
if (!TEST_int_eq(err, test_ints[n].neg_b_err)
|| (!err && !TEST_int_eq(r, -b)))
goto err;
err = 0;
r = safe_abs_int(a, &err);
if (!TEST_int_eq(err, test_ints[n].abs_a_err)
|| (!err && !TEST_int_eq(r, a < 0 ? -a : a)))
goto err;
err = 0;
r = safe_abs_int(b, &err);
if (!TEST_int_eq(err, test_ints[n].abs_b_err)
|| (!err && !TEST_int_eq(r, b < 0 ? -b : b)))
goto err;
return 1;
err:
TEST_info("a = %d b = %d r = %d err = %d", a, b, r, err);
return 0;
}
static const struct {
unsigned int a, b;
int sum_err, sub_err, mul_err, div_err, mod_err, div_round_up_err;
} test_uints[] = { /* + - * / % /r */
{ 3, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 3, 0, 1, 0, 0, 0, 0 },
{ UINT_MAX, 1, 1, 0, 0, 0, 0, 0 },
{ UINT_MAX, 2, 1, 0, 1, 0, 0, 0 },
{ UINT_MAX, 16, 1, 0, 1, 0, 0, 0 },
{ UINT_MAX - 13, 16, 1, 0, 1, 0, 0, 0 },
{ 1, UINT_MAX, 1, 1, 0, 0, 0, 0 },
{ 2, UINT_MAX, 1, 1, 1, 0, 0, 0 },
{ UINT_MAX, 0, 0, 0, 0, 1, 1, 1 },
};
static int test_uint_ops(int n)
{
int err;
unsigned int r;
const unsigned int a = test_uints[n].a, b = test_uints[n].b;
err = 0;
r = safe_add_uint(a, b, &err);
if (!TEST_int_eq(err, test_uints[n].sum_err)
|| (!err && !TEST_uint_eq(r, a + b)))
goto err;
err = 0;
r = safe_sub_uint(a, b, &err);
if (!TEST_int_eq(err, test_uints[n].sub_err)
|| (!err && !TEST_uint_eq(r, a - b)))
goto err;
err = 0;
r = safe_mul_uint(a, b, &err);
if (!TEST_int_eq(err, test_uints[n].mul_err)
|| (!err && !TEST_uint_eq(r, a * b)))
goto err;
err = 0;
r = safe_div_uint(a, b, &err);
if (!TEST_int_eq(err, test_uints[n].div_err)
|| (!err && !TEST_uint_eq(r, a / b)))
goto err;
err = 0;
r = safe_mod_uint(a, b, &err);
if (!TEST_int_eq(err, test_uints[n].mod_err)
|| (!err && !TEST_uint_eq(r, a % b)))
goto err;
err = 0;
r = safe_div_round_up_uint(a, b, &err);
if (!TEST_int_eq(err, test_uints[n].div_round_up_err)
|| (!err && !TEST_uint_eq(r, a / b + (a % b != 0))))
goto err;
err = 0;
r = safe_neg_uint(a, &err);
if (!TEST_int_eq(err, a != 0) || (!err && !TEST_uint_eq(r, 0)))
goto err;
err = 0;
r = safe_neg_uint(b, &err);
if (!TEST_int_eq(err, b != 0) || (!err && !TEST_uint_eq(r, 0)))
goto err;
err = 0;
r = safe_abs_uint(a, &err);
if (!TEST_int_eq(err, 0) || !TEST_uint_eq(r, a))
goto err;
err = 0;
r = safe_abs_uint(b, &err);
if (!TEST_int_eq(err, 0) || !TEST_uint_eq(r, b))
goto err;
return 1;
err:
TEST_info("a = %u b = %u r = %u err = %d", a, b, r, err);
return 0;
}
static const struct {
size_t a, b;
int sum_err, sub_err, mul_err, div_err, mod_err, div_round_up_err;
} test_size_ts[] = {
{ 3, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 3, 0, 1, 0, 0, 0, 0 },
{ 36, 8, 0, 0, 0, 0, 0, 0 },
{ SIZE_MAX, 1, 1, 0, 0, 0, 0, 0 },
{ SIZE_MAX, 2, 1, 0, 1, 0, 0, 0 },
{ SIZE_MAX, 8, 1, 0, 1, 0, 0, 0 },
{ SIZE_MAX - 3, 8, 1, 0, 1, 0, 0, 0 },
{ 1, SIZE_MAX, 1, 1, 0, 0, 0, 0 },
{ 2, SIZE_MAX, 1, 1, 1, 0, 0, 0 },
{ 11, 0, 0, 0, 0, 1, 1, 1 },
};
static int test_size_t_ops(int n)
{
int err;
size_t r;
const size_t a = test_size_ts[n].a, b = test_size_ts[n].b;
err = 0;
r = safe_add_size_t(a, b, &err);
if (!TEST_int_eq(err, test_size_ts[n].sum_err)
|| (!err && !TEST_size_t_eq(r, a + b)))
goto err;
err = 0;
r = safe_sub_size_t(a, b, &err);
if (!TEST_int_eq(err, test_size_ts[n].sub_err)
|| (!err && !TEST_size_t_eq(r, a - b)))
goto err;
err = 0;
r = safe_mul_size_t(a, b, &err);
if (!TEST_int_eq(err, test_size_ts[n].mul_err)
|| (!err && !TEST_size_t_eq(r, a * b)))
goto err;
err = 0;
r = safe_div_size_t(a, b, &err);
if (!TEST_int_eq(err, test_size_ts[n].div_err)
|| (!err && !TEST_size_t_eq(r, a / b)))
goto err;
err = 0;
r = safe_mod_size_t(a, b, &err);
if (!TEST_int_eq(err, test_size_ts[n].mod_err)
|| (!err && !TEST_size_t_eq(r, a % b)))
goto err;
err = 0;
r = safe_div_round_up_size_t(a, b, &err);
if (!TEST_int_eq(err, test_size_ts[n].div_round_up_err)
|| (!err && !TEST_size_t_eq(r, a / b + (a % b != 0))))
goto err;
err = 0;
r = safe_neg_size_t(a, &err);
if (!TEST_int_eq(err, a != 0) || (!err && !TEST_size_t_eq(r, 0)))
goto err;
err = 0;
r = safe_neg_size_t(b, &err);
if (!TEST_int_eq(err, b != 0) || (!err && !TEST_size_t_eq(r, 0)))
goto err;
err = 0;
r = safe_abs_size_t(a, &err);
if (!TEST_int_eq(err, 0) || !TEST_size_t_eq(r, a))
goto err;
err = 0;
r = safe_abs_size_t(b, &err);
if (!TEST_int_eq(err, 0) || !TEST_size_t_eq(r, b))
goto err;
return 1;
err:
TEST_info("a = %zu b = %zu r = %zu err = %d", a, b, r, err);
return 0;
}
static const struct {
int a, b, c;
int err;
} test_muldiv_ints[] = {
{ 3, 1, 2, 0 },
{ 1, 3, 2, 0 },
{ -3, 1, 2, 0 },
{ 1, 3, -2, 0 },
{ INT_MAX, INT_MAX, INT_MAX, 0 },
{ INT_MIN, INT_MIN, INT_MAX, 1 },
{ INT_MIN, INT_MIN, INT_MIN, 0 },
{ INT_MAX, 2, 4, 0 },
{ 8, INT_MAX, 4, 1 },
{ INT_MAX, 8, 4, 1 },
{ INT_MIN, 2, 4, 1 },
{ 8, INT_MIN, 4, 1 },
{ INT_MIN, 8, 4, 1 },
{ 3, 4, 0, 1 },
};
static int test_int_muldiv(int n)
{
int err = 0;
int r, real = 0;
const int a = test_muldiv_ints[n].a;
const int b = test_muldiv_ints[n].b;
const int c = test_muldiv_ints[n].c;
r = safe_muldiv_int(a, b, c, &err);
if (c != 0)
real = (int)((int64_t)a * (int64_t)b / (int64_t)c);
if (!TEST_int_eq(err, test_muldiv_ints[n].err)
|| (!err && !TEST_int_eq(r, real))) {
TEST_info("%d * %d / %d r = %d err = %d", a, b, c, r, err);
return 0;
}
return 1;
}
static const struct {
unsigned int a, b, c;
int err;
} test_muldiv_uints[] = {
{ 3, 1, 2, 0 },
{ 1, 3, 2, 0 },
{ UINT_MAX, UINT_MAX, UINT_MAX, 0 },
{ UINT_MAX, 2, 4, 0 },
{ 8, UINT_MAX, 4, 1 },
{ UINT_MAX, 8, 4, 1 },
{ 3, 4, 0, 1 },
};
static int test_uint_muldiv(int n)
{
int err = 0;
unsigned int r, real = 0;
const unsigned int a = test_muldiv_uints[n].a;
const unsigned int b = test_muldiv_uints[n].b;
const unsigned int c = test_muldiv_uints[n].c;
r = safe_muldiv_uint(a, b, c, &err);
if (c != 0)
real = (unsigned int)((uint64_t)a * (uint64_t)b / (uint64_t)c);
if (!TEST_int_eq(err, test_muldiv_uints[n].err)
|| (!err && !TEST_uint_eq(r, real))) {
TEST_info("%u * %u / %u r = %u err = %d", a, b, c, r, err);
return 0;
}
return 1;
}
int setup_tests(void)
{
ADD_ALL_TESTS(test_int_ops, OSSL_NELEM(test_ints));
ADD_ALL_TESTS(test_uint_ops, OSSL_NELEM(test_uints));
ADD_ALL_TESTS(test_size_t_ops, OSSL_NELEM(test_size_ts));
ADD_ALL_TESTS(test_int_muldiv, OSSL_NELEM(test_muldiv_ints));
ADD_ALL_TESTS(test_uint_muldiv, OSSL_NELEM(test_muldiv_uints));
return 1;
}
|
./openssl/test/ssl_handshake_rtt_test.c | /*
* Copyright 2023 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
*/
/*
* We need access to the deprecated low level HMAC APIs for legacy purposes
* when the deprecated calls are not hidden
*/
#ifndef OPENSSL_NO_DEPRECATED_3_0
# define OPENSSL_SUPPRESS_DEPRECATED
#endif
#include <stdio.h>
#include <string.h>
#include <openssl/opensslconf.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/ssl.h>
#include <openssl/engine.h>
#include "helpers/ssltestlib.h"
#include "testutil.h"
#include "testutil/output.h"
#include "internal/ktls.h"
#include "../ssl/ssl_local.h"
#include "../ssl/statem/statem_local.h"
static OSSL_LIB_CTX *libctx = NULL;
static char *cert = NULL;
static char *privkey = NULL;
/*
* Test 0: Clientside handshake RTT (TLSv1.2)
* Test 1: Serverside handshake RTT (TLSv1.2)
* Test 2: Clientside handshake RTT (TLSv1.3)
* Test 3: Serverside handshake RTT (TLSv1.3)
* Test 4: Clientside handshake RTT with Early Data (TLSv1.3)
*/
static int test_handshake_rtt(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
SSL_CONNECTION *s = NULL;
OSSL_STATEM *st = NULL;
uint64_t rtt;
#ifdef OPENSSL_NO_TLS1_2
if (tst <= 1)
return 1;
#endif
#ifdef OSSL_NO_USABLE_TLS1_3
if (tst >= 2)
return 1;
#endif
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
(tst <= 1) ? TLS1_2_VERSION
: TLS1_3_VERSION,
&sctx, &cctx, cert, privkey))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
s = SSL_CONNECTION_FROM_SSL(tst % 2 == 0 ? clientssl : serverssl);
if (!TEST_ptr(s) || !TEST_ptr(st = &s->statem))
return 0;
/* implicitly set handshake rtt with a delay */
switch (tst) {
case 0:
st->hand_state = TLS_ST_CW_CLNT_HELLO;
ossl_statem_client_write_transition(s);
OSSL_sleep(1);
st->hand_state = TLS_ST_CR_SRVR_DONE;
ossl_statem_client_write_transition(s);
break;
case 1:
st->hand_state = TLS_ST_SW_SRVR_DONE;
ossl_statem_server_write_transition(s);
OSSL_sleep(1);
st->hand_state = TLS_ST_SR_FINISHED;
ossl_statem_server_write_transition(s);
break;
case 2:
st->hand_state = TLS_ST_CW_CLNT_HELLO;
ossl_statem_client_write_transition(s);
OSSL_sleep(1);
st->hand_state = TLS_ST_CR_SRVR_DONE;
ossl_statem_client_write_transition(s);
break;
case 3:
st->hand_state = TLS_ST_SW_SRVR_DONE;
ossl_statem_server_write_transition(s);
OSSL_sleep(1);
st->hand_state = TLS_ST_SR_FINISHED;
ossl_statem_server_write_transition(s);
break;
case 4:
st->hand_state = TLS_ST_EARLY_DATA;
ossl_statem_client_write_transition(s);
OSSL_sleep(1);
st->hand_state = TLS_ST_CR_SRVR_DONE;
ossl_statem_client_write_transition(s);
break;
}
if (!TEST_int_gt(SSL_get_handshake_rtt(SSL_CONNECTION_GET_SSL(s), &rtt), 0))
goto end;
/* 1 millisec is the absolute minimum it could be given the delay */
if (!TEST_uint64_t_ge(rtt, 1000))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
int setup_tests(void)
{
ADD_ALL_TESTS(test_handshake_rtt, 5);
return 1;
}
|
./openssl/test/sslcorrupttest.c | /*
* 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
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <string.h>
#include "helpers/ssltestlib.h"
#include "testutil.h"
static int docorrupt = 0;
static void copy_flags(BIO *bio)
{
int flags;
BIO *next = BIO_next(bio);
flags = BIO_test_flags(next, BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_RWS);
BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_RWS);
BIO_set_flags(bio, flags);
}
static int tls_corrupt_read(BIO *bio, char *out, int outl)
{
int ret;
BIO *next = BIO_next(bio);
ret = BIO_read(next, out, outl);
copy_flags(bio);
return ret;
}
static int tls_corrupt_write(BIO *bio, const char *in, int inl)
{
int ret;
BIO *next = BIO_next(bio);
char *copy;
if (docorrupt) {
if (!TEST_ptr(copy = OPENSSL_memdup(in, inl)))
return 0;
/* corrupt last bit of application data */
copy[inl-1] ^= 1;
ret = BIO_write(next, copy, inl);
OPENSSL_free(copy);
} else {
ret = BIO_write(next, in, inl);
}
copy_flags(bio);
return ret;
}
static long tls_corrupt_ctrl(BIO *bio, int cmd, long num, void *ptr)
{
long ret;
BIO *next = BIO_next(bio);
if (next == NULL)
return 0;
switch (cmd) {
case BIO_CTRL_DUP:
ret = 0L;
break;
default:
ret = BIO_ctrl(next, cmd, num, ptr);
break;
}
return ret;
}
static int tls_corrupt_gets(BIO *bio, char *buf, int size)
{
/* We don't support this - not needed anyway */
return -1;
}
static int tls_corrupt_puts(BIO *bio, const char *str)
{
/* We don't support this - not needed anyway */
return -1;
}
static int tls_corrupt_new(BIO *bio)
{
BIO_set_init(bio, 1);
return 1;
}
static int tls_corrupt_free(BIO *bio)
{
BIO_set_init(bio, 0);
return 1;
}
#define BIO_TYPE_CUSTOM_FILTER (0x80 | BIO_TYPE_FILTER)
static BIO_METHOD *method_tls_corrupt = NULL;
/* Note: Not thread safe! */
static const BIO_METHOD *bio_f_tls_corrupt_filter(void)
{
if (method_tls_corrupt == NULL) {
method_tls_corrupt = BIO_meth_new(BIO_TYPE_CUSTOM_FILTER,
"TLS corrupt filter");
if (method_tls_corrupt == NULL
|| !BIO_meth_set_write(method_tls_corrupt, tls_corrupt_write)
|| !BIO_meth_set_read(method_tls_corrupt, tls_corrupt_read)
|| !BIO_meth_set_puts(method_tls_corrupt, tls_corrupt_puts)
|| !BIO_meth_set_gets(method_tls_corrupt, tls_corrupt_gets)
|| !BIO_meth_set_ctrl(method_tls_corrupt, tls_corrupt_ctrl)
|| !BIO_meth_set_create(method_tls_corrupt, tls_corrupt_new)
|| !BIO_meth_set_destroy(method_tls_corrupt, tls_corrupt_free))
return NULL;
}
return method_tls_corrupt;
}
static void bio_f_tls_corrupt_filter_free(void)
{
BIO_meth_free(method_tls_corrupt);
}
/*
* The test is supposed to be executed with RSA key, customarily
* with apps/server.pem used even in other tests. For this reason
* |cipher_list| is initialized with RSA ciphers' names. This
* naturally means that if test is to be re-purposed for other
* type of key, then NID_auth_* filter below would need adjustment.
*/
static const char **cipher_list = NULL;
static int setup_cipher_list(void)
{
SSL_CTX *ctx = NULL;
SSL *ssl = NULL;
STACK_OF(SSL_CIPHER) *sk_ciphers = NULL;
int i, j, numciphers = 0;
if (!TEST_ptr(ctx = SSL_CTX_new(TLS_server_method()))
|| !TEST_ptr(ssl = SSL_new(ctx))
|| !TEST_ptr(sk_ciphers = SSL_get1_supported_ciphers(ssl)))
goto err;
/*
* The |cipher_list| will be filled only with names of RSA ciphers,
* so that some of the allocated space will be wasted, but the loss
* is deemed acceptable...
*/
cipher_list = OPENSSL_malloc(sk_SSL_CIPHER_num(sk_ciphers) *
sizeof(cipher_list[0]));
if (!TEST_ptr(cipher_list))
goto err;
for (j = 0, i = 0; i < sk_SSL_CIPHER_num(sk_ciphers); i++) {
const SSL_CIPHER *cipher = sk_SSL_CIPHER_value(sk_ciphers, i);
if (SSL_CIPHER_get_auth_nid(cipher) == NID_auth_rsa)
cipher_list[j++] = SSL_CIPHER_get_name(cipher);
}
if (TEST_int_ne(j, 0))
numciphers = j;
err:
sk_SSL_CIPHER_free(sk_ciphers);
SSL_free(ssl);
SSL_CTX_free(ctx);
return numciphers;
}
static char *cert = NULL;
static char *privkey = NULL;
static int test_ssl_corrupt(int testidx)
{
static unsigned char junk[16000] = { 0 };
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *server = NULL, *client = NULL;
BIO *c_to_s_fbio;
int testresult = 0;
STACK_OF(SSL_CIPHER) *ciphers;
const SSL_CIPHER *currcipher;
int err;
docorrupt = 0;
TEST_info("Starting #%d, %s", testidx, cipher_list[testidx]);
if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
return 0;
if (!TEST_true(SSL_CTX_set_dh_auto(sctx, 1))
|| !TEST_true(SSL_CTX_set_cipher_list(cctx, cipher_list[testidx]))
|| !TEST_true(SSL_CTX_set_ciphersuites(cctx, ""))
|| !TEST_ptr(ciphers = SSL_CTX_get_ciphers(cctx))
|| !TEST_int_eq(sk_SSL_CIPHER_num(ciphers), 1)
|| !TEST_ptr(currcipher = sk_SSL_CIPHER_value(ciphers, 0)))
goto end;
/*
* No ciphers we are using are TLSv1.3 compatible so we should not attempt
* to negotiate TLSv1.3
*/
if (!TEST_true(SSL_CTX_set_max_proto_version(cctx, TLS1_2_VERSION)))
goto end;
if (!TEST_ptr(c_to_s_fbio = BIO_new(bio_f_tls_corrupt_filter())))
goto end;
/* BIO is freed by create_ssl_connection on error */
if (!TEST_true(create_ssl_objects(sctx, cctx, &server, &client, NULL,
c_to_s_fbio)))
goto end;
if (!TEST_true(create_ssl_connection(server, client, SSL_ERROR_NONE)))
goto end;
docorrupt = 1;
if (!TEST_int_ge(SSL_write(client, junk, sizeof(junk)), 0))
goto end;
if (!TEST_int_lt(SSL_read(server, junk, sizeof(junk)), 0))
goto end;
do {
err = ERR_get_error();
if (err == 0) {
TEST_error("Decryption failed or bad record MAC not seen");
goto end;
}
} while (ERR_GET_REASON(err) != SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);
testresult = 1;
end:
SSL_free(server);
SSL_free(client);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
int setup_tests(void)
{
int n;
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(cert = test_get_argument(0))
|| !TEST_ptr(privkey = test_get_argument(1)))
return 0;
n = setup_cipher_list();
if (n > 0)
ADD_ALL_TESTS(test_ssl_corrupt, n);
return 1;
}
void cleanup_tests(void)
{
bio_f_tls_corrupt_filter_free();
OPENSSL_free(cipher_list);
}
|
./openssl/test/bio_dgram_test.c | /*
* Copyright 2022-2023 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 <string.h>
#include <openssl/bio.h>
#include <openssl/rand.h>
#include "testutil.h"
#include "internal/sockets.h"
#include "internal/bio_addr.h"
#if !defined(OPENSSL_NO_DGRAM) && !defined(OPENSSL_NO_SOCK)
static int compare_addr(const BIO_ADDR *a, const BIO_ADDR *b)
{
struct in_addr xa, xb;
#if OPENSSL_USE_IPV6
struct in6_addr xa6, xb6;
#endif
void *pa, *pb;
size_t slen, tmplen;
if (BIO_ADDR_family(a) != BIO_ADDR_family(b))
return 0;
if (BIO_ADDR_family(a) == AF_INET) {
pa = &xa;
pb = &xb;
slen = sizeof(xa);
}
#if OPENSSL_USE_IPV6
else if (BIO_ADDR_family(a) == AF_INET6) {
pa = &xa6;
pb = &xb6;
slen = sizeof(xa6);
}
#endif
else {
return 0;
}
tmplen = slen;
if (!TEST_int_eq(BIO_ADDR_rawaddress(a, pa, &tmplen), 1))
return 0;
tmplen = slen;
if (!TEST_int_eq(BIO_ADDR_rawaddress(b, pb, &tmplen), 1))
return 0;
if (!TEST_mem_eq(pa, slen, pb, slen))
return 0;
if (!TEST_int_eq(BIO_ADDR_rawport(a), BIO_ADDR_rawport(b)))
return 0;
return 1;
}
static int do_sendmmsg(BIO *b, BIO_MSG *msg,
size_t num_msg, uint64_t flags,
size_t *num_processed)
{
size_t done;
for (done = 0; done < num_msg; ) {
if (!BIO_sendmmsg(b, msg + done, sizeof(BIO_MSG),
num_msg - done, flags, num_processed))
return 0;
done += *num_processed;
}
*num_processed = done;
return 1;
}
static int do_recvmmsg(BIO *b, BIO_MSG *msg,
size_t num_msg, uint64_t flags,
size_t *num_processed)
{
size_t done;
for (done = 0; done < num_msg; ) {
if (!BIO_recvmmsg(b, msg + done, sizeof(BIO_MSG),
num_msg - done, flags, num_processed))
return 0;
done += *num_processed;
}
*num_processed = done;
return 1;
}
static int test_bio_dgram_impl(int af, int use_local)
{
int testresult = 0;
BIO *b1 = NULL, *b2 = NULL;
int fd1 = -1, fd2 = -1;
BIO_ADDR *addr1 = NULL, *addr2 = NULL, *addr3 = NULL, *addr4 = NULL,
*addr5 = NULL, *addr6 = NULL;
struct in_addr ina;
#if OPENSSL_USE_IPV6
struct in6_addr ina6;
#endif
void *pina;
size_t inal, i;
union BIO_sock_info_u info1 = {0}, info2 = {0};
char rx_buf[128], rx_buf2[128];
BIO_MSG tx_msg[128], rx_msg[128];
char tx_buf[128];
size_t num_processed = 0;
if (af == AF_INET) {
TEST_info("# Testing with AF_INET, local=%d\n", use_local);
pina = &ina;
inal = sizeof(ina);
}
#if OPENSSL_USE_IPV6
else if (af == AF_INET6) {
TEST_info("# Testing with AF_INET6, local=%d\n", use_local);
pina = &ina6;
inal = sizeof(ina6);
}
#endif
else {
goto err;
}
memset(pina, 0, inal);
ina.s_addr = htonl(0x7f000001UL);
#if OPENSSL_USE_IPV6
ina6.s6_addr[15] = 1;
#endif
addr1 = BIO_ADDR_new();
if (!TEST_ptr(addr1))
goto err;
addr2 = BIO_ADDR_new();
if (!TEST_ptr(addr2))
goto err;
addr3 = BIO_ADDR_new();
if (!TEST_ptr(addr3))
goto err;
addr4 = BIO_ADDR_new();
if (!TEST_ptr(addr4))
goto err;
addr5 = BIO_ADDR_new();
if (!TEST_ptr(addr5))
goto err;
addr6 = BIO_ADDR_new();
if (!TEST_ptr(addr6))
goto err;
if (!TEST_int_eq(BIO_ADDR_rawmake(addr1, af, pina, inal, 0), 1))
goto err;
if (!TEST_int_eq(BIO_ADDR_rawmake(addr2, af, pina, inal, 0), 1))
goto err;
fd1 = BIO_socket(af, SOCK_DGRAM, IPPROTO_UDP, 0);
if (!TEST_int_ge(fd1, 0))
goto err;
fd2 = BIO_socket(af, SOCK_DGRAM, IPPROTO_UDP, 0);
if (!TEST_int_ge(fd2, 0))
goto err;
if (BIO_bind(fd1, addr1, 0) <= 0
|| BIO_bind(fd2, addr2, 0) <= 0) {
testresult = TEST_skip("BIO_bind() failed - assuming it's an unavailable address family");
goto err;
}
info1.addr = addr1;
if (!TEST_int_gt(BIO_sock_info(fd1, BIO_SOCK_INFO_ADDRESS, &info1), 0))
goto err;
info2.addr = addr2;
if (!TEST_int_gt(BIO_sock_info(fd2, BIO_SOCK_INFO_ADDRESS, &info2), 0))
goto err;
if (!TEST_int_gt(BIO_ADDR_rawport(addr1), 0))
goto err;
if (!TEST_int_gt(BIO_ADDR_rawport(addr2), 0))
goto err;
b1 = BIO_new_dgram(fd1, 0);
if (!TEST_ptr(b1))
goto err;
b2 = BIO_new_dgram(fd2, 0);
if (!TEST_ptr(b2))
goto err;
if (!TEST_int_gt(BIO_dgram_set_peer(b1, addr2), 0))
goto err;
if (!TEST_int_gt(BIO_write(b1, "hello", 5), 0))
goto err;
/* Receiving automatically sets peer as source addr */
if (!TEST_int_eq(BIO_read(b2, rx_buf, sizeof(rx_buf)), 5))
goto err;
if (!TEST_mem_eq(rx_buf, 5, "hello", 5))
goto err;
if (!TEST_int_gt(BIO_dgram_get_peer(b2, addr3), 0))
goto err;
if (!TEST_int_eq(compare_addr(addr3, addr1), 1))
goto err;
/* Clear peer */
if (!TEST_int_gt(BIO_ADDR_rawmake(addr3, af, pina, inal, 0), 0))
goto err;
if (!TEST_int_gt(BIO_dgram_set_peer(b1, addr3), 0))
goto err;
if (!TEST_int_gt(BIO_dgram_set_peer(b2, addr3), 0))
goto err;
/* Now test using sendmmsg/recvmmsg with no peer set */
tx_msg[0].data = "apple";
tx_msg[0].data_len = 5;
tx_msg[0].peer = NULL;
tx_msg[0].local = NULL;
tx_msg[0].flags = 0;
tx_msg[1].data = "orange";
tx_msg[1].data_len = 6;
tx_msg[1].peer = NULL;
tx_msg[1].local = NULL;
tx_msg[1].flags = 0;
/* First effort should fail due to missing destination address */
if (!TEST_false(do_sendmmsg(b1, tx_msg, 2, 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 0))
goto err;
/*
* Second effort should fail due to local being requested
* when not enabled
*/
tx_msg[0].peer = addr2;
tx_msg[0].local = addr1;
tx_msg[1].peer = addr2;
tx_msg[1].local = addr1;
if (!TEST_false(do_sendmmsg(b1, tx_msg, 2, 0, &num_processed)
|| !TEST_size_t_eq(num_processed, 0)))
goto err;
/* Enable local if we are using it */
if (BIO_dgram_get_local_addr_cap(b1) > 0 && use_local) {
if (!TEST_int_eq(BIO_dgram_set_local_addr_enable(b1, 1), 1))
goto err;
} else {
tx_msg[0].local = NULL;
tx_msg[1].local = NULL;
use_local = 0;
}
/* Third effort should succeed */
if (!TEST_true(do_sendmmsg(b1, tx_msg, 2, 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 2))
goto err;
/* Now try receiving */
rx_msg[0].data = rx_buf;
rx_msg[0].data_len = sizeof(rx_buf);
rx_msg[0].peer = addr3;
rx_msg[0].local = addr4;
rx_msg[0].flags = (1UL<<31); /* undefined flag, should be erased */
memset(rx_buf, 0, sizeof(rx_buf));
rx_msg[1].data = rx_buf2;
rx_msg[1].data_len = sizeof(rx_buf2);
rx_msg[1].peer = addr5;
rx_msg[1].local = addr6;
rx_msg[1].flags = (1UL<<31); /* undefined flag, should be erased */
memset(rx_buf2, 0, sizeof(rx_buf2));
/*
* Should fail at first due to local being requested when not
* enabled
*/
if (!TEST_false(do_recvmmsg(b2, rx_msg, 2, 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 0))
goto err;
/* Fields have not been modified */
if (!TEST_int_eq((int)rx_msg[0].data_len, sizeof(rx_buf)))
goto err;
if (!TEST_int_eq((int)rx_msg[1].data_len, sizeof(rx_buf2)))
goto err;
if (!TEST_ulong_eq((unsigned long)rx_msg[0].flags, 1UL<<31))
goto err;
if (!TEST_ulong_eq((unsigned long)rx_msg[1].flags, 1UL<<31))
goto err;
/* Enable local if we are using it */
if (BIO_dgram_get_local_addr_cap(b2) > 0 && use_local) {
if (!TEST_int_eq(BIO_dgram_set_local_addr_enable(b2, 1), 1))
goto err;
} else {
rx_msg[0].local = NULL;
rx_msg[1].local = NULL;
use_local = 0;
}
/* Do the receive. */
if (!TEST_true(do_recvmmsg(b2, rx_msg, 2, 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 2))
goto err;
/* data_len should have been updated correctly */
if (!TEST_int_eq((int)rx_msg[0].data_len, 5))
goto err;
if (!TEST_int_eq((int)rx_msg[1].data_len, 6))
goto err;
/* flags should have been zeroed */
if (!TEST_int_eq((int)rx_msg[0].flags, 0))
goto err;
if (!TEST_int_eq((int)rx_msg[1].flags, 0))
goto err;
/* peer address should match expected */
if (!TEST_int_eq(compare_addr(addr3, addr1), 1))
goto err;
if (!TEST_int_eq(compare_addr(addr5, addr1), 1))
goto err;
/*
* Do not test local address yet as some platforms do not reliably return
* local addresses for messages queued for RX before local address support
* was enabled. Instead, send some new messages and test they're received
* with the correct local addresses.
*/
if (!TEST_true(do_sendmmsg(b1, tx_msg, 2, 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 2))
goto err;
/* Receive the messages. */
rx_msg[0].data_len = sizeof(rx_buf);
rx_msg[1].data_len = sizeof(rx_buf2);
if (!TEST_true(do_recvmmsg(b2, rx_msg, 2, 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 2))
goto err;
if (rx_msg[0].local != NULL) {
/* If we are using local, it should match expected */
if (!TEST_int_eq(compare_addr(addr4, addr2), 1))
goto err;
if (!TEST_int_eq(compare_addr(addr6, addr2), 1))
goto err;
}
/*
* Try sending more than can be handled in one sendmmsg call (when using the
* sendmmsg implementation)
*/
for (i = 0; i < OSSL_NELEM(tx_msg); ++i) {
tx_buf[i] = (char)i;
tx_msg[i].data = tx_buf + i;
tx_msg[i].data_len = 1;
tx_msg[i].peer = addr2;
tx_msg[i].local = use_local ? addr1 : NULL;
tx_msg[i].flags = 0;
}
if (!TEST_true(do_sendmmsg(b1, tx_msg, OSSL_NELEM(tx_msg), 0, &num_processed))
|| !TEST_size_t_eq(num_processed, OSSL_NELEM(tx_msg)))
goto err;
/*
* Try receiving more than can be handled in one recvmmsg call (when using
* the recvmmsg implementation)
*/
for (i = 0; i < OSSL_NELEM(rx_msg); ++i) {
rx_buf[i] = '\0';
rx_msg[i].data = rx_buf + i;
rx_msg[i].data_len = 1;
rx_msg[i].peer = NULL;
rx_msg[i].local = NULL;
rx_msg[i].flags = 0;
}
if (!TEST_true(do_recvmmsg(b2, rx_msg, OSSL_NELEM(rx_msg), 0, &num_processed))
|| !TEST_size_t_eq(num_processed, OSSL_NELEM(rx_msg)))
goto err;
if (!TEST_mem_eq(tx_buf, OSSL_NELEM(tx_msg), rx_buf, OSSL_NELEM(tx_msg)))
goto err;
testresult = 1;
err:
BIO_free(b1);
BIO_free(b2);
if (fd1 >= 0)
BIO_closesocket(fd1);
if (fd2 >= 0)
BIO_closesocket(fd2);
BIO_ADDR_free(addr1);
BIO_ADDR_free(addr2);
BIO_ADDR_free(addr3);
BIO_ADDR_free(addr4);
BIO_ADDR_free(addr5);
BIO_ADDR_free(addr6);
return testresult;
}
struct bio_dgram_case {
int af, local;
};
static const struct bio_dgram_case bio_dgram_cases[] = {
/* Test without local */
{ AF_INET, 0 },
#if OPENSSL_USE_IPV6
{ AF_INET6, 0 },
#endif
/* Test with local */
{ AF_INET, 1 },
#if OPENSSL_USE_IPV6
{ AF_INET6, 1 }
#endif
};
static int test_bio_dgram(int idx)
{
return test_bio_dgram_impl(bio_dgram_cases[idx].af,
bio_dgram_cases[idx].local);
}
# if !defined(OPENSSL_NO_CHACHA)
static int random_data(const uint32_t *key, uint8_t *data, size_t data_len, size_t offset)
{
int ret = 0, outl;
EVP_CIPHER_CTX *ctx = NULL;
EVP_CIPHER *cipher = NULL;
static const uint8_t zeroes[2048];
uint32_t counter[4] = {0};
counter[0] = (uint32_t)offset;
ctx = EVP_CIPHER_CTX_new();
if (ctx == NULL)
goto err;
cipher = EVP_CIPHER_fetch(NULL, "ChaCha20", NULL);
if (cipher == NULL)
goto err;
if (EVP_EncryptInit_ex2(ctx, cipher, (uint8_t *)key, (uint8_t *)counter, NULL) == 0)
goto err;
while (data_len > 0) {
outl = data_len > sizeof(zeroes) ? (int)sizeof(zeroes) : (int)data_len;
if (EVP_EncryptUpdate(ctx, data, &outl, zeroes, outl) != 1)
goto err;
data += outl;
data_len -= outl;
}
ret = 1;
err:
EVP_CIPHER_CTX_free(ctx);
EVP_CIPHER_free(cipher);
return ret;
}
static int test_bio_dgram_pair(int idx)
{
int testresult = 0, blen, mtu1, mtu2, r;
BIO *bio1 = NULL, *bio2 = NULL;
uint8_t scratch[2048 + 4], scratch2[2048];
uint32_t key[8];
size_t i, num_dgram, num_processed = 0;
BIO_MSG msgs[2], rmsgs[2];
BIO_ADDR *addr1 = NULL, *addr2 = NULL, *addr3 = NULL, *addr4 = NULL;
struct in_addr in_local;
size_t total = 0;
const uint32_t ref_caps = BIO_DGRAM_CAP_HANDLES_SRC_ADDR
| BIO_DGRAM_CAP_HANDLES_DST_ADDR
| BIO_DGRAM_CAP_PROVIDES_SRC_ADDR
| BIO_DGRAM_CAP_PROVIDES_DST_ADDR;
memset(msgs, 0, sizeof(msgs));
memset(rmsgs, 0, sizeof(rmsgs));
in_local.s_addr = ntohl(0x7f000001);
for (i = 0; i < OSSL_NELEM(key); ++i)
key[i] = test_random();
if (idx == 0) {
if (!TEST_int_eq(BIO_new_bio_dgram_pair(&bio1, 0, &bio2, 0), 1))
goto err;
} else {
if (!TEST_ptr(bio1 = bio2 = BIO_new(BIO_s_dgram_mem())))
goto err;
}
mtu1 = BIO_dgram_get_mtu(bio1);
if (!TEST_int_ge(mtu1, 1280))
goto err;
if (idx == 1) {
size_t bufsz;
/*
* Assume the header contains 2 BIO_ADDR structures and a length. We
* set a buffer big enough for 9 full sized datagrams.
*/
bufsz = 9 * (mtu1 + (sizeof(BIO_ADDR) * 2) + sizeof(size_t));
if (!TEST_true(BIO_set_write_buf_size(bio1, bufsz)))
goto err;
}
mtu2 = BIO_dgram_get_mtu(bio2);
if (!TEST_int_ge(mtu2, 1280))
goto err;
if (!TEST_int_eq(mtu1, mtu2))
goto err;
if (!TEST_int_le(mtu1, sizeof(scratch) - 4))
goto err;
for (i = 0; total < 1 * 1024 * 1024; ++i) {
if (!TEST_int_eq(random_data(key, scratch, sizeof(scratch), i), 1))
goto err;
blen = ((*(uint32_t*)scratch) % mtu1) + 1;
r = BIO_write(bio1, scratch + 4, blen);
if (r == -1)
break;
if (!TEST_int_eq(r, blen))
goto err;
total += blen;
}
if (idx <= 1 && !TEST_size_t_lt(total, 1 * 1024 * 1024))
goto err;
if (idx == 2 && !TEST_size_t_ge(total, 1 * 1024 * 1024))
goto err;
/*
* The number of datagrams we can fit depends on the size of the default
* write buffer size, the size of the datagram header and the size of the
* payload data we send in each datagram. The max payload data is based on
* the mtu. The default write buffer size is 9 * (sizeof(header) + mtu) so
* we expect at least 9 maximally sized datagrams to fit in the buffer.
*/
if (!TEST_int_ge(i, 9))
goto err;
/* Check we read back the same data */
num_dgram = i;
for (i = 0; i < num_dgram; ++i) {
if (!TEST_int_eq(random_data(key, scratch, sizeof(scratch), i), 1))
goto err;
blen = ((*(uint32_t*)scratch) % mtu1) + 1;
r = BIO_read(bio2, scratch2, sizeof(scratch2));
if (!TEST_int_eq(r, blen))
goto err;
if (!TEST_mem_eq(scratch + 4, blen, scratch2, blen))
goto err;
}
/* Should now be out of data */
if (!TEST_int_eq(BIO_read(bio2, scratch2, sizeof(scratch2)), -1))
goto err;
/* sendmmsg/recvmmsg */
if (!TEST_int_eq(random_data(key, scratch, sizeof(scratch), 0), 1))
goto err;
msgs[0].data = scratch;
msgs[0].data_len = 19;
msgs[1].data = scratch + 19;
msgs[1].data_len = 46;
if (!TEST_true(BIO_sendmmsg(bio1, msgs, sizeof(BIO_MSG), OSSL_NELEM(msgs), 0,
&num_processed))
|| !TEST_size_t_eq(num_processed, 2))
goto err;
rmsgs[0].data = scratch2;
rmsgs[0].data_len = 64;
rmsgs[1].data = scratch2 + 64;
rmsgs[1].data_len = 64;
if (!TEST_true(BIO_recvmmsg(bio2, rmsgs, sizeof(BIO_MSG), OSSL_NELEM(rmsgs), 0,
&num_processed))
|| !TEST_size_t_eq(num_processed, 2))
goto err;
if (!TEST_mem_eq(rmsgs[0].data, rmsgs[0].data_len, scratch, 19))
goto err;
if (!TEST_mem_eq(rmsgs[1].data, rmsgs[1].data_len, scratch + 19, 46))
goto err;
/* sendmmsg/recvmmsg with peer */
addr1 = BIO_ADDR_new();
if (!TEST_ptr(addr1))
goto err;
if (!TEST_int_eq(BIO_ADDR_rawmake(addr1, AF_INET, &in_local,
sizeof(in_local), 1234), 1))
goto err;
addr2 = BIO_ADDR_new();
if (!TEST_ptr(addr2))
goto err;
if (!TEST_int_eq(BIO_ADDR_rawmake(addr2, AF_INET, &in_local,
sizeof(in_local), 2345), 1))
goto err;
addr3 = BIO_ADDR_new();
if (!TEST_ptr(addr3))
goto err;
addr4 = BIO_ADDR_new();
if (!TEST_ptr(addr4))
goto err;
msgs[0].peer = addr1;
/* fails due to lack of caps on peer */
if (!TEST_false(BIO_sendmmsg(bio1, msgs, sizeof(BIO_MSG),
OSSL_NELEM(msgs), 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 0))
goto err;
if (!TEST_int_eq(BIO_dgram_set_caps(bio2, ref_caps), 1))
goto err;
if (!TEST_int_eq(BIO_dgram_get_caps(bio2), ref_caps))
goto err;
if (!TEST_int_eq(BIO_dgram_get_effective_caps(bio1), ref_caps))
goto err;
if (idx == 0 && !TEST_int_eq(BIO_dgram_get_effective_caps(bio2), 0))
goto err;
if (!TEST_int_eq(BIO_dgram_set_caps(bio1, ref_caps), 1))
goto err;
/* succeeds with cap now available */
if (!TEST_true(BIO_sendmmsg(bio1, msgs, sizeof(BIO_MSG), 1, 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 1))
goto err;
/* enable local addr support */
if (!TEST_int_eq(BIO_dgram_set_local_addr_enable(bio2, 1), 1))
goto err;
rmsgs[0].data = scratch2;
rmsgs[0].data_len = 64;
rmsgs[0].peer = addr3;
rmsgs[0].local = addr4;
if (!TEST_true(BIO_recvmmsg(bio2, rmsgs, sizeof(BIO_MSG), OSSL_NELEM(rmsgs), 0,
&num_processed))
|| !TEST_size_t_eq(num_processed, 1))
goto err;
if (!TEST_mem_eq(rmsgs[0].data, rmsgs[0].data_len, msgs[0].data, 19))
goto err;
/* We didn't set the source address so this should be zero */
if (!TEST_int_eq(BIO_ADDR_family(addr3), 0))
goto err;
if (!TEST_int_eq(BIO_ADDR_family(addr4), AF_INET))
goto err;
if (!TEST_int_eq(BIO_ADDR_rawport(addr4), 1234))
goto err;
/* test source address */
msgs[0].local = addr2;
if (!TEST_int_eq(BIO_dgram_set_local_addr_enable(bio1, 1), 1))
goto err;
if (!TEST_true(BIO_sendmmsg(bio1, msgs, sizeof(BIO_MSG), 1, 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 1))
goto err;
rmsgs[0].data = scratch2;
rmsgs[0].data_len = 64;
if (!TEST_true(BIO_recvmmsg(bio2, rmsgs, sizeof(BIO_MSG), OSSL_NELEM(rmsgs), 0, &num_processed))
|| !TEST_size_t_eq(num_processed, 1))
goto err;
if (!TEST_mem_eq(rmsgs[0].data, rmsgs[0].data_len,
msgs[0].data, msgs[0].data_len))
goto err;
if (!TEST_int_eq(BIO_ADDR_family(addr3), AF_INET))
goto err;
if (!TEST_int_eq(BIO_ADDR_rawport(addr3), 2345))
goto err;
if (!TEST_int_eq(BIO_ADDR_family(addr4), AF_INET))
goto err;
if (!TEST_int_eq(BIO_ADDR_rawport(addr4), 1234))
goto err;
/* test truncation, pending */
r = BIO_write(bio1, scratch, 64);
if (!TEST_int_eq(r, 64))
goto err;
memset(scratch2, 0, 64);
if (!TEST_int_eq(BIO_dgram_set_no_trunc(bio2, 1), 1))
goto err;
if (!TEST_int_eq(BIO_read(bio2, scratch2, 32), -1))
goto err;
if (!TEST_int_eq(BIO_pending(bio2), 64))
goto err;
if (!TEST_int_eq(BIO_dgram_set_no_trunc(bio2, 0), 1))
goto err;
if (!TEST_int_eq(BIO_read(bio2, scratch2, 32), 32))
goto err;
if (!TEST_mem_eq(scratch, 32, scratch2, 32))
goto err;
testresult = 1;
err:
if (idx == 0)
BIO_free(bio1);
BIO_free(bio2);
BIO_ADDR_free(addr1);
BIO_ADDR_free(addr2);
BIO_ADDR_free(addr3);
BIO_ADDR_free(addr4);
return testresult;
}
# endif /* !defined(OPENSSL_NO_CHACHA) */
#endif /* !defined(OPENSSL_NO_DGRAM) && !defined(OPENSSL_NO_SOCK) */
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
#if !defined(OPENSSL_NO_DGRAM) && !defined(OPENSSL_NO_SOCK)
ADD_ALL_TESTS(test_bio_dgram, OSSL_NELEM(bio_dgram_cases));
# if !defined(OPENSSL_NO_CHACHA)
ADD_ALL_TESTS(test_bio_dgram_pair, 3);
# endif
#endif
return 1;
}
|
./openssl/test/cmp_protect_test.c | /*
* Copyright 2007-2023 The OpenSSL Project Authors. All Rights Reserved.
* Copyright Nokia 2007-2019
* Copyright Siemens AG 2015-2019
*
* 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 "helpers/cmp_testlib.h"
static const char *ir_protected_f;
static const char *genm_prot_Ed_f;
static const char *ir_unprotected_f;
static const char *ip_PBM_f;
typedef struct test_fixture {
const char *test_case_name;
OSSL_CMP_CTX *cmp_ctx;
/* for protection tests */
OSSL_CMP_MSG *msg;
OSSL_CMP_PKISI *si; /* for error and response messages */
EVP_PKEY *pubkey;
unsigned char *mem;
int memlen;
X509 *cert;
STACK_OF(X509) *certs;
STACK_OF(X509) *chain;
int with_ss;
int callback_arg;
int expected;
} CMP_PROTECT_TEST_FIXTURE;
static OSSL_LIB_CTX *libctx = NULL;
static OSSL_PROVIDER *default_null_provider = NULL, *provider = NULL;
static void tear_down(CMP_PROTECT_TEST_FIXTURE *fixture)
{
if (fixture != NULL) {
OSSL_CMP_CTX_free(fixture->cmp_ctx);
OSSL_CMP_MSG_free(fixture->msg);
OSSL_CMP_PKISI_free(fixture->si);
OPENSSL_free(fixture->mem);
sk_X509_free(fixture->certs);
sk_X509_free(fixture->chain);
OPENSSL_free(fixture);
}
}
static CMP_PROTECT_TEST_FIXTURE *set_up(const char *const test_case_name)
{
CMP_PROTECT_TEST_FIXTURE *fixture;
if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture))))
return NULL;
fixture->test_case_name = test_case_name;
if (!TEST_ptr(fixture->cmp_ctx = OSSL_CMP_CTX_new(libctx, NULL))) {
tear_down(fixture);
return NULL;
}
return fixture;
}
static EVP_PKEY *prot_RSA_key = NULL;
#ifndef OPENSSL_NO_ECX
static EVP_PKEY *prot_Ed_key = NULL;
static OSSL_CMP_MSG *genm_protected_Ed;
#endif
static EVP_PKEY *server_key = NULL;
static X509 *server_cert = NULL;
static unsigned char rand_data[OSSL_CMP_TRANSACTIONID_LENGTH];
static OSSL_CMP_MSG *ir_unprotected, *ir_protected;
static X509 *endentity1 = NULL, *endentity2 = NULL,
*root = NULL, *intermediate = NULL;
static int execute_calc_protection_fails_test(CMP_PROTECT_TEST_FIXTURE *fixture)
{
ASN1_BIT_STRING *protection =
ossl_cmp_calc_protection(fixture->cmp_ctx, fixture->msg);
int res = TEST_ptr_null(protection);
ASN1_BIT_STRING_free(protection);
return res;
}
static int execute_calc_protection_pbmac_test(CMP_PROTECT_TEST_FIXTURE *fixture)
{
ASN1_BIT_STRING *protection =
ossl_cmp_calc_protection(fixture->cmp_ctx, fixture->msg);
int res = TEST_ptr(protection)
&& TEST_true(ASN1_STRING_cmp(protection,
fixture->msg->protection) == 0);
ASN1_BIT_STRING_free(protection);
return res;
}
/*
* This function works similarly to parts of verify_signature in cmp_vfy.c,
* but without the need for an OSSL_CMP_CTX or an X509 certificate.
*/
static int verify_signature(OSSL_CMP_MSG *msg,
ASN1_BIT_STRING *protection,
EVP_PKEY *pkey, EVP_MD *digest)
{
OSSL_CMP_PROTECTEDPART prot_part;
prot_part.header = OSSL_CMP_MSG_get0_header(msg);
prot_part.body = msg->body;
return ASN1_item_verify_ex(ASN1_ITEM_rptr(OSSL_CMP_PROTECTEDPART),
msg->header->protectionAlg, protection,
&prot_part, NULL, pkey, libctx, NULL) > 0;
}
/* Calls OSSL_CMP_calc_protection and compares and verifies signature */
static int execute_calc_protection_signature_test(CMP_PROTECT_TEST_FIXTURE *
fixture)
{
ASN1_BIT_STRING *protection =
ossl_cmp_calc_protection(fixture->cmp_ctx, fixture->msg);
int ret = (TEST_ptr(protection)
&& TEST_true(verify_signature(fixture->msg, protection,
fixture->pubkey,
fixture->cmp_ctx->digest)));
ASN1_BIT_STRING_free(protection);
return ret;
}
static int test_cmp_calc_protection_no_key_no_secret(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
if (!TEST_ptr(fixture->msg = load_pkimsg(ir_unprotected_f, libctx))
|| !TEST_ptr(fixture->msg->header->protectionAlg =
X509_ALGOR_new() /* no specific alg needed here */)) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_calc_protection_fails_test, tear_down);
return result;
}
static int test_cmp_calc_protection_pkey(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->pubkey = prot_RSA_key;
if (!TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, prot_RSA_key))
|| !TEST_ptr(fixture->msg = load_pkimsg(ir_protected_f, libctx))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_calc_protection_signature_test, tear_down);
return result;
}
#ifndef OPENSSL_NO_ECX
static int test_cmp_calc_protection_pkey_Ed(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->pubkey = prot_Ed_key;
if (!TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, prot_Ed_key))
|| !TEST_ptr(fixture->msg = load_pkimsg(genm_prot_Ed_f, libctx))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_calc_protection_signature_test, tear_down);
return result;
}
#endif
static int test_cmp_calc_protection_pbmac(void)
{
unsigned char sec_insta[] = { 'i', 'n', 's', 't', 'a' };
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
if (!TEST_true(OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx,
sec_insta, sizeof(sec_insta)))
|| !TEST_ptr(fixture->msg = load_pkimsg(ip_PBM_f, libctx))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_calc_protection_pbmac_test, tear_down);
return result;
}
static int execute_MSG_protect_test(CMP_PROTECT_TEST_FIXTURE *fixture)
{
return TEST_int_eq(fixture->expected,
ossl_cmp_msg_protect(fixture->cmp_ctx, fixture->msg));
}
#define SET_OPT_UNPROTECTED_SEND(ctx, val) \
OSSL_CMP_CTX_set_option((ctx), OSSL_CMP_OPT_UNPROTECTED_SEND, (val))
static int test_MSG_protect_unprotected_request(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = 1;
if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
|| !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 1))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_MSG_protect_test, tear_down);
return result;
}
static int test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key(void)
{
const size_t size = sizeof(rand_data) / 2;
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = 1;
if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
|| !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0))
/*
* Use half of the 16 bytes of random input
* for each reference and secret value
*/
|| !TEST_true(OSSL_CMP_CTX_set1_referenceValue(fixture->cmp_ctx,
rand_data, size))
|| !TEST_true(OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx,
rand_data + size,
size))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_MSG_protect_test, tear_down);
return result;
}
static int test_MSG_protect_with_certificate_and_key(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = 1;
if (!TEST_ptr(fixture->msg =
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, server_key))
|| !TEST_true(OSSL_CMP_CTX_set1_cert(fixture->cmp_ctx,
server_cert))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_MSG_protect_test, tear_down);
return result;
}
static int test_MSG_protect_certificate_based_without_cert(void)
{
OSSL_CMP_CTX *ctx;
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
ctx = fixture->cmp_ctx;
fixture->expected = 0;
if (!TEST_ptr(fixture->msg =
OSSL_CMP_MSG_dup(ir_unprotected))
|| !TEST_true(SET_OPT_UNPROTECTED_SEND(ctx, 0))
|| !TEST_true(OSSL_CMP_CTX_set0_newPkey(ctx, 1, server_key))) {
tear_down(fixture);
fixture = NULL;
}
EVP_PKEY_up_ref(server_key);
EXECUTE_TEST(execute_MSG_protect_test, tear_down);
return result;
}
static int test_MSG_protect_no_key_no_secret(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = 0;
if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
|| !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_MSG_protect_test, tear_down);
return result;
}
static int test_MSG_protect_pbmac_no_sender(int with_ref)
{
static unsigned char secret[] = { 47, 11, 8, 15 };
static unsigned char ref[] = { 0xca, 0xfe, 0xba, 0xbe };
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = with_ref;
if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
|| !SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0)
|| !ossl_cmp_hdr_set1_sender(fixture->msg->header, NULL)
|| !OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx,
secret, sizeof(secret))
|| (!OSSL_CMP_CTX_set1_referenceValue(fixture->cmp_ctx,
with_ref ? ref : NULL,
sizeof(ref)))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_MSG_protect_test, tear_down);
return result;
}
static int test_MSG_protect_pbmac_no_sender_with_ref(void)
{
return test_MSG_protect_pbmac_no_sender(1);
}
static int test_MSG_protect_pbmac_no_sender_no_ref(void)
{
return test_MSG_protect_pbmac_no_sender(0);
}
static int execute_MSG_add_extraCerts_test(CMP_PROTECT_TEST_FIXTURE *fixture)
{
return TEST_true(ossl_cmp_msg_add_extraCerts(fixture->cmp_ctx,
fixture->msg));
}
static int test_MSG_add_extraCerts(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_protected))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_MSG_add_extraCerts_test, tear_down);
return result;
}
#ifndef OPENSSL_NO_EC
/* The cert chain tests use EC certs so we skip them in no-ec builds */
static int execute_cmp_build_cert_chain_test(CMP_PROTECT_TEST_FIXTURE *fixture)
{
int ret = 0;
OSSL_CMP_CTX *ctx = fixture->cmp_ctx;
X509_STORE *store;
STACK_OF(X509) *chain =
X509_build_chain(fixture->cert, fixture->certs, NULL,
fixture->with_ss, ctx->libctx, ctx->propq);
if (TEST_ptr(chain)) {
/* Check whether chain built is equal to the expected one */
ret = TEST_int_eq(0, STACK_OF_X509_cmp(chain, fixture->chain));
OSSL_STACK_OF_X509_free(chain);
}
if (!ret)
return 0;
if (TEST_ptr(store = X509_STORE_new())
&& TEST_true(X509_STORE_add_cert(store, root))) {
X509_VERIFY_PARAM_set_flags(X509_STORE_get0_param(store),
X509_V_FLAG_NO_CHECK_TIME);
chain = X509_build_chain(fixture->cert, fixture->certs, store,
fixture->with_ss, ctx->libctx, ctx->propq);
ret = TEST_int_eq(fixture->expected, chain != NULL);
if (ret && chain != NULL) {
/* Check whether chain built is equal to the expected one */
ret = TEST_int_eq(0, STACK_OF_X509_cmp(chain, fixture->chain));
OSSL_STACK_OF_X509_free(chain);
}
}
X509_STORE_free(store);
return ret;
}
static int test_cmp_build_cert_chain(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = 1;
fixture->with_ss = 0;
fixture->cert = endentity2;
if (!TEST_ptr(fixture->certs = sk_X509_new_null())
|| !TEST_ptr(fixture->chain = sk_X509_new_null())
|| !TEST_true(sk_X509_push(fixture->certs, endentity1))
|| !TEST_true(sk_X509_push(fixture->certs, root))
|| !TEST_true(sk_X509_push(fixture->certs, intermediate))
|| !TEST_true(sk_X509_push(fixture->chain, endentity2))
|| !TEST_true(sk_X509_push(fixture->chain, intermediate))) {
tear_down(fixture);
fixture = NULL;
}
if (fixture != NULL) {
result = execute_cmp_build_cert_chain_test(fixture);
fixture->with_ss = 1;
if (result && TEST_true(sk_X509_push(fixture->chain, root)))
result = execute_cmp_build_cert_chain_test(fixture);
}
tear_down(fixture);
return result;
}
static int test_cmp_build_cert_chain_missing_intermediate(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = 0;
fixture->with_ss = 0;
fixture->cert = endentity2;
if (!TEST_ptr(fixture->certs = sk_X509_new_null())
|| !TEST_ptr(fixture->chain = sk_X509_new_null())
|| !TEST_true(sk_X509_push(fixture->certs, endentity1))
|| !TEST_true(sk_X509_push(fixture->certs, root))
|| !TEST_true(sk_X509_push(fixture->chain, endentity2))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_cmp_build_cert_chain_test, tear_down);
return result;
}
static int test_cmp_build_cert_chain_no_root(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = 1;
fixture->with_ss = 0;
fixture->cert = endentity2;
if (!TEST_ptr(fixture->certs = sk_X509_new_null())
|| !TEST_ptr(fixture->chain = sk_X509_new_null())
|| !TEST_true(sk_X509_push(fixture->certs, endentity1))
|| !TEST_true(sk_X509_push(fixture->certs, intermediate))
|| !TEST_true(sk_X509_push(fixture->chain, endentity2))
|| !TEST_true(sk_X509_push(fixture->chain, intermediate))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_cmp_build_cert_chain_test, tear_down);
return result;
}
static int test_cmp_build_cert_chain_only_root(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = 1;
fixture->with_ss = 0; /* still chain must include the only cert (root) */
fixture->cert = root;
if (!TEST_ptr(fixture->certs = sk_X509_new_null())
|| !TEST_ptr(fixture->chain = sk_X509_new_null())
|| !TEST_true(sk_X509_push(fixture->certs, root))
|| !TEST_true(sk_X509_push(fixture->chain, root))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_cmp_build_cert_chain_test, tear_down);
return result;
}
static int test_cmp_build_cert_chain_no_certs(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->expected = 0;
fixture->with_ss = 0;
fixture->cert = endentity2;
if (!TEST_ptr(fixture->certs = sk_X509_new_null())
|| !TEST_ptr(fixture->chain = sk_X509_new_null())
|| !TEST_true(sk_X509_push(fixture->chain, endentity2))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_cmp_build_cert_chain_test, tear_down);
return result;
}
#endif /* OPENSSL_NO_EC */
static int execute_X509_STORE_test(CMP_PROTECT_TEST_FIXTURE *fixture)
{
X509_STORE *store = X509_STORE_new();
STACK_OF(X509) *sk = NULL;
int res = 0;
if (!TEST_true(ossl_cmp_X509_STORE_add1_certs(store,
fixture->certs,
fixture->callback_arg)))
goto err;
sk = X509_STORE_get1_all_certs(store);
if (!TEST_int_eq(0, STACK_OF_X509_cmp(sk, fixture->chain)))
goto err;
res = 1;
err:
X509_STORE_free(store);
OSSL_STACK_OF_X509_free(sk);
return res;
}
static int test_X509_STORE(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->callback_arg = 0; /* self-issued allowed */
if (!TEST_ptr(fixture->certs = sk_X509_new_null())
|| !sk_X509_push(fixture->certs, endentity1)
|| !sk_X509_push(fixture->certs, endentity2)
|| !sk_X509_push(fixture->certs, root)
|| !sk_X509_push(fixture->certs, intermediate)
|| !TEST_ptr(fixture->chain = sk_X509_dup(fixture->certs))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_X509_STORE_test, tear_down);
return result;
}
static int test_X509_STORE_only_self_issued(void)
{
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
fixture->certs = sk_X509_new_null();
fixture->chain = sk_X509_new_null();
fixture->callback_arg = 1; /* only self-issued */
if (!TEST_true(sk_X509_push(fixture->certs, endentity1))
|| !TEST_true(sk_X509_push(fixture->certs, endentity2))
|| !TEST_true(sk_X509_push(fixture->certs, root))
|| !TEST_true(sk_X509_push(fixture->certs, intermediate))
|| !TEST_true(sk_X509_push(fixture->chain, root))) {
tear_down(fixture);
fixture = NULL;
}
EXECUTE_TEST(execute_X509_STORE_test, tear_down);
return result;
}
void cleanup_tests(void)
{
EVP_PKEY_free(prot_RSA_key);
#ifndef OPENSSL_NO_ECX
EVP_PKEY_free(prot_Ed_key);
OSSL_CMP_MSG_free(genm_protected_Ed);
#endif
EVP_PKEY_free(server_key);
X509_free(server_cert);
X509_free(endentity1);
X509_free(endentity2);
X509_free(root);
X509_free(intermediate);
OSSL_CMP_MSG_free(ir_protected);
OSSL_CMP_MSG_free(ir_unprotected);
OSSL_PROVIDER_unload(default_null_provider);
OSSL_PROVIDER_unload(provider);
OSSL_LIB_CTX_free(libctx);
}
#define USAGE "prot_RSA.pem IR_protected.der prot_Ed.pem " \
"GENM_protected_Ed.der IR_unprotected.der IP_PBM.der " \
"server.crt server.pem EndEntity1.crt EndEntity2.crt Root_CA.crt " \
"Intermediate_CA.crt module_name [module_conf_file]\n"
OPT_TEST_DECLARE_USAGE(USAGE)
int setup_tests(void)
{
char *prot_RSA_f;
char *prot_Ed_f;
char *server_key_f;
char *server_cert_f;
char *endentity1_f;
char *endentity2_f;
char *root_f;
char *intermediate_f;
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
RAND_bytes(rand_data, OSSL_CMP_TRANSACTIONID_LENGTH);
if (!TEST_ptr(prot_RSA_f = test_get_argument(0))
|| !TEST_ptr(ir_protected_f = test_get_argument(1))
|| !TEST_ptr(prot_Ed_f = test_get_argument(2))
|| !TEST_ptr(genm_prot_Ed_f = test_get_argument(3))
|| !TEST_ptr(ir_unprotected_f = test_get_argument(4))
|| !TEST_ptr(ip_PBM_f = test_get_argument(5))
|| !TEST_ptr(server_cert_f = test_get_argument(6))
|| !TEST_ptr(server_key_f = test_get_argument(7))
|| !TEST_ptr(endentity1_f = test_get_argument(8))
|| !TEST_ptr(endentity2_f = test_get_argument(9))
|| !TEST_ptr(root_f = test_get_argument(10))
|| !TEST_ptr(intermediate_f = test_get_argument(11))) {
TEST_error("usage: cmp_protect_test %s", USAGE);
return 0;
}
if (!test_arg_libctx(&libctx, &default_null_provider, &provider, 12, USAGE))
return 0;
if (!TEST_ptr(server_key = load_pkey_pem(server_key_f, libctx))
|| !TEST_ptr(server_cert = load_cert_pem(server_cert_f, libctx)))
return 0;
if (!TEST_ptr(prot_RSA_key = load_pkey_pem(prot_RSA_f, libctx)))
return 0;
#ifndef OPENSSL_NO_ECX
if (!TEST_ptr(prot_Ed_key = load_pkey_pem(prot_Ed_f, libctx)))
return 0;
#endif
if (!TEST_ptr(ir_protected = load_pkimsg(ir_protected_f, libctx))
#ifndef OPENSSL_NO_ECX
|| !TEST_ptr(genm_protected_Ed = load_pkimsg(genm_prot_Ed_f, libctx))
#endif
|| !TEST_ptr(ir_unprotected = load_pkimsg(ir_unprotected_f, libctx)))
return 0;
if (!TEST_ptr(endentity1 = load_cert_pem(endentity1_f, libctx))
|| !TEST_ptr(endentity2 = load_cert_pem(endentity2_f, libctx))
|| !TEST_ptr(root = load_cert_pem(root_f, libctx))
|| !TEST_ptr(intermediate = load_cert_pem(intermediate_f, libctx)))
return 0;
if (!TEST_int_eq(1, RAND_bytes(rand_data, OSSL_CMP_TRANSACTIONID_LENGTH)))
return 0;
/* Message protection tests */
ADD_TEST(test_cmp_calc_protection_no_key_no_secret);
ADD_TEST(test_cmp_calc_protection_pkey);
#ifndef OPENSSL_NO_ECX
ADD_TEST(test_cmp_calc_protection_pkey_Ed);
#endif
ADD_TEST(test_cmp_calc_protection_pbmac);
ADD_TEST(test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key);
ADD_TEST(test_MSG_protect_with_certificate_and_key);
ADD_TEST(test_MSG_protect_certificate_based_without_cert);
ADD_TEST(test_MSG_protect_unprotected_request);
ADD_TEST(test_MSG_protect_no_key_no_secret);
ADD_TEST(test_MSG_protect_pbmac_no_sender_with_ref);
ADD_TEST(test_MSG_protect_pbmac_no_sender_no_ref);
ADD_TEST(test_MSG_add_extraCerts);
#ifndef OPENSSL_NO_EC
ADD_TEST(test_cmp_build_cert_chain);
ADD_TEST(test_cmp_build_cert_chain_only_root);
ADD_TEST(test_cmp_build_cert_chain_no_root);
ADD_TEST(test_cmp_build_cert_chain_missing_intermediate);
ADD_TEST(test_cmp_build_cert_chain_no_certs);
#endif
ADD_TEST(test_X509_STORE);
ADD_TEST(test_X509_STORE_only_self_issued);
return 1;
}
|
./openssl/test/recordlentest.c | /*
* Copyright 2017-2023 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 <string.h>
#include "helpers/ssltestlib.h"
#include "testutil.h"
static char *cert = NULL;
static char *privkey = NULL;
#define TEST_PLAINTEXT_OVERFLOW_OK 0
#define TEST_PLAINTEXT_OVERFLOW_NOT_OK 1
#define TEST_ENCRYPTED_OVERFLOW_TLS1_3_OK 2
#define TEST_ENCRYPTED_OVERFLOW_TLS1_3_NOT_OK 3
#define TEST_ENCRYPTED_OVERFLOW_TLS1_2_OK 4
#define TEST_ENCRYPTED_OVERFLOW_TLS1_2_NOT_OK 5
#define TOTAL_RECORD_OVERFLOW_TESTS 6
static int write_record(BIO *b, size_t len, uint8_t rectype, int recversion)
{
unsigned char header[SSL3_RT_HEADER_LENGTH];
size_t written;
unsigned char buf[256];
memset(buf, 0, sizeof(buf));
header[0] = rectype;
header[1] = (recversion >> 8) & 0xff;
header[2] = recversion & 0xff;
header[3] = (len >> 8) & 0xff;
header[4] = len & 0xff;
if (!BIO_write_ex(b, header, SSL3_RT_HEADER_LENGTH, &written)
|| written != SSL3_RT_HEADER_LENGTH)
return 0;
while (len > 0) {
size_t outlen;
if (len > sizeof(buf))
outlen = sizeof(buf);
else
outlen = len;
if (!BIO_write_ex(b, buf, outlen, &written)
|| written != outlen)
return 0;
len -= outlen;
}
return 1;
}
static int fail_due_to_record_overflow(int enc)
{
long err = ERR_peek_error();
int reason;
if (enc)
reason = SSL_R_ENCRYPTED_LENGTH_TOO_LONG;
else
reason = SSL_R_DATA_LENGTH_TOO_LONG;
if (ERR_GET_LIB(err) == ERR_LIB_SSL
&& ERR_GET_REASON(err) == reason)
return 1;
return 0;
}
static int test_record_overflow(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
size_t len = 0;
size_t written;
int overf_expected;
unsigned char buf;
BIO *serverbio;
int recversion;
#ifdef OPENSSL_NO_TLS1_2
if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_OK
|| idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_NOT_OK)
return 1;
#endif
#if defined(OPENSSL_NO_TLS1_3) \
|| (defined(OPENSSL_NO_EC) && defined(OPENSSL_NO_DH))
if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_OK
|| idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_NOT_OK)
return 1;
#endif
if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_OK
|| idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_NOT_OK) {
len = SSL3_RT_MAX_ENCRYPTED_LENGTH;
#ifndef OPENSSL_NO_COMP
len -= SSL3_RT_MAX_COMPRESSED_OVERHEAD;
#endif
SSL_CTX_set_max_proto_version(sctx, TLS1_2_VERSION);
} else if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_OK
|| idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_NOT_OK) {
len = SSL3_RT_MAX_TLS13_ENCRYPTED_LENGTH;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
serverbio = SSL_get_rbio(serverssl);
if (idx == TEST_PLAINTEXT_OVERFLOW_OK
|| idx == TEST_PLAINTEXT_OVERFLOW_NOT_OK) {
len = SSL3_RT_MAX_PLAIN_LENGTH;
if (idx == TEST_PLAINTEXT_OVERFLOW_NOT_OK)
len++;
if (!TEST_true(write_record(serverbio, len,
SSL3_RT_HANDSHAKE, TLS1_VERSION)))
goto end;
if (!TEST_int_le(SSL_accept(serverssl), 0))
goto end;
overf_expected = (idx == TEST_PLAINTEXT_OVERFLOW_OK) ? 0 : 1;
if (!TEST_int_eq(fail_due_to_record_overflow(0), overf_expected))
goto end;
goto success;
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_NOT_OK
|| idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_NOT_OK) {
overf_expected = 1;
len++;
} else {
overf_expected = 0;
}
recversion = TLS1_2_VERSION;
if (!TEST_true(write_record(serverbio, len, SSL3_RT_APPLICATION_DATA,
recversion)))
goto end;
if (!TEST_false(SSL_read_ex(serverssl, &buf, sizeof(buf), &written)))
goto end;
if (!TEST_int_eq(fail_due_to_record_overflow(1), overf_expected))
goto end;
success:
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(cert = test_get_argument(0))
|| !TEST_ptr(privkey = test_get_argument(1)))
return 0;
ADD_ALL_TESTS(test_record_overflow, TOTAL_RECORD_OVERFLOW_TESTS);
return 1;
}
void cleanup_tests(void)
{
bio_s_mempacket_test_free();
}
|
./openssl/test/rand_test.c | /*
* Copyright 2021 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 <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/bio.h>
#include <openssl/core_names.h>
#include "crypto/rand.h"
#include "testutil.h"
static int test_rand(void)
{
EVP_RAND_CTX *privctx;
OSSL_PARAM params[2], *p = params;
unsigned char entropy1[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
unsigned char entropy2[] = { 0xff, 0xfe, 0xfd };
unsigned char outbuf[3];
*p++ = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_ENTROPY,
entropy1, sizeof(entropy1));
*p = OSSL_PARAM_construct_end();
if (!TEST_ptr(privctx = RAND_get0_private(NULL))
|| !TEST_true(EVP_RAND_CTX_set_params(privctx, params))
|| !TEST_int_gt(RAND_priv_bytes(outbuf, sizeof(outbuf)), 0)
|| !TEST_mem_eq(outbuf, sizeof(outbuf), entropy1, sizeof(outbuf))
|| !TEST_int_le(RAND_priv_bytes(outbuf, sizeof(outbuf) + 1), 0)
|| !TEST_int_gt(RAND_priv_bytes(outbuf, sizeof(outbuf)), 0)
|| !TEST_mem_eq(outbuf, sizeof(outbuf),
entropy1 + sizeof(outbuf), sizeof(outbuf)))
return 0;
*params = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_ENTROPY,
entropy2, sizeof(entropy2));
if (!TEST_true(EVP_RAND_CTX_set_params(privctx, params))
|| !TEST_int_gt(RAND_priv_bytes(outbuf, sizeof(outbuf)), 0)
|| !TEST_mem_eq(outbuf, sizeof(outbuf), entropy2, sizeof(outbuf)))
return 0;
return 1;
}
static int test_rand_uniform(void)
{
uint32_t x, i, j;
int err = 0, res = 0;
OSSL_LIB_CTX *ctx;
if (!test_get_libctx(&ctx, NULL, NULL, NULL, NULL))
goto err;
for (i = 1; i < 100; i += 13) {
x = ossl_rand_uniform_uint32(ctx, i, &err);
if (!TEST_int_eq(err, 0)
|| !TEST_uint_ge(x, 0)
|| !TEST_uint_lt(x, i))
return 0;
}
for (i = 1; i < 100; i += 17)
for (j = i + 1; j < 150; j += 11) {
x = ossl_rand_range_uint32(ctx, i, j, &err);
if (!TEST_int_eq(err, 0)
|| !TEST_uint_ge(x, i)
|| !TEST_uint_lt(x, j))
return 0;
}
res = 1;
err:
OSSL_LIB_CTX_free(ctx);
return res;
}
int setup_tests(void)
{
if (!TEST_true(RAND_set_DRBG_type(NULL, "TEST-RAND", NULL, NULL, NULL)))
return 0;
ADD_TEST(test_rand);
ADD_TEST(test_rand_uniform);
return 1;
}
|
./openssl/test/ca_internals_test.c | /*
* Copyright 2021-2022 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 <string.h>
#include "apps.h"
#include "testutil.h"
#include "crypto/asn1.h"
#define binname "ca_internals_test"
char *default_config_file = NULL;
static int test_do_updatedb(void)
{
CA_DB *db = NULL;
time_t testdateutc;
int rv;
size_t argc = test_get_argument_count();
BIO *bio_tmp;
char *testdate;
char *indexfile;
int need64bit;
int have64bit;
if (argc != 4) {
TEST_error("Usage: %s: do_updatedb dbfile testdate need64bit\n", binname);
TEST_error(" testdate format: ASN1-String\n");
return 0;
}
/*
* if the test will only work with 64bit time_t and
* the build only supports 32, assume the test as success
*/
need64bit = (int)strtol(test_get_argument(3), NULL, 0);
have64bit = sizeof(time_t) > sizeof(uint32_t);
if (need64bit && !have64bit) {
BIO_printf(bio_out, "skipping test (need64bit: %i, have64bit: %i)",
need64bit, have64bit);
return 1;
}
testdate = test_get_argument(2);
testdateutc = ossl_asn1_string_to_time_t(testdate);
if (TEST_time_t_lt(testdateutc, 0)) {
return 0;
}
indexfile = test_get_argument(1);
db = load_index(indexfile, NULL);
if (TEST_ptr_null(db)) {
return 0;
}
bio_tmp = bio_err;
bio_err = bio_out;
rv = do_updatedb(db, &testdateutc);
bio_err = bio_tmp;
if (rv > 0) {
if (!TEST_true(save_index(indexfile, "new", db)))
goto end;
if (!TEST_true(rotate_index(indexfile, "new", "old")))
goto end;
}
end:
free_index(db);
return 1;
}
int setup_tests(void)
{
char *command = test_get_argument(0);
if (test_get_argument_count() < 1) {
TEST_error("%s: no command specified for testing\n", binname);
return 0;
}
if (strcmp(command, "do_updatedb") == 0)
return test_do_updatedb();
TEST_error("%s: command '%s' is not supported for testing\n", binname, command);
return 0;
}
|
./openssl/test/ideatest.c | /*
* Copyright 1995-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
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
/*
* IDEA low level APIs are deprecated for public use, but still ok for internal
* use where we're using them to implement the higher level EVP interface, as is
* the case here.
*/
#include "internal/deprecated.h"
#include <string.h>
#include "internal/nelem.h"
#include "testutil.h"
#ifndef OPENSSL_NO_IDEA
# include <openssl/idea.h>
static const unsigned char k[16] = {
0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08
};
static const unsigned char in[8] = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03 };
static const unsigned char c[8] = { 0x11, 0xFB, 0xED, 0x2B, 0x01, 0x98, 0x6D, 0xE5 };
static unsigned char out[80];
static const unsigned char text[] = "Hello to all people out there";
static const unsigned char cfb_key[16] = {
0xe1, 0xf0, 0xc3, 0xd2, 0xa5, 0xb4, 0x87, 0x96,
0x69, 0x78, 0x4b, 0x5a, 0x2d, 0x3c, 0x0f, 0x1e,
};
static const unsigned char cfb_iv[80] =
{ 0x34, 0x12, 0x78, 0x56, 0xab, 0x90, 0xef, 0xcd };
static unsigned char cfb_buf1[40], cfb_buf2[40], cfb_tmp[8];
# define CFB_TEST_SIZE 24
static const unsigned char plain[CFB_TEST_SIZE] = {
0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73,
0x20, 0x74, 0x68, 0x65, 0x20, 0x74,
0x69, 0x6d, 0x65, 0x20, 0x66, 0x6f,
0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20
};
static const unsigned char cfb_cipher64[CFB_TEST_SIZE] = {
0x59, 0xD8, 0xE2, 0x65, 0x00, 0x58, 0x6C, 0x3F,
0x2C, 0x17, 0x25, 0xD0, 0x1A, 0x38, 0xB7, 0x2A,
0x39, 0x61, 0x37, 0xDC, 0x79, 0xFB, 0x9F, 0x45
/*- 0xF9,0x78,0x32,0xB5,0x42,0x1A,0x6B,0x38,
0x9A,0x44,0xD6,0x04,0x19,0x43,0xC4,0xD9,
0x3D,0x1E,0xAE,0x47,0xFC,0xCF,0x29,0x0B,*/
};
static int test_idea_ecb(void)
{
IDEA_KEY_SCHEDULE key, dkey;
IDEA_set_encrypt_key(k, &key);
IDEA_ecb_encrypt(in, out, &key);
if (!TEST_mem_eq(out, IDEA_BLOCK, c, sizeof(c)))
return 0;
IDEA_set_decrypt_key(&key, &dkey);
IDEA_ecb_encrypt(c, out, &dkey);
return TEST_mem_eq(out, IDEA_BLOCK, in, sizeof(in));
}
static int test_idea_cbc(void)
{
IDEA_KEY_SCHEDULE key, dkey;
unsigned char iv[IDEA_BLOCK];
const size_t text_len = sizeof(text);
IDEA_set_encrypt_key(k, &key);
IDEA_set_decrypt_key(&key, &dkey);
memcpy(iv, k, sizeof(iv));
IDEA_cbc_encrypt(text, out, text_len, &key, iv, 1);
memcpy(iv, k, sizeof(iv));
IDEA_cbc_encrypt(out, out, IDEA_BLOCK, &dkey, iv, 0);
IDEA_cbc_encrypt(&out[8], &out[8], text_len - 8, &dkey, iv, 0);
return TEST_mem_eq(text, text_len, out, text_len);
}
static int test_idea_cfb64(void)
{
IDEA_KEY_SCHEDULE eks, dks;
int n;
IDEA_set_encrypt_key(cfb_key, &eks);
IDEA_set_decrypt_key(&eks, &dks);
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_tmp));
n = 0;
IDEA_cfb64_encrypt(plain, cfb_buf1, (long)12, &eks,
cfb_tmp, &n, IDEA_ENCRYPT);
IDEA_cfb64_encrypt(&plain[12], &cfb_buf1[12],
(long)CFB_TEST_SIZE - 12, &eks,
cfb_tmp, &n, IDEA_ENCRYPT);
if (!TEST_mem_eq(cfb_cipher64, CFB_TEST_SIZE, cfb_buf1, CFB_TEST_SIZE))
return 0;
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_tmp));
n = 0;
IDEA_cfb64_encrypt(cfb_buf1, cfb_buf2, (long)13, &eks,
cfb_tmp, &n, IDEA_DECRYPT);
IDEA_cfb64_encrypt(&cfb_buf1[13], &cfb_buf2[13],
(long)CFB_TEST_SIZE - 13, &eks,
cfb_tmp, &n, IDEA_DECRYPT);
return TEST_mem_eq(plain, CFB_TEST_SIZE, cfb_buf2, CFB_TEST_SIZE);
}
#endif
int setup_tests(void)
{
#ifndef OPENSSL_NO_IDEA
ADD_TEST(test_idea_ecb);
ADD_TEST(test_idea_cbc);
ADD_TEST(test_idea_cfb64);
#endif
return 1;
}
|
./openssl/test/bad_dtls_test.c | /*
* Copyright 2016-2021 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
*/
/*
* Unit test for Cisco DTLS1_BAD_VER session resume, as used by
* AnyConnect VPN protocol.
*
* This is designed to exercise the code paths in
* http://git.infradead.org/users/dwmw2/openconnect.git/blob/HEAD:/dtls.c
* which have frequently been affected by regressions in DTLS1_BAD_VER
* support.
*
* Note that unlike other SSL tests, we don't test against our own SSL
* server method. Firstly because we don't have one; we *only* support
* DTLS1_BAD_VER as a client. And secondly because even if that were
* fixed up it's the wrong thing to test against - because if changes
* are made in generic DTLS code which don't take DTLS1_BAD_VER into
* account, there's plenty of scope for making those changes such that
* they break *both* the client and the server in the same way.
*
* So we handle the server side manually. In a session resume there isn't
* much to be done anyway.
*/
#include <string.h>
#include <openssl/core_names.h>
#include <openssl/params.h>
#include <openssl/opensslconf.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/kdf.h>
#include "internal/packet.h"
#include "internal/nelem.h"
#include "testutil.h"
/* For DTLS1_BAD_VER packets the MAC doesn't include the handshake header */
#define MAC_OFFSET (DTLS1_RT_HEADER_LENGTH + DTLS1_HM_HEADER_LENGTH)
static unsigned char client_random[SSL3_RANDOM_SIZE];
static unsigned char server_random[SSL3_RANDOM_SIZE];
/* These are all generated locally, sized purely according to our own whim */
static unsigned char session_id[32];
static unsigned char master_secret[48];
static unsigned char cookie[20];
/* We've hard-coded the cipher suite; we know it's 104 bytes */
static unsigned char key_block[104];
#define mac_key (key_block + 20)
#define dec_key (key_block + 40)
#define enc_key (key_block + 56)
static EVP_MD_CTX *handshake_md;
static int do_PRF(const void *seed1, int seed1_len,
const void *seed2, int seed2_len,
const void *seed3, int seed3_len,
unsigned char *out, int olen)
{
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
size_t outlen = olen;
/* No error handling. If it all screws up, the test will fail anyway */
EVP_PKEY_derive_init(pctx);
EVP_PKEY_CTX_set_tls1_prf_md(pctx, EVP_md5_sha1());
EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, master_secret, sizeof(master_secret));
EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed1, seed1_len);
EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed2, seed2_len);
EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed3, seed3_len);
EVP_PKEY_derive(pctx, out, &outlen);
EVP_PKEY_CTX_free(pctx);
return 1;
}
static SSL_SESSION *client_session(void)
{
static unsigned char session_asn1[] = {
0x30, 0x5F, /* SEQUENCE, length 0x5F */
0x02, 0x01, 0x01, /* INTEGER, SSL_SESSION_ASN1_VERSION */
0x02, 0x02, 0x01, 0x00, /* INTEGER, DTLS1_BAD_VER */
0x04, 0x02, 0x00, 0x2F, /* OCTET_STRING, AES128-SHA */
0x04, 0x20, /* OCTET_STRING, session id */
#define SS_SESSID_OFS 15 /* Session ID goes here */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x30, /* OCTET_STRING, master secret */
#define SS_SECRET_OFS 49 /* Master secret goes here */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char *p = session_asn1;
/* Copy the randomly-generated fields into the above ASN1 */
memcpy(session_asn1 + SS_SESSID_OFS, session_id, sizeof(session_id));
memcpy(session_asn1 + SS_SECRET_OFS, master_secret, sizeof(master_secret));
return d2i_SSL_SESSION(NULL, &p, sizeof(session_asn1));
}
/* Returns 1 for initial ClientHello, 2 for ClientHello with cookie */
static int validate_client_hello(BIO *wbio)
{
PACKET pkt, pkt2;
long len;
unsigned char *data;
int cookie_found = 0;
unsigned int u = 0;
if ((len = BIO_get_mem_data(wbio, (char **)&data)) < 0)
return 0;
if (!PACKET_buf_init(&pkt, data, len))
return 0;
/* Check record header type */
if (!PACKET_get_1(&pkt, &u) || u != SSL3_RT_HANDSHAKE)
return 0;
/* Version */
if (!PACKET_get_net_2(&pkt, &u) || u != DTLS1_BAD_VER)
return 0;
/* Skip the rest of the record header */
if (!PACKET_forward(&pkt, DTLS1_RT_HEADER_LENGTH - 3))
return 0;
/* Check it's a ClientHello */
if (!PACKET_get_1(&pkt, &u) || u != SSL3_MT_CLIENT_HELLO)
return 0;
/* Skip the rest of the handshake message header */
if (!PACKET_forward(&pkt, DTLS1_HM_HEADER_LENGTH - 1))
return 0;
/* Check client version */
if (!PACKET_get_net_2(&pkt, &u) || u != DTLS1_BAD_VER)
return 0;
/* Store random */
if (!PACKET_copy_bytes(&pkt, client_random, SSL3_RANDOM_SIZE))
return 0;
/* Check session id length and content */
if (!PACKET_get_length_prefixed_1(&pkt, &pkt2) ||
!PACKET_equal(&pkt2, session_id, sizeof(session_id)))
return 0;
/* Check cookie */
if (!PACKET_get_length_prefixed_1(&pkt, &pkt2))
return 0;
if (PACKET_remaining(&pkt2)) {
if (!PACKET_equal(&pkt2, cookie, sizeof(cookie)))
return 0;
cookie_found = 1;
}
/* Skip ciphers */
if (!PACKET_get_net_2(&pkt, &u) || !PACKET_forward(&pkt, u))
return 0;
/* Skip compression */
if (!PACKET_get_1(&pkt, &u) || !PACKET_forward(&pkt, u))
return 0;
/* Skip extensions */
if (!PACKET_get_net_2(&pkt, &u) || !PACKET_forward(&pkt, u))
return 0;
/* Now we are at the end */
if (PACKET_remaining(&pkt))
return 0;
/* Update handshake MAC for second ClientHello (with cookie) */
if (cookie_found && !EVP_DigestUpdate(handshake_md, data + MAC_OFFSET,
len - MAC_OFFSET))
return 0;
(void)BIO_reset(wbio);
return 1 + cookie_found;
}
static int send_hello_verify(BIO *rbio)
{
static unsigned char hello_verify[] = {
0x16, /* Handshake */
0x01, 0x00, /* DTLS1_BAD_VER */
0x00, 0x00, /* Epoch 0 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Seq# 0 */
0x00, 0x23, /* Length */
0x03, /* Hello Verify */
0x00, 0x00, 0x17, /* Length */
0x00, 0x00, /* Seq# 0 */
0x00, 0x00, 0x00, /* Fragment offset */
0x00, 0x00, 0x17, /* Fragment length */
0x01, 0x00, /* DTLS1_BAD_VER */
0x14, /* Cookie length */
#define HV_COOKIE_OFS 28 /* Cookie goes here */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
memcpy(hello_verify + HV_COOKIE_OFS, cookie, sizeof(cookie));
BIO_write(rbio, hello_verify, sizeof(hello_verify));
return 1;
}
static int send_server_hello(BIO *rbio)
{
static unsigned char server_hello[] = {
0x16, /* Handshake */
0x01, 0x00, /* DTLS1_BAD_VER */
0x00, 0x00, /* Epoch 0 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* Seq# 1 */
0x00, 0x52, /* Length */
0x02, /* Server Hello */
0x00, 0x00, 0x46, /* Length */
0x00, 0x01, /* Seq# */
0x00, 0x00, 0x00, /* Fragment offset */
0x00, 0x00, 0x46, /* Fragment length */
0x01, 0x00, /* DTLS1_BAD_VER */
#define SH_RANDOM_OFS 27 /* Server random goes here */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, /* Session ID length */
#define SH_SESSID_OFS 60 /* Session ID goes here */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x2f, /* Cipher suite AES128-SHA */
0x00, /* Compression null */
};
static unsigned char change_cipher_spec[] = {
0x14, /* Change Cipher Spec */
0x01, 0x00, /* DTLS1_BAD_VER */
0x00, 0x00, /* Epoch 0 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, /* Seq# 2 */
0x00, 0x03, /* Length */
0x01, 0x00, 0x02, /* Message */
};
memcpy(server_hello + SH_RANDOM_OFS, server_random, sizeof(server_random));
memcpy(server_hello + SH_SESSID_OFS, session_id, sizeof(session_id));
if (!EVP_DigestUpdate(handshake_md, server_hello + MAC_OFFSET,
sizeof(server_hello) - MAC_OFFSET))
return 0;
BIO_write(rbio, server_hello, sizeof(server_hello));
BIO_write(rbio, change_cipher_spec, sizeof(change_cipher_spec));
return 1;
}
/* Create header, HMAC, pad, encrypt and send a record */
static int send_record(BIO *rbio, unsigned char type, uint64_t seqnr,
const void *msg, size_t len)
{
/* Note that the order of the record header fields on the wire,
* and in the HMAC, is different. So we just keep them in separate
* variables and handle them individually. */
static unsigned char epoch[2] = { 0x00, 0x01 };
static unsigned char seq[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static unsigned char ver[2] = { 0x01, 0x00 }; /* DTLS1_BAD_VER */
unsigned char lenbytes[2];
EVP_MAC *hmac = NULL;
EVP_MAC_CTX *ctx = NULL;
EVP_CIPHER_CTX *enc_ctx = NULL;
unsigned char iv[16];
unsigned char pad;
unsigned char *enc;
OSSL_PARAM params[2];
int ret = 0;
seq[0] = (seqnr >> 40) & 0xff;
seq[1] = (seqnr >> 32) & 0xff;
seq[2] = (seqnr >> 24) & 0xff;
seq[3] = (seqnr >> 16) & 0xff;
seq[4] = (seqnr >> 8) & 0xff;
seq[5] = seqnr & 0xff;
pad = 15 - ((len + SHA_DIGEST_LENGTH) % 16);
enc = OPENSSL_malloc(len + SHA_DIGEST_LENGTH + 1 + pad);
if (enc == NULL)
return 0;
/* Copy record to encryption buffer */
memcpy(enc, msg, len);
/* Append HMAC to data */
if (!TEST_ptr(hmac = EVP_MAC_fetch(NULL, "HMAC", NULL))
|| !TEST_ptr(ctx = EVP_MAC_CTX_new(hmac)))
goto end;
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,
"SHA1", 0);
params[1] = OSSL_PARAM_construct_end();
lenbytes[0] = (unsigned char)(len >> 8);
lenbytes[1] = (unsigned char)(len);
if (!EVP_MAC_init(ctx, mac_key, 20, params)
|| !EVP_MAC_update(ctx, epoch, 2)
|| !EVP_MAC_update(ctx, seq, 6)
|| !EVP_MAC_update(ctx, &type, 1)
|| !EVP_MAC_update(ctx, ver, 2) /* Version */
|| !EVP_MAC_update(ctx, lenbytes, 2) /* Length */
|| !EVP_MAC_update(ctx, enc, len) /* Finally the data itself */
|| !EVP_MAC_final(ctx, enc + len, NULL, SHA_DIGEST_LENGTH))
goto end;
/* Append padding bytes */
len += SHA_DIGEST_LENGTH;
do {
enc[len++] = pad;
} while (len % 16);
/* Generate IV, and encrypt */
if (!TEST_int_gt(RAND_bytes(iv, sizeof(iv)), 0)
|| !TEST_ptr(enc_ctx = EVP_CIPHER_CTX_new())
|| !TEST_true(EVP_CipherInit_ex(enc_ctx, EVP_aes_128_cbc(), NULL,
enc_key, iv, 1))
|| !TEST_int_ge(EVP_Cipher(enc_ctx, enc, enc, len), 0))
goto end;
/* Finally write header (from fragmented variables), IV and encrypted record */
BIO_write(rbio, &type, 1);
BIO_write(rbio, ver, 2);
BIO_write(rbio, epoch, 2);
BIO_write(rbio, seq, 6);
lenbytes[0] = (unsigned char)((len + sizeof(iv)) >> 8);
lenbytes[1] = (unsigned char)(len + sizeof(iv));
BIO_write(rbio, lenbytes, 2);
BIO_write(rbio, iv, sizeof(iv));
BIO_write(rbio, enc, len);
ret = 1;
end:
EVP_MAC_free(hmac);
EVP_MAC_CTX_free(ctx);
EVP_CIPHER_CTX_free(enc_ctx);
OPENSSL_free(enc);
return ret;
}
static int send_finished(SSL *s, BIO *rbio)
{
static unsigned char finished_msg[DTLS1_HM_HEADER_LENGTH +
TLS1_FINISH_MAC_LENGTH] = {
0x14, /* Finished */
0x00, 0x00, 0x0c, /* Length */
0x00, 0x03, /* Seq# 3 */
0x00, 0x00, 0x00, /* Fragment offset */
0x00, 0x00, 0x0c, /* Fragment length */
/* Finished MAC (12 bytes) */
};
unsigned char handshake_hash[EVP_MAX_MD_SIZE];
/* Derive key material */
do_PRF(TLS_MD_KEY_EXPANSION_CONST, TLS_MD_KEY_EXPANSION_CONST_SIZE,
server_random, SSL3_RANDOM_SIZE,
client_random, SSL3_RANDOM_SIZE,
key_block, sizeof(key_block));
/* Generate Finished MAC */
if (!EVP_DigestFinal_ex(handshake_md, handshake_hash, NULL))
return 0;
do_PRF(TLS_MD_SERVER_FINISH_CONST, TLS_MD_SERVER_FINISH_CONST_SIZE,
handshake_hash, EVP_MD_CTX_get_size(handshake_md),
NULL, 0,
finished_msg + DTLS1_HM_HEADER_LENGTH, TLS1_FINISH_MAC_LENGTH);
return send_record(rbio, SSL3_RT_HANDSHAKE, 0,
finished_msg, sizeof(finished_msg));
}
static int validate_ccs(BIO *wbio)
{
PACKET pkt;
long len;
unsigned char *data;
unsigned int u;
len = BIO_get_mem_data(wbio, (char **)&data);
if (len < 0)
return 0;
if (!PACKET_buf_init(&pkt, data, len))
return 0;
/* Check record header type */
if (!PACKET_get_1(&pkt, &u) || u != SSL3_RT_CHANGE_CIPHER_SPEC)
return 0;
/* Version */
if (!PACKET_get_net_2(&pkt, &u) || u != DTLS1_BAD_VER)
return 0;
/* Skip the rest of the record header */
if (!PACKET_forward(&pkt, DTLS1_RT_HEADER_LENGTH - 3))
return 0;
/* Check ChangeCipherSpec message */
if (!PACKET_get_1(&pkt, &u) || u != SSL3_MT_CCS)
return 0;
/* A DTLS1_BAD_VER ChangeCipherSpec also contains the
* handshake sequence number (which is 2 here) */
if (!PACKET_get_net_2(&pkt, &u) || u != 0x0002)
return 0;
/* Now check the Finished packet */
if (!PACKET_get_1(&pkt, &u) || u != SSL3_RT_HANDSHAKE)
return 0;
if (!PACKET_get_net_2(&pkt, &u) || u != DTLS1_BAD_VER)
return 0;
/* Check epoch is now 1 */
if (!PACKET_get_net_2(&pkt, &u) || u != 0x0001)
return 0;
/* That'll do for now. If OpenSSL accepted *our* Finished packet
* then it's evidently remembered that DTLS1_BAD_VER doesn't
* include the handshake header in the MAC. There's not a lot of
* point in implementing decryption here, just to check that it
* continues to get it right for one more packet. */
return 1;
}
#define NODROP(x) { x##UL, 0 }
#define DROP(x) { x##UL, 1 }
static struct {
uint64_t seq;
int drop;
} tests[] = {
NODROP(1), NODROP(3), NODROP(2),
NODROP(0x1234), NODROP(0x1230), NODROP(0x1235),
NODROP(0xffff), NODROP(0x10001), NODROP(0xfffe), NODROP(0x10000),
DROP(0x10001), DROP(0xff), NODROP(0x100000), NODROP(0x800000), NODROP(0x7fffe1),
NODROP(0xffffff), NODROP(0x1000000), NODROP(0xfffffe), DROP(0xffffff), NODROP(0x1000010),
NODROP(0xfffffd), NODROP(0x1000011), DROP(0x12), NODROP(0x1000012),
NODROP(0x1ffffff), NODROP(0x2000000), DROP(0x1ff00fe), NODROP(0x2000001),
NODROP(0x20fffff), NODROP(0x2105500), DROP(0x20ffffe), NODROP(0x21054ff),
NODROP(0x211ffff), DROP(0x2110000), NODROP(0x2120000)
/* The last test should be NODROP, because a DROP wouldn't get tested. */
};
static int test_bad_dtls(void)
{
SSL_SESSION *sess = NULL;
SSL_CTX *ctx = NULL;
SSL *con = NULL;
BIO *rbio = NULL;
BIO *wbio = NULL;
time_t now = 0;
int testresult = 0;
int ret;
int i;
RAND_bytes(session_id, sizeof(session_id));
RAND_bytes(master_secret, sizeof(master_secret));
RAND_bytes(cookie, sizeof(cookie));
RAND_bytes(server_random + 4, sizeof(server_random) - 4);
now = time(NULL);
memcpy(server_random, &now, sizeof(now));
sess = client_session();
if (!TEST_ptr(sess))
goto end;
handshake_md = EVP_MD_CTX_new();
if (!TEST_ptr(handshake_md)
|| !TEST_true(EVP_DigestInit_ex(handshake_md, EVP_md5_sha1(),
NULL)))
goto end;
ctx = SSL_CTX_new(DTLS_client_method());
if (!TEST_ptr(ctx)
|| !TEST_true(SSL_CTX_set_min_proto_version(ctx, DTLS1_BAD_VER))
|| !TEST_true(SSL_CTX_set_max_proto_version(ctx, DTLS1_BAD_VER))
|| !TEST_true(SSL_CTX_set_options(ctx,
SSL_OP_LEGACY_SERVER_CONNECT))
|| !TEST_true(SSL_CTX_set_cipher_list(ctx, "AES128-SHA")))
goto end;
SSL_CTX_set_security_level(ctx, 0);
con = SSL_new(ctx);
if (!TEST_ptr(con)
|| !TEST_true(SSL_set_session(con, sess)))
goto end;
SSL_SESSION_free(sess);
rbio = BIO_new(BIO_s_mem());
wbio = BIO_new(BIO_s_mem());
if (!TEST_ptr(rbio)
|| !TEST_ptr(wbio))
goto end;
SSL_set_bio(con, rbio, wbio);
if (!TEST_true(BIO_up_ref(rbio))) {
/*
* We can't up-ref but we assigned ownership to con, so we shouldn't
* free in the "end" block
*/
rbio = wbio = NULL;
goto end;
}
if (!TEST_true(BIO_up_ref(wbio))) {
wbio = NULL;
goto end;
}
SSL_set_connect_state(con);
/* Send initial ClientHello */
ret = SSL_do_handshake(con);
if (!TEST_int_le(ret, 0)
|| !TEST_int_eq(SSL_get_error(con, ret), SSL_ERROR_WANT_READ)
|| !TEST_int_eq(validate_client_hello(wbio), 1)
|| !TEST_true(send_hello_verify(rbio)))
goto end;
ret = SSL_do_handshake(con);
if (!TEST_int_le(ret, 0)
|| !TEST_int_eq(SSL_get_error(con, ret), SSL_ERROR_WANT_READ)
|| !TEST_int_eq(validate_client_hello(wbio), 2)
|| !TEST_true(send_server_hello(rbio)))
goto end;
ret = SSL_do_handshake(con);
if (!TEST_int_le(ret, 0)
|| !TEST_int_eq(SSL_get_error(con, ret), SSL_ERROR_WANT_READ)
|| !TEST_true(send_finished(con, rbio)))
goto end;
ret = SSL_do_handshake(con);
if (!TEST_int_gt(ret, 0)
|| !TEST_true(validate_ccs(wbio)))
goto end;
/* While we're here and crafting packets by hand, we might as well do a
bit of a stress test on the DTLS record replay handling. Not Cisco-DTLS
specific but useful anyway for the general case. It's been broken
before, and in fact was broken even for a basic 0, 2, 1 test case
when this test was first added.... */
for (i = 0; i < (int)OSSL_NELEM(tests); i++) {
uint64_t recv_buf[2];
if (!TEST_true(send_record(rbio, SSL3_RT_APPLICATION_DATA, tests[i].seq,
&tests[i].seq, sizeof(uint64_t)))) {
TEST_error("Failed to send data seq #0x%x%08x (%d)\n",
(unsigned int)(tests[i].seq >> 32), (unsigned int)tests[i].seq, i);
goto end;
}
if (tests[i].drop)
continue;
ret = SSL_read(con, recv_buf, 2 * sizeof(uint64_t));
if (!TEST_int_eq(ret, (int)sizeof(uint64_t))) {
TEST_error("SSL_read failed or wrong size on seq#0x%x%08x (%d)\n",
(unsigned int)(tests[i].seq >> 32), (unsigned int)tests[i].seq, i);
goto end;
}
if (!TEST_true(recv_buf[0] == tests[i].seq))
goto end;
}
/* The last test cannot be DROP() */
if (!TEST_false(tests[i-1].drop))
goto end;
testresult = 1;
end:
BIO_free(rbio);
BIO_free(wbio);
SSL_free(con);
SSL_CTX_free(ctx);
EVP_MD_CTX_free(handshake_md);
return testresult;
}
int setup_tests(void)
{
ADD_TEST(test_bad_dtls);
return 1;
}
|
./openssl/test/versions.c | /*
* Copyright 2018 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 <openssl/opensslv.h>
#include <openssl/crypto.h>
/* A simple helper for the perl function OpenSSL::Test::openssl_versions */
int main(void)
{
printf("Build version: %s\n", OPENSSL_FULL_VERSION_STR);
printf("Library version: %s\n",
OpenSSL_version(OPENSSL_FULL_VERSION_STRING));
return 0;
}
|
./openssl/test/threadstest.h | /*
* Copyright 2021 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
*/
#if defined(_WIN32)
# include <windows.h>
#endif
#include <string.h>
#include "testutil.h"
#if !defined(OPENSSL_THREADS) || defined(CRYPTO_TDEBUG)
typedef unsigned int thread_t;
static int run_thread(thread_t *t, void (*f)(void))
{
f();
return 1;
}
static int wait_for_thread(thread_t thread)
{
return 1;
}
#elif defined(OPENSSL_SYS_WINDOWS)
typedef HANDLE thread_t;
static DWORD WINAPI thread_run(LPVOID arg)
{
void (*f)(void);
*(void **) (&f) = arg;
f();
return 0;
}
static int run_thread(thread_t *t, void (*f)(void))
{
*t = CreateThread(NULL, 0, thread_run, *(void **) &f, 0, NULL);
return *t != NULL;
}
static int wait_for_thread(thread_t thread)
{
return WaitForSingleObject(thread, INFINITE) == 0;
}
#else
typedef pthread_t thread_t;
static void *thread_run(void *arg)
{
void (*f)(void);
*(void **) (&f) = arg;
f();
return NULL;
}
static int run_thread(thread_t *t, void (*f)(void))
{
return pthread_create(t, NULL, thread_run, *(void **) &f) == 0;
}
static int wait_for_thread(thread_t thread)
{
return pthread_join(thread, NULL) == 0;
}
#endif
|
./openssl/test/cipherbytes_test.c | /*
* 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 may obtain a copy of the License at
* https://www.openssl.org/source/license.html
* or in the file LICENSE in the source distribution.
*/
#include <string.h>
#include <stdio.h>
#include <openssl/opensslconf.h>
#include <openssl/err.h>
#include <openssl/e_os2.h>
#include <openssl/ssl.h>
#include <openssl/ssl3.h>
#include <openssl/tls1.h>
#include "internal/nelem.h"
#include "testutil.h"
static SSL_CTX *ctx;
static SSL *s;
static int test_empty(void)
{
STACK_OF(SSL_CIPHER) *sk = NULL, *scsv = NULL;
const unsigned char bytes[] = {0x00};
int ret = 0;
if (!TEST_int_eq(SSL_bytes_to_cipher_list(s, bytes, 0, 0, &sk, &scsv), 0)
|| !TEST_ptr_null(sk)
|| !TEST_ptr_null(scsv))
goto err;
ret = 1;
err:
sk_SSL_CIPHER_free(sk);
sk_SSL_CIPHER_free(scsv);
return ret;
}
static int test_unsupported(void)
{
STACK_OF(SSL_CIPHER) *sk, *scsv;
/* ECDH-RSA-AES256 (unsupported), ECDHE-ECDSA-AES128, <unassigned> */
const unsigned char bytes[] = {0xc0, 0x0f, 0x00, 0x2f, 0x01, 0x00};
int ret = 0;
if (!TEST_true(SSL_bytes_to_cipher_list(s, bytes, sizeof(bytes),
0, &sk, &scsv))
|| !TEST_ptr(sk)
|| !TEST_int_eq(sk_SSL_CIPHER_num(sk), 1)
|| !TEST_ptr(scsv)
|| !TEST_int_eq(sk_SSL_CIPHER_num(scsv), 0)
|| !TEST_str_eq(SSL_CIPHER_get_name(sk_SSL_CIPHER_value(sk, 0)),
"AES128-SHA"))
goto err;
ret = 1;
err:
sk_SSL_CIPHER_free(sk);
sk_SSL_CIPHER_free(scsv);
return ret;
}
static int test_v2(void)
{
STACK_OF(SSL_CIPHER) *sk, *scsv;
/* ECDHE-ECDSA-AES256GCM, SSL2_RC4_1238_WITH_MD5,
* ECDHE-ECDSA-CHACHA20-POLY1305 */
const unsigned char bytes[] = {0x00, 0x00, 0x35, 0x01, 0x00, 0x80,
0x00, 0x00, 0x33};
int ret = 0;
if (!TEST_true(SSL_bytes_to_cipher_list(s, bytes, sizeof(bytes), 1,
&sk, &scsv))
|| !TEST_ptr(sk)
|| !TEST_int_eq(sk_SSL_CIPHER_num(sk), 2)
|| !TEST_ptr(scsv)
|| !TEST_int_eq(sk_SSL_CIPHER_num(scsv), 0))
goto err;
if (strcmp(SSL_CIPHER_get_name(sk_SSL_CIPHER_value(sk, 0)),
"AES256-SHA") != 0 ||
strcmp(SSL_CIPHER_get_name(sk_SSL_CIPHER_value(sk, 1)),
"DHE-RSA-AES128-SHA") != 0)
goto err;
ret = 1;
err:
sk_SSL_CIPHER_free(sk);
sk_SSL_CIPHER_free(scsv);
return ret;
}
static int test_v3(void)
{
STACK_OF(SSL_CIPHER) *sk = NULL, *scsv = NULL;
/* ECDHE-ECDSA-AES256GCM, ECDHE-ECDSA-CHACHAPOLY, DHE-RSA-AES256GCM,
* EMPTY-RENEGOTIATION-INFO-SCSV, FALLBACK-SCSV */
const unsigned char bytes[] = {0x00, 0x2f, 0x00, 0x33, 0x00, 0x9f, 0x00, 0xff,
0x56, 0x00};
int ret = 0;
if (!SSL_bytes_to_cipher_list(s, bytes, sizeof(bytes), 0, &sk, &scsv)
|| !TEST_ptr(sk)
|| !TEST_int_eq(sk_SSL_CIPHER_num(sk), 3)
|| !TEST_ptr(scsv)
|| !TEST_int_eq(sk_SSL_CIPHER_num(scsv), 2)
|| !TEST_str_eq(SSL_CIPHER_get_name(sk_SSL_CIPHER_value(sk, 0)),
"AES128-SHA")
|| !TEST_str_eq(SSL_CIPHER_get_name(sk_SSL_CIPHER_value(sk, 1)),
"DHE-RSA-AES128-SHA")
|| !TEST_str_eq(SSL_CIPHER_get_name(sk_SSL_CIPHER_value(sk, 2)),
"DHE-RSA-AES256-GCM-SHA384")
|| !TEST_str_eq(SSL_CIPHER_get_name(sk_SSL_CIPHER_value(scsv, 0)),
"TLS_EMPTY_RENEGOTIATION_INFO_SCSV")
|| !TEST_str_eq(SSL_CIPHER_get_name(sk_SSL_CIPHER_value(scsv, 1)),
"TLS_FALLBACK_SCSV"))
goto err;
ret = 1;
err:
sk_SSL_CIPHER_free(sk);
sk_SSL_CIPHER_free(scsv);
return ret;
}
int setup_tests(void)
{
if (!TEST_ptr(ctx = SSL_CTX_new(TLS_server_method()))
|| !TEST_ptr(s = SSL_new(ctx)))
return 0;
ADD_TEST(test_empty);
ADD_TEST(test_unsupported);
ADD_TEST(test_v2);
ADD_TEST(test_v3);
return 1;
}
void cleanup_tests(void)
{
SSL_free(s);
SSL_CTX_free(ctx);
}
|
./openssl/test/endecoder_legacy_test.c | /*
* Copyright 2020-2021 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
*/
/*
* This program tests the following known key type specific function against
* the corresponding OSSL_ENCODER implementation:
*
* - i2d_{TYPE}PrivateKey()
* - i2d_{TYPE}PublicKey(),
* - i2d_{TYPE}params(),
* - i2d_{TYPE}_PUBKEY(),
* - PEM_write_bio_{TYPE}PrivateKey()
* - PEM_write_bio_{TYPE}PublicKey()
* - PEM_write_bio_{TYPE}params()
* - PEM_write_bio_{TYPE}_PUBKEY()
*
* as well as the following functions against the corresponding OSSL_DECODER
* implementation.
*
* - d2i_{TYPE}PrivateKey()
* - d2i_{TYPE}PublicKey(),
* - d2i_{TYPE}params(),
* - d2i_{TYPE}_PUBKEY(),
* - PEM_read_bio_{TYPE}PrivateKey()
* - PEM_read_bio_{TYPE}PublicKey()
* - PEM_read_bio_{TYPE}params()
* - PEM_read_bio_{TYPE}_PUBKEY()
*/
#include <stdlib.h>
#include <string.h>
/*
* We test deprecated functions, so we need to suppress deprecation warnings.
*/
#define OPENSSL_SUPPRESS_DEPRECATED
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <openssl/asn1.h>
#include <openssl/pem.h>
#include <openssl/params.h>
#include <openssl/encoder.h>
#include <openssl/decoder.h>
#include <openssl/dh.h>
#include <openssl/dsa.h>
#ifndef OPENSSL_NO_DEPRECATED_3_0
# include <openssl/rsa.h>
#endif
#include "internal/nelem.h"
#include "crypto/evp.h"
#include "testutil.h"
typedef int PEM_write_bio_of_void_protected(BIO *out, const void *obj,
const EVP_CIPHER *enc,
unsigned char *kstr, int klen,
pem_password_cb *cb, void *u);
typedef int PEM_write_bio_of_void_unprotected(BIO *out, const void *obj);
typedef void *PEM_read_bio_of_void(BIO *out, void **obj,
pem_password_cb *cb, void *u);
typedef int EVP_PKEY_print_fn(BIO *out, const EVP_PKEY *pkey,
int indent, ASN1_PCTX *pctx);
typedef int EVP_PKEY_eq_fn(const EVP_PKEY *a, const EVP_PKEY *b);
static struct test_stanza_st {
const char *keytype;
const char *structure[2];
int evp_type;
i2d_of_void *i2d_PrivateKey;
i2d_of_void *i2d_PublicKey;
i2d_of_void *i2d_params;
i2d_of_void *i2d_PUBKEY;
PEM_write_bio_of_void_protected *pem_write_bio_PrivateKey;
PEM_write_bio_of_void_unprotected *pem_write_bio_PublicKey;
PEM_write_bio_of_void_unprotected *pem_write_bio_params;
PEM_write_bio_of_void_unprotected *pem_write_bio_PUBKEY;
d2i_of_void *d2i_PrivateKey;
d2i_of_void *d2i_PublicKey;
d2i_of_void *d2i_params;
d2i_of_void *d2i_PUBKEY;
PEM_read_bio_of_void *pem_read_bio_PrivateKey;
PEM_read_bio_of_void *pem_read_bio_PublicKey;
PEM_read_bio_of_void *pem_read_bio_params;
PEM_read_bio_of_void *pem_read_bio_PUBKEY;
} test_stanzas[] = {
#ifndef OPENSSL_NO_DH
{ "DH", { "DH", "type-specific" }, EVP_PKEY_DH,
NULL, /* No i2d_DHPrivateKey */
NULL, /* No i2d_DHPublicKey */
(i2d_of_void *)i2d_DHparams,
NULL, /* No i2d_DH_PUBKEY */
NULL, /* No PEM_write_bio_DHPrivateKey */
NULL, /* No PEM_write_bio_DHPublicKey */
(PEM_write_bio_of_void_unprotected *)PEM_write_bio_DHparams,
NULL, /* No PEM_write_bio_DH_PUBKEY */
NULL, /* No d2i_DHPrivateKey */
NULL, /* No d2i_DHPublicKey */
(d2i_of_void *)d2i_DHparams,
NULL, /* No d2i_DH_PUBKEY */
NULL, /* No PEM_read_bio_DHPrivateKey */
NULL, /* No PEM_read_bio_DHPublicKey */
(PEM_read_bio_of_void *)PEM_read_bio_DHparams,
NULL }, /* No PEM_read_bio_DH_PUBKEY */
{ "DHX", { "DHX", "type-specific" }, EVP_PKEY_DHX,
NULL, /* No i2d_DHxPrivateKey */
NULL, /* No i2d_DHxPublicKey */
(i2d_of_void *)i2d_DHxparams,
NULL, /* No i2d_DHx_PUBKEY */
NULL, /* No PEM_write_bio_DHxPrivateKey */
NULL, /* No PEM_write_bio_DHxPublicKey */
(PEM_write_bio_of_void_unprotected *)PEM_write_bio_DHxparams,
NULL, /* No PEM_write_bio_DHx_PUBKEY */
NULL, /* No d2i_DHxPrivateKey */
NULL, /* No d2i_DHxPublicKey */
(d2i_of_void *)d2i_DHxparams,
NULL, /* No d2i_DHx_PUBKEY */
NULL, /* No PEM_read_bio_DHxPrivateKey */
NULL, /* No PEM_read_bio_DHxPublicKey */
NULL, /* No PEM_read_bio_DHxparams */
NULL }, /* No PEM_read_bio_DHx_PUBKEY */
#endif
#ifndef OPENSSL_NO_DSA
{ "DSA", { "DSA", "type-specific" }, EVP_PKEY_DSA,
(i2d_of_void *)i2d_DSAPrivateKey,
(i2d_of_void *)i2d_DSAPublicKey,
(i2d_of_void *)i2d_DSAparams,
(i2d_of_void *)i2d_DSA_PUBKEY,
(PEM_write_bio_of_void_protected *)PEM_write_bio_DSAPrivateKey,
NULL, /* No PEM_write_bio_DSAPublicKey */
(PEM_write_bio_of_void_unprotected *)PEM_write_bio_DSAparams,
(PEM_write_bio_of_void_unprotected *)PEM_write_bio_DSA_PUBKEY,
(d2i_of_void *)d2i_DSAPrivateKey,
(d2i_of_void *)d2i_DSAPublicKey,
(d2i_of_void *)d2i_DSAparams,
(d2i_of_void *)d2i_DSA_PUBKEY,
(PEM_read_bio_of_void *)PEM_read_bio_DSAPrivateKey,
NULL, /* No PEM_write_bio_DSAPublicKey */
(PEM_read_bio_of_void *)PEM_read_bio_DSAparams,
(PEM_read_bio_of_void *)PEM_read_bio_DSA_PUBKEY },
#endif
#ifndef OPENSSL_NO_EC
{ "EC", { "EC", "type-specific" }, EVP_PKEY_EC,
(i2d_of_void *)i2d_ECPrivateKey,
NULL, /* No i2d_ECPublicKey */
(i2d_of_void *)i2d_ECParameters,
(i2d_of_void *)i2d_EC_PUBKEY,
(PEM_write_bio_of_void_protected *)PEM_write_bio_ECPrivateKey,
NULL, /* No PEM_write_bio_ECPublicKey */
NULL, /* No PEM_write_bio_ECParameters */
(PEM_write_bio_of_void_unprotected *)PEM_write_bio_EC_PUBKEY,
(d2i_of_void *)d2i_ECPrivateKey,
NULL, /* No d2i_ECPublicKey */
(d2i_of_void *)d2i_ECParameters,
(d2i_of_void *)d2i_EC_PUBKEY,
(PEM_read_bio_of_void *)PEM_read_bio_ECPrivateKey,
NULL, /* No PEM_read_bio_ECPublicKey */
NULL, /* No PEM_read_bio_ECParameters */
(PEM_read_bio_of_void *)PEM_read_bio_EC_PUBKEY, },
#endif
{ "RSA", { "RSA", "type-specific" }, EVP_PKEY_RSA,
(i2d_of_void *)i2d_RSAPrivateKey,
(i2d_of_void *)i2d_RSAPublicKey,
NULL, /* No i2d_RSAparams */
(i2d_of_void *)i2d_RSA_PUBKEY,
(PEM_write_bio_of_void_protected *)PEM_write_bio_RSAPrivateKey,
(PEM_write_bio_of_void_unprotected *)PEM_write_bio_RSAPublicKey,
NULL, /* No PEM_write_bio_RSAparams */
(PEM_write_bio_of_void_unprotected *)PEM_write_bio_RSA_PUBKEY,
(d2i_of_void *)d2i_RSAPrivateKey,
(d2i_of_void *)d2i_RSAPublicKey,
NULL, /* No d2i_RSAparams */
(d2i_of_void *)d2i_RSA_PUBKEY,
(PEM_read_bio_of_void *)PEM_read_bio_RSAPrivateKey,
(PEM_read_bio_of_void *)PEM_read_bio_RSAPublicKey,
NULL, /* No PEM_read_bio_RSAparams */
(PEM_read_bio_of_void *)PEM_read_bio_RSA_PUBKEY }
};
/*
* Keys that we're going to test with. We initialize this with the intended
* key types, and generate the keys themselves on program setup.
* They must all be downgradable with EVP_PKEY_get0()
*/
#ifndef OPENSSL_NO_DH
static const OSSL_PARAM DH_params[] = { OSSL_PARAM_END };
static const OSSL_PARAM DHX_params[] = { OSSL_PARAM_END };
#endif
#ifndef OPENSSL_NO_DSA
static size_t qbits = 160; /* PVK only tolerates 160 Q bits */
static size_t pbits = 1024; /* With 160 Q bits, we MUST use 1024 P bits */
static const OSSL_PARAM DSA_params[] = {
OSSL_PARAM_size_t("pbits", &pbits),
OSSL_PARAM_size_t("qbits", &qbits),
OSSL_PARAM_END
};
#endif
#ifndef OPENSSL_NO_EC
static char groupname[] = "prime256v1";
static const OSSL_PARAM EC_params[] = {
OSSL_PARAM_utf8_string("group", groupname, sizeof(groupname) - 1),
OSSL_PARAM_END
};
#endif
static struct key_st {
const char *keytype;
int evp_type;
/* non-NULL if a template EVP_PKEY must be generated first */
const OSSL_PARAM *template_params;
EVP_PKEY *key;
} keys[] = {
#ifndef OPENSSL_NO_DH
{ "DH", EVP_PKEY_DH, DH_params, NULL },
{ "DHX", EVP_PKEY_DHX, DHX_params, NULL },
#endif
#ifndef OPENSSL_NO_DSA
{ "DSA", EVP_PKEY_DSA, DSA_params, NULL },
#endif
#ifndef OPENSSL_NO_EC
{ "EC", EVP_PKEY_EC, EC_params, NULL },
#endif
#ifndef OPENSSL_NO_DEPRECATED_3_0
{ "RSA", EVP_PKEY_RSA, NULL, NULL },
#endif
};
static EVP_PKEY *make_key(const char *type,
const OSSL_PARAM *gen_template_params)
{
EVP_PKEY *template = NULL;
EVP_PKEY *pkey = NULL;
EVP_PKEY_CTX *ctx = NULL;
OSSL_PARAM *gen_template_params_noconst =
(OSSL_PARAM *)gen_template_params;
if (gen_template_params != NULL
&& ((ctx = EVP_PKEY_CTX_new_from_name(NULL, type, NULL)) == NULL
|| EVP_PKEY_paramgen_init(ctx) <= 0
|| (gen_template_params[0].key != NULL
&& EVP_PKEY_CTX_set_params(ctx, gen_template_params_noconst) <= 0)
|| EVP_PKEY_generate(ctx, &template) <= 0))
goto end;
EVP_PKEY_CTX_free(ctx);
/*
* No real need to check the errors other than for the cascade
* effect. |pkey| will simply remain NULL if something goes wrong.
*/
ctx =
template != NULL
? EVP_PKEY_CTX_new(template, NULL)
: EVP_PKEY_CTX_new_from_name(NULL, type, NULL);
(void)(ctx != NULL
&& EVP_PKEY_keygen_init(ctx) > 0
&& EVP_PKEY_keygen(ctx, &pkey) > 0);
end:
EVP_PKEY_free(template);
EVP_PKEY_CTX_free(ctx);
return pkey;
}
static struct key_st *lookup_key(const char *type)
{
size_t i;
for (i = 0; i < OSSL_NELEM(keys); i++) {
if (strcmp(keys[i].keytype, type) == 0)
return &keys[i];
}
return NULL;
}
static int test_membio_str_eq(BIO *bio_provided, BIO *bio_legacy)
{
char *str_provided = NULL, *str_legacy = NULL;
long len_provided = BIO_get_mem_data(bio_provided, &str_provided);
long len_legacy = BIO_get_mem_data(bio_legacy, &str_legacy);
return TEST_long_ge(len_legacy, 0)
&& TEST_long_ge(len_provided, 0)
&& TEST_strn2_eq(str_provided, len_provided,
str_legacy, len_legacy);
}
static int test_protected_PEM(const char *keytype, int evp_type,
const void *legacy_key,
PEM_write_bio_of_void_protected *pem_write_bio,
PEM_read_bio_of_void *pem_read_bio,
EVP_PKEY_eq_fn *evp_pkey_eq,
EVP_PKEY_print_fn *evp_pkey_print,
EVP_PKEY *provided_pkey, int selection,
const char *structure)
{
int ok = 0;
BIO *membio_legacy = NULL;
BIO *membio_provided = NULL;
OSSL_ENCODER_CTX *ectx = NULL;
OSSL_DECODER_CTX *dctx = NULL;
void *decoded_legacy_key = NULL;
EVP_PKEY *decoded_legacy_pkey = NULL;
EVP_PKEY *decoded_provided_pkey = NULL;
/* Set up the BIOs, so we have them */
if (!TEST_ptr(membio_legacy = BIO_new(BIO_s_mem()))
|| !TEST_ptr(membio_provided = BIO_new(BIO_s_mem())))
goto end;
if (!TEST_ptr(ectx =
OSSL_ENCODER_CTX_new_for_pkey(provided_pkey, selection,
"PEM", structure,
NULL))
|| !TEST_true(OSSL_ENCODER_to_bio(ectx, membio_provided))
|| !TEST_true(pem_write_bio(membio_legacy, legacy_key,
NULL, NULL, 0, NULL, NULL))
|| !test_membio_str_eq(membio_provided, membio_legacy))
goto end;
if (pem_read_bio != NULL) {
/* Now try decoding the results and compare the resulting keys */
if (!TEST_ptr(decoded_legacy_pkey = EVP_PKEY_new())
|| !TEST_ptr(dctx =
OSSL_DECODER_CTX_new_for_pkey(&decoded_provided_pkey,
"PEM", structure,
keytype, selection,
NULL, NULL))
|| !TEST_true(OSSL_DECODER_from_bio(dctx, membio_provided))
|| !TEST_ptr(decoded_legacy_key =
pem_read_bio(membio_legacy, NULL, NULL, NULL))
|| !TEST_true(EVP_PKEY_assign(decoded_legacy_pkey, evp_type,
decoded_legacy_key)))
goto end;
if (!TEST_int_gt(evp_pkey_eq(decoded_provided_pkey,
decoded_legacy_pkey), 0)) {
TEST_info("decoded_provided_pkey:");
evp_pkey_print(bio_out, decoded_provided_pkey, 0, NULL);
TEST_info("decoded_legacy_pkey:");
evp_pkey_print(bio_out, decoded_legacy_pkey, 0, NULL);
}
}
ok = 1;
end:
EVP_PKEY_free(decoded_legacy_pkey);
EVP_PKEY_free(decoded_provided_pkey);
OSSL_ENCODER_CTX_free(ectx);
OSSL_DECODER_CTX_free(dctx);
BIO_free(membio_provided);
BIO_free(membio_legacy);
return ok;
}
static int test_unprotected_PEM(const char *keytype, int evp_type,
const void *legacy_key,
PEM_write_bio_of_void_unprotected *pem_write_bio,
PEM_read_bio_of_void *pem_read_bio,
EVP_PKEY_eq_fn *evp_pkey_eq,
EVP_PKEY_print_fn *evp_pkey_print,
EVP_PKEY *provided_pkey, int selection,
const char *structure)
{
int ok = 0;
BIO *membio_legacy = NULL;
BIO *membio_provided = NULL;
OSSL_ENCODER_CTX *ectx = NULL;
OSSL_DECODER_CTX *dctx = NULL;
void *decoded_legacy_key = NULL;
EVP_PKEY *decoded_legacy_pkey = NULL;
EVP_PKEY *decoded_provided_pkey = NULL;
/* Set up the BIOs, so we have them */
if (!TEST_ptr(membio_legacy = BIO_new(BIO_s_mem()))
|| !TEST_ptr(membio_provided = BIO_new(BIO_s_mem())))
goto end;
if (!TEST_ptr(ectx =
OSSL_ENCODER_CTX_new_for_pkey(provided_pkey, selection,
"PEM", structure,
NULL))
|| !TEST_true(OSSL_ENCODER_to_bio(ectx, membio_provided))
|| !TEST_true(pem_write_bio(membio_legacy, legacy_key))
|| !test_membio_str_eq(membio_provided, membio_legacy))
goto end;
if (pem_read_bio != NULL) {
/* Now try decoding the results and compare the resulting keys */
if (!TEST_ptr(decoded_legacy_pkey = EVP_PKEY_new())
|| !TEST_ptr(dctx =
OSSL_DECODER_CTX_new_for_pkey(&decoded_provided_pkey,
"PEM", structure,
keytype, selection,
NULL, NULL))
|| !TEST_true(OSSL_DECODER_from_bio(dctx, membio_provided))
|| !TEST_ptr(decoded_legacy_key =
pem_read_bio(membio_legacy, NULL, NULL, NULL))
|| !TEST_true(EVP_PKEY_assign(decoded_legacy_pkey, evp_type,
decoded_legacy_key)))
goto end;
if (!TEST_int_gt(evp_pkey_eq(decoded_provided_pkey,
decoded_legacy_pkey), 0)) {
TEST_info("decoded_provided_pkey:");
evp_pkey_print(bio_out, decoded_provided_pkey, 0, NULL);
TEST_info("decoded_legacy_pkey:");
evp_pkey_print(bio_out, decoded_legacy_pkey, 0, NULL);
}
}
ok = 1;
end:
EVP_PKEY_free(decoded_legacy_pkey);
EVP_PKEY_free(decoded_provided_pkey);
OSSL_ENCODER_CTX_free(ectx);
OSSL_DECODER_CTX_free(dctx);
BIO_free(membio_provided);
BIO_free(membio_legacy);
return ok;
}
static int test_DER(const char *keytype, int evp_type,
const void *legacy_key, i2d_of_void *i2d, d2i_of_void *d2i,
EVP_PKEY_eq_fn *evp_pkey_eq,
EVP_PKEY_print_fn *evp_pkey_print,
EVP_PKEY *provided_pkey, int selection,
const char *structure)
{
int ok = 0;
unsigned char *der_legacy = NULL;
const unsigned char *pder_legacy = NULL;
size_t der_legacy_len = 0;
unsigned char *der_provided = NULL;
const unsigned char *pder_provided = NULL;
size_t der_provided_len = 0;
size_t tmp_size;
OSSL_ENCODER_CTX *ectx = NULL;
OSSL_DECODER_CTX *dctx = NULL;
void *decoded_legacy_key = NULL;
EVP_PKEY *decoded_legacy_pkey = NULL;
EVP_PKEY *decoded_provided_pkey = NULL;
if (!TEST_ptr(ectx =
OSSL_ENCODER_CTX_new_for_pkey(provided_pkey, selection,
"DER", structure,
NULL))
|| !TEST_true(OSSL_ENCODER_to_data(ectx,
&der_provided, &der_provided_len))
|| !TEST_size_t_gt(der_legacy_len = i2d(legacy_key, &der_legacy), 0)
|| !TEST_mem_eq(der_provided, der_provided_len,
der_legacy, der_legacy_len))
goto end;
if (d2i != NULL) {
/* Now try decoding the results and compare the resulting keys */
if (!TEST_ptr(decoded_legacy_pkey = EVP_PKEY_new())
|| !TEST_ptr(dctx =
OSSL_DECODER_CTX_new_for_pkey(&decoded_provided_pkey,
"DER", structure,
keytype, selection,
NULL, NULL))
|| !TEST_true((pder_provided = der_provided,
tmp_size = der_provided_len,
OSSL_DECODER_from_data(dctx, &pder_provided,
&tmp_size)))
|| !TEST_ptr((pder_legacy = der_legacy,
decoded_legacy_key = d2i(NULL, &pder_legacy,
(long)der_legacy_len)))
|| !TEST_true(EVP_PKEY_assign(decoded_legacy_pkey, evp_type,
decoded_legacy_key)))
goto end;
if (!TEST_int_gt(evp_pkey_eq(decoded_provided_pkey,
decoded_legacy_pkey), 0)) {
TEST_info("decoded_provided_pkey:");
evp_pkey_print(bio_out, decoded_provided_pkey, 0, NULL);
TEST_info("decoded_legacy_pkey:");
evp_pkey_print(bio_out, decoded_legacy_pkey, 0, NULL);
}
}
ok = 1;
end:
EVP_PKEY_free(decoded_legacy_pkey);
EVP_PKEY_free(decoded_provided_pkey);
OSSL_ENCODER_CTX_free(ectx);
OSSL_DECODER_CTX_free(dctx);
OPENSSL_free(der_provided);
OPENSSL_free(der_legacy);
return ok;
}
static int test_key(int idx)
{
struct test_stanza_st *test_stanza = NULL;
struct key_st *key = NULL;
int ok = 0;
size_t i;
EVP_PKEY *pkey = NULL, *downgraded_pkey = NULL;
const void *legacy_obj = NULL;
/* Get the test data */
if (!TEST_ptr(test_stanza = &test_stanzas[idx])
|| !TEST_ptr(key = lookup_key(test_stanza->keytype)))
goto end;
/* Set up the keys */
if (!TEST_ptr(pkey = key->key)
|| !TEST_true(evp_pkey_copy_downgraded(&downgraded_pkey, pkey))
|| !TEST_ptr(downgraded_pkey)
|| !TEST_int_eq(EVP_PKEY_get_id(downgraded_pkey), key->evp_type)
|| !TEST_ptr(legacy_obj = EVP_PKEY_get0(downgraded_pkey)))
goto end;
ok = 1;
/* Test PrivateKey to PEM */
if (test_stanza->pem_write_bio_PrivateKey != NULL) {
int selection = OSSL_KEYMGMT_SELECT_ALL;
for (i = 0; i < OSSL_NELEM(test_stanza->structure); i++) {
const char *structure = test_stanza->structure[i];
TEST_info("Test OSSL_ENCODER against PEM_write_bio_{TYPE}PrivateKey for %s, %s",
test_stanza->keytype, structure);
if (!test_protected_PEM(key->keytype, key->evp_type, legacy_obj,
test_stanza->pem_write_bio_PrivateKey,
test_stanza->pem_read_bio_PrivateKey,
EVP_PKEY_eq, EVP_PKEY_print_private,
pkey, selection, structure))
ok = 0;
}
}
/* Test PublicKey to PEM */
if (test_stanza->pem_write_bio_PublicKey != NULL) {
int selection =
OSSL_KEYMGMT_SELECT_PUBLIC_KEY
| OSSL_KEYMGMT_SELECT_ALL_PARAMETERS;
for (i = 0; i < OSSL_NELEM(test_stanza->structure); i++) {
const char *structure = test_stanza->structure[i];
TEST_info("Test OSSL_ENCODER against PEM_write_bio_{TYPE}PublicKey for %s, %s",
test_stanza->keytype, structure);
if (!test_unprotected_PEM(key->keytype, key->evp_type, legacy_obj,
test_stanza->pem_write_bio_PublicKey,
test_stanza->pem_read_bio_PublicKey,
EVP_PKEY_eq, EVP_PKEY_print_public,
pkey, selection, structure))
ok = 0;
}
}
/* Test params to PEM */
if (test_stanza->pem_write_bio_params != NULL) {
int selection = OSSL_KEYMGMT_SELECT_ALL_PARAMETERS;
for (i = 0; i < OSSL_NELEM(test_stanza->structure); i++) {
const char *structure = test_stanza->structure[i];
TEST_info("Test OSSL_ENCODER against PEM_write_bio_{TYPE}params for %s, %s",
test_stanza->keytype, structure);
if (!test_unprotected_PEM(key->keytype, key->evp_type, legacy_obj,
test_stanza->pem_write_bio_params,
test_stanza->pem_read_bio_params,
EVP_PKEY_parameters_eq,
EVP_PKEY_print_params,
pkey, selection, structure))
ok = 0;
}
}
/* Test PUBKEY to PEM */
if (test_stanza->pem_write_bio_PUBKEY != NULL) {
int selection =
OSSL_KEYMGMT_SELECT_PUBLIC_KEY
| OSSL_KEYMGMT_SELECT_ALL_PARAMETERS;
const char *structure = "SubjectPublicKeyInfo";
TEST_info("Test OSSL_ENCODER against PEM_write_bio_{TYPE}_PUBKEY for %s, %s",
test_stanza->keytype, structure);
if (!test_unprotected_PEM(key->keytype, key->evp_type, legacy_obj,
test_stanza->pem_write_bio_PUBKEY,
test_stanza->pem_read_bio_PUBKEY,
EVP_PKEY_eq, EVP_PKEY_print_public,
pkey, selection, structure))
ok = 0;
}
/* Test PrivateKey to DER */
if (test_stanza->i2d_PrivateKey != NULL) {
int selection = OSSL_KEYMGMT_SELECT_ALL;
for (i = 0; i < OSSL_NELEM(test_stanza->structure); i++) {
const char *structure = test_stanza->structure[i];
TEST_info("Test OSSL_ENCODER against i2d_{TYPE}PrivateKey for %s, %s",
test_stanza->keytype, structure);
if (!test_DER(key->keytype, key->evp_type, legacy_obj,
test_stanza->i2d_PrivateKey,
test_stanza->d2i_PrivateKey,
EVP_PKEY_eq, EVP_PKEY_print_private,
pkey, selection, structure))
ok = 0;
}
}
/* Test PublicKey to DER */
if (test_stanza->i2d_PublicKey != NULL) {
int selection =
OSSL_KEYMGMT_SELECT_PUBLIC_KEY
| OSSL_KEYMGMT_SELECT_ALL_PARAMETERS;
for (i = 0; i < OSSL_NELEM(test_stanza->structure); i++) {
const char *structure = test_stanza->structure[i];
TEST_info("Test OSSL_ENCODER against i2d_{TYPE}PublicKey for %s, %s",
test_stanza->keytype, structure);
if (!test_DER(key->keytype, key->evp_type, legacy_obj,
test_stanza->i2d_PublicKey,
test_stanza->d2i_PublicKey,
EVP_PKEY_eq, EVP_PKEY_print_public,
pkey, selection, structure))
ok = 0;
}
}
/* Test params to DER */
if (test_stanza->i2d_params != NULL) {
int selection = OSSL_KEYMGMT_SELECT_ALL_PARAMETERS;
for (i = 0; i < OSSL_NELEM(test_stanza->structure); i++) {
const char *structure = test_stanza->structure[i];
TEST_info("Test OSSL_ENCODER against i2d_{TYPE}params for %s, %s",
test_stanza->keytype, structure);
if (!test_DER(key->keytype, key->evp_type, legacy_obj,
test_stanza->i2d_params, test_stanza->d2i_params,
EVP_PKEY_parameters_eq, EVP_PKEY_print_params,
pkey, selection, structure))
ok = 0;
}
}
/* Test PUBKEY to DER */
if (test_stanza->i2d_PUBKEY != NULL) {
int selection =
OSSL_KEYMGMT_SELECT_PUBLIC_KEY
| OSSL_KEYMGMT_SELECT_ALL_PARAMETERS;
const char *structure = "SubjectPublicKeyInfo";
TEST_info("Test OSSL_ENCODER against i2d_{TYPE}_PUBKEY for %s, %s",
test_stanza->keytype, structure);
if (!test_DER(key->keytype, key->evp_type, legacy_obj,
test_stanza->i2d_PUBKEY, test_stanza->d2i_PUBKEY,
EVP_PKEY_eq, EVP_PKEY_print_public,
pkey, selection, structure))
ok = 0;
}
end:
EVP_PKEY_free(downgraded_pkey);
return ok;
}
#define USAGE "rsa-key.pem dh-key.pem\n"
OPT_TEST_DECLARE_USAGE(USAGE)
int setup_tests(void)
{
size_t i;
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (test_get_argument_count() != 2) {
TEST_error("usage: endecoder_legacy_test %s", USAGE);
return 0;
}
TEST_info("Generating keys...");
for (i = 0; i < OSSL_NELEM(keys); i++) {
#ifndef OPENSSL_NO_DH
if (strcmp(keys[i].keytype, "DH") == 0) {
if (!TEST_ptr(keys[i].key =
load_pkey_pem(test_get_argument(1), NULL)))
return 0;
continue;
}
#endif
#ifndef OPENSSL_NO_DEPRECATED_3_0
if (strcmp(keys[i].keytype, "RSA") == 0) {
if (!TEST_ptr(keys[i].key =
load_pkey_pem(test_get_argument(0), NULL)))
return 0;
continue;
}
#endif
TEST_info("Generating %s key...", keys[i].keytype);
if (!TEST_ptr(keys[i].key =
make_key(keys[i].keytype, keys[i].template_params)))
return 0;
}
TEST_info("Generating keys done");
ADD_ALL_TESTS(test_key, OSSL_NELEM(test_stanzas));
return 1;
}
void cleanup_tests(void)
{
size_t i;
for (i = 0; i < OSSL_NELEM(keys); i++)
EVP_PKEY_free(keys[i].key);
}
|
./openssl/test/dhtest.c | /*
* Copyright 1995-2023 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
*/
/*
* DH low level APIs are deprecated for public use, but still ok for
* internal use.
*/
#include "internal/deprecated.h"
#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/obj_mac.h>
#include <openssl/core_names.h>
#include "testutil.h"
#ifndef OPENSSL_NO_DH
# include <openssl/dh.h>
# include "crypto/bn_dh.h"
# include "crypto/dh.h"
static int cb(int p, int n, BN_GENCB *arg);
static int dh_test(void)
{
DH *dh = NULL;
BIGNUM *p = NULL, *q = NULL, *g = NULL;
const BIGNUM *p2, *q2, *g2;
BIGNUM *priv_key = NULL;
const BIGNUM *pub_key2, *priv_key2;
BN_GENCB *_cb = NULL;
DH *a = NULL;
DH *b = NULL;
DH *c = NULL;
const BIGNUM *ap = NULL, *ag = NULL, *apub_key = NULL;
const BIGNUM *bpub_key = NULL, *bpriv_key = NULL;
BIGNUM *bp = NULL, *bg = NULL, *cpriv_key = NULL;
unsigned char *abuf = NULL;
unsigned char *bbuf = NULL;
unsigned char *cbuf = NULL;
int i, alen, blen, clen, aout, bout, cout;
int ret = 0;
if (!TEST_ptr(dh = DH_new())
|| !TEST_ptr(p = BN_new())
|| !TEST_ptr(q = BN_new())
|| !TEST_ptr(g = BN_new())
|| !TEST_ptr(priv_key = BN_new()))
goto err1;
/*
* I) basic tests
*/
/* using a small predefined Sophie Germain DH group with generator 3 */
if (!TEST_true(BN_set_word(p, 4079L))
|| !TEST_true(BN_set_word(q, 2039L))
|| !TEST_true(BN_set_word(g, 3L))
|| !TEST_true(DH_set0_pqg(dh, p, q, g)))
goto err1;
/* check fails, because p is way too small */
if (!TEST_true(DH_check(dh, &i)))
goto err2;
i ^= DH_MODULUS_TOO_SMALL;
if (!TEST_false(i & DH_CHECK_P_NOT_PRIME)
|| !TEST_false(i & DH_CHECK_P_NOT_SAFE_PRIME)
|| !TEST_false(i & DH_UNABLE_TO_CHECK_GENERATOR)
|| !TEST_false(i & DH_NOT_SUITABLE_GENERATOR)
|| !TEST_false(i & DH_CHECK_Q_NOT_PRIME)
|| !TEST_false(i & DH_CHECK_INVALID_Q_VALUE)
|| !TEST_false(i & DH_CHECK_INVALID_J_VALUE)
|| !TEST_false(i & DH_MODULUS_TOO_SMALL)
|| !TEST_false(i & DH_MODULUS_TOO_LARGE)
|| !TEST_false(i))
goto err2;
/* test the combined getter for p, q, and g */
DH_get0_pqg(dh, &p2, &q2, &g2);
if (!TEST_ptr_eq(p2, p)
|| !TEST_ptr_eq(q2, q)
|| !TEST_ptr_eq(g2, g))
goto err2;
/* test the simple getters for p, q, and g */
if (!TEST_ptr_eq(DH_get0_p(dh), p2)
|| !TEST_ptr_eq(DH_get0_q(dh), q2)
|| !TEST_ptr_eq(DH_get0_g(dh), g2))
goto err2;
/* set the private key only*/
if (!TEST_true(BN_set_word(priv_key, 1234L))
|| !TEST_true(DH_set0_key(dh, NULL, priv_key)))
goto err2;
/* test the combined getter for pub_key and priv_key */
DH_get0_key(dh, &pub_key2, &priv_key2);
if (!TEST_ptr_eq(pub_key2, NULL)
|| !TEST_ptr_eq(priv_key2, priv_key))
goto err3;
/* test the simple getters for pub_key and priv_key */
if (!TEST_ptr_eq(DH_get0_pub_key(dh), pub_key2)
|| !TEST_ptr_eq(DH_get0_priv_key(dh), priv_key2))
goto err3;
/* now generate a key pair (expect failure since modulus is too small) */
if (!TEST_false(DH_generate_key(dh)))
goto err3;
/* We'll have a stale error on the queue from the above test so clear it */
ERR_clear_error();
if (!TEST_ptr(BN_copy(q, p)) || !TEST_true(BN_add(q, q, BN_value_one())))
goto err3;
if (!TEST_true(DH_check(dh, &i)))
goto err3;
if (!TEST_true(i & DH_CHECK_INVALID_Q_VALUE)
|| !TEST_false(i & DH_CHECK_Q_NOT_PRIME))
goto err3;
/* Modulus of size: dh check max modulus bits + 1 */
if (!TEST_true(BN_set_word(p, 1))
|| !TEST_true(BN_lshift(p, p, OPENSSL_DH_CHECK_MAX_MODULUS_BITS)))
goto err3;
/*
* We expect no checks at all for an excessively large modulus
*/
if (!TEST_false(DH_check(dh, &i)))
goto err3;
/* We'll have a stale error on the queue from the above test so clear it */
ERR_clear_error();
/*
* II) key generation
*/
/* generate a DH group ... */
if (!TEST_ptr(_cb = BN_GENCB_new()))
goto err3;
BN_GENCB_set(_cb, &cb, NULL);
if (!TEST_ptr(a = DH_new())
|| !TEST_true(DH_generate_parameters_ex(a, 512,
DH_GENERATOR_5, _cb)))
goto err3;
/* ... and check whether it is valid */
if (!TEST_true(DH_check(a, &i)))
goto err3;
if (!TEST_false(i & DH_CHECK_P_NOT_PRIME)
|| !TEST_false(i & DH_CHECK_P_NOT_SAFE_PRIME)
|| !TEST_false(i & DH_UNABLE_TO_CHECK_GENERATOR)
|| !TEST_false(i & DH_NOT_SUITABLE_GENERATOR)
|| !TEST_false(i & DH_CHECK_Q_NOT_PRIME)
|| !TEST_false(i & DH_CHECK_INVALID_Q_VALUE)
|| !TEST_false(i & DH_CHECK_INVALID_J_VALUE)
|| !TEST_false(i & DH_MODULUS_TOO_SMALL)
|| !TEST_false(i & DH_MODULUS_TOO_LARGE)
|| !TEST_false(i))
goto err3;
DH_get0_pqg(a, &ap, NULL, &ag);
/* now create another copy of the DH group for the peer */
if (!TEST_ptr(b = DH_new()))
goto err3;
if (!TEST_ptr(bp = BN_dup(ap))
|| !TEST_ptr(bg = BN_dup(ag))
|| !TEST_true(DH_set0_pqg(b, bp, NULL, bg)))
goto err3;
bp = bg = NULL;
/*
* III) simulate a key exchange
*/
if (!DH_generate_key(a))
goto err3;
DH_get0_key(a, &apub_key, NULL);
if (!DH_generate_key(b))
goto err3;
DH_get0_key(b, &bpub_key, &bpriv_key);
/* Also test with a private-key-only copy of |b|. */
if (!TEST_ptr(c = DHparams_dup(b))
|| !TEST_ptr(cpriv_key = BN_dup(bpriv_key))
|| !TEST_true(DH_set0_key(c, NULL, cpriv_key)))
goto err3;
cpriv_key = NULL;
alen = DH_size(a);
if (!TEST_ptr(abuf = OPENSSL_malloc(alen))
|| !TEST_true((aout = DH_compute_key(abuf, bpub_key, a)) != -1))
goto err3;
blen = DH_size(b);
if (!TEST_ptr(bbuf = OPENSSL_malloc(blen))
|| !TEST_true((bout = DH_compute_key(bbuf, apub_key, b)) != -1))
goto err3;
clen = DH_size(c);
if (!TEST_ptr(cbuf = OPENSSL_malloc(clen))
|| !TEST_true((cout = DH_compute_key(cbuf, apub_key, c)) != -1))
goto err3;
if (!TEST_true(aout >= 20)
|| !TEST_mem_eq(abuf, aout, bbuf, bout)
|| !TEST_mem_eq(abuf, aout, cbuf, cout))
goto err3;
ret = 1;
goto success;
err1:
/* an error occurred before p,q,g were assigned to dh */
BN_free(p);
BN_free(q);
BN_free(g);
err2:
/* an error occurred before priv_key was assigned to dh */
BN_free(priv_key);
err3:
success:
OPENSSL_free(abuf);
OPENSSL_free(bbuf);
OPENSSL_free(cbuf);
DH_free(b);
DH_free(a);
DH_free(c);
BN_free(bp);
BN_free(bg);
BN_free(cpriv_key);
BN_GENCB_free(_cb);
DH_free(dh);
return ret;
}
static int cb(int p, int n, BN_GENCB *arg)
{
return 1;
}
static int dh_computekey_range_test(void)
{
int ret = 0, sz;
DH *dh = NULL;
BIGNUM *p = NULL, *q = NULL, *g = NULL, *pub = NULL, *priv = NULL;
unsigned char *buf = NULL;
if (!TEST_ptr(p = BN_dup(&ossl_bignum_ffdhe2048_p))
|| !TEST_ptr(q = BN_dup(&ossl_bignum_ffdhe2048_q))
|| !TEST_ptr(g = BN_dup(&ossl_bignum_const_2))
|| !TEST_ptr(dh = DH_new())
|| !TEST_true(DH_set0_pqg(dh, p, q, g)))
goto err;
p = q = g = NULL;
if (!TEST_int_gt(sz = DH_size(dh), 0)
|| !TEST_ptr(buf = OPENSSL_malloc(sz))
|| !TEST_ptr(pub = BN_new())
|| !TEST_ptr(priv = BN_new()))
goto err;
if (!TEST_true(BN_set_word(priv, 1))
|| !TEST_true(DH_set0_key(dh, NULL, priv)))
goto err;
priv = NULL;
if (!TEST_true(BN_set_word(pub, 1)))
goto err;
/* Given z = pub ^ priv mod p */
/* Test that z == 1 fails */
if (!TEST_int_le(ossl_dh_compute_key(buf, pub, dh), 0))
goto err;
/* Test that z == 0 fails */
if (!TEST_ptr(BN_copy(pub, DH_get0_p(dh)))
|| !TEST_int_le(ossl_dh_compute_key(buf, pub, dh), 0))
goto err;
/* Test that z == p - 1 fails */
if (!TEST_true(BN_sub_word(pub, 1))
|| !TEST_int_le(ossl_dh_compute_key(buf, pub, dh), 0))
goto err;
/* Test that z == p - 2 passes */
if (!TEST_true(BN_sub_word(pub, 1))
|| !TEST_int_eq(ossl_dh_compute_key(buf, pub, dh), sz))
goto err;
ret = 1;
err:
OPENSSL_free(buf);
BN_free(priv);
BN_free(pub);
BN_free(g);
BN_free(q);
BN_free(p);
DH_free(dh);
return ret;
}
/* Test data from RFC 5114 */
static const unsigned char dhtest_1024_160_xA[] = {
0xB9, 0xA3, 0xB3, 0xAE, 0x8F, 0xEF, 0xC1, 0xA2, 0x93, 0x04, 0x96, 0x50,
0x70, 0x86, 0xF8, 0x45, 0x5D, 0x48, 0x94, 0x3E
};
static const unsigned char dhtest_1024_160_yA[] = {
0x2A, 0x85, 0x3B, 0x3D, 0x92, 0x19, 0x75, 0x01, 0xB9, 0x01, 0x5B, 0x2D,
0xEB, 0x3E, 0xD8, 0x4F, 0x5E, 0x02, 0x1D, 0xCC, 0x3E, 0x52, 0xF1, 0x09,
0xD3, 0x27, 0x3D, 0x2B, 0x75, 0x21, 0x28, 0x1C, 0xBA, 0xBE, 0x0E, 0x76,
0xFF, 0x57, 0x27, 0xFA, 0x8A, 0xCC, 0xE2, 0x69, 0x56, 0xBA, 0x9A, 0x1F,
0xCA, 0x26, 0xF2, 0x02, 0x28, 0xD8, 0x69, 0x3F, 0xEB, 0x10, 0x84, 0x1D,
0x84, 0xA7, 0x36, 0x00, 0x54, 0xEC, 0xE5, 0xA7, 0xF5, 0xB7, 0xA6, 0x1A,
0xD3, 0xDF, 0xB3, 0xC6, 0x0D, 0x2E, 0x43, 0x10, 0x6D, 0x87, 0x27, 0xDA,
0x37, 0xDF, 0x9C, 0xCE, 0x95, 0xB4, 0x78, 0x75, 0x5D, 0x06, 0xBC, 0xEA,
0x8F, 0x9D, 0x45, 0x96, 0x5F, 0x75, 0xA5, 0xF3, 0xD1, 0xDF, 0x37, 0x01,
0x16, 0x5F, 0xC9, 0xE5, 0x0C, 0x42, 0x79, 0xCE, 0xB0, 0x7F, 0x98, 0x95,
0x40, 0xAE, 0x96, 0xD5, 0xD8, 0x8E, 0xD7, 0x76
};
static const unsigned char dhtest_1024_160_xB[] = {
0x93, 0x92, 0xC9, 0xF9, 0xEB, 0x6A, 0x7A, 0x6A, 0x90, 0x22, 0xF7, 0xD8,
0x3E, 0x72, 0x23, 0xC6, 0x83, 0x5B, 0xBD, 0xDA
};
static const unsigned char dhtest_1024_160_yB[] = {
0x71, 0x7A, 0x6C, 0xB0, 0x53, 0x37, 0x1F, 0xF4, 0xA3, 0xB9, 0x32, 0x94,
0x1C, 0x1E, 0x56, 0x63, 0xF8, 0x61, 0xA1, 0xD6, 0xAD, 0x34, 0xAE, 0x66,
0x57, 0x6D, 0xFB, 0x98, 0xF6, 0xC6, 0xCB, 0xF9, 0xDD, 0xD5, 0xA5, 0x6C,
0x78, 0x33, 0xF6, 0xBC, 0xFD, 0xFF, 0x09, 0x55, 0x82, 0xAD, 0x86, 0x8E,
0x44, 0x0E, 0x8D, 0x09, 0xFD, 0x76, 0x9E, 0x3C, 0xEC, 0xCD, 0xC3, 0xD3,
0xB1, 0xE4, 0xCF, 0xA0, 0x57, 0x77, 0x6C, 0xAA, 0xF9, 0x73, 0x9B, 0x6A,
0x9F, 0xEE, 0x8E, 0x74, 0x11, 0xF8, 0xD6, 0xDA, 0xC0, 0x9D, 0x6A, 0x4E,
0xDB, 0x46, 0xCC, 0x2B, 0x5D, 0x52, 0x03, 0x09, 0x0E, 0xAE, 0x61, 0x26,
0x31, 0x1E, 0x53, 0xFD, 0x2C, 0x14, 0xB5, 0x74, 0xE6, 0xA3, 0x10, 0x9A,
0x3D, 0xA1, 0xBE, 0x41, 0xBD, 0xCE, 0xAA, 0x18, 0x6F, 0x5C, 0xE0, 0x67,
0x16, 0xA2, 0xB6, 0xA0, 0x7B, 0x3C, 0x33, 0xFE
};
static const unsigned char dhtest_1024_160_Z[] = {
0x5C, 0x80, 0x4F, 0x45, 0x4D, 0x30, 0xD9, 0xC4, 0xDF, 0x85, 0x27, 0x1F,
0x93, 0x52, 0x8C, 0x91, 0xDF, 0x6B, 0x48, 0xAB, 0x5F, 0x80, 0xB3, 0xB5,
0x9C, 0xAA, 0xC1, 0xB2, 0x8F, 0x8A, 0xCB, 0xA9, 0xCD, 0x3E, 0x39, 0xF3,
0xCB, 0x61, 0x45, 0x25, 0xD9, 0x52, 0x1D, 0x2E, 0x64, 0x4C, 0x53, 0xB8,
0x07, 0xB8, 0x10, 0xF3, 0x40, 0x06, 0x2F, 0x25, 0x7D, 0x7D, 0x6F, 0xBF,
0xE8, 0xD5, 0xE8, 0xF0, 0x72, 0xE9, 0xB6, 0xE9, 0xAF, 0xDA, 0x94, 0x13,
0xEA, 0xFB, 0x2E, 0x8B, 0x06, 0x99, 0xB1, 0xFB, 0x5A, 0x0C, 0xAC, 0xED,
0xDE, 0xAE, 0xAD, 0x7E, 0x9C, 0xFB, 0xB3, 0x6A, 0xE2, 0xB4, 0x20, 0x83,
0x5B, 0xD8, 0x3A, 0x19, 0xFB, 0x0B, 0x5E, 0x96, 0xBF, 0x8F, 0xA4, 0xD0,
0x9E, 0x34, 0x55, 0x25, 0x16, 0x7E, 0xCD, 0x91, 0x55, 0x41, 0x6F, 0x46,
0xF4, 0x08, 0xED, 0x31, 0xB6, 0x3C, 0x6E, 0x6D
};
static const unsigned char dhtest_2048_224_xA[] = {
0x22, 0xE6, 0x26, 0x01, 0xDB, 0xFF, 0xD0, 0x67, 0x08, 0xA6, 0x80, 0xF7,
0x47, 0xF3, 0x61, 0xF7, 0x6D, 0x8F, 0x4F, 0x72, 0x1A, 0x05, 0x48, 0xE4,
0x83, 0x29, 0x4B, 0x0C
};
static const unsigned char dhtest_2048_224_yA[] = {
0x1B, 0x3A, 0x63, 0x45, 0x1B, 0xD8, 0x86, 0xE6, 0x99, 0xE6, 0x7B, 0x49,
0x4E, 0x28, 0x8B, 0xD7, 0xF8, 0xE0, 0xD3, 0x70, 0xBA, 0xDD, 0xA7, 0xA0,
0xEF, 0xD2, 0xFD, 0xE7, 0xD8, 0xF6, 0x61, 0x45, 0xCC, 0x9F, 0x28, 0x04,
0x19, 0x97, 0x5E, 0xB8, 0x08, 0x87, 0x7C, 0x8A, 0x4C, 0x0C, 0x8E, 0x0B,
0xD4, 0x8D, 0x4A, 0x54, 0x01, 0xEB, 0x1E, 0x87, 0x76, 0xBF, 0xEE, 0xE1,
0x34, 0xC0, 0x38, 0x31, 0xAC, 0x27, 0x3C, 0xD9, 0xD6, 0x35, 0xAB, 0x0C,
0xE0, 0x06, 0xA4, 0x2A, 0x88, 0x7E, 0x3F, 0x52, 0xFB, 0x87, 0x66, 0xB6,
0x50, 0xF3, 0x80, 0x78, 0xBC, 0x8E, 0xE8, 0x58, 0x0C, 0xEF, 0xE2, 0x43,
0x96, 0x8C, 0xFC, 0x4F, 0x8D, 0xC3, 0xDB, 0x08, 0x45, 0x54, 0x17, 0x1D,
0x41, 0xBF, 0x2E, 0x86, 0x1B, 0x7B, 0xB4, 0xD6, 0x9D, 0xD0, 0xE0, 0x1E,
0xA3, 0x87, 0xCB, 0xAA, 0x5C, 0xA6, 0x72, 0xAF, 0xCB, 0xE8, 0xBD, 0xB9,
0xD6, 0x2D, 0x4C, 0xE1, 0x5F, 0x17, 0xDD, 0x36, 0xF9, 0x1E, 0xD1, 0xEE,
0xDD, 0x65, 0xCA, 0x4A, 0x06, 0x45, 0x5C, 0xB9, 0x4C, 0xD4, 0x0A, 0x52,
0xEC, 0x36, 0x0E, 0x84, 0xB3, 0xC9, 0x26, 0xE2, 0x2C, 0x43, 0x80, 0xA3,
0xBF, 0x30, 0x9D, 0x56, 0x84, 0x97, 0x68, 0xB7, 0xF5, 0x2C, 0xFD, 0xF6,
0x55, 0xFD, 0x05, 0x3A, 0x7E, 0xF7, 0x06, 0x97, 0x9E, 0x7E, 0x58, 0x06,
0xB1, 0x7D, 0xFA, 0xE5, 0x3A, 0xD2, 0xA5, 0xBC, 0x56, 0x8E, 0xBB, 0x52,
0x9A, 0x7A, 0x61, 0xD6, 0x8D, 0x25, 0x6F, 0x8F, 0xC9, 0x7C, 0x07, 0x4A,
0x86, 0x1D, 0x82, 0x7E, 0x2E, 0xBC, 0x8C, 0x61, 0x34, 0x55, 0x31, 0x15,
0xB7, 0x0E, 0x71, 0x03, 0x92, 0x0A, 0xA1, 0x6D, 0x85, 0xE5, 0x2B, 0xCB,
0xAB, 0x8D, 0x78, 0x6A, 0x68, 0x17, 0x8F, 0xA8, 0xFF, 0x7C, 0x2F, 0x5C,
0x71, 0x64, 0x8D, 0x6F
};
static const unsigned char dhtest_2048_224_xB[] = {
0x4F, 0xF3, 0xBC, 0x96, 0xC7, 0xFC, 0x6A, 0x6D, 0x71, 0xD3, 0xB3, 0x63,
0x80, 0x0A, 0x7C, 0xDF, 0xEF, 0x6F, 0xC4, 0x1B, 0x44, 0x17, 0xEA, 0x15,
0x35, 0x3B, 0x75, 0x90
};
static const unsigned char dhtest_2048_224_yB[] = {
0x4D, 0xCE, 0xE9, 0x92, 0xA9, 0x76, 0x2A, 0x13, 0xF2, 0xF8, 0x38, 0x44,
0xAD, 0x3D, 0x77, 0xEE, 0x0E, 0x31, 0xC9, 0x71, 0x8B, 0x3D, 0xB6, 0xC2,
0x03, 0x5D, 0x39, 0x61, 0x18, 0x2C, 0x3E, 0x0B, 0xA2, 0x47, 0xEC, 0x41,
0x82, 0xD7, 0x60, 0xCD, 0x48, 0xD9, 0x95, 0x99, 0x97, 0x06, 0x22, 0xA1,
0x88, 0x1B, 0xBA, 0x2D, 0xC8, 0x22, 0x93, 0x9C, 0x78, 0xC3, 0x91, 0x2C,
0x66, 0x61, 0xFA, 0x54, 0x38, 0xB2, 0x07, 0x66, 0x22, 0x2B, 0x75, 0xE2,
0x4C, 0x2E, 0x3A, 0xD0, 0xC7, 0x28, 0x72, 0x36, 0x12, 0x95, 0x25, 0xEE,
0x15, 0xB5, 0xDD, 0x79, 0x98, 0xAA, 0x04, 0xC4, 0xA9, 0x69, 0x6C, 0xAC,
0xD7, 0x17, 0x20, 0x83, 0xA9, 0x7A, 0x81, 0x66, 0x4E, 0xAD, 0x2C, 0x47,
0x9E, 0x44, 0x4E, 0x4C, 0x06, 0x54, 0xCC, 0x19, 0xE2, 0x8D, 0x77, 0x03,
0xCE, 0xE8, 0xDA, 0xCD, 0x61, 0x26, 0xF5, 0xD6, 0x65, 0xEC, 0x52, 0xC6,
0x72, 0x55, 0xDB, 0x92, 0x01, 0x4B, 0x03, 0x7E, 0xB6, 0x21, 0xA2, 0xAC,
0x8E, 0x36, 0x5D, 0xE0, 0x71, 0xFF, 0xC1, 0x40, 0x0A, 0xCF, 0x07, 0x7A,
0x12, 0x91, 0x3D, 0xD8, 0xDE, 0x89, 0x47, 0x34, 0x37, 0xAB, 0x7B, 0xA3,
0x46, 0x74, 0x3C, 0x1B, 0x21, 0x5D, 0xD9, 0xC1, 0x21, 0x64, 0xA7, 0xE4,
0x05, 0x31, 0x18, 0xD1, 0x99, 0xBE, 0xC8, 0xEF, 0x6F, 0xC5, 0x61, 0x17,
0x0C, 0x84, 0xC8, 0x7D, 0x10, 0xEE, 0x9A, 0x67, 0x4A, 0x1F, 0xA8, 0xFF,
0xE1, 0x3B, 0xDF, 0xBA, 0x1D, 0x44, 0xDE, 0x48, 0x94, 0x6D, 0x68, 0xDC,
0x0C, 0xDD, 0x77, 0x76, 0x35, 0xA7, 0xAB, 0x5B, 0xFB, 0x1E, 0x4B, 0xB7,
0xB8, 0x56, 0xF9, 0x68, 0x27, 0x73, 0x4C, 0x18, 0x41, 0x38, 0xE9, 0x15,
0xD9, 0xC3, 0x00, 0x2E, 0xBC, 0xE5, 0x31, 0x20, 0x54, 0x6A, 0x7E, 0x20,
0x02, 0x14, 0x2B, 0x6C
};
static const unsigned char dhtest_2048_224_Z[] = {
0x34, 0xD9, 0xBD, 0xDC, 0x1B, 0x42, 0x17, 0x6C, 0x31, 0x3F, 0xEA, 0x03,
0x4C, 0x21, 0x03, 0x4D, 0x07, 0x4A, 0x63, 0x13, 0xBB, 0x4E, 0xCD, 0xB3,
0x70, 0x3F, 0xFF, 0x42, 0x45, 0x67, 0xA4, 0x6B, 0xDF, 0x75, 0x53, 0x0E,
0xDE, 0x0A, 0x9D, 0xA5, 0x22, 0x9D, 0xE7, 0xD7, 0x67, 0x32, 0x28, 0x6C,
0xBC, 0x0F, 0x91, 0xDA, 0x4C, 0x3C, 0x85, 0x2F, 0xC0, 0x99, 0xC6, 0x79,
0x53, 0x1D, 0x94, 0xC7, 0x8A, 0xB0, 0x3D, 0x9D, 0xEC, 0xB0, 0xA4, 0xE4,
0xCA, 0x8B, 0x2B, 0xB4, 0x59, 0x1C, 0x40, 0x21, 0xCF, 0x8C, 0xE3, 0xA2,
0x0A, 0x54, 0x1D, 0x33, 0x99, 0x40, 0x17, 0xD0, 0x20, 0x0A, 0xE2, 0xC9,
0x51, 0x6E, 0x2F, 0xF5, 0x14, 0x57, 0x79, 0x26, 0x9E, 0x86, 0x2B, 0x0F,
0xB4, 0x74, 0xA2, 0xD5, 0x6D, 0xC3, 0x1E, 0xD5, 0x69, 0xA7, 0x70, 0x0B,
0x4C, 0x4A, 0xB1, 0x6B, 0x22, 0xA4, 0x55, 0x13, 0x53, 0x1E, 0xF5, 0x23,
0xD7, 0x12, 0x12, 0x07, 0x7B, 0x5A, 0x16, 0x9B, 0xDE, 0xFF, 0xAD, 0x7A,
0xD9, 0x60, 0x82, 0x84, 0xC7, 0x79, 0x5B, 0x6D, 0x5A, 0x51, 0x83, 0xB8,
0x70, 0x66, 0xDE, 0x17, 0xD8, 0xD6, 0x71, 0xC9, 0xEB, 0xD8, 0xEC, 0x89,
0x54, 0x4D, 0x45, 0xEC, 0x06, 0x15, 0x93, 0xD4, 0x42, 0xC6, 0x2A, 0xB9,
0xCE, 0x3B, 0x1C, 0xB9, 0x94, 0x3A, 0x1D, 0x23, 0xA5, 0xEA, 0x3B, 0xCF,
0x21, 0xA0, 0x14, 0x71, 0xE6, 0x7E, 0x00, 0x3E, 0x7F, 0x8A, 0x69, 0xC7,
0x28, 0xBE, 0x49, 0x0B, 0x2F, 0xC8, 0x8C, 0xFE, 0xB9, 0x2D, 0xB6, 0xA2,
0x15, 0xE5, 0xD0, 0x3C, 0x17, 0xC4, 0x64, 0xC9, 0xAC, 0x1A, 0x46, 0xE2,
0x03, 0xE1, 0x3F, 0x95, 0x29, 0x95, 0xFB, 0x03, 0xC6, 0x9D, 0x3C, 0xC4,
0x7F, 0xCB, 0x51, 0x0B, 0x69, 0x98, 0xFF, 0xD3, 0xAA, 0x6D, 0xE7, 0x3C,
0xF9, 0xF6, 0x38, 0x69
};
static const unsigned char dhtest_2048_256_xA[] = {
0x08, 0x81, 0x38, 0x2C, 0xDB, 0x87, 0x66, 0x0C, 0x6D, 0xC1, 0x3E, 0x61,
0x49, 0x38, 0xD5, 0xB9, 0xC8, 0xB2, 0xF2, 0x48, 0x58, 0x1C, 0xC5, 0xE3,
0x1B, 0x35, 0x45, 0x43, 0x97, 0xFC, 0xE5, 0x0E
};
static const unsigned char dhtest_2048_256_yA[] = {
0x2E, 0x93, 0x80, 0xC8, 0x32, 0x3A, 0xF9, 0x75, 0x45, 0xBC, 0x49, 0x41,
0xDE, 0xB0, 0xEC, 0x37, 0x42, 0xC6, 0x2F, 0xE0, 0xEC, 0xE8, 0x24, 0xA6,
0xAB, 0xDB, 0xE6, 0x6C, 0x59, 0xBE, 0xE0, 0x24, 0x29, 0x11, 0xBF, 0xB9,
0x67, 0x23, 0x5C, 0xEB, 0xA3, 0x5A, 0xE1, 0x3E, 0x4E, 0xC7, 0x52, 0xBE,
0x63, 0x0B, 0x92, 0xDC, 0x4B, 0xDE, 0x28, 0x47, 0xA9, 0xC6, 0x2C, 0xB8,
0x15, 0x27, 0x45, 0x42, 0x1F, 0xB7, 0xEB, 0x60, 0xA6, 0x3C, 0x0F, 0xE9,
0x15, 0x9F, 0xCC, 0xE7, 0x26, 0xCE, 0x7C, 0xD8, 0x52, 0x3D, 0x74, 0x50,
0x66, 0x7E, 0xF8, 0x40, 0xE4, 0x91, 0x91, 0x21, 0xEB, 0x5F, 0x01, 0xC8,
0xC9, 0xB0, 0xD3, 0xD6, 0x48, 0xA9, 0x3B, 0xFB, 0x75, 0x68, 0x9E, 0x82,
0x44, 0xAC, 0x13, 0x4A, 0xF5, 0x44, 0x71, 0x1C, 0xE7, 0x9A, 0x02, 0xDC,
0xC3, 0x42, 0x26, 0x68, 0x47, 0x80, 0xDD, 0xDC, 0xB4, 0x98, 0x59, 0x41,
0x06, 0xC3, 0x7F, 0x5B, 0xC7, 0x98, 0x56, 0x48, 0x7A, 0xF5, 0xAB, 0x02,
0x2A, 0x2E, 0x5E, 0x42, 0xF0, 0x98, 0x97, 0xC1, 0xA8, 0x5A, 0x11, 0xEA,
0x02, 0x12, 0xAF, 0x04, 0xD9, 0xB4, 0xCE, 0xBC, 0x93, 0x7C, 0x3C, 0x1A,
0x3E, 0x15, 0xA8, 0xA0, 0x34, 0x2E, 0x33, 0x76, 0x15, 0xC8, 0x4E, 0x7F,
0xE3, 0xB8, 0xB9, 0xB8, 0x7F, 0xB1, 0xE7, 0x3A, 0x15, 0xAF, 0x12, 0xA3,
0x0D, 0x74, 0x6E, 0x06, 0xDF, 0xC3, 0x4F, 0x29, 0x0D, 0x79, 0x7C, 0xE5,
0x1A, 0xA1, 0x3A, 0xA7, 0x85, 0xBF, 0x66, 0x58, 0xAF, 0xF5, 0xE4, 0xB0,
0x93, 0x00, 0x3C, 0xBE, 0xAF, 0x66, 0x5B, 0x3C, 0x2E, 0x11, 0x3A, 0x3A,
0x4E, 0x90, 0x52, 0x69, 0x34, 0x1D, 0xC0, 0x71, 0x14, 0x26, 0x68, 0x5F,
0x4E, 0xF3, 0x7E, 0x86, 0x8A, 0x81, 0x26, 0xFF, 0x3F, 0x22, 0x79, 0xB5,
0x7C, 0xA6, 0x7E, 0x29
};
static const unsigned char dhtest_2048_256_xB[] = {
0x7D, 0x62, 0xA7, 0xE3, 0xEF, 0x36, 0xDE, 0x61, 0x7B, 0x13, 0xD1, 0xAF,
0xB8, 0x2C, 0x78, 0x0D, 0x83, 0xA2, 0x3B, 0xD4, 0xEE, 0x67, 0x05, 0x64,
0x51, 0x21, 0xF3, 0x71, 0xF5, 0x46, 0xA5, 0x3D
};
static const unsigned char dhtest_2048_256_yB[] = {
0x57, 0x5F, 0x03, 0x51, 0xBD, 0x2B, 0x1B, 0x81, 0x74, 0x48, 0xBD, 0xF8,
0x7A, 0x6C, 0x36, 0x2C, 0x1E, 0x28, 0x9D, 0x39, 0x03, 0xA3, 0x0B, 0x98,
0x32, 0xC5, 0x74, 0x1F, 0xA2, 0x50, 0x36, 0x3E, 0x7A, 0xCB, 0xC7, 0xF7,
0x7F, 0x3D, 0xAC, 0xBC, 0x1F, 0x13, 0x1A, 0xDD, 0x8E, 0x03, 0x36, 0x7E,
0xFF, 0x8F, 0xBB, 0xB3, 0xE1, 0xC5, 0x78, 0x44, 0x24, 0x80, 0x9B, 0x25,
0xAF, 0xE4, 0xD2, 0x26, 0x2A, 0x1A, 0x6F, 0xD2, 0xFA, 0xB6, 0x41, 0x05,
0xCA, 0x30, 0xA6, 0x74, 0xE0, 0x7F, 0x78, 0x09, 0x85, 0x20, 0x88, 0x63,
0x2F, 0xC0, 0x49, 0x23, 0x37, 0x91, 0xAD, 0x4E, 0xDD, 0x08, 0x3A, 0x97,
0x8B, 0x88, 0x3E, 0xE6, 0x18, 0xBC, 0x5E, 0x0D, 0xD0, 0x47, 0x41, 0x5F,
0x2D, 0x95, 0xE6, 0x83, 0xCF, 0x14, 0x82, 0x6B, 0x5F, 0xBE, 0x10, 0xD3,
0xCE, 0x41, 0xC6, 0xC1, 0x20, 0xC7, 0x8A, 0xB2, 0x00, 0x08, 0xC6, 0x98,
0xBF, 0x7F, 0x0B, 0xCA, 0xB9, 0xD7, 0xF4, 0x07, 0xBE, 0xD0, 0xF4, 0x3A,
0xFB, 0x29, 0x70, 0xF5, 0x7F, 0x8D, 0x12, 0x04, 0x39, 0x63, 0xE6, 0x6D,
0xDD, 0x32, 0x0D, 0x59, 0x9A, 0xD9, 0x93, 0x6C, 0x8F, 0x44, 0x13, 0x7C,
0x08, 0xB1, 0x80, 0xEC, 0x5E, 0x98, 0x5C, 0xEB, 0xE1, 0x86, 0xF3, 0xD5,
0x49, 0x67, 0x7E, 0x80, 0x60, 0x73, 0x31, 0xEE, 0x17, 0xAF, 0x33, 0x80,
0xA7, 0x25, 0xB0, 0x78, 0x23, 0x17, 0xD7, 0xDD, 0x43, 0xF5, 0x9D, 0x7A,
0xF9, 0x56, 0x8A, 0x9B, 0xB6, 0x3A, 0x84, 0xD3, 0x65, 0xF9, 0x22, 0x44,
0xED, 0x12, 0x09, 0x88, 0x21, 0x93, 0x02, 0xF4, 0x29, 0x24, 0xC7, 0xCA,
0x90, 0xB8, 0x9D, 0x24, 0xF7, 0x1B, 0x0A, 0xB6, 0x97, 0x82, 0x3D, 0x7D,
0xEB, 0x1A, 0xFF, 0x5B, 0x0E, 0x8E, 0x4A, 0x45, 0xD4, 0x9F, 0x7F, 0x53,
0x75, 0x7E, 0x19, 0x13
};
static const unsigned char dhtest_2048_256_Z[] = {
0x86, 0xC7, 0x0B, 0xF8, 0xD0, 0xBB, 0x81, 0xBB, 0x01, 0x07, 0x8A, 0x17,
0x21, 0x9C, 0xB7, 0xD2, 0x72, 0x03, 0xDB, 0x2A, 0x19, 0xC8, 0x77, 0xF1,
0xD1, 0xF1, 0x9F, 0xD7, 0xD7, 0x7E, 0xF2, 0x25, 0x46, 0xA6, 0x8F, 0x00,
0x5A, 0xD5, 0x2D, 0xC8, 0x45, 0x53, 0xB7, 0x8F, 0xC6, 0x03, 0x30, 0xBE,
0x51, 0xEA, 0x7C, 0x06, 0x72, 0xCA, 0xC1, 0x51, 0x5E, 0x4B, 0x35, 0xC0,
0x47, 0xB9, 0xA5, 0x51, 0xB8, 0x8F, 0x39, 0xDC, 0x26, 0xDA, 0x14, 0xA0,
0x9E, 0xF7, 0x47, 0x74, 0xD4, 0x7C, 0x76, 0x2D, 0xD1, 0x77, 0xF9, 0xED,
0x5B, 0xC2, 0xF1, 0x1E, 0x52, 0xC8, 0x79, 0xBD, 0x95, 0x09, 0x85, 0x04,
0xCD, 0x9E, 0xEC, 0xD8, 0xA8, 0xF9, 0xB3, 0xEF, 0xBD, 0x1F, 0x00, 0x8A,
0xC5, 0x85, 0x30, 0x97, 0xD9, 0xD1, 0x83, 0x7F, 0x2B, 0x18, 0xF7, 0x7C,
0xD7, 0xBE, 0x01, 0xAF, 0x80, 0xA7, 0xC7, 0xB5, 0xEA, 0x3C, 0xA5, 0x4C,
0xC0, 0x2D, 0x0C, 0x11, 0x6F, 0xEE, 0x3F, 0x95, 0xBB, 0x87, 0x39, 0x93,
0x85, 0x87, 0x5D, 0x7E, 0x86, 0x74, 0x7E, 0x67, 0x6E, 0x72, 0x89, 0x38,
0xAC, 0xBF, 0xF7, 0x09, 0x8E, 0x05, 0xBE, 0x4D, 0xCF, 0xB2, 0x40, 0x52,
0xB8, 0x3A, 0xEF, 0xFB, 0x14, 0x78, 0x3F, 0x02, 0x9A, 0xDB, 0xDE, 0x7F,
0x53, 0xFA, 0xE9, 0x20, 0x84, 0x22, 0x40, 0x90, 0xE0, 0x07, 0xCE, 0xE9,
0x4D, 0x4B, 0xF2, 0xBA, 0xCE, 0x9F, 0xFD, 0x4B, 0x57, 0xD2, 0xAF, 0x7C,
0x72, 0x4D, 0x0C, 0xAA, 0x19, 0xBF, 0x05, 0x01, 0xF6, 0xF1, 0x7B, 0x4A,
0xA1, 0x0F, 0x42, 0x5E, 0x3E, 0xA7, 0x60, 0x80, 0xB4, 0xB9, 0xD6, 0xB3,
0xCE, 0xFE, 0xA1, 0x15, 0xB2, 0xCE, 0xB8, 0x78, 0x9B, 0xB8, 0xA3, 0xB0,
0xEA, 0x87, 0xFE, 0xBE, 0x63, 0xB6, 0xC8, 0xF8, 0x46, 0xEC, 0x6D, 0xB0,
0xC2, 0x6C, 0x5D, 0x7C
};
typedef struct {
DH *(*get_param) (void);
const unsigned char *xA;
size_t xA_len;
const unsigned char *yA;
size_t yA_len;
const unsigned char *xB;
size_t xB_len;
const unsigned char *yB;
size_t yB_len;
const unsigned char *Z;
size_t Z_len;
} rfc5114_td;
# define make_rfc5114_td(pre) { \
DH_get_##pre, \
dhtest_##pre##_xA, sizeof(dhtest_##pre##_xA), \
dhtest_##pre##_yA, sizeof(dhtest_##pre##_yA), \
dhtest_##pre##_xB, sizeof(dhtest_##pre##_xB), \
dhtest_##pre##_yB, sizeof(dhtest_##pre##_yB), \
dhtest_##pre##_Z, sizeof(dhtest_##pre##_Z) \
}
static const rfc5114_td rfctd[] = {
make_rfc5114_td(1024_160),
make_rfc5114_td(2048_224),
make_rfc5114_td(2048_256)
};
static int rfc5114_test(void)
{
int i;
DH *dhA = NULL;
DH *dhB = NULL;
unsigned char *Z1 = NULL;
unsigned char *Z2 = NULL;
int szA, szB;
const rfc5114_td *td = NULL;
BIGNUM *priv_key = NULL, *pub_key = NULL;
const BIGNUM *pub_key_tmp;
for (i = 0; i < (int)OSSL_NELEM(rfctd); i++) {
td = rfctd + i;
/* Set up DH structures setting key components */
if (!TEST_ptr(dhA = td->get_param())
|| !TEST_ptr(dhB = td->get_param()))
goto bad_err;
if (!TEST_ptr(priv_key = BN_bin2bn(td->xA, td->xA_len, NULL))
|| !TEST_ptr(pub_key = BN_bin2bn(td->yA, td->yA_len, NULL))
|| !TEST_true(DH_set0_key(dhA, pub_key, priv_key)))
goto bad_err;
if (!TEST_ptr(priv_key = BN_bin2bn(td->xB, td->xB_len, NULL))
|| !TEST_ptr(pub_key = BN_bin2bn(td->yB, td->yB_len, NULL))
|| !TEST_true(DH_set0_key(dhB, pub_key, priv_key)))
goto bad_err;
priv_key = pub_key = NULL;
if (!TEST_int_gt(szA = DH_size(dhA), 0)
|| !TEST_int_gt(szB = DH_size(dhB), 0)
|| !TEST_size_t_eq(td->Z_len, (size_t)szA)
|| !TEST_size_t_eq(td->Z_len, (size_t)szB))
goto err;
if (!TEST_ptr(Z1 = OPENSSL_malloc((size_t)szA))
|| !TEST_ptr(Z2 = OPENSSL_malloc((size_t)szB)))
goto bad_err;
/*
* Work out shared secrets using both sides and compare with expected
* values.
*/
DH_get0_key(dhB, &pub_key_tmp, NULL);
if (!TEST_int_ne(DH_compute_key(Z1, pub_key_tmp, dhA), -1))
goto bad_err;
DH_get0_key(dhA, &pub_key_tmp, NULL);
if (!TEST_int_ne(DH_compute_key(Z2, pub_key_tmp, dhB), -1))
goto bad_err;
if (!TEST_mem_eq(Z1, td->Z_len, td->Z, td->Z_len)
|| !TEST_mem_eq(Z2, td->Z_len, td->Z, td->Z_len))
goto err;
DH_free(dhA);
dhA = NULL;
DH_free(dhB);
dhB = NULL;
OPENSSL_free(Z1);
Z1 = NULL;
OPENSSL_free(Z2);
Z2 = NULL;
}
return 1;
bad_err:
DH_free(dhA);
DH_free(dhB);
BN_free(pub_key);
BN_free(priv_key);
OPENSSL_free(Z1);
OPENSSL_free(Z2);
TEST_error("Initialisation error RFC5114 set %d\n", i + 1);
return 0;
err:
DH_free(dhA);
DH_free(dhB);
OPENSSL_free(Z1);
OPENSSL_free(Z2);
TEST_error("Test failed RFC5114 set %d\n", i + 1);
return 0;
}
static int rfc7919_test(void)
{
DH *a = NULL, *b = NULL;
const BIGNUM *apub_key = NULL, *bpub_key = NULL;
unsigned char *abuf = NULL;
unsigned char *bbuf = NULL;
int i, alen, blen, aout, bout;
int ret = 0;
if (!TEST_ptr(a = DH_new_by_nid(NID_ffdhe2048)))
goto err;
if (!DH_check(a, &i))
goto err;
if (!TEST_false(i & DH_CHECK_P_NOT_PRIME)
|| !TEST_false(i & DH_CHECK_P_NOT_SAFE_PRIME)
|| !TEST_false(i & DH_UNABLE_TO_CHECK_GENERATOR)
|| !TEST_false(i & DH_NOT_SUITABLE_GENERATOR)
|| !TEST_false(i))
goto err;
if (!DH_generate_key(a))
goto err;
DH_get0_key(a, &apub_key, NULL);
/* now create another copy of the DH group for the peer */
if (!TEST_ptr(b = DH_new_by_nid(NID_ffdhe2048)))
goto err;
if (!DH_generate_key(b))
goto err;
DH_get0_key(b, &bpub_key, NULL);
alen = DH_size(a);
if (!TEST_int_gt(alen, 0) || !TEST_ptr(abuf = OPENSSL_malloc(alen))
|| !TEST_true((aout = DH_compute_key(abuf, bpub_key, a)) != -1))
goto err;
blen = DH_size(b);
if (!TEST_int_gt(blen, 0) || !TEST_ptr(bbuf = OPENSSL_malloc(blen))
|| !TEST_true((bout = DH_compute_key(bbuf, apub_key, b)) != -1))
goto err;
if (!TEST_true(aout >= 20)
|| !TEST_mem_eq(abuf, aout, bbuf, bout))
goto err;
ret = 1;
err:
OPENSSL_free(abuf);
OPENSSL_free(bbuf);
DH_free(a);
DH_free(b);
return ret;
}
static int prime_groups[] = {
NID_ffdhe2048,
NID_ffdhe3072,
NID_ffdhe4096,
NID_ffdhe6144,
NID_ffdhe8192,
NID_modp_2048,
NID_modp_3072,
NID_modp_4096,
NID_modp_6144,
};
static int dh_test_prime_groups(int index)
{
int ok = 0;
DH *dh = NULL;
const BIGNUM *p, *q, *g;
if (!TEST_ptr(dh = DH_new_by_nid(prime_groups[index])))
goto err;
DH_get0_pqg(dh, &p, &q, &g);
if (!TEST_ptr(p) || !TEST_ptr(q) || !TEST_ptr(g))
goto err;
if (!TEST_int_eq(DH_get_nid(dh), prime_groups[index]))
goto err;
/* Since q is set there is no need for the private length to be set */
if (!TEST_int_eq((int)DH_get_length(dh), 0))
goto err;
ok = 1;
err:
DH_free(dh);
return ok;
}
static int dh_rfc5114_fix_nid_test(void)
{
int ok = 0;
EVP_PKEY_CTX *paramgen_ctx;
/* Run the test. Success is any time the test does not cause a SIGSEGV interrupt */
paramgen_ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_DHX, 0);
if (!TEST_ptr(paramgen_ctx))
goto err;
if (!TEST_int_eq(EVP_PKEY_paramgen_init(paramgen_ctx), 1))
goto err;
/* Tested function is called here */
if (!TEST_int_eq(EVP_PKEY_CTX_set_dhx_rfc5114(paramgen_ctx, 3), 1))
goto err;
/* Negative test */
if (!TEST_int_eq(EVP_PKEY_CTX_set_dhx_rfc5114(paramgen_ctx, 99), 0))
goto err;
/* If we're still running then the test passed. */
ok = 1;
err:
EVP_PKEY_CTX_free(paramgen_ctx);
return ok;
}
static int dh_set_dh_nid_test(void)
{
int ok = 0;
EVP_PKEY_CTX *paramgen_ctx;
/* Run the test. Success is any time the test does not cause a SIGSEGV interrupt */
paramgen_ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_DH, 0);
if (!TEST_ptr(paramgen_ctx))
goto err;
if (!TEST_int_eq(EVP_PKEY_paramgen_init(paramgen_ctx), 1))
goto err;
/* Tested function is called here */
if (!TEST_int_eq(EVP_PKEY_CTX_set_dh_nid(paramgen_ctx, NID_ffdhe2048), 1))
goto err;
/* Negative test */
if (!TEST_int_eq(EVP_PKEY_CTX_set_dh_nid(paramgen_ctx, NID_secp521r1), 0))
goto err;
/* If we're still running then the test passed. */
ok = 1;
err:
EVP_PKEY_CTX_free(paramgen_ctx);
return ok;
}
static int dh_get_nid(void)
{
int ok = 0;
const BIGNUM *p, *q, *g;
BIGNUM *pcpy = NULL, *gcpy = NULL, *qcpy = NULL;
DH *dh1 = DH_new_by_nid(NID_ffdhe2048);
DH *dh2 = DH_new();
if (!TEST_ptr(dh1)
|| !TEST_ptr(dh2))
goto err;
/* Set new DH parameters manually using a existing named group's p & g */
DH_get0_pqg(dh1, &p, &q, &g);
if (!TEST_ptr(p)
|| !TEST_ptr(q)
|| !TEST_ptr(g)
|| !TEST_ptr(pcpy = BN_dup(p))
|| !TEST_ptr(gcpy = BN_dup(g)))
goto err;
if (!TEST_true(DH_set0_pqg(dh2, pcpy, NULL, gcpy)))
goto err;
pcpy = gcpy = NULL;
/* Test q is set if p and g are provided */
if (!TEST_ptr(DH_get0_q(dh2)))
goto err;
/* Test that setting p & g manually returns that it is a named group */
if (!TEST_int_eq(DH_get_nid(dh2), NID_ffdhe2048))
goto err;
/* Test that after changing g it is no longer a named group */
if (!TEST_ptr(gcpy = BN_dup(BN_value_one())))
goto err;
if (!TEST_true(DH_set0_pqg(dh2, NULL, NULL, gcpy)))
goto err;
gcpy = NULL;
if (!TEST_int_eq(DH_get_nid(dh2), NID_undef))
goto err;
/* Test that setting an incorrect q results in this not being a named group */
if (!TEST_ptr(pcpy = BN_dup(p))
|| !TEST_ptr(qcpy = BN_dup(q))
|| !TEST_ptr(gcpy = BN_dup(g))
|| !TEST_int_eq(BN_add_word(qcpy, 2), 1)
|| !TEST_true(DH_set0_pqg(dh2, pcpy, qcpy, gcpy)))
goto err;
pcpy = qcpy = gcpy = NULL;
if (!TEST_int_eq(DH_get_nid(dh2), NID_undef))
goto err;
ok = 1;
err:
BN_free(pcpy);
BN_free(qcpy);
BN_free(gcpy);
DH_free(dh2);
DH_free(dh1);
return ok;
}
static const unsigned char dh_pub_der[] = {
0x30, 0x82, 0x02, 0x28, 0x30, 0x82, 0x01, 0x1b, 0x06, 0x09, 0x2a, 0x86,
0x48, 0x86, 0xf7, 0x0d, 0x01, 0x03, 0x01, 0x30, 0x82, 0x01, 0x0c, 0x02,
0x82, 0x01, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xc9, 0x0f, 0xda, 0xa2, 0x21, 0x68, 0xc2, 0x34, 0xc4, 0xc6, 0x62, 0x8b,
0x80, 0xdc, 0x1c, 0xd1, 0x29, 0x02, 0x4e, 0x08, 0x8a, 0x67, 0xcc, 0x74,
0x02, 0x0b, 0xbe, 0xa6, 0x3b, 0x13, 0x9b, 0x22, 0x51, 0x4a, 0x08, 0x79,
0x8e, 0x34, 0x04, 0xdd, 0xef, 0x95, 0x19, 0xb3, 0xcd, 0x3a, 0x43, 0x1b,
0x30, 0x2b, 0x0a, 0x6d, 0xf2, 0x5f, 0x14, 0x37, 0x4f, 0xe1, 0x35, 0x6d,
0x6d, 0x51, 0xc2, 0x45, 0xe4, 0x85, 0xb5, 0x76, 0x62, 0x5e, 0x7e, 0xc6,
0xf4, 0x4c, 0x42, 0xe9, 0xa6, 0x37, 0xed, 0x6b, 0x0b, 0xff, 0x5c, 0xb6,
0xf4, 0x06, 0xb7, 0xed, 0xee, 0x38, 0x6b, 0xfb, 0x5a, 0x89, 0x9f, 0xa5,
0xae, 0x9f, 0x24, 0x11, 0x7c, 0x4b, 0x1f, 0xe6, 0x49, 0x28, 0x66, 0x51,
0xec, 0xe4, 0x5b, 0x3d, 0xc2, 0x00, 0x7c, 0xb8, 0xa1, 0x63, 0xbf, 0x05,
0x98, 0xda, 0x48, 0x36, 0x1c, 0x55, 0xd3, 0x9a, 0x69, 0x16, 0x3f, 0xa8,
0xfd, 0x24, 0xcf, 0x5f, 0x83, 0x65, 0x5d, 0x23, 0xdc, 0xa3, 0xad, 0x96,
0x1c, 0x62, 0xf3, 0x56, 0x20, 0x85, 0x52, 0xbb, 0x9e, 0xd5, 0x29, 0x07,
0x70, 0x96, 0x96, 0x6d, 0x67, 0x0c, 0x35, 0x4e, 0x4a, 0xbc, 0x98, 0x04,
0xf1, 0x74, 0x6c, 0x08, 0xca, 0x18, 0x21, 0x7c, 0x32, 0x90, 0x5e, 0x46,
0x2e, 0x36, 0xce, 0x3b, 0xe3, 0x9e, 0x77, 0x2c, 0x18, 0x0e, 0x86, 0x03,
0x9b, 0x27, 0x83, 0xa2, 0xec, 0x07, 0xa2, 0x8f, 0xb5, 0xc5, 0x5d, 0xf0,
0x6f, 0x4c, 0x52, 0xc9, 0xde, 0x2b, 0xcb, 0xf6, 0x95, 0x58, 0x17, 0x18,
0x39, 0x95, 0x49, 0x7c, 0xea, 0x95, 0x6a, 0xe5, 0x15, 0xd2, 0x26, 0x18,
0x98, 0xfa, 0x05, 0x10, 0x15, 0x72, 0x8e, 0x5a, 0x8a, 0xac, 0xaa, 0x68,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x01, 0x02, 0x02,
0x02, 0x04, 0x00, 0x03, 0x82, 0x01, 0x05, 0x00, 0x02, 0x82, 0x01, 0x00,
0x08, 0x87, 0x8a, 0x5f, 0x4f, 0x3b, 0xef, 0xe1, 0x77, 0x13, 0x3b, 0xd7,
0x58, 0x76, 0xc9, 0xeb, 0x7e, 0x2d, 0xcc, 0x7e, 0xed, 0xc5, 0xee, 0xf9,
0x2d, 0x55, 0xb0, 0xe2, 0x37, 0x8c, 0x51, 0x87, 0x6a, 0x8e, 0x0d, 0xb2,
0x08, 0xed, 0x4f, 0x88, 0x9b, 0x63, 0x19, 0x7a, 0x67, 0xa1, 0x61, 0xd8,
0x17, 0xa0, 0x2c, 0xdb, 0xc2, 0xfa, 0xb3, 0x4f, 0xe7, 0xcb, 0x16, 0xf2,
0xe7, 0xd0, 0x2c, 0xf8, 0xcc, 0x97, 0xd3, 0xe7, 0xae, 0xc2, 0x71, 0xd8,
0x2b, 0x12, 0x83, 0xe9, 0x5a, 0x45, 0xfe, 0x66, 0x5c, 0xa2, 0xb6, 0xce,
0x2f, 0x04, 0x05, 0xe7, 0xa7, 0xbc, 0xe5, 0x63, 0x1a, 0x93, 0x3d, 0x4d,
0xf4, 0x77, 0xdd, 0x2a, 0xc9, 0x51, 0x7b, 0xf5, 0x54, 0xa2, 0xab, 0x26,
0xee, 0x16, 0xd3, 0x83, 0x92, 0x85, 0x40, 0x67, 0xa3, 0xa9, 0x31, 0x16,
0x64, 0x45, 0x5a, 0x2a, 0x9d, 0xa8, 0x1a, 0x84, 0x2f, 0x59, 0x57, 0x6b,
0xbb, 0x51, 0x28, 0xbd, 0x91, 0x60, 0xd9, 0x8f, 0x54, 0x6a, 0xa0, 0x6b,
0xb2, 0xf6, 0x78, 0x79, 0xd2, 0x3a, 0x8f, 0xa6, 0x24, 0x7e, 0xe9, 0x6e,
0x66, 0x30, 0xed, 0xbf, 0x55, 0x71, 0x9c, 0x89, 0x81, 0xf0, 0xa7, 0xe7,
0x05, 0x87, 0x51, 0xc1, 0xff, 0xe5, 0xcf, 0x1f, 0x19, 0xe4, 0xeb, 0x7c,
0x1c, 0x1a, 0x58, 0xd5, 0x22, 0x3d, 0x31, 0x22, 0xc7, 0x8b, 0x60, 0xf5,
0xe8, 0x95, 0x73, 0xe0, 0x20, 0xe2, 0x4f, 0x03, 0x9e, 0x89, 0x34, 0x91,
0x5e, 0xda, 0x4f, 0x60, 0xff, 0xc9, 0x4f, 0x5a, 0x37, 0x1e, 0xb0, 0xed,
0x26, 0x4c, 0xa4, 0xc6, 0x26, 0xc9, 0xcc, 0xab, 0xd2, 0x1a, 0x3a, 0x82,
0x68, 0x03, 0x49, 0x8f, 0xb0, 0xb9, 0xc8, 0x48, 0x9d, 0xc7, 0xdf, 0x8b,
0x1c, 0xbf, 0xda, 0x89, 0x78, 0x6f, 0xd3, 0x62, 0xad, 0x35, 0xb9, 0xd3,
0x9b, 0xd0, 0x25, 0x65
};
/*
* Load PKCS3 DH Parameters that contain an optional private value length.
* Loading a named group should not overwrite the private value length field.
*/
static int dh_load_pkcs3_namedgroup_privlen_test(void)
{
int ret, privlen = 0;
EVP_PKEY *pkey = NULL;
const unsigned char *p = dh_pub_der;
ret = TEST_ptr(pkey = d2i_PUBKEY_ex(NULL, &p, sizeof(dh_pub_der),
NULL, NULL))
&& TEST_true(EVP_PKEY_get_int_param(pkey, OSSL_PKEY_PARAM_DH_PRIV_LEN,
&privlen))
&& TEST_int_eq(privlen, 1024);
EVP_PKEY_free(pkey);
return ret;
}
#endif
int setup_tests(void)
{
#ifdef OPENSSL_NO_DH
TEST_note("No DH support");
#else
ADD_TEST(dh_test);
ADD_TEST(dh_computekey_range_test);
ADD_TEST(rfc5114_test);
ADD_TEST(rfc7919_test);
ADD_ALL_TESTS(dh_test_prime_groups, OSSL_NELEM(prime_groups));
ADD_TEST(dh_get_nid);
ADD_TEST(dh_load_pkcs3_namedgroup_privlen_test);
ADD_TEST(dh_rfc5114_fix_nid_test);
ADD_TEST(dh_set_dh_nid_test);
#endif
return 1;
}
|
./openssl/test/time_test.c | /*
* Copyright 2023 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 "testutil.h"
#include "internal/time.h"
static int test_time_to_timeval(void)
{
OSSL_TIME a;
struct timeval tv;
a = ossl_time_zero();
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 0) || !TEST_long_eq(tv.tv_usec, 0))
return 0;
/* Test that zero round trips */
if (!TEST_true(ossl_time_is_zero(ossl_time_from_timeval(tv))))
return 0;
/* We should round up nano secs to the next usec */
a = ossl_ticks2time(1);
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 0) || !TEST_long_eq(tv.tv_usec, 1))
return 0;
a = ossl_ticks2time(999);
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 0) || !TEST_long_eq(tv.tv_usec, 1))
return 0;
a = ossl_ticks2time(1000);
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 0) || !TEST_long_eq(tv.tv_usec, 1))
return 0;
a = ossl_ticks2time(1001);
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 0) || !TEST_long_eq(tv.tv_usec, 2))
return 0;
a = ossl_ticks2time(999000);
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 0) || !TEST_long_eq(tv.tv_usec, 999))
return 0;
a = ossl_ticks2time(999999001);
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 1) || !TEST_long_eq(tv.tv_usec, 0))
return 0;
a = ossl_ticks2time(999999999);
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 1) || !TEST_long_eq(tv.tv_usec, 0))
return 0;
a = ossl_ticks2time(1000000000);
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 1) || !TEST_long_eq(tv.tv_usec, 0))
return 0;
a = ossl_ticks2time(1000000001);
tv = ossl_time_to_timeval(a);
if (!TEST_long_eq(tv.tv_sec, 1) || !TEST_long_eq(tv.tv_usec, 1))
return 0;
/*
* Note that we don't currently support infinity round tripping. Instead
* callers need to explicitly test for infinity.
*/
return 1;
}
int setup_tests(void)
{
ADD_TEST(test_time_to_timeval);
return 1;
}
|
./openssl/test/rand_status_test.c | /*
* Copyright 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
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <openssl/rand.h>
#include "testutil.h"
/*
* This needs to be in a test executable all by itself so that it can be
* guaranteed to run before any generate calls have been made.
*/
static int test_rand_status(void)
{
return TEST_true(RAND_status());
}
int setup_tests(void)
{
ADD_TEST(test_rand_status);
return 1;
}
|
./openssl/test/sslapitest.c | /*
* Copyright 2016-2023 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
*/
/*
* We need access to the deprecated low level HMAC APIs for legacy purposes
* when the deprecated calls are not hidden
*/
#ifndef OPENSSL_NO_DEPRECATED_3_0
# define OPENSSL_SUPPRESS_DEPRECATED
#endif
#include <stdio.h>
#include <string.h>
#include <openssl/opensslconf.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/ssl.h>
#include <openssl/ocsp.h>
#include <openssl/srp.h>
#include <openssl/txt_db.h>
#include <openssl/aes.h>
#include <openssl/rand.h>
#include <openssl/core_names.h>
#include <openssl/core_dispatch.h>
#include <openssl/provider.h>
#include <openssl/param_build.h>
#include <openssl/x509v3.h>
#include <openssl/dh.h>
#include <openssl/engine.h>
#include "helpers/ssltestlib.h"
#include "testutil.h"
#include "testutil/output.h"
#include "internal/nelem.h"
#include "internal/ktls.h"
#include "../ssl/ssl_local.h"
#include "../ssl/record/methods/recmethod_local.h"
#include "filterprov.h"
#undef OSSL_NO_USABLE_TLS1_3
#if defined(OPENSSL_NO_TLS1_3) \
|| (defined(OPENSSL_NO_EC) && defined(OPENSSL_NO_DH))
/*
* If we don't have ec or dh then there are no built-in groups that are usable
* with TLSv1.3
*/
# define OSSL_NO_USABLE_TLS1_3
#endif
/* Defined in tls-provider.c */
int tls_provider_init(const OSSL_CORE_HANDLE *handle,
const OSSL_DISPATCH *in,
const OSSL_DISPATCH **out,
void **provctx);
static OSSL_LIB_CTX *libctx = NULL;
static OSSL_PROVIDER *defctxnull = NULL;
#ifndef OSSL_NO_USABLE_TLS1_3
static SSL_SESSION *clientpsk = NULL;
static SSL_SESSION *serverpsk = NULL;
static const char *pskid = "Identity";
static const char *srvid;
static int use_session_cb(SSL *ssl, const EVP_MD *md, const unsigned char **id,
size_t *idlen, SSL_SESSION **sess);
static int find_session_cb(SSL *ssl, const unsigned char *identity,
size_t identity_len, SSL_SESSION **sess);
static int use_session_cb_cnt = 0;
static int find_session_cb_cnt = 0;
#endif
static char *certsdir = NULL;
static char *cert = NULL;
static char *privkey = NULL;
static char *cert2 = NULL;
static char *privkey2 = NULL;
static char *cert1024 = NULL;
static char *privkey1024 = NULL;
static char *cert3072 = NULL;
static char *privkey3072 = NULL;
static char *cert4096 = NULL;
static char *privkey4096 = NULL;
static char *cert8192 = NULL;
static char *privkey8192 = NULL;
static char *srpvfile = NULL;
static char *tmpfilename = NULL;
static char *dhfile = NULL;
static int is_fips = 0;
static int fips_ems_check = 0;
#define LOG_BUFFER_SIZE 2048
static char server_log_buffer[LOG_BUFFER_SIZE + 1] = {0};
static size_t server_log_buffer_index = 0;
static char client_log_buffer[LOG_BUFFER_SIZE + 1] = {0};
static size_t client_log_buffer_index = 0;
static int error_writing_log = 0;
#ifndef OPENSSL_NO_OCSP
static const unsigned char orespder[] = "Dummy OCSP Response";
static int ocsp_server_called = 0;
static int ocsp_client_called = 0;
static int cdummyarg = 1;
static X509 *ocspcert = NULL;
#endif
#define CLIENT_VERSION_LEN 2
/*
* This structure is used to validate that the correct number of log messages
* of various types are emitted when emitting secret logs.
*/
struct sslapitest_log_counts {
unsigned int rsa_key_exchange_count;
unsigned int master_secret_count;
unsigned int client_early_secret_count;
unsigned int client_handshake_secret_count;
unsigned int server_handshake_secret_count;
unsigned int client_application_secret_count;
unsigned int server_application_secret_count;
unsigned int early_exporter_secret_count;
unsigned int exporter_secret_count;
};
static int hostname_cb(SSL *s, int *al, void *arg)
{
const char *hostname = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
if (hostname != NULL && (strcmp(hostname, "goodhost") == 0
|| strcmp(hostname, "altgoodhost") == 0))
return SSL_TLSEXT_ERR_OK;
return SSL_TLSEXT_ERR_NOACK;
}
static void client_keylog_callback(const SSL *ssl, const char *line)
{
int line_length = strlen(line);
/* If the log doesn't fit, error out. */
if (client_log_buffer_index + line_length > sizeof(client_log_buffer) - 1) {
TEST_info("Client log too full");
error_writing_log = 1;
return;
}
strcat(client_log_buffer, line);
client_log_buffer_index += line_length;
client_log_buffer[client_log_buffer_index++] = '\n';
}
static void server_keylog_callback(const SSL *ssl, const char *line)
{
int line_length = strlen(line);
/* If the log doesn't fit, error out. */
if (server_log_buffer_index + line_length > sizeof(server_log_buffer) - 1) {
TEST_info("Server log too full");
error_writing_log = 1;
return;
}
strcat(server_log_buffer, line);
server_log_buffer_index += line_length;
server_log_buffer[server_log_buffer_index++] = '\n';
}
static int compare_hex_encoded_buffer(const char *hex_encoded,
size_t hex_length,
const uint8_t *raw,
size_t raw_length)
{
size_t i, j;
char hexed[3];
if (!TEST_size_t_eq(raw_length * 2, hex_length))
return 1;
for (i = j = 0; i < raw_length && j + 1 < hex_length; i++, j += 2) {
sprintf(hexed, "%02x", raw[i]);
if (!TEST_int_eq(hexed[0], hex_encoded[j])
|| !TEST_int_eq(hexed[1], hex_encoded[j + 1]))
return 1;
}
return 0;
}
static int test_keylog_output(char *buffer, const SSL *ssl,
const SSL_SESSION *session,
struct sslapitest_log_counts *expected)
{
char *token = NULL;
unsigned char actual_client_random[SSL3_RANDOM_SIZE] = {0};
size_t client_random_size = SSL3_RANDOM_SIZE;
unsigned char actual_master_key[SSL_MAX_MASTER_KEY_LENGTH] = {0};
size_t master_key_size = SSL_MAX_MASTER_KEY_LENGTH;
unsigned int rsa_key_exchange_count = 0;
unsigned int master_secret_count = 0;
unsigned int client_early_secret_count = 0;
unsigned int client_handshake_secret_count = 0;
unsigned int server_handshake_secret_count = 0;
unsigned int client_application_secret_count = 0;
unsigned int server_application_secret_count = 0;
unsigned int early_exporter_secret_count = 0;
unsigned int exporter_secret_count = 0;
for (token = strtok(buffer, " \n"); token != NULL;
token = strtok(NULL, " \n")) {
if (strcmp(token, "RSA") == 0) {
/*
* Premaster secret. Tokens should be: 16 ASCII bytes of
* hex-encoded encrypted secret, then the hex-encoded pre-master
* secret.
*/
if (!TEST_ptr(token = strtok(NULL, " \n")))
return 0;
if (!TEST_size_t_eq(strlen(token), 16))
return 0;
if (!TEST_ptr(token = strtok(NULL, " \n")))
return 0;
/*
* We can't sensibly check the log because the premaster secret is
* transient, and OpenSSL doesn't keep hold of it once the master
* secret is generated.
*/
rsa_key_exchange_count++;
} else if (strcmp(token, "CLIENT_RANDOM") == 0) {
/*
* Master secret. Tokens should be: 64 ASCII bytes of hex-encoded
* client random, then the hex-encoded master secret.
*/
client_random_size = SSL_get_client_random(ssl,
actual_client_random,
SSL3_RANDOM_SIZE);
if (!TEST_size_t_eq(client_random_size, SSL3_RANDOM_SIZE))
return 0;
if (!TEST_ptr(token = strtok(NULL, " \n")))
return 0;
if (!TEST_size_t_eq(strlen(token), 64))
return 0;
if (!TEST_false(compare_hex_encoded_buffer(token, 64,
actual_client_random,
client_random_size)))
return 0;
if (!TEST_ptr(token = strtok(NULL, " \n")))
return 0;
master_key_size = SSL_SESSION_get_master_key(session,
actual_master_key,
master_key_size);
if (!TEST_size_t_ne(master_key_size, 0))
return 0;
if (!TEST_false(compare_hex_encoded_buffer(token, strlen(token),
actual_master_key,
master_key_size)))
return 0;
master_secret_count++;
} else if (strcmp(token, "CLIENT_EARLY_TRAFFIC_SECRET") == 0
|| strcmp(token, "CLIENT_HANDSHAKE_TRAFFIC_SECRET") == 0
|| strcmp(token, "SERVER_HANDSHAKE_TRAFFIC_SECRET") == 0
|| strcmp(token, "CLIENT_TRAFFIC_SECRET_0") == 0
|| strcmp(token, "SERVER_TRAFFIC_SECRET_0") == 0
|| strcmp(token, "EARLY_EXPORTER_SECRET") == 0
|| strcmp(token, "EXPORTER_SECRET") == 0) {
/*
* TLSv1.3 secret. Tokens should be: 64 ASCII bytes of hex-encoded
* client random, and then the hex-encoded secret. In this case,
* we treat all of these secrets identically and then just
* distinguish between them when counting what we saw.
*/
if (strcmp(token, "CLIENT_EARLY_TRAFFIC_SECRET") == 0)
client_early_secret_count++;
else if (strcmp(token, "CLIENT_HANDSHAKE_TRAFFIC_SECRET") == 0)
client_handshake_secret_count++;
else if (strcmp(token, "SERVER_HANDSHAKE_TRAFFIC_SECRET") == 0)
server_handshake_secret_count++;
else if (strcmp(token, "CLIENT_TRAFFIC_SECRET_0") == 0)
client_application_secret_count++;
else if (strcmp(token, "SERVER_TRAFFIC_SECRET_0") == 0)
server_application_secret_count++;
else if (strcmp(token, "EARLY_EXPORTER_SECRET") == 0)
early_exporter_secret_count++;
else if (strcmp(token, "EXPORTER_SECRET") == 0)
exporter_secret_count++;
client_random_size = SSL_get_client_random(ssl,
actual_client_random,
SSL3_RANDOM_SIZE);
if (!TEST_size_t_eq(client_random_size, SSL3_RANDOM_SIZE))
return 0;
if (!TEST_ptr(token = strtok(NULL, " \n")))
return 0;
if (!TEST_size_t_eq(strlen(token), 64))
return 0;
if (!TEST_false(compare_hex_encoded_buffer(token, 64,
actual_client_random,
client_random_size)))
return 0;
if (!TEST_ptr(token = strtok(NULL, " \n")))
return 0;
} else {
TEST_info("Unexpected token %s\n", token);
return 0;
}
}
/* Got what we expected? */
if (!TEST_size_t_eq(rsa_key_exchange_count,
expected->rsa_key_exchange_count)
|| !TEST_size_t_eq(master_secret_count,
expected->master_secret_count)
|| !TEST_size_t_eq(client_early_secret_count,
expected->client_early_secret_count)
|| !TEST_size_t_eq(client_handshake_secret_count,
expected->client_handshake_secret_count)
|| !TEST_size_t_eq(server_handshake_secret_count,
expected->server_handshake_secret_count)
|| !TEST_size_t_eq(client_application_secret_count,
expected->client_application_secret_count)
|| !TEST_size_t_eq(server_application_secret_count,
expected->server_application_secret_count)
|| !TEST_size_t_eq(early_exporter_secret_count,
expected->early_exporter_secret_count)
|| !TEST_size_t_eq(exporter_secret_count,
expected->exporter_secret_count))
return 0;
return 1;
}
#if !defined(OPENSSL_NO_TLS1_2) || defined(OSSL_NO_USABLE_TLS1_3)
static int test_keylog(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
struct sslapitest_log_counts expected;
/* Clean up logging space */
memset(&expected, 0, sizeof(expected));
memset(client_log_buffer, 0, sizeof(client_log_buffer));
memset(server_log_buffer, 0, sizeof(server_log_buffer));
client_log_buffer_index = 0;
server_log_buffer_index = 0;
error_writing_log = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
return 0;
/* We cannot log the master secret for TLSv1.3, so we should forbid it. */
SSL_CTX_set_options(cctx, SSL_OP_NO_TLSv1_3);
SSL_CTX_set_options(sctx, SSL_OP_NO_TLSv1_3);
/* We also want to ensure that we use RSA-based key exchange. */
if (!TEST_true(SSL_CTX_set_cipher_list(cctx, "RSA")))
goto end;
if (!TEST_true(SSL_CTX_get_keylog_callback(cctx) == NULL)
|| !TEST_true(SSL_CTX_get_keylog_callback(sctx) == NULL))
goto end;
SSL_CTX_set_keylog_callback(cctx, client_keylog_callback);
if (!TEST_true(SSL_CTX_get_keylog_callback(cctx)
== client_keylog_callback))
goto end;
SSL_CTX_set_keylog_callback(sctx, server_keylog_callback);
if (!TEST_true(SSL_CTX_get_keylog_callback(sctx)
== server_keylog_callback))
goto end;
/* Now do a handshake and check that the logs have been written to. */
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_false(error_writing_log)
|| !TEST_int_gt(client_log_buffer_index, 0)
|| !TEST_int_gt(server_log_buffer_index, 0))
goto end;
/*
* Now we want to test that our output data was vaguely sensible. We
* do that by using strtok and confirming that we have more or less the
* data we expect. For both client and server, we expect to see one master
* secret. The client should also see an RSA key exchange.
*/
expected.rsa_key_exchange_count = 1;
expected.master_secret_count = 1;
if (!TEST_true(test_keylog_output(client_log_buffer, clientssl,
SSL_get_session(clientssl), &expected)))
goto end;
expected.rsa_key_exchange_count = 0;
if (!TEST_true(test_keylog_output(server_log_buffer, serverssl,
SSL_get_session(serverssl), &expected)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif
#ifndef OSSL_NO_USABLE_TLS1_3
static int test_keylog_no_master_key(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
SSL_SESSION *sess = NULL;
int testresult = 0;
struct sslapitest_log_counts expected;
unsigned char buf[1];
size_t readbytes, written;
/* Clean up logging space */
memset(&expected, 0, sizeof(expected));
memset(client_log_buffer, 0, sizeof(client_log_buffer));
memset(server_log_buffer, 0, sizeof(server_log_buffer));
client_log_buffer_index = 0;
server_log_buffer_index = 0;
error_writing_log = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey))
|| !TEST_true(SSL_CTX_set_max_early_data(sctx,
SSL3_RT_MAX_PLAIN_LENGTH)))
return 0;
if (!TEST_true(SSL_CTX_get_keylog_callback(cctx) == NULL)
|| !TEST_true(SSL_CTX_get_keylog_callback(sctx) == NULL))
goto end;
SSL_CTX_set_keylog_callback(cctx, client_keylog_callback);
if (!TEST_true(SSL_CTX_get_keylog_callback(cctx)
== client_keylog_callback))
goto end;
SSL_CTX_set_keylog_callback(sctx, server_keylog_callback);
if (!TEST_true(SSL_CTX_get_keylog_callback(sctx)
== server_keylog_callback))
goto end;
/* Now do a handshake and check that the logs have been written to. */
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_false(error_writing_log))
goto end;
/*
* Now we want to test that our output data was vaguely sensible. For this
* test, we expect no CLIENT_RANDOM entry because it doesn't make sense for
* TLSv1.3, but we do expect both client and server to emit keys.
*/
expected.client_handshake_secret_count = 1;
expected.server_handshake_secret_count = 1;
expected.client_application_secret_count = 1;
expected.server_application_secret_count = 1;
expected.exporter_secret_count = 1;
if (!TEST_true(test_keylog_output(client_log_buffer, clientssl,
SSL_get_session(clientssl), &expected))
|| !TEST_true(test_keylog_output(server_log_buffer, serverssl,
SSL_get_session(serverssl),
&expected)))
goto end;
/* Terminate old session and resume with early data. */
sess = SSL_get1_session(clientssl);
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
/* Reset key log */
memset(client_log_buffer, 0, sizeof(client_log_buffer));
memset(server_log_buffer, 0, sizeof(server_log_buffer));
client_log_buffer_index = 0;
server_log_buffer_index = 0;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, sess))
/* Here writing 0 length early data is enough. */
|| !TEST_true(SSL_write_early_data(clientssl, NULL, 0, &written))
|| !TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_ERROR)
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_ACCEPTED)
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl)))
goto end;
/* In addition to the previous entries, expect early secrets. */
expected.client_early_secret_count = 1;
expected.early_exporter_secret_count = 1;
if (!TEST_true(test_keylog_output(client_log_buffer, clientssl,
SSL_get_session(clientssl), &expected))
|| !TEST_true(test_keylog_output(server_log_buffer, serverssl,
SSL_get_session(serverssl),
&expected)))
goto end;
testresult = 1;
end:
SSL_SESSION_free(sess);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif
static int verify_retry_cb(X509_STORE_CTX *ctx, void *arg)
{
int res = X509_verify_cert(ctx);
int idx = SSL_get_ex_data_X509_STORE_CTX_idx();
SSL *ssl;
/* this should not happen but check anyway */
if (idx < 0
|| (ssl = X509_STORE_CTX_get_ex_data(ctx, idx)) == NULL)
return 0;
if (res == 0 && X509_STORE_CTX_get_error(ctx) ==
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY)
/* indicate SSL_ERROR_WANT_RETRY_VERIFY */
return SSL_set_retry_verify(ssl);
return res;
}
static int test_client_cert_verify_cb(void)
{
/* server key, cert, chain, and root */
char *skey = test_mk_file_path(certsdir, "leaf.key");
char *leaf = test_mk_file_path(certsdir, "leaf.pem");
char *int2 = test_mk_file_path(certsdir, "subinterCA.pem");
char *int1 = test_mk_file_path(certsdir, "interCA.pem");
char *root = test_mk_file_path(certsdir, "rootCA.pem");
X509 *crt1 = NULL, *crt2 = NULL;
STACK_OF(X509) *server_chain;
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, NULL, NULL)))
goto end;
if (!TEST_int_eq(SSL_CTX_use_certificate_chain_file(sctx, leaf), 1)
|| !TEST_int_eq(SSL_CTX_use_PrivateKey_file(sctx, skey,
SSL_FILETYPE_PEM), 1)
|| !TEST_int_eq(SSL_CTX_check_private_key(sctx), 1))
goto end;
if (!TEST_true(SSL_CTX_load_verify_locations(cctx, root, NULL)))
goto end;
SSL_CTX_set_verify(cctx, SSL_VERIFY_PEER, NULL);
SSL_CTX_set_cert_verify_callback(cctx, verify_retry_cb, NULL);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
/* attempt SSL_connect() with incomplete server chain */
if (!TEST_false(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_WANT_RETRY_VERIFY)))
goto end;
/* application provides intermediate certs needed to verify server cert */
if (!TEST_ptr((crt1 = load_cert_pem(int1, libctx)))
|| !TEST_ptr((crt2 = load_cert_pem(int2, libctx)))
|| !TEST_ptr((server_chain = SSL_get_peer_cert_chain(clientssl))))
goto end;
/* add certs in reverse order to demonstrate real chain building */
if (!TEST_true(sk_X509_push(server_chain, crt1)))
goto end;
crt1 = NULL;
if (!TEST_true(sk_X509_push(server_chain, crt2)))
goto end;
crt2 = NULL;
/* continue SSL_connect(), must now succeed with completed server chain */
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
testresult = 1;
end:
X509_free(crt1);
X509_free(crt2);
if (clientssl != NULL) {
SSL_shutdown(clientssl);
SSL_free(clientssl);
}
if (serverssl != NULL) {
SSL_shutdown(serverssl);
SSL_free(serverssl);
}
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
OPENSSL_free(skey);
OPENSSL_free(leaf);
OPENSSL_free(int2);
OPENSSL_free(int1);
OPENSSL_free(root);
return testresult;
}
static int test_ssl_build_cert_chain(void)
{
int ret = 0;
SSL_CTX *ssl_ctx = NULL;
SSL *ssl = NULL;
char *skey = test_mk_file_path(certsdir, "leaf.key");
char *leaf_chain = test_mk_file_path(certsdir, "leaf-chain.pem");
if (!TEST_ptr(ssl_ctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method())))
goto end;
if (!TEST_ptr(ssl = SSL_new(ssl_ctx)))
goto end;
/* leaf_chain contains leaf + subinterCA + interCA + rootCA */
if (!TEST_int_eq(SSL_use_certificate_chain_file(ssl, leaf_chain), 1)
|| !TEST_int_eq(SSL_use_PrivateKey_file(ssl, skey, SSL_FILETYPE_PEM), 1)
|| !TEST_int_eq(SSL_check_private_key(ssl), 1))
goto end;
if (!TEST_true(SSL_build_cert_chain(ssl, SSL_BUILD_CHAIN_FLAG_NO_ROOT
| SSL_BUILD_CHAIN_FLAG_CHECK)))
goto end;
ret = 1;
end:
SSL_free(ssl);
SSL_CTX_free(ssl_ctx);
OPENSSL_free(leaf_chain);
OPENSSL_free(skey);
return ret;
}
static int get_password_cb(char *buf, int size, int rw_flag, void *userdata)
{
static const char pass[] = "testpass";
if (!TEST_int_eq(size, PEM_BUFSIZE))
return -1;
memcpy(buf, pass, sizeof(pass) - 1);
return sizeof(pass) - 1;
}
static int test_ssl_ctx_build_cert_chain(void)
{
int ret = 0;
SSL_CTX *ctx = NULL;
char *skey = test_mk_file_path(certsdir, "leaf-encrypted.key");
char *leaf_chain = test_mk_file_path(certsdir, "leaf-chain.pem");
if (!TEST_ptr(ctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method())))
goto end;
SSL_CTX_set_default_passwd_cb(ctx, get_password_cb);
/* leaf_chain contains leaf + subinterCA + interCA + rootCA */
if (!TEST_int_eq(SSL_CTX_use_certificate_chain_file(ctx, leaf_chain), 1)
|| !TEST_int_eq(SSL_CTX_use_PrivateKey_file(ctx, skey,
SSL_FILETYPE_PEM), 1)
|| !TEST_int_eq(SSL_CTX_check_private_key(ctx), 1))
goto end;
if (!TEST_true(SSL_CTX_build_cert_chain(ctx, SSL_BUILD_CHAIN_FLAG_NO_ROOT
| SSL_BUILD_CHAIN_FLAG_CHECK)))
goto end;
ret = 1;
end:
SSL_CTX_free(ctx);
OPENSSL_free(leaf_chain);
OPENSSL_free(skey);
return ret;
}
#ifndef OPENSSL_NO_TLS1_2
static int full_client_hello_callback(SSL *s, int *al, void *arg)
{
int *ctr = arg;
const unsigned char *p;
int *exts;
/* We only configure two ciphers, but the SCSV is added automatically. */
#ifdef OPENSSL_NO_EC
const unsigned char expected_ciphers[] = {0x00, 0x9d, 0x00, 0xff};
#else
const unsigned char expected_ciphers[] = {0x00, 0x9d, 0xc0,
0x2c, 0x00, 0xff};
#endif
const int expected_extensions[] = {
#ifndef OPENSSL_NO_EC
11, 10,
#endif
35, 22, 23, 13};
size_t len;
/* Make sure we can defer processing and get called back. */
if ((*ctr)++ == 0)
return SSL_CLIENT_HELLO_RETRY;
len = SSL_client_hello_get0_ciphers(s, &p);
if (!TEST_mem_eq(p, len, expected_ciphers, sizeof(expected_ciphers))
|| !TEST_size_t_eq(
SSL_client_hello_get0_compression_methods(s, &p), 1)
|| !TEST_int_eq(*p, 0))
return SSL_CLIENT_HELLO_ERROR;
if (!SSL_client_hello_get1_extensions_present(s, &exts, &len))
return SSL_CLIENT_HELLO_ERROR;
if (len != OSSL_NELEM(expected_extensions) ||
memcmp(exts, expected_extensions, len * sizeof(*exts)) != 0) {
printf("ClientHello callback expected extensions mismatch\n");
OPENSSL_free(exts);
return SSL_CLIENT_HELLO_ERROR;
}
OPENSSL_free(exts);
return SSL_CLIENT_HELLO_SUCCESS;
}
static int test_client_hello_cb(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testctr = 0, testresult = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
SSL_CTX_set_client_hello_cb(sctx, full_client_hello_callback, &testctr);
/* The gimpy cipher list we configure can't do TLS 1.3. */
SSL_CTX_set_max_proto_version(cctx, TLS1_2_VERSION);
if (!TEST_true(SSL_CTX_set_cipher_list(cctx,
"AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384"))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_false(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_WANT_CLIENT_HELLO_CB))
/*
* Passing a -1 literal is a hack since
* the real value was lost.
* */
|| !TEST_int_eq(SSL_get_error(serverssl, -1),
SSL_ERROR_WANT_CLIENT_HELLO_CB)
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
static int test_no_ems(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0, status;
if (!create_ssl_ctx_pair(libctx, TLS_server_method(), TLS_client_method(),
TLS1_VERSION, TLS1_2_VERSION,
&sctx, &cctx, cert, privkey)) {
printf("Unable to create SSL_CTX pair\n");
goto end;
}
SSL_CTX_set_options(sctx, SSL_OP_NO_EXTENDED_MASTER_SECRET);
if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
printf("Unable to create SSL objects\n");
goto end;
}
status = create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE);
if (fips_ems_check) {
if (status == 1) {
printf("When FIPS uses the EMS check a connection that doesn't use EMS should fail\n");
goto end;
}
} else {
if (!status) {
printf("Creating SSL connection failed\n");
goto end;
}
if (SSL_get_extms_support(serverssl)) {
printf("Server reports Extended Master Secret support\n");
goto end;
}
if (SSL_get_extms_support(clientssl)) {
printf("Client reports Extended Master Secret support\n");
goto end;
}
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Very focused test to exercise a single case in the server-side state
* machine, when the ChangeCipherState message needs to actually change
* from one cipher to a different cipher (i.e., not changing from null
* encryption to real encryption).
*/
static int test_ccs_change_cipher(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
SSL_SESSION *sess = NULL, *sesspre, *sesspost;
int testresult = 0;
int i;
unsigned char buf;
size_t readbytes;
/*
* Create a connection so we can resume and potentially (but not) use
* a different cipher in the second connection.
*/
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, TLS1_2_VERSION,
&sctx, &cctx, cert, privkey))
|| !TEST_true(SSL_CTX_set_options(sctx, SSL_OP_NO_TICKET))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(SSL_set_cipher_list(clientssl, "AES128-GCM-SHA256"))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_ptr(sesspre = SSL_get0_session(serverssl))
|| !TEST_ptr(sess = SSL_get1_session(clientssl)))
goto end;
shutdown_ssl_connection(serverssl, clientssl);
serverssl = clientssl = NULL;
/* Resume, preferring a different cipher. Our server will force the
* same cipher to be used as the initial handshake. */
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, sess))
|| !TEST_true(SSL_set_cipher_list(clientssl, "AES256-GCM-SHA384:AES128-GCM-SHA256"))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl))
|| !TEST_true(SSL_session_reused(serverssl))
|| !TEST_ptr(sesspost = SSL_get0_session(serverssl))
|| !TEST_ptr_eq(sesspre, sesspost)
|| !TEST_int_eq(TLS1_CK_RSA_WITH_AES_128_GCM_SHA256,
SSL_CIPHER_get_id(SSL_get_current_cipher(clientssl))))
goto end;
shutdown_ssl_connection(serverssl, clientssl);
serverssl = clientssl = NULL;
/*
* Now create a fresh connection and try to renegotiate a different
* cipher on it.
*/
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(SSL_set_cipher_list(clientssl, "AES128-GCM-SHA256"))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_ptr(sesspre = SSL_get0_session(serverssl))
|| !TEST_true(SSL_set_cipher_list(clientssl, "AES256-GCM-SHA384"))
|| !TEST_true(SSL_renegotiate(clientssl))
|| !TEST_true(SSL_renegotiate_pending(clientssl)))
goto end;
/* Actually drive the renegotiation. */
for (i = 0; i < 3; i++) {
if (SSL_read_ex(clientssl, &buf, sizeof(buf), &readbytes) > 0) {
if (!TEST_ulong_eq(readbytes, 0))
goto end;
} else if (!TEST_int_eq(SSL_get_error(clientssl, 0),
SSL_ERROR_WANT_READ)) {
goto end;
}
if (SSL_read_ex(serverssl, &buf, sizeof(buf), &readbytes) > 0) {
if (!TEST_ulong_eq(readbytes, 0))
goto end;
} else if (!TEST_int_eq(SSL_get_error(serverssl, 0),
SSL_ERROR_WANT_READ)) {
goto end;
}
}
/* sesspre and sesspost should be different since the cipher changed. */
if (!TEST_false(SSL_renegotiate_pending(clientssl))
|| !TEST_false(SSL_session_reused(clientssl))
|| !TEST_false(SSL_session_reused(serverssl))
|| !TEST_ptr(sesspost = SSL_get0_session(serverssl))
|| !TEST_ptr_ne(sesspre, sesspost)
|| !TEST_int_eq(TLS1_CK_RSA_WITH_AES_256_GCM_SHA384,
SSL_CIPHER_get_id(SSL_get_current_cipher(clientssl))))
goto end;
shutdown_ssl_connection(serverssl, clientssl);
serverssl = clientssl = NULL;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
SSL_SESSION_free(sess);
return testresult;
}
#endif
static int execute_test_large_message(const SSL_METHOD *smeth,
const SSL_METHOD *cmeth,
int min_version, int max_version,
int read_ahead)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, smeth, cmeth, min_version,
max_version, &sctx, &cctx, cert,
privkey)))
goto end;
#ifdef OPENSSL_NO_DTLS1_2
if (smeth == DTLS_server_method()) {
/*
* Default sigalgs are SHA1 based in <DTLS1.2 which is in security
* level 0
*/
if (!TEST_true(SSL_CTX_set_cipher_list(sctx, "DEFAULT:@SECLEVEL=0"))
|| !TEST_true(SSL_CTX_set_cipher_list(cctx,
"DEFAULT:@SECLEVEL=0")))
goto end;
}
#endif
if (read_ahead) {
/*
* Test that read_ahead works correctly when dealing with large
* records
*/
SSL_CTX_set_read_ahead(cctx, 1);
}
if (!ssl_ctx_add_large_cert_chain(libctx, sctx, cert))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
/*
* Calling SSL_clear() first is not required but this tests that SSL_clear()
* doesn't leak.
*/
if (!TEST_true(SSL_clear(serverssl)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#if !defined(OPENSSL_NO_SOCK) && !defined(OPENSSL_NO_KTLS) && \
!(defined(OSSL_NO_USABLE_TLS1_3) && defined(OPENSSL_NO_TLS1_2))
/* sock must be connected */
static int ktls_chk_platform(int sock)
{
if (!ktls_enable(sock))
return 0;
return 1;
}
static int ping_pong_query(SSL *clientssl, SSL *serverssl)
{
static char count = 1;
unsigned char cbuf[16000] = {0};
unsigned char sbuf[16000];
size_t err = 0;
char crec_wseq_before[SEQ_NUM_SIZE];
char crec_wseq_after[SEQ_NUM_SIZE];
char crec_rseq_before[SEQ_NUM_SIZE];
char crec_rseq_after[SEQ_NUM_SIZE];
char srec_wseq_before[SEQ_NUM_SIZE];
char srec_wseq_after[SEQ_NUM_SIZE];
char srec_rseq_before[SEQ_NUM_SIZE];
char srec_rseq_after[SEQ_NUM_SIZE];
SSL_CONNECTION *clientsc, *serversc;
if (!TEST_ptr(clientsc = SSL_CONNECTION_FROM_SSL_ONLY(clientssl))
|| !TEST_ptr(serversc = SSL_CONNECTION_FROM_SSL_ONLY(serverssl)))
goto end;
cbuf[0] = count++;
memcpy(crec_wseq_before, &clientsc->rlayer.wrl->sequence, SEQ_NUM_SIZE);
memcpy(srec_wseq_before, &serversc->rlayer.wrl->sequence, SEQ_NUM_SIZE);
memcpy(crec_rseq_before, &clientsc->rlayer.rrl->sequence, SEQ_NUM_SIZE);
memcpy(srec_rseq_before, &serversc->rlayer.rrl->sequence, SEQ_NUM_SIZE);
if (!TEST_true(SSL_write(clientssl, cbuf, sizeof(cbuf)) == sizeof(cbuf)))
goto end;
while ((err = SSL_read(serverssl, &sbuf, sizeof(sbuf))) != sizeof(sbuf)) {
if (SSL_get_error(serverssl, err) != SSL_ERROR_WANT_READ) {
goto end;
}
}
if (!TEST_true(SSL_write(serverssl, sbuf, sizeof(sbuf)) == sizeof(sbuf)))
goto end;
while ((err = SSL_read(clientssl, &cbuf, sizeof(cbuf))) != sizeof(cbuf)) {
if (SSL_get_error(clientssl, err) != SSL_ERROR_WANT_READ) {
goto end;
}
}
memcpy(crec_wseq_after, &clientsc->rlayer.wrl->sequence, SEQ_NUM_SIZE);
memcpy(srec_wseq_after, &serversc->rlayer.wrl->sequence, SEQ_NUM_SIZE);
memcpy(crec_rseq_after, &clientsc->rlayer.rrl->sequence, SEQ_NUM_SIZE);
memcpy(srec_rseq_after, &serversc->rlayer.rrl->sequence, SEQ_NUM_SIZE);
/* verify the payload */
if (!TEST_mem_eq(cbuf, sizeof(cbuf), sbuf, sizeof(sbuf)))
goto end;
/*
* If ktls is used then kernel sequences are used instead of
* OpenSSL sequences
*/
if (!BIO_get_ktls_send(clientsc->wbio)) {
if (!TEST_mem_ne(crec_wseq_before, SEQ_NUM_SIZE,
crec_wseq_after, SEQ_NUM_SIZE))
goto end;
} else {
if (!TEST_mem_eq(crec_wseq_before, SEQ_NUM_SIZE,
crec_wseq_after, SEQ_NUM_SIZE))
goto end;
}
if (!BIO_get_ktls_send(serversc->wbio)) {
if (!TEST_mem_ne(srec_wseq_before, SEQ_NUM_SIZE,
srec_wseq_after, SEQ_NUM_SIZE))
goto end;
} else {
if (!TEST_mem_eq(srec_wseq_before, SEQ_NUM_SIZE,
srec_wseq_after, SEQ_NUM_SIZE))
goto end;
}
if (!BIO_get_ktls_recv(clientsc->wbio)) {
if (!TEST_mem_ne(crec_rseq_before, SEQ_NUM_SIZE,
crec_rseq_after, SEQ_NUM_SIZE))
goto end;
} else {
if (!TEST_mem_eq(crec_rseq_before, SEQ_NUM_SIZE,
crec_rseq_after, SEQ_NUM_SIZE))
goto end;
}
if (!BIO_get_ktls_recv(serversc->wbio)) {
if (!TEST_mem_ne(srec_rseq_before, SEQ_NUM_SIZE,
srec_rseq_after, SEQ_NUM_SIZE))
goto end;
} else {
if (!TEST_mem_eq(srec_rseq_before, SEQ_NUM_SIZE,
srec_rseq_after, SEQ_NUM_SIZE))
goto end;
}
return 1;
end:
return 0;
}
static int execute_test_ktls(int cis_ktls, int sis_ktls,
int tls_version, const char *cipher)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int ktls_used = 0, testresult = 0;
int cfd = -1, sfd = -1;
int rx_supported;
SSL_CONNECTION *clientsc, *serversc;
unsigned char *buf = NULL;
const size_t bufsz = SSL3_RT_MAX_PLAIN_LENGTH + 16;
int ret;
size_t offset = 0, i;
if (!TEST_true(create_test_sockets(&cfd, &sfd, SOCK_STREAM, NULL)))
goto end;
/* Skip this test if the platform does not support ktls */
if (!ktls_chk_platform(cfd)) {
testresult = TEST_skip("Kernel does not support KTLS");
goto end;
}
if (is_fips && strstr(cipher, "CHACHA") != NULL) {
testresult = TEST_skip("CHACHA is not supported in FIPS");
goto end;
}
/* Create a session based on SHA-256 */
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
tls_version, tls_version,
&sctx, &cctx, cert, privkey)))
goto end;
if (tls_version == TLS1_3_VERSION) {
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx, cipher))
|| !TEST_true(SSL_CTX_set_ciphersuites(sctx, cipher)))
goto end;
} else {
if (!TEST_true(SSL_CTX_set_cipher_list(cctx, cipher))
|| !TEST_true(SSL_CTX_set_cipher_list(sctx, cipher)))
goto end;
}
if (!TEST_true(create_ssl_objects2(sctx, cctx, &serverssl,
&clientssl, sfd, cfd)))
goto end;
if (!TEST_ptr(clientsc = SSL_CONNECTION_FROM_SSL_ONLY(clientssl))
|| !TEST_ptr(serversc = SSL_CONNECTION_FROM_SSL_ONLY(serverssl)))
goto end;
if (cis_ktls) {
if (!TEST_true(SSL_set_options(clientssl, SSL_OP_ENABLE_KTLS)))
goto end;
}
if (sis_ktls) {
if (!TEST_true(SSL_set_options(serverssl, SSL_OP_ENABLE_KTLS)))
goto end;
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
/*
* The running kernel may not support a given cipher suite
* or direction, so just check that KTLS isn't used when it
* isn't enabled.
*/
if (!cis_ktls) {
if (!TEST_false(BIO_get_ktls_send(clientsc->wbio)))
goto end;
} else {
if (BIO_get_ktls_send(clientsc->wbio))
ktls_used = 1;
}
if (!sis_ktls) {
if (!TEST_false(BIO_get_ktls_send(serversc->wbio)))
goto end;
} else {
if (BIO_get_ktls_send(serversc->wbio))
ktls_used = 1;
}
#if defined(OPENSSL_NO_KTLS_RX)
rx_supported = 0;
#else
rx_supported = 1;
#endif
if (!cis_ktls || !rx_supported) {
if (!TEST_false(BIO_get_ktls_recv(clientsc->rbio)))
goto end;
} else {
if (BIO_get_ktls_send(clientsc->rbio))
ktls_used = 1;
}
if (!sis_ktls || !rx_supported) {
if (!TEST_false(BIO_get_ktls_recv(serversc->rbio)))
goto end;
} else {
if (BIO_get_ktls_send(serversc->rbio))
ktls_used = 1;
}
if ((cis_ktls || sis_ktls) && !ktls_used) {
testresult = TEST_skip("KTLS not supported for %s cipher %s",
tls_version == TLS1_3_VERSION ? "TLS 1.3" :
"TLS 1.2", cipher);
goto end;
}
if (!TEST_true(ping_pong_query(clientssl, serverssl)))
goto end;
buf = OPENSSL_zalloc(bufsz);
if (!TEST_ptr(buf))
goto end;
/*
* Write some data that exceeds the maximum record length. KTLS may choose
* to coalesce this data into a single buffer when we read it again.
*/
while ((ret = SSL_write(clientssl, buf, bufsz)) != (int)bufsz) {
if (!TEST_true(SSL_get_error(clientssl, ret) == SSL_ERROR_WANT_WRITE))
goto end;
}
/* Now check that we can read all the data we wrote */
do {
ret = SSL_read(serverssl, buf + offset, bufsz - offset);
if (ret <= 0) {
if (!TEST_true(SSL_get_error(serverssl, ret) == SSL_ERROR_WANT_READ))
goto end;
} else {
offset += ret;
}
} while (offset < bufsz);
if (!TEST_true(offset == bufsz))
goto end;
for (i = 0; i < bufsz; i++)
if (!TEST_true(buf[i] == 0))
goto end;
testresult = 1;
end:
OPENSSL_free(buf);
if (clientssl) {
SSL_shutdown(clientssl);
SSL_free(clientssl);
}
if (serverssl) {
SSL_shutdown(serverssl);
SSL_free(serverssl);
}
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
serverssl = clientssl = NULL;
if (cfd != -1)
close(cfd);
if (sfd != -1)
close(sfd);
return testresult;
}
#define SENDFILE_SZ (16 * 4096)
#define SENDFILE_CHUNK (4 * 4096)
#define min(a,b) ((a) > (b) ? (b) : (a))
static int execute_test_ktls_sendfile(int tls_version, const char *cipher,
int zerocopy)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
unsigned char *buf, *buf_dst;
BIO *out = NULL, *in = NULL;
int cfd = -1, sfd = -1, ffd, err;
ssize_t chunk_size = 0;
off_t chunk_off = 0;
int testresult = 0;
FILE *ffdp;
SSL_CONNECTION *serversc;
buf = OPENSSL_zalloc(SENDFILE_SZ);
buf_dst = OPENSSL_zalloc(SENDFILE_SZ);
if (!TEST_ptr(buf) || !TEST_ptr(buf_dst)
|| !TEST_true(create_test_sockets(&cfd, &sfd, SOCK_STREAM, NULL)))
goto end;
/* Skip this test if the platform does not support ktls */
if (!ktls_chk_platform(sfd)) {
testresult = TEST_skip("Kernel does not support KTLS");
goto end;
}
if (is_fips && strstr(cipher, "CHACHA") != NULL) {
testresult = TEST_skip("CHACHA is not supported in FIPS");
goto end;
}
/* Create a session based on SHA-256 */
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
tls_version, tls_version,
&sctx, &cctx, cert, privkey)))
goto end;
if (tls_version == TLS1_3_VERSION) {
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx, cipher))
|| !TEST_true(SSL_CTX_set_ciphersuites(sctx, cipher)))
goto end;
} else {
if (!TEST_true(SSL_CTX_set_cipher_list(cctx, cipher))
|| !TEST_true(SSL_CTX_set_cipher_list(sctx, cipher)))
goto end;
}
if (!TEST_true(create_ssl_objects2(sctx, cctx, &serverssl,
&clientssl, sfd, cfd)))
goto end;
if (!TEST_ptr(serversc = SSL_CONNECTION_FROM_SSL_ONLY(serverssl)))
goto end;
if (!TEST_true(SSL_set_options(serverssl, SSL_OP_ENABLE_KTLS)))
goto end;
if (zerocopy) {
if (!TEST_true(SSL_set_options(serverssl,
SSL_OP_ENABLE_KTLS_TX_ZEROCOPY_SENDFILE)))
goto end;
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
if (!BIO_get_ktls_send(serversc->wbio)) {
testresult = TEST_skip("Failed to enable KTLS for %s cipher %s",
tls_version == TLS1_3_VERSION ? "TLS 1.3" :
"TLS 1.2", cipher);
goto end;
}
if (!TEST_int_gt(RAND_bytes_ex(libctx, buf, SENDFILE_SZ, 0), 0))
goto end;
out = BIO_new_file(tmpfilename, "wb");
if (!TEST_ptr(out))
goto end;
if (BIO_write(out, buf, SENDFILE_SZ) != SENDFILE_SZ)
goto end;
BIO_free(out);
out = NULL;
in = BIO_new_file(tmpfilename, "rb");
BIO_get_fp(in, &ffdp);
ffd = fileno(ffdp);
while (chunk_off < SENDFILE_SZ) {
chunk_size = min(SENDFILE_CHUNK, SENDFILE_SZ - chunk_off);
while ((err = SSL_sendfile(serverssl,
ffd,
chunk_off,
chunk_size,
0)) != chunk_size) {
if (SSL_get_error(serverssl, err) != SSL_ERROR_WANT_WRITE)
goto end;
}
while ((err = SSL_read(clientssl,
buf_dst + chunk_off,
chunk_size)) != chunk_size) {
if (SSL_get_error(clientssl, err) != SSL_ERROR_WANT_READ)
goto end;
}
/* verify the payload */
if (!TEST_mem_eq(buf_dst + chunk_off,
chunk_size,
buf + chunk_off,
chunk_size))
goto end;
chunk_off += chunk_size;
}
testresult = 1;
end:
if (clientssl) {
SSL_shutdown(clientssl);
SSL_free(clientssl);
}
if (serverssl) {
SSL_shutdown(serverssl);
SSL_free(serverssl);
}
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
serverssl = clientssl = NULL;
BIO_free(out);
BIO_free(in);
if (cfd != -1)
close(cfd);
if (sfd != -1)
close(sfd);
OPENSSL_free(buf);
OPENSSL_free(buf_dst);
return testresult;
}
static struct ktls_test_cipher {
int tls_version;
const char *cipher;
} ktls_test_ciphers[] = {
# if !defined(OPENSSL_NO_TLS1_2)
# ifdef OPENSSL_KTLS_AES_GCM_128
{ TLS1_2_VERSION, "AES128-GCM-SHA256" },
# endif
# ifdef OPENSSL_KTLS_AES_CCM_128
{ TLS1_2_VERSION, "AES128-CCM"},
# endif
# ifdef OPENSSL_KTLS_AES_GCM_256
{ TLS1_2_VERSION, "AES256-GCM-SHA384"},
# endif
# ifdef OPENSSL_KTLS_CHACHA20_POLY1305
# ifndef OPENSSL_NO_EC
{ TLS1_2_VERSION, "ECDHE-RSA-CHACHA20-POLY1305"},
# endif
# endif
# endif
# if !defined(OSSL_NO_USABLE_TLS1_3)
# ifdef OPENSSL_KTLS_AES_GCM_128
{ TLS1_3_VERSION, "TLS_AES_128_GCM_SHA256" },
# endif
# ifdef OPENSSL_KTLS_AES_CCM_128
{ TLS1_3_VERSION, "TLS_AES_128_CCM_SHA256" },
# endif
# ifdef OPENSSL_KTLS_AES_GCM_256
{ TLS1_3_VERSION, "TLS_AES_256_GCM_SHA384" },
# endif
# ifdef OPENSSL_KTLS_CHACHA20_POLY1305
{ TLS1_3_VERSION, "TLS_CHACHA20_POLY1305_SHA256" },
# endif
# endif
};
#define NUM_KTLS_TEST_CIPHERS \
(sizeof(ktls_test_ciphers) / sizeof(ktls_test_ciphers[0]))
static int test_ktls(int test)
{
struct ktls_test_cipher *cipher;
int cis_ktls, sis_ktls;
OPENSSL_assert(test / 4 < (int)NUM_KTLS_TEST_CIPHERS);
cipher = &ktls_test_ciphers[test / 4];
cis_ktls = (test & 1) != 0;
sis_ktls = (test & 2) != 0;
return execute_test_ktls(cis_ktls, sis_ktls, cipher->tls_version,
cipher->cipher);
}
static int test_ktls_sendfile(int test)
{
struct ktls_test_cipher *cipher;
int tst = test >> 1;
OPENSSL_assert(tst < (int)NUM_KTLS_TEST_CIPHERS);
cipher = &ktls_test_ciphers[tst];
return execute_test_ktls_sendfile(cipher->tls_version, cipher->cipher,
test & 1);
}
#endif
static int test_large_message_tls(void)
{
return execute_test_large_message(TLS_server_method(), TLS_client_method(),
TLS1_VERSION, 0, 0);
}
static int test_large_message_tls_read_ahead(void)
{
return execute_test_large_message(TLS_server_method(), TLS_client_method(),
TLS1_VERSION, 0, 1);
}
#ifndef OPENSSL_NO_DTLS
static int test_large_message_dtls(void)
{
# ifdef OPENSSL_NO_DTLS1_2
/* Not supported in the FIPS provider */
if (is_fips)
return 1;
# endif
/*
* read_ahead is not relevant to DTLS because DTLS always acts as if
* read_ahead is set.
*/
return execute_test_large_message(DTLS_server_method(),
DTLS_client_method(),
DTLS1_VERSION, 0, 0);
}
#endif
/*
* Test we can successfully send the maximum amount of application data. We
* test each protocol version individually, each with and without EtM enabled.
* TLSv1.3 doesn't use EtM so technically it is redundant to test both but it is
* simpler this way. We also test all combinations with and without the
* SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS option which affects the size of the
* underlying buffer.
*/
static int test_large_app_data(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0, prot;
unsigned char *msg, *buf = NULL;
size_t written, readbytes;
const SSL_METHOD *smeth = TLS_server_method();
const SSL_METHOD *cmeth = TLS_client_method();
switch (tst >> 2) {
case 0:
#ifndef OSSL_NO_USABLE_TLS1_3
prot = TLS1_3_VERSION;
break;
#else
return 1;
#endif
case 1:
#ifndef OPENSSL_NO_TLS1_2
prot = TLS1_2_VERSION;
break;
#else
return 1;
#endif
case 2:
#ifndef OPENSSL_NO_TLS1_1
prot = TLS1_1_VERSION;
break;
#else
return 1;
#endif
case 3:
#ifndef OPENSSL_NO_TLS1
prot = TLS1_VERSION;
break;
#else
return 1;
#endif
case 4:
#ifndef OPENSSL_NO_SSL3
prot = SSL3_VERSION;
break;
#else
return 1;
#endif
case 5:
#ifndef OPENSSL_NO_DTLS1_2
prot = DTLS1_2_VERSION;
smeth = DTLS_server_method();
cmeth = DTLS_client_method();
break;
#else
return 1;
#endif
case 6:
#ifndef OPENSSL_NO_DTLS1
prot = DTLS1_VERSION;
smeth = DTLS_server_method();
cmeth = DTLS_client_method();
break;
#else
return 1;
#endif
default:
/* Shouldn't happen */
return 0;
}
if ((prot < TLS1_2_VERSION || prot == DTLS1_VERSION) && is_fips)
return 1;
/* Maximal sized message of zeros */
msg = OPENSSL_zalloc(SSL3_RT_MAX_PLAIN_LENGTH);
if (!TEST_ptr(msg))
goto end;
buf = OPENSSL_malloc(SSL3_RT_MAX_PLAIN_LENGTH + 1);
if (!TEST_ptr(buf))
goto end;
/* Set whole buffer to all bits set */
memset(buf, 0xff, SSL3_RT_MAX_PLAIN_LENGTH + 1);
if (!TEST_true(create_ssl_ctx_pair(libctx, smeth, cmeth, prot, prot,
&sctx, &cctx, cert, privkey)))
goto end;
if (prot < TLS1_2_VERSION || prot == DTLS1_VERSION) {
/* Older protocol versions need SECLEVEL=0 due to SHA1 usage */
if (!TEST_true(SSL_CTX_set_cipher_list(cctx, "DEFAULT:@SECLEVEL=0"))
|| !TEST_true(SSL_CTX_set_cipher_list(sctx,
"DEFAULT:@SECLEVEL=0")))
goto end;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if ((tst & 1) != 0) {
/* Setting this option gives us a minimally sized underlying buffer */
if (!TEST_true(SSL_set_options(serverssl,
SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS))
|| !TEST_true(SSL_set_options(clientssl,
SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)))
goto end;
}
if ((tst & 2) != 0) {
/*
* Setting this option means the MAC is added before encryption
* giving us a larger record for the encryption process
*/
if (!TEST_true(SSL_set_options(serverssl, SSL_OP_NO_ENCRYPT_THEN_MAC))
|| !TEST_true(SSL_set_options(clientssl,
SSL_OP_NO_ENCRYPT_THEN_MAC)))
goto end;
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
if (!TEST_true(SSL_write_ex(clientssl, msg, SSL3_RT_MAX_PLAIN_LENGTH,
&written))
|| !TEST_size_t_eq(written, SSL3_RT_MAX_PLAIN_LENGTH))
goto end;
/* We provide a buffer slightly larger than what we are actually expecting */
if (!TEST_true(SSL_read_ex(serverssl, buf, SSL3_RT_MAX_PLAIN_LENGTH + 1,
&readbytes)))
goto end;
if (!TEST_mem_eq(msg, written, buf, readbytes))
goto end;
testresult = 1;
end:
OPENSSL_free(msg);
OPENSSL_free(buf);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#if !defined(OPENSSL_NO_TLS1_2) || !defined(OSSL_NO_USABLE_TLS1_3) \
|| !defined(OPENSSL_NO_DTLS)
static int execute_cleanse_plaintext(const SSL_METHOD *smeth,
const SSL_METHOD *cmeth,
int min_version, int max_version)
{
size_t i;
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
const unsigned char *zbuf;
SSL_CONNECTION *serversc;
TLS_RECORD *rr;
static unsigned char cbuf[16000];
static unsigned char sbuf[16000];
if (!TEST_true(create_ssl_ctx_pair(libctx,
smeth, cmeth,
min_version, max_version,
&sctx, &cctx, cert,
privkey)))
goto end;
# ifdef OPENSSL_NO_DTLS1_2
if (smeth == DTLS_server_method()) {
/* Not supported in the FIPS provider */
if (is_fips) {
testresult = 1;
goto end;
};
/*
* Default sigalgs are SHA1 based in <DTLS1.2 which is in security
* level 0
*/
if (!TEST_true(SSL_CTX_set_cipher_list(sctx, "DEFAULT:@SECLEVEL=0"))
|| !TEST_true(SSL_CTX_set_cipher_list(cctx,
"DEFAULT:@SECLEVEL=0")))
goto end;
}
# endif
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (!TEST_true(SSL_set_options(serverssl, SSL_OP_CLEANSE_PLAINTEXT)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
for (i = 0; i < sizeof(cbuf); i++) {
cbuf[i] = i & 0xff;
}
if (!TEST_int_eq(SSL_write(clientssl, cbuf, sizeof(cbuf)), sizeof(cbuf)))
goto end;
if (!TEST_int_eq(SSL_peek(serverssl, &sbuf, sizeof(sbuf)), sizeof(sbuf)))
goto end;
if (!TEST_mem_eq(cbuf, sizeof(cbuf), sbuf, sizeof(sbuf)))
goto end;
/*
* Since we called SSL_peek(), we know the data in the record
* layer is a plaintext record. We can gather the pointer to check
* for zeroization after SSL_read().
*/
if (!TEST_ptr(serversc = SSL_CONNECTION_FROM_SSL_ONLY(serverssl)))
goto end;
rr = serversc->rlayer.tlsrecs;
zbuf = &rr->data[rr->off];
if (!TEST_int_eq(rr->length, sizeof(cbuf)))
goto end;
/*
* After SSL_peek() the plaintext must still be stored in the
* record.
*/
if (!TEST_mem_eq(cbuf, sizeof(cbuf), zbuf, sizeof(cbuf)))
goto end;
memset(sbuf, 0, sizeof(sbuf));
if (!TEST_int_eq(SSL_read(serverssl, &sbuf, sizeof(sbuf)), sizeof(sbuf)))
goto end;
if (!TEST_mem_eq(cbuf, sizeof(cbuf), sbuf, sizeof(cbuf)))
goto end;
/* Check if rbuf is cleansed */
memset(cbuf, 0, sizeof(cbuf));
if (!TEST_mem_eq(cbuf, sizeof(cbuf), zbuf, sizeof(cbuf)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif /*
* !defined(OPENSSL_NO_TLS1_2) || !defined(OSSL_NO_USABLE_TLS1_3)
* || !defined(OPENSSL_NO_DTLS)
*/
static int test_cleanse_plaintext(void)
{
#if !defined(OPENSSL_NO_TLS1_2)
if (!TEST_true(execute_cleanse_plaintext(TLS_server_method(),
TLS_client_method(),
TLS1_2_VERSION,
TLS1_2_VERSION)))
return 0;
#endif
#if !defined(OSSL_NO_USABLE_TLS1_3)
if (!TEST_true(execute_cleanse_plaintext(TLS_server_method(),
TLS_client_method(),
TLS1_3_VERSION,
TLS1_3_VERSION)))
return 0;
#endif
#if !defined(OPENSSL_NO_DTLS)
if (!TEST_true(execute_cleanse_plaintext(DTLS_server_method(),
DTLS_client_method(),
DTLS1_VERSION,
0)))
return 0;
#endif
return 1;
}
#ifndef OPENSSL_NO_OCSP
static int ocsp_server_cb(SSL *s, void *arg)
{
int *argi = (int *)arg;
unsigned char *copy = NULL;
STACK_OF(OCSP_RESPID) *ids = NULL;
OCSP_RESPID *id = NULL;
if (*argi == 2) {
/* In this test we are expecting exactly 1 OCSP_RESPID */
SSL_get_tlsext_status_ids(s, &ids);
if (ids == NULL || sk_OCSP_RESPID_num(ids) != 1)
return SSL_TLSEXT_ERR_ALERT_FATAL;
id = sk_OCSP_RESPID_value(ids, 0);
if (id == NULL || !OCSP_RESPID_match_ex(id, ocspcert, libctx, NULL))
return SSL_TLSEXT_ERR_ALERT_FATAL;
} else if (*argi != 1) {
return SSL_TLSEXT_ERR_ALERT_FATAL;
}
if (!TEST_ptr(copy = OPENSSL_memdup(orespder, sizeof(orespder))))
return SSL_TLSEXT_ERR_ALERT_FATAL;
if (!TEST_true(SSL_set_tlsext_status_ocsp_resp(s, copy,
sizeof(orespder)))) {
OPENSSL_free(copy);
return SSL_TLSEXT_ERR_ALERT_FATAL;
}
ocsp_server_called = 1;
return SSL_TLSEXT_ERR_OK;
}
static int ocsp_client_cb(SSL *s, void *arg)
{
int *argi = (int *)arg;
const unsigned char *respderin;
size_t len;
if (*argi != 1 && *argi != 2)
return 0;
len = SSL_get_tlsext_status_ocsp_resp(s, &respderin);
if (!TEST_mem_eq(orespder, len, respderin, len))
return 0;
ocsp_client_called = 1;
return 1;
}
static int test_tlsext_status_type(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
STACK_OF(OCSP_RESPID) *ids = NULL;
OCSP_RESPID *id = NULL;
BIO *certbio = NULL;
if (!create_ssl_ctx_pair(libctx, TLS_server_method(), TLS_client_method(),
TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey))
return 0;
if (SSL_CTX_get_tlsext_status_type(cctx) != -1)
goto end;
/* First just do various checks getting and setting tlsext_status_type */
clientssl = SSL_new(cctx);
if (!TEST_int_eq(SSL_get_tlsext_status_type(clientssl), -1)
|| !TEST_true(SSL_set_tlsext_status_type(clientssl,
TLSEXT_STATUSTYPE_ocsp))
|| !TEST_int_eq(SSL_get_tlsext_status_type(clientssl),
TLSEXT_STATUSTYPE_ocsp))
goto end;
SSL_free(clientssl);
clientssl = NULL;
if (!SSL_CTX_set_tlsext_status_type(cctx, TLSEXT_STATUSTYPE_ocsp)
|| SSL_CTX_get_tlsext_status_type(cctx) != TLSEXT_STATUSTYPE_ocsp)
goto end;
clientssl = SSL_new(cctx);
if (SSL_get_tlsext_status_type(clientssl) != TLSEXT_STATUSTYPE_ocsp)
goto end;
SSL_free(clientssl);
clientssl = NULL;
/*
* Now actually do a handshake and check OCSP information is exchanged and
* the callbacks get called
*/
SSL_CTX_set_tlsext_status_cb(cctx, ocsp_client_cb);
SSL_CTX_set_tlsext_status_arg(cctx, &cdummyarg);
SSL_CTX_set_tlsext_status_cb(sctx, ocsp_server_cb);
SSL_CTX_set_tlsext_status_arg(sctx, &cdummyarg);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_true(ocsp_client_called)
|| !TEST_true(ocsp_server_called))
goto end;
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = NULL;
clientssl = NULL;
/* Try again but this time force the server side callback to fail */
ocsp_client_called = 0;
ocsp_server_called = 0;
cdummyarg = 0;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
/* This should fail because the callback will fail */
|| !TEST_false(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_false(ocsp_client_called)
|| !TEST_false(ocsp_server_called))
goto end;
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = NULL;
clientssl = NULL;
/*
* This time we'll get the client to send an OCSP_RESPID that it will
* accept.
*/
ocsp_client_called = 0;
ocsp_server_called = 0;
cdummyarg = 2;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
/*
* We'll just use any old cert for this test - it doesn't have to be an OCSP
* specific one. We'll use the server cert.
*/
if (!TEST_ptr(certbio = BIO_new_file(cert, "r"))
|| !TEST_ptr(id = OCSP_RESPID_new())
|| !TEST_ptr(ids = sk_OCSP_RESPID_new_null())
|| !TEST_ptr(ocspcert = X509_new_ex(libctx, NULL))
|| !TEST_ptr(PEM_read_bio_X509(certbio, &ocspcert, NULL, NULL))
|| !TEST_true(OCSP_RESPID_set_by_key_ex(id, ocspcert, libctx, NULL))
|| !TEST_true(sk_OCSP_RESPID_push(ids, id)))
goto end;
id = NULL;
SSL_set_tlsext_status_ids(clientssl, ids);
/* Control has been transferred */
ids = NULL;
BIO_free(certbio);
certbio = NULL;
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_true(ocsp_client_called)
|| !TEST_true(ocsp_server_called))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
sk_OCSP_RESPID_pop_free(ids, OCSP_RESPID_free);
OCSP_RESPID_free(id);
BIO_free(certbio);
X509_free(ocspcert);
ocspcert = NULL;
return testresult;
}
#endif
#if !defined(OSSL_NO_USABLE_TLS1_3) || !defined(OPENSSL_NO_TLS1_2)
static int new_called, remove_called, get_called;
static int new_session_cb(SSL *ssl, SSL_SESSION *sess)
{
new_called++;
/*
* sess has been up-refed for us, but we don't actually need it so free it
* immediately.
*/
SSL_SESSION_free(sess);
return 1;
}
static void remove_session_cb(SSL_CTX *ctx, SSL_SESSION *sess)
{
remove_called++;
}
static SSL_SESSION *get_sess_val = NULL;
static SSL_SESSION *get_session_cb(SSL *ssl, const unsigned char *id, int len,
int *copy)
{
get_called++;
*copy = 1;
return get_sess_val;
}
static int execute_test_session(int maxprot, int use_int_cache,
int use_ext_cache, long s_options)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl1 = NULL, *clientssl1 = NULL;
SSL *serverssl2 = NULL, *clientssl2 = NULL;
# ifndef OPENSSL_NO_TLS1_1
SSL *serverssl3 = NULL, *clientssl3 = NULL;
# endif
SSL_SESSION *sess1 = NULL, *sess2 = NULL;
int testresult = 0, numnewsesstick = 1;
new_called = remove_called = 0;
/* TLSv1.3 sends 2 NewSessionTickets */
if (maxprot == TLS1_3_VERSION)
numnewsesstick = 2;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
return 0;
/*
* Only allow the max protocol version so we can force a connection failure
* later
*/
SSL_CTX_set_min_proto_version(cctx, maxprot);
SSL_CTX_set_max_proto_version(cctx, maxprot);
/* Set up session cache */
if (use_ext_cache) {
SSL_CTX_sess_set_new_cb(cctx, new_session_cb);
SSL_CTX_sess_set_remove_cb(cctx, remove_session_cb);
}
if (use_int_cache) {
/* Also covers instance where both are set */
SSL_CTX_set_session_cache_mode(cctx, SSL_SESS_CACHE_CLIENT);
} else {
SSL_CTX_set_session_cache_mode(cctx,
SSL_SESS_CACHE_CLIENT
| 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,
SSL_ERROR_NONE))
|| !TEST_ptr(sess1 = SSL_get1_session(clientssl1)))
goto end;
/* Should fail because it should already be in the cache */
if (use_int_cache && !TEST_false(SSL_CTX_add_session(cctx, sess1)))
goto end;
if (use_ext_cache
&& (!TEST_int_eq(new_called, numnewsesstick)
|| !TEST_int_eq(remove_called, 0)))
goto end;
new_called = remove_called = 0;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl2,
&clientssl2, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl2, sess1))
|| !TEST_true(create_ssl_connection(serverssl2, clientssl2,
SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl2)))
goto end;
if (maxprot == TLS1_3_VERSION) {
/*
* In TLSv1.3 we should have created a new session even though we have
* resumed. Since we attempted a resume we should also have removed the
* old ticket from the cache so that we try to only use tickets once.
*/
if (use_ext_cache
&& (!TEST_int_eq(new_called, 1)
|| !TEST_int_eq(remove_called, 1)))
goto end;
} else {
/*
* In TLSv1.2 we expect to have resumed so no sessions added or
* removed.
*/
if (use_ext_cache
&& (!TEST_int_eq(new_called, 0)
|| !TEST_int_eq(remove_called, 0)))
goto end;
}
SSL_SESSION_free(sess1);
if (!TEST_ptr(sess1 = SSL_get1_session(clientssl2)))
goto end;
shutdown_ssl_connection(serverssl2, clientssl2);
serverssl2 = clientssl2 = NULL;
new_called = remove_called = 0;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl2,
&clientssl2, NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl2, clientssl2,
SSL_ERROR_NONE)))
goto end;
if (!TEST_ptr(sess2 = SSL_get1_session(clientssl2)))
goto end;
if (use_ext_cache
&& (!TEST_int_eq(new_called, numnewsesstick)
|| !TEST_int_eq(remove_called, 0)))
goto end;
new_called = remove_called = 0;
/*
* This should clear sess2 from the cache because it is a "bad" session.
* See SSL_set_session() documentation.
*/
if (!TEST_true(SSL_set_session(clientssl2, sess1)))
goto end;
if (use_ext_cache
&& (!TEST_int_eq(new_called, 0) || !TEST_int_eq(remove_called, 1)))
goto end;
if (!TEST_ptr_eq(SSL_get_session(clientssl2), sess1))
goto end;
if (use_int_cache) {
/* Should succeeded because it should not already be in the cache */
if (!TEST_true(SSL_CTX_add_session(cctx, sess2))
|| !TEST_true(SSL_CTX_remove_session(cctx, sess2)))
goto end;
}
new_called = remove_called = 0;
/* This shouldn't be in the cache so should fail */
if (!TEST_false(SSL_CTX_remove_session(cctx, sess2)))
goto end;
if (use_ext_cache
&& (!TEST_int_eq(new_called, 0) || !TEST_int_eq(remove_called, 1)))
goto end;
# if !defined(OPENSSL_NO_TLS1_1)
new_called = remove_called = 0;
/* Force a connection failure */
SSL_CTX_set_max_proto_version(sctx, TLS1_1_VERSION);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl3,
&clientssl3, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl3, sess1))
/* This should fail because of the mismatched protocol versions */
|| !TEST_false(create_ssl_connection(serverssl3, clientssl3,
SSL_ERROR_NONE)))
goto end;
/* We should have automatically removed the session from the cache */
if (use_ext_cache
&& (!TEST_int_eq(new_called, 0) || !TEST_int_eq(remove_called, 1)))
goto end;
/* Should succeed because it should not already be in the cache */
if (use_int_cache && !TEST_true(SSL_CTX_add_session(cctx, sess2)))
goto end;
# endif
/* Now do some tests for server side caching */
if (use_ext_cache) {
SSL_CTX_sess_set_new_cb(cctx, NULL);
SSL_CTX_sess_set_remove_cb(cctx, NULL);
SSL_CTX_sess_set_new_cb(sctx, new_session_cb);
SSL_CTX_sess_set_remove_cb(sctx, remove_session_cb);
SSL_CTX_sess_set_get_cb(sctx, get_session_cb);
get_sess_val = NULL;
}
SSL_CTX_set_session_cache_mode(cctx, 0);
/* Internal caching is the default on the server side */
if (!use_int_cache)
SSL_CTX_set_session_cache_mode(sctx,
SSL_SESS_CACHE_SERVER
| SSL_SESS_CACHE_NO_INTERNAL_STORE);
SSL_free(serverssl1);
SSL_free(clientssl1);
serverssl1 = clientssl1 = NULL;
SSL_free(serverssl2);
SSL_free(clientssl2);
serverssl2 = clientssl2 = NULL;
SSL_SESSION_free(sess1);
sess1 = NULL;
SSL_SESSION_free(sess2);
sess2 = NULL;
SSL_CTX_set_max_proto_version(sctx, maxprot);
if (maxprot == TLS1_2_VERSION)
SSL_CTX_set_options(sctx, SSL_OP_NO_TICKET);
new_called = remove_called = get_called = 0;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl1, &clientssl1,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl1, clientssl1,
SSL_ERROR_NONE))
|| !TEST_ptr(sess1 = SSL_get1_session(clientssl1))
|| !TEST_ptr(sess2 = SSL_get1_session(serverssl1)))
goto end;
if (use_int_cache) {
if (maxprot == TLS1_3_VERSION && !use_ext_cache) {
/*
* In TLSv1.3 it should not have been added to the internal cache,
* except in the case where we also have an external cache (in that
* case it gets added to the cache in order to generate remove
* events after timeout).
*/
if (!TEST_false(SSL_CTX_remove_session(sctx, sess2)))
goto end;
} else {
/* Should fail because it should already be in the cache */
if (!TEST_false(SSL_CTX_add_session(sctx, sess2)))
goto end;
}
}
if (use_ext_cache) {
SSL_SESSION *tmp = sess2;
if (!TEST_int_eq(new_called, numnewsesstick)
|| !TEST_int_eq(remove_called, 0)
|| !TEST_int_eq(get_called, 0))
goto end;
/*
* Delete the session from the internal cache to force a lookup from
* the external cache. We take a copy first because
* SSL_CTX_remove_session() also marks the session as non-resumable.
*/
if (use_int_cache && maxprot != TLS1_3_VERSION) {
if (!TEST_ptr(tmp = SSL_SESSION_dup(sess2))
|| !TEST_true(sess2->owner != NULL)
|| !TEST_true(tmp->owner == NULL)
|| !TEST_true(SSL_CTX_remove_session(sctx, sess2)))
goto end;
SSL_SESSION_free(sess2);
}
sess2 = tmp;
}
new_called = remove_called = get_called = 0;
get_sess_val = sess2;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl2,
&clientssl2, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl2, sess1))
|| !TEST_true(create_ssl_connection(serverssl2, clientssl2,
SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl2)))
goto end;
if (use_ext_cache) {
if (!TEST_int_eq(remove_called, 0))
goto end;
if (maxprot == TLS1_3_VERSION) {
if (!TEST_int_eq(new_called, 1)
|| !TEST_int_eq(get_called, 0))
goto end;
} else {
if (!TEST_int_eq(new_called, 0)
|| !TEST_int_eq(get_called, 1))
goto end;
}
}
/*
* Make a small cache, force out all other sessions but
* sess2, try to add sess1, which should succeed. Then
* make sure it's there by checking the owners. Despite
* the timeouts, sess1 should have kicked out sess2
*/
/* Make sess1 expire before sess2 */
if (!TEST_long_gt(SSL_SESSION_set_time(sess1, 1000), 0)
|| !TEST_long_gt(SSL_SESSION_set_timeout(sess1, 1000), 0)
|| !TEST_long_gt(SSL_SESSION_set_time(sess2, 2000), 0)
|| !TEST_long_gt(SSL_SESSION_set_timeout(sess2, 2000), 0))
goto end;
if (!TEST_long_ne(SSL_CTX_sess_set_cache_size(sctx, 1), 0))
goto end;
/* Don't care about results - cache should only be sess2 at end */
SSL_CTX_add_session(sctx, sess1);
SSL_CTX_add_session(sctx, sess2);
/* Now add sess1, and make sure it remains, despite timeout */
if (!TEST_true(SSL_CTX_add_session(sctx, sess1))
|| !TEST_ptr(sess1->owner)
|| !TEST_ptr_null(sess2->owner))
goto end;
testresult = 1;
end:
SSL_free(serverssl1);
SSL_free(clientssl1);
SSL_free(serverssl2);
SSL_free(clientssl2);
# ifndef OPENSSL_NO_TLS1_1
SSL_free(serverssl3);
SSL_free(clientssl3);
# endif
SSL_SESSION_free(sess1);
SSL_SESSION_free(sess2);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif /* !defined(OSSL_NO_USABLE_TLS1_3) || !defined(OPENSSL_NO_TLS1_2) */
static int test_session_with_only_int_cache(void)
{
#ifndef OSSL_NO_USABLE_TLS1_3
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, 0);
#else
return 1;
#endif
}
static int test_session_with_only_ext_cache(void)
{
#ifndef OSSL_NO_USABLE_TLS1_3
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, 0);
#else
return 1;
#endif
}
static int test_session_with_both_cache(void)
{
#ifndef OSSL_NO_USABLE_TLS1_3
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, 0);
#else
return 1;
#endif
}
static int test_session_wo_ca_names(void)
{
#ifndef OSSL_NO_USABLE_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 OSSL_NO_USABLE_TLS1_3
static SSL_SESSION *sesscache[6];
static int do_cache;
static int new_cachesession_cb(SSL *ssl, SSL_SESSION *sess)
{
if (do_cache) {
sesscache[new_called] = sess;
} else {
/* We don't need the reference to the session, so free it */
SSL_SESSION_free(sess);
}
new_called++;
return 1;
}
static int post_handshake_verify(SSL *sssl, SSL *cssl)
{
SSL_set_verify(sssl, SSL_VERIFY_PEER, NULL);
if (!TEST_true(SSL_verify_client_post_handshake(sssl)))
return 0;
/* Start handshake on the server and client */
if (!TEST_int_eq(SSL_do_handshake(sssl), 1)
|| !TEST_int_le(SSL_read(cssl, NULL, 0), 0)
|| !TEST_int_le(SSL_read(sssl, NULL, 0), 0)
|| !TEST_true(create_ssl_connection(sssl, cssl,
SSL_ERROR_NONE)))
return 0;
return 1;
}
static int setup_ticket_test(int stateful, int idx, SSL_CTX **sctx,
SSL_CTX **cctx)
{
int sess_id_ctx = 1;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
sctx, cctx, cert, privkey))
|| !TEST_true(SSL_CTX_set_num_tickets(*sctx, idx))
|| !TEST_true(SSL_CTX_set_session_id_context(*sctx,
(void *)&sess_id_ctx,
sizeof(sess_id_ctx))))
return 0;
if (stateful)
SSL_CTX_set_options(*sctx, SSL_OP_NO_TICKET);
SSL_CTX_set_session_cache_mode(*cctx, SSL_SESS_CACHE_CLIENT
| SSL_SESS_CACHE_NO_INTERNAL_STORE);
SSL_CTX_sess_set_new_cb(*cctx, new_cachesession_cb);
return 1;
}
static int check_resumption(int idx, SSL_CTX *sctx, SSL_CTX *cctx, int succ)
{
SSL *serverssl = NULL, *clientssl = NULL;
int i;
/* Test that we can resume with all the tickets we got given */
for (i = 0; i < idx * 2; i++) {
new_called = 0;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, sesscache[i])))
goto end;
SSL_set_post_handshake_auth(clientssl, 1);
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
/*
* Following a successful resumption we only get 1 ticket. After a
* failed one we should get idx tickets.
*/
if (succ) {
if (!TEST_true(SSL_session_reused(clientssl))
|| !TEST_int_eq(new_called, 1))
goto end;
} else {
if (!TEST_false(SSL_session_reused(clientssl))
|| !TEST_int_eq(new_called, idx))
goto end;
}
new_called = 0;
/* After a post-handshake authentication we should get 1 new ticket */
if (succ
&& (!post_handshake_verify(serverssl, clientssl)
|| !TEST_int_eq(new_called, 1)))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
SSL_SESSION_free(sesscache[i]);
sesscache[i] = NULL;
}
return 1;
end:
SSL_free(clientssl);
SSL_free(serverssl);
return 0;
}
static int test_tickets(int stateful, int idx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
int testresult = 0;
size_t j;
/* idx is the test number, but also the number of tickets we want */
new_called = 0;
do_cache = 1;
if (!setup_ticket_test(stateful, idx, &sctx, &cctx))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
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, new_called))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
clientssl = serverssl = NULL;
sctx = cctx = NULL;
/*
* Now we try to resume with the tickets we previously created. The
* resumption attempt is expected to fail (because we're now using a new
* SSL_CTX). We should see idx number of tickets issued again.
*/
/* Stop caching sessions - just count them */
do_cache = 0;
if (!setup_ticket_test(stateful, idx, &sctx, &cctx))
goto end;
if (!check_resumption(idx, sctx, cctx, 0))
goto end;
/* Start again with caching sessions */
new_called = 0;
do_cache = 1;
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
sctx = cctx = NULL;
if (!setup_ticket_test(stateful, idx, &sctx, &cctx))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
SSL_set_post_handshake_auth(clientssl, 1);
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, new_called))
goto end;
/* After a post-handshake authentication we should get new tickets issued */
if (!post_handshake_verify(serverssl, clientssl)
|| !TEST_int_eq(idx * 2, new_called))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
/* Stop caching sessions - just count them */
do_cache = 0;
/*
* Check we can resume with all the tickets we created. This time around the
* resumptions should all be successful.
*/
if (!check_resumption(idx, sctx, cctx, 1))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
for (j = 0; j < OSSL_NELEM(sesscache); j++) {
SSL_SESSION_free(sesscache[j]);
sesscache[j] = NULL;
}
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
static int test_stateless_tickets(int idx)
{
return test_tickets(0, idx);
}
static int test_stateful_tickets(int idx)
{
return test_tickets(1, idx);
}
static int test_psk_tickets(void)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
int testresult = 0;
int sess_id_ctx = 1;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, NULL, NULL))
|| !TEST_true(SSL_CTX_set_session_id_context(sctx,
(void *)&sess_id_ctx,
sizeof(sess_id_ctx))))
goto end;
SSL_CTX_set_session_cache_mode(cctx, SSL_SESS_CACHE_CLIENT
| SSL_SESS_CACHE_NO_INTERNAL_STORE);
SSL_CTX_set_psk_use_session_callback(cctx, use_session_cb);
SSL_CTX_set_psk_find_session_callback(sctx, find_session_cb);
SSL_CTX_sess_set_new_cb(cctx, new_session_cb);
use_session_cb_cnt = 0;
find_session_cb_cnt = 0;
srvid = pskid;
new_called = 0;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
clientpsk = serverpsk = create_a_psk(clientssl, SHA384_DIGEST_LENGTH);
if (!TEST_ptr(clientpsk))
goto end;
SSL_SESSION_up_ref(clientpsk);
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_int_eq(1, find_session_cb_cnt)
|| !TEST_int_eq(1, use_session_cb_cnt)
/* We should always get 1 ticket when using external PSK */
|| !TEST_int_eq(1, new_called))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
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;
/* Once more, but with SSL_do_handshake() to drive the ticket generation */
c = '4';
new_called = 0;
if (!TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_true(SSL_do_handshake(serverssl))
|| !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 = '5';
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
* even if we explicitly try to hit the state machine.
*/
if (!TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_true(SSL_new_session_ticket(serverssl))
|| !TEST_int_eq(0, new_called)
|| !TEST_true(SSL_do_handshake(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;
/* Even trying to hit the state machine now will still not send tickets */
if (!TEST_true(SSL_do_handshake(serverssl))
|| !TEST_int_eq(0, new_called))
goto end;
/* Now the *next* write should send the tickets */
c = '6';
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
#define USE_BIO_1 1
#define USE_BIO_2 2
#define USE_DEFAULT 3
#define CONNTYPE_CONNECTION_SUCCESS 0
#define CONNTYPE_CONNECTION_FAIL 1
#define CONNTYPE_NO_CONNECTION 2
#define TOTAL_NO_CONN_SSL_SET_BIO_TESTS (3 * 3 * 3 * 3)
#define TOTAL_CONN_SUCCESS_SSL_SET_BIO_TESTS (2 * 2)
#if !defined(OSSL_NO_USABLE_TLS1_3) && !defined(OPENSSL_NO_TLS1_2)
# define TOTAL_CONN_FAIL_SSL_SET_BIO_TESTS (2 * 2)
#else
# define TOTAL_CONN_FAIL_SSL_SET_BIO_TESTS 0
#endif
#define TOTAL_SSL_SET_BIO_TESTS TOTAL_NO_CONN_SSL_SET_BIO_TESTS \
+ TOTAL_CONN_SUCCESS_SSL_SET_BIO_TESTS \
+ TOTAL_CONN_FAIL_SSL_SET_BIO_TESTS
static void setupbio(BIO **res, BIO *bio1, BIO *bio2, int type)
{
switch (type) {
case USE_NULL:
*res = NULL;
break;
case USE_BIO_1:
*res = bio1;
break;
case USE_BIO_2:
*res = bio2;
break;
}
}
/*
* Tests calls to SSL_set_bio() under various conditions.
*
* For the first 3 * 3 * 3 * 3 = 81 tests we do 2 calls to SSL_set_bio() with
* various combinations of valid BIOs or NULL being set for the rbio/wbio. We
* then do more tests where we create a successful connection first using our
* standard connection setup functions, and then call SSL_set_bio() with
* various combinations of valid BIOs or NULL. We then repeat these tests
* following a failed connection. In this last case we are looking to check that
* SSL_set_bio() functions correctly in the case where s->bbio is not NULL.
*/
static int test_ssl_set_bio(int idx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
BIO *bio1 = NULL;
BIO *bio2 = NULL;
BIO *irbio = NULL, *iwbio = NULL, *nrbio = NULL, *nwbio = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
int initrbio, initwbio, newrbio, newwbio, conntype;
int testresult = 0;
if (idx < TOTAL_NO_CONN_SSL_SET_BIO_TESTS) {
initrbio = idx % 3;
idx /= 3;
initwbio = idx % 3;
idx /= 3;
newrbio = idx % 3;
idx /= 3;
newwbio = idx % 3;
conntype = CONNTYPE_NO_CONNECTION;
} else {
idx -= TOTAL_NO_CONN_SSL_SET_BIO_TESTS;
initrbio = initwbio = USE_DEFAULT;
newrbio = idx % 2;
idx /= 2;
newwbio = idx % 2;
idx /= 2;
conntype = idx % 2;
}
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
if (conntype == CONNTYPE_CONNECTION_FAIL) {
/*
* We won't ever get here if either TLSv1.3 or TLSv1.2 is disabled
* because we reduced the number of tests in the definition of
* TOTAL_CONN_FAIL_SSL_SET_BIO_TESTS to avoid this scenario. By setting
* mismatched protocol versions we will force a connection failure.
*/
SSL_CTX_set_min_proto_version(sctx, TLS1_3_VERSION);
SSL_CTX_set_max_proto_version(cctx, TLS1_2_VERSION);
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (initrbio == USE_BIO_1
|| initwbio == USE_BIO_1
|| newrbio == USE_BIO_1
|| newwbio == USE_BIO_1) {
if (!TEST_ptr(bio1 = BIO_new(BIO_s_mem())))
goto end;
}
if (initrbio == USE_BIO_2
|| initwbio == USE_BIO_2
|| newrbio == USE_BIO_2
|| newwbio == USE_BIO_2) {
if (!TEST_ptr(bio2 = BIO_new(BIO_s_mem())))
goto end;
}
if (initrbio != USE_DEFAULT) {
setupbio(&irbio, bio1, bio2, initrbio);
setupbio(&iwbio, bio1, bio2, initwbio);
SSL_set_bio(clientssl, irbio, iwbio);
/*
* We want to maintain our own refs to these BIO, so do an up ref for
* each BIO that will have ownership transferred in the SSL_set_bio()
* call
*/
if (irbio != NULL)
BIO_up_ref(irbio);
if (iwbio != NULL && iwbio != irbio)
BIO_up_ref(iwbio);
}
if (conntype != CONNTYPE_NO_CONNECTION
&& !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)
== (conntype == CONNTYPE_CONNECTION_SUCCESS)))
goto end;
setupbio(&nrbio, bio1, bio2, newrbio);
setupbio(&nwbio, bio1, bio2, newwbio);
/*
* We will (maybe) transfer ownership again so do more up refs.
* SSL_set_bio() has some really complicated ownership rules where BIOs have
* already been set!
*/
if (nrbio != NULL
&& nrbio != irbio
&& (nwbio != iwbio || nrbio != nwbio))
BIO_up_ref(nrbio);
if (nwbio != NULL
&& nwbio != nrbio
&& (nwbio != iwbio || (nwbio == iwbio && irbio == iwbio)))
BIO_up_ref(nwbio);
SSL_set_bio(clientssl, nrbio, nwbio);
testresult = 1;
end:
BIO_free(bio1);
BIO_free(bio2);
/*
* This test is checking that the ref counting for SSL_set_bio is correct.
* If we get here and we did too many frees then we will fail in the above
* functions.
*/
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
typedef enum { NO_BIO_CHANGE, CHANGE_RBIO, CHANGE_WBIO } bio_change_t;
static int execute_test_ssl_bio(int pop_ssl, bio_change_t change_bio)
{
BIO *sslbio = NULL, *membio1 = NULL, *membio2 = NULL;
SSL_CTX *ctx;
SSL *ssl = NULL;
int testresult = 0;
if (!TEST_ptr(ctx = SSL_CTX_new_ex(libctx, NULL, TLS_method()))
|| !TEST_ptr(ssl = SSL_new(ctx))
|| !TEST_ptr(sslbio = BIO_new(BIO_f_ssl()))
|| !TEST_ptr(membio1 = BIO_new(BIO_s_mem())))
goto end;
BIO_set_ssl(sslbio, ssl, BIO_CLOSE);
/*
* If anything goes wrong here then we could leak memory.
*/
BIO_push(sslbio, membio1);
/* Verify changing the rbio/wbio directly does not cause leaks */
if (change_bio != NO_BIO_CHANGE) {
if (!TEST_ptr(membio2 = BIO_new(BIO_s_mem()))) {
ssl = NULL;
goto end;
}
if (change_bio == CHANGE_RBIO)
SSL_set0_rbio(ssl, membio2);
else
SSL_set0_wbio(ssl, membio2);
}
ssl = NULL;
if (pop_ssl)
BIO_pop(sslbio);
else
BIO_pop(membio1);
testresult = 1;
end:
BIO_free(membio1);
BIO_free(sslbio);
SSL_free(ssl);
SSL_CTX_free(ctx);
return testresult;
}
static int test_ssl_bio_pop_next_bio(void)
{
return execute_test_ssl_bio(0, NO_BIO_CHANGE);
}
static int test_ssl_bio_pop_ssl_bio(void)
{
return execute_test_ssl_bio(1, NO_BIO_CHANGE);
}
static int test_ssl_bio_change_rbio(void)
{
return execute_test_ssl_bio(0, CHANGE_RBIO);
}
static int test_ssl_bio_change_wbio(void)
{
return execute_test_ssl_bio(0, CHANGE_WBIO);
}
#if !defined(OPENSSL_NO_TLS1_2) || defined(OSSL_NO_USABLE_TLS1_3)
typedef struct {
/* The list of sig algs */
const int *list;
/* The length of the list */
size_t listlen;
/* A sigalgs list in string format */
const char *liststr;
/* Whether setting the list should succeed */
int valid;
/* Whether creating a connection with the list should succeed */
int connsuccess;
} sigalgs_list;
static const int validlist1[] = {NID_sha256, EVP_PKEY_RSA};
# ifndef OPENSSL_NO_EC
static const int validlist2[] = {NID_sha256, EVP_PKEY_RSA, NID_sha512, EVP_PKEY_EC};
static const int validlist3[] = {NID_sha512, EVP_PKEY_EC};
# endif
static const int invalidlist1[] = {NID_undef, EVP_PKEY_RSA};
static const int invalidlist2[] = {NID_sha256, NID_undef};
static const int invalidlist3[] = {NID_sha256, EVP_PKEY_RSA, NID_sha256};
static const int invalidlist4[] = {NID_sha256};
static const sigalgs_list testsigalgs[] = {
{validlist1, OSSL_NELEM(validlist1), NULL, 1, 1},
# ifndef OPENSSL_NO_EC
{validlist2, OSSL_NELEM(validlist2), NULL, 1, 1},
{validlist3, OSSL_NELEM(validlist3), NULL, 1, 0},
# endif
{NULL, 0, "RSA+SHA256", 1, 1},
# ifndef OPENSSL_NO_EC
{NULL, 0, "RSA+SHA256:ECDSA+SHA512", 1, 1},
{NULL, 0, "ECDSA+SHA512", 1, 0},
# endif
{invalidlist1, OSSL_NELEM(invalidlist1), NULL, 0, 0},
{invalidlist2, OSSL_NELEM(invalidlist2), NULL, 0, 0},
{invalidlist3, OSSL_NELEM(invalidlist3), NULL, 0, 0},
{invalidlist4, OSSL_NELEM(invalidlist4), NULL, 0, 0},
{NULL, 0, "RSA", 0, 0},
{NULL, 0, "SHA256", 0, 0},
{NULL, 0, "RSA+SHA256:SHA256", 0, 0},
{NULL, 0, "Invalid", 0, 0}
};
static int test_set_sigalgs(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
const sigalgs_list *curr;
int testctx;
/* Should never happen */
if (!TEST_size_t_le((size_t)idx, OSSL_NELEM(testsigalgs) * 2))
return 0;
testctx = ((size_t)idx < OSSL_NELEM(testsigalgs));
curr = testctx ? &testsigalgs[idx]
: &testsigalgs[idx - OSSL_NELEM(testsigalgs)];
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
return 0;
SSL_CTX_set_max_proto_version(cctx, TLS1_2_VERSION);
if (testctx) {
int ret;
if (curr->list != NULL)
ret = SSL_CTX_set1_sigalgs(cctx, curr->list, curr->listlen);
else
ret = SSL_CTX_set1_sigalgs_list(cctx, curr->liststr);
if (!ret) {
if (curr->valid)
TEST_info("Failure setting sigalgs in SSL_CTX (%d)\n", idx);
else
testresult = 1;
goto end;
}
if (!curr->valid) {
TEST_info("Not-failed setting sigalgs in SSL_CTX (%d)\n", idx);
goto end;
}
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if (!testctx) {
int ret;
if (curr->list != NULL)
ret = SSL_set1_sigalgs(clientssl, curr->list, curr->listlen);
else
ret = SSL_set1_sigalgs_list(clientssl, curr->liststr);
if (!ret) {
if (curr->valid)
TEST_info("Failure setting sigalgs in SSL (%d)\n", idx);
else
testresult = 1;
goto end;
}
if (!curr->valid)
goto end;
}
if (!TEST_int_eq(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE),
curr->connsuccess))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif
#ifndef OSSL_NO_USABLE_TLS1_3
static int psk_client_cb_cnt = 0;
static int psk_server_cb_cnt = 0;
static int use_session_cb(SSL *ssl, const EVP_MD *md, const unsigned char **id,
size_t *idlen, SSL_SESSION **sess)
{
switch (++use_session_cb_cnt) {
case 1:
/* The first call should always have a NULL md */
if (md != NULL)
return 0;
break;
case 2:
/* The second call should always have an md */
if (md == NULL)
return 0;
break;
default:
/* We should only be called a maximum of twice */
return 0;
}
if (clientpsk != NULL)
SSL_SESSION_up_ref(clientpsk);
*sess = clientpsk;
*id = (const unsigned char *)pskid;
*idlen = strlen(pskid);
return 1;
}
#ifndef OPENSSL_NO_PSK
static unsigned int psk_client_cb(SSL *ssl, const char *hint, char *id,
unsigned int max_id_len,
unsigned char *psk,
unsigned int max_psk_len)
{
unsigned int psklen = 0;
psk_client_cb_cnt++;
if (strlen(pskid) + 1 > max_id_len)
return 0;
/* We should only ever be called a maximum of twice per connection */
if (psk_client_cb_cnt > 2)
return 0;
if (clientpsk == NULL)
return 0;
/* We'll reuse the PSK we set up for TLSv1.3 */
if (SSL_SESSION_get_master_key(clientpsk, NULL, 0) > max_psk_len)
return 0;
psklen = SSL_SESSION_get_master_key(clientpsk, psk, max_psk_len);
strncpy(id, pskid, max_id_len);
return psklen;
}
#endif /* OPENSSL_NO_PSK */
static int find_session_cb(SSL *ssl, const unsigned char *identity,
size_t identity_len, SSL_SESSION **sess)
{
find_session_cb_cnt++;
/* We should only ever be called a maximum of twice per connection */
if (find_session_cb_cnt > 2)
return 0;
if (serverpsk == NULL)
return 0;
/* Identity should match that set by the client */
if (strlen(srvid) != identity_len
|| strncmp(srvid, (const char *)identity, identity_len) != 0) {
/* No PSK found, continue but without a PSK */
*sess = NULL;
return 1;
}
SSL_SESSION_up_ref(serverpsk);
*sess = serverpsk;
return 1;
}
#ifndef OPENSSL_NO_PSK
static unsigned int psk_server_cb(SSL *ssl, const char *identity,
unsigned char *psk, unsigned int max_psk_len)
{
unsigned int psklen = 0;
psk_server_cb_cnt++;
/* We should only ever be called a maximum of twice per connection */
if (find_session_cb_cnt > 2)
return 0;
if (serverpsk == NULL)
return 0;
/* Identity should match that set by the client */
if (strcmp(srvid, identity) != 0) {
return 0;
}
/* We'll reuse the PSK we set up for TLSv1.3 */
if (SSL_SESSION_get_master_key(serverpsk, NULL, 0) > max_psk_len)
return 0;
psklen = SSL_SESSION_get_master_key(serverpsk, psk, max_psk_len);
return psklen;
}
#endif /* OPENSSL_NO_PSK */
#define MSG1 "Hello"
#define MSG2 "World."
#define MSG3 "This"
#define MSG4 "is"
#define MSG5 "a"
#define MSG6 "test"
#define MSG7 "message."
static int artificial_ticket_time = 0;
static int ed_gen_cb(SSL *s, void *arg)
{
SSL_SESSION *sess = SSL_get0_session(s);
if (sess == NULL)
return 0;
/*
* Artificially give the ticket some age. Just do it for the number of
* tickets we've been told to do.
*/
if (artificial_ticket_time == 0)
return 1;
artificial_ticket_time--;
if (SSL_SESSION_set_time(sess, SSL_SESSION_get_time(sess) - 10) == 0)
return 0;
return 1;
}
/*
* Helper method to setup objects for early data test. Caller frees objects on
* error.
*/
static int setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl,
SSL **serverssl, SSL_SESSION **sess, int idx,
size_t mdsize)
{
int artificial = (artificial_ticket_time > 0);
if (*sctx == NULL
&& !TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, 0,
sctx, cctx, cert, privkey)))
return 0;
if (artificial)
SSL_CTX_set_session_ticket_cb(*sctx, ed_gen_cb, NULL, NULL);
if (!TEST_true(SSL_CTX_set_max_early_data(*sctx, SSL3_RT_MAX_PLAIN_LENGTH)))
return 0;
if (idx == 1) {
/* When idx == 1 we repeat the tests with read_ahead set */
SSL_CTX_set_read_ahead(*cctx, 1);
SSL_CTX_set_read_ahead(*sctx, 1);
} else if (idx == 2) {
/* When idx == 2 we are doing early_data with a PSK. Set up callbacks */
SSL_CTX_set_psk_use_session_callback(*cctx, use_session_cb);
SSL_CTX_set_psk_find_session_callback(*sctx, find_session_cb);
use_session_cb_cnt = 0;
find_session_cb_cnt = 0;
srvid = pskid;
}
if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl, clientssl,
NULL, NULL)))
return 0;
/*
* For one of the run throughs (doesn't matter which one), we'll try sending
* some SNI data in the initial ClientHello. This will be ignored (because
* there is no SNI cb set up by the server), so it should not impact
* early_data.
*/
if (idx == 1
&& !TEST_true(SSL_set_tlsext_host_name(*clientssl, "localhost")))
return 0;
if (idx == 2) {
clientpsk = create_a_psk(*clientssl, mdsize);
if (!TEST_ptr(clientpsk)
/*
* We just choose an arbitrary value for max_early_data which
* should be big enough for testing purposes.
*/
|| !TEST_true(SSL_SESSION_set_max_early_data(clientpsk,
0x100))
|| !TEST_true(SSL_SESSION_up_ref(clientpsk))) {
SSL_SESSION_free(clientpsk);
clientpsk = NULL;
return 0;
}
serverpsk = clientpsk;
if (sess != NULL) {
if (!TEST_true(SSL_SESSION_up_ref(clientpsk))) {
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
return 0;
}
*sess = clientpsk;
}
return 1;
}
if (sess == NULL)
return 1;
if (!TEST_true(create_ssl_connection(*serverssl, *clientssl,
SSL_ERROR_NONE)))
return 0;
*sess = SSL_get1_session(*clientssl);
SSL_shutdown(*clientssl);
SSL_shutdown(*serverssl);
SSL_free(*serverssl);
SSL_free(*clientssl);
*serverssl = *clientssl = NULL;
/*
* Artificially give the ticket some age to match the artificial age we
* gave it on the server side
*/
if (artificial
&& !TEST_long_gt(SSL_SESSION_set_time(*sess,
SSL_SESSION_get_time(*sess) - 10), 0))
return 0;
if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl,
clientssl, NULL, NULL))
|| !TEST_true(SSL_set_session(*clientssl, *sess)))
return 0;
return 1;
}
static int test_early_data_read_write(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
SSL_SESSION *sess = NULL;
unsigned char buf[20], data[1024];
size_t readbytes, written, eoedlen, rawread, rawwritten;
BIO *rbio;
/* Artificially give the next 2 tickets some age for non PSK sessions */
if (idx != 2)
artificial_ticket_time = 2;
if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
&serverssl, &sess, idx,
SHA384_DIGEST_LENGTH))) {
artificial_ticket_time = 0;
goto end;
}
artificial_ticket_time = 0;
/* Write and read some early data */
if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
&written))
|| !TEST_size_t_eq(written, strlen(MSG1))
|| !TEST_int_eq(SSL_read_early_data(serverssl, buf,
sizeof(buf), &readbytes),
SSL_READ_EARLY_DATA_SUCCESS)
|| !TEST_mem_eq(MSG1, readbytes, buf, strlen(MSG1))
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_ACCEPTED))
goto end;
/*
* Server should be able to write data, and client should be able to
* read it.
*/
if (!TEST_true(SSL_write_early_data(serverssl, MSG2, strlen(MSG2),
&written))
|| !TEST_size_t_eq(written, strlen(MSG2))
|| !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes))
|| !TEST_mem_eq(buf, readbytes, MSG2, strlen(MSG2)))
goto end;
/* Even after reading normal data, client should be able write early data */
if (!TEST_true(SSL_write_early_data(clientssl, MSG3, strlen(MSG3),
&written))
|| !TEST_size_t_eq(written, strlen(MSG3)))
goto end;
/* Server should still be able read early data after writing data */
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_SUCCESS)
|| !TEST_mem_eq(buf, readbytes, MSG3, strlen(MSG3)))
goto end;
/* Write more data from server and read it from client */
if (!TEST_true(SSL_write_early_data(serverssl, MSG4, strlen(MSG4),
&written))
|| !TEST_size_t_eq(written, strlen(MSG4))
|| !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes))
|| !TEST_mem_eq(buf, readbytes, MSG4, strlen(MSG4)))
goto end;
/*
* If client writes normal data it should mean writing early data is no
* longer possible.
*/
if (!TEST_true(SSL_write_ex(clientssl, MSG5, strlen(MSG5), &written))
|| !TEST_size_t_eq(written, strlen(MSG5))
|| !TEST_int_eq(SSL_get_early_data_status(clientssl),
SSL_EARLY_DATA_ACCEPTED))
goto end;
/*
* At this point the client has written EndOfEarlyData, ClientFinished and
* normal (fully protected) data. We are going to cause a delay between the
* arrival of EndOfEarlyData and ClientFinished. We read out all the data
* in the read BIO, and then just put back the EndOfEarlyData message.
*/
rbio = SSL_get_rbio(serverssl);
if (!TEST_true(BIO_read_ex(rbio, data, sizeof(data), &rawread))
|| !TEST_size_t_lt(rawread, sizeof(data))
|| !TEST_size_t_gt(rawread, SSL3_RT_HEADER_LENGTH))
goto end;
/* Record length is in the 4th and 5th bytes of the record header */
eoedlen = SSL3_RT_HEADER_LENGTH + (data[3] << 8 | data[4]);
if (!TEST_true(BIO_write_ex(rbio, data, eoedlen, &rawwritten))
|| !TEST_size_t_eq(rawwritten, eoedlen))
goto end;
/* Server should be told that there is no more early data */
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_FINISH)
|| !TEST_size_t_eq(readbytes, 0))
goto end;
/*
* Server has not finished init yet, so should still be able to write early
* data.
*/
if (!TEST_true(SSL_write_early_data(serverssl, MSG6, strlen(MSG6),
&written))
|| !TEST_size_t_eq(written, strlen(MSG6)))
goto end;
/* Push the ClientFinished and the normal data back into the server rbio */
if (!TEST_true(BIO_write_ex(rbio, data + eoedlen, rawread - eoedlen,
&rawwritten))
|| !TEST_size_t_eq(rawwritten, rawread - eoedlen))
goto end;
/* Server should be able to read normal data */
if (!TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))
|| !TEST_size_t_eq(readbytes, strlen(MSG5)))
goto end;
/* Client and server should not be able to write/read early data now */
if (!TEST_false(SSL_write_early_data(clientssl, MSG6, strlen(MSG6),
&written)))
goto end;
ERR_clear_error();
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_ERROR))
goto end;
ERR_clear_error();
/* Client should be able to read the data sent by the server */
if (!TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes))
|| !TEST_mem_eq(buf, readbytes, MSG6, strlen(MSG6)))
goto end;
/*
* Make sure we process the two NewSessionTickets. These arrive
* post-handshake. We attempt reads which we do not expect to return any
* data.
*/
if (!TEST_false(SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes))
|| !TEST_false(SSL_read_ex(clientssl, buf, sizeof(buf),
&readbytes)))
goto end;
/* Server should be able to write normal data */
if (!TEST_true(SSL_write_ex(serverssl, MSG7, strlen(MSG7), &written))
|| !TEST_size_t_eq(written, strlen(MSG7))
|| !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes))
|| !TEST_mem_eq(buf, readbytes, MSG7, strlen(MSG7)))
goto end;
SSL_SESSION_free(sess);
sess = SSL_get1_session(clientssl);
use_session_cb_cnt = 0;
find_session_cb_cnt = 0;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, sess)))
goto end;
/* Write and read some early data */
if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
&written))
|| !TEST_size_t_eq(written, strlen(MSG1))
|| !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)))
goto end;
if (!TEST_int_gt(SSL_connect(clientssl), 0)
|| !TEST_int_gt(SSL_accept(serverssl), 0))
goto end;
/* Client and server should not be able to write/read early data now */
if (!TEST_false(SSL_write_early_data(clientssl, MSG6, strlen(MSG6),
&written)))
goto end;
ERR_clear_error();
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_ERROR))
goto end;
ERR_clear_error();
/* Client and server should be able to write/read normal data */
if (!TEST_true(SSL_write_ex(clientssl, MSG5, strlen(MSG5), &written))
|| !TEST_size_t_eq(written, strlen(MSG5))
|| !TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))
|| !TEST_size_t_eq(readbytes, strlen(MSG5)))
goto end;
testresult = 1;
end:
SSL_SESSION_free(sess);
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
static int allow_ed_cb_called = 0;
static int allow_early_data_cb(SSL *s, void *arg)
{
int *usecb = (int *)arg;
allow_ed_cb_called++;
if (*usecb == 1)
return 0;
return 1;
}
/*
* idx == 0: Standard early_data setup
* idx == 1: early_data setup using read_ahead
* usecb == 0: Don't use a custom early data callback
* usecb == 1: Use a custom early data callback and reject the early data
* usecb == 2: Use a custom early data callback and accept the early data
* confopt == 0: Configure anti-replay directly
* confopt == 1: Configure anti-replay using SSL_CONF
*/
static int test_early_data_replay_int(int idx, int usecb, int confopt)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
SSL_SESSION *sess = NULL;
size_t readbytes, written;
unsigned char buf[20];
allow_ed_cb_called = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
return 0;
if (usecb > 0) {
if (confopt == 0) {
SSL_CTX_set_options(sctx, SSL_OP_NO_ANTI_REPLAY);
} else {
SSL_CONF_CTX *confctx = SSL_CONF_CTX_new();
if (!TEST_ptr(confctx))
goto end;
SSL_CONF_CTX_set_flags(confctx, SSL_CONF_FLAG_FILE
| SSL_CONF_FLAG_SERVER);
SSL_CONF_CTX_set_ssl_ctx(confctx, sctx);
if (!TEST_int_eq(SSL_CONF_cmd(confctx, "Options", "-AntiReplay"),
2)) {
SSL_CONF_CTX_free(confctx);
goto end;
}
SSL_CONF_CTX_free(confctx);
}
SSL_CTX_set_allow_early_data_cb(sctx, allow_early_data_cb, &usecb);
}
if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
&serverssl, &sess, idx,
SHA384_DIGEST_LENGTH)))
goto end;
/*
* The server is configured to accept early data. Create a connection to
* "use up" the ticket
*/
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl)))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, sess)))
goto end;
/* Write and read some early data */
if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
&written))
|| !TEST_size_t_eq(written, strlen(MSG1)))
goto end;
if (usecb <= 1) {
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_FINISH)
/*
* The ticket was reused, so the we should have rejected the
* early data
*/
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_REJECTED))
goto end;
} else {
/* In this case the callback decides to accept the early data */
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_SUCCESS)
|| !TEST_mem_eq(MSG1, strlen(MSG1), buf, readbytes)
/*
* Server will have sent its flight so client can now send
* end of early data and complete its half of the handshake
*/
|| !TEST_int_gt(SSL_connect(clientssl), 0)
|| !TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_FINISH)
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_ACCEPTED))
goto end;
}
/* Complete the connection */
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
|| !TEST_int_eq(SSL_session_reused(clientssl), (usecb > 0) ? 1 : 0)
|| !TEST_int_eq(allow_ed_cb_called, usecb > 0 ? 1 : 0))
goto end;
testresult = 1;
end:
SSL_SESSION_free(sess);
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
static int test_early_data_replay(int idx)
{
int ret = 1, usecb, confopt;
for (usecb = 0; usecb < 3; usecb++) {
for (confopt = 0; confopt < 2; confopt++)
ret &= test_early_data_replay_int(idx, usecb, confopt);
}
return ret;
}
static const char *ciphersuites[] = {
"TLS_AES_128_CCM_8_SHA256",
"TLS_AES_128_GCM_SHA256",
"TLS_AES_256_GCM_SHA384",
"TLS_AES_128_CCM_SHA256",
#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
"TLS_CHACHA20_POLY1305_SHA256"
#endif
};
/*
* Helper function to test that a server attempting to read early data can
* handle a connection from a client where the early data should be skipped.
* testtype: 0 == No HRR
* testtype: 1 == HRR
* testtype: 2 == HRR, invalid early_data sent after HRR
* testtype: 3 == recv_max_early_data set to 0
*/
static int early_data_skip_helper(int testtype, int cipher, 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;
if (is_fips && cipher == 4)
return 1;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
if (cipher == 0) {
SSL_CTX_set_security_level(sctx, 0);
SSL_CTX_set_security_level(cctx, 0);
}
if (!TEST_true(SSL_CTX_set_ciphersuites(sctx, ciphersuites[cipher]))
|| !TEST_true(SSL_CTX_set_ciphersuites(cctx, ciphersuites[cipher])))
goto end;
if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
&serverssl, &sess, idx,
cipher == 2 ? SHA384_DIGEST_LENGTH
: SHA256_DIGEST_LENGTH)))
goto end;
if (testtype == 1 || testtype == 2) {
/* Force an HRR to occur */
#if defined(OPENSSL_NO_EC)
if (!TEST_true(SSL_set1_groups_list(serverssl, "ffdhe3072")))
goto end;
#else
if (!TEST_true(SSL_set1_groups_list(serverssl, "P-384")))
goto end;
#endif
} else if (idx == 2) {
/*
* We force early_data rejection by ensuring the PSK identity is
* unrecognised
*/
srvid = "Dummy Identity";
} else {
/*
* Deliberately corrupt the creation time. We take 20 seconds off the
* time. It could be any value as long as it is not within tolerance.
* This should mean the ticket is rejected.
*/
if (!TEST_true(SSL_SESSION_set_time(sess, (long)(time(NULL) - 20))))
goto end;
}
if (testtype == 3
&& !TEST_true(SSL_set_recv_max_early_data(serverssl, 0)))
goto end;
/* Write some early data */
if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
&written))
|| !TEST_size_t_eq(written, strlen(MSG1)))
goto end;
/* Server should reject the early data */
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_FINISH)
|| !TEST_size_t_eq(readbytes, 0)
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_REJECTED))
goto end;
switch (testtype) {
case 0:
/* Nothing to do */
break;
case 1:
/*
* Finish off the handshake. We perform the same writes and reads as
* further down but we expect them to fail due to the incomplete
* handshake.
*/
if (!TEST_false(SSL_write_ex(clientssl, MSG2, strlen(MSG2), &written))
|| !TEST_false(SSL_read_ex(serverssl, buf, sizeof(buf),
&readbytes)))
goto end;
break;
case 2:
{
BIO *wbio = SSL_get_wbio(clientssl);
/* A record that will appear as bad early_data */
const unsigned char bad_early_data[] = {
0x17, 0x03, 0x03, 0x00, 0x01, 0x00
};
/*
* We force the client to attempt a write. This will fail because
* we're still in the handshake. It will cause the second
* ClientHello to be sent.
*/
if (!TEST_false(SSL_write_ex(clientssl, MSG2, strlen(MSG2),
&written)))
goto end;
/*
* Inject some early_data after the second ClientHello. This should
* cause the server to fail
*/
if (!TEST_true(BIO_write_ex(wbio, bad_early_data,
sizeof(bad_early_data), &written)))
goto end;
}
/* fallthrough */
case 3:
/*
* This client has sent more early_data than we are willing to skip
* (case 3) or sent invalid early_data (case 2) so the connection should
* abort.
*/
if (!TEST_false(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))
|| !TEST_int_eq(SSL_get_error(serverssl, 0), SSL_ERROR_SSL))
goto end;
/* Connection has failed - nothing more to do */
testresult = 1;
goto end;
default:
TEST_error("Invalid test type");
goto end;
}
ERR_clear_error();
/*
* Should be able to send normal data despite rejection of early data. The
* early_data should be skipped.
*/
if (!TEST_true(SSL_write_ex(clientssl, MSG2, strlen(MSG2), &written))
|| !TEST_size_t_eq(written, strlen(MSG2))
|| !TEST_int_eq(SSL_get_early_data_status(clientssl),
SSL_EARLY_DATA_REJECTED)
|| !TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))
|| !TEST_mem_eq(buf, readbytes, MSG2, strlen(MSG2)))
goto end;
/*
* Failure to decrypt early data records should not leave spurious errors
* on the error stack
*/
if (!TEST_long_eq(ERR_peek_error(), 0))
goto end;
testresult = 1;
end:
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
SSL_SESSION_free(sess);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test that a server attempting to read early data can handle a connection
* from a client where the early data is not acceptable.
*/
static int test_early_data_skip(int idx)
{
return early_data_skip_helper(0,
idx % OSSL_NELEM(ciphersuites),
idx / OSSL_NELEM(ciphersuites));
}
/*
* Test that a server attempting to read early data can handle a connection
* from a client where an HRR occurs.
*/
static int test_early_data_skip_hrr(int idx)
{
return early_data_skip_helper(1,
idx % OSSL_NELEM(ciphersuites),
idx / OSSL_NELEM(ciphersuites));
}
/*
* Test that a server attempting to read early data can handle a connection
* from a client where an HRR occurs and correctly fails if early_data is sent
* after the HRR
*/
static int test_early_data_skip_hrr_fail(int idx)
{
return early_data_skip_helper(2,
idx % OSSL_NELEM(ciphersuites),
idx / OSSL_NELEM(ciphersuites));
}
/*
* Test that a server attempting to read early data will abort if it tries to
* skip over too much.
*/
static int test_early_data_skip_abort(int idx)
{
return early_data_skip_helper(3,
idx % OSSL_NELEM(ciphersuites),
idx / OSSL_NELEM(ciphersuites));
}
/*
* Test that a server attempting to read early data can handle a connection
* from a client that doesn't send any.
*/
static int test_early_data_not_sent(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;
if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
&serverssl, &sess, idx,
SHA384_DIGEST_LENGTH)))
goto end;
/* Write some data - should block due to handshake with server */
SSL_set_connect_state(clientssl);
if (!TEST_false(SSL_write_ex(clientssl, MSG1, strlen(MSG1), &written)))
goto end;
/* Server should detect that early data has not been sent */
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_FINISH)
|| !TEST_size_t_eq(readbytes, 0)
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_NOT_SENT)
|| !TEST_int_eq(SSL_get_early_data_status(clientssl),
SSL_EARLY_DATA_NOT_SENT))
goto end;
/* Continue writing the message we started earlier */
if (!TEST_true(SSL_write_ex(clientssl, MSG1, strlen(MSG1), &written))
|| !TEST_size_t_eq(written, strlen(MSG1))
|| !TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))
|| !TEST_mem_eq(buf, readbytes, MSG1, strlen(MSG1))
|| !SSL_write_ex(serverssl, MSG2, strlen(MSG2), &written)
|| !TEST_size_t_eq(written, strlen(MSG2)))
goto end;
if (!TEST_true(SSL_read_ex(clientssl, 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;
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
static const char *servalpn;
static int alpn_select_cb(SSL *ssl, const unsigned char **out,
unsigned char *outlen, const unsigned char *in,
unsigned int inlen, void *arg)
{
unsigned int protlen = 0;
const unsigned char *prot;
for (prot = in; prot < in + inlen; prot += protlen) {
protlen = *prot++;
if (in + inlen < prot + protlen)
return SSL_TLSEXT_ERR_NOACK;
if (protlen == strlen(servalpn)
&& memcmp(prot, servalpn, protlen) == 0) {
*out = prot;
*outlen = protlen;
return SSL_TLSEXT_ERR_OK;
}
}
return SSL_TLSEXT_ERR_NOACK;
}
/* Test that a PSK can be used to send early_data */
static int test_early_data_psk(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
SSL_SESSION *sess = NULL;
unsigned char alpnlist[] = {
0x08, 'g', 'o', 'o', 'd', 'a', 'l', 'p', 'n', 0x07, 'b', 'a', 'd', 'a',
'l', 'p', 'n'
};
#define GOODALPNLEN 9
#define BADALPNLEN 8
#define GOODALPN (alpnlist)
#define BADALPN (alpnlist + GOODALPNLEN)
int err = 0;
unsigned char buf[20];
size_t readbytes, written;
int readearlyres = SSL_READ_EARLY_DATA_SUCCESS, connectres = 1;
int edstatus = SSL_EARLY_DATA_ACCEPTED;
/* 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,
SHA384_DIGEST_LENGTH)))
goto end;
servalpn = "goodalpn";
/*
* Note: There is no test for inconsistent SNI with late client detection.
* This is because servers do not acknowledge SNI even if they are using
* it in a resumption handshake - so it is not actually possible for a
* client to detect a problem.
*/
switch (idx) {
case 0:
/* Set inconsistent SNI (early client detection) */
err = SSL_R_INCONSISTENT_EARLY_DATA_SNI;
if (!TEST_true(SSL_SESSION_set1_hostname(sess, "goodhost"))
|| !TEST_true(SSL_set_tlsext_host_name(clientssl, "badhost")))
goto end;
break;
case 1:
/* Set inconsistent ALPN (early client detection) */
err = SSL_R_INCONSISTENT_EARLY_DATA_ALPN;
/* SSL_set_alpn_protos returns 0 for success and 1 for failure */
if (!TEST_true(SSL_SESSION_set1_alpn_selected(sess, GOODALPN,
GOODALPNLEN))
|| !TEST_false(SSL_set_alpn_protos(clientssl, BADALPN,
BADALPNLEN)))
goto end;
break;
case 2:
/*
* Set invalid protocol version. Technically this affects PSKs without
* early_data too, but we test it here because it is similar to the
* SNI/ALPN consistency tests.
*/
err = SSL_R_BAD_PSK;
if (!TEST_true(SSL_SESSION_set_protocol_version(sess, TLS1_2_VERSION)))
goto end;
break;
case 3:
/*
* Set inconsistent SNI (server side). In this case the connection
* will succeed and accept early_data. In TLSv1.3 on the server side SNI
* is associated with each handshake - not the session. Therefore it
* should not matter that we used a different server name last time.
*/
SSL_SESSION_free(serverpsk);
serverpsk = SSL_SESSION_dup(clientpsk);
if (!TEST_ptr(serverpsk)
|| !TEST_true(SSL_SESSION_set1_hostname(serverpsk, "badhost")))
goto end;
/* Fall through */
case 4:
/* Set consistent SNI */
if (!TEST_true(SSL_SESSION_set1_hostname(sess, "goodhost"))
|| !TEST_true(SSL_set_tlsext_host_name(clientssl, "goodhost"))
|| !TEST_true(SSL_CTX_set_tlsext_servername_callback(sctx,
hostname_cb)))
goto end;
break;
case 5:
/*
* Set inconsistent ALPN (server detected). In this case the connection
* will succeed but reject early_data.
*/
servalpn = "badalpn";
edstatus = SSL_EARLY_DATA_REJECTED;
readearlyres = SSL_READ_EARLY_DATA_FINISH;
/* Fall through */
case 6:
/*
* Set consistent ALPN.
* SSL_set_alpn_protos returns 0 for success and 1 for failure. It
* accepts a list of protos (each one length prefixed).
* SSL_set1_alpn_selected accepts a single protocol (not length
* prefixed)
*/
if (!TEST_true(SSL_SESSION_set1_alpn_selected(sess, GOODALPN + 1,
GOODALPNLEN - 1))
|| !TEST_false(SSL_set_alpn_protos(clientssl, GOODALPN,
GOODALPNLEN)))
goto end;
SSL_CTX_set_alpn_select_cb(sctx, alpn_select_cb, NULL);
break;
case 7:
/* Set inconsistent ALPN (late client detection) */
SSL_SESSION_free(serverpsk);
serverpsk = SSL_SESSION_dup(clientpsk);
if (!TEST_ptr(serverpsk)
|| !TEST_true(SSL_SESSION_set1_alpn_selected(clientpsk,
BADALPN + 1,
BADALPNLEN - 1))
|| !TEST_true(SSL_SESSION_set1_alpn_selected(serverpsk,
GOODALPN + 1,
GOODALPNLEN - 1))
|| !TEST_false(SSL_set_alpn_protos(clientssl, alpnlist,
sizeof(alpnlist))))
goto end;
SSL_CTX_set_alpn_select_cb(sctx, alpn_select_cb, NULL);
edstatus = SSL_EARLY_DATA_ACCEPTED;
readearlyres = SSL_READ_EARLY_DATA_SUCCESS;
/* SSL_connect() call should fail */
connectres = -1;
break;
default:
TEST_error("Bad test index");
goto end;
}
SSL_set_connect_state(clientssl);
if (err != 0) {
if (!TEST_false(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
&written))
|| !TEST_int_eq(SSL_get_error(clientssl, 0), SSL_ERROR_SSL)
|| !TEST_int_eq(ERR_GET_REASON(ERR_get_error()), err))
goto end;
} else {
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), readearlyres)
|| (readearlyres == SSL_READ_EARLY_DATA_SUCCESS
&& !TEST_mem_eq(buf, readbytes, MSG1, strlen(MSG1)))
|| !TEST_int_eq(SSL_get_early_data_status(serverssl), edstatus)
|| !TEST_int_eq(SSL_connect(clientssl), connectres))
goto end;
}
testresult = 1;
end:
SSL_SESSION_free(sess);
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
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,
SHA384_DIGEST_LENGTH)))
goto end;
if (idx == 4) {
/* CCM8 ciphers are considered low security due to their short tag */
SSL_set_security_level(clientssl, 0);
SSL_set_security_level(serverssl, 0);
}
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.
*/
static int test_early_data_not_expected(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;
if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
&serverssl, &sess, idx,
SHA384_DIGEST_LENGTH)))
goto end;
/* Write some early data */
if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
&written)))
goto end;
/*
* Server should skip over early data and then block waiting for client to
* continue handshake
*/
if (!TEST_int_le(SSL_accept(serverssl), 0)
|| !TEST_int_gt(SSL_connect(clientssl), 0)
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_REJECTED)
|| !TEST_int_gt(SSL_accept(serverssl), 0)
|| !TEST_int_eq(SSL_get_early_data_status(clientssl),
SSL_EARLY_DATA_REJECTED))
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;
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
# ifndef OPENSSL_NO_TLS1_2
/*
* Test that a server attempting to read early data can handle a connection
* from a TLSv1.2 client.
*/
static int test_early_data_tls1_2(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
unsigned char buf[20];
size_t readbytes, written;
if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
&serverssl, NULL, idx,
SHA384_DIGEST_LENGTH)))
goto end;
/* Write some data - should block due to handshake with server */
SSL_set_max_proto_version(clientssl, TLS1_2_VERSION);
SSL_set_connect_state(clientssl);
if (!TEST_false(SSL_write_ex(clientssl, MSG1, strlen(MSG1), &written)))
goto end;
/*
* Server should do TLSv1.2 handshake. First it will block waiting for more
* messages from client after ServerDone. Then SSL_read_early_data should
* finish and detect that early data has not been sent
*/
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_ERROR))
goto end;
/*
* Continue writing the message we started earlier. Will still block waiting
* for the CCS/Finished from server
*/
if (!TEST_false(SSL_write_ex(clientssl, MSG1, strlen(MSG1), &written))
|| !TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_FINISH)
|| !TEST_size_t_eq(readbytes, 0)
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_NOT_SENT))
goto end;
/* Continue writing the message we started earlier */
if (!TEST_true(SSL_write_ex(clientssl, MSG1, strlen(MSG1), &written))
|| !TEST_size_t_eq(written, strlen(MSG1))
|| !TEST_int_eq(SSL_get_early_data_status(clientssl),
SSL_EARLY_DATA_NOT_SENT)
|| !TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))
|| !TEST_mem_eq(buf, readbytes, MSG1, strlen(MSG1))
|| !TEST_true(SSL_write_ex(serverssl, MSG2, strlen(MSG2), &written))
|| !TEST_size_t_eq(written, strlen(MSG2))
|| !SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes)
|| !TEST_mem_eq(buf, readbytes, MSG2, strlen(MSG2)))
goto end;
testresult = 1;
end:
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
# endif /* OPENSSL_NO_TLS1_2 */
/*
* Test configuring the TLSv1.3 ciphersuites
*
* Test 0: Set a default ciphersuite in the SSL_CTX (no explicit cipher_list)
* Test 1: Set a non-default ciphersuite in the SSL_CTX (no explicit cipher_list)
* Test 2: Set a default ciphersuite in the SSL (no explicit cipher_list)
* Test 3: Set a non-default ciphersuite in the SSL (no explicit cipher_list)
* Test 4: Set a default ciphersuite in the SSL_CTX (SSL_CTX cipher_list)
* Test 5: Set a non-default ciphersuite in the SSL_CTX (SSL_CTX cipher_list)
* Test 6: Set a default ciphersuite in the SSL (SSL_CTX cipher_list)
* Test 7: Set a non-default ciphersuite in the SSL (SSL_CTX cipher_list)
* Test 8: Set a default ciphersuite in the SSL (SSL cipher_list)
* Test 9: Set a non-default ciphersuite in the SSL (SSL cipher_list)
*/
static int test_set_ciphersuite(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey))
|| !TEST_true(SSL_CTX_set_ciphersuites(sctx,
"TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256")))
goto end;
if (idx >=4 && idx <= 7) {
/* SSL_CTX explicit cipher list */
if (!TEST_true(SSL_CTX_set_cipher_list(cctx, "AES256-GCM-SHA384")))
goto end;
}
if (idx == 0 || idx == 4) {
/* Default ciphersuite */
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
"TLS_AES_128_GCM_SHA256")))
goto end;
} else if (idx == 1 || idx == 5) {
/* Non default ciphersuite */
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
"TLS_AES_128_CCM_SHA256")))
goto end;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if (idx == 8 || idx == 9) {
/* SSL explicit cipher list */
if (!TEST_true(SSL_set_cipher_list(clientssl, "AES256-GCM-SHA384")))
goto end;
}
if (idx == 2 || idx == 6 || idx == 8) {
/* Default ciphersuite */
if (!TEST_true(SSL_set_ciphersuites(clientssl,
"TLS_AES_128_GCM_SHA256")))
goto end;
} else if (idx == 3 || idx == 7 || idx == 9) {
/* Non default ciphersuite */
if (!TEST_true(SSL_set_ciphersuites(clientssl,
"TLS_AES_128_CCM_SHA256")))
goto end;
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
static int test_ciphersuite_change(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
SSL_SESSION *clntsess = NULL;
int testresult = 0;
const SSL_CIPHER *aes_128_gcm_sha256 = NULL;
/* Create a session based on SHA-256 */
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey))
|| !TEST_true(SSL_CTX_set_ciphersuites(sctx,
"TLS_AES_128_GCM_SHA256:"
"TLS_AES_256_GCM_SHA384:"
"TLS_AES_128_CCM_SHA256"))
|| !TEST_true(SSL_CTX_set_ciphersuites(cctx,
"TLS_AES_128_GCM_SHA256")))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
clntsess = SSL_get1_session(clientssl);
/* Save for later */
aes_128_gcm_sha256 = SSL_SESSION_get0_cipher(clntsess);
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
/* Check we can resume a session with a different SHA-256 ciphersuite */
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
"TLS_AES_128_CCM_SHA256"))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, clntsess))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl)))
goto end;
SSL_SESSION_free(clntsess);
clntsess = SSL_get1_session(clientssl);
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
/*
* Check attempting to resume a SHA-256 session with no SHA-256 ciphersuites
* succeeds but does not resume.
*/
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx, "TLS_AES_256_GCM_SHA384"))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, clntsess))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_SSL))
|| !TEST_false(SSL_session_reused(clientssl)))
goto end;
SSL_SESSION_free(clntsess);
clntsess = NULL;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
/* Create a session based on SHA384 */
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx, "TLS_AES_256_GCM_SHA384"))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
clntsess = SSL_get1_session(clientssl);
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
"TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384"))
|| !TEST_true(SSL_CTX_set_ciphersuites(sctx,
"TLS_AES_256_GCM_SHA384"))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, clntsess))
/*
* We use SSL_ERROR_WANT_READ below so that we can pause the
* connection after the initial ClientHello has been sent to
* enable us to make some session changes.
*/
|| !TEST_false(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_WANT_READ)))
goto end;
/* Trick the client into thinking this session is for a different digest */
clntsess->cipher = aes_128_gcm_sha256;
clntsess->cipher_id = clntsess->cipher->id;
/*
* Continue the previously started connection. Server has selected a SHA-384
* ciphersuite, but client thinks the session is for SHA-256, so it should
* bail out.
*/
if (!TEST_false(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_SSL))
|| !TEST_int_eq(ERR_GET_REASON(ERR_get_error()),
SSL_R_CIPHERSUITE_DIGEST_HAS_CHANGED))
goto end;
testresult = 1;
end:
SSL_SESSION_free(clntsess);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test TLSv1.3 Key exchange
* Test 0 = Test all ECDHE Key exchange with TLSv1.3 client and server
* Test 1 = Test NID_X9_62_prime256v1 with TLSv1.3 client and server
* Test 2 = Test NID_secp384r1 with TLSv1.3 client and server
* Test 3 = Test NID_secp521r1 with TLSv1.3 client and server
* Test 4 = Test NID_X25519 with TLSv1.3 client and server
* Test 5 = Test NID_X448 with TLSv1.3 client and server
* Test 6 = Test all FFDHE Key exchange with TLSv1.3 client and server
* Test 7 = Test NID_ffdhe2048 with TLSv1.3 client and server
* Test 8 = Test NID_ffdhe3072 with TLSv1.3 client and server
* Test 9 = Test NID_ffdhe4096 with TLSv1.3 client and server
* Test 10 = Test NID_ffdhe6144 with TLSv1.3 client and server
* Test 11 = Test NID_ffdhe8192 with TLSv1.3 client and server
* Test 12 = Test all ECDHE with TLSv1.2 client and server
* Test 13 = Test all FFDHE with TLSv1.2 client and server
*/
# ifndef OPENSSL_NO_EC
static int ecdhe_kexch_groups[] = {NID_X9_62_prime256v1, NID_secp384r1,
NID_secp521r1,
# ifndef OPENSSL_NO_ECX
NID_X25519, NID_X448
# endif
};
# endif
# ifndef OPENSSL_NO_DH
static int ffdhe_kexch_groups[] = {NID_ffdhe2048, NID_ffdhe3072, NID_ffdhe4096,
NID_ffdhe6144, NID_ffdhe8192};
# endif
static int test_key_exchange(int idx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
int testresult = 0;
int kexch_alg;
int *kexch_groups = &kexch_alg;
int kexch_groups_size = 1;
int max_version = TLS1_3_VERSION;
char *kexch_name0 = NULL;
switch (idx) {
# ifndef OPENSSL_NO_EC
# ifndef OPENSSL_NO_TLS1_2
case 12:
max_version = TLS1_2_VERSION;
# endif
/* Fall through */
case 0:
kexch_groups = ecdhe_kexch_groups;
kexch_groups_size = OSSL_NELEM(ecdhe_kexch_groups);
kexch_name0 = "secp256r1";
break;
case 1:
kexch_alg = NID_X9_62_prime256v1;
kexch_name0 = "secp256r1";
break;
case 2:
kexch_alg = NID_secp384r1;
kexch_name0 = "secp384r1";
break;
case 3:
kexch_alg = NID_secp521r1;
kexch_name0 = "secp521r1";
break;
# ifndef OPENSSL_NO_ECX
case 4:
kexch_alg = NID_X25519;
kexch_name0 = "x25519";
break;
case 5:
kexch_alg = NID_X448;
kexch_name0 = "x448";
break;
# endif
# endif
# ifndef OPENSSL_NO_DH
# ifndef OPENSSL_NO_TLS1_2
case 13:
max_version = TLS1_2_VERSION;
kexch_name0 = "ffdhe2048";
# endif
/* Fall through */
case 6:
kexch_groups = ffdhe_kexch_groups;
kexch_groups_size = OSSL_NELEM(ffdhe_kexch_groups);
kexch_name0 = "ffdhe2048";
break;
case 7:
kexch_alg = NID_ffdhe2048;
kexch_name0 = "ffdhe2048";
break;
case 8:
kexch_alg = NID_ffdhe3072;
kexch_name0 = "ffdhe3072";
break;
case 9:
kexch_alg = NID_ffdhe4096;
kexch_name0 = "ffdhe4096";
break;
case 10:
kexch_alg = NID_ffdhe6144;
kexch_name0 = "ffdhe6144";
break;
case 11:
kexch_alg = NID_ffdhe8192;
kexch_name0 = "ffdhe8192";
break;
# endif
default:
/* We're skipping this test */
return 1;
}
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION,
max_version, &sctx, &cctx, cert,
privkey)))
goto end;
if (!TEST_true(SSL_CTX_set_ciphersuites(sctx,
TLS1_3_RFC_AES_128_GCM_SHA256)))
goto end;
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
TLS1_3_RFC_AES_128_GCM_SHA256)))
goto end;
if (!TEST_true(SSL_CTX_set_cipher_list(sctx,
TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ":"
TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256))
|| !TEST_true(SSL_CTX_set_dh_auto(sctx, 1)))
goto end;
/*
* Must include an EC ciphersuite so that we send supported groups in
* TLSv1.2
*/
# ifndef OPENSSL_NO_TLS1_2
if (!TEST_true(SSL_CTX_set_cipher_list(cctx,
TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ":"
TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256)))
goto end;
# endif
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (!TEST_true(SSL_set1_groups(serverssl, kexch_groups, kexch_groups_size))
|| !TEST_true(SSL_set1_groups(clientssl, kexch_groups, kexch_groups_size)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
/*
* If Handshake succeeds the negotiated kexch alg should be the first one in
* configured, except in the case of FFDHE groups (idx 13), which are
* TLSv1.3 only so we expect no shared group to exist.
*/
if (!TEST_int_eq(SSL_get_shared_group(serverssl, 0),
idx == 13 ? 0 : kexch_groups[0]))
goto end;
if (!TEST_str_eq(SSL_group_to_name(serverssl, kexch_groups[0]),
kexch_name0))
goto end;
/* We don't implement RFC 7919 named groups for TLS 1.2. */
if (idx != 13) {
if (!TEST_str_eq(SSL_get0_group_name(serverssl), kexch_name0)
|| !TEST_str_eq(SSL_get0_group_name(clientssl), kexch_name0))
goto end;
if (!TEST_int_eq(SSL_get_negotiated_group(serverssl), kexch_groups[0]))
goto end;
if (!TEST_int_eq(SSL_get_negotiated_group(clientssl), kexch_groups[0]))
goto end;
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
# if !defined(OPENSSL_NO_TLS1_2) \
&& !defined(OPENSSL_NO_EC) \
&& !defined(OPENSSL_NO_DH)
static int set_ssl_groups(SSL *serverssl, SSL *clientssl, int clientmulti,
int isecdhe, int idx)
{
int kexch_alg;
int *kexch_groups = &kexch_alg;
int numec, numff;
numec = OSSL_NELEM(ecdhe_kexch_groups);
numff = OSSL_NELEM(ffdhe_kexch_groups);
if (isecdhe)
kexch_alg = ecdhe_kexch_groups[idx];
else
kexch_alg = ffdhe_kexch_groups[idx];
if (clientmulti) {
if (!TEST_true(SSL_set1_groups(serverssl, kexch_groups, 1)))
return 0;
if (isecdhe) {
if (!TEST_true(SSL_set1_groups(clientssl, ecdhe_kexch_groups,
numec)))
return 0;
} else {
if (!TEST_true(SSL_set1_groups(clientssl, ffdhe_kexch_groups,
numff)))
return 0;
}
} else {
if (!TEST_true(SSL_set1_groups(clientssl, kexch_groups, 1)))
return 0;
if (isecdhe) {
if (!TEST_true(SSL_set1_groups(serverssl, ecdhe_kexch_groups,
numec)))
return 0;
} else {
if (!TEST_true(SSL_set1_groups(serverssl, ffdhe_kexch_groups,
numff)))
return 0;
}
}
return 1;
}
/*-
* Test the SSL_get_negotiated_group() API across a battery of scenarios.
* Run through both the ECDHE and FFDHE group lists used in the previous
* test, for both TLS 1.2 and TLS 1.3, negotiating each group in turn,
* confirming the expected result; then perform a resumption handshake
* while offering the same group list, and another resumption handshake
* offering a different group list. The returned value should be the
* negotiated group for the initial handshake; for TLS 1.3 resumption
* handshakes the returned value will be negotiated on the resumption
* handshake itself, but for TLS 1.2 resumption handshakes the value will
* be cached in the session from the original handshake, regardless of what
* was offered in the resumption ClientHello.
*
* Using E for the number of EC groups and F for the number of FF groups:
* E tests of ECDHE with TLS 1.3, server only has one group
* F tests of FFDHE with TLS 1.3, server only has one group
* E tests of ECDHE with TLS 1.2, server only has one group
* F tests of FFDHE with TLS 1.2, server only has one group
* E tests of ECDHE with TLS 1.3, client sends only one group
* F tests of FFDHE with TLS 1.3, client sends only one group
* E tests of ECDHE with TLS 1.2, client sends only one group
* F tests of FFDHE with TLS 1.2, client sends only one group
*/
static int test_negotiated_group(int idx)
{
int clientmulti, istls13, isecdhe, numec, numff, numgroups;
int expectednid;
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
SSL_SESSION *origsess = NULL;
int testresult = 0;
int kexch_alg;
int max_version = TLS1_3_VERSION;
numec = OSSL_NELEM(ecdhe_kexch_groups);
numff = OSSL_NELEM(ffdhe_kexch_groups);
numgroups = numec + numff;
clientmulti = (idx < 2 * numgroups);
idx = idx % (2 * numgroups);
istls13 = (idx < numgroups);
idx = idx % numgroups;
isecdhe = (idx < numec);
if (!isecdhe)
idx -= numec;
/* Now 'idx' is an index into ecdhe_kexch_groups or ffdhe_kexch_groups */
if (isecdhe)
kexch_alg = ecdhe_kexch_groups[idx];
else
kexch_alg = ffdhe_kexch_groups[idx];
/* We expect nothing for the unimplemented TLS 1.2 FFDHE named groups */
if (!istls13 && !isecdhe)
expectednid = NID_undef;
else
expectednid = kexch_alg;
if (!istls13)
max_version = TLS1_2_VERSION;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION,
max_version, &sctx, &cctx, cert,
privkey)))
goto end;
/*
* Force (EC)DHE ciphers for TLS 1.2.
* Be sure to enable auto tmp DH so that FFDHE can succeed.
*/
if (!TEST_true(SSL_CTX_set_cipher_list(sctx,
TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ":"
TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256))
|| !TEST_true(SSL_CTX_set_dh_auto(sctx, 1)))
goto end;
if (!TEST_true(SSL_CTX_set_cipher_list(cctx,
TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ":"
TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (!TEST_true(set_ssl_groups(serverssl, clientssl, clientmulti, isecdhe,
idx)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
/* Initial handshake; always the configured one */
if (!TEST_uint_eq(SSL_get_negotiated_group(clientssl), expectednid)
|| !TEST_uint_eq(SSL_get_negotiated_group(serverssl), expectednid))
goto end;
if (!TEST_ptr((origsess = SSL_get1_session(clientssl))))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
/* First resumption attempt; use the same config as initial handshake */
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, origsess))
|| !TEST_true(set_ssl_groups(serverssl, clientssl, clientmulti,
isecdhe, idx)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl)))
goto end;
/* Still had better agree, since nothing changed... */
if (!TEST_uint_eq(SSL_get_negotiated_group(clientssl), expectednid)
|| !TEST_uint_eq(SSL_get_negotiated_group(serverssl), expectednid))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
/*-
* Second resumption attempt
* The party that picks one group changes it, which we effectuate by
* changing 'idx' and updating what we expect.
*/
if (idx == 0)
idx = 1;
else
idx--;
if (istls13) {
if (isecdhe)
expectednid = ecdhe_kexch_groups[idx];
else
expectednid = ffdhe_kexch_groups[idx];
/* Verify that we are changing what we expect. */
if (!TEST_int_ne(expectednid, kexch_alg))
goto end;
} else {
/* TLS 1.2 only supports named groups for ECDHE. */
if (isecdhe)
expectednid = kexch_alg;
else
expectednid = 0;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, origsess))
|| !TEST_true(set_ssl_groups(serverssl, clientssl, clientmulti,
isecdhe, idx)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl)))
goto end;
/* Check that we get what we expected */
if (!TEST_uint_eq(SSL_get_negotiated_group(clientssl), expectednid)
|| !TEST_uint_eq(SSL_get_negotiated_group(serverssl), expectednid))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
SSL_SESSION_free(origsess);
return testresult;
}
# endif /* !defined(OPENSSL_NO_EC) && !defined(OPENSSL_NO_DH) */
/*
* Test TLSv1.3 Cipher Suite
* Test 0 = Set TLS1.3 cipher on context
* Test 1 = Set TLS1.3 cipher on SSL
* Test 2 = Set TLS1.3 and TLS1.2 cipher on context
* Test 3 = Set TLS1.3 and TLS1.2 cipher on SSL
*/
static int test_tls13_ciphersuite(int idx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
static const struct {
const char *ciphername;
int fipscapable;
int low_security;
} t13_ciphers[] = {
{ TLS1_3_RFC_AES_128_GCM_SHA256, 1, 0 },
{ TLS1_3_RFC_AES_256_GCM_SHA384, 1, 0 },
{ TLS1_3_RFC_AES_128_CCM_SHA256, 1, 0 },
# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
{ TLS1_3_RFC_CHACHA20_POLY1305_SHA256, 0, 0 },
{ TLS1_3_RFC_AES_256_GCM_SHA384
":" TLS1_3_RFC_CHACHA20_POLY1305_SHA256, 0, 0 },
# endif
/* CCM8 ciphers are considered low security due to their short tag */
{ TLS1_3_RFC_AES_128_CCM_8_SHA256
":" TLS1_3_RFC_AES_128_CCM_SHA256, 1, 1 }
};
const char *t13_cipher = NULL;
const char *t12_cipher = NULL;
const char *negotiated_scipher;
const char *negotiated_ccipher;
int set_at_ctx = 0;
int set_at_ssl = 0;
int testresult = 0;
int max_ver;
size_t i;
switch (idx) {
case 0:
set_at_ctx = 1;
break;
case 1:
set_at_ssl = 1;
break;
case 2:
set_at_ctx = 1;
t12_cipher = TLS1_TXT_RSA_WITH_AES_128_SHA256;
break;
case 3:
set_at_ssl = 1;
t12_cipher = TLS1_TXT_RSA_WITH_AES_128_SHA256;
break;
}
for (max_ver = TLS1_2_VERSION; max_ver <= TLS1_3_VERSION; max_ver++) {
# ifdef OPENSSL_NO_TLS1_2
if (max_ver == TLS1_2_VERSION)
continue;
# endif
for (i = 0; i < OSSL_NELEM(t13_ciphers); i++) {
if (is_fips && !t13_ciphers[i].fipscapable)
continue;
t13_cipher = t13_ciphers[i].ciphername;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, max_ver,
&sctx, &cctx, cert, privkey)))
goto end;
if (t13_ciphers[i].low_security) {
SSL_CTX_set_security_level(sctx, 0);
SSL_CTX_set_security_level(cctx, 0);
}
if (set_at_ctx) {
if (!TEST_true(SSL_CTX_set_ciphersuites(sctx, t13_cipher))
|| !TEST_true(SSL_CTX_set_ciphersuites(cctx, t13_cipher)))
goto end;
if (t12_cipher != NULL) {
if (!TEST_true(SSL_CTX_set_cipher_list(sctx, t12_cipher))
|| !TEST_true(SSL_CTX_set_cipher_list(cctx,
t12_cipher)))
goto end;
}
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if (set_at_ssl) {
if (!TEST_true(SSL_set_ciphersuites(serverssl, t13_cipher))
|| !TEST_true(SSL_set_ciphersuites(clientssl, t13_cipher)))
goto end;
if (t12_cipher != NULL) {
if (!TEST_true(SSL_set_cipher_list(serverssl, t12_cipher))
|| !TEST_true(SSL_set_cipher_list(clientssl,
t12_cipher)))
goto end;
}
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
negotiated_scipher = SSL_CIPHER_get_name(SSL_get_current_cipher(
serverssl));
negotiated_ccipher = SSL_CIPHER_get_name(SSL_get_current_cipher(
clientssl));
if (!TEST_str_eq(negotiated_scipher, negotiated_ccipher))
goto end;
/*
* TEST_strn_eq is used below because t13_cipher can contain
* multiple ciphersuites
*/
if (max_ver == TLS1_3_VERSION
&& !TEST_strn_eq(t13_cipher, negotiated_scipher,
strlen(negotiated_scipher)))
goto end;
# ifndef OPENSSL_NO_TLS1_2
/* Below validation is not done when t12_cipher is NULL */
if (max_ver == TLS1_2_VERSION && t12_cipher != NULL
&& !TEST_str_eq(t12_cipher, negotiated_scipher))
goto end;
# endif
SSL_free(serverssl);
serverssl = NULL;
SSL_free(clientssl);
clientssl = NULL;
SSL_CTX_free(sctx);
sctx = NULL;
SSL_CTX_free(cctx);
cctx = NULL;
}
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test TLSv1.3 PSKs
* Test 0 = Test new style callbacks
* Test 1 = Test both new and old style callbacks
* Test 2 = Test old style callbacks
* Test 3 = Test old style callbacks with no certificate
*/
static int test_tls13_psk(int idx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
const SSL_CIPHER *cipher = NULL;
const unsigned char key[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f
};
int testresult = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, idx == 3 ? NULL : cert,
idx == 3 ? NULL : privkey)))
goto end;
if (idx != 3) {
/*
* We use a ciphersuite with SHA256 to ease testing old style PSK
* callbacks which will always default to SHA256. This should not be
* necessary if we have no cert/priv key. In that case the server should
* prefer SHA256 automatically.
*/
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
"TLS_AES_128_GCM_SHA256")))
goto end;
} else {
/*
* As noted above the server should prefer SHA256 automatically. However
* we are careful not to offer TLS_CHACHA20_POLY1305_SHA256 so this same
* code works even if we are testing with only the FIPS provider loaded.
*/
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
"TLS_AES_256_GCM_SHA384:"
"TLS_AES_128_GCM_SHA256")))
goto end;
}
/*
* Test 0: New style callbacks only
* Test 1: New and old style callbacks (only the new ones should be used)
* Test 2: Old style callbacks only
*/
if (idx == 0 || idx == 1) {
SSL_CTX_set_psk_use_session_callback(cctx, use_session_cb);
SSL_CTX_set_psk_find_session_callback(sctx, find_session_cb);
}
#ifndef OPENSSL_NO_PSK
if (idx >= 1) {
SSL_CTX_set_psk_client_callback(cctx, psk_client_cb);
SSL_CTX_set_psk_server_callback(sctx, psk_server_cb);
}
#endif
srvid = pskid;
use_session_cb_cnt = 0;
find_session_cb_cnt = 0;
psk_client_cb_cnt = 0;
psk_server_cb_cnt = 0;
if (idx != 3) {
/*
* Check we can create a connection if callback decides not to send a
* PSK
*/
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_false(SSL_session_reused(clientssl))
|| !TEST_false(SSL_session_reused(serverssl)))
goto end;
if (idx == 0 || idx == 1) {
if (!TEST_true(use_session_cb_cnt == 1)
|| !TEST_true(find_session_cb_cnt == 0)
/*
* If no old style callback then below should be 0
* otherwise 1
*/
|| !TEST_true(psk_client_cb_cnt == idx)
|| !TEST_true(psk_server_cb_cnt == 0))
goto end;
} else {
if (!TEST_true(use_session_cb_cnt == 0)
|| !TEST_true(find_session_cb_cnt == 0)
|| !TEST_true(psk_client_cb_cnt == 1)
|| !TEST_true(psk_server_cb_cnt == 0))
goto end;
}
shutdown_ssl_connection(serverssl, clientssl);
serverssl = clientssl = NULL;
use_session_cb_cnt = psk_client_cb_cnt = 0;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
/* Create the PSK */
cipher = SSL_CIPHER_find(clientssl, TLS13_AES_128_GCM_SHA256_BYTES);
clientpsk = SSL_SESSION_new();
if (!TEST_ptr(clientpsk)
|| !TEST_ptr(cipher)
|| !TEST_true(SSL_SESSION_set1_master_key(clientpsk, key,
sizeof(key)))
|| !TEST_true(SSL_SESSION_set_cipher(clientpsk, cipher))
|| !TEST_true(SSL_SESSION_set_protocol_version(clientpsk,
TLS1_3_VERSION))
|| !TEST_true(SSL_SESSION_up_ref(clientpsk)))
goto end;
serverpsk = clientpsk;
/* Check we can create a connection and the PSK is used */
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl))
|| !TEST_true(SSL_session_reused(serverssl)))
goto end;
if (idx == 0 || idx == 1) {
if (!TEST_true(use_session_cb_cnt == 1)
|| !TEST_true(find_session_cb_cnt == 1)
|| !TEST_true(psk_client_cb_cnt == 0)
|| !TEST_true(psk_server_cb_cnt == 0))
goto end;
} else {
if (!TEST_true(use_session_cb_cnt == 0)
|| !TEST_true(find_session_cb_cnt == 0)
|| !TEST_true(psk_client_cb_cnt == 1)
|| !TEST_true(psk_server_cb_cnt == 1))
goto end;
}
shutdown_ssl_connection(serverssl, clientssl);
serverssl = clientssl = NULL;
use_session_cb_cnt = find_session_cb_cnt = 0;
psk_client_cb_cnt = psk_server_cb_cnt = 0;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
/* Force an HRR */
#if defined(OPENSSL_NO_EC)
if (!TEST_true(SSL_set1_groups_list(serverssl, "ffdhe3072")))
goto end;
#else
if (!TEST_true(SSL_set1_groups_list(serverssl, "P-384")))
goto end;
#endif
/*
* Check we can create a connection, the PSK is used and the callbacks are
* called twice.
*/
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl))
|| !TEST_true(SSL_session_reused(serverssl)))
goto end;
if (idx == 0 || idx == 1) {
if (!TEST_true(use_session_cb_cnt == 2)
|| !TEST_true(find_session_cb_cnt == 2)
|| !TEST_true(psk_client_cb_cnt == 0)
|| !TEST_true(psk_server_cb_cnt == 0))
goto end;
} else {
if (!TEST_true(use_session_cb_cnt == 0)
|| !TEST_true(find_session_cb_cnt == 0)
|| !TEST_true(psk_client_cb_cnt == 2)
|| !TEST_true(psk_server_cb_cnt == 2))
goto end;
}
shutdown_ssl_connection(serverssl, clientssl);
serverssl = clientssl = NULL;
use_session_cb_cnt = find_session_cb_cnt = 0;
psk_client_cb_cnt = psk_server_cb_cnt = 0;
if (idx != 3) {
/*
* Check that if the server rejects the PSK we can still connect, but with
* a full handshake
*/
srvid = "Dummy Identity";
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_false(SSL_session_reused(clientssl))
|| !TEST_false(SSL_session_reused(serverssl)))
goto end;
if (idx == 0 || idx == 1) {
if (!TEST_true(use_session_cb_cnt == 1)
|| !TEST_true(find_session_cb_cnt == 1)
|| !TEST_true(psk_client_cb_cnt == 0)
/*
* If no old style callback then below should be 0
* otherwise 1
*/
|| !TEST_true(psk_server_cb_cnt == idx))
goto end;
} else {
if (!TEST_true(use_session_cb_cnt == 0)
|| !TEST_true(find_session_cb_cnt == 0)
|| !TEST_true(psk_client_cb_cnt == 1)
|| !TEST_true(psk_server_cb_cnt == 1))
goto end;
}
shutdown_ssl_connection(serverssl, clientssl);
serverssl = clientssl = NULL;
}
testresult = 1;
end:
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#ifndef OSSL_NO_USABLE_TLS1_3
/*
* Test TLS1.3 connection establishment succeeds with various configurations of
* the options `SSL_OP_ALLOW_NO_DHE_KEX` and `SSL_OP_PREFER_NO_DHE_KEX`.
* The verification of whether the right KEX mode is chosen is not covered by
* this test but by `test_tls13kexmodes`.
*
* Tests (idx & 1): Server has `SSL_OP_ALLOW_NO_DHE_KEX` set.
* Tests (idx & 2): Server has `SSL_OP_PREFER_NO_DHE_KEX` set.
* Tests (idx & 4): Client has `SSL_OP_ALLOW_NO_DHE_KEX` set.
*/
static int test_tls13_no_dhe_kex(const int idx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
int testresult = 0;
size_t j;
SSL_SESSION *saved_session;
int server_allow_no_dhe = (idx & 1) != 0;
int server_prefer_no_dhe = (idx & 2) != 0;
int client_allow_no_dhe = (idx & 4) != 0;
uint64_t server_options = 0
| (server_allow_no_dhe ? SSL_OP_ALLOW_NO_DHE_KEX : 0)
| (server_prefer_no_dhe ? SSL_OP_PREFER_NO_DHE_KEX : 0);
uint64_t client_options = 0
| (client_allow_no_dhe ? SSL_OP_ALLOW_NO_DHE_KEX : 0);
new_called = 0;
do_cache = 1;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_3_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
SSL_CTX_set_session_cache_mode(cctx, SSL_SESS_CACHE_CLIENT
| SSL_SESS_CACHE_NO_INTERNAL_STORE);
SSL_CTX_set_options(sctx, server_options);
SSL_CTX_set_options(cctx, client_options);
SSL_CTX_sess_set_new_cb(cctx, new_cachesession_cb);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
/* Check we got the number of tickets we were expecting */
|| !TEST_int_eq(2, new_called))
goto end;
/* We'll reuse the last ticket. */
saved_session = sesscache[new_called - 1];
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(cctx);
clientssl = serverssl = NULL;
cctx = NULL;
/*
* Now we resume with the last ticket we created.
*/
/* The server context already exists, so we only create the client. */
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_3_VERSION, 0,
NULL, &cctx, cert, privkey)))
goto end;
SSL_CTX_set_options(cctx, client_options);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, saved_session)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
/*
* Make sure, the session was resumed.
*/
if (!TEST_true(SSL_session_reused(clientssl)))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
for (j = 0; j < OSSL_NELEM(sesscache); j++) {
SSL_SESSION_free(sesscache[j]);
sesscache[j] = NULL;
}
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif /* OSSL_NO_USABLE_TLS1_3 */
static unsigned char cookie_magic_value[] = "cookie magic";
static int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
unsigned int *cookie_len)
{
/*
* Not suitable as a real cookie generation function but good enough for
* testing!
*/
memcpy(cookie, cookie_magic_value, sizeof(cookie_magic_value) - 1);
*cookie_len = sizeof(cookie_magic_value) - 1;
return 1;
}
static int verify_cookie_callback(SSL *ssl, const unsigned char *cookie,
unsigned int cookie_len)
{
if (cookie_len == sizeof(cookie_magic_value) - 1
&& memcmp(cookie, cookie_magic_value, cookie_len) == 0)
return 1;
return 0;
}
static int generate_stateless_cookie_callback(SSL *ssl, unsigned char *cookie,
size_t *cookie_len)
{
unsigned int temp;
int res = generate_cookie_callback(ssl, cookie, &temp);
*cookie_len = temp;
return res;
}
static int verify_stateless_cookie_callback(SSL *ssl, const unsigned char *cookie,
size_t cookie_len)
{
return verify_cookie_callback(ssl, cookie, cookie_len);
}
static int test_stateless(void)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
int testresult = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
/* The arrival of CCS messages can confuse the test */
SSL_CTX_clear_options(cctx, SSL_OP_ENABLE_MIDDLEBOX_COMPAT);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
/* Send the first ClientHello */
|| !TEST_false(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_WANT_READ))
/*
* This should fail with a -1 return because we have no callbacks
* set up
*/
|| !TEST_int_eq(SSL_stateless(serverssl), -1))
goto end;
/* Fatal error so abandon the connection from this client */
SSL_free(clientssl);
clientssl = NULL;
/* Set up the cookie generation and verification callbacks */
SSL_CTX_set_stateless_cookie_generate_cb(sctx, generate_stateless_cookie_callback);
SSL_CTX_set_stateless_cookie_verify_cb(sctx, verify_stateless_cookie_callback);
/*
* Create a new connection from the client (we can reuse the server SSL
* object).
*/
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
/* Send the first ClientHello */
|| !TEST_false(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_WANT_READ))
/* This should fail because there is no cookie */
|| !TEST_int_eq(SSL_stateless(serverssl), 0))
goto end;
/* Abandon the connection from this client */
SSL_free(clientssl);
clientssl = NULL;
/*
* Now create a connection from a new client but with the same server SSL
* object
*/
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
/* Send the first ClientHello */
|| !TEST_false(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_WANT_READ))
/* This should fail because there is no cookie */
|| !TEST_int_eq(SSL_stateless(serverssl), 0)
/* Send the second ClientHello */
|| !TEST_false(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_WANT_READ))
/* This should succeed because a cookie is now present */
|| !TEST_int_eq(SSL_stateless(serverssl), 1)
/* Complete the connection */
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
shutdown_ssl_connection(serverssl, clientssl);
serverssl = clientssl = NULL;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif /* OSSL_NO_USABLE_TLS1_3 */
static int clntaddoldcb = 0;
static int clntparseoldcb = 0;
static int srvaddoldcb = 0;
static int srvparseoldcb = 0;
static int clntaddnewcb = 0;
static int clntparsenewcb = 0;
static int srvaddnewcb = 0;
static int srvparsenewcb = 0;
static int snicb = 0;
#define TEST_EXT_TYPE1 0xff00
static int old_add_cb(SSL *s, unsigned int ext_type, const unsigned char **out,
size_t *outlen, int *al, void *add_arg)
{
int *server = (int *)add_arg;
unsigned char *data;
if (SSL_is_server(s))
srvaddoldcb++;
else
clntaddoldcb++;
if (*server != SSL_is_server(s)
|| (data = OPENSSL_malloc(sizeof(*data))) == NULL)
return -1;
*data = 1;
*out = data;
*outlen = sizeof(char);
return 1;
}
static void old_free_cb(SSL *s, unsigned int ext_type, const unsigned char *out,
void *add_arg)
{
OPENSSL_free((unsigned char *)out);
}
static int old_parse_cb(SSL *s, unsigned int ext_type, const unsigned char *in,
size_t inlen, int *al, void *parse_arg)
{
int *server = (int *)parse_arg;
if (SSL_is_server(s))
srvparseoldcb++;
else
clntparseoldcb++;
if (*server != SSL_is_server(s)
|| inlen != sizeof(char)
|| *in != 1)
return -1;
return 1;
}
static int new_add_cb(SSL *s, unsigned int ext_type, unsigned int context,
const unsigned char **out, size_t *outlen, X509 *x,
size_t chainidx, int *al, void *add_arg)
{
int *server = (int *)add_arg;
unsigned char *data;
if (SSL_is_server(s))
srvaddnewcb++;
else
clntaddnewcb++;
if (*server != SSL_is_server(s)
|| (data = OPENSSL_malloc(sizeof(*data))) == NULL)
return -1;
*data = 1;
*out = data;
*outlen = sizeof(*data);
return 1;
}
static void new_free_cb(SSL *s, unsigned int ext_type, unsigned int context,
const unsigned char *out, void *add_arg)
{
OPENSSL_free((unsigned char *)out);
}
static int new_parse_cb(SSL *s, unsigned int ext_type, unsigned int context,
const unsigned char *in, size_t inlen, X509 *x,
size_t chainidx, int *al, void *parse_arg)
{
int *server = (int *)parse_arg;
if (SSL_is_server(s))
srvparsenewcb++;
else
clntparsenewcb++;
if (*server != SSL_is_server(s)
|| inlen != sizeof(char) || *in != 1)
return -1;
return 1;
}
static int sni_cb(SSL *s, int *al, void *arg)
{
SSL_CTX *ctx = (SSL_CTX *)arg;
if (SSL_set_SSL_CTX(s, ctx) == NULL) {
*al = SSL_AD_INTERNAL_ERROR;
return SSL_TLSEXT_ERR_ALERT_FATAL;
}
snicb++;
return SSL_TLSEXT_ERR_OK;
}
static int verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
{
return 1;
}
/*
* Custom call back tests.
* Test 0: Old style callbacks in TLSv1.2
* Test 1: New style callbacks in TLSv1.2
* Test 2: New style callbacks in TLSv1.2 with SNI
* Test 3: New style callbacks in TLSv1.3. Extensions in CH and EE
* Test 4: New style callbacks in TLSv1.3. Extensions in CH, SH, EE, Cert + NST
* Test 5: New style callbacks in TLSv1.3. Extensions in CR + Client Cert
*/
static int test_custom_exts(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
static int server = 1;
static int client = 0;
SSL_SESSION *sess = NULL;
unsigned int context;
#if defined(OPENSSL_NO_TLS1_2) && !defined(OSSL_NO_USABLE_TLS1_3)
/* Skip tests for TLSv1.2 and below in this case */
if (tst < 3)
return 1;
#endif
/* Reset callback counters */
clntaddoldcb = clntparseoldcb = srvaddoldcb = srvparseoldcb = 0;
clntaddnewcb = clntparsenewcb = srvaddnewcb = srvparsenewcb = 0;
snicb = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
if (tst == 2
&& !TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(), NULL,
TLS1_VERSION, 0,
&sctx2, NULL, cert, privkey)))
goto end;
if (tst < 3) {
SSL_CTX_set_options(cctx, SSL_OP_NO_TLSv1_3);
SSL_CTX_set_options(sctx, SSL_OP_NO_TLSv1_3);
if (sctx2 != NULL)
SSL_CTX_set_options(sctx2, SSL_OP_NO_TLSv1_3);
}
if (tst == 5) {
context = SSL_EXT_TLS1_3_CERTIFICATE_REQUEST
| SSL_EXT_TLS1_3_CERTIFICATE;
SSL_CTX_set_verify(sctx,
SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
verify_cb);
if (!TEST_int_eq(SSL_CTX_use_certificate_file(cctx, cert,
SSL_FILETYPE_PEM), 1)
|| !TEST_int_eq(SSL_CTX_use_PrivateKey_file(cctx, privkey,
SSL_FILETYPE_PEM), 1)
|| !TEST_int_eq(SSL_CTX_check_private_key(cctx), 1))
goto end;
} else if (tst == 4) {
context = SSL_EXT_CLIENT_HELLO
| SSL_EXT_TLS1_2_SERVER_HELLO
| SSL_EXT_TLS1_3_SERVER_HELLO
| SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS
| SSL_EXT_TLS1_3_CERTIFICATE
| SSL_EXT_TLS1_3_NEW_SESSION_TICKET;
} else {
context = SSL_EXT_CLIENT_HELLO
| SSL_EXT_TLS1_2_SERVER_HELLO
| SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS;
}
/* Create a client side custom extension */
if (tst == 0) {
if (!TEST_true(SSL_CTX_add_client_custom_ext(cctx, TEST_EXT_TYPE1,
old_add_cb, old_free_cb,
&client, old_parse_cb,
&client)))
goto end;
} else {
if (!TEST_true(SSL_CTX_add_custom_ext(cctx, TEST_EXT_TYPE1, context,
new_add_cb, new_free_cb,
&client, new_parse_cb, &client)))
goto end;
}
/* Should not be able to add duplicates */
if (!TEST_false(SSL_CTX_add_client_custom_ext(cctx, TEST_EXT_TYPE1,
old_add_cb, old_free_cb,
&client, old_parse_cb,
&client))
|| !TEST_false(SSL_CTX_add_custom_ext(cctx, TEST_EXT_TYPE1,
context, new_add_cb,
new_free_cb, &client,
new_parse_cb, &client)))
goto end;
/* Create a server side custom extension */
if (tst == 0) {
if (!TEST_true(SSL_CTX_add_server_custom_ext(sctx, TEST_EXT_TYPE1,
old_add_cb, old_free_cb,
&server, old_parse_cb,
&server)))
goto end;
} else {
if (!TEST_true(SSL_CTX_add_custom_ext(sctx, TEST_EXT_TYPE1, context,
new_add_cb, new_free_cb,
&server, new_parse_cb, &server)))
goto end;
if (sctx2 != NULL
&& !TEST_true(SSL_CTX_add_custom_ext(sctx2, TEST_EXT_TYPE1,
context, new_add_cb,
new_free_cb, &server,
new_parse_cb, &server)))
goto end;
}
/* Should not be able to add duplicates */
if (!TEST_false(SSL_CTX_add_server_custom_ext(sctx, TEST_EXT_TYPE1,
old_add_cb, old_free_cb,
&server, old_parse_cb,
&server))
|| !TEST_false(SSL_CTX_add_custom_ext(sctx, TEST_EXT_TYPE1,
context, new_add_cb,
new_free_cb, &server,
new_parse_cb, &server)))
goto end;
if (tst == 2) {
/* Set up SNI */
if (!TEST_true(SSL_CTX_set_tlsext_servername_callback(sctx, sni_cb))
|| !TEST_true(SSL_CTX_set_tlsext_servername_arg(sctx, sctx2)))
goto end;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
if (tst == 0) {
if (clntaddoldcb != 1
|| clntparseoldcb != 1
|| srvaddoldcb != 1
|| srvparseoldcb != 1)
goto end;
} else if (tst == 1 || tst == 2 || tst == 3) {
if (clntaddnewcb != 1
|| clntparsenewcb != 1
|| srvaddnewcb != 1
|| srvparsenewcb != 1
|| (tst != 2 && snicb != 0)
|| (tst == 2 && snicb != 1))
goto end;
} else if (tst == 5) {
if (clntaddnewcb != 1
|| clntparsenewcb != 1
|| srvaddnewcb != 1
|| srvparsenewcb != 1)
goto end;
} else {
/* In this case there 2 NewSessionTicket messages created */
if (clntaddnewcb != 1
|| clntparsenewcb != 5
|| srvaddnewcb != 5
|| srvparsenewcb != 1)
goto end;
}
sess = SSL_get1_session(clientssl);
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
if (tst == 3 || tst == 5) {
/* We don't bother with the resumption aspects for these tests */
testresult = 1;
goto end;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, sess))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
/*
* For a resumed session we expect to add the ClientHello extension. For the
* old style callbacks we ignore it on the server side because they set
* SSL_EXT_IGNORE_ON_RESUMPTION. The new style callbacks do not ignore
* them.
*/
if (tst == 0) {
if (clntaddoldcb != 2
|| clntparseoldcb != 1
|| srvaddoldcb != 1
|| srvparseoldcb != 1)
goto end;
} else if (tst == 1 || tst == 2 || tst == 3) {
if (clntaddnewcb != 2
|| clntparsenewcb != 2
|| srvaddnewcb != 2
|| srvparsenewcb != 2)
goto end;
} else {
/*
* No Certificate message extensions in the resumption handshake,
* 2 NewSessionTickets in the initial handshake, 1 in the resumption
*/
if (clntaddnewcb != 2
|| clntparsenewcb != 8
|| srvaddnewcb != 8
|| srvparsenewcb != 2)
goto end;
}
testresult = 1;
end:
SSL_SESSION_free(sess);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx2);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#if !defined(OPENSSL_NO_TLS1_2) && !defined(OSSL_NO_USABLE_TLS1_3)
#define SYNTHV1CONTEXT (SSL_EXT_TLS1_2_AND_BELOW_ONLY \
| SSL_EXT_CLIENT_HELLO \
| SSL_EXT_TLS1_2_SERVER_HELLO \
| SSL_EXT_IGNORE_ON_RESUMPTION)
#define TLS13CONTEXT (SSL_EXT_TLS1_3_CERTIFICATE \
| SSL_EXT_TLS1_2_SERVER_HELLO \
| SSL_EXT_CLIENT_HELLO)
#define SERVERINFO_CUSTOM \
0x00, (char)TLSEXT_TYPE_signed_certificate_timestamp, \
0x00, 0x03, \
0x04, 0x05, 0x06 \
static const unsigned char serverinfo_custom_tls13[] = {
0x00, 0x00, (TLS13CONTEXT >> 8) & 0xff, TLS13CONTEXT & 0xff,
SERVERINFO_CUSTOM
};
static const unsigned char serverinfo_custom_v2[] = {
0x00, 0x00, (SYNTHV1CONTEXT >> 8) & 0xff, SYNTHV1CONTEXT & 0xff,
SERVERINFO_CUSTOM
};
static const unsigned char serverinfo_custom_v1[] = {
SERVERINFO_CUSTOM
};
static const size_t serverinfo_custom_tls13_len = sizeof(serverinfo_custom_tls13);
static const size_t serverinfo_custom_v2_len = sizeof(serverinfo_custom_v2);
static const size_t serverinfo_custom_v1_len = sizeof(serverinfo_custom_v1);
static int serverinfo_custom_parse_cb(SSL *s, unsigned int ext_type,
unsigned int context,
const unsigned char *in,
size_t inlen, X509 *x,
size_t chainidx, int *al,
void *parse_arg)
{
const size_t len = serverinfo_custom_v1_len;
const unsigned char *si = &serverinfo_custom_v1[len - 3];
int *p_cb_result = (int*)parse_arg;
*p_cb_result = TEST_mem_eq(in, inlen, si, 3);
return 1;
}
static int test_serverinfo_custom(const int idx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
int cb_result = 0;
/*
* Following variables are set in the switch statement
* according to the test iteration.
* Default values do not make much sense: test would fail with them.
*/
int serverinfo_version = 0;
int protocol_version = 0;
unsigned int extension_context = 0;
const unsigned char *si = NULL;
size_t si_len = 0;
const int call_use_serverinfo_ex = idx > 0;
switch (idx) {
case 0: /* FALLTHROUGH */
case 1:
serverinfo_version = SSL_SERVERINFOV1;
protocol_version = TLS1_2_VERSION;
extension_context = SYNTHV1CONTEXT;
si = serverinfo_custom_v1;
si_len = serverinfo_custom_v1_len;
break;
case 2:
serverinfo_version = SSL_SERVERINFOV2;
protocol_version = TLS1_2_VERSION;
extension_context = SYNTHV1CONTEXT;
si = serverinfo_custom_v2;
si_len = serverinfo_custom_v2_len;
break;
case 3:
serverinfo_version = SSL_SERVERINFOV2;
protocol_version = TLS1_3_VERSION;
extension_context = TLS13CONTEXT;
si = serverinfo_custom_tls13;
si_len = serverinfo_custom_tls13_len;
break;
}
if (!TEST_true(create_ssl_ctx_pair(libctx,
TLS_method(),
TLS_method(),
protocol_version,
protocol_version,
&sctx, &cctx, cert, privkey)))
goto end;
if (call_use_serverinfo_ex) {
if (!TEST_true(SSL_CTX_use_serverinfo_ex(sctx, serverinfo_version,
si, si_len)))
goto end;
} else {
if (!TEST_true(SSL_CTX_use_serverinfo(sctx, si, si_len)))
goto end;
}
if (!TEST_true(SSL_CTX_add_custom_ext(cctx, TLSEXT_TYPE_signed_certificate_timestamp,
extension_context,
NULL, NULL, NULL,
serverinfo_custom_parse_cb,
&cb_result))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_int_eq(SSL_do_handshake(clientssl), 1))
goto end;
if (!TEST_true(cb_result))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif
/*
* Test that SSL_export_keying_material() produces expected results. There are
* no test vectors so all we do is test that both sides of the communication
* produce the same results for different protocol versions.
*/
#define SMALL_LABEL_LEN 10
#define LONG_LABEL_LEN 249
static int test_export_key_mat(int tst)
{
int testresult = 0;
SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
const char label[LONG_LABEL_LEN + 1] = "test label";
const unsigned char context[] = "context";
const unsigned char *emptycontext = NULL;
unsigned char longcontext[1280];
int test_longcontext = fips_provider_version_ge(libctx, 3, 3, 0);
unsigned char ckeymat1[80], ckeymat2[80], ckeymat3[80], ckeymat4[80];
unsigned char skeymat1[80], skeymat2[80], skeymat3[80], skeymat4[80];
size_t labellen;
const int protocols[] = {
TLS1_VERSION,
TLS1_1_VERSION,
TLS1_2_VERSION,
TLS1_3_VERSION,
TLS1_3_VERSION,
TLS1_3_VERSION
};
#ifdef OPENSSL_NO_TLS1
if (tst == 0)
return 1;
#endif
#ifdef OPENSSL_NO_TLS1_1
if (tst == 1)
return 1;
#endif
if (is_fips && (tst == 0 || tst == 1))
return 1;
#ifdef OPENSSL_NO_TLS1_2
if (tst == 2)
return 1;
#endif
#ifdef OSSL_NO_USABLE_TLS1_3
if (tst >= 3)
return 1;
#endif
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
OPENSSL_assert(tst >= 0 && (size_t)tst < OSSL_NELEM(protocols));
SSL_CTX_set_max_proto_version(cctx, protocols[tst]);
SSL_CTX_set_min_proto_version(cctx, protocols[tst]);
if ((protocols[tst] < TLS1_2_VERSION) &&
(!SSL_CTX_set_cipher_list(cctx, "DEFAULT:@SECLEVEL=0")
|| !SSL_CTX_set_cipher_list(sctx, "DEFAULT:@SECLEVEL=0")))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
NULL)))
goto end;
/*
* Premature call of SSL_export_keying_material should just fail.
*/
if (!TEST_int_le(SSL_export_keying_material(clientssl, ckeymat1,
sizeof(ckeymat1), label,
SMALL_LABEL_LEN + 1, context,
sizeof(context) - 1, 1), 0))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
if (tst == 5) {
/*
* TLSv1.3 imposes a maximum label len of 249 bytes. Check we fail if we
* go over that.
*/
if (!TEST_int_le(SSL_export_keying_material(clientssl, ckeymat1,
sizeof(ckeymat1), label,
LONG_LABEL_LEN + 1, context,
sizeof(context) - 1, 1), 0))
goto end;
testresult = 1;
goto end;
} else if (tst == 4) {
labellen = LONG_LABEL_LEN;
} else {
labellen = SMALL_LABEL_LEN;
}
memset(longcontext, 1, sizeof(longcontext));
if (!TEST_int_eq(SSL_export_keying_material(clientssl, ckeymat1,
sizeof(ckeymat1), label,
labellen, context,
sizeof(context) - 1, 1), 1)
|| !TEST_int_eq(SSL_export_keying_material(clientssl, ckeymat2,
sizeof(ckeymat2), label,
labellen,
emptycontext,
0, 1), 1)
|| !TEST_int_eq(SSL_export_keying_material(clientssl, ckeymat3,
sizeof(ckeymat3), label,
labellen,
NULL, 0, 0), 1)
|| (test_longcontext
&& !TEST_int_eq(SSL_export_keying_material(clientssl,
ckeymat4,
sizeof(ckeymat4), label,
labellen,
longcontext,
sizeof(longcontext), 1),
1))
|| !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat1,
sizeof(skeymat1), label,
labellen,
context,
sizeof(context) -1, 1),
1)
|| !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat2,
sizeof(skeymat2), label,
labellen,
emptycontext,
0, 1), 1)
|| !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat3,
sizeof(skeymat3), label,
labellen,
NULL, 0, 0), 1)
|| (test_longcontext
&& !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat4,
sizeof(skeymat4), label,
labellen,
longcontext,
sizeof(longcontext), 1),
1))
/*
* Check that both sides created the same key material with the
* same context.
*/
|| !TEST_mem_eq(ckeymat1, sizeof(ckeymat1), skeymat1,
sizeof(skeymat1))
/*
* Check that both sides created the same key material with an
* empty context.
*/
|| !TEST_mem_eq(ckeymat2, sizeof(ckeymat2), skeymat2,
sizeof(skeymat2))
/*
* Check that both sides created the same key material without a
* context.
*/
|| !TEST_mem_eq(ckeymat3, sizeof(ckeymat3), skeymat3,
sizeof(skeymat3))
/*
* Check that both sides created the same key material with a
* long context.
*/
|| (test_longcontext
&& !TEST_mem_eq(ckeymat4, sizeof(ckeymat4), skeymat4,
sizeof(skeymat4)))
/* Different contexts should produce different results */
|| !TEST_mem_ne(ckeymat1, sizeof(ckeymat1), ckeymat2,
sizeof(ckeymat2)))
goto end;
/*
* Check that an empty context and no context produce different results in
* protocols less than TLSv1.3. In TLSv1.3 they should be the same.
*/
if ((tst < 3 && !TEST_mem_ne(ckeymat2, sizeof(ckeymat2), ckeymat3,
sizeof(ckeymat3)))
|| (tst >= 3 && !TEST_mem_eq(ckeymat2, sizeof(ckeymat2), ckeymat3,
sizeof(ckeymat3))))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx2);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#ifndef OSSL_NO_USABLE_TLS1_3
/*
* Test that SSL_export_keying_material_early() produces expected
* results. There are no test vectors so all we do is test that both
* sides of the communication produce the same results for different
* protocol versions.
*/
static int test_export_key_mat_early(int idx)
{
static const char label[] = "test label";
static const unsigned char context[] = "context";
int testresult = 0;
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
SSL_SESSION *sess = NULL;
const unsigned char *emptycontext = NULL;
unsigned char ckeymat1[80], ckeymat2[80];
unsigned char skeymat1[80], skeymat2[80];
unsigned char buf[1];
size_t readbytes, written;
if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl, &serverssl,
&sess, idx, SHA384_DIGEST_LENGTH)))
goto end;
/* Here writing 0 length early data is enough. */
if (!TEST_true(SSL_write_early_data(clientssl, NULL, 0, &written))
|| !TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_ERROR)
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_ACCEPTED))
goto end;
if (!TEST_int_eq(SSL_export_keying_material_early(
clientssl, ckeymat1, sizeof(ckeymat1), label,
sizeof(label) - 1, context, sizeof(context) - 1), 1)
|| !TEST_int_eq(SSL_export_keying_material_early(
clientssl, ckeymat2, sizeof(ckeymat2), label,
sizeof(label) - 1, emptycontext, 0), 1)
|| !TEST_int_eq(SSL_export_keying_material_early(
serverssl, skeymat1, sizeof(skeymat1), label,
sizeof(label) - 1, context, sizeof(context) - 1), 1)
|| !TEST_int_eq(SSL_export_keying_material_early(
serverssl, skeymat2, sizeof(skeymat2), label,
sizeof(label) - 1, emptycontext, 0), 1)
/*
* Check that both sides created the same key material with the
* same context.
*/
|| !TEST_mem_eq(ckeymat1, sizeof(ckeymat1), skeymat1,
sizeof(skeymat1))
/*
* Check that both sides created the same key material with an
* empty context.
*/
|| !TEST_mem_eq(ckeymat2, sizeof(ckeymat2), skeymat2,
sizeof(skeymat2))
/* Different contexts should produce different results */
|| !TEST_mem_ne(ckeymat1, sizeof(ckeymat1), ckeymat2,
sizeof(ckeymat2)))
goto end;
testresult = 1;
end:
SSL_SESSION_free(sess);
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#define NUM_KEY_UPDATE_MESSAGES 40
/*
* Test KeyUpdate.
*/
static int test_key_update(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0, i, j;
char buf[20];
static char *mess = "A test message";
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_3_VERSION,
0,
&sctx, &cctx, cert, privkey))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
for (j = 0; j < 2; j++) {
/* Send lots of KeyUpdate messages */
for (i = 0; i < NUM_KEY_UPDATE_MESSAGES; i++) {
if (!TEST_true(SSL_key_update(clientssl,
(j == 0)
? SSL_KEY_UPDATE_NOT_REQUESTED
: SSL_KEY_UPDATE_REQUESTED))
|| !TEST_true(SSL_do_handshake(clientssl)))
goto end;
}
/* Check that sending and receiving app data is ok */
if (!TEST_int_eq(SSL_write(clientssl, mess, strlen(mess)), strlen(mess))
|| !TEST_int_eq(SSL_read(serverssl, buf, sizeof(buf)),
strlen(mess)))
goto end;
if (!TEST_int_eq(SSL_write(serverssl, mess, strlen(mess)), strlen(mess))
|| !TEST_int_eq(SSL_read(clientssl, buf, sizeof(buf)),
strlen(mess)))
goto end;
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test we can handle a KeyUpdate (update requested) message while
* write data is pending in peer.
* Test 0: Client sends KeyUpdate while Server is writing
* Test 1: Server sends KeyUpdate while Client is writing
*/
static int test_key_update_peer_in_write(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char buf[20];
static char *mess = "A test message";
BIO *bretry = BIO_new(bio_s_always_retry());
BIO *tmp = NULL;
SSL *peerupdate = NULL, *peerwrite = NULL;
if (!TEST_ptr(bretry)
|| !TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_3_VERSION,
0,
&sctx, &cctx, cert, privkey))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
peerupdate = tst == 0 ? clientssl : serverssl;
peerwrite = tst == 0 ? serverssl : clientssl;
if (!TEST_true(SSL_key_update(peerupdate, SSL_KEY_UPDATE_REQUESTED))
|| !TEST_int_eq(SSL_do_handshake(peerupdate), 1))
goto end;
/* Swap the writing endpoint's write BIO to force a retry */
tmp = SSL_get_wbio(peerwrite);
if (!TEST_ptr(tmp) || !TEST_true(BIO_up_ref(tmp))) {
tmp = NULL;
goto end;
}
SSL_set0_wbio(peerwrite, bretry);
bretry = NULL;
/* Write data that we know will fail with SSL_ERROR_WANT_WRITE */
if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), -1)
|| !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_WRITE)
|| !TEST_true(SSL_want_write(peerwrite))
|| !TEST_true(SSL_net_write_desired(peerwrite)))
goto end;
/* Reinstate the original writing endpoint's write BIO */
SSL_set0_wbio(peerwrite, tmp);
tmp = NULL;
/* Now read some data - we will read the key update */
if (!TEST_int_eq(SSL_read(peerwrite, buf, sizeof(buf)), -1)
|| !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_READ)
|| !TEST_true(SSL_want_read(peerwrite))
|| !TEST_true(SSL_net_read_desired(peerwrite)))
goto end;
/*
* Complete the write we started previously and read it from the other
* endpoint
*/
if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), strlen(mess))
|| !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), strlen(mess)))
goto end;
/* Write more data to ensure we send the KeyUpdate message back */
if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), strlen(mess))
|| !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), strlen(mess)))
goto end;
if (!TEST_false(SSL_net_read_desired(peerwrite))
|| !TEST_false(SSL_net_write_desired(peerwrite))
|| !TEST_int_eq(SSL_want(peerwrite), SSL_NOTHING))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
BIO_free(bretry);
BIO_free(tmp);
return testresult;
}
/*
* Test we can handle a KeyUpdate (update requested) message while
* peer read data is pending after peer accepted keyupdate(the msg header
* had been read 5 bytes).
* Test 0: Client sends KeyUpdate while Server is reading
* Test 1: Server sends KeyUpdate while Client is reading
*/
static int test_key_update_peer_in_read(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char prbuf[515], lwbuf[515] = {0};
static char *mess = "A test message";
BIO *lbio = NULL, *pbio = NULL;
SSL *local = NULL, *peer = NULL;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_3_VERSION,
0,
&sctx, &cctx, cert, privkey))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
local = tst == 0 ? clientssl : serverssl;
peer = tst == 0 ? serverssl : clientssl;
if (!TEST_int_eq(BIO_new_bio_pair(&lbio, 512, &pbio, 512), 1))
goto end;
SSL_set_bio(local, lbio, lbio);
SSL_set_bio(peer, pbio, pbio);
/*
* we first write keyupdate msg then appdata in local
* write data in local will fail with SSL_ERROR_WANT_WRITE,because
* lwbuf app data msg size + key updata msg size > 512(the size of
* the bio pair buffer)
*/
if (!TEST_true(SSL_key_update(local, SSL_KEY_UPDATE_REQUESTED))
|| !TEST_int_eq(SSL_write(local, lwbuf, sizeof(lwbuf)), -1)
|| !TEST_int_eq(SSL_get_error(local, -1), SSL_ERROR_WANT_WRITE))
goto end;
/*
* first read keyupdate msg in peer in peer
* then read appdata that we know will fail with SSL_ERROR_WANT_READ
*/
if (!TEST_int_eq(SSL_read(peer, prbuf, sizeof(prbuf)), -1)
|| !TEST_int_eq(SSL_get_error(peer, -1), SSL_ERROR_WANT_READ))
goto end;
/* Now write some data in peer - we will write the key update */
if (!TEST_int_eq(SSL_write(peer, mess, strlen(mess)), strlen(mess)))
goto end;
/*
* write data in local previously that we will complete
* read data in peer previously that we will complete
*/
if (!TEST_int_eq(SSL_write(local, lwbuf, sizeof(lwbuf)), sizeof(lwbuf))
|| !TEST_int_eq(SSL_read(peer, prbuf, sizeof(prbuf)), sizeof(prbuf)))
goto end;
/* check that sending and receiving appdata ok */
if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), strlen(mess))
|| !TEST_int_eq(SSL_read(peer, prbuf, sizeof(prbuf)), strlen(mess)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test we can't send a KeyUpdate (update requested) message while
* local write data is pending.
* Test 0: Client sends KeyUpdate while Client is writing
* Test 1: Server sends KeyUpdate while Server is writing
*/
static int test_key_update_local_in_write(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char buf[20];
static char *mess = "A test message";
BIO *bretry = BIO_new(bio_s_always_retry());
BIO *tmp = NULL;
SSL *local = NULL, *peer = NULL;
if (!TEST_ptr(bretry)
|| !TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_3_VERSION,
0,
&sctx, &cctx, cert, privkey))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
local = tst == 0 ? clientssl : serverssl;
peer = tst == 0 ? serverssl : clientssl;
/* Swap the writing endpoint's write BIO to force a retry */
tmp = SSL_get_wbio(local);
if (!TEST_ptr(tmp) || !TEST_true(BIO_up_ref(tmp))) {
tmp = NULL;
goto end;
}
SSL_set0_wbio(local, bretry);
bretry = NULL;
/* write data in local will fail with SSL_ERROR_WANT_WRITE */
if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), -1)
|| !TEST_int_eq(SSL_get_error(local, -1), SSL_ERROR_WANT_WRITE))
goto end;
/* Reinstate the original writing endpoint's write BIO */
SSL_set0_wbio(local, tmp);
tmp = NULL;
/* SSL_key_update will fail, because writing in local*/
if (!TEST_false(SSL_key_update(local, SSL_KEY_UPDATE_REQUESTED))
|| !TEST_int_eq(ERR_GET_REASON(ERR_peek_error()), SSL_R_BAD_WRITE_RETRY))
goto end;
ERR_clear_error();
/* write data in local previously that we will complete */
if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), strlen(mess)))
goto end;
/* SSL_key_update will succeed because there is no pending write data */
if (!TEST_true(SSL_key_update(local, SSL_KEY_UPDATE_REQUESTED))
|| !TEST_int_eq(SSL_do_handshake(local), 1))
goto end;
/*
* we write some appdata in local
* read data in peer - we will read the keyupdate msg
*/
if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), strlen(mess))
|| !TEST_int_eq(SSL_read(peer, buf, sizeof(buf)), strlen(mess)))
goto end;
/* Write more peer more data to ensure we send the keyupdate message back */
if (!TEST_int_eq(SSL_write(peer, mess, strlen(mess)), strlen(mess))
|| !TEST_int_eq(SSL_read(local, buf, sizeof(buf)), strlen(mess)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
BIO_free(bretry);
BIO_free(tmp);
return testresult;
}
/*
* Test we can handle a KeyUpdate (update requested) message while
* local read data is pending(the msg header had been read 5 bytes).
* Test 0: Client sends KeyUpdate while Client is reading
* Test 1: Server sends KeyUpdate while Server is reading
*/
static int test_key_update_local_in_read(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char lrbuf[515], pwbuf[515] = {0}, prbuf[20];
static char *mess = "A test message";
BIO *lbio = NULL, *pbio = NULL;
SSL *local = NULL, *peer = NULL;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_3_VERSION,
0,
&sctx, &cctx, cert, privkey))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
local = tst == 0 ? clientssl : serverssl;
peer = tst == 0 ? serverssl : clientssl;
if (!TEST_int_eq(BIO_new_bio_pair(&lbio, 512, &pbio, 512), 1))
goto end;
SSL_set_bio(local, lbio, lbio);
SSL_set_bio(peer, pbio, pbio);
/* write app data in peer will fail with SSL_ERROR_WANT_WRITE */
if (!TEST_int_eq(SSL_write(peer, pwbuf, sizeof(pwbuf)), -1)
|| !TEST_int_eq(SSL_get_error(peer, -1), SSL_ERROR_WANT_WRITE))
goto end;
/* read appdata in local will fail with SSL_ERROR_WANT_READ */
if (!TEST_int_eq(SSL_read(local, lrbuf, sizeof(lrbuf)), -1)
|| !TEST_int_eq(SSL_get_error(local, -1), SSL_ERROR_WANT_READ))
goto end;
/* SSL_do_handshake will send keyupdate msg */
if (!TEST_true(SSL_key_update(local, SSL_KEY_UPDATE_REQUESTED))
|| !TEST_int_eq(SSL_do_handshake(local), 1))
goto end;
/*
* write data in peer previously that we will complete
* read data in local previously that we will complete
*/
if (!TEST_int_eq(SSL_write(peer, pwbuf, sizeof(pwbuf)), sizeof(pwbuf))
|| !TEST_int_eq(SSL_read(local, lrbuf, sizeof(lrbuf)), sizeof(lrbuf)))
goto end;
/*
* write data in local
* read data in peer - we will read the key update
*/
if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), strlen(mess))
|| !TEST_int_eq(SSL_read(peer, prbuf, sizeof(prbuf)), strlen(mess)))
goto end;
/* Write more peer data to ensure we send the keyupdate message back */
if (!TEST_int_eq(SSL_write(peer, mess, strlen(mess)), strlen(mess))
|| !TEST_int_eq(SSL_read(local, lrbuf, sizeof(lrbuf)), strlen(mess)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif /* OSSL_NO_USABLE_TLS1_3 */
static int test_ssl_clear(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
#ifdef OPENSSL_NO_TLS1_2
if (idx == 1)
return 1;
#endif
/* Create an initial connection */
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey))
|| (idx == 1
&& !TEST_true(SSL_CTX_set_max_proto_version(cctx,
TLS1_2_VERSION)))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
serverssl = NULL;
/* Clear clientssl - we're going to reuse the object */
if (!TEST_true(SSL_clear(clientssl)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl)))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/* Parse CH and retrieve any MFL extension value if present */
static int get_MFL_from_client_hello(BIO *bio, int *mfl_codemfl_code)
{
long len;
unsigned char *data;
PACKET pkt, pkt2, pkt3;
unsigned int MFL_code = 0, type = 0;
if (!TEST_uint_gt(len = BIO_get_mem_data(bio, (char **) &data), 0))
goto end;
memset(&pkt, 0, sizeof(pkt));
memset(&pkt2, 0, sizeof(pkt2));
memset(&pkt3, 0, sizeof(pkt3));
if (!TEST_long_gt(len, 0)
|| !TEST_true(PACKET_buf_init(&pkt, data, len))
/* Skip the record header */
|| !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH)
/* Skip the handshake message header */
|| !TEST_true(PACKET_forward(&pkt, SSL3_HM_HEADER_LENGTH))
/* Skip client version and random */
|| !TEST_true(PACKET_forward(&pkt, CLIENT_VERSION_LEN
+ SSL3_RANDOM_SIZE))
/* Skip session id */
|| !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
/* Skip ciphers */
|| !TEST_true(PACKET_get_length_prefixed_2(&pkt, &pkt2))
/* Skip compression */
|| !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
/* Extensions len */
|| !TEST_true(PACKET_as_length_prefixed_2(&pkt, &pkt2)))
goto end;
/* Loop through all extensions */
while (PACKET_remaining(&pkt2)) {
if (!TEST_true(PACKET_get_net_2(&pkt2, &type))
|| !TEST_true(PACKET_get_length_prefixed_2(&pkt2, &pkt3)))
goto end;
if (type == TLSEXT_TYPE_max_fragment_length) {
if (!TEST_uint_ne(PACKET_remaining(&pkt3), 0)
|| !TEST_true(PACKET_get_1(&pkt3, &MFL_code)))
goto end;
*mfl_codemfl_code = MFL_code;
return 1;
}
}
end:
return 0;
}
/* Maximum-Fragment-Length TLS extension mode to test */
static const unsigned char max_fragment_len_test[] = {
TLSEXT_max_fragment_length_512,
TLSEXT_max_fragment_length_1024,
TLSEXT_max_fragment_length_2048,
TLSEXT_max_fragment_length_4096
};
static int test_max_fragment_len_ext(int idx_tst)
{
SSL_CTX *ctx = NULL;
SSL *con = NULL;
int testresult = 0, MFL_mode = 0;
BIO *rbio, *wbio;
if (!TEST_true(create_ssl_ctx_pair(libctx, NULL, TLS_client_method(),
TLS1_VERSION, 0, NULL, &ctx, NULL,
NULL)))
return 0;
if (!TEST_true(SSL_CTX_set_tlsext_max_fragment_length(
ctx, max_fragment_len_test[idx_tst])))
goto end;
con = SSL_new(ctx);
if (!TEST_ptr(con))
goto end;
rbio = BIO_new(BIO_s_mem());
wbio = BIO_new(BIO_s_mem());
if (!TEST_ptr(rbio)|| !TEST_ptr(wbio)) {
BIO_free(rbio);
BIO_free(wbio);
goto end;
}
SSL_set_bio(con, rbio, wbio);
if (!TEST_int_le(SSL_connect(con), 0)) {
/* This shouldn't succeed because we don't have a server! */
goto end;
}
if (!TEST_true(get_MFL_from_client_hello(wbio, &MFL_mode)))
/* no MFL in client hello */
goto end;
if (!TEST_true(max_fragment_len_test[idx_tst] == MFL_mode))
goto end;
testresult = 1;
end:
SSL_free(con);
SSL_CTX_free(ctx);
return testresult;
}
#ifndef OSSL_NO_USABLE_TLS1_3
static int test_pha_key_update(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
return 0;
if (!TEST_true(SSL_CTX_set_min_proto_version(sctx, TLS1_3_VERSION))
|| !TEST_true(SSL_CTX_set_max_proto_version(sctx, TLS1_3_VERSION))
|| !TEST_true(SSL_CTX_set_min_proto_version(cctx, TLS1_3_VERSION))
|| !TEST_true(SSL_CTX_set_max_proto_version(cctx, TLS1_3_VERSION)))
goto end;
SSL_CTX_set_post_handshake_auth(cctx, 1);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
SSL_set_verify(serverssl, SSL_VERIFY_PEER, NULL);
if (!TEST_true(SSL_verify_client_post_handshake(serverssl)))
goto end;
if (!TEST_true(SSL_key_update(clientssl, SSL_KEY_UPDATE_NOT_REQUESTED)))
goto end;
/* Start handshake on the server */
if (!TEST_int_eq(SSL_do_handshake(serverssl), 1))
goto end;
/* Starts with SSL_connect(), but it's really just SSL_do_handshake() */
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif
#if !defined(OPENSSL_NO_SRP) && !defined(OPENSSL_NO_TLS1_2)
static SRP_VBASE *vbase = NULL;
static int ssl_srp_cb(SSL *s, int *ad, void *arg)
{
int ret = SSL3_AL_FATAL;
char *username;
SRP_user_pwd *user = NULL;
username = SSL_get_srp_username(s);
if (username == NULL) {
*ad = SSL_AD_INTERNAL_ERROR;
goto err;
}
user = SRP_VBASE_get1_by_user(vbase, username);
if (user == NULL) {
*ad = SSL_AD_INTERNAL_ERROR;
goto err;
}
if (SSL_set_srp_server_param(s, user->N, user->g, user->s, user->v,
user->info) <= 0) {
*ad = SSL_AD_INTERNAL_ERROR;
goto err;
}
ret = 0;
err:
SRP_user_pwd_free(user);
return ret;
}
static int create_new_vfile(char *userid, char *password, const char *filename)
{
char *gNid = NULL;
OPENSSL_STRING *row = OPENSSL_zalloc(sizeof(row) * (DB_NUMBER + 1));
TXT_DB *db = NULL;
int ret = 0;
BIO *out = NULL, *dummy = BIO_new_mem_buf("", 0);
size_t i;
if (!TEST_ptr(dummy) || !TEST_ptr(row))
goto end;
gNid = SRP_create_verifier_ex(userid, password, &row[DB_srpsalt],
&row[DB_srpverifier], NULL, NULL, libctx, NULL);
if (!TEST_ptr(gNid))
goto end;
/*
* The only way to create an empty TXT_DB is to provide a BIO with no data
* in it!
*/
db = TXT_DB_read(dummy, DB_NUMBER);
if (!TEST_ptr(db))
goto end;
out = BIO_new_file(filename, "w");
if (!TEST_ptr(out))
goto end;
row[DB_srpid] = OPENSSL_strdup(userid);
row[DB_srptype] = OPENSSL_strdup("V");
row[DB_srpgN] = OPENSSL_strdup(gNid);
if (!TEST_ptr(row[DB_srpid])
|| !TEST_ptr(row[DB_srptype])
|| !TEST_ptr(row[DB_srpgN])
|| !TEST_true(TXT_DB_insert(db, row)))
goto end;
row = NULL;
if (TXT_DB_write(out, db) <= 0)
goto end;
ret = 1;
end:
if (row != NULL) {
for (i = 0; i < DB_NUMBER; i++)
OPENSSL_free(row[i]);
}
OPENSSL_free(row);
BIO_free(dummy);
BIO_free(out);
TXT_DB_free(db);
return ret;
}
static int create_new_vbase(char *userid, char *password)
{
BIGNUM *verifier = NULL, *salt = NULL;
const SRP_gN *lgN = NULL;
SRP_user_pwd *user_pwd = NULL;
int ret = 0;
lgN = SRP_get_default_gN(NULL);
if (!TEST_ptr(lgN))
goto end;
if (!TEST_true(SRP_create_verifier_BN_ex(userid, password, &salt, &verifier,
lgN->N, lgN->g, libctx, NULL)))
goto end;
user_pwd = OPENSSL_zalloc(sizeof(*user_pwd));
if (!TEST_ptr(user_pwd))
goto end;
user_pwd->N = lgN->N;
user_pwd->g = lgN->g;
user_pwd->id = OPENSSL_strdup(userid);
if (!TEST_ptr(user_pwd->id))
goto end;
user_pwd->v = verifier;
user_pwd->s = salt;
verifier = salt = NULL;
if (sk_SRP_user_pwd_insert(vbase->users_pwd, user_pwd, 0) == 0)
goto end;
user_pwd = NULL;
ret = 1;
end:
SRP_user_pwd_free(user_pwd);
BN_free(salt);
BN_free(verifier);
return ret;
}
/*
* SRP tests
*
* Test 0: Simple successful SRP connection, new vbase
* Test 1: Connection failure due to bad password, new vbase
* Test 2: Simple successful SRP connection, vbase loaded from existing file
* Test 3: Connection failure due to bad password, vbase loaded from existing
* file
* Test 4: Simple successful SRP connection, vbase loaded from new file
* Test 5: Connection failure due to bad password, vbase loaded from new file
*/
static int test_srp(int tst)
{
char *userid = "test", *password = "password", *tstsrpfile;
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int ret, testresult = 0;
vbase = SRP_VBASE_new(NULL);
if (!TEST_ptr(vbase))
goto end;
if (tst == 0 || tst == 1) {
if (!TEST_true(create_new_vbase(userid, password)))
goto end;
} else {
if (tst == 4 || tst == 5) {
if (!TEST_true(create_new_vfile(userid, password, tmpfilename)))
goto end;
tstsrpfile = tmpfilename;
} else {
tstsrpfile = srpvfile;
}
if (!TEST_int_eq(SRP_VBASE_init(vbase, tstsrpfile), SRP_NO_ERROR))
goto end;
}
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
if (!TEST_int_gt(SSL_CTX_set_srp_username_callback(sctx, ssl_srp_cb), 0)
|| !TEST_true(SSL_CTX_set_cipher_list(cctx, "SRP-AES-128-CBC-SHA"))
|| !TEST_true(SSL_CTX_set_max_proto_version(sctx, TLS1_2_VERSION))
|| !TEST_true(SSL_CTX_set_max_proto_version(cctx, TLS1_2_VERSION))
|| !TEST_int_gt(SSL_CTX_set_srp_username(cctx, userid), 0))
goto end;
if (tst % 2 == 1) {
if (!TEST_int_gt(SSL_CTX_set_srp_password(cctx, "badpass"), 0))
goto end;
} else {
if (!TEST_int_gt(SSL_CTX_set_srp_password(cctx, password), 0))
goto end;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
ret = create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE);
if (ret) {
if (!TEST_true(tst % 2 == 0))
goto end;
} else {
if (!TEST_true(tst % 2 == 1))
goto end;
}
testresult = 1;
end:
SRP_VBASE_free(vbase);
vbase = NULL;
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif
static int info_cb_failed = 0;
static int info_cb_offset = 0;
static int info_cb_this_state = -1;
static struct info_cb_states_st {
int where;
const char *statestr;
} info_cb_states[][60] = {
{
/* TLSv1.2 server followed by resumption */
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "TRCH"}, {SSL_CB_LOOP, "TWSH"},
{SSL_CB_LOOP, "TWSC"}, {SSL_CB_LOOP, "TWSKE"}, {SSL_CB_LOOP, "TWSD"},
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TWSD"}, {SSL_CB_LOOP, "TRCKE"},
{SSL_CB_LOOP, "TRCCS"}, {SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TWST"},
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWFIN"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
{SSL_CB_ALERT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
{SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "TRCH"},
{SSL_CB_LOOP, "TWSH"}, {SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWFIN"},
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TWFIN"}, {SSL_CB_LOOP, "TRCCS"},
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
{SSL_CB_EXIT, NULL}, {0, NULL},
}, {
/* TLSv1.2 client followed by resumption */
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TWCH"},
{SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TRSC"}, {SSL_CB_LOOP, "TRSKE"},
{SSL_CB_LOOP, "TRSD"}, {SSL_CB_LOOP, "TWCKE"}, {SSL_CB_LOOP, "TWCCS"},
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TWFIN"},
{SSL_CB_LOOP, "TRST"}, {SSL_CB_LOOP, "TRCCS"}, {SSL_CB_LOOP, "TRFIN"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL}, {SSL_CB_ALERT, NULL},
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TWCH"},
{SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TRCCS"}, {SSL_CB_LOOP, "TRFIN"},
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWFIN"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL}, {0, NULL},
}, {
/* TLSv1.3 server followed by resumption */
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "TRCH"}, {SSL_CB_LOOP, "TWSH"},
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"}, {SSL_CB_LOOP, "TWSC"},
{SSL_CB_LOOP, "TWSCV"}, {SSL_CB_LOOP, "TWFIN"}, {SSL_CB_LOOP, "TED"},
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TRFIN"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_LOOP, "TWST"},
{SSL_CB_LOOP, "TWST"}, {SSL_CB_EXIT, NULL}, {SSL_CB_ALERT, NULL},
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "TRCH"}, {SSL_CB_LOOP, "TWSH"},
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"}, {SSL_CB_LOOP, "TWFIN"},
{SSL_CB_LOOP, "TED"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TED"},
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
{SSL_CB_LOOP, "TWST"}, {SSL_CB_EXIT, NULL}, {0, NULL},
}, {
/* TLSv1.3 client followed by resumption */
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TWCH"},
{SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"}, {SSL_CB_LOOP, "TRSC"},
{SSL_CB_LOOP, "TRSCV"}, {SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TWCCS"},
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK"}, {SSL_CB_LOOP, "SSLOK"},
{SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK"},
{SSL_CB_LOOP, "SSLOK"}, {SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL},
{SSL_CB_ALERT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
{SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "TWCH"}, {SSL_CB_EXIT, NULL},
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"},
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWFIN"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
{SSL_CB_LOOP, "SSLOK"}, {SSL_CB_LOOP, "SSLOK"}, {SSL_CB_LOOP, "TRST"},
{SSL_CB_EXIT, NULL}, {0, NULL},
}, {
/* TLSv1.3 server, early_data */
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "TRCH"}, {SSL_CB_LOOP, "TWSH"},
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"}, {SSL_CB_LOOP, "TWFIN"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "TED"},
{SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TWEOED"}, {SSL_CB_LOOP, "TRFIN"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_LOOP, "TWST"},
{SSL_CB_EXIT, NULL}, {0, NULL},
}, {
/* TLSv1.3 client, early_data */
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_LOOP, "TWCCS"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "TED"},
{SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"},
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TPEDE"}, {SSL_CB_LOOP, "TWEOED"},
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK"}, {SSL_CB_LOOP, "SSLOK"},
{SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL}, {0, NULL},
}, {
/* TLSv1.3 server, certificate compression, followed by resumption */
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "TRCH"}, {SSL_CB_LOOP, "TWSH"},
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"}, {SSL_CB_LOOP, "TWSCC"},
{SSL_CB_LOOP, "TWSCV"}, {SSL_CB_LOOP, "TWFIN"}, {SSL_CB_LOOP, "TED"},
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TRFIN"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_LOOP, "TWST"},
{SSL_CB_LOOP, "TWST"}, {SSL_CB_EXIT, NULL}, {SSL_CB_ALERT, NULL},
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "TRCH"}, {SSL_CB_LOOP, "TWSH"},
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"}, {SSL_CB_LOOP, "TWFIN"},
{SSL_CB_LOOP, "TED"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TED"},
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
{SSL_CB_LOOP, "TWST"}, {SSL_CB_EXIT, NULL}, {0, NULL},
}, {
/* TLSv1.3 client, certificate compression, followed by resumption */
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT"},
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TWCH"},
{SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"}, {SSL_CB_LOOP, "TRSCC"},
{SSL_CB_LOOP, "TRSCV"}, {SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TWCCS"},
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK"}, {SSL_CB_LOOP, "SSLOK"},
{SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK"},
{SSL_CB_LOOP, "SSLOK"}, {SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL},
{SSL_CB_ALERT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
{SSL_CB_LOOP, "PINIT"}, {SSL_CB_LOOP, "TWCH"}, {SSL_CB_EXIT, NULL},
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"},
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWFIN"},
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
{SSL_CB_LOOP, "SSLOK"}, {SSL_CB_LOOP, "SSLOK"}, {SSL_CB_LOOP, "TRST"},
{SSL_CB_EXIT, NULL}, {0, NULL},
}, {
{0, NULL},
}
};
static void sslapi_info_callback(const SSL *s, int where, int ret)
{
struct info_cb_states_st *state = info_cb_states[info_cb_offset];
/* We do not ever expect a connection to fail in this test */
if (!TEST_false(ret == 0)) {
info_cb_failed = 1;
return;
}
/*
* Do some sanity checks. We never expect these things to happen in this
* test
*/
if (!TEST_false((SSL_is_server(s) && (where & SSL_ST_CONNECT) != 0))
|| !TEST_false(!SSL_is_server(s) && (where & SSL_ST_ACCEPT) != 0)
|| !TEST_int_ne(state[++info_cb_this_state].where, 0)) {
info_cb_failed = 1;
return;
}
/* Now check we're in the right state */
if (!TEST_true((where & state[info_cb_this_state].where) != 0)) {
info_cb_failed = 1;
return;
}
if ((where & SSL_CB_LOOP) != 0
&& !TEST_int_eq(strcmp(SSL_state_string(s),
state[info_cb_this_state].statestr), 0)) {
info_cb_failed = 1;
return;
}
/*
* Check that, if we've got SSL_CB_HANDSHAKE_DONE we are not in init
*/
if ((where & SSL_CB_HANDSHAKE_DONE)
&& SSL_in_init((SSL *)s) != 0) {
info_cb_failed = 1;
return;
}
}
/*
* Test the info callback gets called when we expect it to.
*
* Test 0: TLSv1.2, server
* Test 1: TLSv1.2, client
* Test 2: TLSv1.3, server
* Test 3: TLSv1.3, client
* Test 4: TLSv1.3, server, early_data
* Test 5: TLSv1.3, client, early_data
* Test 6: TLSv1.3, server, compressed certificate
* Test 7: TLSv1.3, client, compressed certificate
*/
static int test_info_callback(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
SSL_SESSION *clntsess = NULL;
int testresult = 0;
int tlsvers;
if (tst < 2) {
/* We need either ECDHE or DHE for the TLSv1.2 test to work */
#if !defined(OPENSSL_NO_TLS1_2) && (!defined(OPENSSL_NO_EC) \
|| !defined(OPENSSL_NO_DH))
tlsvers = TLS1_2_VERSION;
#else
return 1;
#endif
} else {
#ifndef OSSL_NO_USABLE_TLS1_3
tlsvers = TLS1_3_VERSION;
#else
return 1;
#endif
}
/* Reset globals */
info_cb_failed = 0;
info_cb_this_state = -1;
info_cb_offset = tst;
#ifndef OSSL_NO_USABLE_TLS1_3
if (tst >= 4 && tst < 6) {
SSL_SESSION *sess = NULL;
size_t written, readbytes;
unsigned char buf[80];
/* early_data tests */
if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
&serverssl, &sess, 0,
SHA384_DIGEST_LENGTH)))
goto end;
/* We don't actually need this reference */
SSL_SESSION_free(sess);
SSL_set_info_callback((tst % 2) == 0 ? serverssl : clientssl,
sslapi_info_callback);
/* Write and read some early data and then complete the connection */
if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
&written))
|| !TEST_size_t_eq(written, strlen(MSG1))
|| !TEST_int_eq(SSL_read_early_data(serverssl, buf,
sizeof(buf), &readbytes),
SSL_READ_EARLY_DATA_SUCCESS)
|| !TEST_mem_eq(MSG1, readbytes, buf, strlen(MSG1))
|| !TEST_int_eq(SSL_get_early_data_status(serverssl),
SSL_EARLY_DATA_ACCEPTED)
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_false(info_cb_failed))
goto end;
testresult = 1;
goto end;
}
#endif
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
tlsvers, tlsvers, &sctx, &cctx, cert,
privkey)))
goto end;
if (!TEST_true(SSL_CTX_set_dh_auto(sctx, 1)))
goto end;
/*
* For even numbered tests we check the server callbacks. For odd numbers we
* check the client.
*/
SSL_CTX_set_info_callback((tst % 2) == 0 ? sctx : cctx,
sslapi_info_callback);
if (tst >= 6) {
if (!SSL_CTX_compress_certs(sctx, 0))
goto end;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_false(info_cb_failed))
goto end;
clntsess = SSL_get1_session(clientssl);
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
/* Now do a resumption */
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
NULL))
|| !TEST_true(SSL_set_session(clientssl, clntsess))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_true(SSL_session_reused(clientssl))
|| !TEST_false(info_cb_failed))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_SESSION_free(clntsess);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
static int test_ssl_pending(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char msg[] = "A test message";
char buf[5];
size_t written, readbytes;
if (tst == 0) {
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
} else {
#ifndef OPENSSL_NO_DTLS
if (!TEST_true(create_ssl_ctx_pair(libctx, DTLS_server_method(),
DTLS_client_method(),
DTLS1_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
# ifdef OPENSSL_NO_DTLS1_2
/* Not supported in the FIPS provider */
if (is_fips) {
testresult = 1;
goto end;
};
/*
* Default sigalgs are SHA1 based in <DTLS1.2 which is in security
* level 0
*/
if (!TEST_true(SSL_CTX_set_cipher_list(sctx, "DEFAULT:@SECLEVEL=0"))
|| !TEST_true(SSL_CTX_set_cipher_list(cctx,
"DEFAULT:@SECLEVEL=0")))
goto end;
# endif
#else
return 1;
#endif
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
if (!TEST_int_eq(SSL_pending(clientssl), 0)
|| !TEST_false(SSL_has_pending(clientssl))
|| !TEST_int_eq(SSL_pending(serverssl), 0)
|| !TEST_false(SSL_has_pending(serverssl))
|| !TEST_true(SSL_write_ex(serverssl, msg, sizeof(msg), &written))
|| !TEST_size_t_eq(written, sizeof(msg))
|| !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes))
|| !TEST_size_t_eq(readbytes, sizeof(buf))
|| !TEST_int_eq(SSL_pending(clientssl), (int)(written - readbytes))
|| !TEST_true(SSL_has_pending(clientssl)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
static struct {
unsigned int maxprot;
const char *clntciphers;
const char *clnttls13ciphers;
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
* TLSv1.3 is enabled but TLSv1.2 is disabled.
*/
#if defined(OSSL_NO_USABLE_TLS1_3) || !defined(OPENSSL_NO_TLS1_2)
{
TLS1_2_VERSION,
"AES128-SHA:AES256-SHA",
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"
},
{
TLS1_2_VERSION,
"AES128-SHA:AES256-SHA",
NULL,
"AES128-SHA:DHE-RSA-AES128-SHA",
NULL,
"AES128-SHA",
"AES128-SHA"
},
#endif
/*
* This test combines TLSv1.3 and TLSv1.2 ciphersuites so they must both be
* enabled.
*/
#if !defined(OSSL_NO_USABLE_TLS1_3) && !defined(OPENSSL_NO_TLS1_2) \
&& !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
{
TLS1_3_VERSION,
"AES128-SHA:AES256-SHA",
NULL,
"AES256-SHA:AES128-SHA256",
NULL,
"TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:"
"TLS_AES_128_GCM_SHA256:AES256-SHA",
"TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:AES256-SHA"
},
#endif
#ifndef OSSL_NO_USABLE_TLS1_3
{
TLS1_3_VERSION,
"AES128-SHA",
"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 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];
OSSL_LIB_CTX *tmplibctx = OSSL_LIB_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_ex(tmplibctx, NULL, TLS_client_method());
if (!TEST_ptr(cctx))
goto end;
} else {
sctx = SSL_CTX_new_ex(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(),
TLS1_VERSION,
shared_ciphers_data[tst].maxprot,
&sctx, &cctx, cert, privkey)))
goto end;
if (!TEST_true(SSL_CTX_set_cipher_list(cctx,
shared_ciphers_data[tst].clntciphers))
|| (shared_ciphers_data[tst].clnttls13ciphers != NULL
&& !TEST_true(SSL_CTX_set_ciphersuites(cctx,
shared_ciphers_data[tst].clnttls13ciphers)))
|| !TEST_true(SSL_CTX_set_cipher_list(sctx,
shared_ciphers_data[tst].srvrciphers))
|| (shared_ciphers_data[tst].srvrtls13ciphers != NULL
&& !TEST_true(SSL_CTX_set_ciphersuites(sctx,
shared_ciphers_data[tst].srvrtls13ciphers))))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
if (!TEST_ptr(SSL_get_shared_ciphers(serverssl, buf, sizeof(buf)))
|| !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;
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
OSSL_LIB_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;
static SSL_TICKET_RETURN tick_dec_ret = SSL_TICKET_RETURN_ABORT;
static int gen_tick_cb(SSL *s, void *arg)
{
gen_tick_called = 1;
return SSL_SESSION_set1_ticket_appdata(SSL_get_session(s), appdata,
strlen(appdata));
}
static SSL_TICKET_RETURN dec_tick_cb(SSL *s, SSL_SESSION *ss,
const unsigned char *keyname,
size_t keyname_length,
SSL_TICKET_STATUS status,
void *arg)
{
void *tickdata;
size_t tickdlen;
dec_tick_called = 1;
if (status == SSL_TICKET_EMPTY)
return SSL_TICKET_RETURN_IGNORE_RENEW;
if (!TEST_true(status == SSL_TICKET_SUCCESS
|| status == SSL_TICKET_SUCCESS_RENEW))
return SSL_TICKET_RETURN_ABORT;
if (!TEST_true(SSL_SESSION_get0_ticket_appdata(ss, &tickdata,
&tickdlen))
|| !TEST_size_t_eq(tickdlen, strlen(appdata))
|| !TEST_int_eq(memcmp(tickdata, appdata, tickdlen), 0))
return SSL_TICKET_RETURN_ABORT;
if (tick_key_cb_called) {
/* Don't change what the ticket key callback wanted to do */
switch (status) {
case SSL_TICKET_NO_DECRYPT:
return SSL_TICKET_RETURN_IGNORE_RENEW;
case SSL_TICKET_SUCCESS:
return SSL_TICKET_RETURN_USE;
case SSL_TICKET_SUCCESS_RENEW:
return SSL_TICKET_RETURN_USE_RENEW;
default:
return SSL_TICKET_RETURN_ABORT;
}
}
return tick_dec_ret;
}
#ifndef OPENSSL_NO_DEPRECATED_3_0
static int tick_key_cb(SSL *s, unsigned char key_name[16],
unsigned char iv[EVP_MAX_IV_LENGTH], EVP_CIPHER_CTX *ctx,
HMAC_CTX *hctx, int enc)
{
const unsigned char tick_aes_key[16] = "0123456789abcdef";
const unsigned char tick_hmac_key[16] = "0123456789abcdef";
EVP_CIPHER *aes128cbc;
EVP_MD *sha256;
int ret;
tick_key_cb_called = 1;
if (tick_key_renew == -1)
return 0;
aes128cbc = EVP_CIPHER_fetch(libctx, "AES-128-CBC", NULL);
if (!TEST_ptr(aes128cbc))
return 0;
sha256 = EVP_MD_fetch(libctx, "SHA-256", NULL);
if (!TEST_ptr(sha256)) {
EVP_CIPHER_free(aes128cbc);
return 0;
}
memset(iv, 0, AES_BLOCK_SIZE);
memset(key_name, 0, 16);
if (aes128cbc == NULL
|| sha256 == NULL
|| !EVP_CipherInit_ex(ctx, aes128cbc, NULL, tick_aes_key, iv, enc)
|| !HMAC_Init_ex(hctx, tick_hmac_key, sizeof(tick_hmac_key), sha256,
NULL))
ret = -1;
else
ret = tick_key_renew ? 2 : 1;
EVP_CIPHER_free(aes128cbc);
EVP_MD_free(sha256);
return ret;
}
#endif
static int tick_key_evp_cb(SSL *s, unsigned char key_name[16],
unsigned char iv[EVP_MAX_IV_LENGTH],
EVP_CIPHER_CTX *ctx, EVP_MAC_CTX *hctx, int enc)
{
const unsigned char tick_aes_key[16] = "0123456789abcdef";
unsigned char tick_hmac_key[16] = "0123456789abcdef";
OSSL_PARAM params[2];
EVP_CIPHER *aes128cbc;
int ret;
tick_key_cb_called = 1;
if (tick_key_renew == -1)
return 0;
aes128cbc = EVP_CIPHER_fetch(libctx, "AES-128-CBC", NULL);
if (!TEST_ptr(aes128cbc))
return 0;
memset(iv, 0, AES_BLOCK_SIZE);
memset(key_name, 0, 16);
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,
"SHA256", 0);
params[1] = OSSL_PARAM_construct_end();
if (aes128cbc == NULL
|| !EVP_CipherInit_ex(ctx, aes128cbc, NULL, tick_aes_key, iv, enc)
|| !EVP_MAC_init(hctx, tick_hmac_key, sizeof(tick_hmac_key),
params))
ret = -1;
else
ret = tick_key_renew ? 2 : 1;
EVP_CIPHER_free(aes128cbc);
return ret;
}
/*
* Test the various ticket callbacks
* Test 0: TLSv1.2, no ticket key callback, no ticket, no renewal
* Test 1: TLSv1.3, no ticket key callback, no ticket, no renewal
* Test 2: TLSv1.2, no ticket key callback, no ticket, renewal
* Test 3: TLSv1.3, no ticket key callback, no ticket, renewal
* Test 4: TLSv1.2, no ticket key callback, ticket, no renewal
* Test 5: TLSv1.3, no ticket key callback, ticket, no renewal
* Test 6: TLSv1.2, no ticket key callback, ticket, renewal
* Test 7: TLSv1.3, no ticket key callback, ticket, renewal
* Test 8: TLSv1.2, old ticket key callback, ticket, no renewal
* Test 9: TLSv1.3, old ticket key callback, ticket, no renewal
* Test 10: TLSv1.2, old ticket key callback, ticket, renewal
* Test 11: TLSv1.3, old ticket key callback, ticket, renewal
* Test 12: TLSv1.2, old ticket key callback, no ticket
* Test 13: TLSv1.3, old ticket key callback, no ticket
* Test 14: TLSv1.2, ticket key callback, ticket, no renewal
* Test 15: TLSv1.3, ticket key callback, ticket, no renewal
* Test 16: TLSv1.2, ticket key callback, ticket, renewal
* Test 17: TLSv1.3, ticket key callback, ticket, renewal
* Test 18: TLSv1.2, ticket key callback, no ticket
* Test 19: TLSv1.3, ticket key callback, no ticket
*/
static int test_ticket_callbacks(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
SSL_SESSION *clntsess = NULL;
int testresult = 0;
#ifdef OPENSSL_NO_TLS1_2
if (tst % 2 == 0)
return 1;
#endif
#ifdef OSSL_NO_USABLE_TLS1_3
if (tst % 2 == 1)
return 1;
#endif
#ifdef OPENSSL_NO_DEPRECATED_3_0
if (tst >= 8 && tst <= 13)
return 1;
#endif
gen_tick_called = dec_tick_called = tick_key_cb_called = 0;
/* Which tests the ticket key callback should request renewal for */
if (tst == 10 || tst == 11 || tst == 16 || tst == 17)
tick_key_renew = 1;
else if (tst == 12 || tst == 13 || tst == 18 || tst == 19)
tick_key_renew = -1; /* abort sending the ticket/0-length ticket */
else
tick_key_renew = 0;
/* Which tests the decrypt ticket callback should request renewal for */
switch (tst) {
case 0:
case 1:
tick_dec_ret = SSL_TICKET_RETURN_IGNORE;
break;
case 2:
case 3:
tick_dec_ret = SSL_TICKET_RETURN_IGNORE_RENEW;
break;
case 4:
case 5:
tick_dec_ret = SSL_TICKET_RETURN_USE;
break;
case 6:
case 7:
tick_dec_ret = SSL_TICKET_RETURN_USE_RENEW;
break;
default:
tick_dec_ret = SSL_TICKET_RETURN_ABORT;
}
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
((tst % 2) == 0) ? TLS1_2_VERSION
: TLS1_3_VERSION,
&sctx, &cctx, cert, privkey)))
goto end;
/*
* We only want sessions to resume from tickets - not the session cache. So
* switch the cache off.
*/
if (!TEST_true(SSL_CTX_set_session_cache_mode(sctx, SSL_SESS_CACHE_OFF)))
goto end;
if (!TEST_true(SSL_CTX_set_session_ticket_cb(sctx, gen_tick_cb, dec_tick_cb,
NULL)))
goto end;
if (tst >= 14) {
if (!TEST_true(SSL_CTX_set_tlsext_ticket_key_evp_cb(sctx, tick_key_evp_cb)))
goto end;
#ifndef OPENSSL_NO_DEPRECATED_3_0
} else if (tst >= 8) {
if (!TEST_true(SSL_CTX_set_tlsext_ticket_key_cb(sctx, tick_key_cb)))
goto end;
#endif
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
/*
* The decrypt ticket key callback in TLSv1.2 should be called even though
* we have no ticket yet, because it gets called with a status of
* SSL_TICKET_EMPTY (the client indicates support for tickets but does not
* actually send any ticket data). This does not happen in TLSv1.3 because
* it is not valid to send empty ticket data in TLSv1.3.
*/
if (!TEST_int_eq(gen_tick_called, 1)
|| !TEST_int_eq(dec_tick_called, ((tst % 2) == 0) ? 1 : 0))
goto end;
gen_tick_called = dec_tick_called = 0;
clntsess = SSL_get1_session(clientssl);
SSL_shutdown(clientssl);
SSL_shutdown(serverssl);
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
/* Now do a resumption */
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
NULL))
|| !TEST_true(SSL_set_session(clientssl, clntsess))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
if (tick_dec_ret == SSL_TICKET_RETURN_IGNORE
|| tick_dec_ret == SSL_TICKET_RETURN_IGNORE_RENEW
|| tick_key_renew == -1) {
if (!TEST_false(SSL_session_reused(clientssl)))
goto end;
} else {
if (!TEST_true(SSL_session_reused(clientssl)))
goto end;
}
if (!TEST_int_eq(gen_tick_called,
(tick_key_renew
|| tick_dec_ret == SSL_TICKET_RETURN_IGNORE_RENEW
|| tick_dec_ret == SSL_TICKET_RETURN_USE_RENEW)
? 1 : 0)
/* There is no ticket to decrypt in tests 13 and 19 */
|| !TEST_int_eq(dec_tick_called, (tst == 13 || tst == 19) ? 0 : 1))
goto end;
testresult = 1;
end:
SSL_SESSION_free(clntsess);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test incorrect shutdown.
* Test 0: client does not shutdown properly,
* server does not set SSL_OP_IGNORE_UNEXPECTED_EOF,
* server should get SSL_ERROR_SSL
* Test 1: client does not shutdown properly,
* server sets SSL_OP_IGNORE_UNEXPECTED_EOF,
* server should get SSL_ERROR_ZERO_RETURN
*/
static int test_incorrect_shutdown(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char buf[80];
BIO *c2s;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), 0, 0,
&sctx, &cctx, cert, privkey)))
goto end;
if (tst == 1)
SSL_CTX_set_options(sctx, SSL_OP_IGNORE_UNEXPECTED_EOF);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
c2s = SSL_get_rbio(serverssl);
BIO_set_mem_eof_return(c2s, 0);
if (!TEST_false(SSL_read(serverssl, buf, sizeof(buf))))
goto end;
if (tst == 0 && !TEST_int_eq(SSL_get_error(serverssl, 0), SSL_ERROR_SSL) )
goto end;
if (tst == 1 && !TEST_int_eq(SSL_get_error(serverssl, 0), SSL_ERROR_ZERO_RETURN) )
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test bi-directional shutdown.
* Test 0: TLSv1.2
* Test 1: TLSv1.2, server continues to read/write after client shutdown
* Test 2: TLSv1.3, no pending NewSessionTicket messages
* Test 3: TLSv1.3, pending NewSessionTicket messages
* Test 4: TLSv1.3, server continues to read/write after client shutdown, server
* sends key update, client reads it
* Test 5: TLSv1.3, server continues to read/write after client shutdown, server
* sends CertificateRequest, client reads and ignores it
* Test 6: TLSv1.3, server continues to read/write after client shutdown, client
* doesn't read it
*/
static int test_shutdown(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char msg[] = "A test message";
char buf[80];
size_t written, readbytes;
SSL_SESSION *sess;
#ifdef OPENSSL_NO_TLS1_2
if (tst <= 1)
return 1;
#endif
#ifdef OSSL_NO_USABLE_TLS1_3
if (tst >= 2)
return 1;
#endif
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
(tst <= 1) ? TLS1_2_VERSION
: TLS1_3_VERSION,
&sctx, &cctx, cert, privkey)))
goto end;
if (tst == 5)
SSL_CTX_set_post_handshake_auth(cctx, 1);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (tst == 3) {
if (!TEST_true(create_bare_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE, 1, 0))
|| !TEST_ptr_ne(sess = SSL_get_session(clientssl), NULL)
|| !TEST_false(SSL_SESSION_is_resumable(sess)))
goto end;
} else if (!TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
|| !TEST_ptr_ne(sess = SSL_get_session(clientssl), NULL)
|| !TEST_true(SSL_SESSION_is_resumable(sess))) {
goto end;
}
if (!TEST_int_eq(SSL_shutdown(clientssl), 0))
goto end;
if (tst >= 4) {
/*
* Reading on the server after the client has sent close_notify should
* fail and provide SSL_ERROR_ZERO_RETURN
*/
if (!TEST_false(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))
|| !TEST_int_eq(SSL_get_error(serverssl, 0),
SSL_ERROR_ZERO_RETURN)
|| !TEST_int_eq(SSL_get_shutdown(serverssl),
SSL_RECEIVED_SHUTDOWN)
/*
* Even though we're shutdown on receive we should still be
* able to write.
*/
|| !TEST_true(SSL_write(serverssl, msg, sizeof(msg))))
goto end;
if (tst == 4
&& !TEST_true(SSL_key_update(serverssl,
SSL_KEY_UPDATE_REQUESTED)))
goto end;
if (tst == 5) {
SSL_set_verify(serverssl, SSL_VERIFY_PEER, NULL);
if (!TEST_true(SSL_verify_client_post_handshake(serverssl)))
goto end;
}
if ((tst == 4 || tst == 5)
&& !TEST_true(SSL_write(serverssl, msg, sizeof(msg))))
goto end;
if (!TEST_int_eq(SSL_shutdown(serverssl), 1))
goto end;
if (tst == 4 || tst == 5) {
/* Should still be able to read data from server */
if (!TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf),
&readbytes))
|| !TEST_size_t_eq(readbytes, sizeof(msg))
|| !TEST_int_eq(memcmp(msg, buf, readbytes), 0)
|| !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf),
&readbytes))
|| !TEST_size_t_eq(readbytes, sizeof(msg))
|| !TEST_int_eq(memcmp(msg, buf, readbytes), 0))
goto end;
}
}
/* Writing on the client after sending close_notify shouldn't be possible */
if (!TEST_false(SSL_write_ex(clientssl, msg, sizeof(msg), &written)))
goto end;
if (tst < 4) {
/*
* For these tests the client has sent close_notify but it has not yet
* been received by the server. The server has not sent close_notify
* yet.
*/
if (!TEST_int_eq(SSL_shutdown(serverssl), 0)
/*
* Writing on the server after sending close_notify shouldn't
* be possible.
*/
|| !TEST_false(SSL_write_ex(serverssl, msg, sizeof(msg), &written))
|| !TEST_int_eq(SSL_shutdown(clientssl), 1)
|| !TEST_ptr_ne(sess = SSL_get_session(clientssl), NULL)
|| !TEST_true(SSL_SESSION_is_resumable(sess))
|| !TEST_int_eq(SSL_shutdown(serverssl), 1))
goto end;
} else if (tst == 4 || tst == 5) {
/*
* In this test the client has sent close_notify and it has been
* received by the server which has responded with a close_notify. The
* client needs to read the close_notify sent by the server.
*/
if (!TEST_int_eq(SSL_shutdown(clientssl), 1)
|| !TEST_ptr_ne(sess = SSL_get_session(clientssl), NULL)
|| !TEST_true(SSL_SESSION_is_resumable(sess)))
goto end;
} else {
/*
* tst == 6
*
* The client has sent close_notify and is expecting a close_notify
* back, but instead there is application data first. The shutdown
* should fail with a fatal error.
*/
if (!TEST_int_eq(SSL_shutdown(clientssl), -1)
|| !TEST_int_eq(SSL_get_error(clientssl, -1), SSL_ERROR_SSL))
goto end;
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test that sending close_notify alerts works correctly in the case of a
* retryable write failure.
*/
static int test_async_shutdown(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
BIO *bretry = BIO_new(bio_s_always_retry()), *tmp = NULL;
if (!TEST_ptr(bretry))
goto end;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
0, 0,
&sctx, &cctx, cert, privkey)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
NULL)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
/* Close write side of clientssl */
if (!TEST_int_eq(SSL_shutdown(clientssl), 0))
goto end;
tmp = SSL_get_wbio(serverssl);
if (!TEST_true(BIO_up_ref(tmp))) {
tmp = NULL;
goto end;
}
SSL_set0_wbio(serverssl, bretry);
bretry = NULL;
/* First server shutdown should fail because of a retrable write failure */
if (!TEST_int_eq(SSL_shutdown(serverssl), -1)
|| !TEST_int_eq(SSL_get_error(serverssl, -1), SSL_ERROR_WANT_WRITE))
goto end;
/* Second server shutdown should fail for the same reason */
if (!TEST_int_eq(SSL_shutdown(serverssl), -1)
|| !TEST_int_eq(SSL_get_error(serverssl, -1), SSL_ERROR_WANT_WRITE))
goto end;
SSL_set0_wbio(serverssl, tmp);
tmp = NULL;
/* Third server shutdown should send close_notify */
if (!TEST_int_eq(SSL_shutdown(serverssl), 0))
goto end;
/* Fourth server shutdown should read close_notify from client and finish */
if (!TEST_int_eq(SSL_shutdown(serverssl), 1))
goto end;
/* Client should also successfully fully shutdown */
if (!TEST_int_eq(SSL_shutdown(clientssl), 1))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
BIO_free(bretry);
BIO_free(tmp);
return testresult;
}
#if !defined(OPENSSL_NO_TLS1_2) || !defined(OSSL_NO_USABLE_TLS1_3)
static int cert_cb_cnt;
static int cert_cb(SSL *s, void *arg)
{
SSL_CTX *ctx = (SSL_CTX *)arg;
BIO *in = NULL;
EVP_PKEY *pkey = NULL;
X509 *x509 = NULL, *rootx = NULL;
STACK_OF(X509) *chain = NULL;
char *rootfile = NULL, *ecdsacert = NULL, *ecdsakey = NULL;
int ret = 0;
if (cert_cb_cnt == 0) {
/* Suspend the handshake */
cert_cb_cnt++;
return -1;
} else if (cert_cb_cnt == 1) {
/*
* Update the SSL_CTX, set the certificate and private key and then
* continue the handshake normally.
*/
if (ctx != NULL && !TEST_ptr(SSL_set_SSL_CTX(s, ctx)))
return 0;
if (!TEST_true(SSL_use_certificate_file(s, cert, SSL_FILETYPE_PEM))
|| !TEST_true(SSL_use_PrivateKey_file(s, privkey,
SSL_FILETYPE_PEM))
|| !TEST_true(SSL_check_private_key(s)))
return 0;
cert_cb_cnt++;
return 1;
} else if (cert_cb_cnt == 3) {
int rv;
rootfile = test_mk_file_path(certsdir, "rootcert.pem");
ecdsacert = test_mk_file_path(certsdir, "server-ecdsa-cert.pem");
ecdsakey = test_mk_file_path(certsdir, "server-ecdsa-key.pem");
if (!TEST_ptr(rootfile) || !TEST_ptr(ecdsacert) || !TEST_ptr(ecdsakey))
goto out;
chain = sk_X509_new_null();
if (!TEST_ptr(chain))
goto out;
if (!TEST_ptr(in = BIO_new(BIO_s_file()))
|| !TEST_int_gt(BIO_read_filename(in, rootfile), 0)
|| !TEST_ptr(rootx = X509_new_ex(libctx, NULL))
|| !TEST_ptr(PEM_read_bio_X509(in, &rootx, NULL, NULL))
|| !TEST_true(sk_X509_push(chain, rootx)))
goto out;
rootx = NULL;
BIO_free(in);
if (!TEST_ptr(in = BIO_new(BIO_s_file()))
|| !TEST_int_gt(BIO_read_filename(in, ecdsacert), 0)
|| !TEST_ptr(x509 = X509_new_ex(libctx, NULL))
|| !TEST_ptr(PEM_read_bio_X509(in, &x509, NULL, NULL)))
goto out;
BIO_free(in);
if (!TEST_ptr(in = BIO_new(BIO_s_file()))
|| !TEST_int_gt(BIO_read_filename(in, ecdsakey), 0)
|| !TEST_ptr(pkey = PEM_read_bio_PrivateKey_ex(in, NULL,
NULL, NULL,
libctx, NULL)))
goto out;
rv = SSL_check_chain(s, x509, pkey, chain);
/*
* If the cert doesn't show as valid here (e.g., because we don't
* have any shared sigalgs), then we will not set it, and there will
* be no certificate at all on the SSL or SSL_CTX. This, in turn,
* will cause tls_choose_sigalgs() to fail the connection.
*/
if ((rv & (CERT_PKEY_VALID | CERT_PKEY_CA_SIGNATURE))
== (CERT_PKEY_VALID | CERT_PKEY_CA_SIGNATURE)) {
if (!SSL_use_cert_and_key(s, x509, pkey, NULL, 1))
goto out;
}
ret = 1;
}
/* Abort the handshake */
out:
OPENSSL_free(ecdsacert);
OPENSSL_free(ecdsakey);
OPENSSL_free(rootfile);
BIO_free(in);
EVP_PKEY_free(pkey);
X509_free(x509);
X509_free(rootx);
OSSL_STACK_OF_X509_free(chain);
return ret;
}
/*
* Test the certificate callback.
* Test 0: Callback fails
* Test 1: Success - no SSL_set_SSL_CTX() in the callback
* Test 2: Success - SSL_set_SSL_CTX() in the callback
* Test 3: Success - Call SSL_check_chain from the callback
* Test 4: Failure - SSL_check_chain fails from callback due to bad cert in the
* chain
* Test 5: Failure - SSL_check_chain fails from callback due to bad ee cert
*/
static int test_cert_cb_int(int prot, int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL, *snictx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0, ret;
#ifdef OPENSSL_NO_EC
/* We use an EC cert in these tests, so we skip in a no-ec build */
if (tst >= 3)
return 1;
#endif
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
prot,
&sctx, &cctx, NULL, NULL)))
goto end;
if (tst == 0)
cert_cb_cnt = -1;
else if (tst >= 3)
cert_cb_cnt = 3;
else
cert_cb_cnt = 0;
if (tst == 2) {
snictx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
if (!TEST_ptr(snictx))
goto end;
}
SSL_CTX_set_cert_cb(sctx, cert_cb, snictx);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (tst == 4) {
/*
* We cause SSL_check_chain() to fail by specifying sig_algs that
* the chain doesn't meet (the root uses an RSA cert)
*/
if (!TEST_true(SSL_set1_sigalgs_list(clientssl,
"ecdsa_secp256r1_sha256")))
goto end;
} else if (tst == 5) {
/*
* We cause SSL_check_chain() to fail by specifying sig_algs that
* the ee cert doesn't meet (the ee uses an ECDSA cert)
*/
if (!TEST_true(SSL_set1_sigalgs_list(clientssl,
"rsa_pss_rsae_sha256:rsa_pkcs1_sha256")))
goto end;
}
ret = create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE);
if (!TEST_true(tst == 0 || tst == 4 || tst == 5 ? !ret : ret)
|| (tst > 0
&& !TEST_int_eq((cert_cb_cnt - 2) * (cert_cb_cnt - 3), 0))) {
goto end;
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
SSL_CTX_free(snictx);
return testresult;
}
#endif
static int test_cert_cb(int tst)
{
int testresult = 1;
#ifndef OPENSSL_NO_TLS1_2
testresult &= test_cert_cb_int(TLS1_2_VERSION, tst);
#endif
#ifndef OSSL_NO_USABLE_TLS1_3
testresult &= test_cert_cb_int(TLS1_3_VERSION, tst);
#endif
return testresult;
}
static int client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
{
X509 *xcert;
EVP_PKEY *privpkey;
BIO *in = NULL;
BIO *priv_in = NULL;
/* Check that SSL_get0_peer_certificate() returns something sensible */
if (!TEST_ptr(SSL_get0_peer_certificate(ssl)))
return 0;
in = BIO_new_file(cert, "r");
if (!TEST_ptr(in))
return 0;
if (!TEST_ptr(xcert = X509_new_ex(libctx, NULL))
|| !TEST_ptr(PEM_read_bio_X509(in, &xcert, NULL, NULL))
|| !TEST_ptr(priv_in = BIO_new_file(privkey, "r"))
|| !TEST_ptr(privpkey = PEM_read_bio_PrivateKey_ex(priv_in, NULL,
NULL, NULL,
libctx, NULL)))
goto err;
*x509 = xcert;
*pkey = privpkey;
BIO_free(in);
BIO_free(priv_in);
return 1;
err:
X509_free(xcert);
BIO_free(in);
BIO_free(priv_in);
return 0;
}
static int test_client_cert_cb(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
#ifdef OPENSSL_NO_TLS1_2
if (tst == 0)
return 1;
#endif
#ifdef OSSL_NO_USABLE_TLS1_3
if (tst == 1)
return 1;
#endif
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
tst == 0 ? TLS1_2_VERSION
: TLS1_3_VERSION,
&sctx, &cctx, cert, privkey)))
goto end;
/*
* Test that setting a client_cert_cb results in a client certificate being
* sent.
*/
SSL_CTX_set_client_cert_cb(cctx, client_cert_cb);
SSL_CTX_set_verify(sctx,
SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
verify_cb);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#if !defined(OPENSSL_NO_TLS1_2) || !defined(OSSL_NO_USABLE_TLS1_3)
/*
* Test setting certificate authorities on both client and server.
*
* Test 0: SSL_CTX_set0_CA_list() only
* Test 1: Both SSL_CTX_set0_CA_list() and SSL_CTX_set_client_CA_list()
* Test 2: Only SSL_CTX_set_client_CA_list()
*/
static int test_ca_names_int(int prot, int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
size_t i;
X509_NAME *name[] = { NULL, NULL, NULL, NULL };
char *strnames[] = { "Jack", "Jill", "John", "Joanne" };
STACK_OF(X509_NAME) *sk1 = NULL, *sk2 = NULL;
const STACK_OF(X509_NAME) *sktmp = NULL;
for (i = 0; i < OSSL_NELEM(name); i++) {
name[i] = X509_NAME_new();
if (!TEST_ptr(name[i])
|| !TEST_true(X509_NAME_add_entry_by_txt(name[i], "CN",
MBSTRING_ASC,
(unsigned char *)
strnames[i],
-1, -1, 0)))
goto end;
}
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
prot,
&sctx, &cctx, cert, privkey)))
goto end;
SSL_CTX_set_verify(sctx, SSL_VERIFY_PEER, NULL);
if (tst == 0 || tst == 1) {
if (!TEST_ptr(sk1 = sk_X509_NAME_new_null())
|| !TEST_true(sk_X509_NAME_push(sk1, X509_NAME_dup(name[0])))
|| !TEST_true(sk_X509_NAME_push(sk1, X509_NAME_dup(name[1])))
|| !TEST_ptr(sk2 = sk_X509_NAME_new_null())
|| !TEST_true(sk_X509_NAME_push(sk2, X509_NAME_dup(name[0])))
|| !TEST_true(sk_X509_NAME_push(sk2, X509_NAME_dup(name[1]))))
goto end;
SSL_CTX_set0_CA_list(sctx, sk1);
SSL_CTX_set0_CA_list(cctx, sk2);
sk1 = sk2 = NULL;
}
if (tst == 1 || tst == 2) {
if (!TEST_ptr(sk1 = sk_X509_NAME_new_null())
|| !TEST_true(sk_X509_NAME_push(sk1, X509_NAME_dup(name[2])))
|| !TEST_true(sk_X509_NAME_push(sk1, X509_NAME_dup(name[3])))
|| !TEST_ptr(sk2 = sk_X509_NAME_new_null())
|| !TEST_true(sk_X509_NAME_push(sk2, X509_NAME_dup(name[2])))
|| !TEST_true(sk_X509_NAME_push(sk2, X509_NAME_dup(name[3]))))
goto end;
SSL_CTX_set_client_CA_list(sctx, sk1);
SSL_CTX_set_client_CA_list(cctx, sk2);
sk1 = sk2 = NULL;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
/*
* We only expect certificate authorities to have been sent to the server
* if we are using TLSv1.3 and SSL_set0_CA_list() was used
*/
sktmp = SSL_get0_peer_CA_list(serverssl);
if (prot == TLS1_3_VERSION
&& (tst == 0 || tst == 1)) {
if (!TEST_ptr(sktmp)
|| !TEST_int_eq(sk_X509_NAME_num(sktmp), 2)
|| !TEST_int_eq(X509_NAME_cmp(sk_X509_NAME_value(sktmp, 0),
name[0]), 0)
|| !TEST_int_eq(X509_NAME_cmp(sk_X509_NAME_value(sktmp, 1),
name[1]), 0))
goto end;
} else if (!TEST_ptr_null(sktmp)) {
goto end;
}
/*
* In all tests we expect certificate authorities to have been sent to the
* client. However, SSL_set_client_CA_list() should override
* SSL_set0_CA_list()
*/
sktmp = SSL_get0_peer_CA_list(clientssl);
if (!TEST_ptr(sktmp)
|| !TEST_int_eq(sk_X509_NAME_num(sktmp), 2)
|| !TEST_int_eq(X509_NAME_cmp(sk_X509_NAME_value(sktmp, 0),
name[tst == 0 ? 0 : 2]), 0)
|| !TEST_int_eq(X509_NAME_cmp(sk_X509_NAME_value(sktmp, 1),
name[tst == 0 ? 1 : 3]), 0))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
for (i = 0; i < OSSL_NELEM(name); i++)
X509_NAME_free(name[i]);
sk_X509_NAME_pop_free(sk1, X509_NAME_free);
sk_X509_NAME_pop_free(sk2, X509_NAME_free);
return testresult;
}
#endif
static int test_ca_names(int tst)
{
int testresult = 1;
#ifndef OPENSSL_NO_TLS1_2
testresult &= test_ca_names_int(TLS1_2_VERSION, tst);
#endif
#ifndef OSSL_NO_USABLE_TLS1_3
testresult &= test_ca_names_int(TLS1_3_VERSION, tst);
#endif
return testresult;
}
#ifndef OPENSSL_NO_TLS1_2
static const char *multiblock_cipherlist_data[]=
{
"AES128-SHA",
"AES128-SHA256",
"AES256-SHA",
"AES256-SHA256",
};
/* Reduce the fragment size - so the multiblock test buffer can be small */
# define MULTIBLOCK_FRAGSIZE 512
static int test_multiblock_write(int test_index)
{
static const char *fetchable_ciphers[]=
{
"AES-128-CBC-HMAC-SHA1",
"AES-128-CBC-HMAC-SHA256",
"AES-256-CBC-HMAC-SHA1",
"AES-256-CBC-HMAC-SHA256"
};
const char *cipherlist = multiblock_cipherlist_data[test_index];
const SSL_METHOD *smeth = TLS_server_method();
const SSL_METHOD *cmeth = TLS_client_method();
int min_version = TLS1_VERSION;
int max_version = TLS1_2_VERSION; /* Don't select TLS1_3 */
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
/*
* Choose a buffer large enough to perform a multi-block operation
* i.e: write_len >= 4 * frag_size
* 9 * is chosen so that multiple multiblocks are used + some leftover.
*/
unsigned char msg[MULTIBLOCK_FRAGSIZE * 9];
unsigned char buf[sizeof(msg)], *p = buf;
size_t readbytes, written, len;
EVP_CIPHER *ciph = NULL;
/*
* Check if the cipher exists before attempting to use it since it only has
* a hardware specific implementation.
*/
ciph = EVP_CIPHER_fetch(libctx, fetchable_ciphers[test_index], "");
if (ciph == NULL) {
TEST_skip("Multiblock cipher is not available for %s", cipherlist);
return 1;
}
EVP_CIPHER_free(ciph);
/* Set up a buffer with some data that will be sent to the client */
RAND_bytes(msg, sizeof(msg));
if (!TEST_true(create_ssl_ctx_pair(libctx, smeth, cmeth, min_version,
max_version, &sctx, &cctx, cert,
privkey)))
goto end;
if (!TEST_true(SSL_CTX_set_max_send_fragment(sctx, MULTIBLOCK_FRAGSIZE)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
/* settings to force it to use AES-CBC-HMAC_SHA */
SSL_set_options(serverssl, SSL_OP_NO_ENCRYPT_THEN_MAC);
if (!TEST_true(SSL_CTX_set_cipher_list(cctx, cipherlist)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
if (!TEST_true(SSL_write_ex(serverssl, msg, sizeof(msg), &written))
|| !TEST_size_t_eq(written, sizeof(msg)))
goto end;
len = written;
while (len > 0) {
if (!TEST_true(SSL_read_ex(clientssl, p, MULTIBLOCK_FRAGSIZE, &readbytes)))
goto end;
p += readbytes;
len -= readbytes;
}
if (!TEST_mem_eq(msg, sizeof(msg), buf, sizeof(buf)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif /* OPENSSL_NO_TLS1_2 */
static int test_session_timeout(int test)
{
/*
* Test session ordering and timeout
* Can't explicitly test performance of the new code,
* but can test to see if the ordering of the sessions
* are correct, and they are removed as expected
*/
SSL_SESSION *early = NULL;
SSL_SESSION *middle = NULL;
SSL_SESSION *late = NULL;
SSL_CTX *ctx;
int testresult = 0;
long now = (long)time(NULL);
#define TIMEOUT 10
if (!TEST_ptr(ctx = SSL_CTX_new_ex(libctx, NULL, TLS_method()))
|| !TEST_ptr(early = SSL_SESSION_new())
|| !TEST_ptr(middle = SSL_SESSION_new())
|| !TEST_ptr(late = SSL_SESSION_new()))
goto end;
/* assign unique session ids */
early->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
memset(early->session_id, 1, SSL3_SSL_SESSION_ID_LENGTH);
middle->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
memset(middle->session_id, 2, SSL3_SSL_SESSION_ID_LENGTH);
late->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
memset(late->session_id, 3, SSL3_SSL_SESSION_ID_LENGTH);
if (!TEST_int_eq(SSL_CTX_add_session(ctx, early), 1)
|| !TEST_int_eq(SSL_CTX_add_session(ctx, middle), 1)
|| !TEST_int_eq(SSL_CTX_add_session(ctx, late), 1))
goto end;
/* Make sure they are all added */
if (!TEST_ptr(early->prev)
|| !TEST_ptr(middle->prev)
|| !TEST_ptr(late->prev))
goto end;
if (!TEST_int_ne(SSL_SESSION_set_time(early, now - 10), 0)
|| !TEST_int_ne(SSL_SESSION_set_time(middle, now), 0)
|| !TEST_int_ne(SSL_SESSION_set_time(late, now + 10), 0))
goto end;
if (!TEST_int_ne(SSL_SESSION_set_timeout(early, TIMEOUT), 0)
|| !TEST_int_ne(SSL_SESSION_set_timeout(middle, TIMEOUT), 0)
|| !TEST_int_ne(SSL_SESSION_set_timeout(late, TIMEOUT), 0))
goto end;
/* Make sure they are all still there */
if (!TEST_ptr(early->prev)
|| !TEST_ptr(middle->prev)
|| !TEST_ptr(late->prev))
goto end;
/* Make sure they are in the expected order */
if (!TEST_ptr_eq(late->next, middle)
|| !TEST_ptr_eq(middle->next, early)
|| !TEST_ptr_eq(early->prev, middle)
|| !TEST_ptr_eq(middle->prev, late))
goto end;
/* This should remove "early" */
SSL_CTX_flush_sessions(ctx, now + TIMEOUT - 1);
if (!TEST_ptr_null(early->prev)
|| !TEST_ptr(middle->prev)
|| !TEST_ptr(late->prev))
goto end;
/* This should remove "middle" */
SSL_CTX_flush_sessions(ctx, now + TIMEOUT + 1);
if (!TEST_ptr_null(early->prev)
|| !TEST_ptr_null(middle->prev)
|| !TEST_ptr(late->prev))
goto end;
/* This should remove "late" */
SSL_CTX_flush_sessions(ctx, now + TIMEOUT + 11);
if (!TEST_ptr_null(early->prev)
|| !TEST_ptr_null(middle->prev)
|| !TEST_ptr_null(late->prev))
goto end;
/* Add them back in again */
if (!TEST_int_eq(SSL_CTX_add_session(ctx, early), 1)
|| !TEST_int_eq(SSL_CTX_add_session(ctx, middle), 1)
|| !TEST_int_eq(SSL_CTX_add_session(ctx, late), 1))
goto end;
/* Make sure they are all added */
if (!TEST_ptr(early->prev)
|| !TEST_ptr(middle->prev)
|| !TEST_ptr(late->prev))
goto end;
/* This should remove all of them */
SSL_CTX_flush_sessions(ctx, 0);
if (!TEST_ptr_null(early->prev)
|| !TEST_ptr_null(middle->prev)
|| !TEST_ptr_null(late->prev))
goto end;
(void)SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_UPDATE_TIME
| SSL_CTX_get_session_cache_mode(ctx));
/* make sure |now| is NOT equal to the current time */
now -= 10;
if (!TEST_int_ne(SSL_SESSION_set_time(early, now), 0)
|| !TEST_int_eq(SSL_CTX_add_session(ctx, early), 1)
|| !TEST_long_ne(SSL_SESSION_get_time(early), now))
goto end;
testresult = 1;
end:
SSL_CTX_free(ctx);
SSL_SESSION_free(early);
SSL_SESSION_free(middle);
SSL_SESSION_free(late);
return testresult;
}
/*
* Test 0: Client sets servername and server acknowledges it (TLSv1.2)
* Test 1: Client sets servername and server does not acknowledge it (TLSv1.2)
* Test 2: Client sets inconsistent servername on resumption (TLSv1.2)
* Test 3: Client does not set servername on initial handshake (TLSv1.2)
* Test 4: Client does not set servername on resumption handshake (TLSv1.2)
* Test 5: Client sets servername and server acknowledges it (TLSv1.3)
* Test 6: Client sets servername and server does not acknowledge it (TLSv1.3)
* Test 7: Client sets inconsistent servername on resumption (TLSv1.3)
* Test 8: Client does not set servername on initial handshake(TLSv1.3)
* Test 9: Client does not set servername on resumption handshake (TLSv1.3)
*/
static int test_servername(int tst)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
SSL_SESSION *sess = NULL;
const char *sexpectedhost = NULL, *cexpectedhost = NULL;
#ifdef OPENSSL_NO_TLS1_2
if (tst <= 4)
return 1;
#endif
#ifdef OSSL_NO_USABLE_TLS1_3
if (tst >= 5)
return 1;
#endif
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
(tst <= 4) ? TLS1_2_VERSION
: TLS1_3_VERSION,
&sctx, &cctx, cert, privkey))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (tst != 1 && tst != 6) {
if (!TEST_true(SSL_CTX_set_tlsext_servername_callback(sctx,
hostname_cb)))
goto end;
}
if (tst != 3 && tst != 8) {
if (!TEST_true(SSL_set_tlsext_host_name(clientssl, "goodhost")))
goto end;
sexpectedhost = cexpectedhost = "goodhost";
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
if (!TEST_str_eq(SSL_get_servername(clientssl, TLSEXT_NAMETYPE_host_name),
cexpectedhost)
|| !TEST_str_eq(SSL_get_servername(serverssl,
TLSEXT_NAMETYPE_host_name),
sexpectedhost))
goto end;
/* Now repeat with a resumption handshake */
if (!TEST_int_eq(SSL_shutdown(clientssl), 0)
|| !TEST_ptr_ne(sess = SSL_get1_session(clientssl), NULL)
|| !TEST_true(SSL_SESSION_is_resumable(sess))
|| !TEST_int_eq(SSL_shutdown(serverssl), 0))
goto end;
SSL_free(clientssl);
SSL_free(serverssl);
clientssl = serverssl = NULL;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
NULL)))
goto end;
if (!TEST_true(SSL_set_session(clientssl, sess)))
goto end;
sexpectedhost = cexpectedhost = "goodhost";
if (tst == 2 || tst == 7) {
/* Set an inconsistent hostname */
if (!TEST_true(SSL_set_tlsext_host_name(clientssl, "altgoodhost")))
goto end;
/*
* In TLSv1.2 we expect the hostname from the original handshake, in
* TLSv1.3 we expect the hostname from this handshake
*/
if (tst == 7)
sexpectedhost = cexpectedhost = "altgoodhost";
if (!TEST_str_eq(SSL_get_servername(clientssl,
TLSEXT_NAMETYPE_host_name),
"altgoodhost"))
goto end;
} else if (tst == 4 || tst == 9) {
/*
* A TLSv1.3 session does not associate a session with a servername,
* but a TLSv1.2 session does.
*/
if (tst == 9)
sexpectedhost = cexpectedhost = NULL;
if (!TEST_str_eq(SSL_get_servername(clientssl,
TLSEXT_NAMETYPE_host_name),
cexpectedhost))
goto end;
} else {
if (!TEST_true(SSL_set_tlsext_host_name(clientssl, "goodhost")))
goto end;
/*
* In a TLSv1.2 resumption where the hostname was not acknowledged
* we expect the hostname on the server to be empty. On the client we
* return what was requested in this case.
*
* Similarly if the client didn't set a hostname on an original TLSv1.2
* session but is now, the server hostname will be empty, but the client
* is as we set it.
*/
if (tst == 1 || tst == 3)
sexpectedhost = NULL;
if (!TEST_str_eq(SSL_get_servername(clientssl,
TLSEXT_NAMETYPE_host_name),
"goodhost"))
goto end;
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
if (!TEST_true(SSL_session_reused(clientssl))
|| !TEST_true(SSL_session_reused(serverssl))
|| !TEST_str_eq(SSL_get_servername(clientssl,
TLSEXT_NAMETYPE_host_name),
cexpectedhost)
|| !TEST_str_eq(SSL_get_servername(serverssl,
TLSEXT_NAMETYPE_host_name),
sexpectedhost))
goto end;
testresult = 1;
end:
SSL_SESSION_free(sess);
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#if !defined(OPENSSL_NO_EC) \
&& (!defined(OSSL_NO_USABLE_TLS1_3) || !defined(OPENSSL_NO_TLS1_2))
/*
* Test that if signature algorithms are not available, then we do not offer or
* accept them.
* Test 0: Two RSA sig algs available: both RSA sig algs shared
* Test 1: The client only has SHA2-256: only SHA2-256 algorithms shared
* Test 2: The server only has SHA2-256: only SHA2-256 algorithms shared
* Test 3: An RSA and an ECDSA sig alg available: both sig algs shared
* Test 4: The client only has an ECDSA sig alg: only ECDSA algorithms shared
* Test 5: The server only has an ECDSA sig alg: only ECDSA algorithms shared
*/
static int test_sigalgs_available(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
OSSL_LIB_CTX *tmpctx = OSSL_LIB_CTX_new();
OSSL_LIB_CTX *clientctx = libctx, *serverctx = libctx;
OSSL_PROVIDER *filterprov = NULL;
int sig, hash;
if (!TEST_ptr(tmpctx))
goto end;
if (idx != 0 && idx != 3) {
if (!TEST_true(OSSL_PROVIDER_add_builtin(tmpctx, "filter",
filter_provider_init)))
goto end;
filterprov = OSSL_PROVIDER_load(tmpctx, "filter");
if (!TEST_ptr(filterprov))
goto end;
if (idx < 3) {
/*
* Only enable SHA2-256 so rsa_pss_rsae_sha384 should not be offered
* or accepted for the peer that uses this libctx. Note that libssl
* *requires* SHA2-256 to be available so we cannot disable that. We
* also need SHA1 for our certificate.
*/
if (!TEST_true(filter_provider_set_filter(OSSL_OP_DIGEST,
"SHA2-256:SHA1")))
goto end;
} else {
if (!TEST_true(filter_provider_set_filter(OSSL_OP_SIGNATURE,
"ECDSA"))
# ifdef OPENSSL_NO_ECX
|| !TEST_true(filter_provider_set_filter(OSSL_OP_KEYMGMT, "EC"))
# else
|| !TEST_true(filter_provider_set_filter(OSSL_OP_KEYMGMT,
"EC:X25519:X448"))
# endif
)
goto end;
}
if (idx == 1 || idx == 4)
clientctx = tmpctx;
else
serverctx = tmpctx;
}
cctx = SSL_CTX_new_ex(clientctx, NULL, TLS_client_method());
sctx = SSL_CTX_new_ex(serverctx, NULL, TLS_server_method());
if (!TEST_ptr(cctx) || !TEST_ptr(sctx))
goto end;
if (idx != 5) {
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
0,
&sctx, &cctx, cert, privkey)))
goto end;
} else {
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
0,
&sctx, &cctx, cert2, privkey2)))
goto end;
}
/* Ensure we only use TLSv1.2 ciphersuites based on SHA256 */
if (idx < 4) {
if (!TEST_true(SSL_CTX_set_cipher_list(cctx,
"ECDHE-RSA-AES128-GCM-SHA256")))
goto end;
} else {
if (!TEST_true(SSL_CTX_set_cipher_list(cctx,
"ECDHE-ECDSA-AES128-GCM-SHA256")))
goto end;
}
if (idx < 3) {
if (!SSL_CTX_set1_sigalgs_list(cctx,
"rsa_pss_rsae_sha384"
":rsa_pss_rsae_sha256")
|| !SSL_CTX_set1_sigalgs_list(sctx,
"rsa_pss_rsae_sha384"
":rsa_pss_rsae_sha256"))
goto end;
} else {
if (!SSL_CTX_set1_sigalgs_list(cctx, "rsa_pss_rsae_sha256:ECDSA+SHA256")
|| !SSL_CTX_set1_sigalgs_list(sctx,
"rsa_pss_rsae_sha256:ECDSA+SHA256"))
goto end;
}
if (idx != 5
&& (!TEST_int_eq(SSL_CTX_use_certificate_file(sctx, cert2,
SSL_FILETYPE_PEM), 1)
|| !TEST_int_eq(SSL_CTX_use_PrivateKey_file(sctx,
privkey2,
SSL_FILETYPE_PEM), 1)
|| !TEST_int_eq(SSL_CTX_check_private_key(sctx), 1)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
/* For tests 0 and 3 we expect 2 shared sigalgs, otherwise exactly 1 */
if (!TEST_int_eq(SSL_get_shared_sigalgs(serverssl, 0, &sig, &hash, NULL,
NULL, NULL),
(idx == 0 || idx == 3) ? 2 : 1))
goto end;
if (!TEST_int_eq(hash, idx == 0 ? NID_sha384 : NID_sha256))
goto end;
if (!TEST_int_eq(sig, (idx == 4 || idx == 5) ? EVP_PKEY_EC
: NID_rsassaPss))
goto end;
testresult = filter_provider_check_clean_finish();
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
OSSL_PROVIDER_unload(filterprov);
OSSL_LIB_CTX_free(tmpctx);
return testresult;
}
#endif /*
* !defined(OPENSSL_NO_EC) \
* && (!defined(OSSL_NO_USABLE_TLS1_3) || !defined(OPENSSL_NO_TLS1_2))
*/
#ifndef OPENSSL_NO_TLS1_3
/* This test can run in TLSv1.3 even if ec and dh are disabled */
static int test_pluggable_group(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
OSSL_PROVIDER *tlsprov = OSSL_PROVIDER_load(libctx, "tls-provider");
/* Check that we are not impacted by a provider without any groups */
OSSL_PROVIDER *legacyprov = OSSL_PROVIDER_load(libctx, "legacy");
const char *group_name = idx == 0 ? "xorgroup" : "xorkemgroup";
if (!TEST_ptr(tlsprov))
goto end;
if (legacyprov == NULL) {
/*
* In this case we assume we've been built with "no-legacy" and skip
* this test (there is no OPENSSL_NO_LEGACY)
*/
testresult = 1;
goto end;
}
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_3_VERSION,
TLS1_3_VERSION,
&sctx, &cctx, cert, privkey))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (!TEST_true(SSL_set1_groups_list(serverssl, group_name))
|| !TEST_true(SSL_set1_groups_list(clientssl, group_name)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
if (!TEST_str_eq(group_name,
SSL_group_to_name(serverssl, SSL_get_shared_group(serverssl, 0))))
goto end;
if (!TEST_str_eq(group_name, SSL_get0_group_name(serverssl))
|| !TEST_str_eq(group_name, SSL_get0_group_name(clientssl)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
OSSL_PROVIDER_unload(tlsprov);
OSSL_PROVIDER_unload(legacyprov);
return testresult;
}
/*
* This function triggers encode, decode and sign functions
* of the artificial "xorhmacsig" algorithm implemented in tls-provider
* creating private key and certificate files for use in TLS testing.
*/
static int create_cert_key(int idx, char *certfilename, char *privkeyfilename)
{
EVP_PKEY_CTX *evpctx = EVP_PKEY_CTX_new_from_name(libctx,
(idx == 0) ? "xorhmacsig" : "xorhmacsha2sig", NULL);
EVP_PKEY *pkey = NULL;
X509 *x509 = X509_new();
X509_NAME *name = NULL;
BIO *keybio = NULL, *certbio = NULL;
int ret = 1;
if (!TEST_ptr(evpctx)
|| !TEST_true(EVP_PKEY_keygen_init(evpctx))
|| !TEST_true(EVP_PKEY_generate(evpctx, &pkey))
|| !TEST_ptr(pkey)
|| !TEST_ptr(x509)
|| !TEST_true(ASN1_INTEGER_set(X509_get_serialNumber(x509), 1))
|| !TEST_true(X509_gmtime_adj(X509_getm_notBefore(x509), 0))
|| !TEST_true(X509_gmtime_adj(X509_getm_notAfter(x509), 31536000L))
|| !TEST_true(X509_set_pubkey(x509, pkey))
|| !TEST_ptr(name = X509_get_subject_name(x509))
|| !TEST_true(X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC,
(unsigned char *)"CH", -1, -1, 0))
|| !TEST_true(X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC,
(unsigned char *)"test.org", -1, -1, 0))
|| !TEST_true(X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC,
(unsigned char *)"localhost", -1, -1, 0))
|| !TEST_true(X509_set_issuer_name(x509, name))
|| !TEST_true(X509_sign(x509, pkey, EVP_sha1()))
|| !TEST_ptr(keybio = BIO_new_file(privkeyfilename, "wb"))
|| !TEST_true(PEM_write_bio_PrivateKey(keybio, pkey, NULL, NULL, 0, NULL, NULL))
|| !TEST_ptr(certbio = BIO_new_file(certfilename, "wb"))
|| !TEST_true(PEM_write_bio_X509(certbio, x509)))
ret = 0;
EVP_PKEY_free(pkey);
X509_free(x509);
EVP_PKEY_CTX_free(evpctx);
BIO_free(keybio);
BIO_free(certbio);
return ret;
}
/*
* Test that signature algorithms loaded via the provider interface can
* correctly establish a TLS (1.3) connection.
* Test 0: Signature algorithm with built-in hashing functionality: "xorhmacsig"
* Test 1: Signature algorithm using external SHA2 hashing: "xorhmacsha2sig"
* Test 2: Test 0 using RPK
* Test 3: Test 1 using RPK
*/
static int test_pluggable_signature(int idx)
{
static const unsigned char cert_type_rpk[] = { TLSEXT_cert_type_rpk, TLSEXT_cert_type_x509 };
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
OSSL_PROVIDER *tlsprov = OSSL_PROVIDER_load(libctx, "tls-provider");
OSSL_PROVIDER *defaultprov = OSSL_PROVIDER_load(libctx, "default");
char *certfilename = "tls-prov-cert.pem";
char *privkeyfilename = "tls-prov-key.pem";
int sigidx = idx % 2;
int rpkidx = idx / 2;
/* create key and certificate for the different algorithm types */
if (!TEST_ptr(tlsprov)
|| !TEST_true(create_cert_key(sigidx, certfilename, privkeyfilename)))
goto end;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_3_VERSION,
TLS1_3_VERSION,
&sctx, &cctx, certfilename, privkeyfilename))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
/* Enable RPK for server cert */
if (rpkidx) {
if (!TEST_true(SSL_set1_server_cert_type(serverssl, cert_type_rpk, sizeof(cert_type_rpk)))
|| !TEST_true(SSL_set1_server_cert_type(clientssl, cert_type_rpk, sizeof(cert_type_rpk))))
goto end;
}
/* This is necessary to pass minimal setup w/o other groups configured */
if (!TEST_true(SSL_set1_groups_list(serverssl, "xorgroup"))
|| !TEST_true(SSL_set1_groups_list(clientssl, "xorgroup")))
goto end;
/*
* If this connection gets established, it must have been completed
* via the tls-provider-implemented "hmacsig" algorithm, testing
* both sign and verify functions during handshake.
*/
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
/* If using RPK, make sure we got one */
if (rpkidx && !TEST_long_eq(SSL_get_verify_result(clientssl), X509_V_ERR_RPK_UNTRUSTED))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
OSSL_PROVIDER_unload(tlsprov);
OSSL_PROVIDER_unload(defaultprov);
return testresult;
}
#endif
#ifndef OPENSSL_NO_TLS1_2
static int test_ssl_dup(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL, *client2ssl = NULL;
int testresult = 0;
BIO *rbio = NULL, *wbio = NULL;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
0,
0,
&sctx, &cctx, cert, privkey)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (!TEST_true(SSL_set_min_proto_version(clientssl, TLS1_2_VERSION))
|| !TEST_true(SSL_set_max_proto_version(clientssl, TLS1_2_VERSION)))
goto end;
client2ssl = SSL_dup(clientssl);
rbio = SSL_get_rbio(clientssl);
if (!TEST_ptr(rbio)
|| !TEST_true(BIO_up_ref(rbio)))
goto end;
SSL_set0_rbio(client2ssl, rbio);
rbio = NULL;
wbio = SSL_get_wbio(clientssl);
if (!TEST_ptr(wbio) || !TEST_true(BIO_up_ref(wbio)))
goto end;
SSL_set0_wbio(client2ssl, wbio);
rbio = NULL;
if (!TEST_ptr(client2ssl)
/* Handshake not started so pointers should be different */
|| !TEST_ptr_ne(clientssl, client2ssl))
goto end;
if (!TEST_int_eq(SSL_get_min_proto_version(client2ssl), TLS1_2_VERSION)
|| !TEST_int_eq(SSL_get_max_proto_version(client2ssl), TLS1_2_VERSION))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, client2ssl, SSL_ERROR_NONE)))
goto end;
SSL_free(clientssl);
clientssl = SSL_dup(client2ssl);
if (!TEST_ptr(clientssl)
/* Handshake has finished so pointers should be the same */
|| !TEST_ptr_eq(clientssl, client2ssl))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_free(client2ssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
# ifndef OPENSSL_NO_DH
static EVP_PKEY *tmp_dh_params = NULL;
/* Helper function for the test_set_tmp_dh() tests */
static EVP_PKEY *get_tmp_dh_params(void)
{
if (tmp_dh_params == NULL) {
BIGNUM *p = NULL;
OSSL_PARAM_BLD *tmpl = NULL;
EVP_PKEY_CTX *pctx = NULL;
OSSL_PARAM *params = NULL;
EVP_PKEY *dhpkey = NULL;
p = BN_get_rfc3526_prime_2048(NULL);
if (!TEST_ptr(p))
goto end;
pctx = EVP_PKEY_CTX_new_from_name(libctx, "DH", NULL);
if (!TEST_ptr(pctx)
|| !TEST_int_eq(EVP_PKEY_fromdata_init(pctx), 1))
goto end;
tmpl = OSSL_PARAM_BLD_new();
if (!TEST_ptr(tmpl)
|| !TEST_true(OSSL_PARAM_BLD_push_BN(tmpl,
OSSL_PKEY_PARAM_FFC_P,
p))
|| !TEST_true(OSSL_PARAM_BLD_push_uint(tmpl,
OSSL_PKEY_PARAM_FFC_G,
2)))
goto end;
params = OSSL_PARAM_BLD_to_param(tmpl);
if (!TEST_ptr(params)
|| !TEST_int_eq(EVP_PKEY_fromdata(pctx, &dhpkey,
EVP_PKEY_KEY_PARAMETERS,
params), 1))
goto end;
tmp_dh_params = dhpkey;
end:
BN_free(p);
EVP_PKEY_CTX_free(pctx);
OSSL_PARAM_BLD_free(tmpl);
OSSL_PARAM_free(params);
}
if (tmp_dh_params != NULL && !EVP_PKEY_up_ref(tmp_dh_params))
return NULL;
return tmp_dh_params;
}
# ifndef OPENSSL_NO_DEPRECATED_3_0
/* Callback used by test_set_tmp_dh() */
static DH *tmp_dh_callback(SSL *s, int is_export, int keylen)
{
EVP_PKEY *dhpkey = get_tmp_dh_params();
DH *ret = NULL;
if (!TEST_ptr(dhpkey))
return NULL;
/*
* libssl does not free the returned DH, so we free it now knowing that even
* after we free dhpkey, there will still be a reference to the owning
* EVP_PKEY in tmp_dh_params, and so the DH object will live for the length
* of time we need it for.
*/
ret = EVP_PKEY_get1_DH(dhpkey);
DH_free(ret);
EVP_PKEY_free(dhpkey);
return ret;
}
# endif
/*
* Test the various methods for setting temporary DH parameters
*
* Test 0: Default (no auto) setting
* Test 1: Explicit SSL_CTX auto off
* Test 2: Explicit SSL auto off
* Test 3: Explicit SSL_CTX auto on
* Test 4: Explicit SSL auto on
* Test 5: Explicit SSL_CTX auto off, custom DH params via EVP_PKEY
* Test 6: Explicit SSL auto off, custom DH params via EVP_PKEY
*
* The following are testing deprecated APIs, so we only run them if available
* Test 7: Explicit SSL_CTX auto off, custom DH params via DH
* Test 8: Explicit SSL auto off, custom DH params via DH
* Test 9: Explicit SSL_CTX auto off, custom DH params via callback
* Test 10: Explicit SSL auto off, custom DH params via callback
*/
static int test_set_tmp_dh(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
int dhauto = (idx == 3 || idx == 4) ? 1 : 0;
int expected = (idx <= 2) ? 0 : 1;
EVP_PKEY *dhpkey = NULL;
# ifndef OPENSSL_NO_DEPRECATED_3_0
DH *dh = NULL;
# else
if (idx >= 7)
return 1;
# endif
if (idx >= 5 && idx <= 8) {
dhpkey = get_tmp_dh_params();
if (!TEST_ptr(dhpkey))
goto end;
}
# ifndef OPENSSL_NO_DEPRECATED_3_0
if (idx == 7 || idx == 8) {
dh = EVP_PKEY_get1_DH(dhpkey);
if (!TEST_ptr(dh))
goto end;
}
# endif
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
0,
0,
&sctx, &cctx, cert, privkey)))
goto end;
if ((idx & 1) == 1) {
if (!TEST_true(SSL_CTX_set_dh_auto(sctx, dhauto)))
goto end;
}
if (idx == 5) {
if (!TEST_true(SSL_CTX_set0_tmp_dh_pkey(sctx, dhpkey)))
goto end;
dhpkey = NULL;
}
# ifndef OPENSSL_NO_DEPRECATED_3_0
else if (idx == 7) {
if (!TEST_true(SSL_CTX_set_tmp_dh(sctx, dh)))
goto end;
} else if (idx == 9) {
SSL_CTX_set_tmp_dh_callback(sctx, tmp_dh_callback);
}
# endif
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if ((idx & 1) == 0 && idx != 0) {
if (!TEST_true(SSL_set_dh_auto(serverssl, dhauto)))
goto end;
}
if (idx == 6) {
if (!TEST_true(SSL_set0_tmp_dh_pkey(serverssl, dhpkey)))
goto end;
dhpkey = NULL;
}
# ifndef OPENSSL_NO_DEPRECATED_3_0
else if (idx == 8) {
if (!TEST_true(SSL_set_tmp_dh(serverssl, dh)))
goto end;
} else if (idx == 10) {
SSL_set_tmp_dh_callback(serverssl, tmp_dh_callback);
}
# endif
if (!TEST_true(SSL_set_min_proto_version(serverssl, TLS1_2_VERSION))
|| !TEST_true(SSL_set_max_proto_version(serverssl, TLS1_2_VERSION))
|| !TEST_true(SSL_set_cipher_list(serverssl, "DHE-RSA-AES128-SHA")))
goto end;
/*
* If autoon then we should succeed. Otherwise we expect failure because
* there are no parameters
*/
if (!TEST_int_eq(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE), expected))
goto end;
testresult = 1;
end:
# ifndef OPENSSL_NO_DEPRECATED_3_0
DH_free(dh);
# endif
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
EVP_PKEY_free(dhpkey);
return testresult;
}
/*
* Test the auto DH keys are appropriately sized
*/
static int test_dh_auto(int idx)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, TLS_client_method());
SSL_CTX *sctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
EVP_PKEY *tmpkey = NULL;
char *thiscert = NULL, *thiskey = NULL;
size_t expdhsize = 0;
const char *ciphersuite = "DHE-RSA-AES128-SHA";
if (!TEST_ptr(sctx) || !TEST_ptr(cctx))
goto end;
switch (idx) {
case 0:
/* The FIPS provider doesn't support this DH size - so we ignore it */
if (is_fips) {
testresult = 1;
goto end;
}
thiscert = cert1024;
thiskey = privkey1024;
expdhsize = 1024;
SSL_CTX_set_security_level(sctx, 1);
SSL_CTX_set_security_level(cctx, 1);
break;
case 1:
/* 2048 bit prime */
thiscert = cert;
thiskey = privkey;
expdhsize = 2048;
break;
case 2:
thiscert = cert3072;
thiskey = privkey3072;
expdhsize = 3072;
break;
case 3:
thiscert = cert4096;
thiskey = privkey4096;
expdhsize = 4096;
break;
case 4:
thiscert = cert8192;
thiskey = privkey8192;
expdhsize = 8192;
break;
/* No certificate cases */
case 5:
/* The FIPS provider doesn't support this DH size - so we ignore it */
if (is_fips) {
testresult = 1;
goto end;
}
ciphersuite = "ADH-AES128-SHA256:@SECLEVEL=0";
expdhsize = 1024;
break;
case 6:
ciphersuite = "ADH-AES256-SHA256:@SECLEVEL=0";
expdhsize = 3072;
break;
default:
TEST_error("Invalid text index");
goto end;
}
if (!TEST_true(create_ssl_ctx_pair(libctx, NULL,
NULL,
0,
0,
&sctx, &cctx, thiscert, thiskey)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
NULL, NULL)))
goto end;
if (!TEST_true(SSL_set_dh_auto(serverssl, 1))
|| !TEST_true(SSL_set_min_proto_version(serverssl, TLS1_2_VERSION))
|| !TEST_true(SSL_set_max_proto_version(serverssl, TLS1_2_VERSION))
|| !TEST_true(SSL_set_cipher_list(serverssl, ciphersuite))
|| !TEST_true(SSL_set_cipher_list(clientssl, ciphersuite)))
goto end;
/*
* Send the server's first flight. At this point the server has created the
* temporary DH key but hasn't finished using it yet. Once used it is
* removed, so we cannot test it.
*/
if (!TEST_int_le(SSL_connect(clientssl), 0)
|| !TEST_int_le(SSL_accept(serverssl), 0))
goto end;
if (!TEST_int_gt(SSL_get_tmp_key(serverssl, &tmpkey), 0))
goto end;
if (!TEST_size_t_eq(EVP_PKEY_get_bits(tmpkey), expdhsize))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
EVP_PKEY_free(tmpkey);
return testresult;
}
# endif /* OPENSSL_NO_DH */
#endif /* OPENSSL_NO_TLS1_2 */
#ifndef OSSL_NO_USABLE_TLS1_3
/*
* Test that setting an SNI callback works with TLSv1.3. Specifically we check
* that it works even without a certificate configured for the original
* SSL_CTX
*/
static int test_sni_tls13(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
/* Reset callback counter */
snicb = 0;
/* Create an initial SSL_CTX with no certificate configured */
sctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
if (!TEST_ptr(sctx))
goto end;
/* Require TLSv1.3 as a minimum */
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_3_VERSION, 0,
&sctx2, &cctx, cert, privkey)))
goto end;
/* Set up SNI */
if (!TEST_true(SSL_CTX_set_tlsext_servername_callback(sctx, sni_cb))
|| !TEST_true(SSL_CTX_set_tlsext_servername_arg(sctx, sctx2)))
goto end;
/*
* Connection should still succeed because the final SSL_CTX has the right
* certificates configured.
*/
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
/* We should have had the SNI callback called exactly once */
if (!TEST_int_eq(snicb, 1))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx2);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test that the lifetime hint of a TLSv1.3 ticket is no more than 1 week
* 0 = TLSv1.2
* 1 = TLSv1.3
*/
static int test_ticket_lifetime(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
int version = TLS1_3_VERSION;
#define ONE_WEEK_SEC (7 * 24 * 60 * 60)
#define TWO_WEEK_SEC (2 * ONE_WEEK_SEC)
if (idx == 0) {
#ifdef OPENSSL_NO_TLS1_2
return TEST_skip("TLS 1.2 is disabled.");
#else
version = TLS1_2_VERSION;
#endif
}
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), version, version,
&sctx, &cctx, cert, privkey)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
/*
* Set the timeout to be more than 1 week
* make sure the returned value is the default
*/
if (!TEST_long_eq(SSL_CTX_set_timeout(sctx, TWO_WEEK_SEC),
SSL_get_default_timeout(serverssl)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
if (idx == 0) {
/* TLSv1.2 uses the set value */
if (!TEST_ulong_eq(SSL_SESSION_get_ticket_lifetime_hint(SSL_get_session(clientssl)), TWO_WEEK_SEC))
goto end;
} else {
/* TLSv1.3 uses the limited value */
if (!TEST_ulong_le(SSL_SESSION_get_ticket_lifetime_hint(SSL_get_session(clientssl)), ONE_WEEK_SEC))
goto end;
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif
/*
* Test that setting an ALPN does not violate RFC
*/
static int test_set_alpn(void)
{
SSL_CTX *ctx = NULL;
SSL *ssl = NULL;
int testresult = 0;
unsigned char bad0[] = { 0x00, 'b', 'a', 'd' };
unsigned char good[] = { 0x04, 'g', 'o', 'o', 'd' };
unsigned char bad1[] = { 0x01, 'b', 'a', 'd' };
unsigned char bad2[] = { 0x03, 'b', 'a', 'd', 0x00};
unsigned char bad3[] = { 0x03, 'b', 'a', 'd', 0x01, 'b', 'a', 'd'};
unsigned char bad4[] = { 0x03, 'b', 'a', 'd', 0x06, 'b', 'a', 'd'};
/* Create an initial SSL_CTX with no certificate configured */
ctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
if (!TEST_ptr(ctx))
goto end;
/* the set_alpn functions return 0 (false) on success, non-zero (true) on failure */
if (!TEST_false(SSL_CTX_set_alpn_protos(ctx, NULL, 2)))
goto end;
if (!TEST_false(SSL_CTX_set_alpn_protos(ctx, good, 0)))
goto end;
if (!TEST_false(SSL_CTX_set_alpn_protos(ctx, good, sizeof(good))))
goto end;
if (!TEST_true(SSL_CTX_set_alpn_protos(ctx, good, 1)))
goto end;
if (!TEST_true(SSL_CTX_set_alpn_protos(ctx, bad0, sizeof(bad0))))
goto end;
if (!TEST_true(SSL_CTX_set_alpn_protos(ctx, bad1, sizeof(bad1))))
goto end;
if (!TEST_true(SSL_CTX_set_alpn_protos(ctx, bad2, sizeof(bad2))))
goto end;
if (!TEST_true(SSL_CTX_set_alpn_protos(ctx, bad3, sizeof(bad3))))
goto end;
if (!TEST_true(SSL_CTX_set_alpn_protos(ctx, bad4, sizeof(bad4))))
goto end;
ssl = SSL_new(ctx);
if (!TEST_ptr(ssl))
goto end;
if (!TEST_false(SSL_set_alpn_protos(ssl, NULL, 2)))
goto end;
if (!TEST_false(SSL_set_alpn_protos(ssl, good, 0)))
goto end;
if (!TEST_false(SSL_set_alpn_protos(ssl, good, sizeof(good))))
goto end;
if (!TEST_true(SSL_set_alpn_protos(ssl, good, 1)))
goto end;
if (!TEST_true(SSL_set_alpn_protos(ssl, bad0, sizeof(bad0))))
goto end;
if (!TEST_true(SSL_set_alpn_protos(ssl, bad1, sizeof(bad1))))
goto end;
if (!TEST_true(SSL_set_alpn_protos(ssl, bad2, sizeof(bad2))))
goto end;
if (!TEST_true(SSL_set_alpn_protos(ssl, bad3, sizeof(bad3))))
goto end;
if (!TEST_true(SSL_set_alpn_protos(ssl, bad4, sizeof(bad4))))
goto end;
testresult = 1;
end:
SSL_free(ssl);
SSL_CTX_free(ctx);
return testresult;
}
/*
* Test SSL_CTX_set1_verify/chain_cert_store and SSL_CTX_get_verify/chain_cert_store.
*/
static int test_set_verify_cert_store_ssl_ctx(void)
{
SSL_CTX *ctx = NULL;
int testresult = 0;
X509_STORE *store = NULL, *new_store = NULL,
*cstore = NULL, *new_cstore = NULL;
/* Create an initial SSL_CTX. */
ctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
if (!TEST_ptr(ctx))
goto end;
/* Retrieve verify store pointer. */
if (!TEST_true(SSL_CTX_get0_verify_cert_store(ctx, &store)))
goto end;
/* Retrieve chain store pointer. */
if (!TEST_true(SSL_CTX_get0_chain_cert_store(ctx, &cstore)))
goto end;
/* We haven't set any yet, so this should be NULL. */
if (!TEST_ptr_null(store) || !TEST_ptr_null(cstore))
goto end;
/* Create stores. We use separate stores so pointers are different. */
new_store = X509_STORE_new();
if (!TEST_ptr(new_store))
goto end;
new_cstore = X509_STORE_new();
if (!TEST_ptr(new_cstore))
goto end;
/* Set stores. */
if (!TEST_true(SSL_CTX_set1_verify_cert_store(ctx, new_store)))
goto end;
if (!TEST_true(SSL_CTX_set1_chain_cert_store(ctx, new_cstore)))
goto end;
/* Should be able to retrieve the same pointer. */
if (!TEST_true(SSL_CTX_get0_verify_cert_store(ctx, &store)))
goto end;
if (!TEST_true(SSL_CTX_get0_chain_cert_store(ctx, &cstore)))
goto end;
if (!TEST_ptr_eq(store, new_store) || !TEST_ptr_eq(cstore, new_cstore))
goto end;
/* Should be able to unset again. */
if (!TEST_true(SSL_CTX_set1_verify_cert_store(ctx, NULL)))
goto end;
if (!TEST_true(SSL_CTX_set1_chain_cert_store(ctx, NULL)))
goto end;
/* Should now be NULL. */
if (!TEST_true(SSL_CTX_get0_verify_cert_store(ctx, &store)))
goto end;
if (!TEST_true(SSL_CTX_get0_chain_cert_store(ctx, &cstore)))
goto end;
if (!TEST_ptr_null(store) || !TEST_ptr_null(cstore))
goto end;
testresult = 1;
end:
X509_STORE_free(new_store);
X509_STORE_free(new_cstore);
SSL_CTX_free(ctx);
return testresult;
}
/*
* Test SSL_set1_verify/chain_cert_store and SSL_get_verify/chain_cert_store.
*/
static int test_set_verify_cert_store_ssl(void)
{
SSL_CTX *ctx = NULL;
SSL *ssl = NULL;
int testresult = 0;
X509_STORE *store = NULL, *new_store = NULL,
*cstore = NULL, *new_cstore = NULL;
/* Create an initial SSL_CTX. */
ctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
if (!TEST_ptr(ctx))
goto end;
/* Create an SSL object. */
ssl = SSL_new(ctx);
if (!TEST_ptr(ssl))
goto end;
/* Retrieve verify store pointer. */
if (!TEST_true(SSL_get0_verify_cert_store(ssl, &store)))
goto end;
/* Retrieve chain store pointer. */
if (!TEST_true(SSL_get0_chain_cert_store(ssl, &cstore)))
goto end;
/* We haven't set any yet, so this should be NULL. */
if (!TEST_ptr_null(store) || !TEST_ptr_null(cstore))
goto end;
/* Create stores. We use separate stores so pointers are different. */
new_store = X509_STORE_new();
if (!TEST_ptr(new_store))
goto end;
new_cstore = X509_STORE_new();
if (!TEST_ptr(new_cstore))
goto end;
/* Set stores. */
if (!TEST_true(SSL_set1_verify_cert_store(ssl, new_store)))
goto end;
if (!TEST_true(SSL_set1_chain_cert_store(ssl, new_cstore)))
goto end;
/* Should be able to retrieve the same pointer. */
if (!TEST_true(SSL_get0_verify_cert_store(ssl, &store)))
goto end;
if (!TEST_true(SSL_get0_chain_cert_store(ssl, &cstore)))
goto end;
if (!TEST_ptr_eq(store, new_store) || !TEST_ptr_eq(cstore, new_cstore))
goto end;
/* Should be able to unset again. */
if (!TEST_true(SSL_set1_verify_cert_store(ssl, NULL)))
goto end;
if (!TEST_true(SSL_set1_chain_cert_store(ssl, NULL)))
goto end;
/* Should now be NULL. */
if (!TEST_true(SSL_get0_verify_cert_store(ssl, &store)))
goto end;
if (!TEST_true(SSL_get0_chain_cert_store(ssl, &cstore)))
goto end;
if (!TEST_ptr_null(store) || !TEST_ptr_null(cstore))
goto end;
testresult = 1;
end:
X509_STORE_free(new_store);
X509_STORE_free(new_cstore);
SSL_free(ssl);
SSL_CTX_free(ctx);
return testresult;
}
static int test_inherit_verify_param(void)
{
int testresult = 0;
SSL_CTX *ctx = NULL;
X509_VERIFY_PARAM *cp = NULL;
SSL *ssl = NULL;
X509_VERIFY_PARAM *sp = NULL;
int hostflags = X509_CHECK_FLAG_NEVER_CHECK_SUBJECT;
ctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
if (!TEST_ptr(ctx))
goto end;
cp = SSL_CTX_get0_param(ctx);
if (!TEST_ptr(cp))
goto end;
if (!TEST_int_eq(X509_VERIFY_PARAM_get_hostflags(cp), 0))
goto end;
X509_VERIFY_PARAM_set_hostflags(cp, hostflags);
ssl = SSL_new(ctx);
if (!TEST_ptr(ssl))
goto end;
sp = SSL_get0_param(ssl);
if (!TEST_ptr(sp))
goto end;
if (!TEST_int_eq(X509_VERIFY_PARAM_get_hostflags(sp), hostflags))
goto end;
testresult = 1;
end:
SSL_free(ssl);
SSL_CTX_free(ctx);
return testresult;
}
static int test_load_dhfile(void)
{
#ifndef OPENSSL_NO_DH
int testresult = 0;
SSL_CTX *ctx = NULL;
SSL_CONF_CTX *cctx = NULL;
if (dhfile == NULL)
return 1;
if (!TEST_ptr(ctx = SSL_CTX_new_ex(libctx, NULL, TLS_client_method()))
|| !TEST_ptr(cctx = SSL_CONF_CTX_new()))
goto end;
SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
SSL_CONF_CTX_set_flags(cctx,
SSL_CONF_FLAG_CERTIFICATE
| SSL_CONF_FLAG_SERVER
| SSL_CONF_FLAG_FILE);
if (!TEST_int_eq(SSL_CONF_cmd(cctx, "DHParameters", dhfile), 2))
goto end;
testresult = 1;
end:
SSL_CONF_CTX_free(cctx);
SSL_CTX_free(ctx);
return testresult;
#else
return TEST_skip("DH not supported by this build");
#endif
}
#ifndef OSSL_NO_USABLE_TLS1_3
/* Test that read_ahead works across a key change */
static int test_read_ahead_key_change(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char *msg = "Hello World";
size_t written, readbytes;
char buf[80];
int i;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_3_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
SSL_CTX_set_read_ahead(sctx, 1);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
/* Write some data, send a key update, write more data */
if (!TEST_true(SSL_write_ex(clientssl, msg, strlen(msg), &written))
|| !TEST_size_t_eq(written, strlen(msg)))
goto end;
if (!TEST_true(SSL_key_update(clientssl, SSL_KEY_UPDATE_NOT_REQUESTED)))
goto end;
if (!TEST_true(SSL_write_ex(clientssl, msg, strlen(msg), &written))
|| !TEST_size_t_eq(written, strlen(msg)))
goto end;
/*
* Since read_ahead is on the first read below should read the record with
* the first app data, the second record with the key update message, and
* the third record with the app data all in one go. We should be able to
* still process the read_ahead data correctly even though it crosses
* epochs
*/
for (i = 0; i < 2; i++) {
if (!TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf) - 1,
&readbytes)))
goto end;
buf[readbytes] = '\0';
if (!TEST_str_eq(buf, msg))
goto end;
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
static size_t record_pad_cb(SSL *s, int type, size_t len, void *arg)
{
int *called = arg;
switch ((*called)++) {
case 0:
/* Add some padding to first record */
return 512;
case 1:
/* Maximally pad the second record */
return SSL3_RT_MAX_PLAIN_LENGTH - len;
case 2:
/*
* Exceeding the maximum padding should be fine. It should just pad to
* the maximum anyway
*/
return SSL3_RT_MAX_PLAIN_LENGTH + 1 - len;
case 3:
/*
* Very large padding should also be ok. Should just pad to the maximum
* allowed
*/
return SIZE_MAX;
default:
return 0;
}
}
/*
* Test that setting record padding in TLSv1.3 works as expected
* Test 0: Record padding callback on the SSL_CTX
* Test 1: Record padding callback on the SSL
* Test 2: Record block padding on the SSL_CTX
* Test 3: Record block padding on the SSL
*/
static int test_tls13_record_padding(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
char *msg = "Hello World";
size_t written, readbytes;
char buf[80];
int i;
int called = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_3_VERSION, 0,
&sctx, &cctx, cert, privkey)))
goto end;
if (idx == 0) {
SSL_CTX_set_record_padding_callback(cctx, record_pad_cb);
SSL_CTX_set_record_padding_callback_arg(cctx, &called);
if (!TEST_ptr_eq(SSL_CTX_get_record_padding_callback_arg(cctx), &called))
goto end;
} else if (idx == 2) {
/* Exceeding the max plain length should fail */
if (!TEST_false(SSL_CTX_set_block_padding(cctx,
SSL3_RT_MAX_PLAIN_LENGTH + 1)))
goto end;
if (!TEST_true(SSL_CTX_set_block_padding(cctx, 512)))
goto end;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if (idx == 1) {
SSL_set_record_padding_callback(clientssl, record_pad_cb);
SSL_set_record_padding_callback_arg(clientssl, &called);
if (!TEST_ptr_eq(SSL_get_record_padding_callback_arg(clientssl), &called))
goto end;
} else if (idx == 3) {
/* Exceeding the max plain length should fail */
if (!TEST_false(SSL_set_block_padding(clientssl,
SSL3_RT_MAX_PLAIN_LENGTH + 1)))
goto end;
if (!TEST_true(SSL_set_block_padding(clientssl, 512)))
goto end;
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
called = 0;
/*
* Write some data, then check we can read it. Do this four times to check
* we can continue to write and read padded data after the initial record
* padding has been added. We don't actually check that the padding has
* been applied to the record - just that we can continue to communicate
* normally and that the callback has been called (if appropriate).
*/
for (i = 0; i < 4; i++) {
if (!TEST_true(SSL_write_ex(clientssl, msg, strlen(msg), &written))
|| !TEST_size_t_eq(written, strlen(msg)))
goto end;
if (!TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf) - 1,
&readbytes))
|| !TEST_size_t_eq(written, readbytes))
goto end;
buf[readbytes] = '\0';
if (!TEST_str_eq(buf, msg))
goto end;
}
if ((idx == 0 || idx == 1) && !TEST_int_eq(called, 4))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
#endif /* OSSL_NO_USABLE_TLS1_3 */
#if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_DYNAMIC_ENGINE)
static ENGINE *load_dasync(void)
{
ENGINE *e;
if (!TEST_ptr(e = ENGINE_by_id("dasync")))
return NULL;
if (!TEST_true(ENGINE_init(e))) {
ENGINE_free(e);
return NULL;
}
if (!TEST_true(ENGINE_register_ciphers(e))) {
ENGINE_free(e);
return NULL;
}
return e;
}
/*
* Test TLSv1.2 with a pipeline capable cipher. TLSv1.3 and DTLS do not
* support this yet. The only pipeline capable cipher that we have is in the
* dasync engine (providers don't support this yet), so we have to use
* deprecated APIs for this test.
*
* Test 0: Client has pipelining enabled, server does not
* Test 1: Server has pipelining enabled, client does not
* Test 2: Client has pipelining enabled, server does not: not enough data to
* fill all the pipelines
* Test 3: Client has pipelining enabled, server does not: not enough data to
* fill all the pipelines by more than a full pipeline's worth
* Test 4: Client has pipelining enabled, server does not: more data than all
* the available pipelines can take
* Test 5: Client has pipelining enabled, server does not: Maximum size pipeline
* Test 6: Repeat of test 0, but the engine is loaded late (after the SSL_CTX
* is created)
*/
static int test_pipelining(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL, *peera, *peerb;
int testresult = 0, numreads;
/* A 55 byte message */
unsigned char *msg = (unsigned char *)
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123";
size_t written, readbytes, offset, msglen, fragsize = 10, numpipes = 5;
size_t expectedreads;
unsigned char *buf = NULL;
ENGINE *e = NULL;
if (idx != 6) {
e = load_dasync();
if (e == NULL)
return 0;
}
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), 0,
TLS1_2_VERSION, &sctx, &cctx, cert,
privkey)))
goto end;
if (idx == 6) {
e = load_dasync();
if (e == NULL)
goto end;
/* Now act like test 0 */
idx = 0;
}
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if (!TEST_true(SSL_set_cipher_list(clientssl, "AES128-SHA")))
goto end;
/* peera is always configured for pipelining, while peerb is not. */
if (idx == 1) {
peera = serverssl;
peerb = clientssl;
} else {
peera = clientssl;
peerb = serverssl;
}
if (idx == 5) {
numpipes = 2;
/* Maximum allowed fragment size */
fragsize = SSL3_RT_MAX_PLAIN_LENGTH;
msglen = fragsize * numpipes;
msg = OPENSSL_malloc(msglen);
if (!TEST_ptr(msg))
goto end;
if (!TEST_int_gt(RAND_bytes_ex(libctx, msg, msglen, 0), 0))
goto end;
} else if (idx == 4) {
msglen = 55;
} else {
msglen = 50;
}
if (idx == 2)
msglen -= 2; /* Send 2 less bytes */
else if (idx == 3)
msglen -= 12; /* Send 12 less bytes */
buf = OPENSSL_malloc(msglen);
if (!TEST_ptr(buf))
goto end;
if (idx == 5) {
/*
* Test that setting a split send fragment longer than the maximum
* allowed fails
*/
if (!TEST_false(SSL_set_split_send_fragment(peera, fragsize + 1)))
goto end;
}
/*
* In the normal case. We have 5 pipelines with 10 bytes per pipeline
* (50 bytes in total). This is a ridiculously small number of bytes -
* but sufficient for our purposes
*/
if (!TEST_true(SSL_set_max_pipelines(peera, numpipes))
|| !TEST_true(SSL_set_split_send_fragment(peera, fragsize)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
/* Write some data from peera to peerb */
if (!TEST_true(SSL_write_ex(peera, msg, msglen, &written))
|| !TEST_size_t_eq(written, msglen))
goto end;
/*
* If the pipelining code worked, then we expect all |numpipes| pipelines to
* have been used - except in test 3 where only |numpipes - 1| pipelines
* will be used. This will result in |numpipes| records (|numpipes - 1| for
* test 3) having been sent to peerb. Since peerb is not using read_ahead we
* expect this to be read in |numpipes| or |numpipes - 1| separate
* SSL_read_ex calls. In the case of test 4, there is then one additional
* read for left over data that couldn't fit in the previous pipelines
*/
for (offset = 0, numreads = 0;
offset < msglen;
offset += readbytes, numreads++) {
if (!TEST_true(SSL_read_ex(peerb, buf + offset,
msglen - offset, &readbytes)))
goto end;
}
expectedreads = idx == 4 ? numpipes + 1
: (idx == 3 ? numpipes - 1 : numpipes);
if (!TEST_mem_eq(msg, msglen, buf, offset)
|| !TEST_int_eq(numreads, expectedreads))
goto end;
/*
* Write some data from peerb to peera. We do this in up to |numpipes + 1|
* chunks to exercise the read pipelining code on peera.
*/
for (offset = 0; offset < msglen; offset += fragsize) {
size_t sendlen = msglen - offset;
if (sendlen > fragsize)
sendlen = fragsize;
if (!TEST_true(SSL_write_ex(peerb, msg + offset, sendlen, &written))
|| !TEST_size_t_eq(written, sendlen))
goto end;
}
/*
* The data was written in |numpipes|, |numpipes - 1| or |numpipes + 1|
* separate chunks (depending on which test we are running). If the
* pipelining is working then we expect peera to read up to numpipes chunks
* and process them in parallel, giving back the complete result in a single
* call to SSL_read_ex
*/
if (!TEST_true(SSL_read_ex(peera, buf, msglen, &readbytes))
|| !TEST_size_t_le(readbytes, msglen))
goto end;
if (idx == 4) {
size_t readbytes2;
if (!TEST_true(SSL_read_ex(peera, buf + readbytes,
msglen - readbytes, &readbytes2)))
goto end;
readbytes += readbytes2;
if (!TEST_size_t_le(readbytes, msglen))
goto end;
}
if (!TEST_mem_eq(msg, msglen, buf, readbytes))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
if (e != NULL) {
ENGINE_unregister_ciphers(e);
ENGINE_finish(e);
ENGINE_free(e);
}
OPENSSL_free(buf);
if (fragsize == SSL3_RT_MAX_PLAIN_LENGTH)
OPENSSL_free(msg);
return testresult;
}
#endif /* !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_DYNAMIC_ENGINE) */
static int check_version_string(SSL *s, int version)
{
const char *verstr = NULL;
switch (version) {
case SSL3_VERSION:
verstr = "SSLv3";
break;
case TLS1_VERSION:
verstr = "TLSv1";
break;
case TLS1_1_VERSION:
verstr = "TLSv1.1";
break;
case TLS1_2_VERSION:
verstr = "TLSv1.2";
break;
case TLS1_3_VERSION:
verstr = "TLSv1.3";
break;
case DTLS1_VERSION:
verstr = "DTLSv1";
break;
case DTLS1_2_VERSION:
verstr = "DTLSv1.2";
}
return TEST_str_eq(verstr, SSL_get_version(s));
}
/*
* Test that SSL_version, SSL_get_version, SSL_is_quic, SSL_is_tls and
* SSL_is_dtls return the expected results for a (D)TLS connection. Compare with
* test_version() in quicapitest.c which does the same thing for QUIC
* connections.
*/
static int test_version(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0, version;
const SSL_METHOD *servmeth = TLS_server_method();
const SSL_METHOD *clientmeth = TLS_client_method();
switch (idx) {
#if !defined(OPENSSL_NO_SSL3)
case 0:
version = SSL3_VERSION;
break;
#endif
#if !defined(OPENSSL_NO_TLS1)
case 1:
version = TLS1_VERSION;
break;
#endif
#if !defined(OPENSSL_NO_TLS1_2)
case 2:
version = TLS1_2_VERSION;
break;
#endif
#if !defined(OSSL_NO_USABLE_TLS1_3)
case 3:
version = TLS1_3_VERSION;
break;
#endif
#if !defined(OPENSSL_NO_DTLS1)
case 4:
version = DTLS1_VERSION;
break;
#endif
#if !defined(OPENSSL_NO_DTLS1_2)
case 5:
version = DTLS1_2_VERSION;
break;
#endif
/*
* NB we do not support QUIC in this test. That is covered by quicapitest.c
* We also don't support DTLS1_BAD_VER since we have no server support for
* that.
*/
default:
TEST_skip("Unsupported protocol version");
return 1;
}
if (is_fips
&& (version == SSL3_VERSION
|| version == TLS1_VERSION
|| version == DTLS1_VERSION)) {
TEST_skip("Protocol version not supported with FIPS");
return 1;
}
#if !defined(OPENSSL_NO_DTLS)
if (version == DTLS1_VERSION || version == DTLS1_2_VERSION) {
servmeth = DTLS_server_method();
clientmeth = DTLS_client_method();
}
#endif
if (!TEST_true(create_ssl_ctx_pair(libctx, servmeth, clientmeth, version,
version, &sctx, &cctx, cert, privkey)))
goto end;
if (!TEST_true(SSL_CTX_set_cipher_list(sctx, "DEFAULT:@SECLEVEL=0"))
|| !TEST_true(SSL_CTX_set_cipher_list(cctx,
"DEFAULT:@SECLEVEL=0")))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
if (!TEST_int_eq(SSL_version(serverssl), version)
|| !TEST_int_eq(SSL_version(clientssl), version)
|| !TEST_true(check_version_string(serverssl, version))
|| !TEST_true(check_version_string(clientssl, version)))
goto end;
if (version == DTLS1_VERSION || version == DTLS1_2_VERSION) {
if (!TEST_true(SSL_is_dtls(serverssl))
|| !TEST_true(SSL_is_dtls(clientssl))
|| !TEST_false(SSL_is_tls(serverssl))
|| !TEST_false(SSL_is_tls(clientssl))
|| !TEST_false(SSL_is_quic(serverssl))
|| !TEST_false(SSL_is_quic(clientssl)))
goto end;
} else {
if (!TEST_true(SSL_is_tls(serverssl))
|| !TEST_true(SSL_is_tls(clientssl))
|| !TEST_false(SSL_is_dtls(serverssl))
|| !TEST_false(SSL_is_dtls(clientssl))
|| !TEST_false(SSL_is_quic(serverssl))
|| !TEST_false(SSL_is_quic(clientssl)))
goto end;
}
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test that the SSL_rstate_string*() APIs return sane results
*/
static int test_rstate_string(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0, version;
const SSL_METHOD *servmeth = TLS_server_method();
const SSL_METHOD *clientmeth = TLS_client_method();
size_t written, readbytes;
unsigned char buf[2];
unsigned char dummyheader[SSL3_RT_HEADER_LENGTH] = {
SSL3_RT_APPLICATION_DATA,
TLS1_2_VERSION_MAJOR,
0, /* To be filled in later */
0,
1
};
if (!TEST_true(create_ssl_ctx_pair(libctx, servmeth, clientmeth, 0,
0, &sctx, &cctx, cert, privkey)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
if (!TEST_str_eq(SSL_rstate_string(serverssl), "RH")
|| !TEST_str_eq(SSL_rstate_string_long(serverssl), "read header"))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
if (!TEST_str_eq(SSL_rstate_string(serverssl), "RH")
|| !TEST_str_eq(SSL_rstate_string_long(serverssl), "read header"))
goto end;
/* Fill in the correct version for the record header */
version = SSL_version(serverssl);
if (version == TLS1_3_VERSION)
version = TLS1_2_VERSION;
dummyheader[2] = version & 0xff;
/*
* Send a dummy header. If we continued to read the body as well this
* would fail with a bad record mac, but we're not going to go that far.
*/
if (!TEST_true(BIO_write_ex(SSL_get_rbio(serverssl), dummyheader,
sizeof(dummyheader), &written))
|| !TEST_size_t_eq(written, SSL3_RT_HEADER_LENGTH))
goto end;
if (!TEST_false(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes)))
goto end;
if (!TEST_str_eq(SSL_rstate_string(serverssl), "RB")
|| !TEST_str_eq(SSL_rstate_string_long(serverssl), "read body"))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Force a write retry during handshaking. We test various combinations of
* scenarios. We test a large certificate message which will fill the buffering
* BIO used in the handshake. We try with client auth on and off. Finally we
* also try a BIO that indicates retry via a 0 return. BIO_write() is documented
* to indicate retry via -1 - but sometimes BIOs don't do that.
*
* Test 0: Standard certificate message
* Test 1: Large certificate message
* Test 2: Standard cert, verify peer
* Test 3: Large cert, verify peer
* Test 4: Standard cert, BIO returns 0 on retry
* Test 5: Large cert, BIO returns 0 on retry
* Test 6: Standard cert, verify peer, BIO returns 0 on retry
* Test 7: Large cert, verify peer, BIO returns 0 on retry
* Test 8-15: Repeat of above with TLSv1.2
*/
static int test_handshake_retry(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
BIO *tmp = NULL, *bretry = BIO_new(bio_s_always_retry());
int maxversion = 0;
if (!TEST_ptr(bretry))
goto end;
#ifndef OPENSSL_NO_TLS1_2
if ((idx & 8) == 8)
maxversion = TLS1_2_VERSION;
#else
if ((idx & 8) == 8)
return TEST_skip("No TLSv1.2");
#endif
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), 0, maxversion,
&sctx, &cctx, cert, privkey)))
goto end;
/*
* Add a large amount of data to fill the buffering BIO used by the SSL
* object
*/
if ((idx & 1) == 1 && !ssl_ctx_add_large_cert_chain(libctx, sctx, cert))
goto end;
/*
* We don't actually configure a client cert, but neither do we fail if one
* isn't present.
*/
if ((idx & 2) == 2)
SSL_CTX_set_verify(sctx, SSL_VERIFY_PEER, NULL);
if ((idx & 4) == 4)
set_always_retry_err_val(0);
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
&clientssl, NULL, NULL)))
goto end;
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_int_eq(SSL_connect(clientssl), -1))
goto end;
if (!TEST_int_eq(SSL_accept(serverssl), -1)
|| !TEST_int_eq(SSL_get_error(serverssl, -1), SSL_ERROR_WANT_WRITE))
goto end;
/* Restore a BIO that will let the write succeed */
SSL_set0_wbio(serverssl, tmp);
tmp = NULL;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
BIO_free(bretry);
BIO_free(tmp);
set_always_retry_err_val(-1);
return testresult;
}
/*
* Test that receiving retries when writing application data works as expected
*/
static int test_data_retry(void)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
int testresult = 0;
unsigned char inbuf[1200], outbuf[1200];
size_t i;
BIO *tmp = NULL;
BIO *bretry = BIO_new(bio_s_maybe_retry());
size_t written, readbytes, totread = 0;
if (!TEST_ptr(bretry))
goto end;
for (i = 0; i < sizeof(inbuf); i++)
inbuf[i] = (unsigned char)(0xff & i);
memset(outbuf, 0, sizeof(outbuf));
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), 0, 0, &sctx, &cctx,
cert, privkey)))
goto end;
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
NULL)))
goto end;
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
goto end;
/* Smallest possible max send fragment is 512 */
if (!TEST_true(SSL_set_max_send_fragment(clientssl, 512)))
goto end;
tmp = SSL_get_wbio(clientssl);
if (!TEST_ptr(tmp))
goto end;
if (!TEST_true(BIO_up_ref(tmp)))
goto end;
BIO_push(bretry, tmp);
tmp = NULL;
SSL_set0_wbio(clientssl, bretry);
if (!BIO_up_ref(bretry)) {
bretry = NULL;
goto end;
}
for (i = 0; i < 3; i++) {
/* We expect this call to make no progress and indicate retry */
if (!TEST_false(SSL_write_ex(clientssl, inbuf, sizeof(inbuf), &written)))
goto end;
if (!TEST_int_eq(SSL_get_error(clientssl, 0), SSL_ERROR_WANT_WRITE))
goto end;
/* Allow one write to progress, but the next one to signal retry */
if (!TEST_true(BIO_ctrl(bretry, MAYBE_RETRY_CTRL_SET_RETRY_AFTER_CNT, 1,
NULL)))
goto end;
if (i == 2)
break;
/*
* This call will hopefully make progress but will still indicate retry
* because there is more data than will fit into a single record.
*/
if (!TEST_false(SSL_write_ex(clientssl, inbuf, sizeof(inbuf), &written)))
goto end;
if (!TEST_int_eq(SSL_get_error(clientssl, 0), SSL_ERROR_WANT_WRITE))
goto end;
}
/* The final call should write the last chunk of data and succeed */
if (!TEST_true(SSL_write_ex(clientssl, inbuf, sizeof(inbuf), &written)))
goto end;
/* Read all the data available */
while (SSL_read_ex(serverssl, outbuf + totread, sizeof(outbuf) - totread,
&readbytes))
totread += readbytes;
if (!TEST_mem_eq(inbuf, sizeof(inbuf), outbuf, totread))
goto end;
testresult = 1;
end:
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
BIO_free_all(bretry);
BIO_free(tmp);
return testresult;
}
OPT_TEST_DECLARE_USAGE("certfile privkeyfile srpvfile tmpfile provider config dhfile\n")
int setup_tests(void)
{
char *modulename;
char *configfile;
libctx = OSSL_LIB_CTX_new();
if (!TEST_ptr(libctx))
return 0;
defctxnull = OSSL_PROVIDER_load(NULL, "null");
/*
* Verify that the default and fips providers in the default libctx are not
* available
*/
if (!TEST_false(OSSL_PROVIDER_available(NULL, "default"))
|| !TEST_false(OSSL_PROVIDER_available(NULL, "fips")))
return 0;
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(certsdir = test_get_argument(0))
|| !TEST_ptr(srpvfile = test_get_argument(1))
|| !TEST_ptr(tmpfilename = test_get_argument(2))
|| !TEST_ptr(modulename = test_get_argument(3))
|| !TEST_ptr(configfile = test_get_argument(4))
|| !TEST_ptr(dhfile = test_get_argument(5)))
return 0;
if (!TEST_true(OSSL_LIB_CTX_load_config(libctx, configfile)))
return 0;
/* Check we have the expected provider available */
if (!TEST_true(OSSL_PROVIDER_available(libctx, modulename)))
return 0;
/* Check the default provider is not available */
if (strcmp(modulename, "default") != 0
&& !TEST_false(OSSL_PROVIDER_available(libctx, "default")))
return 0;
if (strcmp(modulename, "fips") == 0) {
OSSL_PROVIDER *prov = NULL;
OSSL_PARAM params[2];
is_fips = 1;
prov = OSSL_PROVIDER_load(libctx, "fips");
if (prov != NULL) {
/* Query the fips provider to check if the check ems option is enabled */
params[0] =
OSSL_PARAM_construct_int(OSSL_PROV_PARAM_TLS1_PRF_EMS_CHECK,
&fips_ems_check);
params[1] = OSSL_PARAM_construct_end();
OSSL_PROVIDER_get_params(prov, params);
OSSL_PROVIDER_unload(prov);
}
}
/*
* We add, but don't load the test "tls-provider". We'll load it when we
* need it.
*/
if (!TEST_true(OSSL_PROVIDER_add_builtin(libctx, "tls-provider",
tls_provider_init)))
return 0;
if (getenv("OPENSSL_TEST_GETCOUNTS") != NULL) {
#ifdef OPENSSL_NO_CRYPTO_MDEBUG
TEST_error("not supported in this build");
return 0;
#else
int i, mcount, rcount, fcount;
for (i = 0; i < 4; i++)
test_export_key_mat(i);
CRYPTO_get_alloc_counts(&mcount, &rcount, &fcount);
test_printf_stdout("malloc %d realloc %d free %d\n",
mcount, rcount, fcount);
return 1;
#endif
}
cert = test_mk_file_path(certsdir, "servercert.pem");
if (cert == NULL)
goto err;
privkey = test_mk_file_path(certsdir, "serverkey.pem");
if (privkey == NULL)
goto err;
cert2 = test_mk_file_path(certsdir, "server-ecdsa-cert.pem");
if (cert2 == NULL)
goto err;
privkey2 = test_mk_file_path(certsdir, "server-ecdsa-key.pem");
if (privkey2 == NULL)
goto err;
cert1024 = test_mk_file_path(certsdir, "ee-cert-1024.pem");
if (cert1024 == NULL)
goto err;
privkey1024 = test_mk_file_path(certsdir, "ee-key-1024.pem");
if (privkey1024 == NULL)
goto err;
cert3072 = test_mk_file_path(certsdir, "ee-cert-3072.pem");
if (cert3072 == NULL)
goto err;
privkey3072 = test_mk_file_path(certsdir, "ee-key-3072.pem");
if (privkey3072 == NULL)
goto err;
cert4096 = test_mk_file_path(certsdir, "ee-cert-4096.pem");
if (cert4096 == NULL)
goto err;
privkey4096 = test_mk_file_path(certsdir, "ee-key-4096.pem");
if (privkey4096 == NULL)
goto err;
cert8192 = test_mk_file_path(certsdir, "ee-cert-8192.pem");
if (cert8192 == NULL)
goto err;
privkey8192 = test_mk_file_path(certsdir, "ee-key-8192.pem");
if (privkey8192 == NULL)
goto err;
if (fips_ems_check) {
#ifndef OPENSSL_NO_TLS1_2
ADD_TEST(test_no_ems);
#endif
return 1;
}
#if !defined(OPENSSL_NO_KTLS) && !defined(OPENSSL_NO_SOCK)
# if !defined(OPENSSL_NO_TLS1_2) || !defined(OSSL_NO_USABLE_TLS1_3)
ADD_ALL_TESTS(test_ktls, NUM_KTLS_TEST_CIPHERS * 4);
ADD_ALL_TESTS(test_ktls_sendfile, NUM_KTLS_TEST_CIPHERS * 2);
# endif
#endif
ADD_TEST(test_large_message_tls);
ADD_TEST(test_large_message_tls_read_ahead);
#ifndef OPENSSL_NO_DTLS
ADD_TEST(test_large_message_dtls);
#endif
ADD_ALL_TESTS(test_large_app_data, 28);
ADD_TEST(test_cleanse_plaintext);
#ifndef OPENSSL_NO_OCSP
ADD_TEST(test_tlsext_status_type);
#endif
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 OSSL_NO_USABLE_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);
ADD_TEST(test_ssl_bio_pop_ssl_bio);
ADD_TEST(test_ssl_bio_change_rbio);
ADD_TEST(test_ssl_bio_change_wbio);
#if !defined(OPENSSL_NO_TLS1_2) || defined(OSSL_NO_USABLE_TLS1_3)
ADD_ALL_TESTS(test_set_sigalgs, OSSL_NELEM(testsigalgs) * 2);
ADD_TEST(test_keylog);
#endif
#ifndef OSSL_NO_USABLE_TLS1_3
ADD_TEST(test_keylog_no_master_key);
#endif
ADD_TEST(test_client_cert_verify_cb);
ADD_TEST(test_ssl_build_cert_chain);
ADD_TEST(test_ssl_ctx_build_cert_chain);
#ifndef OPENSSL_NO_TLS1_2
ADD_TEST(test_client_hello_cb);
ADD_TEST(test_no_ems);
ADD_TEST(test_ccs_change_cipher);
#endif
#ifndef OSSL_NO_USABLE_TLS1_3
ADD_ALL_TESTS(test_early_data_read_write, 6);
/*
* We don't do replay tests for external PSK. Replay protection isn't used
* in that scenario.
*/
ADD_ALL_TESTS(test_early_data_replay, 2);
ADD_ALL_TESTS(test_early_data_skip, OSSL_NELEM(ciphersuites) * 3);
ADD_ALL_TESTS(test_early_data_skip_hrr, OSSL_NELEM(ciphersuites) * 3);
ADD_ALL_TESTS(test_early_data_skip_hrr_fail, OSSL_NELEM(ciphersuites) * 3);
ADD_ALL_TESTS(test_early_data_skip_abort, OSSL_NELEM(ciphersuites) * 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);
# endif
#endif
#ifndef OSSL_NO_USABLE_TLS1_3
ADD_ALL_TESTS(test_set_ciphersuite, 10);
ADD_TEST(test_ciphersuite_change);
ADD_ALL_TESTS(test_tls13_ciphersuite, 4);
# ifdef OPENSSL_NO_PSK
ADD_ALL_TESTS(test_tls13_psk, 1);
# else
ADD_ALL_TESTS(test_tls13_psk, 4);
# endif /* OPENSSL_NO_PSK */
#ifndef OSSL_NO_USABLE_TLS1_3
ADD_ALL_TESTS(test_tls13_no_dhe_kex, 8);
#endif /* OSSL_NO_USABLE_TLS1_3 */
# ifndef OPENSSL_NO_TLS1_2
/* Test with both TLSv1.3 and 1.2 versions */
ADD_ALL_TESTS(test_key_exchange, 14);
# if !defined(OPENSSL_NO_EC) && !defined(OPENSSL_NO_DH)
ADD_ALL_TESTS(test_negotiated_group,
4 * (OSSL_NELEM(ecdhe_kexch_groups)
+ OSSL_NELEM(ffdhe_kexch_groups)));
# endif
# else
/* Test with only TLSv1.3 versions */
ADD_ALL_TESTS(test_key_exchange, 12);
# endif
ADD_ALL_TESTS(test_custom_exts, 6);
ADD_TEST(test_stateless);
ADD_TEST(test_pha_key_update);
#else
ADD_ALL_TESTS(test_custom_exts, 3);
#endif
ADD_ALL_TESTS(test_export_key_mat, 6);
#ifndef OSSL_NO_USABLE_TLS1_3
ADD_ALL_TESTS(test_export_key_mat_early, 3);
ADD_TEST(test_key_update);
ADD_ALL_TESTS(test_key_update_peer_in_write, 2);
ADD_ALL_TESTS(test_key_update_peer_in_read, 2);
ADD_ALL_TESTS(test_key_update_local_in_write, 2);
ADD_ALL_TESTS(test_key_update_local_in_read, 2);
#endif
ADD_ALL_TESTS(test_ssl_clear, 2);
ADD_ALL_TESTS(test_max_fragment_len_ext, OSSL_NELEM(max_fragment_len_test));
#if !defined(OPENSSL_NO_SRP) && !defined(OPENSSL_NO_TLS1_2)
ADD_ALL_TESTS(test_srp, 6);
#endif
#if !defined(OPENSSL_NO_COMP_ALG)
/* Add compression case */
ADD_ALL_TESTS(test_info_callback, 8);
#else
ADD_ALL_TESTS(test_info_callback, 6);
#endif
ADD_ALL_TESTS(test_ssl_pending, 2);
ADD_ALL_TESTS(test_ssl_get_shared_ciphers, OSSL_NELEM(shared_ciphers_data));
ADD_ALL_TESTS(test_ticket_callbacks, 20);
ADD_ALL_TESTS(test_shutdown, 7);
ADD_TEST(test_async_shutdown);
ADD_ALL_TESTS(test_incorrect_shutdown, 2);
ADD_ALL_TESTS(test_cert_cb, 6);
ADD_ALL_TESTS(test_client_cert_cb, 2);
ADD_ALL_TESTS(test_ca_names, 3);
#ifndef OPENSSL_NO_TLS1_2
ADD_ALL_TESTS(test_multiblock_write, OSSL_NELEM(multiblock_cipherlist_data));
#endif
ADD_ALL_TESTS(test_servername, 10);
#if !defined(OPENSSL_NO_EC) \
&& (!defined(OSSL_NO_USABLE_TLS1_3) || !defined(OPENSSL_NO_TLS1_2))
ADD_ALL_TESTS(test_sigalgs_available, 6);
#endif
#ifndef OPENSSL_NO_TLS1_3
ADD_ALL_TESTS(test_pluggable_group, 2);
ADD_ALL_TESTS(test_pluggable_signature, 4);
#endif
#ifndef OPENSSL_NO_TLS1_2
ADD_TEST(test_ssl_dup);
# ifndef OPENSSL_NO_DH
ADD_ALL_TESTS(test_set_tmp_dh, 11);
ADD_ALL_TESTS(test_dh_auto, 7);
# endif
#endif
#ifndef OSSL_NO_USABLE_TLS1_3
ADD_TEST(test_sni_tls13);
ADD_ALL_TESTS(test_ticket_lifetime, 2);
#endif
ADD_TEST(test_inherit_verify_param);
ADD_TEST(test_set_alpn);
ADD_TEST(test_set_verify_cert_store_ssl_ctx);
ADD_TEST(test_set_verify_cert_store_ssl);
ADD_ALL_TESTS(test_session_timeout, 1);
ADD_TEST(test_load_dhfile);
#ifndef OSSL_NO_USABLE_TLS1_3
ADD_TEST(test_read_ahead_key_change);
ADD_ALL_TESTS(test_tls13_record_padding, 4);
#endif
#if !defined(OPENSSL_NO_TLS1_2) && !defined(OSSL_NO_USABLE_TLS1_3)
ADD_ALL_TESTS(test_serverinfo_custom, 4);
#endif
#if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_DYNAMIC_ENGINE)
ADD_ALL_TESTS(test_pipelining, 7);
#endif
ADD_ALL_TESTS(test_version, 6);
ADD_TEST(test_rstate_string);
ADD_ALL_TESTS(test_handshake_retry, 16);
ADD_TEST(test_data_retry);
return 1;
err:
OPENSSL_free(cert);
OPENSSL_free(privkey);
OPENSSL_free(cert2);
OPENSSL_free(privkey2);
return 0;
}
void cleanup_tests(void)
{
# if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_DH)
EVP_PKEY_free(tmp_dh_params);
#endif
OPENSSL_free(cert);
OPENSSL_free(privkey);
OPENSSL_free(cert2);
OPENSSL_free(privkey2);
OPENSSL_free(cert1024);
OPENSSL_free(privkey1024);
OPENSSL_free(cert3072);
OPENSSL_free(privkey3072);
OPENSSL_free(cert4096);
OPENSSL_free(privkey4096);
OPENSSL_free(cert8192);
OPENSSL_free(privkey8192);
bio_s_mempacket_test_free();
bio_s_always_retry_free();
bio_s_maybe_retry_free();
OSSL_PROVIDER_unload(defctxnull);
OSSL_LIB_CTX_free(libctx);
}
|
./openssl/test/tls-provider.c | /*
* Copyright 2019-2023 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 <string.h>
#include <openssl/core_names.h>
#include <openssl/core_dispatch.h>
#include <openssl/rand.h>
#include <openssl/params.h>
#include <openssl/err.h>
#include <openssl/proverr.h>
#include <openssl/pkcs12.h>
#include <openssl/provider.h>
#include <assert.h>
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/core_object.h>
#include "internal/asn1.h"
/* For TLS1_3_VERSION */
#include <openssl/ssl.h>
#include "internal/nelem.h"
#include "internal/refcount.h"
/* error codes */
/* xorprovider error codes */
#define XORPROV_R_INVALID_DIGEST 1
#define XORPROV_R_INVALID_SIZE 2
#define XORPROV_R_INVALID_KEY 3
#define XORPROV_R_UNSUPPORTED 4
#define XORPROV_R_MISSING_OID 5
#define XORPROV_R_OBJ_CREATE_ERR 6
#define XORPROV_R_INVALID_ENCODING 7
#define XORPROV_R_SIGN_ERROR 8
#define XORPROV_R_LIB_CREATE_ERR 9
#define XORPROV_R_NO_PRIVATE_KEY 10
#define XORPROV_R_BUFFER_LENGTH_WRONG 11
#define XORPROV_R_SIGNING_FAILED 12
#define XORPROV_R_WRONG_PARAMETERS 13
#define XORPROV_R_VERIFY_ERROR 14
#define XORPROV_R_EVPINFO_MISSING 15
static OSSL_FUNC_keymgmt_import_fn xor_import;
static OSSL_FUNC_keymgmt_import_types_fn xor_import_types;
static OSSL_FUNC_keymgmt_import_types_ex_fn xor_import_types_ex;
static OSSL_FUNC_keymgmt_export_fn xor_export;
static OSSL_FUNC_keymgmt_export_types_fn xor_export_types;
static OSSL_FUNC_keymgmt_export_types_ex_fn xor_export_types_ex;
int tls_provider_init(const OSSL_CORE_HANDLE *handle,
const OSSL_DISPATCH *in,
const OSSL_DISPATCH **out,
void **provctx);
#define XOR_KEY_SIZE 32
/*
* Top secret. This algorithm only works if no one knows what this number is.
* Please don't tell anyone what it is.
*
* This algorithm is for testing only - don't really use it!
*/
static const unsigned char private_constant[XOR_KEY_SIZE] = {
0xd3, 0x6b, 0x54, 0xec, 0x5b, 0xac, 0x89, 0x96, 0x8c, 0x2c, 0x66, 0xa5,
0x67, 0x0d, 0xe3, 0xdd, 0x43, 0x69, 0xbc, 0x83, 0x3d, 0x60, 0xc7, 0xb8,
0x2b, 0x1c, 0x5a, 0xfd, 0xb5, 0xcd, 0xd0, 0xf8
};
typedef struct xorkey_st {
unsigned char privkey[XOR_KEY_SIZE];
unsigned char pubkey[XOR_KEY_SIZE];
int hasprivkey;
int haspubkey;
char *tls_name;
CRYPTO_REF_COUNT references;
} XORKEY;
/* Key Management for the dummy XOR KEX, KEM and signature algorithms */
static OSSL_FUNC_keymgmt_new_fn xor_newkey;
static OSSL_FUNC_keymgmt_free_fn xor_freekey;
static OSSL_FUNC_keymgmt_has_fn xor_has;
static OSSL_FUNC_keymgmt_dup_fn xor_dup;
static OSSL_FUNC_keymgmt_gen_init_fn xor_gen_init;
static OSSL_FUNC_keymgmt_gen_set_params_fn xor_gen_set_params;
static OSSL_FUNC_keymgmt_gen_settable_params_fn xor_gen_settable_params;
static OSSL_FUNC_keymgmt_gen_fn xor_gen;
static OSSL_FUNC_keymgmt_gen_cleanup_fn xor_gen_cleanup;
static OSSL_FUNC_keymgmt_load_fn xor_load;
static OSSL_FUNC_keymgmt_get_params_fn xor_get_params;
static OSSL_FUNC_keymgmt_gettable_params_fn xor_gettable_params;
static OSSL_FUNC_keymgmt_set_params_fn xor_set_params;
static OSSL_FUNC_keymgmt_settable_params_fn xor_settable_params;
/*
* Dummy "XOR" Key Exchange algorithm. We just xor the private and public keys
* together. Don't use this!
*/
static OSSL_FUNC_keyexch_newctx_fn xor_newkemkexctx;
static OSSL_FUNC_keyexch_init_fn xor_init;
static OSSL_FUNC_keyexch_set_peer_fn xor_set_peer;
static OSSL_FUNC_keyexch_derive_fn xor_derive;
static OSSL_FUNC_keyexch_freectx_fn xor_freectx;
static OSSL_FUNC_keyexch_dupctx_fn xor_dupctx;
/*
* Dummy "XOR" Key Encapsulation Method. We just build a KEM over the xor KEX.
* Don't use this!
*/
static OSSL_FUNC_kem_newctx_fn xor_newkemkexctx;
static OSSL_FUNC_kem_freectx_fn xor_freectx;
static OSSL_FUNC_kem_dupctx_fn xor_dupctx;
static OSSL_FUNC_kem_encapsulate_init_fn xor_init;
static OSSL_FUNC_kem_encapsulate_fn xor_encapsulate;
static OSSL_FUNC_kem_decapsulate_init_fn xor_init;
static OSSL_FUNC_kem_decapsulate_fn xor_decapsulate;
/*
* Common key management table access functions
*/
static OSSL_FUNC_keymgmt_new_fn *
xor_prov_get_keymgmt_new(const OSSL_DISPATCH *fns)
{
/* Pilfer the keymgmt dispatch table */
for (; fns->function_id != 0; fns++)
if (fns->function_id == OSSL_FUNC_KEYMGMT_NEW)
return OSSL_FUNC_keymgmt_new(fns);
return NULL;
}
static OSSL_FUNC_keymgmt_free_fn *
xor_prov_get_keymgmt_free(const OSSL_DISPATCH *fns)
{
/* Pilfer the keymgmt dispatch table */
for (; fns->function_id != 0; fns++)
if (fns->function_id == OSSL_FUNC_KEYMGMT_FREE)
return OSSL_FUNC_keymgmt_free(fns);
return NULL;
}
static OSSL_FUNC_keymgmt_import_fn *
xor_prov_get_keymgmt_import(const OSSL_DISPATCH *fns)
{
/* Pilfer the keymgmt dispatch table */
for (; fns->function_id != 0; fns++)
if (fns->function_id == OSSL_FUNC_KEYMGMT_IMPORT)
return OSSL_FUNC_keymgmt_import(fns);
return NULL;
}
static OSSL_FUNC_keymgmt_export_fn *
xor_prov_get_keymgmt_export(const OSSL_DISPATCH *fns)
{
/* Pilfer the keymgmt dispatch table */
for (; fns->function_id != 0; fns++)
if (fns->function_id == OSSL_FUNC_KEYMGMT_EXPORT)
return OSSL_FUNC_keymgmt_export(fns);
return NULL;
}
static void *xor_prov_import_key(const OSSL_DISPATCH *fns, void *provctx,
int selection, const OSSL_PARAM params[])
{
OSSL_FUNC_keymgmt_new_fn *kmgmt_new = xor_prov_get_keymgmt_new(fns);
OSSL_FUNC_keymgmt_free_fn *kmgmt_free = xor_prov_get_keymgmt_free(fns);
OSSL_FUNC_keymgmt_import_fn *kmgmt_import =
xor_prov_get_keymgmt_import(fns);
void *key = NULL;
if (kmgmt_new != NULL && kmgmt_import != NULL && kmgmt_free != NULL) {
if ((key = kmgmt_new(provctx)) == NULL
|| !kmgmt_import(key, selection, params)) {
kmgmt_free(key);
key = NULL;
}
}
return key;
}
static void xor_prov_free_key(const OSSL_DISPATCH *fns, void *key)
{
OSSL_FUNC_keymgmt_free_fn *kmgmt_free = xor_prov_get_keymgmt_free(fns);
if (kmgmt_free != NULL)
kmgmt_free(key);
}
/*
* We define 2 dummy TLS groups called "xorgroup" and "xorkemgroup" for test
* purposes
*/
struct tls_group_st {
unsigned int group_id; /* for "tls-group-id", see provider-base(7) */
unsigned int secbits;
unsigned int mintls;
unsigned int maxtls;
unsigned int mindtls;
unsigned int maxdtls;
unsigned int is_kem; /* boolean */
};
#define XORGROUP_NAME "xorgroup"
#define XORGROUP_NAME_INTERNAL "xorgroup-int"
static struct tls_group_st xor_group = {
0, /* group_id, set by randomize_tls_alg_id() */
128, /* secbits */
TLS1_3_VERSION, /* mintls */
0, /* maxtls */
-1, /* mindtls */
-1, /* maxdtls */
0 /* is_kem */
};
#define XORKEMGROUP_NAME "xorkemgroup"
#define XORKEMGROUP_NAME_INTERNAL "xorkemgroup-int"
static struct tls_group_st xor_kemgroup = {
0, /* group_id, set by randomize_tls_alg_id() */
128, /* secbits */
TLS1_3_VERSION, /* mintls */
0, /* maxtls */
-1, /* mindtls */
-1, /* maxdtls */
1 /* is_kem */
};
#define ALGORITHM "XOR"
static const OSSL_PARAM xor_group_params[] = {
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME,
XORGROUP_NAME, sizeof(XORGROUP_NAME)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME_INTERNAL,
XORGROUP_NAME_INTERNAL,
sizeof(XORGROUP_NAME_INTERNAL)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_ALG, ALGORITHM,
sizeof(ALGORITHM)),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_ID, &xor_group.group_id),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_SECURITY_BITS,
&xor_group.secbits),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_TLS, &xor_group.mintls),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_TLS, &xor_group.maxtls),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_DTLS, &xor_group.mindtls),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_DTLS, &xor_group.maxdtls),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_IS_KEM, &xor_group.is_kem),
OSSL_PARAM_END
};
static const OSSL_PARAM xor_kemgroup_params[] = {
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME,
XORKEMGROUP_NAME, sizeof(XORKEMGROUP_NAME)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME_INTERNAL,
XORKEMGROUP_NAME_INTERNAL,
sizeof(XORKEMGROUP_NAME_INTERNAL)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_ALG, ALGORITHM,
sizeof(ALGORITHM)),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_ID, &xor_kemgroup.group_id),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_SECURITY_BITS,
&xor_kemgroup.secbits),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_TLS, &xor_kemgroup.mintls),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_TLS, &xor_kemgroup.maxtls),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_DTLS, &xor_kemgroup.mindtls),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_DTLS, &xor_kemgroup.maxdtls),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_IS_KEM, &xor_kemgroup.is_kem),
OSSL_PARAM_END
};
#define NUM_DUMMY_GROUPS 50
static char *dummy_group_names[NUM_DUMMY_GROUPS];
/*
* We define a dummy TLS sigalg called for test purposes
*/
struct tls_sigalg_st {
unsigned int code_point; /* for "tls-sigalg-alg", see provider-base(7) */
unsigned int secbits;
unsigned int mintls;
unsigned int maxtls;
};
#define XORSIGALG_NAME "xorhmacsig"
#define XORSIGALG_OID "1.3.6.1.4.1.16604.998888.1"
#define XORSIGALG_HASH_NAME "xorhmacsha2sig"
#define XORSIGALG_HASH "SHA256"
#define XORSIGALG_HASH_OID "1.3.6.1.4.1.16604.998888.2"
#define XORSIGALG12_NAME "xorhmacsig12"
#define XORSIGALG12_OID "1.3.6.1.4.1.16604.998888.3"
static struct tls_sigalg_st xor_sigalg = {
0, /* alg id, set by randomize_tls_alg_id() */
128, /* secbits */
TLS1_3_VERSION, /* mintls */
0, /* maxtls */
};
static struct tls_sigalg_st xor_sigalg_hash = {
0, /* alg id, set by randomize_tls_alg_id() */
128, /* secbits */
TLS1_3_VERSION, /* mintls */
0, /* maxtls */
};
static struct tls_sigalg_st xor_sigalg12 = {
0, /* alg id, set by randomize_tls_alg_id() */
128, /* secbits */
TLS1_2_VERSION, /* mintls */
TLS1_2_VERSION, /* maxtls */
};
static const OSSL_PARAM xor_sig_nohash_params[] = {
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_IANA_NAME,
XORSIGALG_NAME, sizeof(XORSIGALG_NAME)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_NAME,
XORSIGALG_NAME,
sizeof(XORSIGALG_NAME)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_OID,
XORSIGALG_OID, sizeof(XORSIGALG_OID)),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_SIGALG_CODE_POINT,
&xor_sigalg.code_point),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_SIGALG_SECURITY_BITS,
&xor_sigalg.secbits),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MIN_TLS,
&xor_sigalg.mintls),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MAX_TLS,
&xor_sigalg.maxtls),
OSSL_PARAM_END
};
static const OSSL_PARAM xor_sig_hash_params[] = {
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_IANA_NAME,
XORSIGALG_HASH_NAME, sizeof(XORSIGALG_HASH_NAME)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_NAME,
XORSIGALG_HASH_NAME,
sizeof(XORSIGALG_HASH_NAME)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_HASH_NAME,
XORSIGALG_HASH, sizeof(XORSIGALG_HASH)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_OID,
XORSIGALG_HASH_OID, sizeof(XORSIGALG_HASH_OID)),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_SIGALG_CODE_POINT,
&xor_sigalg_hash.code_point),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_SIGALG_SECURITY_BITS,
&xor_sigalg_hash.secbits),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MIN_TLS,
&xor_sigalg_hash.mintls),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MAX_TLS,
&xor_sigalg_hash.maxtls),
OSSL_PARAM_END
};
static const OSSL_PARAM xor_sig_12_params[] = {
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_IANA_NAME,
XORSIGALG12_NAME, sizeof(XORSIGALG12_NAME)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_NAME,
XORSIGALG12_NAME,
sizeof(XORSIGALG12_NAME)),
OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_OID,
XORSIGALG12_OID, sizeof(XORSIGALG12_OID)),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_SIGALG_CODE_POINT,
&xor_sigalg12.code_point),
OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_SIGALG_SECURITY_BITS,
&xor_sigalg12.secbits),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MIN_TLS,
&xor_sigalg12.mintls),
OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MAX_TLS,
&xor_sigalg12.maxtls),
OSSL_PARAM_END
};
static int tls_prov_get_capabilities(void *provctx, const char *capability,
OSSL_CALLBACK *cb, void *arg)
{
int ret = 0;
int i;
const char *dummy_base = "dummy";
const size_t dummy_name_max_size = strlen(dummy_base) + 3;
if (strcmp(capability, "TLS-GROUP") == 0) {
/* Register our 2 groups */
ret = cb(xor_group_params, arg);
ret &= cb(xor_kemgroup_params, arg);
/*
* Now register some dummy groups > GROUPLIST_INCREMENT (== 40) as defined
* in ssl/t1_lib.c, to make sure we exercise the code paths for registering
* large numbers of groups.
*/
for (i = 0; i < NUM_DUMMY_GROUPS; i++) {
OSSL_PARAM dummygroup[OSSL_NELEM(xor_group_params)];
memcpy(dummygroup, xor_group_params, sizeof(xor_group_params));
/* Give the dummy group a unique name */
if (dummy_group_names[i] == NULL) {
dummy_group_names[i] = OPENSSL_zalloc(dummy_name_max_size);
if (dummy_group_names[i] == NULL)
return 0;
BIO_snprintf(dummy_group_names[i],
dummy_name_max_size,
"%s%d", dummy_base, i);
}
dummygroup[0].data = dummy_group_names[i];
dummygroup[0].data_size = strlen(dummy_group_names[i]) + 1;
ret &= cb(dummygroup, arg);
}
}
if (strcmp(capability, "TLS-SIGALG") == 0) {
ret = cb(xor_sig_nohash_params, arg);
ret &= cb(xor_sig_hash_params, arg);
ret &= cb(xor_sig_12_params, arg);
}
return ret;
}
typedef struct {
OSSL_LIB_CTX *libctx;
} PROV_XOR_CTX;
static PROV_XOR_CTX *xor_newprovctx(OSSL_LIB_CTX *libctx)
{
PROV_XOR_CTX* prov_ctx = OPENSSL_malloc(sizeof(PROV_XOR_CTX));
if (prov_ctx == NULL)
return NULL;
if (libctx == NULL) {
OPENSSL_free(prov_ctx);
return NULL;
}
prov_ctx->libctx = libctx;
return prov_ctx;
}
#define PROV_XOR_LIBCTX_OF(provctx) (((PROV_XOR_CTX *)provctx)->libctx)
/*
* Dummy "XOR" Key Exchange and signature algorithm. We just xor the
* private and public keys together. Don't use this!
*/
typedef struct {
XORKEY *key;
XORKEY *peerkey;
void *provctx;
} PROV_XORKEMKEX_CTX;
static void *xor_newkemkexctx(void *provctx)
{
PROV_XORKEMKEX_CTX *pxorctx = OPENSSL_zalloc(sizeof(PROV_XORKEMKEX_CTX));
if (pxorctx == NULL)
return NULL;
pxorctx->provctx = provctx;
return pxorctx;
}
static int xor_init(void *vpxorctx, void *vkey,
ossl_unused const OSSL_PARAM params[])
{
PROV_XORKEMKEX_CTX *pxorctx = (PROV_XORKEMKEX_CTX *)vpxorctx;
if (pxorctx == NULL || vkey == NULL)
return 0;
pxorctx->key = vkey;
return 1;
}
static int xor_set_peer(void *vpxorctx, void *vpeerkey)
{
PROV_XORKEMKEX_CTX *pxorctx = (PROV_XORKEMKEX_CTX *)vpxorctx;
if (pxorctx == NULL || vpeerkey == NULL)
return 0;
pxorctx->peerkey = vpeerkey;
return 1;
}
static int xor_derive(void *vpxorctx, unsigned char *secret, size_t *secretlen,
size_t outlen)
{
PROV_XORKEMKEX_CTX *pxorctx = (PROV_XORKEMKEX_CTX *)vpxorctx;
int i;
if (pxorctx->key == NULL || pxorctx->peerkey == NULL)
return 0;
*secretlen = XOR_KEY_SIZE;
if (secret == NULL)
return 1;
if (outlen < XOR_KEY_SIZE)
return 0;
for (i = 0; i < XOR_KEY_SIZE; i++)
secret[i] = pxorctx->key->privkey[i] ^ pxorctx->peerkey->pubkey[i];
return 1;
}
static void xor_freectx(void *pxorctx)
{
OPENSSL_free(pxorctx);
}
static void *xor_dupctx(void *vpxorctx)
{
PROV_XORKEMKEX_CTX *srcctx = (PROV_XORKEMKEX_CTX *)vpxorctx;
PROV_XORKEMKEX_CTX *dstctx;
dstctx = OPENSSL_zalloc(sizeof(*srcctx));
if (dstctx == NULL)
return NULL;
*dstctx = *srcctx;
return dstctx;
}
static const OSSL_DISPATCH xor_keyexch_functions[] = {
{ OSSL_FUNC_KEYEXCH_NEWCTX, (void (*)(void))xor_newkemkexctx },
{ OSSL_FUNC_KEYEXCH_INIT, (void (*)(void))xor_init },
{ OSSL_FUNC_KEYEXCH_DERIVE, (void (*)(void))xor_derive },
{ OSSL_FUNC_KEYEXCH_SET_PEER, (void (*)(void))xor_set_peer },
{ OSSL_FUNC_KEYEXCH_FREECTX, (void (*)(void))xor_freectx },
{ OSSL_FUNC_KEYEXCH_DUPCTX, (void (*)(void))xor_dupctx },
OSSL_DISPATCH_END
};
static const OSSL_ALGORITHM tls_prov_keyexch[] = {
/*
* Obviously this is not FIPS approved, but in order to test in conjunction
* with the FIPS provider we pretend that it is.
*/
{ "XOR", "provider=tls-provider,fips=yes", xor_keyexch_functions },
{ NULL, NULL, NULL }
};
/*
* Dummy "XOR" Key Encapsulation Method. We just build a KEM over the xor KEX.
* Don't use this!
*/
static int xor_encapsulate(void *vpxorctx,
unsigned char *ct, size_t *ctlen,
unsigned char *ss, size_t *sslen)
{
/*
* We are building this around a KEX:
*
* 1. we generate ephemeral keypair
* 2. we encode our ephemeral pubkey as the outgoing ct
* 3. we derive using our ephemeral privkey in combination with the peer
* pubkey from the ctx; the result is our ss.
*/
int rv = 0;
void *genctx = NULL, *derivectx = NULL;
XORKEY *ourkey = NULL;
PROV_XORKEMKEX_CTX *pxorctx = vpxorctx;
if (ct == NULL || ss == NULL) {
/* Just return sizes */
if (ctlen == NULL && sslen == NULL)
return 0;
if (ctlen != NULL)
*ctlen = XOR_KEY_SIZE;
if (sslen != NULL)
*sslen = XOR_KEY_SIZE;
return 1;
}
/* 1. Generate keypair */
genctx = xor_gen_init(pxorctx->provctx, OSSL_KEYMGMT_SELECT_KEYPAIR, NULL);
if (genctx == NULL)
goto end;
ourkey = xor_gen(genctx, NULL, NULL);
if (ourkey == NULL)
goto end;
/* 2. Encode ephemeral pubkey as ct */
memcpy(ct, ourkey->pubkey, XOR_KEY_SIZE);
*ctlen = XOR_KEY_SIZE;
/* 3. Derive ss via KEX */
derivectx = xor_newkemkexctx(pxorctx->provctx);
if (derivectx == NULL
|| !xor_init(derivectx, ourkey, NULL)
|| !xor_set_peer(derivectx, pxorctx->key)
|| !xor_derive(derivectx, ss, sslen, XOR_KEY_SIZE))
goto end;
rv = 1;
end:
xor_gen_cleanup(genctx);
xor_freekey(ourkey);
xor_freectx(derivectx);
return rv;
}
static int xor_decapsulate(void *vpxorctx,
unsigned char *ss, size_t *sslen,
const unsigned char *ct, size_t ctlen)
{
/*
* We are building this around a KEX:
*
* - ct is our peer's pubkey
* - decapsulate is just derive.
*/
int rv = 0;
void *derivectx = NULL;
XORKEY *peerkey = NULL;
PROV_XORKEMKEX_CTX *pxorctx = vpxorctx;
if (ss == NULL) {
/* Just return size */
if (sslen == NULL)
return 0;
*sslen = XOR_KEY_SIZE;
return 1;
}
if (ctlen != XOR_KEY_SIZE)
return 0;
peerkey = xor_newkey(pxorctx->provctx);
if (peerkey == NULL)
goto end;
memcpy(peerkey->pubkey, ct, XOR_KEY_SIZE);
/* Derive ss via KEX */
derivectx = xor_newkemkexctx(pxorctx->provctx);
if (derivectx == NULL
|| !xor_init(derivectx, pxorctx->key, NULL)
|| !xor_set_peer(derivectx, peerkey)
|| !xor_derive(derivectx, ss, sslen, XOR_KEY_SIZE))
goto end;
rv = 1;
end:
xor_freekey(peerkey);
xor_freectx(derivectx);
return rv;
}
static const OSSL_DISPATCH xor_kem_functions[] = {
{ OSSL_FUNC_KEM_NEWCTX, (void (*)(void))xor_newkemkexctx },
{ OSSL_FUNC_KEM_FREECTX, (void (*)(void))xor_freectx },
{ OSSL_FUNC_KEM_DUPCTX, (void (*)(void))xor_dupctx },
{ OSSL_FUNC_KEM_ENCAPSULATE_INIT, (void (*)(void))xor_init },
{ OSSL_FUNC_KEM_ENCAPSULATE, (void (*)(void))xor_encapsulate },
{ OSSL_FUNC_KEM_DECAPSULATE_INIT, (void (*)(void))xor_init },
{ OSSL_FUNC_KEM_DECAPSULATE, (void (*)(void))xor_decapsulate },
OSSL_DISPATCH_END
};
static const OSSL_ALGORITHM tls_prov_kem[] = {
/*
* Obviously this is not FIPS approved, but in order to test in conjunction
* with the FIPS provider we pretend that it is.
*/
{ "XOR", "provider=tls-provider,fips=yes", xor_kem_functions },
{ NULL, NULL, NULL }
};
/* Key Management for the dummy XOR key exchange algorithm */
static void *xor_newkey(void *provctx)
{
XORKEY *ret = OPENSSL_zalloc(sizeof(XORKEY));
if (ret == NULL)
return NULL;
if (!CRYPTO_NEW_REF(&ret->references, 1)) {
OPENSSL_free(ret);
return NULL;
}
return ret;
}
static void xor_freekey(void *keydata)
{
XORKEY* key = (XORKEY *)keydata;
int refcnt;
if (key == NULL)
return;
if (CRYPTO_DOWN_REF(&key->references, &refcnt) <= 0)
return;
if (refcnt > 0)
return;
assert(refcnt == 0);
if (key != NULL) {
OPENSSL_free(key->tls_name);
key->tls_name = NULL;
}
CRYPTO_FREE_REF(&key->references);
OPENSSL_free(key);
}
static int xor_key_up_ref(XORKEY *key)
{
int refcnt;
if (CRYPTO_UP_REF(&key->references, &refcnt) <= 0)
return 0;
assert(refcnt > 1);
return (refcnt > 1);
}
static int xor_has(const void *vkey, int selection)
{
const XORKEY *key = vkey;
int ok = 0;
if (key != NULL) {
ok = 1;
if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
ok = ok && key->haspubkey;
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
ok = ok && key->hasprivkey;
}
return ok;
}
static void *xor_dup(const void *vfromkey, int selection)
{
XORKEY *tokey = xor_newkey(NULL);
const XORKEY *fromkey = vfromkey;
int ok = 0;
if (tokey != NULL && fromkey != NULL) {
ok = 1;
if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
if (fromkey->haspubkey) {
memcpy(tokey->pubkey, fromkey->pubkey, XOR_KEY_SIZE);
tokey->haspubkey = 1;
} else {
tokey->haspubkey = 0;
}
}
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
if (fromkey->hasprivkey) {
memcpy(tokey->privkey, fromkey->privkey, XOR_KEY_SIZE);
tokey->hasprivkey = 1;
} else {
tokey->hasprivkey = 0;
}
}
if (fromkey->tls_name != NULL)
tokey->tls_name = OPENSSL_strdup(fromkey->tls_name);
}
if (!ok) {
xor_freekey(tokey);
tokey = NULL;
}
return tokey;
}
static ossl_inline int xor_get_params(void *vkey, OSSL_PARAM params[])
{
XORKEY *key = vkey;
OSSL_PARAM *p;
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_BITS)) != NULL
&& !OSSL_PARAM_set_int(p, XOR_KEY_SIZE))
return 0;
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_SECURITY_BITS)) != NULL
&& !OSSL_PARAM_set_int(p, xor_group.secbits))
return 0;
if ((p = OSSL_PARAM_locate(params,
OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY)) != NULL) {
if (p->data_type != OSSL_PARAM_OCTET_STRING)
return 0;
p->return_size = XOR_KEY_SIZE;
if (p->data != NULL && p->data_size >= XOR_KEY_SIZE)
memcpy(p->data, key->pubkey, XOR_KEY_SIZE);
}
return 1;
}
static const OSSL_PARAM xor_params[] = {
OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL),
OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL),
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, NULL, 0),
OSSL_PARAM_END
};
static const OSSL_PARAM *xor_gettable_params(void *provctx)
{
return xor_params;
}
static int xor_set_params(void *vkey, const OSSL_PARAM params[])
{
XORKEY *key = vkey;
const OSSL_PARAM *p;
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY);
if (p != NULL) {
if (p->data_type != OSSL_PARAM_OCTET_STRING
|| p->data_size != XOR_KEY_SIZE)
return 0;
memcpy(key->pubkey, p->data, XOR_KEY_SIZE);
key->haspubkey = 1;
}
return 1;
}
static const OSSL_PARAM xor_known_settable_params[] = {
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, NULL, 0),
OSSL_PARAM_END
};
static void *xor_load(const void *reference, size_t reference_sz)
{
XORKEY *key = NULL;
if (reference_sz == sizeof(key)) {
/* The contents of the reference is the address to our object */
key = *(XORKEY **)reference;
/* We grabbed, so we detach it */
*(XORKEY **)reference = NULL;
return key;
}
return NULL;
}
/* check one key is the "XOR complement" of the other */
static int xor_recreate(const unsigned char *kd1, const unsigned char *kd2) {
int i;
for (i = 0; i < XOR_KEY_SIZE; i++) {
if ((kd1[i] & 0xff) != ((kd2[i] ^ private_constant[i]) & 0xff))
return 0;
}
return 1;
}
static int xor_match(const void *keydata1, const void *keydata2, int selection)
{
const XORKEY *key1 = keydata1;
const XORKEY *key2 = keydata2;
int ok = 1;
if (key1->tls_name != NULL && key2->tls_name != NULL)
ok = ok & (strcmp(key1->tls_name, key2->tls_name) == 0);
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
if (key1->hasprivkey) {
if (key2->hasprivkey)
ok = ok & (CRYPTO_memcmp(key1->privkey, key2->privkey,
XOR_KEY_SIZE) == 0);
else
ok = ok & xor_recreate(key1->privkey, key2->pubkey);
} else {
if (key2->hasprivkey)
ok = ok & xor_recreate(key2->privkey, key1->pubkey);
else
ok = 0;
}
}
if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
if (key1->haspubkey) {
if (key2->haspubkey)
ok = ok & (CRYPTO_memcmp(key1->pubkey, key2->pubkey, XOR_KEY_SIZE) == 0);
else
ok = ok & xor_recreate(key1->pubkey, key2->privkey);
} else {
if (key2->haspubkey)
ok = ok & xor_recreate(key2->pubkey, key1->privkey);
else
ok = 0;
}
}
return ok;
}
static const OSSL_PARAM *xor_settable_params(void *provctx)
{
return xor_known_settable_params;
}
struct xor_gen_ctx {
int selection;
OSSL_LIB_CTX *libctx;
};
static void *xor_gen_init(void *provctx, int selection,
const OSSL_PARAM params[])
{
struct xor_gen_ctx *gctx = NULL;
if ((selection & (OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS)) == 0)
return NULL;
if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL)
gctx->selection = selection;
gctx->libctx = PROV_XOR_LIBCTX_OF(provctx);
if (!xor_gen_set_params(gctx, params)) {
OPENSSL_free(gctx);
return NULL;
}
return gctx;
}
static int xor_gen_set_params(void *genctx, const OSSL_PARAM params[])
{
struct xor_gen_ctx *gctx = genctx;
const OSSL_PARAM *p;
if (gctx == NULL)
return 0;
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_GROUP_NAME);
if (p != NULL) {
if (p->data_type != OSSL_PARAM_UTF8_STRING
|| (strcmp(p->data, XORGROUP_NAME_INTERNAL) != 0
&& strcmp(p->data, XORKEMGROUP_NAME_INTERNAL) != 0))
return 0;
}
return 1;
}
static const OSSL_PARAM *xor_gen_settable_params(ossl_unused void *genctx,
ossl_unused void *provctx)
{
static OSSL_PARAM settable[] = {
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, NULL, 0),
OSSL_PARAM_END
};
return settable;
}
static void *xor_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
{
struct xor_gen_ctx *gctx = genctx;
XORKEY *key = xor_newkey(NULL);
size_t i;
if (key == NULL)
return NULL;
if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
if (RAND_bytes_ex(gctx->libctx, key->privkey, XOR_KEY_SIZE, 0) <= 0) {
OPENSSL_free(key);
return NULL;
}
for (i = 0; i < XOR_KEY_SIZE; i++)
key->pubkey[i] = key->privkey[i] ^ private_constant[i];
key->hasprivkey = 1;
key->haspubkey = 1;
}
return key;
}
/* IMPORT + EXPORT */
static int xor_import(void *vkey, int select, const OSSL_PARAM params[])
{
XORKEY *key = vkey;
const OSSL_PARAM *param_priv_key, *param_pub_key;
unsigned char privkey[XOR_KEY_SIZE];
unsigned char pubkey[XOR_KEY_SIZE];
void *pprivkey = privkey, *ppubkey = pubkey;
size_t priv_len = 0, pub_len = 0;
int res = 0;
if (key == NULL || (select & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
return 0;
memset(privkey, 0, sizeof(privkey));
memset(pubkey, 0, sizeof(pubkey));
param_priv_key = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
param_pub_key = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PUB_KEY);
if ((param_priv_key != NULL
&& !OSSL_PARAM_get_octet_string(param_priv_key, &pprivkey,
sizeof(privkey), &priv_len))
|| (param_pub_key != NULL
&& !OSSL_PARAM_get_octet_string(param_pub_key, &ppubkey,
sizeof(pubkey), &pub_len)))
goto err;
if (priv_len > 0) {
memcpy(key->privkey, privkey, priv_len);
key->hasprivkey = 1;
}
if (pub_len > 0) {
memcpy(key->pubkey, pubkey, pub_len);
key->haspubkey = 1;
}
res = 1;
err:
return res;
}
static int xor_export(void *vkey, int select, OSSL_CALLBACK *param_cb,
void *cbarg)
{
XORKEY *key = vkey;
OSSL_PARAM params[3], *p = params;
if (key == NULL || (select & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
return 0;
*p++ = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_PRIV_KEY,
key->privkey,
sizeof(key->privkey));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_PUB_KEY,
key->pubkey, sizeof(key->pubkey));
*p++ = OSSL_PARAM_construct_end();
return param_cb(params, cbarg);
}
static const OSSL_PARAM xor_key_types[] = {
OSSL_PARAM_BN(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0),
OSSL_PARAM_BN(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
OSSL_PARAM_END
};
static const OSSL_PARAM *xor_import_types(int select)
{
return (select & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0 ? xor_key_types : NULL;
}
static const OSSL_PARAM *xor_import_types_ex(void *provctx, int select)
{
if (provctx == NULL)
return NULL;
return xor_import_types(select);
}
static const OSSL_PARAM *xor_export_types(int select)
{
return (select & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0 ? xor_key_types : NULL;
}
static const OSSL_PARAM *xor_export_types_ex(void *provctx, int select)
{
if (provctx == NULL)
return NULL;
return xor_export_types(select);
}
static void xor_gen_cleanup(void *genctx)
{
OPENSSL_free(genctx);
}
static const OSSL_DISPATCH xor_keymgmt_functions[] = {
{ OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))xor_newkey },
{ OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))xor_gen_init },
{ OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))xor_gen_set_params },
{ OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
(void (*)(void))xor_gen_settable_params },
{ OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))xor_gen },
{ OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))xor_gen_cleanup },
{ OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))xor_get_params },
{ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))xor_gettable_params },
{ OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*) (void))xor_set_params },
{ OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, (void (*) (void))xor_settable_params },
{ OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))xor_has },
{ OSSL_FUNC_KEYMGMT_DUP, (void (*)(void))xor_dup },
{ OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))xor_freekey },
{ OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))xor_import },
{ OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))xor_import_types },
{ OSSL_FUNC_KEYMGMT_IMPORT_TYPES_EX, (void (*)(void))xor_import_types_ex },
{ OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))xor_export },
{ OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))xor_export_types },
{ OSSL_FUNC_KEYMGMT_EXPORT_TYPES_EX, (void (*)(void))xor_export_types_ex },
OSSL_DISPATCH_END
};
/* We're re-using most XOR keymgmt functions also for signature operations: */
static void *xor_xorhmacsig_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
{
XORKEY *k = xor_gen(genctx, osslcb, cbarg);
if (k == NULL)
return NULL;
k->tls_name = OPENSSL_strdup(XORSIGALG_NAME);
if (k->tls_name == NULL) {
xor_freekey(k);
return NULL;
}
return k;
}
static void *xor_xorhmacsha2sig_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
{
XORKEY* k = xor_gen(genctx, osslcb, cbarg);
if (k == NULL)
return NULL;
k->tls_name = OPENSSL_strdup(XORSIGALG_HASH_NAME);
if (k->tls_name == NULL) {
xor_freekey(k);
return NULL;
}
return k;
}
static const OSSL_DISPATCH xor_xorhmacsig_keymgmt_functions[] = {
{ OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))xor_newkey },
{ OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))xor_gen_init },
{ OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))xor_gen_set_params },
{ OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
(void (*)(void))xor_gen_settable_params },
{ OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))xor_xorhmacsig_gen },
{ OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))xor_gen_cleanup },
{ OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))xor_get_params },
{ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))xor_gettable_params },
{ OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*) (void))xor_set_params },
{ OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, (void (*) (void))xor_settable_params },
{ OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))xor_has },
{ OSSL_FUNC_KEYMGMT_DUP, (void (*)(void))xor_dup },
{ OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))xor_freekey },
{ OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))xor_import },
{ OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))xor_import_types },
{ OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))xor_export },
{ OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))xor_export_types },
{ OSSL_FUNC_KEYMGMT_LOAD, (void (*)(void))xor_load },
{ OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))xor_match },
OSSL_DISPATCH_END
};
static const OSSL_DISPATCH xor_xorhmacsha2sig_keymgmt_functions[] = {
{ OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))xor_newkey },
{ OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))xor_gen_init },
{ OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))xor_gen_set_params },
{ OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
(void (*)(void))xor_gen_settable_params },
{ OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))xor_xorhmacsha2sig_gen },
{ OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))xor_gen_cleanup },
{ OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))xor_get_params },
{ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))xor_gettable_params },
{ OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*) (void))xor_set_params },
{ OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, (void (*) (void))xor_settable_params },
{ OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))xor_has },
{ OSSL_FUNC_KEYMGMT_DUP, (void (*)(void))xor_dup },
{ OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))xor_freekey },
{ OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))xor_import },
{ OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))xor_import_types },
{ OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))xor_export },
{ OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))xor_export_types },
{ OSSL_FUNC_KEYMGMT_LOAD, (void (*)(void))xor_load },
{ OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))xor_match },
OSSL_DISPATCH_END
};
typedef enum {
KEY_OP_PUBLIC,
KEY_OP_PRIVATE,
KEY_OP_KEYGEN
} xor_key_op_t;
/* Re-create XORKEY from encoding(s): Same end-state as after key-gen */
static XORKEY *xor_key_op(const X509_ALGOR *palg,
const unsigned char *p, int plen,
xor_key_op_t op,
OSSL_LIB_CTX *libctx, const char *propq)
{
XORKEY *key = NULL;
int nid = NID_undef;
if (palg != NULL) {
int ptype;
/* Algorithm parameters must be absent */
X509_ALGOR_get0(NULL, &ptype, NULL, palg);
if (ptype != V_ASN1_UNDEF || palg->algorithm == NULL) {
ERR_raise(ERR_LIB_USER, XORPROV_R_INVALID_ENCODING);
return 0;
}
nid = OBJ_obj2nid(palg->algorithm);
}
if (p == NULL || nid == EVP_PKEY_NONE || nid == NID_undef) {
ERR_raise(ERR_LIB_USER, XORPROV_R_INVALID_ENCODING);
return 0;
}
key = xor_newkey(NULL);
if (key == NULL) {
ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE);
return 0;
}
if (XOR_KEY_SIZE != plen) {
ERR_raise(ERR_LIB_USER, XORPROV_R_INVALID_ENCODING);
goto err;
}
if (op == KEY_OP_PUBLIC) {
memcpy(key->pubkey, p, plen);
key->haspubkey = 1;
} else {
memcpy(key->privkey, p, plen);
key->hasprivkey = 1;
}
key->tls_name = OPENSSL_strdup(OBJ_nid2sn(nid));
if (key->tls_name == NULL)
goto err;
return key;
err:
xor_freekey(key);
return NULL;
}
static XORKEY *xor_key_from_x509pubkey(const X509_PUBKEY *xpk,
OSSL_LIB_CTX *libctx, const char *propq)
{
const unsigned char *p;
int plen;
X509_ALGOR *palg;
if (!xpk || (!X509_PUBKEY_get0_param(NULL, &p, &plen, &palg, xpk))) {
return NULL;
}
return xor_key_op(palg, p, plen, KEY_OP_PUBLIC, libctx, propq);
}
static XORKEY *xor_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf,
OSSL_LIB_CTX *libctx, const char *propq)
{
XORKEY *xork = NULL;
const unsigned char *p;
int plen;
ASN1_OCTET_STRING *oct = NULL;
const X509_ALGOR *palg;
if (!PKCS8_pkey_get0(NULL, &p, &plen, &palg, p8inf))
return 0;
oct = d2i_ASN1_OCTET_STRING(NULL, &p, plen);
if (oct == NULL) {
p = NULL;
plen = 0;
} else {
p = ASN1_STRING_get0_data(oct);
plen = ASN1_STRING_length(oct);
}
xork = xor_key_op(palg, p, plen, KEY_OP_PRIVATE,
libctx, propq);
ASN1_OCTET_STRING_free(oct);
return xork;
}
static const OSSL_ALGORITHM tls_prov_keymgmt[] = {
/*
* Obviously this is not FIPS approved, but in order to test in conjunction
* with the FIPS provider we pretend that it is.
*/
{ "XOR", "provider=tls-provider,fips=yes",
xor_keymgmt_functions },
{ XORSIGALG_NAME, "provider=tls-provider,fips=yes",
xor_xorhmacsig_keymgmt_functions },
{ XORSIGALG_HASH_NAME,
"provider=tls-provider,fips=yes",
xor_xorhmacsha2sig_keymgmt_functions },
{ NULL, NULL, NULL }
};
struct key2any_ctx_st {
PROV_XOR_CTX *provctx;
/* Set to 0 if parameters should not be saved (dsa only) */
int save_parameters;
/* Set to 1 if intending to encrypt/decrypt, otherwise 0 */
int cipher_intent;
EVP_CIPHER *cipher;
OSSL_PASSPHRASE_CALLBACK *pwcb;
void *pwcbarg;
};
typedef int check_key_type_fn(const void *key, int nid);
typedef int key_to_paramstring_fn(const void *key, int nid, int save,
void **str, int *strtype);
typedef int key_to_der_fn(BIO *out, const void *key,
int key_nid, const char *pemname,
key_to_paramstring_fn *p2s, i2d_of_void *k2d,
struct key2any_ctx_st *ctx);
typedef int write_bio_of_void_fn(BIO *bp, const void *x);
/* Free the blob allocated during key_to_paramstring_fn */
static void free_asn1_data(int type, void *data)
{
switch(type) {
case V_ASN1_OBJECT:
ASN1_OBJECT_free(data);
break;
case V_ASN1_SEQUENCE:
ASN1_STRING_free(data);
break;
}
}
static PKCS8_PRIV_KEY_INFO *key_to_p8info(const void *key, int key_nid,
void *params, int params_type,
i2d_of_void *k2d)
{
/* der, derlen store the key DER output and its length */
unsigned char *der = NULL;
int derlen;
/* The final PKCS#8 info */
PKCS8_PRIV_KEY_INFO *p8info = NULL;
if ((p8info = PKCS8_PRIV_KEY_INFO_new()) == NULL
|| (derlen = k2d(key, &der)) <= 0
|| !PKCS8_pkey_set0(p8info, OBJ_nid2obj(key_nid), 0,
V_ASN1_UNDEF, NULL,
der, derlen)) {
ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE);
PKCS8_PRIV_KEY_INFO_free(p8info);
OPENSSL_free(der);
p8info = NULL;
}
return p8info;
}
static X509_SIG *p8info_to_encp8(PKCS8_PRIV_KEY_INFO *p8info,
struct key2any_ctx_st *ctx)
{
X509_SIG *p8 = NULL;
char kstr[PEM_BUFSIZE];
size_t klen = 0;
OSSL_LIB_CTX *libctx = PROV_XOR_LIBCTX_OF(ctx->provctx);
if (ctx->cipher == NULL || ctx->pwcb == NULL)
return NULL;
if (!ctx->pwcb(kstr, PEM_BUFSIZE, &klen, NULL, ctx->pwcbarg)) {
ERR_raise(ERR_LIB_USER, PROV_R_UNABLE_TO_GET_PASSPHRASE);
return NULL;
}
/* First argument == -1 means "standard" */
p8 = PKCS8_encrypt_ex(-1, ctx->cipher, kstr, klen, NULL, 0, 0, p8info, libctx, NULL);
OPENSSL_cleanse(kstr, klen);
return p8;
}
static X509_SIG *key_to_encp8(const void *key, int key_nid,
void *params, int params_type,
i2d_of_void *k2d, struct key2any_ctx_st *ctx)
{
PKCS8_PRIV_KEY_INFO *p8info =
key_to_p8info(key, key_nid, params, params_type, k2d);
X509_SIG *p8 = NULL;
if (p8info == NULL) {
free_asn1_data(params_type, params);
} else {
p8 = p8info_to_encp8(p8info, ctx);
PKCS8_PRIV_KEY_INFO_free(p8info);
}
return p8;
}
static X509_PUBKEY *xorx_key_to_pubkey(const void *key, int key_nid,
void *params, int params_type,
i2d_of_void k2d)
{
/* der, derlen store the key DER output and its length */
unsigned char *der = NULL;
int derlen;
/* The final X509_PUBKEY */
X509_PUBKEY *xpk = NULL;
if ((xpk = X509_PUBKEY_new()) == NULL
|| (derlen = k2d(key, &der)) <= 0
|| !X509_PUBKEY_set0_param(xpk, OBJ_nid2obj(key_nid),
V_ASN1_UNDEF, NULL,
der, derlen)) {
ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE);
X509_PUBKEY_free(xpk);
OPENSSL_free(der);
xpk = NULL;
}
return xpk;
}
/*
* key_to_epki_* produce encoded output with the private key data in a
* EncryptedPrivateKeyInfo structure (defined by PKCS#8). They require
* that there's an intent to encrypt, anything else is an error.
*
* key_to_pki_* primarily produce encoded output with the private key data
* in a PrivateKeyInfo structure (also defined by PKCS#8). However, if
* there is an intent to encrypt the data, the corresponding key_to_epki_*
* function is used instead.
*
* key_to_spki_* produce encoded output with the public key data in an
* X.509 SubjectPublicKeyInfo.
*
* Key parameters don't have any defined envelopment of this kind, but are
* included in some manner in the output from the functions described above,
* either in the AlgorithmIdentifier's parameter field, or as part of the
* key data itself.
*/
static int key_to_epki_der_priv_bio(BIO *out, const void *key,
int key_nid,
ossl_unused const char *pemname,
key_to_paramstring_fn *p2s,
i2d_of_void *k2d,
struct key2any_ctx_st *ctx)
{
int ret = 0;
void *str = NULL;
int strtype = V_ASN1_UNDEF;
X509_SIG *p8;
if (!ctx->cipher_intent)
return 0;
if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters,
&str, &strtype))
return 0;
p8 = key_to_encp8(key, key_nid, str, strtype, k2d, ctx);
if (p8 != NULL)
ret = i2d_PKCS8_bio(out, p8);
X509_SIG_free(p8);
return ret;
}
static int key_to_epki_pem_priv_bio(BIO *out, const void *key,
int key_nid,
ossl_unused const char *pemname,
key_to_paramstring_fn *p2s,
i2d_of_void *k2d,
struct key2any_ctx_st *ctx)
{
int ret = 0;
void *str = NULL;
int strtype = V_ASN1_UNDEF;
X509_SIG *p8;
if (!ctx->cipher_intent)
return 0;
if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters,
&str, &strtype))
return 0;
p8 = key_to_encp8(key, key_nid, str, strtype, k2d, ctx);
if (p8 != NULL)
ret = PEM_write_bio_PKCS8(out, p8);
X509_SIG_free(p8);
return ret;
}
static int key_to_pki_der_priv_bio(BIO *out, const void *key,
int key_nid,
ossl_unused const char *pemname,
key_to_paramstring_fn *p2s,
i2d_of_void *k2d,
struct key2any_ctx_st *ctx)
{
int ret = 0;
void *str = NULL;
int strtype = V_ASN1_UNDEF;
PKCS8_PRIV_KEY_INFO *p8info;
if (ctx->cipher_intent)
return key_to_epki_der_priv_bio(out, key, key_nid, pemname,
p2s, k2d, ctx);
if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters,
&str, &strtype))
return 0;
p8info = key_to_p8info(key, key_nid, str, strtype, k2d);
if (p8info != NULL)
ret = i2d_PKCS8_PRIV_KEY_INFO_bio(out, p8info);
else
free_asn1_data(strtype, str);
PKCS8_PRIV_KEY_INFO_free(p8info);
return ret;
}
static int key_to_pki_pem_priv_bio(BIO *out, const void *key,
int key_nid,
ossl_unused const char *pemname,
key_to_paramstring_fn *p2s,
i2d_of_void *k2d,
struct key2any_ctx_st *ctx)
{
int ret = 0;
void *str = NULL;
int strtype = V_ASN1_UNDEF;
PKCS8_PRIV_KEY_INFO *p8info;
if (ctx->cipher_intent)
return key_to_epki_pem_priv_bio(out, key, key_nid, pemname,
p2s, k2d, ctx);
if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters,
&str, &strtype))
return 0;
p8info = key_to_p8info(key, key_nid, str, strtype, k2d);
if (p8info != NULL)
ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(out, p8info);
else
free_asn1_data(strtype, str);
PKCS8_PRIV_KEY_INFO_free(p8info);
return ret;
}
static int key_to_spki_der_pub_bio(BIO *out, const void *key,
int key_nid,
ossl_unused const char *pemname,
key_to_paramstring_fn *p2s,
i2d_of_void *k2d,
struct key2any_ctx_st *ctx)
{
int ret = 0;
X509_PUBKEY *xpk = NULL;
void *str = NULL;
int strtype = V_ASN1_UNDEF;
if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters,
&str, &strtype))
return 0;
xpk = xorx_key_to_pubkey(key, key_nid, str, strtype, k2d);
if (xpk != NULL)
ret = i2d_X509_PUBKEY_bio(out, xpk);
X509_PUBKEY_free(xpk);
return ret;
}
static int key_to_spki_pem_pub_bio(BIO *out, const void *key,
int key_nid,
ossl_unused const char *pemname,
key_to_paramstring_fn *p2s,
i2d_of_void *k2d,
struct key2any_ctx_st *ctx)
{
int ret = 0;
X509_PUBKEY *xpk = NULL;
void *str = NULL;
int strtype = V_ASN1_UNDEF;
if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters,
&str, &strtype))
return 0;
xpk = xorx_key_to_pubkey(key, key_nid, str, strtype, k2d);
if (xpk != NULL)
ret = PEM_write_bio_X509_PUBKEY(out, xpk);
else
free_asn1_data(strtype, str);
/* Also frees |str| */
X509_PUBKEY_free(xpk);
return ret;
}
/* ---------------------------------------------------------------------- */
static int prepare_xorx_params(const void *xorxkey, int nid, int save,
void **pstr, int *pstrtype)
{
ASN1_OBJECT *params = NULL;
XORKEY *k = (XORKEY*)xorxkey;
if (k->tls_name && OBJ_sn2nid(k->tls_name) != nid) {
ERR_raise(ERR_LIB_USER, XORPROV_R_INVALID_KEY);
return 0;
}
if (nid == NID_undef) {
ERR_raise(ERR_LIB_USER, XORPROV_R_MISSING_OID);
return 0;
}
params = OBJ_nid2obj(nid);
if (params == NULL || OBJ_length(params) == 0) {
/* unexpected error */
ERR_raise(ERR_LIB_USER, XORPROV_R_MISSING_OID);
ASN1_OBJECT_free(params);
return 0;
}
*pstr = params;
*pstrtype = V_ASN1_OBJECT;
return 1;
}
static int xorx_spki_pub_to_der(const void *vecxkey, unsigned char **pder)
{
const XORKEY *xorxkey = vecxkey;
unsigned char *keyblob;
int retlen;
if (xorxkey == NULL) {
ERR_raise(ERR_LIB_USER, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
keyblob = OPENSSL_memdup(xorxkey->pubkey, retlen = XOR_KEY_SIZE);
if (keyblob == NULL) {
ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE);
return 0;
}
*pder = keyblob;
return retlen;
}
static int xorx_pki_priv_to_der(const void *vecxkey, unsigned char **pder)
{
XORKEY *xorxkey = (XORKEY *)vecxkey;
unsigned char* buf = NULL;
ASN1_OCTET_STRING oct;
int keybloblen;
if (xorxkey == NULL) {
ERR_raise(ERR_LIB_USER, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
buf = OPENSSL_secure_malloc(XOR_KEY_SIZE);
memcpy(buf, xorxkey->privkey, XOR_KEY_SIZE);
oct.data = buf;
oct.length = XOR_KEY_SIZE;
oct.flags = 0;
keybloblen = i2d_ASN1_OCTET_STRING(&oct, pder);
if (keybloblen < 0) {
ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE);
keybloblen = 0;
}
OPENSSL_secure_clear_free(buf, XOR_KEY_SIZE);
return keybloblen;
}
# define xorx_epki_priv_to_der xorx_pki_priv_to_der
/*
* XORX only has PKCS#8 / SubjectPublicKeyInfo
* representation, so we don't define xorx_type_specific_[priv,pub,params]_to_der.
*/
# define xorx_check_key_type NULL
# define xorhmacsig_evp_type 0
# define xorhmacsig_input_type XORSIGALG_NAME
# define xorhmacsig_pem_type XORSIGALG_NAME
# define xorhmacsha2sig_evp_type 0
# define xorhmacsha2sig_input_type XORSIGALG_HASH_NAME
# define xorhmacsha2sig_pem_type XORSIGALG_HASH_NAME
/* ---------------------------------------------------------------------- */
static OSSL_FUNC_decoder_newctx_fn key2any_newctx;
static OSSL_FUNC_decoder_freectx_fn key2any_freectx;
static void *key2any_newctx(void *provctx)
{
struct key2any_ctx_st *ctx = OPENSSL_zalloc(sizeof(*ctx));
if (ctx != NULL) {
ctx->provctx = provctx;
ctx->save_parameters = 1;
}
return ctx;
}
static void key2any_freectx(void *vctx)
{
struct key2any_ctx_st *ctx = vctx;
EVP_CIPHER_free(ctx->cipher);
OPENSSL_free(ctx);
}
static const OSSL_PARAM *key2any_settable_ctx_params(ossl_unused void *provctx)
{
static const OSSL_PARAM settables[] = {
OSSL_PARAM_utf8_string(OSSL_ENCODER_PARAM_CIPHER, NULL, 0),
OSSL_PARAM_utf8_string(OSSL_ENCODER_PARAM_PROPERTIES, NULL, 0),
OSSL_PARAM_END,
};
return settables;
}
static int key2any_set_ctx_params(void *vctx, const OSSL_PARAM params[])
{
struct key2any_ctx_st *ctx = vctx;
OSSL_LIB_CTX *libctx = PROV_XOR_LIBCTX_OF(ctx->provctx);
const OSSL_PARAM *cipherp =
OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_CIPHER);
const OSSL_PARAM *propsp =
OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_PROPERTIES);
const OSSL_PARAM *save_paramsp =
OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_SAVE_PARAMETERS);
if (cipherp != NULL) {
const char *ciphername = NULL;
const char *props = NULL;
if (!OSSL_PARAM_get_utf8_string_ptr(cipherp, &ciphername))
return 0;
if (propsp != NULL && !OSSL_PARAM_get_utf8_string_ptr(propsp, &props))
return 0;
EVP_CIPHER_free(ctx->cipher);
ctx->cipher = NULL;
ctx->cipher_intent = ciphername != NULL;
if (ciphername != NULL
&& ((ctx->cipher =
EVP_CIPHER_fetch(libctx, ciphername, props)) == NULL)) {
return 0;
}
}
if (save_paramsp != NULL) {
if (!OSSL_PARAM_get_int(save_paramsp, &ctx->save_parameters)) {
return 0;
}
}
return 1;
}
static int key2any_check_selection(int selection, int selection_mask)
{
/*
* The selections are kinda sorta "levels", i.e. each selection given
* here is assumed to include those following.
*/
int checks[] = {
OSSL_KEYMGMT_SELECT_PRIVATE_KEY,
OSSL_KEYMGMT_SELECT_PUBLIC_KEY,
OSSL_KEYMGMT_SELECT_ALL_PARAMETERS
};
size_t i;
/* The decoder implementations made here support guessing */
if (selection == 0)
return 1;
for (i = 0; i < OSSL_NELEM(checks); i++) {
int check1 = (selection & checks[i]) != 0;
int check2 = (selection_mask & checks[i]) != 0;
/*
* If the caller asked for the currently checked bit(s), return
* whether the decoder description says it's supported.
*/
if (check1)
return check2;
}
/* This should be dead code, but just to be safe... */
return 0;
}
static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout,
const void *key, const char* typestr, const char *pemname,
key_to_der_fn *writer,
OSSL_PASSPHRASE_CALLBACK *pwcb, void *pwcbarg,
key_to_paramstring_fn *key2paramstring,
i2d_of_void *key2der)
{
int ret = 0;
int type = OBJ_sn2nid(typestr);
if (key == NULL || type <= 0) {
ERR_raise(ERR_LIB_USER, ERR_R_PASSED_NULL_PARAMETER);
} else if (writer != NULL) {
BIO *out = BIO_new_from_core_bio(ctx->provctx->libctx, cout);
if (out != NULL) {
ctx->pwcb = pwcb;
ctx->pwcbarg = pwcbarg;
ret = writer(out, key, type, pemname, key2paramstring, key2der, ctx);
}
BIO_free(out);
} else {
ERR_raise(ERR_LIB_USER, ERR_R_PASSED_INVALID_ARGUMENT);
}
return ret;
}
#define DO_ENC_PRIVATE_KEY_selection_mask OSSL_KEYMGMT_SELECT_PRIVATE_KEY
#define DO_ENC_PRIVATE_KEY(impl, type, kind, output) \
if ((selection & DO_ENC_PRIVATE_KEY_selection_mask) != 0) \
return key2any_encode(ctx, cout, key, impl##_pem_type, \
impl##_pem_type " PRIVATE KEY", \
key_to_##kind##_##output##_priv_bio, \
cb, cbarg, prepare_##type##_params, \
type##_##kind##_priv_to_der);
#define DO_ENC_PUBLIC_KEY_selection_mask OSSL_KEYMGMT_SELECT_PUBLIC_KEY
#define DO_ENC_PUBLIC_KEY(impl, type, kind, output) \
if ((selection & DO_ENC_PUBLIC_KEY_selection_mask) != 0) \
return key2any_encode(ctx, cout, key, impl##_pem_type, \
impl##_pem_type " PUBLIC KEY", \
key_to_##kind##_##output##_pub_bio, \
cb, cbarg, prepare_##type##_params, \
type##_##kind##_pub_to_der);
#define DO_ENC_PARAMETERS_selection_mask OSSL_KEYMGMT_SELECT_ALL_PARAMETERS
#define DO_ENC_PARAMETERS(impl, type, kind, output) \
if ((selection & DO_ENC_PARAMETERS_selection_mask) != 0) \
return key2any_encode(ctx, cout, key, impl##_pem_type, \
impl##_pem_type " PARAMETERS", \
key_to_##kind##_##output##_param_bio, \
NULL, NULL, NULL, \
type##_##kind##_params_to_der);
/*-
* Implement the kinds of output structure that can be produced. They are
* referred to by name, and for each name, the following macros are defined
* (braces not included):
*
* DO_{kind}_selection_mask
*
* A mask of selection bits that must not be zero. This is used as a
* selection criterion for each implementation.
* This mask must never be zero.
*
* DO_{kind}
*
* The performing macro. It must use the DO_ macros defined above,
* always in this order:
*
* - DO_PRIVATE_KEY
* - DO_PUBLIC_KEY
* - DO_PARAMETERS
*
* Any of those may be omitted, but the relative order must still be
* the same.
*/
/*
* PKCS#8 defines two structures for private keys only:
* - PrivateKeyInfo (raw unencrypted form)
* - EncryptedPrivateKeyInfo (encrypted wrapping)
*
* To allow a certain amount of flexibility, we allow the routines
* for PrivateKeyInfo to also produce EncryptedPrivateKeyInfo if a
* passphrase callback has been passed to them.
*/
#define DO_ENC_PrivateKeyInfo_selection_mask DO_ENC_PRIVATE_KEY_selection_mask
#define DO_ENC_PrivateKeyInfo(impl, type, output) \
DO_ENC_PRIVATE_KEY(impl, type, pki, output)
#define DO_ENC_EncryptedPrivateKeyInfo_selection_mask DO_ENC_PRIVATE_KEY_selection_mask
#define DO_ENC_EncryptedPrivateKeyInfo(impl, type, output) \
DO_ENC_PRIVATE_KEY(impl, type, epki, output)
/* SubjectPublicKeyInfo is a structure for public keys only */
#define DO_ENC_SubjectPublicKeyInfo_selection_mask DO_ENC_PUBLIC_KEY_selection_mask
#define DO_ENC_SubjectPublicKeyInfo(impl, type, output) \
DO_ENC_PUBLIC_KEY(impl, type, spki, output)
/*
* MAKE_ENCODER is the single driver for creating OSSL_DISPATCH tables.
* It takes the following arguments:
*
* impl This is the key type name that's being implemented.
* type This is the type name for the set of functions that implement
* the key type. For example, ed25519, ed448, x25519 and x448
* are all implemented with the exact same set of functions.
* kind What kind of support to implement. These translate into
* the DO_##kind macros above.
* output The output type to implement. may be der or pem.
*
* The resulting OSSL_DISPATCH array gets the following name (expressed in
* C preprocessor terms) from those arguments:
*
* xor_##impl##_to_##kind##_##output##_encoder_functions
*/
#define MAKE_ENCODER(impl, type, kind, output) \
static OSSL_FUNC_encoder_import_object_fn \
impl##_to_##kind##_##output##_import_object; \
static OSSL_FUNC_encoder_free_object_fn \
impl##_to_##kind##_##output##_free_object; \
static OSSL_FUNC_encoder_encode_fn \
impl##_to_##kind##_##output##_encode; \
\
static void * \
impl##_to_##kind##_##output##_import_object(void *vctx, int selection, \
const OSSL_PARAM params[]) \
{ \
struct key2any_ctx_st *ctx = vctx; \
\
return xor_prov_import_key(xor_##impl##_keymgmt_functions, \
ctx->provctx, selection, params); \
} \
static void impl##_to_##kind##_##output##_free_object(void *key) \
{ \
xor_prov_free_key(xor_##impl##_keymgmt_functions, key); \
} \
static int impl##_to_##kind##_##output##_does_selection(void *ctx, \
int selection) \
{ \
return key2any_check_selection(selection, \
DO_ENC_##kind##_selection_mask); \
} \
static int \
impl##_to_##kind##_##output##_encode(void *ctx, OSSL_CORE_BIO *cout, \
const void *key, \
const OSSL_PARAM key_abstract[], \
int selection, \
OSSL_PASSPHRASE_CALLBACK *cb, \
void *cbarg) \
{ \
/* We don't deal with abstract objects */ \
if (key_abstract != NULL) { \
ERR_raise(ERR_LIB_USER, ERR_R_PASSED_INVALID_ARGUMENT); \
return 0; \
} \
DO_ENC_##kind(impl, type, output) \
\
ERR_raise(ERR_LIB_USER, ERR_R_PASSED_INVALID_ARGUMENT); \
return 0; \
} \
static const OSSL_DISPATCH \
xor_##impl##_to_##kind##_##output##_encoder_functions[] = { \
{ OSSL_FUNC_ENCODER_NEWCTX, \
(void (*)(void))key2any_newctx }, \
{ OSSL_FUNC_ENCODER_FREECTX, \
(void (*)(void))key2any_freectx }, \
{ OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS, \
(void (*)(void))key2any_settable_ctx_params }, \
{ OSSL_FUNC_ENCODER_SET_CTX_PARAMS, \
(void (*)(void))key2any_set_ctx_params }, \
{ OSSL_FUNC_ENCODER_DOES_SELECTION, \
(void (*)(void))impl##_to_##kind##_##output##_does_selection }, \
{ OSSL_FUNC_ENCODER_IMPORT_OBJECT, \
(void (*)(void))impl##_to_##kind##_##output##_import_object }, \
{ OSSL_FUNC_ENCODER_FREE_OBJECT, \
(void (*)(void))impl##_to_##kind##_##output##_free_object }, \
{ OSSL_FUNC_ENCODER_ENCODE, \
(void (*)(void))impl##_to_##kind##_##output##_encode }, \
OSSL_DISPATCH_END \
}
/*
* Replacements for i2d_{TYPE}PrivateKey, i2d_{TYPE}PublicKey,
* i2d_{TYPE}params, as they exist.
*/
/*
* PKCS#8 and SubjectPublicKeyInfo support. This may duplicate some of the
* implementations specified above, but are more specific.
* The SubjectPublicKeyInfo implementations also replace the
* PEM_write_bio_{TYPE}_PUBKEY functions.
* For PEM, these are expected to be used by PEM_write_bio_PrivateKey(),
* PEM_write_bio_PUBKEY() and PEM_write_bio_Parameters().
*/
MAKE_ENCODER(xorhmacsig, xorx, EncryptedPrivateKeyInfo, der);
MAKE_ENCODER(xorhmacsig, xorx, EncryptedPrivateKeyInfo, pem);
MAKE_ENCODER(xorhmacsig, xorx, PrivateKeyInfo, der);
MAKE_ENCODER(xorhmacsig, xorx, PrivateKeyInfo, pem);
MAKE_ENCODER(xorhmacsig, xorx, SubjectPublicKeyInfo, der);
MAKE_ENCODER(xorhmacsig, xorx, SubjectPublicKeyInfo, pem);
MAKE_ENCODER(xorhmacsha2sig, xorx, EncryptedPrivateKeyInfo, der);
MAKE_ENCODER(xorhmacsha2sig, xorx, EncryptedPrivateKeyInfo, pem);
MAKE_ENCODER(xorhmacsha2sig, xorx, PrivateKeyInfo, der);
MAKE_ENCODER(xorhmacsha2sig, xorx, PrivateKeyInfo, pem);
MAKE_ENCODER(xorhmacsha2sig, xorx, SubjectPublicKeyInfo, der);
MAKE_ENCODER(xorhmacsha2sig, xorx, SubjectPublicKeyInfo, pem);
static const OSSL_ALGORITHM tls_prov_encoder[] = {
#define ENCODER_PROVIDER "tls-provider"
#ifndef ENCODER_PROVIDER
# error Macro ENCODER_PROVIDER undefined
#endif
#define ENCODER_STRUCTURE_PKCS8 "pkcs8"
#define ENCODER_STRUCTURE_SubjectPublicKeyInfo "SubjectPublicKeyInfo"
#define ENCODER_STRUCTURE_PrivateKeyInfo "PrivateKeyInfo"
#define ENCODER_STRUCTURE_EncryptedPrivateKeyInfo "EncryptedPrivateKeyInfo"
#define ENCODER_STRUCTURE_PKCS1 "pkcs1"
#define ENCODER_STRUCTURE_PKCS3 "pkcs3"
/* Arguments are prefixed with '_' to avoid build breaks on certain platforms */
/*
* Obviously this is not FIPS approved, but in order to test in conjunction
* with the FIPS provider we pretend that it is.
*/
#define ENCODER_TEXT(_name, _sym) \
{ _name, \
"provider=" ENCODER_PROVIDER ",fips=yes,output=text", \
(xor_##_sym##_to_text_encoder_functions) }
#define ENCODER(_name, _sym, _fips, _output) \
{ _name, \
"provider=" ENCODER_PROVIDER ",fips=yes,output=" #_output, \
(xor_##_sym##_to_##_output##_encoder_functions) }
#define ENCODER_w_structure(_name, _sym, _output, _structure) \
{ _name, \
"provider=" ENCODER_PROVIDER ",fips=yes,output=" #_output \
",structure=" ENCODER_STRUCTURE_##_structure, \
(xor_##_sym##_to_##_structure##_##_output##_encoder_functions) }
/*
* Entries for human text "encoders"
*/
/*
* Entries for PKCS#8 and SubjectPublicKeyInfo.
* The "der" ones are added convenience for any user that wants to use
* OSSL_ENCODER directly.
* The "pem" ones also support PEM_write_bio_PrivateKey() and
* PEM_write_bio_PUBKEY().
*/
ENCODER_w_structure(XORSIGALG_NAME, xorhmacsig, der, PrivateKeyInfo),
ENCODER_w_structure(XORSIGALG_NAME, xorhmacsig, pem, PrivateKeyInfo),
ENCODER_w_structure(XORSIGALG_NAME, xorhmacsig, der, EncryptedPrivateKeyInfo),
ENCODER_w_structure(XORSIGALG_NAME, xorhmacsig, pem, EncryptedPrivateKeyInfo),
ENCODER_w_structure(XORSIGALG_NAME, xorhmacsig, der, SubjectPublicKeyInfo),
ENCODER_w_structure(XORSIGALG_NAME, xorhmacsig, pem, SubjectPublicKeyInfo),
ENCODER_w_structure(XORSIGALG_HASH_NAME, xorhmacsha2sig,
der, PrivateKeyInfo),
ENCODER_w_structure(XORSIGALG_HASH_NAME, xorhmacsha2sig,
pem, PrivateKeyInfo),
ENCODER_w_structure(XORSIGALG_HASH_NAME, xorhmacsha2sig,
der, EncryptedPrivateKeyInfo),
ENCODER_w_structure(XORSIGALG_HASH_NAME, xorhmacsha2sig,
pem, EncryptedPrivateKeyInfo),
ENCODER_w_structure(XORSIGALG_HASH_NAME, xorhmacsha2sig,
der, SubjectPublicKeyInfo),
ENCODER_w_structure(XORSIGALG_HASH_NAME, xorhmacsha2sig,
pem, SubjectPublicKeyInfo),
#undef ENCODER_PROVIDER
{ NULL, NULL, NULL }
};
struct der2key_ctx_st; /* Forward declaration */
typedef int check_key_fn(void *, struct der2key_ctx_st *ctx);
typedef void adjust_key_fn(void *, struct der2key_ctx_st *ctx);
typedef void free_key_fn(void *);
typedef void *d2i_PKCS8_fn(void **, const unsigned char **, long,
struct der2key_ctx_st *);
struct keytype_desc_st {
const char *keytype_name;
const OSSL_DISPATCH *fns; /* Keymgmt (to pilfer functions from) */
/* The input structure name */
const char *structure_name;
/*
* The EVP_PKEY_xxx type macro. Should be zero for type specific
* structures, non-zero when the outermost structure is PKCS#8 or
* SubjectPublicKeyInfo. This determines which of the function
* pointers below will be used.
*/
int evp_type;
/* The selection mask for OSSL_FUNC_decoder_does_selection() */
int selection_mask;
/* For type specific decoders, we use the corresponding d2i */
d2i_of_void *d2i_private_key; /* From type-specific DER */
d2i_of_void *d2i_public_key; /* From type-specific DER */
d2i_of_void *d2i_key_params; /* From type-specific DER */
d2i_PKCS8_fn *d2i_PKCS8; /* Wrapped in a PrivateKeyInfo */
d2i_of_void *d2i_PUBKEY; /* Wrapped in a SubjectPublicKeyInfo */
/*
* For any key, we may need to check that the key meets expectations.
* This is useful when the same functions can decode several variants
* of a key.
*/
check_key_fn *check_key;
/*
* For any key, we may need to make provider specific adjustments, such
* as ensure the key carries the correct library context.
*/
adjust_key_fn *adjust_key;
/* {type}_free() */
free_key_fn *free_key;
};
/*
* Start blatant code steal. Alternative: Open up d2i_X509_PUBKEY_INTERNAL
* as per https://github.com/openssl/openssl/issues/16697 (TBD)
* Code from openssl/crypto/x509/x_pubkey.c as
* ossl_d2i_X509_PUBKEY_INTERNAL is presently not public
*/
struct X509_pubkey_st {
X509_ALGOR *algor;
ASN1_BIT_STRING *public_key;
EVP_PKEY *pkey;
/* extra data for the callback, used by d2i_PUBKEY_ex */
OSSL_LIB_CTX *libctx;
char *propq;
};
ASN1_SEQUENCE(X509_PUBKEY_INTERNAL) = {
ASN1_SIMPLE(X509_PUBKEY, algor, X509_ALGOR),
ASN1_SIMPLE(X509_PUBKEY, public_key, ASN1_BIT_STRING)
} static_ASN1_SEQUENCE_END_name(X509_PUBKEY, X509_PUBKEY_INTERNAL)
static X509_PUBKEY *xorx_d2i_X509_PUBKEY_INTERNAL(const unsigned char **pp,
long len, OSSL_LIB_CTX *libctx)
{
X509_PUBKEY *xpub = OPENSSL_zalloc(sizeof(*xpub));
if (xpub == NULL)
return NULL;
return (X509_PUBKEY *)ASN1_item_d2i_ex((ASN1_VALUE **)&xpub, pp, len,
ASN1_ITEM_rptr(X509_PUBKEY_INTERNAL),
libctx, NULL);
}
/* end steal https://github.com/openssl/openssl/issues/16697 */
/*
* Context used for DER to key decoding.
*/
struct der2key_ctx_st {
PROV_XOR_CTX *provctx;
struct keytype_desc_st *desc;
/* The selection that is passed to xor_der2key_decode() */
int selection;
/* Flag used to signal that a failure is fatal */
unsigned int flag_fatal : 1;
};
static int xor_read_der(PROV_XOR_CTX *provctx, OSSL_CORE_BIO *cin,
unsigned char **data, long *len)
{
BUF_MEM *mem = NULL;
BIO *in = BIO_new_from_core_bio(provctx->libctx, cin);
int ok = (asn1_d2i_read_bio(in, &mem) >= 0);
if (ok) {
*data = (unsigned char *)mem->data;
*len = (long)mem->length;
OPENSSL_free(mem);
}
BIO_free(in);
return ok;
}
typedef void *key_from_pkcs8_t(const PKCS8_PRIV_KEY_INFO *p8inf,
OSSL_LIB_CTX *libctx, const char *propq);
static void *xor_der2key_decode_p8(const unsigned char **input_der,
long input_der_len, struct der2key_ctx_st *ctx,
key_from_pkcs8_t *key_from_pkcs8)
{
PKCS8_PRIV_KEY_INFO *p8inf = NULL;
const X509_ALGOR *alg = NULL;
void *key = NULL;
if ((p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, input_der, input_der_len)) != NULL
&& PKCS8_pkey_get0(NULL, NULL, NULL, &alg, p8inf)
&& OBJ_obj2nid(alg->algorithm) == ctx->desc->evp_type)
key = key_from_pkcs8(p8inf, PROV_XOR_LIBCTX_OF(ctx->provctx), NULL);
PKCS8_PRIV_KEY_INFO_free(p8inf);
return key;
}
static XORKEY *xor_d2i_PUBKEY(XORKEY **a,
const unsigned char **pp, long length)
{
XORKEY *key = NULL;
X509_PUBKEY *xpk;
xpk = xorx_d2i_X509_PUBKEY_INTERNAL(pp, length, NULL);
key = xor_key_from_x509pubkey(xpk, NULL, NULL);
if (key == NULL)
goto err_exit;
if (a != NULL) {
xor_freekey(*a);
*a = key;
}
err_exit:
X509_PUBKEY_free(xpk);
return key;
}
/* ---------------------------------------------------------------------- */
static OSSL_FUNC_decoder_freectx_fn der2key_freectx;
static OSSL_FUNC_decoder_decode_fn xor_der2key_decode;
static OSSL_FUNC_decoder_export_object_fn der2key_export_object;
static struct der2key_ctx_st *
der2key_newctx(void *provctx, struct keytype_desc_st *desc, const char* tls_name)
{
struct der2key_ctx_st *ctx = OPENSSL_zalloc(sizeof(*ctx));
if (ctx != NULL) {
ctx->provctx = provctx;
ctx->desc = desc;
if (desc->evp_type == 0) {
ctx->desc->evp_type = OBJ_sn2nid(tls_name);
}
}
return ctx;
}
static void der2key_freectx(void *vctx)
{
struct der2key_ctx_st *ctx = vctx;
OPENSSL_free(ctx);
}
static int der2key_check_selection(int selection,
const struct keytype_desc_st *desc)
{
/*
* The selections are kinda sorta "levels", i.e. each selection given
* here is assumed to include those following.
*/
int checks[] = {
OSSL_KEYMGMT_SELECT_PRIVATE_KEY,
OSSL_KEYMGMT_SELECT_PUBLIC_KEY,
OSSL_KEYMGMT_SELECT_ALL_PARAMETERS
};
size_t i;
/* The decoder implementations made here support guessing */
if (selection == 0)
return 1;
for (i = 0; i < OSSL_NELEM(checks); i++) {
int check1 = (selection & checks[i]) != 0;
int check2 = (desc->selection_mask & checks[i]) != 0;
/*
* If the caller asked for the currently checked bit(s), return
* whether the decoder description says it's supported.
*/
if (check1)
return check2;
}
/* This should be dead code, but just to be safe... */
return 0;
}
static int xor_der2key_decode(void *vctx, OSSL_CORE_BIO *cin, int selection,
OSSL_CALLBACK *data_cb, void *data_cbarg,
OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)
{
struct der2key_ctx_st *ctx = vctx;
unsigned char *der = NULL;
const unsigned char *derp;
long der_len = 0;
void *key = NULL;
int ok = 0;
ctx->selection = selection;
/*
* The caller is allowed to specify 0 as a selection mark, to have the
* structure and key type guessed. For type-specific structures, this
* is not recommended, as some structures are very similar.
* Note that 0 isn't the same as OSSL_KEYMGMT_SELECT_ALL, as the latter
* signifies a private key structure, where everything else is assumed
* to be present as well.
*/
if (selection == 0)
selection = ctx->desc->selection_mask;
if ((selection & ctx->desc->selection_mask) == 0) {
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
return 0;
}
ok = xor_read_der(ctx->provctx, cin, &der, &der_len);
if (!ok)
goto next;
ok = 0; /* Assume that we fail */
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
derp = der;
if (ctx->desc->d2i_PKCS8 != NULL) {
key = ctx->desc->d2i_PKCS8(NULL, &derp, der_len, ctx);
if (ctx->flag_fatal)
goto end;
} else if (ctx->desc->d2i_private_key != NULL) {
key = ctx->desc->d2i_private_key(NULL, &derp, der_len);
}
if (key == NULL && ctx->selection != 0)
goto next;
}
if (key == NULL && (selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
derp = der;
if (ctx->desc->d2i_PUBKEY != NULL)
key = ctx->desc->d2i_PUBKEY(NULL, &derp, der_len);
else
key = ctx->desc->d2i_public_key(NULL, &derp, der_len);
if (key == NULL && ctx->selection != 0)
goto next;
}
if (key == NULL && (selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0) {
derp = der;
if (ctx->desc->d2i_key_params != NULL)
key = ctx->desc->d2i_key_params(NULL, &derp, der_len);
if (key == NULL && ctx->selection != 0)
goto next;
}
/*
* Last minute check to see if this was the correct type of key. This
* should never lead to a fatal error, i.e. the decoding itself was
* correct, it was just an unexpected key type. This is generally for
* classes of key types that have subtle variants, like RSA-PSS keys as
* opposed to plain RSA keys.
*/
if (key != NULL
&& ctx->desc->check_key != NULL
&& !ctx->desc->check_key(key, ctx)) {
ctx->desc->free_key(key);
key = NULL;
}
if (key != NULL && ctx->desc->adjust_key != NULL)
ctx->desc->adjust_key(key, ctx);
next:
/*
* Indicated that we successfully decoded something, or not at all.
* Ending up "empty handed" is not an error.
*/
ok = 1;
/*
* We free memory here so it's not held up during the callback, because
* we know the process is recursive and the allocated chunks of memory
* add up.
*/
OPENSSL_free(der);
der = NULL;
if (key != NULL) {
OSSL_PARAM params[4];
int object_type = OSSL_OBJECT_PKEY;
params[0] =
OSSL_PARAM_construct_int(OSSL_OBJECT_PARAM_TYPE, &object_type);
params[1] =
OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_TYPE,
(char *)ctx->desc->keytype_name,
0);
/* The address of the key becomes the octet string */
params[2] =
OSSL_PARAM_construct_octet_string(OSSL_OBJECT_PARAM_REFERENCE,
&key, sizeof(key));
params[3] = OSSL_PARAM_construct_end();
ok = data_cb(params, data_cbarg);
}
end:
ctx->desc->free_key(key);
OPENSSL_free(der);
return ok;
}
static int der2key_export_object(void *vctx,
const void *reference, size_t reference_sz,
OSSL_CALLBACK *export_cb, void *export_cbarg)
{
struct der2key_ctx_st *ctx = vctx;
OSSL_FUNC_keymgmt_export_fn *export =
xor_prov_get_keymgmt_export(ctx->desc->fns);
void *keydata;
if (reference_sz == sizeof(keydata) && export != NULL) {
/* The contents of the reference is the address to our object */
keydata = *(void **)reference;
return export(keydata, ctx->selection, export_cb, export_cbarg);
}
return 0;
}
/* ---------------------------------------------------------------------- */
static void *xorx_d2i_PKCS8(void **key, const unsigned char **der, long der_len,
struct der2key_ctx_st *ctx)
{
return xor_der2key_decode_p8(der, der_len, ctx,
(key_from_pkcs8_t *)xor_key_from_pkcs8);
}
static void xorx_key_adjust(void *key, struct der2key_ctx_st *ctx)
{
}
/* ---------------------------------------------------------------------- */
#define DO_PrivateKeyInfo(keytype) \
"PrivateKeyInfo", 0, \
( OSSL_KEYMGMT_SELECT_PRIVATE_KEY ), \
NULL, \
NULL, \
NULL, \
xorx_d2i_PKCS8, \
NULL, \
NULL, \
xorx_key_adjust, \
(free_key_fn *)xor_freekey
#define DO_SubjectPublicKeyInfo(keytype) \
"SubjectPublicKeyInfo", 0, \
( OSSL_KEYMGMT_SELECT_PUBLIC_KEY ), \
NULL, \
NULL, \
NULL, \
NULL, \
(d2i_of_void *)xor_d2i_PUBKEY, \
NULL, \
xorx_key_adjust, \
(free_key_fn *)xor_freekey
/*
* MAKE_DECODER is the single driver for creating OSSL_DISPATCH tables.
* It takes the following arguments:
*
* keytype_name The implementation key type as a string.
* keytype The implementation key type. This must correspond exactly
* to our existing keymgmt keytype names... in other words,
* there must exist an ossl_##keytype##_keymgmt_functions.
* type The type name for the set of functions that implement the
* decoder for the key type. This isn't necessarily the same
* as keytype. For example, the key types ed25519, ed448,
* x25519 and x448 are all handled by the same functions with
* the common type name ecx.
* kind The kind of support to implement. This translates into
* the DO_##kind macros above, to populate the keytype_desc_st
* structure.
*/
#define MAKE_DECODER(keytype_name, keytype, type, kind) \
static struct keytype_desc_st kind##_##keytype##_desc = \
{ keytype_name, xor_##keytype##_keymgmt_functions, \
DO_##kind(keytype) }; \
\
static OSSL_FUNC_decoder_newctx_fn kind##_der2##keytype##_newctx; \
\
static void *kind##_der2##keytype##_newctx(void *provctx) \
{ \
return der2key_newctx(provctx, &kind##_##keytype##_desc, keytype_name );\
} \
static int kind##_der2##keytype##_does_selection(void *provctx, \
int selection) \
{ \
return der2key_check_selection(selection, \
&kind##_##keytype##_desc); \
} \
static const OSSL_DISPATCH \
xor_##kind##_der_to_##keytype##_decoder_functions[] = { \
{ OSSL_FUNC_DECODER_NEWCTX, \
(void (*)(void))kind##_der2##keytype##_newctx }, \
{ OSSL_FUNC_DECODER_FREECTX, \
(void (*)(void))der2key_freectx }, \
{ OSSL_FUNC_DECODER_DOES_SELECTION, \
(void (*)(void))kind##_der2##keytype##_does_selection }, \
{ OSSL_FUNC_DECODER_DECODE, \
(void (*)(void))xor_der2key_decode }, \
{ OSSL_FUNC_DECODER_EXPORT_OBJECT, \
(void (*)(void))der2key_export_object }, \
OSSL_DISPATCH_END \
}
MAKE_DECODER(XORSIGALG_NAME, xorhmacsig, xor, PrivateKeyInfo);
MAKE_DECODER(XORSIGALG_NAME, xorhmacsig, xor, SubjectPublicKeyInfo);
MAKE_DECODER(XORSIGALG_HASH_NAME, xorhmacsha2sig, xor, PrivateKeyInfo);
MAKE_DECODER(XORSIGALG_HASH_NAME, xorhmacsha2sig, xor, SubjectPublicKeyInfo);
static const OSSL_ALGORITHM tls_prov_decoder[] = {
#define DECODER_PROVIDER "tls-provider"
#define DECODER_STRUCTURE_SubjectPublicKeyInfo "SubjectPublicKeyInfo"
#define DECODER_STRUCTURE_PrivateKeyInfo "PrivateKeyInfo"
/* Arguments are prefixed with '_' to avoid build breaks on certain platforms */
/*
* Obviously this is not FIPS approved, but in order to test in conjunction
* with the FIPS provider we pretend that it is.
*/
#define DECODER(_name, _input, _output) \
{ _name, \
"provider=" DECODER_PROVIDER ",fips=yes,input=" #_input, \
(xor_##_input##_to_##_output##_decoder_functions) }
#define DECODER_w_structure(_name, _input, _structure, _output) \
{ _name, \
"provider=" DECODER_PROVIDER ",fips=yes,input=" #_input \
",structure=" DECODER_STRUCTURE_##_structure, \
(xor_##_structure##_##_input##_to_##_output##_decoder_functions) }
DECODER_w_structure(XORSIGALG_NAME, der, PrivateKeyInfo, xorhmacsig),
DECODER_w_structure(XORSIGALG_NAME, der, SubjectPublicKeyInfo, xorhmacsig),
DECODER_w_structure(XORSIGALG_HASH_NAME, der, PrivateKeyInfo, xorhmacsha2sig),
DECODER_w_structure(XORSIGALG_HASH_NAME, der, SubjectPublicKeyInfo, xorhmacsha2sig),
#undef DECODER_PROVIDER
{ NULL, NULL, NULL }
};
#define OSSL_MAX_NAME_SIZE 50
#define OSSL_MAX_PROPQUERY_SIZE 256 /* Property query strings */
static OSSL_FUNC_signature_newctx_fn xor_sig_newctx;
static OSSL_FUNC_signature_sign_init_fn xor_sig_sign_init;
static OSSL_FUNC_signature_verify_init_fn xor_sig_verify_init;
static OSSL_FUNC_signature_sign_fn xor_sig_sign;
static OSSL_FUNC_signature_verify_fn xor_sig_verify;
static OSSL_FUNC_signature_digest_sign_init_fn xor_sig_digest_sign_init;
static OSSL_FUNC_signature_digest_sign_update_fn xor_sig_digest_signverify_update;
static OSSL_FUNC_signature_digest_sign_final_fn xor_sig_digest_sign_final;
static OSSL_FUNC_signature_digest_verify_init_fn xor_sig_digest_verify_init;
static OSSL_FUNC_signature_digest_verify_update_fn xor_sig_digest_signverify_update;
static OSSL_FUNC_signature_digest_verify_final_fn xor_sig_digest_verify_final;
static OSSL_FUNC_signature_freectx_fn xor_sig_freectx;
static OSSL_FUNC_signature_dupctx_fn xor_sig_dupctx;
static OSSL_FUNC_signature_get_ctx_params_fn xor_sig_get_ctx_params;
static OSSL_FUNC_signature_gettable_ctx_params_fn xor_sig_gettable_ctx_params;
static OSSL_FUNC_signature_set_ctx_params_fn xor_sig_set_ctx_params;
static OSSL_FUNC_signature_settable_ctx_params_fn xor_sig_settable_ctx_params;
static OSSL_FUNC_signature_get_ctx_md_params_fn xor_sig_get_ctx_md_params;
static OSSL_FUNC_signature_gettable_ctx_md_params_fn xor_sig_gettable_ctx_md_params;
static OSSL_FUNC_signature_set_ctx_md_params_fn xor_sig_set_ctx_md_params;
static OSSL_FUNC_signature_settable_ctx_md_params_fn xor_sig_settable_ctx_md_params;
static int xor_get_aid(unsigned char** oidbuf, const char *tls_name) {
X509_ALGOR *algor = X509_ALGOR_new();
int aidlen = 0;
X509_ALGOR_set0(algor, OBJ_txt2obj(tls_name, 0), V_ASN1_UNDEF, NULL);
aidlen = i2d_X509_ALGOR(algor, oidbuf);
X509_ALGOR_free(algor);
return(aidlen);
}
/*
* What's passed as an actual key is defined by the KEYMGMT interface.
*/
typedef struct {
OSSL_LIB_CTX *libctx;
char *propq;
XORKEY *sig;
/*
* Flag to determine if the hash function can be changed (1) or not (0)
* Because it's dangerous to change during a DigestSign or DigestVerify
* operation, this flag is cleared by their Init function, and set again
* by their Final function.
*/
unsigned int flag_allow_md : 1;
char mdname[OSSL_MAX_NAME_SIZE];
/* The Algorithm Identifier of the combined signature algorithm */
unsigned char *aid;
size_t aid_len;
/* main digest */
EVP_MD *md;
EVP_MD_CTX *mdctx;
int operation;
} PROV_XORSIG_CTX;
static void *xor_sig_newctx(void *provctx, const char *propq)
{
PROV_XORSIG_CTX *pxor_sigctx;
pxor_sigctx = OPENSSL_zalloc(sizeof(PROV_XORSIG_CTX));
if (pxor_sigctx == NULL)
return NULL;
pxor_sigctx->libctx = ((PROV_XOR_CTX*)provctx)->libctx;
pxor_sigctx->flag_allow_md = 0;
if (propq != NULL && (pxor_sigctx->propq = OPENSSL_strdup(propq)) == NULL) {
OPENSSL_free(pxor_sigctx);
pxor_sigctx = NULL;
ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE);
}
return pxor_sigctx;
}
static int xor_sig_setup_md(PROV_XORSIG_CTX *ctx,
const char *mdname, const char *mdprops)
{
EVP_MD *md;
if (mdprops == NULL)
mdprops = ctx->propq;
md = EVP_MD_fetch(ctx->libctx, mdname, mdprops);
if ((md == NULL) || (EVP_MD_nid(md)==NID_undef)) {
if (md == NULL)
ERR_raise_data(ERR_LIB_USER, XORPROV_R_INVALID_DIGEST,
"%s could not be fetched", mdname);
EVP_MD_free(md);
return 0;
}
EVP_MD_CTX_free(ctx->mdctx);
ctx->mdctx = NULL;
EVP_MD_free(ctx->md);
ctx->md = NULL;
OPENSSL_free(ctx->aid);
ctx->aid = NULL;
ctx->aid_len = xor_get_aid(&(ctx->aid), ctx->sig->tls_name);
ctx->mdctx = NULL;
ctx->md = md;
OPENSSL_strlcpy(ctx->mdname, mdname, sizeof(ctx->mdname));
return 1;
}
static int xor_sig_signverify_init(void *vpxor_sigctx, void *vxorsig,
int operation)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
if (pxor_sigctx == NULL || vxorsig == NULL)
return 0;
xor_freekey(pxor_sigctx->sig);
if (!xor_key_up_ref(vxorsig))
return 0;
pxor_sigctx->sig = vxorsig;
pxor_sigctx->operation = operation;
if ((operation==EVP_PKEY_OP_SIGN && pxor_sigctx->sig == NULL)
|| (operation==EVP_PKEY_OP_VERIFY && pxor_sigctx->sig == NULL)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_INVALID_KEY);
return 0;
}
return 1;
}
static int xor_sig_sign_init(void *vpxor_sigctx, void *vxorsig,
const OSSL_PARAM params[])
{
return xor_sig_signverify_init(vpxor_sigctx, vxorsig, EVP_PKEY_OP_SIGN);
}
static int xor_sig_verify_init(void *vpxor_sigctx, void *vxorsig,
const OSSL_PARAM params[])
{
return xor_sig_signverify_init(vpxor_sigctx, vxorsig, EVP_PKEY_OP_VERIFY);
}
static int xor_sig_sign(void *vpxor_sigctx, unsigned char *sig, size_t *siglen,
size_t sigsize, const unsigned char *tbs, size_t tbslen)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
XORKEY *xorkey = pxor_sigctx->sig;
size_t max_sig_len = EVP_MAX_MD_SIZE;
size_t xor_sig_len = 0;
int rv = 0;
if (xorkey == NULL || !xorkey->hasprivkey) {
ERR_raise(ERR_LIB_USER, XORPROV_R_NO_PRIVATE_KEY);
return rv;
}
if (sig == NULL) {
*siglen = max_sig_len;
return 1;
}
if (*siglen < max_sig_len) {
ERR_raise(ERR_LIB_USER, XORPROV_R_BUFFER_LENGTH_WRONG);
return rv;
}
/*
* create HMAC using XORKEY as key and hash as data:
* No real crypto, just for test, don't do this at home!
*/
if (!EVP_Q_mac(pxor_sigctx->libctx, "HMAC", NULL, "sha1", NULL,
xorkey->privkey, XOR_KEY_SIZE, tbs, tbslen,
&sig[0], EVP_MAX_MD_SIZE, &xor_sig_len)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_SIGNING_FAILED);
goto endsign;
}
*siglen = xor_sig_len;
rv = 1; /* success */
endsign:
return rv;
}
static int xor_sig_verify(void *vpxor_sigctx,
const unsigned char *sig, size_t siglen,
const unsigned char *tbs, size_t tbslen)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
XORKEY *xorkey = pxor_sigctx->sig;
unsigned char resignature[EVP_MAX_MD_SIZE];
size_t resiglen;
int i;
if (xorkey == NULL || sig == NULL || tbs == NULL) {
ERR_raise(ERR_LIB_USER, XORPROV_R_WRONG_PARAMETERS);
return 0;
}
/*
* This is no real verify: just re-sign and compare:
* Don't do this at home! Not fit for real use!
*/
/* First re-create private key from public key: */
for (i = 0; i < XOR_KEY_SIZE; i++)
xorkey->privkey[i] = xorkey->pubkey[i] ^ private_constant[i];
/* Now re-create signature */
if (!EVP_Q_mac(pxor_sigctx->libctx, "HMAC", NULL, "sha1", NULL,
xorkey->privkey, XOR_KEY_SIZE, tbs, tbslen,
&resignature[0], EVP_MAX_MD_SIZE, &resiglen)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_VERIFY_ERROR);
return 0;
}
/* Now compare with signature passed */
if (siglen != resiglen || memcmp(resignature, sig, siglen) != 0) {
ERR_raise(ERR_LIB_USER, XORPROV_R_VERIFY_ERROR);
return 0;
}
return 1;
}
static int xor_sig_digest_signverify_init(void *vpxor_sigctx, const char *mdname,
void *vxorsig, int operation)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
char *rmdname = (char *)mdname;
if (rmdname == NULL)
rmdname = "sha256";
pxor_sigctx->flag_allow_md = 0;
if (!xor_sig_signverify_init(vpxor_sigctx, vxorsig, operation))
return 0;
if (!xor_sig_setup_md(pxor_sigctx, rmdname, NULL))
return 0;
pxor_sigctx->mdctx = EVP_MD_CTX_new();
if (pxor_sigctx->mdctx == NULL)
goto error;
if (!EVP_DigestInit_ex(pxor_sigctx->mdctx, pxor_sigctx->md, NULL))
goto error;
return 1;
error:
EVP_MD_CTX_free(pxor_sigctx->mdctx);
EVP_MD_free(pxor_sigctx->md);
pxor_sigctx->mdctx = NULL;
pxor_sigctx->md = NULL;
return 0;
}
static int xor_sig_digest_sign_init(void *vpxor_sigctx, const char *mdname,
void *vxorsig, const OSSL_PARAM params[])
{
return xor_sig_digest_signverify_init(vpxor_sigctx, mdname, vxorsig,
EVP_PKEY_OP_SIGN);
}
static int xor_sig_digest_verify_init(void *vpxor_sigctx, const char *mdname, void *vxorsig, const OSSL_PARAM params[])
{
return xor_sig_digest_signverify_init(vpxor_sigctx, mdname,
vxorsig, EVP_PKEY_OP_VERIFY);
}
int xor_sig_digest_signverify_update(void *vpxor_sigctx,
const unsigned char *data,
size_t datalen)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
if (pxor_sigctx == NULL || pxor_sigctx->mdctx == NULL)
return 0;
return EVP_DigestUpdate(pxor_sigctx->mdctx, data, datalen);
}
int xor_sig_digest_sign_final(void *vpxor_sigctx,
unsigned char *sig, size_t *siglen,
size_t sigsize)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
unsigned char digest[EVP_MAX_MD_SIZE];
unsigned int dlen = 0;
if (sig != NULL) {
if (pxor_sigctx == NULL || pxor_sigctx->mdctx == NULL)
return 0;
if (!EVP_DigestFinal_ex(pxor_sigctx->mdctx, digest, &dlen))
return 0;
pxor_sigctx->flag_allow_md = 1;
}
return xor_sig_sign(vpxor_sigctx, sig, siglen, sigsize, digest, (size_t)dlen);
}
int xor_sig_digest_verify_final(void *vpxor_sigctx, const unsigned char *sig,
size_t siglen)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
unsigned char digest[EVP_MAX_MD_SIZE];
unsigned int dlen = 0;
if (pxor_sigctx == NULL || pxor_sigctx->mdctx == NULL)
return 0;
if (!EVP_DigestFinal_ex(pxor_sigctx->mdctx, digest, &dlen))
return 0;
pxor_sigctx->flag_allow_md = 1;
return xor_sig_verify(vpxor_sigctx, sig, siglen, digest, (size_t)dlen);
}
static void xor_sig_freectx(void *vpxor_sigctx)
{
PROV_XORSIG_CTX *ctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
OPENSSL_free(ctx->propq);
EVP_MD_CTX_free(ctx->mdctx);
EVP_MD_free(ctx->md);
ctx->propq = NULL;
ctx->mdctx = NULL;
ctx->md = NULL;
xor_freekey(ctx->sig);
ctx->sig = NULL;
OPENSSL_free(ctx->aid);
OPENSSL_free(ctx);
}
static void *xor_sig_dupctx(void *vpxor_sigctx)
{
PROV_XORSIG_CTX *srcctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
PROV_XORSIG_CTX *dstctx;
dstctx = OPENSSL_zalloc(sizeof(*srcctx));
if (dstctx == NULL)
return NULL;
*dstctx = *srcctx;
dstctx->sig = NULL;
dstctx->md = NULL;
dstctx->mdctx = NULL;
dstctx->aid = NULL;
if ((srcctx->sig != NULL) && !xor_key_up_ref(srcctx->sig))
goto err;
dstctx->sig = srcctx->sig;
if (srcctx->md != NULL && !EVP_MD_up_ref(srcctx->md))
goto err;
dstctx->md = srcctx->md;
if (srcctx->mdctx != NULL) {
dstctx->mdctx = EVP_MD_CTX_new();
if (dstctx->mdctx == NULL
|| !EVP_MD_CTX_copy_ex(dstctx->mdctx, srcctx->mdctx))
goto err;
}
return dstctx;
err:
xor_sig_freectx(dstctx);
return NULL;
}
static int xor_sig_get_ctx_params(void *vpxor_sigctx, OSSL_PARAM *params)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
OSSL_PARAM *p;
if (pxor_sigctx == NULL || params == NULL)
return 0;
p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID);
if (pxor_sigctx->aid == NULL)
pxor_sigctx->aid_len = xor_get_aid(&(pxor_sigctx->aid), pxor_sigctx->sig->tls_name);
if (p != NULL
&& !OSSL_PARAM_set_octet_string(p, pxor_sigctx->aid, pxor_sigctx->aid_len))
return 0;
p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST);
if (p != NULL && !OSSL_PARAM_set_utf8_string(p, pxor_sigctx->mdname))
return 0;
return 1;
}
static const OSSL_PARAM known_gettable_ctx_params[] = {
OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0),
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
OSSL_PARAM_END
};
static const OSSL_PARAM *xor_sig_gettable_ctx_params(ossl_unused void *vpxor_sigctx, ossl_unused void *vctx)
{
return known_gettable_ctx_params;
}
static int xor_sig_set_ctx_params(void *vpxor_sigctx, const OSSL_PARAM params[])
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
const OSSL_PARAM *p;
if (pxor_sigctx == NULL || params == NULL)
return 0;
p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_DIGEST);
/* Not allowed during certain operations */
if (p != NULL && !pxor_sigctx->flag_allow_md)
return 0;
if (p != NULL) {
char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname;
char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops;
const OSSL_PARAM *propsp =
OSSL_PARAM_locate_const(params,
OSSL_SIGNATURE_PARAM_PROPERTIES);
if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname)))
return 0;
if (propsp != NULL
&& !OSSL_PARAM_get_utf8_string(propsp, &pmdprops, sizeof(mdprops)))
return 0;
if (!xor_sig_setup_md(pxor_sigctx, mdname, mdprops))
return 0;
}
return 1;
}
static const OSSL_PARAM known_settable_ctx_params[] = {
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PROPERTIES, NULL, 0),
OSSL_PARAM_END
};
static const OSSL_PARAM *xor_sig_settable_ctx_params(ossl_unused void *vpsm2ctx,
ossl_unused void *provctx)
{
return known_settable_ctx_params;
}
static int xor_sig_get_ctx_md_params(void *vpxor_sigctx, OSSL_PARAM *params)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
if (pxor_sigctx->mdctx == NULL)
return 0;
return EVP_MD_CTX_get_params(pxor_sigctx->mdctx, params);
}
static const OSSL_PARAM *xor_sig_gettable_ctx_md_params(void *vpxor_sigctx)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
if (pxor_sigctx->md == NULL)
return 0;
return EVP_MD_gettable_ctx_params(pxor_sigctx->md);
}
static int xor_sig_set_ctx_md_params(void *vpxor_sigctx, const OSSL_PARAM params[])
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
if (pxor_sigctx->mdctx == NULL)
return 0;
return EVP_MD_CTX_set_params(pxor_sigctx->mdctx, params);
}
static const OSSL_PARAM *xor_sig_settable_ctx_md_params(void *vpxor_sigctx)
{
PROV_XORSIG_CTX *pxor_sigctx = (PROV_XORSIG_CTX *)vpxor_sigctx;
if (pxor_sigctx->md == NULL)
return 0;
return EVP_MD_settable_ctx_params(pxor_sigctx->md);
}
static const OSSL_DISPATCH xor_signature_functions[] = {
{ OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))xor_sig_newctx },
{ OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))xor_sig_sign_init },
{ OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))xor_sig_sign },
{ OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))xor_sig_verify_init },
{ OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))xor_sig_verify },
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT,
(void (*)(void))xor_sig_digest_sign_init },
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE,
(void (*)(void))xor_sig_digest_signverify_update },
{ OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL,
(void (*)(void))xor_sig_digest_sign_final },
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT,
(void (*)(void))xor_sig_digest_verify_init },
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE,
(void (*)(void))xor_sig_digest_signverify_update },
{ OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL,
(void (*)(void))xor_sig_digest_verify_final },
{ OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))xor_sig_freectx },
{ OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))xor_sig_dupctx },
{ OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, (void (*)(void))xor_sig_get_ctx_params },
{ OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
(void (*)(void))xor_sig_gettable_ctx_params },
{ OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, (void (*)(void))xor_sig_set_ctx_params },
{ OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS,
(void (*)(void))xor_sig_settable_ctx_params },
{ OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS,
(void (*)(void))xor_sig_get_ctx_md_params },
{ OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS,
(void (*)(void))xor_sig_gettable_ctx_md_params },
{ OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS,
(void (*)(void))xor_sig_set_ctx_md_params },
{ OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS,
(void (*)(void))xor_sig_settable_ctx_md_params },
OSSL_DISPATCH_END
};
static const OSSL_ALGORITHM tls_prov_signature[] = {
/*
* Obviously this is not FIPS approved, but in order to test in conjunction
* with the FIPS provider we pretend that it is.
*/
{ XORSIGALG_NAME, "provider=tls-provider,fips=yes",
xor_signature_functions },
{ XORSIGALG_HASH_NAME, "provider=tls-provider,fips=yes",
xor_signature_functions },
{ XORSIGALG12_NAME, "provider=tls-provider,fips=yes",
xor_signature_functions },
{ NULL, NULL, NULL }
};
static const OSSL_ALGORITHM *tls_prov_query(void *provctx, int operation_id,
int *no_cache)
{
*no_cache = 0;
switch (operation_id) {
case OSSL_OP_KEYMGMT:
return tls_prov_keymgmt;
case OSSL_OP_KEYEXCH:
return tls_prov_keyexch;
case OSSL_OP_KEM:
return tls_prov_kem;
case OSSL_OP_ENCODER:
return tls_prov_encoder;
case OSSL_OP_DECODER:
return tls_prov_decoder;
case OSSL_OP_SIGNATURE:
return tls_prov_signature;
}
return NULL;
}
static void tls_prov_teardown(void *provctx)
{
int i;
PROV_XOR_CTX *pctx = (PROV_XOR_CTX*)provctx;
OSSL_LIB_CTX_free(pctx->libctx);
for (i = 0; i < NUM_DUMMY_GROUPS; i++) {
OPENSSL_free(dummy_group_names[i]);
dummy_group_names[i] = NULL;
}
OPENSSL_free(pctx);
}
/* Functions we provide to the core */
static const OSSL_DISPATCH tls_prov_dispatch_table[] = {
{ OSSL_FUNC_PROVIDER_TEARDOWN, (void (*)(void))tls_prov_teardown },
{ OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))tls_prov_query },
{ OSSL_FUNC_PROVIDER_GET_CAPABILITIES, (void (*)(void))tls_prov_get_capabilities },
OSSL_DISPATCH_END
};
static
unsigned int randomize_tls_alg_id(OSSL_LIB_CTX *libctx)
{
/*
* Randomise the id we're going to use to ensure we don't interoperate
* with anything but ourselves.
*/
unsigned int id;
static unsigned int mem[10] = { 0 };
static int in_mem = 0;
int i;
retry:
if (RAND_bytes_ex(libctx, (unsigned char *)&id, sizeof(id), 0) <= 0)
return 0;
/*
* Ensure id is within the IANA Reserved for private use range
* (65024-65279)
*/
id %= 65279 - 65024;
id += 65024;
/* Ensure we did not already issue this id */
for (i = 0; i < in_mem; i++)
if (mem[i] == id)
goto retry;
/* Add this id to the list of ids issued by this function */
mem[in_mem++] = id;
return id;
}
int tls_provider_init(const OSSL_CORE_HANDLE *handle,
const OSSL_DISPATCH *in,
const OSSL_DISPATCH **out,
void **provctx)
{
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new_from_dispatch(handle, in);
OSSL_FUNC_core_obj_create_fn *c_obj_create= NULL;
OSSL_FUNC_core_obj_add_sigid_fn *c_obj_add_sigid= NULL;
PROV_XOR_CTX *prov_ctx = xor_newprovctx(libctx);
if (libctx == NULL || prov_ctx == NULL)
return 0;
*provctx = prov_ctx;
/*
* Randomise the group_id and code_points we're going to use to ensure we
* don't interoperate with anything but ourselves.
*/
xor_group.group_id = randomize_tls_alg_id(libctx);
xor_kemgroup.group_id = randomize_tls_alg_id(libctx);
xor_sigalg.code_point = randomize_tls_alg_id(libctx);
xor_sigalg_hash.code_point = randomize_tls_alg_id(libctx);
/* Retrieve registration functions */
for (; in->function_id != 0; in++) {
switch (in->function_id) {
case OSSL_FUNC_CORE_OBJ_CREATE:
c_obj_create = OSSL_FUNC_core_obj_create(in);
break;
case OSSL_FUNC_CORE_OBJ_ADD_SIGID:
c_obj_add_sigid = OSSL_FUNC_core_obj_add_sigid(in);
break;
/* Just ignore anything we don't understand */
default:
break;
}
}
/*
* Register algorithms manually as add_provider_sigalgs is
* only called during session establishment -- too late for
* key & cert generation...
*/
if (!c_obj_create(handle, XORSIGALG_OID, XORSIGALG_NAME, XORSIGALG_NAME)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_OBJ_CREATE_ERR);
return 0;
}
if (!c_obj_add_sigid(handle, XORSIGALG_OID, "", XORSIGALG_OID)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_OBJ_CREATE_ERR);
return 0;
}
if (!c_obj_create(handle, XORSIGALG_HASH_OID, XORSIGALG_HASH_NAME, NULL)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_OBJ_CREATE_ERR);
return 0;
}
if (!c_obj_add_sigid(handle, XORSIGALG_HASH_OID, XORSIGALG_HASH, XORSIGALG_HASH_OID)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_OBJ_CREATE_ERR);
return 0;
}
*out = tls_prov_dispatch_table;
return 1;
}
|
./openssl/test/enginetest.c | /*
* Copyright 2000-2022 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
*/
/* We need to use some deprecated APIs */
#define OPENSSL_SUPPRESS_DEPRECATED
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <openssl/e_os2.h>
# include "testutil.h"
#ifndef OPENSSL_NO_ENGINE
# include <openssl/buffer.h>
# include <openssl/crypto.h>
# include <openssl/engine.h>
# include <openssl/rsa.h>
# include <openssl/err.h>
# include <openssl/x509.h>
# include <openssl/pem.h>
static void display_engine_list(void)
{
ENGINE *h;
int loop;
loop = 0;
for (h = ENGINE_get_first(); h != NULL; h = ENGINE_get_next(h)) {
TEST_info("#%d: id = \"%s\", name = \"%s\"",
loop++, ENGINE_get_id(h), ENGINE_get_name(h));
}
/*
* ENGINE_get_first() increases the struct_ref counter, so we must call
* ENGINE_free() to decrease it again
*/
ENGINE_free(h);
}
#define NUMTOADD 512
static int test_engines(void)
{
ENGINE *block[NUMTOADD];
char *eid[NUMTOADD];
char *ename[NUMTOADD];
char buf[256];
ENGINE *ptr;
int loop;
int to_return = 0;
ENGINE *new_h1 = NULL;
ENGINE *new_h2 = NULL;
ENGINE *new_h3 = NULL;
ENGINE *new_h4 = NULL;
memset(block, 0, sizeof(block));
if (!TEST_ptr(new_h1 = ENGINE_new())
|| !TEST_true(ENGINE_set_id(new_h1, "test_id0"))
|| !TEST_true(ENGINE_set_name(new_h1, "First test item"))
|| !TEST_ptr(new_h2 = ENGINE_new())
|| !TEST_true(ENGINE_set_id(new_h2, "test_id1"))
|| !TEST_true(ENGINE_set_name(new_h2, "Second test item"))
|| !TEST_ptr(new_h3 = ENGINE_new())
|| !TEST_true(ENGINE_set_id(new_h3, "test_id2"))
|| !TEST_true(ENGINE_set_name(new_h3, "Third test item"))
|| !TEST_ptr(new_h4 = ENGINE_new())
|| !TEST_true(ENGINE_set_id(new_h4, "test_id3"))
|| !TEST_true(ENGINE_set_name(new_h4, "Fourth test item")))
goto end;
TEST_info("Engines:");
display_engine_list();
if (!TEST_true(ENGINE_add(new_h1)))
goto end;
TEST_info("Engines:");
display_engine_list();
ptr = ENGINE_get_first();
if (!TEST_true(ENGINE_remove(ptr)))
goto end;
ENGINE_free(ptr);
TEST_info("Engines:");
display_engine_list();
if (!TEST_true(ENGINE_add(new_h3))
|| !TEST_true(ENGINE_add(new_h2)))
goto end;
TEST_info("Engines:");
display_engine_list();
if (!TEST_true(ENGINE_remove(new_h2)))
goto end;
TEST_info("Engines:");
display_engine_list();
if (!TEST_true(ENGINE_add(new_h4)))
goto end;
TEST_info("Engines:");
display_engine_list();
/* Should fail. */
if (!TEST_false(ENGINE_add(new_h3)))
goto end;
ERR_clear_error();
/* Should fail. */
if (!TEST_false(ENGINE_remove(new_h2)))
goto end;
ERR_clear_error();
if (!TEST_true(ENGINE_remove(new_h3)))
goto end;
TEST_info("Engines:");
display_engine_list();
if (!TEST_true(ENGINE_remove(new_h4)))
goto end;
TEST_info("Engines:");
display_engine_list();
/*
* At this point, we should have an empty list, unless some hardware
* support engine got added. However, since we don't allow the config
* file to be loaded and don't otherwise load any built in engines,
* that is unlikely. Still, we check, if for nothing else, then to
* notify that something is a little off (and might mean that |new_h1|
* wasn't unloaded when it should have)
*/
if ((ptr = ENGINE_get_first()) != NULL) {
if (!ENGINE_remove(ptr))
TEST_info("Remove failed - probably no hardware support present");
}
ENGINE_free(ptr);
TEST_info("Engines:");
display_engine_list();
if (!TEST_true(ENGINE_add(new_h1))
|| !TEST_true(ENGINE_remove(new_h1)))
goto end;
TEST_info("About to beef up the engine-type list");
for (loop = 0; loop < NUMTOADD; loop++) {
sprintf(buf, "id%d", loop);
eid[loop] = OPENSSL_strdup(buf);
sprintf(buf, "Fake engine type %d", loop);
ename[loop] = OPENSSL_strdup(buf);
if (!TEST_ptr(block[loop] = ENGINE_new())
|| !TEST_true(ENGINE_set_id(block[loop], eid[loop]))
|| !TEST_true(ENGINE_set_name(block[loop], ename[loop])))
goto end;
}
for (loop = 0; loop < NUMTOADD; loop++) {
if (!TEST_true(ENGINE_add(block[loop]))) {
test_note("Adding stopped at %d, (%s,%s)",
loop, ENGINE_get_id(block[loop]),
ENGINE_get_name(block[loop]));
goto cleanup_loop;
}
}
cleanup_loop:
TEST_info("About to empty the engine-type list");
while ((ptr = ENGINE_get_first()) != NULL) {
if (!TEST_true(ENGINE_remove(ptr)))
goto end;
ENGINE_free(ptr);
}
for (loop = 0; loop < NUMTOADD; loop++) {
OPENSSL_free(eid[loop]);
OPENSSL_free(ename[loop]);
}
to_return = 1;
end:
ENGINE_free(new_h1);
ENGINE_free(new_h2);
ENGINE_free(new_h3);
ENGINE_free(new_h4);
for (loop = 0; loop < NUMTOADD; loop++)
ENGINE_free(block[loop]);
return to_return;
}
/* Test EVP_PKEY method */
static EVP_PKEY_METHOD *test_rsa = NULL;
static int called_encrypt = 0;
/* Test function to check operation has been redirected */
static int test_encrypt(EVP_PKEY_CTX *ctx, unsigned char *sig,
size_t *siglen, const unsigned char *tbs, size_t tbslen)
{
called_encrypt = 1;
return 1;
}
static int test_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth,
const int **pnids, int nid)
{
static const int rnid = EVP_PKEY_RSA;
if (pmeth == NULL) {
*pnids = &rnid;
return 1;
}
if (nid == EVP_PKEY_RSA) {
*pmeth = test_rsa;
return 1;
}
*pmeth = NULL;
return 0;
}
/* Return a test EVP_PKEY value */
static EVP_PKEY *get_test_pkey(void)
{
static unsigned char n[] =
"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"
"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"
"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"
"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"
"\xF5";
static unsigned char e[] = "\x11";
RSA *rsa = RSA_new();
EVP_PKEY *pk = EVP_PKEY_new();
if (rsa == NULL || pk == NULL || !EVP_PKEY_assign_RSA(pk, rsa)) {
RSA_free(rsa);
EVP_PKEY_free(pk);
return NULL;
}
if (!RSA_set0_key(rsa, BN_bin2bn(n, sizeof(n)-1, NULL),
BN_bin2bn(e, sizeof(e)-1, NULL), NULL)) {
EVP_PKEY_free(pk);
return NULL;
}
return pk;
}
static int test_redirect(void)
{
const unsigned char pt[] = "Hello World\n";
unsigned char *tmp = NULL;
size_t len;
EVP_PKEY_CTX *ctx = NULL;
ENGINE *e = NULL;
EVP_PKEY *pkey = NULL;
int to_return = 0;
if (!TEST_ptr(pkey = get_test_pkey()))
goto err;
len = EVP_PKEY_get_size(pkey);
if (!TEST_ptr(tmp = OPENSSL_malloc(len)))
goto err;
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new(pkey, NULL)))
goto err;
TEST_info("EVP_PKEY_encrypt test: no redirection");
/* Encrypt some data: should succeed but not be redirected */
if (!TEST_int_gt(EVP_PKEY_encrypt_init(ctx), 0)
|| !TEST_int_gt(EVP_PKEY_encrypt(ctx, tmp, &len, pt, sizeof(pt)), 0)
|| !TEST_false(called_encrypt))
goto err;
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
/* Create a test ENGINE */
if (!TEST_ptr(e = ENGINE_new())
|| !TEST_true(ENGINE_set_id(e, "Test redirect engine"))
|| !TEST_true(ENGINE_set_name(e, "Test redirect engine")))
goto err;
/*
* Try to create a context for this engine and test key.
* Try setting test key engine. Both should fail because the
* engine has no public key methods.
*/
if (!TEST_ptr_null(ctx = EVP_PKEY_CTX_new(pkey, e))
|| !TEST_int_le(EVP_PKEY_set1_engine(pkey, e), 0))
goto err;
/* Setup an empty test EVP_PKEY_METHOD and set callback to return it */
if (!TEST_ptr(test_rsa = EVP_PKEY_meth_new(EVP_PKEY_RSA, 0)))
goto err;
ENGINE_set_pkey_meths(e, test_pkey_meths);
/* Getting a context for test ENGINE should now succeed */
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new(pkey, e)))
goto err;
/* Encrypt should fail because operation is not supported */
if (!TEST_int_le(EVP_PKEY_encrypt_init(ctx), 0))
goto err;
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
/* Add test encrypt operation to method */
EVP_PKEY_meth_set_encrypt(test_rsa, 0, test_encrypt);
TEST_info("EVP_PKEY_encrypt test: redirection via EVP_PKEY_CTX_new()");
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new(pkey, e)))
goto err;
/* Encrypt some data: should succeed and be redirected */
if (!TEST_int_gt(EVP_PKEY_encrypt_init(ctx), 0)
|| !TEST_int_gt(EVP_PKEY_encrypt(ctx, tmp, &len, pt, sizeof(pt)), 0)
|| !TEST_true(called_encrypt))
goto err;
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
called_encrypt = 0;
/* Create context with default engine: should not be redirected */
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new(pkey, NULL))
|| !TEST_int_gt(EVP_PKEY_encrypt_init(ctx), 0)
|| !TEST_int_gt(EVP_PKEY_encrypt(ctx, tmp, &len, pt, sizeof(pt)), 0)
|| !TEST_false(called_encrypt))
goto err;
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
/* Set engine explicitly for test key */
if (!TEST_true(EVP_PKEY_set1_engine(pkey, e)))
goto err;
TEST_info("EVP_PKEY_encrypt test: redirection via EVP_PKEY_set1_engine()");
/* Create context with default engine: should be redirected now */
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new(pkey, NULL))
|| !TEST_int_gt(EVP_PKEY_encrypt_init(ctx), 0)
|| !TEST_int_gt(EVP_PKEY_encrypt(ctx, tmp, &len, pt, sizeof(pt)), 0)
|| !TEST_true(called_encrypt))
goto err;
to_return = 1;
err:
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(pkey);
ENGINE_free(e);
OPENSSL_free(tmp);
return to_return;
}
static int test_x509_dup_w_engine(void)
{
ENGINE *e = NULL;
X509 *cert = NULL, *dupcert = NULL;
X509_PUBKEY *pubkey, *duppubkey = NULL;
int ret = 0;
BIO *b = NULL;
RSA_METHOD *rsameth = NULL;
if (!TEST_ptr(b = BIO_new_file(test_get_argument(0), "r"))
|| !TEST_ptr(cert = PEM_read_bio_X509(b, NULL, NULL, NULL)))
goto err;
/* Dup without an engine */
if (!TEST_ptr(dupcert = X509_dup(cert)))
goto err;
X509_free(dupcert);
dupcert = NULL;
if (!TEST_ptr(pubkey = X509_get_X509_PUBKEY(cert))
|| !TEST_ptr(duppubkey = X509_PUBKEY_dup(pubkey))
|| !TEST_ptr_ne(duppubkey, pubkey)
|| !TEST_ptr_ne(X509_PUBKEY_get0(duppubkey), X509_PUBKEY_get0(pubkey)))
goto err;
X509_PUBKEY_free(duppubkey);
duppubkey = NULL;
X509_free(cert);
cert = NULL;
/* Create a test ENGINE */
if (!TEST_ptr(e = ENGINE_new())
|| !TEST_true(ENGINE_set_id(e, "Test dummy engine"))
|| !TEST_true(ENGINE_set_name(e, "Test dummy engine")))
goto err;
if (!TEST_ptr(rsameth = RSA_meth_dup(RSA_get_default_method())))
goto err;
ENGINE_set_RSA(e, rsameth);
if (!TEST_true(ENGINE_set_default_RSA(e)))
goto err;
if (!TEST_int_ge(BIO_seek(b, 0), 0)
|| !TEST_ptr(cert = PEM_read_bio_X509(b, NULL, NULL, NULL)))
goto err;
/* Dup with an engine set on the key */
if (!TEST_ptr(dupcert = X509_dup(cert)))
goto err;
if (!TEST_ptr(pubkey = X509_get_X509_PUBKEY(cert))
|| !TEST_ptr(duppubkey = X509_PUBKEY_dup(pubkey))
|| !TEST_ptr_ne(duppubkey, pubkey)
|| !TEST_ptr_ne(X509_PUBKEY_get0(duppubkey), X509_PUBKEY_get0(pubkey)))
goto err;
ret = 1;
err:
X509_free(cert);
X509_free(dupcert);
X509_PUBKEY_free(duppubkey);
if (e != NULL) {
ENGINE_unregister_RSA(e);
ENGINE_free(e);
}
RSA_meth_free(rsameth);
BIO_free(b);
return ret;
}
#endif
int global_init(void)
{
/*
* If the config file gets loaded, the dynamic engine will be loaded,
* and that interferes with our test above.
*/
return OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL);
}
OPT_TEST_DECLARE_USAGE("certfile\n")
int setup_tests(void)
{
#ifdef OPENSSL_NO_ENGINE
TEST_note("No ENGINE support");
#else
int n;
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
n = test_get_argument_count();
if (n == 0)
return 0;
ADD_TEST(test_engines);
ADD_TEST(test_redirect);
ADD_TEST(test_x509_dup_w_engine);
#endif
return 1;
}
|
./openssl/test/localetest.c | /*
* Copyright 2022 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 "internal/e_os.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <openssl/x509.h>
#include "testutil.h"
#include "testutil/output.h"
#ifndef OPENSSL_NO_LOCALE
# include <locale.h>
# ifdef OPENSSL_SYS_MACOSX
# include <xlocale.h>
# endif
int setup_tests(void)
{
const unsigned char der_bytes[] = {
0x30, 0x82, 0x03, 0x09, 0x30, 0x82, 0x01, 0xf1, 0xa0, 0x03, 0x02, 0x01,
0x02, 0x02, 0x14, 0x08, 0xe0, 0x8c, 0xd3, 0xf3, 0xbf, 0x2c, 0xf2, 0x0d,
0x0a, 0x75, 0xd1, 0xe8, 0xea, 0xbe, 0x70, 0x61, 0xd9, 0x67, 0xf9, 0x30,
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b,
0x05, 0x00, 0x30, 0x14, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04,
0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74,
0x30, 0x1e, 0x17, 0x0d, 0x32, 0x32, 0x30, 0x34, 0x31, 0x31, 0x31, 0x34,
0x31, 0x39, 0x35, 0x37, 0x5a, 0x17, 0x0d, 0x32, 0x32, 0x30, 0x35, 0x31,
0x31, 0x31, 0x34, 0x31, 0x39, 0x35, 0x37, 0x5a, 0x30, 0x14, 0x31, 0x12,
0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63,
0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d,
0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82,
0x01, 0x01, 0x00, 0xc3, 0x1f, 0x5c, 0x56, 0x46, 0x8d, 0x69, 0xb6, 0x48,
0x3c, 0xbf, 0xe2, 0x0f, 0xa7, 0x4a, 0x44, 0x72, 0x74, 0x36, 0xfe, 0xe8,
0x2f, 0x10, 0x4a, 0xe9, 0x46, 0x45, 0x72, 0x5e, 0x48, 0xdd, 0x75, 0xab,
0xd9, 0x63, 0x91, 0x37, 0x93, 0x46, 0x28, 0x7e, 0x45, 0x94, 0x4b, 0x8a,
0xd5, 0x05, 0x2b, 0x9a, 0x01, 0x96, 0x30, 0xde, 0xcc, 0x14, 0x2d, 0x06,
0x09, 0x1b, 0x7d, 0x50, 0x14, 0x99, 0x36, 0x6b, 0x97, 0x6e, 0xc9, 0xb1,
0x69, 0x70, 0xcd, 0x9b, 0x74, 0x24, 0x9a, 0xe2, 0xd4, 0xc0, 0x1e, 0xbc,
0xec, 0xf6, 0x7a, 0xbb, 0xa0, 0x53, 0x93, 0xf8, 0x68, 0x9a, 0x18, 0xa1,
0xa1, 0x5c, 0x47, 0x93, 0xd1, 0x4c, 0x36, 0x8c, 0x00, 0xb3, 0x66, 0xda,
0xf1, 0x05, 0xb2, 0x3a, 0xad, 0x7e, 0x4b, 0xf3, 0xd3, 0x93, 0xfa, 0x59,
0x09, 0x9c, 0x60, 0x37, 0x69, 0x61, 0xe8, 0x5a, 0x33, 0xc6, 0xb2, 0x1a,
0xba, 0x36, 0xe2, 0xb3, 0x58, 0xe9, 0x73, 0x01, 0x2d, 0x36, 0x48, 0x36,
0x94, 0xe4, 0xb2, 0xa4, 0x5b, 0xdf, 0x3d, 0x5f, 0x62, 0x9f, 0xd9, 0xf3,
0x24, 0x0c, 0xf0, 0x2f, 0x71, 0x44, 0x79, 0x13, 0x70, 0x95, 0xa7, 0xbe,
0xea, 0x0a, 0x08, 0x0a, 0xa6, 0x4b, 0xe9, 0x58, 0x6b, 0xa4, 0xc2, 0xed,
0x74, 0x1e, 0xb0, 0x3b, 0x59, 0xd5, 0xe6, 0xdb, 0x8f, 0x58, 0x6a, 0xa3,
0x7d, 0x52, 0x40, 0xec, 0x72, 0xb7, 0xba, 0x7e, 0x30, 0x9d, 0x12, 0x57,
0xf2, 0x48, 0xae, 0x80, 0x0d, 0x0a, 0xf4, 0xfd, 0x24, 0xed, 0xd8, 0x05,
0xb2, 0x96, 0x44, 0x02, 0x3e, 0x6e, 0x25, 0xb0, 0xc4, 0x93, 0xda, 0xfe,
0x78, 0xd9, 0xbb, 0xd2, 0x71, 0x69, 0x70, 0x7f, 0xba, 0xf7, 0xb0, 0x4f,
0x14, 0xf7, 0x98, 0x71, 0x01, 0x6c, 0xec, 0x6f, 0x76, 0x03, 0x59, 0xff,
0xe2, 0xba, 0x8d, 0xd9, 0x21, 0x08, 0xb3, 0x02, 0x03, 0x01, 0x00, 0x01,
0xa3, 0x53, 0x30, 0x51, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04,
0x16, 0x04, 0x14, 0x59, 0xb8, 0x6e, 0x1a, 0x72, 0xe9, 0x27, 0x1e, 0xbf,
0x80, 0x87, 0x0f, 0xa9, 0xd0, 0x06, 0x6a, 0x11, 0x30, 0x77, 0x8e, 0x30,
0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
0x59, 0xb8, 0x6e, 0x1a, 0x72, 0xe9, 0x27, 0x1e, 0xbf, 0x80, 0x87, 0x0f,
0xa9, 0xd0, 0x06, 0x6a, 0x11, 0x30, 0x77, 0x8e, 0x30, 0x0f, 0x06, 0x03,
0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01,
0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x98, 0x76, 0x9e,
0x3c, 0xfc, 0x3f, 0x58, 0xe8, 0xf2, 0x1f, 0x2e, 0x11, 0xa2, 0x59, 0xfa,
0x27, 0xb5, 0xec, 0x9d, 0x97, 0x05, 0x06, 0x2c, 0x95, 0xa5, 0x28, 0x88,
0x86, 0xeb, 0x4e, 0x8a, 0x62, 0xe9, 0x87, 0x78, 0xd8, 0x18, 0x22, 0x4e,
0xb1, 0x8d, 0x46, 0x4a, 0x4c, 0x6e, 0x7c, 0x53, 0x62, 0x2c, 0xf2, 0x7a,
0x95, 0xa0, 0x1a, 0x30, 0x18, 0x6a, 0x31, 0x6f, 0x3f, 0x55, 0x25, 0x9f,
0x67, 0x60, 0x68, 0x99, 0x0f, 0x41, 0x09, 0xc8, 0xe2, 0x04, 0x33, 0x22,
0x1a, 0xe9, 0xf3, 0xae, 0xce, 0xb6, 0x83, 0x64, 0x78, 0x66, 0x14, 0xc9,
0x54, 0xc8, 0x34, 0x70, 0x96, 0xaf, 0x16, 0xcd, 0xb8, 0xdf, 0x81, 0x7e,
0xf0, 0xa6, 0x7d, 0xc1, 0x13, 0xb2, 0x76, 0x3a, 0xd5, 0x7e, 0x68, 0x8c,
0xd5, 0x00, 0x70, 0x82, 0x23, 0x7e, 0x5e, 0xc9, 0x31, 0x2f, 0x33, 0x54,
0xaa, 0xaf, 0xcd, 0xe9, 0x38, 0x9a, 0x23, 0x53, 0xad, 0x4e, 0x72, 0xa7,
0x6f, 0x47, 0x60, 0xc9, 0xd3, 0x06, 0x9b, 0x7a, 0x21, 0xc6, 0xe9, 0xdb,
0x3c, 0xaa, 0xc0, 0x21, 0x29, 0x5f, 0x44, 0x6a, 0x45, 0x90, 0x73, 0x5e,
0x6d, 0x78, 0x82, 0xcb, 0x42, 0xe6, 0xba, 0x67, 0xb2, 0xe6, 0xa2, 0x15,
0x04, 0xea, 0x69, 0xae, 0x3e, 0xc0, 0x0c, 0x10, 0x99, 0xec, 0xa9, 0xb0,
0x7e, 0xe8, 0x94, 0xe2, 0xf3, 0xaf, 0xf7, 0x9f, 0x65, 0xe7, 0xd7, 0xe2,
0x49, 0xfa, 0x52, 0x7d, 0xb5, 0xfd, 0xa0, 0xa5, 0xe0, 0x49, 0xa7, 0x3d,
0x94, 0x20, 0x2d, 0xec, 0x8c, 0x22, 0xa5, 0xa4, 0x43, 0xfa, 0x7e, 0xd0,
0x50, 0x21, 0xb8, 0x67, 0x18, 0x44, 0x69, 0x8f, 0xdd, 0x47, 0x41, 0xc6,
0x35, 0xe0, 0xe9, 0x2e, 0x41, 0xa9, 0x6f, 0x41, 0xee, 0xb9, 0xbd, 0x45,
0xf3, 0x88, 0xc1, 0x23, 0x35, 0x96, 0xba, 0xf8, 0xcd, 0x4b, 0x83, 0x73,
0x5f
};
char str1[] = "SubjectPublicKeyInfo", str2[] = "subjectpublickeyinfo";
int res;
X509 *cert = NULL;
X509_PUBKEY *cert_pubkey = NULL;
const unsigned char *p = der_bytes;
if (setlocale(LC_ALL, "") == NULL)
return TEST_skip("Cannot set the locale necessary for test");
res = strcasecmp(str1, str2);
TEST_note("Case-insensitive comparison via strcasecmp in current locale %s\n", res ? "failed" : "succeeded");
if (!TEST_false(OPENSSL_strcasecmp(str1, str2)))
return 0;
cert = d2i_X509(NULL, &p, sizeof(der_bytes));
if (!TEST_ptr(cert))
return 0;
cert_pubkey = X509_get_X509_PUBKEY(cert);
if (!TEST_ptr(cert_pubkey)) {
X509_free(cert);
return 0;
}
if (!TEST_ptr(X509_PUBKEY_get0(cert_pubkey))) {
X509_free(cert);
return 0;
}
X509_free(cert);
return 1;
}
#else
int setup_tests(void)
{
return TEST_skip("Locale support not available");
}
#endif /* OPENSSL_NO_LOCALE */
void cleanup_tests(void)
{
}
|
./openssl/test/decoder_propq_test.c | /*
* Copyright 2023 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 <openssl/pem.h>
#include <openssl/evp.h>
#include "testutil.h"
static OSSL_LIB_CTX *libctx = NULL;
static OSSL_PROVIDER *nullprov = NULL;
static OSSL_PROVIDER *libprov = NULL;
static const char *filename = NULL;
static pem_password_cb passcb;
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_CONFIG_FILE,
OPT_PROVIDER_NAME,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("file\n"),
{ "config", OPT_CONFIG_FILE, '<',
"The configuration file to use for the libctx" },
{ "provider", OPT_PROVIDER_NAME, 's',
"The provider to load (The default value is 'default')" },
{ OPT_HELP_STR, 1, '-', "file\tFile to decode.\n" },
{ NULL }
};
return test_options;
}
static int passcb(char *buf, int size, int rwflag, void *userdata)
{
strcpy(buf, "pass");
return strlen(buf);
}
static int test_decode_nonfipsalg(void)
{
int ret = 0;
EVP_PKEY *privkey = NULL;
BIO *bio = NULL;
/*
* Apply the "fips=true" property to all fetches for the libctx.
* We do this to test that we are using the propq override
*/
EVP_default_properties_enable_fips(libctx, 1);
if (!TEST_ptr(bio = BIO_new_file(filename, "r")))
goto err;
/*
* If NULL is passed as the propq here it uses the global property "fips=true",
* Which we expect to fail if the decode uses a non FIPS algorithm
*/
if (!TEST_ptr_null(PEM_read_bio_PrivateKey_ex(bio, &privkey, &passcb, NULL, libctx, NULL)))
goto err;
/*
* Pass if we override the libctx global prop query to optionally use fips=true
* This assumes that the libctx contains the default provider
*/
if (!TEST_ptr_null(PEM_read_bio_PrivateKey_ex(bio, &privkey, &passcb, NULL, libctx, "?fips=true")))
goto err;
ret = 1;
err:
BIO_free(bio);
EVP_PKEY_free(privkey);
return ret;
}
int setup_tests(void)
{
const char *prov_name = "default";
char *config_file = NULL;
OPTION_CHOICE o;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_PROVIDER_NAME:
prov_name = opt_arg();
break;
case OPT_CONFIG_FILE:
config_file = opt_arg();
break;
case OPT_TEST_CASES:
break;
default:
case OPT_ERR:
return 0;
}
}
filename = test_get_argument(0);
if (!test_get_libctx(&libctx, &nullprov, config_file, &libprov, prov_name))
return 0;
ADD_TEST(test_decode_nonfipsalg);
return 1;
}
void cleanup_tests(void)
{
OSSL_PROVIDER_unload(libprov);
OSSL_LIB_CTX_free(libctx);
OSSL_PROVIDER_unload(nullprov);
}
|
./openssl/test/x509_check_cert_pkey_test.c | /*
* Copyright 2017-2023 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 <string.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include "testutil.h"
/*
* c: path of a cert in PEM format
* k: path of a key in PEM format
* t: API type, "cert" for X509_ and "req" for X509_REQ_ APIs.
* e: expected, "ok" for success, "failed" for what should fail.
*/
static const char *c;
static const char *k;
static const char *t;
static const char *e;
static int test_x509_check_cert_pkey(void)
{
BIO *bio = NULL;
X509 *x509 = NULL;
X509_REQ *x509_req = NULL;
EVP_PKEY *pkey = NULL;
int ret = 0, type = 0, expected = 0, result = 0;
/*
* we check them first thus if fails we don't need to do
* those PEM parsing operations.
*/
if (strcmp(t, "cert") == 0) {
type = 1;
} else if (strcmp(t, "req") == 0) {
type = 2;
} else {
TEST_error("invalid 'type'");
goto failed;
}
if (strcmp(e, "ok") == 0) {
expected = 1;
} else if (strcmp(e, "failed") == 0) {
expected = 0;
} else {
TEST_error("invalid 'expected'");
goto failed;
}
/* process private key */
if (!TEST_ptr(bio = BIO_new_file(k, "r")))
goto failed;
if (!TEST_ptr(pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)))
goto failed;
BIO_free(bio);
/* process cert or cert request, use the same local var */
if (!TEST_ptr(bio = BIO_new_file(c, "r")))
goto failed;
switch (type) {
case 1:
x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
if (x509 == NULL) {
TEST_error("read PEM x509 failed");
goto failed;
}
result = X509_check_private_key(x509, pkey);
break;
case 2:
x509_req = PEM_read_bio_X509_REQ(bio, NULL, NULL, NULL);
if (x509_req == NULL) {
TEST_error("read PEM x509 req failed");
goto failed;
}
result = X509_REQ_check_private_key(x509_req, pkey);
break;
default:
/* should never be here */
break;
}
if (!TEST_int_eq(result, expected)) {
TEST_error("check private key: expected: %d, got: %d", expected, result);
goto failed;
}
ret = 1;
failed:
BIO_free(bio);
X509_free(x509);
X509_REQ_free(x509_req);
EVP_PKEY_free(pkey);
return ret;
}
static const char *file; /* path of a cert/CRL/key file in PEM format */
static int expected; /* expected number of certs/CRLs/keys included */
static int test_PEM_X509_INFO_read_bio(void)
{
BIO *in;
STACK_OF(X509_INFO) *sk;
X509_INFO *it;
int i, count = 0;
if (!TEST_ptr((in = BIO_new_file(file, "r"))))
return 0;
sk = PEM_X509_INFO_read_bio(in, NULL, NULL, "");
BIO_free(in);
for (i = 0; i < sk_X509_INFO_num(sk); i++) {
it = sk_X509_INFO_value(sk, i);
if (it->x509 != NULL)
count++;
if (it->crl != NULL)
count++;
if (it->x_pkey != NULL)
count++;
}
sk_X509_INFO_pop_free(sk, X509_INFO_free);
return TEST_int_eq(count, expected);
}
const OPTIONS *test_get_options(void)
{
enum { OPT_TEST_ENUM };
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("cert key type expected\n"
" or [options] file num\n"),
{ OPT_HELP_STR, 1, '-', "cert\tcertificate or CSR filename in PEM\n" },
{ OPT_HELP_STR, 1, '-', "key\tprivate key filename in PEM\n" },
{ OPT_HELP_STR, 1, '-', "type\t\tvalue must be 'cert' or 'req'\n" },
{ OPT_HELP_STR, 1, '-', "expected\tthe expected return value, either 'ok' or 'failed'\n" },
{ OPT_HELP_STR, 1, '-', "file\tPEM format file containing certs, keys, and/OR CRLs\n" },
{ OPT_HELP_STR, 1, '-', "num\texpected number of credentials to be loaded from file\n" },
{ NULL }
};
return test_options;
}
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (test_get_argument_count() == 2) {
const char *num; /* expected number of certs/CRLs/keys included */
if (!TEST_ptr(file = test_get_argument(0))
|| !TEST_ptr(num = test_get_argument(1)))
return 0;
if (!TEST_int_eq(sscanf(num, "%d", &expected), 1))
return 0;
ADD_TEST(test_PEM_X509_INFO_read_bio);
return 1;
}
if (!TEST_ptr(c = test_get_argument(0))
|| !TEST_ptr(k = test_get_argument(1))
|| !TEST_ptr(t = test_get_argument(2))
|| !TEST_ptr(e = test_get_argument(3))) {
return 0;
}
ADD_TEST(test_x509_check_cert_pkey);
return 1;
}
|
./openssl/test/bn_internal_test.c | /*
* Copyright 1995-2021 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 <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <openssl/bn.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include "internal/nelem.h"
#include "internal/numbers.h"
#include "testutil.h"
#include "bn_prime.h"
#include "crypto/bn.h"
static BN_CTX *ctx;
static int test_is_prime_enhanced(void)
{
int ret;
int status = 0;
BIGNUM *bn = NULL;
ret = TEST_ptr(bn = BN_new())
/* test passing a prime returns the correct status */
&& TEST_true(BN_set_word(bn, 11))
/* return extra parameters related to composite */
&& TEST_true(ossl_bn_miller_rabin_is_prime(bn, 10, ctx, NULL, 1,
&status))
&& TEST_int_eq(status, BN_PRIMETEST_PROBABLY_PRIME);
BN_free(bn);
return ret;
}
static int composites[] = {
9, 21, 77, 81, 265
};
static int test_is_composite_enhanced(int id)
{
int ret;
int status = 0;
BIGNUM *bn = NULL;
ret = TEST_ptr(bn = BN_new())
/* negative tests for different composite numbers */
&& TEST_true(BN_set_word(bn, composites[id]))
&& TEST_true(ossl_bn_miller_rabin_is_prime(bn, 10, ctx, NULL, 1,
&status))
&& TEST_int_ne(status, BN_PRIMETEST_PROBABLY_PRIME);
BN_free(bn);
return ret;
}
/* Test that multiplying all the small primes from 3 to 751 equals a constant.
* This test is mainly used to test that both 32 and 64 bit are correct.
*/
static int test_bn_small_factors(void)
{
int ret = 0, i;
BIGNUM *b = NULL;
if (!(TEST_ptr(b = BN_new()) && TEST_true(BN_set_word(b, 3))))
goto err;
for (i = 1; i < NUMPRIMES; i++) {
prime_t p = primes[i];
if (p > 3 && p <= 751 && !BN_mul_word(b, p))
goto err;
if (p > 751)
break;
}
ret = TEST_BN_eq(ossl_bn_get0_small_factors(), b);
err:
BN_free(b);
return ret;
}
int setup_tests(void)
{
if (!TEST_ptr(ctx = BN_CTX_new()))
return 0;
ADD_TEST(test_is_prime_enhanced);
ADD_ALL_TESTS(test_is_composite_enhanced, (int)OSSL_NELEM(composites));
ADD_TEST(test_bn_small_factors);
return 1;
}
void cleanup_tests(void)
{
BN_CTX_free(ctx);
}
|
./openssl/test/threadstest.c | /*
* Copyright 2016-2023 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
*/
/*
* The test_multi_downgrade_shared_pkey function tests the thread safety of a
* deprecated function.
*/
#ifndef OPENSSL_NO_DEPRECATED_3_0
# define OPENSSL_SUPPRESS_DEPRECATED
#endif
#if defined(_WIN32)
# include <windows.h>
#endif
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/rsa.h>
#include <openssl/aes.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/pem.h>
#include <openssl/evp.h>
#include "internal/tsan_assist.h"
#include "internal/nelem.h"
#include "testutil.h"
#include "threadstest.h"
/* Limit the maximum number of threads */
#define MAXIMUM_THREADS 10
/* Limit the maximum number of providers loaded into a library context */
#define MAXIMUM_PROVIDERS 4
static int do_fips = 0;
static char *privkey;
static char *config_file = NULL;
static int multidefault_run = 0;
static const char *default_provider[] = { "default", NULL };
static const char *fips_provider[] = { "fips", NULL };
static const char *fips_and_default_providers[] = { "default", "fips", NULL };
static CRYPTO_RWLOCK *global_lock;
#ifdef TSAN_REQUIRES_LOCKING
static CRYPTO_RWLOCK *tsan_lock;
#endif
/* Grab a globally unique integer value, return 0 on failure */
static int get_new_uid(void)
{
/*
* Start with a nice large number to avoid potential conflicts when
* we generate a new OID.
*/
static TSAN_QUALIFIER int current_uid = 1 << (sizeof(int) * 8 - 2);
#ifdef TSAN_REQUIRES_LOCKING
int r;
if (!TEST_true(CRYPTO_THREAD_write_lock(tsan_lock)))
return 0;
r = ++current_uid;
if (!TEST_true(CRYPTO_THREAD_unlock(tsan_lock)))
return 0;
return r;
#else
return tsan_counter(¤t_uid);
#endif
}
static int test_lock(void)
{
CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
int res;
res = TEST_true(CRYPTO_THREAD_read_lock(lock))
&& TEST_true(CRYPTO_THREAD_unlock(lock))
&& TEST_true(CRYPTO_THREAD_write_lock(lock))
&& TEST_true(CRYPTO_THREAD_unlock(lock));
CRYPTO_THREAD_lock_free(lock);
return res;
}
static CRYPTO_ONCE once_run = CRYPTO_ONCE_STATIC_INIT;
static unsigned once_run_count = 0;
static void once_do_run(void)
{
once_run_count++;
}
static void once_run_thread_cb(void)
{
CRYPTO_THREAD_run_once(&once_run, once_do_run);
}
static int test_once(void)
{
thread_t thread;
if (!TEST_true(run_thread(&thread, once_run_thread_cb))
|| !TEST_true(wait_for_thread(thread))
|| !CRYPTO_THREAD_run_once(&once_run, once_do_run)
|| !TEST_int_eq(once_run_count, 1))
return 0;
return 1;
}
static CRYPTO_THREAD_LOCAL thread_local_key;
static unsigned destructor_run_count = 0;
static int thread_local_thread_cb_ok = 0;
static void thread_local_destructor(void *arg)
{
unsigned *count;
if (arg == NULL)
return;
count = arg;
(*count)++;
}
static void thread_local_thread_cb(void)
{
void *ptr;
ptr = CRYPTO_THREAD_get_local(&thread_local_key);
if (!TEST_ptr_null(ptr)
|| !TEST_true(CRYPTO_THREAD_set_local(&thread_local_key,
&destructor_run_count)))
return;
ptr = CRYPTO_THREAD_get_local(&thread_local_key);
if (!TEST_ptr_eq(ptr, &destructor_run_count))
return;
thread_local_thread_cb_ok = 1;
}
static int test_thread_local(void)
{
thread_t thread;
void *ptr = NULL;
if (!TEST_true(CRYPTO_THREAD_init_local(&thread_local_key,
thread_local_destructor)))
return 0;
ptr = CRYPTO_THREAD_get_local(&thread_local_key);
if (!TEST_ptr_null(ptr)
|| !TEST_true(run_thread(&thread, thread_local_thread_cb))
|| !TEST_true(wait_for_thread(thread))
|| !TEST_int_eq(thread_local_thread_cb_ok, 1))
return 0;
#if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG)
ptr = CRYPTO_THREAD_get_local(&thread_local_key);
if (!TEST_ptr_null(ptr))
return 0;
# if !defined(OPENSSL_SYS_WINDOWS)
if (!TEST_int_eq(destructor_run_count, 1))
return 0;
# endif
#endif
if (!TEST_true(CRYPTO_THREAD_cleanup_local(&thread_local_key)))
return 0;
return 1;
}
static int test_atomic(void)
{
int val = 0, ret = 0, testresult = 0;
uint64_t val64 = 1, ret64 = 0;
CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
if (!TEST_ptr(lock))
return 0;
if (CRYPTO_atomic_add(&val, 1, &ret, NULL)) {
/* This succeeds therefore we're on a platform with lockless atomics */
if (!TEST_int_eq(val, 1) || !TEST_int_eq(val, ret))
goto err;
} else {
/* This failed therefore we're on a platform without lockless atomics */
if (!TEST_int_eq(val, 0) || !TEST_int_eq(val, ret))
goto err;
}
val = 0;
ret = 0;
if (!TEST_true(CRYPTO_atomic_add(&val, 1, &ret, lock)))
goto err;
if (!TEST_int_eq(val, 1) || !TEST_int_eq(val, ret))
goto err;
if (CRYPTO_atomic_or(&val64, 2, &ret64, NULL)) {
/* This succeeds therefore we're on a platform with lockless atomics */
if (!TEST_uint_eq((unsigned int)val64, 3)
|| !TEST_uint_eq((unsigned int)val64, (unsigned int)ret64))
goto err;
} else {
/* This failed therefore we're on a platform without lockless atomics */
if (!TEST_uint_eq((unsigned int)val64, 1)
|| !TEST_int_eq((unsigned int)ret64, 0))
goto err;
}
val64 = 1;
ret64 = 0;
if (!TEST_true(CRYPTO_atomic_or(&val64, 2, &ret64, lock)))
goto err;
if (!TEST_uint_eq((unsigned int)val64, 3)
|| !TEST_uint_eq((unsigned int)val64, (unsigned int)ret64))
goto err;
ret64 = 0;
if (CRYPTO_atomic_load(&val64, &ret64, NULL)) {
/* This succeeds therefore we're on a platform with lockless atomics */
if (!TEST_uint_eq((unsigned int)val64, 3)
|| !TEST_uint_eq((unsigned int)val64, (unsigned int)ret64))
goto err;
} else {
/* This failed therefore we're on a platform without lockless atomics */
if (!TEST_uint_eq((unsigned int)val64, 3)
|| !TEST_int_eq((unsigned int)ret64, 0))
goto err;
}
ret64 = 0;
if (!TEST_true(CRYPTO_atomic_load(&val64, &ret64, lock)))
goto err;
if (!TEST_uint_eq((unsigned int)val64, 3)
|| !TEST_uint_eq((unsigned int)val64, (unsigned int)ret64))
goto err;
testresult = 1;
err:
CRYPTO_THREAD_lock_free(lock);
return testresult;
}
static OSSL_LIB_CTX *multi_libctx = NULL;
static int multi_success;
static OSSL_PROVIDER *multi_provider[MAXIMUM_PROVIDERS + 1];
static size_t multi_num_threads;
static thread_t multi_threads[MAXIMUM_THREADS];
static void multi_intialise(void)
{
multi_success = 1;
multi_libctx = NULL;
multi_num_threads = 0;
memset(multi_threads, 0, sizeof(multi_threads));
memset(multi_provider, 0, sizeof(multi_provider));
}
static void multi_set_success(int ok)
{
if (CRYPTO_THREAD_write_lock(global_lock) == 0) {
/* not synchronized, but better than not reporting failure */
multi_success = ok;
return;
}
multi_success = ok;
CRYPTO_THREAD_unlock(global_lock);
}
static void thead_teardown_libctx(void)
{
OSSL_PROVIDER **p;
for (p = multi_provider; *p != NULL; p++)
OSSL_PROVIDER_unload(*p);
OSSL_LIB_CTX_free(multi_libctx);
multi_intialise();
}
static int thread_setup_libctx(int libctx, const char *providers[])
{
size_t n;
if (libctx && !TEST_true(test_get_libctx(&multi_libctx, NULL, config_file,
NULL, NULL)))
return 0;
if (providers != NULL)
for (n = 0; providers[n] != NULL; n++)
if (!TEST_size_t_lt(n, MAXIMUM_PROVIDERS)
|| !TEST_ptr(multi_provider[n] = OSSL_PROVIDER_load(multi_libctx,
providers[n]))) {
thead_teardown_libctx();
return 0;
}
return 1;
}
static int teardown_threads(void)
{
size_t i;
for (i = 0; i < multi_num_threads; i++)
if (!TEST_true(wait_for_thread(multi_threads[i])))
return 0;
return 1;
}
static int start_threads(size_t n, void (*thread_func)(void))
{
size_t i;
if (!TEST_size_t_le(multi_num_threads + n, MAXIMUM_THREADS))
return 0;
for (i = 0 ; i < n; i++)
if (!TEST_true(run_thread(multi_threads + multi_num_threads++, thread_func)))
return 0;
return 1;
}
/* Template multi-threaded test function */
static int thread_run_test(void (*main_func)(void),
size_t num_threads, void (*thread_func)(void),
int libctx, const char *providers[])
{
int testresult = 0;
multi_intialise();
if (!thread_setup_libctx(libctx, providers)
|| !start_threads(num_threads, thread_func))
goto err;
if (main_func != NULL)
main_func();
if (!teardown_threads()
|| !TEST_true(multi_success))
goto err;
testresult = 1;
err:
thead_teardown_libctx();
return testresult;
}
static void thread_general_worker(void)
{
EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
EVP_MD *md = EVP_MD_fetch(multi_libctx, "SHA2-256", NULL);
EVP_CIPHER_CTX *cipherctx = EVP_CIPHER_CTX_new();
EVP_CIPHER *ciph = EVP_CIPHER_fetch(multi_libctx, "AES-128-CBC", NULL);
const char *message = "Hello World";
size_t messlen = strlen(message);
/* Should be big enough for encryption output too */
unsigned char out[EVP_MAX_MD_SIZE];
const unsigned char key[AES_BLOCK_SIZE] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f
};
const unsigned char iv[AES_BLOCK_SIZE] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f
};
unsigned int mdoutl;
int ciphoutl;
EVP_PKEY *pkey = NULL;
int testresult = 0;
int i, isfips;
isfips = OSSL_PROVIDER_available(multi_libctx, "fips");
if (!TEST_ptr(mdctx)
|| !TEST_ptr(md)
|| !TEST_ptr(cipherctx)
|| !TEST_ptr(ciph))
goto err;
/* Do some work */
for (i = 0; i < 5; i++) {
if (!TEST_true(EVP_DigestInit_ex(mdctx, md, NULL))
|| !TEST_true(EVP_DigestUpdate(mdctx, message, messlen))
|| !TEST_true(EVP_DigestFinal(mdctx, out, &mdoutl)))
goto err;
}
for (i = 0; i < 5; i++) {
if (!TEST_true(EVP_EncryptInit_ex(cipherctx, ciph, NULL, key, iv))
|| !TEST_true(EVP_EncryptUpdate(cipherctx, out, &ciphoutl,
(unsigned char *)message,
messlen))
|| !TEST_true(EVP_EncryptFinal(cipherctx, out, &ciphoutl)))
goto err;
}
/*
* We want the test to run quickly - not securely.
* Therefore we use an insecure bit length where we can (512).
* In the FIPS module though we must use a longer length.
*/
pkey = EVP_PKEY_Q_keygen(multi_libctx, NULL, "RSA", isfips ? 2048 : 512);
if (!TEST_ptr(pkey))
goto err;
testresult = 1;
err:
EVP_MD_CTX_free(mdctx);
EVP_MD_free(md);
EVP_CIPHER_CTX_free(cipherctx);
EVP_CIPHER_free(ciph);
EVP_PKEY_free(pkey);
if (!testresult)
multi_set_success(0);
}
static void thread_multi_simple_fetch(void)
{
EVP_MD *md = EVP_MD_fetch(multi_libctx, "SHA2-256", NULL);
if (md != NULL)
EVP_MD_free(md);
else
multi_set_success(0);
}
static EVP_PKEY *shared_evp_pkey = NULL;
static void thread_shared_evp_pkey(void)
{
char *msg = "Hello World";
unsigned char ctbuf[256];
unsigned char ptbuf[256];
size_t ptlen, ctlen = sizeof(ctbuf);
EVP_PKEY_CTX *ctx = NULL;
int success = 0;
int i;
for (i = 0; i < 1 + do_fips; i++) {
if (i > 0)
EVP_PKEY_CTX_free(ctx);
ctx = EVP_PKEY_CTX_new_from_pkey(multi_libctx, shared_evp_pkey,
i == 0 ? "provider=default"
: "provider=fips");
if (!TEST_ptr(ctx))
goto err;
if (!TEST_int_ge(EVP_PKEY_encrypt_init(ctx), 0)
|| !TEST_int_ge(EVP_PKEY_encrypt(ctx, ctbuf, &ctlen,
(unsigned char *)msg, strlen(msg)),
0))
goto err;
EVP_PKEY_CTX_free(ctx);
ctx = EVP_PKEY_CTX_new_from_pkey(multi_libctx, shared_evp_pkey, NULL);
if (!TEST_ptr(ctx))
goto err;
ptlen = sizeof(ptbuf);
if (!TEST_int_ge(EVP_PKEY_decrypt_init(ctx), 0)
|| !TEST_int_gt(EVP_PKEY_decrypt(ctx, ptbuf, &ptlen, ctbuf, ctlen),
0)
|| !TEST_mem_eq(msg, strlen(msg), ptbuf, ptlen))
goto err;
}
success = 1;
err:
EVP_PKEY_CTX_free(ctx);
if (!success)
multi_set_success(0);
}
static void thread_provider_load_unload(void)
{
OSSL_PROVIDER *deflt = OSSL_PROVIDER_load(multi_libctx, "default");
if (!TEST_ptr(deflt)
|| !TEST_true(OSSL_PROVIDER_available(multi_libctx, "default")))
multi_set_success(0);
OSSL_PROVIDER_unload(deflt);
}
static int test_multi_general_worker_default_provider(void)
{
return thread_run_test(&thread_general_worker, 2, &thread_general_worker,
1, default_provider);
}
static int test_multi_general_worker_fips_provider(void)
{
if (!do_fips)
return TEST_skip("FIPS not supported");
return thread_run_test(&thread_general_worker, 2, &thread_general_worker,
1, fips_provider);
}
static int test_multi_fetch_worker(void)
{
return thread_run_test(&thread_multi_simple_fetch,
2, &thread_multi_simple_fetch, 1, default_provider);
}
static int test_multi_shared_pkey_common(void (*worker)(void))
{
int testresult = 0;
multi_intialise();
if (!thread_setup_libctx(1, do_fips ? fips_and_default_providers
: default_provider)
|| !TEST_ptr(shared_evp_pkey = load_pkey_pem(privkey, multi_libctx))
|| !start_threads(1, &thread_shared_evp_pkey)
|| !start_threads(1, worker))
goto err;
thread_shared_evp_pkey();
if (!teardown_threads()
|| !TEST_true(multi_success))
goto err;
testresult = 1;
err:
EVP_PKEY_free(shared_evp_pkey);
thead_teardown_libctx();
return testresult;
}
#ifndef OPENSSL_NO_DEPRECATED_3_0
static void thread_downgrade_shared_evp_pkey(void)
{
/*
* This test is only relevant for deprecated functions that perform
* downgrading
*/
if (EVP_PKEY_get0_RSA(shared_evp_pkey) == NULL)
multi_set_success(0);
}
static int test_multi_downgrade_shared_pkey(void)
{
return test_multi_shared_pkey_common(&thread_downgrade_shared_evp_pkey);
}
#endif
static int test_multi_shared_pkey(void)
{
return test_multi_shared_pkey_common(&thread_shared_evp_pkey);
}
static int test_multi_load_unload_provider(void)
{
EVP_MD *sha256 = NULL;
OSSL_PROVIDER *prov = NULL;
int testresult = 0;
multi_intialise();
if (!thread_setup_libctx(1, NULL)
|| !TEST_ptr(prov = OSSL_PROVIDER_load(multi_libctx, "default"))
|| !TEST_ptr(sha256 = EVP_MD_fetch(multi_libctx, "SHA2-256", NULL))
|| !TEST_true(OSSL_PROVIDER_unload(prov)))
goto err;
prov = NULL;
if (!start_threads(2, &thread_provider_load_unload))
goto err;
thread_provider_load_unload();
if (!teardown_threads()
|| !TEST_true(multi_success))
goto err;
testresult = 1;
err:
OSSL_PROVIDER_unload(prov);
EVP_MD_free(sha256);
thead_teardown_libctx();
return testresult;
}
static char *multi_load_provider = "legacy";
/*
* This test attempts to load several providers at the same time, and if
* run with a thread sanitizer, should crash if the core provider code
* doesn't synchronize well enough.
*/
static void test_multi_load_worker(void)
{
OSSL_PROVIDER *prov;
if (!TEST_ptr(prov = OSSL_PROVIDER_load(multi_libctx, multi_load_provider))
|| !TEST_true(OSSL_PROVIDER_unload(prov)))
multi_set_success(0);
}
static int test_multi_default(void)
{
/* Avoid running this test twice */
if (multidefault_run) {
TEST_skip("multi default test already run");
return 1;
}
multidefault_run = 1;
return thread_run_test(&thread_multi_simple_fetch,
2, &thread_multi_simple_fetch, 0, default_provider);
}
static int test_multi_load(void)
{
int res = 1;
OSSL_PROVIDER *prov;
/* The multidefault test must run prior to this test */
if (!multidefault_run) {
TEST_info("Running multi default test first");
res = test_multi_default();
}
/*
* We use the legacy provider in test_multi_load_worker because it uses a
* child libctx that might hit more codepaths that might be sensitive to
* threading issues. But in a no-legacy build that won't be loadable so
* we use the default provider instead.
*/
prov = OSSL_PROVIDER_load(NULL, "legacy");
if (prov == NULL) {
TEST_info("Cannot load legacy provider - assuming this is a no-legacy build");
multi_load_provider = "default";
}
OSSL_PROVIDER_unload(prov);
return thread_run_test(NULL, MAXIMUM_THREADS, &test_multi_load_worker, 0,
NULL) && res;
}
static void test_obj_create_one(void)
{
char tids[12], oid[40], sn[30], ln[30];
int id = get_new_uid();
BIO_snprintf(tids, sizeof(tids), "%d", id);
BIO_snprintf(oid, sizeof(oid), "1.3.6.1.4.1.16604.%s", tids);
BIO_snprintf(sn, sizeof(sn), "short-name-%s", tids);
BIO_snprintf(ln, sizeof(ln), "long-name-%s", tids);
if (!TEST_int_ne(id, 0)
|| !TEST_true(id = OBJ_create(oid, sn, ln))
|| !TEST_true(OBJ_add_sigid(id, NID_sha3_256, NID_rsa)))
multi_set_success(0);
}
static int test_obj_add(void)
{
return thread_run_test(&test_obj_create_one,
MAXIMUM_THREADS, &test_obj_create_one,
1, default_provider);
}
static void test_lib_ctx_load_config_worker(void)
{
if (!TEST_int_eq(OSSL_LIB_CTX_load_config(multi_libctx, config_file), 1))
multi_set_success(0);
}
static int test_lib_ctx_load_config(void)
{
return thread_run_test(&test_lib_ctx_load_config_worker,
MAXIMUM_THREADS, &test_lib_ctx_load_config_worker,
1, default_provider);
}
#if !defined(OPENSSL_NO_DGRAM) && !defined(OPENSSL_NO_SOCK)
static BIO *multi_bio1, *multi_bio2;
static void test_bio_dgram_pair_worker(void)
{
ossl_unused int r;
int ok = 0;
uint8_t ch = 0;
uint8_t scratch[64];
BIO_MSG msg = {0};
size_t num_processed = 0;
if (!TEST_int_eq(RAND_bytes_ex(multi_libctx, &ch, 1, 64), 1))
goto err;
msg.data = scratch;
msg.data_len = sizeof(scratch);
/*
* We do not test for failure here as recvmmsg may fail if no sendmmsg
* has been called yet. The purpose of this code is to exercise tsan.
*/
if (ch & 2)
r = BIO_sendmmsg(ch & 1 ? multi_bio2 : multi_bio1, &msg,
sizeof(BIO_MSG), 1, 0, &num_processed);
else
r = BIO_recvmmsg(ch & 1 ? multi_bio2 : multi_bio1, &msg,
sizeof(BIO_MSG), 1, 0, &num_processed);
ok = 1;
err:
if (ok == 0)
multi_set_success(0);
}
static int test_bio_dgram_pair(void)
{
int r;
BIO *bio1 = NULL, *bio2 = NULL;
r = BIO_new_bio_dgram_pair(&bio1, 0, &bio2, 0);
if (!TEST_int_eq(r, 1))
goto err;
multi_bio1 = bio1;
multi_bio2 = bio2;
r = thread_run_test(&test_bio_dgram_pair_worker,
MAXIMUM_THREADS, &test_bio_dgram_pair_worker,
1, default_provider);
err:
BIO_free(bio1);
BIO_free(bio2);
return r;
}
#endif
static const char *pemdataraw[] = {
"-----BEGIN RSA PRIVATE KEY-----\n",
"MIIBOgIBAAJBAMFcGsaxxdgiuuGmCkVImy4h99CqT7jwY3pexPGcnUFtR2Fh36Bp\n",
"oncwtkZ4cAgtvd4Qs8PkxUdp6p/DlUmObdkCAwEAAQJAUR44xX6zB3eaeyvTRzms\n",
"kHADrPCmPWnr8dxsNwiDGHzrMKLN+i/HAam+97HxIKVWNDH2ba9Mf1SA8xu9dcHZ\n",
"AQIhAOHPCLxbtQFVxlnhSyxYeb7O323c3QulPNn3bhOipElpAiEA2zZpBE8ZXVnL\n",
"74QjG4zINlDfH+EOEtjJJ3RtaYDugvECIBtsQDxXytChsRgDQ1TcXdStXPcDppie\n",
"dZhm8yhRTTBZAiAZjE/U9rsIDC0ebxIAZfn3iplWh84yGB3pgUI3J5WkoQIhAInE\n",
"HTUY5WRj5riZtkyGnbm3DvF+1eMtO2lYV+OuLcfE\n",
"-----END RSA PRIVATE KEY-----\n",
NULL
};
static void test_pem_read_one(void)
{
EVP_PKEY *key = NULL;
BIO *pem = NULL;
char *pemdata;
size_t len;
pemdata = glue_strings(pemdataraw, &len);
if (pemdata == NULL) {
multi_set_success(0);
goto err;
}
pem = BIO_new_mem_buf(pemdata, len);
if (pem == NULL) {
multi_set_success(0);
goto err;
}
key = PEM_read_bio_PrivateKey(pem, NULL, NULL, NULL);
if (key == NULL)
multi_set_success(0);
err:
EVP_PKEY_free(key);
BIO_free(pem);
OPENSSL_free(pemdata);
}
/* Test reading PEM files in multiple threads */
static int test_pem_read(void)
{
return thread_run_test(&test_pem_read_one, MAXIMUM_THREADS,
&test_pem_read_one, 1, default_provider);
}
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_FIPS, OPT_CONFIG_FILE,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "fips", OPT_FIPS, '-', "Test the FIPS provider" },
{ "config", OPT_CONFIG_FILE, '<',
"The configuration file to use for the libctx" },
{ NULL }
};
return options;
}
int setup_tests(void)
{
OPTION_CHOICE o;
char *datadir;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_FIPS:
do_fips = 1;
break;
case OPT_CONFIG_FILE:
config_file = opt_arg();
break;
case OPT_TEST_CASES:
break;
default:
return 0;
}
}
if (!TEST_ptr(datadir = test_get_argument(0)))
return 0;
privkey = test_mk_file_path(datadir, "rsakey.pem");
if (!TEST_ptr(privkey))
return 0;
if (!TEST_ptr(global_lock = CRYPTO_THREAD_lock_new()))
return 0;
#ifdef TSAN_REQUIRES_LOCKING
if (!TEST_ptr(tsan_lock = CRYPTO_THREAD_lock_new()))
return 0;
#endif
/* Keep first to validate auto creation of default library context */
ADD_TEST(test_multi_default);
ADD_TEST(test_lock);
ADD_TEST(test_once);
ADD_TEST(test_thread_local);
ADD_TEST(test_atomic);
ADD_TEST(test_multi_load);
ADD_TEST(test_multi_general_worker_default_provider);
ADD_TEST(test_multi_general_worker_fips_provider);
ADD_TEST(test_multi_fetch_worker);
ADD_TEST(test_multi_shared_pkey);
#ifndef OPENSSL_NO_DEPRECATED_3_0
ADD_TEST(test_multi_downgrade_shared_pkey);
#endif
ADD_TEST(test_multi_load_unload_provider);
ADD_TEST(test_obj_add);
ADD_TEST(test_lib_ctx_load_config);
#if !defined(OPENSSL_NO_DGRAM) && !defined(OPENSSL_NO_SOCK)
ADD_TEST(test_bio_dgram_pair);
#endif
ADD_TEST(test_pem_read);
return 1;
}
void cleanup_tests(void)
{
OPENSSL_free(privkey);
#ifdef TSAN_REQUIRES_LOCKING
CRYPTO_THREAD_lock_free(tsan_lock);
#endif
CRYPTO_THREAD_lock_free(global_lock);
}
|
./openssl/test/cmp_server_test.c | /*
* Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright Nokia 2007-2020
* Copyright Siemens AG 2015-2020
*
* 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 "helpers/cmp_testlib.h"
typedef struct test_fixture {
const char *test_case_name;
int expected;
OSSL_CMP_SRV_CTX *srv_ctx;
OSSL_CMP_MSG *req;
} CMP_SRV_TEST_FIXTURE;
static OSSL_LIB_CTX *libctx = NULL;
static OSSL_PROVIDER *default_null_provider = NULL, *provider = NULL;
static OSSL_CMP_MSG *request = NULL;
static void tear_down(CMP_SRV_TEST_FIXTURE *fixture)
{
OSSL_CMP_SRV_CTX_free(fixture->srv_ctx);
OPENSSL_free(fixture);
}
static CMP_SRV_TEST_FIXTURE *set_up(const char *const test_case_name)
{
CMP_SRV_TEST_FIXTURE *fixture;
if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture))))
return NULL;
fixture->test_case_name = test_case_name;
if (!TEST_ptr(fixture->srv_ctx = OSSL_CMP_SRV_CTX_new(libctx, NULL)))
goto err;
return fixture;
err:
tear_down(fixture);
return NULL;
}
static int dummy_errorCode = CMP_R_MULTIPLE_SAN_SOURCES; /* any reason code */
static OSSL_CMP_PKISI *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx,
const OSSL_CMP_MSG *cert_req,
int certReqId,
const OSSL_CRMF_MSG *crm,
const X509_REQ *p10cr,
X509 **certOut,
STACK_OF(X509) **chainOut,
STACK_OF(X509) **caPubs)
{
ERR_raise(ERR_LIB_CMP, dummy_errorCode);
return NULL;
}
static int execute_test_handle_request(CMP_SRV_TEST_FIXTURE *fixture)
{
OSSL_CMP_SRV_CTX *ctx = fixture->srv_ctx;
OSSL_CMP_CTX *client_ctx;
OSSL_CMP_CTX *cmp_ctx;
char *dummy_custom_ctx = "@test_dummy", *custom_ctx;
OSSL_CMP_MSG *rsp = NULL;
OSSL_CMP_ERRORMSGCONTENT *errorContent;
int res = 0;
if (!TEST_ptr(client_ctx = OSSL_CMP_CTX_new(libctx, NULL))
|| !TEST_true(OSSL_CMP_CTX_set_transfer_cb_arg(client_ctx, ctx)))
goto end;
if (!TEST_true(OSSL_CMP_SRV_CTX_init(ctx, dummy_custom_ctx,
process_cert_request, NULL, NULL,
NULL, NULL, NULL))
|| !TEST_true(OSSL_CMP_SRV_CTX_init_trans(ctx, NULL, NULL))
|| !TEST_ptr(custom_ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(ctx))
|| !TEST_int_eq(strcmp(custom_ctx, dummy_custom_ctx), 0))
goto end;
if (!TEST_true(OSSL_CMP_SRV_CTX_set_send_unprotected_errors(ctx, 0))
|| !TEST_true(OSSL_CMP_SRV_CTX_set_accept_unprotected(ctx, 0))
|| !TEST_true(OSSL_CMP_SRV_CTX_set_accept_raverified(ctx, 1))
|| !TEST_true(OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(ctx, 1)))
goto end;
if (!TEST_ptr(cmp_ctx = OSSL_CMP_SRV_CTX_get0_cmp_ctx(ctx))
|| !OSSL_CMP_CTX_set1_referenceValue(cmp_ctx,
(unsigned char *)"server", 6)
|| !OSSL_CMP_CTX_set1_secretValue(cmp_ctx,
(unsigned char *)"1234", 4))
goto end;
if (!TEST_ptr(rsp = OSSL_CMP_CTX_server_perform(client_ctx, fixture->req))
|| !TEST_int_eq(OSSL_CMP_MSG_get_bodytype(rsp),
OSSL_CMP_PKIBODY_ERROR)
|| !TEST_ptr(errorContent = rsp->body->value.error)
|| !TEST_int_eq(ASN1_INTEGER_get(errorContent->errorCode),
ERR_PACK(ERR_LIB_CMP, 0, dummy_errorCode)))
goto end;
res = 1;
end:
OSSL_CMP_MSG_free(rsp);
OSSL_CMP_CTX_free(client_ctx);
return res;
}
static int test_handle_request(void)
{
SETUP_TEST_FIXTURE(CMP_SRV_TEST_FIXTURE, set_up);
fixture->req = request;
fixture->expected = 1;
EXECUTE_TEST(execute_test_handle_request, tear_down);
return result;
}
void cleanup_tests(void)
{
OSSL_CMP_MSG_free(request);
OSSL_PROVIDER_unload(default_null_provider);
OSSL_PROVIDER_unload(provider);
OSSL_LIB_CTX_free(libctx);
return;
}
#define USAGE \
"CR_protected_PBM_1234.der module_name [module_conf_file]\n"
OPT_TEST_DECLARE_USAGE(USAGE)
int setup_tests(void)
{
const char *request_f;
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(request_f = test_get_argument(0))) {
TEST_error("usage: cmp_server_test %s", USAGE);
return 0;
}
if (!test_arg_libctx(&libctx, &default_null_provider, &provider, 1, USAGE))
return 0;
if (!TEST_ptr(request = load_pkimsg(request_f, libctx))) {
cleanup_tests();
return 0;
}
/*
* this (indirectly) calls
* OSSL_CMP_SRV_CTX_new(),
* OSSL_CMP_SRV_CTX_free(),
* OSSL_CMP_CTX_server_perform(),
* OSSL_CMP_SRV_process_request(),
* OSSL_CMP_SRV_CTX_init(),
* OSSL_CMP_SRV_CTX_get0_cmp_ctx(),
* OSSL_CMP_SRV_CTX_get0_custom_ctx(),
* OSSL_CMP_SRV_CTX_set_send_unprotected_errors(),
* OSSL_CMP_SRV_CTX_set_accept_unprotected(),
* OSSL_CMP_SRV_CTX_set_accept_raverified(), and
* OSSL_CMP_SRV_CTX_set_grant_implicit_confirm()
*/
ADD_TEST(test_handle_request);
return 1;
}
|
./openssl/test/quic_tserver_test.c | /*
* Copyright 2022-2023 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 <openssl/ssl.h>
#include <openssl/quic.h>
#include <openssl/bio.h>
#include "internal/common.h"
#include "internal/sockets.h"
#include "internal/quic_tserver.h"
#include "internal/quic_thread_assist.h"
#include "internal/quic_ssl.h"
#include "internal/time.h"
#include "testutil.h"
static const char msg1[] = "The quick brown fox jumped over the lazy dogs.";
static char msg2[1024], msg3[1024];
static OSSL_TIME fake_time;
static CRYPTO_RWLOCK *fake_time_lock;
static const char *certfile, *keyfile;
static int is_want(SSL *s, int ret)
{
int ec = SSL_get_error(s, ret);
return ec == SSL_ERROR_WANT_READ || ec == SSL_ERROR_WANT_WRITE;
}
static unsigned char scratch_buf[2048];
static OSSL_TIME fake_now(void *arg)
{
OSSL_TIME t;
if (!CRYPTO_THREAD_read_lock(fake_time_lock))
return ossl_time_zero();
t = fake_time;
CRYPTO_THREAD_unlock(fake_time_lock);
return t;
}
static OSSL_TIME real_now(void *arg)
{
return ossl_time_now();
}
static int do_test(int use_thread_assist, int use_fake_time, int use_inject)
{
int testresult = 0, ret;
int s_fd = -1, c_fd = -1;
BIO *s_net_bio = NULL, *s_net_bio_own = NULL;
BIO *c_net_bio = NULL, *c_net_bio_own = NULL;
BIO *c_pair_own = NULL, *s_pair_own = NULL;
QUIC_TSERVER_ARGS tserver_args = {0};
QUIC_TSERVER *tserver = NULL;
BIO_ADDR *s_addr_ = NULL;
struct in_addr ina = {0};
union BIO_sock_info_u s_info = {0};
SSL_CTX *c_ctx = NULL;
SSL *c_ssl = NULL;
int c_connected = 0, c_write_done = 0, c_begin_read = 0, s_read_done = 0;
int c_wait_eos = 0, c_done_eos = 0;
int c_start_idle_test = 0, c_done_idle_test = 0;
size_t l = 0, s_total_read = 0, s_total_written = 0, c_total_read = 0;
size_t idle_units_done = 0;
int s_begin_write = 0;
OSSL_TIME start_time;
unsigned char alpn[] = { 8, 'o', 's', 's', 'l', 't', 'e', 's', 't' };
size_t limit_ms = 10000;
#if defined(OPENSSL_NO_QUIC_THREAD_ASSIST)
if (use_thread_assist) {
TEST_skip("thread assisted mode not enabled");
return 1;
}
#endif
ina.s_addr = htonl(0x7f000001UL);
/* Setup test server. */
s_fd = BIO_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0);
if (!TEST_int_ge(s_fd, 0))
goto err;
if (!TEST_true(BIO_socket_nbio(s_fd, 1)))
goto err;
if (!TEST_ptr(s_addr_ = BIO_ADDR_new()))
goto err;
if (!TEST_true(BIO_ADDR_rawmake(s_addr_, AF_INET, &ina, sizeof(ina), 0)))
goto err;
if (!TEST_true(BIO_bind(s_fd, s_addr_, 0)))
goto err;
s_info.addr = s_addr_;
if (!TEST_true(BIO_sock_info(s_fd, BIO_SOCK_INFO_ADDRESS, &s_info)))
goto err;
if (!TEST_int_gt(BIO_ADDR_rawport(s_addr_), 0))
goto err;
if (!TEST_ptr(s_net_bio = s_net_bio_own = BIO_new_dgram(s_fd, 0)))
goto err;
if (!BIO_up_ref(s_net_bio))
goto err;
fake_time = ossl_ms2time(1000);
tserver_args.net_rbio = s_net_bio;
tserver_args.net_wbio = s_net_bio;
tserver_args.alpn = NULL;
tserver_args.ctx = NULL;
if (use_fake_time)
tserver_args.now_cb = fake_now;
if (!TEST_ptr(tserver = ossl_quic_tserver_new(&tserver_args, certfile,
keyfile))) {
BIO_free(s_net_bio);
goto err;
}
s_net_bio_own = NULL;
if (use_inject) {
/*
* In inject mode we create a dgram pair to feed to the QUIC client on
* the read side. We don't feed anything to this, it is just a
* placeholder to give the client something which never returns any
* datagrams.
*/
if (!TEST_true(BIO_new_bio_dgram_pair(&c_pair_own, 5000,
&s_pair_own, 5000)))
goto err;
}
/* Setup test client. */
c_fd = BIO_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0);
if (!TEST_int_ge(c_fd, 0))
goto err;
if (!TEST_true(BIO_socket_nbio(c_fd, 1)))
goto err;
if (!TEST_ptr(c_net_bio = c_net_bio_own = BIO_new_dgram(c_fd, 0)))
goto err;
if (!BIO_dgram_set_peer(c_net_bio, s_addr_))
goto err;
if (!TEST_ptr(c_ctx = SSL_CTX_new(use_thread_assist
? OSSL_QUIC_client_thread_method()
: OSSL_QUIC_client_method())))
goto err;
if (!TEST_ptr(c_ssl = SSL_new(c_ctx)))
goto err;
if (use_fake_time)
if (!TEST_true(ossl_quic_conn_set_override_now_cb(c_ssl, fake_now, NULL)))
goto err;
/* 0 is a success for SSL_set_alpn_protos() */
if (!TEST_false(SSL_set_alpn_protos(c_ssl, alpn, sizeof(alpn))))
goto err;
/* Takes ownership of our reference to the BIO. */
if (use_inject) {
SSL_set0_rbio(c_ssl, c_pair_own);
c_pair_own = NULL;
} else {
SSL_set0_rbio(c_ssl, c_net_bio);
/* Get another reference to be transferred in the SSL_set0_wbio call. */
if (!TEST_true(BIO_up_ref(c_net_bio))) {
c_net_bio_own = NULL; /* SSL_free will free the first reference. */
goto err;
}
}
SSL_set0_wbio(c_ssl, c_net_bio);
c_net_bio_own = NULL;
if (!TEST_true(SSL_set_blocking_mode(c_ssl, 0)))
goto err;
/*
* We use real time for the timeout not fake time. Otherwise with fake time
* we could hit a hang if we never increment the fake time
*/
start_time = real_now(NULL);
for (;;) {
if (ossl_time_compare(ossl_time_subtract(real_now(NULL), start_time),
ossl_ms2time(limit_ms)) >= 0) {
TEST_error("timeout while attempting QUIC server test");
goto err;
}
if (!c_start_idle_test) {
ret = SSL_connect(c_ssl);
if (!TEST_true(ret == 1 || is_want(c_ssl, ret)))
goto err;
if (ret == 1)
c_connected = 1;
}
if (c_connected && !c_write_done) {
if (!TEST_int_eq(SSL_write(c_ssl, msg1, sizeof(msg1) - 1),
(int)sizeof(msg1) - 1))
goto err;
if (!TEST_true(SSL_stream_conclude(c_ssl, 0)))
goto err;
c_write_done = 1;
}
if (c_connected && c_write_done && !s_read_done) {
if (!ossl_quic_tserver_read(tserver, 0,
(unsigned char *)msg2 + s_total_read,
sizeof(msg2) - s_total_read, &l)) {
if (!TEST_true(ossl_quic_tserver_has_read_ended(tserver, 0)))
goto err;
if (!TEST_mem_eq(msg1, sizeof(msg1) - 1, msg2, s_total_read))
goto err;
s_begin_write = 1;
s_read_done = 1;
} else {
s_total_read += l;
if (!TEST_size_t_le(s_total_read, sizeof(msg1) - 1))
goto err;
}
}
if (s_begin_write && s_total_written < sizeof(msg1) - 1) {
if (!TEST_true(ossl_quic_tserver_write(tserver, 0,
(unsigned char *)msg2 + s_total_written,
sizeof(msg1) - 1 - s_total_written, &l)))
goto err;
s_total_written += l;
if (s_total_written == sizeof(msg1) - 1) {
ossl_quic_tserver_conclude(tserver, 0);
c_begin_read = 1;
}
}
if (c_begin_read && c_total_read < sizeof(msg1) - 1) {
ret = SSL_read_ex(c_ssl, msg3 + c_total_read,
sizeof(msg1) - 1 - c_total_read, &l);
if (!TEST_true(ret == 1 || is_want(c_ssl, ret)))
goto err;
c_total_read += l;
if (c_total_read == sizeof(msg1) - 1) {
if (!TEST_mem_eq(msg1, sizeof(msg1) - 1,
msg3, c_total_read))
goto err;
c_wait_eos = 1;
}
}
if (c_wait_eos && !c_done_eos) {
unsigned char c;
ret = SSL_read_ex(c_ssl, &c, sizeof(c), &l);
if (!TEST_false(ret))
goto err;
/*
* Allow the implementation to take as long as it wants to finally
* notice EOS. Account for varied timings in OS networking stacks.
*/
if (SSL_get_error(c_ssl, ret) != SSL_ERROR_WANT_READ) {
if (!TEST_int_eq(SSL_get_error(c_ssl, ret),
SSL_ERROR_ZERO_RETURN))
goto err;
c_done_eos = 1;
if (use_thread_assist && use_fake_time) {
if (!TEST_true(ossl_quic_tserver_is_connected(tserver)))
goto err;
c_start_idle_test = 1;
limit_ms = 120000; /* extend time limit */
} else {
/* DONE */
break;
}
}
}
if (c_start_idle_test && !c_done_idle_test) {
/* This is more than our default idle timeout of 30s. */
if (idle_units_done < 600) {
struct timeval tv;
int isinf;
if (!TEST_true(CRYPTO_THREAD_write_lock(fake_time_lock)))
goto err;
fake_time = ossl_time_add(fake_time, ossl_ms2time(100));
CRYPTO_THREAD_unlock(fake_time_lock);
++idle_units_done;
ossl_quic_conn_force_assist_thread_wake(c_ssl);
/*
* If the event timeout has expired then give the assistance
* thread a chance to catch up
*/
if (!TEST_true(SSL_get_event_timeout(c_ssl, &tv, &isinf)))
goto err;
if (!isinf && ossl_time_compare(ossl_time_zero(),
ossl_time_from_timeval(tv)) >= 0)
OSSL_sleep(100); /* Ensure CPU scheduling for test purposes */
} else {
c_done_idle_test = 1;
}
}
if (c_done_idle_test) {
/*
* If we have finished the fake idling duration, the connection
* should still be healthy in TA mode.
*/
if (!TEST_true(ossl_quic_tserver_is_connected(tserver)))
goto err;
/* DONE */
break;
}
/*
* This is inefficient because we spin until things work without
* blocking but this is just a test.
*/
if (!c_start_idle_test || c_done_idle_test) {
/* Inhibit manual ticking during idle test to test TA mode. */
SSL_handle_events(c_ssl);
}
ossl_quic_tserver_tick(tserver);
if (use_inject) {
BIO_MSG rmsg = {0};
size_t msgs_processed = 0;
for (;;) {
/*
* Manually spoonfeed received datagrams from the real BIO_dgram
* into QUIC via the injection interface, thereby testing the
* injection interface.
*/
rmsg.data = scratch_buf;
rmsg.data_len = sizeof(scratch_buf);
if (!BIO_recvmmsg(c_net_bio, &rmsg, sizeof(rmsg), 1, 0, &msgs_processed)
|| msgs_processed == 0 || rmsg.data_len == 0)
break;
if (!TEST_true(SSL_inject_net_dgram(c_ssl, rmsg.data, rmsg.data_len,
NULL, NULL)))
goto err;
}
}
}
testresult = 1;
err:
SSL_free(c_ssl);
SSL_CTX_free(c_ctx);
ossl_quic_tserver_free(tserver);
BIO_ADDR_free(s_addr_);
BIO_free(s_net_bio_own);
BIO_free(c_net_bio_own);
BIO_free(c_pair_own);
BIO_free(s_pair_own);
if (s_fd >= 0)
BIO_closesocket(s_fd);
if (c_fd >= 0)
BIO_closesocket(c_fd);
return testresult;
}
static int test_tserver(int idx)
{
int thread_assisted, use_fake_time, use_inject;
thread_assisted = idx % 2;
idx /= 2;
use_inject = idx % 2;
idx /= 2;
use_fake_time = idx % 2;
if (use_fake_time && !thread_assisted)
return 1;
return do_test(thread_assisted, use_fake_time, use_inject);
}
OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(certfile = test_get_argument(0))
|| !TEST_ptr(keyfile = test_get_argument(1)))
return 0;
if ((fake_time_lock = CRYPTO_THREAD_lock_new()) == NULL)
return 0;
ADD_ALL_TESTS(test_tserver, 2 * 2 * 2);
return 1;
}
|
./openssl/test/cc_dummy.c | /*
* Copyright 2022-2023 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 "internal/quic_cc.h"
#include "internal/quic_types.h"
typedef struct ossl_cc_dummy_st {
size_t max_dgram_len;
size_t *p_diag_max_dgram_len;
} OSSL_CC_DUMMY;
static void dummy_update_diag(OSSL_CC_DUMMY *d);
static OSSL_CC_DATA *dummy_new(OSSL_TIME (*now_cb)(void *arg),
void *now_cb_arg)
{
OSSL_CC_DUMMY *d = OPENSSL_zalloc(sizeof(*d));
if (d == NULL)
return NULL;
d->max_dgram_len = QUIC_MIN_INITIAL_DGRAM_LEN;
return (OSSL_CC_DATA *)d;
}
static void dummy_free(OSSL_CC_DATA *cc)
{
OPENSSL_free(cc);
}
static void dummy_reset(OSSL_CC_DATA *cc)
{
}
static int dummy_set_input_params(OSSL_CC_DATA *cc, const OSSL_PARAM *params)
{
OSSL_CC_DUMMY *d = (OSSL_CC_DUMMY *)cc;
const OSSL_PARAM *p;
size_t value;
p = OSSL_PARAM_locate_const(params, OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN);
if (p != NULL) {
if (!OSSL_PARAM_get_size_t(p, &value))
return 0;
if (value < QUIC_MIN_INITIAL_DGRAM_LEN)
return 0;
d->max_dgram_len = value;
dummy_update_diag(d);
}
return 1;
}
static int dummy_bind_diagnostic(OSSL_CC_DATA *cc, OSSL_PARAM *params)
{
OSSL_CC_DUMMY *d = (OSSL_CC_DUMMY *)cc;
const OSSL_PARAM *p;
p = OSSL_PARAM_locate_const(params, OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN);
if (p != NULL) {
if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER
|| p->data_size != sizeof(size_t))
return 0;
d->p_diag_max_dgram_len = p->data;
}
dummy_update_diag(d);
return 1;
}
static int dummy_unbind_diagnostic(OSSL_CC_DATA *cc, OSSL_PARAM *params)
{
OSSL_CC_DUMMY *d = (OSSL_CC_DUMMY *)cc;
if (OSSL_PARAM_locate_const(params, OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN)
!= NULL)
d->p_diag_max_dgram_len = NULL;
return 1;
}
static void dummy_update_diag(OSSL_CC_DUMMY *d)
{
if (d->p_diag_max_dgram_len != NULL)
*d->p_diag_max_dgram_len = d->max_dgram_len;
}
static uint64_t dummy_get_tx_allowance(OSSL_CC_DATA *cc)
{
return SIZE_MAX;
}
static OSSL_TIME dummy_get_wakeup_deadline(OSSL_CC_DATA *cc)
{
return ossl_time_infinite();
}
static int dummy_on_data_sent(OSSL_CC_DATA *cc,
uint64_t num_bytes)
{
return 1;
}
static int dummy_on_data_acked(OSSL_CC_DATA *cc,
const OSSL_CC_ACK_INFO *info)
{
return 1;
}
static int dummy_on_data_lost(OSSL_CC_DATA *cc,
const OSSL_CC_LOSS_INFO *info)
{
return 1;
}
static int dummy_on_data_lost_finished(OSSL_CC_DATA *cc,
uint32_t flags)
{
return 1;
}
static int dummy_on_data_invalidated(OSSL_CC_DATA *cc,
uint64_t num_bytes)
{
return 1;
}
const OSSL_CC_METHOD ossl_cc_dummy_method = {
dummy_new,
dummy_free,
dummy_reset,
dummy_set_input_params,
dummy_bind_diagnostic,
dummy_unbind_diagnostic,
dummy_get_tx_allowance,
dummy_get_wakeup_deadline,
dummy_on_data_sent,
dummy_on_data_acked,
dummy_on_data_lost,
dummy_on_data_lost_finished,
dummy_on_data_invalidated,
};
|
./openssl/test/namemap_internal_test.c | /*
* Copyright 2019-2021 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 <openssl/evp.h>
#include "internal/namemap.h"
#include "testutil.h"
#define NAME1 "name1"
#define NAME2 "name2"
#define ALIAS1 "alias1"
#define ALIAS1_UC "ALIAS1"
static int test_namemap_empty(void)
{
OSSL_NAMEMAP *nm = NULL;
int ok;
ok = TEST_int_eq(ossl_namemap_empty(NULL), 1)
&& TEST_ptr(nm = ossl_namemap_new())
&& TEST_int_eq(ossl_namemap_empty(nm), 1)
&& TEST_int_ne(ossl_namemap_add_name(nm, 0, NAME1), 0)
&& TEST_int_eq(ossl_namemap_empty(nm), 0);
ossl_namemap_free(nm);
return ok;
}
static int test_namemap(OSSL_NAMEMAP *nm)
{
int num1 = ossl_namemap_add_name(nm, 0, NAME1);
int num2 = ossl_namemap_add_name(nm, 0, NAME2);
int num3 = ossl_namemap_add_name(nm, num1, ALIAS1);
int num4 = ossl_namemap_add_name(nm, 0, ALIAS1_UC);
int check1 = ossl_namemap_name2num(nm, NAME1);
int check2 = ossl_namemap_name2num(nm, NAME2);
int check3 = ossl_namemap_name2num(nm, ALIAS1);
int check4 = ossl_namemap_name2num(nm, ALIAS1_UC);
int false1 = ossl_namemap_name2num(nm, "cookie");
return TEST_int_ne(num1, 0)
&& TEST_int_ne(num2, 0)
&& TEST_int_eq(num1, num3)
&& TEST_int_eq(num3, num4)
&& TEST_int_eq(num1, check1)
&& TEST_int_eq(num2, check2)
&& TEST_int_eq(num3, check3)
&& TEST_int_eq(num4, check4)
&& TEST_int_eq(false1, 0);
}
static int test_namemap_independent(void)
{
OSSL_NAMEMAP *nm = ossl_namemap_new();
int ok = TEST_ptr(nm) && test_namemap(nm);
ossl_namemap_free(nm);
return ok;
}
static int test_namemap_stored(void)
{
OSSL_NAMEMAP *nm = ossl_namemap_stored(NULL);
return TEST_ptr(nm)
&& test_namemap(nm);
}
/*
* Test that EVP_get_digestbyname() will use the namemap when it can't find
* entries in the legacy method database.
*/
static int test_digestbyname(void)
{
int id;
OSSL_NAMEMAP *nm = ossl_namemap_stored(NULL);
const EVP_MD *sha256, *foo;
if (!TEST_ptr(nm))
return 0;
id = ossl_namemap_add_name(nm, 0, "SHA256");
if (!TEST_int_ne(id, 0))
return 0;
if (!TEST_int_eq(ossl_namemap_add_name(nm, id, "foo"), id))
return 0;
sha256 = EVP_get_digestbyname("SHA256");
if (!TEST_ptr(sha256))
return 0;
foo = EVP_get_digestbyname("foo");
if (!TEST_ptr_eq(sha256, foo))
return 0;
return 1;
}
/*
* Test that EVP_get_cipherbyname() will use the namemap when it can't find
* entries in the legacy method database.
*/
static int test_cipherbyname(void)
{
int id;
OSSL_NAMEMAP *nm = ossl_namemap_stored(NULL);
const EVP_CIPHER *aes128, *bar;
if (!TEST_ptr(nm))
return 0;
id = ossl_namemap_add_name(nm, 0, "AES-128-CBC");
if (!TEST_int_ne(id, 0))
return 0;
if (!TEST_int_eq(ossl_namemap_add_name(nm, id, "bar"), id))
return 0;
aes128 = EVP_get_cipherbyname("AES-128-CBC");
if (!TEST_ptr(aes128))
return 0;
bar = EVP_get_cipherbyname("bar");
if (!TEST_ptr_eq(aes128, bar))
return 0;
return 1;
}
/*
* Test that EVP_CIPHER_is_a() responds appropriately, even for ciphers that
* are entirely legacy.
*/
static int test_cipher_is_a(void)
{
EVP_CIPHER *fetched = EVP_CIPHER_fetch(NULL, "AES-256-CCM", NULL);
int rv = 1;
if (!TEST_ptr(fetched))
return 0;
if (!TEST_true(EVP_CIPHER_is_a(fetched, "id-aes256-CCM"))
|| !TEST_false(EVP_CIPHER_is_a(fetched, "AES-128-GCM")))
rv = 0;
if (!TEST_true(EVP_CIPHER_is_a(EVP_aes_256_gcm(), "AES-256-GCM"))
|| !TEST_false(EVP_CIPHER_is_a(EVP_aes_256_gcm(), "AES-128-CCM")))
rv = 0;
EVP_CIPHER_free(fetched);
return rv;
}
/*
* Test that EVP_MD_is_a() responds appropriately, even for MDs that are
* entirely legacy.
*/
static int test_digest_is_a(void)
{
EVP_MD *fetched = EVP_MD_fetch(NULL, "SHA2-512", NULL);
int rv = 1;
if (!TEST_ptr(fetched))
return 0;
if (!TEST_true(EVP_MD_is_a(fetched, "SHA512"))
|| !TEST_false(EVP_MD_is_a(fetched, "SHA1")))
rv = 0;
if (!TEST_true(EVP_MD_is_a(EVP_sha256(), "SHA2-256"))
|| !TEST_false(EVP_MD_is_a(EVP_sha256(), "SHA3-256")))
rv = 0;
EVP_MD_free(fetched);
return rv;
}
int setup_tests(void)
{
ADD_TEST(test_namemap_empty);
ADD_TEST(test_namemap_independent);
ADD_TEST(test_namemap_stored);
ADD_TEST(test_digestbyname);
ADD_TEST(test_cipherbyname);
ADD_TEST(test_digest_is_a);
ADD_TEST(test_cipher_is_a);
return 1;
}
|
./openssl/test/quic_multistream_test.c | /*
* Copyright 2023 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 <openssl/ssl.h>
#include <openssl/quic.h>
#include <openssl/bio.h>
#include <openssl/lhash.h>
#include "internal/quic_tserver.h"
#include "internal/quic_ssl.h"
#include "internal/quic_error.h"
#include "internal/quic_stream_map.h"
#include "internal/quic_engine.h"
#include "testutil.h"
#include "helpers/quictestlib.h"
#if defined(OPENSSL_THREADS)
# include "internal/thread_arch.h"
#endif
#include "internal/numbers.h" /* UINT64_C */
static const char *certfile, *keyfile;
#if defined(OPENSSL_THREADS)
struct child_thread_args {
struct helper *h;
const struct script_op *script;
const char *script_name;
int thread_idx;
CRYPTO_THREAD *t;
CRYPTO_MUTEX *m;
int testresult;
int done;
int s_checked_out;
};
#endif
typedef struct stream_info {
const char *name;
SSL *c_stream;
uint64_t s_stream_id;
} STREAM_INFO;
DEFINE_LHASH_OF_EX(STREAM_INFO);
struct helper {
int s_fd;
BIO *s_net_bio, *s_net_bio_own, *s_qtf_wbio, *s_qtf_wbio_own;
/* The BIO_ADDR used for BIO_bind() */
BIO_ADDR *s_net_bio_orig_addr;
/* The resulting address, which is the one to connect to */
BIO_ADDR *s_net_bio_addr;
/*
* When doing a blocking mode test run, s_priv always points to the TSERVER
* and s is NULL when the main thread should not be touching s_priv.
*/
QUIC_TSERVER *s, *s_priv;
LHASH_OF(STREAM_INFO) *s_streams;
int c_fd;
BIO *c_net_bio, *c_net_bio_own;
SSL_CTX *c_ctx;
SSL *c_conn;
LHASH_OF(STREAM_INFO) *c_streams;
#if defined(OPENSSL_THREADS)
struct child_thread_args *threads;
size_t num_threads;
CRYPTO_MUTEX *misc_m;
CRYPTO_CONDVAR *misc_cv;
#endif
OSSL_TIME start_time;
/*
* This is a duration recording the amount of time we have skipped forwards
* for testing purposes relative to the real ossl_time_now() clock. We add
* a quantity of time to this every time we skip some time.
*/
CRYPTO_RWLOCK *time_lock;
OSSL_TIME time_slip; /* protected by time_lock */
QTEST_FAULT *qtf;
int init, blocking, check_spin_again;
int free_order, need_injector;
int (*qtf_packet_plain_cb)(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t buf_len);
int (*qtf_handshake_cb)(struct helper *h,
unsigned char *buf, size_t buf_len);
int (*qtf_datagram_cb)(struct helper *h,
BIO_MSG *m, size_t stride);
uint64_t inject_word0, inject_word1;
uint64_t scratch0, scratch1, fail_count;
#if defined(OPENSSL_THREADS)
struct {
CRYPTO_THREAD *t;
CRYPTO_MUTEX *m;
CRYPTO_CONDVAR *c;
int ready, stop;
} server_thread;
int s_checked_out;
#endif
};
struct helper_local {
struct helper *h;
LHASH_OF(STREAM_INFO) *c_streams;
int thread_idx;
const struct script_op *check_op;
};
struct script_op {
uint32_t op;
const void *arg0;
size_t arg1;
int (*check_func)(struct helper *h, struct helper_local *hl);
const char *stream_name;
uint64_t arg2;
int (*qtf_packet_plain_cb)(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t buf_len);
int (*qtf_handshake_cb)(struct helper *h,
unsigned char *buf, size_t buf_len);
int (*qtf_datagram_cb)(struct helper *h,
BIO_MSG *m, size_t stride);
};
#define OPK_END 0
#define OPK_CHECK 1
#define OPK_C_SET_ALPN 2
#define OPK_C_CONNECT_WAIT 3
#define OPK_C_WRITE 4
#define OPK_S_WRITE 5
#define OPK_C_READ_EXPECT 6
#define OPK_S_READ_EXPECT 7
#define OPK_C_EXPECT_FIN 8
#define OPK_S_EXPECT_FIN 9
#define OPK_C_CONCLUDE 10
#define OPK_S_CONCLUDE 11
#define OPK_C_DETACH 12
#define OPK_C_ATTACH 13
#define OPK_C_NEW_STREAM 14
#define OPK_S_NEW_STREAM 15
#define OPK_C_ACCEPT_STREAM_WAIT 16
#define OPK_C_ACCEPT_STREAM_NONE 17
#define OPK_C_FREE_STREAM 18
#define OPK_C_SET_DEFAULT_STREAM_MODE 19
#define OPK_C_SET_INCOMING_STREAM_POLICY 20
#define OPK_C_SHUTDOWN_WAIT 21
#define OPK_C_EXPECT_CONN_CLOSE_INFO 22
#define OPK_S_EXPECT_CONN_CLOSE_INFO 23
#define OPK_S_BIND_STREAM_ID 24
#define OPK_C_WAIT_FOR_DATA 25
#define OPK_C_WRITE_FAIL 26
#define OPK_S_WRITE_FAIL 27
#define OPK_C_READ_FAIL 28
#define OPK_C_STREAM_RESET 29
#define OPK_S_ACCEPT_STREAM_WAIT 30
#define OPK_NEW_THREAD 31
#define OPK_BEGIN_REPEAT 32
#define OPK_END_REPEAT 33
#define OPK_S_UNBIND_STREAM_ID 34
#define OPK_C_READ_FAIL_WAIT 35
#define OPK_C_CLOSE_SOCKET 36
#define OPK_C_EXPECT_SSL_ERR 37
#define OPK_EXPECT_ERR_REASON 38
#define OPK_EXPECT_ERR_LIB 39
#define OPK_SLEEP 40
#define OPK_S_READ_FAIL 41
#define OPK_S_SET_INJECT_PLAIN 42
#define OPK_SET_INJECT_WORD 43
#define OPK_C_INHIBIT_TICK 44
#define OPK_C_SET_WRITE_BUF_SIZE 45
#define OPK_S_SET_INJECT_HANDSHAKE 46
#define OPK_S_NEW_TICKET 47
#define OPK_C_SKIP_IF_UNBOUND 48
#define OPK_S_SET_INJECT_DATAGRAM 49
#define OPK_S_SHUTDOWN 50
#define OPK_POP_ERR 51
#define EXPECT_CONN_CLOSE_APP (1U << 0)
#define EXPECT_CONN_CLOSE_REMOTE (1U << 1)
/* OPK_C_NEW_STREAM */
#define ALLOW_FAIL (1U << 16)
#define C_BIDI_ID(ordinal) \
(((ordinal) << 2) | QUIC_STREAM_INITIATOR_CLIENT | QUIC_STREAM_DIR_BIDI)
#define S_BIDI_ID(ordinal) \
(((ordinal) << 2) | QUIC_STREAM_INITIATOR_SERVER | QUIC_STREAM_DIR_BIDI)
#define C_UNI_ID(ordinal) \
(((ordinal) << 2) | QUIC_STREAM_INITIATOR_CLIENT | QUIC_STREAM_DIR_UNI)
#define S_UNI_ID(ordinal) \
(((ordinal) << 2) | QUIC_STREAM_INITIATOR_SERVER | QUIC_STREAM_DIR_UNI)
#define ANY_ID UINT64_MAX
#define OP_END \
{OPK_END}
#define OP_CHECK(func, arg2) \
{OPK_CHECK, NULL, 0, (func), NULL, (arg2)},
#define OP_C_SET_ALPN(alpn) \
{OPK_C_SET_ALPN, (alpn), 0, NULL, NULL},
#define OP_C_CONNECT_WAIT() \
{OPK_C_CONNECT_WAIT, NULL, 0, NULL, NULL},
#define OP_C_CONNECT_WAIT_OR_FAIL() \
{OPK_C_CONNECT_WAIT, NULL, 1, NULL, NULL},
#define OP_C_WRITE(stream_name, buf, buf_len) \
{OPK_C_WRITE, (buf), (buf_len), NULL, #stream_name},
#define OP_S_WRITE(stream_name, buf, buf_len) \
{OPK_S_WRITE, (buf), (buf_len), NULL, #stream_name},
#define OP_C_READ_EXPECT(stream_name, buf, buf_len) \
{OPK_C_READ_EXPECT, (buf), (buf_len), NULL, #stream_name},
#define OP_S_READ_EXPECT(stream_name, buf, buf_len) \
{OPK_S_READ_EXPECT, (buf), (buf_len), NULL, #stream_name},
#define OP_C_EXPECT_FIN(stream_name) \
{OPK_C_EXPECT_FIN, NULL, 0, NULL, #stream_name},
#define OP_S_EXPECT_FIN(stream_name) \
{OPK_S_EXPECT_FIN, NULL, 0, NULL, #stream_name},
#define OP_C_CONCLUDE(stream_name) \
{OPK_C_CONCLUDE, NULL, 0, NULL, #stream_name},
#define OP_S_CONCLUDE(stream_name) \
{OPK_S_CONCLUDE, NULL, 0, NULL, #stream_name},
#define OP_C_DETACH(stream_name) \
{OPK_C_DETACH, NULL, 0, NULL, #stream_name},
#define OP_C_ATTACH(stream_name) \
{OPK_C_ATTACH, NULL, 0, NULL, #stream_name},
#define OP_C_NEW_STREAM_BIDI(stream_name, expect_id) \
{OPK_C_NEW_STREAM, NULL, 0, NULL, #stream_name, (expect_id)},
#define OP_C_NEW_STREAM_BIDI_EX(stream_name, expect_id, flags) \
{OPK_C_NEW_STREAM, NULL, (flags), NULL, #stream_name, (expect_id)},
#define OP_C_NEW_STREAM_UNI(stream_name, expect_id) \
{OPK_C_NEW_STREAM, NULL, SSL_STREAM_FLAG_UNI, \
NULL, #stream_name, (expect_id)},
#define OP_C_NEW_STREAM_UNI_EX(stream_name, expect_id, flags) \
{OPK_C_NEW_STREAM, NULL, (flags) | SSL_STREAM_FLAG_UNI, \
NULL, #stream_name, (expect_id)},
#define OP_S_NEW_STREAM_BIDI(stream_name, expect_id) \
{OPK_S_NEW_STREAM, NULL, 0, NULL, #stream_name, (expect_id)},
#define OP_S_NEW_STREAM_UNI(stream_name, expect_id) \
{OPK_S_NEW_STREAM, NULL, 1, NULL, #stream_name, (expect_id)},
#define OP_C_ACCEPT_STREAM_WAIT(stream_name) \
{OPK_C_ACCEPT_STREAM_WAIT, NULL, 0, NULL, #stream_name},
#define OP_C_ACCEPT_STREAM_NONE() \
{OPK_C_ACCEPT_STREAM_NONE, NULL, 0, NULL, NULL},
#define OP_C_FREE_STREAM(stream_name) \
{OPK_C_FREE_STREAM, NULL, 0, NULL, #stream_name},
#define OP_C_SET_DEFAULT_STREAM_MODE(mode) \
{OPK_C_SET_DEFAULT_STREAM_MODE, NULL, (mode), NULL, NULL},
#define OP_C_SET_INCOMING_STREAM_POLICY(policy) \
{OPK_C_SET_INCOMING_STREAM_POLICY, NULL, (policy), NULL, NULL},
#define OP_C_SHUTDOWN_WAIT(reason, flags) \
{OPK_C_SHUTDOWN_WAIT, (reason), (flags), NULL, NULL},
#define OP_C_EXPECT_CONN_CLOSE_INFO(ec, app, remote) \
{OPK_C_EXPECT_CONN_CLOSE_INFO, NULL, \
((app) ? EXPECT_CONN_CLOSE_APP : 0) | \
((remote) ? EXPECT_CONN_CLOSE_REMOTE : 0), \
NULL, NULL, (ec)},
#define OP_S_EXPECT_CONN_CLOSE_INFO(ec, app, remote) \
{OPK_S_EXPECT_CONN_CLOSE_INFO, NULL, \
((app) ? EXPECT_CONN_CLOSE_APP : 0) | \
((remote) ? EXPECT_CONN_CLOSE_REMOTE : 0), \
NULL, NULL, (ec)},
#define OP_S_BIND_STREAM_ID(stream_name, stream_id) \
{OPK_S_BIND_STREAM_ID, NULL, 0, NULL, #stream_name, (stream_id)},
#define OP_C_WAIT_FOR_DATA(stream_name) \
{OPK_C_WAIT_FOR_DATA, NULL, 0, NULL, #stream_name},
#define OP_C_WRITE_FAIL(stream_name) \
{OPK_C_WRITE_FAIL, NULL, 0, NULL, #stream_name},
#define OP_S_WRITE_FAIL(stream_name) \
{OPK_S_WRITE_FAIL, NULL, 0, NULL, #stream_name},
#define OP_C_READ_FAIL(stream_name) \
{OPK_C_READ_FAIL, NULL, 0, NULL, #stream_name},
#define OP_S_READ_FAIL(stream_name) \
{OPK_S_READ_FAIL, NULL, 0, NULL, #stream_name},
#define OP_C_STREAM_RESET(stream_name, aec) \
{OPK_C_STREAM_RESET, NULL, 0, NULL, #stream_name, (aec)},
#define OP_S_ACCEPT_STREAM_WAIT(stream_name) \
{OPK_S_ACCEPT_STREAM_WAIT, NULL, 0, NULL, #stream_name},
#define OP_NEW_THREAD(num_threads, script) \
{OPK_NEW_THREAD, (script), (num_threads), NULL, NULL, 0 },
#define OP_BEGIN_REPEAT(n) \
{OPK_BEGIN_REPEAT, NULL, (n)},
#define OP_END_REPEAT() \
{OPK_END_REPEAT},
#define OP_S_UNBIND_STREAM_ID(stream_name) \
{OPK_S_UNBIND_STREAM_ID, NULL, 0, NULL, #stream_name},
#define OP_C_READ_FAIL_WAIT(stream_name) \
{OPK_C_READ_FAIL_WAIT, NULL, 0, NULL, #stream_name},
#define OP_C_CLOSE_SOCKET() \
{OPK_C_CLOSE_SOCKET},
#define OP_C_EXPECT_SSL_ERR(stream_name, err) \
{OPK_C_EXPECT_SSL_ERR, NULL, (err), NULL, #stream_name},
#define OP_EXPECT_ERR_REASON(err) \
{OPK_EXPECT_ERR_REASON, NULL, (err)},
#define OP_EXPECT_ERR_LIB(lib) \
{OPK_EXPECT_ERR_LIB, NULL, (lib)},
#define OP_SLEEP(ms) \
{OPK_SLEEP, NULL, 0, NULL, NULL, (ms)},
#define OP_S_SET_INJECT_PLAIN(f) \
{OPK_S_SET_INJECT_PLAIN, NULL, 0, NULL, NULL, 0, (f)},
#define OP_SET_INJECT_WORD(w0, w1) \
{OPK_SET_INJECT_WORD, NULL, (w0), NULL, NULL, (w1), NULL},
#define OP_C_INHIBIT_TICK(inhibit) \
{OPK_C_INHIBIT_TICK, NULL, (inhibit), NULL, NULL, 0, NULL},
#define OP_C_SET_WRITE_BUF_SIZE(stream_name, size) \
{OPK_C_SET_WRITE_BUF_SIZE, NULL, (size), NULL, #stream_name},
#define OP_S_SET_INJECT_HANDSHAKE(f) \
{OPK_S_SET_INJECT_HANDSHAKE, NULL, 0, NULL, NULL, 0, NULL, (f)},
#define OP_S_NEW_TICKET() \
{OPK_S_NEW_TICKET},
#define OP_C_SKIP_IF_UNBOUND(stream_name, n) \
{OPK_C_SKIP_IF_UNBOUND, NULL, (n), NULL, #stream_name},
#define OP_S_SET_INJECT_DATAGRAM(f) \
{OPK_S_SET_INJECT_DATAGRAM, NULL, 0, NULL, NULL, 0, NULL, NULL, (f)},
#define OP_S_SHUTDOWN(error_code) \
{OPK_S_SHUTDOWN, NULL, (error_code)},
#define OP_POP_ERR() \
{OPK_POP_ERR},
static OSSL_TIME get_time(void *arg)
{
struct helper *h = arg;
OSSL_TIME t;
if (!TEST_true(CRYPTO_THREAD_read_lock(h->time_lock)))
return ossl_time_zero();
t = ossl_time_add(ossl_time_now(), h->time_slip);
CRYPTO_THREAD_unlock(h->time_lock);
return t;
}
static int skip_time_ms(struct helper *h, struct helper_local *hl)
{
if (!TEST_true(CRYPTO_THREAD_write_lock(h->time_lock)))
return 0;
h->time_slip = ossl_time_add(h->time_slip, ossl_ms2time(hl->check_op->arg2));
CRYPTO_THREAD_unlock(h->time_lock);
return 1;
}
static QUIC_TSERVER *s_lock(struct helper *h, struct helper_local *hl);
static void s_unlock(struct helper *h, struct helper_local *hl);
#define ACQUIRE_S() s_lock(h, hl)
static int check_rejected(struct helper *h, struct helper_local *hl)
{
uint64_t stream_id = hl->check_op->arg2;
if (!ossl_quic_tserver_stream_has_peer_stop_sending(ACQUIRE_S(), stream_id, NULL)
|| !ossl_quic_tserver_stream_has_peer_reset_stream(ACQUIRE_S(), stream_id, NULL)) {
h->check_spin_again = 1;
return 0;
}
return 1;
}
static int check_stream_reset(struct helper *h, struct helper_local *hl)
{
uint64_t stream_id = hl->check_op->arg2, aec = 0;
if (!ossl_quic_tserver_stream_has_peer_reset_stream(ACQUIRE_S(), stream_id, &aec)) {
h->check_spin_again = 1;
return 0;
}
return TEST_uint64_t_eq(aec, 42);
}
static int check_stream_stopped(struct helper *h, struct helper_local *hl)
{
uint64_t stream_id = hl->check_op->arg2;
if (!ossl_quic_tserver_stream_has_peer_stop_sending(ACQUIRE_S(), stream_id, NULL)) {
h->check_spin_again = 1;
return 0;
}
return 1;
}
static int override_key_update(struct helper *h, struct helper_local *hl)
{
QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn);
ossl_quic_channel_set_txku_threshold_override(ch, hl->check_op->arg2);
return 1;
}
static int trigger_key_update(struct helper *h, struct helper_local *hl)
{
if (!TEST_true(SSL_key_update(h->c_conn, SSL_KEY_UPDATE_REQUESTED)))
return 0;
return 1;
}
static int check_key_update_ge(struct helper *h, struct helper_local *hl)
{
QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn);
int64_t txke = (int64_t)ossl_quic_channel_get_tx_key_epoch(ch);
int64_t rxke = (int64_t)ossl_quic_channel_get_rx_key_epoch(ch);
int64_t diff = txke - rxke;
/*
* TXKE must always be equal to or ahead of RXKE.
* It can be ahead of RXKE by at most 1.
*/
if (!TEST_int64_t_ge(diff, 0) || !TEST_int64_t_le(diff, 1))
return 0;
/* Caller specifies a minimum number of RXKEs which must have happened. */
if (!TEST_uint64_t_ge((uint64_t)rxke, hl->check_op->arg2))
return 0;
return 1;
}
static int check_key_update_lt(struct helper *h, struct helper_local *hl)
{
QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn);
uint64_t txke = ossl_quic_channel_get_tx_key_epoch(ch);
/* Caller specifies a maximum number of TXKEs which must have happened. */
if (!TEST_uint64_t_lt(txke, hl->check_op->arg2))
return 0;
return 1;
}
static unsigned long stream_info_hash(const STREAM_INFO *info)
{
return OPENSSL_LH_strhash(info->name);
}
static int stream_info_cmp(const STREAM_INFO *a, const STREAM_INFO *b)
{
return strcmp(a->name, b->name);
}
static void cleanup_stream(STREAM_INFO *info)
{
SSL_free(info->c_stream);
OPENSSL_free(info);
}
static void helper_cleanup_streams(LHASH_OF(STREAM_INFO) **lh)
{
if (*lh == NULL)
return;
lh_STREAM_INFO_doall(*lh, cleanup_stream);
lh_STREAM_INFO_free(*lh);
*lh = NULL;
}
#if defined(OPENSSL_THREADS)
static CRYPTO_THREAD_RETVAL run_script_child_thread(void *arg);
static int join_threads(struct child_thread_args *threads, size_t num_threads)
{
int ok = 1;
size_t i;
CRYPTO_THREAD_RETVAL rv;
for (i = 0; i < num_threads; ++i) {
if (threads[i].t != NULL) {
ossl_crypto_thread_native_join(threads[i].t, &rv);
if (!threads[i].testresult)
/* Do not log failure here, worker will do it. */
ok = 0;
ossl_crypto_thread_native_clean(threads[i].t);
threads[i].t = NULL;
}
ossl_crypto_mutex_free(&threads[i].m);
}
return ok;
}
static int join_server_thread(struct helper *h)
{
CRYPTO_THREAD_RETVAL rv;
if (h->server_thread.t == NULL)
return 1;
ossl_crypto_mutex_lock(h->server_thread.m);
h->server_thread.stop = 1;
ossl_crypto_condvar_signal(h->server_thread.c);
ossl_crypto_mutex_unlock(h->server_thread.m);
ossl_crypto_thread_native_join(h->server_thread.t, &rv);
ossl_crypto_thread_native_clean(h->server_thread.t);
h->server_thread.t = NULL;
return 1;
}
/* Ensure the server-state lock is currently held. Idempotent. */
static int *s_checked_out_p(struct helper *h, int thread_idx)
{
return (thread_idx < 0) ? &h->s_checked_out
: &h->threads[thread_idx].s_checked_out;
}
static QUIC_TSERVER *s_lock(struct helper *h, struct helper_local *hl)
{
int *p_checked_out = s_checked_out_p(h, hl->thread_idx);
if (h->server_thread.m == NULL || *p_checked_out)
return h->s;
ossl_crypto_mutex_lock(h->server_thread.m);
h->s = h->s_priv;
*p_checked_out = 1;
return h->s;
}
/* Ensure the server-state lock is currently not held. Idempotent. */
static void s_unlock(struct helper *h, struct helper_local *hl)
{
int *p_checked_out = s_checked_out_p(h, hl->thread_idx);
if (h->server_thread.m == NULL || !*p_checked_out)
return;
*p_checked_out = 0;
h->s = NULL;
ossl_crypto_mutex_unlock(h->server_thread.m);
}
static unsigned int server_helper_thread(void *arg)
{
struct helper *h = arg;
ossl_crypto_mutex_lock(h->server_thread.m);
for (;;) {
int ready, stop;
ready = h->server_thread.ready;
stop = h->server_thread.stop;
if (stop)
break;
if (!ready) {
ossl_crypto_condvar_wait(h->server_thread.c, h->server_thread.m);
continue;
}
ossl_quic_tserver_tick(h->s_priv);
ossl_crypto_mutex_unlock(h->server_thread.m);
/*
* Give the main thread an opportunity to get the mutex, which is
* sometimes necessary in some script operations.
*/
OSSL_sleep(1);
ossl_crypto_mutex_lock(h->server_thread.m);
}
ossl_crypto_mutex_unlock(h->server_thread.m);
return 1;
}
#else
static QUIC_TSERVER *s_lock(struct helper *h, struct helper_local *hl)
{
return h->s;
}
static void s_unlock(struct helper *h, struct helper_local *hl)
{}
#endif
static void helper_cleanup(struct helper *h)
{
#if defined(OPENSSL_THREADS)
join_threads(h->threads, h->num_threads);
join_server_thread(h);
OPENSSL_free(h->threads);
h->threads = NULL;
h->num_threads = 0;
#endif
if (h->free_order == 0) {
/* order 0: streams, then conn */
helper_cleanup_streams(&h->c_streams);
SSL_free(h->c_conn);
h->c_conn = NULL;
} else {
/* order 1: conn, then streams */
SSL_free(h->c_conn);
h->c_conn = NULL;
helper_cleanup_streams(&h->c_streams);
}
helper_cleanup_streams(&h->s_streams);
ossl_quic_tserver_free(h->s_priv);
h->s_priv = h->s = NULL;
BIO_free(h->s_net_bio_own);
h->s_net_bio_own = NULL;
BIO_free(h->c_net_bio_own);
h->c_net_bio_own = NULL;
BIO_free(h->s_qtf_wbio_own);
h->s_qtf_wbio_own = NULL;
qtest_fault_free(h->qtf);
h->qtf = NULL;
if (h->s_fd >= 0) {
BIO_closesocket(h->s_fd);
h->s_fd = -1;
}
if (h->c_fd >= 0) {
BIO_closesocket(h->c_fd);
h->c_fd = -1;
}
BIO_ADDR_free(h->s_net_bio_addr);
h->s_net_bio_addr = NULL;
BIO_ADDR_free(h->s_net_bio_orig_addr);
h->s_net_bio_orig_addr = NULL;
SSL_CTX_free(h->c_ctx);
h->c_ctx = NULL;
CRYPTO_THREAD_lock_free(h->time_lock);
h->time_lock = NULL;
#if defined(OPENSSL_THREADS)
ossl_crypto_mutex_free(&h->misc_m);
ossl_crypto_condvar_free(&h->misc_cv);
ossl_crypto_mutex_free(&h->server_thread.m);
ossl_crypto_condvar_free(&h->server_thread.c);
#endif
}
static int helper_init(struct helper *h, int free_order, int blocking,
int need_injector)
{
struct in_addr ina = {0};
QUIC_TSERVER_ARGS s_args = {0};
union BIO_sock_info_u info;
memset(h, 0, sizeof(*h));
h->c_fd = -1;
h->s_fd = -1;
h->free_order = free_order;
h->blocking = blocking;
h->need_injector = need_injector;
h->time_slip = ossl_time_zero();
if (!TEST_ptr(h->time_lock = CRYPTO_THREAD_lock_new()))
goto err;
if (!TEST_ptr(h->s_streams = lh_STREAM_INFO_new(stream_info_hash,
stream_info_cmp)))
goto err;
if (!TEST_ptr(h->c_streams = lh_STREAM_INFO_new(stream_info_hash,
stream_info_cmp)))
goto err;
ina.s_addr = htonl(0x7f000001UL);
h->s_fd = BIO_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0);
if (!TEST_int_ge(h->s_fd, 0))
goto err;
if (!TEST_true(BIO_socket_nbio(h->s_fd, 1)))
goto err;
if (!TEST_ptr(h->s_net_bio_orig_addr = BIO_ADDR_new())
|| !TEST_ptr(h->s_net_bio_addr = BIO_ADDR_new()))
goto err;
if (!TEST_true(BIO_ADDR_rawmake(h->s_net_bio_orig_addr, AF_INET,
&ina, sizeof(ina), 0)))
goto err;
if (!TEST_true(BIO_bind(h->s_fd, h->s_net_bio_orig_addr, 0)))
goto err;
info.addr = h->s_net_bio_addr;
if (!TEST_true(BIO_sock_info(h->s_fd, BIO_SOCK_INFO_ADDRESS, &info)))
goto err;
if (!TEST_int_gt(BIO_ADDR_rawport(h->s_net_bio_addr), 0))
goto err;
if (!TEST_ptr(h->s_net_bio = h->s_net_bio_own = BIO_new_dgram(h->s_fd, 0)))
goto err;
if (!BIO_up_ref(h->s_net_bio))
goto err;
if (need_injector) {
h->s_qtf_wbio = h->s_qtf_wbio_own = BIO_new(qtest_get_bio_method());
if (!TEST_ptr(h->s_qtf_wbio))
goto err;
if (!TEST_ptr(BIO_push(h->s_qtf_wbio, h->s_net_bio)))
goto err;
s_args.net_wbio = h->s_qtf_wbio;
} else {
s_args.net_wbio = h->s_net_bio;
}
s_args.net_rbio = h->s_net_bio;
s_args.alpn = NULL;
s_args.now_cb = get_time;
s_args.now_cb_arg = h;
s_args.ctx = NULL;
if (!TEST_ptr(h->s_priv = ossl_quic_tserver_new(&s_args, certfile, keyfile)))
goto err;
if (!blocking)
h->s = h->s_priv;
if (need_injector) {
h->qtf = qtest_create_injector(h->s_priv);
if (!TEST_ptr(h->qtf))
goto err;
BIO_set_data(h->s_qtf_wbio, h->qtf);
}
h->s_net_bio_own = NULL;
h->s_qtf_wbio_own = NULL;
h->c_fd = BIO_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0);
if (!TEST_int_ge(h->c_fd, 0))
goto err;
if (!TEST_true(BIO_socket_nbio(h->c_fd, 1)))
goto err;
if (!TEST_ptr(h->c_net_bio = h->c_net_bio_own = BIO_new_dgram(h->c_fd, 0)))
goto err;
if (!TEST_true(BIO_dgram_set_peer(h->c_net_bio, h->s_net_bio_addr)))
goto err;
if (!TEST_ptr(h->c_ctx = SSL_CTX_new(OSSL_QUIC_client_method())))
goto err;
if (!TEST_ptr(h->c_conn = SSL_new(h->c_ctx)))
goto err;
/* Use custom time function for virtual time skip. */
if (!TEST_true(ossl_quic_conn_set_override_now_cb(h->c_conn, get_time, h)))
goto err;
/* Takes ownership of our reference to the BIO. */
SSL_set0_rbio(h->c_conn, h->c_net_bio);
h->c_net_bio_own = NULL;
if (!TEST_true(BIO_up_ref(h->c_net_bio)))
goto err;
SSL_set0_wbio(h->c_conn, h->c_net_bio);
if (!TEST_true(SSL_set_blocking_mode(h->c_conn, h->blocking)))
goto err;
#if defined(OPENSSL_THREADS)
if (!TEST_ptr(h->misc_m = ossl_crypto_mutex_new()))
goto err;
if (!TEST_ptr(h->misc_cv = ossl_crypto_condvar_new()))
goto err;
#endif
if (h->blocking) {
#if defined(OPENSSL_THREADS)
if (!TEST_ptr(h->server_thread.m = ossl_crypto_mutex_new()))
goto err;
if (!TEST_ptr(h->server_thread.c = ossl_crypto_condvar_new()))
goto err;
h->server_thread.t
= ossl_crypto_thread_native_start(server_helper_thread, h, 1);
if (!TEST_ptr(h->server_thread.t))
goto err;
#else
TEST_error("cannot support blocking mode without threads");
goto err;
#endif
}
h->start_time = ossl_time_now();
h->init = 1;
return 1;
err:
helper_cleanup(h);
return 0;
}
static int helper_local_init(struct helper_local *hl, struct helper *h,
int thread_idx)
{
hl->h = h;
hl->c_streams = NULL;
hl->thread_idx = thread_idx;
if (!TEST_ptr(h))
return 0;
if (thread_idx < 0) {
hl->c_streams = h->c_streams;
} else {
if (!TEST_ptr(hl->c_streams = lh_STREAM_INFO_new(stream_info_hash,
stream_info_cmp)))
return 0;
}
return 1;
}
static void helper_local_cleanup(struct helper_local *hl)
{
if (hl->h == NULL)
return;
if (hl->thread_idx >= 0)
helper_cleanup_streams(&hl->c_streams);
hl->h = NULL;
}
static STREAM_INFO *get_stream_info(LHASH_OF(STREAM_INFO) *lh,
const char *stream_name)
{
STREAM_INFO key, *info;
if (!TEST_ptr(stream_name))
return NULL;
if (!strcmp(stream_name, "DEFAULT"))
return NULL;
key.name = stream_name;
info = lh_STREAM_INFO_retrieve(lh, &key);
if (info == NULL) {
info = OPENSSL_zalloc(sizeof(*info));
if (info == NULL)
return NULL;
info->name = stream_name;
info->s_stream_id = UINT64_MAX;
lh_STREAM_INFO_insert(lh, info);
}
return info;
}
static int helper_local_set_c_stream(struct helper_local *hl,
const char *stream_name,
SSL *c_stream)
{
STREAM_INFO *info = get_stream_info(hl->c_streams, stream_name);
if (info == NULL)
return 0;
info->c_stream = c_stream;
info->s_stream_id = UINT64_MAX;
return 1;
}
static SSL *helper_local_get_c_stream(struct helper_local *hl,
const char *stream_name)
{
STREAM_INFO *info;
if (!strcmp(stream_name, "DEFAULT"))
return hl->h->c_conn;
info = get_stream_info(hl->c_streams, stream_name);
if (info == NULL)
return NULL;
return info->c_stream;
}
static int
helper_set_s_stream(struct helper *h, const char *stream_name,
uint64_t s_stream_id)
{
STREAM_INFO *info;
if (!strcmp(stream_name, "DEFAULT"))
return 0;
info = get_stream_info(h->s_streams, stream_name);
if (info == NULL)
return 0;
info->c_stream = NULL;
info->s_stream_id = s_stream_id;
return 1;
}
static uint64_t helper_get_s_stream(struct helper *h, const char *stream_name)
{
STREAM_INFO *info;
if (!strcmp(stream_name, "DEFAULT"))
return UINT64_MAX;
info = get_stream_info(h->s_streams, stream_name);
if (info == NULL)
return UINT64_MAX;
return info->s_stream_id;
}
static int helper_packet_plain_listener(QTEST_FAULT *qtf, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t buf_len,
void *arg)
{
struct helper *h = arg;
return h->qtf_packet_plain_cb(h, hdr, buf, buf_len);
}
static int helper_handshake_listener(QTEST_FAULT *fault,
unsigned char *buf, size_t buf_len,
void *arg)
{
struct helper *h = arg;
return h->qtf_handshake_cb(h, buf, buf_len);
}
static int helper_datagram_listener(QTEST_FAULT *fault,
BIO_MSG *msg, size_t stride,
void *arg)
{
struct helper *h = arg;
return h->qtf_datagram_cb(h, msg, stride);
}
static int is_want(SSL *s, int ret)
{
int ec = SSL_get_error(s, ret);
return ec == SSL_ERROR_WANT_READ || ec == SSL_ERROR_WANT_WRITE;
}
static int check_consistent_want(SSL *s, int ret)
{
int ec = SSL_get_error(s, ret);
int w = SSL_want(s);
int ok = TEST_true(
(ec == SSL_ERROR_NONE && w == SSL_NOTHING)
|| (ec == SSL_ERROR_ZERO_RETURN && w == SSL_NOTHING)
|| (ec == SSL_ERROR_SSL && w == SSL_NOTHING)
|| (ec == SSL_ERROR_SYSCALL && w == SSL_NOTHING)
|| (ec == SSL_ERROR_WANT_READ && w == SSL_READING)
|| (ec == SSL_ERROR_WANT_WRITE && w == SSL_WRITING)
|| (ec == SSL_ERROR_WANT_CLIENT_HELLO_CB && w == SSL_CLIENT_HELLO_CB)
|| (ec == SSL_ERROR_WANT_X509_LOOKUP && w == SSL_X509_LOOKUP)
|| (ec == SSL_ERROR_WANT_RETRY_VERIFY && w == SSL_RETRY_VERIFY)
);
if (!ok)
TEST_error("got error=%d, want=%d", ec, w);
return ok;
}
static int run_script_worker(struct helper *h, const struct script_op *script,
const char *script_name,
int thread_idx)
{
int testresult = 0;
unsigned char *tmp_buf = NULL;
int connect_started = 0;
size_t offset = 0;
size_t op_idx = 0;
const struct script_op *op = NULL;
int no_advance = 0, first = 1;
#if defined(OPENSSL_THREADS)
int end_wait_warning = 0;
#endif
OSSL_TIME op_start_time = ossl_time_zero(), op_deadline = ossl_time_zero();
struct helper_local hl_, *hl = &hl_;
#define REPEAT_SLOTS 8
size_t repeat_stack_idx[REPEAT_SLOTS], repeat_stack_done[REPEAT_SLOTS];
size_t repeat_stack_limit[REPEAT_SLOTS];
size_t repeat_stack_len = 0;
if (!TEST_true(helper_local_init(hl, h, thread_idx)))
goto out;
#define COMMON_SPIN_AGAIN() \
{ \
no_advance = 1; \
continue; \
}
#define S_SPIN_AGAIN() \
{ \
s_lock(h, hl); \
ossl_quic_tserver_tick(h->s); \
COMMON_SPIN_AGAIN(); \
}
#define C_SPIN_AGAIN() \
{ \
if (h->blocking) { \
TEST_error("spin again in blocking mode"); \
goto out; \
} \
COMMON_SPIN_AGAIN(); \
}
for (;;) {
SSL *c_tgt = h->c_conn;
uint64_t s_stream_id = UINT64_MAX;
s_unlock(h, hl);
if (no_advance) {
no_advance = 0;
} else {
if (!first)
++op_idx;
first = 0;
offset = 0;
op_start_time = ossl_time_now();
op_deadline = ossl_time_add(op_start_time, ossl_ms2time(60000));
}
if (!TEST_int_le(ossl_time_compare(ossl_time_now(), op_deadline), 0)) {
TEST_error("op %zu timed out on thread %d", op_idx + 1, thread_idx);
goto out;
}
op = &script[op_idx];
if (op->stream_name != NULL) {
c_tgt = helper_local_get_c_stream(hl, op->stream_name);
if (thread_idx < 0)
s_stream_id = helper_get_s_stream(h, op->stream_name);
else
s_stream_id = UINT64_MAX;
}
if (thread_idx < 0) {
if (!h->blocking) {
ossl_quic_tserver_tick(h->s);
}
#if defined(OPENSSL_THREADS)
else if (h->blocking && !h->server_thread.ready) {
ossl_crypto_mutex_lock(h->server_thread.m);
h->server_thread.ready = 1;
ossl_crypto_condvar_signal(h->server_thread.c);
ossl_crypto_mutex_unlock(h->server_thread.m);
}
if (h->blocking)
assert(h->s == NULL);
#endif
}
if (thread_idx >= 0 || connect_started)
SSL_handle_events(h->c_conn);
if (thread_idx >= 0) {
/* Only allow certain opcodes on child threads. */
switch (op->op) {
case OPK_END:
case OPK_CHECK:
case OPK_C_ACCEPT_STREAM_WAIT:
case OPK_C_NEW_STREAM:
case OPK_C_READ_EXPECT:
case OPK_C_EXPECT_FIN:
case OPK_C_WRITE:
case OPK_C_CONCLUDE:
case OPK_C_FREE_STREAM:
case OPK_BEGIN_REPEAT:
case OPK_END_REPEAT:
case OPK_C_READ_FAIL_WAIT:
case OPK_C_EXPECT_SSL_ERR:
case OPK_EXPECT_ERR_REASON:
case OPK_EXPECT_ERR_LIB:
case OPK_POP_ERR:
case OPK_SLEEP:
break;
default:
TEST_error("opcode %lu not allowed on child thread",
(unsigned long)op->op);
goto out;
}
}
switch (op->op) {
case OPK_END:
if (!TEST_size_t_eq(repeat_stack_len, 0))
goto out;
#if defined(OPENSSL_THREADS)
if (thread_idx < 0) {
int done;
size_t i;
for (i = 0; i < h->num_threads; ++i) {
if (h->threads[i].m == NULL)
continue;
ossl_crypto_mutex_lock(h->threads[i].m);
done = h->threads[i].done;
ossl_crypto_mutex_unlock(h->threads[i].m);
if (!done) {
if (!end_wait_warning) {
TEST_info("still waiting for other threads to finish (%zu)", i);
end_wait_warning = 1;
}
S_SPIN_AGAIN();
}
}
}
#endif
TEST_info("script \"%s\" finished on thread %d", script_name, thread_idx);
testresult = 1;
goto out;
case OPK_BEGIN_REPEAT:
if (!TEST_size_t_lt(repeat_stack_len, OSSL_NELEM(repeat_stack_idx)))
goto out;
if (!TEST_size_t_gt(op->arg1, 0))
goto out;
repeat_stack_idx[repeat_stack_len] = op_idx + 1;
repeat_stack_done[repeat_stack_len] = 0;
repeat_stack_limit[repeat_stack_len] = op->arg1;
++repeat_stack_len;
break;
case OPK_C_SKIP_IF_UNBOUND:
if (c_tgt != NULL)
break;
op_idx += op->arg1;
break;
case OPK_END_REPEAT:
if (!TEST_size_t_gt(repeat_stack_len, 0))
goto out;
if (++repeat_stack_done[repeat_stack_len - 1]
== repeat_stack_limit[repeat_stack_len - 1]) {
--repeat_stack_len;
} else {
op_idx = repeat_stack_idx[repeat_stack_len - 1];
no_advance = 1;
continue;
}
break;
case OPK_CHECK:
{
int ok;
hl->check_op = op;
ok = op->check_func(h, hl);
hl->check_op = NULL;
if (thread_idx < 0 && h->check_spin_again) {
h->check_spin_again = 0;
S_SPIN_AGAIN();
}
if (!TEST_true(ok))
goto out;
}
break;
case OPK_C_SET_ALPN:
{
const char *alpn = op->arg0;
size_t alpn_len = strlen(alpn);
if (!TEST_size_t_le(alpn_len, UINT8_MAX)
|| !TEST_ptr(tmp_buf = (unsigned char *)OPENSSL_malloc(alpn_len + 1)))
goto out;
memcpy(tmp_buf + 1, alpn, alpn_len);
tmp_buf[0] = (unsigned char)alpn_len;
/* 0 is the success case for SSL_set_alpn_protos(). */
if (!TEST_false(SSL_set_alpn_protos(h->c_conn, tmp_buf,
alpn_len + 1)))
goto out;
OPENSSL_free(tmp_buf);
tmp_buf = NULL;
}
break;
case OPK_C_CONNECT_WAIT:
{
int ret;
connect_started = 1;
ret = SSL_connect(h->c_conn);
if (!check_consistent_want(c_tgt, ret))
goto out;
if (ret != 1) {
if (!h->blocking && is_want(h->c_conn, ret))
C_SPIN_AGAIN();
if (op->arg1 == 0 && !TEST_int_eq(ret, 1))
goto out;
}
}
break;
case OPK_C_WRITE:
{
size_t bytes_written = 0;
int r;
if (!TEST_ptr(c_tgt))
goto out;
r = SSL_write_ex(c_tgt, op->arg0, op->arg1, &bytes_written);
if (!TEST_true(r)
|| !check_consistent_want(c_tgt, r)
|| !TEST_size_t_eq(bytes_written, op->arg1))
goto out;
}
break;
case OPK_S_WRITE:
{
size_t bytes_written = 0;
if (!TEST_uint64_t_ne(s_stream_id, UINT64_MAX))
goto out;
if (!TEST_true(ossl_quic_tserver_write(ACQUIRE_S(), s_stream_id,
op->arg0, op->arg1,
&bytes_written))
|| !TEST_size_t_eq(bytes_written, op->arg1))
goto out;
}
break;
case OPK_C_CONCLUDE:
{
if (!TEST_true(SSL_stream_conclude(c_tgt, 0)))
goto out;
}
break;
case OPK_S_CONCLUDE:
{
if (!TEST_uint64_t_ne(s_stream_id, UINT64_MAX))
goto out;
ossl_quic_tserver_conclude(ACQUIRE_S(), s_stream_id);
}
break;
case OPK_C_WAIT_FOR_DATA:
{
char buf[1];
size_t bytes_read = 0;
if (!TEST_ptr(c_tgt))
goto out;
if (!SSL_peek_ex(c_tgt, buf, sizeof(buf), &bytes_read)
|| bytes_read == 0)
C_SPIN_AGAIN();
}
break;
case OPK_C_READ_EXPECT:
{
size_t bytes_read = 0;
int r;
if (op->arg1 > 0 && tmp_buf == NULL
&& !TEST_ptr(tmp_buf = OPENSSL_malloc(op->arg1)))
goto out;
r = SSL_read_ex(c_tgt, tmp_buf + offset, op->arg1 - offset,
&bytes_read);
if (!check_consistent_want(c_tgt, r))
goto out;
if (!r)
C_SPIN_AGAIN();
if (bytes_read + offset != op->arg1) {
offset += bytes_read;
C_SPIN_AGAIN();
}
if (op->arg1 > 0
&& !TEST_mem_eq(tmp_buf, op->arg1, op->arg0, op->arg1))
goto out;
OPENSSL_free(tmp_buf);
tmp_buf = NULL;
}
break;
case OPK_S_READ_EXPECT:
{
size_t bytes_read = 0;
if (!TEST_uint64_t_ne(s_stream_id, UINT64_MAX))
goto out;
if (op->arg1 > 0 && tmp_buf == NULL
&& !TEST_ptr(tmp_buf = OPENSSL_malloc(op->arg1)))
goto out;
if (!TEST_true(ossl_quic_tserver_read(ACQUIRE_S(), s_stream_id,
tmp_buf + offset,
op->arg1 - offset,
&bytes_read)))
goto out;
if (bytes_read + offset != op->arg1) {
offset += bytes_read;
S_SPIN_AGAIN();
}
if (op->arg1 > 0
&& !TEST_mem_eq(tmp_buf, op->arg1, op->arg0, op->arg1))
goto out;
OPENSSL_free(tmp_buf);
tmp_buf = NULL;
}
break;
case OPK_C_EXPECT_FIN:
{
char buf[1];
size_t bytes_read = 0;
int r;
r = SSL_read_ex(c_tgt, buf, sizeof(buf), &bytes_read);
if (!check_consistent_want(c_tgt, r)
|| !TEST_false(r)
|| !TEST_size_t_eq(bytes_read, 0))
goto out;
if (is_want(c_tgt, 0))
C_SPIN_AGAIN();
if (!TEST_int_eq(SSL_get_error(c_tgt, 0),
SSL_ERROR_ZERO_RETURN))
goto out;
if (!TEST_int_eq(SSL_want(c_tgt), SSL_NOTHING))
goto out;
}
break;
case OPK_S_EXPECT_FIN:
{
if (!TEST_uint64_t_ne(s_stream_id, UINT64_MAX))
goto out;
if (!ossl_quic_tserver_has_read_ended(ACQUIRE_S(), s_stream_id))
S_SPIN_AGAIN();
}
break;
case OPK_C_DETACH:
{
SSL *c_stream;
if (!TEST_ptr_null(c_tgt))
goto out; /* don't overwrite existing stream with same name */
if (!TEST_ptr(op->stream_name))
goto out;
if (!TEST_ptr(c_stream = ossl_quic_detach_stream(h->c_conn)))
goto out;
if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name, c_stream)))
goto out;
}
break;
case OPK_C_ATTACH:
{
if (!TEST_ptr(c_tgt))
goto out;
if (!TEST_ptr(op->stream_name))
goto out;
if (!TEST_true(ossl_quic_attach_stream(h->c_conn, c_tgt)))
goto out;
if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name, NULL)))
goto out;
}
break;
case OPK_C_NEW_STREAM:
{
SSL *c_stream;
uint64_t flags = op->arg1;
int allow_fail = ((flags & ALLOW_FAIL) != 0);
flags &= ~(uint64_t)ALLOW_FAIL;
if (!TEST_ptr_null(c_tgt))
goto out; /* don't overwrite existing stream with same name */
if (!TEST_ptr(op->stream_name))
goto out;
c_stream = SSL_new_stream(h->c_conn, flags);
if (!allow_fail && !TEST_ptr(c_stream))
goto out;
if (allow_fail && c_stream == NULL) {
if (!TEST_size_t_eq(ERR_GET_REASON(ERR_get_error()),
SSL_R_STREAM_COUNT_LIMITED))
goto out;
++h->fail_count;
break;
}
if (op->arg2 != UINT64_MAX
&& !TEST_uint64_t_eq(SSL_get_stream_id(c_stream),
op->arg2))
goto out;
if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name, c_stream)))
goto out;
}
break;
case OPK_S_NEW_STREAM:
{
uint64_t stream_id = UINT64_MAX;
if (!TEST_uint64_t_eq(s_stream_id, UINT64_MAX))
goto out; /* don't overwrite existing stream with same name */
if (!TEST_ptr(op->stream_name))
goto out;
if (!TEST_true(ossl_quic_tserver_stream_new(ACQUIRE_S(),
op->arg1 > 0,
&stream_id)))
goto out;
if (op->arg2 != UINT64_MAX
&& !TEST_uint64_t_eq(stream_id, op->arg2))
goto out;
if (!TEST_true(helper_set_s_stream(h, op->stream_name,
stream_id)))
goto out;
}
break;
case OPK_C_ACCEPT_STREAM_WAIT:
{
SSL *c_stream;
if (!TEST_ptr_null(c_tgt))
goto out; /* don't overwrite existing stream with same name */
if (!TEST_ptr(op->stream_name))
goto out;
if ((c_stream = SSL_accept_stream(h->c_conn, 0)) == NULL)
C_SPIN_AGAIN();
if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name,
c_stream)))
goto out;
}
break;
case OPK_S_ACCEPT_STREAM_WAIT:
{
uint64_t new_stream_id;
if (!TEST_uint64_t_eq(s_stream_id, UINT64_MAX))
goto out;
if (!TEST_ptr(op->stream_name))
goto out;
new_stream_id = ossl_quic_tserver_pop_incoming_stream(ACQUIRE_S());
if (new_stream_id == UINT64_MAX)
S_SPIN_AGAIN();
if (!TEST_true(helper_set_s_stream(h, op->stream_name, new_stream_id)))
goto out;
}
break;
case OPK_C_ACCEPT_STREAM_NONE:
{
SSL *c_stream;
if (!TEST_ptr_null(c_stream = SSL_accept_stream(h->c_conn,
SSL_ACCEPT_STREAM_NO_BLOCK))) {
SSL_free(c_stream);
goto out;
}
}
break;
case OPK_C_FREE_STREAM:
{
if (!TEST_ptr(c_tgt)
|| !TEST_true(!SSL_is_connection(c_tgt)))
goto out;
if (!TEST_ptr(op->stream_name))
goto out;
if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name, NULL)))
goto out;
SSL_free(c_tgt);
c_tgt = NULL;
}
break;
case OPK_C_SET_DEFAULT_STREAM_MODE:
{
if (!TEST_ptr(c_tgt))
goto out;
if (!TEST_true(SSL_set_default_stream_mode(c_tgt, op->arg1)))
goto out;
}
break;
case OPK_C_SET_INCOMING_STREAM_POLICY:
{
if (!TEST_ptr(c_tgt))
goto out;
if (!TEST_true(SSL_set_incoming_stream_policy(c_tgt,
op->arg1, 0)))
goto out;
}
break;
case OPK_C_SHUTDOWN_WAIT:
{
int ret;
QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn);
SSL_SHUTDOWN_EX_ARGS args = {0};
ossl_quic_engine_set_inhibit_tick(ossl_quic_channel_get0_engine(ch), 0);
if (!TEST_ptr(c_tgt))
goto out;
args.quic_reason = (const char *)op->arg0;
ret = SSL_shutdown_ex(c_tgt, op->arg1, &args, sizeof(args));
if (!TEST_int_ge(ret, 0))
goto out;
if (ret == 0)
C_SPIN_AGAIN();
}
break;
case OPK_S_SHUTDOWN:
{
ossl_quic_tserver_shutdown(ACQUIRE_S(), op->arg1);
}
break;
case OPK_C_EXPECT_CONN_CLOSE_INFO:
{
SSL_CONN_CLOSE_INFO cc_info = {0};
int expect_app = (op->arg1 & EXPECT_CONN_CLOSE_APP) != 0;
int expect_remote = (op->arg1 & EXPECT_CONN_CLOSE_REMOTE) != 0;
uint64_t error_code = op->arg2;
if (!TEST_ptr(c_tgt))
goto out;
if (h->blocking
&& !TEST_true(SSL_shutdown_ex(c_tgt,
SSL_SHUTDOWN_FLAG_WAIT_PEER,
NULL, 0)))
goto out;
if (!SSL_get_conn_close_info(c_tgt, &cc_info, sizeof(cc_info)))
C_SPIN_AGAIN();
if (!TEST_int_eq(expect_app,
(cc_info.flags
& SSL_CONN_CLOSE_FLAG_TRANSPORT) == 0)
|| !TEST_int_eq(expect_remote,
(cc_info.flags
& SSL_CONN_CLOSE_FLAG_LOCAL) == 0)
|| !TEST_uint64_t_eq(error_code, cc_info.error_code)) {
TEST_info("Connection close reason: %s", cc_info.reason);
goto out;
}
}
break;
case OPK_S_EXPECT_CONN_CLOSE_INFO:
{
const QUIC_TERMINATE_CAUSE *tc;
int expect_app = (op->arg1 & EXPECT_CONN_CLOSE_APP) != 0;
int expect_remote = (op->arg1 & EXPECT_CONN_CLOSE_REMOTE) != 0;
uint64_t error_code = op->arg2;
if (!ossl_quic_tserver_is_term_any(ACQUIRE_S())) {
ossl_quic_tserver_ping(ACQUIRE_S());
S_SPIN_AGAIN();
}
if (!TEST_ptr(tc = ossl_quic_tserver_get_terminate_cause(ACQUIRE_S())))
goto out;
if (!TEST_uint64_t_eq(error_code, tc->error_code)
|| !TEST_int_eq(expect_app, tc->app)
|| !TEST_int_eq(expect_remote, tc->remote))
goto out;
}
break;
case OPK_S_BIND_STREAM_ID:
{
if (!TEST_uint64_t_eq(s_stream_id, UINT64_MAX))
goto out;
if (!TEST_ptr(op->stream_name))
goto out;
if (!TEST_true(helper_set_s_stream(h, op->stream_name, op->arg2)))
goto out;
}
break;
case OPK_S_UNBIND_STREAM_ID:
{
if (!TEST_uint64_t_ne(s_stream_id, UINT64_MAX))
goto out;
if (!TEST_ptr(op->stream_name))
goto out;
if (!TEST_true(helper_set_s_stream(h, op->stream_name, UINT64_MAX)))
goto out;
}
break;
case OPK_C_WRITE_FAIL:
{
size_t bytes_written = 0;
int r;
if (!TEST_ptr(c_tgt))
goto out;
r = SSL_write_ex(c_tgt, "apple", 5, &bytes_written);
if (!TEST_false(r)
|| !check_consistent_want(c_tgt, r))
goto out;
}
break;
case OPK_S_WRITE_FAIL:
{
size_t bytes_written = 0;
if (!TEST_uint64_t_ne(s_stream_id, UINT64_MAX))
goto out;
if (!TEST_false(ossl_quic_tserver_write(ACQUIRE_S(), s_stream_id,
(const unsigned char *)"apple", 5,
&bytes_written)))
goto out;
}
break;
case OPK_C_READ_FAIL:
{
size_t bytes_read = 0;
char buf[1];
int r;
if (!TEST_ptr(c_tgt))
goto out;
r = SSL_read_ex(c_tgt, buf, sizeof(buf), &bytes_read);
if (!TEST_false(r))
goto out;
if (!check_consistent_want(c_tgt, r))
goto out;
}
break;
case OPK_C_READ_FAIL_WAIT:
{
size_t bytes_read = 0;
char buf[1];
int r;
if (!TEST_ptr(c_tgt))
goto out;
r = SSL_read_ex(c_tgt, buf, sizeof(buf), &bytes_read);
if (!TEST_false(r))
goto out;
if (!check_consistent_want(c_tgt, r))
goto out;
if (is_want(c_tgt, 0))
C_SPIN_AGAIN();
}
break;
case OPK_S_READ_FAIL:
{
size_t bytes_read = 0;
unsigned char buf[1];
if (!TEST_uint64_t_ne(s_stream_id, UINT64_MAX))
goto out;
if (!TEST_false(ossl_quic_tserver_read(ACQUIRE_S(), s_stream_id,
buf, sizeof(buf),
&bytes_read)))
goto out;
}
break;
case OPK_C_STREAM_RESET:
{
SSL_STREAM_RESET_ARGS args = {0};
if (!TEST_ptr(c_tgt))
goto out;
args.quic_error_code = op->arg2;
if (!TEST_true(SSL_stream_reset(c_tgt, &args, sizeof(args))))
goto out;
}
break;
case OPK_NEW_THREAD:
{
#if !defined(OPENSSL_THREADS)
/*
* If this test script requires threading and we do not have
* support for it, skip the rest of it.
*/
TEST_skip("threading not supported, skipping");
testresult = 1;
goto out;
#else
size_t i;
if (!TEST_ptr_null(h->threads)) {
TEST_error("max one NEW_THREAD operation per script");
goto out;
}
h->threads = OPENSSL_zalloc(op->arg1 * sizeof(struct child_thread_args));
if (!TEST_ptr(h->threads))
goto out;
h->num_threads = op->arg1;
for (i = 0; i < op->arg1; ++i) {
h->threads[i].h = h;
h->threads[i].script = op->arg0;
h->threads[i].script_name = script_name;
h->threads[i].thread_idx = i;
h->threads[i].m = ossl_crypto_mutex_new();
if (!TEST_ptr(h->threads[i].m))
goto out;
h->threads[i].t
= ossl_crypto_thread_native_start(run_script_child_thread,
&h->threads[i], 1);
if (!TEST_ptr(h->threads[i].t))
goto out;
}
#endif
}
break;
case OPK_C_CLOSE_SOCKET:
{
BIO_closesocket(h->c_fd);
h->c_fd = -1;
}
break;
case OPK_C_EXPECT_SSL_ERR:
{
if (!TEST_size_t_eq((size_t)SSL_get_error(c_tgt, 0), op->arg1))
goto out;
if (!TEST_int_eq(SSL_want(c_tgt), SSL_NOTHING))
goto out;
}
break;
case OPK_EXPECT_ERR_REASON:
{
if (!TEST_size_t_eq((size_t)ERR_GET_REASON(ERR_peek_last_error()), op->arg1))
goto out;
}
break;
case OPK_EXPECT_ERR_LIB:
{
if (!TEST_size_t_eq((size_t)ERR_GET_LIB(ERR_peek_last_error()), op->arg1))
goto out;
}
break;
case OPK_POP_ERR:
ERR_pop();
break;
case OPK_SLEEP:
{
OSSL_sleep(op->arg2);
}
break;
case OPK_S_SET_INJECT_PLAIN:
h->qtf_packet_plain_cb = op->qtf_packet_plain_cb;
if (!TEST_true(qtest_fault_set_packet_plain_listener(h->qtf,
h->qtf_packet_plain_cb != NULL ?
helper_packet_plain_listener : NULL,
h)))
goto out;
break;
case OPK_S_SET_INJECT_HANDSHAKE:
h->qtf_handshake_cb = op->qtf_handshake_cb;
if (!TEST_true(qtest_fault_set_handshake_listener(h->qtf,
h->qtf_handshake_cb != NULL ?
helper_handshake_listener : NULL,
h)))
goto out;
break;
case OPK_S_SET_INJECT_DATAGRAM:
h->qtf_datagram_cb = op->qtf_datagram_cb;
if (!TEST_true(qtest_fault_set_datagram_listener(h->qtf,
h->qtf_datagram_cb != NULL ?
helper_datagram_listener : NULL,
h)))
goto out;
break;
case OPK_SET_INJECT_WORD:
/*
* Must hold server tick lock - callbacks can be called from other
* thread when running test in blocking mode (tsan).
*/
ACQUIRE_S();
h->inject_word0 = op->arg1;
h->inject_word1 = op->arg2;
break;
case OPK_C_INHIBIT_TICK:
{
QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn);
ossl_quic_engine_set_inhibit_tick(ossl_quic_channel_get0_engine(ch),
op->arg1);
}
break;
case OPK_C_SET_WRITE_BUF_SIZE:
if (!TEST_ptr(c_tgt))
goto out;
if (!TEST_true(ossl_quic_set_write_buffer_size(c_tgt, op->arg1)))
goto out;
break;
case OPK_S_NEW_TICKET:
if (!TEST_true(ossl_quic_tserver_new_ticket(ACQUIRE_S())))
goto out;
break;
default:
TEST_error("unknown op");
goto out;
}
}
out:
s_unlock(h, hl); /* idempotent */
if (!testresult) {
size_t i;
const QUIC_TERMINATE_CAUSE *tcause;
const char *e_str, *f_str;
TEST_error("failed in script \"%s\" at op %zu, thread %d\n",
script_name, op_idx + 1, thread_idx);
for (i = 0; i < repeat_stack_len; ++i)
TEST_info("while repeating, iteration %zu of %zu, starting at script op %zu",
repeat_stack_done[i],
repeat_stack_limit[i],
repeat_stack_idx[i]);
ERR_print_errors_fp(stderr);
if (h->c_conn != NULL) {
SSL_CONN_CLOSE_INFO cc_info = {0};
if (SSL_get_conn_close_info(h->c_conn, &cc_info, sizeof(cc_info))) {
e_str = ossl_quic_err_to_string(cc_info.error_code);
f_str = ossl_quic_frame_type_to_string(cc_info.frame_type);
if (e_str == NULL)
e_str = "?";
if (f_str == NULL)
f_str = "?";
TEST_info("client side is closed: %llu(%s)/%llu(%s), "
"%s, %s, reason: \"%s\"",
(unsigned long long)cc_info.error_code,
e_str,
(unsigned long long)cc_info.frame_type,
f_str,
(cc_info.flags & SSL_CONN_CLOSE_FLAG_LOCAL) != 0
? "local" : "remote",
(cc_info.flags & SSL_CONN_CLOSE_FLAG_TRANSPORT) != 0
? "transport" : "app",
cc_info.reason != NULL ? cc_info.reason : "-");
}
}
tcause = (h->s != NULL
? ossl_quic_tserver_get_terminate_cause(h->s) : NULL);
if (tcause != NULL) {
e_str = ossl_quic_err_to_string(tcause->error_code);
f_str = ossl_quic_frame_type_to_string(tcause->frame_type);
if (e_str == NULL)
e_str = "?";
if (f_str == NULL)
f_str = "?";
TEST_info("server side is closed: %llu(%s)/%llu(%s), "
"%s, %s, reason: \"%s\"",
(unsigned long long)tcause->error_code,
e_str,
(unsigned long long)tcause->frame_type,
f_str,
tcause->remote ? "remote" : "local",
tcause->app ? "app" : "transport",
tcause->reason != NULL ? tcause->reason : "-");
}
}
OPENSSL_free(tmp_buf);
helper_local_cleanup(hl);
return testresult;
}
static int run_script(const struct script_op *script,
const char *script_name,
int free_order,
int blocking)
{
int testresult = 0;
struct helper h;
if (!TEST_true(helper_init(&h, free_order, blocking, 1)))
goto out;
if (!TEST_true(run_script_worker(&h, script, script_name, -1)))
goto out;
#if defined(OPENSSL_THREADS)
if (!TEST_true(join_threads(h.threads, h.num_threads)))
goto out;
#endif
testresult = 1;
out:
helper_cleanup(&h);
return testresult;
}
#if defined(OPENSSL_THREADS)
static CRYPTO_THREAD_RETVAL run_script_child_thread(void *arg)
{
int testresult;
struct child_thread_args *args = arg;
testresult = run_script_worker(args->h, args->script,
args->script_name,
args->thread_idx);
ossl_crypto_mutex_lock(args->m);
args->testresult = testresult;
args->done = 1;
ossl_crypto_mutex_unlock(args->m);
return 1;
}
#endif
/* 1. Simple single-stream test */
static const struct script_op script_1[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_C_CONCLUDE (DEFAULT)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_S_EXPECT_FIN (a)
OP_S_WRITE (a, "orange", 6)
OP_S_CONCLUDE (a)
OP_C_READ_EXPECT (DEFAULT, "orange", 6)
OP_C_EXPECT_FIN (DEFAULT)
OP_END
};
/* 2. Multi-stream test */
static const struct script_op script_2[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_INCOMING_STREAM_POLICY(SSL_INCOMING_STREAM_POLICY_ACCEPT)
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (DEFAULT, "orange", 6)
OP_C_NEW_STREAM_BIDI (b, C_BIDI_ID(1))
OP_C_WRITE (b, "flamingo", 8)
OP_C_CONCLUDE (b)
OP_S_BIND_STREAM_ID (b, C_BIDI_ID(1))
OP_S_READ_EXPECT (b, "flamingo", 8)
OP_S_EXPECT_FIN (b)
OP_S_WRITE (b, "gargoyle", 8)
OP_S_CONCLUDE (b)
OP_C_READ_EXPECT (b, "gargoyle", 8)
OP_C_EXPECT_FIN (b)
OP_C_NEW_STREAM_UNI (c, C_UNI_ID(0))
OP_C_WRITE (c, "elephant", 8)
OP_C_CONCLUDE (c)
OP_S_BIND_STREAM_ID (c, C_UNI_ID(0))
OP_S_READ_EXPECT (c, "elephant", 8)
OP_S_EXPECT_FIN (c)
OP_S_WRITE_FAIL (c)
OP_C_ACCEPT_STREAM_NONE ()
OP_S_NEW_STREAM_BIDI (d, S_BIDI_ID(0))
OP_S_WRITE (d, "frog", 4)
OP_S_CONCLUDE (d)
OP_C_ACCEPT_STREAM_WAIT (d)
OP_C_ACCEPT_STREAM_NONE ()
OP_C_READ_EXPECT (d, "frog", 4)
OP_C_EXPECT_FIN (d)
OP_S_NEW_STREAM_BIDI (e, S_BIDI_ID(1))
OP_S_WRITE (e, "mixture", 7)
OP_S_CONCLUDE (e)
OP_C_ACCEPT_STREAM_WAIT (e)
OP_C_READ_EXPECT (e, "mixture", 7)
OP_C_EXPECT_FIN (e)
OP_C_WRITE (e, "ramble", 6)
OP_S_READ_EXPECT (e, "ramble", 6)
OP_C_CONCLUDE (e)
OP_S_EXPECT_FIN (e)
OP_S_NEW_STREAM_UNI (f, S_UNI_ID(0))
OP_S_WRITE (f, "yonder", 6)
OP_S_CONCLUDE (f)
OP_C_ACCEPT_STREAM_WAIT (f)
OP_C_ACCEPT_STREAM_NONE ()
OP_C_READ_EXPECT (f, "yonder", 6)
OP_C_EXPECT_FIN (f)
OP_C_WRITE_FAIL (f)
OP_C_SET_INCOMING_STREAM_POLICY(SSL_INCOMING_STREAM_POLICY_REJECT)
OP_S_NEW_STREAM_BIDI (g, S_BIDI_ID(2))
OP_S_WRITE (g, "unseen", 6)
OP_S_CONCLUDE (g)
OP_C_ACCEPT_STREAM_NONE ()
OP_C_SET_INCOMING_STREAM_POLICY(SSL_INCOMING_STREAM_POLICY_AUTO)
OP_S_NEW_STREAM_BIDI (h, S_BIDI_ID(3))
OP_S_WRITE (h, "UNSEEN", 6)
OP_S_CONCLUDE (h)
OP_C_ACCEPT_STREAM_NONE ()
/*
* Streams g, h should have been rejected, so server should have got
* STOP_SENDING/RESET_STREAM.
*/
OP_CHECK (check_rejected, S_BIDI_ID(2))
OP_CHECK (check_rejected, S_BIDI_ID(3))
OP_END
};
/* 3. Default stream detach/reattach test */
static const struct script_op script_3[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_C_DETACH (a) /* DEFAULT becomes stream 'a' */
OP_C_WRITE_FAIL (DEFAULT)
OP_C_WRITE (a, "by", 2)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "appleby", 7)
OP_S_WRITE (a, "hello", 5)
OP_C_READ_EXPECT (a, "hello", 5)
OP_C_WRITE_FAIL (DEFAULT)
OP_C_ATTACH (a)
OP_C_WRITE (DEFAULT, "is here", 7)
OP_S_READ_EXPECT (a, "is here", 7)
OP_C_DETACH (a)
OP_C_CONCLUDE (a)
OP_S_EXPECT_FIN (a)
OP_END
};
/* 4. Default stream mode test */
static const struct script_op script_4[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_WRITE_FAIL (DEFAULT)
OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_READ_FAIL (DEFAULT)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "apple", 5)
OP_C_ATTACH (a)
OP_C_WRITE (DEFAULT, "orange", 6)
OP_S_READ_EXPECT (a, "orange", 6)
OP_END
};
/* 5. Test stream reset functionality */
static const struct script_op script_5[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_NEW_STREAM_BIDI (b, C_BIDI_ID(1))
OP_C_WRITE (a, "apple", 5)
OP_C_STREAM_RESET (a, 42)
OP_C_WRITE (b, "strawberry", 10)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_BIND_STREAM_ID (b, C_BIDI_ID(1))
OP_S_READ_EXPECT (b, "strawberry", 10)
/* Reset disrupts read of already sent data */
OP_S_READ_FAIL (a)
OP_CHECK (check_stream_reset, C_BIDI_ID(0))
OP_END
};
/* 6. Test STOP_SENDING functionality */
static const struct script_op script_6[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_FREE_STREAM (a)
OP_C_ACCEPT_STREAM_NONE ()
OP_CHECK (check_stream_stopped, S_BIDI_ID(0))
OP_END
};
/* 7. Unidirectional default stream mode test (client sends first) */
static const struct script_op script_7[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_AUTO_UNI)
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_UNI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_S_WRITE_FAIL (a)
OP_END
};
/* 8. Unidirectional default stream mode test (server sends first) */
static const struct script_op script_8[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_AUTO_UNI)
OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_READ_EXPECT (DEFAULT, "apple", 5)
OP_C_WRITE_FAIL (DEFAULT)
OP_END
};
/* 9. Unidirectional default stream mode test (server sends first on bidi) */
static const struct script_op script_9[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_AUTO_UNI)
OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_READ_EXPECT (DEFAULT, "apple", 5)
OP_C_WRITE (DEFAULT, "orange", 6)
OP_S_READ_EXPECT (a, "orange", 6)
OP_END
};
/* 10. Shutdown */
static const struct script_op script_10[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_C_SHUTDOWN_WAIT (NULL, 0)
OP_C_EXPECT_CONN_CLOSE_INFO(0, 1, 0)
OP_S_EXPECT_CONN_CLOSE_INFO(0, 1, 1)
OP_END
};
/* 11. Many threads accepted on the same client connection */
static const struct script_op script_11_child[] = {
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "foo", 3)
OP_C_EXPECT_FIN (a)
OP_END
};
static const struct script_op script_11[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_NEW_THREAD (5, script_11_child)
OP_S_NEW_STREAM_BIDI (a, ANY_ID)
OP_S_WRITE (a, "foo", 3)
OP_S_CONCLUDE (a)
OP_S_NEW_STREAM_BIDI (b, ANY_ID)
OP_S_WRITE (b, "foo", 3)
OP_S_CONCLUDE (b)
OP_S_NEW_STREAM_BIDI (c, ANY_ID)
OP_S_WRITE (c, "foo", 3)
OP_S_CONCLUDE (c)
OP_S_NEW_STREAM_BIDI (d, ANY_ID)
OP_S_WRITE (d, "foo", 3)
OP_S_CONCLUDE (d)
OP_S_NEW_STREAM_BIDI (e, ANY_ID)
OP_S_WRITE (e, "foo", 3)
OP_S_CONCLUDE (e)
OP_END
};
/* 12. Many threads initiated on the same client connection */
static const struct script_op script_12_child[] = {
OP_C_NEW_STREAM_BIDI (a, ANY_ID)
OP_C_WRITE (a, "foo", 3)
OP_C_CONCLUDE (a)
OP_C_FREE_STREAM (a)
OP_END
};
static const struct script_op script_12[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_NEW_THREAD (5, script_12_child)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "foo", 3)
OP_S_EXPECT_FIN (a)
OP_S_BIND_STREAM_ID (b, C_BIDI_ID(1))
OP_S_READ_EXPECT (b, "foo", 3)
OP_S_EXPECT_FIN (b)
OP_S_BIND_STREAM_ID (c, C_BIDI_ID(2))
OP_S_READ_EXPECT (c, "foo", 3)
OP_S_EXPECT_FIN (c)
OP_S_BIND_STREAM_ID (d, C_BIDI_ID(3))
OP_S_READ_EXPECT (d, "foo", 3)
OP_S_EXPECT_FIN (d)
OP_S_BIND_STREAM_ID (e, C_BIDI_ID(4))
OP_S_READ_EXPECT (e, "foo", 3)
OP_S_EXPECT_FIN (e)
OP_END
};
/* 13. Many threads accepted on the same client connection (stress test) */
static const struct script_op script_13_child[] = {
OP_BEGIN_REPEAT (10)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "foo", 3)
OP_C_EXPECT_FIN (a)
OP_C_FREE_STREAM (a)
OP_END_REPEAT ()
OP_END
};
static const struct script_op script_13[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_NEW_THREAD (5, script_13_child)
OP_BEGIN_REPEAT (50)
OP_S_NEW_STREAM_BIDI (a, ANY_ID)
OP_S_WRITE (a, "foo", 3)
OP_S_CONCLUDE (a)
OP_S_UNBIND_STREAM_ID (a)
OP_END_REPEAT ()
OP_END
};
/* 14. Many threads initiating on the same client connection (stress test) */
static const struct script_op script_14_child[] = {
OP_BEGIN_REPEAT (10)
OP_C_NEW_STREAM_BIDI (a, ANY_ID)
OP_C_WRITE (a, "foo", 3)
OP_C_CONCLUDE (a)
OP_C_FREE_STREAM (a)
OP_END_REPEAT ()
OP_END
};
static const struct script_op script_14[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_NEW_THREAD (5, script_14_child)
OP_BEGIN_REPEAT (50)
OP_S_ACCEPT_STREAM_WAIT (a)
OP_S_READ_EXPECT (a, "foo", 3)
OP_S_EXPECT_FIN (a)
OP_S_UNBIND_STREAM_ID (a)
OP_END_REPEAT ()
OP_END
};
/* 15. Client sending large number of streams, MAX_STREAMS test */
static const struct script_op script_15[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
/*
* This will cause a protocol violation to be raised by the server if we are
* not handling the stream limit correctly on the TX side.
*/
OP_BEGIN_REPEAT (200)
OP_C_NEW_STREAM_BIDI_EX (a, ANY_ID, SSL_STREAM_FLAG_ADVANCE)
OP_C_WRITE (a, "foo", 3)
OP_C_CONCLUDE (a)
OP_C_FREE_STREAM (a)
OP_END_REPEAT ()
/* Prove the connection is still good. */
OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
OP_S_WRITE (a, "bar", 3)
OP_S_CONCLUDE (a)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "bar", 3)
OP_C_EXPECT_FIN (a)
/*
* Drain the queue of incoming streams. We should be able to get all 200
* even though only 100 can be initiated at a time.
*/
OP_BEGIN_REPEAT (200)
OP_S_ACCEPT_STREAM_WAIT (b)
OP_S_READ_EXPECT (b, "foo", 3)
OP_S_EXPECT_FIN (b)
OP_S_UNBIND_STREAM_ID (b)
OP_END_REPEAT ()
OP_END
};
/* 16. Server sending large number of streams, MAX_STREAMS test */
static const struct script_op script_16[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
/*
* This will cause a protocol violation to be raised by the client if we are
* not handling the stream limit correctly on the TX side.
*/
OP_BEGIN_REPEAT (200)
OP_S_NEW_STREAM_BIDI (a, ANY_ID)
OP_S_WRITE (a, "foo", 3)
OP_S_CONCLUDE (a)
OP_S_UNBIND_STREAM_ID (a)
OP_END_REPEAT ()
/* Prove that the connection is still good. */
OP_C_NEW_STREAM_BIDI (a, ANY_ID)
OP_C_WRITE (a, "bar", 3)
OP_C_CONCLUDE (a)
OP_S_ACCEPT_STREAM_WAIT (b)
OP_S_READ_EXPECT (b, "bar", 3)
OP_S_EXPECT_FIN (b)
/* Drain the queue of incoming streams. */
OP_BEGIN_REPEAT (200)
OP_C_ACCEPT_STREAM_WAIT (b)
OP_C_READ_EXPECT (b, "foo", 3)
OP_C_EXPECT_FIN (b)
OP_C_FREE_STREAM (b)
OP_END_REPEAT ()
OP_END
};
/* 17. Key update test - unlimited */
static const struct script_op script_17[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_CHECK (override_key_update, 1)
OP_BEGIN_REPEAT (200)
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_READ_EXPECT (a, "apple", 5)
/*
* TXKU frequency is bounded by RTT because a previous TXKU needs to be
* acknowledged by the peer first before another one can be begin. By
* waiting this long, we eliminate any such concern and ensure as many key
* updates as possible can occur for the purposes of this test.
*/
OP_CHECK (skip_time_ms, 100)
OP_END_REPEAT ()
/* At least 5 RXKUs detected */
OP_CHECK (check_key_update_ge, 5)
/*
* Prove the connection is still healthy by sending something in both
* directions.
*/
OP_C_WRITE (DEFAULT, "xyzzy", 5)
OP_S_READ_EXPECT (a, "xyzzy", 5)
OP_S_WRITE (a, "plugh", 5)
OP_C_READ_EXPECT (DEFAULT, "plugh", 5)
OP_END
};
/* 18. Key update test - RTT-bounded */
static const struct script_op script_18[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_CHECK (override_key_update, 1)
OP_BEGIN_REPEAT (200)
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_READ_EXPECT (a, "apple", 5)
OP_CHECK (skip_time_ms, 8)
OP_END_REPEAT ()
/*
* This time we simulate far less time passing between writes, so there are
* fewer opportunities to initiate TXKUs. Note that we ask for a TXKU every
* 1 packet above, which is absurd; thus this ensures we only actually
* generate TXKUs when we are allowed to.
*/
OP_CHECK (check_key_update_lt, 240)
/*
* Prove the connection is still healthy by sending something in both
* directions.
*/
OP_C_WRITE (DEFAULT, "xyzzy", 5)
OP_S_READ_EXPECT (a, "xyzzy", 5)
OP_S_WRITE (a, "plugh", 5)
OP_C_READ_EXPECT (DEFAULT, "plugh", 5)
OP_END
};
/* 19. Key update test - artificially triggered */
static const struct script_op script_19[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_C_WRITE (DEFAULT, "orange", 6)
OP_S_READ_EXPECT (a, "orange", 6)
OP_S_WRITE (a, "strawberry", 10)
OP_C_READ_EXPECT (DEFAULT, "strawberry", 10)
OP_CHECK (check_key_update_lt, 1)
OP_CHECK (trigger_key_update, 0)
OP_C_WRITE (DEFAULT, "orange", 6)
OP_S_READ_EXPECT (a, "orange", 6)
OP_S_WRITE (a, "ok", 2)
OP_C_READ_EXPECT (DEFAULT, "ok", 2)
OP_CHECK (check_key_update_ge, 1)
OP_END
};
/* 20. Multiple threads accept stream with socket forcibly closed (error test) */
static int script_20_trigger(struct helper *h, volatile uint64_t *counter)
{
#if defined(OPENSSL_THREADS)
ossl_crypto_mutex_lock(h->misc_m);
++*counter;
ossl_crypto_condvar_broadcast(h->misc_cv);
ossl_crypto_mutex_unlock(h->misc_m);
#endif
return 1;
}
static int script_20_wait(struct helper *h, volatile uint64_t *counter, uint64_t threshold)
{
#if defined(OPENSSL_THREADS)
int stop = 0;
ossl_crypto_mutex_lock(h->misc_m);
while (!stop) {
stop = (*counter >= threshold);
if (stop)
break;
ossl_crypto_condvar_wait(h->misc_cv, h->misc_m);
}
ossl_crypto_mutex_unlock(h->misc_m);
#endif
return 1;
}
static int script_20_trigger1(struct helper *h, struct helper_local *hl)
{
return script_20_trigger(h, &h->scratch0);
}
static int script_20_wait1(struct helper *h, struct helper_local *hl)
{
return script_20_wait(h, &h->scratch0, hl->check_op->arg2);
}
static int script_20_trigger2(struct helper *h, struct helper_local *hl)
{
return script_20_trigger(h, &h->scratch1);
}
static int script_20_wait2(struct helper *h, struct helper_local *hl)
{
return script_20_wait(h, &h->scratch1, hl->check_op->arg2);
}
static const struct script_op script_20_child[] = {
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "foo", 3)
OP_CHECK (script_20_trigger1, 0)
OP_CHECK (script_20_wait2, 1)
OP_C_READ_FAIL_WAIT (a)
OP_C_EXPECT_SSL_ERR (a, SSL_ERROR_SYSCALL)
OP_EXPECT_ERR_LIB (ERR_LIB_SSL)
OP_EXPECT_ERR_REASON (SSL_R_PROTOCOL_IS_SHUTDOWN)
OP_POP_ERR ()
OP_EXPECT_ERR_LIB (ERR_LIB_SSL)
OP_EXPECT_ERR_REASON (SSL_R_QUIC_NETWORK_ERROR)
OP_C_FREE_STREAM (a)
OP_END
};
static const struct script_op script_20[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_NEW_THREAD (5, script_20_child)
OP_BEGIN_REPEAT (5)
OP_S_NEW_STREAM_BIDI (a, ANY_ID)
OP_S_WRITE (a, "foo", 3)
OP_S_UNBIND_STREAM_ID (a)
OP_END_REPEAT ()
OP_CHECK (script_20_wait1, 5)
OP_C_CLOSE_SOCKET ()
OP_CHECK (script_20_trigger2, 0)
OP_END
};
/* 21. Fault injection - unknown frame in 1-RTT packet */
static int script_21_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[8];
size_t written;
if (h->inject_word0 == 0 || hdr->type != h->inject_word0)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_21[] = {
OP_S_SET_INJECT_PLAIN (script_21_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (QUIC_PKT_TYPE_1RTT, OSSL_QUIC_VLINT_MAX)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 22. Fault injection - non-zero packet header reserved bits */
static int script_22_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
if (h->inject_word0 == 0)
return 1;
hdr->reserved = 1;
return 1;
}
static const struct script_op script_22[] = {
OP_S_SET_INJECT_PLAIN (script_22_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, 0)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_PROTOCOL_VIOLATION,0,0)
OP_END
};
/* 23. Fault injection - empty NEW_TOKEN */
static int script_23_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[16];
size_t written;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_NEW_TOKEN))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, 0)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_23[] = {
OP_S_SET_INJECT_PLAIN (script_23_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, 0)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 24. Fault injection - excess value of MAX_STREAMS_BIDI */
static int script_24_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[16];
size_t written;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, (((uint64_t)1) << 60) + 1)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_24[] = {
OP_S_SET_INJECT_PLAIN (script_24_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_BIDI)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 25. Fault injection - excess value of MAX_STREAMS_UNI */
static const struct script_op script_25[] = {
OP_S_SET_INJECT_PLAIN (script_24_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_UNI)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 26. Fault injection - excess value of STREAMS_BLOCKED_BIDI */
static const struct script_op script_26[] = {
OP_S_SET_INJECT_PLAIN (script_24_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_BIDI)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_LIMIT_ERROR,0,0)
OP_END
};
/* 27. Fault injection - excess value of STREAMS_BLOCKED_UNI */
static const struct script_op script_27[] = {
OP_S_SET_INJECT_PLAIN (script_24_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_UNI)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_LIMIT_ERROR,0,0)
OP_END
};
/* 28. Fault injection - received RESET_STREAM for send-only stream */
static int script_28_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[32];
size_t written;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, /* stream ID */
h->inject_word0 - 1))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, 123))
|| (h->inject_word1 == OSSL_QUIC_FRAME_TYPE_RESET_STREAM
&& !TEST_true(WPACKET_quic_write_vlint(&wpkt, 5)))) /* final size */
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_28[] = {
OP_S_SET_INJECT_PLAIN (script_28_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "orange", 6)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "orange", 6)
OP_C_NEW_STREAM_UNI (b, C_UNI_ID(0))
OP_C_WRITE (b, "apple", 5)
OP_S_BIND_STREAM_ID (b, C_UNI_ID(0))
OP_S_READ_EXPECT (b, "apple", 5)
OP_SET_INJECT_WORD (C_UNI_ID(0) + 1, OSSL_QUIC_FRAME_TYPE_RESET_STREAM)
OP_S_WRITE (a, "fruit", 5)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 29. Fault injection - received RESET_STREAM for nonexistent send-only stream */
static const struct script_op script_29[] = {
OP_S_SET_INJECT_PLAIN (script_28_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "orange", 6)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "orange", 6)
OP_C_NEW_STREAM_UNI (b, C_UNI_ID(0))
OP_C_WRITE (b, "apple", 5)
OP_S_BIND_STREAM_ID (b, C_UNI_ID(0))
OP_S_READ_EXPECT (b, "apple", 5)
OP_SET_INJECT_WORD (C_UNI_ID(1) + 1, OSSL_QUIC_FRAME_TYPE_RESET_STREAM)
OP_S_WRITE (a, "fruit", 5)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 30. Fault injection - received STOP_SENDING for receive-only stream */
static const struct script_op script_30[] = {
OP_S_SET_INJECT_PLAIN (script_28_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (S_UNI_ID(0) + 1, OSSL_QUIC_FRAME_TYPE_STOP_SENDING)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 31. Fault injection - received STOP_SENDING for nonexistent receive-only stream */
static const struct script_op script_31[] = {
OP_S_SET_INJECT_PLAIN (script_28_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (C_UNI_ID(0) + 1, OSSL_QUIC_FRAME_TYPE_STOP_SENDING)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 32. Fault injection - STREAM frame for nonexistent stream */
static int script_32_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[64];
size_t written;
uint64_t type = OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN, offset, flen, i;
if (hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
switch (h->inject_word1) {
default:
return 0;
case 0:
return 1;
case 1:
offset = 0;
flen = 0;
break;
case 2:
offset = (((uint64_t)1)<<62) - 1;
flen = 5;
break;
case 3:
offset = 1 * 1024 * 1024 * 1024; /* 1G */
flen = 5;
break;
case 4:
offset = 0;
flen = 1;
break;
}
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, type))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, /* stream ID */
h->inject_word0 - 1))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, offset))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, flen)))
goto err;
for (i = 0; i < flen; ++i)
if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x42)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_32[] = {
OP_S_SET_INJECT_PLAIN (script_32_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (C_UNI_ID(0) + 1, 1)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 33. Fault injection - STREAM frame with illegal offset */
static const struct script_op script_33[] = {
OP_S_SET_INJECT_PLAIN (script_32_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (C_BIDI_ID(0) + 1, 2)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 34. Fault injection - STREAM frame which exceeds FC */
static const struct script_op script_34[] = {
OP_S_SET_INJECT_PLAIN (script_32_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (C_BIDI_ID(0) + 1, 3)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FLOW_CONTROL_ERROR,0,0)
OP_END
};
/* 35. Fault injection - MAX_STREAM_DATA for receive-only stream */
static const struct script_op script_35[] = {
OP_S_SET_INJECT_PLAIN (script_28_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (S_UNI_ID(0) + 1, OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 36. Fault injection - MAX_STREAM_DATA for nonexistent stream */
static const struct script_op script_36[] = {
OP_S_SET_INJECT_PLAIN (script_28_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (C_BIDI_ID(0) + 1, OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 37. Fault injection - STREAM_DATA_BLOCKED for send-only stream */
static const struct script_op script_37[] = {
OP_S_SET_INJECT_PLAIN (script_28_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_UNI (a, C_UNI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_UNI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_S_NEW_STREAM_UNI (b, S_UNI_ID(0))
OP_SET_INJECT_WORD (C_UNI_ID(0) + 1, OSSL_QUIC_FRAME_TYPE_STREAM_DATA_BLOCKED)
OP_S_WRITE (b, "orange", 5)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 38. Fault injection - STREAM_DATA_BLOCKED for non-existent stream */
static const struct script_op script_38[] = {
OP_S_SET_INJECT_PLAIN (script_28_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_UNI (a, C_UNI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_UNI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (C_BIDI_ID(0) + 1, OSSL_QUIC_FRAME_TYPE_STREAM_DATA_BLOCKED)
OP_S_NEW_STREAM_UNI (b, S_UNI_ID(0))
OP_S_WRITE (b, "orange", 5)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 39. Fault injection - NEW_CONN_ID with zero-len CID */
static int script_39_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[64];
size_t i, written;
uint64_t seq_no = 0, retire_prior_to = 0;
QUIC_CONN_ID new_cid = {0};
QUIC_CHANNEL *ch = ossl_quic_tserver_get_channel(h->s_priv);
if (hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
switch (h->inject_word1) {
case 0:
return 1;
case 1:
new_cid.id_len = 0;
break;
case 2:
new_cid.id_len = 21;
break;
case 3:
new_cid.id_len = 1;
new_cid.id[0] = 0x55;
seq_no = 0;
retire_prior_to = 1;
break;
case 4:
/* Use our actual CID so we don't break connectivity. */
ossl_quic_channel_get_diag_local_cid(ch, &new_cid);
seq_no = 2;
retire_prior_to = 2;
break;
case 5:
/*
* Use a bogus CID which will need to be ignored if connectivity is to
* be continued.
*/
new_cid.id_len = 8;
new_cid.id[0] = 0x55;
seq_no = 1;
retire_prior_to = 1;
break;
}
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, seq_no)) /* seq no */
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, retire_prior_to)) /* retire prior to */
|| !TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id_len))) /* len */
goto err;
for (i = 0; i < new_cid.id_len && i < OSSL_NELEM(new_cid.id); ++i)
if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id[i])))
goto err;
for (; i < new_cid.id_len; ++i)
if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x55)))
goto err;
for (i = 0; i < QUIC_STATELESS_RESET_TOKEN_LEN; ++i)
if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x42)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_39[] = {
OP_S_SET_INJECT_PLAIN (script_39_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (0, 1)
OP_S_WRITE (a, "orange", 5)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 40. Shutdown flush test */
static const unsigned char script_40_data[1024] = "strawberry";
static const struct script_op script_40[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_C_INHIBIT_TICK (1)
OP_C_SET_WRITE_BUF_SIZE (a, 1024 * 100 * 3)
OP_BEGIN_REPEAT (100)
OP_C_WRITE (a, script_40_data, sizeof(script_40_data))
OP_END_REPEAT ()
OP_C_CONCLUDE (a)
OP_C_SHUTDOWN_WAIT (NULL, 0) /* disengages tick inhibition */
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_BEGIN_REPEAT (100)
OP_S_READ_EXPECT (a, script_40_data, sizeof(script_40_data))
OP_END_REPEAT ()
OP_S_EXPECT_FIN (a)
OP_C_EXPECT_CONN_CLOSE_INFO(0, 1, 0)
OP_S_EXPECT_CONN_CLOSE_INFO(0, 1, 1)
OP_END
};
/* 41. Fault injection - PATH_CHALLENGE yields PATH_RESPONSE */
static const uint64_t path_challenge = UINT64_C(0xbdeb9451169c83aa);
static int script_41_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[16];
size_t written;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1))
|| !TEST_true(WPACKET_put_bytes_u64(&wpkt, path_challenge)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written))
|| !TEST_size_t_eq(written, 9))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
--h->inject_word0;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static void script_41_trace(int write_p, int version, int content_type,
const void *buf, size_t len, SSL *ssl, void *arg)
{
uint64_t frame_type, frame_data;
int was_minimal;
struct helper *h = arg;
PACKET pkt;
if (version != OSSL_QUIC1_VERSION
|| content_type != SSL3_RT_QUIC_FRAME_FULL
|| len < 1)
return;
if (!TEST_true(PACKET_buf_init(&pkt, buf, len))) {
++h->scratch1;
return;
}
if (!TEST_true(ossl_quic_wire_peek_frame_header(&pkt, &frame_type,
&was_minimal))) {
++h->scratch1;
return;
}
if (frame_type != OSSL_QUIC_FRAME_TYPE_PATH_RESPONSE)
return;
if (!TEST_true(ossl_quic_wire_decode_frame_path_response(&pkt, &frame_data))
|| !TEST_uint64_t_eq(frame_data, path_challenge)) {
++h->scratch1;
return;
}
++h->scratch0;
}
static int script_41_setup(struct helper *h, struct helper_local *hl)
{
ossl_quic_tserver_set_msg_callback(ACQUIRE_S(), script_41_trace, h);
return 1;
}
static int script_41_check(struct helper *h, struct helper_local *hl)
{
/* At least one valid challenge/response echo? */
if (!TEST_uint64_t_gt(h->scratch0, 0))
return 0;
/* No failed tests? */
if (!TEST_uint64_t_eq(h->scratch1, 0))
return 0;
return 1;
}
static const struct script_op script_41[] = {
OP_S_SET_INJECT_PLAIN (script_41_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_CHECK (script_41_setup, 0)
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_PATH_CHALLENGE)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (DEFAULT, "orange", 6)
OP_C_WRITE (DEFAULT, "strawberry", 10)
OP_S_READ_EXPECT (a, "strawberry", 10)
OP_CHECK (script_41_check, 0)
OP_END
};
/* 42. Fault injection - CRYPTO frame with illegal offset */
static int script_42_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
unsigned char frame_buf[64];
size_t written;
WPACKET wpkt;
if (h->inject_word0 == 0)
return 1;
--h->inject_word0;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_CRYPTO))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, 1))
|| !TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x42)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_42[] = {
OP_S_SET_INJECT_PLAIN (script_42_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, (((uint64_t)1) << 62) - 1)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 43. Fault injection - CRYPTO frame exceeding FC */
static const struct script_op script_43[] = {
OP_S_SET_INJECT_PLAIN (script_42_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, 0x100000 /* 1 MiB */)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_CRYPTO_BUFFER_EXCEEDED,0,0)
OP_END
};
/* 44. Fault injection - PADDING */
static int script_44_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[16];
size_t written;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(ossl_quic_wire_encode_padding(&wpkt, 1)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_44[] = {
OP_S_SET_INJECT_PLAIN (script_44_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, 0)
OP_S_WRITE (a, "Strawberry", 10)
OP_C_READ_EXPECT (DEFAULT, "Strawberry", 10)
OP_END
};
/* 45. PING must generate ACK */
static int force_ping(struct helper *h, struct helper_local *hl)
{
QUIC_CHANNEL *ch = ossl_quic_tserver_get_channel(ACQUIRE_S());
h->scratch0 = ossl_quic_channel_get_diag_num_rx_ack(ch);
if (!TEST_true(ossl_quic_tserver_ping(ACQUIRE_S())))
return 0;
return 1;
}
static int wait_incoming_acks_increased(struct helper *h, struct helper_local *hl)
{
QUIC_CHANNEL *ch = ossl_quic_tserver_get_channel(ACQUIRE_S());
uint16_t count;
count = ossl_quic_channel_get_diag_num_rx_ack(ch);
if (count == h->scratch0) {
h->check_spin_again = 1;
return 0;
}
return 1;
}
static const struct script_op script_45[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_BEGIN_REPEAT (2)
OP_CHECK (force_ping, 0)
OP_CHECK (wait_incoming_acks_increased, 0)
OP_END_REPEAT ()
OP_S_WRITE (a, "Strawberry", 10)
OP_C_READ_EXPECT (DEFAULT, "Strawberry", 10)
OP_END
};
/* 46. Fault injection - ACK - malformed initial range */
static int script_46_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[16];
size_t written;
uint64_t type = 0, largest_acked = 0, first_range = 0, range_count = 0;
uint64_t agap = 0, alen = 0;
uint64_t ect0 = 0, ect1 = 0, ecnce = 0;
if (h->inject_word0 == 0)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
type = OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN;
switch (h->inject_word0) {
case 1:
largest_acked = 100;
first_range = 101;
range_count = 0;
break;
case 2:
largest_acked = 100;
first_range = 80;
/* [20..100]; [0..18] */
range_count = 1;
agap = 0;
alen = 19;
break;
case 3:
largest_acked = 100;
first_range = 80;
range_count = 1;
agap = 18;
alen = 1;
break;
case 4:
type = OSSL_QUIC_FRAME_TYPE_ACK_WITH_ECN;
largest_acked = 100;
first_range = 1;
range_count = 0;
break;
case 5:
type = OSSL_QUIC_FRAME_TYPE_ACK_WITH_ECN;
largest_acked = 0;
first_range = 0;
range_count = 0;
ect0 = 0;
ect1 = 50;
ecnce = 200;
break;
}
h->inject_word0 = 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, type))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, largest_acked))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, /*ack_delay=*/0))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, /*ack_range_count=*/range_count))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, /*first_ack_range=*/first_range)))
goto err;
if (range_count > 0)
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, /*range[0].gap=*/agap))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, /*range[0].len=*/alen)))
goto err;
if (type == OSSL_QUIC_FRAME_TYPE_ACK_WITH_ECN)
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, ect0))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, ect1))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, ecnce)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_46[] = {
OP_S_SET_INJECT_PLAIN (script_46_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, 0)
OP_S_WRITE (a, "Strawberry", 10)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 47. Fault injection - ACK - malformed subsequent range */
static const struct script_op script_47[] = {
OP_S_SET_INJECT_PLAIN (script_46_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (2, 0)
OP_S_WRITE (a, "Strawberry", 10)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 48. Fault injection - ACK - malformed subsequent range */
static const struct script_op script_48[] = {
OP_S_SET_INJECT_PLAIN (script_46_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (3, 0)
OP_S_WRITE (a, "Strawberry", 10)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 49. Fault injection - ACK - fictional PN */
static const struct script_op script_49[] = {
OP_S_SET_INJECT_PLAIN (script_46_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (4, 0)
OP_S_WRITE (a, "Strawberry", 10)
OP_C_READ_EXPECT (DEFAULT, "Strawberry", 10)
OP_END
};
/* 50. Fault injection - ACK - duplicate PN */
static const struct script_op script_50[] = {
OP_S_SET_INJECT_PLAIN (script_46_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_BEGIN_REPEAT (2)
OP_SET_INJECT_WORD (5, 0)
OP_S_WRITE (a, "Strawberry", 10)
OP_C_READ_EXPECT (DEFAULT, "Strawberry", 10)
OP_END_REPEAT ()
OP_END
};
/* 51. Fault injection - PATH_RESPONSE is ignored */
static const struct script_op script_51[] = {
OP_S_SET_INJECT_PLAIN (script_41_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_PATH_RESPONSE)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (DEFAULT, "orange", 6)
OP_C_WRITE (DEFAULT, "Strawberry", 10)
OP_S_READ_EXPECT (a, "Strawberry", 10)
OP_END
};
/* 52. Fault injection - ignore BLOCKED frames with bogus values */
static int script_52_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
unsigned char frame_buf[64];
size_t written;
WPACKET wpkt;
uint64_t type = h->inject_word1;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
--h->inject_word0;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, type)))
goto err;
if (type == OSSL_QUIC_FRAME_TYPE_STREAM_DATA_BLOCKED)
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, C_BIDI_ID(0))))
goto err;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, 0xFFFFFF)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_52[] = {
OP_S_SET_INJECT_PLAIN (script_52_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_DATA_BLOCKED)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (DEFAULT, "orange", 6)
OP_C_WRITE (DEFAULT, "Strawberry", 10)
OP_S_READ_EXPECT (a, "Strawberry", 10)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_STREAM_DATA_BLOCKED)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (DEFAULT, "orange", 6)
OP_C_WRITE (DEFAULT, "Strawberry", 10)
OP_S_READ_EXPECT (a, "Strawberry", 10)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_UNI)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (DEFAULT, "orange", 6)
OP_C_WRITE (DEFAULT, "Strawberry", 10)
OP_S_READ_EXPECT (a, "Strawberry", 10)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_BIDI)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (DEFAULT, "orange", 6)
OP_C_WRITE (DEFAULT, "Strawberry", 10)
OP_S_READ_EXPECT (a, "Strawberry", 10)
OP_END
};
/* 53. Fault injection - excess CRYPTO buffer size */
static int script_53_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
size_t written;
WPACKET wpkt;
uint64_t offset = 0, data_len = 100;
unsigned char *frame_buf = NULL;
size_t frame_len, i;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
h->inject_word0 = 0;
switch (h->inject_word1) {
case 0:
/*
* Far out offset which will not have been reached during handshake.
* This will not be delivered to the QUIC_TLS instance since it will be
* waiting for in-order delivery of previous bytes. This tests our flow
* control on CRYPTO stream buffering.
*/
offset = 100000;
data_len = 1;
break;
}
frame_len = 1 + 8 + 8 + (size_t)data_len;
if (!TEST_ptr(frame_buf = OPENSSL_malloc(frame_len)))
return 0;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf, frame_len, 0)))
goto err;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_CRYPTO))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, offset))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, data_len)))
goto err;
for (i = 0; i < data_len; ++i)
if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x42)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
OPENSSL_free(frame_buf);
return ok;
}
static const struct script_op script_53[] = {
OP_S_SET_INJECT_PLAIN (script_53_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, 0)
OP_S_WRITE (a, "Strawberry", 10)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_CRYPTO_BUFFER_EXCEEDED,0,0)
OP_END
};
/* 54. Fault injection - corrupted crypto stream data */
static int script_54_inject_handshake(struct helper *h,
unsigned char *buf, size_t buf_len)
{
size_t i;
for (i = 0; i < buf_len; ++i)
buf[i] ^= 0xff;
return 1;
}
static const struct script_op script_54[] = {
OP_S_SET_INJECT_HANDSHAKE(script_54_inject_handshake)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT_OR_FAIL()
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_CRYPTO_UNEXPECTED_MESSAGE,0,0)
OP_END
};
/* 55. Fault injection - NEW_CONN_ID with >20 byte CID */
static const struct script_op script_55[] = {
OP_S_SET_INJECT_PLAIN (script_39_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (0, 2)
OP_S_WRITE (a, "orange", 5)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 56. Fault injection - NEW_CONN_ID with seq no < retire prior to */
static const struct script_op script_56[] = {
OP_S_SET_INJECT_PLAIN (script_39_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (0, 3)
OP_S_WRITE (a, "orange", 5)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
/* 57. Fault injection - NEW_CONN_ID with lower seq so ignored */
static const struct script_op script_57[] = {
OP_S_SET_INJECT_PLAIN (script_39_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (0, 4)
OP_S_WRITE (a, "orange", 5)
OP_C_READ_EXPECT (a, "orange", 5)
OP_C_WRITE (a, "Strawberry", 10)
OP_S_READ_EXPECT (a, "Strawberry", 10)
/*
* Now we send a NEW_CONN_ID with a bogus CID. However the sequence number
* is old so it should be ignored and we should still be able to
* communicate.
*/
OP_SET_INJECT_WORD (0, 5)
OP_S_WRITE (a, "raspberry", 9)
OP_C_READ_EXPECT (a, "raspberry", 9)
OP_C_WRITE (a, "peach", 5)
OP_S_READ_EXPECT (a, "peach", 5)
OP_END
};
/* 58. Fault injection - repeated HANDSHAKE_DONE */
static int script_58_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
unsigned char frame_buf[64];
size_t written;
WPACKET wpkt;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (h->inject_word0 == 1) {
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE)))
goto err;
} else {
/* Needless multi-byte encoding */
if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x40))
|| !TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x1E)))
goto err;
}
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_58[] = {
OP_S_SET_INJECT_PLAIN (script_58_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, 0)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (DEFAULT, "orange", 6)
OP_C_WRITE (DEFAULT, "Strawberry", 10)
OP_S_READ_EXPECT (a, "Strawberry", 10)
OP_END
};
/* 59. Fault injection - multi-byte frame encoding */
static const struct script_op script_59[] = {
OP_S_SET_INJECT_PLAIN (script_58_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (2, 0)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_PROTOCOL_VIOLATION,0,0)
OP_END
};
/* 60. Connection close reason truncation */
static char long_reason[2048];
static int init_reason(struct helper *h, struct helper_local *hl)
{
memset(long_reason, '~', sizeof(long_reason));
memcpy(long_reason, "This is a long reason string.", 29);
long_reason[OSSL_NELEM(long_reason) - 1] = '\0';
return 1;
}
static int check_shutdown_reason(struct helper *h, struct helper_local *hl)
{
const QUIC_TERMINATE_CAUSE *tc = ossl_quic_tserver_get_terminate_cause(ACQUIRE_S());
if (tc == NULL) {
h->check_spin_again = 1;
return 0;
}
if (!TEST_size_t_ge(tc->reason_len, 50)
|| !TEST_mem_eq(long_reason, tc->reason_len,
tc->reason, tc->reason_len))
return 0;
return 1;
}
static const struct script_op script_60[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_WRITE (DEFAULT, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_CHECK (init_reason, 0)
OP_C_SHUTDOWN_WAIT (long_reason, 0)
OP_CHECK (check_shutdown_reason, 0)
OP_END
};
/* 61. Fault injection - RESET_STREAM exceeding stream count FC */
static int script_61_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[32];
size_t written;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word0))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, /* stream ID */
h->inject_word1))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, 123))
|| (h->inject_word0 == OSSL_QUIC_FRAME_TYPE_RESET_STREAM
&& !TEST_true(WPACKET_quic_write_vlint(&wpkt, 0)))) /* final size */
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_61[] = {
OP_S_SET_INJECT_PLAIN (script_61_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "orange", 6)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "orange", 6)
OP_SET_INJECT_WORD (OSSL_QUIC_FRAME_TYPE_RESET_STREAM,
S_BIDI_ID(OSSL_QUIC_VLINT_MAX / 4))
OP_S_WRITE (a, "fruit", 5)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_LIMIT_ERROR,0,0)
OP_END
};
/* 62. Fault injection - STOP_SENDING with high ID */
static const struct script_op script_62[] = {
OP_S_SET_INJECT_PLAIN (script_61_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "orange", 6)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "orange", 6)
OP_SET_INJECT_WORD (OSSL_QUIC_FRAME_TYPE_STOP_SENDING,
C_BIDI_ID(OSSL_QUIC_VLINT_MAX / 4))
OP_S_WRITE (a, "fruit", 5)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_STATE_ERROR,0,0)
OP_END
};
/* 63. Fault injection - STREAM frame exceeding stream limit */
static const struct script_op script_63[] = {
OP_S_SET_INJECT_PLAIN (script_32_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (S_BIDI_ID(5000) + 1, 4)
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_STREAM_LIMIT_ERROR,0,0)
OP_END
};
/* 64. Fault injection - STREAM - zero-length no-FIN is accepted */
static const struct script_op script_64[] = {
OP_S_SET_INJECT_PLAIN (script_32_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (S_BIDI_ID(20) + 1, 1)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (a, "orange", 6)
OP_END
};
/* 65. Fault injection - CRYPTO - zero-length is accepted */
static int script_65_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
unsigned char frame_buf[64];
size_t written;
WPACKET wpkt;
if (h->inject_word0 == 0)
return 1;
--h->inject_word0;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_CRYPTO))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, 0))
|| !TEST_true(WPACKET_quic_write_vlint(&wpkt, 0)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_65[] = {
OP_S_SET_INJECT_PLAIN (script_65_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, 0)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (a, "orange", 6)
OP_END
};
/* 66. Fault injection - large MAX_STREAM_DATA */
static int script_66_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
unsigned char *buf, size_t len)
{
int ok = 0;
WPACKET wpkt;
unsigned char frame_buf[64];
size_t written;
if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1)))
goto err;
if (h->inject_word1 == OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA)
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, /* stream ID */
h->inject_word0 - 1)))
goto err;
if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_VLINT_MAX)))
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
goto err;
ok = 1;
err:
if (ok)
WPACKET_finish(&wpkt);
else
WPACKET_cleanup(&wpkt);
return ok;
}
static const struct script_op script_66[] = {
OP_S_SET_INJECT_PLAIN (script_66_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (S_BIDI_ID(0) + 1, OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (a, "orange", 6)
OP_C_WRITE (a, "Strawberry", 10)
OP_S_READ_EXPECT (a, "Strawberry", 10)
OP_END
};
/* 67. Fault injection - large MAX_DATA */
static const struct script_op script_67[] = {
OP_S_SET_INJECT_PLAIN (script_66_inject_plain)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
OP_S_WRITE (a, "apple", 5)
OP_C_ACCEPT_STREAM_WAIT (a)
OP_C_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, OSSL_QUIC_FRAME_TYPE_MAX_DATA)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (a, "orange", 6)
OP_C_WRITE (a, "Strawberry", 10)
OP_S_READ_EXPECT (a, "Strawberry", 10)
OP_END
};
/* 68. Fault injection - Unexpected TLS messages */
static int script_68_inject_handshake(struct helper *h, unsigned char *msg,
size_t msglen)
{
const unsigned char *data;
size_t datalen;
const unsigned char certreq[] = {
SSL3_MT_CERTIFICATE_REQUEST, /* CertificateRequest message */
0, 0, 12, /* Length of message */
1, 1, /* certificate_request_context */
0, 8, /* Extensions block length */
0, TLSEXT_TYPE_signature_algorithms, /* sig_algs extension*/
0, 4, /* 4 bytes of sig algs extension*/
0, 2, /* sigalgs list is 2 bytes long */
8, 4 /* rsa_pss_rsae_sha256 */
};
const unsigned char keyupdate[] = {
SSL3_MT_KEY_UPDATE, /* KeyUpdate message */
0, 0, 1, /* Length of message */
SSL_KEY_UPDATE_NOT_REQUESTED /* update_not_requested */
};
/* We transform the NewSessionTicket message into something else */
switch(h->inject_word0) {
case 0:
return 1;
case 1:
/* CertificateRequest message */
data = certreq;
datalen = sizeof(certreq);
break;
case 2:
/* KeyUpdate message */
data = keyupdate;
datalen = sizeof(keyupdate);
break;
default:
return 0;
}
if (!TEST_true(qtest_fault_resize_message(h->qtf,
datalen - SSL3_HM_HEADER_LENGTH)))
return 0;
memcpy(msg, data, datalen);
return 1;
}
/* Send a CerticateRequest message post-handshake */
static const struct script_op script_68[] = {
OP_S_SET_INJECT_HANDSHAKE(script_68_inject_handshake)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (1, 0)
OP_S_NEW_TICKET ()
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_PROTOCOL_VIOLATION, 0, 0)
OP_END
};
/* 69. Send a TLS KeyUpdate message post-handshake */
static const struct script_op script_69[] = {
OP_S_SET_INJECT_HANDSHAKE(script_68_inject_handshake)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_SET_INJECT_WORD (2, 0)
OP_S_NEW_TICKET ()
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_CRYPTO_ERR_BEGIN
+ SSL_AD_UNEXPECTED_MESSAGE, 0, 0)
OP_END
};
static int set_max_early_data(struct helper *h, struct helper_local *hl)
{
if (!TEST_true(ossl_quic_tserver_set_max_early_data(ACQUIRE_S(),
(uint32_t)hl->check_op->arg2)))
return 0;
return 1;
}
/* 70. Send a TLS NewSessionTicket message with invalid max_early_data */
static const struct script_op script_70[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_CHECK (set_max_early_data, 0xfffffffe)
OP_S_NEW_TICKET ()
OP_S_WRITE (a, "orange", 6)
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_PROTOCOL_VIOLATION, 0, 0)
OP_END
};
/* 71. Send a TLS NewSessionTicket message with valid max_early_data */
static const struct script_op script_71[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_CHECK (set_max_early_data, 0xffffffff)
OP_S_NEW_TICKET ()
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (a, "orange", 6)
OP_END
};
/* 72. Test that APL stops handing out streams after limit reached (bidi) */
static int script_72_check(struct helper *h, struct helper_local *hl)
{
if (!TEST_uint64_t_ge(h->fail_count, 50))
return 0;
return 1;
}
static const struct script_op script_72[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
/*
* Request more streams than a server will initially hand out and test that
* they fail properly.
*/
OP_BEGIN_REPEAT (200)
OP_C_NEW_STREAM_BIDI_EX (a, ANY_ID, ALLOW_FAIL | SSL_STREAM_FLAG_NO_BLOCK)
OP_C_SKIP_IF_UNBOUND (a, 2)
OP_C_WRITE (a, "apple", 5)
OP_C_FREE_STREAM (a)
OP_END_REPEAT ()
OP_CHECK (script_72_check, 0)
OP_END
};
/* 73. Test that APL stops handing out streams after limit reached (uni) */
static const struct script_op script_73[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
/*
* Request more streams than a server will initially hand out and test that
* they fail properly.
*/
OP_BEGIN_REPEAT (200)
OP_C_NEW_STREAM_UNI_EX (a, ANY_ID, ALLOW_FAIL | SSL_STREAM_FLAG_NO_BLOCK)
OP_C_SKIP_IF_UNBOUND (a, 2)
OP_C_WRITE (a, "apple", 5)
OP_C_FREE_STREAM (a)
OP_END_REPEAT ()
OP_CHECK (script_72_check, 0)
OP_END
};
/* 74. Version negotiation: QUIC_VERSION_1 ignored */
static int generate_version_neg(WPACKET *wpkt, uint32_t version)
{
QUIC_PKT_HDR hdr = {0};
hdr.type = QUIC_PKT_TYPE_VERSION_NEG;
hdr.fixed = 1;
hdr.dst_conn_id.id_len = 0;
hdr.src_conn_id.id_len = 8;
memset(hdr.src_conn_id.id, 0x55, 8);
if (!TEST_true(ossl_quic_wire_encode_pkt_hdr(wpkt, 0, &hdr, NULL)))
return 0;
if (!TEST_true(WPACKET_put_bytes_u32(wpkt, version)))
return 0;
return 1;
}
static int server_gen_version_neg(struct helper *h, BIO_MSG *msg, size_t stride)
{
int rc = 0, have_wpkt = 0;
size_t l;
WPACKET wpkt;
BUF_MEM *buf = NULL;
uint32_t version;
switch (h->inject_word0) {
case 0:
return 1;
case 1:
version = QUIC_VERSION_1;
break;
default:
version = 0x5432abcd;
break;
}
if (!TEST_ptr(buf = BUF_MEM_new()))
goto err;
if (!TEST_true(WPACKET_init(&wpkt, buf)))
goto err;
have_wpkt = 1;
generate_version_neg(&wpkt, version);
if (!TEST_true(WPACKET_get_total_written(&wpkt, &l)))
goto err;
if (!TEST_true(qtest_fault_resize_datagram(h->qtf, l)))
return 0;
memcpy(msg->data, buf->data, l);
h->inject_word0 = 0;
rc = 1;
err:
if (have_wpkt)
WPACKET_finish(&wpkt);
BUF_MEM_free(buf);
return rc;
}
static const struct script_op script_74[] = {
OP_S_SET_INJECT_DATAGRAM (server_gen_version_neg)
OP_SET_INJECT_WORD (1, 0)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_END
};
/* 75. Version negotiation: Unknown version causes connection abort */
static const struct script_op script_75[] = {
OP_S_SET_INJECT_DATAGRAM (server_gen_version_neg)
OP_SET_INJECT_WORD (2, 0)
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT_OR_FAIL()
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_CONNECTION_REFUSED,0,0)
OP_END
};
/* 76. Test peer-initiated shutdown wait */
static int script_76_check(struct helper *h, struct helper_local *hl)
{
if (!TEST_false(SSL_shutdown_ex(h->c_conn,
SSL_SHUTDOWN_FLAG_WAIT_PEER
| SSL_SHUTDOWN_FLAG_NO_BLOCK,
NULL, 0)))
return 0;
return 1;
}
static const struct script_op script_76[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
/* Check a WAIT_PEER call doesn't succeed yet. */
OP_CHECK (script_76_check, 0)
OP_S_SHUTDOWN (42)
OP_C_SHUTDOWN_WAIT (NULL, SSL_SHUTDOWN_FLAG_WAIT_PEER)
OP_C_EXPECT_CONN_CLOSE_INFO(42, 1, 1)
OP_END
};
/* 77. Ensure default stream popping operates correctly */
static const struct script_op script_77[] = {
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT ()
OP_C_SET_INCOMING_STREAM_POLICY(SSL_INCOMING_STREAM_POLICY_ACCEPT)
OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
OP_S_WRITE (a, "Strawberry", 10)
OP_C_READ_EXPECT (DEFAULT, "Strawberry", 10)
OP_S_NEW_STREAM_BIDI (b, S_BIDI_ID(1))
OP_S_WRITE (b, "xyz", 3)
OP_C_ACCEPT_STREAM_WAIT (b)
OP_C_READ_EXPECT (b, "xyz", 3)
OP_END
};
/* 78. Post-connection session ticket handling */
static size_t new_session_count;
static int on_new_session(SSL *s, SSL_SESSION *sess)
{
++new_session_count;
return 0; /* do not ref session, we aren't keeping it */
}
static int setup_session(struct helper *h, struct helper_local *hl)
{
SSL_CTX_set_session_cache_mode(h->c_ctx, SSL_SESS_CACHE_BOTH);
SSL_CTX_sess_set_new_cb(h->c_ctx, on_new_session);
return 1;
}
static int trigger_late_session_ticket(struct helper *h, struct helper_local *hl)
{
new_session_count = 0;
if (!TEST_true(ossl_quic_tserver_new_ticket(ACQUIRE_S())))
return 0;
return 1;
}
static int check_got_session_ticket(struct helper *h, struct helper_local *hl)
{
if (!TEST_size_t_gt(new_session_count, 0))
return 0;
return 1;
}
static const struct script_op script_78[] = {
OP_C_SET_ALPN ("ossltest")
OP_CHECK (setup_session, 0)
OP_C_CONNECT_WAIT ()
OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_WRITE (a, "apple", 5)
OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_READ_EXPECT (a, "apple", 5)
OP_S_WRITE (a, "orange", 6)
OP_C_READ_EXPECT (a, "orange", 6)
OP_CHECK (trigger_late_session_ticket, 0)
OP_S_WRITE (a, "Strawberry", 10)
OP_C_READ_EXPECT (a, "Strawberry", 10)
OP_CHECK (check_got_session_ticket, 0)
OP_END
};
static const struct script_op *const scripts[] = {
script_1,
script_2,
script_3,
script_4,
script_5,
script_6,
script_7,
script_8,
script_9,
script_10,
script_11,
script_12,
script_13,
script_14,
script_15,
script_16,
script_17,
script_18,
script_19,
script_20,
script_21,
script_22,
script_23,
script_24,
script_25,
script_26,
script_27,
script_28,
script_29,
script_30,
script_31,
script_32,
script_33,
script_34,
script_35,
script_36,
script_37,
script_38,
script_39,
script_40,
script_41,
script_42,
script_43,
script_44,
script_45,
script_46,
script_47,
script_48,
script_49,
script_50,
script_51,
script_52,
script_53,
script_54,
script_55,
script_56,
script_57,
script_58,
script_59,
script_60,
script_61,
script_62,
script_63,
script_64,
script_65,
script_66,
script_67,
script_68,
script_69,
script_70,
script_71,
script_72,
script_73,
script_74,
script_75,
script_76,
script_77,
script_78
};
static int test_script(int idx)
{
int script_idx, free_order, blocking;
char script_name[64];
free_order = idx % 2;
idx /= 2;
blocking = idx % 2;
idx /= 2;
script_idx = idx;
if (blocking && free_order)
return 1; /* don't need to test free_order twice */
#if !defined(OPENSSL_THREADS)
if (blocking) {
TEST_skip("cannot test in blocking mode without threads");
return 1;
}
#endif
snprintf(script_name, sizeof(script_name), "script %d", script_idx + 1);
TEST_info("Running script %d (order=%d, blocking=%d)", script_idx + 1,
free_order, blocking);
return run_script(scripts[script_idx], script_name, free_order, blocking);
}
/* Dynamically generated tests. */
static struct script_op dyn_frame_types_script[] = {
OP_S_SET_INJECT_PLAIN (script_21_inject_plain)
OP_SET_INJECT_WORD (0, 0) /* dynamic */
OP_C_SET_ALPN ("ossltest")
OP_C_CONNECT_WAIT_OR_FAIL()
OP_C_EXPECT_CONN_CLOSE_INFO(QUIC_ERR_FRAME_ENCODING_ERROR,0,0)
OP_END
};
struct forbidden_frame_type {
uint64_t pkt_type, frame_type, expected_err;
};
static const struct forbidden_frame_type forbidden_frame_types[] = {
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_VLINT_MAX, QUIC_ERR_FRAME_ENCODING_ERROR },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_VLINT_MAX, QUIC_ERR_FRAME_ENCODING_ERROR },
{ QUIC_PKT_TYPE_1RTT, OSSL_QUIC_VLINT_MAX, QUIC_ERR_FRAME_ENCODING_ERROR },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_STREAM, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_RESET_STREAM, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_STOP_SENDING, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_NEW_TOKEN, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_MAX_DATA, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_BIDI, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_UNI, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_DATA_BLOCKED, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_STREAM_DATA_BLOCKED, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_BIDI, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_UNI, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_RETIRE_CONN_ID, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_PATH_CHALLENGE, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_PATH_RESPONSE, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_APP, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_INITIAL, OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_STREAM, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_RESET_STREAM, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_STOP_SENDING, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_NEW_TOKEN, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_MAX_DATA, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_BIDI, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_UNI, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_DATA_BLOCKED, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_STREAM_DATA_BLOCKED, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_BIDI, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_UNI, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_RETIRE_CONN_ID, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_PATH_CHALLENGE, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_PATH_RESPONSE, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_APP, QUIC_ERR_PROTOCOL_VIOLATION },
{ QUIC_PKT_TYPE_HANDSHAKE, OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE, QUIC_ERR_PROTOCOL_VIOLATION },
/* Client uses a zero-length CID so this is not allowed. */
{ QUIC_PKT_TYPE_1RTT, OSSL_QUIC_FRAME_TYPE_RETIRE_CONN_ID, QUIC_ERR_PROTOCOL_VIOLATION },
};
static ossl_unused int test_dyn_frame_types(int idx)
{
size_t i;
char script_name[64];
struct script_op *s = dyn_frame_types_script;
for (i = 0; i < OSSL_NELEM(dyn_frame_types_script); ++i)
if (s[i].op == OPK_SET_INJECT_WORD) {
s[i].arg1 = (size_t)forbidden_frame_types[idx].pkt_type;
s[i].arg2 = forbidden_frame_types[idx].frame_type;
} else if (s[i].op == OPK_C_EXPECT_CONN_CLOSE_INFO) {
s[i].arg2 = forbidden_frame_types[idx].expected_err;
}
snprintf(script_name, sizeof(script_name),
"dyn script %d", idx);
return run_script(dyn_frame_types_script, script_name, 0, 0);
}
OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(certfile = test_get_argument(0))
|| !TEST_ptr(keyfile = test_get_argument(1)))
return 0;
ADD_ALL_TESTS(test_dyn_frame_types, OSSL_NELEM(forbidden_frame_types));
ADD_ALL_TESTS(test_script, OSSL_NELEM(scripts) * 2 * 2);
return 1;
}
|
./openssl/test/acvp_test.c | /*
* Copyright 2020-2021 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
*/
/*
* A set of tests demonstrating uses cases for CAVS/ACVP testing.
*
* For examples of testing KDF's, Digests, KeyAgreement & DRBG's refer to
* providers/fips/self_test_kats.c
*/
#include <string.h>
#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_EC is defined */
#include <openssl/core_names.h>
#include <openssl/evp.h>
#include <openssl/ec.h>
#include <openssl/dh.h>
#include <openssl/dsa.h>
#include <openssl/rsa.h>
#include <openssl/param_build.h>
#include <openssl/provider.h>
#include <openssl/self_test.h>
#include "testutil.h"
#include "testutil/output.h"
#include "acvp_test.inc"
#include "internal/nelem.h"
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_CONFIG_FILE,
OPT_TEST_ENUM
} OPTION_CHOICE;
typedef struct st_args {
int enable;
int called;
} SELF_TEST_ARGS;
static OSSL_PROVIDER *prov_null = NULL;
static OSSL_LIB_CTX *libctx = NULL;
static SELF_TEST_ARGS self_test_args = { 0 };
static OSSL_CALLBACK self_test_events;
const OPTIONS *test_get_options(void)
{
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "config", OPT_CONFIG_FILE, '<',
"The configuration file to use for the libctx" },
{ NULL }
};
return test_options;
}
static int pkey_get_bn_bytes(EVP_PKEY *pkey, const char *name,
unsigned char **out, size_t *out_len)
{
unsigned char *buf = NULL;
BIGNUM *bn = NULL;
int sz;
if (!EVP_PKEY_get_bn_param(pkey, name, &bn))
goto err;
sz = BN_num_bytes(bn);
buf = OPENSSL_zalloc(sz);
if (buf == NULL)
goto err;
if (BN_bn2binpad(bn, buf, sz) <= 0)
goto err;
*out_len = sz;
*out = buf;
BN_free(bn);
return 1;
err:
OPENSSL_free(buf);
BN_free(bn);
return 0;
}
static int sig_gen(EVP_PKEY *pkey, OSSL_PARAM *params, const char *digest_name,
const unsigned char *msg, size_t msg_len,
unsigned char **sig_out, size_t *sig_out_len)
{
int ret = 0;
EVP_MD_CTX *md_ctx = NULL;
unsigned char *sig = NULL;
size_t sig_len;
size_t sz = EVP_PKEY_get_size(pkey);
sig_len = sz;
if (!TEST_ptr(sig = OPENSSL_malloc(sz))
|| !TEST_ptr(md_ctx = EVP_MD_CTX_new())
|| !TEST_int_eq(EVP_DigestSignInit_ex(md_ctx, NULL, digest_name, libctx,
NULL, pkey, NULL), 1)
|| !TEST_int_gt(EVP_DigestSign(md_ctx, sig, &sig_len, msg, msg_len), 0))
goto err;
*sig_out = sig;
*sig_out_len = sig_len;
sig = NULL;
ret = 1;
err:
OPENSSL_free(sig);
EVP_MD_CTX_free(md_ctx);
return ret;
}
#ifndef OPENSSL_NO_EC
static int ecdsa_keygen_test(int id)
{
int ret = 0;
EVP_PKEY *pkey = NULL;
unsigned char *priv = NULL;
unsigned char *pubx = NULL, *puby = NULL;
size_t priv_len = 0, pubx_len = 0, puby_len = 0;
const struct ecdsa_keygen_st *tst = &ecdsa_keygen_data[id];
self_test_args.called = 0;
self_test_args.enable = 1;
if (!TEST_ptr(pkey = EVP_PKEY_Q_keygen(libctx, NULL, "EC", tst->curve_name))
|| !TEST_int_ge(self_test_args.called, 3)
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_PRIV_KEY, &priv,
&priv_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_EC_PUB_X, &pubx,
&pubx_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_EC_PUB_Y, &puby,
&puby_len)))
goto err;
test_output_memory("qy", puby, puby_len);
test_output_memory("qx", pubx, pubx_len);
test_output_memory("d", priv, priv_len);
ret = 1;
err:
self_test_args.enable = 0;
self_test_args.called = 0;
OPENSSL_clear_free(priv, priv_len);
OPENSSL_free(pubx);
OPENSSL_free(puby);
EVP_PKEY_free(pkey);
return ret;
}
static int ecdsa_create_pkey(EVP_PKEY **pkey, const char *curve_name,
const unsigned char *pub, size_t pub_len,
int expected)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
OSSL_PARAM_BLD *bld = NULL;
OSSL_PARAM *params = NULL;
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|| (curve_name != NULL
&& !TEST_true(OSSL_PARAM_BLD_push_utf8_string(
bld, OSSL_PKEY_PARAM_GROUP_NAME, curve_name, 0) > 0))
|| !TEST_true(OSSL_PARAM_BLD_push_octet_string(bld,
OSSL_PKEY_PARAM_PUB_KEY,
pub, pub_len) > 0)
|| !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld))
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "EC", NULL))
|| !TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1)
|| !TEST_int_eq(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_PUBLIC_KEY,
params), expected))
goto err;
ret = 1;
err:
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_CTX_free(ctx);
return ret;
}
static int ecdsa_pub_verify_test(int id)
{
const struct ecdsa_pub_verify_st *tst = &ecdsa_pv_data[id];
int ret = 0;
EVP_PKEY_CTX *key_ctx = NULL;
EVP_PKEY *pkey = NULL;
if (!TEST_true(ecdsa_create_pkey(&pkey, tst->curve_name,
tst->pub, tst->pub_len, tst->pass)))
goto err;
if (tst->pass) {
if (!TEST_ptr(key_ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, ""))
|| !TEST_int_eq(EVP_PKEY_public_check(key_ctx), tst->pass))
goto err;
}
ret = 1;
err:
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(key_ctx);
return ret;
}
/* Extract r and s from an ecdsa signature */
static int get_ecdsa_sig_rs_bytes(const unsigned char *sig, size_t sig_len,
unsigned char **r, unsigned char **s,
size_t *rlen, size_t *slen)
{
int ret = 0;
unsigned char *rbuf = NULL, *sbuf = NULL;
size_t r1_len, s1_len;
const BIGNUM *r1, *s1;
ECDSA_SIG *sign = d2i_ECDSA_SIG(NULL, &sig, sig_len);
if (sign == NULL)
return 0;
r1 = ECDSA_SIG_get0_r(sign);
s1 = ECDSA_SIG_get0_s(sign);
if (r1 == NULL || s1 == NULL)
goto err;
r1_len = BN_num_bytes(r1);
s1_len = BN_num_bytes(s1);
rbuf = OPENSSL_zalloc(r1_len);
sbuf = OPENSSL_zalloc(s1_len);
if (rbuf == NULL || sbuf == NULL)
goto err;
if (BN_bn2binpad(r1, rbuf, r1_len) <= 0)
goto err;
if (BN_bn2binpad(s1, sbuf, s1_len) <= 0)
goto err;
*r = rbuf;
*s = sbuf;
*rlen = r1_len;
*slen = s1_len;
ret = 1;
err:
if (ret == 0) {
OPENSSL_free(rbuf);
OPENSSL_free(sbuf);
}
ECDSA_SIG_free(sign);
return ret;
}
static int ecdsa_siggen_test(int id)
{
int ret = 0;
EVP_PKEY *pkey = NULL;
size_t sig_len = 0, rlen = 0, slen = 0;
unsigned char *sig = NULL;
unsigned char *r = NULL, *s = NULL;
const struct ecdsa_siggen_st *tst = &ecdsa_siggen_data[id];
if (!TEST_ptr(pkey = EVP_PKEY_Q_keygen(libctx, NULL, "EC", tst->curve_name)))
goto err;
if (!TEST_true(sig_gen(pkey, NULL, tst->digest_alg, tst->msg, tst->msg_len,
&sig, &sig_len))
|| !TEST_true(get_ecdsa_sig_rs_bytes(sig, sig_len, &r, &s, &rlen, &slen)))
goto err;
test_output_memory("r", r, rlen);
test_output_memory("s", s, slen);
ret = 1;
err:
OPENSSL_free(r);
OPENSSL_free(s);
OPENSSL_free(sig);
EVP_PKEY_free(pkey);
return ret;
}
static int ecdsa_sigver_test(int id)
{
int ret = 0;
EVP_MD_CTX *md_ctx = NULL;
EVP_PKEY *pkey = NULL;
ECDSA_SIG *sign = NULL;
size_t sig_len;
unsigned char *sig = NULL;
BIGNUM *rbn = NULL, *sbn = NULL;
const struct ecdsa_sigver_st *tst = &ecdsa_sigver_data[id];
if (!TEST_true(ecdsa_create_pkey(&pkey, tst->curve_name,
tst->pub, tst->pub_len, 1)))
goto err;
if (!TEST_ptr(sign = ECDSA_SIG_new())
|| !TEST_ptr(rbn = BN_bin2bn(tst->r, tst->r_len, NULL))
|| !TEST_ptr(sbn = BN_bin2bn(tst->s, tst->s_len, NULL))
|| !TEST_true(ECDSA_SIG_set0(sign, rbn, sbn)))
goto err;
rbn = sbn = NULL;
ret = TEST_int_gt((sig_len = i2d_ECDSA_SIG(sign, &sig)), 0)
&& TEST_ptr(md_ctx = EVP_MD_CTX_new())
&& TEST_true(EVP_DigestVerifyInit_ex(md_ctx, NULL, tst->digest_alg,
libctx, NULL, pkey, NULL)
&& TEST_int_eq(EVP_DigestVerify(md_ctx, sig, sig_len,
tst->msg, tst->msg_len), tst->pass));
err:
BN_free(rbn);
BN_free(sbn);
OPENSSL_free(sig);
ECDSA_SIG_free(sign);
EVP_PKEY_free(pkey);
EVP_MD_CTX_free(md_ctx);
return ret;
}
#endif /* OPENSSL_NO_EC */
#ifndef OPENSSL_NO_DSA
static int pkey_get_octet_bytes(EVP_PKEY *pkey, const char *name,
unsigned char **out, size_t *out_len)
{
size_t len = 0;
unsigned char *buf = NULL;
if (!EVP_PKEY_get_octet_string_param(pkey, name, NULL, 0, &len))
goto err;
buf = OPENSSL_zalloc(len);
if (buf == NULL)
goto err;
if (!EVP_PKEY_get_octet_string_param(pkey, name, buf, len, out_len))
goto err;
*out = buf;
return 1;
err:
OPENSSL_free(buf);
return 0;
}
static EVP_PKEY *dsa_paramgen(int L, int N)
{
EVP_PKEY_CTX *paramgen_ctx = NULL;
EVP_PKEY *param_key = NULL;
if (!TEST_ptr(paramgen_ctx = EVP_PKEY_CTX_new_from_name(libctx, "DSA", NULL))
|| !TEST_int_gt(EVP_PKEY_paramgen_init(paramgen_ctx), 0)
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_bits(paramgen_ctx, L))
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_q_bits(paramgen_ctx, N))
|| !TEST_true(EVP_PKEY_paramgen(paramgen_ctx, ¶m_key)))
return NULL;
EVP_PKEY_CTX_free(paramgen_ctx);
return param_key;
}
static EVP_PKEY *dsa_keygen(int L, int N)
{
EVP_PKEY *param_key = NULL, *key = NULL;
EVP_PKEY_CTX *keygen_ctx = NULL;
if (!TEST_ptr(param_key = dsa_paramgen(L, N))
|| !TEST_ptr(keygen_ctx = EVP_PKEY_CTX_new_from_pkey(libctx, param_key,
NULL))
|| !TEST_int_gt(EVP_PKEY_keygen_init(keygen_ctx), 0)
|| !TEST_int_gt(EVP_PKEY_keygen(keygen_ctx, &key), 0))
goto err;
err:
EVP_PKEY_free(param_key);
EVP_PKEY_CTX_free(keygen_ctx);
return key;
}
static int dsa_keygen_test(int id)
{
int ret = 0, i;
EVP_PKEY_CTX *paramgen_ctx = NULL, *keygen_ctx = NULL;
EVP_PKEY *param_key = NULL, *key = NULL;
unsigned char *priv = NULL, *pub = NULL;
size_t priv_len = 0, pub_len = 0;
const struct dsa_paramgen_st *tst = &dsa_keygen_data[id];
if (!TEST_ptr(param_key = dsa_paramgen(tst->L, tst->N))
|| !TEST_ptr(keygen_ctx = EVP_PKEY_CTX_new_from_pkey(libctx, param_key,
NULL))
|| !TEST_int_gt(EVP_PKEY_keygen_init(keygen_ctx), 0))
goto err;
for (i = 0; i < 2; ++i) {
if (!TEST_int_gt(EVP_PKEY_keygen(keygen_ctx, &key), 0)
|| !TEST_true(pkey_get_bn_bytes(key, OSSL_PKEY_PARAM_PRIV_KEY,
&priv, &priv_len))
|| !TEST_true(pkey_get_bn_bytes(key, OSSL_PKEY_PARAM_PUB_KEY,
&pub, &pub_len)))
goto err;
test_output_memory("y", pub, pub_len);
test_output_memory("x", priv, priv_len);
EVP_PKEY_free(key);
OPENSSL_clear_free(priv, priv_len);
OPENSSL_free(pub);
key = NULL;
pub = priv = NULL;
}
ret = 1;
err:
OPENSSL_clear_free(priv, priv_len);
OPENSSL_free(pub);
EVP_PKEY_free(param_key);
EVP_PKEY_free(key);
EVP_PKEY_CTX_free(keygen_ctx);
EVP_PKEY_CTX_free(paramgen_ctx);
return ret;
}
static int dsa_paramgen_test(int id)
{
int ret = 0, counter = 0;
EVP_PKEY_CTX *paramgen_ctx = NULL;
EVP_PKEY *param_key = NULL;
unsigned char *p = NULL, *q = NULL, *seed = NULL;
size_t plen = 0, qlen = 0, seedlen = 0;
const struct dsa_paramgen_st *tst = &dsa_paramgen_data[id];
if (!TEST_ptr(paramgen_ctx = EVP_PKEY_CTX_new_from_name(libctx, "DSA", NULL))
|| !TEST_int_gt(EVP_PKEY_paramgen_init(paramgen_ctx), 0)
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_bits(paramgen_ctx, tst->L))
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_q_bits(paramgen_ctx, tst->N))
|| !TEST_true(EVP_PKEY_paramgen(paramgen_ctx, ¶m_key))
|| !TEST_true(pkey_get_bn_bytes(param_key, OSSL_PKEY_PARAM_FFC_P,
&p, &plen))
|| !TEST_true(pkey_get_bn_bytes(param_key, OSSL_PKEY_PARAM_FFC_Q,
&q, &qlen))
|| !TEST_true(pkey_get_octet_bytes(param_key, OSSL_PKEY_PARAM_FFC_SEED,
&seed, &seedlen))
|| !TEST_true(EVP_PKEY_get_int_param(param_key,
OSSL_PKEY_PARAM_FFC_PCOUNTER,
&counter)))
goto err;
test_output_memory("p", p, plen);
test_output_memory("q", q, qlen);
test_output_memory("domainSeed", seed, seedlen);
test_printf_stderr("%s: %d\n", "counter", counter);
ret = 1;
err:
OPENSSL_free(p);
OPENSSL_free(q);
OPENSSL_free(seed);
EVP_PKEY_free(param_key);
EVP_PKEY_CTX_free(paramgen_ctx);
return ret;
}
static int dsa_create_pkey(EVP_PKEY **pkey,
const unsigned char *p, size_t p_len,
const unsigned char *q, size_t q_len,
const unsigned char *g, size_t g_len,
const unsigned char *seed, size_t seed_len,
int counter,
int validate_pq, int validate_g,
const unsigned char *pub, size_t pub_len,
BN_CTX *bn_ctx)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
OSSL_PARAM_BLD *bld = NULL;
OSSL_PARAM *params = NULL;
BIGNUM *p_bn = NULL, *q_bn = NULL, *g_bn = NULL, *pub_bn = NULL;
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|| !TEST_ptr(p_bn = BN_CTX_get(bn_ctx))
|| !TEST_ptr(BN_bin2bn(p, p_len, p_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_int(bld,
OSSL_PKEY_PARAM_FFC_VALIDATE_PQ,
validate_pq))
|| !TEST_true(OSSL_PARAM_BLD_push_int(bld,
OSSL_PKEY_PARAM_FFC_VALIDATE_G,
validate_g))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_FFC_P, p_bn))
|| !TEST_ptr(q_bn = BN_CTX_get(bn_ctx))
|| !TEST_ptr(BN_bin2bn(q, q_len, q_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_FFC_Q, q_bn)))
goto err;
if (g != NULL) {
if (!TEST_ptr(g_bn = BN_CTX_get(bn_ctx))
|| !TEST_ptr(BN_bin2bn(g, g_len, g_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld,
OSSL_PKEY_PARAM_FFC_G, g_bn)))
goto err;
}
if (seed != NULL) {
if (!TEST_true(OSSL_PARAM_BLD_push_octet_string(bld,
OSSL_PKEY_PARAM_FFC_SEED, seed, seed_len)))
goto err;
}
if (counter != -1) {
if (!TEST_true(OSSL_PARAM_BLD_push_int(bld,
OSSL_PKEY_PARAM_FFC_PCOUNTER,
counter)))
goto err;
}
if (pub != NULL) {
if (!TEST_ptr(pub_bn = BN_CTX_get(bn_ctx))
|| !TEST_ptr(BN_bin2bn(pub, pub_len, pub_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld,
OSSL_PKEY_PARAM_PUB_KEY,
pub_bn)))
goto err;
}
if (!TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld))
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "DSA", NULL))
|| !TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1)
|| !TEST_int_eq(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_PUBLIC_KEY,
params), 1))
goto err;
ret = 1;
err:
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_CTX_free(ctx);
return ret;
}
static int dsa_pqver_test(int id)
{
int ret = 0;
BN_CTX *bn_ctx = NULL;
EVP_PKEY_CTX *key_ctx = NULL;
EVP_PKEY *param_key = NULL;
const struct dsa_pqver_st *tst = &dsa_pqver_data[id];
if (!TEST_ptr(bn_ctx = BN_CTX_new_ex(libctx))
|| !TEST_true(dsa_create_pkey(¶m_key, tst->p, tst->p_len,
tst->q, tst->q_len, NULL, 0,
tst->seed, tst->seed_len, tst->counter,
1, 0,
NULL, 0,
bn_ctx))
|| !TEST_ptr(key_ctx = EVP_PKEY_CTX_new_from_pkey(libctx, param_key,
NULL))
|| !TEST_int_eq(EVP_PKEY_param_check(key_ctx), tst->pass))
goto err;
ret = 1;
err:
BN_CTX_free(bn_ctx);
EVP_PKEY_free(param_key);
EVP_PKEY_CTX_free(key_ctx);
return ret;
}
/* Extract r and s from a dsa signature */
static int get_dsa_sig_rs_bytes(const unsigned char *sig, size_t sig_len,
unsigned char **r, unsigned char **s,
size_t *r_len, size_t *s_len)
{
int ret = 0;
unsigned char *rbuf = NULL, *sbuf = NULL;
size_t r1_len, s1_len;
const BIGNUM *r1, *s1;
DSA_SIG *sign = d2i_DSA_SIG(NULL, &sig, sig_len);
if (sign == NULL)
return 0;
DSA_SIG_get0(sign, &r1, &s1);
if (r1 == NULL || s1 == NULL)
goto err;
r1_len = BN_num_bytes(r1);
s1_len = BN_num_bytes(s1);
rbuf = OPENSSL_zalloc(r1_len);
sbuf = OPENSSL_zalloc(s1_len);
if (rbuf == NULL || sbuf == NULL)
goto err;
if (BN_bn2binpad(r1, rbuf, r1_len) <= 0)
goto err;
if (BN_bn2binpad(s1, sbuf, s1_len) <= 0)
goto err;
*r = rbuf;
*s = sbuf;
*r_len = r1_len;
*s_len = s1_len;
ret = 1;
err:
if (ret == 0) {
OPENSSL_free(rbuf);
OPENSSL_free(sbuf);
}
DSA_SIG_free(sign);
return ret;
}
static int dsa_siggen_test(int id)
{
int ret = 0;
EVP_PKEY *pkey = NULL;
unsigned char *sig = NULL, *r = NULL, *s = NULL;
size_t sig_len = 0, rlen = 0, slen = 0;
const struct dsa_siggen_st *tst = &dsa_siggen_data[id];
if (!TEST_ptr(pkey = dsa_keygen(tst->L, tst->N)))
goto err;
if (!TEST_true(sig_gen(pkey, NULL, tst->digest_alg, tst->msg, tst->msg_len,
&sig, &sig_len))
|| !TEST_true(get_dsa_sig_rs_bytes(sig, sig_len, &r, &s, &rlen, &slen)))
goto err;
test_output_memory("r", r, rlen);
test_output_memory("s", s, slen);
ret = 1;
err:
OPENSSL_free(r);
OPENSSL_free(s);
OPENSSL_free(sig);
EVP_PKEY_free(pkey);
return ret;
}
static int dsa_sigver_test(int id)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
EVP_PKEY *pkey = NULL;
DSA_SIG *sign = NULL;
size_t sig_len;
unsigned char *sig = NULL;
BIGNUM *rbn = NULL, *sbn = NULL;
EVP_MD *md = NULL;
unsigned char digest[EVP_MAX_MD_SIZE];
unsigned int digest_len;
BN_CTX *bn_ctx = NULL;
const struct dsa_sigver_st *tst = &dsa_sigver_data[id];
if (!TEST_ptr(bn_ctx = BN_CTX_new())
|| !TEST_true(dsa_create_pkey(&pkey, tst->p, tst->p_len,
tst->q, tst->q_len, tst->g, tst->g_len,
NULL, 0, 0, 0, 0, tst->pub, tst->pub_len,
bn_ctx)))
goto err;
if (!TEST_ptr(sign = DSA_SIG_new())
|| !TEST_ptr(rbn = BN_bin2bn(tst->r, tst->r_len, NULL))
|| !TEST_ptr(sbn = BN_bin2bn(tst->s, tst->s_len, NULL))
|| !TEST_true(DSA_SIG_set0(sign, rbn, sbn)))
goto err;
rbn = sbn = NULL;
if (!TEST_ptr(md = EVP_MD_fetch(libctx, tst->digest_alg, ""))
|| !TEST_true(EVP_Digest(tst->msg, tst->msg_len,
digest, &digest_len, md, NULL)))
goto err;
if (!TEST_int_gt((sig_len = i2d_DSA_SIG(sign, &sig)), 0)
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, ""))
|| !TEST_int_gt(EVP_PKEY_verify_init(ctx), 0)
|| !TEST_int_eq(EVP_PKEY_verify(ctx, sig, sig_len, digest, digest_len),
tst->pass))
goto err;
ret = 1;
err:
EVP_PKEY_CTX_free(ctx);
OPENSSL_free(sig);
EVP_MD_free(md);
DSA_SIG_free(sign);
EVP_PKEY_free(pkey);
BN_free(rbn);
BN_free(sbn);
BN_CTX_free(bn_ctx);
return ret;
}
#endif /* OPENSSL_NO_DSA */
/* cipher encrypt/decrypt */
static int cipher_enc(const char *alg,
const unsigned char *pt, size_t pt_len,
const unsigned char *key, size_t key_len,
const unsigned char *iv, size_t iv_len,
const unsigned char *ct, size_t ct_len,
int enc)
{
int ret = 0, out_len = 0, len = 0;
EVP_CIPHER_CTX *ctx = NULL;
EVP_CIPHER *cipher = NULL;
unsigned char out[256] = { 0 };
TEST_note("%s : %s", alg, enc ? "encrypt" : "decrypt");
if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new())
|| !TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, alg, ""))
|| !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc))
|| !TEST_true(EVP_CIPHER_CTX_set_padding(ctx, 0))
|| !TEST_true(EVP_CipherUpdate(ctx, out, &len, pt, pt_len))
|| !TEST_true(EVP_CipherFinal_ex(ctx, out + len, &out_len)))
goto err;
out_len += len;
if (!TEST_mem_eq(out, out_len, ct, ct_len))
goto err;
ret = 1;
err:
EVP_CIPHER_free(cipher);
EVP_CIPHER_CTX_free(ctx);
return ret;
}
static int cipher_enc_dec_test(int id)
{
const struct cipher_st *tst = &cipher_enc_data[id];
const int enc = 1;
return TEST_true(cipher_enc(tst->alg, tst->pt, tst->pt_len,
tst->key, tst->key_len,
tst->iv, tst->iv_len,
tst->ct, tst->ct_len, enc))
&& TEST_true(cipher_enc(tst->alg, tst->ct, tst->ct_len,
tst->key, tst->key_len,
tst->iv, tst->iv_len,
tst->pt, tst->pt_len, !enc));
}
static int aes_ccm_enc_dec(const char *alg,
const unsigned char *pt, size_t pt_len,
const unsigned char *key, size_t key_len,
const unsigned char *iv, size_t iv_len,
const unsigned char *aad, size_t aad_len,
const unsigned char *ct, size_t ct_len,
const unsigned char *tag, size_t tag_len,
int enc, int pass)
{
int ret = 0;
EVP_CIPHER_CTX *ctx;
EVP_CIPHER *cipher = NULL;
int out_len, len;
unsigned char out[1024];
TEST_note("%s : %s : expected to %s", alg, enc ? "encrypt" : "decrypt",
pass ? "pass" : "fail");
if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new())
|| !TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, alg, ""))
|| !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, enc))
|| !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, iv_len,
NULL), 0)
|| !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len,
enc ? NULL : (void *)tag), 0)
|| !TEST_true(EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, enc))
|| !TEST_true(EVP_CIPHER_CTX_set_padding(ctx, 0))
|| !TEST_true(EVP_CipherUpdate(ctx, NULL, &len, NULL, pt_len))
|| !TEST_true(EVP_CipherUpdate(ctx, NULL, &len, aad, aad_len))
|| !TEST_int_eq(EVP_CipherUpdate(ctx, out, &len, pt, pt_len), pass))
goto err;
if (!pass) {
ret = 1;
goto err;
}
if (!TEST_true(EVP_CipherFinal_ex(ctx, out + len, &out_len)))
goto err;
if (enc) {
out_len += len;
if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG,
tag_len, out + out_len), 0)
|| !TEST_mem_eq(out, out_len, ct, ct_len)
|| !TEST_mem_eq(out + out_len, tag_len, tag, tag_len))
goto err;
} else {
if (!TEST_mem_eq(out, out_len + len, ct, ct_len))
goto err;
}
ret = 1;
err:
EVP_CIPHER_free(cipher);
EVP_CIPHER_CTX_free(ctx);
return ret;
}
static int aes_ccm_enc_dec_test(int id)
{
const struct cipher_ccm_st *tst = &aes_ccm_enc_data[id];
/* The tag is on the end of the cipher text */
const size_t tag_len = tst->ct_len - tst->pt_len;
const size_t ct_len = tst->ct_len - tag_len;
const unsigned char *tag = tst->ct + ct_len;
const int enc = 1;
const int pass = 1;
if (ct_len < 1)
return 0;
return aes_ccm_enc_dec(tst->alg, tst->pt, tst->pt_len,
tst->key, tst->key_len,
tst->iv, tst->iv_len, tst->aad, tst->aad_len,
tst->ct, ct_len, tag, tag_len, enc, pass)
&& aes_ccm_enc_dec(tst->alg, tst->ct, ct_len,
tst->key, tst->key_len,
tst->iv, tst->iv_len, tst->aad, tst->aad_len,
tst->pt, tst->pt_len, tag, tag_len, !enc, pass)
/* test that it fails if the tag is incorrect */
&& aes_ccm_enc_dec(tst->alg, tst->ct, ct_len,
tst->key, tst->key_len,
tst->iv, tst->iv_len, tst->aad, tst->aad_len,
tst->pt, tst->pt_len,
tag - 1, tag_len, !enc, !pass);
}
static int aes_gcm_enc_dec(const char *alg,
const unsigned char *pt, size_t pt_len,
const unsigned char *key, size_t key_len,
const unsigned char *iv, size_t iv_len,
const unsigned char *aad, size_t aad_len,
const unsigned char *ct, size_t ct_len,
const unsigned char *tag, size_t tag_len,
int enc, int pass)
{
int ret = 0;
EVP_CIPHER_CTX *ctx;
EVP_CIPHER *cipher = NULL;
int out_len, len;
unsigned char out[1024];
TEST_note("%s : %s : expected to %s", alg, enc ? "encrypt" : "decrypt",
pass ? "pass" : "fail");
if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new())
|| !TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, alg, ""))
|| !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, enc))
|| !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, iv_len,
NULL), 0))
goto err;
if (!enc) {
if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len,
(void *)tag), 0))
goto err;
}
/*
* For testing purposes the IV it being set here. In a compliant application
* the IV would be generated internally. A fake entropy source could also
* be used to feed in the random IV bytes (see fake_random.c)
*/
if (!TEST_true(EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, enc))
|| !TEST_true(EVP_CIPHER_CTX_set_padding(ctx, 0))
|| !TEST_true(EVP_CipherUpdate(ctx, NULL, &len, aad, aad_len))
|| !TEST_true(EVP_CipherUpdate(ctx, out, &len, pt, pt_len)))
goto err;
if (!TEST_int_eq(EVP_CipherFinal_ex(ctx, out + len, &out_len), pass))
goto err;
if (!pass) {
ret = 1;
goto err;
}
out_len += len;
if (enc) {
if (!TEST_mem_eq(out, out_len, ct, ct_len)
|| !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG,
tag_len, out + out_len), 0)
|| !TEST_mem_eq(out + out_len, tag_len, tag, tag_len))
goto err;
} else {
if (!TEST_mem_eq(out, out_len, ct, ct_len))
goto err;
}
ret = 1;
err:
EVP_CIPHER_free(cipher);
EVP_CIPHER_CTX_free(ctx);
return ret;
}
static int aes_gcm_enc_dec_test(int id)
{
const struct cipher_gcm_st *tst = &aes_gcm_enc_data[id];
int enc = 1;
int pass = 1;
return aes_gcm_enc_dec(tst->alg, tst->pt, tst->pt_len,
tst->key, tst->key_len,
tst->iv, tst->iv_len, tst->aad, tst->aad_len,
tst->ct, tst->ct_len, tst->tag, tst->tag_len,
enc, pass)
&& aes_gcm_enc_dec(tst->alg, tst->ct, tst->ct_len,
tst->key, tst->key_len,
tst->iv, tst->iv_len, tst->aad, tst->aad_len,
tst->pt, tst->pt_len, tst->tag, tst->tag_len,
!enc, pass)
/* Fail if incorrect tag passed to decrypt */
&& aes_gcm_enc_dec(tst->alg, tst->ct, tst->ct_len,
tst->key, tst->key_len,
tst->iv, tst->iv_len, tst->aad, tst->aad_len,
tst->pt, tst->pt_len, tst->aad, tst->tag_len,
!enc, !pass);
}
#ifndef OPENSSL_NO_DH
static int dh_create_pkey(EVP_PKEY **pkey, const char *group_name,
const unsigned char *pub, size_t pub_len,
const unsigned char *priv, size_t priv_len,
BN_CTX *bn_ctx, int pass)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
OSSL_PARAM_BLD *bld = NULL;
OSSL_PARAM *params = NULL;
BIGNUM *pub_bn = NULL, *priv_bn = NULL;
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|| (group_name != NULL
&& !TEST_int_gt(OSSL_PARAM_BLD_push_utf8_string(
bld, OSSL_PKEY_PARAM_GROUP_NAME,
group_name, 0), 0)))
goto err;
if (pub != NULL) {
if (!TEST_ptr(pub_bn = BN_CTX_get(bn_ctx))
|| !TEST_ptr(BN_bin2bn(pub, pub_len, pub_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PUB_KEY,
pub_bn)))
goto err;
}
if (priv != NULL) {
if (!TEST_ptr(priv_bn = BN_CTX_get(bn_ctx))
|| !TEST_ptr(BN_bin2bn(priv, priv_len, priv_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PRIV_KEY,
priv_bn)))
goto err;
}
if (!TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld))
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "DH", NULL))
|| !TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1)
|| !TEST_int_eq(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_KEYPAIR, params),
pass))
goto err;
ret = 1;
err:
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_CTX_free(ctx);
return ret;
}
static int dh_safe_prime_keygen_test(int id)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
EVP_PKEY *pkey = NULL;
unsigned char *priv = NULL;
unsigned char *pub = NULL;
size_t priv_len = 0, pub_len = 0;
OSSL_PARAM params[2];
const struct dh_safe_prime_keygen_st *tst = &dh_safe_prime_keygen_data[id];
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME,
(char *)tst->group_name, 0);
params[1] = OSSL_PARAM_construct_end();
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "DH", NULL))
|| !TEST_int_gt(EVP_PKEY_keygen_init(ctx), 0)
|| !TEST_true(EVP_PKEY_CTX_set_params(ctx, params))
|| !TEST_int_gt(EVP_PKEY_keygen(ctx, &pkey), 0)
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_PRIV_KEY,
&priv, &priv_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_PUB_KEY,
&pub, &pub_len)))
goto err;
test_output_memory("x", priv, priv_len);
test_output_memory("y", pub, pub_len);
ret = 1;
err:
OPENSSL_clear_free(priv, priv_len);
OPENSSL_free(pub);
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(ctx);
return ret;
}
static int dh_safe_prime_keyver_test(int id)
{
int ret = 0;
BN_CTX *bn_ctx = NULL;
EVP_PKEY_CTX *key_ctx = NULL;
EVP_PKEY *pkey = NULL;
const struct dh_safe_prime_keyver_st *tst = &dh_safe_prime_keyver_data[id];
if (!TEST_ptr(bn_ctx = BN_CTX_new_ex(libctx))
|| !TEST_true(dh_create_pkey(&pkey, tst->group_name,
tst->pub, tst->pub_len,
tst->priv, tst->priv_len, bn_ctx, 1))
|| !TEST_ptr(key_ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, ""))
|| !TEST_int_eq(EVP_PKEY_check(key_ctx), tst->pass))
goto err;
ret = 1;
err:
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(key_ctx);
BN_CTX_free(bn_ctx);
return ret;
}
#endif /* OPENSSL_NO_DH */
static int rsa_create_pkey(EVP_PKEY **pkey,
const unsigned char *n, size_t n_len,
const unsigned char *e, size_t e_len,
const unsigned char *d, size_t d_len,
BN_CTX *bn_ctx)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
OSSL_PARAM_BLD *bld = NULL;
OSSL_PARAM *params = NULL;
BIGNUM *e_bn = NULL, *d_bn = NULL, *n_bn = NULL;
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|| !TEST_ptr(n_bn = BN_CTX_get(bn_ctx))
|| !TEST_ptr(BN_bin2bn(n, n_len, n_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_N, n_bn)))
goto err;
if (e != NULL) {
if (!TEST_ptr(e_bn = BN_CTX_get(bn_ctx))
|| !TEST_ptr(BN_bin2bn(e, e_len, e_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_E,
e_bn)))
goto err;
}
if (d != NULL) {
if (!TEST_ptr(d_bn = BN_CTX_get(bn_ctx))
|| !TEST_ptr(BN_bin2bn(d, d_len, d_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_D,
d_bn)))
goto err;
}
if (!TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld))
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA", NULL))
|| !TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1)
|| !TEST_int_eq(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_KEYPAIR, params),
1))
goto err;
ret = 1;
err:
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_CTX_free(ctx);
return ret;
}
static int rsa_keygen_test(int id)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
EVP_PKEY *pkey = NULL;
BIGNUM *e_bn = NULL;
BIGNUM *xp1_bn = NULL, *xp2_bn = NULL, *xp_bn = NULL;
BIGNUM *xq1_bn = NULL, *xq2_bn = NULL, *xq_bn = NULL;
unsigned char *n = NULL, *d = NULL;
unsigned char *p = NULL, *p1 = NULL, *p2 = NULL;
unsigned char *q = NULL, *q1 = NULL, *q2 = NULL;
size_t n_len = 0, d_len = 0;
size_t p_len = 0, p1_len = 0, p2_len = 0;
size_t q_len = 0, q1_len = 0, q2_len = 0;
OSSL_PARAM_BLD *bld = NULL;
OSSL_PARAM *params = NULL;
const struct rsa_keygen_st *tst = &rsa_keygen_data[id];
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|| !TEST_ptr(xp1_bn = BN_bin2bn(tst->xp1, tst->xp1_len, NULL))
|| !TEST_ptr(xp2_bn = BN_bin2bn(tst->xp2, tst->xp2_len, NULL))
|| !TEST_ptr(xp_bn = BN_bin2bn(tst->xp, tst->xp_len, NULL))
|| !TEST_ptr(xq1_bn = BN_bin2bn(tst->xq1, tst->xq1_len, NULL))
|| !TEST_ptr(xq2_bn = BN_bin2bn(tst->xq2, tst->xq2_len, NULL))
|| !TEST_ptr(xq_bn = BN_bin2bn(tst->xq, tst->xq_len, NULL))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_TEST_XP1,
xp1_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_TEST_XP2,
xp2_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_TEST_XP,
xp_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_TEST_XQ1,
xq1_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_TEST_XQ2,
xq2_bn))
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_TEST_XQ,
xq_bn))
|| !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)))
goto err;
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA", NULL))
|| !TEST_ptr(e_bn = BN_bin2bn(tst->e, tst->e_len, NULL))
|| !TEST_int_gt(EVP_PKEY_keygen_init(ctx), 0)
|| !TEST_int_gt(EVP_PKEY_CTX_set_params(ctx, params), 0)
|| !TEST_int_gt(EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, tst->mod), 0)
|| !TEST_int_gt(EVP_PKEY_CTX_set1_rsa_keygen_pubexp(ctx, e_bn), 0)
|| !TEST_int_gt(EVP_PKEY_keygen(ctx, &pkey), 0)
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_TEST_P1,
&p1, &p1_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_TEST_P2,
&p2, &p2_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_TEST_Q1,
&q1, &q1_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_TEST_Q2,
&q2, &q2_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_FACTOR1,
&p, &p_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_FACTOR2,
&q, &q_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_N,
&n, &n_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_D,
&d, &d_len)))
goto err;
if (!TEST_mem_eq(tst->p1, tst->p1_len, p1, p1_len)
|| !TEST_mem_eq(tst->p2, tst->p2_len, p2, p2_len)
|| !TEST_mem_eq(tst->p, tst->p_len, p, p_len)
|| !TEST_mem_eq(tst->q1, tst->q1_len, q1, q1_len)
|| !TEST_mem_eq(tst->q2, tst->q2_len, q2, q2_len)
|| !TEST_mem_eq(tst->q, tst->q_len, q, q_len)
|| !TEST_mem_eq(tst->n, tst->n_len, n, n_len)
|| !TEST_mem_eq(tst->d, tst->d_len, d, d_len))
goto err;
test_output_memory("p1", p1, p1_len);
test_output_memory("p2", p2, p2_len);
test_output_memory("p", p, p_len);
test_output_memory("q1", q1, q1_len);
test_output_memory("q2", q2, q2_len);
test_output_memory("q", q, q_len);
test_output_memory("n", n, n_len);
test_output_memory("d", d, d_len);
ret = 1;
err:
BN_free(xp1_bn);
BN_free(xp2_bn);
BN_free(xp_bn);
BN_free(xq1_bn);
BN_free(xq2_bn);
BN_free(xq_bn);
BN_free(e_bn);
OPENSSL_free(p1);
OPENSSL_free(p2);
OPENSSL_free(q1);
OPENSSL_free(q2);
OPENSSL_free(p);
OPENSSL_free(q);
OPENSSL_free(n);
OPENSSL_free(d);
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(ctx);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
return ret;
}
static int rsa_siggen_test(int id)
{
int ret = 0;
EVP_PKEY *pkey = NULL;
unsigned char *sig = NULL, *n = NULL, *e = NULL;
size_t sig_len = 0, n_len = 0, e_len = 0;
OSSL_PARAM params[4], *p;
const struct rsa_siggen_st *tst = &rsa_siggen_data[id];
int salt_len = tst->pss_salt_len;
TEST_note("RSA %s signature generation", tst->sig_pad_mode);
p = params;
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_SIGNATURE_PARAM_PAD_MODE,
(char *)tst->sig_pad_mode, 0);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST,
(char *)tst->digest_alg, 0);
if (salt_len >= 0)
*p++ = OSSL_PARAM_construct_int(OSSL_SIGNATURE_PARAM_PSS_SALTLEN,
&salt_len);
*p++ = OSSL_PARAM_construct_end();
if (!TEST_ptr(pkey = EVP_PKEY_Q_keygen(libctx, NULL, "RSA", tst->mod))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_N, &n, &n_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_E, &e, &e_len))
|| !TEST_true(sig_gen(pkey, params, tst->digest_alg,
tst->msg, tst->msg_len,
&sig, &sig_len)))
goto err;
test_output_memory("n", n, n_len);
test_output_memory("e", e, e_len);
test_output_memory("sig", sig, sig_len);
ret = 1;
err:
OPENSSL_free(n);
OPENSSL_free(e);
OPENSSL_free(sig);
EVP_PKEY_free(pkey);
return ret;
}
static int rsa_sigver_test(int id)
{
int ret = 0;
EVP_PKEY_CTX *pkey_ctx = NULL;
EVP_PKEY *pkey = NULL;
EVP_MD_CTX *md_ctx = NULL;
BN_CTX *bn_ctx = NULL;
OSSL_PARAM params[4], *p;
const struct rsa_sigver_st *tst = &rsa_sigver_data[id];
int salt_len = tst->pss_salt_len;
TEST_note("RSA %s Signature Verify : expected to %s ", tst->sig_pad_mode,
tst->pass == PASS ? "pass" : "fail");
p = params;
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_SIGNATURE_PARAM_PAD_MODE,
(char *)tst->sig_pad_mode, 0);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST,
(char *)tst->digest_alg, 0);
if (salt_len >= 0)
*p++ = OSSL_PARAM_construct_int(OSSL_SIGNATURE_PARAM_PSS_SALTLEN,
&salt_len);
*p++ = OSSL_PARAM_construct_end();
if (!TEST_ptr(bn_ctx = BN_CTX_new())
|| !TEST_true(rsa_create_pkey(&pkey, tst->n, tst->n_len,
tst->e, tst->e_len, NULL, 0, bn_ctx))
|| !TEST_ptr(md_ctx = EVP_MD_CTX_new())
|| !TEST_true(EVP_DigestVerifyInit_ex(md_ctx, &pkey_ctx,
tst->digest_alg, libctx, NULL,
pkey, NULL))
|| !TEST_true(EVP_PKEY_CTX_set_params(pkey_ctx, params))
|| !TEST_int_eq(EVP_DigestVerify(md_ctx, tst->sig, tst->sig_len,
tst->msg, tst->msg_len), tst->pass))
goto err;
ret = 1;
err:
EVP_PKEY_free(pkey);
BN_CTX_free(bn_ctx);
EVP_MD_CTX_free(md_ctx);
return ret;
}
static int rsa_decryption_primitive_test(int id)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
EVP_PKEY *pkey = NULL;
unsigned char pt[2048];
size_t pt_len = sizeof(pt);
unsigned char *n = NULL, *e = NULL;
size_t n_len = 0, e_len = 0;
BN_CTX *bn_ctx = NULL;
const struct rsa_decrypt_prim_st *tst = &rsa_decrypt_prim_data[id];
if (!TEST_ptr(pkey = EVP_PKEY_Q_keygen(libctx, NULL, "RSA", 2048))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_N, &n, &n_len))
|| !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_E, &e, &e_len))
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, ""))
|| !TEST_int_gt(EVP_PKEY_decrypt_init(ctx), 0)
|| !TEST_int_gt(EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_NO_PADDING), 0))
goto err;
test_output_memory("n", n, n_len);
test_output_memory("e", e, e_len);
if (EVP_PKEY_decrypt(ctx, pt, &pt_len, tst->ct, tst->ct_len) <= 0)
TEST_note("Decryption Failed");
else
test_output_memory("pt", pt, pt_len);
ret = 1;
err:
OPENSSL_free(n);
OPENSSL_free(e);
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(pkey);
BN_CTX_free(bn_ctx);
return ret;
}
static int self_test_events(const OSSL_PARAM params[], void *varg)
{
SELF_TEST_ARGS *args = varg;
const OSSL_PARAM *p = NULL;
const char *phase = NULL, *type = NULL, *desc = NULL;
int ret = 0;
if (!args->enable)
return 1;
args->called++;
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_PHASE);
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
goto err;
phase = (const char *)p->data;
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_DESC);
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
goto err;
desc = (const char *)p->data;
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_TYPE);
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
goto err;
type = (const char *)p->data;
BIO_printf(bio_out, "%s %s %s\n", phase, desc, type);
ret = 1;
err:
return ret;
}
static int drbg_test(int id)
{
OSSL_PARAM params[3];
EVP_RAND *rand = NULL;
EVP_RAND_CTX *ctx = NULL, *parent = NULL;
unsigned char returned_bits[64];
const size_t returned_bits_len = sizeof(returned_bits);
unsigned int strength = 256;
const struct drbg_st *tst = &drbg_data[id];
int res = 0;
/* Create the seed source */
if (!TEST_ptr(rand = EVP_RAND_fetch(libctx, "TEST-RAND", "-fips"))
|| !TEST_ptr(parent = EVP_RAND_CTX_new(rand, NULL)))
goto err;
EVP_RAND_free(rand);
rand = NULL;
params[0] = OSSL_PARAM_construct_uint(OSSL_RAND_PARAM_STRENGTH, &strength);
params[1] = OSSL_PARAM_construct_end();
if (!TEST_true(EVP_RAND_CTX_set_params(parent, params)))
goto err;
/* Get the DRBG */
if (!TEST_ptr(rand = EVP_RAND_fetch(libctx, tst->drbg_name, ""))
|| !TEST_ptr(ctx = EVP_RAND_CTX_new(rand, parent)))
goto err;
/* Set the DRBG up */
params[0] = OSSL_PARAM_construct_int(OSSL_DRBG_PARAM_USE_DF,
(int *)&tst->use_df);
params[1] = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_CIPHER,
(char *)tst->cipher, 0);
params[2] = OSSL_PARAM_construct_end();
if (!TEST_true(EVP_RAND_CTX_set_params(ctx, params)))
goto err;
/* Feed in the entropy and nonce */
params[0] = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_ENTROPY,
(void *)tst->entropy_input,
tst->entropy_input_len);
params[1] = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_NONCE,
(void *)tst->nonce,
tst->nonce_len);
params[2] = OSSL_PARAM_construct_end();
if (!TEST_true(EVP_RAND_CTX_set_params(parent, params)))
goto err;
/*
* Run the test
* A NULL personalisation string defaults to the built in so something
* non-NULL is needed if there is no personalisation string
*/
if (!TEST_true(EVP_RAND_instantiate(ctx, 0, 0, (void *)"", 0, NULL))
|| !TEST_true(EVP_RAND_generate(ctx, returned_bits, returned_bits_len,
0, 0, NULL, 0))
|| !TEST_true(EVP_RAND_generate(ctx, returned_bits, returned_bits_len,
0, 0, NULL, 0)))
goto err;
test_output_memory("returned bits", returned_bits, returned_bits_len);
/* Clean up */
if (!TEST_true(EVP_RAND_uninstantiate(ctx))
|| !TEST_true(EVP_RAND_uninstantiate(parent)))
goto err;
/* Verify the output */
if (!TEST_mem_eq(returned_bits, returned_bits_len,
tst->returned_bits, tst->returned_bits_len))
goto err;
res = 1;
err:
EVP_RAND_CTX_free(ctx);
/* Coverity is confused by the upref/free in EVP_RAND_CTX_new() subdue it */
/* coverity[pass_freed_arg] */
EVP_RAND_CTX_free(parent);
EVP_RAND_free(rand);
return res;
}
static int aes_cfb1_bits_test(void)
{
int ret = 0;
EVP_CIPHER *cipher = NULL;
EVP_CIPHER_CTX *ctx = NULL;
unsigned char out[16] = { 0 };
int outlen;
const OSSL_PARAM *params, *p;
static const unsigned char key[] = {
0x12, 0x22, 0x58, 0x2F, 0x1C, 0x1A, 0x8A, 0x88,
0x30, 0xFC, 0x18, 0xB7, 0x24, 0x89, 0x7F, 0xC0
};
static const unsigned char iv[] = {
0x05, 0x28, 0xB5, 0x2B, 0x58, 0x27, 0x63, 0x5C,
0x81, 0x86, 0xD3, 0x63, 0x60, 0xB0, 0xAA, 0x2B
};
static const unsigned char pt[] = {
0xB4
};
static const unsigned char expected[] = {
0x6C
};
if (!TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, "AES-128-CFB1", "fips=yes")))
goto err;
if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new()))
goto err;
if (!TEST_int_gt(EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 1), 0))
goto err;
if (!TEST_ptr(params = EVP_CIPHER_CTX_settable_params(ctx))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params,
OSSL_CIPHER_PARAM_USE_BITS)))
goto err;
EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS);
if (!TEST_int_gt(EVP_CipherUpdate(ctx, out, &outlen, pt, 7), 0))
goto err;
if (!TEST_int_eq(outlen, 7))
goto err;
if (!TEST_mem_eq(out, (outlen + 7) / 8, expected, sizeof(expected)))
goto err;
ret = 1;
err:
EVP_CIPHER_free(cipher);
EVP_CIPHER_CTX_free(ctx);
return ret;
}
int setup_tests(void)
{
char *config_file = NULL;
OPTION_CHOICE o;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_CONFIG_FILE:
config_file = opt_arg();
break;
case OPT_TEST_CASES:
break;
default:
case OPT_ERR:
return 0;
}
}
if (!test_get_libctx(&libctx, &prov_null, config_file, NULL, NULL))
return 0;
OSSL_SELF_TEST_set_callback(libctx, self_test_events, &self_test_args);
ADD_TEST(aes_cfb1_bits_test);
ADD_ALL_TESTS(cipher_enc_dec_test, OSSL_NELEM(cipher_enc_data));
ADD_ALL_TESTS(aes_ccm_enc_dec_test, OSSL_NELEM(aes_ccm_enc_data));
ADD_ALL_TESTS(aes_gcm_enc_dec_test, OSSL_NELEM(aes_gcm_enc_data));
ADD_ALL_TESTS(rsa_keygen_test, OSSL_NELEM(rsa_keygen_data));
ADD_ALL_TESTS(rsa_siggen_test, OSSL_NELEM(rsa_siggen_data));
ADD_ALL_TESTS(rsa_sigver_test, OSSL_NELEM(rsa_sigver_data));
ADD_ALL_TESTS(rsa_decryption_primitive_test,
OSSL_NELEM(rsa_decrypt_prim_data));
#ifndef OPENSSL_NO_DH
ADD_ALL_TESTS(dh_safe_prime_keygen_test,
OSSL_NELEM(dh_safe_prime_keygen_data));
ADD_ALL_TESTS(dh_safe_prime_keyver_test,
OSSL_NELEM(dh_safe_prime_keyver_data));
#endif /* OPENSSL_NO_DH */
#ifndef OPENSSL_NO_DSA
ADD_ALL_TESTS(dsa_keygen_test, OSSL_NELEM(dsa_keygen_data));
ADD_ALL_TESTS(dsa_paramgen_test, OSSL_NELEM(dsa_paramgen_data));
ADD_ALL_TESTS(dsa_pqver_test, OSSL_NELEM(dsa_pqver_data));
ADD_ALL_TESTS(dsa_siggen_test, OSSL_NELEM(dsa_siggen_data));
ADD_ALL_TESTS(dsa_sigver_test, OSSL_NELEM(dsa_sigver_data));
#endif /* OPENSSL_NO_DSA */
#ifndef OPENSSL_NO_EC
ADD_ALL_TESTS(ecdsa_keygen_test, OSSL_NELEM(ecdsa_keygen_data));
ADD_ALL_TESTS(ecdsa_pub_verify_test, OSSL_NELEM(ecdsa_pv_data));
ADD_ALL_TESTS(ecdsa_siggen_test, OSSL_NELEM(ecdsa_siggen_data));
ADD_ALL_TESTS(ecdsa_sigver_test, OSSL_NELEM(ecdsa_sigver_data));
#endif /* OPENSSL_NO_EC */
ADD_ALL_TESTS(drbg_test, OSSL_NELEM(drbg_data));
return 1;
}
void cleanup_tests(void)
{
OSSL_PROVIDER_unload(prov_null);
OSSL_LIB_CTX_free(libctx);
}
|
./openssl/test/asn1_decode_test.c | /*
* Copyright 2017-2021 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 <string.h>
#include <openssl/rand.h>
#include <openssl/asn1t.h>
#include <openssl/obj_mac.h>
#include "internal/numbers.h"
#include "testutil.h"
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wunused-function"
#endif
#ifdef __clang__
# pragma clang diagnostic ignored "-Wunused-function"
#endif
/* Badly coded ASN.1 INTEGER zero wrapped in a sequence */
static unsigned char t_invalid_zero[] = {
0x30, 0x02, /* SEQUENCE tag + length */
0x02, 0x00 /* INTEGER tag + length */
};
#ifndef OPENSSL_NO_DEPRECATED_3_0
/* LONG case ************************************************************* */
typedef struct {
long test_long;
} ASN1_LONG_DATA;
ASN1_SEQUENCE(ASN1_LONG_DATA) = {
ASN1_EMBED(ASN1_LONG_DATA, test_long, LONG),
} static_ASN1_SEQUENCE_END(ASN1_LONG_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_LONG_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_LONG_DATA)
static int test_long(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_LONG_DATA *dectst =
d2i_ASN1_LONG_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_LONG_DATA_free(dectst);
return 1;
}
#endif
/* INT32 case ************************************************************* */
typedef struct {
int32_t test_int32;
} ASN1_INT32_DATA;
ASN1_SEQUENCE(ASN1_INT32_DATA) = {
ASN1_EMBED(ASN1_INT32_DATA, test_int32, INT32),
} static_ASN1_SEQUENCE_END(ASN1_INT32_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_INT32_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_INT32_DATA)
static int test_int32(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_INT32_DATA *dectst =
d2i_ASN1_INT32_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_INT32_DATA_free(dectst);
return 1;
}
/* UINT32 case ************************************************************* */
typedef struct {
uint32_t test_uint32;
} ASN1_UINT32_DATA;
ASN1_SEQUENCE(ASN1_UINT32_DATA) = {
ASN1_EMBED(ASN1_UINT32_DATA, test_uint32, UINT32),
} static_ASN1_SEQUENCE_END(ASN1_UINT32_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_UINT32_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_UINT32_DATA)
static int test_uint32(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_UINT32_DATA *dectst =
d2i_ASN1_UINT32_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_UINT32_DATA_free(dectst);
return 1;
}
/* INT64 case ************************************************************* */
typedef struct {
int64_t test_int64;
} ASN1_INT64_DATA;
ASN1_SEQUENCE(ASN1_INT64_DATA) = {
ASN1_EMBED(ASN1_INT64_DATA, test_int64, INT64),
} static_ASN1_SEQUENCE_END(ASN1_INT64_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_INT64_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_INT64_DATA)
static int test_int64(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_INT64_DATA *dectst =
d2i_ASN1_INT64_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_INT64_DATA_free(dectst);
return 1;
}
/* UINT64 case ************************************************************* */
typedef struct {
uint64_t test_uint64;
} ASN1_UINT64_DATA;
ASN1_SEQUENCE(ASN1_UINT64_DATA) = {
ASN1_EMBED(ASN1_UINT64_DATA, test_uint64, UINT64),
} static_ASN1_SEQUENCE_END(ASN1_UINT64_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_UINT64_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_UINT64_DATA)
static int test_uint64(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_UINT64_DATA *dectst =
d2i_ASN1_UINT64_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_UINT64_DATA_free(dectst);
return 1;
}
typedef struct {
ASN1_STRING *invalidDirString;
} INVALIDTEMPLATE;
ASN1_SEQUENCE(INVALIDTEMPLATE) = {
/*
* DirectoryString is a CHOICE type so it must use explicit tagging -
* but we deliberately use implicit here, which makes this template invalid.
*/
ASN1_IMP(INVALIDTEMPLATE, invalidDirString, DIRECTORYSTRING, 12)
} static_ASN1_SEQUENCE_END(INVALIDTEMPLATE)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(INVALIDTEMPLATE)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(INVALIDTEMPLATE)
/* Empty sequence for invalid template test */
static unsigned char t_invalid_template[] = {
0x30, 0x03, /* SEQUENCE tag + length */
0x0c, 0x01, 0x41 /* UTF8String, length 1, "A" */
};
static int test_invalid_template(void)
{
const unsigned char *p = t_invalid_template;
INVALIDTEMPLATE *tmp = d2i_INVALIDTEMPLATE(NULL, &p,
sizeof(t_invalid_template));
/* We expect a NULL pointer return */
if (TEST_ptr_null(tmp))
return 1;
INVALIDTEMPLATE_free(tmp);
return 0;
}
static int test_reuse_asn1_object(void)
{
static unsigned char cn_der[] = { 0x06, 0x03, 0x55, 0x04, 0x06 };
static unsigned char oid_der[] = {
0x06, 0x06, 0x2a, 0x03, 0x04, 0x05, 0x06, 0x07
};
int ret = 0;
ASN1_OBJECT *obj;
unsigned char const *p = oid_der;
/* Create an object that owns dynamically allocated 'sn' and 'ln' fields */
if (!TEST_ptr(obj = ASN1_OBJECT_create(NID_undef, cn_der, sizeof(cn_der),
"C", "countryName")))
goto err;
/* reuse obj - this should not leak sn and ln */
if (!TEST_ptr(d2i_ASN1_OBJECT(&obj, &p, sizeof(oid_der))))
goto err;
ret = 1;
err:
ASN1_OBJECT_free(obj);
return ret;
}
int setup_tests(void)
{
#ifndef OPENSSL_NO_DEPRECATED_3_0
ADD_TEST(test_long);
#endif
ADD_TEST(test_int32);
ADD_TEST(test_uint32);
ADD_TEST(test_int64);
ADD_TEST(test_uint64);
ADD_TEST(test_invalid_template);
ADD_TEST(test_reuse_asn1_object);
return 1;
}
|
./openssl/test/ffc_internal_test.c | /*
* Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2019-2020, Oracle and/or its affiliates. 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
*/
/*
* This is an internal test that is intentionally using internal APIs. Some of
* those APIs are deprecated for public use.
*/
#include "internal/deprecated.h"
#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 "testutil.h"
#include "internal/ffc.h"
#include "crypto/security_bits.h"
#ifndef OPENSSL_NO_DSA
static const unsigned char dsa_2048_224_sha224_p[] = {
0x93, 0x57, 0x93, 0x62, 0x1b, 0x9a, 0x10, 0x9b, 0xc1, 0x56, 0x0f, 0x24,
0x71, 0x76, 0x4e, 0xd3, 0xed, 0x78, 0x78, 0x7a, 0xbf, 0x89, 0x71, 0x67,
0x8e, 0x03, 0xd8, 0x5b, 0xcd, 0x22, 0x8f, 0x70, 0x74, 0xff, 0x22, 0x05,
0x07, 0x0c, 0x4c, 0x60, 0xed, 0x41, 0xe1, 0x9e, 0x9c, 0xaa, 0x3e, 0x19,
0x5c, 0x3d, 0x80, 0x58, 0xb2, 0x7f, 0x5f, 0x89, 0xec, 0xb5, 0x19, 0xdb,
0x06, 0x11, 0xe9, 0x78, 0x5c, 0xf9, 0xa0, 0x9e, 0x70, 0x62, 0x14, 0x7b,
0xda, 0x92, 0xbf, 0xb2, 0x6b, 0x01, 0x6f, 0xb8, 0x68, 0x9c, 0x89, 0x36,
0x89, 0x72, 0x79, 0x49, 0x93, 0x3d, 0x14, 0xb2, 0x2d, 0xbb, 0xf0, 0xdf,
0x94, 0x45, 0x0b, 0x5f, 0xf1, 0x75, 0x37, 0xeb, 0x49, 0xb9, 0x2d, 0xce,
0xb7, 0xf4, 0x95, 0x77, 0xc2, 0xe9, 0x39, 0x1c, 0x4e, 0x0c, 0x40, 0x62,
0x33, 0x0a, 0xe6, 0x29, 0x6f, 0xba, 0xef, 0x02, 0xdd, 0x0d, 0xe4, 0x04,
0x01, 0x70, 0x40, 0xb9, 0xc9, 0x7e, 0x2f, 0x10, 0x37, 0xe9, 0xde, 0xb0,
0xf6, 0xeb, 0x71, 0x7f, 0x9c, 0x35, 0x16, 0xf3, 0x0d, 0xc4, 0xe8, 0x02,
0x37, 0x6c, 0xdd, 0xb3, 0x8d, 0x2d, 0x1e, 0x28, 0x13, 0x22, 0x89, 0x40,
0xe5, 0xfa, 0x16, 0x67, 0xd6, 0xda, 0x12, 0xa2, 0x38, 0x83, 0x25, 0xcc,
0x26, 0xc1, 0x27, 0x74, 0xfe, 0xf6, 0x7a, 0xb6, 0xa1, 0xe4, 0xe8, 0xdf,
0x5d, 0xd2, 0x9c, 0x2f, 0xec, 0xea, 0x08, 0xca, 0x48, 0xdb, 0x18, 0x4b,
0x12, 0xee, 0x16, 0x9b, 0xa6, 0x00, 0xa0, 0x18, 0x98, 0x7d, 0xce, 0x6c,
0x6d, 0xf8, 0xfc, 0x95, 0x51, 0x1b, 0x0a, 0x40, 0xb6, 0xfc, 0xe5, 0xe2,
0xb0, 0x26, 0x53, 0x4c, 0xd7, 0xfe, 0xaa, 0x6d, 0xbc, 0xdd, 0xc0, 0x61,
0x65, 0xe4, 0x89, 0x44, 0x18, 0x6f, 0xd5, 0x39, 0xcf, 0x75, 0x6d, 0x29,
0xcc, 0xf8, 0x40, 0xab
};
static const unsigned char dsa_2048_224_sha224_q[] = {
0xf2, 0x5e, 0x4e, 0x9a, 0x15, 0xa8, 0x13, 0xdf, 0xa3, 0x17, 0x90, 0xc6,
0xd6, 0x5e, 0xb1, 0xfb, 0x31, 0xf8, 0xb5, 0xb1, 0x4b, 0xa7, 0x6d, 0xde,
0x57, 0x76, 0x6f, 0x11
};
static const unsigned char dsa_2048_224_sha224_seed[] = {
0xd2, 0xb1, 0x36, 0xd8, 0x5b, 0x8e, 0xa4, 0xb2, 0x6a, 0xab, 0x4e, 0x85,
0x8b, 0x49, 0xf9, 0xdd, 0xe6, 0xa1, 0xcd, 0xad, 0x49, 0x52, 0xe9, 0xb3,
0x36, 0x17, 0x06, 0xcf
};
static const unsigned char dsa_2048_224_sha224_bad_seed[] = {
0xd2, 0xb1, 0x36, 0xd8, 0x5b, 0x8e, 0xa4, 0xb2, 0x6a, 0xab, 0x4e, 0x85,
0x8b, 0x49, 0xf9, 0xdd, 0xe6, 0xa1, 0xcd, 0xad, 0x49, 0x52, 0xe9, 0xb3,
0x36, 0x17, 0x06, 0xd0
};
static int dsa_2048_224_sha224_counter = 2878;
static const unsigned char dsa_3072_256_sha512_p[] = {
0x9a, 0x82, 0x8b, 0x8d, 0xea, 0xd0, 0x56, 0x23, 0x88, 0x2d, 0x5d, 0x41,
0x42, 0x4c, 0x13, 0x5a, 0x15, 0x81, 0x59, 0x02, 0xc5, 0x00, 0x82, 0x28,
0x01, 0xee, 0x8f, 0x99, 0xfd, 0x6a, 0x95, 0xf2, 0x0f, 0xae, 0x34, 0x77,
0x29, 0xcc, 0xc7, 0x50, 0x0e, 0x03, 0xef, 0xb0, 0x4d, 0xe5, 0x10, 0x00,
0xa8, 0x7b, 0xce, 0x8c, 0xc6, 0xb2, 0x01, 0x74, 0x23, 0x1b, 0x7f, 0xe8,
0xf9, 0x71, 0x28, 0x39, 0xcf, 0x18, 0x04, 0xb2, 0x95, 0x61, 0x2d, 0x11,
0x71, 0x6b, 0xdd, 0x0d, 0x0b, 0xf0, 0xe6, 0x97, 0x52, 0x29, 0x9d, 0x45,
0xb1, 0x23, 0xda, 0xb0, 0xd5, 0xcb, 0x51, 0x71, 0x8e, 0x40, 0x9c, 0x97,
0x13, 0xea, 0x1f, 0x4b, 0x32, 0x5d, 0x27, 0x74, 0x81, 0x8d, 0x47, 0x8a,
0x08, 0xce, 0xf4, 0xd1, 0x28, 0xa2, 0x0f, 0x9b, 0x2e, 0xc9, 0xa3, 0x0e,
0x5d, 0xde, 0x47, 0x19, 0x6d, 0x5f, 0x98, 0xe0, 0x8e, 0x7f, 0x60, 0x8f,
0x25, 0xa7, 0xa4, 0xeb, 0xb9, 0xf3, 0x24, 0xa4, 0x9e, 0xc1, 0xbd, 0x14,
0x27, 0x7c, 0x27, 0xc8, 0x4f, 0x5f, 0xed, 0xfd, 0x86, 0xc8, 0xf1, 0xd7,
0x82, 0xe2, 0xeb, 0xe5, 0xd2, 0xbe, 0xb0, 0x65, 0x28, 0xab, 0x99, 0x9e,
0xcd, 0xd5, 0x22, 0xf8, 0x1b, 0x3b, 0x01, 0xe9, 0x20, 0x3d, 0xe4, 0x98,
0x22, 0xfe, 0xfc, 0x09, 0x7e, 0x95, 0x20, 0xda, 0xb6, 0x12, 0x2c, 0x94,
0x5c, 0xea, 0x74, 0x71, 0xbd, 0x19, 0xac, 0x78, 0x43, 0x02, 0x51, 0xb8,
0x5f, 0x06, 0x1d, 0xea, 0xc8, 0xa4, 0x3b, 0xc9, 0x78, 0xa3, 0x2b, 0x09,
0xdc, 0x76, 0x74, 0xc4, 0x23, 0x14, 0x48, 0x2e, 0x84, 0x2b, 0xa3, 0x82,
0xc1, 0xba, 0x0b, 0x39, 0x2a, 0x9f, 0x24, 0x7b, 0xd6, 0xc2, 0xea, 0x5a,
0xb6, 0xbd, 0x15, 0x82, 0x21, 0x85, 0xe0, 0x6b, 0x12, 0x4f, 0x8d, 0x64,
0x75, 0xeb, 0x7e, 0xa1, 0xdb, 0xe0, 0x9d, 0x25, 0xae, 0x3b, 0xe9, 0x9b,
0x21, 0x7f, 0x9a, 0x3d, 0x66, 0xd0, 0x52, 0x1d, 0x39, 0x8b, 0xeb, 0xfc,
0xec, 0xbe, 0x72, 0x20, 0x5a, 0xdf, 0x1b, 0x00, 0xf1, 0x0e, 0xed, 0xc6,
0x78, 0x6f, 0xc9, 0xab, 0xe4, 0xd6, 0x81, 0x8b, 0xcc, 0xf6, 0xd4, 0x6a,
0x31, 0x62, 0x08, 0xd9, 0x38, 0x21, 0x8f, 0xda, 0x9e, 0xb1, 0x2b, 0x9c,
0xc0, 0xbe, 0xf7, 0x9a, 0x43, 0x2d, 0x07, 0x59, 0x46, 0x0e, 0xd5, 0x23,
0x4e, 0xaa, 0x4a, 0x04, 0xc2, 0xde, 0x33, 0xa6, 0x34, 0xba, 0xac, 0x4f,
0x78, 0xd8, 0xca, 0x76, 0xce, 0x5e, 0xd4, 0xf6, 0x85, 0x4c, 0x6a, 0x60,
0x08, 0x5d, 0x0e, 0x34, 0x8b, 0xf2, 0xb6, 0xe3, 0xb7, 0x51, 0xca, 0x43,
0xaa, 0x68, 0x7b, 0x0a, 0x6e, 0xea, 0xce, 0x1e, 0x2c, 0x34, 0x8e, 0x0f,
0xe2, 0xcc, 0x38, 0xf2, 0x9a, 0x98, 0xef, 0xe6, 0x7f, 0xf6, 0x62, 0xbb
};
static const unsigned char dsa_3072_256_sha512_q[] = {
0xc1, 0xdb, 0xc1, 0x21, 0x50, 0x49, 0x63, 0xa3, 0x77, 0x6d, 0x4c, 0x92,
0xed, 0x58, 0x9e, 0x98, 0xea, 0xac, 0x7a, 0x90, 0x13, 0x24, 0xf7, 0xcd,
0xd7, 0xe6, 0xd4, 0x8f, 0xf0, 0x45, 0x4b, 0xf7
};
static const unsigned char dsa_3072_256_sha512_seed[] = {
0x35, 0x24, 0xb5, 0x59, 0xd5, 0x27, 0x58, 0x10, 0xf6, 0xa2, 0x7c, 0x9a,
0x0d, 0xc2, 0x70, 0x8a, 0xb0, 0x41, 0x4a, 0x84, 0x0b, 0xfe, 0x66, 0xf5,
0x3a, 0xbf, 0x4a, 0xa9, 0xcb, 0xfc, 0xa6, 0x22
};
static int dsa_3072_256_sha512_counter = 1604;
static const unsigned char dsa_2048_224_sha256_p[] = {
0xe9, 0x13, 0xbc, 0xf2, 0x14, 0x5d, 0xf9, 0x79, 0xd6, 0x6d, 0xf5, 0xc5,
0xbe, 0x7b, 0x6f, 0x90, 0x63, 0xd0, 0xfd, 0xee, 0x4f, 0xc4, 0x65, 0x83,
0xbf, 0xec, 0xc3, 0x2c, 0x5d, 0x30, 0xc8, 0xa4, 0x3b, 0x2f, 0x3b, 0x29,
0x43, 0x69, 0xfb, 0x6e, 0xa9, 0xa4, 0x07, 0x6c, 0xcd, 0xb0, 0xd2, 0xd9,
0xd3, 0xe6, 0xf4, 0x87, 0x16, 0xb7, 0xe5, 0x06, 0xb9, 0xba, 0xd6, 0x87,
0xbc, 0x01, 0x9e, 0xba, 0xc2, 0xcf, 0x39, 0xb6, 0xec, 0xdc, 0x75, 0x07,
0xc1, 0x39, 0x2d, 0x6a, 0x95, 0x31, 0x97, 0xda, 0x54, 0x20, 0x29, 0xe0,
0x1b, 0xf9, 0x74, 0x65, 0xaa, 0xc1, 0x47, 0xd3, 0x9e, 0xb4, 0x3c, 0x1d,
0xe0, 0xdc, 0x2d, 0x21, 0xab, 0x12, 0x3b, 0xa5, 0x51, 0x1e, 0xc6, 0xbc,
0x6b, 0x4c, 0x22, 0xd1, 0x7c, 0xc6, 0xce, 0xcb, 0x8c, 0x1d, 0x1f, 0xce,
0x1c, 0xe2, 0x75, 0x49, 0x6d, 0x2c, 0xee, 0x7f, 0x5f, 0xb8, 0x74, 0x42,
0x5c, 0x96, 0x77, 0x13, 0xff, 0x80, 0xf3, 0x05, 0xc7, 0xfe, 0x08, 0x3b,
0x25, 0x36, 0x46, 0xa2, 0xc4, 0x26, 0xb4, 0xb0, 0x3b, 0xd5, 0xb2, 0x4c,
0x13, 0x29, 0x0e, 0x47, 0x31, 0x66, 0x7d, 0x78, 0x57, 0xe6, 0xc2, 0xb5,
0x9f, 0x46, 0x17, 0xbc, 0xa9, 0x9a, 0x49, 0x1c, 0x0f, 0x45, 0xe0, 0x88,
0x97, 0xa1, 0x30, 0x7c, 0x42, 0xb7, 0x2c, 0x0a, 0xce, 0xb3, 0xa5, 0x7a,
0x61, 0x8e, 0xab, 0x44, 0xc1, 0xdc, 0x70, 0xe5, 0xda, 0x78, 0x2a, 0xb4,
0xe6, 0x3c, 0xa0, 0x58, 0xda, 0x62, 0x0a, 0xb2, 0xa9, 0x3d, 0xaa, 0x49,
0x7e, 0x7f, 0x9a, 0x19, 0x67, 0xee, 0xd6, 0xe3, 0x67, 0x13, 0xe8, 0x6f,
0x79, 0x50, 0x76, 0xfc, 0xb3, 0x9d, 0x7e, 0x9e, 0x3e, 0x6e, 0x47, 0xb1,
0x11, 0x5e, 0xc8, 0x83, 0x3a, 0x3c, 0xfc, 0x82, 0x5c, 0x9d, 0x34, 0x65,
0x73, 0xb4, 0x56, 0xd5
};
static const unsigned char dsa_2048_224_sha256_q[] = {
0xb0, 0xdf, 0xa1, 0x7b, 0xa4, 0x77, 0x64, 0x0e, 0xb9, 0x28, 0xbb, 0xbc,
0xd4, 0x60, 0x02, 0xaf, 0x21, 0x8c, 0xb0, 0x69, 0x0f, 0x8a, 0x7b, 0xc6,
0x80, 0xcb, 0x0a, 0x45
};
static const unsigned char dsa_2048_224_sha256_g[] = {
0x11, 0x7c, 0x5f, 0xf6, 0x99, 0x44, 0x67, 0x5b, 0x69, 0xa3, 0x83, 0xef,
0xb5, 0x85, 0xa2, 0x19, 0x35, 0x18, 0x2a, 0xf2, 0x58, 0xf4, 0xc9, 0x58,
0x9e, 0xb9, 0xe8, 0x91, 0x17, 0x2f, 0xb0, 0x60, 0x85, 0x95, 0xa6, 0x62,
0x36, 0xd0, 0xff, 0x94, 0xb9, 0xa6, 0x50, 0xad, 0xa6, 0xf6, 0x04, 0x28,
0xc2, 0xc9, 0xb9, 0x75, 0xf3, 0x66, 0xb4, 0xeb, 0xf6, 0xd5, 0x06, 0x13,
0x01, 0x64, 0x82, 0xa9, 0xf1, 0xd5, 0x41, 0xdc, 0xf2, 0x08, 0xfc, 0x2f,
0xc4, 0xa1, 0x21, 0xee, 0x7d, 0xbc, 0xda, 0x5a, 0xa4, 0xa2, 0xb9, 0x68,
0x87, 0x36, 0xba, 0x53, 0x9e, 0x14, 0x4e, 0x76, 0x5c, 0xba, 0x79, 0x3d,
0x0f, 0xe5, 0x99, 0x1c, 0x27, 0xfc, 0xaf, 0x10, 0x63, 0x87, 0x68, 0x0e,
0x3e, 0x6e, 0xaa, 0xf3, 0xdf, 0x76, 0x7e, 0x02, 0x9a, 0x41, 0x96, 0xa1,
0x6c, 0xbb, 0x67, 0xee, 0x0c, 0xad, 0x72, 0x65, 0xf1, 0x70, 0xb0, 0x39,
0x9b, 0x54, 0x5f, 0xd7, 0x6c, 0xc5, 0x9a, 0x90, 0x53, 0x18, 0xde, 0x5e,
0x62, 0x89, 0xb9, 0x2f, 0x66, 0x59, 0x3a, 0x3d, 0x10, 0xeb, 0xa5, 0x99,
0xf6, 0x21, 0x7d, 0xf2, 0x7b, 0x42, 0x15, 0x1c, 0x55, 0x79, 0x15, 0xaa,
0xa4, 0x17, 0x2e, 0x48, 0xc3, 0xa8, 0x36, 0xf5, 0x1a, 0x97, 0xce, 0xbd,
0x72, 0xef, 0x1d, 0x50, 0x5b, 0xb1, 0x60, 0x0a, 0x5c, 0x0b, 0xa6, 0x21,
0x38, 0x28, 0x4e, 0x89, 0x33, 0x1d, 0xb5, 0x7e, 0x5c, 0xf1, 0x6b, 0x2c,
0xbd, 0xad, 0x84, 0xb2, 0x8e, 0x96, 0xe2, 0x30, 0xe7, 0x54, 0xb8, 0xc9,
0x70, 0xcb, 0x10, 0x30, 0x63, 0x90, 0xf4, 0x45, 0x64, 0x93, 0x09, 0x38,
0x6a, 0x47, 0x58, 0x31, 0x04, 0x1a, 0x18, 0x04, 0x1a, 0xe0, 0xd7, 0x0b,
0x3c, 0xbe, 0x2a, 0x9c, 0xec, 0xcc, 0x0d, 0x0c, 0xed, 0xde, 0x54, 0xbc,
0xe6, 0x93, 0x59, 0xfc
};
static int ffc_params_validate_g_unverified_test(void)
{
int ret = 0, res;
FFC_PARAMS params;
BIGNUM *p = NULL, *q = NULL, *g = NULL;
BIGNUM *p1 = NULL, *g1 = NULL;
ossl_ffc_params_init(¶ms);
if (!TEST_ptr(p = BN_bin2bn(dsa_2048_224_sha256_p,
sizeof(dsa_2048_224_sha256_p), NULL)))
goto err;
p1 = p;
if (!TEST_ptr(q = BN_bin2bn(dsa_2048_224_sha256_q,
sizeof(dsa_2048_224_sha256_q), NULL)))
goto err;
if (!TEST_ptr(g = BN_bin2bn(dsa_2048_224_sha256_g,
sizeof(dsa_2048_224_sha256_g), NULL)))
goto err;
g1 = g;
/* Fail if g is NULL */
ossl_ffc_params_set0_pqg(¶ms, p, q, NULL);
p = NULL;
q = NULL;
ossl_ffc_params_set_flags(¶ms, FFC_PARAM_FLAG_VALIDATE_G);
ossl_ffc_set_digest(¶ms, "SHA256", NULL);
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
ossl_ffc_params_set0_pqg(¶ms, p, q, g);
g = NULL;
if (!TEST_true(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
/* incorrect g */
BN_add_word(g1, 1);
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
/* fail if g < 2 */
BN_set_word(g1, 1);
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
BN_copy(g1, p1);
/* Fail if g >= p */
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
ret = 1;
err:
ossl_ffc_params_cleanup(¶ms);
BN_free(p);
BN_free(q);
BN_free(g);
return ret;
}
static int ffc_params_validate_pq_test(void)
{
int ret = 0, res = -1;
FFC_PARAMS params;
BIGNUM *p = NULL, *q = NULL;
ossl_ffc_params_init(¶ms);
if (!TEST_ptr(p = BN_bin2bn(dsa_2048_224_sha224_p,
sizeof(dsa_2048_224_sha224_p),
NULL)))
goto err;
if (!TEST_ptr(q = BN_bin2bn(dsa_2048_224_sha224_q,
sizeof(dsa_2048_224_sha224_q),
NULL)))
goto err;
/* No p */
ossl_ffc_params_set0_pqg(¶ms, NULL, q, NULL);
q = NULL;
ossl_ffc_params_set_flags(¶ms, FFC_PARAM_FLAG_VALIDATE_PQ);
ossl_ffc_set_digest(¶ms, "SHA224", NULL);
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
/* Test valid case */
ossl_ffc_params_set0_pqg(¶ms, p, NULL, NULL);
p = NULL;
ossl_ffc_params_set_validate_params(¶ms, dsa_2048_224_sha224_seed,
sizeof(dsa_2048_224_sha224_seed),
dsa_2048_224_sha224_counter);
if (!TEST_true(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
/* Bad counter - so p is not prime */
ossl_ffc_params_set_validate_params(¶ms, dsa_2048_224_sha224_seed,
sizeof(dsa_2048_224_sha224_seed),
1);
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
/* seedlen smaller than N */
ossl_ffc_params_set_validate_params(¶ms, dsa_2048_224_sha224_seed,
sizeof(dsa_2048_224_sha224_seed)-1,
dsa_2048_224_sha224_counter);
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
/* Provided seed doesn't produce a valid prime q */
ossl_ffc_params_set_validate_params(¶ms, dsa_2048_224_sha224_bad_seed,
sizeof(dsa_2048_224_sha224_bad_seed),
dsa_2048_224_sha224_counter);
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
if (!TEST_ptr(p = BN_bin2bn(dsa_3072_256_sha512_p,
sizeof(dsa_3072_256_sha512_p), NULL)))
goto err;
if (!TEST_ptr(q = BN_bin2bn(dsa_3072_256_sha512_q,
sizeof(dsa_3072_256_sha512_q),
NULL)))
goto err;
ossl_ffc_params_set0_pqg(¶ms, p, q, NULL);
p = q = NULL;
ossl_ffc_set_digest(¶ms, "SHA512", NULL);
ossl_ffc_params_set_validate_params(¶ms, dsa_3072_256_sha512_seed,
sizeof(dsa_3072_256_sha512_seed),
dsa_3072_256_sha512_counter);
/* Q doesn't div P-1 */
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
/* Bad L/N for FIPS DH */
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DH,
&res, NULL)))
goto err;
ret = 1;
err:
ossl_ffc_params_cleanup(¶ms);
BN_free(p);
BN_free(q);
return ret;
}
#endif /* OPENSSL_NO_DSA */
#ifndef OPENSSL_NO_DH
static int ffc_params_gen_test(void)
{
int ret = 0, res = -1;
FFC_PARAMS params;
ossl_ffc_params_init(¶ms);
if (!TEST_true(ossl_ffc_params_FIPS186_4_generate(NULL, ¶ms,
FFC_PARAM_TYPE_DH,
2048, 256, &res, NULL)))
goto err;
if (!TEST_true(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DH,
&res, NULL)))
goto err;
ret = 1;
err:
ossl_ffc_params_cleanup(¶ms);
return ret;
}
static int ffc_params_gen_canonicalg_test(void)
{
int ret = 0, res = -1;
FFC_PARAMS params;
ossl_ffc_params_init(¶ms);
params.gindex = 1;
if (!TEST_true(ossl_ffc_params_FIPS186_4_generate(NULL, ¶ms,
FFC_PARAM_TYPE_DH,
2048, 256, &res, NULL)))
goto err;
if (!TEST_true(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DH,
&res, NULL)))
goto err;
if (!TEST_true(ossl_ffc_params_print(bio_out, ¶ms, 4)))
goto err;
ret = 1;
err:
ossl_ffc_params_cleanup(¶ms);
return ret;
}
static int ffc_params_fips186_2_gen_validate_test(void)
{
int ret = 0, res = -1;
FFC_PARAMS params;
BIGNUM *bn = NULL;
ossl_ffc_params_init(¶ms);
if (!TEST_ptr(bn = BN_new()))
goto err;
if (!TEST_true(ossl_ffc_params_FIPS186_2_generate(NULL, ¶ms,
FFC_PARAM_TYPE_DH,
1024, 160, &res, NULL)))
goto err;
if (!TEST_true(ossl_ffc_params_FIPS186_2_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DH,
&res, NULL)))
goto err;
/*
* The fips186-2 generation should produce a different q compared to
* fips 186-4 given the same seed value. So validation of q will fail.
*/
if (!TEST_false(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL)))
goto err;
/* As the params are randomly generated the error is one of the following */
if (!TEST_true(res == FFC_CHECK_Q_MISMATCH || res == FFC_CHECK_Q_NOT_PRIME))
goto err;
ossl_ffc_params_set_flags(¶ms, FFC_PARAM_FLAG_VALIDATE_G);
/* Partially valid g test will still pass */
if (!TEST_int_eq(ossl_ffc_params_FIPS186_4_validate(NULL, ¶ms,
FFC_PARAM_TYPE_DSA,
&res, NULL), 2))
goto err;
if (!TEST_true(ossl_ffc_params_print(bio_out, ¶ms, 4)))
goto err;
ret = 1;
err:
BN_free(bn);
ossl_ffc_params_cleanup(¶ms);
return ret;
}
extern FFC_PARAMS *ossl_dh_get0_params(DH *dh);
static int ffc_public_validate_test(void)
{
int ret = 0, res = -1;
FFC_PARAMS *params;
BIGNUM *pub = NULL;
DH *dh = NULL;
if (!TEST_ptr(pub = BN_new()))
goto err;
if (!TEST_ptr(dh = DH_new_by_nid(NID_ffdhe2048)))
goto err;
params = ossl_dh_get0_params(dh);
if (!TEST_true(BN_set_word(pub, 1)))
goto err;
BN_set_negative(pub, 1);
/* Check must succeed but set res if public key is negative */
if (!TEST_true(ossl_ffc_validate_public_key(params, pub, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PUBKEY_TOO_SMALL, res))
goto err;
if (!TEST_true(BN_set_word(pub, 0)))
goto err;
/* Check must succeed but set res if public key is zero */
if (!TEST_true(ossl_ffc_validate_public_key(params, pub, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PUBKEY_TOO_SMALL, res))
goto err;
/* Check must succeed but set res if public key is 1 */
if (!TEST_true(ossl_ffc_validate_public_key(params, BN_value_one(), &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PUBKEY_TOO_SMALL, res))
goto err;
if (!TEST_true(BN_add_word(pub, 2)))
goto err;
/* Pass if public key >= 2 */
if (!TEST_true(ossl_ffc_validate_public_key(params, pub, &res)))
goto err;
if (!TEST_ptr(BN_copy(pub, params->p)))
goto err;
/* Check must succeed but set res if public key = p */
if (!TEST_true(ossl_ffc_validate_public_key(params, pub, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PUBKEY_TOO_LARGE, res))
goto err;
if (!TEST_true(BN_sub_word(pub, 1)))
goto err;
/* Check must succeed but set res if public key = p - 1 */
if (!TEST_true(ossl_ffc_validate_public_key(params, pub, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PUBKEY_TOO_LARGE, res))
goto err;
if (!TEST_true(BN_sub_word(pub, 1)))
goto err;
/* Check must succeed but set res if public key is not related to p & q */
if (!TEST_true(ossl_ffc_validate_public_key(params, pub, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PUBKEY_INVALID, res))
goto err;
if (!TEST_true(BN_sub_word(pub, 5)))
goto err;
/* Pass if public key is valid */
if (!TEST_true(ossl_ffc_validate_public_key(params, pub, &res)))
goto err;
/* Check must succeed but set res if params is NULL */
if (!TEST_true(ossl_ffc_validate_public_key(NULL, pub, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PASSED_NULL_PARAM, res))
goto err;
res = -1;
/* Check must succeed but set res if pubkey is NULL */
if (!TEST_true(ossl_ffc_validate_public_key(params, NULL, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PASSED_NULL_PARAM, res))
goto err;
res = -1;
BN_free(params->p);
params->p = NULL;
/* Check must succeed but set res if params->p is NULL */
if (!TEST_true(ossl_ffc_validate_public_key(params, pub, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PASSED_NULL_PARAM, res))
goto err;
ret = 1;
err:
DH_free(dh);
BN_free(pub);
return ret;
}
static int ffc_private_validate_test(void)
{
int ret = 0, res = -1;
FFC_PARAMS *params;
BIGNUM *priv = NULL;
DH *dh = NULL;
if (!TEST_ptr(priv = BN_new()))
goto err;
if (!TEST_ptr(dh = DH_new_by_nid(NID_ffdhe2048)))
goto err;
params = ossl_dh_get0_params(dh);
if (!TEST_true(BN_set_word(priv, 1)))
goto err;
BN_set_negative(priv, 1);
/* Fail if priv key is negative */
if (!TEST_false(ossl_ffc_validate_private_key(params->q, priv, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PRIVKEY_TOO_SMALL, res))
goto err;
if (!TEST_true(BN_set_word(priv, 0)))
goto err;
/* Fail if priv key is zero */
if (!TEST_false(ossl_ffc_validate_private_key(params->q, priv, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PRIVKEY_TOO_SMALL, res))
goto err;
/* Pass if priv key >= 1 */
if (!TEST_true(ossl_ffc_validate_private_key(params->q, BN_value_one(),
&res)))
goto err;
if (!TEST_ptr(BN_copy(priv, params->q)))
goto err;
/* Fail if priv key = upper */
if (!TEST_false(ossl_ffc_validate_private_key(params->q, priv, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PRIVKEY_TOO_LARGE, res))
goto err;
if (!TEST_true(BN_sub_word(priv, 1)))
goto err;
/* Pass if priv key <= upper - 1 */
if (!TEST_true(ossl_ffc_validate_private_key(params->q, priv, &res)))
goto err;
if (!TEST_false(ossl_ffc_validate_private_key(NULL, priv, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PASSED_NULL_PARAM, res))
goto err;
res = -1;
if (!TEST_false(ossl_ffc_validate_private_key(params->q, NULL, &res)))
goto err;
if (!TEST_int_eq(FFC_ERROR_PASSED_NULL_PARAM, res))
goto err;
ret = 1;
err:
DH_free(dh);
BN_free(priv);
return ret;
}
static int ffc_private_gen_test(int index)
{
int ret = 0, res = -1, N;
FFC_PARAMS *params;
BIGNUM *priv = NULL;
DH *dh = NULL;
BN_CTX *ctx = NULL;
if (!TEST_ptr(ctx = BN_CTX_new_ex(NULL)))
goto err;
if (!TEST_ptr(priv = BN_new()))
goto err;
if (!TEST_ptr(dh = DH_new_by_nid(NID_ffdhe2048)))
goto err;
params = ossl_dh_get0_params(dh);
N = BN_num_bits(params->q);
/* Fail since N < 2*s - where s = 112*/
if (!TEST_false(ossl_ffc_generate_private_key(ctx, params, 220, 112, priv)))
goto err;
/* fail since N > len(q) */
if (!TEST_false(ossl_ffc_generate_private_key(ctx, params, N + 1, 112, priv)))
goto err;
/* s must be always set */
if (!TEST_false(ossl_ffc_generate_private_key(ctx, params, N, 0, priv)))
goto err;
/* pass since 2s <= N <= len(q) */
if (!TEST_true(ossl_ffc_generate_private_key(ctx, params, N, 112, priv)))
goto err;
/* pass since N = len(q) */
if (!TEST_true(ossl_ffc_validate_private_key(params->q, priv, &res)))
goto err;
/* pass since 2s <= N < len(q) */
if (!TEST_true(ossl_ffc_generate_private_key(ctx, params, N / 2, 112, priv)))
goto err;
if (!TEST_true(ossl_ffc_validate_private_key(params->q, priv, &res)))
goto err;
/* N is ignored in this case */
if (!TEST_true(ossl_ffc_generate_private_key(ctx, params, 0,
ossl_ifc_ffc_compute_security_bits(BN_num_bits(params->p)),
priv)))
goto err;
if (!TEST_int_le(BN_num_bits(priv), 225))
goto err;
if (!TEST_true(ossl_ffc_validate_private_key(params->q, priv, &res)))
goto err;
ret = 1;
err:
DH_free(dh);
BN_free(priv);
BN_CTX_free(ctx);
return ret;
}
static int ffc_params_copy_test(void)
{
int ret = 0;
DH *dh = NULL;
FFC_PARAMS *params, copy;
ossl_ffc_params_init(©);
if (!TEST_ptr(dh = DH_new_by_nid(NID_ffdhe3072)))
goto err;
params = ossl_dh_get0_params(dh);
if (!TEST_int_eq(params->keylength, 275))
goto err;
if (!TEST_true(ossl_ffc_params_copy(©, params)))
goto err;
if (!TEST_int_eq(copy.keylength, 275))
goto err;
if (!TEST_true(ossl_ffc_params_cmp(©, params, 0)))
goto err;
ret = 1;
err:
ossl_ffc_params_cleanup(©);
DH_free(dh);
return ret;
}
#endif /* OPENSSL_NO_DH */
int setup_tests(void)
{
#ifndef OPENSSL_NO_DSA
ADD_TEST(ffc_params_validate_pq_test);
ADD_TEST(ffc_params_validate_g_unverified_test);
#endif /* OPENSSL_NO_DSA */
#ifndef OPENSSL_NO_DH
ADD_TEST(ffc_params_gen_test);
ADD_TEST(ffc_params_gen_canonicalg_test);
ADD_TEST(ffc_params_fips186_2_gen_validate_test);
ADD_TEST(ffc_public_validate_test);
ADD_TEST(ffc_private_validate_test);
ADD_ALL_TESTS(ffc_private_gen_test, 10);
ADD_TEST(ffc_params_copy_test);
#endif /* OPENSSL_NO_DH */
return 1;
}
|
./openssl/test/evp_libctx_test.c | /*
* Copyright 2020-2022 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
*/
/*
* These tests are setup to load null into the default library context.
* Any tests are expected to use the created 'libctx' to find algorithms.
* The framework runs the tests twice using the 'default' provider or
* 'fips' provider as inputs.
*/
/*
* DSA/DH low level APIs are deprecated for public use, but still ok for
* internal use.
*/
#include "internal/deprecated.h"
#include <assert.h>
#include <openssl/evp.h>
#include <openssl/provider.h>
#include <openssl/dsa.h>
#include <openssl/dh.h>
#include <openssl/safestack.h>
#include <openssl/core_dispatch.h>
#include <openssl/core_names.h>
#include <openssl/x509.h>
#include <openssl/encoder.h>
#include "testutil.h"
#include "internal/nelem.h"
#include "crypto/bn_dh.h" /* _bignum_ffdhe2048_p */
static OSSL_LIB_CTX *libctx = NULL;
static OSSL_PROVIDER *nullprov = NULL;
static OSSL_PROVIDER *libprov = NULL;
static STACK_OF(OPENSSL_STRING) *cipher_names = NULL;
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_CONFIG_FILE,
OPT_PROVIDER_NAME,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "config", OPT_CONFIG_FILE, '<',
"The configuration file to use for the libctx" },
{ "provider", OPT_PROVIDER_NAME, 's',
"The provider to load (The default value is 'default')" },
{ NULL }
};
return test_options;
}
#ifndef OPENSSL_NO_DH
static const char *getname(int id)
{
const char *name[] = {"p", "q", "g" };
if (id >= 0 && id < 3)
return name[id];
return "?";
}
#endif
/*
* We're using some DH specific values in this test, so we skip compilation if
* we're in a no-dh build.
*/
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DH)
static int test_dsa_param_keygen(int tstid)
{
int ret = 0;
int expected;
EVP_PKEY_CTX *gen_ctx = NULL;
EVP_PKEY *pkey_parm = NULL;
EVP_PKEY *pkey = NULL, *dup_pk = NULL;
DSA *dsa = NULL;
int pind, qind, gind;
BIGNUM *p = NULL, *q = NULL, *g = NULL;
/*
* Just grab some fixed dh p, q, g values for testing,
* these 'safe primes' should not be used normally for dsa *.
*/
static const BIGNUM *bn[] = {
&ossl_bignum_dh2048_256_p, &ossl_bignum_dh2048_256_q,
&ossl_bignum_dh2048_256_g
};
/*
* These tests are using bad values for p, q, g by reusing the values.
* A value of 0 uses p, 1 uses q and 2 uses g.
* There are 27 different combinations, with only the 1 valid combination.
*/
pind = tstid / 9;
qind = (tstid / 3) % 3;
gind = tstid % 3;
expected = (pind == 0 && qind == 1 && gind == 2);
TEST_note("Testing with (p, q, g) = (%s, %s, %s)\n", getname(pind),
getname(qind), getname(gind));
if (!TEST_ptr(pkey_parm = EVP_PKEY_new())
|| !TEST_ptr(dsa = DSA_new())
|| !TEST_ptr(p = BN_dup(bn[pind]))
|| !TEST_ptr(q = BN_dup(bn[qind]))
|| !TEST_ptr(g = BN_dup(bn[gind]))
|| !TEST_true(DSA_set0_pqg(dsa, p, q, g)))
goto err;
p = q = g = NULL;
if (!TEST_true(EVP_PKEY_assign_DSA(pkey_parm, dsa)))
goto err;
dsa = NULL;
if (!TEST_ptr(gen_ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey_parm, NULL))
|| !TEST_int_gt(EVP_PKEY_keygen_init(gen_ctx), 0)
|| !TEST_int_eq(EVP_PKEY_keygen(gen_ctx, &pkey), expected))
goto err;
if (expected) {
if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pkey))
|| !TEST_int_eq(EVP_PKEY_eq(pkey, dup_pk), 1))
goto err;
}
ret = 1;
err:
EVP_PKEY_free(pkey);
EVP_PKEY_free(dup_pk);
EVP_PKEY_CTX_free(gen_ctx);
EVP_PKEY_free(pkey_parm);
DSA_free(dsa);
BN_free(g);
BN_free(q);
BN_free(p);
return ret;
}
#endif /* OPENSSL_NO_DSA */
#ifndef OPENSSL_NO_DH
static int do_dh_param_keygen(int tstid, const BIGNUM **bn)
{
int ret = 0;
int expected;
EVP_PKEY_CTX *gen_ctx = NULL;
EVP_PKEY *pkey_parm = NULL;
EVP_PKEY *pkey = NULL, *dup_pk = NULL;
DH *dh = NULL;
int pind, qind, gind;
BIGNUM *p = NULL, *q = NULL, *g = NULL;
/*
* These tests are using bad values for p, q, g by reusing the values.
* A value of 0 uses p, 1 uses q and 2 uses g.
* There are 27 different combinations, with only the 1 valid combination.
*/
pind = tstid / 9;
qind = (tstid / 3) % 3;
gind = tstid % 3;
expected = (pind == 0 && qind == 1 && gind == 2);
TEST_note("Testing with (p, q, g) = (%s, %s, %s)", getname(pind),
getname(qind), getname(gind));
if (!TEST_ptr(pkey_parm = EVP_PKEY_new())
|| !TEST_ptr(dh = DH_new())
|| !TEST_ptr(p = BN_dup(bn[pind]))
|| !TEST_ptr(q = BN_dup(bn[qind]))
|| !TEST_ptr(g = BN_dup(bn[gind]))
|| !TEST_true(DH_set0_pqg(dh, p, q, g)))
goto err;
p = q = g = NULL;
if (!TEST_true(EVP_PKEY_assign_DH(pkey_parm, dh)))
goto err;
dh = NULL;
if (!TEST_ptr(gen_ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey_parm, NULL))
|| !TEST_int_gt(EVP_PKEY_keygen_init(gen_ctx), 0)
|| !TEST_int_eq(EVP_PKEY_keygen(gen_ctx, &pkey), expected))
goto err;
if (expected) {
if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pkey))
|| !TEST_int_eq(EVP_PKEY_eq(pkey, dup_pk), 1))
goto err;
}
ret = 1;
err:
EVP_PKEY_free(pkey);
EVP_PKEY_free(dup_pk);
EVP_PKEY_CTX_free(gen_ctx);
EVP_PKEY_free(pkey_parm);
DH_free(dh);
BN_free(g);
BN_free(q);
BN_free(p);
return ret;
}
/*
* Note that we get the fips186-4 path being run for most of these cases since
* the internal code will detect that the p, q, g does not match a safe prime
* group (Except for when tstid = 5, which sets the correct p, q, g)
*/
static int test_dh_safeprime_param_keygen(int tstid)
{
static const BIGNUM *bn[] = {
&ossl_bignum_ffdhe2048_p, &ossl_bignum_ffdhe2048_q,
&ossl_bignum_const_2
};
return do_dh_param_keygen(tstid, bn);
}
static int dhx_cert_load(void)
{
int ret = 0;
X509 *cert = NULL;
BIO *bio = NULL;
static const unsigned char dhx_cert[] = {
0x30,0x82,0x03,0xff,0x30,0x82,0x02,0xe7,0xa0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0xdb,0xf5,0x4d,0x22,0xa0,0x7a,0x67,0xa6,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,
0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x44,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,
0x04,0x06,0x13,0x02,0x55,0x4b,0x31,0x16,0x30,0x14,0x06,0x03,0x55,0x04,0x0a,0x0c,
0x0d,0x4f,0x70,0x65,0x6e,0x53,0x53,0x4c,0x20,0x47,0x72,0x6f,0x75,0x70,0x31,0x1d,
0x30,0x1b,0x06,0x03,0x55,0x04,0x03,0x0c,0x14,0x54,0x65,0x73,0x74,0x20,0x53,0x2f,
0x4d,0x49,0x4d,0x45,0x20,0x52,0x53,0x41,0x20,0x52,0x6f,0x6f,0x74,0x30,0x1e,0x17,
0x0d,0x31,0x33,0x30,0x38,0x30,0x32,0x31,0x34,0x34,0x39,0x32,0x39,0x5a,0x17,0x0d,
0x32,0x33,0x30,0x36,0x31,0x31,0x31,0x34,0x34,0x39,0x32,0x39,0x5a,0x30,0x44,0x31,
0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x4b,0x31,0x16,0x30,0x14,
0x06,0x03,0x55,0x04,0x0a,0x0c,0x0d,0x4f,0x70,0x65,0x6e,0x53,0x53,0x4c,0x20,0x47,
0x72,0x6f,0x75,0x70,0x31,0x1d,0x30,0x1b,0x06,0x03,0x55,0x04,0x03,0x0c,0x14,0x54,
0x65,0x73,0x74,0x20,0x53,0x2f,0x4d,0x49,0x4d,0x45,0x20,0x45,0x45,0x20,0x44,0x48,
0x20,0x23,0x31,0x30,0x82,0x01,0xb6,0x30,0x82,0x01,0x2b,0x06,0x07,0x2a,0x86,0x48,
0xce,0x3e,0x02,0x01,0x30,0x82,0x01,0x1e,0x02,0x81,0x81,0x00,0xd4,0x0c,0x4a,0x0c,
0x04,0x72,0x71,0x19,0xdf,0x59,0x19,0xc5,0xaf,0x44,0x7f,0xca,0x8e,0x2b,0xf0,0x09,
0xf5,0xd3,0x25,0xb1,0x73,0x16,0x55,0x89,0xdf,0xfd,0x07,0xaf,0x19,0xd3,0x7f,0xd0,
0x07,0xa2,0xfe,0x3f,0x5a,0xf1,0x01,0xc6,0xf8,0x2b,0xef,0x4e,0x6d,0x03,0x38,0x42,
0xa1,0x37,0xd4,0x14,0xb4,0x00,0x4a,0xb1,0x86,0x5a,0x83,0xce,0xb9,0x08,0x0e,0xc1,
0x99,0x27,0x47,0x8d,0x0b,0x85,0xa8,0x82,0xed,0xcc,0x0d,0xb9,0xb0,0x32,0x7e,0xdf,
0xe8,0xe4,0xf6,0xf6,0xec,0xb3,0xee,0x7a,0x11,0x34,0x65,0x97,0xfc,0x1a,0xb0,0x95,
0x4b,0x19,0xb9,0xa6,0x1c,0xd9,0x01,0x32,0xf7,0x35,0x7c,0x2d,0x5d,0xfe,0xc1,0x85,
0x70,0x49,0xf8,0xcc,0x99,0xd0,0xbe,0xf1,0x5a,0x78,0xc8,0x03,0x02,0x81,0x80,0x69,
0x00,0xfd,0x66,0xf2,0xfc,0x15,0x8b,0x09,0xb8,0xdc,0x4d,0xea,0xaa,0x79,0x55,0xf9,
0xdf,0x46,0xa6,0x2f,0xca,0x2d,0x8f,0x59,0x2a,0xad,0x44,0xa3,0xc6,0x18,0x2f,0x95,
0xb6,0x16,0x20,0xe3,0xd3,0xd1,0x8f,0x03,0xce,0x71,0x7c,0xef,0x3a,0xc7,0x44,0x39,
0x0e,0xe2,0x1f,0xd8,0xd3,0x89,0x2b,0xe7,0x51,0xdc,0x12,0x48,0x4c,0x18,0x4d,0x99,
0x12,0x06,0xe4,0x17,0x02,0x03,0x8c,0x24,0x05,0x8e,0xa6,0x85,0xf2,0x69,0x1b,0xe1,
0x6a,0xdc,0xe2,0x04,0x3a,0x01,0x9d,0x64,0xbe,0xfe,0x45,0xf9,0x44,0x18,0x71,0xbd,
0x2d,0x3e,0x7a,0x6f,0x72,0x7d,0x1a,0x80,0x42,0x57,0xae,0x18,0x6f,0x91,0xd6,0x61,
0x03,0x8a,0x1c,0x89,0x73,0xc7,0x56,0x41,0x03,0xd3,0xf8,0xed,0x65,0xe2,0x85,0x02,
0x15,0x00,0x89,0x94,0xab,0x10,0x67,0x45,0x41,0xad,0x63,0xc6,0x71,0x40,0x8d,0x6b,
0x9e,0x19,0x5b,0xa4,0xc7,0xf5,0x03,0x81,0x84,0x00,0x02,0x81,0x80,0x2f,0x5b,0xde,
0x72,0x02,0x36,0x6b,0x00,0x5e,0x24,0x7f,0x14,0x2c,0x18,0x52,0x42,0x97,0x4b,0xdb,
0x6e,0x15,0x50,0x3c,0x45,0x3e,0x25,0xf3,0xb7,0xc5,0x6e,0xe5,0x52,0xe7,0xc4,0xfb,
0xf4,0xa5,0xf0,0x39,0x12,0x7f,0xbc,0x54,0x1c,0x93,0xb9,0x5e,0xee,0xe9,0x14,0xb0,
0xdf,0xfe,0xfc,0x36,0xe4,0xf2,0xaf,0xfb,0x13,0xc8,0xdf,0x18,0x94,0x1d,0x40,0xb9,
0x71,0xdd,0x4c,0x9c,0xa7,0x03,0x52,0x02,0xb5,0xed,0x71,0x80,0x3e,0x23,0xda,0x28,
0xe5,0xab,0xe7,0x6f,0xf2,0x0a,0x0e,0x00,0x5b,0x7d,0xc6,0x4b,0xd7,0xc7,0xb2,0xc3,
0xba,0x62,0x7f,0x70,0x28,0xa0,0x9d,0x71,0x13,0x70,0xd1,0x9f,0x32,0x2f,0x3e,0xd2,
0xcd,0x1b,0xa4,0xc6,0x72,0xa0,0x74,0x5d,0x71,0xef,0x03,0x43,0x6e,0xa3,0x60,0x30,
0x5e,0x30,0x0c,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x02,0x30,0x00,0x30,
0x0e,0x06,0x03,0x55,0x1d,0x0f,0x01,0x01,0xff,0x04,0x04,0x03,0x02,0x05,0xe0,0x30,
0x1d,0x06,0x03,0x55,0x1d,0x0e,0x04,0x16,0x04,0x14,0x0b,0x5a,0x4d,0x5f,0x7d,0x25,
0xc7,0xf2,0x9d,0xc1,0xaa,0xb7,0x63,0x82,0x2f,0xfa,0x8f,0x32,0xe7,0xc0,0x30,0x1f,
0x06,0x03,0x55,0x1d,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0xdf,0x7e,0x5e,0x88,0x05,
0x24,0x33,0x08,0xdd,0x22,0x81,0x02,0x97,0xcc,0x9a,0xb7,0xb1,0x33,0x27,0x30,0x30,
0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x82,
0x01,0x01,0x00,0x5a,0xf2,0x63,0xef,0xd3,0x16,0xd7,0xf5,0xaa,0xdd,0x12,0x00,0x36,
0x00,0x21,0xa2,0x7b,0x08,0xd6,0x3b,0x9f,0x62,0xac,0x53,0x1f,0xed,0x4c,0xd1,0x15,
0x34,0x65,0x71,0xee,0x96,0x07,0xa6,0xef,0xb2,0xde,0xd8,0xbb,0x35,0x6e,0x2c,0xe2,
0xd1,0x26,0xef,0x7e,0x94,0xe2,0x88,0x51,0xa4,0x6c,0xaa,0x27,0x2a,0xd3,0xb6,0xc2,
0xf7,0xea,0xc3,0x0b,0xa9,0xb5,0x28,0x37,0xa2,0x63,0x08,0xe4,0x88,0xc0,0x1b,0x16,
0x1b,0xca,0xfd,0x8a,0x07,0x32,0x29,0xa7,0x53,0xb5,0x2d,0x30,0xe4,0xf5,0x16,0xc3,
0xe3,0xc2,0x4c,0x30,0x5d,0x35,0x80,0x1c,0xa2,0xdb,0xe3,0x4b,0x51,0x0d,0x4c,0x60,
0x5f,0xb9,0x46,0xac,0xa8,0x46,0xa7,0x32,0xa7,0x9c,0x76,0xf8,0xe9,0xb5,0x19,0xe2,
0x0c,0xe1,0x0f,0xc6,0x46,0xe2,0x38,0xa7,0x87,0x72,0x6d,0x6c,0xbc,0x88,0x2f,0x9d,
0x2d,0xe5,0xd0,0x7d,0x1e,0xc7,0x5d,0xf8,0x7e,0xb4,0x0b,0xa6,0xf9,0x6c,0xe3,0x7c,
0xb2,0x70,0x6e,0x75,0x9b,0x1e,0x63,0xe1,0x4d,0xb2,0x81,0xd3,0x55,0x38,0x94,0x1a,
0x7a,0xfa,0xbf,0x01,0x18,0x70,0x2d,0x35,0xd3,0xe3,0x10,0x7a,0x9a,0xa7,0x8f,0xf3,
0xbd,0x56,0x55,0x5e,0xd8,0xbd,0x4e,0x16,0x76,0xd0,0x48,0x4c,0xf9,0x51,0x54,0xdf,
0x2d,0xb0,0xc9,0xaa,0x5e,0x42,0x38,0x50,0xbf,0x0f,0xc0,0xd9,0x84,0x44,0x4b,0x42,
0x24,0xec,0x14,0xa3,0xde,0x11,0xdf,0x58,0x7f,0xc2,0x4d,0xb2,0xd5,0x42,0x78,0x6e,
0x52,0x3e,0xad,0xc3,0x5f,0x04,0xc4,0xe6,0x31,0xaa,0x81,0x06,0x8b,0x13,0x4b,0x3c,
0x0e,0x6a,0xb1
};
if (!TEST_ptr(bio = BIO_new_mem_buf(dhx_cert, sizeof(dhx_cert)))
|| !TEST_ptr(cert = X509_new_ex(libctx, NULL))
|| !TEST_ptr(d2i_X509_bio(bio, &cert)))
goto err;
ret = 1;
err:
X509_free(cert);
BIO_free(bio);
return ret;
}
#endif /* OPENSSL_NO_DH */
static int test_cipher_reinit(int test_id)
{
int ret = 0, diff, ccm, siv, no_null_key;
int out1_len = 0, out2_len = 0, out3_len = 0;
EVP_CIPHER *cipher = NULL;
EVP_CIPHER_CTX *ctx = NULL;
unsigned char out1[256];
unsigned char out2[256];
unsigned char out3[256];
unsigned char in[16] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
};
unsigned char key[64] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x02, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x03, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
};
unsigned char iv[16] = {
0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00
};
const char *name = sk_OPENSSL_STRING_value(cipher_names, test_id);
if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new()))
goto err;
TEST_note("Fetching %s\n", name);
if (!TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, name, NULL)))
goto err;
/* ccm fails on the second update - this matches OpenSSL 1_1_1 behaviour */
ccm = (EVP_CIPHER_get_mode(cipher) == EVP_CIPH_CCM_MODE);
/* siv cannot be called with NULL key as the iv is irrelevant */
siv = (EVP_CIPHER_get_mode(cipher) == EVP_CIPH_SIV_MODE);
/*
* Skip init call with a null key for RC4 as the stream cipher does not
* handle reinit (1.1.1 behaviour).
*/
no_null_key = EVP_CIPHER_is_a(cipher, "RC4")
|| EVP_CIPHER_is_a(cipher, "RC4-40")
|| EVP_CIPHER_is_a(cipher, "RC4-HMAC-MD5");
/* DES3-WRAP uses random every update - so it will give a different value */
diff = EVP_CIPHER_is_a(cipher, "DES3-WRAP");
if (!TEST_true(EVP_EncryptInit_ex(ctx, cipher, NULL, key, iv))
|| !TEST_true(EVP_EncryptUpdate(ctx, out1, &out1_len, in, sizeof(in)))
|| !TEST_true(EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv))
|| !TEST_int_eq(EVP_EncryptUpdate(ctx, out2, &out2_len, in, sizeof(in)),
ccm ? 0 : 1)
|| (!no_null_key
&& (!TEST_true(EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv))
|| !TEST_int_eq(EVP_EncryptUpdate(ctx, out3, &out3_len, in, sizeof(in)),
ccm || siv ? 0 : 1))))
goto err;
if (ccm == 0) {
if (diff) {
if (!TEST_mem_ne(out1, out1_len, out2, out2_len)
|| !TEST_mem_ne(out1, out1_len, out3, out3_len)
|| !TEST_mem_ne(out2, out2_len, out3, out3_len))
goto err;
} else {
if (!TEST_mem_eq(out1, out1_len, out2, out2_len)
|| (!siv && !no_null_key && !TEST_mem_eq(out1, out1_len, out3, out3_len)))
goto err;
}
}
ret = 1;
err:
EVP_CIPHER_free(cipher);
EVP_CIPHER_CTX_free(ctx);
return ret;
}
/*
* This test only uses a partial block (half the block size) of input for each
* EVP_EncryptUpdate() in order to test that the second init/update is not using
* a leftover buffer from the first init/update.
* Note: some ciphers don't need a full block to produce output.
*/
static int test_cipher_reinit_partialupdate(int test_id)
{
int ret = 0, in_len;
int out1_len = 0, out2_len = 0, out3_len = 0;
EVP_CIPHER *cipher = NULL;
EVP_CIPHER_CTX *ctx = NULL;
unsigned char out1[256];
unsigned char out2[256];
unsigned char out3[256];
static const unsigned char in[32] = {
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0xba, 0xbe, 0xba, 0xbe, 0x00, 0x00, 0xba, 0xbe,
0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
};
static const unsigned char key[64] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x02, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x03, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
};
static const unsigned char iv[16] = {
0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00
};
const char *name = sk_OPENSSL_STRING_value(cipher_names, test_id);
if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new()))
goto err;
TEST_note("Fetching %s\n", name);
if (!TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, name, NULL)))
goto err;
in_len = EVP_CIPHER_get_block_size(cipher) / 2;
/* skip any ciphers that don't allow partial updates */
if (((EVP_CIPHER_get_flags(cipher)
& (EVP_CIPH_FLAG_CTS | EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK)) != 0)
|| EVP_CIPHER_get_mode(cipher) == EVP_CIPH_CCM_MODE
|| EVP_CIPHER_get_mode(cipher) == EVP_CIPH_XTS_MODE
|| EVP_CIPHER_get_mode(cipher) == EVP_CIPH_WRAP_MODE) {
ret = 1;
goto err;
}
if (!TEST_true(EVP_EncryptInit_ex(ctx, cipher, NULL, key, iv))
|| !TEST_true(EVP_EncryptUpdate(ctx, out1, &out1_len, in, in_len))
|| !TEST_true(EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv))
|| !TEST_true(EVP_EncryptUpdate(ctx, out2, &out2_len, in, in_len)))
goto err;
if (!TEST_mem_eq(out1, out1_len, out2, out2_len))
goto err;
if (EVP_CIPHER_get_mode(cipher) != EVP_CIPH_SIV_MODE) {
if (!TEST_true(EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv))
|| !TEST_true(EVP_EncryptUpdate(ctx, out3, &out3_len, in, in_len)))
goto err;
if (!TEST_mem_eq(out1, out1_len, out3, out3_len))
goto err;
}
ret = 1;
err:
EVP_CIPHER_free(cipher);
EVP_CIPHER_CTX_free(ctx);
return ret;
}
static int name_cmp(const char * const *a, const char * const *b)
{
return OPENSSL_strcasecmp(*a, *b);
}
static void collect_cipher_names(EVP_CIPHER *cipher, void *cipher_names_list)
{
STACK_OF(OPENSSL_STRING) *names = cipher_names_list;
const char *name = EVP_CIPHER_get0_name(cipher);
char *namedup = NULL;
assert(name != NULL);
/* the cipher will be freed after returning, strdup is needed */
if ((namedup = OPENSSL_strdup(name)) != NULL
&& !sk_OPENSSL_STRING_push(names, namedup))
OPENSSL_free(namedup);
}
static int rsa_keygen(int bits, EVP_PKEY **pub, EVP_PKEY **priv)
{
int ret = 0;
unsigned char *pub_der = NULL;
const unsigned char *pp = NULL;
size_t len = 0;
OSSL_ENCODER_CTX *ectx = NULL;
if (!TEST_ptr(*priv = EVP_PKEY_Q_keygen(libctx, NULL, "RSA", bits))
|| !TEST_ptr(ectx =
OSSL_ENCODER_CTX_new_for_pkey(*priv,
EVP_PKEY_PUBLIC_KEY,
"DER", "type-specific",
NULL))
|| !TEST_true(OSSL_ENCODER_to_data(ectx, &pub_der, &len)))
goto err;
pp = pub_der;
if (!TEST_ptr(d2i_PublicKey(EVP_PKEY_RSA, pub, &pp, len)))
goto err;
ret = 1;
err:
OSSL_ENCODER_CTX_free(ectx);
OPENSSL_free(pub_der);
return ret;
}
static int kem_rsa_gen_recover(void)
{
int ret = 0;
EVP_PKEY *pub = NULL;
EVP_PKEY *priv = NULL;
EVP_PKEY_CTX *sctx = NULL, *rctx = NULL, *dctx = NULL;
unsigned char secret[256] = { 0, };
unsigned char ct[256] = { 0, };
unsigned char unwrap[256] = { 0, };
size_t ctlen = 0, unwraplen = 0, secretlen = 0;
int bits = 2048;
ret = TEST_true(rsa_keygen(bits, &pub, &priv))
&& TEST_ptr(sctx = EVP_PKEY_CTX_new_from_pkey(libctx, pub, NULL))
&& TEST_int_eq(EVP_PKEY_encapsulate_init(sctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(sctx, "RSASVE"), 1)
&& TEST_ptr(dctx = EVP_PKEY_CTX_dup(sctx))
&& TEST_int_eq(EVP_PKEY_encapsulate(dctx, NULL, &ctlen, NULL,
&secretlen), 1)
&& TEST_int_eq(ctlen, secretlen)
&& TEST_int_eq(ctlen, bits / 8)
&& TEST_int_eq(EVP_PKEY_encapsulate(dctx, ct, &ctlen, secret,
&secretlen), 1)
&& TEST_ptr(rctx = EVP_PKEY_CTX_new_from_pkey(libctx, priv, NULL))
&& TEST_int_eq(EVP_PKEY_decapsulate_init(rctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(rctx, "RSASVE"), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(rctx, NULL, &unwraplen,
ct, ctlen), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(rctx, unwrap, &unwraplen,
ct, ctlen), 1)
&& TEST_mem_eq(unwrap, unwraplen, secret, secretlen);
EVP_PKEY_free(pub);
EVP_PKEY_free(priv);
EVP_PKEY_CTX_free(rctx);
EVP_PKEY_CTX_free(dctx);
EVP_PKEY_CTX_free(sctx);
return ret;
}
#ifndef OPENSSL_NO_DES
/*
* This test makes sure that EVP_CIPHER_CTX_rand_key() works correctly
* For fips mode this code would produce an error if the flag is not set.
*/
static int test_cipher_tdes_randkey(void)
{
int ret;
EVP_CIPHER_CTX *ctx = NULL;
EVP_CIPHER *tdes_cipher = NULL, *aes_cipher = NULL;
unsigned char key[24] = { 0 };
ret = TEST_ptr(aes_cipher = EVP_CIPHER_fetch(libctx, "AES-256-CBC", NULL))
&& TEST_int_eq(EVP_CIPHER_get_flags(aes_cipher) & EVP_CIPH_RAND_KEY, 0)
&& TEST_ptr(tdes_cipher = EVP_CIPHER_fetch(libctx, "DES-EDE3-CBC", NULL))
&& TEST_int_ne(EVP_CIPHER_get_flags(tdes_cipher) & EVP_CIPH_RAND_KEY, 0)
&& TEST_ptr(ctx = EVP_CIPHER_CTX_new())
&& TEST_true(EVP_CipherInit_ex(ctx, tdes_cipher, NULL, NULL, NULL, 1))
&& TEST_int_gt(EVP_CIPHER_CTX_rand_key(ctx, key), 0);
EVP_CIPHER_CTX_free(ctx);
EVP_CIPHER_free(tdes_cipher);
EVP_CIPHER_free(aes_cipher);
return ret;
}
#endif /* OPENSSL_NO_DES */
static int kem_rsa_params(void)
{
int ret = 0;
EVP_PKEY *pub = NULL;
EVP_PKEY *priv = NULL;
EVP_PKEY_CTX *pubctx = NULL, *privctx = NULL;
unsigned char secret[256] = { 0, };
unsigned char ct[256] = { 0, };
size_t ctlen = 0, secretlen = 0;
ret = TEST_true(rsa_keygen(2048, &pub, &priv))
&& TEST_ptr(pubctx = EVP_PKEY_CTX_new_from_pkey(libctx, pub, NULL))
&& TEST_ptr(privctx = EVP_PKEY_CTX_new_from_pkey(libctx, priv, NULL))
/* Test setting kem op before the init fails */
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSASVE"), -2)
/* Test NULL ctx passed */
&& TEST_int_eq(EVP_PKEY_encapsulate_init(NULL, NULL), 0)
&& TEST_int_eq(EVP_PKEY_encapsulate(NULL, NULL, NULL, NULL, NULL), 0)
&& TEST_int_eq(EVP_PKEY_decapsulate_init(NULL, NULL), 0)
&& TEST_int_eq(EVP_PKEY_decapsulate(NULL, NULL, NULL, NULL, 0), 0)
/* Test Invalid operation */
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, NULL), -1)
&& TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, NULL, NULL, 0), 0)
/* Wrong key component - no secret should be returned on failure */
&& TEST_int_eq(EVP_PKEY_decapsulate_init(pubctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSASVE"), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(pubctx, secret, &secretlen, ct,
sizeof(ct)), 0)
&& TEST_uchar_eq(secret[0], 0)
/* Test encapsulate fails if the mode is not set */
&& TEST_int_eq(EVP_PKEY_encapsulate_init(pubctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, &ctlen, secret, &secretlen), -2)
/* Test setting a bad kem ops fail */
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSA"), 0)
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, NULL), 0)
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(NULL, "RSASVE"), 0)
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(NULL, NULL), 0)
/* Test secretlen is optional */
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSASVE"), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, &ctlen, secret, NULL), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, NULL), 1)
/* Test outlen is optional */
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, &secretlen), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, NULL, secret, &secretlen), 1)
/* test that either len must be set if out is NULL */
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, NULL), 0)
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, NULL), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, &secretlen), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, &secretlen), 1)
/* Secret buffer should be set if there is an output buffer */
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, &ctlen, NULL, NULL), 0)
/* Test that lengths are optional if ct is not NULL */
&& TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, NULL, secret, NULL), 1)
/* Pass if secret or secret length are not NULL */
&& TEST_int_eq(EVP_PKEY_decapsulate_init(privctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(privctx, "RSASVE"), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, NULL, ct, sizeof(ct)), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, &secretlen, ct, sizeof(ct)), 1)
&& TEST_int_eq(secretlen, 256)
/* Fail if passed NULL arguments */
&& TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, NULL, ct, sizeof(ct)), 0)
&& TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, NULL, 0), 0)
&& TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, NULL, sizeof(ct)), 0)
&& TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, ct, 0), 0);
EVP_PKEY_free(pub);
EVP_PKEY_free(priv);
EVP_PKEY_CTX_free(pubctx);
EVP_PKEY_CTX_free(privctx);
return ret;
}
#ifndef OPENSSL_NO_DH
static EVP_PKEY *gen_dh_key(void)
{
EVP_PKEY_CTX *gctx = NULL;
EVP_PKEY *pkey = NULL;
OSSL_PARAM params[2];
params[0] = OSSL_PARAM_construct_utf8_string("group", "ffdhe2048", 0);
params[1] = OSSL_PARAM_construct_end();
if (!TEST_ptr(gctx = EVP_PKEY_CTX_new_from_name(libctx, "DH", NULL))
|| !TEST_int_gt(EVP_PKEY_keygen_init(gctx), 0)
|| !TEST_true(EVP_PKEY_CTX_set_params(gctx, params))
|| !TEST_true(EVP_PKEY_keygen(gctx, &pkey)))
goto err;
err:
EVP_PKEY_CTX_free(gctx);
return pkey;
}
/* Fail if we try to use a dh key */
static int kem_invalid_keytype(void)
{
int ret = 0;
EVP_PKEY *key = NULL;
EVP_PKEY_CTX *sctx = NULL;
if (!TEST_ptr(key = gen_dh_key()))
goto done;
if (!TEST_ptr(sctx = EVP_PKEY_CTX_new_from_pkey(libctx, key, NULL)))
goto done;
if (!TEST_int_eq(EVP_PKEY_encapsulate_init(sctx, NULL), -2))
goto done;
ret = 1;
done:
EVP_PKEY_free(key);
EVP_PKEY_CTX_free(sctx);
return ret;
}
#endif /* OPENSSL_NO_DH */
int setup_tests(void)
{
const char *prov_name = "default";
char *config_file = NULL;
OPTION_CHOICE o;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_PROVIDER_NAME:
prov_name = opt_arg();
break;
case OPT_CONFIG_FILE:
config_file = opt_arg();
break;
case OPT_TEST_CASES:
break;
default:
case OPT_ERR:
return 0;
}
}
if (!test_get_libctx(&libctx, &nullprov, config_file, &libprov, prov_name))
return 0;
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DH)
ADD_ALL_TESTS(test_dsa_param_keygen, 3 * 3 * 3);
#endif
#ifndef OPENSSL_NO_DH
ADD_ALL_TESTS(test_dh_safeprime_param_keygen, 3 * 3 * 3);
ADD_TEST(dhx_cert_load);
#endif
if (!TEST_ptr(cipher_names = sk_OPENSSL_STRING_new(name_cmp)))
return 0;
EVP_CIPHER_do_all_provided(libctx, collect_cipher_names, cipher_names);
ADD_ALL_TESTS(test_cipher_reinit, sk_OPENSSL_STRING_num(cipher_names));
ADD_ALL_TESTS(test_cipher_reinit_partialupdate,
sk_OPENSSL_STRING_num(cipher_names));
ADD_TEST(kem_rsa_gen_recover);
ADD_TEST(kem_rsa_params);
#ifndef OPENSSL_NO_DH
ADD_TEST(kem_invalid_keytype);
#endif
#ifndef OPENSSL_NO_DES
ADD_TEST(test_cipher_tdes_randkey);
#endif
return 1;
}
/* Because OPENSSL_free is a macro, it can't be passed as a function pointer */
static void string_free(char *m)
{
OPENSSL_free(m);
}
void cleanup_tests(void)
{
sk_OPENSSL_STRING_pop_free(cipher_names, string_free);
OSSL_PROVIDER_unload(libprov);
OSSL_LIB_CTX_free(libctx);
OSSL_PROVIDER_unload(nullprov);
}
|
./openssl/test/clienthellotest.c | /*
* Copyright 2015-2021 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 <string.h>
#include <openssl/opensslconf.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <time.h>
#include "internal/packet.h"
#include "testutil.h"
#define CLIENT_VERSION_LEN 2
#define TOTAL_NUM_TESTS 4
/*
* Test that explicitly setting ticket data results in it appearing in the
* ClientHello for a negotiated SSL/TLS version
*/
#define TEST_SET_SESSION_TICK_DATA_VER_NEG 0
/* Enable padding and make sure ClientHello is long enough to require it */
#define TEST_ADD_PADDING 1
/* Enable padding and make sure ClientHello is short enough to not need it */
#define TEST_PADDING_NOT_NEEDED 2
/*
* Enable padding and add a PSK to the ClientHello (this will also ensure the
* ClientHello is long enough to need padding)
*/
#define TEST_ADD_PADDING_AND_PSK 3
#define F5_WORKAROUND_MIN_MSG_LEN 0x7f
#define F5_WORKAROUND_MAX_MSG_LEN 0x200
static const char *sessionfile = NULL;
/* Dummy ALPN protocols used to pad out the size of the ClientHello */
/* ASCII 'O' = 79 = 0x4F = EBCDIC '|'*/
#ifdef CHARSET_EBCDIC
static const char alpn_prots[] =
"|1234567890123456789012345678901234567890123456789012345678901234567890123456789"
"|1234567890123456789012345678901234567890123456789012345678901234567890123456789";
#else
static const char alpn_prots[] =
"O1234567890123456789012345678901234567890123456789012345678901234567890123456789"
"O1234567890123456789012345678901234567890123456789012345678901234567890123456789";
#endif
static int test_client_hello(int currtest)
{
SSL_CTX *ctx;
SSL *con = NULL;
BIO *rbio;
BIO *wbio;
long len;
unsigned char *data;
PACKET pkt, pkt2, pkt3;
char *dummytick = "Hello World!";
unsigned int type = 0;
int testresult = 0;
size_t msglen;
BIO *sessbio = NULL;
SSL_SESSION *sess = NULL;
#ifdef OPENSSL_NO_TLS1_3
if (currtest == TEST_ADD_PADDING_AND_PSK)
return 1;
#endif
memset(&pkt, 0, sizeof(pkt));
memset(&pkt2, 0, sizeof(pkt2));
memset(&pkt3, 0, sizeof(pkt3));
/*
* For each test set up an SSL_CTX and SSL and see what ClientHello gets
* produced when we try to connect
*/
ctx = SSL_CTX_new(TLS_method());
if (!TEST_ptr(ctx))
goto end;
if (!TEST_true(SSL_CTX_set_max_proto_version(ctx, 0)))
goto end;
switch (currtest) {
case TEST_SET_SESSION_TICK_DATA_VER_NEG:
#if !defined(OPENSSL_NO_TLS1_3) && defined(OPENSSL_NO_TLS1_2)
/* TLSv1.3 is enabled and TLSv1.2 is disabled so can't do this test */
SSL_CTX_free(ctx);
return 1;
#else
/* Testing for session tickets <= TLS1.2; not relevant for 1.3 */
if (!TEST_true(SSL_CTX_set_max_proto_version(ctx, TLS1_2_VERSION)))
goto end;
#endif
break;
case TEST_ADD_PADDING_AND_PSK:
/*
* In this case we're doing TLSv1.3 and we're sending a PSK so the
* ClientHello is already going to be quite long. To avoid getting one
* that is too long for this test we use a restricted ciphersuite list
*/
if (!TEST_false(SSL_CTX_set_cipher_list(ctx, "")))
goto end;
ERR_clear_error();
/* Fall through */
case TEST_ADD_PADDING:
case TEST_PADDING_NOT_NEEDED:
SSL_CTX_set_options(ctx, SSL_OP_TLSEXT_PADDING);
/* Make sure we get a consistent size across TLS versions */
SSL_CTX_clear_options(ctx, SSL_OP_ENABLE_MIDDLEBOX_COMPAT);
/*
* Add some dummy ALPN protocols so that the ClientHello is at least
* F5_WORKAROUND_MIN_MSG_LEN bytes long - meaning padding will be
* needed.
*/
if (currtest == TEST_ADD_PADDING) {
if (!TEST_false(SSL_CTX_set_alpn_protos(ctx,
(unsigned char *)alpn_prots,
sizeof(alpn_prots) - 1)))
goto end;
/*
* Otherwise we need to make sure we have a small enough message to
* not need padding.
*/
} else if (!TEST_true(SSL_CTX_set_cipher_list(ctx,
"AES128-SHA"))
|| !TEST_true(SSL_CTX_set_ciphersuites(ctx,
"TLS_AES_128_GCM_SHA256"))) {
goto end;
}
break;
default:
goto end;
}
con = SSL_new(ctx);
if (!TEST_ptr(con))
goto end;
if (currtest == TEST_ADD_PADDING_AND_PSK) {
sessbio = BIO_new_file(sessionfile, "r");
if (!TEST_ptr(sessbio)) {
TEST_info("Unable to open session.pem");
goto end;
}
sess = PEM_read_bio_SSL_SESSION(sessbio, NULL, NULL, NULL);
if (!TEST_ptr(sess)) {
TEST_info("Unable to load SSL_SESSION");
goto end;
}
/*
* We reset the creation time so that we don't discard the session as
* too old.
*/
if (!TEST_true(SSL_SESSION_set_time(sess, (long)time(NULL)))
|| !TEST_true(SSL_set_session(con, sess)))
goto end;
}
rbio = BIO_new(BIO_s_mem());
wbio = BIO_new(BIO_s_mem());
if (!TEST_ptr(rbio)|| !TEST_ptr(wbio)) {
BIO_free(rbio);
BIO_free(wbio);
goto end;
}
SSL_set_bio(con, rbio, wbio);
SSL_set_connect_state(con);
if (currtest == TEST_SET_SESSION_TICK_DATA_VER_NEG) {
if (!TEST_true(SSL_set_session_ticket_ext(con, dummytick,
strlen(dummytick))))
goto end;
}
if (!TEST_int_le(SSL_connect(con), 0)) {
/* This shouldn't succeed because we don't have a server! */
goto end;
}
if (!TEST_long_ge(len = BIO_get_mem_data(wbio, (char **)&data), 0)
|| !TEST_true(PACKET_buf_init(&pkt, data, len))
/* Skip the record header */
|| !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH))
goto end;
msglen = PACKET_remaining(&pkt);
/* Skip the handshake message header */
if (!TEST_true(PACKET_forward(&pkt, SSL3_HM_HEADER_LENGTH))
/* Skip client version and random */
|| !TEST_true(PACKET_forward(&pkt, CLIENT_VERSION_LEN
+ SSL3_RANDOM_SIZE))
/* Skip session id */
|| !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
/* Skip ciphers */
|| !TEST_true(PACKET_get_length_prefixed_2(&pkt, &pkt2))
/* Skip compression */
|| !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
/* Extensions len */
|| !TEST_true(PACKET_as_length_prefixed_2(&pkt, &pkt2)))
goto end;
/* Loop through all extensions */
while (PACKET_remaining(&pkt2)) {
if (!TEST_true(PACKET_get_net_2(&pkt2, &type))
|| !TEST_true(PACKET_get_length_prefixed_2(&pkt2, &pkt3)))
goto end;
if (type == TLSEXT_TYPE_session_ticket) {
if (currtest == TEST_SET_SESSION_TICK_DATA_VER_NEG) {
if (TEST_true(PACKET_equal(&pkt3, dummytick,
strlen(dummytick)))) {
/* Ticket data is as we expected */
testresult = 1;
}
goto end;
}
}
if (type == TLSEXT_TYPE_padding) {
if (!TEST_false(currtest == TEST_PADDING_NOT_NEEDED))
goto end;
else if (TEST_true(currtest == TEST_ADD_PADDING
|| currtest == TEST_ADD_PADDING_AND_PSK))
testresult = TEST_true(msglen == F5_WORKAROUND_MAX_MSG_LEN);
}
}
if (currtest == TEST_PADDING_NOT_NEEDED)
testresult = 1;
end:
SSL_free(con);
SSL_CTX_free(ctx);
SSL_SESSION_free(sess);
BIO_free(sessbio);
return testresult;
}
OPT_TEST_DECLARE_USAGE("sessionfile\n")
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(sessionfile = test_get_argument(0)))
return 0;
ADD_ALL_TESTS(test_client_hello, TOTAL_NUM_TESTS);
return 1;
}
|
./openssl/test/evp_pkey_dhkem_test.c | /*
* Copyright 2022-2023 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 <openssl/evp.h>
#include <openssl/core_names.h>
#include <openssl/param_build.h>
#include <openssl/proverr.h>
#include "internal/nelem.h"
#include "testutil.h"
#define TEST_KEM_ENCAP 0
#define TEST_KEM_DECAP 1
#define TEST_KEM_ENCAP_DECAP 2
#define TEST_TYPE_AUTH 0
#define TEST_TYPE_NOAUTH 1
#define TEST_TYPE_AUTH_NOAUTH 2
#define TEST_KEYTYPE_P256 0
#define TEST_KEYTYPE_X25519 1
#define TEST_KEYTYPES_P256_X25519 2
static OSSL_LIB_CTX *libctx = NULL;
static OSSL_PROVIDER *nullprov = NULL;
static OSSL_PROVIDER *libprov = NULL;
static OSSL_PARAM opparam[2];
static EVP_PKEY *rkey[TEST_KEYTYPES_P256_X25519] = { NULL, NULL };
static EVP_PKEY_CTX *rctx[TEST_KEYTYPES_P256_X25519] = { NULL, NULL };
#include "dhkem_test.inc"
/* Perform encapsulate KAT's */
static int test_dhkem_encapsulate(int tstid)
{
int ret = 0;
EVP_PKEY *rpub = NULL, *spriv = NULL;
const TEST_ENCAPDATA *t = &ec_encapdata[tstid];
TEST_note("Test %s %s Decapsulate", t->curve,
t->spriv != NULL ? "Auth" : "");
if (!TEST_ptr(rpub = new_raw_public_key(t->curve, t->rpub, t->rpublen)))
goto err;
if (t->spriv != NULL) {
if (!TEST_ptr(spriv = new_raw_private_key(t->curve,
t->spriv, t->sprivlen,
t->spub, t->spublen)))
goto err;
}
ret = do_encap(t, rpub, spriv);
err:
EVP_PKEY_free(spriv);
EVP_PKEY_free(rpub);
return ret;
}
/* Perform decapsulate KAT's */
static int test_dhkem_decapsulate(int tstid)
{
int ret = 0;
EVP_PKEY *rpriv = NULL, *spub = NULL;
const TEST_ENCAPDATA *t = &ec_encapdata[tstid];
TEST_note("Test %s %s Decapsulate", t->curve, t->spub != NULL ? "Auth" : "");
if (!TEST_ptr(rpriv = new_raw_private_key(t->curve, t->rpriv, t->rprivlen,
t->rpub, t->rpublen)))
goto err;
if (t->spub != NULL) {
if (!TEST_ptr(spub = new_raw_public_key(t->curve, t->spub, t->spublen)))
goto err;
}
ret = do_decap(t, rpriv, spub);
err:
EVP_PKEY_free(spub);
EVP_PKEY_free(rpriv);
return ret;
}
/* Test that there are settables and they have correct data types */
static int test_settables(int tstid)
{
EVP_PKEY_CTX *ctx = rctx[tstid];
const OSSL_PARAM *settableparams;
const OSSL_PARAM *p;
return TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, NULL), 1)
&& TEST_ptr(settableparams = EVP_PKEY_CTX_settable_params(ctx))
&& TEST_ptr(p = OSSL_PARAM_locate_const(settableparams,
OSSL_KEM_PARAM_OPERATION))
&& TEST_uint_eq(p->data_type, OSSL_PARAM_UTF8_STRING)
&& TEST_ptr(p = OSSL_PARAM_locate_const(settableparams,
OSSL_KEM_PARAM_IKME))
&& TEST_uint_eq(p->data_type, OSSL_PARAM_OCTET_STRING);
}
/* Test initing multiple times passes */
static int test_init_multiple(int tstid)
{
EVP_PKEY_CTX *ctx = rctx[tstid];
return TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, NULL), 1);
}
/* Fail is various bad inputs are passed to the derivekey (keygen) operation */
static int test_ec_dhkem_derivekey_fail(void)
{
int ret = 0;
EVP_PKEY *pkey = NULL;
OSSL_PARAM params[3];
EVP_PKEY_CTX *genctx = NULL;
const TEST_DERIVEKEY_DATA *t = &ec_derivekey_data[0];
BIGNUM *priv = NULL;
/* Check non nist curve fails */
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME,
"secp256k1", 0);
params[1] = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_DHKEM_IKM,
(char *)t->ikm, t->ikmlen);
params[2] = OSSL_PARAM_construct_end();
if (!TEST_ptr(genctx = EVP_PKEY_CTX_new_from_name(libctx, "EC", NULL))
|| !TEST_int_eq(EVP_PKEY_keygen_init(genctx), 1)
|| !TEST_int_eq(EVP_PKEY_CTX_set_params(genctx, params), 1)
|| !TEST_int_eq(EVP_PKEY_generate(genctx, &pkey),0))
goto err;
/* Fail if curve is not one of P-256, P-384 or P-521 */
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME,
"P-224", 0);
params[1] = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_DHKEM_IKM,
(char *)t->ikm, t->ikmlen);
params[2] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_PKEY_keygen_init(genctx), 1)
|| !TEST_int_eq(EVP_PKEY_CTX_set_params(genctx, params), 1)
|| !TEST_int_eq(EVP_PKEY_generate(genctx, &pkey), 0))
goto err;
/* Fail if ikm len is too small*/
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME,
"P-256", 0);
params[1] = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_DHKEM_IKM,
(char *)t->ikm, t->ikmlen - 1);
params[2] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_PKEY_CTX_set_params(genctx, params), 1)
|| !TEST_int_eq(EVP_PKEY_generate(genctx, &pkey), 0))
goto err;
ret = 1;
err:
BN_free(priv);
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(genctx);
return ret;
}
/* Fail if the operation parameter is not set */
static int test_no_operation_set(int tstid)
{
EVP_PKEY_CTX *ctx = rctx[tstid];
const TEST_ENCAPDATA *t = &ec_encapdata[tstid];
size_t len = 0;
return TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(ctx, NULL, &len, NULL, NULL), -2)
&& TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, NULL), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(ctx, NULL, &len,
t->expected_enc,
t->expected_enclen), -2);
}
/* Fail if the ikm is too small */
static int test_ikm_small(int tstid)
{
unsigned char tmp[16] = { 0 };
unsigned char secret[256];
unsigned char enc[256];
size_t secretlen = sizeof(secret);
size_t enclen = sizeof(enc);
OSSL_PARAM params[3];
EVP_PKEY_CTX *ctx = rctx[tstid];
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_KEM_PARAM_OPERATION,
OSSL_KEM_PARAM_OPERATION_DHKEM,
0);
params[1] = OSSL_PARAM_construct_octet_string(OSSL_KEM_PARAM_IKME,
tmp, sizeof(tmp));
params[2] = OSSL_PARAM_construct_end();
return TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, params), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(ctx, enc, &enclen,
secret, &secretlen), 0);
}
/* Fail if buffers lengths are too small to hold returned data */
static int test_input_size_small(int tstid)
{
int ret = 0;
unsigned char sec[256];
unsigned char enc[256];
size_t seclen = sizeof(sec);
size_t enclen = sizeof(enc);
EVP_PKEY_CTX *ctx = rctx[tstid];
if (!TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, opparam), 1)
|| !TEST_int_eq(EVP_PKEY_encapsulate(ctx, NULL, &enclen,
NULL, &seclen), 1))
goto err;
/* buffer too small for enc */
enclen--;
if (!TEST_int_eq(EVP_PKEY_encapsulate(ctx, enc, &enclen, sec, &seclen),
0))
goto err;
enclen++;
/* buffer too small for secret */
seclen--;
if (!TEST_int_eq(EVP_PKEY_encapsulate(ctx, enc, &enclen, sec, &seclen), 0))
goto err;
seclen++;
if (!TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, opparam), 1))
goto err;
/* buffer too small for decapsulate secret */
seclen--;
if (!TEST_int_eq(EVP_PKEY_decapsulate(ctx, sec, &seclen, enc, enclen), 0))
goto err;
seclen++;
/* incorrect enclen passed to decap */
enclen--;
ret = TEST_int_eq(EVP_PKEY_decapsulate(ctx, sec, &seclen, enc, enclen), 0);
err:
return ret;
}
/* Fail if the auth key has a different curve */
static int test_ec_auth_key_curve_mismatch(void)
{
int ret = 0;
EVP_PKEY *auth = NULL;
if (!TEST_ptr(auth = EVP_PKEY_Q_keygen(libctx, NULL, "EC", "P-521")))
return 0;
ret = TEST_int_eq(EVP_PKEY_auth_encapsulate_init(rctx[0], auth, opparam), 0);
EVP_PKEY_free(auth);
return ret;
}
/* Fail if the auth key has a different key type to the recipient */
static int test_auth_key_type_mismatch(int tstid)
{
int id1 = tstid;
int id2 = !tstid;
return TEST_int_eq(EVP_PKEY_auth_encapsulate_init(rctx[id1],
rkey[id2], opparam), 0);
}
static int test_ec_invalid_private_key(void)
{
int ret = 0;
EVP_PKEY *priv = NULL;
EVP_PKEY_CTX *ctx = NULL;
const TEST_ENCAPDATA *t = &ec_encapdata[0];
static const unsigned char order[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84,
0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51
};
ret = TEST_ptr(priv = new_raw_private_key("P-256", order, sizeof(order),
t->rpub, t->rpublen))
&& TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, priv, NULL))
&& TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, NULL), 0);
EVP_PKEY_free(priv);
EVP_PKEY_CTX_free(ctx);
return ret;
}
static int test_ec_public_key_infinity(void)
{
int ret = 0;
EVP_PKEY *key = NULL;
EVP_PKEY_CTX *keyctx = NULL;
unsigned char s[256];
unsigned char e[256];
size_t slen = sizeof(s);
size_t elen = sizeof(e);
unsigned char tmp[1] = { 0 }; /* The encoding for an EC point at infinity */
EVP_PKEY_CTX *ctx = rctx[0];
const TEST_ENCAPDATA *t = &ec_encapdata[0];
ret = TEST_ptr(key = new_raw_private_key(t->curve, t->rpriv, t->rprivlen,
tmp, sizeof(tmp)))
&& TEST_ptr(keyctx = EVP_PKEY_CTX_new_from_pkey(libctx, key, NULL))
/* Fail if the recipient public key is invalid */
&& TEST_int_eq(EVP_PKEY_encapsulate_init(keyctx, opparam), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(keyctx, e, &elen, s, &slen), 0)
/* Fail the decap if the recipient public key is invalid */
&& TEST_int_eq(EVP_PKEY_decapsulate_init(keyctx, opparam), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(keyctx, s, &slen,
t->expected_enc,
t->expected_enclen), 0)
/* Fail if the auth key has a bad public key */
&& TEST_int_eq(EVP_PKEY_auth_encapsulate_init(ctx, key, opparam), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(ctx, e, &elen, s, &slen), 0);
EVP_PKEY_free(key);
EVP_PKEY_CTX_free(keyctx);
return ret;
}
/* Test incorrectly passing NULL values fail */
static int test_null_params(int tstid)
{
EVP_PKEY_CTX *ctx = rctx[tstid];
const TEST_ENCAPDATA *t = &ec_encapdata[tstid];
/* auth_encap/decap init must be passed a non NULL value */
return TEST_int_eq(EVP_PKEY_auth_encapsulate_init(ctx, NULL, opparam), 0)
&& TEST_int_eq(EVP_PKEY_auth_decapsulate_init(ctx, NULL, opparam), 0)
/* Check decap fails if NULL params are passed */
&& TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, opparam), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(ctx, NULL, NULL,
t->expected_enc,
t->expected_enclen), 0)
/* Check encap fails if NULL params are passed */
&& TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, opparam), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(ctx, NULL, NULL,
NULL, NULL), 0);
}
static int test_set_params(int tstid)
{
int ret = 0;
EVP_PKEY_CTX *ctx = rctx[tstid];
OSSL_PARAM badparams[4];
int val = 1;
/* wrong data type for operation param */
badparams[0] = OSSL_PARAM_construct_int(OSSL_KEM_PARAM_OPERATION, &val);
badparams[1] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, badparams), 0))
goto err;
/* unknown string used for the operation param */
badparams[0] = OSSL_PARAM_construct_utf8_string(OSSL_KEM_PARAM_OPERATION,
"unknown_op", 0);
badparams[1] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, badparams), 0))
goto err;
/* NULL string set for the operation param */
badparams[0] = OSSL_PARAM_construct_utf8_string(OSSL_KEM_PARAM_OPERATION,
NULL, 0);
badparams[1] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, badparams), 0))
goto err;
/* wrong data type for ikme param */
badparams[0] = OSSL_PARAM_construct_int(OSSL_KEM_PARAM_IKME, &val);
badparams[1] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, badparams), 0))
goto err;
/* Setting the ikme to NULL is allowed */
badparams[0] = OSSL_PARAM_construct_octet_string(OSSL_KEM_PARAM_IKME, NULL, 0);
badparams[1] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, badparams), 1))
goto err;
/* Test that unknown params are ignored */
badparams[0] = OSSL_PARAM_construct_int("unknownparam", &val);
badparams[1] = OSSL_PARAM_construct_end();
ret = TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, badparams), 1);
err:
return ret;
}
/*
* ECX keys autogen the public key if a private key is loaded,
* So this test passes for ECX, but fails for EC
*/
static int test_nopublic(int tstid)
{
int ret = 0;
EVP_PKEY_CTX *ctx = NULL;
EVP_PKEY *priv = NULL;
int encap = ((tstid & 1) == 0);
int keytype = tstid >= TEST_KEM_ENCAP_DECAP;
const TEST_ENCAPDATA *t = &ec_encapdata[keytype];
int expected = (keytype == TEST_KEYTYPE_X25519);
TEST_note("%s %s", t->curve, encap ? "Encap" : "Decap");
if (!TEST_ptr(priv = new_raw_private_key(t->curve, t->rpriv, t->rprivlen,
NULL, 0)))
goto err;
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, priv, NULL)))
goto err;
if (encap) {
if (!TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, opparam), expected))
goto err;
} else {
if (!TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, opparam), expected))
goto err;
}
if (expected == 0
&& !TEST_int_eq(ERR_GET_REASON(ERR_get_error()), PROV_R_NOT_A_PUBLIC_KEY))
goto err;
ret = 1;
err:
EVP_PKEY_free(priv);
EVP_PKEY_CTX_free(ctx);
return ret;
}
/* Test that not setting the auth public key fails the auth encap/decap init */
static int test_noauthpublic(int tstid)
{
int ret = 0;
EVP_PKEY *auth = NULL;
int encap = ((tstid & 1) == 0);
int keytype = tstid >= TEST_KEM_ENCAP_DECAP;
const TEST_ENCAPDATA *t = &ec_encapdata[keytype];
EVP_PKEY_CTX *ctx = rctx[keytype];
int expected = (keytype == TEST_KEYTYPE_X25519);
TEST_note("%s %s", t->curve, encap ? "Encap" : "Decap");
if (!TEST_ptr(auth = new_raw_private_key(t->curve, t->rpriv,
t->rprivlen, NULL, expected)))
goto err;
if (encap) {
if (!TEST_int_eq(EVP_PKEY_auth_encapsulate_init(ctx, auth,
opparam), expected))
goto err;
} else {
if (!TEST_int_eq(EVP_PKEY_auth_decapsulate_init(ctx, auth,
opparam), expected))
goto err;
}
if (expected == 0
&& !TEST_int_eq(ERR_GET_REASON(ERR_get_error()),
PROV_R_NOT_A_PUBLIC_KEY))
goto err;
ret = 1;
err:
EVP_PKEY_free(auth);
return ret;
}
/* EC specific tests */
/* Perform EC DHKEM KATs */
static int test_ec_dhkem_derivekey(int tstid)
{
int ret = 0;
EVP_PKEY *pkey = NULL;
OSSL_PARAM params[3];
EVP_PKEY_CTX *genctx = NULL;
const TEST_DERIVEKEY_DATA *t = &ec_derivekey_data[tstid];
unsigned char pubkey[133];
unsigned char privkey[66];
size_t pubkeylen = 0, privkeylen = 0;
BIGNUM *priv = NULL;
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME,
(char *)t->curvename, 0);
params[1] = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_DHKEM_IKM,
(char *)t->ikm, t->ikmlen);
params[2] = OSSL_PARAM_construct_end();
ret = TEST_ptr(genctx = EVP_PKEY_CTX_new_from_name(libctx, "EC", NULL))
&& TEST_int_eq(EVP_PKEY_keygen_init(genctx), 1)
&& TEST_int_eq(EVP_PKEY_CTX_set_params(genctx, params), 1)
&& TEST_int_eq(EVP_PKEY_generate(genctx, &pkey), 1)
&& TEST_true(EVP_PKEY_get_octet_string_param(pkey,
OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY,
pubkey, sizeof(pubkey), &pubkeylen))
&& TEST_true(EVP_PKEY_get_bn_param(pkey, OSSL_PKEY_PARAM_PRIV_KEY,
&priv))
&& TEST_int_gt(privkeylen = BN_bn2bin(priv, privkey), 0)
&& TEST_int_le(privkeylen, sizeof(privkey))
&& TEST_mem_eq(privkey, privkeylen, t->priv, t->privlen)
&& TEST_mem_eq(pubkey, pubkeylen, t->pub, t->publen);
BN_free(priv);
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(genctx);
return ret;
}
/*
* Test that encapsulation uses a random seed if the ikm is not specified,
* and verify that the shared secret matches the decapsulate result.
*/
static int test_ec_noikme(int tstid)
{
int ret = 0, auth = 0;
EVP_PKEY_CTX *ctx = NULL;
EVP_PKEY *recip = NULL;
EVP_PKEY *sender_auth = NULL;
unsigned char sender_secret[256];
unsigned char recip_secret[256];
unsigned char sender_pub[256];
size_t sender_secretlen = sizeof(sender_secret);
size_t recip_secretlen = sizeof(recip_secret);
size_t sender_publen = sizeof(sender_pub);
const char *curve;
int sz = OSSL_NELEM(dhkem_supported_curves);
const char *op = OSSL_KEM_PARAM_OPERATION_DHKEM;
if (tstid >= sz) {
auth = 1;
tstid -= sz;
}
curve = dhkem_supported_curves[tstid];
TEST_note("testing encap/decap of curve %s%s\n", curve,
auth ? " with auth" : "");
if (curve[0] == 'X') {
if (!TEST_ptr(recip = EVP_PKEY_Q_keygen(libctx, NULL, curve))
|| (auth
&& !TEST_ptr(sender_auth = EVP_PKEY_Q_keygen(libctx, NULL,
curve))))
goto err;
} else {
if (!TEST_ptr(recip = EVP_PKEY_Q_keygen(libctx, NULL, "EC", curve))
|| (auth
&& !TEST_ptr(sender_auth = EVP_PKEY_Q_keygen(libctx, NULL,
"EC", curve))))
goto err;
}
ret = TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, recip, NULL))
&& (sender_auth == NULL
|| TEST_int_eq(EVP_PKEY_auth_encapsulate_init(ctx, sender_auth,
NULL), 1))
&& (sender_auth != NULL
|| TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, NULL), 1))
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(ctx, op), 1)
&& TEST_int_eq(EVP_PKEY_encapsulate(ctx, sender_pub, &sender_publen,
sender_secret, &sender_secretlen), 1)
&& (sender_auth == NULL
|| TEST_int_eq(EVP_PKEY_auth_decapsulate_init(ctx, sender_auth,
NULL), 1))
&& (sender_auth != NULL
|| TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, NULL), 1))
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(ctx, op), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(ctx, recip_secret, &recip_secretlen,
sender_pub, sender_publen), 1)
&& TEST_mem_eq(recip_secret, recip_secretlen,
sender_secret, sender_secretlen);
err:
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(sender_auth);
EVP_PKEY_free(recip);
return ret;
}
/* Test encap/decap init fail if the curve is invalid */
static int do_ec_curve_failtest(const char *curve)
{
int ret;
EVP_PKEY *key = NULL;
EVP_PKEY_CTX *ctx = NULL;
ret = TEST_ptr(key = EVP_PKEY_Q_keygen(libctx, NULL, "EC", curve))
&& TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, key, NULL))
&& TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, NULL), -2)
&& TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, NULL), -2);
EVP_PKEY_free(key);
EVP_PKEY_CTX_free(ctx);
return ret;
}
static int test_ec_curve_nonnist(void)
{
return do_ec_curve_failtest("secp256k1");
}
static int test_ec_curve_unsupported(void)
{
return do_ec_curve_failtest("P-224");
}
/* Test that passing a bad recipient public EC key fails during encap/decap */
static int test_ec_badpublic(int tstid)
{
int ret = 0;
EVP_PKEY *recippriv = NULL;
EVP_PKEY_CTX *ctx = NULL;
unsigned char secret[256];
unsigned char pub[256];
size_t secretlen = sizeof(secret);
int encap = ((tstid & 1) == 0);
const TEST_ENCAPDATA *t = &ec_encapdata[0];
TEST_note("%s %s", t->curve, encap ? "Encap" : "Decap");
/* Set the recipient public key to the point at infinity */
pub[0] = 0;
if (!TEST_ptr(recippriv = new_raw_private_key(t->curve, t->rpriv, t->rprivlen,
pub, 1)))
goto err;
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, recippriv, NULL)))
goto err;
if (encap) {
unsigned char enc[256];
size_t enclen = sizeof(enc);
if (!TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, opparam), 1))
goto err;
if (!TEST_int_eq(EVP_PKEY_encapsulate(ctx, enc , &enclen,
secret, &secretlen), 0 ))
goto err;
} else {
if (!TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, opparam), 1))
goto err;
if (!TEST_int_eq(EVP_PKEY_decapsulate(ctx, secret, &secretlen,
t->expected_enc,
t->expected_enclen),
0))
goto err;
}
if (!TEST_int_eq(ERR_GET_REASON(ERR_get_error()), PROV_R_INVALID_KEY))
goto err;
ret = 1;
err:
EVP_PKEY_free(recippriv);
EVP_PKEY_CTX_free(ctx);
return ret;
}
static int test_ec_badauth(int tstid)
{
int ret = 0;
EVP_PKEY *auth = NULL;
unsigned char enc[256];
unsigned char secret[256];
unsigned char pub[256];
size_t enclen = sizeof(enc);
size_t secretlen = sizeof(secret);
int encap = ((tstid & 1) == 0);
const TEST_ENCAPDATA *t = &ec_encapdata[TEST_KEYTYPE_P256];
EVP_PKEY_CTX *ctx = rctx[TEST_KEYTYPE_P256];
TEST_note("%s %s", t->curve, encap ? "Encap" : "Decap");
/* Set the auth public key to the point at infinity */
pub[0] = 0;
if (!TEST_ptr(auth = new_raw_private_key(t->curve, t->rpriv, t->rprivlen,
pub, 1)))
goto err;
if (encap) {
if (!TEST_int_eq(EVP_PKEY_auth_encapsulate_init(ctx, auth,
opparam), 1)
|| !TEST_int_eq(EVP_PKEY_encapsulate(ctx, enc, &enclen,
secret, &secretlen), 0))
goto err;
} else {
if (!TEST_int_eq(EVP_PKEY_auth_decapsulate_init(ctx, auth, opparam), 1)
|| !TEST_int_eq(EVP_PKEY_decapsulate(ctx, secret, &secretlen,
t->expected_enc,
t->expected_enclen), 0))
goto err;
}
if (!TEST_int_eq(ERR_GET_REASON(ERR_get_error()), PROV_R_INVALID_KEY))
goto err;
ret = 1;
err:
EVP_PKEY_free(auth);
return ret;
}
static int test_ec_invalid_decap_enc_buffer(void)
{
const TEST_ENCAPDATA *t = &ec_encapdata[TEST_KEYTYPE_P256];
unsigned char enc[256];
unsigned char secret[256];
size_t secretlen = sizeof(secret);
EVP_PKEY_CTX *ctx = rctx[0];
memcpy(enc, t->expected_enc, t->expected_enclen);
enc[0] = 0xFF;
return TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, opparam), 1)
&& TEST_int_eq(EVP_PKEY_decapsulate(ctx, secret, &secretlen,
enc, t->expected_enclen), 0);
}
#ifndef OPENSSL_NO_ECX
/* ECX specific tests */
/* Perform ECX DHKEM KATs */
static int test_ecx_dhkem_derivekey(int tstid)
{
int ret;
OSSL_PARAM params[2];
EVP_PKEY_CTX *genctx;
EVP_PKEY *pkey = NULL;
unsigned char pubkey[64];
unsigned char privkey[64];
unsigned char masked_priv[64];
size_t pubkeylen = 0, privkeylen = 0;
const TEST_DERIVEKEY_DATA *t = &ecx_derivekey_data[tstid];
memcpy(masked_priv, t->priv, t->privlen);
if (OPENSSL_strcasecmp(t->curvename, "X25519") == 0) {
/*
* The RFC test vector seems incorrect since it is not in serialized form,
* So manually do the conversion here for now.
*/
masked_priv[0] &= 248;
masked_priv[t->privlen - 1] &= 127;
masked_priv[t->privlen - 1] |= 64;
} else {
masked_priv[0] &= 252;
masked_priv[t->privlen - 1] |= 128;
}
params[0] = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_DHKEM_IKM,
(char *)t->ikm, t->ikmlen);
params[1] = OSSL_PARAM_construct_end();
ret = TEST_ptr(genctx = EVP_PKEY_CTX_new_from_name(libctx, t->curvename, NULL))
&& TEST_int_eq(EVP_PKEY_keygen_init(genctx), 1)
&& TEST_int_eq(EVP_PKEY_CTX_set_params(genctx, params), 1)
&& TEST_int_eq(EVP_PKEY_keygen(genctx, &pkey), 1)
&& TEST_int_eq(EVP_PKEY_get_octet_string_param(pkey,
OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY,
pubkey, sizeof(pubkey), &pubkeylen), 1)
&& TEST_int_eq(EVP_PKEY_get_octet_string_param(pkey,
OSSL_PKEY_PARAM_PRIV_KEY,
privkey, sizeof(privkey), &privkeylen), 1)
&& TEST_mem_eq(t->pub, t->publen, pubkey, pubkeylen)
&& TEST_mem_eq(masked_priv, t->privlen, privkey, privkeylen);
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(genctx);
return ret;
}
/* Fail if the auth key has a different curve */
static int test_ecx_auth_key_curve_mismatch(void)
{
int ret = 0;
EVP_PKEY *auth = NULL;
if (!TEST_ptr(auth = EVP_PKEY_Q_keygen(libctx, NULL, "X448")))
return 0;
ret = TEST_int_eq(EVP_PKEY_auth_encapsulate_init(rctx[TEST_KEYTYPE_X25519],
auth, opparam), 0);
EVP_PKEY_free(auth);
return ret;
}
/* Fail if ED448 is used for DHKEM */
static int test_ed_curve_unsupported(void)
{
int ret;
EVP_PKEY *key = NULL;
EVP_PKEY_CTX *ctx = NULL;
ret = TEST_ptr(key = EVP_PKEY_Q_keygen(libctx, NULL, "ED448"))
&& TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, key, NULL))
&& TEST_int_eq(EVP_PKEY_encapsulate_init(ctx, NULL), -2)
&& TEST_int_eq(EVP_PKEY_decapsulate_init(ctx, NULL), -2);
EVP_PKEY_free(key);
EVP_PKEY_CTX_free(ctx);
return ret;
}
#endif
int setup_tests(void)
{
const char *prov_name = "default";
char *config_file = NULL;
char *op = OSSL_KEM_PARAM_OPERATION_DHKEM;
if (!test_get_libctx(&libctx, &nullprov, config_file, &libprov, prov_name))
return 0;
opparam[0] = OSSL_PARAM_construct_utf8_string(OSSL_KEM_PARAM_OPERATION,
op, 0);
opparam[1] = OSSL_PARAM_construct_end();
/* Create P256 and X25519 keys and ctxs */
if (!TEST_ptr(rkey[TEST_KEYTYPE_P256] = EVP_PKEY_Q_keygen(libctx, NULL,
"EC", "P-256")))
goto err;
#ifndef OPENSSL_NO_ECX
if (!TEST_ptr(rkey[TEST_KEYTYPE_X25519] = EVP_PKEY_Q_keygen(libctx, NULL,
"X25519")))
goto err;
#endif
if (!TEST_ptr(rctx[TEST_KEYTYPE_P256] =
EVP_PKEY_CTX_new_from_pkey(libctx,
rkey[TEST_KEYTYPE_P256], NULL)))
goto err;
#ifndef OPENSSL_NO_ECX
if (!TEST_ptr(rctx[TEST_KEYTYPE_X25519] =
EVP_PKEY_CTX_new_from_pkey(libctx,
rkey[TEST_KEYTYPE_X25519], NULL)))
goto err;
#endif
ADD_ALL_TESTS(test_dhkem_encapsulate, OSSL_NELEM(ec_encapdata));
ADD_ALL_TESTS(test_dhkem_decapsulate, OSSL_NELEM(ec_encapdata));
#ifndef OPENSSL_NO_ECX
ADD_ALL_TESTS(test_settables, TEST_KEYTYPES_P256_X25519);
ADD_ALL_TESTS(test_init_multiple, TEST_KEYTYPES_P256_X25519);
ADD_ALL_TESTS(test_auth_key_type_mismatch, TEST_KEYTYPES_P256_X25519);
ADD_ALL_TESTS(test_no_operation_set, TEST_KEYTYPES_P256_X25519);
ADD_ALL_TESTS(test_ikm_small, TEST_KEYTYPES_P256_X25519);
ADD_ALL_TESTS(test_input_size_small, TEST_KEYTYPES_P256_X25519);
ADD_ALL_TESTS(test_null_params, TEST_KEYTYPES_P256_X25519);
ADD_ALL_TESTS(test_set_params, TEST_KEYTYPES_P256_X25519);
ADD_ALL_TESTS(test_nopublic,
TEST_KEM_ENCAP_DECAP * TEST_KEYTYPES_P256_X25519);
ADD_ALL_TESTS(test_noauthpublic,
TEST_KEM_ENCAP_DECAP * TEST_KEYTYPES_P256_X25519);
#else
ADD_ALL_TESTS(test_settables, TEST_KEYTYPE_P256);
ADD_ALL_TESTS(test_init_multiple, TEST_KEYTYPE_P256);
ADD_ALL_TESTS(test_auth_key_type_mismatch, TEST_KEYTYPE_P256);
ADD_ALL_TESTS(test_no_operation_set, TEST_KEYTYPE_P256);
ADD_ALL_TESTS(test_ikm_small, TEST_KEYTYPE_P256);
ADD_ALL_TESTS(test_input_size_small, TEST_KEYTYPE_P256);
ADD_ALL_TESTS(test_null_params, TEST_KEYTYPE_P256);
ADD_ALL_TESTS(test_set_params, TEST_KEYTYPE_P256);
ADD_ALL_TESTS(test_nopublic,
TEST_KEM_ENCAP_DECAP * TEST_KEYTYPE_P256);
ADD_ALL_TESTS(test_noauthpublic,
TEST_KEM_ENCAP_DECAP * TEST_KEYTYPE_P256);
#endif
/* EC Specific tests */
ADD_ALL_TESTS(test_ec_dhkem_derivekey, OSSL_NELEM(ec_derivekey_data));
ADD_ALL_TESTS(test_ec_noikme,
TEST_TYPE_AUTH_NOAUTH * OSSL_NELEM(dhkem_supported_curves));
ADD_TEST(test_ec_auth_key_curve_mismatch);
ADD_TEST(test_ec_invalid_private_key);
ADD_TEST(test_ec_dhkem_derivekey_fail);
ADD_TEST(test_ec_curve_nonnist);
ADD_TEST(test_ec_curve_unsupported);
ADD_TEST(test_ec_invalid_decap_enc_buffer);
ADD_TEST(test_ec_public_key_infinity);
ADD_ALL_TESTS(test_ec_badpublic, TEST_KEM_ENCAP_DECAP);
ADD_ALL_TESTS(test_ec_badauth, TEST_KEM_ENCAP_DECAP);
/* ECX specific tests */
#ifndef OPENSSL_NO_ECX
ADD_ALL_TESTS(test_ecx_dhkem_derivekey, OSSL_NELEM(ecx_derivekey_data));
ADD_TEST(test_ecx_auth_key_curve_mismatch);
ADD_TEST(test_ed_curve_unsupported);
#endif
return 1;
err:
return 0;
}
void cleanup_tests(void)
{
EVP_PKEY_free(rkey[1]);
EVP_PKEY_free(rkey[0]);
EVP_PKEY_CTX_free(rctx[1]);
EVP_PKEY_CTX_free(rctx[0]);
OSSL_PROVIDER_unload(libprov);
OSSL_LIB_CTX_free(libctx);
OSSL_PROVIDER_unload(nullprov);
}
|
./openssl/test/rc2test.c | /*
* Copyright 1995-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
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
/*
* RC2 low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"
#include "internal/nelem.h"
#include "testutil.h"
#ifndef OPENSSL_NO_RC2
# include <openssl/rc2.h>
static unsigned char RC2key[4][16] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
};
static unsigned char RC2plain[4][8] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
};
static unsigned char RC2cipher[4][8] = {
{0x1C, 0x19, 0x8A, 0x83, 0x8D, 0xF0, 0x28, 0xB7},
{0x21, 0x82, 0x9C, 0x78, 0xA9, 0xF9, 0xC0, 0x74},
{0x13, 0xDB, 0x35, 0x17, 0xD3, 0x21, 0x86, 0x9E},
{0x50, 0xDC, 0x01, 0x62, 0xBD, 0x75, 0x7F, 0x31},
};
static int test_rc2(const int n)
{
int testresult = 1;
RC2_KEY key;
unsigned char buf[8], buf2[8];
RC2_set_key(&key, 16, &(RC2key[n][0]), 0 /* or 1024 */ );
RC2_ecb_encrypt(&RC2plain[n][0], buf, &key, RC2_ENCRYPT);
if (!TEST_mem_eq(&RC2cipher[n][0], 8, buf, 8))
testresult = 0;
RC2_ecb_encrypt(buf, buf2, &key, RC2_DECRYPT);
if (!TEST_mem_eq(&RC2plain[n][0], 8, buf2, 8))
testresult = 0;
return testresult;
}
#endif
int setup_tests(void)
{
#ifndef OPENSSL_NO_RC2
ADD_ALL_TESTS(test_rc2, OSSL_NELEM(RC2key));
#endif
return 1;
}
|
./openssl/test/quic_fifd_test.c | /*
* Copyright 2022-2023 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 "internal/packet.h"
#include "internal/quic_txpim.h"
#include "internal/quic_fifd.h"
#include "testutil.h"
static OSSL_TIME cur_time;
static OSSL_TIME fake_now(void *arg) {
return cur_time;
}
static void step_time(uint64_t ms) {
cur_time = ossl_time_add(cur_time, ossl_ms2time(ms));
}
static QUIC_SSTREAM *(*get_sstream_by_id_p)(uint64_t stream_id, uint32_t pn_space,
void *arg);
static QUIC_SSTREAM *get_sstream_by_id(uint64_t stream_id, uint32_t pn_space,
void *arg)
{
return get_sstream_by_id_p(stream_id, pn_space, arg);
}
static void (*regen_frame_p)(uint64_t frame_type, uint64_t stream_id,
QUIC_TXPIM_PKT *pkt, void *arg);
static void regen_frame(uint64_t frame_type, uint64_t stream_id,
QUIC_TXPIM_PKT *pkt, void *arg)
{
regen_frame_p(frame_type, stream_id, pkt, arg);
}
static void confirm_frame(uint64_t frame_type, uint64_t stream_id,
QUIC_TXPIM_PKT *pkt, void *arg)
{}
static void sstream_updated(uint64_t stream_id, void *arg)
{}
typedef struct info_st {
QUIC_FIFD fifd;
OSSL_ACKM *ackm;
QUIC_CFQ *cfq;
QUIC_TXPIM *txpim;
OSSL_STATM statm;
OSSL_CC_DATA *ccdata;
QUIC_SSTREAM *sstream[4];
} INFO;
static INFO *cur_info;
static int cb_fail;
static int cfq_freed;
/* ----------------------------------------------------------------------
* 1. Test that a submitted packet, on ack, acks all streams inside of it
* Test that a submitted packet, on ack, calls the get by ID function
* correctly
* Test that a submitted packet, on ack, acks all fins inside it
* Test that a submitted packet, on ack, releases the TXPIM packet
*/
static QUIC_SSTREAM *sstream_expect(uint64_t stream_id, uint32_t pn_space,
void *arg)
{
if (stream_id == 42 || stream_id == 43)
return cur_info->sstream[stream_id - 42];
cb_fail = 1;
return NULL;
}
static uint64_t regen_frame_type[16];
static uint64_t regen_stream_id[16];
static size_t regen_count;
static void regen_expect(uint64_t frame_type, uint64_t stream_id,
QUIC_TXPIM_PKT *pkt, void *arg)
{
regen_frame_type[regen_count] = frame_type;
regen_stream_id[regen_count] = stream_id;
++regen_count;
}
static const unsigned char placeholder_data[] = "placeholder";
static void cfq_free_cb_(unsigned char *buf, size_t buf_len, void *arg)
{
if (buf == placeholder_data && buf_len == sizeof(placeholder_data))
cfq_freed = 1;
}
#define TEST_KIND_ACK 0
#define TEST_KIND_LOSS 1
#define TEST_KIND_DISCARD 2
#define TEST_KIND_NUM 3
static int test_generic(INFO *info, int kind)
{
int testresult = 0;
size_t i, consumed = 0;
QUIC_TXPIM_PKT *pkt = NULL, *pkt2 = NULL;
OSSL_QUIC_FRAME_STREAM hdr = {0};
OSSL_QTX_IOVEC iov[2];
size_t num_iov;
QUIC_TXPIM_CHUNK chunk = {42, 0, 11, 0};
OSSL_QUIC_FRAME_ACK ack = {0};
OSSL_QUIC_ACK_RANGE ack_ranges[1] = {0};
QUIC_CFQ_ITEM *cfq_item = NULL;
uint32_t pn_space = (kind == TEST_KIND_DISCARD)
? QUIC_PN_SPACE_HANDSHAKE : QUIC_PN_SPACE_APP;
cur_time = ossl_seconds2time(1000);
regen_count = 0;
get_sstream_by_id_p = sstream_expect;
regen_frame_p = regen_expect;
if (!TEST_ptr(pkt = ossl_quic_txpim_pkt_alloc(info->txpim)))
goto err;
for (i = 0; i < 2; ++i) {
num_iov = OSSL_NELEM(iov);
if (!TEST_true(ossl_quic_sstream_append(info->sstream[i],
(unsigned char *)"Test message",
12, &consumed))
|| !TEST_size_t_eq(consumed, 12))
goto err;
if (i == 1)
ossl_quic_sstream_fin(info->sstream[i]);
if (!TEST_true(ossl_quic_sstream_get_stream_frame(info->sstream[i], 0,
&hdr, iov, &num_iov))
|| !TEST_int_eq(hdr.is_fin, i == 1)
|| !TEST_uint64_t_eq(hdr.offset, 0)
|| !TEST_uint64_t_eq(hdr.len, 12)
|| !TEST_size_t_eq(ossl_quic_sstream_get_buffer_used(info->sstream[i]), 12)
|| !TEST_true(ossl_quic_sstream_mark_transmitted(info->sstream[i],
hdr.offset,
hdr.offset + hdr.len - 1)))
goto err;
if (i == 1 && !TEST_true(ossl_quic_sstream_mark_transmitted_fin(info->sstream[i],
hdr.offset + hdr.len)))
goto err;
chunk.has_fin = hdr.is_fin;
chunk.stream_id = 42 + i;
if (!TEST_true(ossl_quic_txpim_pkt_append_chunk(pkt, &chunk)))
goto err;
}
cfq_freed = 0;
if (!TEST_ptr(cfq_item = ossl_quic_cfq_add_frame(info->cfq, 10,
pn_space,
OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID, 0,
placeholder_data,
sizeof(placeholder_data),
cfq_free_cb_, NULL))
|| !TEST_ptr_eq(cfq_item, ossl_quic_cfq_get_priority_head(info->cfq, pn_space)))
goto err;
ossl_quic_txpim_pkt_add_cfq_item(pkt, cfq_item);
pkt->ackm_pkt.pkt_num = 0;
pkt->ackm_pkt.pkt_space = pn_space;
pkt->ackm_pkt.largest_acked = QUIC_PN_INVALID;
pkt->ackm_pkt.num_bytes = 50;
pkt->ackm_pkt.time = cur_time;
pkt->ackm_pkt.is_inflight = 1;
pkt->ackm_pkt.is_ack_eliciting = 1;
if (kind == TEST_KIND_LOSS) {
pkt->had_handshake_done_frame = 1;
pkt->had_max_data_frame = 1;
pkt->had_max_streams_bidi_frame = 1;
pkt->had_max_streams_uni_frame = 1;
pkt->had_ack_frame = 1;
}
ack_ranges[0].start = 0;
ack_ranges[0].end = 0;
ack.ack_ranges = ack_ranges;
ack.num_ack_ranges = 1;
if (!TEST_true(ossl_quic_fifd_pkt_commit(&info->fifd, pkt)))
goto err;
/* CFQ item should have been marked as transmitted */
if (!TEST_ptr_null(ossl_quic_cfq_get_priority_head(info->cfq, pn_space)))
goto err;
switch (kind) {
case TEST_KIND_ACK:
if (!TEST_true(ossl_ackm_on_rx_ack_frame(info->ackm, &ack,
pn_space,
cur_time)))
goto err;
for (i = 0; i < 2; ++i)
if (!TEST_size_t_eq(ossl_quic_sstream_get_buffer_used(info->sstream[i]), 0))
goto err;
/* This should fail, which proves the FIN was acked */
if (!TEST_false(ossl_quic_sstream_mark_lost_fin(info->sstream[1])))
goto err;
/* CFQ item must have been released */
if (!TEST_true(cfq_freed))
goto err;
/* No regen calls should have been made */
if (!TEST_size_t_eq(regen_count, 0))
goto err;
break;
case TEST_KIND_LOSS:
/* Trigger loss detection via packet threshold. */
if (!TEST_ptr(pkt2 = ossl_quic_txpim_pkt_alloc(info->txpim)))
goto err;
step_time(10000);
pkt2->ackm_pkt.pkt_num = 50;
pkt2->ackm_pkt.pkt_space = pn_space;
pkt2->ackm_pkt.largest_acked = QUIC_PN_INVALID;
pkt2->ackm_pkt.num_bytes = 50;
pkt2->ackm_pkt.time = cur_time;
pkt2->ackm_pkt.is_inflight = 1;
pkt2->ackm_pkt.is_ack_eliciting = 1;
ack_ranges[0].start = 50;
ack_ranges[0].end = 50;
ack.ack_ranges = ack_ranges;
ack.num_ack_ranges = 1;
if (!TEST_true(ossl_quic_fifd_pkt_commit(&info->fifd, pkt2))
|| !TEST_true(ossl_ackm_on_rx_ack_frame(info->ackm, &ack,
pn_space, cur_time)))
goto err;
for (i = 0; i < 2; ++i) {
num_iov = OSSL_NELEM(iov);
/*
* Stream data we sent must have been marked as lost; check by
* ensuring it is returned again
*/
if (!TEST_true(ossl_quic_sstream_get_stream_frame(info->sstream[i], 0,
&hdr, iov, &num_iov))
|| !TEST_uint64_t_eq(hdr.offset, 0)
|| !TEST_uint64_t_eq(hdr.len, 12))
goto err;
}
/* FC frame should have regenerated for each stream */
if (!TEST_size_t_eq(regen_count, 7)
|| !TEST_uint64_t_eq(regen_stream_id[0], 42)
|| !TEST_uint64_t_eq(regen_frame_type[0], OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA)
|| !TEST_uint64_t_eq(regen_stream_id[1], 43)
|| !TEST_uint64_t_eq(regen_frame_type[1], OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA)
|| !TEST_uint64_t_eq(regen_frame_type[2], OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE)
|| !TEST_uint64_t_eq(regen_stream_id[2], UINT64_MAX)
|| !TEST_uint64_t_eq(regen_frame_type[3], OSSL_QUIC_FRAME_TYPE_MAX_DATA)
|| !TEST_uint64_t_eq(regen_stream_id[3], UINT64_MAX)
|| !TEST_uint64_t_eq(regen_frame_type[4], OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_BIDI)
|| !TEST_uint64_t_eq(regen_stream_id[4], UINT64_MAX)
|| !TEST_uint64_t_eq(regen_frame_type[5], OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_UNI)
|| !TEST_uint64_t_eq(regen_stream_id[5], UINT64_MAX)
|| !TEST_uint64_t_eq(regen_frame_type[6], OSSL_QUIC_FRAME_TYPE_ACK_WITH_ECN)
|| !TEST_uint64_t_eq(regen_stream_id[6], UINT64_MAX))
goto err;
/* CFQ item should have been marked as lost */
if (!TEST_ptr_eq(cfq_item, ossl_quic_cfq_get_priority_head(info->cfq, pn_space)))
goto err;
/* FIN should have been marked as lost */
num_iov = OSSL_NELEM(iov);
if (!TEST_true(ossl_quic_sstream_get_stream_frame(info->sstream[1], 1,
&hdr, iov, &num_iov))
|| !TEST_true(hdr.is_fin)
|| !TEST_uint64_t_eq(hdr.len, 0))
goto err;
break;
case TEST_KIND_DISCARD:
if (!TEST_true(ossl_ackm_on_pkt_space_discarded(info->ackm, pn_space)))
goto err;
/* CFQ item must have been released */
if (!TEST_true(cfq_freed))
goto err;
break;
default:
goto err;
}
/* TXPIM must have been released */
if (!TEST_size_t_eq(ossl_quic_txpim_get_in_use(info->txpim), 0))
goto err;
testresult = 1;
err:
return testresult;
}
static int test_fifd(int idx)
{
int testresult = 0;
INFO info = {0};
size_t i;
cur_info = &info;
cb_fail = 0;
if (!TEST_true(ossl_statm_init(&info.statm))
|| !TEST_ptr(info.ccdata = ossl_cc_dummy_method.new(fake_now, NULL))
|| !TEST_ptr(info.ackm = ossl_ackm_new(fake_now, NULL,
&info.statm,
&ossl_cc_dummy_method,
info.ccdata))
|| !TEST_true(ossl_ackm_on_handshake_confirmed(info.ackm))
|| !TEST_ptr(info.cfq = ossl_quic_cfq_new())
|| !TEST_ptr(info.txpim = ossl_quic_txpim_new())
|| !TEST_true(ossl_quic_fifd_init(&info.fifd, info.cfq, info.ackm,
info.txpim,
get_sstream_by_id, NULL,
regen_frame, NULL,
confirm_frame, NULL,
sstream_updated, NULL)))
goto err;
for (i = 0; i < OSSL_NELEM(info.sstream); ++i)
if (!TEST_ptr(info.sstream[i] = ossl_quic_sstream_new(1024)))
goto err;
ossl_statm_update_rtt(&info.statm, ossl_time_zero(), ossl_ms2time(1));
if (!TEST_true(test_generic(&info, idx))
|| !TEST_false(cb_fail))
goto err;
testresult = 1;
err:
ossl_quic_fifd_cleanup(&info.fifd);
ossl_quic_cfq_free(info.cfq);
ossl_quic_txpim_free(info.txpim);
ossl_ackm_free(info.ackm);
ossl_statm_destroy(&info.statm);
if (info.ccdata != NULL)
ossl_cc_dummy_method.free(info.ccdata);
for (i = 0; i < OSSL_NELEM(info.sstream); ++i)
ossl_quic_sstream_free(info.sstream[i]);
cur_info = NULL;
return testresult;
}
int setup_tests(void)
{
ADD_ALL_TESTS(test_fifd, TEST_KIND_NUM);
return 1;
}
|
./openssl/test/filterprov.h | /*
* Copyright 2021 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 <openssl/core_dispatch.h>
OSSL_provider_init_fn filter_provider_init;
int filter_provider_set_filter(int operation, const char *name);
int filter_provider_check_clean_finish(void);
|
./openssl/test/sm2_internal_test.c | /*
* Copyright 2017-2021 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
*/
/*
* Low level APIs are deprecated for public use, but still ok for internal use.
*/
#include "internal/deprecated.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <openssl/bn.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include "testutil.h"
#ifndef OPENSSL_NO_SM2
# include "crypto/sm2.h"
static fake_random_generate_cb get_faked_bytes;
static OSSL_PROVIDER *fake_rand = NULL;
static uint8_t *fake_rand_bytes = NULL;
static size_t fake_rand_bytes_offset = 0;
static size_t fake_rand_size = 0;
static int get_faked_bytes(unsigned char *buf, size_t num,
ossl_unused const char *name,
ossl_unused EVP_RAND_CTX *ctx)
{
if (!TEST_ptr(fake_rand_bytes) || !TEST_size_t_gt(fake_rand_size, 0))
return 0;
while (num-- > 0) {
if (fake_rand_bytes_offset >= fake_rand_size)
fake_rand_bytes_offset = 0;
*buf++ = fake_rand_bytes[fake_rand_bytes_offset++];
}
return 1;
}
static int start_fake_rand(const char *hex_bytes)
{
OPENSSL_free(fake_rand_bytes);
fake_rand_bytes_offset = 0;
fake_rand_size = strlen(hex_bytes) / 2;
if (!TEST_ptr(fake_rand_bytes = OPENSSL_hexstr2buf(hex_bytes, NULL)))
return 0;
/* use own random function */
fake_rand_set_public_private_callbacks(NULL, get_faked_bytes);
return 1;
}
static void restore_rand(void)
{
fake_rand_set_public_private_callbacks(NULL, NULL);
OPENSSL_free(fake_rand_bytes);
fake_rand_bytes = NULL;
fake_rand_bytes_offset = 0;
}
static EC_GROUP *create_EC_group(const char *p_hex, const char *a_hex,
const char *b_hex, const char *x_hex,
const char *y_hex, const char *order_hex,
const char *cof_hex)
{
BIGNUM *p = NULL;
BIGNUM *a = NULL;
BIGNUM *b = NULL;
BIGNUM *g_x = NULL;
BIGNUM *g_y = NULL;
BIGNUM *order = NULL;
BIGNUM *cof = NULL;
EC_POINT *generator = NULL;
EC_GROUP *group = NULL;
int ok = 0;
if (!TEST_true(BN_hex2bn(&p, p_hex))
|| !TEST_true(BN_hex2bn(&a, a_hex))
|| !TEST_true(BN_hex2bn(&b, b_hex)))
goto done;
group = EC_GROUP_new_curve_GFp(p, a, b, NULL);
if (!TEST_ptr(group))
goto done;
generator = EC_POINT_new(group);
if (!TEST_ptr(generator))
goto done;
if (!TEST_true(BN_hex2bn(&g_x, x_hex))
|| !TEST_true(BN_hex2bn(&g_y, y_hex))
|| !TEST_true(EC_POINT_set_affine_coordinates(group, generator, g_x,
g_y, NULL)))
goto done;
if (!TEST_true(BN_hex2bn(&order, order_hex))
|| !TEST_true(BN_hex2bn(&cof, cof_hex))
|| !TEST_true(EC_GROUP_set_generator(group, generator, order, cof)))
goto done;
ok = 1;
done:
BN_free(p);
BN_free(a);
BN_free(b);
BN_free(g_x);
BN_free(g_y);
EC_POINT_free(generator);
BN_free(order);
BN_free(cof);
if (!ok) {
EC_GROUP_free(group);
group = NULL;
}
return group;
}
static int test_sm2_crypt(const EC_GROUP *group,
const EVP_MD *digest,
const char *privkey_hex,
const char *message,
const char *k_hex, const char *ctext_hex)
{
const size_t msg_len = strlen(message);
BIGNUM *priv = NULL;
EC_KEY *key = NULL;
EC_POINT *pt = NULL;
unsigned char *expected = OPENSSL_hexstr2buf(ctext_hex, NULL);
size_t ctext_len = 0;
size_t ptext_len = 0;
uint8_t *ctext = NULL;
uint8_t *recovered = NULL;
size_t recovered_len = msg_len;
int rc = 0;
if (!TEST_ptr(expected)
|| !TEST_true(BN_hex2bn(&priv, privkey_hex)))
goto done;
key = EC_KEY_new();
if (!TEST_ptr(key)
|| !TEST_true(EC_KEY_set_group(key, group))
|| !TEST_true(EC_KEY_set_private_key(key, priv)))
goto done;
pt = EC_POINT_new(group);
if (!TEST_ptr(pt)
|| !TEST_true(EC_POINT_mul(group, pt, priv, NULL, NULL, NULL))
|| !TEST_true(EC_KEY_set_public_key(key, pt))
|| !TEST_true(ossl_sm2_ciphertext_size(key, digest, msg_len,
&ctext_len)))
goto done;
ctext = OPENSSL_zalloc(ctext_len);
if (!TEST_ptr(ctext))
goto done;
start_fake_rand(k_hex);
if (!TEST_true(ossl_sm2_encrypt(key, digest,
(const uint8_t *)message, msg_len,
ctext, &ctext_len))) {
restore_rand();
goto done;
}
restore_rand();
if (!TEST_mem_eq(ctext, ctext_len, expected, ctext_len))
goto done;
if (!TEST_true(ossl_sm2_plaintext_size(ctext, ctext_len, &ptext_len))
|| !TEST_int_eq(ptext_len, msg_len))
goto done;
recovered = OPENSSL_zalloc(ptext_len);
if (!TEST_ptr(recovered)
|| !TEST_true(ossl_sm2_decrypt(key, digest, ctext, ctext_len,
recovered, &recovered_len))
|| !TEST_int_eq(recovered_len, msg_len)
|| !TEST_mem_eq(recovered, recovered_len, message, msg_len))
goto done;
rc = 1;
done:
BN_free(priv);
EC_POINT_free(pt);
OPENSSL_free(ctext);
OPENSSL_free(recovered);
OPENSSL_free(expected);
EC_KEY_free(key);
return rc;
}
static int sm2_crypt_test(void)
{
int testresult = 0;
EC_GROUP *gm_group = NULL;
EC_GROUP *test_group =
create_EC_group
("8542D69E4C044F18E8B92435BF6FF7DE457283915C45517D722EDB8B08F1DFC3",
"787968B4FA32C3FD2417842E73BBFEFF2F3C848B6831D7E0EC65228B3937E498",
"63E4C6D3B23B0C849CF84241484BFE48F61D59A5B16BA06E6E12D1DA27C5249A",
"421DEBD61B62EAB6746434EBC3CC315E32220B3BADD50BDC4C4E6C147FEDD43D",
"0680512BCBB42C07D47349D2153B70C4E5D7FDFCBFA36EA1A85841B9E46E09A2",
"8542D69E4C044F18E8B92435BF6FF7DD297720630485628D5AE74EE7C32E79B7",
"1");
if (!TEST_ptr(test_group))
goto done;
if (!test_sm2_crypt(
test_group,
EVP_sm3(),
"1649AB77A00637BD5E2EFE283FBF353534AA7F7CB89463F208DDBC2920BB0DA0",
"encryption standard",
"004C62EEFD6ECFC2B95B92FD6C3D9575148AFA17425546D49018E5388D49DD7B4F"
"0092e8ff62146873c258557548500ab2df2a365e0609ab67640a1f6d57d7b17820"
"008349312695a3e1d2f46905f39a766487f2432e95d6be0cb009fe8c69fd8825a7",
"307B0220245C26FB68B1DDDDB12C4B6BF9F2B6D5FE60A383B0D18D1C4144ABF1"
"7F6252E7022076CB9264C2A7E88E52B19903FDC47378F605E36811F5C07423A2"
"4B84400F01B804209C3D7360C30156FAB7C80A0276712DA9D8094A634B766D3A"
"285E07480653426D0413650053A89B41C418B0C3AAD00D886C00286467"))
goto done;
/* Same test as above except using SHA-256 instead of SM3 */
if (!test_sm2_crypt(
test_group,
EVP_sha256(),
"1649AB77A00637BD5E2EFE283FBF353534AA7F7CB89463F208DDBC2920BB0DA0",
"encryption standard",
"004C62EEFD6ECFC2B95B92FD6C3D9575148AFA17425546D49018E5388D49DD7B4F"
"003da18008784352192d70f22c26c243174a447ba272fec64163dd4742bae8bc98"
"00df17605cf304e9dd1dfeb90c015e93b393a6f046792f790a6fa4228af67d9588",
"307B0220245C26FB68B1DDDDB12C4B6BF9F2B6D5FE60A383B0D18D1C4144ABF17F"
"6252E7022076CB9264C2A7E88E52B19903FDC47378F605E36811F5C07423A24B84"
"400F01B80420BE89139D07853100EFA763F60CBE30099EA3DF7F8F364F9D10A5E9"
"88E3C5AAFC0413229E6C9AEE2BB92CAD649FE2C035689785DA33"))
goto done;
/* From Annex C in both GM/T0003.5-2012 and GB/T 32918.5-2016.*/
gm_group = create_EC_group(
"fffffffeffffffffffffffffffffffffffffffff00000000ffffffffffffffff",
"fffffffeffffffffffffffffffffffffffffffff00000000fffffffffffffffc",
"28e9fa9e9d9f5e344d5a9e4bcf6509a7f39789f515ab8f92ddbcbd414d940e93",
"32c4ae2c1f1981195f9904466a39c9948fe30bbff2660be1715a4589334c74c7",
"bc3736a2f4f6779c59bdcee36b692153d0a9877cc62a474002df32e52139f0a0",
"fffffffeffffffffffffffffffffffff7203df6b21c6052b53bbf40939d54123",
"1");
if (!TEST_ptr(gm_group))
goto done;
if (!test_sm2_crypt(
gm_group,
EVP_sm3(),
/* privkey (from which the encrypting public key is derived) */
"3945208F7B2144B13F36E38AC6D39F95889393692860B51A42FB81EF4DF7C5B8",
/* plaintext message */
"encryption standard",
/* ephemeral nonce k */
"59276E27D506861A16680F3AD9C02DCCEF3CC1FA3CDBE4CE6D54B80DEAC1BC21",
/*
* expected ciphertext, the field values are from GM/T 0003.5-2012
* (Annex C), but serialized following the ASN.1 format specified
* in GM/T 0009-2012 (Sec. 7.2).
*/
"307C" /* SEQUENCE, 0x7c bytes */
"0220" /* INTEGER, 0x20 bytes */
"04EBFC718E8D1798620432268E77FEB6415E2EDE0E073C0F4F640ECD2E149A73"
"0221" /* INTEGER, 0x21 bytes */
"00" /* leading 00 due to DER for pos. int with topmost bit set */
"E858F9D81E5430A57B36DAAB8F950A3C64E6EE6A63094D99283AFF767E124DF0"
"0420" /* OCTET STRING, 0x20 bytes */
"59983C18F809E262923C53AEC295D30383B54E39D609D160AFCB1908D0BD8766"
"0413" /* OCTET STRING, 0x13 bytes */
"21886CA989CA9C7D58087307CA93092D651EFA"))
goto done;
testresult = 1;
done:
EC_GROUP_free(test_group);
EC_GROUP_free(gm_group);
return testresult;
}
static int test_sm2_sign(const EC_GROUP *group,
const char *userid,
const char *privkey_hex,
const char *message,
const char *k_hex,
const char *r_hex,
const char *s_hex)
{
const size_t msg_len = strlen(message);
int ok = 0;
BIGNUM *priv = NULL;
EC_POINT *pt = NULL;
EC_KEY *key = NULL;
ECDSA_SIG *sig = NULL;
const BIGNUM *sig_r = NULL;
const BIGNUM *sig_s = NULL;
BIGNUM *r = NULL;
BIGNUM *s = NULL;
if (!TEST_true(BN_hex2bn(&priv, privkey_hex)))
goto done;
key = EC_KEY_new();
if (!TEST_ptr(key)
|| !TEST_true(EC_KEY_set_group(key, group))
|| !TEST_true(EC_KEY_set_private_key(key, priv)))
goto done;
pt = EC_POINT_new(group);
if (!TEST_ptr(pt)
|| !TEST_true(EC_POINT_mul(group, pt, priv, NULL, NULL, NULL))
|| !TEST_true(EC_KEY_set_public_key(key, pt)))
goto done;
start_fake_rand(k_hex);
sig = ossl_sm2_do_sign(key, EVP_sm3(), (const uint8_t *)userid,
strlen(userid), (const uint8_t *)message, msg_len);
if (!TEST_ptr(sig)) {
restore_rand();
goto done;
}
restore_rand();
ECDSA_SIG_get0(sig, &sig_r, &sig_s);
if (!TEST_true(BN_hex2bn(&r, r_hex))
|| !TEST_true(BN_hex2bn(&s, s_hex))
|| !TEST_BN_eq(r, sig_r)
|| !TEST_BN_eq(s, sig_s))
goto done;
ok = ossl_sm2_do_verify(key, EVP_sm3(), sig, (const uint8_t *)userid,
strlen(userid), (const uint8_t *)message, msg_len);
/* We goto done whether this passes or fails */
TEST_true(ok);
done:
ECDSA_SIG_free(sig);
EC_POINT_free(pt);
EC_KEY_free(key);
BN_free(priv);
BN_free(r);
BN_free(s);
return ok;
}
static int sm2_sig_test(void)
{
int testresult = 0;
EC_GROUP *gm_group = NULL;
/* From draft-shen-sm2-ecdsa-02 */
EC_GROUP *test_group =
create_EC_group
("8542D69E4C044F18E8B92435BF6FF7DE457283915C45517D722EDB8B08F1DFC3",
"787968B4FA32C3FD2417842E73BBFEFF2F3C848B6831D7E0EC65228B3937E498",
"63E4C6D3B23B0C849CF84241484BFE48F61D59A5B16BA06E6E12D1DA27C5249A",
"421DEBD61B62EAB6746434EBC3CC315E32220B3BADD50BDC4C4E6C147FEDD43D",
"0680512BCBB42C07D47349D2153B70C4E5D7FDFCBFA36EA1A85841B9E46E09A2",
"8542D69E4C044F18E8B92435BF6FF7DD297720630485628D5AE74EE7C32E79B7",
"1");
if (!TEST_ptr(test_group))
goto done;
if (!TEST_true(test_sm2_sign(
test_group,
"ALICE123@YAHOO.COM",
"128B2FA8BD433C6C068C8D803DFF79792A519A55171B1B650C23661D15897263",
"message digest",
"006CB28D99385C175C94F94E934817663FC176D925DD72B727260DBAAE1FB2F96F"
"007c47811054c6f99613a578eb8453706ccb96384fe7df5c171671e760bfa8be3a",
"40F1EC59F793D9F49E09DCEF49130D4194F79FB1EED2CAA55BACDB49C4E755D1",
"6FC6DAC32C5D5CF10C77DFB20F7C2EB667A457872FB09EC56327A67EC7DEEBE7")))
goto done;
/* From Annex A in both GM/T0003.5-2012 and GB/T 32918.5-2016.*/
gm_group = create_EC_group(
"fffffffeffffffffffffffffffffffffffffffff00000000ffffffffffffffff",
"fffffffeffffffffffffffffffffffffffffffff00000000fffffffffffffffc",
"28e9fa9e9d9f5e344d5a9e4bcf6509a7f39789f515ab8f92ddbcbd414d940e93",
"32c4ae2c1f1981195f9904466a39c9948fe30bbff2660be1715a4589334c74c7",
"bc3736a2f4f6779c59bdcee36b692153d0a9877cc62a474002df32e52139f0a0",
"fffffffeffffffffffffffffffffffff7203df6b21c6052b53bbf40939d54123",
"1");
if (!TEST_ptr(gm_group))
goto done;
if (!TEST_true(test_sm2_sign(
gm_group,
/* the default ID specified in GM/T 0009-2012 (Sec. 10).*/
SM2_DEFAULT_USERID,
/* privkey */
"3945208F7B2144B13F36E38AC6D39F95889393692860B51A42FB81EF4DF7C5B8",
/* plaintext message */
"message digest",
/* ephemeral nonce k */
"59276E27D506861A16680F3AD9C02DCCEF3CC1FA3CDBE4CE6D54B80DEAC1BC21",
/* expected signature, the field values are from GM/T 0003.5-2012,
Annex A. */
/* signature R, 0x20 bytes */
"F5A03B0648D2C4630EEAC513E1BB81A15944DA3827D5B74143AC7EACEEE720B3",
/* signature S, 0x20 bytes */
"B1B6AA29DF212FD8763182BC0D421CA1BB9038FD1F7F42D4840B69C485BBC1AA")))
goto done;
testresult = 1;
done:
EC_GROUP_free(test_group);
EC_GROUP_free(gm_group);
return testresult;
}
#endif
int setup_tests(void)
{
#ifdef OPENSSL_NO_SM2
TEST_note("SM2 is disabled.");
#else
fake_rand = fake_rand_start(NULL);
if (fake_rand == NULL)
return 0;
ADD_TEST(sm2_crypt_test);
ADD_TEST(sm2_sig_test);
#endif
return 1;
}
void cleanup_tests(void)
{
#ifndef OPENSSL_NO_SM2
fake_rand_finish(fake_rand);
#endif
}
|
./openssl/test/fake_rsaprov.h | /*
* Copyright 2021-2023 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 <openssl/core_dispatch.h>
#define FAKE_PASSPHRASE "Passphrase Testing"
/* Fake RSA provider implementation */
OSSL_PROVIDER *fake_rsa_start(OSSL_LIB_CTX *libctx);
void fake_rsa_finish(OSSL_PROVIDER *p);
OSSL_PARAM *fake_rsa_key_params(int priv);
void fake_rsa_restore_store_state(void);
|
./openssl/test/provider_default_search_path_test.c | /*
* Copyright 2020-2022 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 <stddef.h>
#include <openssl/provider.h>
#include "testutil.h"
static int test_default_libctx(void)
{
OSSL_LIB_CTX *ctx = NULL;
char *path = "./some/path";
const char *retrieved_path = NULL;
int ok;
ok = TEST_true(OSSL_PROVIDER_set_default_search_path(ctx, path))
&& TEST_ptr(retrieved_path = OSSL_PROVIDER_get0_default_search_path(ctx))
&& TEST_str_eq(path, retrieved_path);
return ok;
}
static int test_explicit_libctx(void)
{
OSSL_LIB_CTX *ctx = NULL;
char *def_libctx_path = "./some/path";
char *path = "./another/location";
const char *retrieved_defctx_path = NULL;
const char *retrieved_path = NULL;
int ok;
/* Set search path for default context, then create a new context and set
another path for it. Finally, get both paths and make sure they are
still what we set and are separate. */
ok = TEST_true(OSSL_PROVIDER_set_default_search_path(NULL, def_libctx_path))
&& TEST_ptr(ctx = OSSL_LIB_CTX_new())
&& TEST_true(OSSL_PROVIDER_set_default_search_path(ctx, path))
&& TEST_ptr(retrieved_defctx_path = OSSL_PROVIDER_get0_default_search_path(NULL))
&& TEST_str_eq(def_libctx_path, retrieved_defctx_path)
&& TEST_ptr(retrieved_path = OSSL_PROVIDER_get0_default_search_path(ctx))
&& TEST_str_eq(path, retrieved_path)
&& TEST_str_ne(retrieved_path, retrieved_defctx_path);
OSSL_LIB_CTX_free(ctx);
return ok;
}
int setup_tests(void)
{
ADD_TEST(test_default_libctx);
ADD_TEST(test_explicit_libctx);
return 1;
}
|
./openssl/test/quic_txpim_test.c | /*
* Copyright 2022 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 "internal/packet.h"
#include "internal/quic_txpim.h"
#include "testutil.h"
static int test_txpim(void)
{
int testresult = 0;
QUIC_TXPIM *txpim;
size_t i, j;
QUIC_TXPIM_PKT *pkts[10] = {NULL};
QUIC_TXPIM_CHUNK chunks[3];
const QUIC_TXPIM_CHUNK *rchunks;
if (!TEST_ptr(txpim = ossl_quic_txpim_new()))
goto err;
for (i = 0; i < OSSL_NELEM(pkts); ++i) {
if (!TEST_ptr(pkts[i] = ossl_quic_txpim_pkt_alloc(txpim)))
goto err;
if (!TEST_size_t_eq(ossl_quic_txpim_pkt_get_num_chunks(pkts[i]), 0))
goto err;
for (j = 0; j < OSSL_NELEM(chunks); ++j) {
chunks[j].stream_id = 100 - j;
chunks[j].start = 1000 * i + j * 10;
chunks[j].end = chunks[j].start + 5;
if (!TEST_true(ossl_quic_txpim_pkt_append_chunk(pkts[i], chunks + j)))
goto err;
}
if (!TEST_size_t_eq(ossl_quic_txpim_pkt_get_num_chunks(pkts[i]),
OSSL_NELEM(chunks)))
goto err;
rchunks = ossl_quic_txpim_pkt_get_chunks(pkts[i]);
if (!TEST_uint64_t_eq(rchunks[0].stream_id, 98)
|| !TEST_uint64_t_eq(rchunks[1].stream_id, 99)
|| !TEST_uint64_t_eq(rchunks[2].stream_id, 100))
goto err;
}
testresult = 1;
err:
for (i = 0; i < OSSL_NELEM(pkts); ++i)
if (txpim != NULL && pkts[i] != NULL)
ossl_quic_txpim_pkt_release(txpim, pkts[i]);
ossl_quic_txpim_free(txpim);
return testresult;
}
int setup_tests(void)
{
ADD_TEST(test_txpim);
return 1;
}
|
./openssl/test/evp_xof_test.c | /*
* Copyright 2023 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 <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/core_names.h>
#include "testutil.h"
#include "internal/nelem.h"
static const unsigned char shake256_input[] = {
0x8d, 0x80, 0x01, 0xe2, 0xc0, 0x96, 0xf1, 0xb8,
0x8e, 0x7c, 0x92, 0x24, 0xa0, 0x86, 0xef, 0xd4,
0x79, 0x7f, 0xbf, 0x74, 0xa8, 0x03, 0x3a, 0x2d,
0x42, 0x2a, 0x2b, 0x6b, 0x8f, 0x67, 0x47, 0xe4
};
/*
* This KAT output is 250 bytes, which is more than
* the SHAKE256 block size (136 bytes).
*/
static const unsigned char shake256_output[] = {
0x2e, 0x97, 0x5f, 0x6a, 0x8a, 0x14, 0xf0, 0x70,
0x4d, 0x51, 0xb1, 0x36, 0x67, 0xd8, 0x19, 0x5c,
0x21, 0x9f, 0x71, 0xe6, 0x34, 0x56, 0x96, 0xc4,
0x9f, 0xa4, 0xb9, 0xd0, 0x8e, 0x92, 0x25, 0xd3,
0xd3, 0x93, 0x93, 0x42, 0x51, 0x52, 0xc9, 0x7e,
0x71, 0xdd, 0x24, 0x60, 0x1c, 0x11, 0xab, 0xcf,
0xa0, 0xf1, 0x2f, 0x53, 0xc6, 0x80, 0xbd, 0x3a,
0xe7, 0x57, 0xb8, 0x13, 0x4a, 0x9c, 0x10, 0xd4,
0x29, 0x61, 0x58, 0x69, 0x21, 0x7f, 0xdd, 0x58,
0x85, 0xc4, 0xdb, 0x17, 0x49, 0x85, 0x70, 0x3a,
0x6d, 0x6d, 0xe9, 0x4a, 0x66, 0x7e, 0xac, 0x30,
0x23, 0x44, 0x3a, 0x83, 0x37, 0xae, 0x1b, 0xc6,
0x01, 0xb7, 0x6d, 0x7d, 0x38, 0xec, 0x3c, 0x34,
0x46, 0x31, 0x05, 0xf0, 0xd3, 0x94, 0x9d, 0x78,
0xe5, 0x62, 0xa0, 0x39, 0xe4, 0x46, 0x95, 0x48,
0xb6, 0x09, 0x39, 0x5d, 0xe5, 0xa4, 0xfd, 0x43,
0xc4, 0x6c, 0xa9, 0xfd, 0x6e, 0xe2, 0x9a, 0xda,
0x5e, 0xfc, 0x07, 0xd8, 0x4d, 0x55, 0x32, 0x49,
0x45, 0x0d, 0xab, 0x4a, 0x49, 0xc4, 0x83, 0xde,
0xd2, 0x50, 0xc9, 0x33, 0x8f, 0x85, 0xcd, 0x93,
0x7a, 0xe6, 0x6b, 0xb4, 0x36, 0xf3, 0xb4, 0x02,
0x6e, 0x85, 0x9f, 0xda, 0x1c, 0xa5, 0x71, 0x43,
0x2f, 0x3b, 0xfc, 0x09, 0xe7, 0xc0, 0x3c, 0xa4,
0xd1, 0x83, 0xb7, 0x41, 0x11, 0x1c, 0xa0, 0x48,
0x3d, 0x0e, 0xda, 0xbc, 0x03, 0xfe, 0xb2, 0x3b,
0x17, 0xee, 0x48, 0xe8, 0x44, 0xba, 0x24, 0x08,
0xd9, 0xdc, 0xfd, 0x01, 0x39, 0xd2, 0xe8, 0xc7,
0x31, 0x01, 0x25, 0xae, 0xe8, 0x01, 0xc6, 0x1a,
0xb7, 0x90, 0x0d, 0x1e, 0xfc, 0x47, 0xc0, 0x78,
0x28, 0x17, 0x66, 0xf3, 0x61, 0xc5, 0xe6, 0x11,
0x13, 0x46, 0x23, 0x5e, 0x1d, 0xc3, 0x83, 0x25,
0x66, 0x6c
};
static const unsigned char shake256_largemsg_input[] = {
0xb2, 0xd2, 0x38, 0x65, 0xaf, 0x8f, 0x25, 0x6e,
0x64, 0x40, 0xe2, 0x0d, 0x49, 0x8e, 0x3e, 0x64,
0x46, 0xd2, 0x03, 0xa4, 0x19, 0xe3, 0x7b, 0x80,
0xf7, 0x2b, 0x32, 0xe2, 0x76, 0x01, 0xfe, 0xdd,
0xaa, 0x33, 0x3d, 0xe4, 0x8e, 0xe1, 0x5e, 0x39,
0xa6, 0x92, 0xa3, 0xa7, 0xe3, 0x81, 0x24, 0x74,
0xc7, 0x38, 0x18, 0x92, 0xc9, 0x60, 0x50, 0x15,
0xfb, 0xd8, 0x04, 0xea, 0xea, 0x04, 0xd2, 0xc5,
0xc6, 0x68, 0x04, 0x5b, 0xc3, 0x75, 0x12, 0xd2,
0xbe, 0xa2, 0x67, 0x75, 0x24, 0xbf, 0x68, 0xad,
0x10, 0x86, 0xb3, 0x2c, 0xb3, 0x74, 0xa4, 0x6c,
0xf9, 0xd7, 0x1e, 0x58, 0x69, 0x27, 0x88, 0x49,
0x4e, 0x99, 0x15, 0x33, 0x14, 0xf2, 0x49, 0x21,
0xf4, 0x99, 0xb9, 0xde, 0xd4, 0xf1, 0x12, 0xf5,
0x68, 0xe5, 0x5c, 0xdc, 0x9e, 0xc5, 0x80, 0x6d,
0x39, 0x50, 0x08, 0x95, 0xbb, 0x12, 0x27, 0x50,
0x89, 0xf0, 0xf9, 0xd5, 0x4a, 0x01, 0x0b, 0x0d,
0x90, 0x9f, 0x1e, 0x4a, 0xba, 0xbe, 0x28, 0x36,
0x19, 0x7d, 0x9c, 0x0a, 0x51, 0xfb, 0xeb, 0x00,
0x02, 0x6c, 0x4b, 0x0a, 0xa8, 0x6c, 0xb7, 0xc4,
0xc0, 0x92, 0x37, 0xa7, 0x2d, 0x49, 0x61, 0x80,
0xd9, 0xdb, 0x20, 0x21, 0x9f, 0xcf, 0xb4, 0x57,
0x69, 0x75, 0xfa, 0x1c, 0x95, 0xbf, 0xee, 0x0d,
0x9e, 0x52, 0x6e, 0x1e, 0xf8, 0xdd, 0x41, 0x8c,
0x3b, 0xaa, 0x57, 0x13, 0x84, 0x73, 0x52, 0x62,
0x18, 0x76, 0x46, 0xcc, 0x4b, 0xcb, 0xbd, 0x40,
0xa1, 0xf6, 0xff, 0x7b, 0x32, 0xb9, 0x90, 0x7c,
0x53, 0x2c, 0xf9, 0x38, 0x72, 0x0f, 0xcb, 0x90,
0x42, 0x5e, 0xe2, 0x80, 0x19, 0x26, 0xe7, 0x99,
0x96, 0x98, 0x18, 0xb1, 0x86, 0x5b, 0x4c, 0xd9,
0x08, 0x27, 0x31, 0x8f, 0xf0, 0x90, 0xd9, 0x35,
0x6a, 0x1f, 0x75, 0xc2, 0xe0, 0xa7, 0x60, 0xb8,
0x1d, 0xd6, 0x5f, 0x56, 0xb2, 0x0b, 0x27, 0x0e,
0x98, 0x67, 0x1f, 0x39, 0x18, 0x27, 0x68, 0x0a,
0xe8, 0x31, 0x1b, 0xc0, 0x97, 0xec, 0xd1, 0x20,
0x2a, 0x55, 0x69, 0x23, 0x08, 0x50, 0x05, 0xec,
0x13, 0x3b, 0x56, 0xfc, 0x18, 0xc9, 0x1a, 0xa9,
0x69, 0x0e, 0xe2, 0xcc, 0xc8, 0xd6, 0x19, 0xbb,
0x87, 0x3b, 0x42, 0x77, 0xee, 0x77, 0x81, 0x26,
0xdd, 0xf6, 0x5d, 0xc3, 0xb2, 0xb0, 0xc4, 0x14,
0x6d, 0xb5, 0x4f, 0xdc, 0x13, 0x09, 0xc8, 0x53,
0x50, 0xb3, 0xea, 0xd3, 0x5f, 0x11, 0x67, 0xd4,
0x2f, 0x6e, 0x30, 0x1a, 0xbe, 0xd6, 0xf0, 0x2d,
0xc9, 0x29, 0xd9, 0x0a, 0xa8, 0x6f, 0xa4, 0x18,
0x74, 0x6b, 0xd3, 0x5d, 0x6a, 0x73, 0x3a, 0xf2,
0x94, 0x7f, 0xbd, 0xb4, 0xa6, 0x7f, 0x5b, 0x3d,
0x26, 0xf2, 0x6c, 0x13, 0xcf, 0xb4, 0x26, 0x1e,
0x38, 0x17, 0x66, 0x60, 0xb1, 0x36, 0xae, 0xe0,
0x6d, 0x86, 0x69, 0xe7, 0xe7, 0xae, 0x77, 0x6f,
0x7e, 0x99, 0xe5, 0xd9, 0x62, 0xc9, 0xfc, 0xde,
0xb4, 0xee, 0x7e, 0xc8, 0xe9, 0xb7, 0x2c, 0xe2,
0x70, 0xe8, 0x8b, 0x2d, 0x94, 0xad, 0xe8, 0x54,
0xa3, 0x2d, 0x9a, 0xe2, 0x50, 0x63, 0x87, 0xb3,
0x56, 0x29, 0xea, 0xa8, 0x5e, 0x96, 0x53, 0x9f,
0x23, 0x8a, 0xef, 0xa3, 0xd4, 0x87, 0x09, 0x5f,
0xba, 0xc3, 0xd1, 0xd9, 0x1a, 0x7b, 0x5c, 0x5d,
0x5d, 0x89, 0xed, 0xb6, 0x6e, 0x39, 0x73, 0xa5,
0x64, 0x59, 0x52, 0x8b, 0x61, 0x8f, 0x66, 0x69,
0xb9, 0xf0, 0x45, 0x0a, 0x57, 0xcd, 0xc5, 0x7f,
0x5d, 0xd0, 0xbf, 0xcc, 0x0b, 0x48, 0x12, 0xe1,
0xe2, 0xc2, 0xea, 0xcc, 0x09, 0xd9, 0x42, 0x2c,
0xef, 0x4f, 0xa7, 0xe9, 0x32, 0x5c, 0x3f, 0x22,
0xc0, 0x45, 0x0b, 0x67, 0x3c, 0x31, 0x69, 0x29,
0xa3, 0x39, 0xdd, 0x6e, 0x2f, 0xbe, 0x10, 0xc9,
0x7b, 0xff, 0x19, 0x8a, 0xe9, 0xea, 0xfc, 0x32,
0x41, 0x33, 0x70, 0x2a, 0x9a, 0xa4, 0xe6, 0xb4,
0x7e, 0xb4, 0xc6, 0x21, 0x49, 0x5a, 0xfc, 0x45,
0xd2, 0x23, 0xb3, 0x28, 0x4d, 0x83, 0x60, 0xfe,
0x70, 0x68, 0x03, 0x59, 0xd5, 0x15, 0xaa, 0x9e,
0xa0, 0x2e, 0x36, 0xb5, 0x61, 0x0f, 0x61, 0x05,
0x3c, 0x62, 0x00, 0xa0, 0x47, 0xf1, 0x86, 0xba,
0x33, 0xb8, 0xca, 0x60, 0x2f, 0x3f, 0x0a, 0x67,
0x09, 0x27, 0x2f, 0xa2, 0x96, 0x02, 0x52, 0x58,
0x55, 0x68, 0x80, 0xf4, 0x4f, 0x47, 0xba, 0xff,
0x41, 0x7a, 0x40, 0x4c, 0xfd, 0x9d, 0x10, 0x72,
0x0e, 0x20, 0xa9, 0x7f, 0x9b, 0x9b, 0x14, 0xeb,
0x8e, 0x61, 0x25, 0xcb, 0xf4, 0x58, 0xff, 0x47,
0xa7, 0x08, 0xd6, 0x4e, 0x2b, 0xf1, 0xf9, 0x89,
0xd7, 0x22, 0x0f, 0x8d, 0x35, 0x07, 0xa0, 0x54,
0xab, 0x83, 0xd8, 0xee, 0x5a, 0x3e, 0x88, 0x74,
0x46, 0x41, 0x6e, 0x3e, 0xb7, 0xc0, 0xb6, 0x55,
0xe0, 0x36, 0xc0, 0x2b, 0xbf, 0xb8, 0x24, 0x8a,
0x44, 0x82, 0xf4, 0xcb, 0xb5, 0xd7, 0x41, 0x48,
0x51, 0x08, 0xe0, 0x14, 0x34, 0xd2, 0x6d, 0xe9,
0x7a, 0xec, 0x91, 0x61, 0xa7, 0xe1, 0x81, 0x69,
0x47, 0x1c, 0xc7, 0xf3
};
static const unsigned char shake256_largemsg_output[] = {
0x64, 0xea, 0x24, 0x6a, 0xab, 0x80, 0x37, 0x9e,
0x08, 0xe2, 0x19, 0x9e, 0x09, 0x69, 0xe2, 0xee,
0x1a, 0x5d, 0xd1, 0x68, 0x68, 0xec, 0x8d, 0x42,
0xd0, 0xf8, 0xb8, 0x44, 0x74, 0x54, 0x87, 0x3e,
};
static EVP_MD_CTX *shake_setup(const char *name)
{
EVP_MD_CTX *ctx = NULL;
EVP_MD *md = NULL;
if (!TEST_ptr(md = EVP_MD_fetch(NULL, name, NULL)))
return NULL;
if (!TEST_ptr(ctx = EVP_MD_CTX_new()))
goto err;
if (!TEST_true(EVP_DigestInit_ex2(ctx, md, NULL)))
goto err;
EVP_MD_free(md);
return ctx;
err:
EVP_MD_free(md);
EVP_MD_CTX_free(ctx);
return NULL;
}
static int shake_kat_test(void)
{
int ret = 0;
EVP_MD_CTX *ctx = NULL;
unsigned char out[sizeof(shake256_output)];
if (!TEST_ptr(ctx = shake_setup("SHAKE256")))
return 0;
if (!TEST_true(EVP_DigestUpdate(ctx, shake256_input,
sizeof(shake256_input)))
|| !TEST_true(EVP_DigestFinalXOF(ctx, out, sizeof(out)))
|| !TEST_mem_eq(out, sizeof(out),
shake256_output,sizeof(shake256_output))
/* Test that a second call to EVP_DigestFinalXOF fails */
|| !TEST_false(EVP_DigestFinalXOF(ctx, out, sizeof(out)))
/* Test that a call to EVP_DigestSqueeze fails */
|| !TEST_false(EVP_DigestSqueeze(ctx, out, sizeof(out))))
goto err;
ret = 1;
err:
EVP_MD_CTX_free(ctx);
return ret;
}
static int shake_kat_digestfinal_test(void)
{
int ret = 0;
unsigned int digest_length = 0;
EVP_MD_CTX *ctx = NULL;
unsigned char out[sizeof(shake256_output)];
if (!TEST_ptr(ctx = shake_setup("SHAKE256")))
return 0;
if (!TEST_true(EVP_DigestUpdate(ctx, shake256_input,
sizeof(shake256_input)))
|| !TEST_true(EVP_DigestFinal(ctx, out, &digest_length))
|| !TEST_uint_eq(digest_length, 32)
|| !TEST_mem_eq(out, digest_length,
shake256_output, digest_length)
|| !TEST_false(EVP_DigestFinalXOF(ctx, out, sizeof(out))))
goto err;
ret = 1;
err:
EVP_MD_CTX_free(ctx);
return ret;
}
/*
* Test that EVP_DigestFinal() returns the output length
* set by the OSSL_DIGEST_PARAM_XOFLEN param.
*/
static int shake_kat_digestfinal_xoflen_test(void)
{
int ret = 0;
unsigned int digest_length = 0;
EVP_MD_CTX *ctx = NULL;
unsigned char out[sizeof(shake256_output)];
OSSL_PARAM params[2];
size_t sz = 12;
if (!TEST_ptr(ctx = shake_setup("SHAKE256")))
return 0;
memset(out, 0, sizeof(out));
params[0] = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN, &sz);
params[1] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_MD_CTX_set_params(ctx, params), 1)
|| !TEST_true(EVP_DigestUpdate(ctx, shake256_input,
sizeof(shake256_input)))
|| !TEST_true(EVP_DigestFinal(ctx, out, &digest_length))
|| !TEST_uint_eq(digest_length, (unsigned int)sz)
|| !TEST_mem_eq(out, digest_length,
shake256_output, digest_length)
|| !TEST_uchar_eq(out[digest_length], 0))
goto err;
ret = 1;
err:
EVP_MD_CTX_free(ctx);
return ret;
}
/*
* Test that multiple absorb calls gives the expected result.
* This is a nested test that uses multiple strides for the input.
*/
static int shake_absorb_test(void)
{
int ret = 0;
EVP_MD_CTX *ctx = NULL;
unsigned char out[sizeof(shake256_largemsg_output)];
size_t total = sizeof(shake256_largemsg_input);
size_t i, stride, sz;
if (!TEST_ptr(ctx = shake_setup("SHAKE256")))
return 0;
for (stride = 1; stride < total; ++stride) {
sz = 0;
for (i = 0; i < total; i += sz) {
sz += stride;
if ((i + sz) > total)
sz = total - i;
if (!TEST_true(EVP_DigestUpdate(ctx, shake256_largemsg_input + i,
sz)))
goto err;
}
if (!TEST_true(EVP_DigestFinalXOF(ctx, out, sizeof(out)))
|| !TEST_mem_eq(out, sizeof(out),
shake256_largemsg_output,
sizeof(shake256_largemsg_output)))
goto err;
if (!TEST_true(EVP_DigestInit_ex2(ctx, NULL, NULL)))
goto err;
}
ret = 1;
err:
EVP_MD_CTX_free(ctx);
return ret;
}
/*
* Table containing the size of the output to squeeze for the
* initially call, followed by a size for each subsequent call.
*/
static const struct {
size_t startsz, incsz;
} stride_tests[] = {
{ 1, 1 },
{ 1, 136 },
{ 1, 136/2 },
{ 1, 136/2-1 },
{ 1, 136/2+1 },
{ 1, 136*3 },
{ 8, 8 },
{ 9, 9 },
{ 10, 10 },
{ 136/2 - 1, 136 },
{ 136/2 - 1, 136-1 },
{ 136/2 - 1, 136+1 },
{ 136/2, 136 },
{ 136/2, 136-1 },
{ 136/2, 136+1 },
{ 136/2 + 1, 136 },
{ 136/2 + 1, 136-1 },
{ 136/2 + 1, 136+1 },
{ 136, 2 },
{ 136, 136 },
{ 136-1, 136 },
{ 136-1, 136-1 },
{ 136-1, 136+1 },
{ 136+1, 136 },
{ 136+1, 136-1 },
{ 136+1, 136+1 },
{ 136*3, 136 },
{ 136*3, 136 + 1 },
{ 136*3, 136 - 1 },
{ 136*3, 136/2 },
{ 136*3, 136/2 + 1 },
{ 136*3, 136/2 - 1 },
};
/*
* Helper to do multiple squeezes of output data using SHAKE256.
* tst is an index into the stride_tests[] containing an initial starting
* output length, followed by a second output length to use for all remaining
* squeezes. expected_outlen contains the total number of bytes to squeeze.
* in and inlen represent the input to absorb. expected_out and expected_outlen
* represent the expected output.
*/
static int do_shake_squeeze_test(int tst,
const unsigned char *in, size_t inlen,
const unsigned char *expected_out,
size_t expected_outlen)
{
int ret = 0;
EVP_MD_CTX *ctx = NULL;
unsigned char *out = NULL;
size_t i = 0, sz = stride_tests[tst].startsz;
if (!TEST_ptr(ctx = shake_setup("SHAKE256")))
return 0;
if (!TEST_ptr(out = OPENSSL_malloc(expected_outlen)))
goto err;
if (!TEST_true(EVP_DigestUpdate(ctx, in, inlen)))
goto err;
while (i < expected_outlen) {
if ((i + sz) > expected_outlen)
sz = expected_outlen - i;
if (!TEST_true(EVP_DigestSqueeze(ctx, out + i, sz)))
goto err;
i += sz;
sz = stride_tests[tst].incsz;
}
if (!TEST_mem_eq(out, expected_outlen, expected_out, expected_outlen))
goto err;
ret = 1;
err:
OPENSSL_free(out);
EVP_MD_CTX_free(ctx);
return ret;
}
static int shake_squeeze_kat_test(int tst)
{
return do_shake_squeeze_test(tst, shake256_input, sizeof(shake256_input),
shake256_output, sizeof(shake256_output));
}
/*
* Generate some random input to absorb, and then
* squeeze it out in one operation to get a expected
* output. Use this to test that multiple squeeze calls
* on the same input gives the same output.
*/
static int shake_squeeze_large_test(int tst)
{
int ret = 0;
EVP_MD_CTX *ctx = NULL;
unsigned char msg[16];
unsigned char out[2000];
if (!TEST_int_gt(RAND_bytes(msg, sizeof(msg)), 0)
|| !TEST_ptr(ctx = shake_setup("SHAKE256"))
|| !TEST_true(EVP_DigestUpdate(ctx, msg, sizeof(msg)))
|| !TEST_true(EVP_DigestFinalXOF(ctx, out, sizeof(out))))
goto err;
ret = do_shake_squeeze_test(tst, msg, sizeof(msg), out, sizeof(out));
err:
EVP_MD_CTX_free(ctx);
return ret;
}
static const size_t dupoffset_tests[] = {
1, 135, 136, 137, 136*3-1, 136*3, 136*3+1
};
/* Helper function to test that EVP_MD_CTX_dup() copies the internal state */
static int do_shake_squeeze_dup_test(int tst, const char *alg,
const unsigned char *in, size_t inlen,
const unsigned char *expected_out,
size_t expected_outlen)
{
int ret = 0;
EVP_MD_CTX *cur, *ctx = NULL, *dupctx = NULL;
unsigned char *out = NULL;
size_t i = 0, sz = 10;
size_t dupoffset = dupoffset_tests[tst];
if (!TEST_ptr(ctx = shake_setup(alg)))
return 0;
cur = ctx;
if (!TEST_ptr(out = OPENSSL_malloc(expected_outlen)))
goto err;
if (!TEST_true(EVP_DigestUpdate(ctx, in, inlen)))
goto err;
while (i < expected_outlen) {
if ((i + sz) > expected_outlen)
sz = expected_outlen - i;
if (!TEST_true(EVP_DigestSqueeze(cur, out + i, sz)))
goto err;
i += sz;
/* At a certain offset we swap to a new ctx that copies the state */
if (dupctx == NULL && i >= dupoffset) {
if (!TEST_ptr(dupctx = EVP_MD_CTX_dup(ctx)))
goto err;
cur = dupctx;
}
}
if (!TEST_mem_eq(out, expected_outlen, expected_out, expected_outlen))
goto err;
ret = 1;
err:
OPENSSL_free(out);
EVP_MD_CTX_free(ctx);
EVP_MD_CTX_free(dupctx);
return ret;
}
/* Test that the internal state can be copied */
static int shake_squeeze_dup_test(int tst)
{
int ret = 0;
EVP_MD_CTX *ctx = NULL;
unsigned char msg[16];
unsigned char out[1000];
const char *alg = "SHAKE128";
if (!TEST_int_gt(RAND_bytes(msg, sizeof(msg)), 0)
|| !TEST_ptr(ctx = shake_setup(alg))
|| !TEST_true(EVP_DigestUpdate(ctx, msg, sizeof(msg)))
|| !TEST_true(EVP_DigestFinalXOF(ctx, out, sizeof(out))))
goto err;
ret = do_shake_squeeze_dup_test(tst, alg, msg, sizeof(msg),
out, sizeof(out));
err:
EVP_MD_CTX_free(ctx);
return ret;
}
int setup_tests(void)
{
ADD_TEST(shake_kat_test);
ADD_TEST(shake_kat_digestfinal_test);
ADD_TEST(shake_kat_digestfinal_xoflen_test);
ADD_TEST(shake_absorb_test);
ADD_ALL_TESTS(shake_squeeze_kat_test, OSSL_NELEM(stride_tests));
ADD_ALL_TESTS(shake_squeeze_large_test, OSSL_NELEM(stride_tests));
ADD_ALL_TESTS(shake_squeeze_dup_test, OSSL_NELEM(dupoffset_tests));
return 1;
}
|
./openssl/test/quic_srtm_test.c | /*
* Copyright 2023 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 "internal/quic_srtm.h"
#include "testutil.h"
static char ptrs[8];
static const QUIC_STATELESS_RESET_TOKEN token_1 = {{
0x01, 0x02, 0x03, 0x04
}};
static const QUIC_STATELESS_RESET_TOKEN token_2 = {{
0x01, 0x02, 0x03, 0x05
}};
static int test_srtm(void)
{
int testresult = 0;
QUIC_SRTM *srtm;
void *opaque = NULL;
uint64_t seq_num = 0;
if (!TEST_ptr(srtm = ossl_quic_srtm_new(NULL, NULL)))
goto err;
if (!TEST_true(ossl_quic_srtm_add(srtm, ptrs + 0, 0, &token_1))
|| !TEST_false(ossl_quic_srtm_add(srtm, ptrs + 0, 0, &token_1))
|| !TEST_false(ossl_quic_srtm_remove(srtm, ptrs + 0, 1))
|| !TEST_false(ossl_quic_srtm_remove(srtm, ptrs + 3, 0))
|| !TEST_true(ossl_quic_srtm_cull(srtm, ptrs + 3))
|| !TEST_true(ossl_quic_srtm_cull(srtm, ptrs + 3))
|| !TEST_true(ossl_quic_srtm_add(srtm, ptrs + 0, 1, &token_1))
|| !TEST_true(ossl_quic_srtm_add(srtm, ptrs + 0, 2, &token_1))
|| !TEST_true(ossl_quic_srtm_add(srtm, ptrs + 0, 3, &token_1))
|| !TEST_true(ossl_quic_srtm_add(srtm, ptrs + 1, 0, &token_1))
|| !TEST_true(ossl_quic_srtm_add(srtm, ptrs + 2, 0, &token_2))
|| !TEST_true(ossl_quic_srtm_add(srtm, ptrs + 3, 3, &token_2))
|| !TEST_true(ossl_quic_srtm_remove(srtm, ptrs + 3, 3))
|| !TEST_true(ossl_quic_srtm_lookup(srtm, &token_1, 0, &opaque, &seq_num))
|| !TEST_ptr_eq(opaque, ptrs + 1)
|| !TEST_uint64_t_eq(seq_num, 0)
|| !TEST_true(ossl_quic_srtm_lookup(srtm, &token_1, 1, &opaque, &seq_num))
|| !TEST_ptr_eq(opaque, ptrs + 0)
|| !TEST_uint64_t_eq(seq_num, 3)
|| !TEST_true(ossl_quic_srtm_lookup(srtm, &token_1, 2, &opaque, &seq_num))
|| !TEST_ptr_eq(opaque, ptrs + 0)
|| !TEST_uint64_t_eq(seq_num, 2)
|| !TEST_true(ossl_quic_srtm_lookup(srtm, &token_1, 3, &opaque, &seq_num))
|| !TEST_ptr_eq(opaque, ptrs + 0)
|| !TEST_uint64_t_eq(seq_num, 1)
|| !TEST_true(ossl_quic_srtm_lookup(srtm, &token_1, 4, &opaque, &seq_num))
|| !TEST_ptr_eq(opaque, ptrs + 0)
|| !TEST_uint64_t_eq(seq_num, 0)
|| !TEST_false(ossl_quic_srtm_lookup(srtm, &token_1, 5, &opaque, &seq_num))
|| !TEST_true(ossl_quic_srtm_cull(srtm, ptrs + 0))
|| !TEST_true(ossl_quic_srtm_lookup(srtm, &token_1, 0, &opaque, &seq_num))
|| !TEST_ptr_eq(opaque, ptrs + 1)
|| !TEST_uint64_t_eq(seq_num, 0)
|| !TEST_true(ossl_quic_srtm_lookup(srtm, &token_2, 0, &opaque, &seq_num))
|| !TEST_ptr_eq(opaque, ptrs + 2)
|| !TEST_uint64_t_eq(seq_num, 0)
|| !TEST_true(ossl_quic_srtm_remove(srtm, ptrs + 2, 0))
|| !TEST_false(ossl_quic_srtm_lookup(srtm, &token_2, 0, &opaque, &seq_num))
)
goto err;
testresult = 1;
err:
ossl_quic_srtm_free(srtm);
return testresult;
}
int setup_tests(void)
{
ADD_TEST(test_srtm);
return 1;
}
|
./openssl/test/asynciotest.c | /*
* 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 may obtain a copy of the License at
* https://www.openssl.org/source/license.html
* or in the file LICENSE in the source distribution.
*/
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include "internal/packet.h"
#include "helpers/ssltestlib.h"
#include "testutil.h"
/* Should we fragment records or not? 0 = no, !0 = yes*/
static int fragment = 0;
static char *cert = NULL;
static char *privkey = NULL;
static int async_new(BIO *bi);
static int async_free(BIO *a);
static int async_read(BIO *b, char *out, int outl);
static int async_write(BIO *b, const char *in, int inl);
static long async_ctrl(BIO *b, int cmd, long num, void *ptr);
static int async_gets(BIO *bp, char *buf, int size);
static int async_puts(BIO *bp, const char *str);
/* Choose a sufficiently large type likely to be unused for this custom BIO */
# define BIO_TYPE_ASYNC_FILTER (0x80 | BIO_TYPE_FILTER)
static BIO_METHOD *methods_async = NULL;
struct async_ctrs {
unsigned int rctr;
unsigned int wctr;
};
static const BIO_METHOD *bio_f_async_filter(void)
{
if (methods_async == NULL) {
methods_async = BIO_meth_new(BIO_TYPE_ASYNC_FILTER, "Async filter");
if ( methods_async == NULL
|| !BIO_meth_set_write(methods_async, async_write)
|| !BIO_meth_set_read(methods_async, async_read)
|| !BIO_meth_set_puts(methods_async, async_puts)
|| !BIO_meth_set_gets(methods_async, async_gets)
|| !BIO_meth_set_ctrl(methods_async, async_ctrl)
|| !BIO_meth_set_create(methods_async, async_new)
|| !BIO_meth_set_destroy(methods_async, async_free))
return NULL;
}
return methods_async;
}
static int async_new(BIO *bio)
{
struct async_ctrs *ctrs;
ctrs = OPENSSL_zalloc(sizeof(struct async_ctrs));
if (ctrs == NULL)
return 0;
BIO_set_data(bio, ctrs);
BIO_set_init(bio, 1);
return 1;
}
static int async_free(BIO *bio)
{
struct async_ctrs *ctrs;
if (bio == NULL)
return 0;
ctrs = BIO_get_data(bio);
OPENSSL_free(ctrs);
BIO_set_data(bio, NULL);
BIO_set_init(bio, 0);
return 1;
}
static int async_read(BIO *bio, char *out, int outl)
{
struct async_ctrs *ctrs;
int ret = 0;
BIO *next = BIO_next(bio);
if (outl <= 0)
return 0;
if (next == NULL)
return 0;
ctrs = BIO_get_data(bio);
BIO_clear_retry_flags(bio);
if (ctrs->rctr > 0) {
ret = BIO_read(next, out, 1);
if (ret <= 0 && BIO_should_read(next))
BIO_set_retry_read(bio);
ctrs->rctr = 0;
} else {
ctrs->rctr++;
BIO_set_retry_read(bio);
}
return ret;
}
#define MIN_RECORD_LEN 6
#define CONTENTTYPEPOS 0
#define VERSIONHIPOS 1
#define VERSIONLOPOS 2
#define DATAPOS 5
static int async_write(BIO *bio, const char *in, int inl)
{
struct async_ctrs *ctrs;
int ret = 0;
size_t written = 0;
BIO *next = BIO_next(bio);
if (inl <= 0)
return 0;
if (next == NULL)
return 0;
ctrs = BIO_get_data(bio);
BIO_clear_retry_flags(bio);
if (ctrs->wctr > 0) {
ctrs->wctr = 0;
if (fragment) {
PACKET pkt;
if (!PACKET_buf_init(&pkt, (const unsigned char *)in, inl))
return -1;
while (PACKET_remaining(&pkt) > 0) {
PACKET payload, wholebody, sessionid, extensions;
unsigned int contenttype, versionhi, versionlo, data;
unsigned int msgtype = 0, negversion = 0;
if (!PACKET_get_1(&pkt, &contenttype)
|| !PACKET_get_1(&pkt, &versionhi)
|| !PACKET_get_1(&pkt, &versionlo)
|| !PACKET_get_length_prefixed_2(&pkt, &payload))
return -1;
/* Pretend we wrote out the record header */
written += SSL3_RT_HEADER_LENGTH;
wholebody = payload;
if (contenttype == SSL3_RT_HANDSHAKE
&& !PACKET_get_1(&wholebody, &msgtype))
return -1;
if (msgtype == SSL3_MT_SERVER_HELLO) {
if (!PACKET_forward(&wholebody,
SSL3_HM_HEADER_LENGTH - 1)
|| !PACKET_get_net_2(&wholebody, &negversion)
/* Skip random (32 bytes) */
|| !PACKET_forward(&wholebody, 32)
/* Skip session id */
|| !PACKET_get_length_prefixed_1(&wholebody,
&sessionid)
/*
* Skip ciphersuite (2 bytes) and compression
* method (1 byte)
*/
|| !PACKET_forward(&wholebody, 2 + 1)
|| !PACKET_get_length_prefixed_2(&wholebody,
&extensions))
return -1;
/*
* Find the negotiated version in supported_versions
* extension, if present.
*/
while (PACKET_remaining(&extensions)) {
unsigned int type;
PACKET extbody;
if (!PACKET_get_net_2(&extensions, &type)
|| !PACKET_get_length_prefixed_2(&extensions,
&extbody))
return -1;
if (type == TLSEXT_TYPE_supported_versions
&& (!PACKET_get_net_2(&extbody, &negversion)
|| PACKET_remaining(&extbody) != 0))
return -1;
}
}
while (PACKET_get_1(&payload, &data)) {
/* Create a new one byte long record for each byte in the
* record in the input buffer
*/
char smallrec[MIN_RECORD_LEN] = {
0, /* Content type */
0, /* Version hi */
0, /* Version lo */
0, /* Length hi */
1, /* Length lo */
0 /* Data */
};
smallrec[CONTENTTYPEPOS] = contenttype;
smallrec[VERSIONHIPOS] = versionhi;
smallrec[VERSIONLOPOS] = versionlo;
smallrec[DATAPOS] = data;
ret = BIO_write(next, smallrec, MIN_RECORD_LEN);
if (ret <= 0)
return -1;
written++;
}
/*
* We can't fragment anything after the ServerHello (or CCS <=
* TLS1.2), otherwise we get a bad record MAC
*/
if (contenttype == SSL3_RT_CHANGE_CIPHER_SPEC
|| (negversion == TLS1_3_VERSION
&& msgtype == SSL3_MT_SERVER_HELLO)) {
fragment = 0;
break;
}
}
}
/* Write any data we have left after fragmenting */
ret = 0;
if ((int)written < inl) {
ret = BIO_write(next, in + written, inl - written);
}
if (ret <= 0 && BIO_should_write(next))
BIO_set_retry_write(bio);
else
ret += written;
} else {
ctrs->wctr++;
BIO_set_retry_write(bio);
}
return ret;
}
static long async_ctrl(BIO *bio, int cmd, long num, void *ptr)
{
long ret;
BIO *next = BIO_next(bio);
if (next == NULL)
return 0;
switch (cmd) {
case BIO_CTRL_DUP:
ret = 0L;
break;
default:
ret = BIO_ctrl(next, cmd, num, ptr);
break;
}
return ret;
}
static int async_gets(BIO *bio, char *buf, int size)
{
/* We don't support this - not needed anyway */
return -1;
}
static int async_puts(BIO *bio, const char *str)
{
return async_write(bio, str, strlen(str));
}
#define MAX_ATTEMPTS 100
static int test_asyncio(int test)
{
SSL_CTX *serverctx = NULL, *clientctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
BIO *s_to_c_fbio = NULL, *c_to_s_fbio = NULL;
int testresult = 0, ret;
size_t i, j;
const char testdata[] = "Test data";
char buf[sizeof(testdata)];
if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, 0,
&serverctx, &clientctx, cert, privkey)))
goto end;
/*
* We do 2 test runs. The first time around we just do a normal handshake
* with lots of async io going on. The second time around we also break up
* all records so that the content is only one byte length (up until the
* CCS)
*/
if (test == 1)
fragment = 1;
s_to_c_fbio = BIO_new(bio_f_async_filter());
c_to_s_fbio = BIO_new(bio_f_async_filter());
if (!TEST_ptr(s_to_c_fbio)
|| !TEST_ptr(c_to_s_fbio)) {
BIO_free(s_to_c_fbio);
BIO_free(c_to_s_fbio);
goto end;
}
/* BIOs get freed on error */
if (!TEST_true(create_ssl_objects(serverctx, clientctx, &serverssl,
&clientssl, s_to_c_fbio, c_to_s_fbio))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE)))
goto end;
/*
* Send and receive some test data. Do the whole thing twice to ensure
* we hit at least one async event in both reading and writing
*/
for (j = 0; j < 2; j++) {
int len;
/*
* Write some test data. It should never take more than 2 attempts
* (the first one might be a retryable fail).
*/
for (ret = -1, i = 0, len = 0; len != sizeof(testdata) && i < 2;
i++) {
ret = SSL_write(clientssl, testdata + len,
sizeof(testdata) - len);
if (ret > 0) {
len += ret;
} else {
int ssl_error = SSL_get_error(clientssl, ret);
if (!TEST_false(ssl_error == SSL_ERROR_SYSCALL ||
ssl_error == SSL_ERROR_SSL))
goto end;
}
}
if (!TEST_size_t_eq(len, sizeof(testdata)))
goto end;
/*
* Now read the test data. It may take more attempts here because
* it could fail once for each byte read, including all overhead
* bytes from the record header/padding etc.
*/
for (ret = -1, i = 0, len = 0; len != sizeof(testdata) &&
i < MAX_ATTEMPTS; i++) {
ret = SSL_read(serverssl, buf + len, sizeof(buf) - len);
if (ret > 0) {
len += ret;
} else {
int ssl_error = SSL_get_error(serverssl, ret);
if (!TEST_false(ssl_error == SSL_ERROR_SYSCALL ||
ssl_error == SSL_ERROR_SSL))
goto end;
}
}
if (!TEST_mem_eq(testdata, sizeof(testdata), buf, len))
goto end;
}
/* Also frees the BIOs */
SSL_free(clientssl);
SSL_free(serverssl);
clientssl = serverssl = NULL;
testresult = 1;
end:
SSL_free(clientssl);
SSL_free(serverssl);
SSL_CTX_free(clientctx);
SSL_CTX_free(serverctx);
return testresult;
}
OPT_TEST_DECLARE_USAGE("certname privkey\n")
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(cert = test_get_argument(0))
|| !TEST_ptr(privkey = test_get_argument(1)))
return 0;
ADD_ALL_TESTS(test_asyncio, 2);
return 1;
}
void cleanup_tests(void)
{
BIO_meth_free(methods_async);
}
|
./openssl/test/ecstresstest.c | /*
* Copyright 2017-2021 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 may obtain a copy of the License at
* https://www.openssl.org/source/license.html
* or in the file LICENSE in the source distribution.
*/
#include "internal/nelem.h"
#include "testutil.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define NUM_REPEATS "1000000"
static ossl_intmax_t num_repeats;
static int print_mode = 0;
#ifndef OPENSSL_NO_EC
# include <openssl/ec.h>
# include <openssl/err.h>
# include <openssl/obj_mac.h>
# include <openssl/objects.h>
# include <openssl/rand.h>
# include <openssl/bn.h>
# include <openssl/opensslconf.h>
static const char *kP256DefaultResult =
"A1E24B223B8E81BC1FFF99BAFB909EDB895FACDE7D6DA5EF5E7B3255FB378E0F";
/*
* Perform a deterministic walk on the curve, by starting from |point| and
* using the X-coordinate of the previous point as the next scalar for
* point multiplication.
* Returns the X-coordinate of the end result or NULL on error.
*/
static BIGNUM *walk_curve(const EC_GROUP *group, EC_POINT *point,
ossl_intmax_t num)
{
BIGNUM *scalar = NULL;
ossl_intmax_t i;
if (!TEST_ptr(scalar = BN_new())
|| !TEST_true(EC_POINT_get_affine_coordinates(group, point, scalar,
NULL, NULL)))
goto err;
for (i = 0; i < num; i++) {
if (!TEST_true(EC_POINT_mul(group, point, NULL, point, scalar, NULL))
|| !TEST_true(EC_POINT_get_affine_coordinates(group, point,
scalar,
NULL, NULL)))
goto err;
}
return scalar;
err:
BN_free(scalar);
return NULL;
}
static int test_curve(void)
{
EC_GROUP *group = NULL;
EC_POINT *point = NULL;
BIGNUM *result = NULL, *expected_result = NULL;
int ret = 0;
/*
* We currently hard-code P-256, though adaptation to other curves.
* would be straightforward.
*/
if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1))
|| !TEST_ptr(point = EC_POINT_dup(EC_GROUP_get0_generator(group),
group))
|| !TEST_ptr(result = walk_curve(group, point, num_repeats)))
return 0;
if (print_mode) {
BN_print(bio_out, result);
BIO_printf(bio_out, "\n");
ret = 1;
} else {
if (!TEST_true(BN_hex2bn(&expected_result, kP256DefaultResult))
|| !TEST_ptr(expected_result)
|| !TEST_BN_eq(result, expected_result))
goto err;
ret = 1;
}
err:
EC_GROUP_free(group);
EC_POINT_free(point);
BN_free(result);
BN_free(expected_result);
return ret;
}
#endif
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_NUM_REPEATS,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "num", OPT_NUM_REPEATS, 'M', "Number of repeats" },
{ NULL }
};
return test_options;
}
/*
* Stress test the curve. If the '-num' argument is given, runs the loop
* |num| times and prints the resulting X-coordinate. Otherwise runs the test
* the default number of times and compares against the expected result.
*/
int setup_tests(void)
{
OPTION_CHOICE o;
if (!opt_intmax(NUM_REPEATS, &num_repeats)) {
TEST_error("Cannot parse " NUM_REPEATS);
return 0;
}
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_NUM_REPEATS:
if (!opt_intmax(opt_arg(), &num_repeats)
|| num_repeats < 0)
return 0;
print_mode = 1;
break;
case OPT_TEST_CASES:
break;
default:
case OPT_ERR:
return 0;
}
}
#ifndef OPENSSL_NO_EC
ADD_TEST(test_curve);
#endif
return 1;
}
|
./openssl/test/priority_queue_test.c | /*
* Copyright 2022 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 <string.h>
#include <openssl/opensslconf.h>
#include <internal/priority_queue.h>
#include <openssl/err.h>
#include <openssl/crypto.h>
#include "internal/nelem.h"
#include "testutil.h"
#define MAX_SAMPLES 500000
DEFINE_PRIORITY_QUEUE_OF(size_t);
static size_t num_rec_freed;
static int size_t_compare(const size_t *a, const size_t *b)
{
if (*a < *b)
return -1;
if (*a > *b)
return 1;
return 0;
}
static int qsort_size_t_compare(const void *a, const void *b)
{
return size_t_compare((size_t *)a, (size_t *)b);
}
static int qsort_size_t_compare_rev(const void *a, const void *b)
{
return size_t_compare((size_t *)b, (size_t *)a);
}
static void free_checker(ossl_unused size_t *p)
{
num_rec_freed++;
}
static int test_size_t_priority_queue_int(int reserve, int order, int count,
int remove, int random, int popfree)
{
PRIORITY_QUEUE_OF(size_t) *pq = NULL;
static size_t values[MAX_SAMPLES], sorted[MAX_SAMPLES], ref[MAX_SAMPLES];
size_t n;
int i, res = 0;
static const char *orders[3] = { "unordered", "ascending", "descending" };
TEST_info("testing count %d, %s, %s, values %s, remove %d, %sfree",
count, orders[order], reserve ? "reserve" : "grow",
random ? "random" : "deterministic", remove,
popfree ? "pop " : "");
if (!TEST_size_t_le(count, MAX_SAMPLES))
return 0;
memset(values, 0, sizeof(values));
memset(sorted, 0, sizeof(sorted));
memset(ref, 0, sizeof(ref));
for (i = 0; i < count; i++)
values[i] = random ? test_random() : (size_t)(count - i);
memcpy(sorted, values, sizeof(*sorted) * count);
qsort(sorted, count, sizeof(*sorted), &qsort_size_t_compare);
if (order == 1)
memcpy(values, sorted, sizeof(*values) * count);
else if (order == 2)
qsort(values, count, sizeof(*values), &qsort_size_t_compare_rev);
if (!TEST_ptr(pq = ossl_pqueue_size_t_new(&size_t_compare))
|| !TEST_size_t_eq(ossl_pqueue_size_t_num(pq), 0))
goto err;
if (reserve && !TEST_true(ossl_pqueue_size_t_reserve(pq, count)))
goto err;
for (i = 0; i < count; i++)
if (!TEST_true(ossl_pqueue_size_t_push(pq, values + i, ref + i)))
goto err;
if (!TEST_size_t_eq(*ossl_pqueue_size_t_peek(pq), *sorted)
|| !TEST_size_t_eq(ossl_pqueue_size_t_num(pq), count))
goto err;
if (remove) {
while (remove-- > 0) {
i = test_random() % count;
if (values[i] != SIZE_MAX) {
if (!TEST_ptr_eq(ossl_pqueue_size_t_remove(pq, ref[i]),
values + i))
goto err;
values[i] = SIZE_MAX;
}
}
memcpy(sorted, values, sizeof(*sorted) * count);
qsort(sorted, count, sizeof(*sorted), &qsort_size_t_compare);
}
for (i = 0; ossl_pqueue_size_t_peek(pq) != NULL; i++)
if (!TEST_size_t_eq(*ossl_pqueue_size_t_peek(pq), sorted[i])
|| !TEST_size_t_eq(*ossl_pqueue_size_t_pop(pq), sorted[i]))
goto err;
if (popfree) {
num_rec_freed = 0;
n = ossl_pqueue_size_t_num(pq);
ossl_pqueue_size_t_pop_free(pq, &free_checker);
pq = NULL;
if (!TEST_size_t_eq(num_rec_freed, n))
goto err;
}
res = 1;
err:
ossl_pqueue_size_t_free(pq);
return res;
}
static const int test_size_t_priority_counts[] = {
10, 11, 6, 5, 3, 1, 2, 7500
};
static int test_size_t_priority_queue(int n)
{
int reserve, order, count, remove, random, popfree;
count = n % OSSL_NELEM(test_size_t_priority_counts);
n /= OSSL_NELEM(test_size_t_priority_counts);
order = n % 3;
n /= 3;
random = n % 2;
n /= 2;
reserve = n % 2;
n /= 2;
remove = n % 6;
n /= 6;
popfree = n % 2;
count = test_size_t_priority_counts[count];
return test_size_t_priority_queue_int(reserve, order, count, remove,
random, popfree);
}
static int test_large_priority_queue(void)
{
return test_size_t_priority_queue_int(0, 0, MAX_SAMPLES, MAX_SAMPLES / 100,
1, 1);
}
typedef struct info_st {
uint64_t seq_num, sub_seq;
size_t idx;
} INFO;
DEFINE_PRIORITY_QUEUE_OF(INFO);
static int cmp(const INFO *a, const INFO *b)
{
if (a->seq_num < b->seq_num)
return -1;
if (a->seq_num > b->seq_num)
return 1;
if (a->sub_seq < b->sub_seq)
return -1;
if (a->sub_seq > b->sub_seq)
return 1;
return 0;
}
static int test_22644(void)
{
size_t i;
INFO infos[32];
int res = 0;
PRIORITY_QUEUE_OF(INFO) *pq = ossl_pqueue_INFO_new(cmp);
memset(infos, 0, sizeof(infos));
for (i = 0; i < 32; ++i)
infos[i].sub_seq = i;
infos[0].seq_num = 70650219160667140;
if (!TEST_true(ossl_pqueue_INFO_push(pq, &infos[0], &infos[0].idx))
|| !TEST_size_t_eq(infos[0].idx, 7)
|| !TEST_ptr(ossl_pqueue_INFO_remove(pq, infos[0].idx)))
goto err;
infos[1].seq_num = 289360691352306692;
if (!TEST_true(ossl_pqueue_INFO_push(pq, &infos[1], &infos[1].idx))
|| !TEST_size_t_eq(infos[1].idx, 7)
|| !TEST_ptr(ossl_pqueue_INFO_remove(pq, infos[1].idx)))
goto err;
infos[2].seq_num = 289360691352306692;
if (!TEST_true(ossl_pqueue_INFO_push(pq, &infos[2], &infos[2].idx))
|| !TEST_size_t_eq(infos[2].idx, 7))
goto err;
infos[3].seq_num = 289360691352306692;
if (!TEST_true(ossl_pqueue_INFO_push(pq, &infos[3], &infos[3].idx))
|| !TEST_size_t_eq(infos[3].idx, 6))
goto err;
infos[4].seq_num = 289360691352306692;
if (!TEST_true(ossl_pqueue_INFO_push(pq, &infos[4], &infos[4].idx))
|| !TEST_size_t_eq(infos[4].idx, 5))
goto err;
infos[5].seq_num = 289360691352306692;
if (!TEST_true(ossl_pqueue_INFO_push(pq, &infos[5], &infos[5].idx))
|| !TEST_size_t_eq(infos[5].idx, 4))
goto err;
infos[6].seq_num = 289360691352306692;
if (!TEST_true(ossl_pqueue_INFO_push(pq, &infos[6], &infos[6].idx))
|| !TEST_size_t_eq(infos[6].idx, 3))
goto err;
infos[7].seq_num = 289360691352306692;
if (!TEST_true(ossl_pqueue_INFO_push(pq, &infos[7], &infos[7].idx))
|| !TEST_size_t_eq(infos[7].idx, 2))
goto err;
infos[8].seq_num = 289360691352306692;
if (!TEST_true(ossl_pqueue_INFO_push(pq, &infos[8], &infos[8].idx))
|| !TEST_size_t_eq(infos[8].idx, 1))
goto err;
if (!TEST_ptr(ossl_pqueue_INFO_pop(pq))
|| !TEST_ptr(ossl_pqueue_INFO_pop(pq))) /* crash if bug present */
goto err;
res = 1;
err:
ossl_pqueue_INFO_free(pq);
return res;
}
int setup_tests(void)
{
ADD_ALL_TESTS(test_size_t_priority_queue,
OSSL_NELEM(test_size_t_priority_counts) /* count */
* 3 /* order */
* 2 /* random */
* 2 /* reserve */
* 6 /* remove */
* 2); /* pop & free */
ADD_TEST(test_large_priority_queue);
ADD_TEST(test_22644);
return 1;
}
|
./openssl/test/igetest.c | /*
* Copyright 2006-2017 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
*/
/* The AES_ige_* functions are deprecated, so we suppress warnings about them */
#define OPENSSL_SUPPRESS_DEPRECATED
#include <openssl/crypto.h>
#include <openssl/aes.h>
#include <openssl/rand.h>
#include <stdio.h>
#include <string.h>
#include "internal/nelem.h"
#include "testutil.h"
#ifndef OPENSSL_NO_DEPRECATED_3_0
# define TEST_SIZE 128
# define BIG_TEST_SIZE 10240
# if BIG_TEST_SIZE < TEST_SIZE
# error BIG_TEST_SIZE is smaller than TEST_SIZE
# endif
static unsigned char rkey[16];
static unsigned char rkey2[16];
static unsigned char plaintext[BIG_TEST_SIZE];
static unsigned char saved_iv[AES_BLOCK_SIZE * 4];
# define MAX_VECTOR_SIZE 64
struct ige_test {
const unsigned char key[16];
const unsigned char iv[32];
const unsigned char in[MAX_VECTOR_SIZE];
const unsigned char out[MAX_VECTOR_SIZE];
const size_t length;
const int encrypt;
};
static struct ige_test const ige_test_vectors[] = {
{{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, /* key */
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}, /* iv */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* in */
{0x1a, 0x85, 0x19, 0xa6, 0x55, 0x7b, 0xe6, 0x52,
0xe9, 0xda, 0x8e, 0x43, 0xda, 0x4e, 0xf4, 0x45,
0x3c, 0xf4, 0x56, 0xb4, 0xca, 0x48, 0x8a, 0xa3,
0x83, 0xc7, 0x9c, 0x98, 0xb3, 0x47, 0x97, 0xcb}, /* out */
32, AES_ENCRYPT}, /* test vector 0 */
{{0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
0x61, 0x6e, 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x65}, /* key */
{0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x20, 0x6f, 0x66, 0x20, 0x49, 0x47, 0x45,
0x20, 0x6d, 0x6f, 0x64, 0x65, 0x20, 0x66, 0x6f,
0x72, 0x20, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53}, /* iv */
{0x4c, 0x2e, 0x20, 0x4c, 0x65, 0x74, 0x27, 0x73,
0x20, 0x68, 0x6f, 0x70, 0x65, 0x20, 0x42, 0x65,
0x6e, 0x20, 0x67, 0x6f, 0x74, 0x20, 0x69, 0x74,
0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x21, 0x0a}, /* in */
{0x99, 0x70, 0x64, 0x87, 0xa1, 0xcd, 0xe6, 0x13,
0xbc, 0x6d, 0xe0, 0xb6, 0xf2, 0x4b, 0x1c, 0x7a,
0xa4, 0x48, 0xc8, 0xb9, 0xc3, 0x40, 0x3e, 0x34,
0x67, 0xa8, 0xca, 0xd8, 0x93, 0x40, 0xf5, 0x3b}, /* out */
32, AES_DECRYPT}, /* test vector 1 */
};
struct bi_ige_test {
const unsigned char key1[32];
const unsigned char key2[32];
const unsigned char iv[64];
const unsigned char in[MAX_VECTOR_SIZE];
const unsigned char out[MAX_VECTOR_SIZE];
const size_t keysize;
const size_t length;
const int encrypt;
};
static struct bi_ige_test const bi_ige_test_vectors[] = {
{{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, /* key1 */
{0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}, /* key2 */
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}, /* iv */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* in */
{0x14, 0x40, 0x6f, 0xae, 0xa2, 0x79, 0xf2, 0x56,
0x1f, 0x86, 0xeb, 0x3b, 0x7d, 0xff, 0x53, 0xdc,
0x4e, 0x27, 0x0c, 0x03, 0xde, 0x7c, 0xe5, 0x16,
0x6a, 0x9c, 0x20, 0x33, 0x9d, 0x33, 0xfe, 0x12}, /* out */
16, 32, AES_ENCRYPT}, /* test vector 0 */
{{0x58, 0x0a, 0x06, 0xe9, 0x97, 0x07, 0x59, 0x5c,
0x9e, 0x19, 0xd2, 0xa7, 0xbb, 0x40, 0x2b, 0x7a,
0xc7, 0xd8, 0x11, 0x9e, 0x4c, 0x51, 0x35, 0x75,
0x64, 0x28, 0x0f, 0x23, 0xad, 0x74, 0xac, 0x37}, /* key1 */
{0xd1, 0x80, 0xa0, 0x31, 0x47, 0xa3, 0x11, 0x13,
0x86, 0x26, 0x9e, 0x6d, 0xff, 0xaf, 0x72, 0x74,
0x5b, 0xa2, 0x35, 0x81, 0xd2, 0xa6, 0x3d, 0x21,
0x67, 0x7b, 0x58, 0xa8, 0x18, 0xf9, 0x72, 0xe4}, /* key2 */
{0x80, 0x3d, 0xbd, 0x4c, 0xe6, 0x7b, 0x06, 0xa9,
0x53, 0x35, 0xd5, 0x7e, 0x71, 0xc1, 0x70, 0x70,
0x74, 0x9a, 0x00, 0x28, 0x0c, 0xbf, 0x6c, 0x42,
0x9b, 0xa4, 0xdd, 0x65, 0x11, 0x77, 0x7c, 0x67,
0xfe, 0x76, 0x0a, 0xf0, 0xd5, 0xc6, 0x6e, 0x6a,
0xe7, 0x5e, 0x4c, 0xf2, 0x7e, 0x9e, 0xf9, 0x20,
0x0e, 0x54, 0x6f, 0x2d, 0x8a, 0x8d, 0x7e, 0xbd,
0x48, 0x79, 0x37, 0x99, 0xff, 0x27, 0x93, 0xa3}, /* iv */
{0xf1, 0x54, 0x3d, 0xca, 0xfe, 0xb5, 0xef, 0x1c,
0x4f, 0xa6, 0x43, 0xf6, 0xe6, 0x48, 0x57, 0xf0,
0xee, 0x15, 0x7f, 0xe3, 0xe7, 0x2f, 0xd0, 0x2f,
0x11, 0x95, 0x7a, 0x17, 0x00, 0xab, 0xa7, 0x0b,
0xbe, 0x44, 0x09, 0x9c, 0xcd, 0xac, 0xa8, 0x52,
0xa1, 0x8e, 0x7b, 0x75, 0xbc, 0xa4, 0x92, 0x5a,
0xab, 0x46, 0xd3, 0x3a, 0xa0, 0xd5, 0x35, 0x1c,
0x55, 0xa4, 0xb3, 0xa8, 0x40, 0x81, 0xa5, 0x0b}, /* in */
{0x42, 0xe5, 0x28, 0x30, 0x31, 0xc2, 0xa0, 0x23,
0x68, 0x49, 0x4e, 0xb3, 0x24, 0x59, 0x92, 0x79,
0xc1, 0xa5, 0xcc, 0xe6, 0x76, 0x53, 0xb1, 0xcf,
0x20, 0x86, 0x23, 0xe8, 0x72, 0x55, 0x99, 0x92,
0x0d, 0x16, 0x1c, 0x5a, 0x2f, 0xce, 0xcb, 0x51,
0xe2, 0x67, 0xfa, 0x10, 0xec, 0xcd, 0x3d, 0x67,
0xa5, 0xe6, 0xf7, 0x31, 0x26, 0xb0, 0x0d, 0x76,
0x5e, 0x28, 0xdc, 0x7f, 0x01, 0xc5, 0xa5, 0x4c}, /* out */
32, 64, AES_ENCRYPT}, /* test vector 1 */
};
static int test_ige_vectors(int n)
{
const struct ige_test *const v = &ige_test_vectors[n];
AES_KEY key;
unsigned char buf[MAX_VECTOR_SIZE];
unsigned char iv[AES_BLOCK_SIZE * 2];
int testresult = 1;
if (!TEST_int_le(v->length, MAX_VECTOR_SIZE))
return 0;
if (v->encrypt == AES_ENCRYPT)
AES_set_encrypt_key(v->key, 8 * sizeof(v->key), &key);
else
AES_set_decrypt_key(v->key, 8 * sizeof(v->key), &key);
memcpy(iv, v->iv, sizeof(iv));
AES_ige_encrypt(v->in, buf, v->length, &key, iv, v->encrypt);
if (!TEST_mem_eq(v->out, v->length, buf, v->length)) {
TEST_info("IGE test vector %d failed", n);
test_output_memory("key", v->key, sizeof(v->key));
test_output_memory("iv", v->iv, sizeof(v->iv));
test_output_memory("in", v->in, v->length);
testresult = 0;
}
/* try with in == out */
memcpy(iv, v->iv, sizeof(iv));
memcpy(buf, v->in, v->length);
AES_ige_encrypt(buf, buf, v->length, &key, iv, v->encrypt);
if (!TEST_mem_eq(v->out, v->length, buf, v->length)) {
TEST_info("IGE test vector %d failed (with in == out)", n);
test_output_memory("key", v->key, sizeof(v->key));
test_output_memory("iv", v->iv, sizeof(v->iv));
test_output_memory("in", v->in, v->length);
testresult = 0;
}
return testresult;
}
static int test_bi_ige_vectors(int n)
{
const struct bi_ige_test *const v = &bi_ige_test_vectors[n];
AES_KEY key1;
AES_KEY key2;
unsigned char buf[MAX_VECTOR_SIZE];
if (!TEST_int_le(v->length, MAX_VECTOR_SIZE))
return 0;
if (v->encrypt == AES_ENCRYPT) {
AES_set_encrypt_key(v->key1, 8 * v->keysize, &key1);
AES_set_encrypt_key(v->key2, 8 * v->keysize, &key2);
} else {
AES_set_decrypt_key(v->key1, 8 * v->keysize, &key1);
AES_set_decrypt_key(v->key2, 8 * v->keysize, &key2);
}
AES_bi_ige_encrypt(v->in, buf, v->length, &key1, &key2, v->iv,
v->encrypt);
if (!TEST_mem_eq(v->out, v->length, buf, v->length)) {
test_output_memory("key 1", v->key1, sizeof(v->key1));
test_output_memory("key 2", v->key2, sizeof(v->key2));
test_output_memory("iv", v->iv, sizeof(v->iv));
test_output_memory("in", v->in, v->length);
return 0;
}
return 1;
}
static int test_ige_enc_dec(void)
{
AES_KEY key;
unsigned char iv[AES_BLOCK_SIZE * 4];
unsigned char ciphertext[BIG_TEST_SIZE];
unsigned char checktext[BIG_TEST_SIZE];
memcpy(iv, saved_iv, sizeof(iv));
AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE, &key, iv, AES_ENCRYPT);
AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, iv, AES_DECRYPT);
return TEST_mem_eq(checktext, TEST_SIZE, plaintext, TEST_SIZE);
}
static int test_ige_enc_chaining(void)
{
AES_KEY key;
unsigned char iv[AES_BLOCK_SIZE * 4];
unsigned char ciphertext[BIG_TEST_SIZE];
unsigned char checktext[BIG_TEST_SIZE];
AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE / 2, &key, iv,
AES_ENCRYPT);
AES_ige_encrypt(plaintext + TEST_SIZE / 2,
ciphertext + TEST_SIZE / 2, TEST_SIZE / 2,
&key, iv, AES_ENCRYPT);
AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, iv, AES_DECRYPT);
return TEST_mem_eq(checktext, TEST_SIZE, plaintext, TEST_SIZE);
}
static int test_ige_dec_chaining(void)
{
AES_KEY key;
unsigned char iv[AES_BLOCK_SIZE * 4];
unsigned char ciphertext[BIG_TEST_SIZE];
unsigned char checktext[BIG_TEST_SIZE];
AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE / 2, &key, iv,
AES_ENCRYPT);
AES_ige_encrypt(plaintext + TEST_SIZE / 2,
ciphertext + TEST_SIZE / 2, TEST_SIZE / 2,
&key, iv, AES_ENCRYPT);
AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(ciphertext, checktext, TEST_SIZE / 2, &key, iv,
AES_DECRYPT);
AES_ige_encrypt(ciphertext + TEST_SIZE / 2,
checktext + TEST_SIZE / 2, TEST_SIZE / 2, &key, iv,
AES_DECRYPT);
return TEST_mem_eq(checktext, TEST_SIZE, plaintext, TEST_SIZE);
}
static int test_ige_garble_forwards(void)
{
AES_KEY key;
unsigned char iv[AES_BLOCK_SIZE * 4];
unsigned char ciphertext[BIG_TEST_SIZE];
unsigned char checktext[BIG_TEST_SIZE];
unsigned int n;
int testresult = 1;
const size_t ctsize = sizeof(checktext);
size_t matches;
AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
AES_ENCRYPT);
/* corrupt halfway through */
++ciphertext[sizeof(ciphertext) / 2];
AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv,
AES_DECRYPT);
matches = 0;
for (n = 0; n < sizeof(checktext); ++n)
if (checktext[n] == plaintext[n])
++matches;
/* Fail if there is more than 51% matching bytes */
if (!TEST_size_t_le(matches, ctsize / 2 + ctsize / 100))
testresult = 0;
/* Fail if the garble goes backwards */
if (!TEST_size_t_gt(matches, ctsize / 2))
testresult = 0;
return testresult;
}
static int test_bi_ige_enc_dec(void)
{
AES_KEY key, key2;
unsigned char iv[AES_BLOCK_SIZE * 4];
unsigned char ciphertext[BIG_TEST_SIZE];
unsigned char checktext[BIG_TEST_SIZE];
memcpy(iv, saved_iv, sizeof(iv));
AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_bi_ige_encrypt(plaintext, ciphertext, TEST_SIZE, &key, &key2, iv,
AES_ENCRYPT);
AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_bi_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, &key2, iv,
AES_DECRYPT);
return TEST_mem_eq(checktext, TEST_SIZE, plaintext, TEST_SIZE);
}
static int test_bi_ige_garble1(void)
{
AES_KEY key, key2;
unsigned char iv[AES_BLOCK_SIZE * 4];
unsigned char ciphertext[BIG_TEST_SIZE];
unsigned char checktext[BIG_TEST_SIZE];
unsigned int n;
size_t matches;
memcpy(iv, saved_iv, sizeof(iv));
AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
AES_ENCRYPT);
/* corrupt halfway through */
++ciphertext[sizeof(ciphertext) / 2];
AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv,
AES_DECRYPT);
matches = 0;
for (n = 0; n < sizeof(checktext); ++n)
if (checktext[n] == plaintext[n])
++matches;
/* Fail if there is more than 1% matching bytes */
return TEST_size_t_le(matches, sizeof(checktext) / 100);
}
static int test_bi_ige_garble2(void)
{
AES_KEY key, key2;
unsigned char iv[AES_BLOCK_SIZE * 4];
unsigned char ciphertext[BIG_TEST_SIZE];
unsigned char checktext[BIG_TEST_SIZE];
unsigned int n;
size_t matches;
memcpy(iv, saved_iv, sizeof(iv));
AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
AES_ENCRYPT);
/* corrupt right at the end */
++ciphertext[sizeof(ciphertext) - 1];
AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv,
AES_DECRYPT);
matches = 0;
for (n = 0; n < sizeof(checktext); ++n)
if (checktext[n] == plaintext[n])
++matches;
/* Fail if there is more than 1% matching bytes */
return TEST_size_t_le(matches, sizeof(checktext) / 100);
}
static int test_bi_ige_garble3(void)
{
AES_KEY key, key2;
unsigned char iv[AES_BLOCK_SIZE * 4];
unsigned char ciphertext[BIG_TEST_SIZE];
unsigned char checktext[BIG_TEST_SIZE];
unsigned int n;
size_t matches;
memcpy(iv, saved_iv, sizeof(iv));
AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
AES_ENCRYPT);
/* corrupt right at the start */
++ciphertext[0];
AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv,
AES_DECRYPT);
matches = 0;
for (n = 0; n < sizeof(checktext); ++n)
if (checktext[n] == plaintext[n])
++matches;
/* Fail if there is more than 1% matching bytes */
return TEST_size_t_le(matches, sizeof(checktext) / 100);
}
#endif
int setup_tests(void)
{
#ifndef OPENSSL_NO_DEPRECATED_3_0
RAND_bytes(rkey, sizeof(rkey));
RAND_bytes(rkey2, sizeof(rkey2));
RAND_bytes(plaintext, sizeof(plaintext));
RAND_bytes(saved_iv, sizeof(saved_iv));
ADD_TEST(test_ige_enc_dec);
ADD_TEST(test_ige_enc_chaining);
ADD_TEST(test_ige_dec_chaining);
ADD_TEST(test_ige_garble_forwards);
ADD_TEST(test_bi_ige_enc_dec);
ADD_TEST(test_bi_ige_garble1);
ADD_TEST(test_bi_ige_garble2);
ADD_TEST(test_bi_ige_garble3);
ADD_ALL_TESTS(test_ige_vectors, OSSL_NELEM(ige_test_vectors));
ADD_ALL_TESTS(test_bi_ige_vectors, OSSL_NELEM(bi_ige_test_vectors));
#endif
return 1;
}
|
./openssl/test/pkcs12_api_test.c | /*
* Copyright 2022-2023 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 <string.h>
#include <stdlib.h>
#include "internal/nelem.h"
#include <openssl/pkcs12.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/pem.h>
#include "testutil.h"
#include "helpers/pkcs12.h"
static OSSL_LIB_CTX *testctx = NULL;
static OSSL_PROVIDER *nullprov = NULL;
static int test_null_args(void)
{
return TEST_false(PKCS12_parse(NULL, NULL, NULL, NULL, NULL));
}
static PKCS12 *PKCS12_load(const char *fpath)
{
BIO *bio = NULL;
PKCS12 *p12 = NULL;
bio = BIO_new_file(fpath, "rb");
if (!TEST_ptr(bio))
goto err;
p12 = PKCS12_init_ex(NID_pkcs7_data, testctx, "provider=default");
if (!TEST_ptr(p12))
goto err;
if (!TEST_true(p12 == d2i_PKCS12_bio(bio, &p12)))
goto err;
BIO_free(bio);
return p12;
err:
BIO_free(bio);
PKCS12_free(p12);
return NULL;
}
static const char *in_file = NULL;
static const char *in_pass = "";
static int has_key = 0;
static int has_cert = 0;
static int has_ca = 0;
static int changepass(PKCS12 *p12, EVP_PKEY *key, X509 *cert, STACK_OF(X509) *ca)
{
int ret = 0;
PKCS12 *p12new = NULL;
EVP_PKEY *key2 = NULL;
X509 *cert2 = NULL;
STACK_OF(X509) *ca2 = NULL;
BIO *bio = NULL;
if (!TEST_true(PKCS12_newpass(p12, in_pass, "NEWPASS")))
goto err;
if (!TEST_ptr(bio = BIO_new(BIO_s_mem())))
goto err;
if (!TEST_true(i2d_PKCS12_bio(bio, p12)))
goto err;
if (!TEST_ptr(p12new = PKCS12_init_ex(NID_pkcs7_data, testctx, "provider=default")))
goto err;
if (!TEST_ptr(d2i_PKCS12_bio(bio, &p12new)))
goto err;
if (!TEST_true(PKCS12_parse(p12new, "NEWPASS", &key2, &cert2, &ca2)))
goto err;
if (has_key) {
if (!TEST_ptr(key2) || !TEST_int_eq(EVP_PKEY_eq(key, key2), 1))
goto err;
}
if (has_cert) {
if (!TEST_ptr(cert2) || !TEST_int_eq(X509_cmp(cert, cert2), 0))
goto err;
}
ret = 1;
err:
BIO_free(bio);
PKCS12_free(p12new);
EVP_PKEY_free(key2);
X509_free(cert2);
OSSL_STACK_OF_X509_free(ca2);
return ret;
}
static int pkcs12_parse_test(void)
{
int ret = 0;
PKCS12 *p12 = NULL;
EVP_PKEY *key = NULL;
X509 *cert = NULL;
STACK_OF(X509) *ca = NULL;
if (in_file != NULL) {
p12 = PKCS12_load(in_file);
if (!TEST_ptr(p12))
goto err;
if (!TEST_true(PKCS12_parse(p12, in_pass, &key, &cert, &ca)))
goto err;
if ((has_key && !TEST_ptr(key)) || (!has_key && !TEST_ptr_null(key)))
goto err;
if ((has_cert && !TEST_ptr(cert)) || (!has_cert && !TEST_ptr_null(cert)))
goto err;
if ((has_ca && !TEST_ptr(ca)) || (!has_ca && !TEST_ptr_null(ca)))
goto err;
if (has_key && !changepass(p12, key, cert, ca))
goto err;
}
ret = 1;
err:
PKCS12_free(p12);
EVP_PKEY_free(key);
X509_free(cert);
OSSL_STACK_OF_X509_free(ca);
return TEST_true(ret);
}
static int pkcs12_create_cb(PKCS12_SAFEBAG *bag, void *cbarg)
{
int cb_ret = *((int*)cbarg);
return cb_ret;
}
static PKCS12 *pkcs12_create_ex2_setup(EVP_PKEY **key, X509 **cert, STACK_OF(X509) **ca)
{
PKCS12 *p12 = NULL;
p12 = PKCS12_load("out6.p12");
if (!TEST_ptr(p12))
goto err;
if (!TEST_true(PKCS12_parse(p12, "", key, cert, ca)))
goto err;
return p12;
err:
PKCS12_free(p12);
return NULL;
}
static int pkcs12_create_ex2_test(int test)
{
int ret = 0, cb_ret = 0;
PKCS12 *ptr = NULL, *p12 = NULL;
EVP_PKEY *key = NULL;
X509 *cert = NULL;
STACK_OF(X509) *ca = NULL;
p12 = pkcs12_create_ex2_setup(&key, &cert, &ca);
if (!TEST_ptr(p12))
goto err;
if (test == 0) {
/* Confirm PKCS12_create_ex2 returns NULL */
ptr = PKCS12_create_ex2(NULL, NULL, NULL,
NULL, NULL, NID_undef, NID_undef,
0, 0, 0,
testctx, NULL,
NULL, NULL);
if (TEST_ptr(ptr))
goto err;
/* Can't proceed without a valid cert at least */
if (!TEST_ptr(cert))
goto err;
/* Specified call back called - return success */
cb_ret = 1;
ptr = PKCS12_create_ex2(NULL, NULL, NULL,
cert, NULL, NID_undef, NID_undef,
0, 0, 0,
testctx, NULL,
pkcs12_create_cb, (void*)&cb_ret);
/* PKCS12 successfully created */
if (!TEST_ptr(ptr))
goto err;
} else if (test == 1) {
/* Specified call back called - return error*/
cb_ret = -1;
ptr = PKCS12_create_ex2(NULL, NULL, NULL,
cert, NULL, NID_undef, NID_undef,
0, 0, 0,
testctx, NULL,
pkcs12_create_cb, (void*)&cb_ret);
/* PKCS12 not created */
if (TEST_ptr(ptr))
goto err;
} else if (test == 2) {
/* Specified call back called - return failure */
cb_ret = 0;
ptr = PKCS12_create_ex2(NULL, NULL, NULL,
cert, NULL, NID_undef, NID_undef,
0, 0, 0,
testctx, NULL,
pkcs12_create_cb, (void*)&cb_ret);
/* PKCS12 successfully created */
if (!TEST_ptr(ptr))
goto err;
}
ret = 1;
err:
PKCS12_free(p12);
PKCS12_free(ptr);
EVP_PKEY_free(key);
X509_free(cert);
OSSL_STACK_OF_X509_free(ca);
return TEST_true(ret);
}
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_IN_FILE,
OPT_IN_PASS,
OPT_IN_HAS_KEY,
OPT_IN_HAS_CERT,
OPT_IN_HAS_CA,
OPT_LEGACY,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "in", OPT_IN_FILE, '<', "PKCS12 input file" },
{ "pass", OPT_IN_PASS, 's', "PKCS12 input file password" },
{ "has-key", OPT_IN_HAS_KEY, 'n', "Whether the input file does contain an user key" },
{ "has-cert", OPT_IN_HAS_CERT, 'n', "Whether the input file does contain an user certificate" },
{ "has-ca", OPT_IN_HAS_CA, 'n', "Whether the input file does contain other certificate" },
{ "legacy", OPT_LEGACY, '-', "Test the legacy APIs" },
{ NULL }
};
return options;
}
int setup_tests(void)
{
OPTION_CHOICE o;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_IN_FILE:
in_file = opt_arg();
break;
case OPT_IN_PASS:
in_pass = opt_arg();
break;
case OPT_LEGACY:
break;
case OPT_IN_HAS_KEY:
has_key = opt_int_arg();
break;
case OPT_IN_HAS_CERT:
has_cert = opt_int_arg();
break;
case OPT_IN_HAS_CA:
has_ca = opt_int_arg();
break;
case OPT_TEST_CASES:
break;
default:
return 0;
}
}
if (!test_get_libctx(&testctx, &nullprov, NULL, NULL, NULL)) {
OSSL_LIB_CTX_free(testctx);
testctx = NULL;
return 0;
}
ADD_TEST(test_null_args);
ADD_TEST(pkcs12_parse_test);
ADD_ALL_TESTS(pkcs12_create_ex2_test, 3);
return 1;
}
void cleanup_tests(void)
{
OSSL_LIB_CTX_free(testctx);
OSSL_PROVIDER_unload(nullprov);
}
|
./openssl/test/asn1_time_test.c | /*
* Copyright 1999-2022 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
*/
/* Time tests for the asn1 module */
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <crypto/asn1.h>
#include <openssl/asn1.h>
#include <openssl/evp.h>
#include <openssl/objects.h>
#include "testutil.h"
#include "internal/nelem.h"
struct testdata {
char *data; /* TIME string value */
int type; /* GENERALIZED OR UTC */
int expected_type; /* expected type after set/set_string_gmt */
int check_result; /* check result */
time_t t; /* expected time_t*/
int cmp_result; /* comparison to baseline result */
int convert_result; /* conversion result */
};
struct TESTDATA_asn1_to_utc {
char *input;
time_t expected;
};
static const struct TESTDATA_asn1_to_utc asn1_to_utc[] = {
{
/*
* last second of standard time in central Europe in 2021
* specified in GMT
*/
"210328005959Z",
1616893199,
},
{
/*
* first second of daylight saving time in central Europe in 2021
* specified in GMT
*/
"210328010000Z",
1616893200,
},
{
/*
* last second of standard time in central Europe in 2021
* specified in offset to GMT
*/
"20210328015959+0100",
1616893199,
},
{
/*
* first second of daylight saving time in central Europe in 2021
* specified in offset to GMT
*/
"20210328030000+0200",
1616893200,
},
{
/*
* Invalid strings should get -1 as a result
*/
"INVALID",
-1,
},
};
static struct testdata tbl_testdata_pos[] = {
{ "0", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, }, /* Bad time */
{ "ABCD", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "0ABCD", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "1-700101000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "`9700101000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "19700101000000Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 0, 0, 0, 0, },
{ "A00101000000Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 0, 0, 0, 0, },
{ "A9700101000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "1A700101000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "19A00101000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "197A0101000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "1970A101000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "19700A01000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "197001A1000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "1970010A000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "19700101A00000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "197001010A0000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "1970010100A000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "19700101000A00Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "197001010000A0Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "1970010100000AZ", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "700101000000X", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 0, 0, 0, 0, },
{ "19700101000000X", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 0, 0, 0, 0, },
{ "19700101000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 0, -1, 1, }, /* Epoch begins */
{ "700101000000Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 0, -1, 1, }, /* ditto */
{ "20380119031407Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 0x7FFFFFFF, 1, 1, }, /* Max 32bit time_t */
{ "380119031407Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 0x7FFFFFFF, 1, 1, },
{ "20371231235959Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 2145916799, 1, 1, }, /* Just before 2038 */
{ "20371231235959Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 0, 0, 0, 1, }, /* Bad UTC time */
{ "371231235959Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 2145916799, 1, 1, },
{ "19701006121456Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 24063296, -1, 1, },
{ "701006121456Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 24063296, -1, 1, },
{ "19991231000000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, }, /* Match baseline */
{ "199912310000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, }, /* In various flavors */
{ "991231000000Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
{ "9912310000Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
{ "9912310000+0000", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
{ "199912310000+0000", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
{ "9912310000-0000", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
{ "199912310000-0000", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
{ "199912310100+0100", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
{ "199912302300-0100", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
{ "199912302300-A000", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 0, 946598400, 0, 1, },
{ "199912302300-0A00", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 0, 946598400, 0, 1, },
{ "9912310100+0100", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
{ "9912302300-0100", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 946598400, 0, 1, },
};
/* ASSUMES SIGNED TIME_T */
static struct testdata tbl_testdata_neg[] = {
{ "19011213204552Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, INT_MIN, -1, 0, },
{ "691006121456Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, -7472704, -1, 1, },
{ "19691006121456Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, -7472704, -1, 1, },
};
/* explicit casts to time_t short warnings on systems with 32-bit time_t */
static struct testdata tbl_testdata_pos_64bit[] = {
{ "20380119031408Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, (time_t)0x80000000, 1, 1, },
{ "20380119031409Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, (time_t)0x80000001, 1, 1, },
{ "380119031408Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, (time_t)0x80000000, 1, 1, },
{ "20500101120000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, (time_t)0x967b1ec0, 1, 0, },
};
/* ASSUMES SIGNED TIME_T */
static struct testdata tbl_testdata_neg_64bit[] = {
{ "19011213204551Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, (time_t)-2147483649LL, -1, 0, },
{ "19000101120000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, (time_t)-2208945600LL, -1, 0, },
};
/* A baseline time to compare to */
static ASN1_TIME gtime = {
15,
V_ASN1_GENERALIZEDTIME,
(unsigned char*)"19991231000000Z",
0
};
static time_t gtime_t = 946598400;
static int test_table(struct testdata *tbl, int idx)
{
int error = 0;
ASN1_TIME atime;
ASN1_TIME *ptime;
struct testdata *td = &tbl[idx];
int day, sec;
atime.data = (unsigned char*)td->data;
atime.length = strlen((char*)atime.data);
atime.type = td->type;
atime.flags = 0;
if (!TEST_int_eq(ASN1_TIME_check(&atime), td->check_result)) {
TEST_info("ASN1_TIME_check(%s) unexpected result", atime.data);
error = 1;
}
if (td->check_result == 0)
return 1;
if (!TEST_int_eq(ASN1_TIME_cmp_time_t(&atime, td->t), 0)) {
TEST_info("ASN1_TIME_cmp_time_t(%s vs %ld) compare failed", atime.data, (long)td->t);
error = 1;
}
if (!TEST_true(ASN1_TIME_diff(&day, &sec, &atime, &atime))) {
TEST_info("ASN1_TIME_diff(%s) to self failed", atime.data);
error = 1;
}
if (!TEST_int_eq(day, 0) || !TEST_int_eq(sec, 0)) {
TEST_info("ASN1_TIME_diff(%s) to self not equal", atime.data);
error = 1;
}
if (!TEST_true(ASN1_TIME_diff(&day, &sec, >ime, &atime))) {
TEST_info("ASN1_TIME_diff(%s) to baseline failed", atime.data);
error = 1;
} else if (!((td->cmp_result == 0 && TEST_true((day == 0 && sec == 0))) ||
(td->cmp_result == -1 && TEST_true((day < 0 || sec < 0))) ||
(td->cmp_result == 1 && TEST_true((day > 0 || sec > 0))))) {
TEST_info("ASN1_TIME_diff(%s) to baseline bad comparison", atime.data);
error = 1;
}
if (!TEST_int_eq(ASN1_TIME_cmp_time_t(&atime, gtime_t), td->cmp_result)) {
TEST_info("ASN1_TIME_cmp_time_t(%s) to baseline bad comparison", atime.data);
error = 1;
}
ptime = ASN1_TIME_set(NULL, td->t);
if (!TEST_ptr(ptime)) {
TEST_info("ASN1_TIME_set(%ld) failed", (long)td->t);
error = 1;
} else {
int local_error = 0;
if (!TEST_int_eq(ASN1_TIME_cmp_time_t(ptime, td->t), 0)) {
TEST_info("ASN1_TIME_set(%ld) compare failed (%s->%s)",
(long)td->t, td->data, ptime->data);
local_error = error = 1;
}
if (!TEST_int_eq(ptime->type, td->expected_type)) {
TEST_info("ASN1_TIME_set(%ld) unexpected type", (long)td->t);
local_error = error = 1;
}
if (local_error)
TEST_info("ASN1_TIME_set() = %*s", ptime->length, ptime->data);
ASN1_TIME_free(ptime);
}
ptime = ASN1_TIME_new();
if (!TEST_ptr(ptime)) {
TEST_info("ASN1_TIME_new() failed");
error = 1;
} else {
int local_error = 0;
if (!TEST_int_eq(ASN1_TIME_set_string(ptime, td->data), td->check_result)) {
TEST_info("ASN1_TIME_set_string_gmt(%s) failed", td->data);
local_error = error = 1;
}
if (!TEST_int_eq(ASN1_TIME_normalize(ptime), td->check_result)) {
TEST_info("ASN1_TIME_normalize(%s) failed", td->data);
local_error = error = 1;
}
if (!TEST_int_eq(ptime->type, td->expected_type)) {
TEST_info("ASN1_TIME_set_string_gmt(%s) unexpected type", td->data);
local_error = error = 1;
}
day = sec = 0;
if (!TEST_true(ASN1_TIME_diff(&day, &sec, ptime, &atime)) || !TEST_int_eq(day, 0) || !TEST_int_eq(sec, 0)) {
TEST_info("ASN1_TIME_diff(day=%d, sec=%d, %s) after ASN1_TIME_set_string_gmt() failed", day, sec, td->data);
local_error = error = 1;
}
if (!TEST_int_eq(ASN1_TIME_cmp_time_t(ptime, gtime_t), td->cmp_result)) {
TEST_info("ASN1_TIME_cmp_time_t(%s) after ASN1_TIME_set_string_gnt() to baseline bad comparison", td->data);
local_error = error = 1;
}
if (local_error)
TEST_info("ASN1_TIME_set_string_gmt() = %*s", ptime->length, ptime->data);
ASN1_TIME_free(ptime);
}
ptime = ASN1_TIME_new();
if (!TEST_ptr(ptime)) {
TEST_info("ASN1_TIME_new() failed");
error = 1;
} else {
int local_error = 0;
if (!TEST_int_eq(ASN1_TIME_set_string(ptime, td->data), td->check_result)) {
TEST_info("ASN1_TIME_set_string(%s) failed", td->data);
local_error = error = 1;
}
day = sec = 0;
if (!TEST_true(ASN1_TIME_diff(&day, &sec, ptime, &atime)) || !TEST_int_eq(day, 0) || !TEST_int_eq(sec, 0)) {
TEST_info("ASN1_TIME_diff(day=%d, sec=%d, %s) after ASN1_TIME_set_string() failed", day, sec, td->data);
local_error = error = 1;
}
if (!TEST_int_eq(ASN1_TIME_cmp_time_t(ptime, gtime_t), td->cmp_result)) {
TEST_info("ASN1_TIME_cmp_time_t(%s) after ASN1_TIME_set_string() to baseline bad comparison", td->data);
local_error = error = 1;
}
if (local_error)
TEST_info("ASN1_TIME_set_string() = %*s", ptime->length, ptime->data);
ASN1_TIME_free(ptime);
}
if (td->type == V_ASN1_UTCTIME) {
ptime = ASN1_TIME_to_generalizedtime(&atime, NULL);
if (td->convert_result == 1 && !TEST_ptr(ptime)) {
TEST_info("ASN1_TIME_to_generalizedtime(%s) failed", atime.data);
error = 1;
} else if (td->convert_result == 0 && !TEST_ptr_null(ptime)) {
TEST_info("ASN1_TIME_to_generalizedtime(%s) should have failed", atime.data);
error = 1;
}
if (ptime != NULL && !TEST_int_eq(ASN1_TIME_cmp_time_t(ptime, td->t), 0)) {
TEST_info("ASN1_TIME_to_generalizedtime(%s->%s) bad result", atime.data, ptime->data);
error = 1;
}
ASN1_TIME_free(ptime);
}
/* else cannot simply convert GENERALIZEDTIME to UTCTIME */
if (error)
TEST_error("atime=%s", atime.data);
return !error;
}
static int test_table_pos(int idx)
{
return test_table(tbl_testdata_pos, idx);
}
static int test_table_neg(int idx)
{
return test_table(tbl_testdata_neg, idx);
}
static int test_table_pos_64bit(int idx)
{
return test_table(tbl_testdata_pos_64bit, idx);
}
static int test_table_neg_64bit(int idx)
{
return test_table(tbl_testdata_neg_64bit, idx);
}
struct compare_testdata {
ASN1_TIME t1;
ASN1_TIME t2;
int result;
};
static unsigned char TODAY_GEN_STR[] = "20170825000000Z";
static unsigned char TOMORROW_GEN_STR[] = "20170826000000Z";
static unsigned char TODAY_UTC_STR[] = "170825000000Z";
static unsigned char TOMORROW_UTC_STR[] = "170826000000Z";
#define TODAY_GEN { sizeof(TODAY_GEN_STR)-1, V_ASN1_GENERALIZEDTIME, TODAY_GEN_STR, 0 }
#define TOMORROW_GEN { sizeof(TOMORROW_GEN_STR)-1, V_ASN1_GENERALIZEDTIME, TOMORROW_GEN_STR, 0 }
#define TODAY_UTC { sizeof(TODAY_UTC_STR)-1, V_ASN1_UTCTIME, TODAY_UTC_STR, 0 }
#define TOMORROW_UTC { sizeof(TOMORROW_UTC_STR)-1, V_ASN1_UTCTIME, TOMORROW_UTC_STR, 0 }
static struct compare_testdata tbl_compare_testdata[] = {
{ TODAY_GEN, TODAY_GEN, 0 },
{ TODAY_GEN, TODAY_UTC, 0 },
{ TODAY_GEN, TOMORROW_GEN, -1 },
{ TODAY_GEN, TOMORROW_UTC, -1 },
{ TODAY_UTC, TODAY_GEN, 0 },
{ TODAY_UTC, TODAY_UTC, 0 },
{ TODAY_UTC, TOMORROW_GEN, -1 },
{ TODAY_UTC, TOMORROW_UTC, -1 },
{ TOMORROW_GEN, TODAY_GEN, 1 },
{ TOMORROW_GEN, TODAY_UTC, 1 },
{ TOMORROW_GEN, TOMORROW_GEN, 0 },
{ TOMORROW_GEN, TOMORROW_UTC, 0 },
{ TOMORROW_UTC, TODAY_GEN, 1 },
{ TOMORROW_UTC, TODAY_UTC, 1 },
{ TOMORROW_UTC, TOMORROW_GEN, 0 },
{ TOMORROW_UTC, TOMORROW_UTC, 0 }
};
static int test_table_compare(int idx)
{
struct compare_testdata *td = &tbl_compare_testdata[idx];
return TEST_int_eq(ASN1_TIME_compare(&td->t1, &td->t2), td->result);
}
static int test_time_dup(void)
{
int ret = 0;
ASN1_TIME *asn1_time = NULL;
ASN1_TIME *asn1_time_dup = NULL;
ASN1_TIME *asn1_gentime = NULL;
asn1_time = ASN1_TIME_adj(NULL, time(NULL), 0, 0);
if (asn1_time == NULL) {
TEST_info("Internal error.");
goto err;
}
asn1_gentime = ASN1_TIME_to_generalizedtime(asn1_time, NULL);
if (asn1_gentime == NULL) {
TEST_info("Internal error.");
goto err;
}
asn1_time_dup = ASN1_TIME_dup(asn1_time);
if (!TEST_ptr_ne(asn1_time_dup, NULL)) {
TEST_info("ASN1_TIME_dup() failed.");
goto err;
}
if (!TEST_int_eq(ASN1_TIME_compare(asn1_time, asn1_time_dup), 0)) {
TEST_info("ASN1_TIME_dup() duplicated non-identical value.");
goto err;
}
ASN1_STRING_free(asn1_time_dup);
asn1_time_dup = ASN1_UTCTIME_dup(asn1_time);
if (!TEST_ptr_ne(asn1_time_dup, NULL)) {
TEST_info("ASN1_UTCTIME_dup() failed.");
goto err;
}
if (!TEST_int_eq(ASN1_TIME_compare(asn1_time, asn1_time_dup), 0)) {
TEST_info("ASN1_UTCTIME_dup() duplicated non-identical UTCTIME value.");
goto err;
}
ASN1_STRING_free(asn1_time_dup);
asn1_time_dup = ASN1_GENERALIZEDTIME_dup(asn1_gentime);
if (!TEST_ptr_ne(asn1_time_dup, NULL)) {
TEST_info("ASN1_GENERALIZEDTIME_dup() failed.");
goto err;
}
if (!TEST_int_eq(ASN1_TIME_compare(asn1_gentime, asn1_time_dup), 0)) {
TEST_info("ASN1_GENERALIZEDTIME_dup() dup'ed non-identical value.");
goto err;
}
ret = 1;
err:
ASN1_STRING_free(asn1_time);
ASN1_STRING_free(asn1_gentime);
ASN1_STRING_free(asn1_time_dup);
return ret;
}
static int convert_asn1_to_time_t(int idx)
{
time_t testdateutc;
testdateutc = ossl_asn1_string_to_time_t(asn1_to_utc[idx].input);
if (!TEST_time_t_eq(testdateutc, asn1_to_utc[idx].expected)) {
TEST_info("ossl_asn1_string_to_time_t (%s) failed: expected %lli, got %lli\n",
asn1_to_utc[idx].input,
(long long int)asn1_to_utc[idx].expected,
(long long int)testdateutc);
return 0;
}
return 1;
}
/*
* this test is here to exercise ossl_asn1_time_from_tm
* with an integer year close to INT_MAX.
*/
static int convert_tm_to_asn1_time(void)
{
/* we need 64 bit time_t */
#if ((ULONG_MAX >> 31) >> 31) >= 1
time_t t;
ASN1_TIME *at;
if (sizeof(time_t) * CHAR_BIT >= 64) {
t = 67768011791126057ULL;
at = ASN1_TIME_set(NULL, t);
/*
* If ASN1_TIME_set returns NULL, it means it could not handle the input
* which is fine for this edge case.
*/
ASN1_STRING_free(at);
}
#endif
return 1;
}
int setup_tests(void)
{
/*
* On platforms where |time_t| is an unsigned integer, t will be a
* positive number.
*
* We check if we're on a platform with a signed |time_t| with '!(t > 0)'
* because some compilers are picky if you do 't < 0', or even 't <= 0'
* if |t| is unsigned.
*/
time_t t = -1;
/*
* On some platforms, |time_t| is signed, but a negative value is an
* error, and using it with gmtime() or localtime() generates a NULL.
* If that is the case, we can't perform tests on negative values.
*/
struct tm *ptm = localtime(&t);
ADD_ALL_TESTS(test_table_pos, OSSL_NELEM(tbl_testdata_pos));
if (!(t > 0) && ptm != NULL) {
TEST_info("Adding negative-sign time_t tests");
ADD_ALL_TESTS(test_table_neg, OSSL_NELEM(tbl_testdata_neg));
}
if (sizeof(time_t) > sizeof(uint32_t)) {
TEST_info("Adding 64-bit time_t tests");
ADD_ALL_TESTS(test_table_pos_64bit, OSSL_NELEM(tbl_testdata_pos_64bit));
#ifndef __hpux
if (!(t > 0) && ptm != NULL) {
TEST_info("Adding negative-sign 64-bit time_t tests");
ADD_ALL_TESTS(test_table_neg_64bit, OSSL_NELEM(tbl_testdata_neg_64bit));
}
#endif
}
ADD_ALL_TESTS(test_table_compare, OSSL_NELEM(tbl_compare_testdata));
ADD_TEST(test_time_dup);
ADD_ALL_TESTS(convert_asn1_to_time_t, OSSL_NELEM(asn1_to_utc));
ADD_TEST(convert_tm_to_asn1_time);
return 1;
}
|
./openssl/test/keymgmt_internal_test.c | /*
* Copyright 2019-2021 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
*/
/*
* RSA low level APIs are deprecated for public use, but still ok for
* internal use.
*/
#include "internal/deprecated.h"
#include <string.h>
#include <openssl/bio.h>
#include <openssl/bn.h>
#include <openssl/rsa.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/provider.h>
#include <openssl/core_names.h>
#include "internal/core.h"
#include "internal/nelem.h"
#include "crypto/evp.h" /* For the internal API */
#include "testutil.h"
typedef struct {
OSSL_LIB_CTX *ctx1;
OSSL_PROVIDER *prov1;
OSSL_LIB_CTX *ctx2;
OSSL_PROVIDER *prov2;
} FIXTURE;
/* Collected arguments */
static const char *cert_filename = NULL;
static void tear_down(FIXTURE *fixture)
{
if (fixture != NULL) {
OSSL_PROVIDER_unload(fixture->prov1);
OSSL_PROVIDER_unload(fixture->prov2);
OSSL_LIB_CTX_free(fixture->ctx1);
OSSL_LIB_CTX_free(fixture->ctx2);
OPENSSL_free(fixture);
}
}
static FIXTURE *set_up(const char *testcase_name)
{
FIXTURE *fixture;
if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture)))
|| !TEST_ptr(fixture->ctx1 = OSSL_LIB_CTX_new())
|| !TEST_ptr(fixture->prov1 = OSSL_PROVIDER_load(fixture->ctx1,
"default"))
|| !TEST_ptr(fixture->ctx2 = OSSL_LIB_CTX_new())
|| !TEST_ptr(fixture->prov2 = OSSL_PROVIDER_load(fixture->ctx2,
"default"))) {
tear_down(fixture);
return NULL;
}
return fixture;
}
/* Array indexes */
#define N 0
#define E 1
#define D 2
#define P 3
#define Q 4
#define F3 5 /* Extra factor */
#define DP 6
#define DQ 7
#define E3 8 /* Extra exponent */
#define QINV 9
#define C2 10 /* Extra coefficient */
/*
* We have to do this because OSSL_PARAM_get_ulong() can't handle params
* holding data that isn't exactly sizeof(uint32_t) or sizeof(uint64_t),
* and because the other end deals with BIGNUM, the resulting param might
* be any size. In this particular test, we know that the expected data
* fits within an unsigned long, and we want to get the data in that form
* to make testing of values easier.
*/
static int get_ulong_via_BN(const OSSL_PARAM *p, unsigned long *goal)
{
BIGNUM *n = NULL;
int ret = 1; /* Ever so hopeful */
if (!TEST_true(OSSL_PARAM_get_BN(p, &n))
|| !TEST_int_ge(BN_bn2nativepad(n, (unsigned char *)goal, sizeof(*goal)), 0))
ret = 0;
BN_free(n);
return ret;
}
static int export_cb(const OSSL_PARAM *params, void *arg)
{
unsigned long *keydata = arg;
const OSSL_PARAM *p = NULL;
if (keydata == NULL)
return 0;
if (!TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_N))
|| !TEST_true(get_ulong_via_BN(p, &keydata[N]))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_E))
|| !TEST_true(get_ulong_via_BN(p, &keydata[E]))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_D))
|| !TEST_true(get_ulong_via_BN(p, &keydata[D])))
return 0;
if (!TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR1))
|| !TEST_true(get_ulong_via_BN(p, &keydata[P]))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR2))
|| !TEST_true(get_ulong_via_BN(p, &keydata[Q]))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR3))
|| !TEST_true(get_ulong_via_BN(p, &keydata[F3])))
return 0;
if (!TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_EXPONENT1))
|| !TEST_true(get_ulong_via_BN(p, &keydata[DP]))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_EXPONENT2))
|| !TEST_true(get_ulong_via_BN(p, &keydata[DQ]))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_EXPONENT3))
|| !TEST_true(get_ulong_via_BN(p, &keydata[E3])))
return 0;
if (!TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_COEFFICIENT1))
|| !TEST_true(get_ulong_via_BN(p, &keydata[QINV]))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_COEFFICIENT2))
|| !TEST_true(get_ulong_via_BN(p, &keydata[C2])))
return 0;
return 1;
}
static int test_pass_rsa(FIXTURE *fixture)
{
size_t i;
int ret = 0;
RSA *rsa = NULL;
BIGNUM *bn1 = NULL, *bn2 = NULL, *bn3 = NULL;
EVP_PKEY *pk = NULL, *dup_pk = NULL;
EVP_KEYMGMT *km = NULL, *km1 = NULL, *km2 = NULL, *km3 = NULL;
void *provkey = NULL, *provkey2 = NULL;
BIGNUM *bn_primes[1] = { NULL };
BIGNUM *bn_exps[1] = { NULL };
BIGNUM *bn_coeffs[1] = { NULL };
/*
* 32-bit RSA key, extracted from this command,
* executed with OpenSSL 1.0.2:
* An extra factor was added just for testing purposes.
*
* openssl genrsa 32 | openssl rsa -text
*/
static BN_ULONG expected[] = {
0xbc747fc5, /* N */
0x10001, /* E */
0x7b133399, /* D */
0xe963, /* P */
0xceb7, /* Q */
1, /* F3 */
0x8599, /* DP */
0xbd87, /* DQ */
2, /* E3 */
0xcc3b, /* QINV */
3, /* C3 */
0 /* Extra, should remain zero */
};
static unsigned long keydata[OSSL_NELEM(expected)] = { 0, };
if (!TEST_ptr(rsa = RSA_new()))
goto err;
if (!TEST_ptr(bn1 = BN_new())
|| !TEST_true(BN_set_word(bn1, expected[N]))
|| !TEST_ptr(bn2 = BN_new())
|| !TEST_true(BN_set_word(bn2, expected[E]))
|| !TEST_ptr(bn3 = BN_new())
|| !TEST_true(BN_set_word(bn3, expected[D]))
|| !TEST_true(RSA_set0_key(rsa, bn1, bn2, bn3)))
goto err;
if (!TEST_ptr(bn1 = BN_new())
|| !TEST_true(BN_set_word(bn1, expected[P]))
|| !TEST_ptr(bn2 = BN_new())
|| !TEST_true(BN_set_word(bn2, expected[Q]))
|| !TEST_true(RSA_set0_factors(rsa, bn1, bn2)))
goto err;
if (!TEST_ptr(bn1 = BN_new())
|| !TEST_true(BN_set_word(bn1, expected[DP]))
|| !TEST_ptr(bn2 = BN_new())
|| !TEST_true(BN_set_word(bn2, expected[DQ]))
|| !TEST_ptr(bn3 = BN_new())
|| !TEST_true(BN_set_word(bn3, expected[QINV]))
|| !TEST_true(RSA_set0_crt_params(rsa, bn1, bn2, bn3)))
goto err;
bn1 = bn2 = bn3 = NULL;
if (!TEST_ptr(bn_primes[0] = BN_new())
|| !TEST_true(BN_set_word(bn_primes[0], expected[F3]))
|| !TEST_ptr(bn_exps[0] = BN_new())
|| !TEST_true(BN_set_word(bn_exps[0], expected[E3]))
|| !TEST_ptr(bn_coeffs[0] = BN_new())
|| !TEST_true(BN_set_word(bn_coeffs[0], expected[C2]))
|| !TEST_true(RSA_set0_multi_prime_params(rsa, bn_primes, bn_exps,
bn_coeffs, 1)))
goto err;
if (!TEST_ptr(pk = EVP_PKEY_new())
|| !TEST_true(EVP_PKEY_assign_RSA(pk, rsa)))
goto err;
rsa = NULL;
if (!TEST_ptr(km1 = EVP_KEYMGMT_fetch(fixture->ctx1, "RSA", NULL))
|| !TEST_ptr(km2 = EVP_KEYMGMT_fetch(fixture->ctx2, "RSA", NULL))
|| !TEST_ptr(km3 = EVP_KEYMGMT_fetch(fixture->ctx1, "RSA-PSS", NULL))
|| !TEST_ptr_ne(km1, km2))
goto err;
while (dup_pk == NULL) {
ret = 0;
km = km3;
/* Check that we can't export an RSA key into an RSA-PSS keymanager */
if (!TEST_ptr_null(provkey2 = evp_pkey_export_to_provider(pk, NULL,
&km,
NULL)))
goto err;
if (!TEST_ptr(provkey = evp_pkey_export_to_provider(pk, NULL, &km1,
NULL))
|| !TEST_true(evp_keymgmt_export(km2, provkey,
OSSL_KEYMGMT_SELECT_KEYPAIR,
&export_cb, keydata)))
goto err;
/*
* At this point, the hope is that keydata will have all the numbers
* from the key.
*/
for (i = 0; i < OSSL_NELEM(expected); i++) {
int rv = TEST_int_eq(expected[i], keydata[i]);
if (!rv)
TEST_info("i = %zu", i);
else
ret++;
}
ret = (ret == OSSL_NELEM(expected));
if (!ret || !TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
goto err;
ret = TEST_int_eq(EVP_PKEY_eq(pk, dup_pk), 1);
EVP_PKEY_free(pk);
pk = dup_pk;
if (!ret)
goto err;
}
err:
RSA_free(rsa);
BN_free(bn1);
BN_free(bn2);
BN_free(bn3);
EVP_PKEY_free(pk);
EVP_KEYMGMT_free(km1);
EVP_KEYMGMT_free(km2);
EVP_KEYMGMT_free(km3);
return ret;
}
static int (*tests[])(FIXTURE *) = {
test_pass_rsa
};
static int test_pass_key(int n)
{
SETUP_TEST_FIXTURE(FIXTURE, set_up);
EXECUTE_TEST(tests[n], tear_down);
return result;
}
static int test_evp_pkey_export_to_provider(int n)
{
OSSL_LIB_CTX *libctx = NULL;
OSSL_PROVIDER *prov = NULL;
X509 *cert = NULL;
BIO *bio = NULL;
X509_PUBKEY *pubkey = NULL;
EVP_KEYMGMT *keymgmt = NULL;
EVP_PKEY *pkey = NULL;
void *keydata = NULL;
int ret = 0;
if (!TEST_ptr(libctx = OSSL_LIB_CTX_new())
|| !TEST_ptr(prov = OSSL_PROVIDER_load(libctx, "default")))
goto end;
if ((bio = BIO_new_file(cert_filename, "r")) == NULL) {
TEST_error("Couldn't open '%s' for reading\n", cert_filename);
TEST_openssl_errors();
goto end;
}
if ((cert = PEM_read_bio_X509(bio, NULL, NULL, NULL)) == NULL) {
TEST_error("'%s' doesn't appear to be a X.509 certificate in PEM format\n",
cert_filename);
TEST_openssl_errors();
goto end;
}
pubkey = X509_get_X509_PUBKEY(cert);
pkey = X509_PUBKEY_get0(pubkey);
if (n == 0) {
if (!TEST_ptr(keydata = evp_pkey_export_to_provider(pkey, NULL,
NULL, NULL)))
goto end;
} else if (n == 1) {
if (!TEST_ptr(keydata = evp_pkey_export_to_provider(pkey, NULL,
&keymgmt, NULL)))
goto end;
} else {
keymgmt = EVP_KEYMGMT_fetch(libctx, "RSA", NULL);
if (!TEST_ptr(keydata = evp_pkey_export_to_provider(pkey, NULL,
&keymgmt, NULL)))
goto end;
}
ret = 1;
end:
BIO_free(bio);
X509_free(cert);
EVP_KEYMGMT_free(keymgmt);
OSSL_PROVIDER_unload(prov);
OSSL_LIB_CTX_free(libctx);
return ret;
}
int setup_tests(void)
{
if (!TEST_ptr(cert_filename = test_get_argument(0)))
return 0;
ADD_ALL_TESTS(test_pass_key, 1);
ADD_ALL_TESTS(test_evp_pkey_export_to_provider, 3);
return 1;
}
|
./openssl/test/poly1305_internal_test.c | /*
* Copyright 2016-2018 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
*/
/* Internal tests for the poly1305 module */
#include <stdio.h>
#include <string.h>
#include "testutil.h"
#include "crypto/poly1305.h"
#include "internal/nelem.h"
typedef struct {
size_t size;
const unsigned char data[1024];
} SIZED_DATA;
typedef struct {
SIZED_DATA input;
SIZED_DATA key;
SIZED_DATA expected;
} TESTDATA;
/**********************************************************************
*
* Test of poly1305 internal functions
*
***/
static TESTDATA tests[] = {
/*
* RFC7539
*/
{
{
34,
{
0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72,
0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x46, 0x6f,
0x72, 0x75, 0x6d, 0x20, 0x52, 0x65, 0x73, 0x65,
0x61, 0x72, 0x63, 0x68, 0x20, 0x47, 0x72, 0x6f,
0x75, 0x70
}
},
{
32,
{
0x85, 0xd6, 0xbe, 0x78, 0x57, 0x55, 0x6d, 0x33,
0x7f, 0x44, 0x52, 0xfe, 0x42, 0xd5, 0x06, 0xa8,
0x01, 0x03, 0x80, 0x8a, 0xfb, 0x0d, 0xb2, 0xfd,
0x4a, 0xbf, 0xf6, 0xaf, 0x41, 0x49, 0xf5, 0x1b
}
},
{
16,
{
0xa8, 0x06, 0x1d, 0xc1, 0x30, 0x51, 0x36, 0xc6,
0xc2, 0x2b, 0x8b, 0xaf, 0x0c, 0x01, 0x27, 0xa9
}
}
},
/*
* test vectors from "The Poly1305-AES message-authentication code"
*/
{
{
2,
{
0xf3, 0xf6
}
},
{
32,
{
0x85, 0x1f, 0xc4, 0x0c, 0x34, 0x67, 0xac, 0x0b,
0xe0, 0x5c, 0xc2, 0x04, 0x04, 0xf3, 0xf7, 0x00,
0x58, 0x0b, 0x3b, 0x0f, 0x94, 0x47, 0xbb, 0x1e,
0x69, 0xd0, 0x95, 0xb5, 0x92, 0x8b, 0x6d, 0xbc
}
},
{
16,
{
0xf4, 0xc6, 0x33, 0xc3, 0x04, 0x4f, 0xc1, 0x45,
0xf8, 0x4f, 0x33, 0x5c, 0xb8, 0x19, 0x53, 0xde
}
}
},
{
{
0,
{
0
}
},
{
32,
{
0xa0, 0xf3, 0x08, 0x00, 0x00, 0xf4, 0x64, 0x00,
0xd0, 0xc7, 0xe9, 0x07, 0x6c, 0x83, 0x44, 0x03,
0xdd, 0x3f, 0xab, 0x22, 0x51, 0xf1, 0x1a, 0xc7,
0x59, 0xf0, 0x88, 0x71, 0x29, 0xcc, 0x2e, 0xe7
}
},
{
16,
{
0xdd, 0x3f, 0xab, 0x22, 0x51, 0xf1, 0x1a, 0xc7,
0x59, 0xf0, 0x88, 0x71, 0x29, 0xcc, 0x2e, 0xe7
}
}
},
{
{
32,
{
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
}
},
{
32,
{
0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef
}
},
{
16,
{
0x0e, 0xe1, 0xc1, 0x6b, 0xb7, 0x3f, 0x0f, 0x4f,
0xd1, 0x98, 0x81, 0x75, 0x3c, 0x01, 0xcd, 0xbe
}
}
},
{
{
63,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0x51, 0x54, 0xad, 0x0d, 0x2c, 0xb2, 0x6e, 0x01,
0x27, 0x4f, 0xc5, 0x11, 0x48, 0x49, 0x1f, 0x1b
}
},
},
/*
* self-generated vectors exercise "significant" lengths, such that
* are handled by different code paths
*/
{
{
64,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66
}
},
},
{
{
48,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
}
},
},
{
{
96,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0xbb, 0xb6, 0x13, 0xb2, 0xb6, 0xd7, 0x53, 0xba,
0x07, 0x39, 0x5b, 0x91, 0x6a, 0xae, 0xce, 0x15
}
},
},
{
{
112,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0xc7, 0x94, 0xd7, 0x05, 0x7d, 0x17, 0x78, 0xc4,
0xbb, 0xee, 0x0a, 0x39, 0xb3, 0xd9, 0x73, 0x42
}
},
},
{
{
128,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0xff, 0xbc, 0xb9, 0xb3, 0x71, 0x42, 0x31, 0x52,
0xd7, 0xfc, 0xa5, 0xad, 0x04, 0x2f, 0xba, 0xa9
}
},
},
{
{
144,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0x06, 0x9e, 0xd6, 0xb8, 0xef, 0x0f, 0x20, 0x7b,
0x3e, 0x24, 0x3b, 0xb1, 0x01, 0x9f, 0xe6, 0x32
}
},
},
{
{
160,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0xcc, 0xa3, 0x39, 0xd9, 0xa4, 0x5f, 0xa2, 0x36,
0x8c, 0x2c, 0x68, 0xb3, 0xa4, 0x17, 0x91, 0x33
}
},
},
{
{
288,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61,
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0x53, 0xf6, 0xe8, 0x28, 0xa2, 0xf0, 0xfe, 0x0e,
0xe8, 0x15, 0xbf, 0x0b, 0xd5, 0x84, 0x1a, 0x34
}
},
},
{
{
320,
{
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61,
0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
}
},
{
32,
{
0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
}
},
{
16,
{
0xb8, 0x46, 0xd4, 0x4e, 0x9b, 0xbd, 0x53, 0xce,
0xdf, 0xfb, 0xfb, 0xb6, 0xb7, 0xfa, 0x49, 0x33
}
},
},
/*
* 4th power of the key spills to 131th bit in SIMD key setup
*/
{
{
256,
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
}
},
{
32,
{
0xad, 0x62, 0x81, 0x07, 0xe8, 0x35, 0x1d, 0x0f,
0x2c, 0x23, 0x1a, 0x05, 0xdc, 0x4a, 0x41, 0x06,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
16,
{
0x07, 0x14, 0x5a, 0x4c, 0x02, 0xfe, 0x5f, 0xa3,
0x20, 0x36, 0xde, 0x68, 0xfa, 0xbe, 0x90, 0x66
}
},
},
/*
* poly1305_ieee754.c failed this in final stage
*/
{
{
252,
{
0x84, 0x23, 0x64, 0xe1, 0x56, 0x33, 0x6c, 0x09,
0x98, 0xb9, 0x33, 0xa6, 0x23, 0x77, 0x26, 0x18,
0x0d, 0x9e, 0x3f, 0xdc, 0xbd, 0xe4, 0xcd, 0x5d,
0x17, 0x08, 0x0f, 0xc3, 0xbe, 0xb4, 0x96, 0x14,
0xd7, 0x12, 0x2c, 0x03, 0x74, 0x63, 0xff, 0x10,
0x4d, 0x73, 0xf1, 0x9c, 0x12, 0x70, 0x46, 0x28,
0xd4, 0x17, 0xc4, 0xc5, 0x4a, 0x3f, 0xe3, 0x0d,
0x3c, 0x3d, 0x77, 0x14, 0x38, 0x2d, 0x43, 0xb0,
0x38, 0x2a, 0x50, 0xa5, 0xde, 0xe5, 0x4b, 0xe8,
0x44, 0xb0, 0x76, 0xe8, 0xdf, 0x88, 0x20, 0x1a,
0x1c, 0xd4, 0x3b, 0x90, 0xeb, 0x21, 0x64, 0x3f,
0xa9, 0x6f, 0x39, 0xb5, 0x18, 0xaa, 0x83, 0x40,
0xc9, 0x42, 0xff, 0x3c, 0x31, 0xba, 0xf7, 0xc9,
0xbd, 0xbf, 0x0f, 0x31, 0xae, 0x3f, 0xa0, 0x96,
0xbf, 0x8c, 0x63, 0x03, 0x06, 0x09, 0x82, 0x9f,
0xe7, 0x2e, 0x17, 0x98, 0x24, 0x89, 0x0b, 0xc8,
0xe0, 0x8c, 0x31, 0x5c, 0x1c, 0xce, 0x2a, 0x83,
0x14, 0x4d, 0xbb, 0xff, 0x09, 0xf7, 0x4e, 0x3e,
0xfc, 0x77, 0x0b, 0x54, 0xd0, 0x98, 0x4a, 0x8f,
0x19, 0xb1, 0x47, 0x19, 0xe6, 0x36, 0x35, 0x64,
0x1d, 0x6b, 0x1e, 0xed, 0xf6, 0x3e, 0xfb, 0xf0,
0x80, 0xe1, 0x78, 0x3d, 0x32, 0x44, 0x54, 0x12,
0x11, 0x4c, 0x20, 0xde, 0x0b, 0x83, 0x7a, 0x0d,
0xfa, 0x33, 0xd6, 0xb8, 0x28, 0x25, 0xff, 0xf4,
0x4c, 0x9a, 0x70, 0xea, 0x54, 0xce, 0x47, 0xf0,
0x7d, 0xf6, 0x98, 0xe6, 0xb0, 0x33, 0x23, 0xb5,
0x30, 0x79, 0x36, 0x4a, 0x5f, 0xc3, 0xe9, 0xdd,
0x03, 0x43, 0x92, 0xbd, 0xde, 0x86, 0xdc, 0xcd,
0xda, 0x94, 0x32, 0x1c, 0x5e, 0x44, 0x06, 0x04,
0x89, 0x33, 0x6c, 0xb6, 0x5b, 0xf3, 0x98, 0x9c,
0x36, 0xf7, 0x28, 0x2c, 0x2f, 0x5d, 0x2b, 0x88,
0x2c, 0x17, 0x1e, 0x74
}
},
{
32,
{
0x95, 0xd5, 0xc0, 0x05, 0x50, 0x3e, 0x51, 0x0d,
0x8c, 0xd0, 0xaa, 0x07, 0x2c, 0x4a, 0x4d, 0x06,
0x6e, 0xab, 0xc5, 0x2d, 0x11, 0x65, 0x3d, 0xf4,
0x7f, 0xbf, 0x63, 0xab, 0x19, 0x8b, 0xcc, 0x26
}
},
{
16,
{
0xf2, 0x48, 0x31, 0x2e, 0x57, 0x8d, 0x9d, 0x58,
0xf8, 0xb7, 0xbb, 0x4d, 0x19, 0x10, 0x54, 0x31
}
},
},
/*
* AVX2 in poly1305-x86.pl failed this with 176+32 split
*/
{
{
208,
{
0x24, 0x8a, 0xc3, 0x10, 0x85, 0xb6, 0xc2, 0xad,
0xaa, 0xa3, 0x82, 0x59, 0xa0, 0xd7, 0x19, 0x2c,
0x5c, 0x35, 0xd1, 0xbb, 0x4e, 0xf3, 0x9a, 0xd9,
0x4c, 0x38, 0xd1, 0xc8, 0x24, 0x79, 0xe2, 0xdd,
0x21, 0x59, 0xa0, 0x77, 0x02, 0x4b, 0x05, 0x89,
0xbc, 0x8a, 0x20, 0x10, 0x1b, 0x50, 0x6f, 0x0a,
0x1a, 0xd0, 0xbb, 0xab, 0x76, 0xe8, 0x3a, 0x83,
0xf1, 0xb9, 0x4b, 0xe6, 0xbe, 0xae, 0x74, 0xe8,
0x74, 0xca, 0xb6, 0x92, 0xc5, 0x96, 0x3a, 0x75,
0x43, 0x6b, 0x77, 0x61, 0x21, 0xec, 0x9f, 0x62,
0x39, 0x9a, 0x3e, 0x66, 0xb2, 0xd2, 0x27, 0x07,
0xda, 0xe8, 0x19, 0x33, 0xb6, 0x27, 0x7f, 0x3c,
0x85, 0x16, 0xbc, 0xbe, 0x26, 0xdb, 0xbd, 0x86,
0xf3, 0x73, 0x10, 0x3d, 0x7c, 0xf4, 0xca, 0xd1,
0x88, 0x8c, 0x95, 0x21, 0x18, 0xfb, 0xfb, 0xd0,
0xd7, 0xb4, 0xbe, 0xdc, 0x4a, 0xe4, 0x93, 0x6a,
0xff, 0x91, 0x15, 0x7e, 0x7a, 0xa4, 0x7c, 0x54,
0x44, 0x2e, 0xa7, 0x8d, 0x6a, 0xc2, 0x51, 0xd3,
0x24, 0xa0, 0xfb, 0xe4, 0x9d, 0x89, 0xcc, 0x35,
0x21, 0xb6, 0x6d, 0x16, 0xe9, 0xc6, 0x6a, 0x37,
0x09, 0x89, 0x4e, 0x4e, 0xb0, 0xa4, 0xee, 0xdc,
0x4a, 0xe1, 0x94, 0x68, 0xe6, 0x6b, 0x81, 0xf2,
0x71, 0x35, 0x1b, 0x1d, 0x92, 0x1e, 0xa5, 0x51,
0x04, 0x7a, 0xbc, 0xc6, 0xb8, 0x7a, 0x90, 0x1f,
0xde, 0x7d, 0xb7, 0x9f, 0xa1, 0x81, 0x8c, 0x11,
0x33, 0x6d, 0xbc, 0x07, 0x24, 0x4a, 0x40, 0xeb
}
},
{
32,
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
16,
{
0xbc, 0x93, 0x9b, 0xc5, 0x28, 0x14, 0x80, 0xfa,
0x99, 0xc6, 0xd6, 0x8c, 0x25, 0x8e, 0xc4, 0x2f
}
},
},
/*
* test vectors from Google
*/
{
{
0,
{
0x00,
}
},
{
32,
{
0xc8, 0xaf, 0xaa, 0xc3, 0x31, 0xee, 0x37, 0x2c,
0xd6, 0x08, 0x2d, 0xe1, 0x34, 0x94, 0x3b, 0x17,
0x47, 0x10, 0x13, 0x0e, 0x9f, 0x6f, 0xea, 0x8d,
0x72, 0x29, 0x38, 0x50, 0xa6, 0x67, 0xd8, 0x6c
}
},
{
16,
{
0x47, 0x10, 0x13, 0x0e, 0x9f, 0x6f, 0xea, 0x8d,
0x72, 0x29, 0x38, 0x50, 0xa6, 0x67, 0xd8, 0x6c
}
},
},
{
{
12,
{
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f,
0x72, 0x6c, 0x64, 0x21
}
},
{
32,
{
0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
0x33, 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20,
0x6b, 0x65, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x20,
0x50, 0x6f, 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35
}
},
{
16,
{
0xa6, 0xf7, 0x45, 0x00, 0x8f, 0x81, 0xc9, 0x16,
0xa2, 0x0d, 0xcc, 0x74, 0xee, 0xf2, 0xb2, 0xf0
}
},
},
{
{
32,
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
32,
{
0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
0x33, 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20,
0x6b, 0x65, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x20,
0x50, 0x6f, 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35
}
},
{
16,
{
0x49, 0xec, 0x78, 0x09, 0x0e, 0x48, 0x1e, 0xc6,
0xc2, 0x6b, 0x33, 0xb9, 0x1c, 0xcc, 0x03, 0x07
}
},
},
{
{
128,
{
0x89, 0xda, 0xb8, 0x0b, 0x77, 0x17, 0xc1, 0xdb,
0x5d, 0xb4, 0x37, 0x86, 0x0a, 0x3f, 0x70, 0x21,
0x8e, 0x93, 0xe1, 0xb8, 0xf4, 0x61, 0xfb, 0x67,
0x7f, 0x16, 0xf3, 0x5f, 0x6f, 0x87, 0xe2, 0xa9,
0x1c, 0x99, 0xbc, 0x3a, 0x47, 0xac, 0xe4, 0x76,
0x40, 0xcc, 0x95, 0xc3, 0x45, 0xbe, 0x5e, 0xcc,
0xa5, 0xa3, 0x52, 0x3c, 0x35, 0xcc, 0x01, 0x89,
0x3a, 0xf0, 0xb6, 0x4a, 0x62, 0x03, 0x34, 0x27,
0x03, 0x72, 0xec, 0x12, 0x48, 0x2d, 0x1b, 0x1e,
0x36, 0x35, 0x61, 0x69, 0x8a, 0x57, 0x8b, 0x35,
0x98, 0x03, 0x49, 0x5b, 0xb4, 0xe2, 0xef, 0x19,
0x30, 0xb1, 0x7a, 0x51, 0x90, 0xb5, 0x80, 0xf1,
0x41, 0x30, 0x0d, 0xf3, 0x0a, 0xdb, 0xec, 0xa2,
0x8f, 0x64, 0x27, 0xa8, 0xbc, 0x1a, 0x99, 0x9f,
0xd5, 0x1c, 0x55, 0x4a, 0x01, 0x7d, 0x09, 0x5d,
0x8c, 0x3e, 0x31, 0x27, 0xda, 0xf9, 0xf5, 0x95
}
},
{
32,
{
0x2d, 0x77, 0x3b, 0xe3, 0x7a, 0xdb, 0x1e, 0x4d,
0x68, 0x3b, 0xf0, 0x07, 0x5e, 0x79, 0xc4, 0xee,
0x03, 0x79, 0x18, 0x53, 0x5a, 0x7f, 0x99, 0xcc,
0xb7, 0x04, 0x0f, 0xb5, 0xf5, 0xf4, 0x3a, 0xea
}
},
{
16,
{
0xc8, 0x5d, 0x15, 0xed, 0x44, 0xc3, 0x78, 0xd6,
0xb0, 0x0e, 0x23, 0x06, 0x4c, 0x7b, 0xcd, 0x51
}
},
},
{
{
528,
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b,
0x17, 0x03, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00,
0x06, 0xdb, 0x1f, 0x1f, 0x36, 0x8d, 0x69, 0x6a,
0x81, 0x0a, 0x34, 0x9c, 0x0c, 0x71, 0x4c, 0x9a,
0x5e, 0x78, 0x50, 0xc2, 0x40, 0x7d, 0x72, 0x1a,
0xcd, 0xed, 0x95, 0xe0, 0x18, 0xd7, 0xa8, 0x52,
0x66, 0xa6, 0xe1, 0x28, 0x9c, 0xdb, 0x4a, 0xeb,
0x18, 0xda, 0x5a, 0xc8, 0xa2, 0xb0, 0x02, 0x6d,
0x24, 0xa5, 0x9a, 0xd4, 0x85, 0x22, 0x7f, 0x3e,
0xae, 0xdb, 0xb2, 0xe7, 0xe3, 0x5e, 0x1c, 0x66,
0xcd, 0x60, 0xf9, 0xab, 0xf7, 0x16, 0xdc, 0xc9,
0xac, 0x42, 0x68, 0x2d, 0xd7, 0xda, 0xb2, 0x87,
0xa7, 0x02, 0x4c, 0x4e, 0xef, 0xc3, 0x21, 0xcc,
0x05, 0x74, 0xe1, 0x67, 0x93, 0xe3, 0x7c, 0xec,
0x03, 0xc5, 0xbd, 0xa4, 0x2b, 0x54, 0xc1, 0x14,
0xa8, 0x0b, 0x57, 0xaf, 0x26, 0x41, 0x6c, 0x7b,
0xe7, 0x42, 0x00, 0x5e, 0x20, 0x85, 0x5c, 0x73,
0xe2, 0x1d, 0xc8, 0xe2, 0xed, 0xc9, 0xd4, 0x35,
0xcb, 0x6f, 0x60, 0x59, 0x28, 0x00, 0x11, 0xc2,
0x70, 0xb7, 0x15, 0x70, 0x05, 0x1c, 0x1c, 0x9b,
0x30, 0x52, 0x12, 0x66, 0x20, 0xbc, 0x1e, 0x27,
0x30, 0xfa, 0x06, 0x6c, 0x7a, 0x50, 0x9d, 0x53,
0xc6, 0x0e, 0x5a, 0xe1, 0xb4, 0x0a, 0xa6, 0xe3,
0x9e, 0x49, 0x66, 0x92, 0x28, 0xc9, 0x0e, 0xec,
0xb4, 0xa5, 0x0d, 0xb3, 0x2a, 0x50, 0xbc, 0x49,
0xe9, 0x0b, 0x4f, 0x4b, 0x35, 0x9a, 0x1d, 0xfd,
0x11, 0x74, 0x9c, 0xd3, 0x86, 0x7f, 0xcf, 0x2f,
0xb7, 0xbb, 0x6c, 0xd4, 0x73, 0x8f, 0x6a, 0x4a,
0xd6, 0xf7, 0xca, 0x50, 0x58, 0xf7, 0x61, 0x88,
0x45, 0xaf, 0x9f, 0x02, 0x0f, 0x6c, 0x3b, 0x96,
0x7b, 0x8f, 0x4c, 0xd4, 0xa9, 0x1e, 0x28, 0x13,
0xb5, 0x07, 0xae, 0x66, 0xf2, 0xd3, 0x5c, 0x18,
0x28, 0x4f, 0x72, 0x92, 0x18, 0x60, 0x62, 0xe1,
0x0f, 0xd5, 0x51, 0x0d, 0x18, 0x77, 0x53, 0x51,
0xef, 0x33, 0x4e, 0x76, 0x34, 0xab, 0x47, 0x43,
0xf5, 0xb6, 0x8f, 0x49, 0xad, 0xca, 0xb3, 0x84,
0xd3, 0xfd, 0x75, 0xf7, 0x39, 0x0f, 0x40, 0x06,
0xef, 0x2a, 0x29, 0x5c, 0x8c, 0x7a, 0x07, 0x6a,
0xd5, 0x45, 0x46, 0xcd, 0x25, 0xd2, 0x10, 0x7f,
0xbe, 0x14, 0x36, 0xc8, 0x40, 0x92, 0x4a, 0xae,
0xbe, 0x5b, 0x37, 0x08, 0x93, 0xcd, 0x63, 0xd1,
0x32, 0x5b, 0x86, 0x16, 0xfc, 0x48, 0x10, 0x88,
0x6b, 0xc1, 0x52, 0xc5, 0x32, 0x21, 0xb6, 0xdf,
0x37, 0x31, 0x19, 0x39, 0x32, 0x55, 0xee, 0x72,
0xbc, 0xaa, 0x88, 0x01, 0x74, 0xf1, 0x71, 0x7f,
0x91, 0x84, 0xfa, 0x91, 0x64, 0x6f, 0x17, 0xa2,
0x4a, 0xc5, 0x5d, 0x16, 0xbf, 0xdd, 0xca, 0x95,
0x81, 0xa9, 0x2e, 0xda, 0x47, 0x92, 0x01, 0xf0,
0xed, 0xbf, 0x63, 0x36, 0x00, 0xd6, 0x06, 0x6d,
0x1a, 0xb3, 0x6d, 0x5d, 0x24, 0x15, 0xd7, 0x13,
0x51, 0xbb, 0xcd, 0x60, 0x8a, 0x25, 0x10, 0x8d,
0x25, 0x64, 0x19, 0x92, 0xc1, 0xf2, 0x6c, 0x53,
0x1c, 0xf9, 0xf9, 0x02, 0x03, 0xbc, 0x4c, 0xc1,
0x9f, 0x59, 0x27, 0xd8, 0x34, 0xb0, 0xa4, 0x71,
0x16, 0xd3, 0x88, 0x4b, 0xbb, 0x16, 0x4b, 0x8e,
0xc8, 0x83, 0xd1, 0xac, 0x83, 0x2e, 0x56, 0xb3,
0x91, 0x8a, 0x98, 0x60, 0x1a, 0x08, 0xd1, 0x71,
0x88, 0x15, 0x41, 0xd5, 0x94, 0xdb, 0x39, 0x9c,
0x6a, 0xe6, 0x15, 0x12, 0x21, 0x74, 0x5a, 0xec,
0x81, 0x4c, 0x45, 0xb0, 0xb0, 0x5b, 0x56, 0x54,
0x36, 0xfd, 0x6f, 0x13, 0x7a, 0xa1, 0x0a, 0x0c,
0x0b, 0x64, 0x37, 0x61, 0xdb, 0xd6, 0xf9, 0xa9,
0xdc, 0xb9, 0x9b, 0x1a, 0x6e, 0x69, 0x08, 0x54,
0xce, 0x07, 0x69, 0xcd, 0xe3, 0x97, 0x61, 0xd8,
0x2f, 0xcd, 0xec, 0x15, 0xf0, 0xd9, 0x2d, 0x7d,
0x8e, 0x94, 0xad, 0xe8, 0xeb, 0x83, 0xfb, 0xe0
}
},
{
32,
{
0x99, 0xe5, 0x82, 0x2d, 0xd4, 0x17, 0x3c, 0x99,
0x5e, 0x3d, 0xae, 0x0d, 0xde, 0xfb, 0x97, 0x74,
0x3f, 0xde, 0x3b, 0x08, 0x01, 0x34, 0xb3, 0x9f,
0x76, 0xe9, 0xbf, 0x8d, 0x0e, 0x88, 0xd5, 0x46
}
},
{
16,
{
0x26, 0x37, 0x40, 0x8f, 0xe1, 0x30, 0x86, 0xea,
0x73, 0xf9, 0x71, 0xe3, 0x42, 0x5e, 0x28, 0x20
}
},
},
/*
* test vectors from Hanno Böck
*/
{
{
257,
{
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0x80, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xc5,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xe3, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xac, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xe6,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00,
0xaf, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
0xcc, 0xcc, 0xff, 0xff, 0xff, 0xf5, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xe7, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x71, 0x92, 0x05, 0xa8, 0x52, 0x1d,
0xfc
}
},
{
32,
{
0x7f, 0x1b, 0x02, 0x64, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc
}
},
{
16,
{
0x85, 0x59, 0xb8, 0x76, 0xec, 0xee, 0xd6, 0x6e,
0xb3, 0x77, 0x98, 0xc0, 0x45, 0x7b, 0xaf, 0xf9
}
},
},
{
{
39,
{
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x64
}
},
{
32,
{
0xe0, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
}
},
{
16,
{
0x00, 0xbd, 0x12, 0x58, 0x97, 0x8e, 0x20, 0x54,
0x44, 0xc9, 0xaa, 0xaa, 0x82, 0x00, 0x6f, 0xed
}
},
},
{
{
2,
{
0x02, 0xfc
}
},
{
32,
{
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
}
},
{
16,
{
0x06, 0x12, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
}
},
},
{
{
415,
{
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7a, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x5c, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x6e, 0x7b, 0x00, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7a, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x5c,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0x6e, 0x7b, 0x00, 0x13, 0x00, 0x00, 0x00,
0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0xef, 0xff, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x64, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00,
0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x20, 0x00, 0xef, 0xff, 0x00, 0x09,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7a, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x09, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc
}
},
{
32,
{
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x7b
}
},
{
16,
{
0x33, 0x20, 0x5b, 0xbf, 0x9e, 0x9f, 0x8f, 0x72,
0x12, 0xab, 0x9e, 0x2a, 0xb9, 0xb7, 0xe4, 0xa5
}
},
},
{
{
118,
{
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0xff, 0xff, 0xff, 0xe9,
0xe9, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
0xac, 0xac, 0xac, 0xac, 0x00, 0x00, 0xac, 0xac,
0xec, 0x01, 0x00, 0xac, 0xac, 0xac, 0x2c, 0xac,
0xa2, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
0xac, 0xac, 0xac, 0xac, 0x64, 0xf2
}
},
{
32,
{
0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f,
0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xcf, 0x77, 0x77, 0x77, 0x77, 0x77,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77
}
},
{
16,
{
0x02, 0xee, 0x7c, 0x8c, 0x54, 0x6d, 0xde, 0xb1,
0xa4, 0x67, 0xe4, 0xc3, 0x98, 0x11, 0x58, 0xb9
}
},
},
/*
* test vectors from Andrew Moon
*/
{ /* nacl */
{
131,
{
0x8e, 0x99, 0x3b, 0x9f, 0x48, 0x68, 0x12, 0x73,
0xc2, 0x96, 0x50, 0xba, 0x32, 0xfc, 0x76, 0xce,
0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4,
0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a,
0xc0, 0xdf, 0xc1, 0x7c, 0x98, 0xdc, 0xe8, 0x7b,
0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72,
0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2,
0x27, 0x0d, 0x6f, 0xb8, 0x63, 0xd5, 0x17, 0x38,
0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a,
0xb9, 0x32, 0x16, 0x45, 0x48, 0xe5, 0x26, 0xae,
0x90, 0x22, 0x43, 0x68, 0x51, 0x7a, 0xcf, 0xea,
0xbd, 0x6b, 0xb3, 0x73, 0x2b, 0xc0, 0xe9, 0xda,
0x99, 0x83, 0x2b, 0x61, 0xca, 0x01, 0xb6, 0xde,
0x56, 0x24, 0x4a, 0x9e, 0x88, 0xd5, 0xf9, 0xb3,
0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6,
0x59, 0x9b, 0x1f, 0x65, 0x4c, 0xb4, 0x5a, 0x74,
0xe3, 0x55, 0xa5
}
},
{
32,
{
0xee, 0xa6, 0xa7, 0x25, 0x1c, 0x1e, 0x72, 0x91,
0x6d, 0x11, 0xc2, 0xcb, 0x21, 0x4d, 0x3c, 0x25,
0x25, 0x39, 0x12, 0x1d, 0x8e, 0x23, 0x4e, 0x65,
0x2d, 0x65, 0x1f, 0xa4, 0xc8, 0xcf, 0xf8, 0x80
}
},
{
16,
{
0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9
}
},
},
{ /* wrap 2^130-5 */
{
16,
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
}
},
{
32,
{
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
16,
{
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
},
{ /* wrap 2^128 */
{
16,
{
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
32,
{
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
}
},
{
16,
{
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
},
{ /* limb carry */
{
48,
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
32,
{
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
16,
{
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
},
{ /* 2^130-5 */
{
48,
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xfb, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
}
},
{
32,
{
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
16,
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
},
{ /* 2^130-6 */
{
16,
{
0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
}
},
{
32,
{
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
16,
{
0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
}
},
},
{ /* 5*H+L reduction intermediate */
{
64,
{
0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
32,
{
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
16,
{
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
},
{ /* 5*H+L reduction final */
{
48,
{
0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
32,
{
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
},
{
16,
{
0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
}
}
};
static int test_poly1305(int idx)
{
POLY1305 poly1305;
const TESTDATA test = tests[idx];
const unsigned char *in = test.input.data;
size_t inlen = test.input.size;
const unsigned char *key = test.key.data;
const unsigned char *expected = test.expected.data;
size_t expectedlen = test.expected.size;
unsigned char out[16];
if (!TEST_size_t_eq(expectedlen, sizeof(out)))
return 0;
Poly1305_Init(&poly1305, key);
Poly1305_Update(&poly1305, in, inlen);
Poly1305_Final(&poly1305, out);
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
TEST_info("Poly1305 test #%d failed.", idx);
return 0;
}
if (inlen > 16) {
Poly1305_Init(&poly1305, key);
Poly1305_Update(&poly1305, in, 1);
Poly1305_Update(&poly1305, in+1, inlen-1);
Poly1305_Final(&poly1305, out);
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
TEST_info("Poly1305 test #%d/1+(N-1) failed.", idx);
return 0;
}
}
if (inlen > 32) {
size_t half = inlen / 2;
Poly1305_Init(&poly1305, key);
Poly1305_Update(&poly1305, in, half);
Poly1305_Update(&poly1305, in+half, inlen-half);
Poly1305_Final(&poly1305, out);
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
TEST_info("Poly1305 test #%d/2 failed.", idx);
return 0;
}
for (half = 16; half < inlen; half += 16) {
Poly1305_Init(&poly1305, key);
Poly1305_Update(&poly1305, in, half);
Poly1305_Update(&poly1305, in+half, inlen-half);
Poly1305_Final(&poly1305, out);
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
TEST_info("Poly1305 test #%d/%zu+%zu failed.",
idx, half, inlen-half);
return 0;
}
}
}
return 1;
}
int setup_tests(void)
{
ADD_ALL_TESTS(test_poly1305, OSSL_NELEM(tests));
return 1;
}
|
./openssl/test/ssl_test_ctx_test.c | /*
* 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
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
/*
* Ideally, CONF should offer standard parsing methods and cover them
* in tests. But since we have no CONF tests, we use a custom test for now.
*/
#include <stdio.h>
#include <string.h>
#include "internal/nelem.h"
#include "helpers/ssl_test_ctx.h"
#include "testutil.h"
#include <openssl/e_os2.h>
#include <openssl/err.h>
#include <openssl/conf.h>
#include <openssl/ssl.h>
static CONF *conf = NULL;
typedef struct ssl_test_ctx_test_fixture {
const char *test_case_name;
const char *test_section;
/* Expected parsed configuration. */
SSL_TEST_CTX *expected_ctx;
} SSL_TEST_CTX_TEST_FIXTURE;
static int clientconf_eq(SSL_TEST_CLIENT_CONF *conf1,
SSL_TEST_CLIENT_CONF *conf2)
{
if (!TEST_int_eq(conf1->verify_callback, conf2->verify_callback)
|| !TEST_int_eq(conf1->servername, conf2->servername)
|| !TEST_str_eq(conf1->npn_protocols, conf2->npn_protocols)
|| !TEST_str_eq(conf1->alpn_protocols, conf2->alpn_protocols)
|| !TEST_int_eq(conf1->ct_validation, conf2->ct_validation)
|| !TEST_int_eq(conf1->max_fragment_len_mode,
conf2->max_fragment_len_mode))
return 0;
return 1;
}
static int serverconf_eq(SSL_TEST_SERVER_CONF *serv,
SSL_TEST_SERVER_CONF *serv2)
{
if (!TEST_int_eq(serv->servername_callback, serv2->servername_callback)
|| !TEST_str_eq(serv->npn_protocols, serv2->npn_protocols)
|| !TEST_str_eq(serv->alpn_protocols, serv2->alpn_protocols)
|| !TEST_int_eq(serv->broken_session_ticket,
serv2->broken_session_ticket)
|| !TEST_str_eq(serv->session_ticket_app_data,
serv2->session_ticket_app_data)
|| !TEST_int_eq(serv->cert_status, serv2->cert_status))
return 0;
return 1;
}
static int extraconf_eq(SSL_TEST_EXTRA_CONF *extra,
SSL_TEST_EXTRA_CONF *extra2)
{
if (!TEST_true(clientconf_eq(&extra->client, &extra2->client))
|| !TEST_true(serverconf_eq(&extra->server, &extra2->server))
|| !TEST_true(serverconf_eq(&extra->server2, &extra2->server2)))
return 0;
return 1;
}
static int testctx_eq(SSL_TEST_CTX *ctx, SSL_TEST_CTX *ctx2)
{
if (!TEST_int_eq(ctx->method, ctx2->method)
|| !TEST_int_eq(ctx->handshake_mode, ctx2->handshake_mode)
|| !TEST_int_eq(ctx->app_data_size, ctx2->app_data_size)
|| !TEST_int_eq(ctx->max_fragment_size, ctx2->max_fragment_size)
|| !extraconf_eq(&ctx->extra, &ctx2->extra)
|| !extraconf_eq(&ctx->resume_extra, &ctx2->resume_extra)
|| !TEST_int_eq(ctx->expected_result, ctx2->expected_result)
|| !TEST_int_eq(ctx->expected_client_alert,
ctx2->expected_client_alert)
|| !TEST_int_eq(ctx->expected_server_alert,
ctx2->expected_server_alert)
|| !TEST_int_eq(ctx->expected_protocol, ctx2->expected_protocol)
|| !TEST_int_eq(ctx->expected_servername, ctx2->expected_servername)
|| !TEST_int_eq(ctx->session_ticket_expected,
ctx2->session_ticket_expected)
|| !TEST_int_eq(ctx->compression_expected,
ctx2->compression_expected)
|| !TEST_str_eq(ctx->expected_npn_protocol,
ctx2->expected_npn_protocol)
|| !TEST_str_eq(ctx->expected_alpn_protocol,
ctx2->expected_alpn_protocol)
|| !TEST_str_eq(ctx->expected_cipher,
ctx2->expected_cipher)
|| !TEST_str_eq(ctx->expected_session_ticket_app_data,
ctx2->expected_session_ticket_app_data)
|| !TEST_int_eq(ctx->resumption_expected,
ctx2->resumption_expected)
|| !TEST_int_eq(ctx->session_id_expected,
ctx2->session_id_expected))
return 0;
return 1;
}
static SSL_TEST_CTX_TEST_FIXTURE *set_up(const char *const test_case_name)
{
SSL_TEST_CTX_TEST_FIXTURE *fixture;
if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture))))
return NULL;
fixture->test_case_name = test_case_name;
if (!TEST_ptr(fixture->expected_ctx = SSL_TEST_CTX_new(NULL))) {
OPENSSL_free(fixture);
return NULL;
}
return fixture;
}
static int execute_test(SSL_TEST_CTX_TEST_FIXTURE *fixture)
{
int success = 0;
SSL_TEST_CTX *ctx;
if (!TEST_ptr(ctx = SSL_TEST_CTX_create(conf, fixture->test_section,
fixture->expected_ctx->libctx))
|| !testctx_eq(ctx, fixture->expected_ctx))
goto err;
success = 1;
err:
SSL_TEST_CTX_free(ctx);
return success;
}
static void tear_down(SSL_TEST_CTX_TEST_FIXTURE *fixture)
{
SSL_TEST_CTX_free(fixture->expected_ctx);
OPENSSL_free(fixture);
}
#define SETUP_SSL_TEST_CTX_TEST_FIXTURE() \
SETUP_TEST_FIXTURE(SSL_TEST_CTX_TEST_FIXTURE, set_up);
#define EXECUTE_SSL_TEST_CTX_TEST() \
EXECUTE_TEST(execute_test, tear_down)
static int test_empty_configuration(void)
{
SETUP_SSL_TEST_CTX_TEST_FIXTURE();
fixture->test_section = "ssltest_default";
fixture->expected_ctx->expected_result = SSL_TEST_SUCCESS;
EXECUTE_SSL_TEST_CTX_TEST();
return result;
}
static int test_good_configuration(void)
{
SETUP_SSL_TEST_CTX_TEST_FIXTURE();
fixture->test_section = "ssltest_good";
fixture->expected_ctx->method = SSL_TEST_METHOD_DTLS;
fixture->expected_ctx->handshake_mode = SSL_TEST_HANDSHAKE_RESUME;
fixture->expected_ctx->app_data_size = 1024;
fixture->expected_ctx->max_fragment_size = 2048;
fixture->expected_ctx->expected_result = SSL_TEST_SERVER_FAIL;
fixture->expected_ctx->expected_client_alert = SSL_AD_UNKNOWN_CA;
fixture->expected_ctx->expected_server_alert = 0; /* No alert. */
fixture->expected_ctx->expected_protocol = TLS1_1_VERSION;
fixture->expected_ctx->expected_servername = SSL_TEST_SERVERNAME_SERVER2;
fixture->expected_ctx->session_ticket_expected = SSL_TEST_SESSION_TICKET_YES;
fixture->expected_ctx->compression_expected = SSL_TEST_COMPRESSION_NO;
fixture->expected_ctx->session_id_expected = SSL_TEST_SESSION_ID_IGNORE;
fixture->expected_ctx->resumption_expected = 1;
fixture->expected_ctx->extra.client.verify_callback =
SSL_TEST_VERIFY_REJECT_ALL;
fixture->expected_ctx->extra.client.servername = SSL_TEST_SERVERNAME_SERVER2;
fixture->expected_ctx->extra.client.npn_protocols =
OPENSSL_strdup("foo,bar");
if (!TEST_ptr(fixture->expected_ctx->extra.client.npn_protocols))
goto err;
fixture->expected_ctx->extra.client.max_fragment_len_mode = 0;
fixture->expected_ctx->extra.server.servername_callback =
SSL_TEST_SERVERNAME_IGNORE_MISMATCH;
fixture->expected_ctx->extra.server.broken_session_ticket = 1;
fixture->expected_ctx->resume_extra.server2.alpn_protocols =
OPENSSL_strdup("baz");
if (!TEST_ptr(fixture->expected_ctx->resume_extra.server2.alpn_protocols))
goto err;
fixture->expected_ctx->resume_extra.client.ct_validation =
SSL_TEST_CT_VALIDATION_STRICT;
EXECUTE_SSL_TEST_CTX_TEST();
return result;
err:
tear_down(fixture);
return 0;
}
static const char *bad_configurations[] = {
"ssltest_unknown_option",
"ssltest_wrong_section",
"ssltest_unknown_expected_result",
"ssltest_unknown_alert",
"ssltest_unknown_protocol",
"ssltest_unknown_verify_callback",
"ssltest_unknown_servername",
"ssltest_unknown_servername_callback",
"ssltest_unknown_session_ticket_expected",
"ssltest_unknown_compression_expected",
"ssltest_unknown_session_id_expected",
"ssltest_unknown_method",
"ssltest_unknown_handshake_mode",
"ssltest_unknown_resumption_expected",
"ssltest_unknown_ct_validation",
"ssltest_invalid_max_fragment_len",
};
static int test_bad_configuration(int idx)
{
SSL_TEST_CTX *ctx;
if (!TEST_ptr_null(ctx = SSL_TEST_CTX_create(conf,
bad_configurations[idx], NULL))) {
SSL_TEST_CTX_free(ctx);
return 0;
}
return 1;
}
OPT_TEST_DECLARE_USAGE("conf_file\n")
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(conf = NCONF_new(NULL)))
return 0;
/* argument should point to test/ssl_test_ctx_test.cnf */
if (!TEST_int_gt(NCONF_load(conf, test_get_argument(0), NULL), 0))
return 0;
ADD_TEST(test_empty_configuration);
ADD_TEST(test_good_configuration);
ADD_ALL_TESTS(test_bad_configuration, OSSL_NELEM(bad_configurations));
return 1;
}
void cleanup_tests(void)
{
NCONF_free(conf);
}
|
./openssl/test/tls13encryptiontest.c | /*
* Copyright 2016-2023 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 <openssl/ssl.h>
#include <openssl/evp.h>
#include "../ssl/ssl_local.h"
#include "../ssl/record/record_local.h"
#include "internal/recordmethod.h"
#include "../ssl/record/methods/recmethod_local.h"
#include "internal/nelem.h"
#include "testutil.h"
/*
* Based on the test vectors provided in:
* https://tools.ietf.org/html/draft-ietf-tls-tls13-vectors-06
*/
typedef struct {
/*
* We split these into 3 chunks in order to work around the 509 character
* limit that the standard specifies for string literals
*/
const char *plaintext[3];
const char *ciphertext[3];
const char *key;
const char *iv;
const char *seq;
} RECORD_DATA;
/*
* Note 1: The plaintext values given here have an additional "16" or "17" byte
* added to the end when compared to the official vectors. The official vectors
* do not include the inner content type, but we require it.
*
* Note 2: These are the vectors for the "Simple 1-RTT Handshake"
*/
static RECORD_DATA refdata[] = {
{
/*
* Server: EncryptedExtensions, Certificate, CertificateVerify and
* Finished
*/
{
"080000240022000a00140012001d00170018001901000101010201030104001c"
"00024001000000000b0001b9000001b50001b0308201ac30820115a003020102"
"020102300d06092a864886f70d01010b0500300e310c300a0603550403130372"
"7361301e170d3136303733303031323335395a170d3236303733303031323335"
"395a300e310c300a0603550403130372736130819f300d06092a864886f70d01"
"0101050003818d0030818902818100b4bb498f8279303d980836399b36c6988c"
"0c68de55e1bdb826d3901a2461eafd2de49a91d015abbc9a95137ace6c1af19e",
"aa6af98c7ced43120998e187a80ee0ccb0524b1b018c3e0b63264d449a6d38e2"
"2a5fda430846748030530ef0461c8ca9d9efbfae8ea6d1d03e2bd193eff0ab9a"
"8002c47428a6d35a8d88d79f7f1e3f0203010001a31a301830090603551d1304"
"023000300b0603551d0f0404030205a0300d06092a864886f70d01010b050003"
"81810085aad2a0e5b9276b908c65f73a7267170618a54c5f8a7b337d2df7a594"
"365417f2eae8f8a58c8f8172f9319cf36b7fd6c55b80f21a03015156726096fd"
"335e5e67f2dbf102702e608ccae6bec1fc63a42a99be5c3eb7107c3c54e9b9eb",
"2bd5203b1c3b84e0a8b2f759409ba3eac9d91d402dcc0cc8f8961229ac9187b4"
"2b4de100000f00008408040080754040d0ddab8cf0e2da2bc4995b868ad745c8"
"e1564e33cde17880a42392cc624aeef6b67bb3f0ae71d9d54a2309731d87dc59"
"f642d733be2eb27484ad8a8c8eb3516a7ac57f2625e2b5c0888a8541f4e734f7"
"3d054761df1dd02f0e3e9a33cfa10b6e3eb4ebf7ac053b01fdabbddfc54133bc"
"d24c8bbdceb223b2aa03452a2914000020ac86acbc9cd25a45b57ad5b64db15d"
"4405cf8c80e314583ebf3283ef9a99310c16"
},
{
"f10b26d8fcaf67b5b828f712122216a1cd14187465b77637cbcd78539128bb93"
"246dcca1af56f1eaa271666077455bc54965d85f05f9bd36d6996171eb536aff"
"613eeddc42bad5a2d2227c4606f1215f980e7afaf56bd3b85a51be130003101a"
"758d077b1c891d8e7a22947e5a229851fd42a9dd422608f868272abf92b3d43f"
"b46ac420259346067f66322fd708885680f4b4433c29116f2dfa529e09bba53c"
"7cd920121724809eaddcc84307ef46fc51a0b33d99d39db337fcd761ce0f2b02"
"dc73dedb6fddb77c4f8099bde93d5bee08bcf2131f29a2a37ff07949e8f8bcdd",
"3e8310b8bf8b3444c85aaf0d2aeb2d4f36fd14d5cb51fcebff418b3827136ab9"
"529e9a3d3f35e4c0ae749ea2dbc94982a1281d3e6daab719aa4460889321a008"
"bf10fa06ac0c61cc122cc90d5e22c0030c986ae84a33a0c47df174bcfbd50bf7"
"8ffdf24051ab423db63d5815db2f830040f30521131c98c66f16c362addce2fb"
"a0602cf0a7dddf22e8def7516cdfee95b4056cc9ad38c95352335421b5b1ffba"
"df75e5212fdad7a75f52a2801486a1eec3539580bee0e4b337cda6085ac9eccd"
"1a0f1a46cebfbb5cdfa3251ac28c3bc826148c6d8c1eb6a06f77f6ff632c6a83",
"e283e8f9df7c6dbabf1c6ea40629a85b43ab0c73d34f9d5072832a104eda3f75"
"f5d83da6e14822a18e14099d749eafd823ca2ac7542086501eca206ce7887920"
"008573757ce2f230a890782b99cc682377beee812756d04f9025135fb599d746"
"fefe7316c922ac265ca0d29021375adb63c1509c3e242dfb92b8dee891f7368c"
"4058399b8db9075f2dcc8216194e503b6652d87d2cb41f99adfdcc5be5ec7e1e"
"6326ac22d70bd3ba652827532d669aff005173597f8039c3ea4922d3ec757670"
"222f6ac29b93e90d7ad3f6dd96328e429cfcfd5cca22707fe2d86ad1dcb0be75"
"6e8e"
},
"c66cb1aec519df44c91e10995511ac8b",
"f7f6884c4981716c2d0d29a4",
"0000000000000000"
},
{
/* Client: Finished */
{
"14000020b9027a0204b972b52cdefa58950fa1580d68c9cb124dbe691a7178f2"
"5c554b2316", "", ""
},
{
"9539b4ae2f87fd8e616b295628ea953d9e3858db274970d19813ec136cae7d96"
"e0417775fcabd3d8858fdc60240912d218f5afb21c", "", ""
},
"2679a43e1d76784034ea1797d5ad2649",
"5482405290dd0d2f81c0d942",
"0000000000000000"
},
{
/* Server: NewSessionTicket */
{
"040000c90000001e2fd3992f02000000b2ff099f9676cdff8b0bf8825d000000"
"007905a9d28efeef4a47c6f9b06a0cecdb0070d920b898997c75b79636943ed4"
"2046a96142bd084a04acfa0c490f452d756dea02c0f927259f1f3231ac0d541a"
"769129b740ce38090842b828c27fd729f59737ba98aa7b42e043c5da28f8dca8"
"590b2df410d5134fd6c4cacad8b30370602afa35d265bf4d127976bb36dbda6a"
"626f0270e20eebc73d6fcae2b1a0da122ee9042f76be56ebf41aa469c3d2c9da"
"9197d80008002a00040000040016", "", ""
},
{
"3680c2b2109d25caa26c3b06eea9fdc5cb31613ba702176596da2e886bf6af93"
"507bd68161ad9cb4780653842e1041ecbf0088a65ac4ef438419dd1d95ddd9bd"
"2ad4484e7e167d0e6c008448ae58a0418713b6fc6c51e4bb23a537fb75a74f73"
"de31fe6aa0bc522515f8b25f8955428b5de5ac06762cec22b0aa78c94385ef8e"
"70fa24945b7c1f268510871689bbbbfaf2e7f4a19277024f95f1143ab12a31ec"
"63adb128cb390711fd6d06a498df3e98615d8eb102e23353b480efcca5e8e026"
"7a6d0fe2441f14c8c9664aefb2cfff6ae9e0442728b6a0940c1e824fda06",
"", ""
},
"a688ebb5ac826d6f42d45c0cc44b9b7d",
"c1cad4425a438b5de714830a",
"0000000000000000"
},
{
/* Client: Application Data */
{
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
"202122232425262728292a2b2c2d2e2f303117", "", ""
},
{
"8c3497da00ae023e53c01b4324b665404c1b49e78fe2bf4d17f6348ae8340551"
"e363a0cd05f2179c4fef5ad689b5cae0bae94adc63632e571fb79aa91544c639"
"4d28a1", "", ""
},
"88b96ad686c84be55ace18a59cce5c87",
"b99dc58cd5ff5ab082fdad19",
"0000000000000000"
},
{
/* Server: Application Data */
{
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
"202122232425262728292a2b2c2d2e2f303117", "", ""
},
{
"f65f49fd2df6cd2347c3d30166e3cfddb6308a5906c076112c6a37ff1dbd406b"
"5813c0abd734883017a6b2833186b13c14da5d75f33d8760789994e27d82043a"
"b88d65", "", ""
},
"a688ebb5ac826d6f42d45c0cc44b9b7d",
"c1cad4425a438b5de714830a",
"0000000000000001"
},
{
/* Client: CloseNotify */
{
"010015", "", ""
},
{
"2c2148163d7938a35f6acf2a6606f8cbd1d9f2", "", ""
},
"88b96ad686c84be55ace18a59cce5c87",
"b99dc58cd5ff5ab082fdad19",
"0000000000000001"
},
{
/* Server: CloseNotify */
{
"010015", "", ""
},
{
"f8141ebdb5eda511e0bce639a56ff9ea825a21", "", ""
},
"a688ebb5ac826d6f42d45c0cc44b9b7d",
"c1cad4425a438b5de714830a",
"0000000000000002"
}
};
/*
* Same thing as OPENSSL_hexstr2buf() but enables us to pass the string in
* 3 chunks
*/
static unsigned char *multihexstr2buf(const char *str[3], size_t *len)
{
size_t outer, inner, curr = 0;
unsigned char *outbuf;
size_t totlen = 0;
/* Check lengths of all input strings are even */
for (outer = 0; outer < 3; outer++) {
totlen += strlen(str[outer]);
if ((totlen & 1) != 0)
return NULL;
}
totlen /= 2;
outbuf = OPENSSL_malloc(totlen);
if (outbuf == NULL)
return NULL;
for (outer = 0; outer < 3; outer++) {
for (inner = 0; str[outer][inner] != 0; inner += 2) {
int hi, lo;
hi = OPENSSL_hexchar2int(str[outer][inner]);
lo = OPENSSL_hexchar2int(str[outer][inner + 1]);
if (hi < 0 || lo < 0) {
OPENSSL_free(outbuf);
return NULL;
}
outbuf[curr++] = (hi << 4) | lo;
}
}
*len = totlen;
return outbuf;
}
static int load_record(TLS_RL_RECORD *rec, RECORD_DATA *recd,
unsigned char **key, unsigned char *iv, size_t ivlen,
unsigned char *seq)
{
unsigned char *pt = NULL, *sq = NULL, *ivtmp = NULL;
size_t ptlen;
*key = OPENSSL_hexstr2buf(recd->key, NULL);
ivtmp = OPENSSL_hexstr2buf(recd->iv, NULL);
sq = OPENSSL_hexstr2buf(recd->seq, NULL);
pt = multihexstr2buf(recd->plaintext, &ptlen);
if (*key == NULL || ivtmp == NULL || sq == NULL || pt == NULL)
goto err;
rec->data = rec->input = OPENSSL_malloc(ptlen + EVP_GCM_TLS_TAG_LEN);
if (rec->data == NULL)
goto err;
rec->length = ptlen;
memcpy(rec->data, pt, ptlen);
OPENSSL_free(pt);
memcpy(seq, sq, SEQ_NUM_SIZE);
OPENSSL_free(sq);
memcpy(iv, ivtmp, ivlen);
OPENSSL_free(ivtmp);
return 1;
err:
OPENSSL_free(*key);
*key = NULL;
OPENSSL_free(ivtmp);
OPENSSL_free(sq);
OPENSSL_free(pt);
return 0;
}
static int test_record(TLS_RL_RECORD *rec, RECORD_DATA *recd, int enc)
{
int ret = 0;
unsigned char *refd;
size_t refdatalen = 0;
if (enc)
refd = multihexstr2buf(recd->ciphertext, &refdatalen);
else
refd = multihexstr2buf(recd->plaintext, &refdatalen);
if (!TEST_ptr(refd)) {
TEST_info("Failed to get reference data");
goto err;
}
if (!TEST_mem_eq(rec->data, rec->length, refd, refdatalen))
goto err;
ret = 1;
err:
OPENSSL_free(refd);
return ret;
}
#define TLS13_AES_128_GCM_SHA256_BYTES ((const unsigned char *)"\x13\x01")
static int test_tls13_encryption(void)
{
TLS_RL_RECORD rec;
unsigned char *key = NULL;
const EVP_CIPHER *ciph = EVP_aes_128_gcm();
int ret = 0;
size_t ivlen, ctr;
unsigned char seqbuf[SEQ_NUM_SIZE];
unsigned char iv[EVP_MAX_IV_LENGTH];
OSSL_RECORD_LAYER *rrl = NULL, *wrl = NULL;
/*
* Encrypted TLSv1.3 records always have an outer content type of
* application data, and a record version of TLSv1.2.
*/
rec.data = NULL;
rec.type = SSL3_RT_APPLICATION_DATA;
rec.rec_version = TLS1_2_VERSION;
for (ctr = 0; ctr < OSSL_NELEM(refdata); ctr++) {
/* Load the record */
ivlen = EVP_CIPHER_get_iv_length(ciph);
if (!load_record(&rec, &refdata[ctr], &key, iv, ivlen, seqbuf)) {
TEST_error("Failed loading key into EVP_CIPHER_CTX");
goto err;
}
/* Set up the write record layer */
if (!TEST_true(ossl_tls_record_method.new_record_layer(
NULL, NULL, TLS1_3_VERSION, OSSL_RECORD_ROLE_SERVER,
OSSL_RECORD_DIRECTION_WRITE,
OSSL_RECORD_PROTECTION_LEVEL_APPLICATION, 0, NULL, 0,
key, 16, iv, ivlen, NULL, 0, EVP_aes_128_gcm(),
EVP_GCM_TLS_TAG_LEN, 0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
&wrl)))
goto err;
memcpy(wrl->sequence, seqbuf, sizeof(seqbuf));
/* Encrypt it */
if (!TEST_size_t_eq(wrl->funcs->cipher(wrl, &rec, 1, 1, NULL, 0), 1)) {
TEST_info("Failed to encrypt record %zu", ctr);
goto err;
}
if (!TEST_true(test_record(&rec, &refdata[ctr], 1))) {
TEST_info("Record %zu encryption test failed", ctr);
goto err;
}
/* Set up the read record layer */
if (!TEST_true(ossl_tls_record_method.new_record_layer(
NULL, NULL, TLS1_3_VERSION, OSSL_RECORD_ROLE_SERVER,
OSSL_RECORD_DIRECTION_READ,
OSSL_RECORD_PROTECTION_LEVEL_APPLICATION, 0, NULL, 0,
key, 16, iv, ivlen, NULL, 0, EVP_aes_128_gcm(),
EVP_GCM_TLS_TAG_LEN, 0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
&rrl)))
goto err;
memcpy(rrl->sequence, seqbuf, sizeof(seqbuf));
/* Decrypt it */
if (!TEST_int_eq(rrl->funcs->cipher(rrl, &rec, 1, 0, NULL, 0), 1)) {
TEST_info("Failed to decrypt record %zu", ctr);
goto err;
}
if (!TEST_true(test_record(&rec, &refdata[ctr], 0))) {
TEST_info("Record %zu decryption test failed", ctr);
goto err;
}
ossl_tls_record_method.free(rrl);
ossl_tls_record_method.free(wrl);
rrl = wrl = NULL;
OPENSSL_free(rec.data);
OPENSSL_free(key);
rec.data = NULL;
key = NULL;
}
TEST_note("PASS: %zu records tested", ctr);
ret = 1;
err:
ossl_tls_record_method.free(rrl);
ossl_tls_record_method.free(wrl);
OPENSSL_free(rec.data);
OPENSSL_free(key);
return ret;
}
int setup_tests(void)
{
ADD_TEST(test_tls13_encryption);
return 1;
}
|
./openssl/test/asn1_internal_test.c | /*
* Copyright 1999-2023 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
*/
/* Internal tests for the asn1 module */
/*
* RSA low level APIs are deprecated for public use, but still ok for
* internal use.
*/
#include "internal/deprecated.h"
#include <stdio.h>
#include <string.h>
#include <openssl/asn1.h>
#include <openssl/evp.h>
#include <openssl/objects.h>
#include "testutil.h"
#include "internal/nelem.h"
/**********************************************************************
*
* Test of a_strnid's tbl_standard
*
***/
#include "../crypto/asn1/tbl_standard.h"
static int test_tbl_standard(void)
{
const ASN1_STRING_TABLE *tmp;
int last_nid = -1;
size_t i;
for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++) {
if (tmp->nid < last_nid) {
last_nid = 0;
break;
}
last_nid = tmp->nid;
}
if (TEST_int_ne(last_nid, 0)) {
TEST_info("asn1 tbl_standard: Table order OK");
return 1;
}
TEST_info("asn1 tbl_standard: out of order");
for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++)
TEST_note("asn1 tbl_standard: Index %zu, NID %d, Name=%s",
i, tmp->nid, OBJ_nid2ln(tmp->nid));
return 0;
}
/**********************************************************************
*
* Test of ameth_lib's standard_methods
*
***/
#include "crypto/asn1.h"
#include "../crypto/asn1/standard_methods.h"
static int test_standard_methods(void)
{
const EVP_PKEY_ASN1_METHOD **tmp;
int last_pkey_id = -1;
size_t i;
int ok = 1;
for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods);
i++, tmp++) {
if ((*tmp)->pkey_id < last_pkey_id) {
last_pkey_id = 0;
break;
}
last_pkey_id = (*tmp)->pkey_id;
/*
* One of the following must be true:
*
* pem_str == NULL AND ASN1_PKEY_ALIAS is set
* pem_str != NULL AND ASN1_PKEY_ALIAS is clear
*
* Anything else is an error and may lead to a corrupt ASN1 method table
*/
if (!TEST_true(((*tmp)->pem_str == NULL && ((*tmp)->pkey_flags & ASN1_PKEY_ALIAS) != 0)
|| ((*tmp)->pem_str != NULL && ((*tmp)->pkey_flags & ASN1_PKEY_ALIAS) == 0))) {
TEST_note("asn1 standard methods: Index %zu, pkey ID %d, Name=%s",
i, (*tmp)->pkey_id, OBJ_nid2sn((*tmp)->pkey_id));
ok = 0;
}
}
if (TEST_int_ne(last_pkey_id, 0)) {
TEST_info("asn1 standard methods: Table order OK");
return ok;
}
TEST_note("asn1 standard methods: out of order");
for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods);
i++, tmp++)
TEST_note("asn1 standard methods: Index %zu, pkey ID %d, Name=%s",
i, (*tmp)->pkey_id, OBJ_nid2sn((*tmp)->pkey_id));
return 0;
}
/**********************************************************************
*
* Test of that i2d fail on non-existing non-optional items
*
***/
#include <openssl/rsa.h>
static int test_empty_nonoptional_content(void)
{
RSA *rsa = NULL;
BIGNUM *n = NULL;
BIGNUM *e = NULL;
int ok = 0;
if (!TEST_ptr(rsa = RSA_new())
|| !TEST_ptr(n = BN_new())
|| !TEST_ptr(e = BN_new())
|| !TEST_true(RSA_set0_key(rsa, n, e, NULL)))
goto end;
n = e = NULL; /* They are now "owned" by |rsa| */
/*
* This SHOULD fail, as we're trying to encode a public key as a private
* key. The private key bits MUST be present for a proper RSAPrivateKey.
*/
if (TEST_int_le(i2d_RSAPrivateKey(rsa, NULL), 0))
ok = 1;
end:
RSA_free(rsa);
BN_free(n);
BN_free(e);
return ok;
}
/**********************************************************************
*
* Tests of the Unicode code point range
*
***/
static int test_unicode(const unsigned char *univ, size_t len, int expected)
{
const unsigned char *end = univ + len;
int ok = 1;
for (; univ < end; univ += 4) {
if (!TEST_int_eq(ASN1_mbstring_copy(NULL, univ, 4, MBSTRING_UNIV,
B_ASN1_UTF8STRING),
expected))
ok = 0;
}
return ok;
}
static int test_unicode_range(void)
{
const unsigned char univ_ok[] = "\0\0\0\0"
"\0\0\xd7\xff"
"\0\0\xe0\x00"
"\0\x10\xff\xff";
const unsigned char univ_bad[] = "\0\0\xd8\x00"
"\0\0\xdf\xff"
"\0\x11\x00\x00"
"\x80\x00\x00\x00"
"\xff\xff\xff\xff";
int ok = 1;
if (!test_unicode(univ_ok, sizeof univ_ok - 1, V_ASN1_UTF8STRING))
ok = 0;
if (!test_unicode(univ_bad, sizeof univ_bad - 1, -1))
ok = 0;
return ok;
}
/**********************************************************************
*
* Tests of object creation
*
***/
static int test_obj_create_once(const char *oid, const char *sn, const char *ln)
{
int nid;
ERR_set_mark();
nid = OBJ_create(oid, sn, ln);
if (nid == NID_undef) {
unsigned long err = ERR_peek_last_error();
int l = ERR_GET_LIB(err);
int r = ERR_GET_REASON(err);
/* If it exists, that's fine, otherwise not */
if (l != ERR_LIB_OBJ || r != OBJ_R_OID_EXISTS) {
ERR_clear_last_mark();
return 0;
}
}
ERR_pop_to_mark();
return 1;
}
static int test_obj_create(void)
{
/* Stolen from evp_extra_test.c */
#define arc "1.3.6.1.4.1.16604.998866."
#define broken_arc "25."
#define sn_prefix "custom"
#define ln_prefix "custom"
/* Try different combinations of correct object creation */
if (!TEST_true(test_obj_create_once(NULL, sn_prefix "1", NULL))
|| !TEST_int_ne(OBJ_sn2nid(sn_prefix "1"), NID_undef)
|| !TEST_true(test_obj_create_once(NULL, NULL, ln_prefix "2"))
|| !TEST_int_ne(OBJ_ln2nid(ln_prefix "2"), NID_undef)
|| !TEST_true(test_obj_create_once(NULL, sn_prefix "3", ln_prefix "3"))
|| !TEST_int_ne(OBJ_sn2nid(sn_prefix "3"), NID_undef)
|| !TEST_int_ne(OBJ_ln2nid(ln_prefix "3"), NID_undef)
|| !TEST_true(test_obj_create_once(arc "4", NULL, NULL))
|| !TEST_true(test_obj_create_once(arc "5", sn_prefix "5", NULL))
|| !TEST_int_ne(OBJ_sn2nid(sn_prefix "5"), NID_undef)
|| !TEST_true(test_obj_create_once(arc "6", NULL, ln_prefix "6"))
|| !TEST_int_ne(OBJ_ln2nid(ln_prefix "6"), NID_undef)
|| !TEST_true(test_obj_create_once(arc "7",
sn_prefix "7", ln_prefix "7"))
|| !TEST_int_ne(OBJ_sn2nid(sn_prefix "7"), NID_undef)
|| !TEST_int_ne(OBJ_ln2nid(ln_prefix "7"), NID_undef))
return 0;
if (!TEST_false(test_obj_create_once(NULL, NULL, NULL))
|| !TEST_false(test_obj_create_once(broken_arc "8",
sn_prefix "8", ln_prefix "8")))
return 0;
return 1;
}
static int test_obj_nid_undef(void)
{
if (!TEST_ptr(OBJ_nid2obj(NID_undef))
|| !TEST_ptr(OBJ_nid2sn(NID_undef))
|| !TEST_ptr(OBJ_nid2ln(NID_undef)))
return 0;
return 1;
}
int setup_tests(void)
{
ADD_TEST(test_tbl_standard);
ADD_TEST(test_standard_methods);
ADD_TEST(test_empty_nonoptional_content);
ADD_TEST(test_unicode_range);
ADD_TEST(test_obj_create);
ADD_TEST(test_obj_nid_undef);
return 1;
}
|
./openssl/test/bio_tfo_test.c | /*
* Copyright 2022 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 <openssl/bio.h>
#include "internal/e_os.h"
#include "internal/sockets.h"
#include "internal/bio_tfo.h"
#include "testutil.h"
/* If OS support is added in crypto/bio/bio_tfo.h, add it here */
#if defined(OPENSSL_SYS_LINUX)
# define GOOD_OS 1
#elif defined(__FreeBSD__)
# define GOOD_OS 1
#elif defined(OPENSSL_SYS_MACOSX)
# define GOOD_OS 1
#else
# ifdef GOOD_OS
# undef GOOD_OS
# endif
#endif
#if !defined(OPENSSL_NO_TFO) && defined(GOOD_OS)
/*
* This test is to ensure that if TCP Fast Open is configured, that socket
* connections will still work. These tests are able to detect if TCP Fast
* Open works, but the tests will pass as long as the socket connects.
*
* The first test function tests the socket interface as implemented as BIOs.
*
* The second test functions tests the socket interface as implemented as fds.
*
* The tests are run 5 times. The first time is without TFO.
* The second test will create the TCP fast open cookie,
* this can be seen in `ip tcp_metrics` and in /proc/net/netstat/ on Linux.
* e.g. on Linux 4.15.0-135-generic:
* $ grep '^TcpExt:' /proc/net/netstat | cut -d ' ' -f 84-90 | column -t
* The third attempt will use the cookie and actually do TCP fast open.
* The 4th time is client-TFO only, the 5th time is server-TFO only.
*/
# define SOCKET_DATA "FooBar"
# define SOCKET_DATA_LEN sizeof(SOCKET_DATA)
static int test_bio_tfo(int idx)
{
BIO *cbio = NULL;
BIO *abio = NULL;
BIO *sbio = NULL;
int ret = 0;
int sockerr = 0;
const char *port;
int server_tfo = 0;
int client_tfo = 0;
size_t bytes;
char read_buffer[20];
switch (idx) {
default:
case 0:
break;
case 1:
case 2:
server_tfo = 1;
client_tfo = 1;
break;
case 3:
client_tfo = 1;
break;
case 4:
server_tfo = 1;
break;
}
/* ACCEPT SOCKET */
if (!TEST_ptr(abio = BIO_new_accept("localhost:0"))
|| !TEST_true(BIO_set_nbio_accept(abio, 1))
|| !TEST_true(BIO_set_tfo_accept(abio, server_tfo))
|| !TEST_int_gt(BIO_do_accept(abio), 0)
|| !TEST_ptr(port = BIO_get_accept_port(abio))) {
sockerr = get_last_socket_error();
goto err;
}
/* Note: first BIO_do_accept will basically do the bind/listen */
/* CLIENT SOCKET */
if (!TEST_ptr(cbio = BIO_new_connect("localhost"))
|| !TEST_long_gt(BIO_set_conn_port(cbio, port), 0)
|| !TEST_long_gt(BIO_set_nbio(cbio, 1), 0)
|| !TEST_long_gt(BIO_set_tfo(cbio, client_tfo), 0)) {
sockerr = get_last_socket_error();
goto err;
}
/* FIRST ACCEPT: no connection should be established */
if (BIO_do_accept(abio) <= 0) {
if (!BIO_should_retry(abio)) {
sockerr = get_last_socket_error();
BIO_printf(bio_err, "Error: failed without EAGAIN\n");
goto err;
}
} else {
sbio = BIO_pop(abio);
BIO_printf(bio_err, "Error: accepted unknown connection\n");
goto err;
}
/* CONNECT ATTEMPT: different behavior based on TFO support */
if (BIO_do_connect(cbio) <= 0) {
sockerr = get_last_socket_error();
if (sockerr == EOPNOTSUPP) {
BIO_printf(bio_err, "Skip: TFO not enabled/supported for client\n");
goto success;
} else if (sockerr != EINPROGRESS) {
BIO_printf(bio_err, "Error: failed without EINPROGRESSn");
goto err;
}
}
/* macOS needs some time for this to happen, so put in a select */
if (!TEST_int_ge(BIO_wait(abio, time(NULL) + 2, 0), 0)) {
sockerr = get_last_socket_error();
BIO_printf(bio_err, "Error: socket wait failed\n");
goto err;
}
/* SECOND ACCEPT: if TFO is supported, this will still fail until data is sent */
if (BIO_do_accept(abio) <= 0) {
if (!BIO_should_retry(abio)) {
sockerr = get_last_socket_error();
BIO_printf(bio_err, "Error: failed without EAGAIN\n");
goto err;
}
} else {
if (idx == 0)
BIO_printf(bio_err, "Success: non-TFO connection accepted without data\n");
else if (idx == 1)
BIO_printf(bio_err, "Ignore: connection accepted before data, possibly no TFO cookie, or TFO may not be enabled\n");
else if (idx == 4)
BIO_printf(bio_err, "Success: connection accepted before data, client TFO is disabled\n");
else
BIO_printf(bio_err, "Warning: connection accepted before data, TFO may not be enabled\n");
sbio = BIO_pop(abio);
goto success;
}
/* SEND DATA: this should establish the actual TFO connection */
if (!TEST_true(BIO_write_ex(cbio, SOCKET_DATA, SOCKET_DATA_LEN, &bytes))) {
sockerr = get_last_socket_error();
goto err;
}
/* macOS needs some time for this to happen, so put in a select */
if (!TEST_int_ge(BIO_wait(abio, time(NULL) + 2, 0), 0)) {
sockerr = get_last_socket_error();
BIO_printf(bio_err, "Error: socket wait failed\n");
goto err;
}
/* FINAL ACCEPT: if TFO is enabled, socket should be accepted at *this* point */
if (BIO_do_accept(abio) <= 0) {
sockerr = get_last_socket_error();
BIO_printf(bio_err, "Error: socket not accepted\n");
goto err;
}
BIO_printf(bio_err, "Success: Server accepted socket after write\n");
if (!TEST_ptr(sbio = BIO_pop(abio))
|| !TEST_true(BIO_read_ex(sbio, read_buffer, sizeof(read_buffer), &bytes))
|| !TEST_size_t_eq(bytes, SOCKET_DATA_LEN)
|| !TEST_strn_eq(read_buffer, SOCKET_DATA, SOCKET_DATA_LEN)) {
sockerr = get_last_socket_error();
goto err;
}
success:
sockerr = 0;
ret = 1;
err:
if (sockerr != 0) {
const char *errstr = strerror(sockerr);
if (errstr != NULL)
BIO_printf(bio_err, "last errno: %d=%s\n", sockerr, errstr);
}
BIO_free(cbio);
BIO_free(abio);
BIO_free(sbio);
return ret;
}
static int test_fd_tfo(int idx)
{
struct sockaddr_storage sstorage;
socklen_t slen;
struct addrinfo *ai = NULL;
struct addrinfo hints;
int ret = 0;
int cfd = -1; /* client socket */
int afd = -1; /* accept socket */
int sfd = -1; /* server accepted socket */
BIO_ADDR *baddr = NULL;
char read_buffer[20];
int bytes_read;
int server_flags = BIO_SOCK_NONBLOCK;
int client_flags = BIO_SOCK_NONBLOCK;
int sockerr = 0;
unsigned short port;
void *addr;
size_t addrlen;
switch (idx) {
default:
case 0:
break;
case 1:
case 2:
server_flags |= BIO_SOCK_TFO;
client_flags |= BIO_SOCK_TFO;
break;
case 3:
client_flags |= BIO_SOCK_TFO;
break;
case 4:
server_flags |= BIO_SOCK_TFO;
break;
}
/* ADDRESS SETUP */
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if (!TEST_int_eq(getaddrinfo(NULL, "0", &hints, &ai), 0))
goto err;
switch (ai->ai_family) {
case AF_INET:
port = ((struct sockaddr_in *)ai->ai_addr)->sin_port;
addr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr;
addrlen = sizeof(((struct sockaddr_in *)ai->ai_addr)->sin_addr);
BIO_printf(bio_err, "Using IPv4\n");
break;
case AF_INET6:
port = ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port;
addr = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr;
addrlen = sizeof(((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr);
BIO_printf(bio_err, "Using IPv6\n");
break;
default:
BIO_printf(bio_err, "Unknown address family %d\n", ai->ai_family);
goto err;
}
if (!TEST_ptr(baddr = BIO_ADDR_new())
|| !TEST_true(BIO_ADDR_rawmake(baddr, ai->ai_family, addr, addrlen, port)))
goto err;
/* ACCEPT SOCKET */
if (!TEST_int_ge(afd = BIO_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol, 0), 0)
|| !TEST_true(BIO_listen(afd, baddr, server_flags)))
goto err;
/* UPDATE ADDRESS WITH PORT */
slen = sizeof(sstorage);
if (!TEST_int_ge(getsockname(afd, (struct sockaddr *)&sstorage, &slen), 0))
goto err;
switch (sstorage.ss_family) {
case AF_INET:
port = ((struct sockaddr_in *)&sstorage)->sin_port;
addr = &((struct sockaddr_in *)&sstorage)->sin_addr;
addrlen = sizeof(((struct sockaddr_in *)&sstorage)->sin_addr);
break;
case AF_INET6:
port = ((struct sockaddr_in6 *)&sstorage)->sin6_port;
addr = &((struct sockaddr_in6 *)&sstorage)->sin6_addr;
addrlen = sizeof(((struct sockaddr_in6 *)&sstorage)->sin6_addr);
break;
default:
goto err;
}
if(!TEST_true(BIO_ADDR_rawmake(baddr, sstorage.ss_family, addr, addrlen, port)))
goto err;
/* CLIENT SOCKET */
if (!TEST_int_ge(cfd = BIO_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol, 0), 0))
goto err;
/* FIRST ACCEPT: no connection should be established */
sfd = BIO_accept_ex(afd, NULL, 0);
if (sfd == -1) {
sockerr = get_last_socket_error();
/* Note: Windows would hit WSAEWOULDBLOCK */
if (sockerr != EAGAIN) {
BIO_printf(bio_err, "Error: failed without EAGAIN\n");
goto err;
}
} else {
BIO_printf(bio_err, "Error: accepted unknown connection\n");
goto err;
}
/* CONNECT ATTEMPT: different behavior based on TFO support */
if (!BIO_connect(cfd, baddr, client_flags)) {
sockerr = get_last_socket_error();
if (sockerr == EOPNOTSUPP) {
BIO_printf(bio_err, "Skip: TFO not enabled/supported for client\n");
goto success;
} else {
/* Note: Windows would hit WSAEWOULDBLOCK */
if (sockerr != EINPROGRESS) {
BIO_printf(bio_err, "Error: failed without EINPROGRESS\n");
goto err;
}
}
}
/* macOS needs some time for this to happen, so put in a select */
if (!TEST_int_ge(BIO_socket_wait(afd, 1, time(NULL) + 2), 0)) {
sockerr = get_last_socket_error();
BIO_printf(bio_err, "Error: socket wait failed\n");
goto err;
}
/* SECOND ACCEPT: if TFO is supported, this will still fail until data is sent */
sfd = BIO_accept_ex(afd, NULL, 0);
if (sfd == -1) {
sockerr = get_last_socket_error();
/* Note: Windows would hit WSAEWOULDBLOCK */
if (sockerr != EAGAIN) {
BIO_printf(bio_err, "Error: failed without EAGAIN\n");
goto err;
}
} else {
if (idx == 0)
BIO_printf(bio_err, "Success: non-TFO connection accepted without data\n");
else if (idx == 1)
BIO_printf(bio_err, "Ignore: connection accepted before data, possibly no TFO cookie, or TFO may not be enabled\n");
else if (idx == 4)
BIO_printf(bio_err, "Success: connection accepted before data, client TFO is disabled\n");
else
BIO_printf(bio_err, "Warning: connection accepted before data, TFO may not be enabled\n");
goto success;
}
/* SEND DATA: this should establish the actual TFO connection */
#ifdef OSSL_TFO_SENDTO
if (!TEST_int_ge(sendto(cfd, SOCKET_DATA, SOCKET_DATA_LEN, OSSL_TFO_SENDTO,
(struct sockaddr *)&sstorage, slen), 0)) {
sockerr = get_last_socket_error();
goto err;
}
#else
if (!TEST_int_ge(writesocket(cfd, SOCKET_DATA, SOCKET_DATA_LEN), 0)) {
sockerr = get_last_socket_error();
goto err;
}
#endif
/* macOS needs some time for this to happen, so put in a select */
if (!TEST_int_ge(BIO_socket_wait(afd, 1, time(NULL) + 2), 0)) {
sockerr = get_last_socket_error();
BIO_printf(bio_err, "Error: socket wait failed\n");
goto err;
}
/* FINAL ACCEPT: if TFO is enabled, socket should be accepted at *this* point */
sfd = BIO_accept_ex(afd, NULL, 0);
if (sfd == -1) {
sockerr = get_last_socket_error();
BIO_printf(bio_err, "Error: socket not accepted\n");
goto err;
}
BIO_printf(bio_err, "Success: Server accepted socket after write\n");
bytes_read = readsocket(sfd, read_buffer, sizeof(read_buffer));
if (!TEST_int_eq(bytes_read, SOCKET_DATA_LEN)
|| !TEST_strn_eq(read_buffer, SOCKET_DATA, SOCKET_DATA_LEN)) {
sockerr = get_last_socket_error();
goto err;
}
success:
sockerr = 0;
ret = 1;
err:
if (sockerr != 0) {
const char *errstr = strerror(sockerr);
if (errstr != NULL)
BIO_printf(bio_err, "last errno: %d=%s\n", sockerr, errstr);
}
if (ai != NULL)
freeaddrinfo(ai);
BIO_ADDR_free(baddr);
BIO_closesocket(cfd);
BIO_closesocket(sfd);
BIO_closesocket(afd);
return ret;
}
#endif
int setup_tests(void)
{
#if !defined(OPENSSL_NO_TFO) && defined(GOOD_OS)
ADD_ALL_TESTS(test_bio_tfo, 5);
ADD_ALL_TESTS(test_fd_tfo, 5);
#endif
return 1;
}
|
./openssl/test/test_test.c | /*
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2017, Oracle and/or its affiliates. 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 <string.h>
#include <openssl/opensslconf.h>
#include <openssl/err.h>
#include <openssl/crypto.h>
#include <openssl/bn.h>
#include "internal/nelem.h"
#include "testutil.h"
#define TEST(expected, test) test_case((expected), #test, (test))
static int test_case(int expected, const char *test, int result)
{
if (result != expected) {
fprintf(stderr, "# FATAL: %s != %d\n", test, expected);
return 0;
}
return 1;
}
static int test_int(void)
{
if (!TEST(1, TEST_int_eq(1, 1))
|| !TEST(0, TEST_int_eq(1, -1))
|| !TEST(1, TEST_int_ne(1, 2))
|| !TEST(0, TEST_int_ne(3, 3))
|| !TEST(1, TEST_int_lt(4, 9))
|| !TEST(0, TEST_int_lt(9, 4))
|| !TEST(1, TEST_int_le(4, 9))
|| !TEST(1, TEST_int_le(5, 5))
|| !TEST(0, TEST_int_le(9, 4))
|| !TEST(1, TEST_int_gt(8, 5))
|| !TEST(0, TEST_int_gt(5, 8))
|| !TEST(1, TEST_int_ge(8, 5))
|| !TEST(1, TEST_int_ge(6, 6))
|| !TEST(0, TEST_int_ge(5, 8)))
goto err;
return 1;
err:
return 0;
}
static int test_uint(void)
{
if (!TEST(1, TEST_uint_eq(3u, 3u))
|| !TEST(0, TEST_uint_eq(3u, 5u))
|| !TEST(1, TEST_uint_ne(4u, 2u))
|| !TEST(0, TEST_uint_ne(6u, 6u))
|| !TEST(1, TEST_uint_lt(5u, 9u))
|| !TEST(0, TEST_uint_lt(9u, 5u))
|| !TEST(1, TEST_uint_le(5u, 9u))
|| !TEST(1, TEST_uint_le(7u, 7u))
|| !TEST(0, TEST_uint_le(9u, 5u))
|| !TEST(1, TEST_uint_gt(11u, 1u))
|| !TEST(0, TEST_uint_gt(1u, 11u))
|| !TEST(1, TEST_uint_ge(11u, 1u))
|| !TEST(1, TEST_uint_ge(6u, 6u))
|| !TEST(0, TEST_uint_ge(1u, 11u)))
goto err;
return 1;
err:
return 0;
}
static int test_char(void)
{
if (!TEST(1, TEST_char_eq('a', 'a'))
|| !TEST(0, TEST_char_eq('a', 'A'))
|| !TEST(1, TEST_char_ne('a', 'c'))
|| !TEST(0, TEST_char_ne('e', 'e'))
|| !TEST(1, TEST_char_lt('i', 'x'))
|| !TEST(0, TEST_char_lt('x', 'i'))
|| !TEST(1, TEST_char_le('i', 'x'))
|| !TEST(1, TEST_char_le('n', 'n'))
|| !TEST(0, TEST_char_le('x', 'i'))
|| !TEST(1, TEST_char_gt('w', 'n'))
|| !TEST(0, TEST_char_gt('n', 'w'))
|| !TEST(1, TEST_char_ge('w', 'n'))
|| !TEST(1, TEST_char_ge('p', 'p'))
|| !TEST(0, TEST_char_ge('n', 'w')))
goto err;
return 1;
err:
return 0;
}
static int test_uchar(void)
{
if (!TEST(1, TEST_uchar_eq(49, 49))
|| !TEST(0, TEST_uchar_eq(49, 60))
|| !TEST(1, TEST_uchar_ne(50, 2))
|| !TEST(0, TEST_uchar_ne(66, 66))
|| !TEST(1, TEST_uchar_lt(60, 80))
|| !TEST(0, TEST_uchar_lt(80, 60))
|| !TEST(1, TEST_uchar_le(60, 80))
|| !TEST(1, TEST_uchar_le(78, 78))
|| !TEST(0, TEST_uchar_le(80, 60))
|| !TEST(1, TEST_uchar_gt(88, 37))
|| !TEST(0, TEST_uchar_gt(37, 88))
|| !TEST(1, TEST_uchar_ge(88, 37))
|| !TEST(1, TEST_uchar_ge(66, 66))
|| !TEST(0, TEST_uchar_ge(37, 88)))
goto err;
return 1;
err:
return 0;
}
static int test_long(void)
{
if (!TEST(1, TEST_long_eq(123l, 123l))
|| !TEST(0, TEST_long_eq(123l, -123l))
|| !TEST(1, TEST_long_ne(123l, 500l))
|| !TEST(0, TEST_long_ne(1000l, 1000l))
|| !TEST(1, TEST_long_lt(-8923l, 102934563l))
|| !TEST(0, TEST_long_lt(102934563l, -8923l))
|| !TEST(1, TEST_long_le(-8923l, 102934563l))
|| !TEST(1, TEST_long_le(12345l, 12345l))
|| !TEST(0, TEST_long_le(102934563l, -8923l))
|| !TEST(1, TEST_long_gt(84325677l, 12345l))
|| !TEST(0, TEST_long_gt(12345l, 84325677l))
|| !TEST(1, TEST_long_ge(84325677l, 12345l))
|| !TEST(1, TEST_long_ge(465869l, 465869l))
|| !TEST(0, TEST_long_ge(12345l, 84325677l)))
goto err;
return 1;
err:
return 0;
}
static int test_ulong(void)
{
if (!TEST(1, TEST_ulong_eq(919ul, 919ul))
|| !TEST(0, TEST_ulong_eq(919ul, 10234ul))
|| !TEST(1, TEST_ulong_ne(8190ul, 66ul))
|| !TEST(0, TEST_ulong_ne(10555ul, 10555ul))
|| !TEST(1, TEST_ulong_lt(10234ul, 1000000ul))
|| !TEST(0, TEST_ulong_lt(1000000ul, 10234ul))
|| !TEST(1, TEST_ulong_le(10234ul, 1000000ul))
|| !TEST(1, TEST_ulong_le(100000ul, 100000ul))
|| !TEST(0, TEST_ulong_le(1000000ul, 10234ul))
|| !TEST(1, TEST_ulong_gt(100000000ul, 22ul))
|| !TEST(0, TEST_ulong_gt(22ul, 100000000ul))
|| !TEST(1, TEST_ulong_ge(100000000ul, 22ul))
|| !TEST(1, TEST_ulong_ge(10555ul, 10555ul))
|| !TEST(0, TEST_ulong_ge(22ul, 100000000ul)))
goto err;
return 1;
err:
return 0;
}
static int test_size_t(void)
{
if (!TEST(1, TEST_size_t_eq((size_t)10, (size_t)10))
|| !TEST(0, TEST_size_t_eq((size_t)10, (size_t)12))
|| !TEST(1, TEST_size_t_ne((size_t)10, (size_t)12))
|| !TEST(0, TEST_size_t_ne((size_t)24, (size_t)24))
|| !TEST(1, TEST_size_t_lt((size_t)30, (size_t)88))
|| !TEST(0, TEST_size_t_lt((size_t)88, (size_t)30))
|| !TEST(1, TEST_size_t_le((size_t)30, (size_t)88))
|| !TEST(1, TEST_size_t_le((size_t)33, (size_t)33))
|| !TEST(0, TEST_size_t_le((size_t)88, (size_t)30))
|| !TEST(1, TEST_size_t_gt((size_t)52, (size_t)33))
|| !TEST(0, TEST_size_t_gt((size_t)33, (size_t)52))
|| !TEST(1, TEST_size_t_ge((size_t)52, (size_t)33))
|| !TEST(1, TEST_size_t_ge((size_t)38, (size_t)38))
|| !TEST(0, TEST_size_t_ge((size_t)33, (size_t)52)))
goto err;
return 1;
err:
return 0;
}
static int test_time_t(void)
{
if (!TEST(1, TEST_time_t_eq((time_t)10, (time_t)10))
|| !TEST(0, TEST_time_t_eq((time_t)10, (time_t)12))
|| !TEST(1, TEST_time_t_ne((time_t)10, (time_t)12))
|| !TEST(0, TEST_time_t_ne((time_t)24, (time_t)24))
|| !TEST(1, TEST_time_t_lt((time_t)30, (time_t)88))
|| !TEST(0, TEST_time_t_lt((time_t)88, (time_t)30))
|| !TEST(1, TEST_time_t_le((time_t)30, (time_t)88))
|| !TEST(1, TEST_time_t_le((time_t)33, (time_t)33))
|| !TEST(0, TEST_time_t_le((time_t)88, (time_t)30))
|| !TEST(1, TEST_time_t_gt((time_t)52, (time_t)33))
|| !TEST(0, TEST_time_t_gt((time_t)33, (time_t)52))
|| !TEST(1, TEST_time_t_ge((time_t)52, (time_t)33))
|| !TEST(1, TEST_time_t_ge((time_t)38, (time_t)38))
|| !TEST(0, TEST_time_t_ge((time_t)33, (time_t)52)))
goto err;
return 1;
err:
return 0;
}
static int test_pointer(void)
{
int x = 0;
char y = 1;
if (!TEST(1, TEST_ptr(&y))
|| !TEST(0, TEST_ptr(NULL))
|| !TEST(0, TEST_ptr_null(&y))
|| !TEST(1, TEST_ptr_null(NULL))
|| !TEST(1, TEST_ptr_eq(NULL, NULL))
|| !TEST(0, TEST_ptr_eq(NULL, &y))
|| !TEST(0, TEST_ptr_eq(&y, NULL))
|| !TEST(0, TEST_ptr_eq(&y, &x))
|| !TEST(1, TEST_ptr_eq(&x, &x))
|| !TEST(0, TEST_ptr_ne(NULL, NULL))
|| !TEST(1, TEST_ptr_ne(NULL, &y))
|| !TEST(1, TEST_ptr_ne(&y, NULL))
|| !TEST(1, TEST_ptr_ne(&y, &x))
|| !TEST(0, TEST_ptr_ne(&x, &x)))
goto err;
return 1;
err:
return 0;
}
static int test_bool(void)
{
if (!TEST(0, TEST_true(0))
|| !TEST(1, TEST_true(1))
|| !TEST(1, TEST_false(0))
|| !TEST(0, TEST_false(1)))
goto err;
return 1;
err:
return 0;
}
static int test_string(void)
{
static char buf[] = "abc";
if (!TEST(1, TEST_str_eq(NULL, NULL))
|| !TEST(1, TEST_str_eq("abc", buf))
|| !TEST(0, TEST_str_eq("abc", NULL))
|| !TEST(0, TEST_str_eq("abc", ""))
|| !TEST(0, TEST_str_eq(NULL, buf))
|| !TEST(0, TEST_str_ne(NULL, NULL))
|| !TEST(0, TEST_str_eq("", NULL))
|| !TEST(0, TEST_str_eq(NULL, ""))
|| !TEST(0, TEST_str_ne("", ""))
|| !TEST(0, TEST_str_eq("\1\2\3\4\5", "\1x\3\6\5"))
|| !TEST(0, TEST_str_ne("abc", buf))
|| !TEST(1, TEST_str_ne("abc", NULL))
|| !TEST(1, TEST_str_ne(NULL, buf))
|| !TEST(0, TEST_str_eq("abcdef", "abcdefghijk")))
goto err;
return 1;
err:
return 0;
}
static int test_memory(void)
{
static char buf[] = "xyz";
if (!TEST(1, TEST_mem_eq(NULL, 0, NULL, 0))
|| !TEST(1, TEST_mem_eq(NULL, 1, NULL, 2))
|| !TEST(0, TEST_mem_eq(NULL, 0, "xyz", 3))
|| !TEST(0, TEST_mem_eq(NULL, 7, "abc", 3))
|| !TEST(0, TEST_mem_ne(NULL, 0, NULL, 0))
|| !TEST(0, TEST_mem_eq(NULL, 0, "", 0))
|| !TEST(0, TEST_mem_eq("", 0, NULL, 0))
|| !TEST(0, TEST_mem_ne("", 0, "", 0))
|| !TEST(0, TEST_mem_eq("xyz", 3, NULL, 0))
|| !TEST(0, TEST_mem_eq("xyz", 3, buf, sizeof(buf)))
|| !TEST(1, TEST_mem_eq("xyz", 4, buf, sizeof(buf))))
goto err;
return 1;
err:
return 0;
}
static int test_memory_overflow(void)
{
/* Verify that the memory printing overflows without walking the stack */
const char *p = "1234567890123456789012345678901234567890123456789012";
const char *q = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
return TEST(0, TEST_mem_eq(p, strlen(p), q, strlen(q)));
}
static int test_bignum(void)
{
BIGNUM *a = NULL, *b = NULL, *c = NULL;
int r = 0;
if (!TEST(1, TEST_int_eq(BN_dec2bn(&a, "0"), 1))
|| !TEST(1, TEST_BN_eq_word(a, 0))
|| !TEST(0, TEST_BN_eq_word(a, 30))
|| !TEST(1, TEST_BN_abs_eq_word(a, 0))
|| !TEST(0, TEST_BN_eq_one(a))
|| !TEST(1, TEST_BN_eq_zero(a))
|| !TEST(0, TEST_BN_ne_zero(a))
|| !TEST(1, TEST_BN_le_zero(a))
|| !TEST(0, TEST_BN_lt_zero(a))
|| !TEST(1, TEST_BN_ge_zero(a))
|| !TEST(0, TEST_BN_gt_zero(a))
|| !TEST(1, TEST_BN_even(a))
|| !TEST(0, TEST_BN_odd(a))
|| !TEST(1, TEST_BN_eq(b, c))
|| !TEST(0, TEST_BN_eq(a, b))
|| !TEST(0, TEST_BN_ne(NULL, c))
|| !TEST(1, TEST_int_eq(BN_dec2bn(&b, "1"), 1))
|| !TEST(1, TEST_BN_eq_word(b, 1))
|| !TEST(1, TEST_BN_eq_one(b))
|| !TEST(0, TEST_BN_abs_eq_word(b, 0))
|| !TEST(1, TEST_BN_abs_eq_word(b, 1))
|| !TEST(0, TEST_BN_eq_zero(b))
|| !TEST(1, TEST_BN_ne_zero(b))
|| !TEST(0, TEST_BN_le_zero(b))
|| !TEST(0, TEST_BN_lt_zero(b))
|| !TEST(1, TEST_BN_ge_zero(b))
|| !TEST(1, TEST_BN_gt_zero(b))
|| !TEST(0, TEST_BN_even(b))
|| !TEST(1, TEST_BN_odd(b))
|| !TEST(1, TEST_int_eq(BN_dec2bn(&c, "-334739439"), 10))
|| !TEST(0, TEST_BN_eq_word(c, 334739439))
|| !TEST(1, TEST_BN_abs_eq_word(c, 334739439))
|| !TEST(0, TEST_BN_eq_zero(c))
|| !TEST(1, TEST_BN_ne_zero(c))
|| !TEST(1, TEST_BN_le_zero(c))
|| !TEST(1, TEST_BN_lt_zero(c))
|| !TEST(0, TEST_BN_ge_zero(c))
|| !TEST(0, TEST_BN_gt_zero(c))
|| !TEST(0, TEST_BN_even(c))
|| !TEST(1, TEST_BN_odd(c))
|| !TEST(1, TEST_BN_eq(a, a))
|| !TEST(0, TEST_BN_ne(a, a))
|| !TEST(0, TEST_BN_eq(a, b))
|| !TEST(1, TEST_BN_ne(a, b))
|| !TEST(0, TEST_BN_lt(a, c))
|| !TEST(1, TEST_BN_lt(c, b))
|| !TEST(0, TEST_BN_lt(b, c))
|| !TEST(0, TEST_BN_le(a, c))
|| !TEST(1, TEST_BN_le(c, b))
|| !TEST(0, TEST_BN_le(b, c))
|| !TEST(1, TEST_BN_gt(a, c))
|| !TEST(0, TEST_BN_gt(c, b))
|| !TEST(1, TEST_BN_gt(b, c))
|| !TEST(1, TEST_BN_ge(a, c))
|| !TEST(0, TEST_BN_ge(c, b))
|| !TEST(1, TEST_BN_ge(b, c)))
goto err;
r = 1;
err:
BN_free(a);
BN_free(b);
BN_free(c);
return r;
}
static int test_long_output(void)
{
const char *p = "1234567890123456789012345678901234567890123456789012";
const char *q = "1234567890klmnopqrs01234567890EFGHIJKLM0123456789XYZ";
const char *r = "1234567890123456789012345678901234567890123456789012"
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY+"
"12345678901234567890123ABC78901234567890123456789012";
const char *s = "1234567890123456789012345678901234567890123456789012"
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY-"
"1234567890123456789012345678901234567890123456789012"
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
return TEST(0, TEST_str_eq(p, q))
& TEST(0, TEST_str_eq(q, r))
& TEST(0, TEST_str_eq(r, s))
& TEST(0, TEST_mem_eq(r, strlen(r), s, strlen(s)));
}
static int test_long_bignum(void)
{
int r;
BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL;
const char as[] = "1234567890123456789012345678901234567890123456789012"
"1234567890123456789012345678901234567890123456789012"
"1234567890123456789012345678901234567890123456789012"
"1234567890123456789012345678901234567890123456789012"
"1234567890123456789012345678901234567890123456789012"
"1234567890123456789012345678901234567890123456789012"
"FFFFFF";
const char bs[] = "1234567890123456789012345678901234567890123456789012"
"1234567890123456789012345678901234567890123456789013"
"987657";
const char cs[] = "-" /* 64 characters plus sign */
"123456789012345678901234567890"
"123456789012345678901234567890"
"ABCD";
const char ds[] = "-" /* 63 characters plus sign */
"23456789A123456789B123456789C"
"123456789D123456789E123456789F"
"ABCD";
r = TEST_true(BN_hex2bn(&a, as))
&& TEST_true(BN_hex2bn(&b, bs))
&& TEST_true(BN_hex2bn(&c, cs))
&& TEST_true(BN_hex2bn(&d, ds))
&& (TEST(0, TEST_BN_eq(a, b))
& TEST(0, TEST_BN_eq(b, a))
& TEST(0, TEST_BN_eq(b, NULL))
& TEST(0, TEST_BN_eq(NULL, a))
& TEST(1, TEST_BN_ne(a, NULL))
& TEST(0, TEST_BN_eq(c, d)));
BN_free(a);
BN_free(b);
BN_free(c);
BN_free(d);
return r;
}
static int test_messages(void)
{
TEST_info("This is an %s message.", "info");
TEST_error("This is an %s message.", "error");
return 1;
}
static int test_single_eval(void)
{
int i = 4;
long l = -9000;
char c = 'd';
unsigned char uc = 22;
unsigned long ul = 500;
size_t st = 1234;
char buf[4] = { 0 }, *p = buf;
/* int */
return TEST_int_eq(i++, 4)
&& TEST_int_eq(i, 5)
&& TEST_int_gt(++i, 5)
&& TEST_int_le(5, i++)
&& TEST_int_ne(--i, 5)
&& TEST_int_eq(12, i *= 2)
/* Long */
&& TEST_long_eq(l--, -9000L)
&& TEST_long_eq(++l, -9000L)
&& TEST_long_ne(-9000L, l /= 2)
&& TEST_long_lt(--l, -4500L)
/* char */
&& TEST_char_eq(++c, 'e')
&& TEST_char_eq('e', c--)
&& TEST_char_ne('d', --c)
&& TEST_char_le('b', --c)
&& TEST_char_lt(c++, 'c')
/* unsigned char */
&& TEST_uchar_eq(22, uc++)
&& TEST_uchar_eq(uc /= 2, 11)
&& TEST_ulong_eq(ul ^= 1, 501)
&& TEST_ulong_eq(502, ul ^= 3)
&& TEST_ulong_eq(ul = ul * 3 - 6, 1500)
/* size_t */
&& TEST_size_t_eq((--i, st++), 1234)
&& TEST_size_t_eq(st, 1235)
&& TEST_int_eq(11, i)
/* pointers */
&& TEST_ptr_eq(p++, buf)
&& TEST_ptr_eq(buf + 2, ++p)
&& TEST_ptr_eq(buf, p -= 2)
&& TEST_ptr(++p)
&& TEST_ptr_eq(p, buf + 1)
&& TEST_ptr_null(p = NULL)
/* strings */
&& TEST_str_eq(p = &("123456"[1]), "23456")
&& TEST_str_eq("3456", ++p)
&& TEST_str_ne(p++, "456")
/* memory */
&& TEST_mem_eq(--p, sizeof("3456"), "3456", sizeof("3456"))
&& TEST_mem_ne(p++, sizeof("456"), "456", sizeof("456"))
&& TEST_mem_eq(p--, sizeof("456"), "456", sizeof("456"));
}
static int test_output(void)
{
const char s[] = "1234567890123456789012345678901234567890123456789012"
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
test_output_string("test", s, sizeof(s) - 1);
test_output_memory("test", (const unsigned char *)s, sizeof(s));
return 1;
}
static const char *bn_output_tests[] = {
NULL,
"0",
"-12345678",
"1234567890123456789012345678901234567890123456789012"
"1234567890123456789012345678901234567890123456789013"
"987657"
};
static int test_bn_output(int n)
{
BIGNUM *b = NULL;
if (bn_output_tests[n] != NULL
&& !TEST_true(BN_hex2bn(&b, bn_output_tests[n])))
return 0;
test_output_bignum(bn_output_tests[n], b);
BN_free(b);
return 1;
}
static int test_skip_one(void)
{
return TEST_skip("skip test");
}
static int test_skip_many(int n)
{
return TEST_skip("skip tests: %d", n);
}
static int test_skip_null(void)
{
/*
* This is not a recommended way of skipping a test, a reason or
* description should be included.
*/
return TEST_skip(NULL);
}
int setup_tests(void)
{
ADD_TEST(test_int);
ADD_TEST(test_uint);
ADD_TEST(test_char);
ADD_TEST(test_uchar);
ADD_TEST(test_long);
ADD_TEST(test_ulong);
ADD_TEST(test_size_t);
ADD_TEST(test_time_t);
ADD_TEST(test_pointer);
ADD_TEST(test_bool);
ADD_TEST(test_string);
ADD_TEST(test_memory);
ADD_TEST(test_memory_overflow);
ADD_TEST(test_bignum);
ADD_TEST(test_long_bignum);
ADD_TEST(test_long_output);
ADD_TEST(test_messages);
ADD_TEST(test_single_eval);
ADD_TEST(test_output);
ADD_ALL_TESTS(test_bn_output, OSSL_NELEM(bn_output_tests));
ADD_TEST(test_skip_one);
ADD_TEST(test_skip_null);
ADD_ALL_TESTS(test_skip_many, 3);
return 1;
}
|
./openssl/test/provider_test.c | /*
* Copyright 2019-2023 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 <stddef.h>
#include <openssl/provider.h>
#include <openssl/param_build.h>
#include "testutil.h"
extern OSSL_provider_init_fn PROVIDER_INIT_FUNCTION_NAME;
static char buf[256];
static OSSL_PARAM greeting_request[] = {
{ "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf) },
{ NULL, 0, NULL, 0, 0 }
};
static unsigned int digestsuccess = 0;
static OSSL_PARAM digest_check[] = {
{ "digest-check", OSSL_PARAM_UNSIGNED_INTEGER, &digestsuccess,
sizeof(digestsuccess) },
{ NULL, 0, NULL, 0, 0 }
};
static unsigned int stopsuccess = 0;
static OSSL_PARAM stop_property_mirror[] = {
{ "stop-property-mirror", OSSL_PARAM_UNSIGNED_INTEGER, &stopsuccess,
sizeof(stopsuccess) },
{ NULL, 0, NULL, 0, 0 }
};
static int test_provider(OSSL_LIB_CTX **libctx, const char *name,
OSSL_PROVIDER *legacy)
{
OSSL_PROVIDER *prov = NULL;
const char *greeting = NULL;
char expected_greeting[256];
int ok = 0;
long err;
int dolegacycheck = (legacy != NULL);
OSSL_PROVIDER *deflt = NULL, *base = NULL;
BIO_snprintf(expected_greeting, sizeof(expected_greeting),
"Hello OpenSSL %.20s, greetings from %s!",
OPENSSL_VERSION_STR, name);
/*
* We set properties that we know the providers we are using don't have.
* This should mean that the p_test provider will fail any fetches - which
* is something we test inside the provider.
*/
EVP_set_default_properties(*libctx, "fips=yes");
/*
* Check that it is possible to have a built-in provider mirrored in
* a child lib ctx.
*/
if (!TEST_ptr(base = OSSL_PROVIDER_load(*libctx, "base")))
goto err;
if (!TEST_ptr(prov = OSSL_PROVIDER_load(*libctx, name)))
goto err;
/*
* Once the provider is loaded we clear the default properties and fetches
* should start working again.
*/
EVP_set_default_properties(*libctx, "");
if (dolegacycheck) {
if (!TEST_true(OSSL_PROVIDER_get_params(prov, digest_check))
|| !TEST_true(digestsuccess))
goto err;
/*
* Check that a provider can prevent property mirroring if it sets its
* own properties explicitly
*/
if (!TEST_true(OSSL_PROVIDER_get_params(prov, stop_property_mirror))
|| !TEST_true(stopsuccess))
goto err;
EVP_set_default_properties(*libctx, "fips=yes");
if (!TEST_true(OSSL_PROVIDER_get_params(prov, digest_check))
|| !TEST_true(digestsuccess))
goto err;
EVP_set_default_properties(*libctx, "");
}
if (!TEST_true(OSSL_PROVIDER_get_params(prov, greeting_request))
|| !TEST_ptr(greeting = greeting_request[0].data)
|| !TEST_size_t_gt(greeting_request[0].data_size, 0)
|| !TEST_str_eq(greeting, expected_greeting))
goto err;
/* Make sure we got the error we were expecting */
err = ERR_peek_last_error();
if (!TEST_int_gt(err, 0)
|| !TEST_int_eq(ERR_GET_REASON(err), 1))
goto err;
OSSL_PROVIDER_unload(legacy);
legacy = NULL;
if (dolegacycheck) {
/* Legacy provider should also be unloaded from child libctx */
if (!TEST_true(OSSL_PROVIDER_get_params(prov, digest_check))
|| !TEST_false(digestsuccess))
goto err;
/*
* Loading the legacy provider again should make it available again in
* the child libctx. Loading and unloading the default provider should
* have no impact on the child because the child loads it explicitly
* before this point.
*/
legacy = OSSL_PROVIDER_load(*libctx, "legacy");
deflt = OSSL_PROVIDER_load(*libctx, "default");
if (!TEST_ptr(deflt)
|| !TEST_true(OSSL_PROVIDER_available(*libctx, "default")))
goto err;
OSSL_PROVIDER_unload(deflt);
deflt = NULL;
if (!TEST_ptr(legacy)
|| !TEST_false(OSSL_PROVIDER_available(*libctx, "default"))
|| !TEST_true(OSSL_PROVIDER_get_params(prov, digest_check))
|| !TEST_true(digestsuccess))
goto err;
OSSL_PROVIDER_unload(legacy);
legacy = NULL;
}
if (!TEST_true(OSSL_PROVIDER_unload(base)))
goto err;
base = NULL;
if (!TEST_true(OSSL_PROVIDER_unload(prov)))
goto err;
prov = NULL;
/*
* We must free the libctx to force the provider to really be unloaded from
* memory
*/
OSSL_LIB_CTX_free(*libctx);
*libctx = NULL;
/* We print out all the data to make sure it can still be accessed */
ERR_print_errors_fp(stderr);
ok = 1;
err:
OSSL_PROVIDER_unload(base);
OSSL_PROVIDER_unload(deflt);
OSSL_PROVIDER_unload(legacy);
legacy = NULL;
OSSL_PROVIDER_unload(prov);
OSSL_LIB_CTX_free(*libctx);
*libctx = NULL;
return ok;
}
#ifndef NO_PROVIDER_MODULE
static int test_provider_ex(OSSL_LIB_CTX **libctx, const char *name)
{
OSSL_PROVIDER *prov = NULL;
const char *greeting = NULL;
int ok = 0;
long err;
const char custom_buf[] = "Custom greeting";
OSSL_PARAM_BLD *bld = NULL;
OSSL_PARAM *params = NULL;
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|| !TEST_true(OSSL_PARAM_BLD_push_utf8_string(bld, "greeting", custom_buf,
strlen(custom_buf)))
|| !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld))) {
goto err;
}
if (!TEST_ptr(prov = OSSL_PROVIDER_load_ex(*libctx, name, params)))
goto err;
if (!TEST_true(OSSL_PROVIDER_get_params(prov, greeting_request))
|| !TEST_ptr(greeting = greeting_request[0].data)
|| !TEST_size_t_gt(greeting_request[0].data_size, 0)
|| !TEST_str_eq(greeting, custom_buf))
goto err;
/* Make sure we got the error we were expecting */
err = ERR_peek_last_error();
if (!TEST_int_gt(err, 0)
|| !TEST_int_eq(ERR_GET_REASON(err), 1))
goto err;
if (!TEST_true(OSSL_PROVIDER_unload(prov)))
goto err;
prov = NULL;
/*
* We must free the libctx to force the provider to really be unloaded from
* memory
*/
OSSL_LIB_CTX_free(*libctx);
*libctx = NULL;
/* We print out all the data to make sure it can still be accessed */
ERR_print_errors_fp(stderr);
ok = 1;
err:
OSSL_PARAM_BLD_free(bld);
OSSL_PARAM_free(params);
OSSL_PROVIDER_unload(prov);
OSSL_LIB_CTX_free(*libctx);
*libctx = NULL;
return ok;
}
#endif
static int test_builtin_provider(void)
{
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
const char *name = "p_test_builtin";
int ok;
ok =
TEST_ptr(libctx)
&& TEST_true(OSSL_PROVIDER_add_builtin(libctx, name,
PROVIDER_INIT_FUNCTION_NAME))
&& test_provider(&libctx, name, NULL);
OSSL_LIB_CTX_free(libctx);
return ok;
}
/* Test relies on fetching the MD4 digest from the legacy provider */
#ifndef OPENSSL_NO_MD4
static int test_builtin_provider_with_child(void)
{
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
const char *name = "p_test";
OSSL_PROVIDER *legacy;
if (!TEST_ptr(libctx))
return 0;
legacy = OSSL_PROVIDER_load(libctx, "legacy");
if (legacy == NULL) {
/*
* In this case we assume we've been built with "no-legacy" and skip
* this test (there is no OPENSSL_NO_LEGACY)
*/
OSSL_LIB_CTX_free(libctx);
return 1;
}
if (!TEST_true(OSSL_PROVIDER_add_builtin(libctx, name,
PROVIDER_INIT_FUNCTION_NAME))) {
OSSL_LIB_CTX_free(libctx);
return 0;
}
/* test_provider will free libctx and unload legacy as part of the test */
return test_provider(&libctx, name, legacy);
}
#endif
#ifndef NO_PROVIDER_MODULE
static int test_loaded_provider(void)
{
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
const char *name = "p_test";
int res = 0;
if (!TEST_ptr(libctx))
return 0;
/* test_provider will free libctx as part of the test */
res = test_provider(&libctx, name, NULL);
libctx = OSSL_LIB_CTX_new();
if (!TEST_ptr(libctx))
return 0;
/* test_provider_ex will free libctx as part of the test */
res = res && test_provider_ex(&libctx, name);
return res;
}
#endif
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_LOADED,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "loaded", OPT_LOADED, '-', "Run test with a loaded provider" },
{ NULL }
};
return test_options;
}
int setup_tests(void)
{
OPTION_CHOICE o;
int loaded = 0;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_TEST_CASES:
break;
case OPT_LOADED:
loaded = 1;
break;
default:
return 0;
}
}
if (!loaded) {
ADD_TEST(test_builtin_provider);
#ifndef OPENSSL_NO_MD4
ADD_TEST(test_builtin_provider_with_child);
#endif
}
#ifndef NO_PROVIDER_MODULE
else {
ADD_TEST(test_loaded_provider);
}
#endif
return 1;
}
|
./openssl/test/evp_fetch_prov_test.c | /*
* Copyright 2019-2022 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
*/
/*
* SHA256 low level APIs are deprecated for public use, but still ok for
* internal use. Note, that due to symbols not being exported, only the
* #defines can be accessed. In this case SHA256_CBLOCK.
*/
#include "internal/deprecated.h"
#include <string.h>
#include <openssl/sha.h>
#include <openssl/evp.h>
#include <openssl/provider.h>
#include "internal/sizes.h"
#include "testutil.h"
static char *config_file = NULL;
static char *alg = "digest";
static int use_default_ctx = 0;
static char *fetch_property = NULL;
static int expected_fetch_result = 1;
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_ALG_FETCH_TYPE,
OPT_FETCH_PROPERTY,
OPT_FETCH_FAILURE,
OPT_USE_DEFAULTCTX,
OPT_CONFIG_FILE,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("[provname...]\n"),
{ "config", OPT_CONFIG_FILE, '<', "The configuration file to use for the libctx" },
{ "type", OPT_ALG_FETCH_TYPE, 's', "The fetch type to test" },
{ "property", OPT_FETCH_PROPERTY, 's', "The fetch property e.g. provider=fips" },
{ "fetchfail", OPT_FETCH_FAILURE, '-', "fetch is expected to fail" },
{ "defaultctx", OPT_USE_DEFAULTCTX, '-',
"Use the default context if this is set" },
{ OPT_HELP_STR, 1, '-', "file\tProvider names to explicitly load\n" },
{ NULL }
};
return test_options;
}
static int calculate_digest(const EVP_MD *md, const char *msg, size_t len,
const unsigned char *exptd)
{
unsigned char out[SHA256_DIGEST_LENGTH];
EVP_MD_CTX *ctx;
int ret = 0;
if (!TEST_ptr(ctx = EVP_MD_CTX_new())
|| !TEST_true(EVP_DigestInit_ex(ctx, md, NULL))
|| !TEST_true(EVP_DigestUpdate(ctx, msg, len))
|| !TEST_true(EVP_DigestFinal_ex(ctx, out, NULL))
|| !TEST_mem_eq(out, SHA256_DIGEST_LENGTH, exptd,
SHA256_DIGEST_LENGTH)
|| !TEST_true(md == EVP_MD_CTX_get0_md(ctx)))
goto err;
ret = 1;
err:
EVP_MD_CTX_free(ctx);
return ret;
}
static int load_providers(OSSL_LIB_CTX **libctx, OSSL_PROVIDER *prov[])
{
OSSL_LIB_CTX *ctx = NULL;
int ret = 0;
size_t i;
ctx = OSSL_LIB_CTX_new();
if (!TEST_ptr(ctx))
goto err;
if (!TEST_true(OSSL_LIB_CTX_load_config(ctx, config_file)))
goto err;
if (test_get_argument_count() > 2)
goto err;
for (i = 0; i < test_get_argument_count(); ++i) {
char *provname = test_get_argument(i);
prov[i] = OSSL_PROVIDER_load(ctx, provname);
if (!TEST_ptr(prov[i]))
goto err;
}
ret = 1;
*libctx = ctx;
err:
if (ret == 0)
OSSL_LIB_CTX_free(ctx);
return ret;
}
static void unload_providers(OSSL_LIB_CTX **libctx, OSSL_PROVIDER *prov[])
{
if (prov[0] != NULL)
OSSL_PROVIDER_unload(prov[0]);
if (prov[1] != NULL)
OSSL_PROVIDER_unload(prov[1]);
/* Not normally needed, but we would like to test that
* OPENSSL_thread_stop_ex() behaves as expected.
*/
if (libctx != NULL && *libctx != NULL) {
OPENSSL_thread_stop_ex(*libctx);
OSSL_LIB_CTX_free(*libctx);
}
}
static int test_legacy_provider_unloaded(void)
{
OSSL_LIB_CTX *ctx = NULL;
int rc = 0;
ctx = OSSL_LIB_CTX_new();
if (!TEST_ptr(ctx))
goto err;
if (!TEST_true(OSSL_LIB_CTX_load_config(ctx, config_file)))
goto err;
if (!TEST_int_eq(OSSL_PROVIDER_available(ctx, "legacy"), 0))
goto err;
rc = 1;
err:
OSSL_LIB_CTX_free(ctx);
return rc;
}
static X509_ALGOR *make_algor(int nid)
{
X509_ALGOR *algor;
if (!TEST_ptr(algor = X509_ALGOR_new())
|| !TEST_true(X509_ALGOR_set0(algor, OBJ_nid2obj(nid),
V_ASN1_UNDEF, NULL))) {
X509_ALGOR_free(algor);
return NULL;
}
return algor;
}
/*
* Test EVP_MD_fetch()
*/
static int test_md(const EVP_MD *md)
{
const char testmsg[] = "Hello world";
const unsigned char exptd[] = {
0x27, 0x51, 0x8b, 0xa9, 0x68, 0x30, 0x11, 0xf6, 0xb3, 0x96, 0x07, 0x2c,
0x05, 0xf6, 0x65, 0x6d, 0x04, 0xf5, 0xfb, 0xc3, 0x78, 0x7c, 0xf9, 0x24,
0x90, 0xec, 0x60, 0x6e, 0x50, 0x92, 0xe3, 0x26
};
return TEST_ptr(md)
&& TEST_true(EVP_MD_is_a(md, "SHA256"))
&& TEST_true(calculate_digest(md, testmsg, sizeof(testmsg), exptd))
&& TEST_int_eq(EVP_MD_get_size(md), SHA256_DIGEST_LENGTH)
&& TEST_int_eq(EVP_MD_get_block_size(md), SHA256_CBLOCK);
}
static int test_implicit_EVP_MD_fetch(void)
{
OSSL_LIB_CTX *ctx = NULL;
OSSL_PROVIDER *prov[2] = {NULL, NULL};
int ret = 0;
ret = (use_default_ctx == 0 || load_providers(&ctx, prov))
&& test_md(EVP_sha256());
unload_providers(&ctx, prov);
return ret;
}
static int test_explicit_EVP_MD_fetch(const char *id)
{
OSSL_LIB_CTX *ctx = NULL;
EVP_MD *md = NULL;
OSSL_PROVIDER *prov[2] = {NULL, NULL};
int ret = 0;
if (use_default_ctx == 0 && !load_providers(&ctx, prov))
goto err;
md = EVP_MD_fetch(ctx, id, fetch_property);
if (expected_fetch_result != 0) {
if (!test_md(md))
goto err;
/* Also test EVP_MD_up_ref() while we're doing this */
if (!TEST_true(EVP_MD_up_ref(md)))
goto err;
/* Ref count should now be 2. Release first one here */
EVP_MD_free(md);
} else {
if (!TEST_ptr_null(md))
goto err;
}
ret = 1;
err:
EVP_MD_free(md);
unload_providers(&ctx, prov);
return ret;
}
static int test_explicit_EVP_MD_fetch_by_name(void)
{
return test_explicit_EVP_MD_fetch("SHA256");
}
/*
* idx 0: Allow names from OBJ_obj2txt()
* idx 1: Force an OID in text form from OBJ_obj2txt()
*/
static int test_explicit_EVP_MD_fetch_by_X509_ALGOR(int idx)
{
int ret = 0;
X509_ALGOR *algor = make_algor(NID_sha256);
const ASN1_OBJECT *obj;
char id[OSSL_MAX_NAME_SIZE] = { 0 };
if (algor == NULL)
return 0;
X509_ALGOR_get0(&obj, NULL, NULL, algor);
switch (idx) {
case 0:
if (!TEST_int_gt(OBJ_obj2txt(id, sizeof(id), obj, 0), 0))
goto end;
break;
case 1:
if (!TEST_int_gt(OBJ_obj2txt(id, sizeof(id), obj, 1), 0))
goto end;
break;
}
ret = test_explicit_EVP_MD_fetch(id);
end:
X509_ALGOR_free(algor);
return ret;
}
/*
* Test EVP_CIPHER_fetch()
*/
static int encrypt_decrypt(const EVP_CIPHER *cipher, const unsigned char *msg,
size_t len)
{
int ret = 0, ctlen, ptlen;
EVP_CIPHER_CTX *ctx = NULL;
unsigned char key[128 / 8];
unsigned char ct[64], pt[64];
memset(key, 0, sizeof(key));
if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new())
|| !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, key, NULL, 1))
|| !TEST_true(EVP_CipherUpdate(ctx, ct, &ctlen, msg, len))
|| !TEST_true(EVP_CipherFinal_ex(ctx, ct, &ctlen))
|| !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, key, NULL, 0))
|| !TEST_true(EVP_CipherUpdate(ctx, pt, &ptlen, ct, ctlen))
|| !TEST_true(EVP_CipherFinal_ex(ctx, pt, &ptlen))
|| !TEST_mem_eq(pt, ptlen, msg, len))
goto err;
ret = 1;
err:
EVP_CIPHER_CTX_free(ctx);
return ret;
}
static int test_cipher(const EVP_CIPHER *cipher)
{
const unsigned char testmsg[] = "Hello world";
return TEST_ptr(cipher)
&& TEST_true(encrypt_decrypt(cipher, testmsg, sizeof(testmsg)));
}
static int test_implicit_EVP_CIPHER_fetch(void)
{
OSSL_LIB_CTX *ctx = NULL;
OSSL_PROVIDER *prov[2] = {NULL, NULL};
int ret = 0;
ret = (use_default_ctx == 0 || load_providers(&ctx, prov))
&& test_cipher(EVP_aes_128_cbc());
unload_providers(&ctx, prov);
return ret;
}
static int test_explicit_EVP_CIPHER_fetch(const char *id)
{
OSSL_LIB_CTX *ctx = NULL;
EVP_CIPHER *cipher = NULL;
OSSL_PROVIDER *prov[2] = {NULL, NULL};
int ret = 0;
if (use_default_ctx == 0 && !load_providers(&ctx, prov))
goto err;
cipher = EVP_CIPHER_fetch(ctx, id, fetch_property);
if (expected_fetch_result != 0) {
if (!test_cipher(cipher))
goto err;
if (!TEST_true(EVP_CIPHER_up_ref(cipher)))
goto err;
/* Ref count should now be 2. Release first one here */
EVP_CIPHER_free(cipher);
} else {
if (!TEST_ptr_null(cipher))
goto err;
}
ret = 1;
err:
EVP_CIPHER_free(cipher);
unload_providers(&ctx, prov);
return ret;
}
static int test_explicit_EVP_CIPHER_fetch_by_name(void)
{
return test_explicit_EVP_CIPHER_fetch("AES-128-CBC");
}
/*
* idx 0: Allow names from OBJ_obj2txt()
* idx 1: Force an OID in text form from OBJ_obj2txt()
*/
static int test_explicit_EVP_CIPHER_fetch_by_X509_ALGOR(int idx)
{
int ret = 0;
X509_ALGOR *algor = make_algor(NID_aes_128_cbc);
const ASN1_OBJECT *obj;
char id[OSSL_MAX_NAME_SIZE] = { 0 };
if (algor == NULL)
return 0;
X509_ALGOR_get0(&obj, NULL, NULL, algor);
switch (idx) {
case 0:
if (!TEST_int_gt(OBJ_obj2txt(id, sizeof(id), obj, 0), 0))
goto end;
break;
case 1:
if (!TEST_int_gt(OBJ_obj2txt(id, sizeof(id), obj, 1), 0))
goto end;
break;
}
ret = test_explicit_EVP_CIPHER_fetch(id);
end:
X509_ALGOR_free(algor);
return ret;
}
int setup_tests(void)
{
OPTION_CHOICE o;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_CONFIG_FILE:
config_file = opt_arg();
break;
case OPT_ALG_FETCH_TYPE:
alg = opt_arg();
break;
case OPT_FETCH_PROPERTY:
fetch_property = opt_arg();
break;
case OPT_FETCH_FAILURE:
expected_fetch_result = 0;
break;
case OPT_USE_DEFAULTCTX:
use_default_ctx = 1;
break;
case OPT_TEST_CASES:
break;
default:
case OPT_ERR:
return 0;
}
}
ADD_TEST(test_legacy_provider_unloaded);
if (strcmp(alg, "digest") == 0) {
ADD_TEST(test_implicit_EVP_MD_fetch);
ADD_TEST(test_explicit_EVP_MD_fetch_by_name);
ADD_ALL_TESTS_NOSUBTEST(test_explicit_EVP_MD_fetch_by_X509_ALGOR, 2);
} else {
ADD_TEST(test_implicit_EVP_CIPHER_fetch);
ADD_TEST(test_explicit_EVP_CIPHER_fetch_by_name);
ADD_ALL_TESTS_NOSUBTEST(test_explicit_EVP_CIPHER_fetch_by_X509_ALGOR, 2);
}
return 1;
}
|
./openssl/test/evp_kdf_test.c | /*
* Copyright 2018-2023 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2018-2020, Oracle and/or its affiliates. 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
*/
/* Tests of the EVP_KDF_CTX APIs */
#include <stdio.h>
#include <string.h>
#include <openssl/evp.h>
#include <openssl/kdf.h>
#include <openssl/core_names.h>
#include "internal/numbers.h"
#include "testutil.h"
static EVP_KDF_CTX *get_kdfbyname_libctx(OSSL_LIB_CTX *libctx, const char *name)
{
EVP_KDF *kdf = EVP_KDF_fetch(libctx, name, NULL);
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
EVP_KDF_free(kdf);
return kctx;
}
static EVP_KDF_CTX *get_kdfbyname(const char *name)
{
return get_kdfbyname_libctx(NULL, name);
}
static OSSL_PARAM *construct_tls1_prf_params(const char *digest, const char *secret,
const char *seed)
{
OSSL_PARAM *params = OPENSSL_malloc(sizeof(OSSL_PARAM) * 4);
OSSL_PARAM *p = params;
if (params == NULL)
return NULL;
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
(char *)digest, 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET,
(unsigned char *)secret,
strlen(secret));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
(unsigned char *)seed,
strlen(seed));
*p = OSSL_PARAM_construct_end();
return params;
}
static int test_kdf_tls1_prf(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[16];
OSSL_PARAM *params;
static const unsigned char expected[sizeof(out)] = {
0x8e, 0x4d, 0x93, 0x25, 0x30, 0xd7, 0x65, 0xa0,
0xaa, 0xe9, 0x74, 0xc3, 0x04, 0x73, 0x5e, 0xcc
};
params = construct_tls1_prf_params("sha256", "secret", "seed");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_TLS1_PRF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_tls1_prf_invalid_digest(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
OSSL_PARAM *params;
params = construct_tls1_prf_params("blah", "secret", "seed");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_TLS1_PRF))
&& TEST_false(EVP_KDF_CTX_set_params(kctx, params));
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_tls1_prf_zero_output_size(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[16];
OSSL_PARAM *params;
params = construct_tls1_prf_params("sha256", "secret", "seed");
/* Negative test - derive should fail */
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_TLS1_PRF))
&& TEST_true(EVP_KDF_CTX_set_params(kctx, params))
&& TEST_int_eq(EVP_KDF_derive(kctx, out, 0, NULL), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_tls1_prf_empty_secret(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[16];
OSSL_PARAM *params;
params = construct_tls1_prf_params("sha256", "", "seed");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_TLS1_PRF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_tls1_prf_1byte_secret(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[16];
OSSL_PARAM *params;
params = construct_tls1_prf_params("sha256", "1", "seed");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_TLS1_PRF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_tls1_prf_empty_seed(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[16];
OSSL_PARAM *params;
params = construct_tls1_prf_params("sha256", "secret", "");
/* Negative test - derive should fail */
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_TLS1_PRF))
&& TEST_true(EVP_KDF_CTX_set_params(kctx, params))
&& TEST_int_eq(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_tls1_prf_1byte_seed(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[16];
OSSL_PARAM *params;
params = construct_tls1_prf_params("sha256", "secret", "1");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_TLS1_PRF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static OSSL_PARAM *construct_hkdf_params(char *digest, char *key,
size_t keylen, char *salt, char *info)
{
OSSL_PARAM *params = OPENSSL_malloc(sizeof(OSSL_PARAM) * 5);
OSSL_PARAM *p = params;
if (params == NULL)
return NULL;
if (digest != NULL)
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
digest, 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
salt, strlen(salt));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
(unsigned char *)key, keylen);
if (info != NULL)
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
info, strlen(info));
else
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MODE,
"EXTRACT_ONLY", 0);
*p = OSSL_PARAM_construct_end();
return params;
}
static int test_kdf_hkdf(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[10];
OSSL_PARAM *params;
static const unsigned char expected[sizeof(out)] = {
0x2a, 0xc4, 0x36, 0x9f, 0x52, 0x59, 0x96, 0xf8, 0xde, 0x13
};
params = construct_hkdf_params("sha256", "secret", 6, "salt", "label");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int do_kdf_hkdf_gettables(int expand_only, int has_digest)
{
int ret = 0;
size_t sz = 0;
OSSL_PARAM *params;
OSSL_PARAM params_get[2];
const OSSL_PARAM *gettables, *p;
EVP_KDF_CTX *kctx = NULL;
if (!TEST_ptr(params = construct_hkdf_params(
has_digest ? "sha256" : NULL,
"secret", 6, "salt",
expand_only ? NULL : "label"))
|| !TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF))
|| !TEST_true(EVP_KDF_CTX_set_params(kctx, params)))
goto err;
/* Check OSSL_KDF_PARAM_SIZE is gettable */
if (!TEST_ptr(gettables = EVP_KDF_CTX_gettable_params(kctx))
|| !TEST_ptr(p = OSSL_PARAM_locate_const(gettables, OSSL_KDF_PARAM_SIZE)))
goto err;
/* Get OSSL_KDF_PARAM_SIZE as a size_t */
params_get[0] = OSSL_PARAM_construct_size_t(OSSL_KDF_PARAM_SIZE, &sz);
params_get[1] = OSSL_PARAM_construct_end();
if (has_digest) {
if (!TEST_int_eq(EVP_KDF_CTX_get_params(kctx, params_get), 1)
|| !TEST_size_t_eq(sz, expand_only ? SHA256_DIGEST_LENGTH : SIZE_MAX))
goto err;
} else {
if (!TEST_int_eq(EVP_KDF_CTX_get_params(kctx, params_get), 0))
goto err;
}
/* Get params returns -2 if an unsupported parameter is requested */
params_get[0] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_KDF_CTX_get_params(kctx, params_get), -2))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_hkdf_gettables(void)
{
return do_kdf_hkdf_gettables(0, 1);
}
static int test_kdf_hkdf_gettables_expandonly(void)
{
return do_kdf_hkdf_gettables(1, 1);
}
static int test_kdf_hkdf_gettables_no_digest(void)
{
return do_kdf_hkdf_gettables(1, 0);
}
static int test_kdf_hkdf_invalid_digest(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
OSSL_PARAM *params;
params = construct_hkdf_params("blah", "secret", 6, "salt", "label");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF))
&& TEST_false(EVP_KDF_CTX_set_params(kctx, params));
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_hkdf_derive_set_params_fail(void)
{
int ret = 0, i = 0;
EVP_KDF_CTX *kctx = NULL;
OSSL_PARAM params[2];
unsigned char out[10];
if (!TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF)))
goto end;
/*
* Set the wrong type for the digest so that it causes a failure
* inside kdf_hkdf_derive() when kdf_hkdf_set_ctx_params() is called
*/
params[0] = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_DIGEST, &i);
params[1] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_KDF_derive(kctx, out, sizeof(out), params), 0))
goto end;
ret = 1;
end:
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdf_hkdf_set_invalid_mode(void)
{
int ret = 0, bad_mode = 100;
EVP_KDF_CTX *kctx = NULL;
OSSL_PARAM params[2];
if (!TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF)))
goto end;
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MODE,
"BADMODE", 0);
params[1] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_KDF_CTX_set_params(kctx, params), 0))
goto end;
params[0] = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &bad_mode);
if (!TEST_int_eq(EVP_KDF_CTX_set_params(kctx, params), 0))
goto end;
ret = 1;
end:
EVP_KDF_CTX_free(kctx);
return ret;
}
static int do_kdf_hkdf_set_invalid_param(const char *key, int type)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
OSSL_PARAM params[2];
unsigned char buf[2];
if (!TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF)))
goto end;
/* Set the wrong type for the key so that it causes a failure */
if (type == OSSL_PARAM_UTF8_STRING)
params[0] = OSSL_PARAM_construct_utf8_string(key, "BAD", 0);
else
params[0] = OSSL_PARAM_construct_octet_string(key, buf, sizeof(buf));
params[1] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_KDF_CTX_set_params(kctx, params), 0))
goto end;
ret = 1;
end:
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdf_hkdf_set_ctx_param_fail(void)
{
return do_kdf_hkdf_set_invalid_param(OSSL_KDF_PARAM_MODE,
OSSL_PARAM_OCTET_STRING)
&& do_kdf_hkdf_set_invalid_param(OSSL_KDF_PARAM_KEY,
OSSL_PARAM_UTF8_STRING)
&& do_kdf_hkdf_set_invalid_param(OSSL_KDF_PARAM_SALT,
OSSL_PARAM_UTF8_STRING)
&& do_kdf_hkdf_set_invalid_param(OSSL_KDF_PARAM_INFO,
OSSL_PARAM_UTF8_STRING);
}
static int test_kdf_hkdf_zero_output_size(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[10];
OSSL_PARAM *params;
params = construct_hkdf_params("sha256", "secret", 6, "salt", "label");
/* Negative test - derive should fail */
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF))
&& TEST_true(EVP_KDF_CTX_set_params(kctx, params))
&& TEST_int_eq(EVP_KDF_derive(kctx, out, 0, NULL), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_hkdf_empty_key(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[10];
OSSL_PARAM *params;
params = construct_hkdf_params("sha256", "", 0, "salt", "label");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_hkdf_1byte_key(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[10];
OSSL_PARAM *params;
params = construct_hkdf_params("sha256", "1", 1, "salt", "label");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_hkdf_empty_salt(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[10];
OSSL_PARAM *params;
params = construct_hkdf_params("sha256", "secret", 6, "", "label");
ret = TEST_ptr(params)
&& TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HKDF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static OSSL_PARAM *construct_pbkdf1_params(char *pass, char *digest, char *salt,
unsigned int *iter)
{
OSSL_PARAM *params = OPENSSL_malloc(sizeof(OSSL_PARAM) * 5);
OSSL_PARAM *p = params;
if (params == NULL)
return NULL;
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_PASSWORD,
(unsigned char *)pass, strlen(pass));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
(unsigned char *)salt, strlen(salt));
*p++ = OSSL_PARAM_construct_uint(OSSL_KDF_PARAM_ITER, iter);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
digest, 0);
*p = OSSL_PARAM_construct_end();
return params;
}
static int test_kdf_pbkdf1(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[25];
unsigned int iterations = 4096;
OSSL_LIB_CTX *libctx = NULL;
OSSL_PARAM *params = NULL;
OSSL_PROVIDER *legacyprov = NULL;
OSSL_PROVIDER *defprov = NULL;
const unsigned char expected[sizeof(out)] = {
0xfb, 0x83, 0x4d, 0x36, 0x6d, 0xbc, 0x53, 0x87, 0x35, 0x1b, 0x34, 0x75,
0x95, 0x88, 0x32, 0x4f, 0x3e, 0x82, 0x81, 0x01, 0x21, 0x93, 0x64, 0x00,
0xcc
};
if (!TEST_ptr(libctx = OSSL_LIB_CTX_new()))
goto err;
/* PBKDF1 only available in the legacy provider */
legacyprov = OSSL_PROVIDER_load(libctx, "legacy");
if (legacyprov == NULL) {
OSSL_LIB_CTX_free(libctx);
return TEST_skip("PBKDF1 only available in legacy provider");
}
if (!TEST_ptr(defprov = OSSL_PROVIDER_load(libctx, "default")))
goto err;
params = construct_pbkdf1_params("passwordPASSWORDpassword", "sha256",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
&iterations);
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname_libctx(libctx, OSSL_KDF_NAME_PBKDF1))
|| !TEST_true(EVP_KDF_CTX_set_params(kctx, params))
|| !TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0)
|| !TEST_mem_eq(out, sizeof(out), expected, sizeof(expected)))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
OSSL_PROVIDER_unload(defprov);
OSSL_PROVIDER_unload(legacyprov);
OSSL_LIB_CTX_free(libctx);
return ret;
}
static int test_kdf_pbkdf1_key_too_long(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[EVP_MAX_MD_SIZE + 1];
unsigned int iterations = 4096;
OSSL_LIB_CTX *libctx = NULL;
OSSL_PARAM *params = NULL;
OSSL_PROVIDER *legacyprov = NULL;
OSSL_PROVIDER *defprov = NULL;
if (!TEST_ptr(libctx = OSSL_LIB_CTX_new()))
goto err;
/* PBKDF1 only available in the legacy provider */
legacyprov = OSSL_PROVIDER_load(libctx, "legacy");
if (legacyprov == NULL) {
OSSL_LIB_CTX_free(libctx);
return TEST_skip("PBKDF1 only available in legacy provider");
}
if (!TEST_ptr(defprov = OSSL_PROVIDER_load(libctx, "default")))
goto err;
params = construct_pbkdf1_params("passwordPASSWORDpassword", "sha256",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
&iterations);
/*
* This is the same test sequence as test_kdf_pbkdf1, but we expect
* failure here as the requested key size is longer than the digest
* can provide
*/
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname_libctx(libctx, OSSL_KDF_NAME_PBKDF1))
|| !TEST_true(EVP_KDF_CTX_set_params(kctx, params))
|| !TEST_int_eq(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
OSSL_PROVIDER_unload(defprov);
OSSL_PROVIDER_unload(legacyprov);
OSSL_LIB_CTX_free(libctx);
return ret;
}
static OSSL_PARAM *construct_pbkdf2_params(char *pass, char *digest, char *salt,
unsigned int *iter, int *mode)
{
OSSL_PARAM *params = OPENSSL_malloc(sizeof(OSSL_PARAM) * 6);
OSSL_PARAM *p = params;
if (params == NULL)
return NULL;
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_PASSWORD,
(unsigned char *)pass, strlen(pass));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
(unsigned char *)salt, strlen(salt));
*p++ = OSSL_PARAM_construct_uint(OSSL_KDF_PARAM_ITER, iter);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
digest, 0);
*p++ = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_PKCS5, mode);
*p = OSSL_PARAM_construct_end();
return params;
}
static int test_kdf_pbkdf2(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[25];
unsigned int iterations = 4096;
int mode = 0;
OSSL_PARAM *params;
const unsigned char expected[sizeof(out)] = {
0x34, 0x8c, 0x89, 0xdb, 0xcb, 0xd3, 0x2b, 0x2f,
0x32, 0xd8, 0x14, 0xb8, 0x11, 0x6e, 0x84, 0xcf,
0x2b, 0x17, 0x34, 0x7e, 0xbc, 0x18, 0x00, 0x18,
0x1c
};
params = construct_pbkdf2_params("passwordPASSWORDpassword", "sha256",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
&iterations, &mode);
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_PBKDF2))
|| !TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0)
|| !TEST_mem_eq(out, sizeof(out), expected, sizeof(expected)))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_pbkdf2_small_output(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[25];
unsigned int iterations = 4096;
int mode = 0;
OSSL_PARAM *params;
params = construct_pbkdf2_params("passwordPASSWORDpassword", "sha256",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
&iterations, &mode);
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_PBKDF2))
|| !TEST_true(EVP_KDF_CTX_set_params(kctx, params))
/* A key length that is too small should fail */
|| !TEST_int_eq(EVP_KDF_derive(kctx, out, 112 / 8 - 1, NULL), 0))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_pbkdf2_large_output(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[25];
size_t len = 0;
unsigned int iterations = 4096;
int mode = 0;
OSSL_PARAM *params;
if (sizeof(len) > 32)
len = SIZE_MAX;
params = construct_pbkdf2_params("passwordPASSWORDpassword", "sha256",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
&iterations, &mode);
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_PBKDF2))
/* A key length that is too large should fail */
|| !TEST_true(EVP_KDF_CTX_set_params(kctx, params))
|| (len != 0 && !TEST_int_eq(EVP_KDF_derive(kctx, out, len, NULL), 0)))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_pbkdf2_small_salt(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned int iterations = 4096;
int mode = 0;
OSSL_PARAM *params;
params = construct_pbkdf2_params("passwordPASSWORDpassword", "sha256",
"saltSALT",
&iterations, &mode);
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_PBKDF2))
/* A salt that is too small should fail */
|| !TEST_false(EVP_KDF_CTX_set_params(kctx, params)))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_pbkdf2_small_iterations(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned int iterations = 1;
int mode = 0;
OSSL_PARAM *params;
params = construct_pbkdf2_params("passwordPASSWORDpassword", "sha256",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
&iterations, &mode);
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_PBKDF2))
/* An iteration count that is too small should fail */
|| !TEST_false(EVP_KDF_CTX_set_params(kctx, params)))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_pbkdf2_small_salt_pkcs5(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[25];
unsigned int iterations = 4096;
int mode = 1;
OSSL_PARAM *params;
OSSL_PARAM mode_params[2];
params = construct_pbkdf2_params("passwordPASSWORDpassword", "sha256",
"saltSALT",
&iterations, &mode);
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_PBKDF2))
/* A salt that is too small should pass in pkcs5 mode */
|| !TEST_true(EVP_KDF_CTX_set_params(kctx, params))
|| !TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0))
goto err;
mode = 0;
mode_params[0] = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_PKCS5, &mode);
mode_params[1] = OSSL_PARAM_construct_end();
/* If the "pkcs5" mode is disabled then the derive will now fail */
if (!TEST_true(EVP_KDF_CTX_set_params(kctx, mode_params))
|| !TEST_int_eq(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_pbkdf2_small_iterations_pkcs5(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned char out[25];
unsigned int iterations = 1;
int mode = 1;
OSSL_PARAM *params;
OSSL_PARAM mode_params[2];
params = construct_pbkdf2_params("passwordPASSWORDpassword", "sha256",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
&iterations, &mode);
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_PBKDF2))
/* An iteration count that is too small will pass in pkcs5 mode */
|| !TEST_true(EVP_KDF_CTX_set_params(kctx, params))
|| !TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0))
goto err;
mode = 0;
mode_params[0] = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_PKCS5, &mode);
mode_params[1] = OSSL_PARAM_construct_end();
/* If the "pkcs5" mode is disabled then the derive will now fail */
if (!TEST_true(EVP_KDF_CTX_set_params(kctx, mode_params))
|| !TEST_int_eq(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_pbkdf2_invalid_digest(void)
{
int ret = 0;
EVP_KDF_CTX *kctx = NULL;
unsigned int iterations = 4096;
int mode = 0;
OSSL_PARAM *params;
params = construct_pbkdf2_params("passwordPASSWORDpassword", "blah",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
&iterations, &mode);
if (!TEST_ptr(params)
|| !TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_PBKDF2))
/* Unknown digest should fail */
|| !TEST_false(EVP_KDF_CTX_set_params(kctx, params)))
goto err;
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
#ifndef OPENSSL_NO_SCRYPT
static int test_kdf_scrypt(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[7], *p = params;
unsigned char out[64];
unsigned int nu = 1024, ru = 8, pu = 16, maxmem = 16;
static const unsigned char expected[sizeof(out)] = {
0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00,
0x78, 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe,
0x7c, 0x6a, 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30,
0xe7, 0x73, 0x76, 0x63, 0x4b, 0x37, 0x31, 0x62,
0x2e, 0xaf, 0x30, 0xd9, 0x2e, 0x22, 0xa3, 0x88,
0x6f, 0xf1, 0x09, 0x27, 0x9d, 0x98, 0x30, 0xda,
0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, 0xee, 0x6d,
0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, 0x40
};
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_PASSWORD,
(char *)"password", 8);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
(char *)"NaCl", 4);
*p++ = OSSL_PARAM_construct_uint(OSSL_KDF_PARAM_SCRYPT_N, &nu);
*p++ = OSSL_PARAM_construct_uint(OSSL_KDF_PARAM_SCRYPT_R, &ru);
*p++ = OSSL_PARAM_construct_uint(OSSL_KDF_PARAM_SCRYPT_P, &pu);
*p++ = OSSL_PARAM_construct_uint(OSSL_KDF_PARAM_SCRYPT_MAXMEM, &maxmem);
*p = OSSL_PARAM_construct_end();
ret =
TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_SCRYPT))
&& TEST_true(EVP_KDF_CTX_set_params(kctx, params))
/* failure test *//*
&& TEST_int_le(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0)*/
&& TEST_true(OSSL_PARAM_set_uint(p - 1, 10 * 1024 * 1024))
&& TEST_true(EVP_KDF_CTX_set_params(kctx, p - 1))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
return ret;
}
#endif /* OPENSSL_NO_SCRYPT */
static int test_kdf_ss_hash(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[4], *p = params;
unsigned char out[14];
static unsigned char z[] = {
0x6d,0xbd,0xc2,0x3f,0x04,0x54,0x88,0xe4,0x06,0x27,0x57,0xb0,0x6b,0x9e,
0xba,0xe1,0x83,0xfc,0x5a,0x59,0x46,0xd8,0x0d,0xb9,0x3f,0xec,0x6f,0x62,
0xec,0x07,0xe3,0x72,0x7f,0x01,0x26,0xae,0xd1,0x2c,0xe4,0xb2,0x62,0xf4,
0x7d,0x48,0xd5,0x42,0x87,0xf8,0x1d,0x47,0x4c,0x7c,0x3b,0x18,0x50,0xe9
};
static unsigned char other[] = {
0xa1,0xb2,0xc3,0xd4,0xe5,0x43,0x41,0x56,0x53,0x69,0x64,0x3c,0x83,0x2e,
0x98,0x49,0xdc,0xdb,0xa7,0x1e,0x9a,0x31,0x39,0xe6,0x06,0xe0,0x95,0xde,
0x3c,0x26,0x4a,0x66,0xe9,0x8a,0x16,0x58,0x54,0xcd,0x07,0x98,0x9b,0x1e,
0xe0,0xec,0x3f,0x8d,0xbe
};
static const unsigned char expected[sizeof(out)] = {
0xa4,0x62,0xde,0x16,0xa8,0x9d,0xe8,0x46,0x6e,0xf5,0x46,0x0b,0x47,0xb8
};
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
(char *)"sha224", 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, z, sizeof(z));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, other,
sizeof(other));
*p = OSSL_PARAM_construct_end();
ret =
TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_SSKDF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdf_x963(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[4], *p = params;
unsigned char out[1024 / 8];
/*
* Test data from https://csrc.nist.gov/CSRC/media/Projects/
* Cryptographic-Algorithm-Validation-Program/documents/components/
* 800-135testvectors/ansx963_2001.zip
*/
static unsigned char z[] = {
0x00, 0xaa, 0x5b, 0xb7, 0x9b, 0x33, 0xe3, 0x89, 0xfa, 0x58, 0xce, 0xad,
0xc0, 0x47, 0x19, 0x7f, 0x14, 0xe7, 0x37, 0x12, 0xf4, 0x52, 0xca, 0xa9,
0xfc, 0x4c, 0x9a, 0xdb, 0x36, 0x93, 0x48, 0xb8, 0x15, 0x07, 0x39, 0x2f,
0x1a, 0x86, 0xdd, 0xfd, 0xb7, 0xc4, 0xff, 0x82, 0x31, 0xc4, 0xbd, 0x0f,
0x44, 0xe4, 0x4a, 0x1b, 0x55, 0xb1, 0x40, 0x47, 0x47, 0xa9, 0xe2, 0xe7,
0x53, 0xf5, 0x5e, 0xf0, 0x5a, 0x2d
};
static unsigned char shared[] = {
0xe3, 0xb5, 0xb4, 0xc1, 0xb0, 0xd5, 0xcf, 0x1d, 0x2b, 0x3a, 0x2f, 0x99,
0x37, 0x89, 0x5d, 0x31
};
static const unsigned char expected[sizeof(out)] = {
0x44, 0x63, 0xf8, 0x69, 0xf3, 0xcc, 0x18, 0x76, 0x9b, 0x52, 0x26, 0x4b,
0x01, 0x12, 0xb5, 0x85, 0x8f, 0x7a, 0xd3, 0x2a, 0x5a, 0x2d, 0x96, 0xd8,
0xcf, 0xfa, 0xbf, 0x7f, 0xa7, 0x33, 0x63, 0x3d, 0x6e, 0x4d, 0xd2, 0xa5,
0x99, 0xac, 0xce, 0xb3, 0xea, 0x54, 0xa6, 0x21, 0x7c, 0xe0, 0xb5, 0x0e,
0xef, 0x4f, 0x6b, 0x40, 0xa5, 0xc3, 0x02, 0x50, 0xa5, 0xa8, 0xee, 0xee,
0x20, 0x80, 0x02, 0x26, 0x70, 0x89, 0xdb, 0xf3, 0x51, 0xf3, 0xf5, 0x02,
0x2a, 0xa9, 0x63, 0x8b, 0xf1, 0xee, 0x41, 0x9d, 0xea, 0x9c, 0x4f, 0xf7,
0x45, 0xa2, 0x5a, 0xc2, 0x7b, 0xda, 0x33, 0xca, 0x08, 0xbd, 0x56, 0xdd,
0x1a, 0x59, 0xb4, 0x10, 0x6c, 0xf2, 0xdb, 0xbc, 0x0a, 0xb2, 0xaa, 0x8e,
0x2e, 0xfa, 0x7b, 0x17, 0x90, 0x2d, 0x34, 0x27, 0x69, 0x51, 0xce, 0xcc,
0xab, 0x87, 0xf9, 0x66, 0x1c, 0x3e, 0x88, 0x16
};
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
(char *)"sha512", 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, z, sizeof(z));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, shared,
sizeof(shared));
*p = OSSL_PARAM_construct_end();
ret =
TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_X963KDF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
return ret;
}
#if !defined(OPENSSL_NO_CMAC) && !defined(OPENSSL_NO_CAMELLIA)
/*
* KBKDF test vectors from RFC 6803 (Camellia Encryption for Kerberos 5)
* section 10.
*/
static int test_kdf_kbkdf_6803_128(void)
{
int ret = 0, i, p;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[7];
static unsigned char input_key[] = {
0x57, 0xD0, 0x29, 0x72, 0x98, 0xFF, 0xD9, 0xD3,
0x5D, 0xE5, 0xA4, 0x7F, 0xB4, 0xBD, 0xE2, 0x4B,
};
static unsigned char constants[][5] = {
{ 0x00, 0x00, 0x00, 0x02, 0x99 },
{ 0x00, 0x00, 0x00, 0x02, 0xaa },
{ 0x00, 0x00, 0x00, 0x02, 0x55 },
};
static unsigned char outputs[][16] = {
{0xD1, 0x55, 0x77, 0x5A, 0x20, 0x9D, 0x05, 0xF0,
0x2B, 0x38, 0xD4, 0x2A, 0x38, 0x9E, 0x5A, 0x56},
{0x64, 0xDF, 0x83, 0xF8, 0x5A, 0x53, 0x2F, 0x17,
0x57, 0x7D, 0x8C, 0x37, 0x03, 0x57, 0x96, 0xAB},
{0x3E, 0x4F, 0xBD, 0xF3, 0x0F, 0xB8, 0x25, 0x9C,
0x42, 0x5C, 0xB6, 0xC9, 0x6F, 0x1F, 0x46, 0x35}
};
static unsigned char iv[16] = { 0 };
unsigned char result[16] = { 0 };
for (i = 0; i < 3; i++) {
p = 0;
params[p++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_CIPHER, "CAMELLIA-128-CBC", 0);
params[p++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_MAC, "CMAC", 0);
params[p++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_MODE, "FEEDBACK", 0);
params[p++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_KEY, input_key, sizeof(input_key));
params[p++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_SALT, constants[i], sizeof(constants[i]));
params[p++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_SEED, iv, sizeof(iv));
params[p] = OSSL_PARAM_construct_end();
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result),
params), 0)
&& TEST_mem_eq(result, sizeof(result), outputs[i],
sizeof(outputs[i]));
EVP_KDF_CTX_free(kctx);
if (ret != 1)
return ret;
}
return ret;
}
static int test_kdf_kbkdf_6803_256(void)
{
int ret = 0, i, p;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[7];
static unsigned char input_key[] = {
0xB9, 0xD6, 0x82, 0x8B, 0x20, 0x56, 0xB7, 0xBE,
0x65, 0x6D, 0x88, 0xA1, 0x23, 0xB1, 0xFA, 0xC6,
0x82, 0x14, 0xAC, 0x2B, 0x72, 0x7E, 0xCF, 0x5F,
0x69, 0xAF, 0xE0, 0xC4, 0xDF, 0x2A, 0x6D, 0x2C,
};
static unsigned char constants[][5] = {
{ 0x00, 0x00, 0x00, 0x02, 0x99 },
{ 0x00, 0x00, 0x00, 0x02, 0xaa },
{ 0x00, 0x00, 0x00, 0x02, 0x55 },
};
static unsigned char outputs[][32] = {
{0xE4, 0x67, 0xF9, 0xA9, 0x55, 0x2B, 0xC7, 0xD3,
0x15, 0x5A, 0x62, 0x20, 0xAF, 0x9C, 0x19, 0x22,
0x0E, 0xEE, 0xD4, 0xFF, 0x78, 0xB0, 0xD1, 0xE6,
0xA1, 0x54, 0x49, 0x91, 0x46, 0x1A, 0x9E, 0x50,
},
{0x41, 0x2A, 0xEF, 0xC3, 0x62, 0xA7, 0x28, 0x5F,
0xC3, 0x96, 0x6C, 0x6A, 0x51, 0x81, 0xE7, 0x60,
0x5A, 0xE6, 0x75, 0x23, 0x5B, 0x6D, 0x54, 0x9F,
0xBF, 0xC9, 0xAB, 0x66, 0x30, 0xA4, 0xC6, 0x04,
},
{0xFA, 0x62, 0x4F, 0xA0, 0xE5, 0x23, 0x99, 0x3F,
0xA3, 0x88, 0xAE, 0xFD, 0xC6, 0x7E, 0x67, 0xEB,
0xCD, 0x8C, 0x08, 0xE8, 0xA0, 0x24, 0x6B, 0x1D,
0x73, 0xB0, 0xD1, 0xDD, 0x9F, 0xC5, 0x82, 0xB0,
},
};
static unsigned char iv[16] = { 0 };
unsigned char result[32] = { 0 };
for (i = 0; i < 3; i++) {
p = 0;
params[p++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_CIPHER, "CAMELLIA-256-CBC", 0);
params[p++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_MAC, "CMAC", 0);
params[p++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_MODE, "FEEDBACK", 0);
params[p++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_KEY, input_key, sizeof(input_key));
params[p++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_SALT, constants[i], sizeof(constants[i]));
params[p++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_SEED, iv, sizeof(iv));
params[p] = OSSL_PARAM_construct_end();
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result),
params), 0)
&& TEST_mem_eq(result, sizeof(result), outputs[i],
sizeof(outputs[i]));
EVP_KDF_CTX_free(kctx);
if (ret != 1)
return ret;
}
return ret;
}
#endif
static OSSL_PARAM *construct_kbkdf_params(char *digest, char *mac, unsigned char *key,
size_t keylen, char *salt, char *info, int *r)
{
OSSL_PARAM *params = OPENSSL_malloc(sizeof(OSSL_PARAM) * 8);
OSSL_PARAM *p = params;
if (params == NULL)
return NULL;
*p++ = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_DIGEST, digest, 0);
*p++ = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_MAC, mac, 0);
*p++ = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_MODE, "COUNTER", 0);
*p++ = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_KEY, key, keylen);
*p++ = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_SALT, salt, strlen(salt));
*p++ = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_INFO, info, strlen(info));
*p++ = OSSL_PARAM_construct_int(
OSSL_KDF_PARAM_KBKDF_R, r);
*p = OSSL_PARAM_construct_end();
return params;
}
static int test_kdf_kbkdf_invalid_digest(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM *params;
static unsigned char key[] = {0x01};
int r = 32;
params = construct_kbkdf_params("blah", "HMAC", key, 1, "prf", "test", &r);
if (!TEST_ptr(params))
return 0;
/* Negative test case - set_params should fail */
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_false(EVP_KDF_CTX_set_params(kctx, params));
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_kbkdf_invalid_mac(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM *params;
static unsigned char key[] = {0x01};
int r = 32;
params = construct_kbkdf_params("sha256", "blah", key, 1, "prf", "test", &r);
if (!TEST_ptr(params))
return 0;
/* Negative test case - set_params should fail */
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_false(EVP_KDF_CTX_set_params(kctx, params));
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_kbkdf_invalid_r(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM *params;
static unsigned char key[] = {0x01};
int r = 31;
params = construct_kbkdf_params("sha256", "HMAC", key, 1, "prf", "test", &r);
if (!TEST_ptr(params))
return 0;
/* Negative test case - derive should fail */
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_false(EVP_KDF_CTX_set_params(kctx, params));
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_kbkdf_empty_key(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM *params;
static unsigned char key[] = {0x01};
unsigned char result[32] = { 0 };
int r = 32;
params = construct_kbkdf_params("sha256", "HMAC", key, 0, "prf", "test", &r);
if (!TEST_ptr(params))
return 0;
/* Negative test case - derive should fail */
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_true(EVP_KDF_CTX_set_params(kctx, params))
&& TEST_int_eq(EVP_KDF_derive(kctx, result, sizeof(result), NULL), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_kbkdf_1byte_key(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM *params;
static unsigned char key[] = {0x01};
unsigned char result[32] = { 0 };
int r = 32;
params = construct_kbkdf_params("sha256", "HMAC", key, 1, "prf", "test", &r);
if (!TEST_ptr(params))
return 0;
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result), params), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
static int test_kdf_kbkdf_zero_output_size(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM *params;
static unsigned char key[] = {0x01};
unsigned char result[32] = { 0 };
int r = 32;
params = construct_kbkdf_params("sha256", "HMAC", key, 1, "prf", "test", &r);
if (!TEST_ptr(params))
return 0;
/* Negative test case - derive should fail */
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_true(EVP_KDF_CTX_set_params(kctx, params))
&& TEST_int_eq(EVP_KDF_derive(kctx, result, 0, NULL), 0);
EVP_KDF_CTX_free(kctx);
OPENSSL_free(params);
return ret;
}
/* Two test vectors from RFC 8009 (AES Encryption with HMAC-SHA2 for Kerberos
* 5) appendix A. */
static int test_kdf_kbkdf_8009_prf1(void)
{
int ret, i = 0;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[6];
char *label = "prf", *digest = "sha256", *prf_input = "test",
*mac = "HMAC";
static unsigned char input_key[] = {
0x37, 0x05, 0xD9, 0x60, 0x80, 0xC1, 0x77, 0x28,
0xA0, 0xE8, 0x00, 0xEA, 0xB6, 0xE0, 0xD2, 0x3C,
};
static unsigned char output[] = {
0x9D, 0x18, 0x86, 0x16, 0xF6, 0x38, 0x52, 0xFE,
0x86, 0x91, 0x5B, 0xB8, 0x40, 0xB4, 0xA8, 0x86,
0xFF, 0x3E, 0x6B, 0xB0, 0xF8, 0x19, 0xB4, 0x9B,
0x89, 0x33, 0x93, 0xD3, 0x93, 0x85, 0x42, 0x95,
};
unsigned char result[sizeof(output)] = { 0 };
params[i++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_DIGEST, digest, 0);
params[i++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_MAC, mac, 0);
params[i++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_KEY, input_key, sizeof(input_key));
params[i++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_SALT, label, strlen(label));
params[i++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_INFO, prf_input, strlen(prf_input));
params[i] = OSSL_PARAM_construct_end();
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result), params), 0)
&& TEST_mem_eq(result, sizeof(result), output, sizeof(output));
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdf_kbkdf_8009_prf2(void)
{
int ret, i = 0;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[6];
char *label = "prf", *digest = "sha384", *prf_input = "test",
*mac = "HMAC";
static unsigned char input_key[] = {
0x6D, 0x40, 0x4D, 0x37, 0xFA, 0xF7, 0x9F, 0x9D,
0xF0, 0xD3, 0x35, 0x68, 0xD3, 0x20, 0x66, 0x98,
0x00, 0xEB, 0x48, 0x36, 0x47, 0x2E, 0xA8, 0xA0,
0x26, 0xD1, 0x6B, 0x71, 0x82, 0x46, 0x0C, 0x52,
};
static unsigned char output[] = {
0x98, 0x01, 0xF6, 0x9A, 0x36, 0x8C, 0x2B, 0xF6,
0x75, 0xE5, 0x95, 0x21, 0xE1, 0x77, 0xD9, 0xA0,
0x7F, 0x67, 0xEF, 0xE1, 0xCF, 0xDE, 0x8D, 0x3C,
0x8D, 0x6F, 0x6A, 0x02, 0x56, 0xE3, 0xB1, 0x7D,
0xB3, 0xC1, 0xB6, 0x2A, 0xD1, 0xB8, 0x55, 0x33,
0x60, 0xD1, 0x73, 0x67, 0xEB, 0x15, 0x14, 0xD2,
};
unsigned char result[sizeof(output)] = { 0 };
params[i++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_DIGEST, digest, 0);
params[i++] = OSSL_PARAM_construct_utf8_string(
OSSL_KDF_PARAM_MAC, mac, 0);
params[i++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_KEY, input_key, sizeof(input_key));
params[i++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_SALT, label, strlen(label));
params[i++] = OSSL_PARAM_construct_octet_string(
OSSL_KDF_PARAM_INFO, prf_input, strlen(prf_input));
params[i] = OSSL_PARAM_construct_end();
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result), params), 0)
&& TEST_mem_eq(result, sizeof(result), output, sizeof(output));
EVP_KDF_CTX_free(kctx);
return ret;
}
#if !defined(OPENSSL_NO_CMAC)
/*
* Test vector taken from
* https://csrc.nist.gov/CSRC/media/Projects/
* Cryptographic-Algorithm-Validation-Program/documents/KBKDF800-108/CounterMode.zip
*/
static int test_kdf_kbkdf_fixedinfo(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[8], *p = params;
static char *cipher = "AES128";
static char *mac = "CMAC";
static char *mode = "COUNTER";
int use_l = 0;
int use_separator = 0;
static unsigned char input_key[] = {
0xc1, 0x0b, 0x15, 0x2e, 0x8c, 0x97, 0xb7, 0x7e,
0x18, 0x70, 0x4e, 0x0f, 0x0b, 0xd3, 0x83, 0x05,
};
static unsigned char fixed_input[] = {
0x98, 0xcd, 0x4c, 0xbb, 0xbe, 0xbe, 0x15, 0xd1,
0x7d, 0xc8, 0x6e, 0x6d, 0xba, 0xd8, 0x00, 0xa2,
0xdc, 0xbd, 0x64, 0xf7, 0xc7, 0xad, 0x0e, 0x78,
0xe9, 0xcf, 0x94, 0xff, 0xdb, 0xa8, 0x9d, 0x03,
0xe9, 0x7e, 0xad, 0xf6, 0xc4, 0xf7, 0xb8, 0x06,
0xca, 0xf5, 0x2a, 0xa3, 0x8f, 0x09, 0xd0, 0xeb,
0x71, 0xd7, 0x1f, 0x49, 0x7b, 0xcc, 0x69, 0x06,
0xb4, 0x8d, 0x36, 0xc4,
};
static unsigned char output[] = {
0x26, 0xfa, 0xf6, 0x19, 0x08, 0xad, 0x9e, 0xe8,
0x81, 0xb8, 0x30, 0x5c, 0x22, 0x1d, 0xb5, 0x3f,
};
unsigned char result[sizeof(output)] = { 0 };
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_CIPHER, cipher, 0);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC, mac, 0);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MODE, mode, 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, input_key,
sizeof(input_key));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
fixed_input, sizeof(fixed_input));
*p++ = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_KBKDF_USE_L, &use_l);
*p++ = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_KBKDF_USE_SEPARATOR,
&use_separator);
*p = OSSL_PARAM_construct_end();
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result), params), 0)
&& TEST_mem_eq(result, sizeof(result), output, sizeof(output));
EVP_KDF_CTX_free(kctx);
return ret;
}
#endif /* OPENSSL_NO_CMAC */
static int test_kdf_kbkdf_kmac(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[5], *p = params;
static char *mac = "KMAC256";
static unsigned char input_key[] = {
0xDD, 0x81, 0xEF, 0xC8, 0x2C, 0xDD, 0xEC, 0x51,
0xC4, 0x09, 0xBD, 0x8C, 0xCB, 0xAF, 0x94, 0xF6,
0x5F, 0xFA, 0x7B, 0x92, 0xF1, 0x11, 0xF9, 0x40,
0x2B, 0x0D, 0x6A, 0xE0, 0x5E, 0x44, 0x92, 0x34,
0xF0, 0x3B, 0xBA, 0xF5, 0x4F, 0xEF, 0x19, 0x45,
0xDA
};
static unsigned char context[] = {
0x81, 0xA1, 0xFE, 0x39, 0x91, 0xEE, 0x3F, 0xD3,
0x90, 0x4E, 0x82, 0xE6, 0x13, 0x20, 0xEC, 0x6B,
0x6E, 0x14, 0x0B, 0xBA, 0x95, 0x5D, 0x0B, 0x52,
0x8E, 0x27, 0x67, 0xB3, 0xE0, 0x77, 0x05, 0x15,
0xBD, 0x78, 0xF6, 0xE8, 0x8A, 0x7D, 0x9B, 0x08,
0x20, 0x0F, 0xE9, 0x8D, 0xD6, 0x24, 0x67, 0xE2,
0xCC, 0x6D, 0x42, 0xE6, 0x60, 0x50, 0x20, 0x77,
0x89, 0x89, 0xB7, 0x2D, 0xF7, 0x5F, 0xE2, 0x79,
0xDB, 0x58, 0x0B, 0x7B, 0x02, 0xB9, 0xD9, 0xB0,
0xFA, 0x6B, 0x0B, 0xB6, 0xD4, 0x95, 0xDB, 0x46,
0x55, 0x5F, 0x12, 0xC3, 0xF0, 0xE0, 0x6E, 0xC8,
0xF4, 0xF8, 0xA1, 0x64, 0x2E, 0x96, 0x74, 0x2B,
0xC6, 0xBD, 0x22, 0xB1, 0x6A, 0xBC, 0x41, 0xDF,
0x30, 0x32, 0xC7, 0xCE, 0x18, 0x14, 0x70, 0x2A,
0xED, 0xE5, 0xC4, 0x6B, 0x8A, 0xA8, 0x36, 0xFD,
0x0A, 0x76, 0x38, 0x44, 0x98, 0x0A, 0xE3, 0xC2,
0x3A, 0x24, 0xCB, 0x45, 0xBF, 0xC9, 0x2C, 0x19,
0xCB, 0x9D, 0x6C, 0x27, 0xDE, 0x78, 0x3E, 0x2C,
0x3D, 0x39, 0x6E, 0x11, 0x59, 0xAE, 0x4F, 0x91,
0x03, 0xE2, 0x7B, 0x97, 0xD6, 0x0C, 0x7D, 0x9D,
0x5A, 0xA5, 0x47, 0x57, 0x41, 0xAD, 0x64, 0x5B,
0xF7, 0x1D, 0x1A, 0xDA, 0x3A, 0x39, 0xDF, 0x85,
0x0D, 0x0F, 0x50, 0x15, 0xA7, 0x3D, 0x68, 0x81,
0x7B, 0x0D, 0xF2, 0x24, 0x24, 0x23, 0x37, 0xE5,
0x77, 0xA6, 0x61, 0xBE, 0xFE, 0x4B, 0x3B, 0x8E,
0x4F, 0x15, 0x4F, 0xC1, 0x30, 0xCB, 0x9E, 0xF5,
0x06, 0x9F, 0xBB, 0x0E, 0xF2, 0xF4, 0x43, 0xBB,
0x64, 0x45, 0xA3, 0x7D, 0x3B, 0xB4, 0x70, 0x47,
0xDF, 0x4A, 0xA5, 0xD9, 0x2F, 0xE6, 0x25, 0xC8,
0x1D, 0x43, 0x0A, 0xEA, 0xF9, 0xCC, 0xC7, 0x1F,
0x8A, 0x2D, 0xD8, 0x95, 0x6B, 0x16, 0x30, 0x1D,
0x80, 0x90, 0xA4, 0x23, 0x14, 0x59, 0xD1, 0x5A,
0x00, 0x48, 0x8D, 0xF7, 0xEA, 0x29, 0x23, 0xDF,
0x35, 0x26, 0x25, 0x22, 0x12, 0xC4, 0x4C, 0x09,
0x69, 0xB8, 0xD6, 0x0C, 0x0E, 0x71, 0x90, 0x6C,
0x42, 0x90, 0x02, 0x53, 0xC5, 0x5A, 0xEF, 0x42,
0x66, 0x1D, 0xAF, 0x45, 0xD5, 0x31, 0xD7, 0x61,
0x3A, 0xE6, 0x06, 0xFB, 0x83, 0x72, 0xAD, 0x82,
0xE3, 0x6A, 0x7E, 0x03, 0x9B, 0x37, 0x77, 0xAF,
0x8D, 0x63, 0x28, 0xC2, 0x8A, 0x5E, 0xC6, 0x3B,
0x22, 0xA8, 0x94, 0xC0, 0x46, 0x2F, 0x73, 0xE7,
0xBB, 0x72, 0x44, 0x85, 0x20, 0x1D, 0xD0, 0x6A,
0x52, 0x8C, 0xB1, 0x8B, 0x96, 0x11, 0xEB, 0xFB,
0xDD, 0xF5, 0x74, 0x49, 0x19, 0x93, 0xD3, 0x7F,
0x6C, 0x27, 0x19, 0x54, 0xDD, 0x00, 0x0F, 0x95,
0xF6, 0x14, 0x15, 0x87, 0x32, 0x54, 0xA5, 0x02,
0xAD, 0x41, 0x55, 0x5E, 0xDD, 0x32, 0x62, 0x3B,
0xFC, 0x71, 0xC1, 0x56, 0xC4, 0x6A, 0xFC, 0xD0,
0xF9, 0x77, 0xDA, 0xC5, 0x20, 0x7D, 0xAC, 0xA8,
0xEB, 0x8F, 0xBE, 0xF9, 0x4D, 0xE8, 0x6D, 0x9E,
0x4C, 0x39, 0xB3, 0x15, 0x63, 0xCD, 0xF6, 0x46,
0xEC, 0x3A, 0xD2, 0x89, 0xA9, 0xFA, 0x24, 0xB4,
0x0E, 0x62, 0x6F, 0x9F, 0xF3, 0xF1, 0x3C, 0x61,
0x57, 0xB9, 0x2C, 0xD4, 0x78, 0x4F, 0x76, 0xCF,
0xFB, 0x6A, 0x51, 0xE8, 0x1E, 0x0A, 0x33, 0x69,
0x16, 0xCD, 0xB7, 0x5C, 0xDF, 0x03, 0x62, 0x17,
0x63, 0x37, 0x49, 0xC3, 0xB7, 0x68, 0x09, 0x9E,
0x22, 0xD2, 0x20, 0x96, 0x37, 0x0D, 0x13, 0xA4,
0x96, 0xB1, 0x8D, 0x0B, 0x12, 0x87, 0xEB, 0x57,
0x25, 0x27, 0x08, 0xFC, 0x90, 0x5E, 0x33, 0x77,
0x50, 0x63, 0xE1, 0x8C, 0xF4, 0x0C, 0x80, 0x89,
0x76, 0x63, 0x70, 0x0A, 0x61, 0x59, 0x90, 0x1F,
0xC9, 0x47, 0xBA, 0x12, 0x7B, 0xB2, 0x7A, 0x44,
0xC3, 0x3D, 0xD0, 0x38, 0xF1, 0x7F, 0x02, 0x92
};
static unsigned char label[] = {
0xA5, 0xDE, 0x2A, 0x0A, 0xF0, 0xDA, 0x59, 0x04,
0xCC, 0xFF, 0x50, 0xD3, 0xA5, 0xD2, 0xDE, 0xA3,
0x33, 0xC0, 0x27, 0xED, 0xDC, 0x6A, 0x54, 0x54,
0x95, 0x78, 0x74, 0x0D, 0xE7, 0xB7, 0x92, 0xD6,
0x64, 0xD5, 0xFB, 0x1F, 0x0F, 0x87, 0xFD, 0x65,
0x79, 0x8B, 0x81, 0x83, 0x95, 0x40, 0x7A, 0x19,
0x8D, 0xCA, 0xE0, 0x4A, 0x93, 0xA8
};
static unsigned char output[] = {
0xB5, 0x61, 0xE3, 0x7D, 0x06, 0xD5, 0x34, 0x80,
0x74, 0x61, 0x16, 0x08, 0x6F, 0x89, 0x6F, 0xB1,
0x43, 0xAF, 0x61, 0x28, 0x93, 0xD8, 0xDF, 0xF6,
0xB6, 0x23, 0x43, 0x68, 0xE4, 0x84, 0xF3, 0xED,
0x50, 0xB6, 0x81, 0x6D, 0x50, 0xF4, 0xAF, 0xF2,
0xA5, 0x50, 0x7E, 0x25, 0xBF, 0x05, 0xBE, 0xE7,
0x07, 0xB0, 0x95, 0xC3, 0x04, 0x38, 0xB4, 0xF9,
0xC1, 0x1E, 0x96, 0x08, 0xF4, 0xC9, 0x05, 0x54,
0x4A, 0xB6, 0x81, 0x92, 0x5B, 0x34, 0x8A, 0x45,
0xDD, 0x7D, 0x98, 0x51, 0x1F, 0xD9, 0x90, 0x23,
0x59, 0x97, 0xA2, 0x4E, 0x43, 0x49, 0xEB, 0x4E,
0x86, 0xEC, 0x20, 0x3C, 0x31, 0xFF, 0x49, 0x55,
0x49, 0xF5, 0xF5, 0x16, 0x79, 0xD9, 0x1C, 0x8E,
0x6E, 0xB3, 0x1C, 0xAF, 0xC8, 0xAB, 0x3A, 0x5A,
0xCE, 0xB1, 0xBD, 0x59, 0x69, 0xEE, 0xC0, 0x28,
0x3E, 0x94, 0xD2, 0xCC, 0x91, 0x93, 0x73, 0x6A,
0xD6, 0xB6, 0xC1, 0x42, 0x97, 0xB1, 0x13, 0xCF,
0xF9, 0x55, 0x35, 0x50, 0xFC, 0x86, 0x75, 0x98,
0x9F, 0xFC, 0x96, 0xB1, 0x43, 0x41, 0x8F, 0xFC,
0x31, 0x09, 0x3B, 0x35, 0x22, 0x7B, 0x01, 0x96,
0xA7, 0xF0, 0x78, 0x7B, 0x57, 0x00, 0xF2, 0xE5,
0x92, 0x36, 0xCE, 0x64, 0xFD, 0x65, 0x09, 0xD8,
0xBC, 0x5C, 0x82, 0x5C, 0x4C, 0x62, 0x5B, 0xCE,
0x09, 0xB6, 0xCF, 0x4D, 0xAD, 0x8E, 0xDD, 0x96,
0xB0, 0xCA, 0x52, 0xC1, 0xF4, 0x17, 0x0E, 0x2D,
0x4E, 0xC3, 0xF9, 0x89, 0x1A, 0x24, 0x3D, 0x01,
0xC8, 0x05, 0xBF, 0x7D, 0x2A, 0x46, 0xCD, 0x9A,
0x66, 0xEE, 0x05, 0x78, 0x88, 0x2A, 0xEF, 0x37,
0x9E, 0x72, 0x55, 0xDA, 0x82, 0x7A, 0x9B, 0xE8,
0xF7, 0xA6, 0x74, 0xB8, 0x74, 0x39, 0x03, 0xE8,
0xB9, 0x1F, 0x97, 0x78, 0xB9, 0xD9, 0x37, 0x16,
0xFD, 0x2F, 0x31, 0xDE, 0xCC, 0x06, 0xD6, 0x5A,
0xEB, 0xD1, 0xBB, 0x84, 0x30, 0x16, 0x81, 0xB0,
0x7E, 0x04, 0x8C, 0x06, 0x67, 0xD1, 0x8A, 0x07,
0x33, 0x76, 0x42, 0x8E, 0x87, 0xAB, 0x90, 0x6F,
0x08, 0xED, 0x8D, 0xE8, 0xD0, 0x20, 0x00, 0x7E,
0x3C, 0x4D, 0xA4, 0x40, 0x37, 0x13, 0x0F, 0x00,
0x0C, 0xB7, 0x26, 0x03, 0x93, 0xD0, 0xBB, 0x08,
0xD3, 0xCC, 0xA9, 0x28, 0xC2
};
unsigned char result[sizeof(output)] = { 0 };
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC, mac, 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
input_key, sizeof(input_key));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
context, sizeof(context));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
label, sizeof(label));
*p = OSSL_PARAM_construct_end();
kctx = get_kdfbyname("KBKDF");
ret = TEST_ptr(kctx)
&& TEST_size_t_eq(EVP_KDF_CTX_get_kdf_size(kctx), SIZE_MAX)
&& TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result), params), 0)
&& TEST_mem_eq(result, sizeof(result), output, sizeof(output));
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdf_ss_hmac(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[6], *p = params;
unsigned char out[16];
static unsigned char z[] = {
0xb7,0x4a,0x14,0x9a,0x16,0x15,0x46,0xf8,0xc2,0x0b,0x06,0xac,0x4e,0xd4
};
static unsigned char other[] = {
0x34,0x8a,0x37,0xa2,0x7e,0xf1,0x28,0x2f,0x5f,0x02,0x0d,0xcc
};
static unsigned char salt[] = {
0x36,0x38,0x27,0x1c,0xcd,0x68,0xa2,0x5d,0xc2,0x4e,0xcd,0xdd,0x39,0xef,
0x3f,0x89
};
static const unsigned char expected[sizeof(out)] = {
0x44,0xf6,0x76,0xe8,0x5c,0x1b,0x1a,0x8b,0xbc,0x3d,0x31,0x92,0x18,0x63,
0x1c,0xa3
};
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC,
(char *)OSSL_MAC_NAME_HMAC, 0);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
(char *)"sha256", 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, z, sizeof(z));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, other,
sizeof(other));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT, salt,
sizeof(salt));
*p = OSSL_PARAM_construct_end();
ret =
TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_SSKDF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdf_ss_kmac(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[7], *p = params;
unsigned char out[64];
size_t mac_size = 20;
static unsigned char z[] = {
0xb7,0x4a,0x14,0x9a,0x16,0x15,0x46,0xf8,0xc2,0x0b,0x06,0xac,0x4e,0xd4
};
static unsigned char other[] = {
0x34,0x8a,0x37,0xa2,0x7e,0xf1,0x28,0x2f,0x5f,0x02,0x0d,0xcc
};
static unsigned char salt[] = {
0x36,0x38,0x27,0x1c,0xcd,0x68,0xa2,0x5d,0xc2,0x4e,0xcd,0xdd,0x39,0xef,
0x3f,0x89
};
static const unsigned char expected[sizeof(out)] = {
0xe9,0xc1,0x84,0x53,0xa0,0x62,0xb5,0x3b,0xdb,0xfc,0xbb,0x5a,0x34,0xbd,
0xb8,0xe5,0xe7,0x07,0xee,0xbb,0x5d,0xd1,0x34,0x42,0x43,0xd8,0xcf,0xc2,
0xc2,0xe6,0x33,0x2f,0x91,0xbd,0xa5,0x86,0xf3,0x7d,0xe4,0x8a,0x65,0xd4,
0xc5,0x14,0xfd,0xef,0xaa,0x1e,0x67,0x54,0xf3,0x73,0xd2,0x38,0xe1,0x95,
0xae,0x15,0x7e,0x1d,0xe8,0x14,0x98,0x03
};
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC,
(char *)OSSL_MAC_NAME_KMAC128, 0);
/* The digest parameter is not needed here and should be ignored */
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
(char *)"SHA256", 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, z, sizeof(z));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, other,
sizeof(other));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT, salt,
sizeof(salt));
*p++ = OSSL_PARAM_construct_size_t(OSSL_KDF_PARAM_MAC_SIZE, &mac_size);
*p = OSSL_PARAM_construct_end();
ret =
TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_SSKDF))
&& TEST_size_t_eq(EVP_KDF_CTX_get_kdf_size(kctx), 0)
&& TEST_int_eq(EVP_KDF_CTX_set_params(kctx, params), 1)
/* The bug fix for KMAC returning SIZE_MAX was added in 3.0.8 */
&& (fips_provider_version_lt(NULL, 3, 0, 8)
|| TEST_size_t_eq(EVP_KDF_CTX_get_kdf_size(kctx), SIZE_MAX))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdf_sshkdf(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[6], *p = params;
char kdftype = EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV;
unsigned char out[8];
/* Test data from NIST CAVS 14.1 test vectors */
static unsigned char key[] = {
0x00, 0x00, 0x00, 0x81, 0x00, 0x87, 0x5c, 0x55, 0x1c, 0xef, 0x52, 0x6a,
0x4a, 0x8b, 0xe1, 0xa7, 0xdf, 0x27, 0xe9, 0xed, 0x35, 0x4b, 0xac, 0x9a,
0xfb, 0x71, 0xf5, 0x3d, 0xba, 0xe9, 0x05, 0x67, 0x9d, 0x14, 0xf9, 0xfa,
0xf2, 0x46, 0x9c, 0x53, 0x45, 0x7c, 0xf8, 0x0a, 0x36, 0x6b, 0xe2, 0x78,
0x96, 0x5b, 0xa6, 0x25, 0x52, 0x76, 0xca, 0x2d, 0x9f, 0x4a, 0x97, 0xd2,
0x71, 0xf7, 0x1e, 0x50, 0xd8, 0xa9, 0xec, 0x46, 0x25, 0x3a, 0x6a, 0x90,
0x6a, 0xc2, 0xc5, 0xe4, 0xf4, 0x8b, 0x27, 0xa6, 0x3c, 0xe0, 0x8d, 0x80,
0x39, 0x0a, 0x49, 0x2a, 0xa4, 0x3b, 0xad, 0x9d, 0x88, 0x2c, 0xca, 0xc2,
0x3d, 0xac, 0x88, 0xbc, 0xad, 0xa4, 0xb4, 0xd4, 0x26, 0xa3, 0x62, 0x08,
0x3d, 0xab, 0x65, 0x69, 0xc5, 0x4c, 0x22, 0x4d, 0xd2, 0xd8, 0x76, 0x43,
0xaa, 0x22, 0x76, 0x93, 0xe1, 0x41, 0xad, 0x16, 0x30, 0xce, 0x13, 0x14,
0x4e
};
static unsigned char xcghash[] = {
0x0e, 0x68, 0x3f, 0xc8, 0xa9, 0xed, 0x7c, 0x2f, 0xf0, 0x2d, 0xef, 0x23,
0xb2, 0x74, 0x5e, 0xbc, 0x99, 0xb2, 0x67, 0xda, 0xa8, 0x6a, 0x4a, 0xa7,
0x69, 0x72, 0x39, 0x08, 0x82, 0x53, 0xf6, 0x42
};
static unsigned char sessid[] = {
0x0e, 0x68, 0x3f, 0xc8, 0xa9, 0xed, 0x7c, 0x2f, 0xf0, 0x2d, 0xef, 0x23,
0xb2, 0x74, 0x5e, 0xbc, 0x99, 0xb2, 0x67, 0xda, 0xa8, 0x6a, 0x4a, 0xa7,
0x69, 0x72, 0x39, 0x08, 0x82, 0x53, 0xf6, 0x42
};
static const unsigned char expected[sizeof(out)] = {
0x41, 0xff, 0x2e, 0xad, 0x16, 0x83, 0xf1, 0xe6
};
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
(char *)"sha256", 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, key,
sizeof(key));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SSHKDF_XCGHASH,
xcghash, sizeof(xcghash));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SSHKDF_SESSION_ID,
sessid, sizeof(sessid));
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_SSHKDF_TYPE,
&kdftype, sizeof(kdftype));
*p = OSSL_PARAM_construct_end();
ret =
TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_SSHKDF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdfs_same(EVP_KDF *kdf1, EVP_KDF *kdf2)
{
/* Fast path in case the two are the same algorithm pointer */
if (kdf1 == kdf2)
return 1;
/*
* Compare their names and providers instead.
* This is necessary in a non-caching build (or a cache flush during fetch)
* because without the algorithm in the cache, fetching it a second time
* will result in a different pointer.
*/
return TEST_ptr_eq(EVP_KDF_get0_provider(kdf1), EVP_KDF_get0_provider(kdf2))
&& TEST_str_eq(EVP_KDF_get0_name(kdf1), EVP_KDF_get0_name(kdf2));
}
static int test_kdf_get_kdf(void)
{
EVP_KDF *kdf1 = NULL, *kdf2 = NULL;
ASN1_OBJECT *obj;
int ok = 1;
if (!TEST_ptr(obj = OBJ_nid2obj(NID_id_pbkdf2))
|| !TEST_ptr(kdf1 = EVP_KDF_fetch(NULL, OSSL_KDF_NAME_PBKDF2, NULL))
|| !TEST_ptr(kdf2 = EVP_KDF_fetch(NULL, OBJ_nid2sn(OBJ_obj2nid(obj)),
NULL))
|| !test_kdfs_same(kdf1, kdf2))
ok = 0;
EVP_KDF_free(kdf1);
kdf1 = NULL;
EVP_KDF_free(kdf2);
kdf2 = NULL;
if (!TEST_ptr(kdf1 = EVP_KDF_fetch(NULL, SN_tls1_prf, NULL))
|| !TEST_ptr(kdf2 = EVP_KDF_fetch(NULL, LN_tls1_prf, NULL))
|| !test_kdfs_same(kdf1, kdf2))
ok = 0;
/* kdf1 is re-used below, so don't free it here */
EVP_KDF_free(kdf2);
kdf2 = NULL;
if (!TEST_ptr(kdf2 = EVP_KDF_fetch(NULL, OBJ_nid2sn(NID_tls1_prf), NULL))
|| !test_kdfs_same(kdf1, kdf2))
ok = 0;
EVP_KDF_free(kdf1);
kdf1 = NULL;
EVP_KDF_free(kdf2);
kdf2 = NULL;
return ok;
}
#if !defined(OPENSSL_NO_CMS) && !defined(OPENSSL_NO_DES)
static int test_kdf_x942_asn1(void)
{
int ret;
EVP_KDF_CTX *kctx = NULL;
OSSL_PARAM params[4], *p = params;
const char *cek_alg = SN_id_smime_alg_CMS3DESwrap;
unsigned char out[24];
/* RFC2631 Section 2.1.6 Test data */
static unsigned char z[] = {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,
0x0e,0x0f,0x10,0x11,0x12,0x13
};
static const unsigned char expected[sizeof(out)] = {
0xa0,0x96,0x61,0x39,0x23,0x76,0xf7,0x04,
0x4d,0x90,0x52,0xa3,0x97,0x88,0x32,0x46,
0xb6,0x7f,0x5f,0x1e,0xf6,0x3e,0xb5,0xfb
};
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
(char *)"sha1", 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, z,
sizeof(z));
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_CEK_ALG,
(char *)cek_alg, 0);
*p = OSSL_PARAM_construct_end();
ret =
TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_X942KDF_ASN1))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
return ret;
}
#endif /* OPENSSL_NO_CMS */
static int test_kdf_krb5kdf(void)
{
int ret;
EVP_KDF_CTX *kctx;
OSSL_PARAM params[4], *p = params;
unsigned char out[16];
static unsigned char key[] = {
0x42, 0x26, 0x3C, 0x6E, 0x89, 0xF4, 0xFC, 0x28,
0xB8, 0xDF, 0x68, 0xEE, 0x09, 0x79, 0x9F, 0x15
};
static unsigned char constant[] = {
0x00, 0x00, 0x00, 0x02, 0x99
};
static const unsigned char expected[sizeof(out)] = {
0x34, 0x28, 0x0A, 0x38, 0x2B, 0xC9, 0x27, 0x69,
0xB2, 0xDA, 0x2F, 0x9E, 0xF0, 0x66, 0x85, 0x4B
};
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_CIPHER,
(char *)"AES-128-CBC", 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, key,
sizeof(key));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_CONSTANT,
constant, sizeof(constant));
*p = OSSL_PARAM_construct_end();
ret =
TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_KRB5KDF))
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), params), 0)
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdf_hmac_drbg_settables(void)
{
int ret = 0, i = 0, j = 0;
EVP_KDF_CTX *kctx = NULL;
const OSSL_PARAM *settableparams;
OSSL_PARAM params[5];
static const unsigned char ent[32] = { 0 };
unsigned char out[32];
char digestname[32];
char macname[32];
EVP_MD *shake256 = NULL;
/* Test there are settables */
if (!TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HMACDRBGKDF))
|| !TEST_ptr(settableparams = EVP_KDF_CTX_settable_params(kctx)))
goto err;
/* Fail if no params have been set when doing a derive */
if (!TEST_int_le(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0))
goto err;
/* Fail if we pass the wrong type for params */
params[1] = OSSL_PARAM_construct_end();
for (i = 0; settableparams[i].key != NULL; ++i) {
/* Skip "properties" key since it returns 1 unless the digest is also set */
if (OPENSSL_strcasecmp(settableparams[i].key,
OSSL_KDF_PARAM_PROPERTIES) != 0) {
TEST_note("Testing set int into %s fails", settableparams[i].key);
params[0] = OSSL_PARAM_construct_int(settableparams[i].key, &j);
if (!TEST_int_le(EVP_KDF_CTX_set_params(kctx, params), 0))
goto err;
}
}
/* Test that we can set values multiple times */
params[0] = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_HMACDRBG_ENTROPY,
(char *)ent, sizeof(ent));
params[1] = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_HMACDRBG_NONCE,
(char *)ent, sizeof(ent));
params[2] = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_DIGEST, "SHA256",
0);
params[3] = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_PROPERTIES, "",
0);
params[4] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_KDF_CTX_set_params(kctx, params), 1))
goto err;
if (!TEST_int_eq(EVP_KDF_CTX_set_params(kctx, params), 1))
goto err;
/* Test we can retrieve values back */
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_DIGEST,
digestname, sizeof(digestname));
params[1] = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_MAC,
macname, sizeof(macname));
params[2] = OSSL_PARAM_construct_end();
if (!TEST_int_eq(EVP_KDF_CTX_get_params(kctx, params), 1)
|| !TEST_mem_eq(digestname, params[0].return_size, "SHA2-256", 8)
|| !TEST_mem_eq(macname, params[1].return_size, "HMAC", 4))
goto err;
/* Test the derive */
if (!TEST_int_eq(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 1))
goto err;
/* test that XOF digests are not allowed */
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_DIGEST,
"shake256", 0);
params[1] = OSSL_PARAM_construct_end();
if (!TEST_int_le(EVP_KDF_CTX_set_params(kctx, params), 0))
goto err;
ret = 1;
err:
EVP_MD_free(shake256);
EVP_KDF_CTX_free(kctx);
return ret;
}
static int test_kdf_hmac_drbg_gettables(void)
{
int ret = 0, i, j = 0;
EVP_KDF_CTX *kctx = NULL;
const OSSL_PARAM *gettableparams;
OSSL_PARAM params[3];
char buf[64];
/* Test there are gettables */
if (!TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_HMACDRBGKDF))
|| !TEST_ptr(gettableparams = EVP_KDF_CTX_gettable_params(kctx)))
goto err;
/* Fail if we pass the wrong type for params */
params[1] = OSSL_PARAM_construct_end();
for (i = 0; gettableparams[i].key != NULL; ++i) {
params[0] = OSSL_PARAM_construct_int(gettableparams[i].key, &j);
if (!TEST_int_le(EVP_KDF_CTX_get_params(kctx, params), 0))
goto err;
}
/* fail to get params if they are not set yet */
for (i = 0; gettableparams[i].key != NULL; ++i) {
params[0] = OSSL_PARAM_construct_utf8_string(gettableparams[i].key,
buf, sizeof(buf));
if (!TEST_int_le(EVP_KDF_CTX_get_params(kctx, params), 0))
goto err;
}
ret = 1;
err:
EVP_KDF_CTX_free(kctx);
return ret;
}
int setup_tests(void)
{
ADD_TEST(test_kdf_pbkdf1);
ADD_TEST(test_kdf_pbkdf1_key_too_long);
#if !defined(OPENSSL_NO_CMAC) && !defined(OPENSSL_NO_CAMELLIA)
ADD_TEST(test_kdf_kbkdf_6803_128);
ADD_TEST(test_kdf_kbkdf_6803_256);
#endif
ADD_TEST(test_kdf_kbkdf_invalid_digest);
ADD_TEST(test_kdf_kbkdf_invalid_mac);
ADD_TEST(test_kdf_kbkdf_invalid_r);
ADD_TEST(test_kdf_kbkdf_zero_output_size);
ADD_TEST(test_kdf_kbkdf_empty_key);
ADD_TEST(test_kdf_kbkdf_1byte_key);
ADD_TEST(test_kdf_kbkdf_8009_prf1);
ADD_TEST(test_kdf_kbkdf_8009_prf2);
#if !defined(OPENSSL_NO_CMAC)
ADD_TEST(test_kdf_kbkdf_fixedinfo);
#endif
if (fips_provider_version_ge(NULL, 3, 1, 0))
ADD_TEST(test_kdf_kbkdf_kmac);
ADD_TEST(test_kdf_get_kdf);
ADD_TEST(test_kdf_tls1_prf);
ADD_TEST(test_kdf_tls1_prf_invalid_digest);
ADD_TEST(test_kdf_tls1_prf_zero_output_size);
ADD_TEST(test_kdf_tls1_prf_empty_secret);
ADD_TEST(test_kdf_tls1_prf_1byte_secret);
ADD_TEST(test_kdf_tls1_prf_empty_seed);
ADD_TEST(test_kdf_tls1_prf_1byte_seed);
ADD_TEST(test_kdf_hkdf);
ADD_TEST(test_kdf_hkdf_invalid_digest);
ADD_TEST(test_kdf_hkdf_zero_output_size);
ADD_TEST(test_kdf_hkdf_empty_key);
ADD_TEST(test_kdf_hkdf_1byte_key);
ADD_TEST(test_kdf_hkdf_empty_salt);
ADD_TEST(test_kdf_hkdf_gettables);
ADD_TEST(test_kdf_hkdf_gettables_expandonly);
ADD_TEST(test_kdf_hkdf_gettables_no_digest);
ADD_TEST(test_kdf_hkdf_derive_set_params_fail);
ADD_TEST(test_kdf_hkdf_set_invalid_mode);
ADD_TEST(test_kdf_hkdf_set_ctx_param_fail);
ADD_TEST(test_kdf_pbkdf2);
ADD_TEST(test_kdf_pbkdf2_small_output);
ADD_TEST(test_kdf_pbkdf2_large_output);
ADD_TEST(test_kdf_pbkdf2_small_salt);
ADD_TEST(test_kdf_pbkdf2_small_iterations);
ADD_TEST(test_kdf_pbkdf2_small_salt_pkcs5);
ADD_TEST(test_kdf_pbkdf2_small_iterations_pkcs5);
ADD_TEST(test_kdf_pbkdf2_invalid_digest);
#ifndef OPENSSL_NO_SCRYPT
ADD_TEST(test_kdf_scrypt);
#endif
ADD_TEST(test_kdf_ss_hash);
ADD_TEST(test_kdf_ss_hmac);
ADD_TEST(test_kdf_ss_kmac);
ADD_TEST(test_kdf_sshkdf);
ADD_TEST(test_kdf_x963);
#if !defined(OPENSSL_NO_CMS) && !defined(OPENSSL_NO_DES)
ADD_TEST(test_kdf_x942_asn1);
#endif
ADD_TEST(test_kdf_krb5kdf);
ADD_TEST(test_kdf_hmac_drbg_settables);
ADD_TEST(test_kdf_hmac_drbg_gettables);
return 1;
}
|
./openssl/test/rsa_test.c | /*
* Copyright 1999-2023 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
*/
/* test vectors from p1ovect1.txt */
/*
* RSA low level APIs are deprecated for public use, but still ok for
* internal use.
*/
#include "internal/deprecated.h"
#include <stdio.h>
#include <string.h>
#include "internal/nelem.h"
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/bn.h>
#include "testutil.h"
#include <openssl/rsa.h>
#define SetKey \
RSA_set0_key(key, \
BN_bin2bn(n, sizeof(n)-1, NULL), \
BN_bin2bn(e, sizeof(e)-1, NULL), \
BN_bin2bn(d, sizeof(d)-1, NULL)); \
RSA_set0_factors(key, \
BN_bin2bn(p, sizeof(p)-1, NULL), \
BN_bin2bn(q, sizeof(q)-1, NULL)); \
RSA_set0_crt_params(key, \
BN_bin2bn(dmp1, sizeof(dmp1)-1, NULL), \
BN_bin2bn(dmq1, sizeof(dmq1)-1, NULL), \
BN_bin2bn(iqmp, sizeof(iqmp)-1, NULL)); \
if (c != NULL) \
memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
return sizeof(ctext_ex) - 1;
static int key1(RSA *key, unsigned char *c)
{
static unsigned char n[] =
"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"
"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"
"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"
"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"
"\xF5";
static unsigned char e[] = "\x11";
static unsigned char d[] =
"\x0A\x03\x37\x48\x62\x64\x87\x69\x5F\x5F\x30\xBC\x38\xB9\x8B\x44"
"\xC2\xCD\x2D\xFF\x43\x40\x98\xCD\x20\xD8\xA1\x38\xD0\x90\xBF\x64"
"\x79\x7C\x3F\xA7\xA2\xCD\xCB\x3C\xD1\xE0\xBD\xBA\x26\x54\xB4\xF9"
"\xDF\x8E\x8A\xE5\x9D\x73\x3D\x9F\x33\xB3\x01\x62\x4A\xFD\x1D\x51";
static unsigned char p[] =
"\x00\xD8\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x12"
"\x0D";
static unsigned char q[] =
"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
"\x89";
static unsigned char dmp1[] =
"\x59\x0B\x95\x72\xA2\xC2\xA9\xC4\x06\x05\x9D\xC2\xAB\x2F\x1D\xAF"
"\xEB\x7E\x8B\x4F\x10\xA7\x54\x9E\x8E\xED\xF5\xB4\xFC\xE0\x9E\x05";
static unsigned char dmq1[] =
"\x00\x8E\x3C\x05\x21\xFE\x15\xE0\xEA\x06\xA3\x6F\xF0\xF1\x0C\x99"
"\x52\xC3\x5B\x7A\x75\x14\xFD\x32\x38\xB8\x0A\xAD\x52\x98\x62\x8D"
"\x51";
static unsigned char iqmp[] =
"\x36\x3F\xF7\x18\x9D\xA8\xE9\x0B\x1D\x34\x1F\x71\xD0\x9B\x76\xA8"
"\xA9\x43\xE1\x1D\x10\xB2\x4D\x24\x9F\x2D\xEA\xFE\xF8\x0C\x18\x26";
static unsigned char ctext_ex[] =
"\x1b\x8f\x05\xf9\xca\x1a\x79\x52\x6e\x53\xf3\xcc\x51\x4f\xdb\x89"
"\x2b\xfb\x91\x93\x23\x1e\x78\xb9\x92\xe6\x8d\x50\xa4\x80\xcb\x52"
"\x33\x89\x5c\x74\x95\x8d\x5d\x02\xab\x8c\x0f\xd0\x40\xeb\x58\x44"
"\xb0\x05\xc3\x9e\xd8\x27\x4a\x9d\xbf\xa8\x06\x71\x40\x94\x39\xd2";
SetKey;
}
static int key2(RSA *key, unsigned char *c)
{
static unsigned char n[] =
"\x00\xA3\x07\x9A\x90\xDF\x0D\xFD\x72\xAC\x09\x0C\xCC\x2A\x78\xB8"
"\x74\x13\x13\x3E\x40\x75\x9C\x98\xFA\xF8\x20\x4F\x35\x8A\x0B\x26"
"\x3C\x67\x70\xE7\x83\xA9\x3B\x69\x71\xB7\x37\x79\xD2\x71\x7B\xE8"
"\x34\x77\xCF";
static unsigned char e[] = "\x3";
static unsigned char d[] =
"\x6C\xAF\xBC\x60\x94\xB3\xFE\x4C\x72\xB0\xB3\x32\xC6\xFB\x25\xA2"
"\xB7\x62\x29\x80\x4E\x68\x65\xFC\xA4\x5A\x74\xDF\x0F\x8F\xB8\x41"
"\x3B\x52\xC0\xD0\xE5\x3D\x9B\x59\x0F\xF1\x9B\xE7\x9F\x49\xDD\x21"
"\xE5\xEB";
static unsigned char p[] =
"\x00\xCF\x20\x35\x02\x8B\x9D\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92"
"\xEA\x0D\xA3\xB4\x32\x04\xB5\xCF\xCE\x91";
static unsigned char q[] =
"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5F";
static unsigned char dmp1[] =
"\x00\x8A\x15\x78\xAC\x5D\x13\xAF\x10\x2B\x22\xB9\x99\xCD\x74\x61"
"\xF1\x5E\x6D\x22\xCC\x03\x23\xDF\xDF\x0B";
static unsigned char dmq1[] =
"\x00\x86\x55\x21\x4A\xC5\x4D\x8D\x4E\xCD\x61\x77\xF1\xC7\x36\x90"
"\xCE\x2A\x48\x2C\x8B\x05\x99\xCB\xE0\x3F";
static unsigned char iqmp[] =
"\x00\x83\xEF\xEF\xB8\xA9\xA4\x0D\x1D\xB6\xED\x98\xAD\x84\xED\x13"
"\x35\xDC\xC1\x08\xF3\x22\xD0\x57\xCF\x8D";
static unsigned char ctext_ex[] =
"\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a"
"\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4"
"\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52"
"\x62\x51";
SetKey;
}
static int key3(RSA *key, unsigned char *c)
{
static unsigned char n[] =
"\x00\xBB\xF8\x2F\x09\x06\x82\xCE\x9C\x23\x38\xAC\x2B\x9D\xA8\x71"
"\xF7\x36\x8D\x07\xEE\xD4\x10\x43\xA4\x40\xD6\xB6\xF0\x74\x54\xF5"
"\x1F\xB8\xDF\xBA\xAF\x03\x5C\x02\xAB\x61\xEA\x48\xCE\xEB\x6F\xCD"
"\x48\x76\xED\x52\x0D\x60\xE1\xEC\x46\x19\x71\x9D\x8A\x5B\x8B\x80"
"\x7F\xAF\xB8\xE0\xA3\xDF\xC7\x37\x72\x3E\xE6\xB4\xB7\xD9\x3A\x25"
"\x84\xEE\x6A\x64\x9D\x06\x09\x53\x74\x88\x34\xB2\x45\x45\x98\x39"
"\x4E\xE0\xAA\xB1\x2D\x7B\x61\xA5\x1F\x52\x7A\x9A\x41\xF6\xC1\x68"
"\x7F\xE2\x53\x72\x98\xCA\x2A\x8F\x59\x46\xF8\xE5\xFD\x09\x1D\xBD"
"\xCB";
static unsigned char e[] = "\x11";
static unsigned char d[] =
"\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD"
"\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41"
"\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69"
"\xD6\x87\x0D\xA2\xC0\x82\xA9\x39\xE3\x7F\xDC\xB8\x2E\xC9\x3E\xDA"
"\xC9\x7F\xF3\xAD\x59\x50\xAC\xCF\xBC\x11\x1C\x76\xF1\xA9\x52\x94"
"\x44\xE5\x6A\xAF\x68\xC5\x6C\x09\x2C\xD3\x8D\xC3\xBE\xF5\xD2\x0A"
"\x93\x99\x26\xED\x4F\x74\xA1\x3E\xDD\xFB\xE1\xA1\xCE\xCC\x48\x94"
"\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3"
"\xC1";
static unsigned char p[] =
"\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60"
"\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6"
"\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A"
"\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65"
"\x99";
static unsigned char q[] =
"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
"\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15"
"\x03";
static unsigned char dmp1[] =
"\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A"
"\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E"
"\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E"
"\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81";
static unsigned char dmq1[] =
"\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9"
"\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7"
"\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D"
"\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D";
static unsigned char iqmp[] =
"\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23"
"\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11"
"\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E"
"\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39"
"\xF7";
static unsigned char ctext_ex[] =
"\xb8\x24\x6b\x56\xa6\xed\x58\x81\xae\xb5\x85\xd9\xa2\x5b\x2a\xd7"
"\x90\xc4\x17\xe0\x80\x68\x1b\xf1\xac\x2b\xc3\xde\xb6\x9d\x8b\xce"
"\xf0\xc4\x36\x6f\xec\x40\x0a\xf0\x52\xa7\x2e\x9b\x0e\xff\xb5\xb3"
"\xf2\xf1\x92\xdb\xea\xca\x03\xc1\x27\x40\x05\x71\x13\xbf\x1f\x06"
"\x69\xac\x22\xe9\xf3\xa7\x85\x2e\x3c\x15\xd9\x13\xca\xb0\xb8\x86"
"\x3a\x95\xc9\x92\x94\xce\x86\x74\x21\x49\x54\x61\x03\x46\xf4\xd4"
"\x74\xb2\x6f\x7c\x48\xb4\x2e\xe6\x8e\x1f\x57\x2a\x1f\xc4\x02\x6a"
"\xc4\x56\xb4\xf5\x9f\x7b\x62\x1e\xa1\xb9\xd8\x8f\x64\x20\x2f\xb1";
SetKey;
}
static int rsa_setkey(RSA** key, unsigned char *ctext, int idx)
{
int clen = 0;
*key = RSA_new();
if (*key != NULL)
switch (idx) {
case 0:
clen = key1(*key, ctext);
break;
case 1:
clen = key2(*key, ctext);
break;
case 2:
clen = key3(*key, ctext);
break;
}
return clen;
}
static int test_rsa_simple(int idx, int en_pad_type, int de_pad_type,
int success, unsigned char *ctext_ex, int *clen,
RSA **retkey)
{
int ret = 0;
RSA *key;
unsigned char ptext[256];
unsigned char ctext[256];
static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
int plen;
int clentmp = 0;
int num;
plen = sizeof(ptext_ex) - 1;
clentmp = rsa_setkey(&key, ctext_ex, idx);
if (clen != NULL)
*clen = clentmp;
num = RSA_public_encrypt(plen, ptext_ex, ctext, key, en_pad_type);
if (!TEST_int_eq(num, clentmp))
goto err;
num = RSA_private_decrypt(num, ctext, ptext, key, de_pad_type);
if (success) {
if (!TEST_int_gt(num, 0) || !TEST_mem_eq(ptext, num, ptext_ex, plen))
goto err;
} else {
if (!TEST_int_lt(num, 0))
goto err;
}
ret = 1;
if (retkey != NULL) {
*retkey = key;
key = NULL;
}
err:
RSA_free(key);
return ret;
}
static int test_rsa_pkcs1(int idx)
{
return test_rsa_simple(idx, RSA_PKCS1_PADDING, RSA_PKCS1_PADDING, 1, NULL,
NULL, NULL);
}
static int test_rsa_oaep(int idx)
{
int ret = 0;
RSA *key = NULL;
unsigned char ptext[256];
static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
unsigned char ctext_ex[256];
int plen;
int clen = 0;
int num;
int n;
if (!test_rsa_simple(idx, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_OAEP_PADDING, 1,
ctext_ex, &clen, &key))
goto err;
plen = sizeof(ptext_ex) - 1;
/* Different ciphertexts. Try decrypting ctext_ex */
num = RSA_private_decrypt(clen, ctext_ex, ptext, key,
RSA_PKCS1_OAEP_PADDING);
if (num <= 0 || !TEST_mem_eq(ptext, num, ptext_ex, plen))
goto err;
/* Try decrypting corrupted ciphertexts. */
for (n = 0; n < clen; ++n) {
ctext_ex[n] ^= 1;
num = RSA_private_decrypt(clen, ctext_ex, ptext, key,
RSA_PKCS1_OAEP_PADDING);
if (!TEST_int_le(num, 0))
goto err;
ctext_ex[n] ^= 1;
}
/* Test truncated ciphertexts, as well as negative length. */
for (n = -1; n < clen; ++n) {
num = RSA_private_decrypt(n, ctext_ex, ptext, key,
RSA_PKCS1_OAEP_PADDING);
if (!TEST_int_le(num, 0))
goto err;
}
ret = 1;
err:
RSA_free(key);
return ret;
}
static const struct {
int bits;
unsigned int r;
} rsa_security_bits_cases[] = {
/* NIST SP 800-56B rev 2 (draft) Appendix D Table 5 */
{ 2048, 112 },
{ 3072, 128 },
{ 4096, 152 },
{ 6144, 176 },
{ 8192, 200 },
/* NIST FIPS 140-2 IG 7.5 */
{ 7680, 192 },
{ 15360, 256 },
/* Older values */
{ 256, 40 },
{ 512, 56 },
{ 1024, 80 },
/* Some other values */
{ 8888, 208 },
{ 2468, 120 },
{ 13456, 248 },
/* Edge points */
{ 15359, 256 },
{ 15361, 264 },
{ 7679, 192 },
{ 7681, 200 },
};
static int test_rsa_security_bit(int n)
{
static const unsigned char vals[8] = {
0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40
};
RSA *key = RSA_new();
const int bits = rsa_security_bits_cases[n].bits;
const int result = rsa_security_bits_cases[n].r;
const int bytes = (bits + 7) / 8;
int r = 0;
unsigned char num[2000];
if (!TEST_ptr(key) || !TEST_int_le(bytes, (int)sizeof(num)))
goto err;
/*
* It is necessary to set the RSA key in order to ask for the strength.
* A BN of an appropriate size is created, in general it won't have the
* properties necessary for RSA to function. This is okay here since
* the RSA key is never used.
*/
memset(num, vals[bits % 8], bytes);
/*
* The 'e' parameter is set to the same value as 'n'. This saves having
* an extra BN to hold a sensible value for 'e'. This is safe since the
* RSA key is not used. The 'd' parameter can be NULL safely.
*/
if (TEST_true(RSA_set0_key(key, BN_bin2bn(num, bytes, NULL),
BN_bin2bn(num, bytes, NULL), NULL))
&& TEST_uint_eq(RSA_security_bits(key), result))
r = 1;
err:
RSA_free(key);
return r;
}
static int test_EVP_rsa_legacy_key(void)
{
int ret;
size_t buflen = 384;
size_t msglen = 64;
unsigned char sigbuf[384];
unsigned char msgbuf[64];
BIGNUM *p;
BIGNUM *q;
BIGNUM *n;
BIGNUM *d;
BIGNUM *e;
RSA *rsa;
const EVP_MD *md;
EVP_MD_CTX *ctx = NULL;
EVP_PKEY *pkey = NULL;
unsigned char n_data[] = {
0x00, 0xc7, 0x28, 0x7a, 0x28, 0x91, 0x51, 0xa5, 0xe8, 0x3c, 0x45, 0xcf,
0x1d, 0xa9, 0x69, 0x7a, 0x0d, 0xdb, 0xdd, 0x8f, 0xe2, 0xde, 0x85, 0xdd,
0x85, 0x6d, 0x8f, 0x78, 0x20, 0xd6, 0xe, 0xe5, 0x06, 0xcb, 0x9c, 0xd6,
0xd3, 0xca, 0xef, 0x1d, 0x80, 0xd3, 0x18, 0x23, 0x91, 0x5c, 0xe5, 0xc8,
0x44, 0x37, 0x56, 0x1b, 0x68, 0x7f, 0x08, 0xa3, 0x1c, 0xf6, 0xe8, 0x11,
0x38, 0x0f, 0x2e, 0xad, 0xb1, 0x89, 0x8b, 0x08, 0xe8, 0x35, 0xaf, 0x3b,
0xfe, 0x37, 0x8d, 0x21, 0xd5, 0x3f, 0x1f, 0x4b, 0x01, 0x30, 0xd8, 0xd0,
0x24, 0xf7, 0xab, 0x57, 0xad, 0xac, 0xbc, 0x53, 0x6d, 0x84, 0x8e, 0xa1,
0xb2, 0x5b, 0x8e, 0xe7, 0xb3, 0xac, 0xfc, 0x60, 0x22, 0x10, 0x1e, 0x99,
0xfa, 0xa0, 0x60, 0x00, 0x69, 0x5f, 0x8e, 0xca, 0x6d, 0x9c, 0xee, 0x5e,
0x84, 0x4e, 0x53, 0x83, 0x42, 0x76, 0x4d, 0xb8, 0xc1, 0xeb, 0x4e, 0x3d,
0xc3, 0xce, 0xac, 0x79, 0xbb, 0x29, 0x5d, 0x92, 0x33, 0x6e, 0xcf, 0x8f,
0x5a, 0xf0, 0xb3, 0xb5, 0xdc, 0xd5, 0xa3, 0xaf, 0x40, 0x4b, 0x0f, 0x05,
0xac, 0x46, 0x53, 0x2d, 0x5f, 0x20, 0x96, 0x42, 0xa8, 0x47, 0x61, 0x54,
0x05, 0x2c, 0x8a, 0x26, 0x5d, 0x92, 0x1d, 0x01, 0x2a, 0x27, 0x8a, 0xfc,
0x64, 0x24, 0x5c, 0x34, 0xde, 0x92, 0xc6, 0x82, 0xea, 0x4d, 0xe2, 0x52,
0xe5, 0xad, 0x62, 0x00, 0xc6, 0xc8, 0xe9, 0x0c, 0x22, 0xf0, 0x9e, 0xbe,
0xdc, 0x51, 0x58, 0xad, 0x3b, 0xba, 0x2e, 0x45, 0x65, 0xcc, 0x5b, 0x55,
0x46, 0x67, 0x18, 0x4a, 0x80, 0x67, 0x5b, 0x84, 0x7f, 0x13, 0x37, 0x45,
0xd8, 0x03, 0xc6, 0x22, 0xc3, 0x4a, 0x46, 0x6b, 0xde, 0x50, 0xbf, 0x16,
0x0a, 0x23, 0x0b, 0xaa, 0x50, 0x54, 0xf6, 0x20, 0x83, 0x74, 0x33, 0x97,
0x2e, 0xf2, 0x8e, 0x7e, 0x13 };
unsigned char e_data[] = { 0x01, 0x00, 0x01 };
unsigned char d_data[] = {
0x09, 0x2d, 0xcb, 0xe7, 0x87, 0xbf, 0x10, 0x1a, 0xf2, 0x80, 0x33, 0x2a,
0x06, 0x4f, 0x56, 0xb1, 0x41, 0xd3, 0x65, 0xd8, 0xca, 0x71, 0xb8, 0x02,
0x78, 0xc8, 0xb6, 0x7c, 0x28, 0xf4, 0x6c, 0xe8, 0xd1, 0xc4, 0x92, 0x40,
0x23, 0xa7, 0xbe, 0x9f, 0xdb, 0xda, 0xce, 0x74, 0xda, 0x27, 0xbb, 0x01,
0xad, 0xdd, 0x39, 0x99, 0x28, 0xd5, 0xb0, 0x92, 0xda, 0xac, 0x5a, 0x72,
0xcf, 0x7c, 0x52, 0xc4, 0x0e, 0x77, 0x4a, 0x7b, 0x4d, 0x52, 0x1c, 0xbd,
0x3c, 0x39, 0x34, 0x78, 0x7c, 0x16, 0xc8, 0xa1, 0xae, 0xeb, 0x27, 0x38,
0xb4, 0xf3, 0x80, 0x30, 0x80, 0x78, 0x13, 0x8e, 0x46, 0x20, 0x3e, 0xc2,
0x96, 0x26, 0xb1, 0x76, 0x1e, 0x00, 0x69, 0xbb, 0xd8, 0x2b, 0x58, 0xe4,
0x6c, 0xb4, 0xd0, 0x00, 0x0b, 0x47, 0xec, 0xfb, 0x7d, 0x52, 0x9d, 0x27,
0x92, 0xe6, 0x95, 0x73, 0xa0, 0x39, 0x37, 0xcd, 0x1f, 0x60, 0x13, 0x1c,
0x87, 0x9d, 0xa7, 0x91, 0x90, 0xf9, 0x36, 0xc5, 0xfa, 0x3f, 0xf9, 0x7f,
0x50, 0xf8, 0xb3, 0x54, 0x65, 0xff, 0x6f, 0xa6, 0x22, 0xcc, 0x4a, 0x1e,
0x49, 0x3f, 0x07, 0xc6, 0xf2, 0x65, 0x73, 0x13, 0x1b, 0x2d, 0xb6, 0x15,
0xff, 0xcd, 0x9a, 0x1c, 0xea, 0xef, 0x58, 0x56, 0x91, 0x2d, 0x47, 0x81,
0x56, 0x0d, 0xc3, 0xb0, 0x47, 0x58, 0x8d, 0x05, 0x7d, 0x5b, 0xc0, 0x22,
0xa4, 0xf0, 0x2e, 0x70, 0x36, 0x01, 0x89, 0xa1, 0x71, 0xed, 0x76, 0xe9,
0x8d, 0xf5, 0x49, 0xaf, 0x11, 0xbe, 0xe4, 0xd4, 0x48, 0x92, 0xb6, 0x5b,
0xc2, 0x04, 0xd4, 0x0c, 0x5c, 0x8b, 0xe3, 0xfa, 0x29, 0x63, 0x86, 0xb4,
0x10, 0xad, 0x32, 0x07, 0x85, 0xe2, 0x43, 0x76, 0x16, 0x90, 0xab, 0xdf,
0xb3, 0x36, 0x0a, 0xc4, 0x49, 0x7b, 0x95, 0x48, 0x50, 0x72, 0x8f, 0x7d,
0xf4, 0xfa, 0x60, 0xc1 };
unsigned char p_data[] = {
0x00, 0xed, 0xf7, 0xa7, 0x00, 0x5a, 0xbb, 0xd1, 0x52, 0x65, 0x9b, 0xec,
0xfe, 0x27, 0x8b, 0xe2, 0xbe, 0x40, 0x8c, 0x2f, 0x6f, 0xb4, 0x26, 0xb2,
0xbe, 0x45, 0x4b, 0x3b, 0x5a, 0xaa, 0xc6, 0xaa, 0xfa, 0xc1, 0x3a, 0xa9,
0xa1, 0xba, 0xb7, 0x86, 0x1a, 0x98, 0x15, 0x5f, 0x5c, 0x1c, 0x57, 0x78,
0x78, 0x6a, 0x13, 0xc2, 0x40, 0x7d, 0x07, 0x87, 0x47, 0xc6, 0x96, 0xd5,
0x92, 0xc9, 0x65, 0x2c, 0xfe, 0xbb, 0xe0, 0xd6, 0x76, 0x25, 0x5a, 0xa3,
0xdf, 0x97, 0x4b, 0x64, 0xfd, 0x3b, 0x2b, 0xbc, 0xfb, 0x80, 0xad, 0x3b,
0x7d, 0x1f, 0x48, 0x56, 0x27, 0xf7, 0x2f, 0x8e, 0x92, 0x07, 0xa8, 0x9f,
0xbc, 0x5a, 0xce, 0xfa, 0xd5, 0x67, 0xad, 0xf4, 0xbf, 0xe0, 0xc9, 0x3e,
0x8e, 0xb5, 0x90, 0x58, 0x54, 0x92, 0x9f, 0xda, 0x36, 0xc0, 0x0d, 0x57,
0xfe, 0x6c, 0x23, 0x63, 0x8b, 0xd1, 0x1e, 0x4f, 0xd3 };
unsigned char q_data[] = {
0x00, 0xd6, 0x3f, 0xf5, 0xee, 0xff, 0x4d, 0x7d, 0x8c, 0x1a, 0x85, 0x5d,
0x3c, 0x4f, 0x9d, 0xdf, 0xc7, 0x68, 0x27, 0x7f, 0xe4, 0x4f, 0x4f, 0xd7,
0xa2, 0x3b, 0xcd, 0x4a, 0x34, 0xd8, 0x55, 0x4a, 0x3e, 0x8e, 0xb3, 0xa8,
0xe9, 0x8a, 0xc5, 0x94, 0xd1, 0x09, 0x32, 0x4b, 0x79, 0x8d, 0x7b, 0x03,
0x0b, 0x5d, 0xca, 0x91, 0x41, 0xbc, 0x82, 0xc3, 0x89, 0x67, 0x4d, 0x03,
0x68, 0x03, 0x2d, 0x0e, 0x4e, 0x97, 0x6c, 0xf6, 0x3e, 0x1f, 0xf4, 0x50,
0x06, 0x5d, 0x05, 0x22, 0xf2, 0xf8, 0xf2, 0xde, 0xad, 0x2e, 0x9d, 0xc3,
0x97, 0x1b, 0xc3, 0x75, 0xe7, 0x86, 0xde, 0xc5, 0x11, 0x89, 0xed, 0x6a,
0x13, 0x14, 0x23, 0x4b, 0x98, 0x81, 0xf7, 0xd4, 0x1c, 0xee, 0x30, 0x92,
0x85, 0x20, 0x4f, 0x35, 0x02, 0xfa, 0xda, 0x14, 0x77, 0xfa, 0x08, 0x34,
0x60, 0xc7, 0x93, 0x72, 0xdc, 0xc4, 0x18, 0x70, 0xc1 };
memset(msgbuf, 0xef, 64);
ret = (TEST_ptr((p = BN_bin2bn(p_data, sizeof(p_data), NULL)))
&& TEST_ptr((q = BN_bin2bn(q_data, sizeof(q_data), NULL)))
&& TEST_ptr((n = BN_bin2bn(n_data, sizeof(n_data), NULL)))
&& TEST_ptr((d = BN_bin2bn(d_data, sizeof(d_data), NULL)))
&& TEST_ptr((e = BN_bin2bn(e_data, sizeof(e_data), NULL)))
&& TEST_ptr((rsa = RSA_new()))
&& TEST_ptr((md = EVP_sha256()))
&& TEST_ptr((ctx = EVP_MD_CTX_new()))
&& TEST_ptr((pkey = EVP_PKEY_new()))
&& TEST_true(RSA_set0_factors(rsa, p, q))
&& TEST_true(RSA_set0_key(rsa, n, e, d))
&& TEST_true(EVP_PKEY_assign_RSA(pkey, rsa))
&& TEST_true(EVP_DigestSignInit(ctx, NULL, md, NULL, pkey))
&& TEST_true(EVP_DigestSign(ctx, sigbuf, &buflen, msgbuf, msglen)));
EVP_MD_CTX_free(ctx);
EVP_PKEY_free(pkey);
return ret;
}
static RSA *load_key(int priv)
{
RSA *rsa = NULL;
BIGNUM *pn = NULL, *pe = NULL, *pd= NULL;
/* RSA key extracted using > openssl genpkey -algorithm RSA -text */
static const unsigned char n[] = {
0x00, 0xbe, 0x24, 0x14, 0xf2, 0x39, 0xde, 0x19, 0xb3, 0xd7, 0x86, 0x1e, 0xf8, 0xd3, 0x97,
0x9f, 0x78, 0x28, 0x4c, 0xbf, 0xef, 0x03, 0x29, 0xc5, 0xeb, 0x97, 0x18, 0xdb, 0xa5, 0x17,
0x07, 0x57, 0x96, 0xe2, 0x45, 0x91, 0x2b, 0xd2, 0x9e, 0x28, 0x61, 0xa7, 0x8f, 0x39, 0xaa,
0xde, 0x94, 0x6d, 0x2b, 0x39, 0xde, 0xbe, 0xcf, 0xd7, 0x29, 0x16, 0x3a, 0x1a, 0x86, 0x2f,
0xff, 0x7a, 0x2f, 0x12, 0xc4, 0x8a, 0x32, 0x06, 0x6f, 0x40, 0x42, 0x37, 0xaa, 0x5f, 0xaf,
0x40, 0x77, 0xa5, 0x73, 0x09, 0xbf, 0xc5, 0x85, 0x79, 0xc0, 0x38, 0xd6, 0xb7, 0x2f, 0x77,
0xf0, 0x5a, 0xaf, 0xaf, 0xc3, 0x63, 0x4b, 0xea, 0xa2, 0x0c, 0x27, 0xcd, 0x7c, 0x77, 0xf4,
0x29, 0x5a, 0x69, 0xbd, 0xfe, 0x17, 0xb6, 0xc5, 0xd7, 0xc0, 0x40, 0xf9, 0x29, 0x46, 0x1f,
0xc0, 0x4b, 0xcf, 0x4e, 0x8f, 0x74, 0xd9, 0xc8, 0xd0, 0xde, 0x9c, 0x48, 0x57, 0xcc, 0x30,
0xbc, 0x06, 0x47, 0x4a, 0x8e, 0x40, 0x8a, 0xa1, 0x2a, 0x09, 0x8d, 0xe8, 0x41, 0x3d, 0x21,
0x52, 0xdc, 0x9c, 0xa9, 0x43, 0x63, 0x01, 0x44, 0xb3, 0xec, 0x22, 0x06, 0x29, 0xf6, 0xd8,
0xf6, 0x6b, 0xc3, 0x36, 0x25, 0xb0, 0x9b, 0xdb, 0x9a, 0x22, 0x51, 0x13, 0x42, 0xbd, 0x28,
0x0b, 0xd8, 0x5e, 0xac, 0xc7, 0x71, 0x6e, 0x78, 0xfc, 0xf4, 0x1d, 0x74, 0x9b, 0x1a, 0x19,
0x13, 0x56, 0x04, 0xb4, 0x33, 0x4e, 0xed, 0x54, 0x59, 0x7f, 0x71, 0x5d, 0x24, 0x18, 0x91,
0x51, 0x20, 0x39, 0x78, 0x4e, 0x33, 0x73, 0x96, 0xa8, 0x12, 0x2f, 0xff, 0x48, 0xc2, 0x11,
0x33, 0x95, 0xe5, 0xcc, 0x1a, 0xe2, 0x39, 0xd5, 0x57, 0x44, 0x51, 0x59, 0xd1, 0x35, 0x62,
0x16, 0x22, 0xf5, 0x52, 0x3d, 0xe0, 0x9b, 0x2d, 0x33, 0x34, 0x75, 0x13, 0x7d, 0x62, 0x70,
0x53, 0x31
};
static const unsigned char e[] = {
0x01, 0x00, 0x01
};
static const unsigned char d[] = {
0x0b, 0xd3, 0x07, 0x7a, 0xb0, 0x0c, 0xb2, 0xe3, 0x5d, 0x49, 0x7f, 0xe0, 0xf4, 0x5b, 0x21,
0x31, 0x96, 0x2b, 0x7e, 0x32, 0xdf, 0x5a, 0xec, 0x5e, 0x10, 0x14, 0x9d, 0x99, 0xaa, 0xd8,
0xc3, 0xfa, 0x9c, 0x0e, 0x0c, 0x96, 0xe9, 0xa3, 0x58, 0x62, 0x68, 0xca, 0xba, 0x50, 0xc9,
0x04, 0x58, 0xd4, 0xe3, 0xa5, 0x99, 0x8f, 0x08, 0x2b, 0xcb, 0xe0, 0x1f, 0x84, 0xc5, 0x64,
0xbd, 0x48, 0xe2, 0xc1, 0x56, 0x51, 0x01, 0xb7, 0x8e, 0xca, 0xe3, 0x66, 0x70, 0xea, 0x7f,
0x8f, 0x45, 0x3a, 0xa6, 0x02, 0x3f, 0x16, 0xc3, 0xad, 0x57, 0x97, 0x8a, 0x37, 0x2d, 0x6d,
0xb4, 0xfd, 0x08, 0x98, 0x95, 0x72, 0xeb, 0xd7, 0xa9, 0x9a, 0xfa, 0xcf, 0x55, 0x10, 0x19,
0xf7, 0x7f, 0x7c, 0x8f, 0x49, 0xf3, 0x1d, 0xc2, 0xf2, 0xd7, 0xb3, 0x8a, 0xfc, 0x9b, 0x76,
0x40, 0x5c, 0xa7, 0x2f, 0x7a, 0x8a, 0x3d, 0xdf, 0xbc, 0x52, 0x69, 0x99, 0xf8, 0x4b, 0x7a,
0xbf, 0x11, 0x5d, 0x31, 0x41, 0x5f, 0xa3, 0xb9, 0x74, 0xaf, 0xe4, 0x08, 0x19, 0x9f, 0x88,
0xca, 0xfb, 0x8e, 0xab, 0xa4, 0x00, 0x31, 0xc9, 0xf1, 0x77, 0xe9, 0xe3, 0xf1, 0x98, 0xd9,
0x04, 0x08, 0x0c, 0x38, 0x35, 0x4b, 0xcc, 0xab, 0x22, 0xdf, 0x84, 0xea, 0xe4, 0x2e, 0x57,
0xa5, 0xc1, 0x91, 0x0c, 0x34, 0x3b, 0x88, 0xbc, 0x14, 0xee, 0x6e, 0xe3, 0xf0, 0xe0, 0xdc,
0xae, 0xd6, 0x0c, 0x9b, 0xa0, 0x6d, 0xb6, 0x92, 0x6c, 0x7e, 0x05, 0x46, 0x02, 0xbc, 0x23,
0xbc, 0x65, 0xe6, 0x62, 0x04, 0x19, 0xe6, 0x98, 0x67, 0x2d, 0x15, 0x0a, 0xc4, 0xea, 0xb5,
0x62, 0xa0, 0x54, 0xed, 0x07, 0x45, 0x3e, 0x21, 0x93, 0x3e, 0x22, 0xd0, 0xc3, 0xca, 0x37,
0x3c, 0xea, 0x90, 0xdd, 0xa6, 0xb1, 0x6c, 0x76, 0xce, 0x5a, 0xe1, 0xc2, 0x80, 0x1f, 0x32,
0x21
};
if (!TEST_ptr(rsa = RSA_new()))
return NULL;
pn = BN_bin2bn(n, sizeof(n), NULL);
pe = BN_bin2bn(e, sizeof(e), NULL);
if (priv)
pd = BN_bin2bn(d, sizeof(d), NULL);
if (!TEST_false(pn == NULL
|| pe == NULL
|| (priv && pd == NULL)
|| !RSA_set0_key(rsa, pn, pe, pd))) {
BN_free(pn);
BN_free(pe);
BN_free(pd);
RSA_free(rsa);
rsa = NULL;
}
return rsa;
}
static int test_rsa_saos(void)
{
int ret = 0;
unsigned int siglen = 0;
RSA *rsa_priv = NULL, *rsa_pub = NULL;
static const unsigned char in[256] = { 0 };
unsigned char sig[256];
/* Maximum length allowed: The 3 relates to the octet byte 0x04 followed by a 2 byte length */
unsigned int inlen = sizeof(in) - RSA_PKCS1_PADDING_SIZE - 3;
/* A generated signature when in[inlen]= { 1 }. */
static const unsigned char sig_mismatch[256] = {
0x5f, 0x64, 0xab, 0xd3, 0x86, 0xdf, 0x6e, 0x91,
0xa8, 0xdb, 0x9d, 0x36, 0x7a, 0x15, 0xe5, 0x75,
0xe4, 0x27, 0xdf, 0xeb, 0x8d, 0xaf, 0xb0, 0x60,
0xec, 0x36, 0x8b, 0x00, 0x36, 0xb4, 0x61, 0x38,
0xfe, 0xfa, 0x49, 0x55, 0xcf, 0xb7, 0xff, 0xeb,
0x25, 0xa5, 0x41, 0x1e, 0xaa, 0x74, 0x3d, 0x57,
0xed, 0x5c, 0x4a, 0x01, 0x9e, 0xb2, 0x50, 0xbc,
0x50, 0x15, 0xd5, 0x97, 0x93, 0x91, 0x97, 0xa3,
0xff, 0x67, 0x2a, 0xe9, 0x04, 0xdd, 0x31, 0x6f,
0x4b, 0x44, 0x4f, 0x04, 0xa0, 0x48, 0x6a, 0xc1,
0x8d, 0xc2, 0xf3, 0xf7, 0xc4, 0x8c, 0x29, 0xcb,
0x2c, 0x04, 0x8f, 0x30, 0x71, 0xbb, 0x5b, 0xf9,
0xf9, 0x1b, 0xe8, 0xf0, 0xe8, 0xd1, 0xcf, 0x73,
0xf6, 0x02, 0x45, 0x6f, 0x53, 0x25, 0x1e, 0x74,
0x94, 0x6e, 0xf4, 0x0d, 0x36, 0x6c, 0xa3, 0xae,
0x8f, 0x94, 0x05, 0xa9, 0xe9, 0x65, 0x26, 0x7f,
0x07, 0xc5, 0x7e, 0xab, 0xd9, 0xe9, 0x09, 0x2d,
0x19, 0x8c, 0x6a, 0xcc, 0xd5, 0x62, 0x04, 0xb4,
0x9b, 0xaf, 0x99, 0x6a, 0x7a, 0x7b, 0xef, 0x01,
0x9b, 0xc1, 0x46, 0x59, 0x88, 0xee, 0x8b, 0xd7,
0xe5, 0x35, 0xad, 0x4c, 0xb2, 0x0d, 0x93, 0xdd,
0x0e, 0x50, 0x36, 0x2b, 0x7b, 0x42, 0x9b, 0x59,
0x95, 0xe7, 0xe1, 0x36, 0x50, 0x87, 0x7c, 0xac,
0x47, 0x13, 0x9b, 0xa7, 0x36, 0xdf, 0x8a, 0xd7,
0xee, 0x7d, 0x2e, 0xa6, 0xbb, 0x31, 0x32, 0xed,
0x39, 0x77, 0xf2, 0x41, 0xf9, 0x2d, 0x29, 0xfc,
0x6d, 0x32, 0x8e, 0x35, 0x99, 0x38, 0x8b, 0xd9,
0xc6, 0x77, 0x09, 0xe3, 0xe3, 0x06, 0x98, 0xe1,
0x96, 0xe9, 0x23, 0x11, 0xeb, 0x09, 0xa2, 0x6b,
0x21, 0x52, 0x67, 0x94, 0x15, 0x72, 0x7e, 0xdd,
0x66, 0x1c, 0xe7, 0xdb, 0x0e, 0x71, 0x5d, 0x95,
0x9d, 0xf8, 0x8e, 0x65, 0x97, 0x2f, 0x1a, 0x86
};
/* The signature generated by RSA_private_encrypt of in[inlen] */
static const unsigned char no_octet_sig[256] = {
0x78, 0xaf, 0x3e, 0xd1, 0xbc, 0x99, 0xb3, 0x19,
0xa8, 0xaa, 0x64, 0x56, 0x60, 0x95, 0xa0, 0x81,
0xd8, 0xb4, 0xe1, 0x9c, 0xf8, 0x94, 0xfa, 0x31,
0xb5, 0xde, 0x90, 0x75, 0xa7, 0xdb, 0xd4, 0x7e,
0xda, 0x62, 0xde, 0x16, 0x78, 0x4f, 0x9b, 0xc2,
0xa4, 0xd4, 0x5c, 0x17, 0x4f, 0x2d, 0xf2, 0x84,
0x5b, 0x5d, 0x00, 0xa0, 0xcf, 0xda, 0x3f, 0xbc,
0x40, 0xb4, 0x4e, 0xcb, 0x18, 0xeb, 0x4b, 0x0f,
0xce, 0x95, 0x3a, 0x5a, 0x9c, 0x49, 0xb4, 0x63,
0xd4, 0xde, 0xfb, 0xe2, 0xa8, 0xf3, 0x97, 0x52,
0x36, 0x3e, 0xc0, 0xab, 0xc8, 0x1c, 0xef, 0xdd,
0xf4, 0x37, 0xbc, 0xf3, 0xc3, 0x67, 0xf6, 0xc0,
0x6e, 0x75, 0xa6, 0xf3, 0x7e, 0x37, 0x96, 0xf2,
0xbb, 0x25, 0x3a, 0xa0, 0xa8, 0x8e, 0xce, 0xa0,
0xce, 0x0f, 0x22, 0x2d, 0x9c, 0x30, 0x0d, 0x20,
0x36, 0xc6, 0x9d, 0x36, 0x5d, 0x5b, 0x3e, 0xbc,
0x7c, 0x55, 0x95, 0xb4, 0x69, 0x19, 0x27, 0xf6,
0x63, 0x78, 0x21, 0x2d, 0xcf, 0x51, 0xb0, 0x46,
0x44, 0x02, 0x29, 0x93, 0xa5, 0x1b, 0xda, 0x21,
0xb3, 0x74, 0xf6, 0x4e, 0xd0, 0xdb, 0x3d, 0x59,
0xfd, 0xd7, 0x88, 0xd0, 0x2f, 0x84, 0xf6, 0xb1,
0xaa, 0xce, 0x3e, 0xa0, 0xdc, 0x1a, 0xd0, 0xe3,
0x5f, 0x3c, 0xda, 0x96, 0xee, 0xce, 0xf9, 0x75,
0xcf, 0x8d, 0xf3, 0x03, 0x28, 0xa7, 0x39, 0xbd,
0x95, 0xaa, 0x73, 0xbe, 0xa5, 0x5f, 0x84, 0x33,
0x07, 0x49, 0xbf, 0x03, 0xf8, 0x4b, 0x46, 0xbf,
0x38, 0xd4, 0x9b, 0x14, 0xa7, 0x01, 0xb7, 0x1f,
0x12, 0x08, 0x01, 0xed, 0xcd, 0x34, 0xf5, 0xb4,
0x06, 0x47, 0xe0, 0x53, 0x1c, 0x7c, 0x3f, 0xb5,
0x30, 0x59, 0xbb, 0xe3, 0xd6, 0x7c, 0x41, 0xcc,
0xd2, 0x11, 0x73, 0x03, 0x77, 0x7f, 0x5f, 0xad,
0x4a, 0x54, 0xdf, 0x17, 0x94, 0x97, 0x5c, 0x16
};
if (!TEST_ptr(rsa_priv = load_key(1)))
goto err;
if (!TEST_ptr(rsa_pub = load_key(0)))
goto err;
if (!TEST_int_ge((int)sizeof(sig), RSA_size(rsa_priv)))
goto err;
/* Test that a generated signature can be verified */
if (!TEST_true(RSA_sign_ASN1_OCTET_STRING(0, in, inlen, sig, &siglen,
rsa_priv)))
goto err;
if (!TEST_true(RSA_verify_ASN1_OCTET_STRING(0, in, inlen, sig, siglen, rsa_pub)))
goto err;
/* Test sign fails if the input is too large */
if (!TEST_false(RSA_sign_ASN1_OCTET_STRING(0, in, inlen + 1, sig, &siglen,
rsa_priv)))
goto err;
/* Fail if there is no private signing key */
if (!TEST_false(RSA_sign_ASN1_OCTET_STRING(0, in, inlen, sig, &siglen,
rsa_pub)))
goto err;
/* Fail if the signature is the wrong size */
if (!TEST_false(RSA_verify_ASN1_OCTET_STRING(0, in, inlen, sig, siglen - 1, rsa_pub)))
goto err;
/* Fail if the encrypted input is not octet encoded */
if (!TEST_false(RSA_verify_ASN1_OCTET_STRING(0, in, inlen, (unsigned char *)no_octet_sig,
(unsigned int)sizeof(no_octet_sig),
rsa_pub)))
goto err;
/* Fail if the signature does not match the input */
if (!TEST_false(RSA_verify_ASN1_OCTET_STRING(0, in, inlen, (unsigned char *)sig_mismatch,
(unsigned int)sizeof(sig_mismatch),
rsa_pub)))
goto err;
/* Fail if the signature is corrupt */
sig[0]++;
if (!TEST_false(RSA_verify_ASN1_OCTET_STRING(0, in, inlen, sig, siglen, rsa_pub)))
goto err;
sig[0]--;
ret = 1;
err:
RSA_free(rsa_priv);
RSA_free(rsa_pub);
return ret;
}
int setup_tests(void)
{
ADD_ALL_TESTS(test_rsa_pkcs1, 3);
ADD_ALL_TESTS(test_rsa_oaep, 3);
ADD_ALL_TESTS(test_rsa_security_bit, OSSL_NELEM(rsa_security_bits_cases));
ADD_TEST(test_rsa_saos);
ADD_TEST(test_EVP_rsa_legacy_key);
return 1;
}
|
./openssl/test/cmactest.c | /*
* Copyright 1995-2023 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
*/
/*
* CMAC low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "internal/nelem.h"
#include <openssl/cmac.h>
#include <openssl/aes.h>
#include <openssl/evp.h>
#include "testutil.h"
static const char xtskey[32] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
};
static struct test_st {
const char key[32];
int key_len;
unsigned char data[4096];
int data_len;
const char *mac;
} test[] = {
{
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f
},
16,
"My test data",
12,
"29cec977c48f63c200bd5c4a6881b224"
},
{
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
},
32,
"My test data",
12,
"db6493aa04e4761f473b2b453c031c9a"
},
{
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
},
32,
"My test data again",
18,
"65c11c75ecf590badd0a5e56cbb8af60"
},
/* for aes-128-cbc */
{
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f
},
16,
/* repeat the string below until filling 3072 bytes */
"#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#",
3072,
"35da8a02a7afce90e5b711308cee2dee"
},
/* for aes-192-cbc */
{
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x16, 0x17
},
24,
/* repeat the string below until filling 4095 bytes */
"#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#",
4095,
"59053f4e81f3593610f987adb547c5b2"
},
/* for aes-256-cbc */
{
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
},
32,
/* repeat the string below until filling 2560 bytes */
"#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#",
2560,
"9c6cf85f7f4baca99725764a0df973a9"
},
/* for des-ede3-cbc */
{
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
},
24,
/* repeat the string below until filling 2048 bytes */
"#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#",
2048,
"2c2fccc7fcc5d98a"
},
/* for sm4-cbc */
{
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f
},
16,
/* repeat the string below until filling 2049 bytes */
"#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#",
2049,
"c9a9cbc82a3b2d96074e386fce1216f2"
},
};
static char *pt(unsigned char *md, unsigned int len);
static int test_cmac_bad(void)
{
CMAC_CTX *ctx = NULL;
int ret = 0;
ctx = CMAC_CTX_new();
if (!TEST_ptr(ctx)
|| !TEST_false(CMAC_Init(ctx, NULL, 0, NULL, NULL))
|| !TEST_false(CMAC_Update(ctx, test[0].data, test[0].data_len))
/* Should be able to pass cipher first, and then key */
|| !TEST_true(CMAC_Init(ctx, NULL, 0, EVP_aes_128_cbc(), NULL))
/* Must have a key */
|| !TEST_false(CMAC_Update(ctx, test[0].data, test[0].data_len))
/* Now supply the key */
|| !TEST_true(CMAC_Init(ctx, test[0].key, test[0].key_len, NULL, NULL))
/* Update should now work */
|| !TEST_true(CMAC_Update(ctx, test[0].data, test[0].data_len))
/* XTS is not a suitable cipher to use */
|| !TEST_false(CMAC_Init(ctx, xtskey, sizeof(xtskey), EVP_aes_128_xts(),
NULL))
|| !TEST_false(CMAC_Update(ctx, test[0].data, test[0].data_len)))
goto err;
ret = 1;
err:
CMAC_CTX_free(ctx);
return ret;
}
static int test_cmac_run(void)
{
char *p;
CMAC_CTX *ctx = NULL;
unsigned char buf[AES_BLOCK_SIZE];
size_t len;
int ret = 0;
size_t case_idx = 0;
ctx = CMAC_CTX_new();
/* Construct input data, fill repeatedly until reaching data length */
for (case_idx = 0; case_idx < OSSL_NELEM(test); case_idx++) {
size_t str_len = strlen((char *)test[case_idx].data);
size_t fill_len = test[case_idx].data_len - str_len;
size_t fill_idx = str_len;
while (fill_len > 0) {
if (fill_len > str_len) {
memcpy(&test[case_idx].data[fill_idx], test[case_idx].data, str_len);
fill_len -= str_len;
fill_idx += str_len;
} else {
memcpy(&test[case_idx].data[fill_idx], test[case_idx].data, fill_len);
fill_len = 0;
}
}
}
if (!TEST_true(CMAC_Init(ctx, test[0].key, test[0].key_len,
EVP_aes_128_cbc(), NULL))
|| !TEST_true(CMAC_Update(ctx, test[0].data, test[0].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[0].mac))
goto err;
if (!TEST_true(CMAC_Init(ctx, test[1].key, test[1].key_len,
EVP_aes_256_cbc(), NULL))
|| !TEST_true(CMAC_Update(ctx, test[1].data, test[1].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[1].mac))
goto err;
if (!TEST_true(CMAC_Init(ctx, test[2].key, test[2].key_len, NULL, NULL))
|| !TEST_true(CMAC_Update(ctx, test[2].data, test[2].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[2].mac))
goto err;
/* Test reusing a key */
if (!TEST_true(CMAC_Init(ctx, NULL, 0, NULL, NULL))
|| !TEST_true(CMAC_Update(ctx, test[2].data, test[2].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[2].mac))
goto err;
/* Test setting the cipher and key separately */
if (!TEST_true(CMAC_Init(ctx, NULL, 0, EVP_aes_256_cbc(), NULL))
|| !TEST_true(CMAC_Init(ctx, test[2].key, test[2].key_len, NULL, NULL))
|| !TEST_true(CMAC_Update(ctx, test[2].data, test[2].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[2].mac))
goto err;
/* Test data length is greater than 1 block length */
if (!TEST_true(CMAC_Init(ctx, test[3].key, test[3].key_len,
EVP_aes_128_cbc(), NULL))
|| !TEST_true(CMAC_Update(ctx, test[3].data, test[3].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[3].mac))
goto err;
if (!TEST_true(CMAC_Init(ctx, test[4].key, test[4].key_len,
EVP_aes_192_cbc(), NULL))
|| !TEST_true(CMAC_Update(ctx, test[4].data, test[4].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[4].mac))
goto err;
if (!TEST_true(CMAC_Init(ctx, test[5].key, test[5].key_len,
EVP_aes_256_cbc(), NULL))
|| !TEST_true(CMAC_Update(ctx, test[5].data, test[5].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[5].mac))
goto err;
#ifndef OPENSSL_NO_DES
if (!TEST_true(CMAC_Init(ctx, test[6].key, test[6].key_len,
EVP_des_ede3_cbc(), NULL))
|| !TEST_true(CMAC_Update(ctx, test[6].data, test[6].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[6].mac))
goto err;
#endif
#ifndef OPENSSL_NO_SM4
if (!TEST_true(CMAC_Init(ctx, test[7].key, test[7].key_len,
EVP_sm4_cbc(), NULL))
|| !TEST_true(CMAC_Update(ctx, test[7].data, test[7].data_len))
|| !TEST_true(CMAC_Final(ctx, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[7].mac))
goto err;
#endif
ret = 1;
err:
CMAC_CTX_free(ctx);
return ret;
}
static int test_cmac_copy(void)
{
char *p;
CMAC_CTX *ctx = NULL, *ctx2 = NULL;
unsigned char buf[AES_BLOCK_SIZE];
size_t len;
int ret = 0;
ctx = CMAC_CTX_new();
ctx2 = CMAC_CTX_new();
if (!TEST_ptr(ctx) || !TEST_ptr(ctx2))
goto err;
if (!TEST_true(CMAC_Init(ctx, test[0].key, test[0].key_len,
EVP_aes_128_cbc(), NULL))
|| !TEST_true(CMAC_Update(ctx, test[0].data, test[0].data_len))
|| !TEST_true(CMAC_CTX_copy(ctx2, ctx))
|| !TEST_true(CMAC_Final(ctx2, buf, &len)))
goto err;
p = pt(buf, len);
if (!TEST_str_eq(p, test[0].mac))
goto err;
ret = 1;
err:
CMAC_CTX_free(ctx2);
CMAC_CTX_free(ctx);
return ret;
}
static char *pt(unsigned char *md, unsigned int len)
{
unsigned int i;
static char buf[80];
for (i = 0; i < len; i++)
sprintf(&(buf[i * 2]), "%02x", md[i]);
return buf;
}
int setup_tests(void)
{
ADD_TEST(test_cmac_bad);
ADD_TEST(test_cmac_run);
ADD_TEST(test_cmac_copy);
return 1;
}
|
./openssl/test/bio_comp_test.c | /*
* Copyright 2022 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 <string.h>
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/rand.h>
#include <openssl/comp.h>
#include "testutil.h"
#include "testutil/output.h"
#include "testutil/tu_local.h"
#define COMPRESS 1
#define EXPAND 0
#define BUFFER_SIZE 32 * 1024
#define NUM_SIZES 4
static int sizes[NUM_SIZES] = { 64, 512, 2048, 16 * 1024 };
/* using global buffers */
static unsigned char *original = NULL;
static unsigned char *result = NULL;
/*
* For compression:
* the write operation compresses
* the read operation decompresses
*/
static int do_bio_comp_test(const BIO_METHOD *meth, size_t size)
{
BIO *bcomp = NULL;
BIO *bmem = NULL;
BIO *bexp = NULL;
int osize;
int rsize;
int ret = 0;
/* Compress */
if (!TEST_ptr(meth))
goto err;
if (!TEST_ptr(bcomp = BIO_new(meth)))
goto err;
if (!TEST_ptr(bmem = BIO_new(BIO_s_mem())))
goto err;
BIO_push(bcomp, bmem);
osize = BIO_write(bcomp, original, size);
if (!TEST_int_eq(osize, size)
|| !TEST_true(BIO_flush(bcomp)))
goto err;
BIO_free(bcomp);
bcomp = NULL;
/* decompress */
if (!TEST_ptr(bexp = BIO_new(meth)))
goto err;
BIO_push(bexp, bmem);
rsize = BIO_read(bexp, result, size);
if (!TEST_int_eq(size, rsize)
|| !TEST_mem_eq(original, osize, result, rsize))
goto err;
ret = 1;
err:
BIO_free(bexp);
BIO_free(bcomp);
BIO_free(bmem);
return ret;
}
static int do_bio_comp(const BIO_METHOD *meth, int n)
{
int i;
int success = 0;
int size = sizes[n % 4];
int type = n / 4;
if (!TEST_ptr(original = OPENSSL_malloc(BUFFER_SIZE))
|| !TEST_ptr(result = OPENSSL_malloc(BUFFER_SIZE)))
goto err;
switch (type) {
case 0:
TEST_info("zeros of size %d\n", size);
memset(original, 0, BUFFER_SIZE);
break;
case 1:
TEST_info("ones of size %d\n", size);
memset(original, 1, BUFFER_SIZE);
break;
case 2:
TEST_info("sequential of size %d\n", size);
for (i = 0; i < BUFFER_SIZE; i++)
original[i] = i & 0xFF;
break;
case 3:
TEST_info("random of size %d\n", size);
if (!TEST_int_gt(RAND_bytes(original, BUFFER_SIZE), 0))
goto err;
break;
default:
goto err;
}
if (!TEST_true(do_bio_comp_test(meth, size)))
goto err;
success = 1;
err:
OPENSSL_free(original);
OPENSSL_free(result);
return success;
}
#ifndef OPENSSL_NO_ZSTD
static int test_zstd(int n)
{
return do_bio_comp(BIO_f_zstd(), n);
}
#endif
#ifndef OPENSSL_NO_BROTLI
static int test_brotli(int n)
{
return do_bio_comp(BIO_f_brotli(), n);
}
#endif
#ifndef OPENSSL_NO_ZLIB
static int test_zlib(int n)
{
return do_bio_comp(BIO_f_zlib(), n);
}
#endif
int setup_tests(void)
{
#ifndef OPENSSL_NO_ZLIB
ADD_ALL_TESTS(test_zlib, NUM_SIZES * 4);
#endif
#ifndef OPENSSL_NO_BROTLI
ADD_ALL_TESTS(test_brotli, NUM_SIZES * 4);
#endif
#ifndef OPENSSL_NO_ZSTD
ADD_ALL_TESTS(test_zstd, NUM_SIZES * 4);
#endif
return 1;
}
|
./openssl/test/rsa_sp800_56b_test.c | /*
* Copyright 2018-2023 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
*/
/*
* RSA low level APIs are deprecated for public use, but still ok for
* internal use.
*/
#include "internal/deprecated.h"
#include <stdio.h>
#include <string.h>
#include "internal/nelem.h"
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/bn.h>
#include "testutil.h"
#include "rsa_local.h"
#include <openssl/rsa.h>
/* taken from RSA2 cavs data */
static const unsigned char cav_e[] = {
0x01,0x00,0x01
};
static const unsigned char cav_p[] = {
0xcf,0x72,0x1b,0x9a,0xfd,0x0d,0x22,0x1a,0x74,0x50,0x97,0x22,0x76,0xd8,0xc0,
0xc2,0xfd,0x08,0x81,0x05,0xdd,0x18,0x21,0x99,0x96,0xd6,0x5c,0x79,0xe3,0x02,
0x81,0xd7,0x0e,0x3f,0x3b,0x34,0xda,0x61,0xc9,0x2d,0x84,0x86,0x62,0x1e,0x3d,
0x5d,0xbf,0x92,0x2e,0xcd,0x35,0x3d,0x6e,0xb9,0x59,0x16,0xc9,0x82,0x50,0x41,
0x30,0x45,0x67,0xaa,0xb7,0xbe,0xec,0xea,0x4b,0x9e,0xa0,0xc3,0x05,0xbc,0x4c,
0x01,0xa5,0x4b,0xbd,0xa4,0x20,0xb5,0x20,0xd5,0x59,0x6f,0x82,0x5c,0x8f,0x4f,
0xe0,0x3a,0x4e,0x7e,0xfe,0x44,0xf3,0x3c,0xc0,0x0e,0x14,0x2b,0x32,0xe6,0x28,
0x8b,0x63,0x87,0x00,0xc3,0x53,0x4a,0x5b,0x71,0x7a,0x5b,0x28,0x40,0xc4,0x18,
0xb6,0x77,0x0b,0xab,0x59,0xa4,0x96,0x7d
};
static const unsigned char cav_q[] = {
0xfe,0xab,0xf2,0x7c,0x16,0x4a,0xf0,0x8d,0x31,0xc6,0x0a,0x82,0xe2,0xae,0xbb,
0x03,0x7e,0x7b,0x20,0x4e,0x64,0xb0,0x16,0xad,0x3c,0x01,0x1a,0xd3,0x54,0xbf,
0x2b,0xa4,0x02,0x9e,0xc3,0x0d,0x60,0x3d,0x1f,0xb9,0xc0,0x0d,0xe6,0x97,0x68,
0xbb,0x8c,0x81,0xd5,0xc1,0x54,0x96,0x0f,0x99,0xf0,0xa8,0xa2,0xf3,0xc6,0x8e,
0xec,0xbc,0x31,0x17,0x70,0x98,0x24,0xa3,0x36,0x51,0xa8,0x54,0xc4,0x44,0xdd,
0xf7,0x7e,0xda,0x47,0x4a,0x67,0x44,0x5d,0x4e,0x75,0xf0,0x4d,0x00,0x68,0xe1,
0x4a,0xec,0x1f,0x45,0xf9,0xe6,0xca,0x38,0x95,0x48,0x6f,0xdc,0x9d,0x1b,0xa3,
0x4b,0xfd,0x08,0x4b,0x54,0xcd,0xeb,0x3d,0xef,0x33,0x11,0x6e,0xce,0xe4,0x5d,
0xef,0xa9,0x58,0x5c,0x87,0x4d,0xc8,0xcf
};
static const unsigned char cav_n[] = {
0xce,0x5e,0x8d,0x1a,0xa3,0x08,0x7a,0x2d,0xb4,0x49,0x48,0xf0,0x06,0xb6,0xfe,
0xba,0x2f,0x39,0x7c,0x7b,0xe0,0x5d,0x09,0x2d,0x57,0x4e,0x54,0x60,0x9c,0xe5,
0x08,0x4b,0xe1,0x1a,0x73,0xc1,0x5e,0x2f,0xb6,0x46,0xd7,0x81,0xca,0xbc,0x98,
0xd2,0xf9,0xef,0x1c,0x92,0x8c,0x8d,0x99,0x85,0x28,0x52,0xd6,0xd5,0xab,0x70,
0x7e,0x9e,0xa9,0x87,0x82,0xc8,0x95,0x64,0xeb,0xf0,0x6c,0x0f,0x3f,0xe9,0x02,
0x29,0x2e,0x6d,0xa1,0xec,0xbf,0xdc,0x23,0xdf,0x82,0x4f,0xab,0x39,0x8d,0xcc,
0xac,0x21,0x51,0x14,0xf8,0xef,0xec,0x73,0x80,0x86,0xa3,0xcf,0x8f,0xd5,0xcf,
0x22,0x1f,0xcc,0x23,0x2f,0xba,0xcb,0xf6,0x17,0xcd,0x3a,0x1f,0xd9,0x84,0xb9,
0x88,0xa7,0x78,0x0f,0xaa,0xc9,0x04,0x01,0x20,0x72,0x5d,0x2a,0xfe,0x5b,0xdd,
0x16,0x5a,0xed,0x83,0x02,0x96,0x39,0x46,0x37,0x30,0xc1,0x0d,0x87,0xc2,0xc8,
0x33,0x38,0xed,0x35,0x72,0xe5,0x29,0xf8,0x1f,0x23,0x60,0xe1,0x2a,0x5b,0x1d,
0x6b,0x53,0x3f,0x07,0xc4,0xd9,0xbb,0x04,0x0c,0x5c,0x3f,0x0b,0xc4,0xd4,0x61,
0x96,0x94,0xf1,0x0f,0x4a,0x49,0xac,0xde,0xd2,0xe8,0x42,0xb3,0x4a,0x0b,0x64,
0x7a,0x32,0x5f,0x2b,0x5b,0x0f,0x8b,0x8b,0xe0,0x33,0x23,0x34,0x64,0xf8,0xb5,
0x7f,0x69,0x60,0xb8,0x71,0xe9,0xff,0x92,0x42,0xb1,0xf7,0x23,0xa8,0xa7,0x92,
0x04,0x3d,0x6b,0xff,0xf7,0xab,0xbb,0x14,0x1f,0x4c,0x10,0x97,0xd5,0x6b,0x71,
0x12,0xfd,0x93,0xa0,0x4a,0x3b,0x75,0x72,0x40,0x96,0x1c,0x5f,0x40,0x40,0x57,
0x13
};
static const unsigned char cav_d[] = {
0x47,0x47,0x49,0x1d,0x66,0x2a,0x4b,0x68,0xf5,0xd8,0x4a,0x24,0xfd,0x6c,0xbf,
0x56,0xb7,0x70,0xf7,0x9a,0x21,0xc8,0x80,0x9e,0xf4,0x84,0xcd,0x88,0x01,0x28,
0xea,0x50,0xab,0x13,0x63,0xdf,0xea,0x14,0x38,0xb5,0x07,0x42,0x81,0x2f,0xda,
0xe9,0x24,0x02,0x7e,0xaf,0xef,0x74,0x09,0x0e,0x80,0xfa,0xfb,0xd1,0x19,0x41,
0xe5,0xba,0x0f,0x7c,0x0a,0xa4,0x15,0x55,0xa2,0x58,0x8c,0x3a,0x48,0x2c,0xc6,
0xde,0x4a,0x76,0xfb,0x72,0xb6,0x61,0xe6,0xd2,0x10,0x44,0x4c,0x33,0xb8,0xd2,
0x74,0xb1,0x9d,0x3b,0xcd,0x2f,0xb1,0x4f,0xc3,0x98,0xbd,0x83,0xb7,0x7e,0x75,
0xe8,0xa7,0x6a,0xee,0xcc,0x51,0x8c,0x99,0x17,0x67,0x7f,0x27,0xf9,0x0d,0x6a,
0xb7,0xd4,0x80,0x17,0x89,0x39,0x9c,0xf3,0xd7,0x0f,0xdf,0xb0,0x55,0x80,0x1d,
0xaf,0x57,0x2e,0xd0,0xf0,0x4f,0x42,0x69,0x55,0xbc,0x83,0xd6,0x97,0x83,0x7a,
0xe6,0xc6,0x30,0x6d,0x3d,0xb5,0x21,0xa7,0xc4,0x62,0x0a,0x20,0xce,0x5e,0x5a,
0x17,0x98,0xb3,0x6f,0x6b,0x9a,0xeb,0x6b,0xa3,0xc4,0x75,0xd8,0x2b,0xdc,0x5c,
0x6f,0xec,0x5d,0x49,0xac,0xa8,0xa4,0x2f,0xb8,0x8c,0x4f,0x2e,0x46,0x21,0xee,
0x72,0x6a,0x0e,0x22,0x80,0x71,0xc8,0x76,0x40,0x44,0x61,0x16,0xbf,0xa5,0xf8,
0x89,0xc7,0xe9,0x87,0xdf,0xbd,0x2e,0x4b,0x4e,0xc2,0x97,0x53,0xe9,0x49,0x1c,
0x05,0xb0,0x0b,0x9b,0x9f,0x21,0x19,0x41,0xe9,0xf5,0x61,0xd7,0x33,0x2e,0x2c,
0x94,0xb8,0xa8,0x9a,0x3a,0xcc,0x6a,0x24,0x8d,0x19,0x13,0xee,0xb9,0xb0,0x48,
0x61
};
/* helper function */
static BIGNUM *bn_load_new(const unsigned char *data, int sz)
{
BIGNUM *ret = BN_new();
if (ret != NULL)
BN_bin2bn(data, sz, ret);
return ret;
}
/* Check that small rsa exponents are allowed in non FIPS mode */
static int test_check_public_exponent(void)
{
int ret = 0;
BIGNUM *e = NULL;
ret = TEST_ptr(e = BN_new())
/* e is too small will fail */
&& TEST_true(BN_set_word(e, 1))
&& TEST_false(ossl_rsa_check_public_exponent(e))
/* e is even will fail */
&& TEST_true(BN_set_word(e, 65536))
&& TEST_false(ossl_rsa_check_public_exponent(e))
/* e is ok */
&& TEST_true(BN_set_word(e, 3))
&& TEST_true(ossl_rsa_check_public_exponent(e))
&& TEST_true(BN_set_word(e, 17))
&& TEST_true(ossl_rsa_check_public_exponent(e))
&& TEST_true(BN_set_word(e, 65537))
&& TEST_true(ossl_rsa_check_public_exponent(e))
/* e = 2^256 + 1 is ok */
&& TEST_true(BN_lshift(e, BN_value_one(), 256))
&& TEST_true(BN_add(e, e, BN_value_one()))
&& TEST_true(ossl_rsa_check_public_exponent(e));
BN_free(e);
return ret;
}
static int test_check_prime_factor_range(void)
{
int ret = 0;
BN_CTX *ctx = NULL;
BIGNUM *p = NULL;
BIGNUM *bn_p1 = NULL, *bn_p2 = NULL, *bn_p3 = NULL, *bn_p4 = NULL;
/* Some range checks that are larger than 32 bits */
static const unsigned char p1[] = { 0x0B, 0x50, 0x4F, 0x33, 0x3F };
static const unsigned char p2[] = { 0x10, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char p3[] = { 0x0B, 0x50, 0x4F, 0x33, 0x40 };
static const unsigned char p4[] = { 0x0F, 0xFF, 0xFF, 0xFF, 0xFF };
/* (√2)(2^(nbits/2 - 1) <= p <= 2^(nbits/2) - 1
* For 8 bits: 0xB.504F <= p <= 0xF
* for 72 bits: 0xB504F333F. <= p <= 0xF_FFFF_FFFF
*/
ret = TEST_ptr(p = BN_new())
&& TEST_ptr(bn_p1 = bn_load_new(p1, sizeof(p1)))
&& TEST_ptr(bn_p2 = bn_load_new(p2, sizeof(p2)))
&& TEST_ptr(bn_p3 = bn_load_new(p3, sizeof(p3)))
&& TEST_ptr(bn_p4 = bn_load_new(p4, sizeof(p4)))
&& TEST_ptr(ctx = BN_CTX_new())
&& TEST_true(BN_set_word(p, 0xA))
&& TEST_false(ossl_rsa_check_prime_factor_range(p, 8, ctx))
&& TEST_true(BN_set_word(p, 0x10))
&& TEST_false(ossl_rsa_check_prime_factor_range(p, 8, ctx))
&& TEST_true(BN_set_word(p, 0xB))
&& TEST_false(ossl_rsa_check_prime_factor_range(p, 8, ctx))
&& TEST_true(BN_set_word(p, 0xC))
&& TEST_true(ossl_rsa_check_prime_factor_range(p, 8, ctx))
&& TEST_true(BN_set_word(p, 0xF))
&& TEST_true(ossl_rsa_check_prime_factor_range(p, 8, ctx))
&& TEST_false(ossl_rsa_check_prime_factor_range(bn_p1, 72, ctx))
&& TEST_false(ossl_rsa_check_prime_factor_range(bn_p2, 72, ctx))
&& TEST_true(ossl_rsa_check_prime_factor_range(bn_p3, 72, ctx))
&& TEST_true(ossl_rsa_check_prime_factor_range(bn_p4, 72, ctx));
BN_free(bn_p4);
BN_free(bn_p3);
BN_free(bn_p2);
BN_free(bn_p1);
BN_free(p);
BN_CTX_free(ctx);
return ret;
}
static int test_check_prime_factor(void)
{
int ret = 0;
BN_CTX *ctx = NULL;
BIGNUM *p = NULL, *e = NULL;
BIGNUM *bn_p1 = NULL, *bn_p2 = NULL, *bn_p3 = NULL;
/* Some range checks that are larger than 32 bits */
static const unsigned char p1[] = { 0x0B, 0x50, 0x4f, 0x33, 0x73 };
static const unsigned char p2[] = { 0x0B, 0x50, 0x4f, 0x33, 0x75 };
static const unsigned char p3[] = { 0x0F, 0x50, 0x00, 0x03, 0x75 };
ret = TEST_ptr(p = BN_new())
&& TEST_ptr(bn_p1 = bn_load_new(p1, sizeof(p1)))
&& TEST_ptr(bn_p2 = bn_load_new(p2, sizeof(p2)))
&& TEST_ptr(bn_p3 = bn_load_new(p3, sizeof(p3)))
&& TEST_ptr(e = BN_new())
&& TEST_ptr(ctx = BN_CTX_new())
/* Fails the prime test */
&& TEST_true(BN_set_word(e, 0x1))
&& TEST_false(ossl_rsa_check_prime_factor(bn_p1, e, 72, ctx))
/* p is prime and in range and gcd(p-1, e) = 1 */
&& TEST_true(ossl_rsa_check_prime_factor(bn_p2, e, 72, ctx))
/* gcd(p-1,e) = 1 test fails */
&& TEST_true(BN_set_word(e, 0x2))
&& TEST_false(ossl_rsa_check_prime_factor(p, e, 72, ctx))
/* p fails the range check */
&& TEST_true(BN_set_word(e, 0x1))
&& TEST_false(ossl_rsa_check_prime_factor(bn_p3, e, 72, ctx));
BN_free(bn_p3);
BN_free(bn_p2);
BN_free(bn_p1);
BN_free(e);
BN_free(p);
BN_CTX_free(ctx);
return ret;
}
/* This test uses legacy functions because they can take invalid numbers */
static int test_check_private_exponent(void)
{
int ret = 0;
RSA *key = NULL;
BN_CTX *ctx = NULL;
BIGNUM *p = NULL, *q = NULL, *e = NULL, *d = NULL, *n = NULL;
ret = TEST_ptr(key = RSA_new())
&& TEST_ptr(ctx = BN_CTX_new())
&& TEST_ptr(p = BN_new())
&& TEST_ptr(q = BN_new())
/* lcm(15-1,17-1) = 14*16 / 2 = 112 */
&& TEST_true(BN_set_word(p, 15))
&& TEST_true(BN_set_word(q, 17))
&& TEST_true(RSA_set0_factors(key, p, q));
if (!ret) {
BN_free(p);
BN_free(q);
goto end;
}
ret = TEST_ptr(e = BN_new())
&& TEST_ptr(d = BN_new())
&& TEST_ptr(n = BN_new())
&& TEST_true(BN_set_word(e, 5))
&& TEST_true(BN_set_word(d, 157))
&& TEST_true(BN_set_word(n, 15*17))
&& TEST_true(RSA_set0_key(key, n, e, d));
if (!ret) {
BN_free(e);
BN_free(d);
BN_free(n);
goto end;
}
/* fails since d >= lcm(p-1, q-1) */
ret = TEST_false(ossl_rsa_check_private_exponent(key, 8, ctx))
&& TEST_true(BN_set_word(d, 45))
/* d is correct size and 1 = e.d mod lcm(p-1, q-1) */
&& TEST_true(ossl_rsa_check_private_exponent(key, 8, ctx))
/* d is too small compared to nbits */
&& TEST_false(ossl_rsa_check_private_exponent(key, 16, ctx))
/* d is too small compared to nbits */
&& TEST_true(BN_set_word(d, 16))
&& TEST_false(ossl_rsa_check_private_exponent(key, 8, ctx))
/* fail if 1 != e.d mod lcm(p-1, q-1) */
&& TEST_true(BN_set_word(d, 46))
&& TEST_false(ossl_rsa_check_private_exponent(key, 8, ctx));
end:
RSA_free(key);
BN_CTX_free(ctx);
return ret;
}
static int test_check_crt_components(void)
{
const int P = 15;
const int Q = 17;
const int E = 5;
const int N = P*Q;
const int DP = 3;
const int DQ = 13;
const int QINV = 8;
int ret = 0;
RSA *key = NULL;
BN_CTX *ctx = NULL;
BIGNUM *p = NULL, *q = NULL, *e = NULL;
ret = TEST_ptr(key = RSA_new())
&& TEST_ptr(ctx = BN_CTX_new())
&& TEST_ptr(p = BN_new())
&& TEST_ptr(q = BN_new())
&& TEST_ptr(e = BN_new())
&& TEST_true(BN_set_word(p, P))
&& TEST_true(BN_set_word(q, Q))
&& TEST_true(BN_set_word(e, E))
&& TEST_true(RSA_set0_factors(key, p, q));
if (!ret) {
BN_free(p);
BN_free(q);
goto end;
}
ret = TEST_int_eq(ossl_rsa_sp800_56b_derive_params_from_pq(key, 8, e, ctx), 1)
&& TEST_BN_eq_word(key->n, N)
&& TEST_BN_eq_word(key->dmp1, DP)
&& TEST_BN_eq_word(key->dmq1, DQ)
&& TEST_BN_eq_word(key->iqmp, QINV)
&& TEST_true(ossl_rsa_check_crt_components(key, ctx))
/* (a) 1 < dP < (p – 1). */
&& TEST_true(BN_set_word(key->dmp1, 1))
&& TEST_false(ossl_rsa_check_crt_components(key, ctx))
&& TEST_true(BN_set_word(key->dmp1, P-1))
&& TEST_false(ossl_rsa_check_crt_components(key, ctx))
&& TEST_true(BN_set_word(key->dmp1, DP))
/* (b) 1 < dQ < (q - 1). */
&& TEST_true(BN_set_word(key->dmq1, 1))
&& TEST_false(ossl_rsa_check_crt_components(key, ctx))
&& TEST_true(BN_set_word(key->dmq1, Q-1))
&& TEST_false(ossl_rsa_check_crt_components(key, ctx))
&& TEST_true(BN_set_word(key->dmq1, DQ))
/* (c) 1 < qInv < p */
&& TEST_true(BN_set_word(key->iqmp, 1))
&& TEST_false(ossl_rsa_check_crt_components(key, ctx))
&& TEST_true(BN_set_word(key->iqmp, P))
&& TEST_false(ossl_rsa_check_crt_components(key, ctx))
&& TEST_true(BN_set_word(key->iqmp, QINV))
/* (d) 1 = (dP . e) mod (p - 1)*/
&& TEST_true(BN_set_word(key->dmp1, DP+1))
&& TEST_false(ossl_rsa_check_crt_components(key, ctx))
&& TEST_true(BN_set_word(key->dmp1, DP))
/* (e) 1 = (dQ . e) mod (q - 1) */
&& TEST_true(BN_set_word(key->dmq1, DQ-1))
&& TEST_false(ossl_rsa_check_crt_components(key, ctx))
&& TEST_true(BN_set_word(key->dmq1, DQ))
/* (f) 1 = (qInv . q) mod p */
&& TEST_true(BN_set_word(key->iqmp, QINV+1))
&& TEST_false(ossl_rsa_check_crt_components(key, ctx))
&& TEST_true(BN_set_word(key->iqmp, QINV))
/* check defaults are still valid */
&& TEST_true(ossl_rsa_check_crt_components(key, ctx));
end:
BN_free(e);
RSA_free(key);
BN_CTX_free(ctx);
return ret;
}
static const struct derive_from_pq_test {
int p, q, e;
} derive_from_pq_tests[] = {
{ 15, 17, 6 }, /* Mod_inverse failure */
{ 0, 17, 5 }, /* d is too small */
};
static int test_derive_params_from_pq_fail(int tst)
{
int ret = 0;
RSA *key = NULL;
BN_CTX *ctx = NULL;
BIGNUM *p = NULL, *q = NULL, *e = NULL;
ret = TEST_ptr(key = RSA_new())
&& TEST_ptr(ctx = BN_CTX_new())
&& TEST_ptr(p = BN_new())
&& TEST_ptr(q = BN_new())
&& TEST_ptr(e = BN_new())
&& TEST_true(BN_set_word(p, derive_from_pq_tests[tst].p))
&& TEST_true(BN_set_word(q, derive_from_pq_tests[tst].q))
&& TEST_true(BN_set_word(e, derive_from_pq_tests[tst].e))
&& TEST_true(RSA_set0_factors(key, p, q));
if (!ret) {
BN_free(p);
BN_free(q);
goto end;
}
ret = TEST_int_le(ossl_rsa_sp800_56b_derive_params_from_pq(key, 8, e, ctx), 0);
end:
BN_free(e);
RSA_free(key);
BN_CTX_free(ctx);
return ret;
}
static int test_pq_diff(void)
{
int ret = 0;
BIGNUM *tmp = NULL, *p = NULL, *q = NULL;
ret = TEST_ptr(tmp = BN_new())
&& TEST_ptr(p = BN_new())
&& TEST_ptr(q = BN_new())
/* |1-(2+1)| > 2^1 */
&& TEST_true(BN_set_word(p, 1))
&& TEST_true(BN_set_word(q, 1+2))
&& TEST_false(ossl_rsa_check_pminusq_diff(tmp, p, q, 202))
/* Check |p - q| > 2^(nbits/2 - 100) */
&& TEST_true(BN_set_word(q, 1+3))
&& TEST_true(ossl_rsa_check_pminusq_diff(tmp, p, q, 202))
&& TEST_true(BN_set_word(p, 1+3))
&& TEST_true(BN_set_word(q, 1))
&& TEST_true(ossl_rsa_check_pminusq_diff(tmp, p, q, 202));
BN_free(p);
BN_free(q);
BN_free(tmp);
return ret;
}
static int test_invalid_keypair(void)
{
int ret = 0;
RSA *key = NULL;
BN_CTX *ctx = NULL;
BIGNUM *p = NULL, *q = NULL, *n = NULL, *e = NULL, *d = NULL;
ret = TEST_ptr(key = RSA_new())
&& TEST_ptr(ctx = BN_CTX_new())
/* NULL parameters */
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))
/* load key */
&& TEST_ptr(p = bn_load_new(cav_p, sizeof(cav_p)))
&& TEST_ptr(q = bn_load_new(cav_q, sizeof(cav_q)))
&& TEST_true(RSA_set0_factors(key, p, q));
if (!ret) {
BN_free(p);
BN_free(q);
goto end;
}
ret = TEST_ptr(e = bn_load_new(cav_e, sizeof(cav_e)))
&& TEST_ptr(n = bn_load_new(cav_n, sizeof(cav_n)))
&& TEST_ptr(d = bn_load_new(cav_d, sizeof(cav_d)))
&& TEST_true(RSA_set0_key(key, n, e, d));
if (!ret) {
BN_free(e);
BN_free(n);
BN_free(d);
goto end;
}
/* bad strength/key size */
ret = TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, 100, 2048))
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, 112, 1024))
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, 128, 2048))
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, 140, 3072))
/* mismatching exponent */
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, BN_value_one(),
-1, 2048))
/* bad exponent */
&& TEST_true(BN_add_word(e, 1))
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))
&& TEST_true(BN_sub_word(e, 1))
/* mismatch between bits and modulus */
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, 3072))
&& TEST_true(ossl_rsa_sp800_56b_check_keypair(key, e, 112, 2048))
/* check n == pq failure */
&& TEST_true(BN_add_word(n, 1))
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))
&& TEST_true(BN_sub_word(n, 1))
/* check that validation fails if len(n) is not even */
&& TEST_true(BN_lshift1(n, n))
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, 2049))
&& TEST_true(BN_rshift1(n, n))
/* check p */
&& TEST_true(BN_sub_word(p, 2))
&& TEST_true(BN_mul(n, p, q, ctx))
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))
&& TEST_true(BN_add_word(p, 2))
&& TEST_true(BN_mul(n, p, q, ctx))
/* check q */
&& TEST_true(BN_sub_word(q, 2))
&& TEST_true(BN_mul(n, p, q, ctx))
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))
&& TEST_true(BN_add_word(q, 2))
&& TEST_true(BN_mul(n, p, q, ctx));
end:
RSA_free(key);
BN_CTX_free(ctx);
return ret;
}
static int keygen_size[] =
{
2048, 3072
};
static int test_sp80056b_keygen(int id)
{
RSA *key = NULL;
int ret;
int sz = keygen_size[id];
ret = TEST_ptr(key = RSA_new())
&& TEST_true(ossl_rsa_sp800_56b_generate_key(key, sz, NULL, NULL))
&& TEST_true(ossl_rsa_sp800_56b_check_public(key))
&& TEST_true(ossl_rsa_sp800_56b_check_private(key))
&& TEST_true(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, sz));
RSA_free(key);
return ret;
}
static int test_check_private_key(void)
{
int ret = 0;
BIGNUM *n = NULL, *d = NULL, *e = NULL;
RSA *key = NULL;
ret = TEST_ptr(key = RSA_new())
/* check NULL pointers fail */
&& TEST_false(ossl_rsa_sp800_56b_check_private(key))
/* load private key */
&& TEST_ptr(n = bn_load_new(cav_n, sizeof(cav_n)))
&& TEST_ptr(d = bn_load_new(cav_d, sizeof(cav_d)))
&& TEST_ptr(e = bn_load_new(cav_e, sizeof(cav_e)))
&& TEST_true(RSA_set0_key(key, n, e, d));
if (!ret) {
BN_free(n);
BN_free(e);
BN_free(d);
goto end;
}
/* check d is in range */
ret = TEST_true(ossl_rsa_sp800_56b_check_private(key))
/* check d is too low */
&& TEST_true(BN_set_word(d, 0))
&& TEST_false(ossl_rsa_sp800_56b_check_private(key))
/* check d is too high */
&& TEST_ptr(BN_copy(d, n))
&& TEST_false(ossl_rsa_sp800_56b_check_private(key));
end:
RSA_free(key);
return ret;
}
static int test_check_public_key(void)
{
int ret = 0;
BIGNUM *n = NULL, *e = NULL;
RSA *key = NULL;
ret = TEST_ptr(key = RSA_new())
/* check NULL pointers fail */
&& TEST_false(ossl_rsa_sp800_56b_check_public(key))
/* load public key */
&& TEST_ptr(e = bn_load_new(cav_e, sizeof(cav_e)))
&& TEST_ptr(n = bn_load_new(cav_n, sizeof(cav_n)))
&& TEST_true(RSA_set0_key(key, n, e, NULL));
if (!ret) {
BN_free(e);
BN_free(n);
goto end;
}
/* check public key is valid */
ret = TEST_true(ossl_rsa_sp800_56b_check_public(key))
/* check fail if n is even */
&& TEST_true(BN_add_word(n, 1))
&& TEST_false(ossl_rsa_sp800_56b_check_public(key))
&& TEST_true(BN_sub_word(n, 1))
/* check fail if n is wrong number of bits */
&& TEST_true(BN_lshift1(n, n))
&& TEST_false(ossl_rsa_sp800_56b_check_public(key))
&& TEST_true(BN_rshift1(n, n))
/* test odd exponent fails */
&& TEST_true(BN_add_word(e, 1))
&& TEST_false(ossl_rsa_sp800_56b_check_public(key))
&& TEST_true(BN_sub_word(e, 1))
/* modulus fails composite check */
&& TEST_true(BN_add_word(n, 2))
&& TEST_false(ossl_rsa_sp800_56b_check_public(key));
end:
RSA_free(key);
return ret;
}
int setup_tests(void)
{
ADD_TEST(test_check_public_exponent);
ADD_TEST(test_check_prime_factor_range);
ADD_TEST(test_check_prime_factor);
ADD_TEST(test_check_private_exponent);
ADD_TEST(test_check_crt_components);
ADD_ALL_TESTS(test_derive_params_from_pq_fail, (int)OSSL_NELEM(derive_from_pq_tests));
ADD_TEST(test_check_private_key);
ADD_TEST(test_check_public_key);
ADD_TEST(test_invalid_keypair);
ADD_TEST(test_pq_diff);
ADD_ALL_TESTS(test_sp80056b_keygen, (int)OSSL_NELEM(keygen_size));
return 1;
}
|
./openssl/test/rdcpu_sanitytest.c | /*
* Copyright 2018-2022 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 "testutil.h"
#include "internal/cryptlib.h"
#if (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || \
defined(_M_AMD64) || defined (_M_X64)) && defined(OPENSSL_CPUID_OBJ)
# define IS_X_86 1
size_t OPENSSL_ia32_rdrand_bytes(unsigned char *buf, size_t len);
size_t OPENSSL_ia32_rdseed_bytes(unsigned char *buf, size_t len);
#else
# define IS_X_86 0
#endif
#if defined(__aarch64__) && defined(OPENSSL_CPUID_OBJ)
# define IS_AARCH_64 1
# include "arm_arch.h"
size_t OPENSSL_rndr_bytes(unsigned char *buf, size_t len);
size_t OPENSSL_rndrrs_bytes(unsigned char *buf, size_t len);
#else
# define IS_AARCH_64 0
#endif
#if (IS_X_86 || IS_AARCH_64)
static int sanity_check_bytes(size_t (*rng)(unsigned char *, size_t),
int rounds, int min_failures, int max_retries, int max_zero_words)
{
int testresult = 0;
unsigned char prior[31] = {0}, buf[31] = {0}, check[7];
int failures = 0, zero_words = 0;
int i;
for (i = 0; i < rounds; i++) {
size_t generated = 0;
int retry;
for (retry = 0; retry < max_retries; retry++) {
generated = rng(buf, sizeof(buf));
if (generated == sizeof(buf))
break;
failures++;
}
/*-
* Verify that we don't have too many unexpected runs of zeroes,
* implying that we might be accidentally using the 32-bit RDRAND
* instead of the 64-bit one on 64-bit systems.
*/
size_t j;
for (j = 0; j < sizeof(buf) - 1; j++) {
if (buf[j] == 0 && buf[j+1] == 0) {
zero_words++;
}
}
if (!TEST_int_eq(generated, sizeof(buf)))
goto end;
if (!TEST_false(!memcmp(prior, buf, sizeof(buf))))
goto end;
/* Verify that the last 7 bytes of buf aren't all the same value */
unsigned char *tail = &buf[sizeof(buf) - sizeof(check)];
memset(check, tail[0], 7);
if (!TEST_false(!memcmp(check, tail, sizeof(check))))
goto end;
/* Save the result and make sure it's different next time */
memcpy(prior, buf, sizeof(buf));
}
if (!TEST_int_le(zero_words, max_zero_words))
goto end;
if (!TEST_int_ge(failures, min_failures))
goto end;
testresult = 1;
end:
return testresult;
}
#endif
#if IS_X_86
static int sanity_check_rdrand_bytes(void)
{
return sanity_check_bytes(OPENSSL_ia32_rdrand_bytes, 1000, 0, 10, 10);
}
static int sanity_check_rdseed_bytes(void)
{
/*-
* RDSEED may take many retries to succeed; note that this is effectively
* multiplied by the 8x retry loop in asm, and failure probabilities are
* increased by the fact that we need either 4 or 8 samples depending on
* the platform.
*/
return sanity_check_bytes(OPENSSL_ia32_rdseed_bytes, 1000, 1, 10000, 10);
}
#elif IS_AARCH_64
static int sanity_check_rndr_bytes(void)
{
return sanity_check_bytes(OPENSSL_rndr_bytes, 1000, 0, 10, 10);
}
static int sanity_check_rndrrs_bytes(void)
{
return sanity_check_bytes(OPENSSL_rndrrs_bytes, 1000, 0, 10000, 10);
}
#endif
int setup_tests(void)
{
#if (IS_X_86 || IS_AARCH_64)
OPENSSL_cpuid_setup();
# if IS_X_86
int have_rdseed = (OPENSSL_ia32cap_P[2] & (1 << 18)) != 0;
int have_rdrand = (OPENSSL_ia32cap_P[1] & (1 << (62 - 32))) != 0;
if (have_rdrand) {
ADD_TEST(sanity_check_rdrand_bytes);
}
if (have_rdseed) {
ADD_TEST(sanity_check_rdseed_bytes);
}
# elif IS_AARCH_64
int have_rndr_rndrrs = (OPENSSL_armcap_P & (1 << 8)) != 0;
if (have_rndr_rndrrs) {
ADD_TEST(sanity_check_rndr_bytes);
ADD_TEST(sanity_check_rndrrs_bytes);
}
# endif
#endif
return 1;
}
|
./openssl/test/sslbuffertest.c | /*
* Copyright 2016-2023 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 may obtain a copy of the License at
* https://www.openssl.org/source/license.html
* or in the file LICENSE in the source distribution.
*/
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>
/* We include internal headers so we can check if the buffers are allocated */
#include "../ssl/ssl_local.h"
#include "../ssl/record/record_local.h"
#include "internal/recordmethod.h"
#include "../ssl/record/methods/recmethod_local.h"
#include "internal/packet.h"
#include "helpers/ssltestlib.h"
#include "testutil.h"
struct async_ctrs {
unsigned int rctr;
unsigned int wctr;
};
static SSL_CTX *serverctx = NULL;
static SSL_CTX *clientctx = NULL;
#define MAX_ATTEMPTS 100
static int checkbuffers(SSL *s, int isalloced)
{
SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);
OSSL_RECORD_LAYER *rrl = sc->rlayer.rrl;
OSSL_RECORD_LAYER *wrl = sc->rlayer.wrl;
if (isalloced)
return rrl->rbuf.buf != NULL && wrl->wbuf[0].buf != NULL;
return rrl->rbuf.buf == NULL && wrl->wbuf[0].buf == NULL;
}
/*
* There are 9 passes in the tests
* 0 = control test
* tests during writes
* 1 = free buffers
* 2 = + allocate buffers after free
* 3 = + allocate buffers again
* 4 = + free buffers after allocation
* tests during reads
* 5 = + free buffers
* 6 = + free buffers again
* 7 = + allocate buffers after free
* 8 = + free buffers after allocation
*/
static int test_func(int test)
{
int result = 0;
SSL *serverssl = NULL, *clientssl = NULL;
int ret;
size_t i, j;
const char testdata[] = "Test data";
char buf[sizeof(testdata)];
if (!TEST_true(create_ssl_objects(serverctx, clientctx, &serverssl, &clientssl,
NULL, NULL))) {
TEST_error("Test %d failed: Create SSL objects failed\n", test);
goto end;
}
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))) {
TEST_error("Test %d failed: Create SSL connection failed\n", test);
goto end;
}
/*
* Send and receive some test data. Do the whole thing twice to ensure
* we hit at least one async event in both reading and writing
*/
for (j = 0; j < 2; j++) {
int len;
/*
* Write some test data. It should never take more than 2 attempts
* (the first one might be a retryable fail).
*/
for (ret = -1, i = 0, len = 0; len != sizeof(testdata) && i < 2;
i++) {
/* test == 0 mean to free/allocate = control */
if (test >= 1 && (!TEST_true(SSL_free_buffers(clientssl))
|| !TEST_true(checkbuffers(clientssl, 0))))
goto end;
if (test >= 2 && (!TEST_true(SSL_alloc_buffers(clientssl))
|| !TEST_true(checkbuffers(clientssl, 1))))
goto end;
/* allocate a second time */
if (test >= 3 && (!TEST_true(SSL_alloc_buffers(clientssl))
|| !TEST_true(checkbuffers(clientssl, 1))))
goto end;
if (test >= 4 && (!TEST_true(SSL_free_buffers(clientssl))
|| !TEST_true(checkbuffers(clientssl, 0))))
goto end;
ret = SSL_write(clientssl, testdata + len,
sizeof(testdata) - len);
if (ret > 0) {
len += ret;
} else {
int ssl_error = SSL_get_error(clientssl, ret);
if (ssl_error == SSL_ERROR_SYSCALL ||
ssl_error == SSL_ERROR_SSL) {
TEST_error("Test %d failed: Failed to write app data\n", test);
goto end;
}
}
}
if (!TEST_size_t_eq(len, sizeof(testdata)))
goto end;
/*
* Now read the test data. It may take more attempts here because
* it could fail once for each byte read, including all overhead
* bytes from the record header/padding etc.
*/
for (ret = -1, i = 0, len = 0; len != sizeof(testdata) &&
i < MAX_ATTEMPTS; i++)
{
if (test >= 5 && (!TEST_true(SSL_free_buffers(serverssl))
|| !TEST_true(checkbuffers(serverssl, 0))))
goto end;
/* free a second time */
if (test >= 6 && (!TEST_true(SSL_free_buffers(serverssl))
|| !TEST_true(checkbuffers(serverssl, 0))))
goto end;
if (test >= 7 && (!TEST_true(SSL_alloc_buffers(serverssl))
|| !TEST_true(checkbuffers(serverssl, 1))))
goto end;
if (test >= 8 && (!TEST_true(SSL_free_buffers(serverssl))
|| !TEST_true(checkbuffers(serverssl, 0))))
goto end;
ret = SSL_read(serverssl, buf + len, sizeof(buf) - len);
if (ret > 0) {
len += ret;
} else {
int ssl_error = SSL_get_error(serverssl, ret);
if (ssl_error == SSL_ERROR_SYSCALL ||
ssl_error == SSL_ERROR_SSL) {
TEST_error("Test %d failed: Failed to read app data\n", test);
goto end;
}
}
}
if (!TEST_mem_eq(buf, len, testdata, sizeof(testdata)))
goto end;
}
result = 1;
end:
if (!result)
ERR_print_errors_fp(stderr);
SSL_free(clientssl);
SSL_free(serverssl);
return result;
}
OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
int setup_tests(void)
{
char *cert, *pkey;
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
if (!TEST_ptr(cert = test_get_argument(0))
|| !TEST_ptr(pkey = test_get_argument(1)))
return 0;
if (!create_ssl_ctx_pair(NULL, TLS_server_method(), TLS_client_method(),
TLS1_VERSION, 0,
&serverctx, &clientctx, cert, pkey)) {
TEST_error("Failed to create SSL_CTX pair\n");
return 0;
}
ADD_ALL_TESTS(test_func, 9);
return 1;
}
void cleanup_tests(void)
{
SSL_CTX_free(clientctx);
SSL_CTX_free(serverctx);
}
|
./openssl/test/endecode_test.c | /*
* Copyright 2020-2023 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 <string.h>
#include <openssl/core_dispatch.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
#include <openssl/core_names.h>
#include <openssl/params.h>
#include <openssl/param_build.h>
#include <openssl/encoder.h>
#include <openssl/decoder.h>
#include "internal/cryptlib.h" /* ossl_assert */
#include "crypto/pem.h" /* For PVK and "blob" PEM headers */
#include "crypto/evp.h" /* For evp_pkey_is_provided() */
#include "helpers/predefined_dhparams.h"
#include "testutil.h"
#ifdef STATIC_LEGACY
OSSL_provider_init_fn ossl_legacy_provider_init;
#endif
/* Extended test macros to allow passing file & line number */
#define TEST_FL_ptr(a) test_ptr(file, line, #a, a)
#define TEST_FL_mem_eq(a, m, b, n) test_mem_eq(file, line, #a, #b, a, m, b, n)
#define TEST_FL_strn_eq(a, b, n) test_strn_eq(file, line, #a, #b, a, n, b, n)
#define TEST_FL_strn2_eq(a, m, b, n) test_strn_eq(file, line, #a, #b, a, m, b, n)
#define TEST_FL_int_eq(a, b) test_int_eq(file, line, #a, #b, a, b)
#define TEST_FL_int_ge(a, b) test_int_ge(file, line, #a, #b, a, b)
#define TEST_FL_int_gt(a, b) test_int_gt(file, line, #a, #b, a, b)
#define TEST_FL_long_gt(a, b) test_long_gt(file, line, #a, #b, a, b)
#define TEST_FL_true(a) test_true(file, line, #a, (a) != 0)
#if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC)
# define OPENSSL_NO_KEYPARAMS
#endif
static int default_libctx = 1;
static int is_fips = 0;
static int is_fips_3_0_0 = 0;
static OSSL_LIB_CTX *testctx = NULL;
static OSSL_LIB_CTX *keyctx = NULL;
static char *testpropq = NULL;
static OSSL_PROVIDER *nullprov = NULL;
static OSSL_PROVIDER *deflprov = NULL;
static OSSL_PROVIDER *keyprov = NULL;
#ifndef OPENSSL_NO_EC
static BN_CTX *bnctx = NULL;
static OSSL_PARAM_BLD *bld_prime_nc = NULL;
static OSSL_PARAM_BLD *bld_prime = NULL;
static OSSL_PARAM *ec_explicit_prime_params_nc = NULL;
static OSSL_PARAM *ec_explicit_prime_params_explicit = NULL;
# ifndef OPENSSL_NO_EC2M
static OSSL_PARAM_BLD *bld_tri_nc = NULL;
static OSSL_PARAM_BLD *bld_tri = NULL;
static OSSL_PARAM *ec_explicit_tri_params_nc = NULL;
static OSSL_PARAM *ec_explicit_tri_params_explicit = NULL;
# endif
#endif
#ifndef OPENSSL_NO_KEYPARAMS
static EVP_PKEY *make_template(const char *type, OSSL_PARAM *genparams)
{
EVP_PKEY *pkey = NULL;
EVP_PKEY_CTX *ctx = NULL;
# ifndef OPENSSL_NO_DH
/*
* Use 512-bit DH(X) keys with predetermined parameters for efficiency,
* for testing only. Use a minimum key size of 2048 for security purposes.
*/
if (strcmp(type, "DH") == 0)
return get_dh512(keyctx);
if (strcmp(type, "X9.42 DH") == 0)
return get_dhx512(keyctx);
# endif
/*
* No real need to check the errors other than for the cascade
* effect. |pkey| will simply remain NULL if something goes wrong.
*/
(void)((ctx = EVP_PKEY_CTX_new_from_name(keyctx, type, testpropq)) != NULL
&& EVP_PKEY_paramgen_init(ctx) > 0
&& (genparams == NULL
|| EVP_PKEY_CTX_set_params(ctx, genparams) > 0)
&& EVP_PKEY_generate(ctx, &pkey) > 0);
EVP_PKEY_CTX_free(ctx);
return pkey;
}
#endif
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_EC)
static EVP_PKEY *make_key(const char *type, EVP_PKEY *template,
OSSL_PARAM *genparams)
{
EVP_PKEY *pkey = NULL;
EVP_PKEY_CTX *ctx =
template != NULL
? EVP_PKEY_CTX_new_from_pkey(keyctx, template, testpropq)
: EVP_PKEY_CTX_new_from_name(keyctx, type, testpropq);
/*
* No real need to check the errors other than for the cascade
* effect. |pkey| will simply remain NULL if something goes wrong.
*/
(void)(ctx != NULL
&& EVP_PKEY_keygen_init(ctx) > 0
&& (genparams == NULL
|| EVP_PKEY_CTX_set_params(ctx, genparams) > 0)
&& EVP_PKEY_keygen(ctx, &pkey) > 0);
EVP_PKEY_CTX_free(ctx);
return pkey;
}
#endif
/* Main test driver */
typedef int (encoder)(const char *file, const int line,
void **encoded, long *encoded_len,
void *object, int selection,
const char *output_type, const char *output_structure,
const char *pass, const char *pcipher);
typedef int (decoder)(const char *file, const int line,
void **object, void *encoded, long encoded_len,
const char *input_type, const char *structure_type,
const char *keytype, int selection, const char *pass);
typedef int (tester)(const char *file, const int line,
const void *data1, size_t data1_len,
const void *data2, size_t data2_len);
typedef int (checker)(const char *file, const int line,
const char *type, const void *data, size_t data_len);
typedef void (dumper)(const char *label, const void *data, size_t data_len);
#define FLAG_DECODE_WITH_TYPE 0x0001
#define FLAG_FAIL_IF_FIPS 0x0002
static int test_encode_decode(const char *file, const int line,
const char *type, EVP_PKEY *pkey,
int selection, const char *output_type,
const char *output_structure,
const char *pass, const char *pcipher,
encoder *encode_cb, decoder *decode_cb,
tester *test_cb, checker *check_cb,
dumper *dump_cb, int flags)
{
void *encoded = NULL;
long encoded_len = 0;
EVP_PKEY *pkey2 = NULL;
EVP_PKEY *pkey3 = NULL;
void *encoded2 = NULL;
long encoded2_len = 0;
int ok = 0;
/*
* Encode |pkey|, decode the result into |pkey2|, and finish off by
* encoding |pkey2| as well. That last encoding is for checking and
* dumping purposes.
*/
if (!TEST_true(encode_cb(file, line, &encoded, &encoded_len, pkey, selection,
output_type, output_structure, pass, pcipher)))
goto end;
if ((flags & FLAG_FAIL_IF_FIPS) != 0 && is_fips && !is_fips_3_0_0) {
if (TEST_false(decode_cb(file, line, (void **)&pkey2, encoded,
encoded_len, output_type, output_structure,
(flags & FLAG_DECODE_WITH_TYPE ? type : NULL),
selection, pass)))
ok = 1;
goto end;
}
if (!TEST_true(check_cb(file, line, type, encoded, encoded_len))
|| !TEST_true(decode_cb(file, line, (void **)&pkey2, encoded, encoded_len,
output_type, output_structure,
(flags & FLAG_DECODE_WITH_TYPE ? type : NULL),
selection, pass))
|| ((output_structure == NULL
|| strcmp(output_structure, "type-specific") != 0)
&& !TEST_true(decode_cb(file, line, (void **)&pkey3, encoded, encoded_len,
output_type, output_structure,
(flags & FLAG_DECODE_WITH_TYPE ? type : NULL),
0, pass)))
|| !TEST_true(encode_cb(file, line, &encoded2, &encoded2_len, pkey2, selection,
output_type, output_structure, pass, pcipher)))
goto end;
if (selection == OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) {
if (!TEST_int_eq(EVP_PKEY_parameters_eq(pkey, pkey2), 1)
|| (pkey3 != NULL
&& !TEST_int_eq(EVP_PKEY_parameters_eq(pkey, pkey3), 1)))
goto end;
} else {
if (!TEST_int_eq(EVP_PKEY_eq(pkey, pkey2), 1)
|| (pkey3 != NULL
&& !TEST_int_eq(EVP_PKEY_eq(pkey, pkey3), 1)))
goto end;
}
/*
* Double check the encoding, but only for unprotected keys,
* as protected keys have a random component, which makes the output
* differ.
*/
if ((pass == NULL && pcipher == NULL)
&& !test_cb(file, line, encoded, encoded_len, encoded2, encoded2_len))
goto end;
ok = 1;
end:
if (!ok) {
if (encoded != NULL && encoded_len != 0)
dump_cb("|pkey| encoded", encoded, encoded_len);
if (encoded2 != NULL && encoded2_len != 0)
dump_cb("|pkey2| encoded", encoded2, encoded2_len);
}
OPENSSL_free(encoded);
OPENSSL_free(encoded2);
EVP_PKEY_free(pkey2);
EVP_PKEY_free(pkey3);
return ok;
}
/* Encoding and decoding methods */
static int encode_EVP_PKEY_prov(const char *file, const int line,
void **encoded, long *encoded_len,
void *object, int selection,
const char *output_type,
const char *output_structure,
const char *pass, const char *pcipher)
{
EVP_PKEY *pkey = object;
OSSL_ENCODER_CTX *ectx = NULL;
BIO *mem_ser = NULL;
BUF_MEM *mem_buf = NULL;
const unsigned char *upass = (const unsigned char *)pass;
int ok = 0;
if (!TEST_FL_ptr(ectx = OSSL_ENCODER_CTX_new_for_pkey(pkey, selection,
output_type,
output_structure,
testpropq))
|| !TEST_FL_int_gt(OSSL_ENCODER_CTX_get_num_encoders(ectx), 0)
|| (pass != NULL
&& !TEST_FL_true(OSSL_ENCODER_CTX_set_passphrase(ectx, upass,
strlen(pass))))
|| (pcipher != NULL
&& !TEST_FL_true(OSSL_ENCODER_CTX_set_cipher(ectx, pcipher, NULL)))
|| !TEST_FL_ptr(mem_ser = BIO_new(BIO_s_mem()))
|| !TEST_FL_true(OSSL_ENCODER_to_bio(ectx, mem_ser))
|| !TEST_FL_true(BIO_get_mem_ptr(mem_ser, &mem_buf) > 0)
|| !TEST_FL_ptr(*encoded = mem_buf->data)
|| !TEST_FL_long_gt(*encoded_len = mem_buf->length, 0))
goto end;
/* Detach the encoded output */
mem_buf->data = NULL;
mem_buf->length = 0;
ok = 1;
end:
BIO_free(mem_ser);
OSSL_ENCODER_CTX_free(ectx);
return ok;
}
static int decode_EVP_PKEY_prov(const char *file, const int line,
void **object, void *encoded, long encoded_len,
const char *input_type,
const char *structure_type,
const char *keytype, int selection,
const char *pass)
{
EVP_PKEY *pkey = NULL, *testpkey = NULL;
OSSL_DECODER_CTX *dctx = NULL;
BIO *encoded_bio = NULL;
const unsigned char *upass = (const unsigned char *)pass;
int ok = 0;
int i;
const char *badtype;
if (strcmp(input_type, "DER") == 0)
badtype = "PEM";
else
badtype = "DER";
if (!TEST_FL_ptr(encoded_bio = BIO_new_mem_buf(encoded, encoded_len)))
goto end;
/*
* We attempt the decode 3 times. The first time we provide the expected
* starting input type. The second time we provide NULL for the starting
* type. The third time we provide a bad starting input type.
* The bad starting input type should fail. The other two should succeed
* and produce the same result.
*/
for (i = 0; i < 3; i++) {
const char *testtype = (i == 0) ? input_type
: ((i == 1) ? NULL : badtype);
if (!TEST_FL_ptr(dctx = OSSL_DECODER_CTX_new_for_pkey(&testpkey,
testtype,
structure_type,
keytype,
selection,
testctx, testpropq))
|| (pass != NULL
&& !OSSL_DECODER_CTX_set_passphrase(dctx, upass, strlen(pass)))
|| !TEST_FL_int_gt(BIO_reset(encoded_bio), 0)
/* We expect to fail when using a bad input type */
|| !TEST_FL_int_eq(OSSL_DECODER_from_bio(dctx, encoded_bio),
(i == 2) ? 0 : 1))
goto end;
OSSL_DECODER_CTX_free(dctx);
dctx = NULL;
if (i == 0) {
pkey = testpkey;
testpkey = NULL;
} else if (i == 1) {
if (selection == OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) {
if (!TEST_FL_int_eq(EVP_PKEY_parameters_eq(pkey, testpkey), 1))
goto end;
} else {
if (!TEST_FL_int_eq(EVP_PKEY_eq(pkey, testpkey), 1))
goto end;
}
}
}
ok = 1;
*object = pkey;
pkey = NULL;
end:
EVP_PKEY_free(pkey);
EVP_PKEY_free(testpkey);
BIO_free(encoded_bio);
OSSL_DECODER_CTX_free(dctx);
return ok;
}
static int encode_EVP_PKEY_legacy_PEM(const char *file, const int line,
void **encoded, long *encoded_len,
void *object, ossl_unused int selection,
ossl_unused const char *output_type,
ossl_unused const char *output_structure,
const char *pass, const char *pcipher)
{
EVP_PKEY *pkey = object;
EVP_CIPHER *cipher = NULL;
BIO *mem_ser = NULL;
BUF_MEM *mem_buf = NULL;
const unsigned char *upass = (const unsigned char *)pass;
size_t passlen = 0;
int ok = 0;
if (pcipher != NULL && pass != NULL) {
passlen = strlen(pass);
if (!TEST_FL_ptr(cipher = EVP_CIPHER_fetch(testctx, pcipher, testpropq)))
goto end;
}
if (!TEST_FL_ptr(mem_ser = BIO_new(BIO_s_mem()))
|| !TEST_FL_true(PEM_write_bio_PrivateKey_traditional(mem_ser, pkey,
cipher,
upass, passlen,
NULL, NULL))
|| !TEST_FL_true(BIO_get_mem_ptr(mem_ser, &mem_buf) > 0)
|| !TEST_FL_ptr(*encoded = mem_buf->data)
|| !TEST_FL_long_gt(*encoded_len = mem_buf->length, 0))
goto end;
/* Detach the encoded output */
mem_buf->data = NULL;
mem_buf->length = 0;
ok = 1;
end:
BIO_free(mem_ser);
EVP_CIPHER_free(cipher);
return ok;
}
static int encode_EVP_PKEY_MSBLOB(const char *file, const int line,
void **encoded, long *encoded_len,
void *object, int selection,
ossl_unused const char *output_type,
ossl_unused const char *output_structure,
ossl_unused const char *pass,
ossl_unused const char *pcipher)
{
EVP_PKEY *pkey = object;
BIO *mem_ser = NULL;
BUF_MEM *mem_buf = NULL;
int ok = 0;
if (!TEST_FL_ptr(mem_ser = BIO_new(BIO_s_mem())))
goto end;
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
if (!TEST_FL_int_ge(i2b_PrivateKey_bio(mem_ser, pkey), 0))
goto end;
} else {
if (!TEST_FL_int_ge(i2b_PublicKey_bio(mem_ser, pkey), 0))
goto end;
}
if (!TEST_FL_true(BIO_get_mem_ptr(mem_ser, &mem_buf) > 0)
|| !TEST_FL_ptr(*encoded = mem_buf->data)
|| !TEST_FL_long_gt(*encoded_len = mem_buf->length, 0))
goto end;
/* Detach the encoded output */
mem_buf->data = NULL;
mem_buf->length = 0;
ok = 1;
end:
BIO_free(mem_ser);
return ok;
}
static pem_password_cb pass_pw;
static int pass_pw(char *buf, int size, int rwflag, void *userdata)
{
OPENSSL_strlcpy(buf, userdata, size);
return strlen(userdata);
}
static int encode_EVP_PKEY_PVK(const char *file, const int line,
void **encoded, long *encoded_len,
void *object, int selection,
ossl_unused const char *output_type,
ossl_unused const char *output_structure,
const char *pass,
ossl_unused const char *pcipher)
{
EVP_PKEY *pkey = object;
BIO *mem_ser = NULL;
BUF_MEM *mem_buf = NULL;
int enc = (pass != NULL);
int ok = 0;
if (!TEST_FL_true(ossl_assert((selection
& OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0))
|| !TEST_FL_ptr(mem_ser = BIO_new(BIO_s_mem()))
|| !TEST_FL_int_ge(i2b_PVK_bio_ex(mem_ser, pkey, enc,
pass_pw, (void *)pass, testctx, testpropq), 0)
|| !TEST_FL_true(BIO_get_mem_ptr(mem_ser, &mem_buf) > 0)
|| !TEST_FL_ptr(*encoded = mem_buf->data)
|| !TEST_FL_long_gt(*encoded_len = mem_buf->length, 0))
goto end;
/* Detach the encoded output */
mem_buf->data = NULL;
mem_buf->length = 0;
ok = 1;
end:
BIO_free(mem_ser);
return ok;
}
static int test_text(const char *file, const int line,
const void *data1, size_t data1_len,
const void *data2, size_t data2_len)
{
return TEST_FL_strn2_eq(data1, data1_len, data2, data2_len);
}
static int test_mem(const char *file, const int line,
const void *data1, size_t data1_len,
const void *data2, size_t data2_len)
{
return TEST_FL_mem_eq(data1, data1_len, data2, data2_len);
}
/* Test cases and their dumpers / checkers */
static void collect_name(const char *name, void *arg)
{
char **namelist = arg;
char *new_namelist;
size_t space;
space = strlen(name);
if (*namelist != NULL)
space += strlen(*namelist) + 2 /* for comma and space */;
space++; /* for terminating null byte */
new_namelist = OPENSSL_realloc(*namelist, space);
if (new_namelist == NULL)
return;
if (*namelist != NULL) {
strcat(new_namelist, ", ");
strcat(new_namelist, name);
} else {
strcpy(new_namelist, name);
}
*namelist = new_namelist;
}
static void dump_der(const char *label, const void *data, size_t data_len)
{
test_output_memory(label, data, data_len);
}
static void dump_pem(const char *label, const void *data, size_t data_len)
{
test_output_string(label, data, data_len - 1);
}
static int check_unprotected_PKCS8_DER(const char *file, const int line,
const char *type,
const void *data, size_t data_len)
{
const unsigned char *datap = data;
PKCS8_PRIV_KEY_INFO *p8inf =
d2i_PKCS8_PRIV_KEY_INFO(NULL, &datap, data_len);
int ok = 0;
if (TEST_FL_ptr(p8inf)) {
EVP_PKEY *pkey = EVP_PKCS82PKEY_ex(p8inf, testctx, testpropq);
char *namelist = NULL;
if (TEST_FL_ptr(pkey)) {
if (!(ok = TEST_FL_true(EVP_PKEY_is_a(pkey, type)))) {
EVP_PKEY_type_names_do_all(pkey, collect_name, &namelist);
if (namelist != NULL)
TEST_note("%s isn't any of %s", type, namelist);
OPENSSL_free(namelist);
}
ok = ok && TEST_FL_true(evp_pkey_is_provided(pkey));
EVP_PKEY_free(pkey);
}
}
PKCS8_PRIV_KEY_INFO_free(p8inf);
return ok;
}
static int test_unprotected_via_DER(const char *type, EVP_PKEY *key, int fips)
{
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_ALL_PARAMETERS,
"DER", "PrivateKeyInfo", NULL, NULL,
encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
test_mem, check_unprotected_PKCS8_DER,
dump_der, fips ? 0 : FLAG_FAIL_IF_FIPS);
}
static int check_unprotected_PKCS8_PEM(const char *file, const int line,
const char *type,
const void *data, size_t data_len)
{
static const char expected_pem_header[] =
"-----BEGIN " PEM_STRING_PKCS8INF "-----";
return TEST_FL_strn_eq(data, expected_pem_header,
sizeof(expected_pem_header) - 1);
}
static int test_unprotected_via_PEM(const char *type, EVP_PKEY *key, int fips)
{
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_ALL_PARAMETERS,
"PEM", "PrivateKeyInfo", NULL, NULL,
encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
test_text, check_unprotected_PKCS8_PEM,
dump_pem, fips ? 0 : FLAG_FAIL_IF_FIPS);
}
#ifndef OPENSSL_NO_KEYPARAMS
static int check_params_DER(const char *file, const int line,
const char *type, const void *data, size_t data_len)
{
const unsigned char *datap = data;
int ok = 0;
int itype = NID_undef;
EVP_PKEY *pkey = NULL;
if (strcmp(type, "DH") == 0)
itype = EVP_PKEY_DH;
else if (strcmp(type, "X9.42 DH") == 0)
itype = EVP_PKEY_DHX;
else if (strcmp(type, "DSA") == 0)
itype = EVP_PKEY_DSA;
else if (strcmp(type, "EC") == 0)
itype = EVP_PKEY_EC;
if (itype != NID_undef) {
pkey = d2i_KeyParams(itype, NULL, &datap, data_len);
ok = (pkey != NULL);
EVP_PKEY_free(pkey);
}
return ok;
}
static int check_params_PEM(const char *file, const int line,
const char *type,
const void *data, size_t data_len)
{
static char expected_pem_header[80];
return
TEST_FL_int_gt(BIO_snprintf(expected_pem_header,
sizeof(expected_pem_header),
"-----BEGIN %s PARAMETERS-----", type), 0)
&& TEST_FL_strn_eq(data, expected_pem_header, strlen(expected_pem_header));
}
static int test_params_via_DER(const char *type, EVP_PKEY *key)
{
return test_encode_decode(__FILE__, __LINE__, type, key, OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"DER", "type-specific", NULL, NULL,
encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
test_mem, check_params_DER,
dump_der, FLAG_DECODE_WITH_TYPE);
}
static int test_params_via_PEM(const char *type, EVP_PKEY *key)
{
return test_encode_decode(__FILE__, __LINE__, type, key, OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"PEM", "type-specific", NULL, NULL,
encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
test_text, check_params_PEM,
dump_pem, 0);
}
#endif /* !OPENSSL_NO_KEYPARAMS */
static int check_unprotected_legacy_PEM(const char *file, const int line,
const char *type,
const void *data, size_t data_len)
{
static char expected_pem_header[80];
return
TEST_FL_int_gt(BIO_snprintf(expected_pem_header,
sizeof(expected_pem_header),
"-----BEGIN %s PRIVATE KEY-----", type), 0)
&& TEST_FL_strn_eq(data, expected_pem_header, strlen(expected_pem_header));
}
static int test_unprotected_via_legacy_PEM(const char *type, EVP_PKEY *key)
{
if (!default_libctx || is_fips)
return TEST_skip("Test not available if using a non-default library context or FIPS provider");
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"PEM", "type-specific", NULL, NULL,
encode_EVP_PKEY_legacy_PEM, decode_EVP_PKEY_prov,
test_text, check_unprotected_legacy_PEM,
dump_pem, 0);
}
static int check_MSBLOB(const char *file, const int line,
const char *type, const void *data, size_t data_len)
{
const unsigned char *datap = data;
EVP_PKEY *pkey = b2i_PrivateKey(&datap, data_len);
int ok = TEST_FL_ptr(pkey);
EVP_PKEY_free(pkey);
return ok;
}
static int test_unprotected_via_MSBLOB(const char *type, EVP_PKEY *key)
{
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"MSBLOB", NULL, NULL, NULL,
encode_EVP_PKEY_MSBLOB, decode_EVP_PKEY_prov,
test_mem, check_MSBLOB,
dump_der, 0);
}
static int check_PVK(const char *file, const int line,
const char *type, const void *data, size_t data_len)
{
const unsigned char *in = data;
unsigned int saltlen = 0, keylen = 0;
int ok = ossl_do_PVK_header(&in, data_len, 0, &saltlen, &keylen);
return ok;
}
static int test_unprotected_via_PVK(const char *type, EVP_PKEY *key)
{
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"PVK", NULL, NULL, NULL,
encode_EVP_PKEY_PVK, decode_EVP_PKEY_prov,
test_mem, check_PVK,
dump_der, 0);
}
static const char *pass_cipher = "AES-256-CBC";
static const char *pass = "the holy handgrenade of antioch";
static int check_protected_PKCS8_DER(const char *file, const int line,
const char *type,
const void *data, size_t data_len)
{
const unsigned char *datap = data;
X509_SIG *p8 = d2i_X509_SIG(NULL, &datap, data_len);
int ok = TEST_FL_ptr(p8);
X509_SIG_free(p8);
return ok;
}
static int test_protected_via_DER(const char *type, EVP_PKEY *key, int fips)
{
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"DER", "EncryptedPrivateKeyInfo",
pass, pass_cipher,
encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
test_mem, check_protected_PKCS8_DER,
dump_der, fips ? 0 : FLAG_FAIL_IF_FIPS);
}
static int check_protected_PKCS8_PEM(const char *file, const int line,
const char *type,
const void *data, size_t data_len)
{
static const char expected_pem_header[] =
"-----BEGIN " PEM_STRING_PKCS8 "-----";
return TEST_FL_strn_eq(data, expected_pem_header,
sizeof(expected_pem_header) - 1);
}
static int test_protected_via_PEM(const char *type, EVP_PKEY *key, int fips)
{
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"PEM", "EncryptedPrivateKeyInfo",
pass, pass_cipher,
encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
test_text, check_protected_PKCS8_PEM,
dump_pem, fips ? 0 : FLAG_FAIL_IF_FIPS);
}
static int check_protected_legacy_PEM(const char *file, const int line,
const char *type,
const void *data, size_t data_len)
{
static char expected_pem_header[80];
return
TEST_FL_int_gt(BIO_snprintf(expected_pem_header,
sizeof(expected_pem_header),
"-----BEGIN %s PRIVATE KEY-----", type), 0)
&& TEST_FL_strn_eq(data, expected_pem_header, strlen(expected_pem_header))
&& TEST_FL_ptr(strstr(data, "\nDEK-Info: "));
}
static int test_protected_via_legacy_PEM(const char *type, EVP_PKEY *key)
{
if (!default_libctx || is_fips)
return TEST_skip("Test not available if using a non-default library context or FIPS provider");
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"PEM", "type-specific", pass, pass_cipher,
encode_EVP_PKEY_legacy_PEM, decode_EVP_PKEY_prov,
test_text, check_protected_legacy_PEM,
dump_pem, 0);
}
#ifndef OPENSSL_NO_RC4
static int test_protected_via_PVK(const char *type, EVP_PKEY *key)
{
int ret = 0;
OSSL_PROVIDER *lgcyprov = OSSL_PROVIDER_load(testctx, "legacy");
if (lgcyprov == NULL)
return TEST_skip("Legacy provider not available");
ret = test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_KEYPAIR
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"PVK", NULL, pass, NULL,
encode_EVP_PKEY_PVK, decode_EVP_PKEY_prov,
test_mem, check_PVK, dump_der, 0);
OSSL_PROVIDER_unload(lgcyprov);
return ret;
}
#endif
static int check_public_DER(const char *file, const int line,
const char *type, const void *data, size_t data_len)
{
const unsigned char *datap = data;
EVP_PKEY *pkey = d2i_PUBKEY_ex(NULL, &datap, data_len, testctx, testpropq);
int ok = (TEST_FL_ptr(pkey) && TEST_FL_true(EVP_PKEY_is_a(pkey, type)));
EVP_PKEY_free(pkey);
return ok;
}
static int test_public_via_DER(const char *type, EVP_PKEY *key, int fips)
{
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_PUBLIC_KEY
| OSSL_KEYMGMT_SELECT_ALL_PARAMETERS,
"DER", "SubjectPublicKeyInfo", NULL, NULL,
encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
test_mem, check_public_DER, dump_der,
fips ? 0 : FLAG_FAIL_IF_FIPS);
}
static int check_public_PEM(const char *file, const int line,
const char *type, const void *data, size_t data_len)
{
static const char expected_pem_header[] =
"-----BEGIN " PEM_STRING_PUBLIC "-----";
return
TEST_FL_strn_eq(data, expected_pem_header,
sizeof(expected_pem_header) - 1);
}
static int test_public_via_PEM(const char *type, EVP_PKEY *key, int fips)
{
return test_encode_decode(__FILE__, __LINE__, type, key,
OSSL_KEYMGMT_SELECT_PUBLIC_KEY
| OSSL_KEYMGMT_SELECT_ALL_PARAMETERS,
"PEM", "SubjectPublicKeyInfo", NULL, NULL,
encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
test_text, check_public_PEM, dump_pem,
fips ? 0 : FLAG_FAIL_IF_FIPS);
}
static int check_public_MSBLOB(const char *file, const int line,
const char *type,
const void *data, size_t data_len)
{
const unsigned char *datap = data;
EVP_PKEY *pkey = b2i_PublicKey(&datap, data_len);
int ok = TEST_FL_ptr(pkey);
EVP_PKEY_free(pkey);
return ok;
}
static int test_public_via_MSBLOB(const char *type, EVP_PKEY *key)
{
return test_encode_decode(__FILE__, __LINE__, type, key, OSSL_KEYMGMT_SELECT_PUBLIC_KEY
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
"MSBLOB", NULL, NULL, NULL,
encode_EVP_PKEY_MSBLOB, decode_EVP_PKEY_prov,
test_mem, check_public_MSBLOB, dump_der, 0);
}
#define KEYS(KEYTYPE) \
static EVP_PKEY *key_##KEYTYPE = NULL
#define MAKE_KEYS(KEYTYPE, KEYTYPEstr, params) \
ok = ok \
&& TEST_ptr(key_##KEYTYPE = make_key(KEYTYPEstr, NULL, params))
#define FREE_KEYS(KEYTYPE) \
EVP_PKEY_free(key_##KEYTYPE); \
#define DOMAIN_KEYS(KEYTYPE) \
static EVP_PKEY *template_##KEYTYPE = NULL; \
static EVP_PKEY *key_##KEYTYPE = NULL
#define MAKE_DOMAIN_KEYS(KEYTYPE, KEYTYPEstr, params) \
ok = ok \
&& TEST_ptr(template_##KEYTYPE = \
make_template(KEYTYPEstr, params)) \
&& TEST_ptr(key_##KEYTYPE = \
make_key(KEYTYPEstr, template_##KEYTYPE, NULL))
#define FREE_DOMAIN_KEYS(KEYTYPE) \
EVP_PKEY_free(template_##KEYTYPE); \
EVP_PKEY_free(key_##KEYTYPE)
#define IMPLEMENT_TEST_SUITE(KEYTYPE, KEYTYPEstr, fips) \
static int test_unprotected_##KEYTYPE##_via_DER(void) \
{ \
return test_unprotected_via_DER(KEYTYPEstr, key_##KEYTYPE, fips); \
} \
static int test_unprotected_##KEYTYPE##_via_PEM(void) \
{ \
return test_unprotected_via_PEM(KEYTYPEstr, key_##KEYTYPE, fips); \
} \
static int test_protected_##KEYTYPE##_via_DER(void) \
{ \
return test_protected_via_DER(KEYTYPEstr, key_##KEYTYPE, fips); \
} \
static int test_protected_##KEYTYPE##_via_PEM(void) \
{ \
return test_protected_via_PEM(KEYTYPEstr, key_##KEYTYPE, fips); \
} \
static int test_public_##KEYTYPE##_via_DER(void) \
{ \
return test_public_via_DER(KEYTYPEstr, key_##KEYTYPE, fips); \
} \
static int test_public_##KEYTYPE##_via_PEM(void) \
{ \
return test_public_via_PEM(KEYTYPEstr, key_##KEYTYPE, fips); \
}
#define ADD_TEST_SUITE(KEYTYPE) \
ADD_TEST(test_unprotected_##KEYTYPE##_via_DER); \
ADD_TEST(test_unprotected_##KEYTYPE##_via_PEM); \
ADD_TEST(test_protected_##KEYTYPE##_via_DER); \
ADD_TEST(test_protected_##KEYTYPE##_via_PEM); \
ADD_TEST(test_public_##KEYTYPE##_via_DER); \
ADD_TEST(test_public_##KEYTYPE##_via_PEM)
#define IMPLEMENT_TEST_SUITE_PARAMS(KEYTYPE, KEYTYPEstr) \
static int test_params_##KEYTYPE##_via_DER(void) \
{ \
return test_params_via_DER(KEYTYPEstr, key_##KEYTYPE); \
} \
static int test_params_##KEYTYPE##_via_PEM(void) \
{ \
return test_params_via_PEM(KEYTYPEstr, key_##KEYTYPE); \
}
#define ADD_TEST_SUITE_PARAMS(KEYTYPE) \
ADD_TEST(test_params_##KEYTYPE##_via_DER); \
ADD_TEST(test_params_##KEYTYPE##_via_PEM)
#define IMPLEMENT_TEST_SUITE_LEGACY(KEYTYPE, KEYTYPEstr) \
static int test_unprotected_##KEYTYPE##_via_legacy_PEM(void) \
{ \
return \
test_unprotected_via_legacy_PEM(KEYTYPEstr, key_##KEYTYPE); \
} \
static int test_protected_##KEYTYPE##_via_legacy_PEM(void) \
{ \
return \
test_protected_via_legacy_PEM(KEYTYPEstr, key_##KEYTYPE); \
}
#define ADD_TEST_SUITE_LEGACY(KEYTYPE) \
ADD_TEST(test_unprotected_##KEYTYPE##_via_legacy_PEM); \
ADD_TEST(test_protected_##KEYTYPE##_via_legacy_PEM)
#define IMPLEMENT_TEST_SUITE_MSBLOB(KEYTYPE, KEYTYPEstr) \
static int test_unprotected_##KEYTYPE##_via_MSBLOB(void) \
{ \
return test_unprotected_via_MSBLOB(KEYTYPEstr, key_##KEYTYPE); \
} \
static int test_public_##KEYTYPE##_via_MSBLOB(void) \
{ \
return test_public_via_MSBLOB(KEYTYPEstr, key_##KEYTYPE); \
}
#define ADD_TEST_SUITE_MSBLOB(KEYTYPE) \
ADD_TEST(test_unprotected_##KEYTYPE##_via_MSBLOB); \
ADD_TEST(test_public_##KEYTYPE##_via_MSBLOB)
#define IMPLEMENT_TEST_SUITE_UNPROTECTED_PVK(KEYTYPE, KEYTYPEstr) \
static int test_unprotected_##KEYTYPE##_via_PVK(void) \
{ \
return test_unprotected_via_PVK(KEYTYPEstr, key_##KEYTYPE); \
}
# define ADD_TEST_SUITE_UNPROTECTED_PVK(KEYTYPE) \
ADD_TEST(test_unprotected_##KEYTYPE##_via_PVK)
#ifndef OPENSSL_NO_RC4
# define IMPLEMENT_TEST_SUITE_PROTECTED_PVK(KEYTYPE, KEYTYPEstr) \
static int test_protected_##KEYTYPE##_via_PVK(void) \
{ \
return test_protected_via_PVK(KEYTYPEstr, key_##KEYTYPE); \
}
# define ADD_TEST_SUITE_PROTECTED_PVK(KEYTYPE) \
ADD_TEST(test_protected_##KEYTYPE##_via_PVK)
#endif
#ifndef OPENSSL_NO_DH
DOMAIN_KEYS(DH);
IMPLEMENT_TEST_SUITE(DH, "DH", 1)
IMPLEMENT_TEST_SUITE_PARAMS(DH, "DH")
DOMAIN_KEYS(DHX);
IMPLEMENT_TEST_SUITE(DHX, "X9.42 DH", 1)
IMPLEMENT_TEST_SUITE_PARAMS(DHX, "X9.42 DH")
/*
* DH has no support for PEM_write_bio_PrivateKey_traditional(),
* so no legacy tests.
*/
#endif
#ifndef OPENSSL_NO_DSA
DOMAIN_KEYS(DSA);
IMPLEMENT_TEST_SUITE(DSA, "DSA", 1)
IMPLEMENT_TEST_SUITE_PARAMS(DSA, "DSA")
IMPLEMENT_TEST_SUITE_LEGACY(DSA, "DSA")
IMPLEMENT_TEST_SUITE_MSBLOB(DSA, "DSA")
IMPLEMENT_TEST_SUITE_UNPROTECTED_PVK(DSA, "DSA")
# ifndef OPENSSL_NO_RC4
IMPLEMENT_TEST_SUITE_PROTECTED_PVK(DSA, "DSA")
# endif
#endif
#ifndef OPENSSL_NO_EC
DOMAIN_KEYS(EC);
IMPLEMENT_TEST_SUITE(EC, "EC", 1)
IMPLEMENT_TEST_SUITE_PARAMS(EC, "EC")
IMPLEMENT_TEST_SUITE_LEGACY(EC, "EC")
DOMAIN_KEYS(ECExplicitPrimeNamedCurve);
IMPLEMENT_TEST_SUITE(ECExplicitPrimeNamedCurve, "EC", 1)
IMPLEMENT_TEST_SUITE_LEGACY(ECExplicitPrimeNamedCurve, "EC")
DOMAIN_KEYS(ECExplicitPrime2G);
IMPLEMENT_TEST_SUITE(ECExplicitPrime2G, "EC", 0)
IMPLEMENT_TEST_SUITE_LEGACY(ECExplicitPrime2G, "EC")
# ifndef OPENSSL_NO_EC2M
DOMAIN_KEYS(ECExplicitTriNamedCurve);
IMPLEMENT_TEST_SUITE(ECExplicitTriNamedCurve, "EC", 1)
IMPLEMENT_TEST_SUITE_LEGACY(ECExplicitTriNamedCurve, "EC")
DOMAIN_KEYS(ECExplicitTri2G);
IMPLEMENT_TEST_SUITE(ECExplicitTri2G, "EC", 0)
IMPLEMENT_TEST_SUITE_LEGACY(ECExplicitTri2G, "EC")
# endif
KEYS(ED25519);
IMPLEMENT_TEST_SUITE(ED25519, "ED25519", 1)
KEYS(ED448);
IMPLEMENT_TEST_SUITE(ED448, "ED448", 1)
KEYS(X25519);
IMPLEMENT_TEST_SUITE(X25519, "X25519", 1)
KEYS(X448);
IMPLEMENT_TEST_SUITE(X448, "X448", 1)
/*
* ED25519, ED448, X25519 and X448 have no support for
* PEM_write_bio_PrivateKey_traditional(), so no legacy tests.
*/
#endif
KEYS(RSA);
IMPLEMENT_TEST_SUITE(RSA, "RSA", 1)
IMPLEMENT_TEST_SUITE_LEGACY(RSA, "RSA")
KEYS(RSA_PSS);
IMPLEMENT_TEST_SUITE(RSA_PSS, "RSA-PSS", 1)
/*
* RSA-PSS has no support for PEM_write_bio_PrivateKey_traditional(),
* so no legacy tests.
*/
IMPLEMENT_TEST_SUITE_MSBLOB(RSA, "RSA")
IMPLEMENT_TEST_SUITE_UNPROTECTED_PVK(RSA, "RSA")
#ifndef OPENSSL_NO_RC4
IMPLEMENT_TEST_SUITE_PROTECTED_PVK(RSA, "RSA")
#endif
#ifndef OPENSSL_NO_EC
/* Explicit parameters that match a named curve */
static int do_create_ec_explicit_prime_params(OSSL_PARAM_BLD *bld,
const unsigned char *gen,
size_t gen_len)
{
BIGNUM *a, *b, *prime, *order;
/* Curve prime256v1 */
static const unsigned char prime_data[] = {
0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff
};
static const unsigned char a_data[] = {
0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xfc
};
static const unsigned char b_data[] = {
0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7,
0xb3, 0xeb, 0xbd, 0x55, 0x76, 0x98, 0x86, 0xbc,
0x65, 0x1d, 0x06, 0xb0, 0xcc, 0x53, 0xb0, 0xf6,
0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2, 0x60, 0x4b
};
static const unsigned char seed[] = {
0xc4, 0x9d, 0x36, 0x08, 0x86, 0xe7, 0x04, 0x93,
0x6a, 0x66, 0x78, 0xe1, 0x13, 0x9d, 0x26, 0xb7,
0x81, 0x9f, 0x7e, 0x90
};
static const unsigned char order_data[] = {
0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xbc, 0xe6, 0xfa, 0xad, 0xa7, 0x17, 0x9e,
0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63, 0x25, 0x51
};
return TEST_ptr(a = BN_CTX_get(bnctx))
&& TEST_ptr(b = BN_CTX_get(bnctx))
&& TEST_ptr(prime = BN_CTX_get(bnctx))
&& TEST_ptr(order = BN_CTX_get(bnctx))
&& TEST_ptr(BN_bin2bn(prime_data, sizeof(prime_data), prime))
&& TEST_ptr(BN_bin2bn(a_data, sizeof(a_data), a))
&& TEST_ptr(BN_bin2bn(b_data, sizeof(b_data), b))
&& TEST_ptr(BN_bin2bn(order_data, sizeof(order_data), order))
&& TEST_true(OSSL_PARAM_BLD_push_utf8_string(bld,
OSSL_PKEY_PARAM_EC_FIELD_TYPE, SN_X9_62_prime_field,
0))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_P, prime))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_A, a))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_B, b))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld,
OSSL_PKEY_PARAM_EC_ORDER, order))
&& TEST_true(OSSL_PARAM_BLD_push_octet_string(bld,
OSSL_PKEY_PARAM_EC_GENERATOR, gen, gen_len))
&& TEST_true(OSSL_PARAM_BLD_push_octet_string(bld,
OSSL_PKEY_PARAM_EC_SEED, seed, sizeof(seed)))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_COFACTOR,
BN_value_one()));
}
static int create_ec_explicit_prime_params_namedcurve(OSSL_PARAM_BLD *bld)
{
static const unsigned char prime256v1_gen[] = {
0x04,
0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47,
0xf8, 0xbc, 0xe6, 0xe5, 0x63, 0xa4, 0x40, 0xf2,
0x77, 0x03, 0x7d, 0x81, 0x2d, 0xeb, 0x33, 0xa0,
0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98, 0xc2, 0x96,
0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b,
0x8e, 0xe7, 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16,
0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31, 0x5e, 0xce,
0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5
};
return do_create_ec_explicit_prime_params(bld, prime256v1_gen,
sizeof(prime256v1_gen));
}
static int create_ec_explicit_prime_params(OSSL_PARAM_BLD *bld)
{
/* 2G */
static const unsigned char prime256v1_gen2[] = {
0x04,
0xe4, 0x97, 0x08, 0xbe, 0x7d, 0xfa, 0xa2, 0x9a,
0xa3, 0x12, 0x6f, 0xe4, 0xe7, 0xd0, 0x25, 0xe3,
0x4a, 0xc1, 0x03, 0x15, 0x8c, 0xd9, 0x33, 0xc6,
0x97, 0x42, 0xf5, 0xdc, 0x97, 0xb9, 0xd7, 0x31,
0xe9, 0x7d, 0x74, 0x3d, 0x67, 0x6a, 0x3b, 0x21,
0x08, 0x9c, 0x31, 0x73, 0xf8, 0xc1, 0x27, 0xc9,
0xd2, 0xa0, 0xa0, 0x83, 0x66, 0xe0, 0xc9, 0xda,
0xa8, 0xc6, 0x56, 0x2b, 0x94, 0xb1, 0xae, 0x55
};
return do_create_ec_explicit_prime_params(bld, prime256v1_gen2,
sizeof(prime256v1_gen2));
}
# ifndef OPENSSL_NO_EC2M
static int do_create_ec_explicit_trinomial_params(OSSL_PARAM_BLD *bld,
const unsigned char *gen,
size_t gen_len)
{
BIGNUM *a, *b, *poly, *order, *cofactor;
/* sect233k1 characteristic-two-field tpBasis */
static const unsigned char poly_data[] = {
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
static const unsigned char a_data[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const unsigned char b_data[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
static const unsigned char order_data[] = {
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x06, 0x9D, 0x5B, 0xB9, 0x15, 0xBC, 0xD4, 0x6E, 0xFB,
0x1A, 0xD5, 0xF1, 0x73, 0xAB, 0xDF
};
static const unsigned char cofactor_data[]= {
0x4
};
return TEST_ptr(a = BN_CTX_get(bnctx))
&& TEST_ptr(b = BN_CTX_get(bnctx))
&& TEST_ptr(poly = BN_CTX_get(bnctx))
&& TEST_ptr(order = BN_CTX_get(bnctx))
&& TEST_ptr(cofactor = BN_CTX_get(bnctx))
&& TEST_ptr(BN_bin2bn(poly_data, sizeof(poly_data), poly))
&& TEST_ptr(BN_bin2bn(a_data, sizeof(a_data), a))
&& TEST_ptr(BN_bin2bn(b_data, sizeof(b_data), b))
&& TEST_ptr(BN_bin2bn(order_data, sizeof(order_data), order))
&& TEST_ptr(BN_bin2bn(cofactor_data, sizeof(cofactor_data), cofactor))
&& TEST_true(OSSL_PARAM_BLD_push_utf8_string(bld,
OSSL_PKEY_PARAM_EC_FIELD_TYPE,
SN_X9_62_characteristic_two_field, 0))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_P, poly))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_A, a))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_B, b))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld,
OSSL_PKEY_PARAM_EC_ORDER, order))
&& TEST_true(OSSL_PARAM_BLD_push_octet_string(bld,
OSSL_PKEY_PARAM_EC_GENERATOR, gen, gen_len))
&& TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_COFACTOR,
cofactor));
}
static int create_ec_explicit_trinomial_params_namedcurve(OSSL_PARAM_BLD *bld)
{
static const unsigned char gen[] = {
0x04,
0x01, 0x72, 0x32, 0xBA, 0x85, 0x3A, 0x7E, 0x73, 0x1A, 0xF1, 0x29, 0xF2,
0x2F, 0xF4, 0x14, 0x95, 0x63, 0xA4, 0x19, 0xC2, 0x6B, 0xF5, 0x0A, 0x4C,
0x9D, 0x6E, 0xEF, 0xAD, 0x61, 0x26,
0x01, 0xDB, 0x53, 0x7D, 0xEC, 0xE8, 0x19, 0xB7, 0xF7, 0x0F, 0x55, 0x5A,
0x67, 0xC4, 0x27, 0xA8, 0xCD, 0x9B, 0xF1, 0x8A, 0xEB, 0x9B, 0x56, 0xE0,
0xC1, 0x10, 0x56, 0xFA, 0xE6, 0xA3
};
return do_create_ec_explicit_trinomial_params(bld, gen, sizeof(gen));
}
static int create_ec_explicit_trinomial_params(OSSL_PARAM_BLD *bld)
{
static const unsigned char gen2[] = {
0x04,
0x00, 0xd7, 0xba, 0xd0, 0x26, 0x6c, 0x31, 0x6a, 0x78, 0x76, 0x01, 0xd1,
0x32, 0x4b, 0x8f, 0x30, 0x29, 0x2d, 0x78, 0x30, 0xca, 0x43, 0xaa, 0xf0,
0xa2, 0x5a, 0xd4, 0x0f, 0xb3, 0xf4,
0x00, 0x85, 0x4b, 0x1b, 0x8d, 0x50, 0x10, 0xa5, 0x1c, 0x80, 0xf7, 0x86,
0x40, 0x62, 0x4c, 0x87, 0xd1, 0x26, 0x7a, 0x9c, 0x5c, 0xe9, 0x82, 0x29,
0xd1, 0x67, 0x70, 0x41, 0xea, 0xcb
};
return do_create_ec_explicit_trinomial_params(bld, gen2, sizeof(gen2));
}
# endif /* OPENSSL_NO_EC2M */
#endif /* OPENSSL_NO_EC */
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_CONTEXT,
OPT_RSA_FILE,
OPT_RSA_PSS_FILE,
OPT_CONFIG_FILE,
OPT_PROVIDER_NAME,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "context", OPT_CONTEXT, '-',
"Explicitly use a non-default library context" },
{ "rsa", OPT_RSA_FILE, '<',
"PEM format RSA key file to encode/decode" },
{ "pss", OPT_RSA_PSS_FILE, '<',
"PEM format RSA-PSS key file to encode/decode" },
{ "config", OPT_CONFIG_FILE, '<',
"The configuration file to use for the library context" },
{ "provider", OPT_PROVIDER_NAME, 's',
"The provider to load (The default value is 'default')" },
{ NULL }
};
return options;
}
int setup_tests(void)
{
const char *rsa_file = NULL;
const char *rsa_pss_file = NULL;
const char *prov_name = "default";
char *config_file = NULL;
int ok = 1;
#ifndef OPENSSL_NO_DSA
static size_t qbits = 160; /* PVK only tolerates 160 Q bits */
static size_t pbits = 1024; /* With 160 Q bits, we MUST use 1024 P bits */
OSSL_PARAM DSA_params[] = {
OSSL_PARAM_size_t("pbits", &pbits),
OSSL_PARAM_size_t("qbits", &qbits),
OSSL_PARAM_END
};
#endif
#ifndef OPENSSL_NO_EC
static char groupname[] = "prime256v1";
OSSL_PARAM EC_params[] = {
OSSL_PARAM_utf8_string("group", groupname, sizeof(groupname) - 1),
OSSL_PARAM_END
};
#endif
OPTION_CHOICE o;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_CONTEXT:
default_libctx = 0;
break;
case OPT_PROVIDER_NAME:
prov_name = opt_arg();
break;
case OPT_CONFIG_FILE:
config_file = opt_arg();
break;
case OPT_RSA_FILE:
rsa_file = opt_arg();
break;
case OPT_RSA_PSS_FILE:
rsa_pss_file = opt_arg();
break;
case OPT_TEST_CASES:
break;
default:
return 0;
}
}
if (strcmp(prov_name, "fips") == 0)
is_fips = 1;
if (default_libctx) {
if (!test_get_libctx(NULL, NULL, config_file, &deflprov, prov_name))
return 0;
} else {
if (!test_get_libctx(&testctx, &nullprov, config_file, &deflprov, prov_name))
return 0;
}
/* FIPS(3.0.0): provider imports explicit params but they won't work #17998 */
is_fips_3_0_0 = fips_provider_version_eq(testctx, 3, 0, 0);
if (is_fips_3_0_0 < 0)
return 0;
#ifdef STATIC_LEGACY
/*
* This test is always statically linked against libcrypto. We must not
* attempt to load legacy.so that might be dynamically linked against
* libcrypto. Instead we use a built-in version of the legacy provider.
*/
if (!OSSL_PROVIDER_add_builtin(testctx, "legacy", ossl_legacy_provider_init))
return 0;
#endif
/* Separate provider/ctx for generating the test data */
if (!TEST_ptr(keyctx = OSSL_LIB_CTX_new()))
return 0;
if (!TEST_ptr(keyprov = OSSL_PROVIDER_load(keyctx, "default")))
return 0;
#ifndef OPENSSL_NO_EC
if (!TEST_ptr(bnctx = BN_CTX_new_ex(testctx))
|| !TEST_ptr(bld_prime_nc = OSSL_PARAM_BLD_new())
|| !TEST_ptr(bld_prime = OSSL_PARAM_BLD_new())
|| !create_ec_explicit_prime_params_namedcurve(bld_prime_nc)
|| !create_ec_explicit_prime_params(bld_prime)
|| !TEST_ptr(ec_explicit_prime_params_nc = OSSL_PARAM_BLD_to_param(bld_prime_nc))
|| !TEST_ptr(ec_explicit_prime_params_explicit = OSSL_PARAM_BLD_to_param(bld_prime))
# ifndef OPENSSL_NO_EC2M
|| !TEST_ptr(bld_tri_nc = OSSL_PARAM_BLD_new())
|| !TEST_ptr(bld_tri = OSSL_PARAM_BLD_new())
|| !create_ec_explicit_trinomial_params_namedcurve(bld_tri_nc)
|| !create_ec_explicit_trinomial_params(bld_tri)
|| !TEST_ptr(ec_explicit_tri_params_nc = OSSL_PARAM_BLD_to_param(bld_tri_nc))
|| !TEST_ptr(ec_explicit_tri_params_explicit = OSSL_PARAM_BLD_to_param(bld_tri))
# endif
)
return 0;
#endif
TEST_info("Generating keys...");
#ifndef OPENSSL_NO_DH
TEST_info("Generating DH keys...");
MAKE_DOMAIN_KEYS(DH, "DH", NULL);
MAKE_DOMAIN_KEYS(DHX, "X9.42 DH", NULL);
#endif
#ifndef OPENSSL_NO_DSA
TEST_info("Generating DSA keys...");
MAKE_DOMAIN_KEYS(DSA, "DSA", DSA_params);
#endif
#ifndef OPENSSL_NO_EC
TEST_info("Generating EC keys...");
MAKE_DOMAIN_KEYS(EC, "EC", EC_params);
MAKE_DOMAIN_KEYS(ECExplicitPrimeNamedCurve, "EC", ec_explicit_prime_params_nc);
MAKE_DOMAIN_KEYS(ECExplicitPrime2G, "EC", ec_explicit_prime_params_explicit);
# ifndef OPENSSL_NO_EC2M
MAKE_DOMAIN_KEYS(ECExplicitTriNamedCurve, "EC", ec_explicit_tri_params_nc);
MAKE_DOMAIN_KEYS(ECExplicitTri2G, "EC", ec_explicit_tri_params_explicit);
# endif
MAKE_KEYS(ED25519, "ED25519", NULL);
MAKE_KEYS(ED448, "ED448", NULL);
MAKE_KEYS(X25519, "X25519", NULL);
MAKE_KEYS(X448, "X448", NULL);
#endif
TEST_info("Loading RSA key...");
ok = ok && TEST_ptr(key_RSA = load_pkey_pem(rsa_file, keyctx));
TEST_info("Loading RSA_PSS key...");
ok = ok && TEST_ptr(key_RSA_PSS = load_pkey_pem(rsa_pss_file, keyctx));
TEST_info("Generating keys done");
if (ok) {
#ifndef OPENSSL_NO_DH
ADD_TEST_SUITE(DH);
ADD_TEST_SUITE_PARAMS(DH);
ADD_TEST_SUITE(DHX);
ADD_TEST_SUITE_PARAMS(DHX);
/*
* DH has no support for PEM_write_bio_PrivateKey_traditional(),
* so no legacy tests.
*/
#endif
#ifndef OPENSSL_NO_DSA
ADD_TEST_SUITE(DSA);
ADD_TEST_SUITE_PARAMS(DSA);
ADD_TEST_SUITE_LEGACY(DSA);
ADD_TEST_SUITE_MSBLOB(DSA);
ADD_TEST_SUITE_UNPROTECTED_PVK(DSA);
# ifndef OPENSSL_NO_RC4
ADD_TEST_SUITE_PROTECTED_PVK(DSA);
# endif
#endif
#ifndef OPENSSL_NO_EC
ADD_TEST_SUITE(EC);
ADD_TEST_SUITE_PARAMS(EC);
ADD_TEST_SUITE_LEGACY(EC);
ADD_TEST_SUITE(ECExplicitPrimeNamedCurve);
ADD_TEST_SUITE_LEGACY(ECExplicitPrimeNamedCurve);
ADD_TEST_SUITE(ECExplicitPrime2G);
ADD_TEST_SUITE_LEGACY(ECExplicitPrime2G);
# ifndef OPENSSL_NO_EC2M
ADD_TEST_SUITE(ECExplicitTriNamedCurve);
ADD_TEST_SUITE_LEGACY(ECExplicitTriNamedCurve);
ADD_TEST_SUITE(ECExplicitTri2G);
ADD_TEST_SUITE_LEGACY(ECExplicitTri2G);
# endif
ADD_TEST_SUITE(ED25519);
ADD_TEST_SUITE(ED448);
ADD_TEST_SUITE(X25519);
ADD_TEST_SUITE(X448);
/*
* ED25519, ED448, X25519 and X448 have no support for
* PEM_write_bio_PrivateKey_traditional(), so no legacy tests.
*/
#endif
ADD_TEST_SUITE(RSA);
ADD_TEST_SUITE_LEGACY(RSA);
ADD_TEST_SUITE(RSA_PSS);
/*
* RSA-PSS has no support for PEM_write_bio_PrivateKey_traditional(),
* so no legacy tests.
*/
ADD_TEST_SUITE_MSBLOB(RSA);
ADD_TEST_SUITE_UNPROTECTED_PVK(RSA);
# ifndef OPENSSL_NO_RC4
ADD_TEST_SUITE_PROTECTED_PVK(RSA);
# endif
}
return 1;
}
void cleanup_tests(void)
{
#ifndef OPENSSL_NO_EC
OSSL_PARAM_free(ec_explicit_prime_params_nc);
OSSL_PARAM_free(ec_explicit_prime_params_explicit);
OSSL_PARAM_BLD_free(bld_prime_nc);
OSSL_PARAM_BLD_free(bld_prime);
# ifndef OPENSSL_NO_EC2M
OSSL_PARAM_free(ec_explicit_tri_params_nc);
OSSL_PARAM_free(ec_explicit_tri_params_explicit);
OSSL_PARAM_BLD_free(bld_tri_nc);
OSSL_PARAM_BLD_free(bld_tri);
# endif
BN_CTX_free(bnctx);
#endif /* OPENSSL_NO_EC */
#ifndef OPENSSL_NO_DH
FREE_DOMAIN_KEYS(DH);
FREE_DOMAIN_KEYS(DHX);
#endif
#ifndef OPENSSL_NO_DSA
FREE_DOMAIN_KEYS(DSA);
#endif
#ifndef OPENSSL_NO_EC
FREE_DOMAIN_KEYS(EC);
FREE_DOMAIN_KEYS(ECExplicitPrimeNamedCurve);
FREE_DOMAIN_KEYS(ECExplicitPrime2G);
# ifndef OPENSSL_NO_EC2M
FREE_DOMAIN_KEYS(ECExplicitTriNamedCurve);
FREE_DOMAIN_KEYS(ECExplicitTri2G);
# endif
FREE_KEYS(ED25519);
FREE_KEYS(ED448);
FREE_KEYS(X25519);
FREE_KEYS(X448);
#endif
FREE_KEYS(RSA);
FREE_KEYS(RSA_PSS);
OSSL_PROVIDER_unload(nullprov);
OSSL_PROVIDER_unload(deflprov);
OSSL_PROVIDER_unload(keyprov);
OSSL_LIB_CTX_free(testctx);
OSSL_LIB_CTX_free(keyctx);
}
|
./openssl/test/moduleloadtest.c | /*
* Copyright 2020-2021 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
*/
/*
* Extremely simple dynamic loader, must never be linked with anything other
* than the standard C library. Its purpose is to try to load a dynamic module
* and verify the presence of one symbol, if that's given.
*/
#include <stdio.h>
#include <stdlib.h>
#include <openssl/core.h>
#include "simpledynamic.h"
static int test_load(const char *path, const char *symbol)
{
#ifdef SD_INIT
SD sd = SD_INIT;
SD_SYM sym;
int ret;
if (!sd_load(path, &sd, SD_MODULE))
return 0;
ret = symbol == NULL || sd_sym(sd, symbol, &sym);
if (!sd_close(sd))
ret = 0;
return ret;
#else
fprintf(stderr, "No dynamic loader\n");
return 0;
#endif
}
int main(int argc, char *argv[])
{
const char *m, *s;
if (argc != 2 && argc != 3) {
fprintf(stderr, "Usage: %s sharedobject [ entrypoint ]\n", argv[0]);
return 1;
}
m = argv[1];
s = argc == 3 ? argv[2] : NULL;
return test_load(m, s) ? 0 : 1;
}
|
./openssl/test/build_wincrypt_test.c | /*
* Copyright 2022-2023 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
*/
/*
* Simple buildtest to check for symbol collisions between wincrypt and
* OpenSSL headers
*/
#include <openssl/types.h>
#ifdef _WIN32
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <wincrypt.h>
# ifndef X509_NAME
# ifndef PEDANTIC
# ifdef _MSC_VER
# pragma message("wincrypt.h no longer defining X509_NAME before OpenSSL headers")
# else
# warning "wincrypt.h no longer defining X509_NAME before OpenSSL headers"
# endif
# endif
# endif
#endif
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_STDIO
# include <stdio.h>
#endif
#include <openssl/evp.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
int main(void)
{
return 0;
}
|
./openssl/test/quicapitest.c | /*
* Copyright 2022-2023 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 <string.h>
#include <openssl/opensslconf.h>
#include <openssl/quic.h>
#include <openssl/rand.h>
#include "helpers/ssltestlib.h"
#include "helpers/quictestlib.h"
#include "testutil.h"
#include "testutil/output.h"
#include "../ssl/ssl_local.h"
#include "internal/quic_error.h"
static OSSL_LIB_CTX *libctx = NULL;
static OSSL_PROVIDER *defctxnull = NULL;
static char *certsdir = NULL;
static char *cert = NULL;
static char *ccert = NULL;
static char *cauthca = NULL;
static char *privkey = NULL;
static char *cprivkey = NULL;
static char *datadir = NULL;
static int is_fips = 0;
/* The ssltrace test assumes some options are switched on/off */
#if !defined(OPENSSL_NO_SSL_TRACE) \
&& defined(OPENSSL_NO_BROTLI) && defined(OPENSSL_NO_ZSTD) \
&& !defined(OPENSSL_NO_ECX) && !defined(OPENSSL_NO_DH)
# define DO_SSL_TRACE_TEST
#endif
/*
* Test that we read what we've written.
* Test 0: Non-blocking
* Test 1: Blocking
* Test 2: Blocking, introduce socket error, test error handling.
*/
static int test_quic_write_read(int idx)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL_CTX *sctx = NULL;
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int j, k, ret = 0;
unsigned char buf[20];
static char *msg = "A test message";
size_t msglen = strlen(msg);
size_t numbytes = 0;
int ssock = 0, csock = 0;
uint64_t sid = UINT64_MAX;
SSL_SESSION *sess = NULL;
if (idx >= 1 && !qtest_supports_blocking())
return TEST_skip("Blocking tests not supported in this build");
for (k = 0; k < 2; k++) {
if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, sctx,
cert, privkey,
idx >= 1
? QTEST_FLAG_BLOCK
: 0,
&qtserv, &clientquic,
NULL, NULL))
|| !TEST_true(SSL_set_tlsext_host_name(clientquic, "localhost")))
goto end;
if (sess != NULL && !TEST_true(SSL_set_session(clientquic, sess)))
goto end;
if (!TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto end;
if (idx >= 1) {
if (!TEST_true(BIO_get_fd(ossl_quic_tserver_get0_rbio(qtserv),
&ssock)))
goto end;
if (!TEST_int_gt(csock = SSL_get_rfd(clientquic), 0))
goto end;
}
sid = 0; /* client-initiated bidirectional stream */
for (j = 0; j < 2; j++) {
/* Check that sending and receiving app data is ok */
if (!TEST_true(SSL_write_ex(clientquic, msg, msglen, &numbytes))
|| !TEST_size_t_eq(numbytes, msglen))
goto end;
if (idx >= 1) {
do {
if (!TEST_true(wait_until_sock_readable(ssock)))
goto end;
ossl_quic_tserver_tick(qtserv);
if (!TEST_true(ossl_quic_tserver_read(qtserv, sid, buf,
sizeof(buf),
&numbytes)))
goto end;
} while (numbytes == 0);
if (!TEST_mem_eq(buf, numbytes, msg, msglen))
goto end;
}
if (idx >= 2 && j > 0)
/* Introduce permanent socket error */
BIO_closesocket(csock);
ossl_quic_tserver_tick(qtserv);
if (!TEST_true(ossl_quic_tserver_write(qtserv, sid,
(unsigned char *)msg,
msglen, &numbytes)))
goto end;
ossl_quic_tserver_tick(qtserv);
SSL_handle_events(clientquic);
if (idx >= 2 && j > 0) {
if (!TEST_false(SSL_read_ex(clientquic, buf, 1, &numbytes))
|| !TEST_int_eq(SSL_get_error(clientquic, 0),
SSL_ERROR_SYSCALL)
|| !TEST_false(SSL_write_ex(clientquic, msg, msglen,
&numbytes))
|| !TEST_int_eq(SSL_get_error(clientquic, 0),
SSL_ERROR_SYSCALL))
goto end;
break;
}
/*
* In blocking mode the SSL_read_ex call will block until the socket
* is readable and has our data. In non-blocking mode we're doing
* everything in memory, so it should be immediately available
*/
if (!TEST_true(SSL_read_ex(clientquic, buf, 1, &numbytes))
|| !TEST_size_t_eq(numbytes, 1)
|| !TEST_true(SSL_has_pending(clientquic))
|| !TEST_int_eq(SSL_pending(clientquic), msglen - 1)
|| !TEST_true(SSL_read_ex(clientquic, buf + 1,
sizeof(buf) - 1, &numbytes))
|| !TEST_mem_eq(buf, numbytes + 1, msg, msglen))
goto end;
}
if (sess == NULL) {
/* We didn't supply a session so we're not expecting resumption */
if (!TEST_false(SSL_session_reused(clientquic)))
goto end;
/* We should have a session ticket by now */
sess = SSL_get1_session(clientquic);
if (!TEST_ptr(sess))
goto end;
} else {
/* We supplied a session so we should have resumed */
if (!TEST_true(SSL_session_reused(clientquic)))
goto end;
}
if (!TEST_true(qtest_shutdown(qtserv, clientquic)))
goto end;
if (sctx == NULL) {
sctx = ossl_quic_tserver_get0_ssl_ctx(qtserv);
if (!TEST_true(SSL_CTX_up_ref(sctx))) {
sctx = NULL;
goto end;
}
}
ossl_quic_tserver_free(qtserv);
qtserv = NULL;
SSL_free(clientquic);
clientquic = NULL;
if (idx >= 2)
break;
}
ret = 1;
end:
SSL_SESSION_free(sess);
ossl_quic_tserver_free(qtserv);
SSL_free(clientquic);
SSL_CTX_free(cctx);
SSL_CTX_free(sctx);
return ret;
}
/*
* Test that sending FIN with no data to a client blocking in SSL_read_ex() will
* wake up the client.
*/
static int test_fin_only_blocking(void)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL_CTX *sctx = NULL;
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
const char *msg = "Hello World";
uint64_t sid;
size_t numbytes;
unsigned char buf[32];
int ret = 0;
OSSL_TIME timer, timediff;
if (!qtest_supports_blocking())
return TEST_skip("Blocking tests not supported in this build");
if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, sctx,
cert, privkey,
QTEST_FLAG_BLOCK,
&qtserv, &clientquic,
NULL, NULL))
|| !TEST_true(SSL_set_tlsext_host_name(clientquic, "localhost")))
goto end;
if (!TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto end;
if (!TEST_true(ossl_quic_tserver_stream_new(qtserv, 0, &sid))
|| !TEST_true(ossl_quic_tserver_write(qtserv, sid,
(unsigned char *)msg,
strlen(msg), &numbytes))
|| !TEST_size_t_eq(strlen(msg), numbytes))
goto end;
ossl_quic_tserver_tick(qtserv);
if (!TEST_true(SSL_read_ex(clientquic, buf, sizeof(buf), &numbytes))
|| !TEST_mem_eq(msg, strlen(msg), buf, numbytes))
goto end;
if (!TEST_true(ossl_quic_tserver_conclude(qtserv, sid)))
goto end;
timer = ossl_time_now();
if (!TEST_false(SSL_read_ex(clientquic, buf, sizeof(buf), &numbytes)))
goto end;
timediff = ossl_time_subtract(ossl_time_now(), timer);
if (!TEST_int_eq(SSL_get_error(clientquic, 0), SSL_ERROR_ZERO_RETURN)
/*
* We expect the SSL_read_ex to not have blocked so this should
* be very fast. 20ms should be plenty.
*/
|| !TEST_uint64_t_le(ossl_time2ms(timediff), 20))
goto end;
if (!TEST_true(qtest_shutdown(qtserv, clientquic)))
goto end;
ret = 1;
end:
ossl_quic_tserver_free(qtserv);
SSL_free(clientquic);
SSL_CTX_free(cctx);
SSL_CTX_free(sctx);
return ret;
}
/* Test that a vanilla QUIC SSL object has the expected ciphersuites available */
static int test_ciphersuites(void)
{
SSL_CTX *ctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *ssl;
int testresult = 0;
const STACK_OF(SSL_CIPHER) *ciphers = NULL;
const SSL_CIPHER *cipher;
/* We expect this exact list of ciphersuites by default */
int cipherids[] = {
TLS1_3_CK_AES_256_GCM_SHA384,
#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
TLS1_3_CK_CHACHA20_POLY1305_SHA256,
#endif
TLS1_3_CK_AES_128_GCM_SHA256
};
size_t i, j;
if (!TEST_ptr(ctx))
return 0;
ssl = SSL_new(ctx);
if (!TEST_ptr(ssl))
goto err;
ciphers = SSL_get_ciphers(ssl);
for (i = 0, j = 0; i < OSSL_NELEM(cipherids); i++) {
if (cipherids[i] == TLS1_3_CK_CHACHA20_POLY1305_SHA256 && is_fips)
continue;
cipher = sk_SSL_CIPHER_value(ciphers, j++);
if (!TEST_ptr(cipher))
goto err;
if (!TEST_uint_eq(SSL_CIPHER_get_id(cipher), cipherids[i]))
goto err;
}
/* We should have checked all the ciphers in the stack */
if (!TEST_int_eq(sk_SSL_CIPHER_num(ciphers), j))
goto err;
testresult = 1;
err:
SSL_free(ssl);
SSL_CTX_free(ctx);
return testresult;
}
static int test_cipher_find(void)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL;
struct {
const unsigned char *cipherbytes;
int ok;
} testciphers[] = {
{ TLS13_AES_128_GCM_SHA256_BYTES, 1 },
{ TLS13_AES_256_GCM_SHA384_BYTES, 1 },
{ TLS13_CHACHA20_POLY1305_SHA256_BYTES, 1 },
{ TLS13_AES_128_CCM_SHA256_BYTES, 0 },
{ TLS13_AES_128_CCM_8_SHA256_BYTES, 0 }
};
size_t i;
int testresult = 0;
if (!TEST_ptr(cctx))
goto err;
clientquic = SSL_new(cctx);
if (!TEST_ptr(clientquic))
goto err;
for (i = 0; i < OSSL_NELEM(testciphers); i++)
if (testciphers[i].ok) {
if (!TEST_ptr(SSL_CIPHER_find(clientquic,
testciphers[i].cipherbytes)))
goto err;
} else {
if (!TEST_ptr_null(SSL_CIPHER_find(clientquic,
testciphers[i].cipherbytes)))
goto err;
}
testresult = 1;
err:
SSL_free(clientquic);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test that SSL_version, SSL_get_version, SSL_is_quic, SSL_is_tls and
* SSL_is_dtls return the expected results for a QUIC connection. Compare with
* test_version() in sslapitest.c which does the same thing for TLS/DTLS
* connections.
*/
static int test_version(void)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey, 0, &qtserv,
&clientquic, NULL, NULL))
|| !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
if (!TEST_int_eq(SSL_version(clientquic), OSSL_QUIC1_VERSION)
|| !TEST_str_eq(SSL_get_version(clientquic), "QUICv1"))
goto err;
if (!TEST_true(SSL_is_quic(clientquic))
|| !TEST_false(SSL_is_tls(clientquic))
|| !TEST_false(SSL_is_dtls(clientquic)))
goto err;
testresult = 1;
err:
ossl_quic_tserver_free(qtserv);
SSL_free(clientquic);
SSL_CTX_free(cctx);
return testresult;
}
#if defined(DO_SSL_TRACE_TEST)
static void strip_line_ends(char *str)
{
size_t i;
for (i = strlen(str);
i > 0 && (str[i - 1] == '\n' || str[i - 1] == '\r');
i--);
str[i] = '\0';
}
static int compare_with_file(BIO *membio)
{
BIO *file = NULL, *newfile = NULL;
char buf1[512], buf2[512];
char *reffile;
int ret = 0;
size_t i;
#ifdef OPENSSL_NO_ZLIB
reffile = test_mk_file_path(datadir, "ssltraceref.txt");
#else
reffile = test_mk_file_path(datadir, "ssltraceref-zlib.txt");
#endif
if (!TEST_ptr(reffile))
goto err;
file = BIO_new_file(reffile, "rb");
if (!TEST_ptr(file))
goto err;
newfile = BIO_new_file("ssltraceref-new.txt", "wb");
if (!TEST_ptr(newfile))
goto err;
while (BIO_gets(membio, buf2, sizeof(buf2)) > 0)
if (BIO_puts(newfile, buf2) <= 0) {
TEST_error("Failed writing new file data");
goto err;
}
if (!TEST_int_ge(BIO_seek(membio, 0), 0))
goto err;
while (BIO_gets(file, buf1, sizeof(buf1)) > 0) {
if (BIO_gets(membio, buf2, sizeof(buf2)) <= 0) {
TEST_error("Failed reading mem data");
goto err;
}
strip_line_ends(buf1);
strip_line_ends(buf2);
if (strlen(buf1) != strlen(buf2)) {
TEST_error("Actual and ref line data length mismatch");
TEST_info("%s", buf1);
TEST_info("%s", buf2);
goto err;
}
for (i = 0; i < strlen(buf1); i++) {
/* '?' is a wild card character in the reference text */
if (buf1[i] == '?')
buf2[i] = '?';
}
if (!TEST_str_eq(buf1, buf2))
goto err;
}
if (!TEST_true(BIO_eof(file))
|| !TEST_true(BIO_eof(membio)))
goto err;
ret = 1;
err:
OPENSSL_free(reffile);
BIO_free(file);
BIO_free(newfile);
return ret;
}
/*
* Tests that the SSL_trace() msg_callback works as expected with a QUIC
* connection. This also provides testing of the msg_callback at the same time.
*/
static int test_ssl_trace(void)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
BIO *bio = BIO_new(BIO_s_mem());
/*
* Ensure we only configure ciphersuites that are available with both the
* default and fips providers to get the same output in both cases
*/
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx, "TLS_AES_128_GCM_SHA256")))
goto err;
if (!TEST_ptr(cctx)
|| !TEST_ptr(bio)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey,
QTEST_FLAG_FAKE_TIME,
&qtserv,
&clientquic, NULL, NULL)))
goto err;
SSL_set_msg_callback(clientquic, SSL_trace);
SSL_set_msg_callback_arg(clientquic, bio);
if (!TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
if (!TEST_true(compare_with_file(bio)))
goto err;
testresult = 1;
err:
ossl_quic_tserver_free(qtserv);
SSL_free(clientquic);
SSL_CTX_free(cctx);
BIO_free(bio);
return testresult;
}
#endif
static int ensure_valid_ciphers(const STACK_OF(SSL_CIPHER) *ciphers)
{
size_t i;
/* Ensure ciphersuite list is suitably subsetted. */
for (i = 0; i < (size_t)sk_SSL_CIPHER_num(ciphers); ++i) {
const SSL_CIPHER *cipher = sk_SSL_CIPHER_value(ciphers, i);
switch (SSL_CIPHER_get_id(cipher)) {
case TLS1_3_CK_AES_128_GCM_SHA256:
case TLS1_3_CK_AES_256_GCM_SHA384:
case TLS1_3_CK_CHACHA20_POLY1305_SHA256:
break;
default:
TEST_error("forbidden cipher: %s", SSL_CIPHER_get_name(cipher));
return 0;
}
}
return 1;
}
/*
* Test that handshake-layer APIs which shouldn't work don't work with QUIC.
*/
static int test_quic_forbidden_apis_ctx(void)
{
int testresult = 0;
SSL_CTX *ctx = NULL;
if (!TEST_ptr(ctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method())))
goto err;
#ifndef OPENSSL_NO_SRTP
/* This function returns 0 on success and 1 on error, and should fail. */
if (!TEST_true(SSL_CTX_set_tlsext_use_srtp(ctx, "SRTP_AEAD_AES_128_GCM")))
goto err;
#endif
/*
* List of ciphersuites we do and don't allow in QUIC.
*/
#define QUIC_CIPHERSUITES \
"TLS_AES_128_GCM_SHA256:" \
"TLS_AES_256_GCM_SHA384:" \
"TLS_CHACHA20_POLY1305_SHA256"
#define NON_QUIC_CIPHERSUITES \
"TLS_AES_128_CCM_SHA256:" \
"TLS_AES_256_CCM_SHA384:" \
"TLS_AES_128_CCM_8_SHA256"
/* Set TLSv1.3 ciphersuite list for the SSL_CTX. */
if (!TEST_true(SSL_CTX_set_ciphersuites(ctx,
QUIC_CIPHERSUITES ":"
NON_QUIC_CIPHERSUITES)))
goto err;
/*
* Forbidden ciphersuites should show up in SSL_CTX accessors, they are only
* filtered in SSL_get1_supported_ciphers, so we don't check for
* non-inclusion here.
*/
testresult = 1;
err:
SSL_CTX_free(ctx);
return testresult;
}
static int test_quic_forbidden_apis(void)
{
int testresult = 0;
SSL_CTX *ctx = NULL;
SSL *ssl = NULL;
STACK_OF(SSL_CIPHER) *ciphers = NULL;
if (!TEST_ptr(ctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method())))
goto err;
if (!TEST_ptr(ssl = SSL_new(ctx)))
goto err;
#ifndef OPENSSL_NO_SRTP
/* This function returns 0 on success and 1 on error, and should fail. */
if (!TEST_true(SSL_set_tlsext_use_srtp(ssl, "SRTP_AEAD_AES_128_GCM")))
goto err;
#endif
/* Set TLSv1.3 ciphersuite list for the SSL_CTX. */
if (!TEST_true(SSL_set_ciphersuites(ssl,
QUIC_CIPHERSUITES ":"
NON_QUIC_CIPHERSUITES)))
goto err;
/* Non-QUIC ciphersuites must not appear in supported ciphers list. */
if (!TEST_ptr(ciphers = SSL_get1_supported_ciphers(ssl))
|| !TEST_true(ensure_valid_ciphers(ciphers)))
goto err;
testresult = 1;
err:
sk_SSL_CIPHER_free(ciphers);
SSL_free(ssl);
SSL_CTX_free(ctx);
return testresult;
}
static int test_quic_forbidden_options(void)
{
int testresult = 0;
SSL_CTX *ctx = NULL;
SSL *ssl = NULL;
char buf[16];
size_t len;
if (!TEST_ptr(ctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method())))
goto err;
/* QUIC options restrictions do not affect SSL_CTX */
SSL_CTX_set_options(ctx, UINT64_MAX);
if (!TEST_uint64_t_eq(SSL_CTX_get_options(ctx), UINT64_MAX))
goto err;
/* Set options on CTX which should not be inherited (tested below). */
SSL_CTX_set_read_ahead(ctx, 1);
SSL_CTX_set_max_early_data(ctx, 1);
SSL_CTX_set_recv_max_early_data(ctx, 1);
SSL_CTX_set_quiet_shutdown(ctx, 1);
if (!TEST_ptr(ssl = SSL_new(ctx)))
goto err;
/* Only permitted options get transferred to SSL object */
if (!TEST_uint64_t_eq(SSL_get_options(ssl), OSSL_QUIC_PERMITTED_OPTIONS))
goto err;
/* Try again using SSL_set_options */
SSL_set_options(ssl, UINT64_MAX);
if (!TEST_uint64_t_eq(SSL_get_options(ssl), OSSL_QUIC_PERMITTED_OPTIONS))
goto err;
/* Clear everything */
SSL_clear_options(ssl, UINT64_MAX);
if (!TEST_uint64_t_eq(SSL_get_options(ssl), 0))
goto err;
/* Readahead */
if (!TEST_false(SSL_get_read_ahead(ssl)))
goto err;
SSL_set_read_ahead(ssl, 1);
if (!TEST_false(SSL_get_read_ahead(ssl)))
goto err;
/* Block padding */
if (!TEST_true(SSL_set_block_padding(ssl, 0))
|| !TEST_true(SSL_set_block_padding(ssl, 1))
|| !TEST_false(SSL_set_block_padding(ssl, 2)))
goto err;
/* Max fragment length */
if (!TEST_true(SSL_set_tlsext_max_fragment_length(ssl, TLSEXT_max_fragment_length_DISABLED))
|| !TEST_false(SSL_set_tlsext_max_fragment_length(ssl, TLSEXT_max_fragment_length_512)))
goto err;
/* Max early data */
if (!TEST_false(SSL_set_recv_max_early_data(ssl, 1))
|| !TEST_false(SSL_set_max_early_data(ssl, 1)))
goto err;
/* Read/Write */
if (!TEST_false(SSL_read_early_data(ssl, buf, sizeof(buf), &len))
|| !TEST_false(SSL_write_early_data(ssl, buf, sizeof(buf), &len)))
goto err;
/* Buffer Management */
if (!TEST_true(SSL_alloc_buffers(ssl))
|| !TEST_false(SSL_free_buffers(ssl)))
goto err;
/* Pipelining */
if (!TEST_false(SSL_set_max_send_fragment(ssl, 2))
|| !TEST_false(SSL_set_split_send_fragment(ssl, 2))
|| !TEST_false(SSL_set_max_pipelines(ssl, 2)))
goto err;
/* HRR */
if (!TEST_false(SSL_stateless(ssl)))
goto err;
/* Quiet Shutdown */
if (!TEST_false(SSL_get_quiet_shutdown(ssl)))
goto err;
/* No duplication */
if (!TEST_ptr_null(SSL_dup(ssl)))
goto err;
/* No clear */
if (!TEST_false(SSL_clear(ssl)))
goto err;
testresult = 1;
err:
SSL_free(ssl);
SSL_CTX_free(ctx);
return testresult;
}
static int test_quic_set_fd(int idx)
{
int testresult = 0;
SSL_CTX *ctx = NULL;
SSL *ssl = NULL;
int fd = -1, resfd = -1;
BIO *bio = NULL;
if (!TEST_ptr(ctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method())))
goto err;
if (!TEST_ptr(ssl = SSL_new(ctx)))
goto err;
if (!TEST_int_ge(fd = BIO_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0), 0))
goto err;
if (idx == 0) {
if (!TEST_true(SSL_set_fd(ssl, fd)))
goto err;
if (!TEST_ptr(bio = SSL_get_rbio(ssl)))
goto err;
if (!TEST_ptr_eq(bio, SSL_get_wbio(ssl)))
goto err;
} else if (idx == 1) {
if (!TEST_true(SSL_set_rfd(ssl, fd)))
goto err;
if (!TEST_ptr(bio = SSL_get_rbio(ssl)))
goto err;
if (!TEST_ptr_null(SSL_get_wbio(ssl)))
goto err;
} else {
if (!TEST_true(SSL_set_wfd(ssl, fd)))
goto err;
if (!TEST_ptr(bio = SSL_get_wbio(ssl)))
goto err;
if (!TEST_ptr_null(SSL_get_rbio(ssl)))
goto err;
}
if (!TEST_int_eq(BIO_method_type(bio), BIO_TYPE_DGRAM))
goto err;
if (!TEST_true(BIO_get_fd(bio, &resfd))
|| !TEST_int_eq(resfd, fd))
goto err;
testresult = 1;
err:
SSL_free(ssl);
SSL_CTX_free(ctx);
if (fd >= 0)
BIO_closesocket(fd);
return testresult;
}
#define MAXLOOPS 1000
static int test_bio_ssl(void)
{
/*
* We just use OSSL_QUIC_client_method() rather than
* OSSL_QUIC_client_thread_method(). We will never leave the connection idle
* so we will always be implicitly handling time events anyway via other
* IO calls.
*/
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL, *stream = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
BIO *cbio = NULL, *strbio = NULL, *thisbio;
const char *msg = "Hello world";
int abortctr = 0, err, clienterr = 0, servererr = 0, retc = 0, rets = 0;
size_t written, readbytes, msglen;
int sid = 0, i;
unsigned char buf[80];
if (!TEST_ptr(cctx))
goto err;
cbio = BIO_new_ssl(cctx, 1);
if (!TEST_ptr(cbio))
goto err;
/*
* We must configure the ALPN/peer address etc so we get the SSL object in
* order to pass it to qtest_create_quic_objects for configuration.
*/
if (!TEST_int_eq(BIO_get_ssl(cbio, &clientquic), 1))
goto err;
if (!TEST_true(qtest_create_quic_objects(libctx, NULL, NULL, cert, privkey,
0, &qtserv, &clientquic, NULL,
NULL)))
goto err;
msglen = strlen(msg);
do {
err = BIO_FLAGS_WRITE;
while (!clienterr && !retc && err == BIO_FLAGS_WRITE) {
retc = BIO_write_ex(cbio, msg, msglen, &written);
if (!retc) {
if (BIO_should_retry(cbio))
err = BIO_retry_type(cbio);
else
err = 0;
}
}
if (!clienterr && retc <= 0 && err != BIO_FLAGS_READ) {
TEST_info("BIO_write_ex() failed %d, %d", retc, err);
TEST_openssl_errors();
clienterr = 1;
}
if (!servererr && rets <= 0) {
ossl_quic_tserver_tick(qtserv);
servererr = ossl_quic_tserver_is_term_any(qtserv);
if (!servererr)
rets = ossl_quic_tserver_is_handshake_confirmed(qtserv);
}
if (clienterr && servererr)
goto err;
if (++abortctr == MAXLOOPS) {
TEST_info("No progress made");
goto err;
}
} while ((!retc && !clienterr) || (rets <= 0 && !servererr));
/*
* 2 loops: The first using the default stream, and the second using a new
* client initiated bidi stream.
*/
for (i = 0, thisbio = cbio; i < 2; i++) {
if (!TEST_true(ossl_quic_tserver_read(qtserv, sid, buf, sizeof(buf),
&readbytes))
|| !TEST_mem_eq(msg, msglen, buf, readbytes))
goto err;
if (!TEST_true(ossl_quic_tserver_write(qtserv, sid, (unsigned char *)msg,
msglen, &written)))
goto err;
ossl_quic_tserver_tick(qtserv);
if (!TEST_true(BIO_read_ex(thisbio, buf, sizeof(buf), &readbytes))
|| !TEST_mem_eq(msg, msglen, buf, readbytes))
goto err;
if (i == 1)
break;
/*
* Now create a new stream and repeat. The bottom two bits of the stream
* id represents whether the stream is bidi and whether it is client
* initiated or not. For client initiated bidi they are both 0. So the
* first client initiated bidi stream is 0 and the next one is 4.
*/
sid = 4;
stream = SSL_new_stream(clientquic, 0);
if (!TEST_ptr(stream))
goto err;
thisbio = strbio = BIO_new(BIO_f_ssl());
if (!TEST_ptr(strbio))
goto err;
if (!TEST_int_eq(BIO_set_ssl(thisbio, stream, BIO_CLOSE), 1))
goto err;
stream = NULL;
if (!TEST_true(BIO_write_ex(thisbio, msg, msglen, &written)))
goto err;
ossl_quic_tserver_tick(qtserv);
}
testresult = 1;
err:
BIO_free_all(cbio);
BIO_free_all(strbio);
SSL_free(stream);
ossl_quic_tserver_free(qtserv);
SSL_CTX_free(cctx);
return testresult;
}
#define BACK_PRESSURE_NUM_LOOPS 10000
/*
* Test that sending data from the client to the server faster than the server
* can process it eventually results in back pressure on the client.
*/
static int test_back_pressure(void)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
unsigned char *msg = NULL;
const size_t msglen = 1024;
unsigned char buf[64];
size_t readbytes, written;
int i;
if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey, 0, &qtserv,
&clientquic, NULL, NULL))
|| !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
msg = OPENSSL_malloc(msglen);
if (!TEST_ptr(msg))
goto err;
if (!TEST_int_eq(RAND_bytes_ex(libctx, msg, msglen, 0), 1))
goto err;
/*
* Limit to 10000 loops. If we've not seen any back pressure after that
* we're going to run out of memory, so abort.
*/
for (i = 0; i < BACK_PRESSURE_NUM_LOOPS; i++) {
/* Send data from the client */
if (!SSL_write_ex(clientquic, msg, msglen, &written)) {
/* Check if we are seeing back pressure */
if (SSL_get_error(clientquic, 0) == SSL_ERROR_WANT_WRITE)
break;
TEST_error("Unexpected client failure");
goto err;
}
/* Receive data at the server */
ossl_quic_tserver_tick(qtserv);
if (!TEST_true(ossl_quic_tserver_read(qtserv, 0, buf, sizeof(buf),
&readbytes)))
goto err;
}
if (i == BACK_PRESSURE_NUM_LOOPS) {
TEST_error("No back pressure seen");
goto err;
}
testresult = 1;
err:
SSL_free(clientquic);
ossl_quic_tserver_free(qtserv);
SSL_CTX_free(cctx);
OPENSSL_free(msg);
return testresult;
}
static int dgram_ctr = 0;
static void dgram_cb(int write_p, int version, int content_type,
const void *buf, size_t msglen, SSL *ssl, void *arg)
{
if (!write_p)
return;
if (content_type != SSL3_RT_QUIC_DATAGRAM)
return;
dgram_ctr++;
}
/* Test that we send multiple datagrams in one go when appropriate */
static int test_multiple_dgrams(void)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
unsigned char *buf;
const size_t buflen = 1400;
size_t written;
buf = OPENSSL_zalloc(buflen);
if (!TEST_ptr(cctx)
|| !TEST_ptr(buf)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey, 0, &qtserv,
&clientquic, NULL, NULL))
|| !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
dgram_ctr = 0;
SSL_set_msg_callback(clientquic, dgram_cb);
if (!TEST_true(SSL_write_ex(clientquic, buf, buflen, &written))
|| !TEST_size_t_eq(written, buflen)
/* We wrote enough data for 2 datagrams */
|| !TEST_int_eq(dgram_ctr, 2))
goto err;
testresult = 1;
err:
OPENSSL_free(buf);
SSL_free(clientquic);
ossl_quic_tserver_free(qtserv);
SSL_CTX_free(cctx);
return testresult;
}
static int non_io_retry_cert_verify_cb(X509_STORE_CTX *ctx, void *arg)
{
int idx = SSL_get_ex_data_X509_STORE_CTX_idx();
SSL *ssl;
const int *allow = (int *)arg;
/* this should not happen but check anyway */
if (idx < 0
|| (ssl = X509_STORE_CTX_get_ex_data(ctx, idx)) == NULL)
return 0;
/* If this is our first attempt then retry */
if (*allow == 0)
return SSL_set_retry_verify(ssl);
/* Otherwise do nothing - verification succeeds. Continue as normal */
return 1;
}
/* Test that we can handle a non-io related retry error
* Test 0: Non-blocking
* Test 1: Blocking
*/
static int test_non_io_retry(int idx)
{
SSL_CTX *cctx;
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
int flags = 0, allow = 0;
if (idx >= 1 && !qtest_supports_blocking())
return TEST_skip("Blocking tests not supported in this build");
cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
if (!TEST_ptr(cctx))
goto err;
SSL_CTX_set_cert_verify_callback(cctx, non_io_retry_cert_verify_cb, &allow);
flags = (idx >= 1) ? QTEST_FLAG_BLOCK : 0;
if (!TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert, privkey,
flags, &qtserv, &clientquic, NULL,
NULL))
|| !TEST_true(qtest_create_quic_connection_ex(qtserv, clientquic,
SSL_ERROR_WANT_RETRY_VERIFY))
|| !TEST_int_eq(SSL_want(clientquic), SSL_RETRY_VERIFY))
goto err;
allow = 1;
if (!TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
testresult = 1;
err:
SSL_free(clientquic);
ossl_quic_tserver_free(qtserv);
SSL_CTX_free(cctx);
return testresult;
}
static int use_session_cb_cnt = 0;
static int find_session_cb_cnt = 0;
static const char *pskid = "Identity";
static SSL_SESSION *serverpsk = NULL, *clientpsk = NULL;
static int use_session_cb(SSL *ssl, const EVP_MD *md, const unsigned char **id,
size_t *idlen, SSL_SESSION **sess)
{
use_session_cb_cnt++;
if (clientpsk == NULL)
return 0;
SSL_SESSION_up_ref(clientpsk);
*sess = clientpsk;
*id = (const unsigned char *)pskid;
*idlen = strlen(pskid);
return 1;
}
static int find_session_cb(SSL *ssl, const unsigned char *identity,
size_t identity_len, SSL_SESSION **sess)
{
find_session_cb_cnt++;
if (serverpsk == NULL)
return 0;
/* Identity should match that set by the client */
if (strlen(pskid) != identity_len
|| strncmp(pskid, (const char *)identity, identity_len) != 0)
return 0;
SSL_SESSION_up_ref(serverpsk);
*sess = serverpsk;
return 1;
}
static int test_quic_psk(void)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
if (!TEST_ptr(cctx)
/* No cert or private key for the server, i.e. PSK only */
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, NULL,
NULL, 0, &qtserv,
&clientquic, NULL, NULL)))
goto end;
SSL_set_psk_use_session_callback(clientquic, use_session_cb);
ossl_quic_tserver_set_psk_find_session_cb(qtserv, find_session_cb);
use_session_cb_cnt = 0;
find_session_cb_cnt = 0;
clientpsk = serverpsk = create_a_psk(clientquic, SHA384_DIGEST_LENGTH);
if (!TEST_ptr(clientpsk))
goto end;
/* We already had one ref. Add another one */
SSL_SESSION_up_ref(clientpsk);
if (!TEST_true(qtest_create_quic_connection(qtserv, clientquic))
|| !TEST_int_eq(1, find_session_cb_cnt)
|| !TEST_int_eq(1, use_session_cb_cnt)
/* Check that we actually used the PSK */
|| !TEST_true(SSL_session_reused(clientquic)))
goto end;
testresult = 1;
end:
SSL_free(clientquic);
ossl_quic_tserver_free(qtserv);
SSL_CTX_free(cctx);
SSL_SESSION_free(clientpsk);
SSL_SESSION_free(serverpsk);
clientpsk = serverpsk = NULL;
return testresult;
}
static int test_client_auth(int idx)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL_CTX *sctx = SSL_CTX_new_ex(libctx, NULL, TLS_method());
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
unsigned char buf[20];
static char *msg = "A test message";
size_t msglen = strlen(msg);
size_t numbytes = 0;
if (!TEST_ptr(cctx) || !TEST_ptr(sctx))
goto err;
SSL_CTX_set_verify(sctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT
| SSL_VERIFY_CLIENT_ONCE, NULL);
if (!TEST_true(SSL_CTX_load_verify_file(sctx, cauthca)))
goto err;
if (idx > 0
&& (!TEST_true(SSL_CTX_use_certificate_chain_file(cctx, ccert))
|| !TEST_true(SSL_CTX_use_PrivateKey_file(cctx, cprivkey,
SSL_FILETYPE_PEM))))
goto err;
if (!TEST_true(qtest_create_quic_objects(libctx, cctx, sctx, cert,
privkey, 0, &qtserv,
&clientquic, NULL, NULL)))
goto err;
if (idx > 1) {
if (!TEST_true(ssl_ctx_add_large_cert_chain(libctx, cctx, ccert))
|| !TEST_true(ssl_ctx_add_large_cert_chain(libctx, sctx, cert)))
goto err;
}
if (idx == 0) {
if (!TEST_false(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
/* negative test passed */
testresult = 1;
goto err;
}
if (!TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
/* Check that sending and receiving app data is ok */
if (!TEST_true(SSL_write_ex(clientquic, msg, msglen, &numbytes))
|| !TEST_size_t_eq(numbytes, msglen))
goto err;
ossl_quic_tserver_tick(qtserv);
if (!TEST_true(ossl_quic_tserver_write(qtserv, 0,
(unsigned char *)msg,
msglen, &numbytes)))
goto err;
ossl_quic_tserver_tick(qtserv);
SSL_handle_events(clientquic);
if (!TEST_true(SSL_read_ex(clientquic, buf, sizeof(buf), &numbytes))
|| !TEST_size_t_eq(numbytes, msglen)
|| !TEST_mem_eq(buf, numbytes, msg, msglen))
goto err;
if (!TEST_true(qtest_shutdown(qtserv, clientquic)))
goto err;
testresult = 1;
err:
SSL_free(clientquic);
ossl_quic_tserver_free(qtserv);
SSL_CTX_free(sctx);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test that we correctly handle ALPN supplied by the application
* Test 0: ALPN is provided
* Test 1: No ALPN is provided
*/
static int test_alpn(int idx)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
int ret;
/*
* Ensure we only configure ciphersuites that are available with both the
* default and fips providers to get the same output in both cases
*/
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx, "TLS_AES_128_GCM_SHA256")))
goto err;
if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey,
QTEST_FLAG_FAKE_TIME,
&qtserv,
&clientquic, NULL, NULL)))
goto err;
if (idx == 0) {
/*
* Clear the ALPN we set in qtest_create_quic_objects. We use TEST_false
* because SSL_set_alpn_protos returns 0 for success.
*/
if (!TEST_false(SSL_set_alpn_protos(clientquic, NULL, 0)))
goto err;
}
ret = SSL_connect(clientquic);
if (!TEST_int_le(ret, 0))
goto err;
if (idx == 0) {
/* We expect an immediate error due to lack of ALPN */
if (!TEST_int_eq(SSL_get_error(clientquic, ret), SSL_ERROR_SSL))
goto err;
} else {
/* ALPN was provided so we expect the connection to succeed */
if (!TEST_int_eq(SSL_get_error(clientquic, ret), SSL_ERROR_WANT_READ)
|| !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
}
testresult = 1;
err:
ossl_quic_tserver_free(qtserv);
SSL_free(clientquic);
SSL_CTX_free(cctx);
return testresult;
}
/*
* Test SSL_get_shutdown() behavior.
*/
static int test_get_shutdown(void)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey,
QTEST_FLAG_FAKE_TIME,
&qtserv, &clientquic,
NULL, NULL))
|| !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
if (!TEST_int_eq(SSL_get_shutdown(clientquic), 0))
goto err;
if (!TEST_int_eq(SSL_shutdown(clientquic), 0))
goto err;
if (!TEST_int_eq(SSL_get_shutdown(clientquic), SSL_SENT_SHUTDOWN))
goto err;
do {
ossl_quic_tserver_tick(qtserv);
qtest_add_time(100);
} while (SSL_shutdown(clientquic) == 0);
if (!TEST_int_eq(SSL_get_shutdown(clientquic),
SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN))
goto err;
testresult = 1;
err:
ossl_quic_tserver_free(qtserv);
SSL_free(clientquic);
SSL_CTX_free(cctx);
return testresult;
}
#define MAX_LOOPS 2000
/*
* Keep retrying SSL_read_ex until it succeeds or we give up. Accept a stream
* if we don't already have one
*/
static int unreliable_client_read(SSL *clientquic, SSL **stream, void *buf,
size_t buflen, size_t *readbytes,
QUIC_TSERVER *qtserv)
{
int abortctr;
/* We just do this in a loop with a sleep for simplicity */
for (abortctr = 0; abortctr < MAX_LOOPS; abortctr++) {
if (*stream == NULL) {
SSL_handle_events(clientquic);
*stream = SSL_accept_stream(clientquic, 0);
}
if (*stream != NULL) {
if (SSL_read_ex(*stream, buf, buflen, readbytes))
return 1;
if (!TEST_int_eq(SSL_get_error(*stream, 0), SSL_ERROR_WANT_READ))
return 0;
}
ossl_quic_tserver_tick(qtserv);
qtest_add_time(1);
qtest_wait_for_timeout(clientquic, qtserv);
}
TEST_error("No progress made");
return 0;
}
/* Keep retrying ossl_quic_tserver_read until it succeeds or we give up */
static int unreliable_server_read(QUIC_TSERVER *qtserv, uint64_t sid,
void *buf, size_t buflen, size_t *readbytes,
SSL *clientquic)
{
int abortctr;
/* We just do this in a loop with a sleep for simplicity */
for (abortctr = 0; abortctr < MAX_LOOPS; abortctr++) {
if (ossl_quic_tserver_read(qtserv, sid, buf, buflen, readbytes)
&& *readbytes > 1)
return 1;
ossl_quic_tserver_tick(qtserv);
SSL_handle_events(clientquic);
qtest_add_time(1);
qtest_wait_for_timeout(clientquic, qtserv);
}
TEST_error("No progress made");
return 0;
}
/*
* Create a connection and send data using an unreliable transport. We introduce
* random noise to drop, delay and duplicate datagrams.
* Test 0: Introduce random noise to datagrams
* Test 1: As with test 0 but also split datagrams containing multiple packets
* into individual datagrams so that individual packets can be affected
* by noise - not just a whole datagram.
*/
static int test_noisy_dgram(int idx)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL, *stream[2] = { NULL, NULL };
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
uint64_t sid = 0;
char *msg = "Hello world!";
size_t msglen = strlen(msg), written, readbytes, i, j;
unsigned char buf[80];
int flags = QTEST_FLAG_NOISE | QTEST_FLAG_FAKE_TIME;
QTEST_FAULT *fault = NULL;
if (idx == 1)
flags |= QTEST_FLAG_PACKET_SPLIT;
if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey, flags,
&qtserv,
&clientquic, &fault, NULL)))
goto err;
if (!TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
if (!TEST_true(SSL_set_incoming_stream_policy(clientquic,
SSL_INCOMING_STREAM_POLICY_ACCEPT,
0))
|| !TEST_true(SSL_set_default_stream_mode(clientquic,
SSL_DEFAULT_STREAM_MODE_NONE)))
goto err;
for (j = 0; j < 2; j++) {
if (!TEST_true(ossl_quic_tserver_stream_new(qtserv, 0, &sid)))
goto err;
ossl_quic_tserver_tick(qtserv);
qtest_add_time(1);
/*
* Send data from the server to the client. Some datagrams may get
* lost, modified, dropped or re-ordered. We repeat 20 times to ensure
* we are sending enough datagrams for problems to be noticed.
*/
for (i = 0; i < 20; i++) {
if (!TEST_true(ossl_quic_tserver_write(qtserv, sid,
(unsigned char *)msg, msglen,
&written))
|| !TEST_size_t_eq(msglen, written))
goto err;
ossl_quic_tserver_tick(qtserv);
qtest_add_time(1);
/*
* Since the underlying BIO is now noisy we may get failures that
* need to be retried - so we use unreliable_client_read() to
* handle that
*/
if (!TEST_true(unreliable_client_read(clientquic, &stream[j], buf,
sizeof(buf), &readbytes,
qtserv))
|| !TEST_mem_eq(msg, msglen, buf, readbytes))
goto err;
}
/* Send data from the client to the server */
for (i = 0; i < 20; i++) {
if (!TEST_true(SSL_write_ex(stream[j], (unsigned char *)msg,
msglen, &written))
|| !TEST_size_t_eq(msglen, written))
goto err;
ossl_quic_tserver_tick(qtserv);
qtest_add_time(1);
/*
* Since the underlying BIO is now noisy we may get failures that
* need to be retried - so we use unreliable_server_read() to
* handle that
*/
if (!TEST_true(unreliable_server_read(qtserv, sid, buf, sizeof(buf),
&readbytes, clientquic))
|| !TEST_mem_eq(msg, msglen, buf, readbytes))
goto err;
}
}
testresult = 1;
err:
ossl_quic_tserver_free(qtserv);
SSL_free(stream[0]);
SSL_free(stream[1]);
SSL_free(clientquic);
SSL_CTX_free(cctx);
qtest_fault_free(fault);
return testresult;
}
enum {
TPARAM_OP_DUP,
TPARAM_OP_DROP,
TPARAM_OP_INJECT,
TPARAM_OP_INJECT_TWICE,
TPARAM_OP_INJECT_RAW,
TPARAM_OP_DROP_INJECT,
TPARAM_OP_MUTATE
};
#define TPARAM_CHECK_DUP(name, reason) \
{ QUIC_TPARAM_##name, TPARAM_OP_DUP, (reason) },
#define TPARAM_CHECK_DROP(name, reason) \
{ QUIC_TPARAM_##name, TPARAM_OP_DROP, (reason) },
#define TPARAM_CHECK_INJECT(name, buf, buf_len, reason) \
{ QUIC_TPARAM_##name, TPARAM_OP_INJECT, (reason), \
(buf), (buf_len) },
#define TPARAM_CHECK_INJECT_A(name, buf, reason) \
TPARAM_CHECK_INJECT(name, buf, sizeof(buf), reason)
#define TPARAM_CHECK_DROP_INJECT(name, buf, buf_len, reason) \
{ QUIC_TPARAM_##name, TPARAM_OP_DROP_INJECT, (reason), \
(buf), (buf_len) },
#define TPARAM_CHECK_DROP_INJECT_A(name, buf, reason) \
TPARAM_CHECK_DROP_INJECT(name, buf, sizeof(buf), reason)
#define TPARAM_CHECK_INJECT_TWICE(name, buf, buf_len, reason) \
{ QUIC_TPARAM_##name, TPARAM_OP_INJECT_TWICE, (reason), \
(buf), (buf_len) },
#define TPARAM_CHECK_INJECT_TWICE_A(name, buf, reason) \
TPARAM_CHECK_INJECT_TWICE(name, buf, sizeof(buf), reason)
#define TPARAM_CHECK_INJECT_RAW(buf, buf_len, reason) \
{ 0, TPARAM_OP_INJECT_RAW, (reason), \
(buf), (buf_len) },
#define TPARAM_CHECK_INJECT_RAW_A(buf, reason) \
TPARAM_CHECK_INJECT_RAW(buf, sizeof(buf), reason)
#define TPARAM_CHECK_MUTATE(name, reason) \
{ QUIC_TPARAM_##name, TPARAM_OP_MUTATE, (reason) },
#define TPARAM_CHECK_INT(name, reason) \
TPARAM_CHECK_DROP_INJECT(name, NULL, 0, reason) \
TPARAM_CHECK_DROP_INJECT_A(name, bogus_int, reason) \
TPARAM_CHECK_DROP_INJECT_A(name, int_with_trailer, reason)
struct tparam_test {
uint64_t id;
int op;
const char *expect_fail; /* substring to expect in reason */
const void *buf;
size_t buf_len;
};
static const unsigned char retry_scid_1[8] = { 0 };
static const unsigned char disable_active_migration_1[] = {
0x00
};
static const unsigned char malformed_stateless_reset_token_1[] = {
0x02, 0xff
};
static const unsigned char malformed_stateless_reset_token_2[] = {
0x01
};
static const unsigned char malformed_stateless_reset_token_3[15] = { 0 };
static const unsigned char malformed_stateless_reset_token_4[17] = { 0 };
static const unsigned char malformed_preferred_addr_1[] = {
0x0d, 0xff
};
static const unsigned char malformed_preferred_addr_2[42] = {
0x0d, 0x28, /* too short */
};
static const unsigned char malformed_preferred_addr_3[64] = {
0x0d, 0x3e, /* too long */
};
static const unsigned char malformed_preferred_addr_4[] = {
/* TPARAM too short for CID length indicated */
0x0d, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x55,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char malformed_unknown_1[] = {
0xff
};
static const unsigned char malformed_unknown_2[] = {
0x55, 0x55,
};
static const unsigned char malformed_unknown_3[] = {
0x55, 0x55, 0x01,
};
static const unsigned char ack_delay_exp[] = {
0x03
};
static const unsigned char stateless_reset_token[16] = { 0x42 };
static const unsigned char preferred_addr[] = {
0x44, 0x44, 0x44, 0x44,
0x55, 0x55,
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x77, 0x77,
0x02, 0xAA, 0xBB,
0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99,
0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99,
};
static const unsigned char long_cid[21] = { 0x42 };
static const unsigned char excess_ack_delay_exp[] = {
0x15,
};
static const unsigned char excess_max_ack_delay[] = {
0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
};
static const unsigned char excess_initial_max_streams[] = {
0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
static const unsigned char undersize_udp_payload_size[] = {
0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xaf,
};
static const unsigned char undersize_active_conn_id_limit[] = {
0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
static const unsigned char bogus_int[9] = { 0 };
static const unsigned char int_with_trailer[2] = { 0x01 };
#define QUIC_TPARAM_UNKNOWN_1 0xf1f1
static const struct tparam_test tparam_tests[] = {
TPARAM_CHECK_DUP(ORIG_DCID,
"ORIG_DCID appears multiple times")
TPARAM_CHECK_DUP(INITIAL_SCID,
"INITIAL_SCID appears multiple times")
TPARAM_CHECK_DUP(INITIAL_MAX_DATA,
"INITIAL_MAX_DATA appears multiple times")
TPARAM_CHECK_DUP(INITIAL_MAX_STREAM_DATA_BIDI_LOCAL,
"INITIAL_MAX_STREAM_DATA_BIDI_LOCAL appears multiple times")
TPARAM_CHECK_DUP(INITIAL_MAX_STREAM_DATA_BIDI_REMOTE,
"INITIAL_MAX_STREAM_DATA_BIDI_REMOTE appears multiple times")
TPARAM_CHECK_DUP(INITIAL_MAX_STREAM_DATA_UNI,
"INITIAL_MAX_STREAM_DATA_UNI appears multiple times")
TPARAM_CHECK_DUP(INITIAL_MAX_STREAMS_BIDI,
"INITIAL_MAX_STREAMS_BIDI appears multiple times")
TPARAM_CHECK_DUP(INITIAL_MAX_STREAMS_UNI,
"INITIAL_MAX_STREAMS_UNI appears multiple times")
TPARAM_CHECK_DUP(MAX_IDLE_TIMEOUT,
"MAX_IDLE_TIMEOUT appears multiple times")
TPARAM_CHECK_DUP(MAX_UDP_PAYLOAD_SIZE,
"MAX_UDP_PAYLOAD_SIZE appears multiple times")
TPARAM_CHECK_DUP(ACTIVE_CONN_ID_LIMIT,
"ACTIVE_CONN_ID_LIMIT appears multiple times")
TPARAM_CHECK_DUP(DISABLE_ACTIVE_MIGRATION,
"DISABLE_ACTIVE_MIGRATION appears multiple times")
TPARAM_CHECK_DROP(INITIAL_SCID,
"INITIAL_SCID was not sent but is required")
TPARAM_CHECK_DROP(ORIG_DCID,
"ORIG_DCID was not sent but is required")
TPARAM_CHECK_INJECT_A(RETRY_SCID, retry_scid_1,
"RETRY_SCID sent when not performing a retry")
TPARAM_CHECK_DROP_INJECT_A(DISABLE_ACTIVE_MIGRATION, disable_active_migration_1,
"DISABLE_ACTIVE_MIGRATION is malformed")
TPARAM_CHECK_INJECT(UNKNOWN_1, NULL, 0,
NULL)
TPARAM_CHECK_INJECT_RAW_A(malformed_stateless_reset_token_1,
"STATELESS_RESET_TOKEN is malformed")
TPARAM_CHECK_INJECT_A(STATELESS_RESET_TOKEN,
malformed_stateless_reset_token_2,
"STATELESS_RESET_TOKEN is malformed")
TPARAM_CHECK_INJECT_A(STATELESS_RESET_TOKEN,
malformed_stateless_reset_token_3,
"STATELESS_RESET_TOKEN is malformed")
TPARAM_CHECK_INJECT_A(STATELESS_RESET_TOKEN,
malformed_stateless_reset_token_4,
"STATELESS_RESET_TOKEN is malformed")
TPARAM_CHECK_INJECT(STATELESS_RESET_TOKEN,
NULL, 0,
"STATELESS_RESET_TOKEN is malformed")
TPARAM_CHECK_INJECT_RAW_A(malformed_preferred_addr_1,
"PREFERRED_ADDR is malformed")
TPARAM_CHECK_INJECT_RAW_A(malformed_preferred_addr_2,
"PREFERRED_ADDR is malformed")
TPARAM_CHECK_INJECT_RAW_A(malformed_preferred_addr_3,
"PREFERRED_ADDR is malformed")
TPARAM_CHECK_INJECT_RAW_A(malformed_preferred_addr_4,
"PREFERRED_ADDR is malformed")
TPARAM_CHECK_INJECT_RAW_A(malformed_unknown_1,
"bad transport parameter")
TPARAM_CHECK_INJECT_RAW_A(malformed_unknown_2,
"bad transport parameter")
TPARAM_CHECK_INJECT_RAW_A(malformed_unknown_3,
"bad transport parameter")
TPARAM_CHECK_INJECT_A(ACK_DELAY_EXP, excess_ack_delay_exp,
"ACK_DELAY_EXP is malformed")
TPARAM_CHECK_INJECT_A(MAX_ACK_DELAY, excess_max_ack_delay,
"MAX_ACK_DELAY is malformed")
TPARAM_CHECK_DROP_INJECT_A(INITIAL_MAX_STREAMS_BIDI, excess_initial_max_streams,
"INITIAL_MAX_STREAMS_BIDI is malformed")
TPARAM_CHECK_DROP_INJECT_A(INITIAL_MAX_STREAMS_UNI, excess_initial_max_streams,
"INITIAL_MAX_STREAMS_UNI is malformed")
TPARAM_CHECK_DROP_INJECT_A(MAX_UDP_PAYLOAD_SIZE, undersize_udp_payload_size,
"MAX_UDP_PAYLOAD_SIZE is malformed")
TPARAM_CHECK_DROP_INJECT_A(ACTIVE_CONN_ID_LIMIT, undersize_active_conn_id_limit,
"ACTIVE_CONN_ID_LIMIT is malformed")
TPARAM_CHECK_INJECT_TWICE_A(ACK_DELAY_EXP, ack_delay_exp,
"ACK_DELAY_EXP appears multiple times")
TPARAM_CHECK_INJECT_TWICE_A(MAX_ACK_DELAY, ack_delay_exp,
"MAX_ACK_DELAY appears multiple times")
TPARAM_CHECK_INJECT_TWICE_A(STATELESS_RESET_TOKEN, stateless_reset_token,
"STATELESS_RESET_TOKEN appears multiple times")
TPARAM_CHECK_INJECT_TWICE_A(PREFERRED_ADDR, preferred_addr,
"PREFERRED_ADDR appears multiple times")
TPARAM_CHECK_MUTATE(ORIG_DCID,
"ORIG_DCID does not match expected value")
TPARAM_CHECK_MUTATE(INITIAL_SCID,
"INITIAL_SCID does not match expected value")
TPARAM_CHECK_DROP_INJECT_A(ORIG_DCID, long_cid,
"ORIG_DCID is malformed")
TPARAM_CHECK_DROP_INJECT_A(INITIAL_SCID, long_cid,
"INITIAL_SCID is malformed")
TPARAM_CHECK_INT(INITIAL_MAX_DATA,
"INITIAL_MAX_DATA is malformed")
TPARAM_CHECK_INT(INITIAL_MAX_STREAM_DATA_BIDI_LOCAL,
"INITIAL_MAX_STREAM_DATA_BIDI_LOCAL is malformed")
TPARAM_CHECK_INT(INITIAL_MAX_STREAM_DATA_BIDI_REMOTE,
"INITIAL_MAX_STREAM_DATA_BIDI_REMOTE is malformed")
TPARAM_CHECK_INT(INITIAL_MAX_STREAM_DATA_UNI,
"INITIAL_MAX_STREAM_DATA_UNI is malformed")
TPARAM_CHECK_INT(ACK_DELAY_EXP,
"ACK_DELAY_EXP is malformed")
TPARAM_CHECK_INT(MAX_ACK_DELAY,
"MAX_ACK_DELAY is malformed")
TPARAM_CHECK_INT(INITIAL_MAX_STREAMS_BIDI,
"INITIAL_MAX_STREAMS_BIDI is malformed")
TPARAM_CHECK_INT(INITIAL_MAX_STREAMS_UNI,
"INITIAL_MAX_STREAMS_UNI is malformed")
TPARAM_CHECK_INT(MAX_IDLE_TIMEOUT,
"MAX_IDLE_TIMEOUT is malformed")
TPARAM_CHECK_INT(MAX_UDP_PAYLOAD_SIZE,
"MAX_UDP_PAYLOAD_SIZE is malformed")
TPARAM_CHECK_INT(ACTIVE_CONN_ID_LIMIT,
"ACTIVE_CONN_ID_LIMIT is malformed")
};
struct tparam_ctx {
const struct tparam_test *t;
};
static int tparam_handle(struct tparam_ctx *ctx,
uint64_t id, unsigned char *data,
size_t data_len,
WPACKET *wpkt)
{
const struct tparam_test *t = ctx->t;
switch (t->op) {
case TPARAM_OP_DUP:
if (!TEST_ptr(ossl_quic_wire_encode_transport_param_bytes(wpkt, id,
data, data_len)))
return 0;
/*
* If this is the matching ID, write it again, duplicating the TPARAM.
*/
if (id == t->id
&& !TEST_ptr(ossl_quic_wire_encode_transport_param_bytes(wpkt, id,
data, data_len)))
return 0;
return 1;
case TPARAM_OP_DROP:
case TPARAM_OP_DROP_INJECT:
/* Pass through unless ID matches. */
if (id != t->id
&& !TEST_ptr(ossl_quic_wire_encode_transport_param_bytes(wpkt, id,
data, data_len)))
return 0;
return 1;
case TPARAM_OP_INJECT:
case TPARAM_OP_INJECT_TWICE:
case TPARAM_OP_INJECT_RAW:
/* Always pass through. */
if (!TEST_ptr(ossl_quic_wire_encode_transport_param_bytes(wpkt, id,
data, data_len)))
return 0;
return 1;
case TPARAM_OP_MUTATE:
if (id == t->id) {
if (!TEST_size_t_gt(data_len, 0))
return 0;
data[0] ^= 1;
}
if (!TEST_ptr(ossl_quic_wire_encode_transport_param_bytes(wpkt, id,
data, data_len)))
return 0;
if (id == t->id)
data[0] ^= 1;
return 1;
default:
return 0;
}
}
static int tparam_on_enc_ext(QTEST_FAULT *qtf, QTEST_ENCRYPTED_EXTENSIONS *ee,
size_t ee_len, void *arg)
{
int rc = 0;
struct tparam_ctx *ctx = arg;
PACKET pkt = {0};
WPACKET wpkt;
int have_wpkt = 0;
BUF_MEM *old_bufm = NULL, *new_bufm = NULL;
unsigned char *tp_p;
size_t tp_len, written, old_len, eb_len;
uint64_t id;
if (!TEST_ptr(old_bufm = BUF_MEM_new()))
goto err;
/*
* Delete transport parameters TLS extension and capture the contents of the
* extension which was removed.
*/
if (!TEST_true(qtest_fault_delete_extension(qtf, TLSEXT_TYPE_quic_transport_parameters,
ee->extensions, &ee->extensionslen,
old_bufm)))
goto err;
if (!TEST_true(PACKET_buf_init(&pkt, (unsigned char *)old_bufm->data, old_bufm->length))
|| !TEST_ptr(new_bufm = BUF_MEM_new())
|| !TEST_true(WPACKET_init(&wpkt, new_bufm)))
goto err;
have_wpkt = 1;
/*
* Open transport parameters TLS extension:
*
* u16 Extension ID (quic_transport_parameters)
* u16 Extension Data Length
* ... Extension Data
*
*/
if (!TEST_true(WPACKET_put_bytes_u16(&wpkt,
TLSEXT_TYPE_quic_transport_parameters))
|| !TEST_true(WPACKET_start_sub_packet_u16(&wpkt)))
goto err;
for (; PACKET_remaining(&pkt) > 0; ) {
tp_p = (unsigned char *)ossl_quic_wire_decode_transport_param_bytes(&pkt,
&id,
&tp_len);
if (!TEST_ptr(tp_p)) {
TEST_mem_eq(PACKET_data(&pkt), PACKET_remaining(&pkt), NULL, 0);
goto err;
}
if (!TEST_true(tparam_handle(ctx, id, tp_p, tp_len, &wpkt)))
goto err;
}
if (ctx->t->op == TPARAM_OP_INJECT || ctx->t->op == TPARAM_OP_DROP_INJECT
|| ctx->t->op == TPARAM_OP_INJECT_TWICE) {
if (!TEST_ptr(ossl_quic_wire_encode_transport_param_bytes(&wpkt, ctx->t->id,
ctx->t->buf,
ctx->t->buf_len)))
goto err;
if (ctx->t->op == TPARAM_OP_INJECT_TWICE
&& !TEST_ptr(ossl_quic_wire_encode_transport_param_bytes(&wpkt, ctx->t->id,
ctx->t->buf,
ctx->t->buf_len)))
goto err;
} else if (ctx->t->op == TPARAM_OP_INJECT_RAW) {
if (!TEST_true(WPACKET_memcpy(&wpkt, ctx->t->buf, ctx->t->buf_len)))
goto err;
}
if (!TEST_true(WPACKET_close(&wpkt))) /* end extension data, set length */
goto err;
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
goto err;
WPACKET_finish(&wpkt);
have_wpkt = 0;
/*
* Append the constructed extension blob to the extension block.
*/
old_len = ee->extensionslen;
if (!qtest_fault_resize_message(qtf, ee->extensionslen + written))
goto err;
memcpy(ee->extensions + old_len, new_bufm->data, written);
/* Fixup the extension block header (u16 length of entire block). */
eb_len = (((uint16_t)ee->extensions[0]) << 8) + (uint16_t)ee->extensions[1];
eb_len += written;
ee->extensions[0] = (unsigned char)((eb_len >> 8) & 0xFF);
ee->extensions[1] = (unsigned char)( eb_len & 0xFF);
rc = 1;
err:
if (have_wpkt)
WPACKET_cleanup(&wpkt);
BUF_MEM_free(old_bufm);
BUF_MEM_free(new_bufm);
return rc;
}
static int test_tparam(int idx)
{
int testresult = 0;
SSL_CTX *c_ctx = NULL;
SSL *c_ssl = NULL;
QUIC_TSERVER *s = NULL;
QTEST_FAULT *qtf = NULL;
struct tparam_ctx ctx = {0};
ctx.t = &tparam_tests[idx];
if (!TEST_ptr(c_ctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method())))
goto err;
if (!TEST_true(qtest_create_quic_objects(libctx, c_ctx, NULL, cert,
privkey, 0, &s,
&c_ssl, &qtf, NULL)))
goto err;
if (!TEST_true(qtest_fault_set_hand_enc_ext_listener(qtf, tparam_on_enc_ext,
&ctx)))
goto err;
if (!TEST_true(qtest_create_quic_connection_ex(s, c_ssl,
ctx.t->expect_fail != NULL)))
goto err;
if (ctx.t->expect_fail != NULL) {
SSL_CONN_CLOSE_INFO info = {0};
if (!TEST_true(SSL_get_conn_close_info(c_ssl, &info, sizeof(info))))
goto err;
if (!TEST_true((info.flags & SSL_CONN_CLOSE_FLAG_TRANSPORT) != 0)
|| !TEST_uint64_t_eq(info.error_code, QUIC_ERR_TRANSPORT_PARAMETER_ERROR)
|| !TEST_ptr(strstr(info.reason, ctx.t->expect_fail))) {
TEST_error("expected connection closure information mismatch"
" during TPARAM test: flags=%llu ec=%llu reason='%s'",
(unsigned long long)info.flags,
(unsigned long long)info.error_code,
info.reason);
goto err;
}
}
testresult = 1;
err:
if (!testresult) {
if (ctx.t->expect_fail != NULL)
TEST_info("failed during test for id=%llu, op=%d, bl=%zu, "
"expected failure='%s'", (unsigned long long)ctx.t->id,
ctx.t->op, ctx.t->buf_len, ctx.t->expect_fail);
else
TEST_info("failed during test for id=%llu, op=%d, bl=%zu",
(unsigned long long)ctx.t->id, ctx.t->op, ctx.t->buf_len);
}
ossl_quic_tserver_free(s);
SSL_free(c_ssl);
SSL_CTX_free(c_ctx);
qtest_fault_free(qtf);
return testresult;
}
/***********************************************************************************/
OPT_TEST_DECLARE_USAGE("provider config certsdir datadir\n")
int setup_tests(void)
{
char *modulename;
char *configfile;
libctx = OSSL_LIB_CTX_new();
if (!TEST_ptr(libctx))
return 0;
defctxnull = OSSL_PROVIDER_load(NULL, "null");
/*
* Verify that the default and fips providers in the default libctx are not
* available
*/
if (!TEST_false(OSSL_PROVIDER_available(NULL, "default"))
|| !TEST_false(OSSL_PROVIDER_available(NULL, "fips")))
goto err;
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
goto err;
}
if (!TEST_ptr(modulename = test_get_argument(0))
|| !TEST_ptr(configfile = test_get_argument(1))
|| !TEST_ptr(certsdir = test_get_argument(2))
|| !TEST_ptr(datadir = test_get_argument(3)))
goto err;
if (!TEST_true(OSSL_LIB_CTX_load_config(libctx, configfile)))
goto err;
/* Check we have the expected provider available */
if (!TEST_true(OSSL_PROVIDER_available(libctx, modulename)))
goto err;
/* Check the default provider is not available */
if (strcmp(modulename, "default") != 0
&& !TEST_false(OSSL_PROVIDER_available(libctx, "default")))
goto err;
if (strcmp(modulename, "fips") == 0)
is_fips = 1;
cert = test_mk_file_path(certsdir, "servercert.pem");
if (cert == NULL)
goto err;
ccert = test_mk_file_path(certsdir, "ee-client-chain.pem");
if (ccert == NULL)
goto err;
cauthca = test_mk_file_path(certsdir, "root-cert.pem");
if (cauthca == NULL)
goto err;
privkey = test_mk_file_path(certsdir, "serverkey.pem");
if (privkey == NULL)
goto err;
cprivkey = test_mk_file_path(certsdir, "ee-key.pem");
if (privkey == NULL)
goto err;
ADD_ALL_TESTS(test_quic_write_read, 3);
ADD_TEST(test_fin_only_blocking);
ADD_TEST(test_ciphersuites);
ADD_TEST(test_cipher_find);
ADD_TEST(test_version);
#if defined(DO_SSL_TRACE_TEST)
ADD_TEST(test_ssl_trace);
#endif
ADD_TEST(test_quic_forbidden_apis_ctx);
ADD_TEST(test_quic_forbidden_apis);
ADD_TEST(test_quic_forbidden_options);
ADD_ALL_TESTS(test_quic_set_fd, 3);
ADD_TEST(test_bio_ssl);
ADD_TEST(test_back_pressure);
ADD_TEST(test_multiple_dgrams);
ADD_ALL_TESTS(test_non_io_retry, 2);
ADD_TEST(test_quic_psk);
ADD_ALL_TESTS(test_client_auth, 3);
ADD_ALL_TESTS(test_alpn, 2);
ADD_ALL_TESTS(test_noisy_dgram, 2);
ADD_TEST(test_get_shutdown);
ADD_ALL_TESTS(test_tparam, OSSL_NELEM(tparam_tests));
return 1;
err:
cleanup_tests();
return 0;
}
void cleanup_tests(void)
{
bio_f_noisy_dgram_filter_free();
bio_f_pkt_split_dgram_filter_free();
OPENSSL_free(cert);
OPENSSL_free(privkey);
OPENSSL_free(ccert);
OPENSSL_free(cauthca);
OPENSSL_free(cprivkey);
OSSL_PROVIDER_unload(defctxnull);
OSSL_LIB_CTX_free(libctx);
}
|
./openssl/test/asn1_stable_parse_test.c | /*
* Copyright 2023 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 <openssl/evp.h>
#include "testutil.h"
static char *config_file = NULL;
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_CONFIG_FILE,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "config", OPT_CONFIG_FILE, '<',
"The configuration file to use for the libctx" },
{ NULL }
};
return options;
}
/*
* Test that parsing a config file with incorrect stable settings aren't parsed
* and appropriate errors are raised
*/
static int test_asn1_stable_parse(void)
{
int testret = 0;
unsigned long errcode;
OSSL_LIB_CTX *newctx = OSSL_LIB_CTX_new();
if (!TEST_ptr(newctx))
goto out;
if (!TEST_int_eq(OSSL_LIB_CTX_load_config(newctx, config_file), 0))
goto err;
errcode = ERR_peek_error();
if (ERR_GET_LIB(errcode) != ERR_LIB_ASN1)
goto err;
if (ERR_GET_REASON(errcode) != ASN1_R_INVALID_STRING_TABLE_VALUE)
goto err;
ERR_clear_error();
testret = 1;
err:
OSSL_LIB_CTX_free(newctx);
out:
return testret;
}
int setup_tests(void)
{
OPTION_CHOICE o;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_CONFIG_FILE:
config_file = opt_arg();
break;
default:
return 0;
}
}
ADD_TEST(test_asn1_stable_parse);
return 1;
}
|
./openssl/test/time_offset_test.c | /*
* Copyright 2017-2018 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
*/
/* time_t/offset (+/-XXXX) tests for ASN1 and X509 */
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <openssl/asn1.h>
#include <openssl/x509.h>
#include "testutil.h"
#include "internal/nelem.h"
typedef struct {
const char *data;
int time_result;
int type;
} TESTDATA;
/**********************************************************************
*
* Test driver
*
***/
static TESTDATA tests[] = {
{ "20001201000000Z", 0, V_ASN1_GENERALIZEDTIME },
{ "20001201010000+0100", 0, V_ASN1_GENERALIZEDTIME },
{ "20001201050000+0500", 0, V_ASN1_GENERALIZEDTIME },
{ "20001130230000-0100", 0, V_ASN1_GENERALIZEDTIME },
{ "20001130190000-0500", 0, V_ASN1_GENERALIZEDTIME },
{ "20001130190001-0500", 1, V_ASN1_GENERALIZEDTIME }, /* +1 second */
{ "20001130185959-0500", -1, V_ASN1_GENERALIZEDTIME }, /* -1 second */
{ "001201000000Z", 0, V_ASN1_UTCTIME },
{ "001201010000+0100", 0, V_ASN1_UTCTIME },
{ "001201050000+0500", 0, V_ASN1_UTCTIME },
{ "001130230000-0100", 0, V_ASN1_UTCTIME },
{ "001130190000-0500", 0, V_ASN1_UTCTIME },
{ "001201000000-0000", 0, V_ASN1_UTCTIME },
{ "001201000001-0000", 1, V_ASN1_UTCTIME }, /* +1 second */
{ "001130235959-0000", -1, V_ASN1_UTCTIME }, /* -1 second */
{ "20001201000000+0000", 0, V_ASN1_GENERALIZEDTIME },
{ "20001201000000+0100", -1, V_ASN1_GENERALIZEDTIME },
{ "001201000000+0100", -1, V_ASN1_UTCTIME },
{ "20001201000000-0100", 1, V_ASN1_GENERALIZEDTIME },
{ "001201000000-0100", 1, V_ASN1_UTCTIME },
{ "20001201123400+1234", 0, V_ASN1_GENERALIZEDTIME },
{ "20001130112600-1234", 0, V_ASN1_GENERALIZEDTIME },
};
static time_t the_time = 975628800;
static ASN1_TIME the_asn1_time = {
15,
V_ASN1_GENERALIZEDTIME,
(unsigned char*)"20001201000000Z",
0
};
static int test_offset(int idx)
{
ASN1_TIME at;
const TESTDATA *testdata = &tests[idx];
int ret = -2;
int day, sec;
at.data = (unsigned char*)testdata->data;
at.length = strlen(testdata->data);
at.type = testdata->type;
at.flags = 0;
if (!TEST_true(ASN1_TIME_diff(&day, &sec, &the_asn1_time, &at))) {
TEST_info("ASN1_TIME_diff() failed for %s\n", at.data);
return 0;
}
if (day > 0)
ret = 1;
else if (day < 0)
ret = -1;
else if (sec > 0)
ret = 1;
else if (sec < 0)
ret = -1;
else
ret = 0;
if (!TEST_int_eq(testdata->time_result, ret)) {
TEST_info("ASN1_TIME_diff() test failed for %s day=%d sec=%d\n", at.data, day, sec);
return 0;
}
ret = ASN1_TIME_cmp_time_t(&at, the_time);
if (!TEST_int_eq(testdata->time_result, ret)) {
TEST_info("ASN1_UTCTIME_cmp_time_t() test failed for %s\n", at.data);
return 0;
}
return 1;
}
int setup_tests(void)
{
ADD_ALL_TESTS(test_offset, OSSL_NELEM(tests));
return 1;
}
|
./openssl/test/pemtest.c | /*
* Copyright 2017-2023 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 <string.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
#include "testutil.h"
#include "internal/nelem.h"
typedef struct {
const char *raw;
const char *encoded;
} TESTDATA;
static TESTDATA b64_pem_data[] = {
{ "hello world",
"aGVsbG8gd29ybGQ=" },
{ "a very ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong input",
"YSB2ZXJ5IG9vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29uZyBpbnB1dA==" }
};
static const char *pemtype = "PEMTESTDATA";
static char *pemfile;
static int test_b64(int idx)
{
BIO *b = BIO_new(BIO_s_mem());
char *name = NULL, *header = NULL;
unsigned char *data = NULL;
long len;
int ret = 0;
const char *raw = b64_pem_data[idx].raw;
const char *encoded = b64_pem_data[idx].encoded;
if (!TEST_ptr(b)
|| !TEST_true(BIO_printf(b, "-----BEGIN %s-----\n", pemtype))
|| !TEST_true(BIO_printf(b, "%s\n", encoded))
|| !TEST_true(BIO_printf(b, "-----END %s-----\n", pemtype))
|| !TEST_true(PEM_read_bio_ex(b, &name, &header, &data, &len,
PEM_FLAG_ONLY_B64)))
goto err;
if (!TEST_int_eq(memcmp(pemtype, name, strlen(pemtype)), 0)
|| !TEST_int_eq(len, strlen(raw))
|| !TEST_int_eq(memcmp(data, raw, strlen(raw)), 0))
goto err;
ret = 1;
err:
BIO_free(b);
OPENSSL_free(name);
OPENSSL_free(header);
OPENSSL_free(data);
return ret;
}
static int test_invalid(void)
{
BIO *b = BIO_new(BIO_s_mem());
char *name = NULL, *header = NULL;
unsigned char *data = NULL;
long len;
const char *encoded = b64_pem_data[0].encoded;
if (!TEST_ptr(b)
|| !TEST_true(BIO_printf(b, "-----BEGIN %s-----\n", pemtype))
|| !TEST_true(BIO_printf(b, "%c%s\n", '\t', encoded))
|| !TEST_true(BIO_printf(b, "-----END %s-----\n", pemtype))
/* Expected to fail due to non-base64 character */
|| TEST_true(PEM_read_bio_ex(b, &name, &header, &data, &len,
PEM_FLAG_ONLY_B64))) {
BIO_free(b);
return 0;
}
BIO_free(b);
OPENSSL_free(name);
OPENSSL_free(header);
OPENSSL_free(data);
return 1;
}
static int test_cert_key_cert(void)
{
EVP_PKEY *key;
if (!TEST_ptr(key = load_pkey_pem(pemfile, NULL)))
return 0;
EVP_PKEY_free(key);
return 1;
}
static int test_empty_payload(void)
{
BIO *b;
static char *emptypay =
"-----BEGIN CERTIFICATE-----\n"
"-\n" /* Base64 EOF character */
"-----END CERTIFICATE-----";
char *name = NULL, *header = NULL;
unsigned char *data = NULL;
long len;
int ret = 0;
b = BIO_new_mem_buf(emptypay, strlen(emptypay));
if (!TEST_ptr(b))
return 0;
/* Expected to fail because the payload is empty */
if (!TEST_false(PEM_read_bio_ex(b, &name, &header, &data, &len, 0)))
goto err;
ret = 1;
err:
OPENSSL_free(name);
OPENSSL_free(header);
OPENSSL_free(data);
BIO_free(b);
return ret;
}
static int test_protected_params(void)
{
BIO *b;
static char *protectedpay =
"-----BEGIN RSA PRIVATE KEY-----\n"
"Proc-Type: 4,ENCRYPTED\n"
"DEK-Info: AES-256-CBC,4A44448ED28992710556549B35100CEA\n"
"\n"
"Xw3INxKeH+rUUF57mjATpvj6zknVhedwrlRmRvnwlLv5wqIy5Ae4UVLPh7SUswfC\n"
"-----END RSA PRIVATE KEY-----\n";
EVP_PKEY *pkey = NULL;
int ret = 0;
b = BIO_new_mem_buf(protectedpay, strlen(protectedpay));
if (!TEST_ptr(b))
return 0;
/* Expected to fail because we cannot decrypt protected PEM files */
pkey = PEM_read_bio_Parameters(b, NULL);
if (!TEST_ptr_null(pkey))
goto err;
ret = 1;
err:
EVP_PKEY_free(pkey);
BIO_free(b);
return ret;
}
int setup_tests(void)
{
if (!TEST_ptr(pemfile = test_get_argument(0)))
return 0;
ADD_ALL_TESTS(test_b64, OSSL_NELEM(b64_pem_data));
ADD_TEST(test_invalid);
ADD_TEST(test_cert_key_cert);
ADD_TEST(test_empty_payload);
ADD_TEST(test_protected_params);
return 1;
}
|
./openssl/test/curve448_internal_test.c | /*
* Copyright 2017-2023 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 <string.h>
#include <openssl/e_os2.h>
#include <openssl/evp.h>
#include "crypto/ecx.h"
#include "curve448_local.h"
#include "testutil.h"
static unsigned int max = 1000;
static unsigned int verbose = 0;
/* Test vectors from RFC7748 for X448 */
static const uint8_t in_scalar1[56] = {
0x3d, 0x26, 0x2f, 0xdd, 0xf9, 0xec, 0x8e, 0x88, 0x49, 0x52, 0x66, 0xfe,
0xa1, 0x9a, 0x34, 0xd2, 0x88, 0x82, 0xac, 0xef, 0x04, 0x51, 0x04, 0xd0,
0xd1, 0xaa, 0xe1, 0x21, 0x70, 0x0a, 0x77, 0x9c, 0x98, 0x4c, 0x24, 0xf8,
0xcd, 0xd7, 0x8f, 0xbf, 0xf4, 0x49, 0x43, 0xeb, 0xa3, 0x68, 0xf5, 0x4b,
0x29, 0x25, 0x9a, 0x4f, 0x1c, 0x60, 0x0a, 0xd3
};
static const uint8_t in_u1[56] = {
0x06, 0xfc, 0xe6, 0x40, 0xfa, 0x34, 0x87, 0xbf, 0xda, 0x5f, 0x6c, 0xf2,
0xd5, 0x26, 0x3f, 0x8a, 0xad, 0x88, 0x33, 0x4c, 0xbd, 0x07, 0x43, 0x7f,
0x02, 0x0f, 0x08, 0xf9, 0x81, 0x4d, 0xc0, 0x31, 0xdd, 0xbd, 0xc3, 0x8c,
0x19, 0xc6, 0xda, 0x25, 0x83, 0xfa, 0x54, 0x29, 0xdb, 0x94, 0xad, 0xa1,
0x8a, 0xa7, 0xa7, 0xfb, 0x4e, 0xf8, 0xa0, 0x86
};
static const uint8_t out_u1[56] = {
0xce, 0x3e, 0x4f, 0xf9, 0x5a, 0x60, 0xdc, 0x66, 0x97, 0xda, 0x1d, 0xb1,
0xd8, 0x5e, 0x6a, 0xfb, 0xdf, 0x79, 0xb5, 0x0a, 0x24, 0x12, 0xd7, 0x54,
0x6d, 0x5f, 0x23, 0x9f, 0xe1, 0x4f, 0xba, 0xad, 0xeb, 0x44, 0x5f, 0xc6,
0x6a, 0x01, 0xb0, 0x77, 0x9d, 0x98, 0x22, 0x39, 0x61, 0x11, 0x1e, 0x21,
0x76, 0x62, 0x82, 0xf7, 0x3d, 0xd9, 0x6b, 0x6f
};
static const uint8_t in_scalar2[56] = {
0x20, 0x3d, 0x49, 0x44, 0x28, 0xb8, 0x39, 0x93, 0x52, 0x66, 0x5d, 0xdc,
0xa4, 0x2f, 0x9d, 0xe8, 0xfe, 0xf6, 0x00, 0x90, 0x8e, 0x0d, 0x46, 0x1c,
0xb0, 0x21, 0xf8, 0xc5, 0x38, 0x34, 0x5d, 0xd7, 0x7c, 0x3e, 0x48, 0x06,
0xe2, 0x5f, 0x46, 0xd3, 0x31, 0x5c, 0x44, 0xe0, 0xa5, 0xb4, 0x37, 0x12,
0x82, 0xdd, 0x2c, 0x8d, 0x5b, 0xe3, 0x09, 0x5f
};
static const uint8_t in_u2[56] = {
0x0f, 0xbc, 0xc2, 0xf9, 0x93, 0xcd, 0x56, 0xd3, 0x30, 0x5b, 0x0b, 0x7d,
0x9e, 0x55, 0xd4, 0xc1, 0xa8, 0xfb, 0x5d, 0xbb, 0x52, 0xf8, 0xe9, 0xa1,
0xe9, 0xb6, 0x20, 0x1b, 0x16, 0x5d, 0x01, 0x58, 0x94, 0xe5, 0x6c, 0x4d,
0x35, 0x70, 0xbe, 0xe5, 0x2f, 0xe2, 0x05, 0xe2, 0x8a, 0x78, 0xb9, 0x1c,
0xdf, 0xbd, 0xe7, 0x1c, 0xe8, 0xd1, 0x57, 0xdb
};
static const uint8_t out_u2[56] = {
0x88, 0x4a, 0x02, 0x57, 0x62, 0x39, 0xff, 0x7a, 0x2f, 0x2f, 0x63, 0xb2,
0xdb, 0x6a, 0x9f, 0xf3, 0x70, 0x47, 0xac, 0x13, 0x56, 0x8e, 0x1e, 0x30,
0xfe, 0x63, 0xc4, 0xa7, 0xad, 0x1b, 0x3e, 0xe3, 0xa5, 0x70, 0x0d, 0xf3,
0x43, 0x21, 0xd6, 0x20, 0x77, 0xe6, 0x36, 0x33, 0xc5, 0x75, 0xc1, 0xc9,
0x54, 0x51, 0x4e, 0x99, 0xda, 0x7c, 0x17, 0x9d
};
static const uint8_t in_u3[56] = {
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const uint8_t out_u3[3][56] = {
{
0x3f, 0x48, 0x2c, 0x8a, 0x9f, 0x19, 0xb0, 0x1e, 0x6c, 0x46, 0xee, 0x97,
0x11, 0xd9, 0xdc, 0x14, 0xfd, 0x4b, 0xf6, 0x7a, 0xf3, 0x07, 0x65, 0xc2,
0xae, 0x2b, 0x84, 0x6a, 0x4d, 0x23, 0xa8, 0xcd, 0x0d, 0xb8, 0x97, 0x08,
0x62, 0x39, 0x49, 0x2c, 0xaf, 0x35, 0x0b, 0x51, 0xf8, 0x33, 0x86, 0x8b,
0x9b, 0xc2, 0xb3, 0xbc, 0xa9, 0xcf, 0x41, 0x13
}, {
0xaa, 0x3b, 0x47, 0x49, 0xd5, 0x5b, 0x9d, 0xaf, 0x1e, 0x5b, 0x00, 0x28,
0x88, 0x26, 0xc4, 0x67, 0x27, 0x4c, 0xe3, 0xeb, 0xbd, 0xd5, 0xc1, 0x7b,
0x97, 0x5e, 0x09, 0xd4, 0xaf, 0x6c, 0x67, 0xcf, 0x10, 0xd0, 0x87, 0x20,
0x2d, 0xb8, 0x82, 0x86, 0xe2, 0xb7, 0x9f, 0xce, 0xea, 0x3e, 0xc3, 0x53,
0xef, 0x54, 0xfa, 0xa2, 0x6e, 0x21, 0x9f, 0x38
}, {
0x07, 0x7f, 0x45, 0x36, 0x81, 0xca, 0xca, 0x36, 0x93, 0x19, 0x84, 0x20,
0xbb, 0xe5, 0x15, 0xca, 0xe0, 0x00, 0x24, 0x72, 0x51, 0x9b, 0x3e, 0x67,
0x66, 0x1a, 0x7e, 0x89, 0xca, 0xb9, 0x46, 0x95, 0xc8, 0xf4, 0xbc, 0xd6,
0x6e, 0x61, 0xb9, 0xb9, 0xc9, 0x46, 0xda, 0x8d, 0x52, 0x4d, 0xe3, 0xd6,
0x9b, 0xd9, 0xd9, 0xd6, 0x6b, 0x99, 0x7e, 0x37
}
};
/* Test vectors from RFC8032 for Ed448 */
/* Pure Ed448 */
static const uint8_t privkey1[57] = {
0x6c, 0x82, 0xa5, 0x62, 0xcb, 0x80, 0x8d, 0x10, 0xd6, 0x32, 0xbe, 0x89,
0xc8, 0x51, 0x3e, 0xbf, 0x6c, 0x92, 0x9f, 0x34, 0xdd, 0xfa, 0x8c, 0x9f,
0x63, 0xc9, 0x96, 0x0e, 0xf6, 0xe3, 0x48, 0xa3, 0x52, 0x8c, 0x8a, 0x3f,
0xcc, 0x2f, 0x04, 0x4e, 0x39, 0xa3, 0xfc, 0x5b, 0x94, 0x49, 0x2f, 0x8f,
0x03, 0x2e, 0x75, 0x49, 0xa2, 0x00, 0x98, 0xf9, 0x5b
};
static const uint8_t pubkey1[57] = {
0x5f, 0xd7, 0x44, 0x9b, 0x59, 0xb4, 0x61, 0xfd, 0x2c, 0xe7, 0x87, 0xec,
0x61, 0x6a, 0xd4, 0x6a, 0x1d, 0xa1, 0x34, 0x24, 0x85, 0xa7, 0x0e, 0x1f,
0x8a, 0x0e, 0xa7, 0x5d, 0x80, 0xe9, 0x67, 0x78, 0xed, 0xf1, 0x24, 0x76,
0x9b, 0x46, 0xc7, 0x06, 0x1b, 0xd6, 0x78, 0x3d, 0xf1, 0xe5, 0x0f, 0x6c,
0xd1, 0xfa, 0x1a, 0xbe, 0xaf, 0xe8, 0x25, 0x61, 0x80
};
static const uint8_t sig1[114] = {
0x53, 0x3a, 0x37, 0xf6, 0xbb, 0xe4, 0x57, 0x25, 0x1f, 0x02, 0x3c, 0x0d,
0x88, 0xf9, 0x76, 0xae, 0x2d, 0xfb, 0x50, 0x4a, 0x84, 0x3e, 0x34, 0xd2,
0x07, 0x4f, 0xd8, 0x23, 0xd4, 0x1a, 0x59, 0x1f, 0x2b, 0x23, 0x3f, 0x03,
0x4f, 0x62, 0x82, 0x81, 0xf2, 0xfd, 0x7a, 0x22, 0xdd, 0xd4, 0x7d, 0x78,
0x28, 0xc5, 0x9b, 0xd0, 0xa2, 0x1b, 0xfd, 0x39, 0x80, 0xff, 0x0d, 0x20,
0x28, 0xd4, 0xb1, 0x8a, 0x9d, 0xf6, 0x3e, 0x00, 0x6c, 0x5d, 0x1c, 0x2d,
0x34, 0x5b, 0x92, 0x5d, 0x8d, 0xc0, 0x0b, 0x41, 0x04, 0x85, 0x2d, 0xb9,
0x9a, 0xc5, 0xc7, 0xcd, 0xda, 0x85, 0x30, 0xa1, 0x13, 0xa0, 0xf4, 0xdb,
0xb6, 0x11, 0x49, 0xf0, 0x5a, 0x73, 0x63, 0x26, 0x8c, 0x71, 0xd9, 0x58,
0x08, 0xff, 0x2e, 0x65, 0x26, 0x00
};
static const uint8_t privkey2[57] = {
0xc4, 0xea, 0xb0, 0x5d, 0x35, 0x70, 0x07, 0xc6, 0x32, 0xf3, 0xdb, 0xb4,
0x84, 0x89, 0x92, 0x4d, 0x55, 0x2b, 0x08, 0xfe, 0x0c, 0x35, 0x3a, 0x0d,
0x4a, 0x1f, 0x00, 0xac, 0xda, 0x2c, 0x46, 0x3a, 0xfb, 0xea, 0x67, 0xc5,
0xe8, 0xd2, 0x87, 0x7c, 0x5e, 0x3b, 0xc3, 0x97, 0xa6, 0x59, 0x94, 0x9e,
0xf8, 0x02, 0x1e, 0x95, 0x4e, 0x0a, 0x12, 0x27, 0x4e
};
static const uint8_t pubkey2[57] = {
0x43, 0xba, 0x28, 0xf4, 0x30, 0xcd, 0xff, 0x45, 0x6a, 0xe5, 0x31, 0x54,
0x5f, 0x7e, 0xcd, 0x0a, 0xc8, 0x34, 0xa5, 0x5d, 0x93, 0x58, 0xc0, 0x37,
0x2b, 0xfa, 0x0c, 0x6c, 0x67, 0x98, 0xc0, 0x86, 0x6a, 0xea, 0x01, 0xeb,
0x00, 0x74, 0x28, 0x02, 0xb8, 0x43, 0x8e, 0xa4, 0xcb, 0x82, 0x16, 0x9c,
0x23, 0x51, 0x60, 0x62, 0x7b, 0x4c, 0x3a, 0x94, 0x80
};
static const uint8_t msg2[1] = {
0x03
};
static const uint8_t sig2[114] = {
0x26, 0xb8, 0xf9, 0x17, 0x27, 0xbd, 0x62, 0x89, 0x7a, 0xf1, 0x5e, 0x41,
0xeb, 0x43, 0xc3, 0x77, 0xef, 0xb9, 0xc6, 0x10, 0xd4, 0x8f, 0x23, 0x35,
0xcb, 0x0b, 0xd0, 0x08, 0x78, 0x10, 0xf4, 0x35, 0x25, 0x41, 0xb1, 0x43,
0xc4, 0xb9, 0x81, 0xb7, 0xe1, 0x8f, 0x62, 0xde, 0x8c, 0xcd, 0xf6, 0x33,
0xfc, 0x1b, 0xf0, 0x37, 0xab, 0x7c, 0xd7, 0x79, 0x80, 0x5e, 0x0d, 0xbc,
0xc0, 0xaa, 0xe1, 0xcb, 0xce, 0xe1, 0xaf, 0xb2, 0xe0, 0x27, 0xdf, 0x36,
0xbc, 0x04, 0xdc, 0xec, 0xbf, 0x15, 0x43, 0x36, 0xc1, 0x9f, 0x0a, 0xf7,
0xe0, 0xa6, 0x47, 0x29, 0x05, 0xe7, 0x99, 0xf1, 0x95, 0x3d, 0x2a, 0x0f,
0xf3, 0x34, 0x8a, 0xb2, 0x1a, 0xa4, 0xad, 0xaf, 0xd1, 0xd2, 0x34, 0x44,
0x1c, 0xf8, 0x07, 0xc0, 0x3a, 0x00
};
static const uint8_t privkey3[57] = {
0xc4, 0xea, 0xb0, 0x5d, 0x35, 0x70, 0x07, 0xc6, 0x32, 0xf3, 0xdb, 0xb4,
0x84, 0x89, 0x92, 0x4d, 0x55, 0x2b, 0x08, 0xfe, 0x0c, 0x35, 0x3a, 0x0d,
0x4a, 0x1f, 0x00, 0xac, 0xda, 0x2c, 0x46, 0x3a, 0xfb, 0xea, 0x67, 0xc5,
0xe8, 0xd2, 0x87, 0x7c, 0x5e, 0x3b, 0xc3, 0x97, 0xa6, 0x59, 0x94, 0x9e,
0xf8, 0x02, 0x1e, 0x95, 0x4e, 0x0a, 0x12, 0x27, 0x4e
};
static const uint8_t pubkey3[57] = {
0x43, 0xba, 0x28, 0xf4, 0x30, 0xcd, 0xff, 0x45, 0x6a, 0xe5, 0x31, 0x54,
0x5f, 0x7e, 0xcd, 0x0a, 0xc8, 0x34, 0xa5, 0x5d, 0x93, 0x58, 0xc0, 0x37,
0x2b, 0xfa, 0x0c, 0x6c, 0x67, 0x98, 0xc0, 0x86, 0x6a, 0xea, 0x01, 0xeb,
0x00, 0x74, 0x28, 0x02, 0xb8, 0x43, 0x8e, 0xa4, 0xcb, 0x82, 0x16, 0x9c,
0x23, 0x51, 0x60, 0x62, 0x7b, 0x4c, 0x3a, 0x94, 0x80
};
static const uint8_t msg3[1] = {
0x03
};
static const uint8_t context3[3] = {
0x66, 0x6f, 0x6f
};
static const uint8_t sig3[114] = {
0xd4, 0xf8, 0xf6, 0x13, 0x17, 0x70, 0xdd, 0x46, 0xf4, 0x08, 0x67, 0xd6,
0xfd, 0x5d, 0x50, 0x55, 0xde, 0x43, 0x54, 0x1f, 0x8c, 0x5e, 0x35, 0xab,
0xbc, 0xd0, 0x01, 0xb3, 0x2a, 0x89, 0xf7, 0xd2, 0x15, 0x1f, 0x76, 0x47,
0xf1, 0x1d, 0x8c, 0xa2, 0xae, 0x27, 0x9f, 0xb8, 0x42, 0xd6, 0x07, 0x21,
0x7f, 0xce, 0x6e, 0x04, 0x2f, 0x68, 0x15, 0xea, 0x00, 0x0c, 0x85, 0x74,
0x1d, 0xe5, 0xc8, 0xda, 0x11, 0x44, 0xa6, 0xa1, 0xab, 0xa7, 0xf9, 0x6d,
0xe4, 0x25, 0x05, 0xd7, 0xa7, 0x29, 0x85, 0x24, 0xfd, 0xa5, 0x38, 0xfc,
0xcb, 0xbb, 0x75, 0x4f, 0x57, 0x8c, 0x1c, 0xad, 0x10, 0xd5, 0x4d, 0x0d,
0x54, 0x28, 0x40, 0x7e, 0x85, 0xdc, 0xbc, 0x98, 0xa4, 0x91, 0x55, 0xc1,
0x37, 0x64, 0xe6, 0x6c, 0x3c, 0x00
};
static const uint8_t privkey4[57] = {
0xcd, 0x23, 0xd2, 0x4f, 0x71, 0x42, 0x74, 0xe7, 0x44, 0x34, 0x32, 0x37,
0xb9, 0x32, 0x90, 0xf5, 0x11, 0xf6, 0x42, 0x5f, 0x98, 0xe6, 0x44, 0x59,
0xff, 0x20, 0x3e, 0x89, 0x85, 0x08, 0x3f, 0xfd, 0xf6, 0x05, 0x00, 0x55,
0x3a, 0xbc, 0x0e, 0x05, 0xcd, 0x02, 0x18, 0x4b, 0xdb, 0x89, 0xc4, 0xcc,
0xd6, 0x7e, 0x18, 0x79, 0x51, 0x26, 0x7e, 0xb3, 0x28
};
static const uint8_t pubkey4[57] = {
0xdc, 0xea, 0x9e, 0x78, 0xf3, 0x5a, 0x1b, 0xf3, 0x49, 0x9a, 0x83, 0x1b,
0x10, 0xb8, 0x6c, 0x90, 0xaa, 0xc0, 0x1c, 0xd8, 0x4b, 0x67, 0xa0, 0x10,
0x9b, 0x55, 0xa3, 0x6e, 0x93, 0x28, 0xb1, 0xe3, 0x65, 0xfc, 0xe1, 0x61,
0xd7, 0x1c, 0xe7, 0x13, 0x1a, 0x54, 0x3e, 0xa4, 0xcb, 0x5f, 0x7e, 0x9f,
0x1d, 0x8b, 0x00, 0x69, 0x64, 0x47, 0x00, 0x14, 0x00
};
static const uint8_t msg4[11] = {
0x0c, 0x3e, 0x54, 0x40, 0x74, 0xec, 0x63, 0xb0, 0x26, 0x5e, 0x0c
};
static const uint8_t sig4[114] = {
0x1f, 0x0a, 0x88, 0x88, 0xce, 0x25, 0xe8, 0xd4, 0x58, 0xa2, 0x11, 0x30,
0x87, 0x9b, 0x84, 0x0a, 0x90, 0x89, 0xd9, 0x99, 0xaa, 0xba, 0x03, 0x9e,
0xaf, 0x3e, 0x3a, 0xfa, 0x09, 0x0a, 0x09, 0xd3, 0x89, 0xdb, 0xa8, 0x2c,
0x4f, 0xf2, 0xae, 0x8a, 0xc5, 0xcd, 0xfb, 0x7c, 0x55, 0xe9, 0x4d, 0x5d,
0x96, 0x1a, 0x29, 0xfe, 0x01, 0x09, 0x94, 0x1e, 0x00, 0xb8, 0xdb, 0xde,
0xea, 0x6d, 0x3b, 0x05, 0x10, 0x68, 0xdf, 0x72, 0x54, 0xc0, 0xcd, 0xc1,
0x29, 0xcb, 0xe6, 0x2d, 0xb2, 0xdc, 0x95, 0x7d, 0xbb, 0x47, 0xb5, 0x1f,
0xd3, 0xf2, 0x13, 0xfb, 0x86, 0x98, 0xf0, 0x64, 0x77, 0x42, 0x50, 0xa5,
0x02, 0x89, 0x61, 0xc9, 0xbf, 0x8f, 0xfd, 0x97, 0x3f, 0xe5, 0xd5, 0xc2,
0x06, 0x49, 0x2b, 0x14, 0x0e, 0x00
};
static const uint8_t privkey5[57] = {
0x25, 0x8c, 0xdd, 0x4a, 0xda, 0x32, 0xed, 0x9c, 0x9f, 0xf5, 0x4e, 0x63,
0x75, 0x6a, 0xe5, 0x82, 0xfb, 0x8f, 0xab, 0x2a, 0xc7, 0x21, 0xf2, 0xc8,
0xe6, 0x76, 0xa7, 0x27, 0x68, 0x51, 0x3d, 0x93, 0x9f, 0x63, 0xdd, 0xdb,
0x55, 0x60, 0x91, 0x33, 0xf2, 0x9a, 0xdf, 0x86, 0xec, 0x99, 0x29, 0xdc,
0xcb, 0x52, 0xc1, 0xc5, 0xfd, 0x2f, 0xf7, 0xe2, 0x1b
};
static const uint8_t pubkey5[57] = {
0x3b, 0xa1, 0x6d, 0xa0, 0xc6, 0xf2, 0xcc, 0x1f, 0x30, 0x18, 0x77, 0x40,
0x75, 0x6f, 0x5e, 0x79, 0x8d, 0x6b, 0xc5, 0xfc, 0x01, 0x5d, 0x7c, 0x63,
0xcc, 0x95, 0x10, 0xee, 0x3f, 0xd4, 0x4a, 0xdc, 0x24, 0xd8, 0xe9, 0x68,
0xb6, 0xe4, 0x6e, 0x6f, 0x94, 0xd1, 0x9b, 0x94, 0x53, 0x61, 0x72, 0x6b,
0xd7, 0x5e, 0x14, 0x9e, 0xf0, 0x98, 0x17, 0xf5, 0x80
};
static const uint8_t msg5[12] = {
0x64, 0xa6, 0x5f, 0x3c, 0xde, 0xdc, 0xdd, 0x66, 0x81, 0x1e, 0x29, 0x15
};
static const uint8_t sig5[114] = {
0x7e, 0xee, 0xab, 0x7c, 0x4e, 0x50, 0xfb, 0x79, 0x9b, 0x41, 0x8e, 0xe5,
0xe3, 0x19, 0x7f, 0xf6, 0xbf, 0x15, 0xd4, 0x3a, 0x14, 0xc3, 0x43, 0x89,
0xb5, 0x9d, 0xd1, 0xa7, 0xb1, 0xb8, 0x5b, 0x4a, 0xe9, 0x04, 0x38, 0xac,
0xa6, 0x34, 0xbe, 0xa4, 0x5e, 0x3a, 0x26, 0x95, 0xf1, 0x27, 0x0f, 0x07,
0xfd, 0xcd, 0xf7, 0xc6, 0x2b, 0x8e, 0xfe, 0xaf, 0x00, 0xb4, 0x5c, 0x2c,
0x96, 0xba, 0x45, 0x7e, 0xb1, 0xa8, 0xbf, 0x07, 0x5a, 0x3d, 0xb2, 0x8e,
0x5c, 0x24, 0xf6, 0xb9, 0x23, 0xed, 0x4a, 0xd7, 0x47, 0xc3, 0xc9, 0xe0,
0x3c, 0x70, 0x79, 0xef, 0xb8, 0x7c, 0xb1, 0x10, 0xd3, 0xa9, 0x98, 0x61,
0xe7, 0x20, 0x03, 0xcb, 0xae, 0x6d, 0x6b, 0x8b, 0x82, 0x7e, 0x4e, 0x6c,
0x14, 0x30, 0x64, 0xff, 0x3c, 0x00
};
static const uint8_t privkey6[57] = {
0x7e, 0xf4, 0xe8, 0x45, 0x44, 0x23, 0x67, 0x52, 0xfb, 0xb5, 0x6b, 0x8f,
0x31, 0xa2, 0x3a, 0x10, 0xe4, 0x28, 0x14, 0xf5, 0xf5, 0x5c, 0xa0, 0x37,
0xcd, 0xcc, 0x11, 0xc6, 0x4c, 0x9a, 0x3b, 0x29, 0x49, 0xc1, 0xbb, 0x60,
0x70, 0x03, 0x14, 0x61, 0x17, 0x32, 0xa6, 0xc2, 0xfe, 0xa9, 0x8e, 0xeb,
0xc0, 0x26, 0x6a, 0x11, 0xa9, 0x39, 0x70, 0x10, 0x0e
};
static const uint8_t pubkey6[57] = {
0xb3, 0xda, 0x07, 0x9b, 0x0a, 0xa4, 0x93, 0xa5, 0x77, 0x20, 0x29, 0xf0,
0x46, 0x7b, 0xae, 0xbe, 0xe5, 0xa8, 0x11, 0x2d, 0x9d, 0x3a, 0x22, 0x53,
0x23, 0x61, 0xda, 0x29, 0x4f, 0x7b, 0xb3, 0x81, 0x5c, 0x5d, 0xc5, 0x9e,
0x17, 0x6b, 0x4d, 0x9f, 0x38, 0x1c, 0xa0, 0x93, 0x8e, 0x13, 0xc6, 0xc0,
0x7b, 0x17, 0x4b, 0xe6, 0x5d, 0xfa, 0x57, 0x8e, 0x80
};
static const uint8_t msg6[13] = {
0x64, 0xa6, 0x5f, 0x3c, 0xde, 0xdc, 0xdd, 0x66, 0x81, 0x1e, 0x29, 0x15,
0xe7
};
static const uint8_t sig6[114] = {
0x6a, 0x12, 0x06, 0x6f, 0x55, 0x33, 0x1b, 0x6c, 0x22, 0xac, 0xd5, 0xd5,
0xbf, 0xc5, 0xd7, 0x12, 0x28, 0xfb, 0xda, 0x80, 0xae, 0x8d, 0xec, 0x26,
0xbd, 0xd3, 0x06, 0x74, 0x3c, 0x50, 0x27, 0xcb, 0x48, 0x90, 0x81, 0x0c,
0x16, 0x2c, 0x02, 0x74, 0x68, 0x67, 0x5e, 0xcf, 0x64, 0x5a, 0x83, 0x17,
0x6c, 0x0d, 0x73, 0x23, 0xa2, 0xcc, 0xde, 0x2d, 0x80, 0xef, 0xe5, 0xa1,
0x26, 0x8e, 0x8a, 0xca, 0x1d, 0x6f, 0xbc, 0x19, 0x4d, 0x3f, 0x77, 0xc4,
0x49, 0x86, 0xeb, 0x4a, 0xb4, 0x17, 0x79, 0x19, 0xad, 0x8b, 0xec, 0x33,
0xeb, 0x47, 0xbb, 0xb5, 0xfc, 0x6e, 0x28, 0x19, 0x6f, 0xd1, 0xca, 0xf5,
0x6b, 0x4e, 0x7e, 0x0b, 0xa5, 0x51, 0x92, 0x34, 0xd0, 0x47, 0x15, 0x5a,
0xc7, 0x27, 0xa1, 0x05, 0x31, 0x00
};
static const uint8_t privkey7[57] = {
0xd6, 0x5d, 0xf3, 0x41, 0xad, 0x13, 0xe0, 0x08, 0x56, 0x76, 0x88, 0xba,
0xed, 0xda, 0x8e, 0x9d, 0xcd, 0xc1, 0x7d, 0xc0, 0x24, 0x97, 0x4e, 0xa5,
0xb4, 0x22, 0x7b, 0x65, 0x30, 0xe3, 0x39, 0xbf, 0xf2, 0x1f, 0x99, 0xe6,
0x8c, 0xa6, 0x96, 0x8f, 0x3c, 0xca, 0x6d, 0xfe, 0x0f, 0xb9, 0xf4, 0xfa,
0xb4, 0xfa, 0x13, 0x5d, 0x55, 0x42, 0xea, 0x3f, 0x01
};
static const uint8_t pubkey7[57] = {
0xdf, 0x97, 0x05, 0xf5, 0x8e, 0xdb, 0xab, 0x80, 0x2c, 0x7f, 0x83, 0x63,
0xcf, 0xe5, 0x56, 0x0a, 0xb1, 0xc6, 0x13, 0x2c, 0x20, 0xa9, 0xf1, 0xdd,
0x16, 0x34, 0x83, 0xa2, 0x6f, 0x8a, 0xc5, 0x3a, 0x39, 0xd6, 0x80, 0x8b,
0xf4, 0xa1, 0xdf, 0xbd, 0x26, 0x1b, 0x09, 0x9b, 0xb0, 0x3b, 0x3f, 0xb5,
0x09, 0x06, 0xcb, 0x28, 0xbd, 0x8a, 0x08, 0x1f, 0x00
};
static const uint8_t msg7[64] = {
0xbd, 0x0f, 0x6a, 0x37, 0x47, 0xcd, 0x56, 0x1b, 0xdd, 0xdf, 0x46, 0x40,
0xa3, 0x32, 0x46, 0x1a, 0x4a, 0x30, 0xa1, 0x2a, 0x43, 0x4c, 0xd0, 0xbf,
0x40, 0xd7, 0x66, 0xd9, 0xc6, 0xd4, 0x58, 0xe5, 0x51, 0x22, 0x04, 0xa3,
0x0c, 0x17, 0xd1, 0xf5, 0x0b, 0x50, 0x79, 0x63, 0x1f, 0x64, 0xeb, 0x31,
0x12, 0x18, 0x2d, 0xa3, 0x00, 0x58, 0x35, 0x46, 0x11, 0x13, 0x71, 0x8d,
0x1a, 0x5e, 0xf9, 0x44
};
static const uint8_t sig7[114] = {
0x55, 0x4b, 0xc2, 0x48, 0x08, 0x60, 0xb4, 0x9e, 0xab, 0x85, 0x32, 0xd2,
0xa5, 0x33, 0xb7, 0xd5, 0x78, 0xef, 0x47, 0x3e, 0xeb, 0x58, 0xc9, 0x8b,
0xb2, 0xd0, 0xe1, 0xce, 0x48, 0x8a, 0x98, 0xb1, 0x8d, 0xfd, 0xe9, 0xb9,
0xb9, 0x07, 0x75, 0xe6, 0x7f, 0x47, 0xd4, 0xa1, 0xc3, 0x48, 0x20, 0x58,
0xef, 0xc9, 0xf4, 0x0d, 0x2c, 0xa0, 0x33, 0xa0, 0x80, 0x1b, 0x63, 0xd4,
0x5b, 0x3b, 0x72, 0x2e, 0xf5, 0x52, 0xba, 0xd3, 0xb4, 0xcc, 0xb6, 0x67,
0xda, 0x35, 0x01, 0x92, 0xb6, 0x1c, 0x50, 0x8c, 0xf7, 0xb6, 0xb5, 0xad,
0xad, 0xc2, 0xc8, 0xd9, 0xa4, 0x46, 0xef, 0x00, 0x3f, 0xb0, 0x5c, 0xba,
0x5f, 0x30, 0xe8, 0x8e, 0x36, 0xec, 0x27, 0x03, 0xb3, 0x49, 0xca, 0x22,
0x9c, 0x26, 0x70, 0x83, 0x39, 0x00
};
static const uint8_t privkey8[57] = {
0x2e, 0xc5, 0xfe, 0x3c, 0x17, 0x04, 0x5a, 0xbd, 0xb1, 0x36, 0xa5, 0xe6,
0xa9, 0x13, 0xe3, 0x2a, 0xb7, 0x5a, 0xe6, 0x8b, 0x53, 0xd2, 0xfc, 0x14,
0x9b, 0x77, 0xe5, 0x04, 0x13, 0x2d, 0x37, 0x56, 0x9b, 0x7e, 0x76, 0x6b,
0xa7, 0x4a, 0x19, 0xbd, 0x61, 0x62, 0x34, 0x3a, 0x21, 0xc8, 0x59, 0x0a,
0xa9, 0xce, 0xbc, 0xa9, 0x01, 0x4c, 0x63, 0x6d, 0xf5
};
static const uint8_t pubkey8[57] = {
0x79, 0x75, 0x6f, 0x01, 0x4d, 0xcf, 0xe2, 0x07, 0x9f, 0x5d, 0xd9, 0xe7,
0x18, 0xbe, 0x41, 0x71, 0xe2, 0xef, 0x24, 0x86, 0xa0, 0x8f, 0x25, 0x18,
0x6f, 0x6b, 0xff, 0x43, 0xa9, 0x93, 0x6b, 0x9b, 0xfe, 0x12, 0x40, 0x2b,
0x08, 0xae, 0x65, 0x79, 0x8a, 0x3d, 0x81, 0xe2, 0x2e, 0x9e, 0xc8, 0x0e,
0x76, 0x90, 0x86, 0x2e, 0xf3, 0xd4, 0xed, 0x3a, 0x00
};
static const uint8_t msg8[256] = {
0x15, 0x77, 0x75, 0x32, 0xb0, 0xbd, 0xd0, 0xd1, 0x38, 0x9f, 0x63, 0x6c,
0x5f, 0x6b, 0x9b, 0xa7, 0x34, 0xc9, 0x0a, 0xf5, 0x72, 0x87, 0x7e, 0x2d,
0x27, 0x2d, 0xd0, 0x78, 0xaa, 0x1e, 0x56, 0x7c, 0xfa, 0x80, 0xe1, 0x29,
0x28, 0xbb, 0x54, 0x23, 0x30, 0xe8, 0x40, 0x9f, 0x31, 0x74, 0x50, 0x41,
0x07, 0xec, 0xd5, 0xef, 0xac, 0x61, 0xae, 0x75, 0x04, 0xda, 0xbe, 0x2a,
0x60, 0x2e, 0xde, 0x89, 0xe5, 0xcc, 0xa6, 0x25, 0x7a, 0x7c, 0x77, 0xe2,
0x7a, 0x70, 0x2b, 0x3a, 0xe3, 0x9f, 0xc7, 0x69, 0xfc, 0x54, 0xf2, 0x39,
0x5a, 0xe6, 0xa1, 0x17, 0x8c, 0xab, 0x47, 0x38, 0xe5, 0x43, 0x07, 0x2f,
0xc1, 0xc1, 0x77, 0xfe, 0x71, 0xe9, 0x2e, 0x25, 0xbf, 0x03, 0xe4, 0xec,
0xb7, 0x2f, 0x47, 0xb6, 0x4d, 0x04, 0x65, 0xaa, 0xea, 0x4c, 0x7f, 0xad,
0x37, 0x25, 0x36, 0xc8, 0xba, 0x51, 0x6a, 0x60, 0x39, 0xc3, 0xc2, 0xa3,
0x9f, 0x0e, 0x4d, 0x83, 0x2b, 0xe4, 0x32, 0xdf, 0xa9, 0xa7, 0x06, 0xa6,
0xe5, 0xc7, 0xe1, 0x9f, 0x39, 0x79, 0x64, 0xca, 0x42, 0x58, 0x00, 0x2f,
0x7c, 0x05, 0x41, 0xb5, 0x90, 0x31, 0x6d, 0xbc, 0x56, 0x22, 0xb6, 0xb2,
0xa6, 0xfe, 0x7a, 0x4a, 0xbf, 0xfd, 0x96, 0x10, 0x5e, 0xca, 0x76, 0xea,
0x7b, 0x98, 0x81, 0x6a, 0xf0, 0x74, 0x8c, 0x10, 0xdf, 0x04, 0x8c, 0xe0,
0x12, 0xd9, 0x01, 0x01, 0x5a, 0x51, 0xf1, 0x89, 0xf3, 0x88, 0x81, 0x45,
0xc0, 0x36, 0x50, 0xaa, 0x23, 0xce, 0x89, 0x4c, 0x3b, 0xd8, 0x89, 0xe0,
0x30, 0xd5, 0x65, 0x07, 0x1c, 0x59, 0xf4, 0x09, 0xa9, 0x98, 0x1b, 0x51,
0x87, 0x8f, 0xd6, 0xfc, 0x11, 0x06, 0x24, 0xdc, 0xbc, 0xde, 0x0b, 0xf7,
0xa6, 0x9c, 0xcc, 0xe3, 0x8f, 0xab, 0xdf, 0x86, 0xf3, 0xbe, 0xf6, 0x04,
0x48, 0x19, 0xde, 0x11
};
static const uint8_t sig8[114] = {
0xc6, 0x50, 0xdd, 0xbb, 0x06, 0x01, 0xc1, 0x9c, 0xa1, 0x14, 0x39, 0xe1,
0x64, 0x0d, 0xd9, 0x31, 0xf4, 0x3c, 0x51, 0x8e, 0xa5, 0xbe, 0xa7, 0x0d,
0x3d, 0xcd, 0xe5, 0xf4, 0x19, 0x1f, 0xe5, 0x3f, 0x00, 0xcf, 0x96, 0x65,
0x46, 0xb7, 0x2b, 0xcc, 0x7d, 0x58, 0xbe, 0x2b, 0x9b, 0xad, 0xef, 0x28,
0x74, 0x39, 0x54, 0xe3, 0xa4, 0x4a, 0x23, 0xf8, 0x80, 0xe8, 0xd4, 0xf1,
0xcf, 0xce, 0x2d, 0x7a, 0x61, 0x45, 0x2d, 0x26, 0xda, 0x05, 0x89, 0x6f,
0x0a, 0x50, 0xda, 0x66, 0xa2, 0x39, 0xa8, 0xa1, 0x88, 0xb6, 0xd8, 0x25,
0xb3, 0x30, 0x5a, 0xd7, 0x7b, 0x73, 0xfb, 0xac, 0x08, 0x36, 0xec, 0xc6,
0x09, 0x87, 0xfd, 0x08, 0x52, 0x7c, 0x1a, 0x8e, 0x80, 0xd5, 0x82, 0x3e,
0x65, 0xca, 0xfe, 0x2a, 0x3d, 0x00
};
static const uint8_t privkey9[57] = {
0x87, 0x2d, 0x09, 0x37, 0x80, 0xf5, 0xd3, 0x73, 0x0d, 0xf7, 0xc2, 0x12,
0x66, 0x4b, 0x37, 0xb8, 0xa0, 0xf2, 0x4f, 0x56, 0x81, 0x0d, 0xaa, 0x83,
0x82, 0xcd, 0x4f, 0xa3, 0xf7, 0x76, 0x34, 0xec, 0x44, 0xdc, 0x54, 0xf1,
0xc2, 0xed, 0x9b, 0xea, 0x86, 0xfa, 0xfb, 0x76, 0x32, 0xd8, 0xbe, 0x19,
0x9e, 0xa1, 0x65, 0xf5, 0xad, 0x55, 0xdd, 0x9c, 0xe8
};
static const uint8_t pubkey9[57] = {
0xa8, 0x1b, 0x2e, 0x8a, 0x70, 0xa5, 0xac, 0x94, 0xff, 0xdb, 0xcc, 0x9b,
0xad, 0xfc, 0x3f, 0xeb, 0x08, 0x01, 0xf2, 0x58, 0x57, 0x8b, 0xb1, 0x14,
0xad, 0x44, 0xec, 0xe1, 0xec, 0x0e, 0x79, 0x9d, 0xa0, 0x8e, 0xff, 0xb8,
0x1c, 0x5d, 0x68, 0x5c, 0x0c, 0x56, 0xf6, 0x4e, 0xec, 0xae, 0xf8, 0xcd,
0xf1, 0x1c, 0xc3, 0x87, 0x37, 0x83, 0x8c, 0xf4, 0x00
};
static const uint8_t msg9[1023] = {
0x6d, 0xdf, 0x80, 0x2e, 0x1a, 0xae, 0x49, 0x86, 0x93, 0x5f, 0x7f, 0x98,
0x1b, 0xa3, 0xf0, 0x35, 0x1d, 0x62, 0x73, 0xc0, 0xa0, 0xc2, 0x2c, 0x9c,
0x0e, 0x83, 0x39, 0x16, 0x8e, 0x67, 0x54, 0x12, 0xa3, 0xde, 0xbf, 0xaf,
0x43, 0x5e, 0xd6, 0x51, 0x55, 0x80, 0x07, 0xdb, 0x43, 0x84, 0xb6, 0x50,
0xfc, 0xc0, 0x7e, 0x3b, 0x58, 0x6a, 0x27, 0xa4, 0xf7, 0xa0, 0x0a, 0xc8,
0xa6, 0xfe, 0xc2, 0xcd, 0x86, 0xae, 0x4b, 0xf1, 0x57, 0x0c, 0x41, 0xe6,
0xa4, 0x0c, 0x93, 0x1d, 0xb2, 0x7b, 0x2f, 0xaa, 0x15, 0xa8, 0xce, 0xdd,
0x52, 0xcf, 0xf7, 0x36, 0x2c, 0x4e, 0x6e, 0x23, 0xda, 0xec, 0x0f, 0xbc,
0x3a, 0x79, 0xb6, 0x80, 0x6e, 0x31, 0x6e, 0xfc, 0xc7, 0xb6, 0x81, 0x19,
0xbf, 0x46, 0xbc, 0x76, 0xa2, 0x60, 0x67, 0xa5, 0x3f, 0x29, 0x6d, 0xaf,
0xdb, 0xdc, 0x11, 0xc7, 0x7f, 0x77, 0x77, 0xe9, 0x72, 0x66, 0x0c, 0xf4,
0xb6, 0xa9, 0xb3, 0x69, 0xa6, 0x66, 0x5f, 0x02, 0xe0, 0xcc, 0x9b, 0x6e,
0xdf, 0xad, 0x13, 0x6b, 0x4f, 0xab, 0xe7, 0x23, 0xd2, 0x81, 0x3d, 0xb3,
0x13, 0x6c, 0xfd, 0xe9, 0xb6, 0xd0, 0x44, 0x32, 0x2f, 0xee, 0x29, 0x47,
0x95, 0x2e, 0x03, 0x1b, 0x73, 0xab, 0x5c, 0x60, 0x33, 0x49, 0xb3, 0x07,
0xbd, 0xc2, 0x7b, 0xc6, 0xcb, 0x8b, 0x8b, 0xbd, 0x7b, 0xd3, 0x23, 0x21,
0x9b, 0x80, 0x33, 0xa5, 0x81, 0xb5, 0x9e, 0xad, 0xeb, 0xb0, 0x9b, 0x3c,
0x4f, 0x3d, 0x22, 0x77, 0xd4, 0xf0, 0x34, 0x36, 0x24, 0xac, 0xc8, 0x17,
0x80, 0x47, 0x28, 0xb2, 0x5a, 0xb7, 0x97, 0x17, 0x2b, 0x4c, 0x5c, 0x21,
0xa2, 0x2f, 0x9c, 0x78, 0x39, 0xd6, 0x43, 0x00, 0x23, 0x2e, 0xb6, 0x6e,
0x53, 0xf3, 0x1c, 0x72, 0x3f, 0xa3, 0x7f, 0xe3, 0x87, 0xc7, 0xd3, 0xe5,
0x0b, 0xdf, 0x98, 0x13, 0xa3, 0x0e, 0x5b, 0xb1, 0x2c, 0xf4, 0xcd, 0x93,
0x0c, 0x40, 0xcf, 0xb4, 0xe1, 0xfc, 0x62, 0x25, 0x92, 0xa4, 0x95, 0x88,
0x79, 0x44, 0x94, 0xd5, 0x6d, 0x24, 0xea, 0x4b, 0x40, 0xc8, 0x9f, 0xc0,
0x59, 0x6c, 0xc9, 0xeb, 0xb9, 0x61, 0xc8, 0xcb, 0x10, 0xad, 0xde, 0x97,
0x6a, 0x5d, 0x60, 0x2b, 0x1c, 0x3f, 0x85, 0xb9, 0xb9, 0xa0, 0x01, 0xed,
0x3c, 0x6a, 0x4d, 0x3b, 0x14, 0x37, 0xf5, 0x20, 0x96, 0xcd, 0x19, 0x56,
0xd0, 0x42, 0xa5, 0x97, 0xd5, 0x61, 0xa5, 0x96, 0xec, 0xd3, 0xd1, 0x73,
0x5a, 0x8d, 0x57, 0x0e, 0xa0, 0xec, 0x27, 0x22, 0x5a, 0x2c, 0x4a, 0xaf,
0xf2, 0x63, 0x06, 0xd1, 0x52, 0x6c, 0x1a, 0xf3, 0xca, 0x6d, 0x9c, 0xf5,
0xa2, 0xc9, 0x8f, 0x47, 0xe1, 0xc4, 0x6d, 0xb9, 0xa3, 0x32, 0x34, 0xcf,
0xd4, 0xd8, 0x1f, 0x2c, 0x98, 0x53, 0x8a, 0x09, 0xeb, 0xe7, 0x69, 0x98,
0xd0, 0xd8, 0xfd, 0x25, 0x99, 0x7c, 0x7d, 0x25, 0x5c, 0x6d, 0x66, 0xec,
0xe6, 0xfa, 0x56, 0xf1, 0x11, 0x44, 0x95, 0x0f, 0x02, 0x77, 0x95, 0xe6,
0x53, 0x00, 0x8f, 0x4b, 0xd7, 0xca, 0x2d, 0xee, 0x85, 0xd8, 0xe9, 0x0f,
0x3d, 0xc3, 0x15, 0x13, 0x0c, 0xe2, 0xa0, 0x03, 0x75, 0xa3, 0x18, 0xc7,
0xc3, 0xd9, 0x7b, 0xe2, 0xc8, 0xce, 0x5b, 0x6d, 0xb4, 0x1a, 0x62, 0x54,
0xff, 0x26, 0x4f, 0xa6, 0x15, 0x5b, 0xae, 0xe3, 0xb0, 0x77, 0x3c, 0x0f,
0x49, 0x7c, 0x57, 0x3f, 0x19, 0xbb, 0x4f, 0x42, 0x40, 0x28, 0x1f, 0x0b,
0x1f, 0x4f, 0x7b, 0xe8, 0x57, 0xa4, 0xe5, 0x9d, 0x41, 0x6c, 0x06, 0xb4,
0xc5, 0x0f, 0xa0, 0x9e, 0x18, 0x10, 0xdd, 0xc6, 0xb1, 0x46, 0x7b, 0xae,
0xac, 0x5a, 0x36, 0x68, 0xd1, 0x1b, 0x6e, 0xca, 0xa9, 0x01, 0x44, 0x00,
0x16, 0xf3, 0x89, 0xf8, 0x0a, 0xcc, 0x4d, 0xb9, 0x77, 0x02, 0x5e, 0x7f,
0x59, 0x24, 0x38, 0x8c, 0x7e, 0x34, 0x0a, 0x73, 0x2e, 0x55, 0x44, 0x40,
0xe7, 0x65, 0x70, 0xf8, 0xdd, 0x71, 0xb7, 0xd6, 0x40, 0xb3, 0x45, 0x0d,
0x1f, 0xd5, 0xf0, 0x41, 0x0a, 0x18, 0xf9, 0xa3, 0x49, 0x4f, 0x70, 0x7c,
0x71, 0x7b, 0x79, 0xb4, 0xbf, 0x75, 0xc9, 0x84, 0x00, 0xb0, 0x96, 0xb2,
0x16, 0x53, 0xb5, 0xd2, 0x17, 0xcf, 0x35, 0x65, 0xc9, 0x59, 0x74, 0x56,
0xf7, 0x07, 0x03, 0x49, 0x7a, 0x07, 0x87, 0x63, 0x82, 0x9b, 0xc0, 0x1b,
0xb1, 0xcb, 0xc8, 0xfa, 0x04, 0xea, 0xdc, 0x9a, 0x6e, 0x3f, 0x66, 0x99,
0x58, 0x7a, 0x9e, 0x75, 0xc9, 0x4e, 0x5b, 0xab, 0x00, 0x36, 0xe0, 0xb2,
0xe7, 0x11, 0x39, 0x2c, 0xff, 0x00, 0x47, 0xd0, 0xd6, 0xb0, 0x5b, 0xd2,
0xa5, 0x88, 0xbc, 0x10, 0x97, 0x18, 0x95, 0x42, 0x59, 0xf1, 0xd8, 0x66,
0x78, 0xa5, 0x79, 0xa3, 0x12, 0x0f, 0x19, 0xcf, 0xb2, 0x96, 0x3f, 0x17,
0x7a, 0xeb, 0x70, 0xf2, 0xd4, 0x84, 0x48, 0x26, 0x26, 0x2e, 0x51, 0xb8,
0x02, 0x71, 0x27, 0x20, 0x68, 0xef, 0x5b, 0x38, 0x56, 0xfa, 0x85, 0x35,
0xaa, 0x2a, 0x88, 0xb2, 0xd4, 0x1f, 0x2a, 0x0e, 0x2f, 0xda, 0x76, 0x24,
0xc2, 0x85, 0x02, 0x72, 0xac, 0x4a, 0x2f, 0x56, 0x1f, 0x8f, 0x2f, 0x7a,
0x31, 0x8b, 0xfd, 0x5c, 0xaf, 0x96, 0x96, 0x14, 0x9e, 0x4a, 0xc8, 0x24,
0xad, 0x34, 0x60, 0x53, 0x8f, 0xdc, 0x25, 0x42, 0x1b, 0xee, 0xc2, 0xcc,
0x68, 0x18, 0x16, 0x2d, 0x06, 0xbb, 0xed, 0x0c, 0x40, 0xa3, 0x87, 0x19,
0x23, 0x49, 0xdb, 0x67, 0xa1, 0x18, 0xba, 0xda, 0x6c, 0xd5, 0xab, 0x01,
0x40, 0xee, 0x27, 0x32, 0x04, 0xf6, 0x28, 0xaa, 0xd1, 0xc1, 0x35, 0xf7,
0x70, 0x27, 0x9a, 0x65, 0x1e, 0x24, 0xd8, 0xc1, 0x4d, 0x75, 0xa6, 0x05,
0x9d, 0x76, 0xb9, 0x6a, 0x6f, 0xd8, 0x57, 0xde, 0xf5, 0xe0, 0xb3, 0x54,
0xb2, 0x7a, 0xb9, 0x37, 0xa5, 0x81, 0x5d, 0x16, 0xb5, 0xfa, 0xe4, 0x07,
0xff, 0x18, 0x22, 0x2c, 0x6d, 0x1e, 0xd2, 0x63, 0xbe, 0x68, 0xc9, 0x5f,
0x32, 0xd9, 0x08, 0xbd, 0x89, 0x5c, 0xd7, 0x62, 0x07, 0xae, 0x72, 0x64,
0x87, 0x56, 0x7f, 0x9a, 0x67, 0xda, 0xd7, 0x9a, 0xbe, 0xc3, 0x16, 0xf6,
0x83, 0xb1, 0x7f, 0x2d, 0x02, 0xbf, 0x07, 0xe0, 0xac, 0x8b, 0x5b, 0xc6,
0x16, 0x2c, 0xf9, 0x46, 0x97, 0xb3, 0xc2, 0x7c, 0xd1, 0xfe, 0xa4, 0x9b,
0x27, 0xf2, 0x3b, 0xa2, 0x90, 0x18, 0x71, 0x96, 0x25, 0x06, 0x52, 0x0c,
0x39, 0x2d, 0xa8, 0xb6, 0xad, 0x0d, 0x99, 0xf7, 0x01, 0x3f, 0xbc, 0x06,
0xc2, 0xc1, 0x7a, 0x56, 0x95, 0x00, 0xc8, 0xa7, 0x69, 0x64, 0x81, 0xc1,
0xcd, 0x33, 0xe9, 0xb1, 0x4e, 0x40, 0xb8, 0x2e, 0x79, 0xa5, 0xf5, 0xdb,
0x82, 0x57, 0x1b, 0xa9, 0x7b, 0xae, 0x3a, 0xd3, 0xe0, 0x47, 0x95, 0x15,
0xbb, 0x0e, 0x2b, 0x0f, 0x3b, 0xfc, 0xd1, 0xfd, 0x33, 0x03, 0x4e, 0xfc,
0x62, 0x45, 0xed, 0xdd, 0x7e, 0xe2, 0x08, 0x6d, 0xda, 0xe2, 0x60, 0x0d,
0x8c, 0xa7, 0x3e, 0x21, 0x4e, 0x8c, 0x2b, 0x0b, 0xdb, 0x2b, 0x04, 0x7c,
0x6a, 0x46, 0x4a, 0x56, 0x2e, 0xd7, 0x7b, 0x73, 0xd2, 0xd8, 0x41, 0xc4,
0xb3, 0x49, 0x73, 0x55, 0x12, 0x57, 0x71, 0x3b, 0x75, 0x36, 0x32, 0xef,
0xba, 0x34, 0x81, 0x69, 0xab, 0xc9, 0x0a, 0x68, 0xf4, 0x26, 0x11, 0xa4,
0x01, 0x26, 0xd7, 0xcb, 0x21, 0xb5, 0x86, 0x95, 0x56, 0x81, 0x86, 0xf7,
0xe5, 0x69, 0xd2, 0xff, 0x0f, 0x9e, 0x74, 0x5d, 0x04, 0x87, 0xdd, 0x2e,
0xb9, 0x97, 0xca, 0xfc, 0x5a, 0xbf, 0x9d, 0xd1, 0x02, 0xe6, 0x2f, 0xf6,
0x6c, 0xba, 0x87
};
static const uint8_t sig9[114] = {
0xe3, 0x01, 0x34, 0x5a, 0x41, 0xa3, 0x9a, 0x4d, 0x72, 0xff, 0xf8, 0xdf,
0x69, 0xc9, 0x80, 0x75, 0xa0, 0xcc, 0x08, 0x2b, 0x80, 0x2f, 0xc9, 0xb2,
0xb6, 0xbc, 0x50, 0x3f, 0x92, 0x6b, 0x65, 0xbd, 0xdf, 0x7f, 0x4c, 0x8f,
0x1c, 0xb4, 0x9f, 0x63, 0x96, 0xaf, 0xc8, 0xa7, 0x0a, 0xbe, 0x6d, 0x8a,
0xef, 0x0d, 0xb4, 0x78, 0xd4, 0xc6, 0xb2, 0x97, 0x00, 0x76, 0xc6, 0xa0,
0x48, 0x4f, 0xe7, 0x6d, 0x76, 0xb3, 0xa9, 0x76, 0x25, 0xd7, 0x9f, 0x1c,
0xe2, 0x40, 0xe7, 0xc5, 0x76, 0x75, 0x0d, 0x29, 0x55, 0x28, 0x28, 0x6f,
0x71, 0x9b, 0x41, 0x3d, 0xe9, 0xad, 0xa3, 0xe8, 0xeb, 0x78, 0xed, 0x57,
0x36, 0x03, 0xce, 0x30, 0xd8, 0xbb, 0x76, 0x17, 0x85, 0xdc, 0x30, 0xdb,
0xc3, 0x20, 0x86, 0x9e, 0x1a, 0x00
};
/* Prehash Ed448 */
static const uint8_t phprivkey1[57] = {
0x83, 0x3f, 0xe6, 0x24, 0x09, 0x23, 0x7b, 0x9d, 0x62, 0xec, 0x77, 0x58,
0x75, 0x20, 0x91, 0x1e, 0x9a, 0x75, 0x9c, 0xec, 0x1d, 0x19, 0x75, 0x5b,
0x7d, 0xa9, 0x01, 0xb9, 0x6d, 0xca, 0x3d, 0x42, 0xef, 0x78, 0x22, 0xe0,
0xd5, 0x10, 0x41, 0x27, 0xdc, 0x05, 0xd6, 0xdb, 0xef, 0xde, 0x69, 0xe3,
0xab, 0x2c, 0xec, 0x7c, 0x86, 0x7c, 0x6e, 0x2c, 0x49
};
static const uint8_t phpubkey1[57] = {
0x25, 0x9b, 0x71, 0xc1, 0x9f, 0x83, 0xef, 0x77, 0xa7, 0xab, 0xd2, 0x65,
0x24, 0xcb, 0xdb, 0x31, 0x61, 0xb5, 0x90, 0xa4, 0x8f, 0x7d, 0x17, 0xde,
0x3e, 0xe0, 0xba, 0x9c, 0x52, 0xbe, 0xb7, 0x43, 0xc0, 0x94, 0x28, 0xa1,
0x31, 0xd6, 0xb1, 0xb5, 0x73, 0x03, 0xd9, 0x0d, 0x81, 0x32, 0xc2, 0x76,
0xd5, 0xed, 0x3d, 0x5d, 0x01, 0xc0, 0xf5, 0x38, 0x80
};
static const uint8_t phmsg1[3] = {
0x61, 0x62, 0x63
};
static const uint8_t phsig1[114] = {
0x82, 0x2f, 0x69, 0x01, 0xf7, 0x48, 0x0f, 0x3d, 0x5f, 0x56, 0x2c, 0x59,
0x29, 0x94, 0xd9, 0x69, 0x36, 0x02, 0x87, 0x56, 0x14, 0x48, 0x32, 0x56,
0x50, 0x56, 0x00, 0xbb, 0xc2, 0x81, 0xae, 0x38, 0x1f, 0x54, 0xd6, 0xbc,
0xe2, 0xea, 0x91, 0x15, 0x74, 0x93, 0x2f, 0x52, 0xa4, 0xe6, 0xca, 0xdd,
0x78, 0x76, 0x93, 0x75, 0xec, 0x3f, 0xfd, 0x1b, 0x80, 0x1a, 0x0d, 0x9b,
0x3f, 0x40, 0x30, 0xcd, 0x43, 0x39, 0x64, 0xb6, 0x45, 0x7e, 0xa3, 0x94,
0x76, 0x51, 0x12, 0x14, 0xf9, 0x74, 0x69, 0xb5, 0x7d, 0xd3, 0x2d, 0xbc,
0x56, 0x0a, 0x9a, 0x94, 0xd0, 0x0b, 0xff, 0x07, 0x62, 0x04, 0x64, 0xa3,
0xad, 0x20, 0x3d, 0xf7, 0xdc, 0x7c, 0xe3, 0x60, 0xc3, 0xcd, 0x36, 0x96,
0xd9, 0xd9, 0xfa, 0xb9, 0x0f, 0x00
};
static const uint8_t phprivkey2[57] = {
0x83, 0x3f, 0xe6, 0x24, 0x09, 0x23, 0x7b, 0x9d, 0x62, 0xec, 0x77, 0x58,
0x75, 0x20, 0x91, 0x1e, 0x9a, 0x75, 0x9c, 0xec, 0x1d, 0x19, 0x75, 0x5b,
0x7d, 0xa9, 0x01, 0xb9, 0x6d, 0xca, 0x3d, 0x42, 0xef, 0x78, 0x22, 0xe0,
0xd5, 0x10, 0x41, 0x27, 0xdc, 0x05, 0xd6, 0xdb, 0xef, 0xde, 0x69, 0xe3,
0xab, 0x2c, 0xec, 0x7c, 0x86, 0x7c, 0x6e, 0x2c, 0x49
};
static const uint8_t phpubkey2[57] = {
0x25, 0x9b, 0x71, 0xc1, 0x9f, 0x83, 0xef, 0x77, 0xa7, 0xab, 0xd2, 0x65,
0x24, 0xcb, 0xdb, 0x31, 0x61, 0xb5, 0x90, 0xa4, 0x8f, 0x7d, 0x17, 0xde,
0x3e, 0xe0, 0xba, 0x9c, 0x52, 0xbe, 0xb7, 0x43, 0xc0, 0x94, 0x28, 0xa1,
0x31, 0xd6, 0xb1, 0xb5, 0x73, 0x03, 0xd9, 0x0d, 0x81, 0x32, 0xc2, 0x76,
0xd5, 0xed, 0x3d, 0x5d, 0x01, 0xc0, 0xf5, 0x38, 0x80
};
static const uint8_t phmsg2[3] = {
0x61, 0x62, 0x63
};
static const uint8_t phcontext2[3] = {
0x66, 0x6f, 0x6f
};
static const uint8_t phsig2[114] = {
0xc3, 0x22, 0x99, 0xd4, 0x6e, 0xc8, 0xff, 0x02, 0xb5, 0x45, 0x40, 0x98,
0x28, 0x14, 0xdc, 0xe9, 0xa0, 0x58, 0x12, 0xf8, 0x19, 0x62, 0xb6, 0x49,
0xd5, 0x28, 0x09, 0x59, 0x16, 0xa2, 0xaa, 0x48, 0x10, 0x65, 0xb1, 0x58,
0x04, 0x23, 0xef, 0x92, 0x7e, 0xcf, 0x0a, 0xf5, 0x88, 0x8f, 0x90, 0xda,
0x0f, 0x6a, 0x9a, 0x85, 0xad, 0x5d, 0xc3, 0xf2, 0x80, 0xd9, 0x12, 0x24,
0xba, 0x99, 0x11, 0xa3, 0x65, 0x3d, 0x00, 0xe4, 0x84, 0xe2, 0xce, 0x23,
0x25, 0x21, 0x48, 0x1c, 0x86, 0x58, 0xdf, 0x30, 0x4b, 0xb7, 0x74, 0x5a,
0x73, 0x51, 0x4c, 0xdb, 0x9b, 0xf3, 0xe1, 0x57, 0x84, 0xab, 0x71, 0x28,
0x4f, 0x8d, 0x07, 0x04, 0xa6, 0x08, 0xc5, 0x4a, 0x6b, 0x62, 0xd9, 0x7b,
0xeb, 0x51, 0x1d, 0x13, 0x21, 0x00
};
static const uint8_t *dohash(EVP_MD_CTX *hashctx, const uint8_t *msg,
size_t msglen)
{
static uint8_t hashout[64];
if (!EVP_DigestInit_ex(hashctx, EVP_shake256(), NULL)
|| !EVP_DigestUpdate(hashctx, msg, msglen)
|| !EVP_DigestFinalXOF(hashctx, hashout, sizeof(hashout)))
return NULL;
return hashout;
}
static int test_ed448(void)
{
uint8_t outsig[114];
EVP_MD_CTX *hashctx = EVP_MD_CTX_new();
if (!TEST_ptr(hashctx)
|| !TEST_true(ossl_ed448_sign(NULL, outsig, NULL, 0, pubkey1,
privkey1, NULL, 0, 0, NULL))
|| !TEST_int_eq(memcmp(sig1, outsig, sizeof(sig1)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig, msg2, sizeof(msg2),
pubkey2, privkey2, NULL, 0, 0, NULL))
|| !TEST_int_eq(memcmp(sig2, outsig, sizeof(sig2)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig, msg3, sizeof(msg3),
pubkey3, privkey3, context3,
sizeof(context3), 0, NULL))
|| !TEST_int_eq(memcmp(sig3, outsig, sizeof(sig3)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig, msg4, sizeof(msg4),
pubkey4, privkey4, NULL, 0, 0, NULL))
|| !TEST_int_eq(memcmp(sig4, outsig, sizeof(sig4)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig, msg5, sizeof(msg5),
pubkey5, privkey5, NULL, 0, 0, NULL))
|| !TEST_int_eq(memcmp(sig5, outsig, sizeof(sig5)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig, msg6, sizeof(msg6),
pubkey6, privkey6, NULL, 0, 0, NULL))
|| !TEST_int_eq(memcmp(sig6, outsig, sizeof(sig6)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig, msg7, sizeof(msg7),
pubkey7, privkey7, NULL, 0, 0, NULL))
|| !TEST_int_eq(memcmp(sig7, outsig, sizeof(sig7)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig, msg8, sizeof(msg8),
pubkey8, privkey8, NULL, 0, 0, NULL))
|| !TEST_int_eq(memcmp(sig8, outsig, sizeof(sig8)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig, msg9, sizeof(msg9),
pubkey9, privkey9, NULL, 0, 0, NULL))
|| !TEST_int_eq(memcmp(sig9, outsig, sizeof(sig9)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig,
dohash(hashctx, phmsg1,
sizeof(phmsg1)), 64, phpubkey1,
phprivkey1, NULL, 0, 1, NULL))
|| !TEST_int_eq(memcmp(phsig1, outsig, sizeof(phsig1)), 0)
|| !TEST_true(ossl_ed448_sign(NULL, outsig,
dohash(hashctx, phmsg2,
sizeof(phmsg2)), 64, phpubkey2,
phprivkey2, phcontext2,
sizeof(phcontext2), 1, NULL))
|| !TEST_int_eq(memcmp(phsig2, outsig, sizeof(phsig2)), 0)) {
EVP_MD_CTX_free(hashctx);
return 0;
}
EVP_MD_CTX_free(hashctx);
return 1;
}
static int test_x448(void)
{
uint8_t u[56], k[56], out[56];
unsigned int i;
int j = -1;
/* Curve448 tests */
if (!TEST_true(ossl_x448(out, in_scalar1, in_u1))
|| !TEST_int_eq(memcmp(out, out_u1, sizeof(out)), 0)
|| !TEST_true(ossl_x448(out, in_scalar2, in_u2))
|| !TEST_int_eq(memcmp(out, out_u2, sizeof(out)), 0))
return 0;
memcpy(u, in_u3, sizeof(u));
memcpy(k, in_u3, sizeof(k));
for (i = 1; i <= max; i++) {
if (verbose && i % 10000 == 0) {
printf(".");
fflush(stdout);
}
if (!TEST_true(ossl_x448(out, k, u)))
return 0;
if (i == 1 || i == 1000 || i == 1000000) {
j++;
if (!TEST_int_eq(memcmp(out, out_u3[j], sizeof(out)), 0)) {
TEST_info("Failed at iteration %d", i);
return 0;
}
}
memcpy(u, k, sizeof(u));
memcpy(k, out, sizeof(k));
}
return 1;
}
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_PROGRESS,
OPT_SLOW,
OPT_TEST_ENUM
} OPTION_CHOICE;
const OPTIONS *test_get_options(void)
{
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("conf_file\n"),
{ "f", OPT_SLOW, '-', "Enables a slow test" },
{ "v", OPT_PROGRESS, '-',
"Enables verbose mode (prints progress dots)" },
{ NULL }
};
return test_options;
}
int setup_tests(void)
{
OPTION_CHOICE o;
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_TEST_CASES:
break;
default:
return 0;
/*
* The test vectors contain one test which takes a very long time to run
* so we don't do that be default. Using the -f option will cause it to
* be run.
*/
case OPT_SLOW:
max = 1000000;
break;
case OPT_PROGRESS:
verbose = 1; /* Print progress dots */
break;
}
}
ADD_TEST(test_x448);
ADD_TEST(test_ed448);
return 1;
}
|
./openssl/test/quic_cc_test.c | /*
* Copyright 2022-2023 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
*/
/* For generating debug statistics during congestion controller development. */
/*#define GENERATE_LOG*/
#include "testutil.h"
#include <openssl/ssl.h>
#include "internal/quic_cc.h"
#include "internal/priority_queue.h"
/*
* Time Simulation
* ===============
*/
static OSSL_TIME fake_time = {0};
#define TIME_BASE (ossl_ticks2time(5 * OSSL_TIME_SECOND))
static OSSL_TIME fake_now(void *arg)
{
return fake_time;
}
static void step_time(uint32_t ms)
{
fake_time = ossl_time_add(fake_time, ossl_ms2time(ms));
}
/*
* Network Simulation
* ==================
*
* This is a simple 'network simulator' which emulates a network with a certain
* bandwidth and latency. Sending a packet into the network causes it to consume
* some capacity of the network until the packet exits the network. Note that
* the capacity is not known to the congestion controller as the entire point of
* a congestion controller is to correctly estimate this capacity and this is
* what we are testing. The network simulator does take care of informing the
* congestion controller of ack/loss events automatically but the caller is
* responsible for querying the congestion controller and choosing the size of
* simulated transmitted packets.
*/
typedef struct net_pkt_st {
/*
* The time at which the packet was sent.
*/
OSSL_TIME tx_time;
/*
* The time at which the simulated packet arrives at the RX side (success)
* or is dropped (!success).
*/
OSSL_TIME arrive_time;
/*
* The time at which the transmitting side makes a determination of
* acknowledgement (if success) or loss (if !success).
*/
OSSL_TIME determination_time;
/*
* Current earliest time there is something to be done for this packet.
* min(arrive_time, determination_time).
*/
OSSL_TIME next_time;
/* 1 if the packet will be successfully delivered, 0 if it is to be lost. */
int success;
/* 1 if we have already processed packet arrival. */
int arrived;
/* Size of simulated packet in bytes. */
size_t size;
/* pqueue internal index. */
size_t idx;
} NET_PKT;
DEFINE_PRIORITY_QUEUE_OF(NET_PKT);
static int net_pkt_cmp(const NET_PKT *a, const NET_PKT *b)
{
return ossl_time_compare(a->next_time, b->next_time);
}
struct net_sim {
const OSSL_CC_METHOD *ccm;
OSSL_CC_DATA *cc;
uint64_t capacity; /* bytes/s */
uint64_t latency; /* ms */
uint64_t spare_capacity;
PRIORITY_QUEUE_OF(NET_PKT) *pkts;
uint64_t total_acked, total_lost; /* bytes */
};
static int net_sim_init(struct net_sim *s,
const OSSL_CC_METHOD *ccm, OSSL_CC_DATA *cc,
uint64_t capacity, uint64_t latency)
{
s->ccm = ccm;
s->cc = cc;
s->capacity = capacity;
s->latency = latency;
s->spare_capacity = capacity;
s->total_acked = 0;
s->total_lost = 0;
if (!TEST_ptr(s->pkts = ossl_pqueue_NET_PKT_new(net_pkt_cmp)))
return 0;
return 1;
}
static void do_free(NET_PKT *pkt)
{
OPENSSL_free(pkt);
}
static void net_sim_cleanup(struct net_sim *s)
{
ossl_pqueue_NET_PKT_pop_free(s->pkts, do_free);
}
static int net_sim_process(struct net_sim *s, size_t skip_forward);
static int net_sim_send(struct net_sim *s, size_t sz)
{
NET_PKT *pkt = OPENSSL_zalloc(sizeof(*pkt));
int success;
if (!TEST_ptr(pkt))
return 0;
/*
* Ensure we have processed any events which have come due as these might
* increase our spare capacity.
*/
if (!TEST_true(net_sim_process(s, 0)))
goto err;
/* Do we have room for the packet in the network? */
success = (sz <= s->spare_capacity);
pkt->tx_time = fake_time;
pkt->success = success;
if (success) {
/* This packet will arrive successfully after |latency| time. */
pkt->arrive_time = ossl_time_add(pkt->tx_time,
ossl_ms2time(s->latency));
/* Assume all received packets are acknowledged immediately. */
pkt->determination_time = ossl_time_add(pkt->arrive_time,
ossl_ms2time(s->latency));
pkt->next_time = pkt->arrive_time;
s->spare_capacity -= sz;
} else {
/*
* In our network model, assume all packets are dropped due to a
* bottleneck at the peer's NIC RX queue; thus dropping occurs after
* |latency|.
*/
pkt->arrive_time = ossl_time_add(pkt->tx_time,
ossl_ms2time(s->latency));
/*
* It will take longer to detect loss than to detect acknowledgement.
*/
pkt->determination_time = ossl_time_add(pkt->tx_time,
ossl_ms2time(3 * s->latency));
pkt->next_time = pkt->determination_time;
}
pkt->size = sz;
if (!TEST_true(s->ccm->on_data_sent(s->cc, sz)))
goto err;
if (!TEST_true(ossl_pqueue_NET_PKT_push(s->pkts, pkt, &pkt->idx)))
goto err;
return 1;
err:
OPENSSL_free(pkt);
return 0;
}
static int net_sim_process_one(struct net_sim *s, int skip_forward)
{
NET_PKT *pkt = ossl_pqueue_NET_PKT_peek(s->pkts);
if (pkt == NULL)
return 3;
/* Jump forward to the next significant point in time. */
if (skip_forward && ossl_time_compare(pkt->next_time, fake_time) > 0)
fake_time = pkt->next_time;
if (pkt->success && !pkt->arrived
&& ossl_time_compare(fake_time, pkt->arrive_time) >= 0) {
/* Packet arrives */
s->spare_capacity += pkt->size;
pkt->arrived = 1;
ossl_pqueue_NET_PKT_pop(s->pkts);
pkt->next_time = pkt->determination_time;
if (!ossl_pqueue_NET_PKT_push(s->pkts, pkt, &pkt->idx))
return 0;
return 1;
}
if (ossl_time_compare(fake_time, pkt->determination_time) < 0)
return 2;
if (!TEST_true(!pkt->success || pkt->arrived))
return 0;
if (!pkt->success) {
OSSL_CC_LOSS_INFO loss_info = {0};
loss_info.tx_time = pkt->tx_time;
loss_info.tx_size = pkt->size;
if (!TEST_true(s->ccm->on_data_lost(s->cc, &loss_info)))
return 0;
if (!TEST_true(s->ccm->on_data_lost_finished(s->cc, 0)))
return 0;
s->total_lost += pkt->size;
ossl_pqueue_NET_PKT_pop(s->pkts);
OPENSSL_free(pkt);
} else {
OSSL_CC_ACK_INFO ack_info = {0};
ack_info.tx_time = pkt->tx_time;
ack_info.tx_size = pkt->size;
if (!TEST_true(s->ccm->on_data_acked(s->cc, &ack_info)))
return 0;
s->total_acked += pkt->size;
ossl_pqueue_NET_PKT_pop(s->pkts);
OPENSSL_free(pkt);
}
return 1;
}
static int net_sim_process(struct net_sim *s, size_t skip_forward)
{
int rc;
while ((rc = net_sim_process_one(s, skip_forward > 0 ? 1 : 0)) == 1)
if (skip_forward > 0)
--skip_forward;
return rc;
}
/*
* State Dumping Utilities
* =======================
*
* Utilities for outputting CC state information.
*/
#ifdef GENERATE_LOG
static FILE *logfile;
#endif
static int dump_state(const OSSL_CC_METHOD *ccm, OSSL_CC_DATA *cc,
struct net_sim *s)
{
#ifdef GENERATE_LOG
uint64_t cwnd_size, cur_bytes, state;
if (logfile == NULL)
return 1;
if (!TEST_true(ccm->get_option_uint(cc, OSSL_CC_OPTION_CUR_CWND_SIZE,
&cwnd_size)))
return 0;
if (!TEST_true(ccm->get_option_uint(cc, OSSL_CC_OPTION_CUR_BYTES_IN_FLIGHT,
&cur_bytes)))
return 0;
if (!TEST_true(ccm->get_option_uint(cc, OSSL_CC_OPTION_CUR_STATE,
&state)))
return 0;
fprintf(logfile, "%10lu,%10lu,%10lu,%10lu,%10lu,%10lu,%10lu,%10lu,\"%c\"\n",
ossl_time2ms(fake_time),
ccm->get_tx_allowance(cc),
cwnd_size,
cur_bytes,
s->total_acked,
s->total_lost,
s->capacity,
s->spare_capacity,
(char)state);
#endif
return 1;
}
/*
* Simulation Test
* ===============
*
* Simulator-based unit test in which we simulate a network with a certain
* capacity. The average estimated channel capacity should not be too far from
* the actual channel capacity.
*/
static int test_simulate(void)
{
int testresult = 0;
int rc;
int have_sim = 0;
const OSSL_CC_METHOD *ccm = &ossl_cc_newreno_method;
OSSL_CC_DATA *cc = NULL;
size_t mdpl = 1472;
uint64_t total_sent = 0, total_to_send, allowance;
uint64_t actual_capacity = 16000; /* B/s - 128kb/s */
uint64_t cwnd_sample_sum = 0, cwnd_sample_count = 0;
uint64_t diag_cur_bytes_in_flight = UINT64_MAX;
uint64_t diag_cur_cwnd_size = UINT64_MAX;
struct net_sim sim;
OSSL_PARAM params[3], *p = params;
fake_time = TIME_BASE;
if (!TEST_ptr(cc = ccm->new(fake_now, NULL)))
goto err;
if (!TEST_true(net_sim_init(&sim, ccm, cc, actual_capacity, 100)))
goto err;
have_sim = 1;
*p++ = OSSL_PARAM_construct_size_t(OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN,
&mdpl);
*p++ = OSSL_PARAM_construct_end();
if (!TEST_true(ccm->set_input_params(cc, params)))
goto err;
p = params;
*p++ = OSSL_PARAM_construct_uint64(OSSL_CC_OPTION_CUR_BYTES_IN_FLIGHT,
&diag_cur_bytes_in_flight);
*p++ = OSSL_PARAM_construct_uint64(OSSL_CC_OPTION_CUR_CWND_SIZE,
&diag_cur_cwnd_size);
*p++ = OSSL_PARAM_construct_end();
if (!TEST_true(ccm->bind_diagnostics(cc, params)))
goto err;
ccm->reset(cc);
if (!TEST_uint64_t_ge(allowance = ccm->get_tx_allowance(cc), mdpl))
goto err;
/*
* Start generating traffic. Stop when we've sent 30 MiB.
*/
total_to_send = 30 * 1024 * 1024;
while (total_sent < total_to_send) {
/*
* Assume we are bottlenecked by the network (which is the interesting
* case for testing a congestion controller) and always fill our entire
* TX allowance as and when it becomes available.
*/
for (;;) {
uint64_t sz;
dump_state(ccm, cc, &sim);
allowance = ccm->get_tx_allowance(cc);
sz = allowance > mdpl ? mdpl : allowance;
if (sz > SIZE_MAX)
sz = SIZE_MAX;
/*
* QUIC minimum packet sizes, etc. mean that in practice we will not
* consume the allowance exactly, so only send above a certain size.
*/
if (sz < 30)
break;
step_time(7);
if (!TEST_true(net_sim_send(&sim, (size_t)sz)))
goto err;
total_sent += sz;
}
/* Skip to next event. */
rc = net_sim_process(&sim, 1);
if (!TEST_int_gt(rc, 0))
goto err;
/*
* If we are out of any events to handle at all we definitely should
* have at least one MDPL's worth of allowance as nothing is in flight.
*/
if (rc == 3) {
if (!TEST_uint64_t_eq(diag_cur_bytes_in_flight, 0))
goto err;
if (!TEST_uint64_t_ge(ccm->get_tx_allowance(cc), mdpl))
goto err;
}
/* Update our average of the estimated channel capacity. */
{
uint64_t v = 1;
if (!TEST_uint64_t_ne(diag_cur_bytes_in_flight, UINT64_MAX)
|| !TEST_uint64_t_ne(diag_cur_cwnd_size, UINT64_MAX))
goto err;
cwnd_sample_sum += v;
++cwnd_sample_count;
}
}
/*
* Ensure estimated channel capacity is not too far off from actual channel
* capacity.
*/
{
uint64_t estimated_capacity = cwnd_sample_sum / cwnd_sample_count;
double error = ((double)estimated_capacity / (double)actual_capacity) - 1.0;
TEST_info("est = %6llu kB/s, act=%6llu kB/s (error=%.02f%%)\n",
(unsigned long long)estimated_capacity,
(unsigned long long)actual_capacity,
error * 100.0);
/* Max 5% error */
if (!TEST_double_le(error, 0.05))
goto err;
}
testresult = 1;
err:
if (have_sim)
net_sim_cleanup(&sim);
if (cc != NULL)
ccm->free(cc);
#ifdef GENERATE_LOG
if (logfile != NULL)
fflush(logfile);
#endif
return testresult;
}
/*
* Sanity Test
* ===========
*
* Basic test of the congestion control APIs.
*/
static int test_sanity(void)
{
int testresult = 0;
OSSL_CC_DATA *cc = NULL;
const OSSL_CC_METHOD *ccm = &ossl_cc_newreno_method;
OSSL_CC_LOSS_INFO loss_info = {0};
OSSL_CC_ACK_INFO ack_info = {0};
uint64_t allowance, allowance2;
OSSL_PARAM params[3], *p = params;
size_t mdpl = 1472, diag_mdpl = SIZE_MAX;
uint64_t diag_cur_bytes_in_flight = UINT64_MAX;
fake_time = TIME_BASE;
if (!TEST_ptr(cc = ccm->new(fake_now, NULL)))
goto err;
/* Test configuration of options. */
*p++ = OSSL_PARAM_construct_size_t(OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN,
&mdpl);
*p++ = OSSL_PARAM_construct_end();
if (!TEST_true(ccm->set_input_params(cc, params)))
goto err;
ccm->reset(cc);
p = params;
*p++ = OSSL_PARAM_construct_size_t(OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN,
&diag_mdpl);
*p++ = OSSL_PARAM_construct_uint64(OSSL_CC_OPTION_CUR_BYTES_IN_FLIGHT,
&diag_cur_bytes_in_flight);
*p++ = OSSL_PARAM_construct_end();
if (!TEST_true(ccm->bind_diagnostics(cc, params))
|| !TEST_size_t_eq(diag_mdpl, 1472))
goto err;
if (!TEST_uint64_t_ge(allowance = ccm->get_tx_allowance(cc), 1472))
goto err;
/* There is TX allowance so wakeup should be immediate */
if (!TEST_true(ossl_time_is_zero(ccm->get_wakeup_deadline(cc))))
goto err;
/* No bytes should currently be in flight. */
if (!TEST_uint64_t_eq(diag_cur_bytes_in_flight, 0))
goto err;
/* Tell the CC we have sent some data. */
if (!TEST_true(ccm->on_data_sent(cc, 1200)))
goto err;
/* Allowance should have decreased. */
if (!TEST_uint64_t_eq(ccm->get_tx_allowance(cc), allowance - 1200))
goto err;
/* Acknowledge the data. */
ack_info.tx_time = fake_time;
ack_info.tx_size = 1200;
step_time(100);
if (!TEST_true(ccm->on_data_acked(cc, &ack_info)))
goto err;
/* Allowance should have returned. */
if (!TEST_uint64_t_ge(allowance2 = ccm->get_tx_allowance(cc), allowance))
goto err;
/* Test invalidation. */
if (!TEST_true(ccm->on_data_sent(cc, 1200)))
goto err;
/* Allowance should have decreased. */
if (!TEST_uint64_t_eq(ccm->get_tx_allowance(cc), allowance - 1200))
goto err;
if (!TEST_true(ccm->on_data_invalidated(cc, 1200)))
goto err;
/* Allowance should have returned. */
if (!TEST_uint64_t_eq(ccm->get_tx_allowance(cc), allowance2))
goto err;
/* Test loss. */
if (!TEST_uint64_t_ge(allowance = ccm->get_tx_allowance(cc), 1200 + 1300))
goto err;
if (!TEST_true(ccm->on_data_sent(cc, 1200)))
goto err;
if (!TEST_true(ccm->on_data_sent(cc, 1300)))
goto err;
if (!TEST_uint64_t_eq(allowance2 = ccm->get_tx_allowance(cc),
allowance - 1200 - 1300))
goto err;
loss_info.tx_time = fake_time;
loss_info.tx_size = 1200;
step_time(100);
if (!TEST_true(ccm->on_data_lost(cc, &loss_info)))
goto err;
loss_info.tx_size = 1300;
if (!TEST_true(ccm->on_data_lost(cc, &loss_info)))
goto err;
if (!TEST_true(ccm->on_data_lost_finished(cc, 0)))
goto err;
/* Allowance should have changed due to the lost calls */
if (!TEST_uint64_t_ne(ccm->get_tx_allowance(cc), allowance2))
goto err;
/* But it should not be as high as the original value */
if (!TEST_uint64_t_lt(ccm->get_tx_allowance(cc), allowance))
goto err;
testresult = 1;
err:
if (cc != NULL)
ccm->free(cc);
return testresult;
}
int setup_tests(void)
{
#ifdef GENERATE_LOG
logfile = fopen("quic_cc_stats.csv", "w");
fprintf(logfile,
"\"Time\","
"\"TX Allowance\","
"\"CWND Size\","
"\"Bytes in Flight\","
"\"Total Acked\",\"Total Lost\","
"\"Capacity\",\"Spare Capacity\","
"\"State\"\n");
#endif
ADD_TEST(test_simulate);
ADD_TEST(test_sanity);
return 1;
}
|
./openssl/test/confdump.c | /*
* Copyright 1999-2021 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 <string.h>
#include <openssl/bio.h>
#include <openssl/conf.h>
#include <openssl/safestack.h>
#include <openssl/err.h>
static void dump_section(const char *name, const CONF *cnf)
{
STACK_OF(CONF_VALUE) *sect = NCONF_get_section(cnf, name);
int i;
printf("[ %s ]\n", name);
for (i = 0; i < sk_CONF_VALUE_num(sect); i++) {
CONF_VALUE *cv = sk_CONF_VALUE_value(sect, i);
printf("%s = %s\n", cv->name, cv->value);
}
}
int main(int argc, char **argv)
{
long eline;
CONF *conf = NCONF_new(NCONF_default());
int ret = 1;
STACK_OF(OPENSSL_CSTRING) *section_names = NULL;
if (conf != NULL && NCONF_load(conf, argv[1], &eline)) {
int i;
section_names = NCONF_get_section_names(conf);
for (i = 0; i < sk_OPENSSL_CSTRING_num(section_names); i++) {
dump_section(sk_OPENSSL_CSTRING_value(section_names, i), conf);
}
sk_OPENSSL_CSTRING_free(section_names);
ret = 0;
} else {
ERR_print_errors_fp(stderr);
}
NCONF_free(conf);
return ret;
}
|
./openssl/test/property_test.c | /*
* Copyright 2019-2023 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
* 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 <stdarg.h>
#include <openssl/evp.h>
#include "testutil.h"
#include "internal/nelem.h"
#include "internal/property.h"
#include "../crypto/property/property_local.h"
/*
* We make our OSSL_PROVIDER for testing purposes. All we really need is
* a pointer. We know that as long as we don't try to use the method
* cache flush functions, the provider pointer is merely a pointer being
* passed around, and used as a tag of sorts.
*/
struct ossl_provider_st {
int x;
};
static int add_property_names(const char *n, ...)
{
va_list args;
int res = 1;
va_start(args, n);
do {
if (!TEST_int_ne(ossl_property_name(NULL, n, 1), 0))
res = 0;
} while ((n = va_arg(args, const char *)) != NULL);
va_end(args);
return res;
}
static int up_ref(void *p)
{
return 1;
}
static void down_ref(void *p)
{
}
static int test_property_string(void)
{
OSSL_LIB_CTX *ctx;
OSSL_METHOD_STORE *store = NULL;
int res = 0;
OSSL_PROPERTY_IDX i, j;
/*-
* Use our own library context because we depend on ordering from a
* pristine state.
*/
if (TEST_ptr(ctx = OSSL_LIB_CTX_new())
&& TEST_ptr(store = ossl_method_store_new(ctx))
&& TEST_int_eq(ossl_property_name(ctx, "fnord", 0), 0)
&& TEST_int_ne(ossl_property_name(ctx, "fnord", 1), 0)
&& TEST_int_ne(ossl_property_name(ctx, "name", 1), 0)
/* Pre loaded names */
&& TEST_str_eq(ossl_property_name_str(ctx, 1), "provider")
&& TEST_str_eq(ossl_property_name_str(ctx, 2), "version")
&& TEST_str_eq(ossl_property_name_str(ctx, 3), "fips")
&& TEST_str_eq(ossl_property_name_str(ctx, 4), "output")
&& TEST_str_eq(ossl_property_name_str(ctx, 5), "input")
&& TEST_str_eq(ossl_property_name_str(ctx, 6), "structure")
/* The names we added */
&& TEST_str_eq(ossl_property_name_str(ctx, 7), "fnord")
&& TEST_str_eq(ossl_property_name_str(ctx, 8), "name")
/* Out of range */
&& TEST_ptr_null(ossl_property_name_str(ctx, 0))
&& TEST_ptr_null(ossl_property_name_str(ctx, 9))
/* Property value checks */
&& TEST_int_eq(ossl_property_value(ctx, "fnord", 0), 0)
&& TEST_int_ne(i = ossl_property_value(ctx, "no", 0), 0)
&& TEST_int_ne(j = ossl_property_value(ctx, "yes", 0), 0)
&& TEST_int_ne(i, j)
&& TEST_int_eq(ossl_property_value(ctx, "yes", 1), j)
&& TEST_int_eq(ossl_property_value(ctx, "no", 1), i)
&& TEST_int_ne(i = ossl_property_value(ctx, "illuminati", 1), 0)
&& TEST_int_eq(j = ossl_property_value(ctx, "fnord", 1), i + 1)
&& TEST_int_eq(ossl_property_value(ctx, "fnord", 1), j)
/* Pre loaded values */
&& TEST_str_eq(ossl_property_value_str(ctx, 1), "yes")
&& TEST_str_eq(ossl_property_value_str(ctx, 2), "no")
/* The value we added */
&& TEST_str_eq(ossl_property_value_str(ctx, 3), "illuminati")
&& TEST_str_eq(ossl_property_value_str(ctx, 4), "fnord")
/* Out of range */
&& TEST_ptr_null(ossl_property_value_str(ctx, 0))
&& TEST_ptr_null(ossl_property_value_str(ctx, 5))
/* Check name and values are distinct */
&& TEST_int_eq(ossl_property_value(ctx, "cold", 0), 0)
&& TEST_int_ne(ossl_property_name(ctx, "fnord", 0),
ossl_property_value(ctx, "fnord", 0)))
res = 1;
ossl_method_store_free(store);
OSSL_LIB_CTX_free(ctx);
return res;
}
static const struct {
const char *defn;
const char *query;
int e;
} parser_tests[] = {
{ "", "sky=blue", -1 },
{ "", "sky!=blue", 1 },
{ "groan", "", 0 },
{ "cold=yes", "cold=yes", 1 },
{ "cold=yes", "cold", 1 },
{ "cold=yes", "cold!=no", 1 },
{ "groan", "groan=yes", 1 },
{ "groan", "groan=no", -1 },
{ "groan", "groan!=yes", -1 },
{ "cold=no", "cold", -1 },
{ "cold=no", "?cold", 0 },
{ "cold=no", "cold=no", 1 },
{ "groan", "cold", -1 },
{ "groan", "cold=no", 1 },
{ "groan", "cold!=yes", 1 },
{ "groan=blue", "groan=yellow", -1 },
{ "groan=blue", "?groan=yellow", 0 },
{ "groan=blue", "groan!=yellow", 1 },
{ "groan=blue", "?groan!=yellow", 1 },
{ "today=monday, tomorrow=3", "today!=2", 1 },
{ "today=monday, tomorrow=3", "today!='monday'", -1 },
{ "today=monday, tomorrow=3", "tomorrow=3", 1 },
{ "n=0x3", "n=3", 1 },
{ "n=0x3", "n=-3", -1 },
{ "n=0x33", "n=51", 1 },
{ "n=0x123456789abcdef", "n=0x123456789abcdef", 1 },
{ "n=0x7fffffffffffffff", "n=0x7fffffffffffffff", 1 }, /* INT64_MAX */
{ "n=9223372036854775807", "n=9223372036854775807", 1 }, /* INT64_MAX */
{ "n=0777777777777777777777", "n=0777777777777777777777", 1 }, /* INT64_MAX */
{ "n=033", "n=27", 1 },
{ "n=0", "n=00", 1 },
{ "n=0x0", "n=0", 1 },
{ "n=0, sky=blue", "?n=0, sky=blue", 2 },
{ "n=1, sky=blue", "?n=0, sky=blue", 1 },
};
static int test_property_parse(int n)
{
OSSL_METHOD_STORE *store;
OSSL_PROPERTY_LIST *p = NULL, *q = NULL;
int r = 0;
if (TEST_ptr(store = ossl_method_store_new(NULL))
&& add_property_names("sky", "groan", "cold", "today", "tomorrow", "n",
NULL)
&& TEST_ptr(p = ossl_parse_property(NULL, parser_tests[n].defn))
&& TEST_ptr(q = ossl_parse_query(NULL, parser_tests[n].query, 0))
&& TEST_int_eq(ossl_property_match_count(q, p), parser_tests[n].e))
r = 1;
ossl_property_free(p);
ossl_property_free(q);
ossl_method_store_free(store);
return r;
}
static int test_property_query_value_create(void)
{
OSSL_METHOD_STORE *store;
OSSL_PROPERTY_LIST *p = NULL, *q = NULL, *o = NULL;
int r = 0;
/* The property value used here must not be used in other test cases */
if (TEST_ptr(store = ossl_method_store_new(NULL))
&& add_property_names("wood", NULL)
&& TEST_ptr(p = ossl_parse_query(NULL, "wood=oak", 0)) /* undefined */
&& TEST_ptr(q = ossl_parse_query(NULL, "wood=oak", 1)) /* creates */
&& TEST_ptr(o = ossl_parse_query(NULL, "wood=oak", 0)) /* defined */
&& TEST_int_eq(ossl_property_match_count(q, p), -1)
&& TEST_int_eq(ossl_property_match_count(q, o), 1))
r = 1;
ossl_property_free(o);
ossl_property_free(p);
ossl_property_free(q);
ossl_method_store_free(store);
return r;
}
static const struct {
int query;
const char *ps;
} parse_error_tests[] = {
{ 0, "n=1, n=1" }, /* duplicate name */
{ 0, "n=1, a=hi, n=1" }, /* duplicate name */
{ 1, "n=1, a=bye, ?n=0" }, /* duplicate name */
{ 0, "a=abc,#@!, n=1" }, /* non-ASCII character located */
{ 1, "a='Hello" }, /* Unterminated string */
{ 0, "a=\"World" }, /* Unterminated string */
{ 0, "a=_abd_" }, /* Unquoted string not starting with alphabetic */
{ 1, "a=2, n=012345678" }, /* Bad octal digit */
{ 0, "n=0x28FG, a=3" }, /* Bad hex digit */
{ 0, "n=145d, a=2" }, /* Bad decimal digit */
{ 0, "n=0x8000000000000000, a=3" }, /* Hex overflow */
{ 0, "n=922337203000000000d, a=2" }, /* Decimal overflow */
{ 0, "a=2, n=1000000000000000000000" }, /* Octal overflow */
{ 1, "@='hello'" }, /* Invalid name */
{ 1, "n0123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789=yes" }, /* Name too long */
{ 0, ".n=3" }, /* Invalid name */
{ 1, "fnord.fnord.=3" } /* Invalid name */
};
static int test_property_parse_error(int n)
{
OSSL_METHOD_STORE *store;
OSSL_PROPERTY_LIST *p = NULL;
int r = 0;
const char *ps;
if (!TEST_ptr(store = ossl_method_store_new(NULL))
|| !add_property_names("a", "n", NULL))
goto err;
ps = parse_error_tests[n].ps;
if (parse_error_tests[n].query) {
if (!TEST_ptr_null(p = ossl_parse_query(NULL, ps, 1)))
goto err;
} else if (!TEST_ptr_null(p = ossl_parse_property(NULL, ps))) {
goto err;
}
r = 1;
err:
ossl_property_free(p);
ossl_method_store_free(store);
return r;
}
static const struct {
const char *q_global;
const char *q_local;
const char *prop;
} merge_tests[] = {
{ "", "colour=blue", "colour=blue" },
{ "colour=blue", "", "colour=blue" },
{ "colour=red", "colour=blue", "colour=blue" },
{ "clouds=pink, urn=red", "urn=blue, colour=green",
"urn=blue, colour=green, clouds=pink" },
{ "pot=gold", "urn=blue", "pot=gold, urn=blue" },
{ "night", "day", "day=yes, night=yes" },
{ "day", "night", "day=yes, night=yes" },
{ "", "", "" },
/*
* The following four leave 'day' unspecified in the query, and will match
* any definition
*/
{ "day=yes", "-day", "day=no" },
{ "day=yes", "-day", "day=yes" },
{ "day=yes", "-day", "day=arglebargle" },
{ "day=yes", "-day", "pot=sesquioxidizing" },
{ "day, night", "-night, day", "day=yes, night=no" },
{ "-day", "day=yes", "day=yes" },
};
static int test_property_merge(int n)
{
OSSL_METHOD_STORE *store;
OSSL_PROPERTY_LIST *q_global = NULL, *q_local = NULL;
OSSL_PROPERTY_LIST *q_combined = NULL, *prop = NULL;
int r = 0;
if (TEST_ptr(store = ossl_method_store_new(NULL))
&& add_property_names("colour", "urn", "clouds", "pot", "day", "night",
NULL)
&& TEST_ptr(prop = ossl_parse_property(NULL, merge_tests[n].prop))
&& TEST_ptr(q_global = ossl_parse_query(NULL, merge_tests[n].q_global,
0))
&& TEST_ptr(q_local = ossl_parse_query(NULL, merge_tests[n].q_local, 0))
&& TEST_ptr(q_combined = ossl_property_merge(q_local, q_global))
&& TEST_int_ge(ossl_property_match_count(q_combined, prop), 0))
r = 1;
ossl_property_free(q_global);
ossl_property_free(q_local);
ossl_property_free(q_combined);
ossl_property_free(prop);
ossl_method_store_free(store);
return r;
}
static int test_property_defn_cache(void)
{
OSSL_METHOD_STORE *store;
OSSL_PROPERTY_LIST *red = NULL, *blue = NULL, *blue2 = NULL;
int r;
r = TEST_ptr(store = ossl_method_store_new(NULL))
&& add_property_names("red", "blue", NULL)
&& TEST_ptr(red = ossl_parse_property(NULL, "red"))
&& TEST_ptr(blue = ossl_parse_property(NULL, "blue"))
&& TEST_ptr_ne(red, blue)
&& TEST_true(ossl_prop_defn_set(NULL, "red", &red));
if (!r) {
ossl_property_free(red);
red = NULL;
ossl_property_free(blue);
blue = NULL;
}
r = r && TEST_true(ossl_prop_defn_set(NULL, "blue", &blue));
if (!r) {
ossl_property_free(blue);
blue = NULL;
}
r = r && TEST_ptr_eq(ossl_prop_defn_get(NULL, "red"), red)
&& TEST_ptr_eq(ossl_prop_defn_get(NULL, "blue"), blue)
&& TEST_ptr(blue2 = ossl_parse_property(NULL, "blue"))
&& TEST_ptr_ne(blue2, blue)
&& TEST_true(ossl_prop_defn_set(NULL, "blue", &blue2));
if (!r) {
ossl_property_free(blue2);
blue2 = NULL;
}
r = r && TEST_ptr_eq(blue2, blue)
&& TEST_ptr_eq(ossl_prop_defn_get(NULL, "blue"), blue);
ossl_method_store_free(store);
return r;
}
static const struct {
const char *defn;
const char *query;
int e;
} definition_tests[] = {
{ "alpha", "alpha=yes", 1 },
{ "alpha=no", "alpha", -1 },
{ "alpha=1", "alpha=1", 1 },
{ "alpha=2", "alpha=1",-1 },
{ "alpha", "omega", -1 },
{ "alpha", "?omega", 0 },
{ "alpha", "?omega=1", 0 },
{ "alpha", "?omega=no", 1 },
{ "alpha", "?omega=yes", 0 },
{ "alpha, omega", "?omega=yes", 1 },
{ "alpha, omega", "?omega=no", 0 }
};
static int test_definition_compares(int n)
{
OSSL_METHOD_STORE *store;
OSSL_PROPERTY_LIST *d = NULL, *q = NULL;
int r;
r = TEST_ptr(store = ossl_method_store_new(NULL))
&& add_property_names("alpha", "omega", NULL)
&& TEST_ptr(d = ossl_parse_property(NULL, definition_tests[n].defn))
&& TEST_ptr(q = ossl_parse_query(NULL, definition_tests[n].query, 0))
&& TEST_int_eq(ossl_property_match_count(q, d), definition_tests[n].e);
ossl_property_free(d);
ossl_property_free(q);
ossl_method_store_free(store);
return r;
}
static int test_register_deregister(void)
{
static const struct {
int nid;
const char *prop;
char *impl;
} impls[] = {
{ 6, "position=1", "a" },
{ 6, "position=2", "b" },
{ 6, "position=3", "c" },
{ 6, "position=4", "d" },
};
size_t i;
int ret = 0;
OSSL_METHOD_STORE *store;
OSSL_PROVIDER prov = { 1 };
if (!TEST_ptr(store = ossl_method_store_new(NULL))
|| !add_property_names("position", NULL))
goto err;
for (i = 0; i < OSSL_NELEM(impls); i++)
if (!TEST_true(ossl_method_store_add(store, &prov, impls[i].nid,
impls[i].prop, impls[i].impl,
&up_ref, &down_ref))) {
TEST_note("iteration %zd", i + 1);
goto err;
}
/* Deregister in a different order to registration */
for (i = 0; i < OSSL_NELEM(impls); i++) {
const size_t j = (1 + i * 3) % OSSL_NELEM(impls);
int nid = impls[j].nid;
void *impl = impls[j].impl;
if (!TEST_true(ossl_method_store_remove(store, nid, impl))
|| !TEST_false(ossl_method_store_remove(store, nid, impl))) {
TEST_note("iteration %zd, position %zd", i + 1, j + 1);
goto err;
}
}
if (TEST_false(ossl_method_store_remove(store, impls[0].nid, impls[0].impl)))
ret = 1;
err:
ossl_method_store_free(store);
return ret;
}
static int test_property(void)
{
static OSSL_PROVIDER fake_provider1 = { 1 };
static OSSL_PROVIDER fake_provider2 = { 2 };
static const OSSL_PROVIDER *fake_prov1 = &fake_provider1;
static const OSSL_PROVIDER *fake_prov2 = &fake_provider2;
static const struct {
const OSSL_PROVIDER **prov;
int nid;
const char *prop;
char *impl;
} impls[] = {
{ &fake_prov1, 1, "fast=no, colour=green", "a" },
{ &fake_prov1, 1, "fast, colour=blue", "b" },
{ &fake_prov1, 1, "", "-" },
{ &fake_prov2, 9, "sky=blue, furry", "c" },
{ &fake_prov2, 3, NULL, "d" },
{ &fake_prov2, 6, "sky.colour=blue, sky=green, old.data", "e" },
};
static struct {
const OSSL_PROVIDER **prov;
int nid;
const char *prop;
char *expected;
} queries[] = {
{ &fake_prov1, 1, "fast", "b" },
{ &fake_prov1, 1, "fast=yes", "b" },
{ &fake_prov1, 1, "fast=no, colour=green", "a" },
{ &fake_prov1, 1, "colour=blue, fast", "b" },
{ &fake_prov1, 1, "colour=blue", "b" },
{ &fake_prov2, 9, "furry", "c" },
{ &fake_prov2, 6, "sky.colour=blue", "e" },
{ &fake_prov2, 6, "old.data", "e" },
{ &fake_prov2, 9, "furry=yes, sky=blue", "c" },
{ &fake_prov1, 1, "", "a" },
{ &fake_prov2, 3, "", "d" },
};
OSSL_METHOD_STORE *store;
size_t i;
int ret = 0;
void *result;
if (!TEST_ptr(store = ossl_method_store_new(NULL))
|| !add_property_names("fast", "colour", "sky", "furry", NULL))
goto err;
for (i = 0; i < OSSL_NELEM(impls); i++)
if (!TEST_true(ossl_method_store_add(store, *impls[i].prov,
impls[i].nid, impls[i].prop,
impls[i].impl,
&up_ref, &down_ref))) {
TEST_note("iteration %zd", i + 1);
goto err;
}
/*
* The first check of queries is with NULL given as provider. All
* queries are expected to succeed.
*/
for (i = 0; i < OSSL_NELEM(queries); i++) {
const OSSL_PROVIDER *nullprov = NULL;
OSSL_PROPERTY_LIST *pq = NULL;
if (!TEST_true(ossl_method_store_fetch(store,
queries[i].nid, queries[i].prop,
&nullprov, &result))
|| !TEST_str_eq((char *)result, queries[i].expected)) {
TEST_note("iteration %zd", i + 1);
ossl_property_free(pq);
goto err;
}
ossl_property_free(pq);
}
/*
* The second check of queries is with &address1 given as provider.
*/
for (i = 0; i < OSSL_NELEM(queries); i++) {
OSSL_PROPERTY_LIST *pq = NULL;
result = NULL;
if (queries[i].prov == &fake_prov1) {
if (!TEST_true(ossl_method_store_fetch(store,
queries[i].nid,
queries[i].prop,
&fake_prov1, &result))
|| !TEST_ptr_eq(fake_prov1, &fake_provider1)
|| !TEST_str_eq((char *)result, queries[i].expected)) {
TEST_note("iteration %zd", i + 1);
ossl_property_free(pq);
goto err;
}
} else {
if (!TEST_false(ossl_method_store_fetch(store,
queries[i].nid,
queries[i].prop,
&fake_prov1, &result))
|| !TEST_ptr_eq(fake_prov1, &fake_provider1)
|| !TEST_ptr_null(result)) {
TEST_note("iteration %zd", i + 1);
ossl_property_free(pq);
goto err;
}
}
ossl_property_free(pq);
}
/*
* The third check of queries is with &address2 given as provider.
*/
for (i = 0; i < OSSL_NELEM(queries); i++) {
OSSL_PROPERTY_LIST *pq = NULL;
result = NULL;
if (queries[i].prov == &fake_prov2) {
if (!TEST_true(ossl_method_store_fetch(store,
queries[i].nid,
queries[i].prop,
&fake_prov2, &result))
|| !TEST_ptr_eq(fake_prov2, &fake_provider2)
|| !TEST_str_eq((char *)result, queries[i].expected)) {
TEST_note("iteration %zd", i + 1);
ossl_property_free(pq);
goto err;
}
} else {
if (!TEST_false(ossl_method_store_fetch(store,
queries[i].nid,
queries[i].prop,
&fake_prov2, &result))
|| !TEST_ptr_eq(fake_prov2, &fake_provider2)
|| !TEST_ptr_null(result)) {
TEST_note("iteration %zd", i + 1);
ossl_property_free(pq);
goto err;
}
}
ossl_property_free(pq);
}
ret = 1;
err:
ossl_method_store_free(store);
return ret;
}
static int test_query_cache_stochastic(void)
{
const int max = 10000, tail = 10;
OSSL_METHOD_STORE *store;
int i, res = 0;
char buf[50];
void *result;
int errors = 0;
int v[10001];
OSSL_PROVIDER prov = { 1 };
if (!TEST_ptr(store = ossl_method_store_new(NULL))
|| !add_property_names("n", NULL))
goto err;
for (i = 1; i <= max; i++) {
v[i] = 2 * i;
BIO_snprintf(buf, sizeof(buf), "n=%d\n", i);
if (!TEST_true(ossl_method_store_add(store, &prov, i, buf, "abc",
&up_ref, &down_ref))
|| !TEST_true(ossl_method_store_cache_set(store, &prov, i,
buf, v + i,
&up_ref, &down_ref))
|| !TEST_true(ossl_method_store_cache_set(store, &prov, i,
"n=1234", "miss",
&up_ref, &down_ref))) {
TEST_note("iteration %d", i);
goto err;
}
}
for (i = 1; i <= max; i++) {
BIO_snprintf(buf, sizeof(buf), "n=%d\n", i);
if (!ossl_method_store_cache_get(store, NULL, i, buf, &result)
|| result != v + i)
errors++;
}
/* There is a tiny probability that this will fail when it shouldn't */
res = TEST_int_gt(errors, tail) && TEST_int_lt(errors, max - tail);
err:
ossl_method_store_free(store);
return res;
}
static int test_fips_mode(void)
{
int ret = 0;
OSSL_LIB_CTX *ctx = NULL;
if (!TEST_ptr(ctx = OSSL_LIB_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:
OSSL_LIB_CTX_free(ctx);
return ret;
}
static struct {
const char *in;
const char *out;
} to_string_tests[] = {
{ "fips=yes", "fips=yes" },
{ "fips!=yes", "fips!=yes" },
{ "fips = yes", "fips=yes" },
{ "fips", "fips=yes" },
{ "fips=no", "fips=no" },
{ "-fips", "-fips" },
{ "?fips=yes", "?fips=yes" },
{ "fips=yes,provider=fips", "fips=yes,provider=fips" },
{ "fips = yes , provider = fips", "fips=yes,provider=fips" },
{ "fips=yes,provider!=fips", "fips=yes,provider!=fips" },
{ "fips=yes,?provider=fips", "fips=yes,?provider=fips" },
{ "fips=yes,-provider", "fips=yes,-provider" },
/* foo is an unknown internal name */
{ "foo=yes,fips=yes", "fips=yes"},
{ "", "" },
{ "fips=3", "fips=3" },
{ "fips=-3", "fips=-3" },
{ "provider='foo bar'", "provider='foo bar'" },
{ "provider=\"foo bar'\"", "provider=\"foo bar'\"" },
{ "provider=abc***", "provider='abc***'" },
{ NULL, "" }
};
static int test_property_list_to_string(int i)
{
OSSL_PROPERTY_LIST *pl = NULL;
int ret = 0;
size_t bufsize;
char *buf = NULL;
if (to_string_tests[i].in != NULL
&& !TEST_ptr(pl = ossl_parse_query(NULL, to_string_tests[i].in, 1)))
goto err;
bufsize = ossl_property_list_to_string(NULL, pl, NULL, 0);
if (!TEST_size_t_gt(bufsize, 0))
goto err;
buf = OPENSSL_malloc(bufsize);
if (!TEST_ptr(buf)
|| !TEST_size_t_eq(ossl_property_list_to_string(NULL, pl, buf,
bufsize),
bufsize)
|| !TEST_str_eq(to_string_tests[i].out, buf)
|| !TEST_size_t_eq(bufsize, strlen(to_string_tests[i].out) + 1))
goto err;
ret = 1;
err:
OPENSSL_free(buf);
ossl_property_free(pl);
return ret;
}
int setup_tests(void)
{
ADD_TEST(test_property_string);
ADD_TEST(test_property_query_value_create);
ADD_ALL_TESTS(test_property_parse, OSSL_NELEM(parser_tests));
ADD_ALL_TESTS(test_property_parse_error, OSSL_NELEM(parse_error_tests));
ADD_ALL_TESTS(test_property_merge, OSSL_NELEM(merge_tests));
ADD_TEST(test_property_defn_cache);
ADD_ALL_TESTS(test_definition_compares, OSSL_NELEM(definition_tests));
ADD_TEST(test_register_deregister);
ADD_TEST(test_property);
ADD_TEST(test_query_cache_stochastic);
ADD_TEST(test_fips_mode);
ADD_ALL_TESTS(test_property_list_to_string, OSSL_NELEM(to_string_tests));
return 1;
}
|
./openssl/test/ssl_cert_table_internal_test.c | /*
* Copyright 2017-2021 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
*/
/* Internal tests for the x509 and x509v3 modules */
#include <stdio.h>
#include <string.h>
#include <openssl/ssl.h>
#include "testutil.h"
#include "internal/nelem.h"
#include "../ssl/ssl_local.h"
#include "../ssl/ssl_cert_table.h"
#define test_cert_table(nid, amask, idx) \
do_test_cert_table(nid, amask, idx, #idx)
static int do_test_cert_table(int nid, uint32_t amask, size_t idx,
const char *idxname)
{
const SSL_CERT_LOOKUP *clu = &ssl_cert_info[idx];
if (clu->nid == nid && clu->amask == amask)
return 1;
TEST_error("Invalid table entry for certificate type %s, index %zu",
idxname, idx);
if (clu->nid != nid)
TEST_note("Expected %s, got %s\n", OBJ_nid2sn(nid),
OBJ_nid2sn(clu->nid));
if (clu->amask != amask)
TEST_note("Expected auth mask 0x%x, got 0x%x\n",
(unsigned int)amask, (unsigned int)clu->amask);
return 0;
}
/* Sanity check of ssl_cert_table */
static int test_ssl_cert_table(void)
{
return TEST_size_t_eq(OSSL_NELEM(ssl_cert_info), SSL_PKEY_NUM)
&& test_cert_table(EVP_PKEY_RSA, SSL_aRSA, SSL_PKEY_RSA)
&& test_cert_table(EVP_PKEY_DSA, SSL_aDSS, SSL_PKEY_DSA_SIGN)
&& test_cert_table(EVP_PKEY_EC, SSL_aECDSA, SSL_PKEY_ECC)
&& test_cert_table(NID_id_GostR3410_2001, SSL_aGOST01,
SSL_PKEY_GOST01)
&& test_cert_table(NID_id_GostR3410_2012_256, SSL_aGOST12,
SSL_PKEY_GOST12_256)
&& test_cert_table(NID_id_GostR3410_2012_512, SSL_aGOST12,
SSL_PKEY_GOST12_512)
&& test_cert_table(EVP_PKEY_ED25519, SSL_aECDSA, SSL_PKEY_ED25519)
&& test_cert_table(EVP_PKEY_ED448, SSL_aECDSA, SSL_PKEY_ED448);
}
int setup_tests(void)
{
ADD_TEST(test_ssl_cert_table);
return 1;
}
|
./openssl/test/cmp_ctx_test.c | /*
* Copyright 2007-2023 The OpenSSL Project Authors. All Rights Reserved.
* Copyright Nokia 2007-2019
* Copyright Siemens AG 2015-2019
*
* 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 "helpers/cmp_testlib.h"
#include <openssl/x509_vfy.h>
typedef struct test_fixture {
const char *test_case_name;
OSSL_CMP_CTX *ctx;
} OSSL_CMP_CTX_TEST_FIXTURE;
static void tear_down(OSSL_CMP_CTX_TEST_FIXTURE *fixture)
{
if (fixture != NULL)
OSSL_CMP_CTX_free(fixture->ctx);
OPENSSL_free(fixture);
}
static OSSL_CMP_CTX_TEST_FIXTURE *set_up(const char *const test_case_name)
{
OSSL_CMP_CTX_TEST_FIXTURE *fixture;
if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture))))
return NULL;
if (!TEST_ptr(fixture->ctx = OSSL_CMP_CTX_new(NULL, NULL))) {
tear_down(fixture);
return NULL;
}
fixture->test_case_name = test_case_name;
return fixture;
}
static STACK_OF(X509) *sk_X509_new_1(void)
{
STACK_OF(X509) *sk = sk_X509_new_null();
X509 *x = X509_new();
if (x == NULL || !sk_X509_push(sk, x)) {
sk_X509_free(sk);
X509_free(x);
sk = NULL;
}
return sk;
}
static void sk_X509_pop_X509_free(STACK_OF(X509) *sk)
{
OSSL_STACK_OF_X509_free(sk);
}
static int execute_CTX_reinit_test(OSSL_CMP_CTX_TEST_FIXTURE *fixture)
{
OSSL_CMP_CTX *ctx = fixture->ctx;
ASN1_OCTET_STRING *bytes = NULL;
STACK_OF(X509) *certs = NULL;
X509 *cert = X509_new();
int res = 0;
/* set non-default values in all relevant fields */
ctx->status = 1;
ctx->failInfoCode = 1;
if (!ossl_cmp_ctx_set0_statusString(ctx, sk_ASN1_UTF8STRING_new_null())
|| !ossl_cmp_ctx_set0_newCert(ctx, X509_new())
|| !TEST_ptr(certs = sk_X509_new_1())
|| !ossl_cmp_ctx_set1_newChain(ctx, certs)
|| !ossl_cmp_ctx_set1_caPubs(ctx, certs)
|| !ossl_cmp_ctx_set1_extraCertsIn(ctx, certs)
|| !ossl_cmp_ctx_set1_validatedSrvCert(ctx, cert)
|| !TEST_ptr(bytes = ASN1_OCTET_STRING_new())
|| !OSSL_CMP_CTX_set1_transactionID(ctx, bytes)
|| !OSSL_CMP_CTX_set1_senderNonce(ctx, bytes)
|| !ossl_cmp_ctx_set1_recipNonce(ctx, bytes))
goto err;
if (!TEST_true(OSSL_CMP_CTX_reinit(ctx)))
goto err;
/* check whether values have been reset to default in all relevant fields */
if (!TEST_true(ctx->status == -1
&& ctx->failInfoCode == -1
&& ctx->statusString == NULL
&& ctx->newCert == NULL
&& ctx->newChain == NULL
&& ctx->caPubs == NULL
&& ctx->extraCertsIn == NULL
&& ctx->validatedSrvCert == NULL
&& ctx->transactionID == NULL
&& ctx->senderNonce == NULL
&& ctx->recipNonce == NULL))
goto err;
/* this does not check that all remaining fields are untouched */
res = 1;
err:
X509_free(cert);
sk_X509_pop_X509_free(certs);
ASN1_OCTET_STRING_free(bytes);
return res;
}
static int test_CTX_libctx_propq(void)
{
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
const char *propq = "?provider=legacy";
OSSL_CMP_CTX *cmpctx = OSSL_CMP_CTX_new(libctx, propq);
int res = TEST_ptr(libctx)
&& TEST_ptr(cmpctx)
&& TEST_ptr_eq(libctx, OSSL_CMP_CTX_get0_libctx(cmpctx))
&& TEST_str_eq(propq, OSSL_CMP_CTX_get0_propq(cmpctx));
OSSL_CMP_CTX_free(cmpctx);
OSSL_LIB_CTX_free(libctx);
return res;
}
static int test_CTX_reinit(void)
{
SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up);
EXECUTE_TEST(execute_CTX_reinit_test, tear_down);
return result;
}
#if !defined(OPENSSL_NO_ERR) && !defined(OPENSSL_NO_AUTOERRINIT)
static int msg_total_size = 0;
static int msg_total_size_log_cb(const char *func, const char *file, int line,
OSSL_CMP_severity level, const char *msg)
{
msg_total_size += strlen(msg);
TEST_note("total=%d len=%zu msg='%s'\n", msg_total_size, strlen(msg), msg);
return 1;
}
# define STR64 "This is a 64 bytes looooooooooooooooooooooooooooooooong string.\n"
/* max string length ISO C90 compilers are required to support is 509. */
# define STR509 STR64 STR64 STR64 STR64 STR64 STR64 STR64 \
"This is a 61 bytes loooooooooooooooooooooooooooooong string.\n"
static const char *const max_str_literal = STR509;
# define STR_SEP "<SEP>"
static int execute_CTX_print_errors_test(OSSL_CMP_CTX_TEST_FIXTURE *fixture)
{
OSSL_CMP_CTX *ctx = fixture->ctx;
int base_err_msg_size, expected_size;
int res = 1;
if (!TEST_true(OSSL_CMP_CTX_set_log_cb(ctx, NULL)))
res = 0;
if (!TEST_true(ctx->log_cb == NULL))
res = 0;
# ifndef OPENSSL_NO_STDIO
ERR_raise(ERR_LIB_CMP, CMP_R_MULTIPLE_SAN_SOURCES);
OSSL_CMP_CTX_print_errors(ctx); /* should print above error to STDERR */
# endif
/* this should work regardless of OPENSSL_NO_STDIO and OPENSSL_NO_TRACE: */
if (!TEST_true(OSSL_CMP_CTX_set_log_cb(ctx, msg_total_size_log_cb)))
res = 0;
if (!TEST_true(ctx->log_cb == msg_total_size_log_cb)) {
res = 0;
} else {
ERR_raise(ERR_LIB_CMP, CMP_R_INVALID_ARGS);
base_err_msg_size = strlen("INVALID_ARGS");
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
base_err_msg_size += strlen("NULL_ARGUMENT");
expected_size = base_err_msg_size;
ossl_cmp_add_error_data("data1"); /* should prepend separator ":" */
expected_size += strlen(":" "data1");
ossl_cmp_add_error_data("data2"); /* should prepend separator " : " */
expected_size += strlen(" : " "data2");
ossl_cmp_add_error_line("new line"); /* should prepend separator "\n" */
expected_size += strlen("\n" "new line");
OSSL_CMP_CTX_print_errors(ctx);
if (!TEST_int_eq(msg_total_size, expected_size))
res = 0;
ERR_raise(ERR_LIB_CMP, CMP_R_INVALID_ARGS);
base_err_msg_size = strlen("INVALID_ARGS") + strlen(":");
expected_size = base_err_msg_size;
while (expected_size < 4096) { /* force split */
ERR_add_error_txt(STR_SEP, max_str_literal);
expected_size += strlen(STR_SEP) + strlen(max_str_literal);
}
expected_size += base_err_msg_size - 2 * strlen(STR_SEP);
msg_total_size = 0;
OSSL_CMP_CTX_print_errors(ctx);
if (!TEST_int_eq(msg_total_size, expected_size))
res = 0;
}
return res;
}
static int test_CTX_print_errors(void)
{
SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up);
EXECUTE_TEST(execute_CTX_print_errors_test, tear_down);
return result;
}
#endif
static
int execute_CTX_reqExtensions_have_SAN_test(OSSL_CMP_CTX_TEST_FIXTURE *fixture)
{
OSSL_CMP_CTX *ctx = fixture->ctx;
const int len = 16;
unsigned char str[16 /* = len */];
ASN1_OCTET_STRING *data = NULL;
X509_EXTENSION *ext = NULL;
X509_EXTENSIONS *exts = NULL;
int res = 0;
if (!TEST_false(OSSL_CMP_CTX_reqExtensions_have_SAN(ctx)))
return 0;
if (!TEST_int_eq(1, RAND_bytes(str, len))
|| !TEST_ptr(data = ASN1_OCTET_STRING_new())
|| !TEST_true(ASN1_OCTET_STRING_set(data, str, len)))
goto err;
ext = X509_EXTENSION_create_by_NID(NULL, NID_subject_alt_name, 0, data);
if (!TEST_ptr(ext)
|| !TEST_ptr(exts = sk_X509_EXTENSION_new_null())
|| !TEST_true(sk_X509_EXTENSION_push(exts, ext))
|| !TEST_true(OSSL_CMP_CTX_set0_reqExtensions(ctx, exts))) {
X509_EXTENSION_free(ext);
sk_X509_EXTENSION_free(exts);
goto err;
}
if (TEST_int_eq(OSSL_CMP_CTX_reqExtensions_have_SAN(ctx), 1)) {
ext = sk_X509_EXTENSION_pop(exts);
res = TEST_false(OSSL_CMP_CTX_reqExtensions_have_SAN(ctx));
X509_EXTENSION_free(ext);
}
err:
ASN1_OCTET_STRING_free(data);
return res;
}
static int test_CTX_reqExtensions_have_SAN(void)
{
SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up);
EXECUTE_TEST(execute_CTX_reqExtensions_have_SAN_test, tear_down);
return result;
}
static int test_log_line;
static int test_log_cb_res = 0;
static int test_log_cb(const char *func, const char *file, int line,
OSSL_CMP_severity level, const char *msg)
{
test_log_cb_res =
#ifndef PEDANTIC
(TEST_str_eq(func, "execute_cmp_ctx_log_cb_test")
|| TEST_str_eq(func, "(unknown function)")) &&
#endif
(TEST_str_eq(file, OPENSSL_FILE)
|| TEST_str_eq(file, "(no file)"))
&& (TEST_int_eq(line, test_log_line) || TEST_int_eq(line, 0))
&& (TEST_int_eq(level, OSSL_CMP_LOG_INFO) || TEST_int_eq(level, -1))
&& TEST_str_eq(msg, "ok");
return 1;
}
static int execute_cmp_ctx_log_cb_test(OSSL_CMP_CTX_TEST_FIXTURE *fixture)
{
int res = 1;
OSSL_CMP_CTX *ctx = fixture->ctx;
OSSL_TRACE(ALL, "this general trace message is not shown by default\n");
OSSL_CMP_log_open();
OSSL_CMP_log_open(); /* multiple calls should be harmless */
if (!TEST_true(OSSL_CMP_CTX_set_log_cb(ctx, NULL))) {
res = 0;
} else {
ossl_cmp_err(ctx, "this should be printed as CMP error message");
ossl_cmp_warn(ctx, "this should be printed as CMP warning message");
ossl_cmp_debug(ctx, "this should not be printed");
TEST_true(OSSL_CMP_CTX_set_log_verbosity(ctx, OSSL_CMP_LOG_DEBUG));
ossl_cmp_debug(ctx, "this should be printed as CMP debug message");
TEST_true(OSSL_CMP_CTX_set_log_verbosity(ctx, OSSL_CMP_LOG_INFO));
}
if (!TEST_true(OSSL_CMP_CTX_set_log_cb(ctx, test_log_cb))) {
res = 0;
} else {
test_log_line = OPENSSL_LINE + 1;
ossl_cmp_log2(INFO, ctx, "%s%c", "o", 'k');
if (!TEST_int_eq(test_log_cb_res, 1))
res = 0;
OSSL_CMP_CTX_set_log_verbosity(ctx, OSSL_CMP_LOG_ERR);
test_log_cb_res = -1; /* callback should not be called at all */
test_log_line = OPENSSL_LINE + 1;
ossl_cmp_log2(INFO, ctx, "%s%c", "o", 'k');
if (!TEST_int_eq(test_log_cb_res, -1))
res = 0;
}
OSSL_CMP_log_close();
OSSL_CMP_log_close(); /* multiple calls should be harmless */
return res;
}
static int test_cmp_ctx_log_cb(void)
{
SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up);
EXECUTE_TEST(execute_cmp_ctx_log_cb_test, tear_down);
return result;
}
#ifndef OPENSSL_NO_HTTP
static BIO *test_http_cb(BIO *bio, void *arg, int use_ssl, int detail)
{
return NULL;
}
#endif
static OSSL_CMP_MSG *test_transfer_cb(OSSL_CMP_CTX *ctx,
const OSSL_CMP_MSG *req)
{
return NULL;
}
static int test_certConf_cb(OSSL_CMP_CTX *ctx, X509 *cert, int fail_info,
const char **txt)
{
return 0;
}
typedef OSSL_CMP_CTX CMP_CTX; /* prevents rewriting type name by below macro */
#define OSSL_CMP_CTX 1 /* name prefix for exported setter functions */
#define ossl_cmp_ctx 0 /* name prefix for internal setter functions */
#define set 0
#define set0 0
#define set1 1
#define get 0
#define get0 0
#define get1 1
#define DEFINE_SET_GET_BASE_TEST(PREFIX, SETN, GETN, DUP, FIELD, TYPE, ERR, \
DEFAULT, NEW, FREE) \
static int \
execute_CTX_##SETN##_##GETN##_##FIELD(OSSL_CMP_CTX_TEST_FIXTURE *fixture) \
{ \
CMP_CTX *ctx = fixture->ctx; \
int (*set_fn)(CMP_CTX *ctx, TYPE) = \
(int (*)(CMP_CTX *ctx, TYPE))PREFIX##_##SETN##_##FIELD; \
/* need type cast in above assignment as TYPE arg sometimes is const */ \
TYPE (*get_fn)(const CMP_CTX *ctx) = OSSL_CMP_CTX_##GETN##_##FIELD; \
TYPE val1_to_free = NEW; \
TYPE val1 = val1_to_free; \
TYPE val1_read = 0; /* 0 works for any type */ \
TYPE val2_to_free = NEW; \
TYPE val2 = val2_to_free; \
TYPE val2_read = 0; \
TYPE val3_read = 0; \
int res = 1; \
\
if (!TEST_int_eq(ERR_peek_error(), 0)) \
res = 0; \
if (PREFIX == 1) { /* exported setter functions must test ctx == NULL */ \
if ((*set_fn)(NULL, val1) || ERR_peek_error() == 0) { \
TEST_error("setter did not return error on ctx == NULL"); \
res = 0; \
} \
} \
ERR_clear_error(); \
\
if ((*get_fn)(NULL) != ERR || ERR_peek_error() == 0) { \
TEST_error("getter did not return error on ctx == NULL"); \
res = 0; \
} \
ERR_clear_error(); \
\
val1_read = (*get_fn)(ctx); \
if (!DEFAULT(val1_read)) { \
TEST_error("did not get default value"); \
res = 0; \
} \
if (!(*set_fn)(ctx, val1)) { \
TEST_error("setting first value failed"); \
res = 0; \
} \
if (SETN == 0) \
val1_to_free = 0; /* 0 works for any type */ \
\
if (GETN == 1) \
FREE(val1_read); \
val1_read = (*get_fn)(ctx); \
if (SETN == 0) { \
if (val1_read != val1) { \
TEST_error("set/get first value did not match"); \
res = 0; \
} \
} else { \
if (DUP && val1_read == val1) { \
TEST_error("first set did not dup the value"); \
val1_read = 0; \
res = 0; \
} \
if (DEFAULT(val1_read)) { \
TEST_error("first set had no effect"); \
res = 0; \
} \
} \
\
if (!(*set_fn)(ctx, val2)) { \
TEST_error("setting second value failed"); \
res = 0; \
} \
if (SETN == 0) \
val2_to_free = 0; \
\
val2_read = (*get_fn)(ctx); \
if (DEFAULT(val2_read)) { \
TEST_error("second set reset the value"); \
res = 0; \
} \
if (SETN == 0 && GETN == 0) { \
if (val2_read != val2) { \
TEST_error("set/get second value did not match"); \
res = 0; \
} \
} else { \
if (DUP && val2_read == val2) { \
TEST_error("second set did not dup the value"); \
val2_read = 0; \
res = 0; \
} \
if (val2 == val1) { \
TEST_error("second value is same as first value"); \
res = 0; \
} \
if (GETN == 1 && val2_read == val1_read) { \
/* \
* Note that if GETN == 0 then possibly val2_read == val1_read \
* because set1 may allocate the new copy at the same location. \
*/ \
TEST_error("second get returned same as first get"); \
res = 0; \
} \
} \
\
val3_read = (*get_fn)(ctx); \
if (DEFAULT(val3_read)) { \
TEST_error("third set reset the value"); \
res = 0; \
} \
if (GETN == 0) { \
if (val3_read != val2_read) { \
TEST_error("third get gave different value"); \
res = 0; \
} \
} else { \
if (DUP && val3_read == val2_read) { \
TEST_error("third get did not create a new dup"); \
val3_read = 0; \
res = 0; \
} \
} \
/* this does not check that all remaining fields are untouched */ \
\
if (!TEST_int_eq(ERR_peek_error(), 0)) \
res = 0; \
\
FREE(val1_to_free); \
FREE(val2_to_free); \
if (GETN == 1) { \
FREE(val1_read); \
FREE(val2_read); \
FREE(val3_read); \
} \
return TEST_true(res); \
} \
\
static int test_CTX_##SETN##_##GETN##_##FIELD(void) \
{ \
SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up); \
EXECUTE_TEST(execute_CTX_##SETN##_##GETN##_##FIELD, tear_down); \
return result; \
}
static char *char_new(void)
{
return OPENSSL_strdup("test");
}
static void char_free(char *val)
{
OPENSSL_free(val);
}
#define EMPTY_SK_X509(x) ((x) == NULL || sk_X509_num(x) == 0)
static X509_STORE *X509_STORE_new_1(void)
{
X509_STORE *store = X509_STORE_new();
if (store != NULL)
X509_VERIFY_PARAM_set_flags(X509_STORE_get0_param(store), 1);
return store;
}
#define DEFAULT_STORE(x) \
((x) == NULL || X509_VERIFY_PARAM_get_flags(X509_STORE_get0_param(x)) == 0)
#define IS_NEG(x) ((x) < 0)
#define IS_0(x) ((x) == 0) /* for any type */
#define DROP(x) (void)(x) /* dummy free() for non-pointer and function types */
#define RET_IF_NULL_ARG(ctx, ret) \
if (ctx == NULL) { \
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT); \
return ret; \
}
/* cannot use PREFIX instead of OSSL_CMP and CTX due to #define OSSL_CMP_CTX */
#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, \
TYPE *, NULL, IS_0, TYPE##_new(), TYPE##_free)
#define DEFINE_SET_GET_SK_TEST_DEFAULT(OSSL_CMP, CTX, N, M, FIELD, ELEM_TYPE, \
DEFAULT, NEW, FREE) \
DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set##N, get##M, 1, FIELD, \
STACK_OF(ELEM_TYPE)*, NULL, DEFAULT, NEW, FREE)
#define DEFINE_SET_GET_SK_TEST(OSSL_CMP, CTX, N, M, FIELD, T) \
DEFINE_SET_GET_SK_TEST_DEFAULT(OSSL_CMP, CTX, N, M, FIELD, T, \
IS_0, sk_##T##_new_null(), sk_##T##_free)
#define DEFINE_SET_GET_SK_X509_TEST(OSSL_CMP, CTX, N, M, FNAME) \
DEFINE_SET_GET_SK_TEST_DEFAULT(OSSL_CMP, CTX, N, M, FNAME, X509, \
EMPTY_SK_X509, \
sk_X509_new_1(), sk_X509_pop_X509_free)
#define DEFINE_SET_GET_TEST_DEFAULT(OSSL_CMP, CTX, N, M, DUP, FIELD, TYPE, \
DEFAULT) \
DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set##N, get##M, DUP, FIELD, \
TYPE *, NULL, DEFAULT, TYPE##_new(), TYPE##_free)
#define DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, N, DUP, FIELD, TYPE, DEFAULT) \
static TYPE *OSSL_CMP_CTX_get0_##FIELD(const CMP_CTX *ctx) \
{ \
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) \
DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, N, DUP, FIELD, TYPE, IS_0)
#define DEFINE_SET_SK_TEST(OSSL_CMP, CTX, N, FIELD, TYPE) \
static STACK_OF(TYPE) *OSSL_CMP_CTX_get0_##FIELD(const CMP_CTX *ctx) \
{ \
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, \
sk_##TYPE##_new_null(), sk_##TYPE##_free)
#ifndef OPENSSL_NO_HTTP
typedef OSSL_HTTP_bio_cb_t OSSL_CMP_http_cb_t;
#endif
#define DEFINE_SET_CB_TEST(FIELD) \
static OSSL_CMP_##FIELD##_t OSSL_CMP_CTX_get_##FIELD(const CMP_CTX *ctx) \
{ \
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, \
test_##FIELD, DROP)
#define DEFINE_SET_GET_P_VOID_TEST(FIELD) \
DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, FIELD, void *, \
NULL, IS_0, ((void *)1), DROP)
#define DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, DEFAULT) \
DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set, get, 0, FIELD, int, -1, \
DEFAULT, 1, DROP)
#define DEFINE_SET_GET_INT_TEST(OSSL_CMP, CTX, FIELD) \
DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, IS_NEG)
#define DEFINE_SET_INT_TEST(FIELD) \
static int OSSL_CMP_CTX_get_##FIELD(const CMP_CTX *ctx) \
{ \
RET_IF_NULL_ARG(ctx, -1); \
return ctx->FIELD; \
} \
DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, IS_0)
#define DEFINE_SET_GET_ARG_FN(SETN, GETN, FIELD, ARG, T) \
static int OSSL_CMP_CTX_##SETN##_##FIELD##_##ARG(CMP_CTX *ctx, T val) \
{ \
return OSSL_CMP_CTX_##SETN##_##FIELD(ctx, ARG, val); \
} \
\
static T OSSL_CMP_CTX_##GETN##_##FIELD##_##ARG(const CMP_CTX *ctx) \
{ \
return OSSL_CMP_CTX_##GETN##_##FIELD(ctx, ARG); \
}
#define DEFINE_SET_GET1_STR_FN(SETN, FIELD) \
static int OSSL_CMP_CTX_##SETN##_##FIELD##_str(CMP_CTX *ctx, char *val)\
{ \
return OSSL_CMP_CTX_##SETN##_##FIELD(ctx, (unsigned char *)val, \
strlen(val)); \
} \
\
static char *OSSL_CMP_CTX_get1_##FIELD##_str(const CMP_CTX *ctx) \
{ \
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); \
}
#define push 0
#define push0 0
#define push1 1
#define DEFINE_PUSH_BASE_TEST(PUSHN, DUP, FIELD, ELEM, TYPE, T, \
DEFAULT, NEW, FREE) \
static TYPE sk_top_##FIELD(const CMP_CTX *ctx) \
{ \
return sk_##T##_value(ctx->FIELD, sk_##T##_num(ctx->FIELD) - 1); \
} \
\
static int execute_CTX_##PUSHN##_##ELEM(OSSL_CMP_CTX_TEST_FIXTURE *fixture) \
{ \
CMP_CTX *ctx = fixture->ctx; \
int (*push_fn)(CMP_CTX *ctx, TYPE) = \
(int (*)(CMP_CTX *ctx, TYPE))OSSL_CMP_CTX_##PUSHN##_##ELEM; \
/* \
* need type cast in above assignment because TYPE arg sometimes is const \
*/ \
int n_elem = sk_##T##_num(ctx->FIELD); \
STACK_OF(TYPE) field_read; \
TYPE val1_to_free = NEW; \
TYPE val1 = val1_to_free; \
TYPE val1_read = 0; /* 0 works for any type */ \
TYPE val2_to_free = NEW; \
TYPE val2 = val2_to_free; \
TYPE val2_read = 0; \
int res = 1; \
\
if (!TEST_int_eq(ERR_peek_error(), 0)) \
res = 0; \
if ((*push_fn)(NULL, val1) || ERR_peek_error() == 0) { \
TEST_error("pusher did not return error on ctx == NULL"); \
res = 0; \
} \
ERR_clear_error(); \
\
if (n_elem < 0) /* can happen for NULL stack */ \
n_elem = 0; \
field_read = ctx->FIELD; \
if (!DEFAULT(field_read)) { \
TEST_error("did not get default value for stack field"); \
res = 0; \
} \
if (!(*push_fn)(ctx, val1)) { \
TEST_error("pushing first value failed"); \
res = 0; \
} \
if (PUSHN == 0) \
val1_to_free = 0; /* 0 works for any type */ \
\
if (sk_##T##_num(ctx->FIELD) != ++n_elem) { \
TEST_error("pushing first value did not increment number"); \
res = 0; \
} \
val1_read = sk_top_##FIELD(ctx); \
if (PUSHN == 0) { \
if (val1_read != val1) { \
TEST_error("push/sk_top first value did not match"); \
res = 0; \
} \
} else { \
if (DUP && val1_read == val1) { \
TEST_error("first push did not dup the value"); \
res = 0; \
} \
} \
\
if (!(*push_fn)(ctx, val2)) { \
TEST_error("pushing second value failed"); \
res = 0; \
} \
if (PUSHN == 0) \
val2_to_free = 0; \
\
if (sk_##T##_num(ctx->FIELD) != ++n_elem) { \
TEST_error("pushing second value did not increment number"); \
res = 0; \
} \
val2_read = sk_top_##FIELD(ctx); \
if (PUSHN == 0) { \
if (val2_read != val2) { \
TEST_error("push/sk_top second value did not match"); \
res = 0; \
} \
} else { \
if (DUP && val2_read == val2) { \
TEST_error("second push did not dup the value"); \
res = 0; \
} \
if (val2 == val1) { \
TEST_error("second value is same as first value"); \
res = 0; \
} \
} \
/* this does not check if all remaining fields and elems are untouched */ \
\
if (!TEST_int_eq(ERR_peek_error(), 0)) \
res = 0; \
\
FREE(val1_to_free); \
FREE(val2_to_free); \
return TEST_true(res); \
} \
\
static int test_CTX_##PUSHN##_##ELEM(void) \
{ \
SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up); \
EXECUTE_TEST(execute_CTX_##PUSHN##_##ELEM, tear_down); \
return result; \
} \
#define DEFINE_PUSH_TEST(N, DUP, FIELD, ELEM, TYPE) \
DEFINE_PUSH_BASE_TEST(push##N, DUP, FIELD, ELEM, TYPE *, TYPE, \
IS_0, TYPE##_new(), TYPE##_free)
void cleanup_tests(void)
{
return;
}
DEFINE_SET_GET_ARG_FN(set, get, option, 35, int) /* OPT_IGNORE_KEYUSAGE */
DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, option_35, int, -1, IS_0, \
1 /* true */, DROP)
DEFINE_SET_CB_TEST(log_cb)
DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, 1, 1, serverPath, char, IS_0)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, server, char)
DEFINE_SET_INT_TEST(serverPort)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, proxy, char)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, no_proxy, char)
#ifndef OPENSSL_NO_HTTP
DEFINE_SET_CB_TEST(http_cb)
DEFINE_SET_GET_P_VOID_TEST(http_cb_arg)
#endif
DEFINE_SET_CB_TEST(transfer_cb)
DEFINE_SET_GET_P_VOID_TEST(transfer_cb_arg)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 0, srvCert, X509)
DEFINE_SET_GET_TEST(ossl_cmp, ctx, 1, 0, 0, validatedSrvCert, X509)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, expected_sender, X509_NAME)
DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set0, get0, 0, trusted,
X509_STORE *, NULL,
DEFAULT_STORE, X509_STORE_new_1(), X509_STORE_free)
DEFINE_SET_GET_SK_X509_TEST(OSSL_CMP, CTX, 1, 0, untrusted)
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)
DEFINE_PUSH_TEST(0, 0, geninfo_ITAVs, geninfo_ITAV, OSSL_CMP_ITAV)
DEFINE_SET_SK_TEST(OSSL_CMP, CTX, 1, extraCertsOut, X509)
DEFINE_SET_GET_ARG_FN(set0, get0, newPkey, 1, EVP_PKEY *) /* priv == 1 */
DEFINE_SET_GET_TEST(OSSL_CMP, CTX, 0, 0, 0, newPkey_1, EVP_PKEY)
DEFINE_SET_GET_ARG_FN(set0, get0, newPkey, 0, EVP_PKEY *) /* priv == 0 */
DEFINE_SET_GET_TEST(OSSL_CMP, CTX, 0, 0, 0, newPkey_0, EVP_PKEY)
DEFINE_SET_GET1_STR_FN(set1, referenceValue)
DEFINE_SET_GET_TEST_DEFAULT(OSSL_CMP, CTX, 1, 1, 1, referenceValue_str, char,
IS_0)
DEFINE_SET_GET1_STR_FN(set1, secretValue)
DEFINE_SET_GET_TEST_DEFAULT(OSSL_CMP, CTX, 1, 1, 1, secretValue_str, char, IS_0)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, issuer, X509_NAME)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, subjectName, X509_NAME)
#ifdef ISSUE_9504_RESOLVED
DEFINE_PUSH_TEST(1, 1, subjectAltNames, subjectAltName, GENERAL_NAME)
#endif
DEFINE_SET_SK_TEST(OSSL_CMP, CTX, 0, reqExtensions, X509_EXTENSION)
DEFINE_PUSH_TEST(0, 0, policies, policy, POLICYINFO)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 0, oldCert, X509)
#ifdef ISSUE_9504_RESOLVED
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, p10CSR, X509_REQ)
#endif
DEFINE_PUSH_TEST(0, 0, genm_ITAVs, genm_ITAV, OSSL_CMP_ITAV)
DEFINE_SET_CB_TEST(certConf_cb)
DEFINE_SET_GET_P_VOID_TEST(certConf_cb_arg)
DEFINE_SET_GET_INT_TEST(ossl_cmp, ctx, status)
DEFINE_SET_GET_SK_TEST(ossl_cmp, ctx, 0, 0, statusString, ASN1_UTF8STRING)
DEFINE_SET_GET_INT_TEST(ossl_cmp, ctx, failInfoCode)
DEFINE_SET_GET_TEST(ossl_cmp, ctx, 0, 0, 0, newCert, X509)
DEFINE_SET_GET_SK_X509_TEST(ossl_cmp, ctx, 1, 1, newChain)
DEFINE_SET_GET_SK_X509_TEST(ossl_cmp, ctx, 1, 1, caPubs)
DEFINE_SET_GET_SK_X509_TEST(ossl_cmp, ctx, 1, 1, extraCertsIn)
DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, 1, 1, transactionID, ASN1_OCTET_STRING,
IS_0)
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, senderNonce, ASN1_OCTET_STRING)
DEFINE_SET_TEST(ossl_cmp, ctx, 1, 1, recipNonce, ASN1_OCTET_STRING)
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
/* also tests OSSL_CMP_CTX_new() and OSSL_CMP_CTX_free(): */
ADD_TEST(test_CTX_libctx_propq);
ADD_TEST(test_CTX_reinit);
/* various CMP options: */
ADD_TEST(test_CTX_set_get_option_35);
/* CMP-specific callback for logging and outputting the error queue: */
ADD_TEST(test_CTX_set_get_log_cb);
/*
* also tests OSSL_CMP_log_open(), OSSL_CMP_CTX_set_log_verbosity(),
* ossl_cmp_err(), ossl_cmp_warn(), * ossl_cmp_debug(),
* ossl_cmp_log2(), ossl_cmp_log_parse_metadata(), and OSSL_CMP_log_close()
* with OSSL_CMP_severity OSSL_CMP_LOG_ERR/WARNING/DEBUG/INFO:
*/
ADD_TEST(test_cmp_ctx_log_cb);
#if !defined(OPENSSL_NO_ERR) && !defined(OPENSSL_NO_AUTOERRINIT)
/*
* also tests OSSL_CMP_CTX_set_log_cb(), OSSL_CMP_print_errors_cb(),
* and the macros ossl_cmp_add_error_data and ossl_cmp_add_error_line:
*/
ADD_TEST(test_CTX_print_errors);
#endif
/* message transfer: */
ADD_TEST(test_CTX_set1_get0_serverPath);
ADD_TEST(test_CTX_set1_get0_server);
ADD_TEST(test_CTX_set_get_serverPort);
ADD_TEST(test_CTX_set1_get0_proxy);
ADD_TEST(test_CTX_set1_get0_no_proxy);
#ifndef OPENSSL_NO_HTTP
ADD_TEST(test_CTX_set_get_http_cb);
ADD_TEST(test_CTX_set_get_http_cb_arg);
#endif
ADD_TEST(test_CTX_set_get_transfer_cb);
ADD_TEST(test_CTX_set_get_transfer_cb_arg);
/* server authentication: */
ADD_TEST(test_CTX_set1_get0_srvCert);
ADD_TEST(test_CTX_set1_get0_validatedSrvCert);
ADD_TEST(test_CTX_set1_get0_expected_sender);
ADD_TEST(test_CTX_set0_get0_trusted);
ADD_TEST(test_CTX_set1_get0_untrusted);
/* client authentication: */
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);
ADD_TEST(test_CTX_set1_get1_secretValue_str);
/* CMP message header and extra certificates: */
ADD_TEST(test_CTX_set1_get0_recipient);
ADD_TEST(test_CTX_push0_geninfo_ITAV);
ADD_TEST(test_CTX_set1_get0_extraCertsOut);
/* certificate template: */
ADD_TEST(test_CTX_set0_get0_newPkey_1);
ADD_TEST(test_CTX_set0_get0_newPkey_0);
ADD_TEST(test_CTX_set1_get0_issuer);
ADD_TEST(test_CTX_set1_get0_subjectName);
#ifdef ISSUE_9504_RESOLVED
/*
* test currently fails, see https://github.com/openssl/openssl/issues/9504
*/
ADD_TEST(test_CTX_push1_subjectAltName);
#endif
ADD_TEST(test_CTX_set0_get0_reqExtensions);
ADD_TEST(test_CTX_reqExtensions_have_SAN);
ADD_TEST(test_CTX_push0_policy);
ADD_TEST(test_CTX_set1_get0_oldCert);
#ifdef ISSUE_9504_RESOLVED
/*
* test currently fails, see https://github.com/openssl/openssl/issues/9504
*/
ADD_TEST(test_CTX_set1_get0_p10CSR);
#endif
/* misc body contents: */
ADD_TEST(test_CTX_push0_genm_ITAV);
/* certificate confirmation: */
ADD_TEST(test_CTX_set_get_certConf_cb);
ADD_TEST(test_CTX_set_get_certConf_cb_arg);
/* result fetching: */
ADD_TEST(test_CTX_set_get_status);
ADD_TEST(test_CTX_set0_get0_statusString);
ADD_TEST(test_CTX_set_get_failInfoCode);
ADD_TEST(test_CTX_set0_get0_newCert);
ADD_TEST(test_CTX_set1_get1_newChain);
ADD_TEST(test_CTX_set1_get1_caPubs);
ADD_TEST(test_CTX_set1_get1_extraCertsIn);
/* exported for testing and debugging purposes: */
/* the following three also test ossl_cmp_asn1_octet_string_set1(): */
ADD_TEST(test_CTX_set1_get0_transactionID);
ADD_TEST(test_CTX_set1_get0_senderNonce);
ADD_TEST(test_CTX_set1_get0_recipNonce);
return 1;
}
|
./openssl/test/trace_api_test.c | /*
* Copyright 2022-2023 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 <openssl/trace.h>
#include "testutil.h"
static int test_trace_categories(void)
{
int cat_num;
for (cat_num = -1; cat_num <= OSSL_TRACE_CATEGORY_NUM + 1; ++cat_num) {
const char *cat_name = OSSL_trace_get_category_name(cat_num);
int is_cat_name_eq = 0;
int ret_cat_num;
int expected_ret;
switch (cat_num) {
#define CASE(name) \
case OSSL_TRACE_CATEGORY_##name: \
is_cat_name_eq = TEST_str_eq(cat_name, #name); \
break
CASE(ALL);
CASE(TRACE);
CASE(INIT);
CASE(TLS);
CASE(TLS_CIPHER);
CASE(CONF);
CASE(ENGINE_TABLE);
CASE(ENGINE_REF_COUNT);
CASE(PKCS5V2);
CASE(PKCS12_KEYGEN);
CASE(PKCS12_DECRYPT);
CASE(X509V3_POLICY);
CASE(BN_CTX);
CASE(CMP);
CASE(STORE);
CASE(DECODER);
CASE(ENCODER);
CASE(REF_COUNT);
CASE(HTTP);
#undef CASE
default:
is_cat_name_eq = TEST_ptr_null(cat_name);
break;
}
if (!TEST_true(is_cat_name_eq))
return 0;
ret_cat_num =
OSSL_trace_get_category_num(cat_name);
expected_ret = cat_name != NULL ? cat_num : -1;
if (!TEST_int_eq(expected_ret, ret_cat_num))
return 0;
}
return 1;
}
#ifndef OPENSSL_NO_TRACE
# define OSSL_START "xyz-"
# define OSSL_HELLO "Hello World\n"
/* OSSL_STR80 must have length OSSL_TRACE_STRING_MAX */
# define OSSL_STR80 "1234567890123456789012345678901234567890123456789012345678901234567890123456789\n"
# define OSSL_STR81 (OSSL_STR80"x")
# define OSSL_CTRL "A\xfe\nB"
# define OSSL_MASKED "A \nB"
# define OSSL_BYE "Good Bye Universe\n"
# define OSSL_END "-abc"
# define trace_string(text, full, str) \
OSSL_trace_string(trc_out, text, full, (unsigned char *)(str), strlen(str))
static int put_trace_output(void)
{
int res = 1;
OSSL_TRACE_BEGIN(HTTP) {
res = TEST_int_eq(BIO_printf(trc_out, OSSL_HELLO), strlen(OSSL_HELLO));
res += TEST_int_eq(trace_string(0, 0, OSSL_STR80), strlen(OSSL_STR80));
res += TEST_int_eq(trace_string(0, 0, OSSL_STR81), strlen(OSSL_STR80));
res += TEST_int_eq(trace_string(1, 1, OSSL_CTRL), strlen(OSSL_CTRL));
res += TEST_int_eq(trace_string(0, 1, OSSL_MASKED), strlen(OSSL_MASKED)
+ 1); /* newline added */
res += TEST_int_eq(BIO_printf(trc_out, OSSL_BYE), strlen(OSSL_BYE));
res = res == 6;
/* not using '&&' but '+' to catch potentially multiple test failures */
} OSSL_TRACE_END(HTTP);
return res;
}
static int test_trace_channel(void)
{
static const char expected[] =
OSSL_START"\n" OSSL_HELLO
OSSL_STR80 "[len 81 limited to 80]: "OSSL_STR80
OSSL_CTRL OSSL_MASKED"\n" OSSL_BYE OSSL_END"\n";
static const size_t expected_len = sizeof(expected) - 1;
BIO *bio = NULL;
char *p_buf = NULL;
long len = 0;
int ret = 0;
bio = BIO_new(BIO_s_mem());
if (!TEST_ptr(bio))
goto end;
if (!TEST_int_eq(OSSL_trace_set_channel(OSSL_TRACE_CATEGORY_HTTP, bio), 1)) {
BIO_free(bio);
goto end;
}
if (!TEST_true(OSSL_trace_enabled(OSSL_TRACE_CATEGORY_HTTP)))
goto end;
if (!TEST_int_eq(OSSL_trace_set_prefix(OSSL_TRACE_CATEGORY_HTTP,
OSSL_START), 1))
goto end;
if (!TEST_int_eq(OSSL_trace_set_suffix(OSSL_TRACE_CATEGORY_HTTP,
OSSL_END), 1))
goto end;
ret = put_trace_output();
len = BIO_get_mem_data(bio, &p_buf);
if (!TEST_strn2_eq(p_buf, len, expected, expected_len))
ret = 0;
ret = TEST_int_eq(OSSL_trace_set_channel(OSSL_TRACE_CATEGORY_HTTP, NULL), 1)
&& ret;
end:
return ret;
}
static int trace_cb_failure;
static int trace_cb_called;
static size_t trace_cb(const char *buffer, size_t count,
int category, int cmd, void *data)
{
trace_cb_called = 1;
if (!TEST_true(category == OSSL_TRACE_CATEGORY_TRACE))
trace_cb_failure = 1;
return count;
}
static int test_trace_callback(void)
{
int ret = 0;
if (!TEST_true(OSSL_trace_set_callback(OSSL_TRACE_CATEGORY_TRACE, trace_cb,
NULL)))
goto end;
put_trace_output();
if (!TEST_false(trace_cb_failure) || !TEST_true(trace_cb_called))
goto end;
ret = 1;
end:
return ret;
}
#endif
OPT_TEST_DECLARE_USAGE("\n")
int setup_tests(void)
{
if (!test_skip_common_options()) {
TEST_error("Error parsing test options\n");
return 0;
}
ADD_TEST(test_trace_categories);
#ifndef OPENSSL_NO_TRACE
ADD_TEST(test_trace_channel);
ADD_TEST(test_trace_callback);
#endif
return 1;
}
void cleanup_tests(void)
{
}
|
./openssl/test/sanitytest.c | /*
* Copyright 2015-2023 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 <string.h>
#include <openssl/types.h>
#include "testutil.h"
#include "internal/numbers.h"
#include "internal/time.h"
static int test_sanity_null_zero(void)
{
char *p;
char bytes[sizeof(p)];
/* Is NULL equivalent to all-bytes-zero? */
p = NULL;
memset(bytes, 0, sizeof(bytes));
return TEST_mem_eq(&p, sizeof(p), bytes, sizeof(bytes));
}
static int test_sanity_enum_size(void)
{
enum smallchoices { sa, sb, sc };
enum medchoices { ma, mb, mc, md, me, mf, mg, mh, mi, mj, mk, ml };
enum largechoices {
a01, b01, c01, d01, e01, f01, g01, h01, i01, j01,
a02, b02, c02, d02, e02, f02, g02, h02, i02, j02,
a03, b03, c03, d03, e03, f03, g03, h03, i03, j03,
a04, b04, c04, d04, e04, f04, g04, h04, i04, j04,
a05, b05, c05, d05, e05, f05, g05, h05, i05, j05,
a06, b06, c06, d06, e06, f06, g06, h06, i06, j06,
a07, b07, c07, d07, e07, f07, g07, h07, i07, j07,
a08, b08, c08, d08, e08, f08, g08, h08, i08, j08,
a09, b09, c09, d09, e09, f09, g09, h09, i09, j09,
a10, b10, c10, d10, e10, f10, g10, h10, i10, j10,
xxx };
/* Enum size */
if (!TEST_size_t_eq(sizeof(enum smallchoices), sizeof(int))
|| !TEST_size_t_eq(sizeof(enum medchoices), sizeof(int))
|| !TEST_size_t_eq(sizeof(enum largechoices), sizeof(int)))
return 0;
return 1;
}
static int test_sanity_twos_complement(void)
{
/* Basic two's complement checks. */
if (!TEST_int_eq(~(-1), 0)
|| !TEST_long_eq(~(-1L), 0L))
return 0;
return 1;
}
static int test_sanity_sign(void)
{
/* Check that values with sign bit 1 and value bits 0 are valid */
if (!TEST_int_eq(-(INT_MIN + 1), INT_MAX)
|| !TEST_long_eq(-(LONG_MIN + 1), LONG_MAX))
return 0;
return 1;
}
static int test_sanity_unsigned_conversion(void)
{
/* Check that unsigned-to-signed conversions preserve bit patterns */
if (!TEST_int_eq((int)((unsigned int)INT_MAX + 1), INT_MIN)
|| !TEST_long_eq((long)((unsigned long)LONG_MAX + 1), LONG_MIN))
return 0;
return 1;
}
static int test_sanity_range(void)
{
/* Verify some types are the correct size */
if (!TEST_size_t_eq(sizeof(int8_t), 1)
|| !TEST_size_t_eq(sizeof(uint8_t), 1)
|| !TEST_size_t_eq(sizeof(int16_t), 2)
|| !TEST_size_t_eq(sizeof(uint16_t), 2)
|| !TEST_size_t_eq(sizeof(int32_t), 4)
|| !TEST_size_t_eq(sizeof(uint32_t), 4)
|| !TEST_size_t_eq(sizeof(int64_t), 8)
|| !TEST_size_t_eq(sizeof(uint64_t), 8)
#ifdef UINT128_MAX
|| !TEST_size_t_eq(sizeof(int128_t), 16)
|| !TEST_size_t_eq(sizeof(uint128_t), 16)
#endif
|| !TEST_size_t_eq(sizeof(char), 1)
|| !TEST_size_t_eq(sizeof(unsigned char), 1))
return 0;
/* We want our long longs to be at least 64 bits */
if (!TEST_size_t_ge(sizeof(long long int), 8)
|| !TEST_size_t_ge(sizeof(unsigned long long int), 8))
return 0;
/*
* Verify intmax_t.
* Some platforms defined intmax_t to be 64 bits but still support
* an int128_t, so this check is for at least 64 bits.
*/
if (!TEST_size_t_ge(sizeof(ossl_intmax_t), 8)
|| !TEST_size_t_ge(sizeof(ossl_uintmax_t), 8)
|| !TEST_size_t_ge(sizeof(ossl_uintmax_t), sizeof(size_t)))
return 0;
/* This isn't possible to check using the framework functions */
if (SIZE_MAX < INT_MAX) {
TEST_error("int must not be wider than size_t");
return 0;
}
/* SIZE_MAX is always greater than 2*INT_MAX */
if (SIZE_MAX - INT_MAX <= INT_MAX) {
TEST_error("SIZE_MAX must exceed 2*INT_MAX");
return 0;
}
return 1;
}
static int test_sanity_memcmp(void)
{
return CRYPTO_memcmp("ab", "cd", 2);
}
static int test_sanity_sleep(void)
{
OSSL_TIME start = ossl_time_now();
uint64_t seconds;
/*
* On any reasonable system this must sleep at least one second
* but not more than 20.
* Assuming there is no interruption.
*/
OSSL_sleep(1000);
seconds = ossl_time2seconds(ossl_time_subtract(ossl_time_now(), start));
if (!TEST_uint64_t_ge(seconds, 1) || !TEST_uint64_t_le(seconds, 20))
return 0;
return 1;
}
int setup_tests(void)
{
ADD_TEST(test_sanity_null_zero);
ADD_TEST(test_sanity_enum_size);
ADD_TEST(test_sanity_twos_complement);
ADD_TEST(test_sanity_sign);
ADD_TEST(test_sanity_unsigned_conversion);
ADD_TEST(test_sanity_range);
ADD_TEST(test_sanity_memcmp);
ADD_TEST(test_sanity_sleep);
return 1;
}
|
./openssl/test/siphash_internal_test.c | /*
* Copyright 2016-2022 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
*/
/* Internal tests for the siphash module */
#include <stdio.h>
#include <string.h>
#include <openssl/bio.h>
#include "testutil.h"
#include "crypto/siphash.h"
#include "internal/nelem.h"
typedef struct {
size_t size;
unsigned char data[64];
} SIZED_DATA;
typedef struct {
int idx;
SIZED_DATA expected;
} TESTDATA;
/**********************************************************************
*
* Test of siphash internal functions
*
***/
/* From C reference: https://131002.net/siphash/ */
static TESTDATA tests[] = {
{ 0, { 8, { 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, } } },
{ 1, { 8, { 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, } } },
{ 2, { 8, { 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, } } },
{ 3, { 8, { 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, } } },
{ 4, { 8, { 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, } } },
{ 5, { 8, { 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, } } },
{ 6, { 8, { 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, } } },
{ 7, { 8, { 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, } } },
{ 8, { 8, { 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, } } },
{ 9, { 8, { 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, } } },
{ 10, { 8, { 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, } } },
{ 11, { 8, { 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, } } },
{ 12, { 8, { 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, } } },
{ 13, { 8, { 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, } } },
{ 14, { 8, { 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, } } },
{ 15, { 8, { 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, } } },
{ 16, { 8, { 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, } } },
{ 17, { 8, { 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, } } },
{ 18, { 8, { 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, } } },
{ 19, { 8, { 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, } } },
{ 20, { 8, { 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, } } },
{ 21, { 8, { 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, } } },
{ 22, { 8, { 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, } } },
{ 23, { 8, { 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, } } },
{ 24, { 8, { 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, } } },
{ 25, { 8, { 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, } } },
{ 26, { 8, { 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, } } },
{ 27, { 8, { 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, } } },
{ 28, { 8, { 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, } } },
{ 29, { 8, { 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, } } },
{ 30, { 8, { 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, } } },
{ 31, { 8, { 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, } } },
{ 32, { 8, { 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, } } },
{ 33, { 8, { 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, } } },
{ 34, { 8, { 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, } } },
{ 35, { 8, { 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, } } },
{ 36, { 8, { 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, } } },
{ 37, { 8, { 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, } } },
{ 38, { 8, { 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, } } },
{ 39, { 8, { 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, } } },
{ 40, { 8, { 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, } } },
{ 41, { 8, { 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, } } },
{ 42, { 8, { 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, } } },
{ 43, { 8, { 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, } } },
{ 44, { 8, { 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, } } },
{ 45, { 8, { 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, } } },
{ 46, { 8, { 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, } } },
{ 47, { 8, { 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, } } },
{ 48, { 8, { 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, } } },
{ 49, { 8, { 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, } } },
{ 50, { 8, { 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, } } },
{ 51, { 8, { 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, } } },
{ 52, { 8, { 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, } } },
{ 53, { 8, { 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, } } },
{ 54, { 8, { 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, } } },
{ 55, { 8, { 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, } } },
{ 56, { 8, { 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, } } },
{ 57, { 8, { 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, } } },
{ 58, { 8, { 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, } } },
{ 59, { 8, { 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, } } },
{ 60, { 8, { 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, } } },
{ 61, { 8, { 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, } } },
{ 62, { 8, { 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, } } },
{ 63, { 8, { 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, } } },
{ 0, { 16, { 0xa3, 0x81, 0x7f, 0x04, 0xba, 0x25, 0xa8, 0xe6, 0x6d, 0xf6, 0x72, 0x14, 0xc7, 0x55, 0x02, 0x93, } } },
{ 1, { 16, { 0xda, 0x87, 0xc1, 0xd8, 0x6b, 0x99, 0xaf, 0x44, 0x34, 0x76, 0x59, 0x11, 0x9b, 0x22, 0xfc, 0x45, } } },
{ 2, { 16, { 0x81, 0x77, 0x22, 0x8d, 0xa4, 0xa4, 0x5d, 0xc7, 0xfc, 0xa3, 0x8b, 0xde, 0xf6, 0x0a, 0xff, 0xe4, } } },
{ 3, { 16, { 0x9c, 0x70, 0xb6, 0x0c, 0x52, 0x67, 0xa9, 0x4e, 0x5f, 0x33, 0xb6, 0xb0, 0x29, 0x85, 0xed, 0x51, } } },
{ 4, { 16, { 0xf8, 0x81, 0x64, 0xc1, 0x2d, 0x9c, 0x8f, 0xaf, 0x7d, 0x0f, 0x6e, 0x7c, 0x7b, 0xcd, 0x55, 0x79, } } },
{ 5, { 16, { 0x13, 0x68, 0x87, 0x59, 0x80, 0x77, 0x6f, 0x88, 0x54, 0x52, 0x7a, 0x07, 0x69, 0x0e, 0x96, 0x27, } } },
{ 6, { 16, { 0x14, 0xee, 0xca, 0x33, 0x8b, 0x20, 0x86, 0x13, 0x48, 0x5e, 0xa0, 0x30, 0x8f, 0xd7, 0xa1, 0x5e, } } },
{ 7, { 16, { 0xa1, 0xf1, 0xeb, 0xbe, 0xd8, 0xdb, 0xc1, 0x53, 0xc0, 0xb8, 0x4a, 0xa6, 0x1f, 0xf0, 0x82, 0x39, } } },
{ 8, { 16, { 0x3b, 0x62, 0xa9, 0xba, 0x62, 0x58, 0xf5, 0x61, 0x0f, 0x83, 0xe2, 0x64, 0xf3, 0x14, 0x97, 0xb4, } } },
{ 9, { 16, { 0x26, 0x44, 0x99, 0x06, 0x0a, 0xd9, 0xba, 0xab, 0xc4, 0x7f, 0x8b, 0x02, 0xbb, 0x6d, 0x71, 0xed, } } },
{ 10, { 16, { 0x00, 0x11, 0x0d, 0xc3, 0x78, 0x14, 0x69, 0x56, 0xc9, 0x54, 0x47, 0xd3, 0xf3, 0xd0, 0xfb, 0xba, } } },
{ 11, { 16, { 0x01, 0x51, 0xc5, 0x68, 0x38, 0x6b, 0x66, 0x77, 0xa2, 0xb4, 0xdc, 0x6f, 0x81, 0xe5, 0xdc, 0x18, } } },
{ 12, { 16, { 0xd6, 0x26, 0xb2, 0x66, 0x90, 0x5e, 0xf3, 0x58, 0x82, 0x63, 0x4d, 0xf6, 0x85, 0x32, 0xc1, 0x25, } } },
{ 13, { 16, { 0x98, 0x69, 0xe2, 0x47, 0xe9, 0xc0, 0x8b, 0x10, 0xd0, 0x29, 0x93, 0x4f, 0xc4, 0xb9, 0x52, 0xf7, } } },
{ 14, { 16, { 0x31, 0xfc, 0xef, 0xac, 0x66, 0xd7, 0xde, 0x9c, 0x7e, 0xc7, 0x48, 0x5f, 0xe4, 0x49, 0x49, 0x02, } } },
{ 15, { 16, { 0x54, 0x93, 0xe9, 0x99, 0x33, 0xb0, 0xa8, 0x11, 0x7e, 0x08, 0xec, 0x0f, 0x97, 0xcf, 0xc3, 0xd9, } } },
{ 16, { 16, { 0x6e, 0xe2, 0xa4, 0xca, 0x67, 0xb0, 0x54, 0xbb, 0xfd, 0x33, 0x15, 0xbf, 0x85, 0x23, 0x05, 0x77, } } },
{ 17, { 16, { 0x47, 0x3d, 0x06, 0xe8, 0x73, 0x8d, 0xb8, 0x98, 0x54, 0xc0, 0x66, 0xc4, 0x7a, 0xe4, 0x77, 0x40, } } },
{ 18, { 16, { 0xa4, 0x26, 0xe5, 0xe4, 0x23, 0xbf, 0x48, 0x85, 0x29, 0x4d, 0xa4, 0x81, 0xfe, 0xae, 0xf7, 0x23, } } },
{ 19, { 16, { 0x78, 0x01, 0x77, 0x31, 0xcf, 0x65, 0xfa, 0xb0, 0x74, 0xd5, 0x20, 0x89, 0x52, 0x51, 0x2e, 0xb1, } } },
{ 20, { 16, { 0x9e, 0x25, 0xfc, 0x83, 0x3f, 0x22, 0x90, 0x73, 0x3e, 0x93, 0x44, 0xa5, 0xe8, 0x38, 0x39, 0xeb, } } },
{ 21, { 16, { 0x56, 0x8e, 0x49, 0x5a, 0xbe, 0x52, 0x5a, 0x21, 0x8a, 0x22, 0x14, 0xcd, 0x3e, 0x07, 0x1d, 0x12, } } },
{ 22, { 16, { 0x4a, 0x29, 0xb5, 0x45, 0x52, 0xd1, 0x6b, 0x9a, 0x46, 0x9c, 0x10, 0x52, 0x8e, 0xff, 0x0a, 0xae, } } },
{ 23, { 16, { 0xc9, 0xd1, 0x84, 0xdd, 0xd5, 0xa9, 0xf5, 0xe0, 0xcf, 0x8c, 0xe2, 0x9a, 0x9a, 0xbf, 0x69, 0x1c, } } },
{ 24, { 16, { 0x2d, 0xb4, 0x79, 0xae, 0x78, 0xbd, 0x50, 0xd8, 0x88, 0x2a, 0x8a, 0x17, 0x8a, 0x61, 0x32, 0xad, } } },
{ 25, { 16, { 0x8e, 0xce, 0x5f, 0x04, 0x2d, 0x5e, 0x44, 0x7b, 0x50, 0x51, 0xb9, 0xea, 0xcb, 0x8d, 0x8f, 0x6f, } } },
{ 26, { 16, { 0x9c, 0x0b, 0x53, 0xb4, 0xb3, 0xc3, 0x07, 0xe8, 0x7e, 0xae, 0xe0, 0x86, 0x78, 0x14, 0x1f, 0x66, } } },
{ 27, { 16, { 0xab, 0xf2, 0x48, 0xaf, 0x69, 0xa6, 0xea, 0xe4, 0xbf, 0xd3, 0xeb, 0x2f, 0x12, 0x9e, 0xeb, 0x94, } } },
{ 28, { 16, { 0x06, 0x64, 0xda, 0x16, 0x68, 0x57, 0x4b, 0x88, 0xb9, 0x35, 0xf3, 0x02, 0x73, 0x58, 0xae, 0xf4, } } },
{ 29, { 16, { 0xaa, 0x4b, 0x9d, 0xc4, 0xbf, 0x33, 0x7d, 0xe9, 0x0c, 0xd4, 0xfd, 0x3c, 0x46, 0x7c, 0x6a, 0xb7, } } },
{ 30, { 16, { 0xea, 0x5c, 0x7f, 0x47, 0x1f, 0xaf, 0x6b, 0xde, 0x2b, 0x1a, 0xd7, 0xd4, 0x68, 0x6d, 0x22, 0x87, } } },
{ 31, { 16, { 0x29, 0x39, 0xb0, 0x18, 0x32, 0x23, 0xfa, 0xfc, 0x17, 0x23, 0xde, 0x4f, 0x52, 0xc4, 0x3d, 0x35, } } },
{ 32, { 16, { 0x7c, 0x39, 0x56, 0xca, 0x5e, 0xea, 0xfc, 0x3e, 0x36, 0x3e, 0x9d, 0x55, 0x65, 0x46, 0xeb, 0x68, } } },
{ 33, { 16, { 0x77, 0xc6, 0x07, 0x71, 0x46, 0xf0, 0x1c, 0x32, 0xb6, 0xb6, 0x9d, 0x5f, 0x4e, 0xa9, 0xff, 0xcf, } } },
{ 34, { 16, { 0x37, 0xa6, 0x98, 0x6c, 0xb8, 0x84, 0x7e, 0xdf, 0x09, 0x25, 0xf0, 0xf1, 0x30, 0x9b, 0x54, 0xde, } } },
{ 35, { 16, { 0xa7, 0x05, 0xf0, 0xe6, 0x9d, 0xa9, 0xa8, 0xf9, 0x07, 0x24, 0x1a, 0x2e, 0x92, 0x3c, 0x8c, 0xc8, } } },
{ 36, { 16, { 0x3d, 0xc4, 0x7d, 0x1f, 0x29, 0xc4, 0x48, 0x46, 0x1e, 0x9e, 0x76, 0xed, 0x90, 0x4f, 0x67, 0x11, } } },
{ 37, { 16, { 0x0d, 0x62, 0xbf, 0x01, 0xe6, 0xfc, 0x0e, 0x1a, 0x0d, 0x3c, 0x47, 0x51, 0xc5, 0xd3, 0x69, 0x2b, } } },
{ 38, { 16, { 0x8c, 0x03, 0x46, 0x8b, 0xca, 0x7c, 0x66, 0x9e, 0xe4, 0xfd, 0x5e, 0x08, 0x4b, 0xbe, 0xe7, 0xb5, } } },
{ 39, { 16, { 0x52, 0x8a, 0x5b, 0xb9, 0x3b, 0xaf, 0x2c, 0x9c, 0x44, 0x73, 0xcc, 0xe5, 0xd0, 0xd2, 0x2b, 0xd9, } } },
{ 40, { 16, { 0xdf, 0x6a, 0x30, 0x1e, 0x95, 0xc9, 0x5d, 0xad, 0x97, 0xae, 0x0c, 0xc8, 0xc6, 0x91, 0x3b, 0xd8, } } },
{ 41, { 16, { 0x80, 0x11, 0x89, 0x90, 0x2c, 0x85, 0x7f, 0x39, 0xe7, 0x35, 0x91, 0x28, 0x5e, 0x70, 0xb6, 0xdb, } } },
{ 42, { 16, { 0xe6, 0x17, 0x34, 0x6a, 0xc9, 0xc2, 0x31, 0xbb, 0x36, 0x50, 0xae, 0x34, 0xcc, 0xca, 0x0c, 0x5b, } } },
{ 43, { 16, { 0x27, 0xd9, 0x34, 0x37, 0xef, 0xb7, 0x21, 0xaa, 0x40, 0x18, 0x21, 0xdc, 0xec, 0x5a, 0xdf, 0x89, } } },
{ 44, { 16, { 0x89, 0x23, 0x7d, 0x9d, 0xed, 0x9c, 0x5e, 0x78, 0xd8, 0xb1, 0xc9, 0xb1, 0x66, 0xcc, 0x73, 0x42, } } },
{ 45, { 16, { 0x4a, 0x6d, 0x80, 0x91, 0xbf, 0x5e, 0x7d, 0x65, 0x11, 0x89, 0xfa, 0x94, 0xa2, 0x50, 0xb1, 0x4c, } } },
{ 46, { 16, { 0x0e, 0x33, 0xf9, 0x60, 0x55, 0xe7, 0xae, 0x89, 0x3f, 0xfc, 0x0e, 0x3d, 0xcf, 0x49, 0x29, 0x02, } } },
{ 47, { 16, { 0xe6, 0x1c, 0x43, 0x2b, 0x72, 0x0b, 0x19, 0xd1, 0x8e, 0xc8, 0xd8, 0x4b, 0xdc, 0x63, 0x15, 0x1b, } } },
{ 48, { 16, { 0xf7, 0xe5, 0xae, 0xf5, 0x49, 0xf7, 0x82, 0xcf, 0x37, 0x90, 0x55, 0xa6, 0x08, 0x26, 0x9b, 0x16, } } },
{ 49, { 16, { 0x43, 0x8d, 0x03, 0x0f, 0xd0, 0xb7, 0xa5, 0x4f, 0xa8, 0x37, 0xf2, 0xad, 0x20, 0x1a, 0x64, 0x03, } } },
{ 50, { 16, { 0xa5, 0x90, 0xd3, 0xee, 0x4f, 0xbf, 0x04, 0xe3, 0x24, 0x7e, 0x0d, 0x27, 0xf2, 0x86, 0x42, 0x3f, } } },
{ 51, { 16, { 0x5f, 0xe2, 0xc1, 0xa1, 0x72, 0xfe, 0x93, 0xc4, 0xb1, 0x5c, 0xd3, 0x7c, 0xae, 0xf9, 0xf5, 0x38, } } },
{ 52, { 16, { 0x2c, 0x97, 0x32, 0x5c, 0xbd, 0x06, 0xb3, 0x6e, 0xb2, 0x13, 0x3d, 0xd0, 0x8b, 0x3a, 0x01, 0x7c, } } },
{ 53, { 16, { 0x92, 0xc8, 0x14, 0x22, 0x7a, 0x6b, 0xca, 0x94, 0x9f, 0xf0, 0x65, 0x9f, 0x00, 0x2a, 0xd3, 0x9e, } } },
{ 54, { 16, { 0xdc, 0xe8, 0x50, 0x11, 0x0b, 0xd8, 0x32, 0x8c, 0xfb, 0xd5, 0x08, 0x41, 0xd6, 0x91, 0x1d, 0x87, } } },
{ 55, { 16, { 0x67, 0xf1, 0x49, 0x84, 0xc7, 0xda, 0x79, 0x12, 0x48, 0xe3, 0x2b, 0xb5, 0x92, 0x25, 0x83, 0xda, } } },
{ 56, { 16, { 0x19, 0x38, 0xf2, 0xcf, 0x72, 0xd5, 0x4e, 0xe9, 0x7e, 0x94, 0x16, 0x6f, 0xa9, 0x1d, 0x2a, 0x36, } } },
{ 57, { 16, { 0x74, 0x48, 0x1e, 0x96, 0x46, 0xed, 0x49, 0xfe, 0x0f, 0x62, 0x24, 0x30, 0x16, 0x04, 0x69, 0x8e, } } },
{ 58, { 16, { 0x57, 0xfc, 0xa5, 0xde, 0x98, 0xa9, 0xd6, 0xd8, 0x00, 0x64, 0x38, 0xd0, 0x58, 0x3d, 0x8a, 0x1d, } } },
{ 59, { 16, { 0x9f, 0xec, 0xde, 0x1c, 0xef, 0xdc, 0x1c, 0xbe, 0xd4, 0x76, 0x36, 0x74, 0xd9, 0x57, 0x53, 0x59, } } },
{ 60, { 16, { 0xe3, 0x04, 0x0c, 0x00, 0xeb, 0x28, 0xf1, 0x53, 0x66, 0xca, 0x73, 0xcb, 0xd8, 0x72, 0xe7, 0x40, } } },
{ 61, { 16, { 0x76, 0x97, 0x00, 0x9a, 0x6a, 0x83, 0x1d, 0xfe, 0xcc, 0xa9, 0x1c, 0x59, 0x93, 0x67, 0x0f, 0x7a, } } },
{ 62, { 16, { 0x58, 0x53, 0x54, 0x23, 0x21, 0xf5, 0x67, 0xa0, 0x05, 0xd5, 0x47, 0xa4, 0xf0, 0x47, 0x59, 0xbd, } } },
{ 63, { 16, { 0x51, 0x50, 0xd1, 0x77, 0x2f, 0x50, 0x83, 0x4a, 0x50, 0x3e, 0x06, 0x9a, 0x97, 0x3f, 0xbd, 0x7c, } } }
};
static int test_siphash(int idx)
{
SIPHASH siphash = { 0, };
TESTDATA test = tests[idx];
unsigned char key[SIPHASH_KEY_SIZE];
unsigned char in[64];
size_t inlen = test.idx;
unsigned char *expected = test.expected.data;
size_t expectedlen = test.expected.size;
unsigned char out[SIPHASH_MAX_DIGEST_SIZE];
size_t i;
if (expectedlen != SIPHASH_MIN_DIGEST_SIZE &&
expectedlen != SIPHASH_MAX_DIGEST_SIZE) {
TEST_info("size %zu vs %d and %d", expectedlen,
SIPHASH_MIN_DIGEST_SIZE, SIPHASH_MAX_DIGEST_SIZE);
return 0;
}
if (!TEST_int_le(inlen, sizeof(in)))
return 0;
/* key and in data are 00 01 02 ... */
for (i = 0; i < sizeof(key); i++)
key[i] = (unsigned char)i;
for (i = 0; i < inlen; i++)
in[i] = (unsigned char)i;
if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen))
|| !TEST_true(SipHash_Init(&siphash, key, 0, 0)))
return 0;
SipHash_Update(&siphash, in, inlen);
if (!TEST_true(SipHash_Final(&siphash, out, expectedlen))
|| !TEST_mem_eq(out, expectedlen, expected, expectedlen))
return 0;
if (inlen > 16) {
if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen))
|| !TEST_true(SipHash_Init(&siphash, key, 0, 0)))
return 0;
SipHash_Update(&siphash, in, 1);
SipHash_Update(&siphash, in+1, inlen-1);
if (!TEST_true(SipHash_Final(&siphash, out, expectedlen)))
return 0;
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
TEST_info("SipHash test #%d/1+(N-1) failed.", idx);
return 0;
}
}
if (inlen > 32) {
size_t half = inlen / 2;
if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen))
|| !TEST_true(SipHash_Init(&siphash, key, 0, 0)))
return 0;
SipHash_Update(&siphash, in, half);
SipHash_Update(&siphash, in+half, inlen-half);
if (!TEST_true(SipHash_Final(&siphash, out, expectedlen)))
return 0;
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
TEST_info("SipHash test #%d/2 failed.", idx);
return 0;
}
for (half = 16; half < inlen; half += 16) {
if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen))
|| !TEST_true(SipHash_Init(&siphash, key, 0, 0)))
return 0;
SipHash_Update(&siphash, in, half);
SipHash_Update(&siphash, in+half, inlen-half);
if (!TEST_true(SipHash_Final(&siphash, out, expectedlen)))
return 0;
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
TEST_info("SipHash test #%d/%zu+%zu failed.",
idx, half, inlen-half);
return 0;
}
}
}
return 1;
}
static int test_siphash_basic(void)
{
SIPHASH siphash = { 0, };
unsigned char key[SIPHASH_KEY_SIZE];
unsigned char output[SIPHASH_MAX_DIGEST_SIZE];
/* Use invalid hash size */
return TEST_int_eq(SipHash_set_hash_size(&siphash, 4), 0)
&& TEST_false(SipHash_Final(&siphash, output, 0))
/* Use hash size = 8 */
&& TEST_true(SipHash_set_hash_size(&siphash, 8))
&& TEST_false(SipHash_Final(&siphash, output, 8))
&& TEST_true(SipHash_Init(&siphash, key, 0, 0))
&& TEST_true(SipHash_Final(&siphash, output, 8))
&& TEST_int_eq(SipHash_Final(&siphash, output, 16), 0)
/* Use hash size = 16 */
&& TEST_true(SipHash_set_hash_size(&siphash, 16))
&& TEST_true(SipHash_Init(&siphash, key, 0, 0))
&& TEST_int_eq(SipHash_Final(&siphash, output, 8), 0)
&& TEST_true(SipHash_Final(&siphash, output, 16))
/* Use hash size = 0 (default = 16) */
&& TEST_true(SipHash_set_hash_size(&siphash, 0))
&& TEST_true(SipHash_Init(&siphash, key, 0, 0))
&& TEST_int_eq(SipHash_Final(&siphash, output, 8), 0)
&& TEST_true(SipHash_Final(&siphash, output, 16));
}
int setup_tests(void)
{
ADD_TEST(test_siphash_basic);
ADD_ALL_TESTS(test_siphash, OSSL_NELEM(tests));
return 1;
}
|
./openssl/test/testutil.h | /*
* Copyright 2014-2023 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
*/
#ifndef OSSL_TESTUTIL_H
# define OSSL_TESTUTIL_H
# include <stdarg.h>
# include "internal/common.h" /* for HAS_PREFIX */
# include <openssl/provider.h>
# include <openssl/err.h>
# include <openssl/e_os2.h>
# include <openssl/bn.h>
# include <openssl/x509.h>
# include "opt.h"
/*-
* Simple unit tests should implement setup_tests().
* This function should return zero if the registration process fails.
* To register tests, call ADD_TEST or ADD_ALL_TESTS:
*
* int setup_tests(void)
* {
* ADD_TEST(test_foo);
* ADD_ALL_TESTS(test_bar, num_test_bar);
* return 1;
* }
*
* Tests that require clean up after execution should implement:
*
* void cleanup_tests(void);
*
* The cleanup_tests function will be called even if setup_tests()
* returns failure.
*
* In some cases, early initialization before the framework is set up
* may be needed. In such a case, this should be implemented:
*
* int global_init(void);
*
* This function should return zero if there is an unrecoverable error and
* non-zero if the initialization was successful.
*/
/* Adds a simple test case. */
# define ADD_TEST(test_function) add_test(#test_function, test_function)
/*
* Simple parameterized tests. Calls test_function(idx) for each 0 <= idx < num.
*/
# define ADD_ALL_TESTS(test_function, num) \
add_all_tests(#test_function, test_function, num, 1)
/*
* A variant of the same without TAP output.
*/
# define ADD_ALL_TESTS_NOSUBTEST(test_function, num) \
add_all_tests(#test_function, test_function, num, 0)
/*-
* Test cases that share common setup should use the helper
* SETUP_TEST_FIXTURE and EXECUTE_TEST macros for test case functions.
*
* SETUP_TEST_FIXTURE will call set_up() to create a new TEST_FIXTURE_TYPE
* object called "fixture". It will also allocate the "result" variable used
* by EXECUTE_TEST. set_up() should take a const char* specifying the test
* case name and return a TEST_FIXTURE_TYPE by reference.
* If case set_up() fails then 0 is returned.
*
* EXECUTE_TEST will pass fixture to execute_func() by reference, call
* tear_down(), and return the result of execute_func(). execute_func() should
* take a TEST_FIXTURE_TYPE by reference and return 1 on success and 0 on
* failure. The tear_down function is responsible for deallocation of the
* result variable, if required.
*
* Unit tests can define their own SETUP_TEST_FIXTURE and EXECUTE_TEST
* variations like so:
*
* #define SETUP_FOOBAR_TEST_FIXTURE()\
* SETUP_TEST_FIXTURE(FOOBAR_TEST_FIXTURE, set_up_foobar)
*
* #define EXECUTE_FOOBAR_TEST()\
* EXECUTE_TEST(execute_foobar, tear_down_foobar)
*
* Then test case functions can take the form:
*
* static int test_foobar_feature()
* {
* SETUP_FOOBAR_TEST_FIXTURE();
* [...set individual members of fixture...]
* EXECUTE_FOOBAR_TEST();
* }
*/
# define SETUP_TEST_FIXTURE(TEST_FIXTURE_TYPE, set_up)\
TEST_FIXTURE_TYPE *fixture = set_up(TEST_CASE_NAME); \
int result = 0; \
\
if (fixture == NULL) \
return 0
# define EXECUTE_TEST(execute_func, tear_down)\
if (fixture != NULL) {\
result = execute_func(fixture);\
tear_down(fixture);\
}
/*
* TEST_CASE_NAME is defined as the name of the test case function where
* possible; otherwise we get by with the file name and line number.
*/
# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# if defined(_MSC_VER)
# define TEST_CASE_NAME __FUNCTION__
# else
# define testutil_stringify_helper(s) #s
# define testutil_stringify(s) testutil_stringify_helper(s)
# define TEST_CASE_NAME __FILE__ ":" testutil_stringify(__LINE__)
# endif /* _MSC_VER */
# else
# define TEST_CASE_NAME __func__
# endif /* __STDC_VERSION__ */
/* The default test enum which should be common to all tests */
# define OPT_TEST_ENUM \
OPT_TEST_HELP = 500, \
OPT_TEST_LIST, \
OPT_TEST_SINGLE, \
OPT_TEST_ITERATION, \
OPT_TEST_INDENT, \
OPT_TEST_SEED
/* The Default test OPTIONS common to all tests (without a usage string) */
# define OPT_TEST_OPTIONS \
{ OPT_HELP_STR, 1, '-', "Valid options are:\n" }, \
{ "help", OPT_TEST_HELP, '-', "Display this summary" }, \
{ "list", OPT_TEST_LIST, '-', "Display the list of tests available" }, \
{ "test", OPT_TEST_SINGLE, 's', "Run a single test by id or name" }, \
{ "iter", OPT_TEST_ITERATION, 'n', "Run a single iteration of a test" }, \
{ "indent", OPT_TEST_INDENT,'p', "Number of tabs added to output" }, \
{ "seed", OPT_TEST_SEED, 'n', "Seed value to randomize tests with" }
/* The Default test OPTIONS common to all tests starting with an additional usage string */
# define OPT_TEST_OPTIONS_WITH_EXTRA_USAGE(usage) \
{ OPT_HELP_STR, 1, '-', "Usage: %s [options] " usage }, \
OPT_TEST_OPTIONS
/* The Default test OPTIONS common to all tests with an default usage string */
# define OPT_TEST_OPTIONS_DEFAULT_USAGE \
{ OPT_HELP_STR, 1, '-', "Usage: %s [options]\n" }, \
OPT_TEST_OPTIONS
/*
* Optional Cases that need to be ignored by the test app when using opt_next(),
* (that are handled internally).
*/
# define OPT_TEST_CASES \
OPT_TEST_HELP: \
case OPT_TEST_LIST: \
case OPT_TEST_SINGLE: \
case OPT_TEST_ITERATION: \
case OPT_TEST_INDENT: \
case OPT_TEST_SEED
/*
* Tests that use test_get_argument() that dont have any additional options
* (i.e- dont use opt_next()) can use this to set the usage string.
* It embeds test_get_options() which gives default command line options for
* the test system.
*
* Tests that need to use opt_next() need to specify
* (1) test_get_options() containing an options[] which should include either
* OPT_TEST_OPTIONS_DEFAULT_USAGE or
* OPT_TEST_OPTIONS_WITH_EXTRA_USAGE(...).
* (2) An enum outside the test_get_options() which contains OPT_TEST_ENUM, as
* well as the additional options that need to be handled.
* (3) case OPT_TEST_CASES: break; inside the opt_next() handling code.
*/
# define OPT_TEST_DECLARE_USAGE(usage_str) \
const OPTIONS *test_get_options(void) \
{ \
enum { OPT_TEST_ENUM }; \
static const OPTIONS options[] = { \
OPT_TEST_OPTIONS_WITH_EXTRA_USAGE(usage_str), \
{ NULL } \
}; \
return options; \
}
/*
* Used to read non optional command line values that follow after the options.
* Returns NULL if there is no argument.
*/
char *test_get_argument(size_t n);
/* Return the number of additional non optional command line arguments */
size_t test_get_argument_count(void);
/*
* Skip over common test options. Should be called before calling
* test_get_argument()
*/
int test_skip_common_options(void);
/*
* Get a library context for the tests, populated with the specified provider
* and configuration. If default_null_prov is not NULL, a "null" provider is
* loaded into the default library context to prevent it being used.
* If libctx is NULL, the specified provider is loaded into the default library
* context.
*/
int test_get_libctx(OSSL_LIB_CTX **libctx, OSSL_PROVIDER **default_null_prov,
const char *config_file,
OSSL_PROVIDER **provider, const char *module_name);
int test_arg_libctx(OSSL_LIB_CTX **libctx, OSSL_PROVIDER **default_null_prov,
OSSL_PROVIDER **provider, int argn, const char *usage);
/*
* Internal helpers. Test programs shouldn't use these directly, but should
* rather link to one of the helper main() methods.
*/
void add_test(const char *test_case_name, int (*test_fn) (void));
void add_all_tests(const char *test_case_name, int (*test_fn)(int idx), int num,
int subtest);
/*
* Declarations for user defined functions.
* The first two return a boolean indicating that the test should not proceed.
*/
int global_init(void);
int setup_tests(void);
void cleanup_tests(void);
/*
* Helper functions to detect specific versions of the FIPS provider being in use.
* Because of FIPS rules, code changes after a module has been validated are
* difficult and because we provide a hard guarantee of ABI and behavioural
* stability going forwards, it is a requirement to have tests be conditional
* on specific FIPS provider versions. Without this, bug fixes cannot be tested
* in later releases.
*
* The reason for not including e.g. a less than test is to help avoid any
* temptation to use FIPS provider version numbers that don't exist. Until the
* `new' provider is validated, its version isn't set in stone. Thus a change
* in test behaviour must depend on already validated module versions only.
*
* In all cases, the function returns true if:
* 1. the FIPS provider version matches the criteria specified or
* 2. the FIPS provider isn't being used.
*/
int fips_provider_version_eq(OSSL_LIB_CTX *libctx, int major, int minor, int patch);
int fips_provider_version_ne(OSSL_LIB_CTX *libctx, int major, int minor, int patch);
int fips_provider_version_le(OSSL_LIB_CTX *libctx, int major, int minor, int patch);
int fips_provider_version_lt(OSSL_LIB_CTX *libctx, int major, int minor, int patch);
int fips_provider_version_gt(OSSL_LIB_CTX *libctx, int major, int minor, int patch);
int fips_provider_version_ge(OSSL_LIB_CTX *libctx, int major, int minor, int patch);
/*
* This function matches fips provider version with (potentially multiple)
* <operator>maj.min.patch version strings in versions.
* The operator can be one of = ! <= or > comparison symbols.
* If the fips provider matches all the version comparisons (or if there is no
* fips provider available) the function returns 1.
* If the fips provider does not match the version comparisons, it returns 0.
* On error the function returns -1.
*/
int fips_provider_version_match(OSSL_LIB_CTX *libctx, const char *versions);
/*
* Used to supply test specific command line options,
* If non optional parameters are used, then the first entry in the OPTIONS[]
* should contain:
* { OPT_HELP_STR, 1, '-', "<list of non-optional commandline params>\n"},
* The last entry should always be { NULL }.
*
* Run the test locally using './test/test_name -help' to check the usage.
*/
const OPTIONS *test_get_options(void);
/*
* Test assumption verification helpers.
*/
# define PRINTF_FORMAT(a, b)
# if defined(__GNUC__) && defined(__STDC_VERSION__) \
&& !defined(__MINGW32__) && !defined(__MINGW64__) \
&& !defined(__APPLE__)
/*
* Because we support the 'z' modifier, which made its appearance in C99,
* we can't use __attribute__ with pre C99 dialects.
*/
# if __STDC_VERSION__ >= 199901L
# undef PRINTF_FORMAT
# define PRINTF_FORMAT(a, b) __attribute__ ((format(printf, a, b)))
# endif
# endif
# define DECLARE_COMPARISON(type, name, opname) \
int test_ ## name ## _ ## opname(const char *, int, \
const char *, const char *, \
const type, const type);
# define DECLARE_COMPARISONS(type, name) \
DECLARE_COMPARISON(type, name, eq) \
DECLARE_COMPARISON(type, name, ne) \
DECLARE_COMPARISON(type, name, lt) \
DECLARE_COMPARISON(type, name, le) \
DECLARE_COMPARISON(type, name, gt) \
DECLARE_COMPARISON(type, name, ge)
DECLARE_COMPARISONS(int, int)
DECLARE_COMPARISONS(unsigned int, uint)
DECLARE_COMPARISONS(char, char)
DECLARE_COMPARISONS(unsigned char, uchar)
DECLARE_COMPARISONS(long, long)
DECLARE_COMPARISONS(unsigned long, ulong)
DECLARE_COMPARISONS(int64_t, int64_t)
DECLARE_COMPARISONS(uint64_t, uint64_t)
DECLARE_COMPARISONS(double, double)
DECLARE_COMPARISONS(time_t, time_t)
/*
* Because this comparison uses a printf format specifier that's not
* universally known (yet), we provide an option to not have it declared.
*/
# ifndef TESTUTIL_NO_size_t_COMPARISON
DECLARE_COMPARISONS(size_t, size_t)
# endif
/*
* Pointer comparisons against other pointers and null.
* These functions return 1 if the test is true.
* Otherwise, they return 0 and pretty-print diagnostics.
* These should not be called directly, use the TEST_xxx macros below instead.
*/
DECLARE_COMPARISON(void *, ptr, eq)
DECLARE_COMPARISON(void *, ptr, ne)
int test_ptr(const char *file, int line, const char *s, const void *p);
int test_ptr_null(const char *file, int line, const char *s, const void *p);
/*
* Equality tests for strings where NULL is a legitimate value.
* These calls return 1 if the two passed strings compare true.
* Otherwise, they return 0 and pretty-print diagnostics.
* These should not be called directly, use the TEST_xxx macros below instead.
*/
DECLARE_COMPARISON(char *, str, eq)
DECLARE_COMPARISON(char *, str, ne)
/*
* Same as above, but for strncmp.
*/
int test_strn_eq(const char *file, int line, const char *, const char *,
const char *a, size_t an, const char *b, size_t bn);
int test_strn_ne(const char *file, int line, const char *, const char *,
const char *a, size_t an, const char *b, size_t bn);
/*
* Equality test for memory blocks where NULL is a legitimate value.
* These calls return 1 if the two memory blocks compare true.
* Otherwise, they return 0 and pretty-print diagnostics.
* These should not be called directly, use the TEST_xxx macros below instead.
*/
int test_mem_eq(const char *, int, const char *, const char *,
const void *, size_t, const void *, size_t);
int test_mem_ne(const char *, int, const char *, const char *,
const void *, size_t, const void *, size_t);
/*
* Check a boolean result for being true or false.
* They return 1 if the condition is true (i.e. the value is non-zero).
* Otherwise, they return 0 and pretty-prints diagnostics using |s|.
* These should not be called directly, use the TEST_xxx macros below instead.
*/
int test_true(const char *file, int line, const char *s, int b);
int test_false(const char *file, int line, const char *s, int b);
/*
* Comparisons between BIGNUMs.
* BIGNUMS can be compared against other BIGNUMs or zero.
* Some additional equality tests against 1 & specific values are provided.
* Tests for parity are included as well.
*/
DECLARE_COMPARISONS(BIGNUM *, BN)
int test_BN_eq_zero(const char *file, int line, const char *s, const BIGNUM *a);
int test_BN_ne_zero(const char *file, int line, const char *s, const BIGNUM *a);
int test_BN_lt_zero(const char *file, int line, const char *s, const BIGNUM *a);
int test_BN_le_zero(const char *file, int line, const char *s, const BIGNUM *a);
int test_BN_gt_zero(const char *file, int line, const char *s, const BIGNUM *a);
int test_BN_ge_zero(const char *file, int line, const char *s, const BIGNUM *a);
int test_BN_eq_one(const char *file, int line, const char *s, const BIGNUM *a);
int test_BN_odd(const char *file, int line, const char *s, const BIGNUM *a);
int test_BN_even(const char *file, int line, const char *s, const BIGNUM *a);
int test_BN_eq_word(const char *file, int line, const char *bns, const char *ws,
const BIGNUM *a, BN_ULONG w);
int test_BN_abs_eq_word(const char *file, int line, const char *bns,
const char *ws, const BIGNUM *a, BN_ULONG w);
/*
* Pretty print a failure message.
* These should not be called directly, use the TEST_xxx macros below instead.
*/
void test_error(const char *file, int line, const char *desc, ...)
PRINTF_FORMAT(3, 4);
void test_error_c90(const char *desc, ...) PRINTF_FORMAT(1, 2);
void test_info(const char *file, int line, const char *desc, ...)
PRINTF_FORMAT(3, 4);
void test_info_c90(const char *desc, ...) PRINTF_FORMAT(1, 2);
void test_note(const char *desc, ...) PRINTF_FORMAT(1, 2);
int test_skip(const char *file, int line, const char *desc, ...)
PRINTF_FORMAT(3, 4);
int test_skip_c90(const char *desc, ...) PRINTF_FORMAT(1, 2);
void test_openssl_errors(void);
void test_perror(const char *s);
/*
* The following macros provide wrapper calls to the test functions with
* a default description that indicates the file and line number of the error.
*
* The following macros guarantee to evaluate each argument exactly once.
* This allows constructs such as: if (!TEST_ptr(ptr = OPENSSL_malloc(..)))
* to produce better contextual output than:
* ptr = OPENSSL_malloc(..);
* if (!TEST_ptr(ptr))
*/
# define TEST_int_eq(a, b) test_int_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int_ne(a, b) test_int_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int_lt(a, b) test_int_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int_le(a, b) test_int_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int_gt(a, b) test_int_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int_ge(a, b) test_int_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint_eq(a, b) test_uint_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint_ne(a, b) test_uint_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint_lt(a, b) test_uint_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint_le(a, b) test_uint_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint_gt(a, b) test_uint_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint_ge(a, b) test_uint_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_char_eq(a, b) test_char_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_char_ne(a, b) test_char_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_char_lt(a, b) test_char_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_char_le(a, b) test_char_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_char_gt(a, b) test_char_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_char_ge(a, b) test_char_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uchar_eq(a, b) test_uchar_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uchar_ne(a, b) test_uchar_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uchar_lt(a, b) test_uchar_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uchar_le(a, b) test_uchar_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uchar_gt(a, b) test_uchar_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uchar_ge(a, b) test_uchar_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_long_eq(a, b) test_long_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_long_ne(a, b) test_long_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_long_lt(a, b) test_long_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_long_le(a, b) test_long_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_long_gt(a, b) test_long_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_long_ge(a, b) test_long_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_ulong_eq(a, b) test_ulong_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_ulong_ne(a, b) test_ulong_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_ulong_lt(a, b) test_ulong_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_ulong_le(a, b) test_ulong_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_ulong_gt(a, b) test_ulong_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_ulong_ge(a, b) test_ulong_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int64_t_eq(a, b) test_int64_t_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int64_t_ne(a, b) test_int64_t_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int64_t_lt(a, b) test_int64_t_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int64_t_le(a, b) test_int64_t_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int64_t_gt(a, b) test_int64_t_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_int64_t_ge(a, b) test_int64_t_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint64_t_eq(a, b) test_uint64_t_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint64_t_ne(a, b) test_uint64_t_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint64_t_lt(a, b) test_uint64_t_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint64_t_le(a, b) test_uint64_t_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint64_t_gt(a, b) test_uint64_t_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_uint64_t_ge(a, b) test_uint64_t_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_size_t_eq(a, b) test_size_t_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_size_t_ne(a, b) test_size_t_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_size_t_lt(a, b) test_size_t_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_size_t_le(a, b) test_size_t_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_size_t_gt(a, b) test_size_t_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_size_t_ge(a, b) test_size_t_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_double_eq(a, b) test_double_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_double_ne(a, b) test_double_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_double_lt(a, b) test_double_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_double_le(a, b) test_double_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_double_gt(a, b) test_double_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_double_ge(a, b) test_double_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_time_t_eq(a, b) test_time_t_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_time_t_ne(a, b) test_time_t_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_time_t_lt(a, b) test_time_t_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_time_t_le(a, b) test_time_t_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_time_t_gt(a, b) test_time_t_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_time_t_ge(a, b) test_time_t_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_ptr_eq(a, b) test_ptr_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_ptr_ne(a, b) test_ptr_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_ptr(a) test_ptr(__FILE__, __LINE__, #a, a)
# define TEST_ptr_null(a) test_ptr_null(__FILE__, __LINE__, #a, a)
# define TEST_str_eq(a, b) test_str_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_str_ne(a, b) test_str_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_strn_eq(a, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, n, b, n)
# define TEST_strn_ne(a, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, n, b, n)
# define TEST_strn2_eq(a, m, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
# define TEST_strn2_ne(a, m, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
# define TEST_mem_eq(a, m, b, n) test_mem_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
# define TEST_mem_ne(a, m, b, n) test_mem_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
# define TEST_true(a) test_true(__FILE__, __LINE__, #a, (a) != 0)
# define TEST_false(a) test_false(__FILE__, __LINE__, #a, (a) != 0)
# define TEST_BN_eq(a, b) test_BN_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_BN_ne(a, b) test_BN_ne(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_BN_lt(a, b) test_BN_lt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_BN_gt(a, b) test_BN_gt(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_BN_le(a, b) test_BN_le(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_BN_ge(a, b) test_BN_ge(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_BN_eq_zero(a) test_BN_eq_zero(__FILE__, __LINE__, #a, a)
# define TEST_BN_ne_zero(a) test_BN_ne_zero(__FILE__, __LINE__, #a, a)
# define TEST_BN_lt_zero(a) test_BN_lt_zero(__FILE__, __LINE__, #a, a)
# define TEST_BN_gt_zero(a) test_BN_gt_zero(__FILE__, __LINE__, #a, a)
# define TEST_BN_le_zero(a) test_BN_le_zero(__FILE__, __LINE__, #a, a)
# define TEST_BN_ge_zero(a) test_BN_ge_zero(__FILE__, __LINE__, #a, a)
# define TEST_BN_eq_one(a) test_BN_eq_one(__FILE__, __LINE__, #a, a)
# define TEST_BN_eq_word(a, w) test_BN_eq_word(__FILE__, __LINE__, #a, #w, a, w)
# define TEST_BN_abs_eq_word(a, w) test_BN_abs_eq_word(__FILE__, __LINE__, #a, #w, a, w)
# define TEST_BN_odd(a) test_BN_odd(__FILE__, __LINE__, #a, a)
# define TEST_BN_even(a) test_BN_even(__FILE__, __LINE__, #a, a)
/*
* TEST_error(desc, ...) prints an informative error message in the standard
* format. |desc| is a printf format string.
*/
# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# define TEST_error test_error_c90
# define TEST_info test_info_c90
# define TEST_skip test_skip_c90
# else
# define TEST_error(...) test_error(__FILE__, __LINE__, __VA_ARGS__)
# define TEST_info(...) test_info(__FILE__, __LINE__, __VA_ARGS__)
# define TEST_skip(...) test_skip(__FILE__, __LINE__, __VA_ARGS__)
# endif
# define TEST_note test_note
# define TEST_openssl_errors test_openssl_errors
# define TEST_perror test_perror
extern BIO *bio_out;
extern BIO *bio_err;
/*
* Formatted output for strings, memory and bignums.
*/
void test_output_string(const char *name, const char *m, size_t l);
void test_output_bignum(const char *name, const BIGNUM *bn);
void test_output_memory(const char *name, const unsigned char *m, size_t l);
/*
* Utilities to parse a test file.
*/
# define TESTMAXPAIRS 150
typedef struct pair_st {
char *key;
char *value;
} PAIR;
typedef struct stanza_st {
const char *test_file; /* Input file name */
BIO *fp; /* Input file */
int curr; /* Current line in file */
int start; /* Line where test starts */
int errors; /* Error count */
int numtests; /* Number of tests */
int numskip; /* Number of skipped tests */
int numpairs;
PAIR pairs[TESTMAXPAIRS];
BIO *key; /* temp memory BIO for reading in keys */
char buff[4096]; /* Input buffer for a single key/value */
} STANZA;
/*
* Prepare to start reading the file |testfile| as input.
*/
int test_start_file(STANZA *s, const char *testfile);
int test_end_file(STANZA *s);
/*
* Read a stanza from the test file. A stanza consists of a block
* of lines of the form
* key = value
* The block is terminated by EOF or a blank line.
* Return 1 if found, 0 on EOF or error.
*/
int test_readstanza(STANZA *s);
/*
* Clear a stanza, release all allocated memory.
*/
void test_clearstanza(STANZA *s);
/*
* Glue an array of strings together and return it as an allocated string.
* Optionally return the whole length of this string in |out_len|
*/
char *glue_strings(const char *list[], size_t *out_len);
/*
* Pseudo random number generator of low quality but having repeatability
* across platforms. The two calls are replacements for random(3) and
* srandom(3).
*/
uint32_t test_random(void);
void test_random_seed(uint32_t sd);
/* Fake non-secure random number generator */
typedef int fake_random_generate_cb(unsigned char *out, size_t outlen,
const char *name, EVP_RAND_CTX *ctx);
OSSL_PROVIDER *fake_rand_start(OSSL_LIB_CTX *libctx);
void fake_rand_finish(OSSL_PROVIDER *p);
void fake_rand_set_callback(EVP_RAND_CTX *ctx,
int (*cb)(unsigned char *out, size_t outlen,
const char *name, EVP_RAND_CTX *ctx));
void fake_rand_set_public_private_callbacks(OSSL_LIB_CTX *libctx,
fake_random_generate_cb *cb);
/* Create a file path from a directory and a filename */
char *test_mk_file_path(const char *dir, const char *file);
EVP_PKEY *load_pkey_pem(const char *file, OSSL_LIB_CTX *libctx);
X509 *load_cert_pem(const char *file, OSSL_LIB_CTX *libctx);
X509 *load_cert_der(const unsigned char *bytes, int len);
STACK_OF(X509) *load_certs_pem(const char *file);
X509_REQ *load_csr_der(const char *file, OSSL_LIB_CTX *libctx);
#endif /* OSSL_TESTUTIL_H */
|