use lib bldtop_dir('.');
use platform;
+my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
plan skip_all => "No TLS/SSL protocols are supported by this OpenSSL build"
if alldisabled(grep { $_ ne "ssl3" } available_protocols("tls"));
-plan tests => 2;
+plan tests =>
+ ($no_fips ? 0 : 2) # FIPS install test + sslapitest with fips
+ + 1; # sslapitest with default provider
(undef, my $tmpfilename) = tempfile();
-
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
-ok(run(app(['openssl', 'fipsinstall',
- '-out', bldtop_file('providers', 'fipsinstall.cnf'),
- '-module', bldtop_file('providers', platform->dso('fips')),
- '-provider_name', 'fips', '-mac_name', 'HMAC',
- '-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
- '-section_name', 'fips_sect'])),
- "fipsinstall");
-
ok(run(test(["sslapitest", srctop_dir("test", "certs"),
srctop_file("test", "recipes", "90-test_sslapi_data",
"passwd.txt"), $tmpfilename, "default",
srctop_file("test", "default.cnf")])),
"running sslapitest");
+unless ($no_fips) {
+ ok(run(app(['openssl', 'fipsinstall',
+ '-out', bldtop_file('providers', 'fipsinstall.cnf'),
+ '-module', bldtop_file('providers', platform->dso('fips')),
+ '-provider_name', 'fips', '-mac_name', 'HMAC',
+ '-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
+ '-section_name', 'fips_sect'])),
+ "fipsinstall");
+
+ ok(run(test(["sslapitest", srctop_dir("test", "certs"),
+ srctop_file("test", "recipes", "90-test_sslapi_data",
+ "passwd.txt"), $tmpfilename, "fips",
+ srctop_file("test", "fips.cnf")])),
+ "running sslapitest");
+}
+
unlink $tmpfilename;
static char *srpvfile = NULL;
static char *tmpfilename = NULL;
+static int is_fips = 0;
+
#define LOG_BUFFER_SIZE 2048
static char server_log_buffer[LOG_BUFFER_SIZE + 1] = {0};
static size_t server_log_buffer_index = 0;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(), TLS1_VERSION, 0,
&sctx, &cctx, cert, privkey))
+ || !TEST_true(SSL_CTX_set_ciphersuites(sctx,
+ "TLS_AES_128_GCM_SHA256:"
+ "TLS_AES_256_GCM_SHA384:"
+ "TLS_AES_128_CCM_SHA256"))
|| !TEST_true(SSL_CTX_set_ciphersuites(cctx,
"TLS_AES_128_GCM_SHA256"))
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
SSL_free(clientssl);
serverssl = clientssl = NULL;
-# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
/* Check we can resume a session with a different SHA-256 ciphersuite */
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
- "TLS_CHACHA20_POLY1305_SHA256"))
- || !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
- NULL, NULL))
+ "TLS_AES_128_CCM_SHA256"))
+ || !TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
+ &clientssl, NULL, NULL))
|| !TEST_true(SSL_set_session(clientssl, clntsess))
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
SSL_ERROR_NONE))
SSL_free(serverssl);
SSL_free(clientssl);
serverssl = clientssl = NULL;
-# endif
/*
* Check attempting to resume a SHA-256 session with no SHA-256 ciphersuites
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
- static const char *t13_ciphers[] = {
- TLS1_3_RFC_AES_128_GCM_SHA256,
- TLS1_3_RFC_AES_256_GCM_SHA384,
- TLS1_3_RFC_AES_128_CCM_SHA256,
+ static const struct {
+ const char *ciphername;
+ int fipscapable;
+ } t13_ciphers[] = {
+ { TLS1_3_RFC_AES_128_GCM_SHA256, 1 },
+ { TLS1_3_RFC_AES_256_GCM_SHA384, 1 },
+ { TLS1_3_RFC_AES_128_CCM_SHA256, 1 },
# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
- TLS1_3_RFC_CHACHA20_POLY1305_SHA256,
- TLS1_3_RFC_AES_256_GCM_SHA384 ":" TLS1_3_RFC_CHACHA20_POLY1305_SHA256,
+ { TLS1_3_RFC_CHACHA20_POLY1305_SHA256, 0 },
+ { TLS1_3_RFC_AES_256_GCM_SHA384
+ ":" TLS1_3_RFC_CHACHA20_POLY1305_SHA256, 0 },
# endif
- TLS1_3_RFC_AES_128_CCM_8_SHA256 ":" TLS1_3_RFC_AES_128_CCM_SHA256
+ { TLS1_3_RFC_AES_128_CCM_8_SHA256 ":" TLS1_3_RFC_AES_128_CCM_SHA256, 1 }
};
const char *t13_cipher = NULL;
const char *t12_cipher = NULL;
continue;
# endif
for (i = 0; i < OSSL_NELEM(t13_ciphers); i++) {
- t13_cipher = t13_ciphers[i];
+ if (is_fips && !t13_ciphers[i].fipscapable)
+ continue;
+ t13_cipher = t13_ciphers[i].ciphername;
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION, max_ver,
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
"TLS_AES_128_GCM_SHA256")))
goto end;
+ } else {
+ /*
+ * As noted above the server should prefer SHA256 automatically. However
+ * we are careful not to offer TLS_CHACHA20_POLY1305_SHA256 so this same
+ * code works even if we are testing with only the FIPS provider loaded.
+ */
+ if (!TEST_true(SSL_CTX_set_ciphersuites(cctx,
+ "TLS_AES_256_GCM_SHA384:"
+ "TLS_AES_128_GCM_SHA256")))
+ goto end;
}
/*
if (tst == 1)
return 1;
#endif
+ if (is_fips && (tst == 0 || tst == 1))
+ return 1;
#ifdef OPENSSL_NO_TLS1_2
if (tst == 2)
return 1;
&& !TEST_false(OSSL_PROVIDER_available(libctx, "default")))
return 0;
+ if (strcmp(modulename, "fips") == 0)
+ is_fips = 1;
+
if (getenv("OPENSSL_TEST_GETCOUNTS") != NULL) {
#ifdef OPENSSL_NO_CRYPTO_MDEBUG
TEST_error("not supported in this build");