Latest update.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -296,7 +296,8 @@ static int test_asyncio(int test)
|
||||
const char testdata[] = "Test data";
|
||||
char buf[sizeof(testdata)];
|
||||
|
||||
if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
|
||||
if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_server_method(),
|
||||
TLS_client_method(),
|
||||
TLS1_VERSION, 0,
|
||||
&serverctx, &clientctx, cert, privkey)))
|
||||
goto end;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright (c) 2016 Viktor Dukhovni <openssl-users@dukhovni.org>.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "internal/nelem.h"
|
||||
#include "testutil.h"
|
||||
|
||||
DEFINE_STACK_OF(SSL_CIPHER)
|
||||
|
||||
static SSL_CTX *ctx;
|
||||
static SSL *s;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "internal/nelem.h"
|
||||
#include "testutil.h"
|
||||
|
||||
DEFINE_STACK_OF_CONST(SSL_CIPHER)
|
||||
|
||||
typedef struct cipherlist_test_fixture {
|
||||
const char *test_case_name;
|
||||
SSL_CTX *server;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "internal/nelem.h"
|
||||
#include "testutil.h"
|
||||
|
||||
DEFINE_STACK_OF(SSL_CIPHER)
|
||||
|
||||
typedef struct cipher_id_name {
|
||||
int id;
|
||||
const char *name;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
@@ -15,6 +15,9 @@
|
||||
|
||||
#ifndef NDEBUG /* tests need mock server, which is available only if !NDEBUG */
|
||||
|
||||
DEFINE_STACK_OF(X509)
|
||||
DEFINE_STACK_OF(OSSL_CMP_ITAV)
|
||||
|
||||
static const char *server_key_f;
|
||||
static const char *server_cert_f;
|
||||
static const char *client_key_f;
|
||||
|
||||
+7
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
@@ -13,6 +13,12 @@
|
||||
|
||||
#include <openssl/x509_vfy.h>
|
||||
|
||||
DEFINE_STACK_OF(X509)
|
||||
DEFINE_STACK_OF(ASN1_UTF8STRING)
|
||||
DEFINE_STACK_OF(X509_EXTENSION)
|
||||
DEFINE_STACK_OF(OSSL_CMP_ITAV)
|
||||
DEFINE_STACK_OF(POLICYINFO)
|
||||
|
||||
typedef struct test_fixture {
|
||||
const char *test_case_name;
|
||||
OSSL_CMP_CTX *ctx;
|
||||
|
||||
+4
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
#include "cmp_testlib.h"
|
||||
|
||||
DEFINE_STACK_OF(OSSL_CMP_ITAV)
|
||||
DEFINE_STACK_OF(ASN1_UTF8STRING)
|
||||
|
||||
static unsigned char rand_data[OSSL_CMP_TRANSACTIONID_LENGTH];
|
||||
|
||||
typedef struct test_fixture {
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "cmp_testlib.h"
|
||||
|
||||
DEFINE_STACK_OF(OSSL_CMP_CERTRESPONSE)
|
||||
|
||||
static const char *server_cert_f;
|
||||
static const char *pkcs10_f;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "cmp_testlib.h"
|
||||
|
||||
DEFINE_STACK_OF(X509)
|
||||
|
||||
static const char *ir_protected_f;
|
||||
static const char *ir_unprotected_f;
|
||||
static const char *ip_PBM_f;
|
||||
@@ -101,7 +103,7 @@ static int verify_signature(OSSL_CMP_MSG *msg,
|
||||
ASN1_BIT_STRING *protection,
|
||||
EVP_PKEY *pkey, int digest_nid)
|
||||
{
|
||||
CMP_PROTECTEDPART prot_part;
|
||||
OSSL_CMP_PROTECTEDPART prot_part;
|
||||
unsigned char *prot_part_der = NULL;
|
||||
int len;
|
||||
EVP_MD_CTX *ctx = NULL;
|
||||
@@ -110,8 +112,9 @@ static int verify_signature(OSSL_CMP_MSG *msg,
|
||||
|
||||
prot_part.header = OSSL_CMP_MSG_get0_header(msg);
|
||||
prot_part.body = msg->body;
|
||||
len = i2d_OSSL_CMP_PROTECTEDPART(&prot_part, &prot_part_der);
|
||||
res =
|
||||
TEST_int_ge(len = i2d_CMP_PROTECTEDPART(&prot_part, &prot_part_der), 0)
|
||||
TEST_int_ge(len, 0)
|
||||
&& TEST_ptr(ctx = EVP_MD_CTX_new())
|
||||
&& TEST_true(EVP_DigestVerifyInit(ctx, NULL, digest, NULL, pkey))
|
||||
&& TEST_int_eq(EVP_DigestVerify(ctx, protection->data,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "cmp_testlib.h"
|
||||
|
||||
DEFINE_STACK_OF(ASN1_UTF8STRING)
|
||||
|
||||
typedef struct test_fixture {
|
||||
const char *test_case_name;
|
||||
int pkistatus;
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "cmp_testlib.h"
|
||||
#include <openssl/rsa.h> /* needed in case config no-deprecated */
|
||||
|
||||
DEFINE_STACK_OF(X509)
|
||||
|
||||
EVP_PKEY *load_pem_key(const char *file)
|
||||
{
|
||||
EVP_PKEY *key = NULL;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
|
||||
+18
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "cmp_testlib.h"
|
||||
#include "../crypto/crmf/crmf_local.h" /* for manipulating POPO signature */
|
||||
DEFINE_STACK_OF(OSSL_CRMF_MSG)
|
||||
|
||||
static const char *server_f;
|
||||
static const char *client_f;
|
||||
@@ -109,6 +110,7 @@ static int test_verify_popo(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
static int test_verify_popo_bad(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_VFY_TEST_FIXTURE, set_up);
|
||||
@@ -116,6 +118,7 @@ static int test_verify_popo_bad(void)
|
||||
EXECUTE_TEST(execute_verify_popo_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int execute_validate_msg_test(CMP_VFY_TEST_FIXTURE *fixture)
|
||||
{
|
||||
@@ -444,6 +447,7 @@ static void setup_check_received(CMP_VFY_TEST_FIXTURE **fixture, int expected,
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
static int test_MSG_check_received_no_protection_no_cb(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_VFY_TEST_FIXTURE, set_up);
|
||||
@@ -459,6 +463,7 @@ static int test_MSG_check_received_no_protection_restrictive_cb(void)
|
||||
EXECUTE_TEST(execute_MSG_check_received_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int test_MSG_check_received_no_protection_permissive_cb(void)
|
||||
{
|
||||
@@ -484,6 +489,7 @@ static int test_MSG_check_received_check_transaction_id(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
static int test_MSG_check_received_check_transaction_id_bad(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_VFY_TEST_FIXTURE, set_up);
|
||||
@@ -491,6 +497,7 @@ static int test_MSG_check_received_check_transaction_id_bad(void)
|
||||
EXECUTE_TEST(execute_MSG_check_received_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int test_MSG_check_received_check_recipient_nonce(void)
|
||||
{
|
||||
@@ -507,6 +514,7 @@ static int test_MSG_check_received_check_recipient_nonce(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
static int test_MSG_check_received_check_recipient_nonce_bad(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_VFY_TEST_FIXTURE, set_up);
|
||||
@@ -514,6 +522,7 @@ static int test_MSG_check_received_check_recipient_nonce_bad(void)
|
||||
EXECUTE_TEST(execute_MSG_check_received_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
@@ -596,7 +605,9 @@ int setup_tests(void)
|
||||
|
||||
/* Message validation tests */
|
||||
ADD_TEST(test_verify_popo);
|
||||
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
ADD_TEST(test_verify_popo_bad);
|
||||
#endif
|
||||
ADD_TEST(test_validate_msg_signature_trusted_ok);
|
||||
ADD_TEST(test_validate_msg_signature_trusted_expired);
|
||||
ADD_TEST(test_validate_msg_signature_srvcert_wrong);
|
||||
@@ -617,13 +628,19 @@ int setup_tests(void)
|
||||
ADD_TEST(test_validate_cert_path_expired);
|
||||
ADD_TEST(test_validate_cert_path_wrong_anchor);
|
||||
|
||||
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
ADD_TEST(test_MSG_check_received_no_protection_no_cb);
|
||||
ADD_TEST(test_MSG_check_received_no_protection_restrictive_cb);
|
||||
#endif
|
||||
ADD_TEST(test_MSG_check_received_no_protection_permissive_cb);
|
||||
ADD_TEST(test_MSG_check_received_check_transaction_id);
|
||||
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
ADD_TEST(test_MSG_check_received_check_transaction_id_bad);
|
||||
#endif
|
||||
ADD_TEST(test_MSG_check_received_check_recipient_nonce);
|
||||
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
ADD_TEST(test_MSG_check_received_check_recipient_nonce_bad);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "testutil.h"
|
||||
|
||||
DEFINE_STACK_OF(X509)
|
||||
|
||||
static X509 *cert = NULL;
|
||||
static EVP_PKEY *privkey = NULL;
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
#include <openssl/safestack.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
DEFINE_STACK_OF(CONF_VALUE)
|
||||
DEFINE_STACK_OF_CSTRING()
|
||||
|
||||
static STACK_OF(OPENSSL_CSTRING) *section_names = NULL;
|
||||
|
||||
static void collect_section_name(CONF_VALUE *v)
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
#include "testutil.h"
|
||||
|
||||
DEFINE_STACK_OF(X509)
|
||||
DEFINE_STACK_OF(X509_CRL)
|
||||
|
||||
#define PARAM_TIME 1474934400 /* Sep 27th, 2016 */
|
||||
|
||||
static const char *kCRLTestRoot[] = {
|
||||
|
||||
+4
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#ifndef OPENSSL_NO_CT
|
||||
|
||||
DEFINE_STACK_OF(SCT)
|
||||
|
||||
/* Used when declaring buffers to read text files into */
|
||||
# define CT_TEST_MAX_FILE_SIZE 8096
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include "internal/nelem.h"
|
||||
|
||||
DEFINE_STACK_OF(X509)
|
||||
|
||||
#define _UC(c) ((unsigned char)(c))
|
||||
|
||||
static const char *basedomain;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
openssl_conf = openssl_init
|
||||
|
||||
.include fipsinstall.cnf
|
||||
.include fipsmodule.cnf
|
||||
|
||||
[openssl_init]
|
||||
providers = provider_sect
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2011-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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2018-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
|
||||
|
||||
+201
-40
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
@@ -23,6 +23,8 @@
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/dsa.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/core_names.h>
|
||||
|
||||
#include "testutil.h"
|
||||
#include "internal/nelem.h"
|
||||
@@ -30,45 +32,6 @@
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
static int dsa_cb(int p, int n, BN_GENCB *arg);
|
||||
|
||||
/*
|
||||
* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to FIPS
|
||||
* PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1
|
||||
*/
|
||||
static unsigned char seed[20] = {
|
||||
0xd5, 0x01, 0x4e, 0x4b, 0x60, 0xef, 0x2b, 0xa8, 0xb6, 0x21, 0x1b, 0x40,
|
||||
0x62, 0xba, 0x32, 0x24, 0xe0, 0x42, 0x7d, 0xd3,
|
||||
};
|
||||
|
||||
static unsigned char out_p[] = {
|
||||
0x8d, 0xf2, 0xa4, 0x94, 0x49, 0x22, 0x76, 0xaa,
|
||||
0x3d, 0x25, 0x75, 0x9b, 0xb0, 0x68, 0x69, 0xcb,
|
||||
0xea, 0xc0, 0xd8, 0x3a, 0xfb, 0x8d, 0x0c, 0xf7,
|
||||
0xcb, 0xb8, 0x32, 0x4f, 0x0d, 0x78, 0x82, 0xe5,
|
||||
0xd0, 0x76, 0x2f, 0xc5, 0xb7, 0x21, 0x0e, 0xaf,
|
||||
0xc2, 0xe9, 0xad, 0xac, 0x32, 0xab, 0x7a, 0xac,
|
||||
0x49, 0x69, 0x3d, 0xfb, 0xf8, 0x37, 0x24, 0xc2,
|
||||
0xec, 0x07, 0x36, 0xee, 0x31, 0xc8, 0x02, 0x91,
|
||||
};
|
||||
|
||||
static unsigned char out_q[] = {
|
||||
0xc7, 0x73, 0x21, 0x8c, 0x73, 0x7e, 0xc8, 0xee,
|
||||
0x99, 0x3b, 0x4f, 0x2d, 0xed, 0x30, 0xf4, 0x8e,
|
||||
0xda, 0xce, 0x91, 0x5f,
|
||||
};
|
||||
|
||||
static unsigned char out_g[] = {
|
||||
0x62, 0x6d, 0x02, 0x78, 0x39, 0xea, 0x0a, 0x13,
|
||||
0x41, 0x31, 0x63, 0xa5, 0x5b, 0x4c, 0xb5, 0x00,
|
||||
0x29, 0x9d, 0x55, 0x22, 0x95, 0x6c, 0xef, 0xcb,
|
||||
0x3b, 0xff, 0x10, 0xf3, 0x99, 0xce, 0x2c, 0x2e,
|
||||
0x71, 0xcb, 0x9d, 0xe5, 0xfa, 0x24, 0xba, 0xbf,
|
||||
0x58, 0xe5, 0xb7, 0x95, 0x21, 0x92, 0x5c, 0x9c,
|
||||
0xc4, 0x2e, 0x9f, 0x6f, 0x46, 0x4b, 0x08, 0x8c,
|
||||
0xc5, 0x72, 0xaf, 0x53, 0xe6, 0xd7, 0x88, 0x02,
|
||||
};
|
||||
|
||||
static const unsigned char str1[] = "12345678901234567890";
|
||||
|
||||
static int dsa_test(void)
|
||||
{
|
||||
BN_GENCB *cb;
|
||||
@@ -79,6 +42,41 @@ static int dsa_test(void)
|
||||
unsigned char sig[256];
|
||||
unsigned int siglen;
|
||||
const BIGNUM *p = NULL, *q = NULL, *g = NULL;
|
||||
/*
|
||||
* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to FIPS
|
||||
* PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1
|
||||
*/
|
||||
static unsigned char seed[20] = {
|
||||
0xd5, 0x01, 0x4e, 0x4b, 0x60, 0xef, 0x2b, 0xa8,
|
||||
0xb6, 0x21, 0x1b, 0x40, 0x62, 0xba, 0x32, 0x24,
|
||||
0xe0, 0x42, 0x7d, 0xd3,
|
||||
};
|
||||
static unsigned char out_p[] = {
|
||||
0x8d, 0xf2, 0xa4, 0x94, 0x49, 0x22, 0x76, 0xaa,
|
||||
0x3d, 0x25, 0x75, 0x9b, 0xb0, 0x68, 0x69, 0xcb,
|
||||
0xea, 0xc0, 0xd8, 0x3a, 0xfb, 0x8d, 0x0c, 0xf7,
|
||||
0xcb, 0xb8, 0x32, 0x4f, 0x0d, 0x78, 0x82, 0xe5,
|
||||
0xd0, 0x76, 0x2f, 0xc5, 0xb7, 0x21, 0x0e, 0xaf,
|
||||
0xc2, 0xe9, 0xad, 0xac, 0x32, 0xab, 0x7a, 0xac,
|
||||
0x49, 0x69, 0x3d, 0xfb, 0xf8, 0x37, 0x24, 0xc2,
|
||||
0xec, 0x07, 0x36, 0xee, 0x31, 0xc8, 0x02, 0x91,
|
||||
};
|
||||
static unsigned char out_q[] = {
|
||||
0xc7, 0x73, 0x21, 0x8c, 0x73, 0x7e, 0xc8, 0xee,
|
||||
0x99, 0x3b, 0x4f, 0x2d, 0xed, 0x30, 0xf4, 0x8e,
|
||||
0xda, 0xce, 0x91, 0x5f,
|
||||
};
|
||||
static unsigned char out_g[] = {
|
||||
0x62, 0x6d, 0x02, 0x78, 0x39, 0xea, 0x0a, 0x13,
|
||||
0x41, 0x31, 0x63, 0xa5, 0x5b, 0x4c, 0xb5, 0x00,
|
||||
0x29, 0x9d, 0x55, 0x22, 0x95, 0x6c, 0xef, 0xcb,
|
||||
0x3b, 0xff, 0x10, 0xf3, 0x99, 0xce, 0x2c, 0x2e,
|
||||
0x71, 0xcb, 0x9d, 0xe5, 0xfa, 0x24, 0xba, 0xbf,
|
||||
0x58, 0xe5, 0xb7, 0x95, 0x21, 0x92, 0x5c, 0x9c,
|
||||
0xc4, 0x2e, 0x9f, 0x6f, 0x46, 0x4b, 0x08, 0x8c,
|
||||
0xc5, 0x72, 0xaf, 0x53, 0xe6, 0xd7, 0x88, 0x02,
|
||||
};
|
||||
static const unsigned char str1[] = "12345678901234567890";
|
||||
|
||||
if (!TEST_ptr(cb = BN_GENCB_new()))
|
||||
goto end;
|
||||
@@ -136,12 +134,175 @@ static int dsa_cb(int p, int n, BN_GENCB *arg)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
# define P 0
|
||||
# define Q 1
|
||||
# define G 2
|
||||
# define SEED 3
|
||||
# define PCOUNT 4
|
||||
# define GINDEX 5
|
||||
# define HCOUNT 6
|
||||
# define GROUP 7
|
||||
|
||||
static int dsa_keygen_test(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY *param_key = NULL, *key = NULL;
|
||||
EVP_PKEY_CTX *pg_ctx = NULL, *kg_ctx = NULL;
|
||||
BIGNUM *p_in = NULL, *q_in = NULL, *g_in = NULL;
|
||||
BIGNUM *p_out = NULL, *q_out = NULL, *g_out = NULL;
|
||||
int gindex_out = 0, pcount_out = 0, hcount_out = 0;
|
||||
unsigned char seed_out[32];
|
||||
char group_out[32];
|
||||
size_t len = 0;
|
||||
static const unsigned char seed_data[] = {
|
||||
0xa6, 0xf5, 0x28, 0x8c, 0x50, 0x77, 0xa5, 0x68,
|
||||
0x6d, 0x3a, 0xf5, 0xf1, 0xc6, 0x4c, 0xdc, 0x35,
|
||||
0x95, 0x26, 0x3f, 0x03, 0xdc, 0x00, 0x3f, 0x44,
|
||||
0x7b, 0x2a, 0xc7, 0x29
|
||||
};
|
||||
static const unsigned char expected_p[]= {
|
||||
0xdb, 0x47, 0x07, 0xaf, 0xf0, 0x06, 0x49, 0x55,
|
||||
0xc9, 0xbb, 0x09, 0x41, 0xb8, 0xdb, 0x1f, 0xbc,
|
||||
0xa8, 0xed, 0x12, 0x06, 0x7f, 0x88, 0x49, 0xb8,
|
||||
0xc9, 0x12, 0x87, 0x21, 0xbb, 0x08, 0x6c, 0xbd,
|
||||
0xf1, 0x89, 0xef, 0x84, 0xd9, 0x7a, 0x93, 0xe8,
|
||||
0x45, 0x40, 0x81, 0xec, 0x37, 0x27, 0x1a, 0xa4,
|
||||
0x22, 0x51, 0x99, 0xf0, 0xde, 0x04, 0xdb, 0xea,
|
||||
0xa1, 0xf9, 0x37, 0x83, 0x80, 0x96, 0x36, 0x53,
|
||||
0xf6, 0xae, 0x14, 0x73, 0x33, 0x0f, 0xdf, 0x0b,
|
||||
0xf9, 0x2f, 0x08, 0x46, 0x31, 0xf9, 0x66, 0xcd,
|
||||
0x5a, 0xeb, 0x6c, 0xf3, 0xbb, 0x74, 0xf3, 0x88,
|
||||
0xf0, 0x31, 0x5c, 0xa4, 0xc8, 0x0f, 0x86, 0xf3,
|
||||
0x0f, 0x9f, 0xc0, 0x8c, 0x57, 0xe4, 0x7f, 0x95,
|
||||
0xb3, 0x62, 0xc8, 0x4e, 0xae, 0xf3, 0xd8, 0x14,
|
||||
0xcc, 0x47, 0xc2, 0x4b, 0x4f, 0xef, 0xaf, 0xcd,
|
||||
0xcf, 0xb2, 0xbb, 0xe8, 0xbe, 0x08, 0xca, 0x15,
|
||||
0x90, 0x59, 0x35, 0xef, 0x35, 0x1c, 0xfe, 0xeb,
|
||||
0x33, 0x2e, 0x25, 0x22, 0x57, 0x9c, 0x55, 0x23,
|
||||
0x0c, 0x6f, 0xed, 0x7c, 0xb6, 0xc7, 0x36, 0x0b,
|
||||
0xcb, 0x2b, 0x6a, 0x21, 0xa1, 0x1d, 0x55, 0x77,
|
||||
0xd9, 0x91, 0xcd, 0xc1, 0xcd, 0x3d, 0x82, 0x16,
|
||||
0x9c, 0xa0, 0x13, 0xa5, 0x83, 0x55, 0x3a, 0x73,
|
||||
0x7e, 0x2c, 0x44, 0x3e, 0x70, 0x2e, 0x50, 0x91,
|
||||
0x6e, 0xca, 0x3b, 0xef, 0xff, 0x85, 0x35, 0x70,
|
||||
0xff, 0x61, 0x0c, 0xb1, 0xb2, 0xb7, 0x94, 0x6f,
|
||||
0x65, 0xa4, 0x57, 0x62, 0xef, 0x21, 0x83, 0x0f,
|
||||
0x3e, 0x71, 0xae, 0x7d, 0xe4, 0xad, 0xfb, 0xe3,
|
||||
0xdd, 0xd6, 0x03, 0xda, 0x9a, 0xd8, 0x8f, 0x2d,
|
||||
0xbb, 0x90, 0x87, 0xf8, 0xdb, 0xdc, 0xec, 0x71,
|
||||
0xf2, 0xdb, 0x0b, 0x8e, 0xfc, 0x1a, 0x7e, 0x79,
|
||||
0xb1, 0x1b, 0x0d, 0xfc, 0x70, 0xec, 0x85, 0xc2,
|
||||
0xc5, 0xba, 0xb9, 0x69, 0x3f, 0x88, 0xbc, 0xcb
|
||||
};
|
||||
static const unsigned char expected_q[]= {
|
||||
0x99, 0xb6, 0xa0, 0xee, 0xb3, 0xa6, 0x99, 0x1a,
|
||||
0xb6, 0x67, 0x8d, 0xc1, 0x2b, 0x9b, 0xce, 0x2b,
|
||||
0x01, 0x72, 0x5a, 0x65, 0x76, 0x3d, 0x93, 0x69,
|
||||
0xe2, 0x56, 0xae, 0xd7
|
||||
};
|
||||
static const unsigned char expected_g[]= {
|
||||
0x63, 0xf8, 0xb6, 0xee, 0x2a, 0x27, 0xaf, 0x4f,
|
||||
0x4c, 0xf6, 0x08, 0x28, 0x87, 0x4a, 0xe7, 0x1f,
|
||||
0x45, 0x46, 0x27, 0x52, 0x3b, 0x7f, 0x6f, 0xd2,
|
||||
0x29, 0xcb, 0xe8, 0x11, 0x19, 0x25, 0x35, 0x76,
|
||||
0x99, 0xcb, 0x4f, 0x1b, 0xe0, 0xed, 0x32, 0x9e,
|
||||
0x05, 0xb5, 0xbe, 0xd7, 0xf6, 0x5a, 0xb2, 0xf6,
|
||||
0x0e, 0x0c, 0x7e, 0xf5, 0xe1, 0x05, 0xfe, 0xda,
|
||||
0xaf, 0x0f, 0x27, 0x1e, 0x40, 0x2a, 0xf7, 0xa7,
|
||||
0x23, 0x49, 0x2c, 0xd9, 0x1b, 0x0a, 0xbe, 0xff,
|
||||
0xc7, 0x7c, 0x7d, 0x60, 0xca, 0xa3, 0x19, 0xc3,
|
||||
0xb7, 0xe4, 0x43, 0xb0, 0xf5, 0x75, 0x44, 0x90,
|
||||
0x46, 0x47, 0xb1, 0xa6, 0x48, 0x0b, 0x21, 0x8e,
|
||||
0xee, 0x75, 0xe6, 0x3d, 0xa7, 0xd3, 0x7b, 0x31,
|
||||
0xd1, 0xd2, 0x9d, 0xe2, 0x8a, 0xfc, 0x57, 0xfd,
|
||||
0x8a, 0x10, 0x31, 0xeb, 0x87, 0x36, 0x3f, 0x65,
|
||||
0x72, 0x23, 0x2c, 0xd3, 0xd6, 0x17, 0xa5, 0x62,
|
||||
0x58, 0x65, 0x57, 0x6a, 0xd4, 0xa8, 0xfe, 0xec,
|
||||
0x57, 0x76, 0x0c, 0xb1, 0x4c, 0x93, 0xed, 0xb0,
|
||||
0xb4, 0xf9, 0x45, 0xb3, 0x3e, 0xdd, 0x47, 0xf1,
|
||||
0xfb, 0x7d, 0x25, 0x79, 0x3d, 0xfc, 0xa7, 0x39,
|
||||
0x90, 0x68, 0x6a, 0x6b, 0xae, 0xf2, 0x6e, 0x64,
|
||||
0x8c, 0xfb, 0xb8, 0xdd, 0x76, 0x4e, 0x4a, 0x69,
|
||||
0x8c, 0x97, 0x15, 0x77, 0xb2, 0x67, 0xdc, 0xeb,
|
||||
0x4a, 0x40, 0x6b, 0xb9, 0x47, 0x8f, 0xa6, 0xab,
|
||||
0x6e, 0x98, 0xc0, 0x97, 0x9a, 0x0c, 0xea, 0x00,
|
||||
0xfd, 0x56, 0x1a, 0x74, 0x9a, 0x32, 0x6b, 0xfe,
|
||||
0xbd, 0xdf, 0x6c, 0x82, 0x54, 0x53, 0x4d, 0x70,
|
||||
0x65, 0xe3, 0x8b, 0x37, 0xb8, 0xe4, 0x70, 0x08,
|
||||
0xb7, 0x3b, 0x30, 0x27, 0xaf, 0x1c, 0x77, 0xf3,
|
||||
0x62, 0xd4, 0x9a, 0x59, 0xba, 0xd1, 0x6e, 0x89,
|
||||
0x5c, 0x34, 0x9a, 0xa1, 0xb7, 0x4f, 0x7d, 0x8c,
|
||||
0xdc, 0xbc, 0x74, 0x25, 0x5e, 0xbf, 0x77, 0x46
|
||||
};
|
||||
int expected_c = 1316;
|
||||
int expected_h = 2;
|
||||
|
||||
if (!TEST_ptr(p_in = BN_bin2bn(expected_p, sizeof(expected_p), NULL))
|
||||
|| !TEST_ptr(q_in = BN_bin2bn(expected_q, sizeof(expected_q), NULL))
|
||||
|| !TEST_ptr(g_in = BN_bin2bn(expected_g, sizeof(expected_g), NULL)))
|
||||
goto end;
|
||||
if (!TEST_ptr(pg_ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL))
|
||||
|| !TEST_int_gt(EVP_PKEY_paramgen_init(pg_ctx), 0)
|
||||
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_bits(pg_ctx, 2048))
|
||||
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_q_bits(pg_ctx, 224))
|
||||
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_seed(pg_ctx, seed_data,
|
||||
sizeof(seed_data)))
|
||||
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_md_props(pg_ctx, "SHA256",
|
||||
""))
|
||||
|| !TEST_int_gt(EVP_PKEY_gen(pg_ctx, ¶m_key), 0)
|
||||
|| !TEST_ptr(kg_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, param_key, NULL))
|
||||
|| !TEST_int_gt(EVP_PKEY_keygen_init(kg_ctx), 0)
|
||||
|| !TEST_int_gt(EVP_PKEY_gen(kg_ctx, &key), 0))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(EVP_PKEY_get_bn_param(key, OSSL_PKEY_PARAM_FFC_P, &p_out))
|
||||
|| !TEST_BN_eq(p_in, p_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(key, OSSL_PKEY_PARAM_FFC_Q, &q_out))
|
||||
|| !TEST_BN_eq(q_in, q_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(key, OSSL_PKEY_PARAM_FFC_G, &g_out))
|
||||
|| !TEST_BN_eq(g_in, g_out)
|
||||
|| !TEST_true(EVP_PKEY_get_octet_string_param(
|
||||
key, OSSL_PKEY_PARAM_FFC_SEED, seed_out,
|
||||
sizeof(seed_out), &len))
|
||||
|| !TEST_mem_eq(seed_out, len, seed_data, sizeof(seed_data))
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(key, OSSL_PKEY_PARAM_FFC_GINDEX,
|
||||
&gindex_out))
|
||||
|| !TEST_int_eq(gindex_out, -1)
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(key, OSSL_PKEY_PARAM_FFC_H,
|
||||
&hcount_out))
|
||||
|| !TEST_int_eq(hcount_out, expected_h)
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(key,
|
||||
OSSL_PKEY_PARAM_FFC_PCOUNTER,
|
||||
&pcount_out))
|
||||
|| !TEST_int_eq(pcount_out, expected_c)
|
||||
|| !TEST_false(EVP_PKEY_get_utf8_string_param(key,
|
||||
OSSL_PKEY_PARAM_FFC_GROUP,
|
||||
group_out,
|
||||
sizeof(group_out), &len)))
|
||||
goto end;
|
||||
ret = 1;
|
||||
end:
|
||||
BN_free(p_in);
|
||||
BN_free(q_in);
|
||||
BN_free(g_in);
|
||||
BN_free(p_out);
|
||||
BN_free(q_out);
|
||||
BN_free(g_out);
|
||||
EVP_PKEY_free(param_key);
|
||||
EVP_PKEY_free(key);
|
||||
EVP_PKEY_CTX_free(kg_ctx);
|
||||
EVP_PKEY_CTX_free(pg_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* OPENSSL_NO_DSA */
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
ADD_TEST(dsa_test);
|
||||
ADD_TEST(dsa_keygen_test);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -20,6 +20,8 @@
|
||||
/* for SSL_READ_ETM() */
|
||||
#include "../ssl/ssl_local.h"
|
||||
|
||||
DEFINE_STACK_OF(SSL_CIPHER)
|
||||
|
||||
static int debug = 0;
|
||||
|
||||
static unsigned int clnt_psk_callback(SSL *ssl, const char *hint,
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -61,7 +61,7 @@ static int test_dtls_unprocessed(int testidx)
|
||||
|
||||
timer_cb_count = 0;
|
||||
|
||||
if (!TEST_true(create_ssl_ctx_pair(DTLS_server_method(),
|
||||
if (!TEST_true(create_ssl_ctx_pair(NULL, DTLS_server_method(),
|
||||
DTLS_client_method(),
|
||||
DTLS1_VERSION, 0,
|
||||
&sctx, &cctx, cert, privkey)))
|
||||
@@ -156,7 +156,7 @@ static int test_dtls_drop_records(int idx)
|
||||
SSL_SESSION *sess = NULL;
|
||||
int cli_to_srv_epoch0, cli_to_srv_epoch1, srv_to_cli_epoch0;
|
||||
|
||||
if (!TEST_true(create_ssl_ctx_pair(DTLS_server_method(),
|
||||
if (!TEST_true(create_ssl_ctx_pair(NULL, DTLS_server_method(),
|
||||
DTLS_client_method(),
|
||||
DTLS1_VERSION, 0,
|
||||
&sctx, &cctx, cert, privkey)))
|
||||
@@ -267,7 +267,7 @@ static int test_cookie(void)
|
||||
SSL *serverssl = NULL, *clientssl = NULL;
|
||||
int testresult = 0;
|
||||
|
||||
if (!TEST_true(create_ssl_ctx_pair(DTLS_server_method(),
|
||||
if (!TEST_true(create_ssl_ctx_pair(NULL, DTLS_server_method(),
|
||||
DTLS_client_method(),
|
||||
DTLS1_VERSION, 0,
|
||||
&sctx, &cctx, cert, privkey)))
|
||||
@@ -299,7 +299,7 @@ static int test_dtls_duplicate_records(void)
|
||||
SSL *serverssl = NULL, *clientssl = NULL;
|
||||
int testresult = 0;
|
||||
|
||||
if (!TEST_true(create_ssl_ctx_pair(DTLS_server_method(),
|
||||
if (!TEST_true(create_ssl_ctx_pair(NULL, DTLS_server_method(),
|
||||
DTLS_client_method(),
|
||||
DTLS1_VERSION, 0,
|
||||
&sctx, &cctx, cert, privkey)))
|
||||
|
||||
+75
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -188,6 +188,77 @@ static int field_tests_default(int n)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
/*
|
||||
* Tests a point known to cause an incorrect underflow in an old version of
|
||||
* ecp_nist521.c
|
||||
*/
|
||||
static int underflow_test(void)
|
||||
{
|
||||
BN_CTX *ctx = NULL;
|
||||
EC_GROUP *grp = NULL;
|
||||
EC_POINT *P = NULL, *Q = NULL, *R = NULL;
|
||||
BIGNUM *x1 = NULL, *y1 = NULL, *z1 = NULL, *x2 = NULL, *y2 = NULL;
|
||||
BIGNUM *k = NULL;
|
||||
int testresult = 0;
|
||||
const char *x1str =
|
||||
"1534f0077fffffe87e9adcfe000000000000000000003e05a21d2400002e031b1f4"
|
||||
"b80000c6fafa4f3c1288798d624a247b5e2ffffffffffffffefe099241900004";
|
||||
const char *p521m1 =
|
||||
"1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe";
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (!TEST_ptr(ctx))
|
||||
return 0;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
x1 = BN_CTX_get(ctx);
|
||||
y1 = BN_CTX_get(ctx);
|
||||
z1 = BN_CTX_get(ctx);
|
||||
x2 = BN_CTX_get(ctx);
|
||||
y2 = BN_CTX_get(ctx);
|
||||
k = BN_CTX_get(ctx);
|
||||
if (!TEST_ptr(k))
|
||||
goto err;
|
||||
|
||||
grp = EC_GROUP_new_by_curve_name(NID_secp521r1);
|
||||
P = EC_POINT_new(grp);
|
||||
Q = EC_POINT_new(grp);
|
||||
R = EC_POINT_new(grp);
|
||||
if (!TEST_ptr(grp) || !TEST_ptr(P) || !TEST_ptr(Q) || !TEST_ptr(R))
|
||||
goto err;
|
||||
|
||||
if (!TEST_int_gt(BN_hex2bn(&x1, x1str), 0)
|
||||
|| !TEST_int_gt(BN_hex2bn(&y1, p521m1), 0)
|
||||
|| !TEST_int_gt(BN_hex2bn(&z1, p521m1), 0)
|
||||
|| !TEST_int_gt(BN_hex2bn(&k, "02"), 0)
|
||||
|| !TEST_true(ec_GFp_simple_set_Jprojective_coordinates_GFp(grp, P, x1,
|
||||
y1, z1, ctx))
|
||||
|| !TEST_true(EC_POINT_mul(grp, Q, NULL, P, k, ctx))
|
||||
|| !TEST_true(EC_POINT_get_affine_coordinates(grp, Q, x1, y1, ctx))
|
||||
|| !TEST_true(EC_POINT_dbl(grp, R, P, ctx))
|
||||
|| !TEST_true(EC_POINT_get_affine_coordinates(grp, R, x2, y2, ctx)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_int_eq(BN_cmp(x1, x2), 0)
|
||||
|| !TEST_int_eq(BN_cmp(y1, y2), 0))
|
||||
goto err;
|
||||
|
||||
testresult = 1;
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
EC_POINT_free(P);
|
||||
EC_POINT_free(Q);
|
||||
EC_POINT_free(R);
|
||||
EC_GROUP_free(grp);
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
return testresult;
|
||||
}
|
||||
#endif
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
crv_len = EC_get_builtin_curves(NULL, 0);
|
||||
@@ -201,6 +272,9 @@ int setup_tests(void)
|
||||
ADD_TEST(field_tests_ec2_simple);
|
||||
#endif
|
||||
ADD_ALL_TESTS(field_tests_default, crv_len);
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
ADD_TEST(underflow_test);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
|
||||
+1
-80
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
@@ -268,15 +268,6 @@ static int prime_field_tests(void)
|
||||
test_output_memory("Generator as octet string, hybrid form:",
|
||||
buf, len);
|
||||
|
||||
if (!TEST_true(EC_POINT_get_Jprojective_coordinates_GFp(group, R, x, y, z,
|
||||
ctx)))
|
||||
goto err;
|
||||
TEST_info("A representation of the inverse of that generator in");
|
||||
TEST_note("Jacobian projective coordinates");
|
||||
test_output_bignum("x", x);
|
||||
test_output_bignum("y", y);
|
||||
test_output_bignum("z", z);
|
||||
|
||||
if (!TEST_true(EC_POINT_invert(group, P, ctx))
|
||||
|| !TEST_int_eq(0, EC_POINT_cmp(group, P, R, ctx))
|
||||
|
||||
@@ -1441,75 +1432,6 @@ err:
|
||||
BN_CTX_free(ctx);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests a point known to cause an incorrect underflow in an old version of
|
||||
* ecp_nist521.c
|
||||
*/
|
||||
static int underflow_test(void)
|
||||
{
|
||||
BN_CTX *ctx = NULL;
|
||||
EC_GROUP *grp = NULL;
|
||||
EC_POINT *P = NULL, *Q = NULL, *R = NULL;
|
||||
BIGNUM *x1 = NULL, *y1 = NULL, *z1 = NULL, *x2 = NULL, *y2 = NULL;
|
||||
BIGNUM *k = NULL;
|
||||
int testresult = 0;
|
||||
const char *x1str =
|
||||
"1534f0077fffffe87e9adcfe000000000000000000003e05a21d2400002e031b1f4"
|
||||
"b80000c6fafa4f3c1288798d624a247b5e2ffffffffffffffefe099241900004";
|
||||
const char *p521m1 =
|
||||
"1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe";
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (!TEST_ptr(ctx))
|
||||
return 0;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
x1 = BN_CTX_get(ctx);
|
||||
y1 = BN_CTX_get(ctx);
|
||||
z1 = BN_CTX_get(ctx);
|
||||
x2 = BN_CTX_get(ctx);
|
||||
y2 = BN_CTX_get(ctx);
|
||||
k = BN_CTX_get(ctx);
|
||||
if (!TEST_ptr(k))
|
||||
goto err;
|
||||
|
||||
grp = EC_GROUP_new_by_curve_name(NID_secp521r1);
|
||||
P = EC_POINT_new(grp);
|
||||
Q = EC_POINT_new(grp);
|
||||
R = EC_POINT_new(grp);
|
||||
if (!TEST_ptr(grp) || !TEST_ptr(P) || !TEST_ptr(Q) || !TEST_ptr(R))
|
||||
goto err;
|
||||
|
||||
if (!TEST_int_gt(BN_hex2bn(&x1, x1str), 0)
|
||||
|| !TEST_int_gt(BN_hex2bn(&y1, p521m1), 0)
|
||||
|| !TEST_int_gt(BN_hex2bn(&z1, p521m1), 0)
|
||||
|| !TEST_int_gt(BN_hex2bn(&k, "02"), 0)
|
||||
|| !TEST_true(EC_POINT_set_Jprojective_coordinates_GFp(grp, P, x1,
|
||||
y1, z1, ctx))
|
||||
|| !TEST_true(EC_POINT_mul(grp, Q, NULL, P, k, ctx))
|
||||
|| !TEST_true(EC_POINT_get_affine_coordinates(grp, Q, x1, y1, ctx))
|
||||
|| !TEST_true(EC_POINT_dbl(grp, R, P, ctx))
|
||||
|| !TEST_true(EC_POINT_get_affine_coordinates(grp, R, x2, y2, ctx)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_int_eq(BN_cmp(x1, x2), 0)
|
||||
|| !TEST_int_eq(BN_cmp(y1, y2), 0))
|
||||
goto err;
|
||||
|
||||
testresult = 1;
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
EC_POINT_free(P);
|
||||
EC_POINT_free(Q);
|
||||
EC_POINT_free(R);
|
||||
EC_GROUP_free(grp);
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
return testresult;
|
||||
}
|
||||
# endif
|
||||
|
||||
static const unsigned char p521_named[] = {
|
||||
@@ -2468,7 +2390,6 @@ int setup_tests(void)
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
ADD_ALL_TESTS(nistp_single_test, OSSL_NELEM(nistp_tests_params));
|
||||
ADD_TEST(underflow_test);
|
||||
# endif
|
||||
ADD_ALL_TESTS(internal_curve_test, crv_len);
|
||||
ADD_ALL_TESTS(internal_curve_test_method, crv_len);
|
||||
|
||||
+43
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -1540,6 +1540,47 @@ static int test_EVP_PKEY_set1_DH(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We test what happens with an empty template. For the sake of this test,
|
||||
* the template must be ignored, and we know that's the case for RSA keys
|
||||
* (this might arguably be a misfeature, but that's what we currently do,
|
||||
* even in provider code, since that's how the legacy RSA implementation
|
||||
* does things)
|
||||
*/
|
||||
static int test_keygen_with_empty_template(int n)
|
||||
{
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
EVP_PKEY *tkey = NULL;
|
||||
int ret = 0;
|
||||
|
||||
switch (n) {
|
||||
case 0:
|
||||
/* We do test with no template at all as well */
|
||||
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL)))
|
||||
goto err;
|
||||
break;
|
||||
case 1:
|
||||
/* Here we create an empty RSA key that serves as our template */
|
||||
if (!TEST_ptr(tkey = EVP_PKEY_new())
|
||||
|| !TEST_true(EVP_PKEY_set_type(tkey, EVP_PKEY_RSA))
|
||||
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new(tkey, NULL)))
|
||||
goto err;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!TEST_int_gt(EVP_PKEY_keygen_init(ctx), 0)
|
||||
|| !TEST_int_gt(EVP_PKEY_keygen(ctx, &pkey), 0))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
EVP_PKEY_free(pkey);
|
||||
EVP_PKEY_free(tkey);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_ALL_TESTS(test_EVP_DigestSignInit, 9);
|
||||
@@ -1579,6 +1620,7 @@ int setup_tests(void)
|
||||
#ifndef OPENSSL_NO_DH
|
||||
ADD_TEST(test_EVP_PKEY_set1_DH);
|
||||
#endif
|
||||
ADD_ALL_TESTS(test_keygen_with_empty_template, 2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+479
-37
@@ -12,12 +12,12 @@
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/serializer.h>
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/param_build.h>
|
||||
#include <openssl/core_names.h>
|
||||
#include "crypto/ecx.h"
|
||||
#include "internal/nelem.h"
|
||||
#include "openssl/param_build.h"
|
||||
#include "crypto/evp.h" /* For the internal API */
|
||||
#include "crypto/bn_dh.h" /* _bignum_ffdhe2048_p */
|
||||
#include "internal/nelem.h"
|
||||
#include "testutil.h"
|
||||
|
||||
static char *datadir = NULL;
|
||||
@@ -49,7 +49,7 @@ static int compare_with_file(const char *alg, int type, BIO *membio)
|
||||
{
|
||||
char filename[80];
|
||||
BIO *file = NULL;
|
||||
char buf[1024];
|
||||
char buf[4096];
|
||||
char *memdata, *fullfile = NULL;
|
||||
const char *suffix;
|
||||
size_t readbytes;
|
||||
@@ -391,46 +391,119 @@ static int test_evp_pkey_get_bn_param_large(void)
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_DH
|
||||
/* Array indexes used in test_fromdata_dh */
|
||||
#define PRIV_KEY 0
|
||||
#define PUB_KEY 1
|
||||
#define FFC_P 2
|
||||
#define FFC_G 3
|
||||
|
||||
static int test_fromdata_dh(void)
|
||||
static int test_fromdata_dh_named_group(void)
|
||||
{
|
||||
int ret = 0;
|
||||
int gindex = 0, pcounter = 0, hindex = 0;
|
||||
EVP_PKEY_CTX *ctx = NULL, *key_ctx = NULL;
|
||||
EVP_PKEY *pk = NULL, *copy_pk = NULL;
|
||||
size_t len;
|
||||
BIGNUM *pub = NULL, *priv = NULL;
|
||||
BIGNUM *pub_out = NULL, *priv_out = NULL;
|
||||
BIGNUM *p = NULL, *q = NULL, *g = NULL, *j = NULL;
|
||||
OSSL_PARAM *fromdata_params = NULL;
|
||||
OSSL_PARAM_BLD *bld = NULL;
|
||||
char name_out[80];
|
||||
unsigned char seed_out[32];
|
||||
|
||||
/*
|
||||
* 32-bit DH key, extracted from this command,
|
||||
* executed with OpenSSL 1.0.2:
|
||||
*
|
||||
* openssl dhparam -out dhp.pem 32
|
||||
* openssl genpkey -paramfile dhp.pem | openssl pkey -text
|
||||
* DH key data was generated using the following:
|
||||
* openssl genpkey -algorithm DH -pkeyopt group:ffdhe2048
|
||||
* -pkeyopt priv_len:224 -text
|
||||
*/
|
||||
static unsigned long key_numbers[] = {
|
||||
0x666c2b06, /* priv-key */
|
||||
0x6fa6de50, /* pub-key */
|
||||
0x8bb45f53, /* P */
|
||||
0x2, /* G */
|
||||
static const unsigned char priv_data[] = {
|
||||
0x88, 0x85, 0xe7, 0x9f, 0xee, 0x6d, 0xc5, 0x7c, 0x78, 0xaf, 0x63, 0x5d,
|
||||
0x38, 0x2a, 0xd0, 0xed, 0x56, 0x4b, 0x47, 0x21, 0x2b, 0xfa, 0x55, 0xfa,
|
||||
0x87, 0xe8, 0xa9, 0x7b,
|
||||
};
|
||||
OSSL_PARAM fromdata_params[] = {
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_PRIV_KEY, &key_numbers[PRIV_KEY]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_PUB_KEY, &key_numbers[PUB_KEY]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_FFC_P, &key_numbers[FFC_P]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_FFC_G, &key_numbers[FFC_G]),
|
||||
OSSL_PARAM_END
|
||||
static const unsigned char pub_data[] = {
|
||||
0x00, 0xd6, 0x2d, 0x77, 0xe0, 0xd3, 0x7d, 0xf8, 0xeb, 0x98, 0x50, 0xa1,
|
||||
0x82, 0x22, 0x65, 0xd5, 0xd9, 0xfe, 0xc9, 0x3f, 0xbe, 0x16, 0x83, 0xbd,
|
||||
0x33, 0xe9, 0xc6, 0x93, 0xcf, 0x08, 0xaf, 0x83, 0xfa, 0x80, 0x8a, 0x6c,
|
||||
0x64, 0xdf, 0x70, 0x64, 0xd5, 0x0a, 0x7c, 0x5a, 0x72, 0xda, 0x66, 0xe6,
|
||||
0xf9, 0xf5, 0x31, 0x21, 0x92, 0xb0, 0x60, 0x1a, 0xb5, 0xd3, 0xf0, 0xa5,
|
||||
0xfa, 0x48, 0x95, 0x2e, 0x38, 0xd9, 0xc5, 0xe6, 0xda, 0xfb, 0x6c, 0x03,
|
||||
0x9d, 0x4b, 0x69, 0xb7, 0x95, 0xe4, 0x5c, 0xc0, 0x93, 0x4f, 0x48, 0xd9,
|
||||
0x7e, 0x06, 0x22, 0xb2, 0xde, 0xf3, 0x79, 0x24, 0xed, 0xe1, 0xd1, 0x4a,
|
||||
0x57, 0xf1, 0x40, 0x86, 0x70, 0x42, 0x25, 0xc5, 0x27, 0x68, 0xc9, 0xfa,
|
||||
0xe5, 0x8e, 0x62, 0x7e, 0xff, 0x49, 0x6c, 0x5b, 0xb5, 0xba, 0xf9, 0xef,
|
||||
0x9a, 0x1a, 0x10, 0xd4, 0x81, 0x53, 0xcf, 0x83, 0x04, 0x18, 0x1c, 0xe1,
|
||||
0xdb, 0xe1, 0x65, 0xa9, 0x7f, 0xe1, 0x33, 0xeb, 0xc3, 0x4f, 0xe3, 0xb7,
|
||||
0x22, 0xf7, 0x1c, 0x09, 0x4f, 0xed, 0xc6, 0x07, 0x8e, 0x78, 0x05, 0x8f,
|
||||
0x7c, 0x96, 0xd9, 0x12, 0xe0, 0x81, 0x74, 0x1a, 0xe9, 0x13, 0xc0, 0x20,
|
||||
0x82, 0x65, 0xbb, 0x42, 0x3b, 0xed, 0x08, 0x6a, 0x84, 0x4f, 0xea, 0x77,
|
||||
0x14, 0x32, 0xf9, 0xed, 0xc2, 0x12, 0xd6, 0xc5, 0xc6, 0xb3, 0xe5, 0xf2,
|
||||
0x6e, 0xf6, 0x16, 0x7f, 0x37, 0xde, 0xbc, 0x09, 0xc7, 0x06, 0x6b, 0x12,
|
||||
0xbc, 0xad, 0x2d, 0x49, 0x25, 0xd5, 0xdc, 0xf4, 0x18, 0x14, 0xd2, 0xf0,
|
||||
0xf1, 0x1d, 0x1f, 0x3a, 0xaa, 0x15, 0x55, 0xbb, 0x0d, 0x7f, 0xbe, 0x67,
|
||||
0xa1, 0xa7, 0xf0, 0xaa, 0xb3, 0xfb, 0x41, 0x82, 0x39, 0x49, 0x93, 0xbc,
|
||||
0xa8, 0xee, 0x72, 0x13, 0x45, 0x65, 0x15, 0x42, 0x17, 0xaa, 0xd8, 0xab,
|
||||
0xcf, 0x33, 0x42, 0x83, 0x42
|
||||
};
|
||||
static const char group_name[] = "ffdhe2048";
|
||||
|
||||
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|
||||
|| !TEST_ptr(pub = BN_bin2bn(pub_data, sizeof(pub_data), NULL))
|
||||
|| !TEST_ptr(priv = BN_bin2bn(priv_data, sizeof(priv_data), NULL))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_utf8_string(bld,
|
||||
OSSL_PKEY_PARAM_FFC_GROUP,
|
||||
group_name, 0))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PUB_KEY, pub))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PRIV_KEY, priv))
|
||||
|| !TEST_ptr(fromdata_params = OSSL_PARAM_BLD_to_param(bld)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "DH", NULL)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(EVP_PKEY_key_fromdata_init(ctx))
|
||||
|| !TEST_true(EVP_PKEY_fromdata(ctx, &pk, fromdata_params))
|
||||
|| !TEST_int_eq(EVP_PKEY_bits(pk), 32)
|
||||
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), 0) /* Missing Q */
|
||||
|| !TEST_int_eq(EVP_PKEY_size(pk), 4))
|
||||
|| !TEST_int_eq(EVP_PKEY_bits(pk), 2048)
|
||||
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), 112)
|
||||
|| !TEST_int_eq(EVP_PKEY_size(pk), 256))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_FFC_GROUP,
|
||||
name_out, sizeof(name_out),
|
||||
&len))
|
||||
|| !TEST_str_eq(name_out, group_name)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_PUB_KEY,
|
||||
&pub_out))
|
||||
|
||||
|| !TEST_BN_eq(pub, pub_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_PRIV_KEY,
|
||||
&priv_out))
|
||||
|| !TEST_BN_eq(priv, priv_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_P, &p))
|
||||
|| !TEST_BN_eq(&_bignum_ffdhe2048_p, p)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_Q, &q))
|
||||
|| !TEST_ptr(q)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_G, &g))
|
||||
|| !TEST_BN_eq(&_bignum_const_2, g)
|
||||
|| !TEST_false(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_COFACTOR,
|
||||
&j))
|
||||
|| !TEST_ptr_null(j)
|
||||
|| !TEST_false(EVP_PKEY_get_octet_string_param(pk,
|
||||
OSSL_PKEY_PARAM_FFC_SEED,
|
||||
seed_out,
|
||||
sizeof(seed_out), &len))
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(pk, OSSL_PKEY_PARAM_FFC_GINDEX,
|
||||
&gindex))
|
||||
|| !TEST_int_eq(gindex, -1)
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(pk, OSSL_PKEY_PARAM_FFC_H, &hindex))
|
||||
|| !TEST_int_eq(hindex, 0)
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(pk, OSSL_PKEY_PARAM_FFC_PCOUNTER,
|
||||
&pcounter))
|
||||
|| !TEST_int_eq(pcounter, -1))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(key_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, pk, "")))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(EVP_PKEY_check(key_ctx))
|
||||
|| !TEST_true(EVP_PKEY_public_check(key_ctx))
|
||||
|| !TEST_true(EVP_PKEY_private_check(key_ctx))
|
||||
|| !TEST_true(EVP_PKEY_pairwise_check(key_ctx)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(copy_pk = EVP_PKEY_new())
|
||||
@@ -439,26 +512,164 @@ static int test_fromdata_dh(void)
|
||||
|
||||
ret = test_print_key_using_pem("DH", pk)
|
||||
&& test_print_key_using_serializer("DH", pk);
|
||||
err:
|
||||
BN_free(p);
|
||||
BN_free(q);
|
||||
BN_free(g);
|
||||
BN_free(j);
|
||||
BN_free(pub);
|
||||
BN_free(priv);
|
||||
BN_free(pub_out);
|
||||
BN_free(priv_out);
|
||||
EVP_PKEY_free(copy_pk);
|
||||
EVP_PKEY_free(pk);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
EVP_PKEY_CTX_free(key_ctx);
|
||||
OSSL_PARAM_BLD_free_params(fromdata_params);
|
||||
OSSL_PARAM_BLD_free(bld);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_fromdata_dh_fips186_4(void)
|
||||
{
|
||||
int ret = 0;
|
||||
int gindex = 0, pcounter = 0, hindex = 0;
|
||||
EVP_PKEY_CTX *ctx = NULL, *key_ctx = NULL;
|
||||
EVP_PKEY *pk = NULL;
|
||||
size_t len;
|
||||
BIGNUM *pub = NULL, *priv = NULL;
|
||||
BIGNUM *pub_out = NULL, *priv_out = NULL;
|
||||
BIGNUM *p = NULL, *q = NULL, *g = NULL, *j = NULL;
|
||||
OSSL_PARAM_BLD *bld = NULL;
|
||||
OSSL_PARAM *fromdata_params = NULL;
|
||||
char name_out[80];
|
||||
unsigned char seed_out[32];
|
||||
|
||||
/*
|
||||
* DH key data was generated using the following:
|
||||
* openssl genpkey -algorithm DH
|
||||
* -pkeyopt group:ffdhe2048 -pkeyopt priv_len:224 -text
|
||||
*/
|
||||
static const unsigned char priv_data[] = {
|
||||
0x88, 0x85, 0xe7, 0x9f, 0xee, 0x6d, 0xc5, 0x7c, 0x78, 0xaf, 0x63, 0x5d,
|
||||
0x38, 0x2a, 0xd0, 0xed, 0x56, 0x4b, 0x47, 0x21, 0x2b, 0xfa, 0x55, 0xfa,
|
||||
0x87, 0xe8, 0xa9, 0x7b,
|
||||
};
|
||||
static const unsigned char pub_data[] = {
|
||||
0xd6, 0x2d, 0x77, 0xe0, 0xd3, 0x7d, 0xf8, 0xeb, 0x98, 0x50, 0xa1, 0x82,
|
||||
0x22, 0x65, 0xd5, 0xd9, 0xfe, 0xc9, 0x3f, 0xbe, 0x16, 0x83, 0xbd, 0x33,
|
||||
0xe9, 0xc6, 0x93, 0xcf, 0x08, 0xaf, 0x83, 0xfa, 0x80, 0x8a, 0x6c, 0x64,
|
||||
0xdf, 0x70, 0x64, 0xd5, 0x0a, 0x7c, 0x5a, 0x72, 0xda, 0x66, 0xe6, 0xf9,
|
||||
0xf5, 0x31, 0x21, 0x92, 0xb0, 0x60, 0x1a, 0xb5, 0xd3, 0xf0, 0xa5, 0xfa,
|
||||
0x48, 0x95, 0x2e, 0x38, 0xd9, 0xc5, 0xe6, 0xda, 0xfb, 0x6c, 0x03, 0x9d,
|
||||
0x4b, 0x69, 0xb7, 0x95, 0xe4, 0x5c, 0xc0, 0x93, 0x4f, 0x48, 0xd9, 0x7e,
|
||||
0x06, 0x22, 0xb2, 0xde, 0xf3, 0x79, 0x24, 0xed, 0xe1, 0xd1, 0x4a, 0x57,
|
||||
0xf1, 0x40, 0x86, 0x70, 0x42, 0x25, 0xc5, 0x27, 0x68, 0xc9, 0xfa, 0xe5,
|
||||
0x8e, 0x62, 0x7e, 0xff, 0x49, 0x6c, 0x5b, 0xb5, 0xba, 0xf9, 0xef, 0x9a,
|
||||
0x1a, 0x10, 0xd4, 0x81, 0x53, 0xcf, 0x83, 0x04, 0x18, 0x1c, 0xe1, 0xdb,
|
||||
0xe1, 0x65, 0xa9, 0x7f, 0xe1, 0x33, 0xeb, 0xc3, 0x4f, 0xe3, 0xb7, 0x22,
|
||||
0xf7, 0x1c, 0x09, 0x4f, 0xed, 0xc6, 0x07, 0x8e, 0x78, 0x05, 0x8f, 0x7c,
|
||||
0x96, 0xd9, 0x12, 0xe0, 0x81, 0x74, 0x1a, 0xe9, 0x13, 0xc0, 0x20, 0x82,
|
||||
0x65, 0xbb, 0x42, 0x3b, 0xed, 0x08, 0x6a, 0x84, 0x4f, 0xea, 0x77, 0x14,
|
||||
0x32, 0xf9, 0xed, 0xc2, 0x12, 0xd6, 0xc5, 0xc6, 0xb3, 0xe5, 0xf2, 0x6e,
|
||||
0xf6, 0x16, 0x7f, 0x37, 0xde, 0xbc, 0x09, 0xc7, 0x06, 0x6b, 0x12, 0xbc,
|
||||
0xad, 0x2d, 0x49, 0x25, 0xd5, 0xdc, 0xf4, 0x18, 0x14, 0xd2, 0xf0, 0xf1,
|
||||
0x1d, 0x1f, 0x3a, 0xaa, 0x15, 0x55, 0xbb, 0x0d, 0x7f, 0xbe, 0x67, 0xa1,
|
||||
0xa7, 0xf0, 0xaa, 0xb3, 0xfb, 0x41, 0x82, 0x39, 0x49, 0x93, 0xbc, 0xa8,
|
||||
0xee, 0x72, 0x13, 0x45, 0x65, 0x15, 0x42, 0x17, 0xaa, 0xd8, 0xab, 0xcf,
|
||||
0x33, 0x42, 0x83, 0x42
|
||||
};
|
||||
static const char group_name[] = "ffdhe2048";
|
||||
|
||||
|
||||
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|
||||
|| !TEST_ptr(pub = BN_bin2bn(pub_data, sizeof(pub_data), NULL))
|
||||
|| !TEST_ptr(priv = BN_bin2bn(priv_data, sizeof(priv_data), NULL))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_utf8_string(bld,
|
||||
OSSL_PKEY_PARAM_FFC_GROUP,
|
||||
group_name, 0))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PUB_KEY, pub))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PRIV_KEY, priv))
|
||||
|| !TEST_ptr(fromdata_params = OSSL_PARAM_BLD_to_param(bld)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "DH", NULL)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(EVP_PKEY_key_fromdata_init(ctx))
|
||||
|| !TEST_true(EVP_PKEY_fromdata(ctx, &pk, fromdata_params))
|
||||
|| !TEST_int_eq(EVP_PKEY_bits(pk), 2048)
|
||||
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), 112)
|
||||
|| !TEST_int_eq(EVP_PKEY_size(pk), 256))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_FFC_GROUP,
|
||||
name_out, sizeof(name_out),
|
||||
&len))
|
||||
|| !TEST_str_eq(name_out, group_name)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_PUB_KEY,
|
||||
&pub_out))
|
||||
|| !TEST_BN_eq(pub, pub_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_PRIV_KEY,
|
||||
&priv_out))
|
||||
|| !TEST_BN_eq(priv, priv_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_P, &p))
|
||||
|| !TEST_BN_eq(&_bignum_ffdhe2048_p, p)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_Q, &q))
|
||||
|| !TEST_ptr(q)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_G, &g))
|
||||
|| !TEST_BN_eq(&_bignum_const_2, g)
|
||||
|| !TEST_false(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_COFACTOR,
|
||||
&j))
|
||||
|| !TEST_ptr_null(j)
|
||||
|| !TEST_false(EVP_PKEY_get_octet_string_param(pk,
|
||||
OSSL_PKEY_PARAM_FFC_SEED,
|
||||
seed_out,
|
||||
sizeof(seed_out), &len))
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(pk, OSSL_PKEY_PARAM_FFC_GINDEX,
|
||||
&gindex))
|
||||
|| !TEST_int_eq(gindex, -1)
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(pk, OSSL_PKEY_PARAM_FFC_H, &hindex))
|
||||
|| !TEST_int_eq(hindex, 0)
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(pk, OSSL_PKEY_PARAM_FFC_PCOUNTER,
|
||||
&pcounter))
|
||||
|| !TEST_int_eq(pcounter, -1))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(key_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, pk, "")))
|
||||
goto err;
|
||||
|
||||
if (!TEST_false(EVP_PKEY_check(key_ctx))
|
||||
if (!TEST_true(EVP_PKEY_check(key_ctx))
|
||||
|| !TEST_true(EVP_PKEY_public_check(key_ctx))
|
||||
|| !TEST_false(EVP_PKEY_private_check(key_ctx)) /* Need a q */
|
||||
|| !TEST_true(EVP_PKEY_private_check(key_ctx))
|
||||
|| !TEST_true(EVP_PKEY_pairwise_check(key_ctx)))
|
||||
goto err;
|
||||
|
||||
err:
|
||||
ret = test_print_key_using_pem("DH", pk)
|
||||
&& test_print_key_using_serializer("DH", pk);
|
||||
err:
|
||||
BN_free(p);
|
||||
BN_free(q);
|
||||
BN_free(g);
|
||||
BN_free(j);
|
||||
BN_free(pub);
|
||||
BN_free(priv);
|
||||
BN_free(pub_out);
|
||||
BN_free(priv_out);
|
||||
EVP_PKEY_free(pk);
|
||||
EVP_PKEY_free(copy_pk);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
EVP_PKEY_CTX_free(key_ctx);
|
||||
OSSL_PARAM_BLD_free_params(fromdata_params);
|
||||
OSSL_PARAM_BLD_free(bld);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
/* Array indexes used in test_fromdata_ecx */
|
||||
# define PRIV_KEY 0
|
||||
@@ -678,7 +889,7 @@ static int test_fromdata_ec(void)
|
||||
int ret = 0;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
EVP_PKEY *pk = NULL, *copy_pk = NULL;
|
||||
OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new();
|
||||
OSSL_PARAM_BLD *bld = NULL;
|
||||
BIGNUM *ec_priv_bn = NULL;
|
||||
BIGNUM *bn_priv = NULL;
|
||||
OSSL_PARAM *fromdata_params = NULL;
|
||||
@@ -709,7 +920,7 @@ static int test_fromdata_ec(void)
|
||||
size_t len;
|
||||
|
||||
|
||||
if (!TEST_ptr(bld))
|
||||
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new()))
|
||||
goto err;
|
||||
if (!TEST_ptr(ec_priv_bn = BN_bin2bn(ec_priv_keydata,
|
||||
sizeof(ec_priv_keydata), NULL)))
|
||||
@@ -776,6 +987,233 @@ err:
|
||||
|
||||
#endif /* OPENSSL_NO_EC */
|
||||
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
static int test_fromdata_dsa_fips186_4(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY_CTX *ctx = NULL, *key_ctx = NULL;
|
||||
EVP_PKEY *pk = NULL, *copy_pk = NULL;
|
||||
BIGNUM *pub = NULL, *priv = NULL;
|
||||
BIGNUM *p = NULL, *q = NULL, *g = NULL;
|
||||
BIGNUM *pub_out = NULL, *priv_out = NULL;
|
||||
BIGNUM *p_out = NULL, *q_out = NULL, *g_out = NULL, *j_out = NULL;
|
||||
int gindex_out = 0, pcounter_out = 0, hindex_out = 0;
|
||||
char name_out[80];
|
||||
unsigned char seed_out[32];
|
||||
size_t len;
|
||||
OSSL_PARAM_BLD *bld = NULL;
|
||||
OSSL_PARAM *fromdata_params = NULL;
|
||||
|
||||
/*
|
||||
* DSA parameter data was generated using the following:
|
||||
* openssl genpkey -genparam -algorithm DSA -pkeyopt pbits:2048 \
|
||||
* -pkeyopt qbits:256 -pkeyopt type:0 \
|
||||
* -pkeyopt gindex:1 -out dsa_params.pem -text
|
||||
*/
|
||||
static const unsigned char p_data[] = {
|
||||
0x00, 0xa0, 0xb7, 0x02, 0xc4, 0xac, 0xa6, 0x42, 0xab, 0xf2, 0x34, 0x0b,
|
||||
0x22, 0x47, 0x1f, 0x33, 0xcf, 0xd5, 0x04, 0xe4, 0x3e, 0xec, 0xa1, 0x21,
|
||||
0xc8, 0x41, 0x2b, 0xef, 0xb8, 0x1f, 0x0b, 0x5b, 0x88, 0x8b, 0x67, 0xf8,
|
||||
0x68, 0x6d, 0x7c, 0x4d, 0x96, 0x5f, 0x3c, 0x66, 0xef, 0x58, 0x34, 0xd7,
|
||||
0xf6, 0xa2, 0x1b, 0xad, 0xc8, 0x12, 0x52, 0xb8, 0xe8, 0x2a, 0x63, 0xcc,
|
||||
0xea, 0xe7, 0x4e, 0xc8, 0x34, 0x4c, 0x58, 0x59, 0x0a, 0xc2, 0x4a, 0xe4,
|
||||
0xb4, 0x64, 0x20, 0xf4, 0xf6, 0x0a, 0xcf, 0x86, 0x01, 0x6c, 0x7f, 0x23,
|
||||
0x4a, 0x51, 0x07, 0x99, 0x42, 0x28, 0x7a, 0xff, 0x18, 0x67, 0x52, 0x64,
|
||||
0xf2, 0x9a, 0x62, 0x30, 0xc3, 0x00, 0xde, 0x23, 0xe9, 0x11, 0x95, 0x7e,
|
||||
0xd1, 0x3d, 0x8d, 0xb4, 0x0e, 0x9f, 0x9e, 0xb1, 0x30, 0x03, 0xf0, 0x73,
|
||||
0xa8, 0x40, 0x48, 0x42, 0x7b, 0x60, 0xa0, 0xc4, 0xf2, 0x3b, 0x2d, 0x0a,
|
||||
0x0c, 0xb8, 0x19, 0xfb, 0xb4, 0xf8, 0xe0, 0x2a, 0xc7, 0xf1, 0xc0, 0xc6,
|
||||
0x86, 0x14, 0x60, 0x12, 0x0f, 0xc0, 0xde, 0x4a, 0x67, 0xec, 0xc7, 0xde,
|
||||
0x76, 0x21, 0x1a, 0x55, 0x7f, 0x86, 0xc3, 0x97, 0x98, 0xce, 0xf5, 0xcd,
|
||||
0xf0, 0xe7, 0x12, 0xd6, 0x93, 0xee, 0x1b, 0x9b, 0x61, 0xef, 0x05, 0x8c,
|
||||
0x45, 0x46, 0xd9, 0x64, 0x6f, 0xbe, 0x27, 0xaa, 0x67, 0x01, 0xcc, 0x71,
|
||||
0xb1, 0x60, 0xce, 0x21, 0xd8, 0x51, 0x17, 0x27, 0x0d, 0x90, 0x3d, 0x18,
|
||||
0x7c, 0x87, 0x15, 0x8e, 0x48, 0x4c, 0x6c, 0xc5, 0x72, 0xeb, 0xb7, 0x56,
|
||||
0xf5, 0x6b, 0x60, 0x8f, 0xc2, 0xfd, 0x3f, 0x46, 0x5c, 0x00, 0x91, 0x85,
|
||||
0x79, 0x45, 0x5b, 0x1c, 0x82, 0xc4, 0x87, 0x50, 0x79, 0xba, 0xcc, 0x1c,
|
||||
0x32, 0x7e, 0x2e, 0xb8, 0x2e, 0xc5, 0x4e, 0xd1, 0x9b, 0xdb, 0x66, 0x79,
|
||||
0x7c, 0xfe, 0xaf, 0x6a, 0x05
|
||||
};
|
||||
static const unsigned char q_data[] = {
|
||||
0xa8, 0xcd, 0xf4, 0x33, 0x7b, 0x13, 0x0a, 0x24, 0xc1, 0xde, 0x4a, 0x04,
|
||||
0x7b, 0x4b, 0x71, 0x51, 0x32, 0xe9, 0x47, 0x74, 0xbd, 0x0c, 0x21, 0x40,
|
||||
0x84, 0x12, 0x0a, 0x17, 0x73, 0xdb, 0x29, 0xc7
|
||||
};
|
||||
static const unsigned char g_data[] = {
|
||||
0x6c, 0xc6, 0xa4, 0x3e, 0x61, 0x84, 0xc1, 0xff, 0x6f, 0x4a, 0x1a, 0x6b,
|
||||
0xb0, 0x24, 0x4b, 0xd2, 0x92, 0x5b, 0x29, 0x5c, 0x61, 0xb8, 0xc9, 0x2b,
|
||||
0xd6, 0xf7, 0x59, 0xfd, 0xd8, 0x70, 0x66, 0x77, 0xfc, 0xc1, 0xa4, 0xd4,
|
||||
0xb0, 0x1e, 0xd5, 0xbf, 0x59, 0x98, 0xb3, 0x66, 0x8b, 0xf4, 0x2e, 0xe6,
|
||||
0x12, 0x3e, 0xcc, 0xf8, 0x02, 0xb8, 0xc6, 0xc3, 0x47, 0xd2, 0xf5, 0xaa,
|
||||
0x0c, 0x5f, 0x51, 0xf5, 0xd0, 0x4c, 0x55, 0x3d, 0x07, 0x73, 0xa6, 0x57,
|
||||
0xce, 0x5a, 0xad, 0x42, 0x0c, 0x13, 0x0f, 0xe2, 0x31, 0x25, 0x8e, 0x72,
|
||||
0x12, 0x73, 0x10, 0xdb, 0x7f, 0x79, 0xeb, 0x59, 0xfc, 0xfe, 0xf7, 0x0c,
|
||||
0x1a, 0x81, 0x53, 0x96, 0x22, 0xb8, 0xe7, 0x58, 0xd8, 0x67, 0x80, 0x60,
|
||||
0xad, 0x8b, 0x55, 0x1c, 0x91, 0xf0, 0x72, 0x9a, 0x7e, 0xad, 0x37, 0xf1,
|
||||
0x77, 0x18, 0x96, 0x8a, 0x68, 0x70, 0xfc, 0x71, 0xa9, 0xa2, 0xe8, 0x35,
|
||||
0x27, 0x78, 0xf2, 0xef, 0x59, 0x36, 0x6d, 0x7c, 0xb6, 0x98, 0xd8, 0x1e,
|
||||
0xfa, 0x25, 0x73, 0x97, 0x45, 0x58, 0xe3, 0xae, 0xbd, 0x52, 0x54, 0x05,
|
||||
0xd8, 0x26, 0x26, 0xba, 0xba, 0x05, 0xb5, 0xe9, 0xe5, 0x76, 0xae, 0x25,
|
||||
0xdd, 0xfc, 0x10, 0x89, 0x5a, 0xa9, 0xee, 0x59, 0xc5, 0x79, 0x8b, 0xeb,
|
||||
0x1e, 0x2c, 0x61, 0xab, 0x0d, 0xd1, 0x10, 0x04, 0x91, 0x32, 0x77, 0x4a,
|
||||
0xa6, 0x64, 0x53, 0xda, 0x4c, 0xd7, 0x3a, 0x29, 0xd4, 0xf3, 0x82, 0x25,
|
||||
0x1d, 0x6f, 0x4a, 0x7f, 0xd3, 0x08, 0x3b, 0x42, 0x30, 0x10, 0xd8, 0xd0,
|
||||
0x97, 0x3a, 0xeb, 0x92, 0x63, 0xec, 0x93, 0x2b, 0x6f, 0x32, 0xd8, 0xcd,
|
||||
0x80, 0xd3, 0xc0, 0x4c, 0x03, 0xd5, 0xca, 0xbc, 0x8f, 0xc7, 0x43, 0x53,
|
||||
0x64, 0x66, 0x1c, 0x82, 0x2d, 0xfb, 0xff, 0x39, 0xba, 0xd6, 0x42, 0x62,
|
||||
0x02, 0x6f, 0x96, 0x36
|
||||
};
|
||||
static const unsigned char seed_data[] = {
|
||||
0x64, 0x46, 0x07, 0x32, 0x8d, 0x70, 0x9c, 0xb3, 0x8a, 0x35, 0xde, 0x62,
|
||||
0x00, 0xf2, 0x6d, 0x52, 0x37, 0x4d, 0xb3, 0x84, 0xe1, 0x9d, 0x41, 0x04,
|
||||
0xda, 0x7b, 0xdc, 0x0d, 0x8b, 0x5e, 0xe0, 0x84
|
||||
};
|
||||
const int gindex = 1;
|
||||
const int pcounter = 53;
|
||||
/*
|
||||
* The keypair was generated using
|
||||
* openssl genpkey -paramfile dsa_params.pem --pkeyopt pcounter:53 \
|
||||
* -pkeyopt gindex:1 \
|
||||
* -pkeyopt hexseed:644607328d709cb38a35de6200f26d -text
|
||||
*/
|
||||
static const unsigned char priv_data[] = {
|
||||
0x00, 0x8f, 0xc5, 0x9e, 0xd0, 0xf7, 0x2a, 0x0b, 0x66, 0xf1, 0x32, 0x73,
|
||||
0xae, 0xf6, 0xd9, 0xd4, 0xdb, 0x2d, 0x96, 0x55, 0x89, 0xff, 0xef, 0xa8,
|
||||
0x5f, 0x47, 0x8f, 0xca, 0x02, 0x8a, 0xe1, 0x35, 0x90
|
||||
};
|
||||
static const unsigned char pub_data[] = {
|
||||
0x44, 0x19, 0xc9, 0x46, 0x45, 0x57, 0xc1, 0xa9, 0xd8, 0x30, 0x99, 0x29,
|
||||
0x6a, 0x4b, 0x63, 0x71, 0x69, 0x96, 0x35, 0x17, 0xb2, 0x62, 0x9b, 0x80,
|
||||
0x0a, 0x95, 0x9d, 0x6a, 0xc0, 0x32, 0x0d, 0x07, 0x5f, 0x19, 0x44, 0x02,
|
||||
0xf1, 0xbd, 0xce, 0xdf, 0x10, 0xf8, 0x02, 0x5d, 0x7d, 0x98, 0x8a, 0x73,
|
||||
0x89, 0x00, 0xb6, 0x24, 0xd6, 0x33, 0xe7, 0xcf, 0x8b, 0x49, 0x2a, 0xaf,
|
||||
0x13, 0x1c, 0xb2, 0x52, 0x15, 0xfd, 0x9b, 0xd5, 0x40, 0x4a, 0x1a, 0xda,
|
||||
0x29, 0x4c, 0x92, 0x7e, 0x66, 0x06, 0xdb, 0x61, 0x86, 0xac, 0xb5, 0xda,
|
||||
0x3c, 0x7d, 0x73, 0x7e, 0x54, 0x32, 0x68, 0xa5, 0x02, 0xbc, 0x59, 0x47,
|
||||
0x84, 0xd3, 0x87, 0x71, 0x5f, 0xeb, 0x43, 0x45, 0x24, 0xd3, 0xec, 0x08,
|
||||
0x52, 0xc2, 0x89, 0x2d, 0x9c, 0x1a, 0xcc, 0x91, 0x65, 0x5d, 0xa3, 0xa1,
|
||||
0x35, 0x31, 0x10, 0x1c, 0x3a, 0xa8, 0x4d, 0x18, 0xd5, 0x06, 0xaf, 0xb2,
|
||||
0xec, 0x5c, 0x89, 0x9e, 0x90, 0x86, 0x10, 0x01, 0xeb, 0x51, 0xd5, 0x1b,
|
||||
0x9c, 0xcb, 0x66, 0x07, 0x3f, 0xc4, 0x6e, 0x0a, 0x1b, 0x73, 0xa0, 0x4b,
|
||||
0x5f, 0x4d, 0xab, 0x35, 0x28, 0xfa, 0xda, 0x3a, 0x0c, 0x08, 0xe8, 0xf3,
|
||||
0xef, 0x42, 0x67, 0xbc, 0x21, 0xf2, 0xc2, 0xb8, 0xff, 0x1a, 0x81, 0x05,
|
||||
0x68, 0x73, 0x62, 0xdf, 0xd7, 0xab, 0x0f, 0x22, 0x89, 0x57, 0x96, 0xd4,
|
||||
0x93, 0xaf, 0xa1, 0x21, 0xa3, 0x48, 0xe9, 0xf0, 0x97, 0x47, 0xa0, 0x27,
|
||||
0xba, 0x87, 0xb8, 0x15, 0x5f, 0xff, 0x2c, 0x50, 0x41, 0xf1, 0x7e, 0xc6,
|
||||
0x81, 0xc4, 0x51, 0xf1, 0xfd, 0xd6, 0x86, 0xf7, 0x69, 0x97, 0xf1, 0x49,
|
||||
0xc9, 0xf9, 0xf4, 0x9b, 0xf4, 0xe8, 0x85, 0xa7, 0xbd, 0x36, 0x55, 0x4a,
|
||||
0x3d, 0xe8, 0x65, 0x09, 0x7b, 0xb7, 0x12, 0x64, 0xd2, 0x0a, 0x53, 0x60,
|
||||
0x48, 0xd1, 0x8a, 0xbd
|
||||
};
|
||||
|
||||
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|
||||
|| !TEST_ptr(pub = BN_bin2bn(pub_data, sizeof(pub_data), NULL))
|
||||
|| !TEST_ptr(priv = BN_bin2bn(priv_data, sizeof(priv_data), NULL))
|
||||
|| !TEST_ptr(p = BN_bin2bn(p_data, sizeof(p_data), NULL))
|
||||
|| !TEST_ptr(q = BN_bin2bn(q_data, sizeof(q_data), NULL))
|
||||
|| !TEST_ptr(g = BN_bin2bn(g_data, sizeof(g_data), NULL))
|
||||
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_FFC_P, p))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_FFC_Q, q))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_FFC_G, g))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_octet_string(bld,
|
||||
OSSL_PKEY_PARAM_FFC_SEED,
|
||||
seed_data,
|
||||
sizeof(seed_data)))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_int(bld, OSSL_PKEY_PARAM_FFC_GINDEX,
|
||||
gindex))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_int(bld,
|
||||
OSSL_PKEY_PARAM_FFC_PCOUNTER,
|
||||
pcounter))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PUB_KEY,
|
||||
pub))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PRIV_KEY,
|
||||
priv))
|
||||
|| !TEST_ptr(fromdata_params = OSSL_PARAM_BLD_to_param(bld)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(EVP_PKEY_key_fromdata_init(ctx))
|
||||
|| !TEST_true(EVP_PKEY_fromdata(ctx, &pk, fromdata_params))
|
||||
|| !TEST_int_eq(EVP_PKEY_bits(pk), 2048)
|
||||
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), 112)
|
||||
|| !TEST_int_eq(EVP_PKEY_size(pk), 2 + 2 * (3 + sizeof(q_data))))
|
||||
goto err;
|
||||
|
||||
if (!TEST_false(EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_FFC_GROUP,
|
||||
name_out, sizeof(name_out),
|
||||
&len))
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_PUB_KEY,
|
||||
&pub_out))
|
||||
|| !TEST_BN_eq(pub, pub_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_PRIV_KEY,
|
||||
&priv_out))
|
||||
|| !TEST_BN_eq(priv, priv_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_P, &p_out))
|
||||
|| !TEST_BN_eq(p, p_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_Q, &q_out))
|
||||
|| !TEST_BN_eq(q, q_out)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_G, &g_out))
|
||||
|| !TEST_BN_eq(g, g_out)
|
||||
|| !TEST_false(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_FFC_COFACTOR,
|
||||
&j_out))
|
||||
|| !TEST_ptr_null(j_out)
|
||||
|| !TEST_true(EVP_PKEY_get_octet_string_param(pk,
|
||||
OSSL_PKEY_PARAM_FFC_SEED,
|
||||
seed_out, sizeof(seed_out),
|
||||
&len))
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(pk, OSSL_PKEY_PARAM_FFC_GINDEX,
|
||||
&gindex_out))
|
||||
|| !TEST_int_eq(gindex, gindex_out)
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(pk, OSSL_PKEY_PARAM_FFC_H,
|
||||
&hindex_out))
|
||||
|| !TEST_int_eq(hindex_out, 0)
|
||||
|| !TEST_true(EVP_PKEY_get_int_param(pk, OSSL_PKEY_PARAM_FFC_PCOUNTER,
|
||||
&pcounter_out))
|
||||
|| !TEST_int_eq(pcounter, pcounter_out))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(key_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, pk, "")))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(EVP_PKEY_check(key_ctx))
|
||||
|| !TEST_true(EVP_PKEY_public_check(key_ctx))
|
||||
|| !TEST_true(EVP_PKEY_private_check(key_ctx))
|
||||
|| !TEST_true(EVP_PKEY_pairwise_check(key_ctx)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(copy_pk = EVP_PKEY_new())
|
||||
|| !TEST_true(EVP_PKEY_copy_parameters(copy_pk, pk)))
|
||||
goto err;
|
||||
|
||||
ret = test_print_key_using_pem("DSA", pk)
|
||||
&& test_print_key_using_serializer("DSA", pk);
|
||||
err:
|
||||
OSSL_PARAM_BLD_free_params(fromdata_params);
|
||||
OSSL_PARAM_BLD_free(bld);
|
||||
BN_free(p);
|
||||
BN_free(q);
|
||||
BN_free(g);
|
||||
BN_free(pub);
|
||||
BN_free(priv);
|
||||
BN_free(p_out);
|
||||
BN_free(q_out);
|
||||
BN_free(g_out);
|
||||
BN_free(pub_out);
|
||||
BN_free(priv_out);
|
||||
BN_free(j_out);
|
||||
EVP_PKEY_free(pk);
|
||||
EVP_PKEY_free(copy_pk);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
EVP_PKEY_CTX_free(key_ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* OPENSSL_NO_DSA */
|
||||
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (!test_skip_common_options()) {
|
||||
@@ -789,7 +1227,11 @@ int setup_tests(void)
|
||||
ADD_TEST(test_evp_pkey_get_bn_param_large);
|
||||
ADD_TEST(test_fromdata_rsa);
|
||||
#ifndef OPENSSL_NO_DH
|
||||
ADD_TEST(test_fromdata_dh);
|
||||
ADD_TEST(test_fromdata_dh_fips186_4);
|
||||
ADD_TEST(test_fromdata_dh_named_group);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
ADD_TEST(test_fromdata_dsa_fips186_4);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ADD_ALL_TESTS(test_fromdata_ecx, 4);
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "testutil.h"
|
||||
#include "evp_test.h"
|
||||
|
||||
DEFINE_STACK_OF_STRING()
|
||||
|
||||
#define AAD_NUM 4
|
||||
|
||||
typedef struct evp_test_method_st EVP_TEST_METHOD;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -28,7 +28,7 @@ static int test_fatalerr(void)
|
||||
0x17, 0x03, 0x03, 0x00, 0x05, 'D', 'u', 'm', 'm', 'y'
|
||||
};
|
||||
|
||||
if (!TEST_true(create_ssl_ctx_pair(TLS_method(), TLS_method(),
|
||||
if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_method(), TLS_method(),
|
||||
TLS1_VERSION, 0,
|
||||
&sctx, &cctx, cert, privkey)))
|
||||
goto err;
|
||||
|
||||
@@ -600,19 +600,19 @@ static int ffc_private_gen_test(int index)
|
||||
|
||||
N = BN_num_bits(params->q);
|
||||
/* Fail since N < 2*s - where s = 112*/
|
||||
if (!TEST_false(ffc_generate_private_key_fips(ctx, params, 220, 112, priv)))
|
||||
if (!TEST_false(ffc_generate_private_key(ctx, params, 220, 112, priv)))
|
||||
goto err;
|
||||
/* fail since N > len(q) */
|
||||
if (!TEST_false(ffc_generate_private_key_fips(ctx, params, N + 1, 112, priv)))
|
||||
if (!TEST_false(ffc_generate_private_key(ctx, params, N + 1, 112, priv)))
|
||||
goto err;
|
||||
/* pass since 2s <= N <= len(q) */
|
||||
if (!TEST_true(ffc_generate_private_key_fips(ctx, params, N, 112, priv)))
|
||||
if (!TEST_true(ffc_generate_private_key(ctx, params, N, 112, priv)))
|
||||
goto err;
|
||||
/* pass since N = len(q) */
|
||||
if (!TEST_true(ffc_validate_private_key(params->q, priv, &res)))
|
||||
goto err;
|
||||
/* pass since 2s <= N < len(q) */
|
||||
if (!TEST_true(ffc_generate_private_key_fips(ctx, params, N / 2, 112, priv)))
|
||||
if (!TEST_true(ffc_generate_private_key(ctx, params, N / 2, 112, priv)))
|
||||
goto err;
|
||||
if (!TEST_true(ffc_validate_private_key(params->q, priv, &res)))
|
||||
goto err;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
openssl_conf = openssl_init
|
||||
|
||||
.include fipsinstall.cnf
|
||||
.include fipsmodule.cnf
|
||||
|
||||
[openssl_init]
|
||||
providers = provider_sect
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -127,6 +127,11 @@ sub print_templates {
|
||||
# Shamelessly copied from Configure.
|
||||
sub read_config {
|
||||
my $fname = shift;
|
||||
my $provider = shift;
|
||||
local $ssltests::fips_mode = $provider eq "fips";
|
||||
local $ssltests::no_deflt_libctx =
|
||||
$provider eq "default" || $provider eq "fips";
|
||||
|
||||
open(INPUT, "< $fname") or die "Can't open input file '$fname'!\n";
|
||||
local $/ = undef;
|
||||
my $content = <INPUT>;
|
||||
@@ -136,8 +141,9 @@ sub read_config {
|
||||
}
|
||||
|
||||
my $input_file = shift;
|
||||
my $provider = shift;
|
||||
# Reads the tests into ssltests::tests.
|
||||
read_config($input_file);
|
||||
read_config($input_file, $provider);
|
||||
print_templates();
|
||||
|
||||
1;
|
||||
+1
-1
@@ -46,7 +46,7 @@ static int test_tls13(int idx)
|
||||
SSL *clientssl = NULL, *serverssl = NULL;
|
||||
int testresult = 0;
|
||||
|
||||
if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(),
|
||||
if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_server_method(),
|
||||
TLS_client_method(),
|
||||
TLS1_VERSION,
|
||||
0,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <netinet/sctp.h>
|
||||
#endif
|
||||
|
||||
DEFINE_STACK_OF(X509_NAME)
|
||||
|
||||
HANDSHAKE_RESULT *HANDSHAKE_RESULT_new(void)
|
||||
{
|
||||
HANDSHAKE_RESULT *ret;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "testutil.h"
|
||||
|
||||
DEFINE_STACK_OF(CONF_VALUE)
|
||||
|
||||
static const ASN1_ITEM *x509_it = NULL;
|
||||
static X509 *x509 = NULL;
|
||||
#define SERVER "mock.server"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "testutil.h"
|
||||
|
||||
DEFINE_STACK_OF(X509)
|
||||
|
||||
static const char *certstr;
|
||||
static const char *privkeystr;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
|
||||
+38
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
@@ -69,6 +69,11 @@ static int test_param_type_extra(OSSL_PARAM *param, const unsigned char *cmp,
|
||||
const int sizet = bit32 && sizeof(size_t) > sizeof(int32_t);
|
||||
const int signd = param->data_type == OSSL_PARAM_INTEGER;
|
||||
|
||||
/*
|
||||
* Set the unmodified sentinal directly because there is no param array
|
||||
* for these tests.
|
||||
*/
|
||||
param->return_size = OSSL_PARAM_UNMODIFIED;
|
||||
if (signd) {
|
||||
if ((bit32 && !TEST_true(OSSL_PARAM_get_int32(param, &i32)))
|
||||
|| !TEST_true(OSSL_PARAM_get_int64(param, &i64)))
|
||||
@@ -80,6 +85,8 @@ static int test_param_type_extra(OSSL_PARAM *param, const unsigned char *cmp,
|
||||
|| (sizet && !TEST_true(OSSL_PARAM_get_size_t(param, &s))))
|
||||
return 0;
|
||||
}
|
||||
if (!TEST_false(OSSL_PARAM_modified(param)))
|
||||
return 0;
|
||||
|
||||
/* Check signed types */
|
||||
if (bit32) {
|
||||
@@ -112,6 +119,8 @@ static int test_param_type_extra(OSSL_PARAM *param, const unsigned char *cmp,
|
||||
|| !TEST_size_t_eq((size_t)i64, 12345))
|
||||
return 0;
|
||||
}
|
||||
if (!TEST_true(OSSL_PARAM_modified(param)))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -563,6 +572,33 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_param_modified(void)
|
||||
{
|
||||
OSSL_PARAM param[3] = { OSSL_PARAM_int("a", NULL),
|
||||
OSSL_PARAM_int("b", NULL),
|
||||
OSSL_PARAM_END };
|
||||
int a, b;
|
||||
|
||||
param->data = &a;
|
||||
param[1].data = &b;
|
||||
if (!TEST_false(OSSL_PARAM_modified(param))
|
||||
&& !TEST_true(OSSL_PARAM_set_int32(param, 1234))
|
||||
&& !TEST_true(OSSL_PARAM_modified(param))
|
||||
&& !TEST_false(OSSL_PARAM_modified(param + 1))
|
||||
&& !TEST_true(OSSL_PARAM_set_int32(param + 1, 1))
|
||||
&& !TEST_true(OSSL_PARAM_modified(param + 1)))
|
||||
return 0;
|
||||
OSSL_PARAM_set_all_unmodified(param);
|
||||
if (!TEST_false(OSSL_PARAM_modified(param))
|
||||
&& !TEST_true(OSSL_PARAM_set_int32(param, 4321))
|
||||
&& !TEST_true(OSSL_PARAM_modified(param))
|
||||
&& !TEST_false(OSSL_PARAM_modified(param + 1))
|
||||
&& !TEST_true(OSSL_PARAM_set_int32(param + 1, 2))
|
||||
&& !TEST_true(OSSL_PARAM_modified(param + 1)))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_ALL_TESTS(test_param_int, OSSL_NELEM(raw_values));
|
||||
@@ -577,5 +613,6 @@ int setup_tests(void)
|
||||
ADD_ALL_TESTS(test_param_bignum, OSSL_NELEM(raw_values));
|
||||
ADD_TEST(test_param_real);
|
||||
ADD_TEST(test_param_construct);
|
||||
ADD_TEST(test_param_modified);
|
||||
return 1;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
|
||||
+3
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -467,8 +467,7 @@ static int test_case_variant(OSSL_PARAM *params, const struct provider_dispatch_
|
||||
|| !TEST_size_t_eq(p->return_size, sizeof(p6_init)) /* "provider" value */
|
||||
|| !TEST_str_eq(app_p6, p6_init) /* "provider" value */
|
||||
|| !TEST_char_eq(foo[0], app_foo_init) /* Should remain untouched */
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "foo"))
|
||||
|| !TEST_int_eq(p->return_size, 0))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "foo")))
|
||||
errcnt++;
|
||||
|
||||
/*
|
||||
@@ -519,8 +518,7 @@ static int test_case_variant(OSSL_PARAM *params, const struct provider_dispatch_
|
||||
sizeof(app_p6_init)) /* app value */
|
||||
|| !TEST_str_eq(app_p6, app_p6_init) /* app value */
|
||||
|| !TEST_char_eq(foo[0], app_foo_init) /* Should remain untouched */
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "foo"))
|
||||
|| !TEST_int_eq(p->return_size, 0))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "foo")))
|
||||
errcnt++;
|
||||
|
||||
fin:
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -101,19 +101,28 @@ ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.cnf', '-module', $infile,
|
||||
"fipsinstall fails when the DRBG CTR result is corrupted");
|
||||
|
||||
# corrupt a KAS test
|
||||
ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.conf', '-module', $infile,
|
||||
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
'-section_name', 'fips_install',
|
||||
'-corrupt_desc', 'DH',
|
||||
'-corrupt_type', 'KAT_KA'])),
|
||||
"fipsinstall fails when the kas result is corrupted");
|
||||
SKIP: {
|
||||
skip "Skipping KAS DH corruption test because of no dh in this build", 1
|
||||
if disabled("dh");
|
||||
|
||||
ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.conf', '-module', $infile,
|
||||
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
'-section_name', 'fips_install',
|
||||
'-corrupt_desc', 'DH',
|
||||
'-corrupt_type', 'KAT_KA'])),
|
||||
"fipsinstall fails when the kas result is corrupted");
|
||||
}
|
||||
|
||||
# corrupt a Signature test
|
||||
ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.conf', '-module', $infile,
|
||||
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
'-section_name', 'fips_install',
|
||||
'-corrupt_desc', 'DSA',
|
||||
'-corrupt_type', 'KAT_Signature'])),
|
||||
"fipsinstall fails when the signature result is corrupted");
|
||||
SKIP: {
|
||||
skip "Skipping Signature DSA corruption test because of no dsa in this build", 1
|
||||
if disabled("dsa");
|
||||
ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.conf', '-module', $infile,
|
||||
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
'-section_name', 'fips_install',
|
||||
'-corrupt_desc', 'DSA',
|
||||
'-corrupt_type', 'KAT_Signature'])),
|
||||
"fipsinstall fails when the signature result is corrupted");
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+11
-21
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -21,27 +21,17 @@ plan tests => 7;
|
||||
|
||||
require_ok(srctop_file('test','recipes','tconversion.pl'));
|
||||
|
||||
SKIP: {
|
||||
skip "Skipping initial dsa tests", 2
|
||||
if disabled('deprecated-3.0');
|
||||
ok(run(test(["dsatest"])), "running dsatest");
|
||||
ok(run(test(["dsa_no_digest_size_test"])),
|
||||
"running dsa_no_digest_size_test");
|
||||
|
||||
ok(run(test(["dsatest"])), "running dsatest");
|
||||
ok(run(test(["dsa_no_digest_size_test"])),
|
||||
"running dsa_no_digest_size_test");
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "Skipping dsa conversion test using 'openssl dsa'", 2
|
||||
if disabled('deprecated-3.0');
|
||||
|
||||
subtest "dsa conversions using 'openssl dsa' -- private key" => sub {
|
||||
tconversion("dsa", srctop_file("test","testdsa.pem"));
|
||||
};
|
||||
subtest "dsa conversions using 'openssl dsa' -- public key" => sub {
|
||||
tconversion("msb", srctop_file("test","testdsapub.pem"), "dsa",
|
||||
"-pubin", "-pubout");
|
||||
};
|
||||
}
|
||||
subtest "dsa conversions using 'openssl dsa' -- private key" => sub {
|
||||
tconversion("dsa", srctop_file("test","testdsa.pem"));
|
||||
};
|
||||
subtest "dsa conversions using 'openssl dsa' -- public key" => sub {
|
||||
tconversion("msb", srctop_file("test","testdsapub.pem"), "dsa",
|
||||
"-pubin", "-pubout");
|
||||
};
|
||||
|
||||
subtest "dsa conversions using 'openssl pkey' -- private key PKCS#8" => sub {
|
||||
tconversion("dsa", srctop_file("test","testdsa.pem"), "pkey");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -27,7 +27,7 @@ ok(run(test(["ectest"])), "running ectest");
|
||||
# the command line tool in addition to the algorithm.
|
||||
SKIP: {
|
||||
skip "Skipping EC conversion test", 3
|
||||
if disabled("ec") || disabled('deprecated-3.0');
|
||||
if disabled("ec");
|
||||
|
||||
subtest 'EC conversions -- private key' => sub {
|
||||
tconversion("ec", srctop_file("test","testec-p256.pem"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Spec;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_gendh");
|
||||
|
||||
plan skip_all => "This test is unsupported in a no-dh build" if disabled("dh");
|
||||
|
||||
plan tests => 13;
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DH',
|
||||
'-pkeyopt', 'gindex:1',
|
||||
'-pkeyopt', 'type:fips186_4',
|
||||
'-text'])),
|
||||
"genpkey DH params fips186_4 with verifiable g");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DH',
|
||||
'-pkeyopt', 'type:fips186_4',
|
||||
'-text'])),
|
||||
"genpkey DH params fips186_4 with unverifiable g");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DH',
|
||||
'-pkeyopt', 'type:fips186_2',
|
||||
'-text'])),
|
||||
"genpkey DH params fips186_2");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-algorithm', 'DH',
|
||||
'-pkeyopt', 'type:group',
|
||||
'-text'])),
|
||||
"genpkey DH default group");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-algorithm', 'DH',
|
||||
'-pkeyopt', 'type:group',
|
||||
'-pkeyopt', 'group:ffdhe2048',
|
||||
'-text'])),
|
||||
"genpkey DH group ffdhe2048");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DH',
|
||||
'-pkeyopt', 'gindex:1',
|
||||
'-pkeyopt', 'type:fips186_4',
|
||||
'-out', 'dhgen.pem'])),
|
||||
"genpkey DH params fips186_4 PEM");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DH',
|
||||
'-pkeyopt', 'gindex:1',
|
||||
'-pkeyopt', 'pbits:2048',
|
||||
'-pkeyopt', 'qbits:256',
|
||||
'-pkeyopt', 'type:fips186_4',
|
||||
'-outform', 'DER',
|
||||
'-out', 'dhgen.der'])),
|
||||
"genpkey DH params fips186_4 DER");
|
||||
|
||||
# The seed and counter should be the ones generated from the param generation
|
||||
# Just put some dummy ones in to show it works.
|
||||
ok(run(app([ 'openssl', 'genpkey',
|
||||
'-paramfile', 'dhgen.der',
|
||||
'-pkeyopt', 'gindex:1',
|
||||
'-pkeyopt', 'hexseed:0102030405060708090A0B0C0D0E0F1011121314',
|
||||
'-pkeyopt', 'pcounter:25',
|
||||
'-text'])),
|
||||
"genpkey DH fips186_4 with DER params");
|
||||
|
||||
ok(!run(app([ 'openssl', 'genpkey',
|
||||
'-algorithm', 'DH'])),
|
||||
"genpkey DH with no params should fail");
|
||||
|
||||
ok(!run(app([ 'openssl', 'genpkey', '-algorithm', 'DH', '-pkeyopt',
|
||||
'group:ffdhe3072', '-pkeyopt', 'priv_len:255', '-text'])),
|
||||
'genpkey DH with a small private len should fail');
|
||||
|
||||
ok(!run(app([ 'openssl', 'genpkey', '-algorithm', 'DH', '-pkeyopt',
|
||||
'group:ffdhe3072', '-pkeyopt', 'priv_len:3072', '-text'])),
|
||||
'genpkey DH with a large private len should fail');
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-algorithm', 'DH', '-pkeyopt',
|
||||
'group:ffdhe3072', '-pkeyopt', 'priv_len:256', '-text'])),
|
||||
'genpkey DH with a minimum strength private len');
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-algorithm', 'DH', '-pkeyopt',
|
||||
'group:ffdhe2048', '-pkeyopt', 'priv_len:224', '-text'])),
|
||||
'genpkey 2048 DH with a minimum strength private len');
|
||||
@@ -0,0 +1,77 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Spec;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_gendsa");
|
||||
|
||||
plan skip_all => "This test is unsupported in a no-dsa build"
|
||||
if disabled("dsa");
|
||||
|
||||
plan tests => 8;
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DSA',
|
||||
'-pkeyopt', 'gindex:1',
|
||||
'-pkeyopt', 'type:fips186_4',
|
||||
'-text'])),
|
||||
"genpkey DSA params fips186_4 with verifiable g");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DSA',
|
||||
'-pkeyopt', 'type:fips186_4',
|
||||
'-text'])),
|
||||
"genpkey DSA params fips186_4 with unverifiable g");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DSA',
|
||||
'-pkeyopt', 'type:fips186_2',
|
||||
'-text'])),
|
||||
"genpkey DSA params fips186_2");
|
||||
|
||||
ok(!run(app([ 'openssl', 'genpkey', '-algorithm', 'DSA',
|
||||
'-pkeyopt', 'type:group',
|
||||
'-text'])),
|
||||
"genpkey DSA does not support groups");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DSA',
|
||||
'-pkeyopt', 'gindex:1',
|
||||
'-pkeyopt', 'type:fips186_4',
|
||||
'-out', 'dsagen.pem'])),
|
||||
"genpkey DSA params fips186_4 PEM");
|
||||
|
||||
ok(run(app([ 'openssl', 'genpkey', '-genparam',
|
||||
'-algorithm', 'DSA',
|
||||
'-pkeyopt', 'gindex:1',
|
||||
'-pkeyopt', 'pbits:2048',
|
||||
'-pkeyopt', 'qbits:256',
|
||||
'-pkeyopt', 'type:fips186_4',
|
||||
'-outform', 'DER',
|
||||
'-out', 'dsagen.der'])),
|
||||
"genpkey DSA params fips186_4 DER");
|
||||
|
||||
# The seed and counter should be the ones generated from the param generation
|
||||
# Just put some dummy ones in to show it works.
|
||||
ok(run(app([ 'openssl', 'genpkey',
|
||||
'-paramfile', 'dsagen.der',
|
||||
'-pkeyopt', 'gindex:1',
|
||||
'-pkeyopt', 'hexseed:0102030405060708090A0B0C0D0E0F1011121314',
|
||||
'-pkeyopt', 'pcounter:25',
|
||||
'-text'])),
|
||||
"genpkey DSA fips186_4 with DER params");
|
||||
|
||||
ok(!run(app([ 'openssl', 'genpkey',
|
||||
'-algorithm', 'DSA'])),
|
||||
"genpkey DSA with no params should fail");
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2017 BaishanCloud. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
|
||||
+32
-23
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -16,32 +16,41 @@ use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_rsa");
|
||||
|
||||
plan tests => 6;
|
||||
plan tests => 10;
|
||||
|
||||
require_ok(srctop_file('test','recipes','tconversion.pl'));
|
||||
require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
|
||||
|
||||
ok(run(test(["rsa_test"])), "running rsatest");
|
||||
|
||||
ok(run(app([ 'openssl', 'rsa', '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])), "rsa -check");
|
||||
run_rsa_tests("pkey");
|
||||
|
||||
SKIP: {
|
||||
skip "Skipping rsa conversion test", 3
|
||||
if disabled("rsa");
|
||||
run_rsa_tests("rsa");
|
||||
|
||||
subtest 'rsa conversions -- private key' => sub {
|
||||
tconversion("rsa", srctop_file("test","testrsa.pem"));
|
||||
};
|
||||
subtest 'rsa conversions -- private key PKCS#8' => sub {
|
||||
tconversion("rsa", srctop_file("test","testrsa.pem"), "pkey");
|
||||
};
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "Skipping msblob conversion test", 1
|
||||
if disabled("rsa") || disabled("dsa");
|
||||
|
||||
subtest 'rsa conversions -- public key' => sub {
|
||||
tconversion("msb", srctop_file("test","testrsapub.pem"), "rsa",
|
||||
"-pubin", "-pubout");
|
||||
};
|
||||
sub run_rsa_tests {
|
||||
my $cmd = shift;
|
||||
|
||||
ok(run(app([ 'openssl', $cmd, '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])),
|
||||
"$cmd -check" );
|
||||
|
||||
SKIP: {
|
||||
skip "Skipping $cmd conversion test", 3
|
||||
if disabled("rsa");
|
||||
|
||||
subtest "$cmd conversions -- private key" => sub {
|
||||
tconversion($cmd, srctop_file("test", "testrsa.pem"));
|
||||
};
|
||||
subtest "$cmd conversions -- private key PKCS#8" => sub {
|
||||
tconversion($cmd, srctop_file("test", "testrsa.pem"), "pkey");
|
||||
};
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "Skipping msblob conversion test", 1
|
||||
if disabled($cmd) || disabled("dsa") || $cmd == 'pkey';
|
||||
|
||||
subtest "$cmd conversions -- public key" => sub {
|
||||
tconversion("msb", srctop_file("test", "testrsapub.pem"), "rsa",
|
||||
"-pubin", "-pubout");
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -84,7 +84,7 @@ unless ($no_fips) {
|
||||
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
|
||||
|
||||
ok(run(app(['openssl', 'fipsinstall',
|
||||
'-out', bldtop_file('providers', 'fipsinstall.cnf'),
|
||||
'-out', bldtop_file('providers', 'fipsmodule.cnf'),
|
||||
'-module', $infile,
|
||||
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2001-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
|
||||
@@ -37,7 +37,7 @@ Plaintext = "Hello World"
|
||||
Ciphertext = 3CF55D656E9C0664513358
|
||||
|
||||
Cipher = DESX-CBC
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Key = 0123456789abcdeff1e0d3c2b5a49786fedcba9876543210
|
||||
IV = fedcba9876543210
|
||||
Plaintext = 37363534333231204E6F77206973207468652074696D6520666F722000000000
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2001-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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2001-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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -48,7 +48,7 @@ my @testdata = (
|
||||
unless ($no_fips) {
|
||||
push @setups, {
|
||||
cmd => app(['openssl', 'fipsinstall',
|
||||
'-out', bldtop_file('providers', 'fipsinstall.cnf'),
|
||||
'-out', bldtop_file('providers', 'fipsmodule.cnf'),
|
||||
'-module', bldtop_file('providers', platform->dso('fips')),
|
||||
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,9 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MCQCAQAwFwYJKoZIhvcNAQMBMAoCBQCLtF9TAgECBAYCBGZsKwY=
|
||||
MIIBQwIBADCCARsGCSqGSIb3DQEDATCCAQwCggEBAP//////////rfhUWKK7Spqv
|
||||
3FYgJz088di5xYPOLTaVqeE2QRRkM/vMk53OJJs++X0v42NjDHXY9oGyAq7EYXrT
|
||||
3x7V1f1lYSQz9R9fBm7QhWNlVT3tGvO1VxNef1fJNZhPDHDg5ot34qaJ2vPv6HId
|
||||
8VihNq3nNTCsyk9IOnl6vAqxgrMk+2HRCKlLssjj+7lq2rdg1/RoHU9Co945TfSu
|
||||
Vu3nY3K7GQsHp8juCm1wngL84c334uzANATNKDQvYZFy/pzphYP/jk8SMu7ygYPD
|
||||
/jsbTG+tczu1/LwuwiAFxY7xg30Wg7LG80omwbLv+ohrQjhhKFyX//////////8C
|
||||
AQICAgDgBB8CHQCIheef7m3FfHivY104KtDtVktHISv6VfqH6Kl7
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -1,5 +1,24 @@
|
||||
DH Private-Key: (32 bit)
|
||||
private-key: 1718364934 (0x666c2b06)
|
||||
public-key: 1873206864 (0x6fa6de50)
|
||||
prime: 2343853907 (0x8bb45f53)
|
||||
generator: 2 (0x2)
|
||||
DH Private-Key: (2048 bit)
|
||||
private-key:
|
||||
00:88:85:e7:9f:ee:6d:c5:7c:78:af:63:5d:38:2a:
|
||||
d0:ed:56:4b:47:21:2b:fa:55:fa:87:e8:a9:7b
|
||||
public-key:
|
||||
00:d6:2d:77:e0:d3:7d:f8:eb:98:50:a1:82:22:65:
|
||||
d5:d9:fe:c9:3f:be:16:83:bd:33:e9:c6:93:cf:08:
|
||||
af:83:fa:80:8a:6c:64:df:70:64:d5:0a:7c:5a:72:
|
||||
da:66:e6:f9:f5:31:21:92:b0:60:1a:b5:d3:f0:a5:
|
||||
fa:48:95:2e:38:d9:c5:e6:da:fb:6c:03:9d:4b:69:
|
||||
b7:95:e4:5c:c0:93:4f:48:d9:7e:06:22:b2:de:f3:
|
||||
79:24:ed:e1:d1:4a:57:f1:40:86:70:42:25:c5:27:
|
||||
68:c9:fa:e5:8e:62:7e:ff:49:6c:5b:b5:ba:f9:ef:
|
||||
9a:1a:10:d4:81:53:cf:83:04:18:1c:e1:db:e1:65:
|
||||
a9:7f:e1:33:eb:c3:4f:e3:b7:22:f7:1c:09:4f:ed:
|
||||
c6:07:8e:78:05:8f:7c:96:d9:12:e0:81:74:1a:e9:
|
||||
13:c0:20:82:65:bb:42:3b:ed:08:6a:84:4f:ea:77:
|
||||
14:32:f9:ed:c2:12:d6:c5:c6:b3:e5:f2:6e:f6:16:
|
||||
7f:37:de:bc:09:c7:06:6b:12:bc:ad:2d:49:25:d5:
|
||||
dc:f4:18:14:d2:f0:f1:1d:1f:3a:aa:15:55:bb:0d:
|
||||
7f:be:67:a1:a7:f0:aa:b3:fb:41:82:39:49:93:bc:
|
||||
a8:ee:72:13:45:65:15:42:17:aa:d8:ab:cf:33:42:
|
||||
83:42
|
||||
GROUP: ffdhe2048
|
||||
Binary file not shown.
@@ -1,3 +1,14 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MCIwFwYJKoZIhvcNAQMBMAoCBQCLtF9TAgECAwcAAgRvpt5Q
|
||||
MIICKTCCARsGCSqGSIb3DQEDATCCAQwCggEBAP//////////rfhUWKK7Spqv3FYg
|
||||
Jz088di5xYPOLTaVqeE2QRRkM/vMk53OJJs++X0v42NjDHXY9oGyAq7EYXrT3x7V
|
||||
1f1lYSQz9R9fBm7QhWNlVT3tGvO1VxNef1fJNZhPDHDg5ot34qaJ2vPv6HId8Vih
|
||||
Nq3nNTCsyk9IOnl6vAqxgrMk+2HRCKlLssjj+7lq2rdg1/RoHU9Co945TfSuVu3n
|
||||
Y3K7GQsHp8juCm1wngL84c334uzANATNKDQvYZFy/pzphYP/jk8SMu7ygYPD/jsb
|
||||
TG+tczu1/LwuwiAFxY7xg30Wg7LG80omwbLv+ohrQjhhKFyX//////////8CAQIC
|
||||
AgDgA4IBBgACggEBANYtd+DTffjrmFChgiJl1dn+yT++FoO9M+nGk88Ir4P6gIps
|
||||
ZN9wZNUKfFpy2mbm+fUxIZKwYBq10/Cl+kiVLjjZxeba+2wDnUtpt5XkXMCTT0jZ
|
||||
fgYist7zeSTt4dFKV/FAhnBCJcUnaMn65Y5ifv9JbFu1uvnvmhoQ1IFTz4MEGBzh
|
||||
2+FlqX/hM+vDT+O3IvccCU/txgeOeAWPfJbZEuCBdBrpE8AggmW7QjvtCGqET+p3
|
||||
FDL57cIS1sXGs+XybvYWfzfevAnHBmsSvK0tSSXV3PQYFNLw8R0fOqoVVbsNf75n
|
||||
oafwqrP7QYI5SZO8qO5yE0VlFUIXqtirzzNCg0I=
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -1,4 +1,21 @@
|
||||
DH Public-Key: (32 bit)
|
||||
public-key: 1873206864 (0x6fa6de50)
|
||||
prime: 2343853907 (0x8bb45f53)
|
||||
generator: 2 (0x2)
|
||||
DH Public-Key: (2048 bit)
|
||||
public-key:
|
||||
00:d6:2d:77:e0:d3:7d:f8:eb:98:50:a1:82:22:65:
|
||||
d5:d9:fe:c9:3f:be:16:83:bd:33:e9:c6:93:cf:08:
|
||||
af:83:fa:80:8a:6c:64:df:70:64:d5:0a:7c:5a:72:
|
||||
da:66:e6:f9:f5:31:21:92:b0:60:1a:b5:d3:f0:a5:
|
||||
fa:48:95:2e:38:d9:c5:e6:da:fb:6c:03:9d:4b:69:
|
||||
b7:95:e4:5c:c0:93:4f:48:d9:7e:06:22:b2:de:f3:
|
||||
79:24:ed:e1:d1:4a:57:f1:40:86:70:42:25:c5:27:
|
||||
68:c9:fa:e5:8e:62:7e:ff:49:6c:5b:b5:ba:f9:ef:
|
||||
9a:1a:10:d4:81:53:cf:83:04:18:1c:e1:db:e1:65:
|
||||
a9:7f:e1:33:eb:c3:4f:e3:b7:22:f7:1c:09:4f:ed:
|
||||
c6:07:8e:78:05:8f:7c:96:d9:12:e0:81:74:1a:e9:
|
||||
13:c0:20:82:65:bb:42:3b:ed:08:6a:84:4f:ea:77:
|
||||
14:32:f9:ed:c2:12:d6:c5:c6:b3:e5:f2:6e:f6:16:
|
||||
7f:37:de:bc:09:c7:06:6b:12:bc:ad:2d:49:25:d5:
|
||||
dc:f4:18:14:d2:f0:f1:1d:1f:3a:aa:15:55:bb:0d:
|
||||
7f:be:67:a1:a7:f0:aa:b3:fb:41:82:39:49:93:bc:
|
||||
a8:ee:72:13:45:65:15:42:17:aa:d8:ab:cf:33:42:
|
||||
83:42
|
||||
GROUP: ffdhe2048
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user