cd0318
From 237695d30c9f716333cfa077554a6e1ae0d2c589 Mon Sep 17 00:00:00 2001
cd0318
From: rpm-build <rpm-build>
cd0318
Date: Sat, 20 Aug 2022 09:52:08 +0900
cd0318
Subject: [PATCH] gnutls-3.7.6-fips-rsa-key-sizes.patch
cd0318
cd0318
---
cd0318
 lib/nettle/pk.c        |  54 ++++---
cd0318
 tests/Makefile.am      |   3 +-
cd0318
 tests/fips-rsa-sizes.c | 328 +++++++++++++++++++++++++++++++++++++++++
cd0318
 3 files changed, 361 insertions(+), 24 deletions(-)
cd0318
 create mode 100644 tests/fips-rsa-sizes.c
cd0318
cd0318
diff --git a/lib/nettle/pk.c b/lib/nettle/pk.c
cd0318
index eba246f..f38016b 100644
cd0318
--- a/lib/nettle/pk.c
cd0318
+++ b/lib/nettle/pk.c
cd0318
@@ -1247,20 +1247,20 @@ _wrap_nettle_pk_sign(gnutls_pk_algorithm_t algo,
cd0318
 
cd0318
 			_rsa_params_to_privkey(pk_params, &priv;;
cd0318
 
cd0318
-			/* RSA key size should be 2048-bit or larger in FIPS
cd0318
-			 * 140-3.  In addition to this, only SHA-2 is allowed
cd0318
-			 * for SigGen; it is checked in pk_prepare_hash lib/pk.c
cd0318
-			 */
cd0318
-			if (unlikely(priv.size < 256)) {
cd0318
-				not_approved = true;
cd0318
-			}
cd0318
-
cd0318
 			ret = _rsa_params_to_pubkey(pk_params, &pub;;
cd0318
 			if (ret < 0) {
cd0318
 				gnutls_assert();
cd0318
 				goto cleanup;
cd0318
 			}
cd0318
 
cd0318
+			/* RSA modulus size should be 2048-bit or larger in FIPS
cd0318
+			 * 140-3.  In addition to this, only SHA-2 is allowed
cd0318
+			 * for SigGen; it is checked in pk_prepare_hash lib/pk.c
cd0318
+			 */
cd0318
+			if (unlikely(mpz_sizeinbase(pub.n, 2) < 2048)) {
cd0318
+				not_approved = true;
cd0318
+			}
cd0318
+
cd0318
 			mpz_init(s);
cd0318
 
cd0318
 			if (_gnutls_get_lib_state() == LIB_STATE_SELFTEST)
cd0318
@@ -1298,22 +1298,22 @@ _wrap_nettle_pk_sign(gnutls_pk_algorithm_t algo,
cd0318
 
cd0318
 			_rsa_params_to_privkey(pk_params, &priv;;
cd0318
 
cd0318
-			/* RSA key size should be 2048-bit or larger in FIPS
cd0318
+			ret = _rsa_params_to_pubkey(pk_params, &pub;;
cd0318
+			if (ret < 0) {
cd0318
+				gnutls_assert();
cd0318
+				goto cleanup;
cd0318
+			}
cd0318
+
cd0318
+			/* RSA modulus size should be 2048-bit or larger in FIPS
cd0318
 			 * 140-3.  In addition to this, only SHA-2 is allowed
cd0318
 			 * for SigGen; however, Nettle only support SHA256,
cd0318
 			 * SHA384, and SHA512 for RSA-PSS (see
cd0318
 			 * _rsa_pss_sign_digest_tr in this file for details).
cd0318
 			 */
cd0318
-			if (unlikely(priv.size < 256)) {
cd0318
+			if (unlikely(mpz_sizeinbase(pub.n, 2) < 2048)) {
cd0318
 				not_approved = true;
cd0318
 			}
cd0318
 
cd0318
-			ret = _rsa_params_to_pubkey(pk_params, &pub;;
cd0318
-			if (ret < 0) {
cd0318
-				gnutls_assert();
cd0318
-				goto cleanup;
cd0318
-			}
cd0318
-
cd0318
 			mpz_init(s);
cd0318
 
cd0318
 			ret =
cd0318
@@ -1643,6 +1643,7 @@ _wrap_nettle_pk_verify(gnutls_pk_algorithm_t algo,
cd0318
 	case GNUTLS_PK_RSA:
cd0318
 		{
cd0318
 			struct rsa_public_key pub;
cd0318
+			size_t bits;
cd0318
 
cd0318
 			ret = _rsa_params_to_pubkey(pk_params, &pub;;
cd0318
 			if (ret < 0) {
cd0318
@@ -1650,12 +1651,19 @@ _wrap_nettle_pk_verify(gnutls_pk_algorithm_t algo,
cd0318
 				goto cleanup;
cd0318
 			}
cd0318
 
cd0318
-			/* RSA key size should be 2048-bit or larger in FIPS
cd0318
-			 * 140-3.  In addition to this, only SHA-1 and SHA-2 are
cd0318
-			 * allowed for SigVer; it is checked in
cd0318
-			 * _pkcs1_rsa_verify_sig in lib/pubkey.c
cd0318
+			bits = mpz_sizeinbase(pub.n, 2);
cd0318
+
cd0318
+			/* In FIPS 140-3, RSA key size should be larger than
cd0318
+			 * 2048-bit or one of the known lengths (1024, 1280,
cd0318
+			 * 1536, 1792; i.e., multiple of 256-bits).
cd0318
+			 *
cd0318
+			 * In addition to this, only SHA-1 and SHA-2 are allowed
cd0318
+			 * for SigVer; it is checked in _pkcs1_rsa_verify_sig in
cd0318
+			 * lib/pubkey.c.
cd0318
 			 */
cd0318
-			if (unlikely(pub.size < 256)) {
cd0318
+			if (unlikely(bits < 2048 &&
cd0318
+				     bits != 1024 && bits != 1280 &&
cd0318
+				     bits != 1536 && bits != 1792)) {
cd0318
 				not_approved = true;
cd0318
 			}
cd0318
 
cd0318
@@ -1701,13 +1709,13 @@ _wrap_nettle_pk_verify(gnutls_pk_algorithm_t algo,
cd0318
 				goto cleanup;
cd0318
 			}
cd0318
 
cd0318
-			/* RSA key size should be 2048-bit or larger in FIPS
cd0318
+			/* RSA modulus size should be 2048-bit or larger in FIPS
cd0318
 			 * 140-3.  In addition to this, only SHA-1 and SHA-2 are
cd0318
 			 * allowed for SigVer, while Nettle only supports
cd0318
 			 * SHA256, SHA384, and SHA512 for RSA-PSS (see
cd0318
 			 * _rsa_pss_verify_digest in this file for the details).
cd0318
 			 */
cd0318
-			if (unlikely(pub.size < 256)) {
cd0318
+			if (unlikely(mpz_sizeinbase(pub.n, 2) < 2048)) {
cd0318
 				not_approved = true;
cd0318
 			}
cd0318
 
cd0318
diff --git a/tests/Makefile.am b/tests/Makefile.am
cd0318
index 7a7a4af..dd21e45 100644
cd0318
--- a/tests/Makefile.am
cd0318
+++ b/tests/Makefile.am
cd0318
@@ -233,7 +233,8 @@ ctests += mini-record-2 simple gnutls_hmac_fast set_pkcs12_cred cert certuniquei
cd0318
 	 tls13-without-timeout-func buffer status-request-revoked \
cd0318
 	 set_x509_ocsp_multi_cli kdf-api keylog-func handshake-write \
cd0318
 	 x509cert-dntypes id-on-xmppAddr tls13-compat-mode ciphersuite-name \
cd0318
-	 x509-upnconstraint pkcs7-verify-double-free
cd0318
+	 x509-upnconstraint pkcs7-verify-double-free \
cd0318
+	 fips-rsa-sizes
cd0318
 
cd0318
 ctests += tls-channel-binding
cd0318
 
cd0318
diff --git a/tests/fips-rsa-sizes.c b/tests/fips-rsa-sizes.c
cd0318
new file mode 100644
cd0318
index 0000000..84b9aff
cd0318
--- /dev/null
cd0318
+++ b/tests/fips-rsa-sizes.c
cd0318
@@ -0,0 +1,328 @@
cd0318
+/*
cd0318
+ * Copyright (C) 2022 Red Hat, Inc.
cd0318
+ *
cd0318
+ * Author: Alexander Sosedkin
cd0318
+ *
cd0318
+ * This file is part of GnuTLS.
cd0318
+ *
cd0318
+ * GnuTLS is free software; you can redistribute it and/or modify it
cd0318
+ * under the terms of the GNU General Public License as published by
cd0318
+ * the Free Software Foundation; either version 3 of the License, or
cd0318
+ * (at your option) any later version.
cd0318
+ *
cd0318
+ * GnuTLS is distributed in the hope that it will be useful, but
cd0318
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
cd0318
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
cd0318
+ * General Public License for more details.
cd0318
+ *
cd0318
+ * You should have received a copy of the GNU General Public License
cd0318
+ * along with GnuTLS; if not, write to the Free Software Foundation,
cd0318
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
cd0318
+ */
cd0318
+
cd0318
+#include <assert.h>
cd0318
+#include <stdio.h>
cd0318
+#include <utils.h>
cd0318
+#include <gnutls/gnutls.h>
cd0318
+#include <gnutls/abstract.h>
cd0318
+#include <gnutls/x509.h>
cd0318
+
cd0318
+#define FIPS_PUSH_CONTEXT() do {				\
cd0318
+	ret = gnutls_fips140_push_context(fips_context);	\
cd0318
+	if (ret < 0) {						\
cd0318
+		fail("gnutls_fips140_push_context failed\n");	\
cd0318
+	}							\
cd0318
+} while (0)
cd0318
+
cd0318
+#define FIPS_POP_CONTEXT(state) do {					\
cd0318
+	ret = gnutls_fips140_pop_context();				\
cd0318
+	if (ret < 0) {							\
cd0318
+		fail("gnutls_fips140_context_pop failed\n");		\
cd0318
+	}								\
cd0318
+	fips_state = gnutls_fips140_get_operation_state(fips_context);	\
cd0318
+	if (fips_state != GNUTLS_FIPS140_OP_ ## state) {		\
cd0318
+		fail("operation state is not " # state " (%d)\n",	\
cd0318
+		     fips_state);					\
cd0318
+	}								\
cd0318
+} while (0)
cd0318
+
cd0318
+
cd0318
+void generate_successfully(gnutls_privkey_t* privkey, gnutls_pubkey_t* pubkey,
cd0318
+                           unsigned int size);
cd0318
+void generate_unsuccessfully(gnutls_privkey_t* privkey, gnutls_pubkey_t* pubkey,
cd0318
+                             unsigned int size);
cd0318
+void sign_verify_successfully(gnutls_privkey_t privkey, gnutls_pubkey_t pubkey);
cd0318
+void sign_verify_unsuccessfully(gnutls_privkey_t privkey,
cd0318
+                                gnutls_pubkey_t pubkey);
cd0318
+void nosign_verify(gnutls_privkey_t privkey, gnutls_pubkey_t pubkey);
cd0318
+
cd0318
+
cd0318
+void generate_successfully(gnutls_privkey_t* privkey, gnutls_pubkey_t* pubkey,
cd0318
+                           unsigned int size)
cd0318
+{
cd0318
+	int ret;
cd0318
+	gnutls_x509_privkey_t xprivkey;
cd0318
+	gnutls_fips140_context_t fips_context;
cd0318
+	gnutls_fips140_operation_state_t fips_state;
cd0318
+	assert(gnutls_fips140_context_init(&fips_context) == 0);
cd0318
+
cd0318
+	fprintf(stderr, "%d-bit\n", size);
cd0318
+
cd0318
+	/* x509 generation as well just because why not */
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	assert(gnutls_x509_privkey_init(&xprivkey) == 0);
cd0318
+	ret = gnutls_x509_privkey_generate(xprivkey, GNUTLS_PK_RSA, size, 0);
cd0318
+	if (ret != GNUTLS_E_SUCCESS)
cd0318
+		fail("%d-bit x509_privkey_init (%d)\n", size, ret);
cd0318
+	FIPS_POP_CONTEXT(APPROVED);
cd0318
+	gnutls_x509_privkey_deinit(xprivkey);
cd0318
+
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	assert(gnutls_privkey_init(privkey) == 0);
cd0318
+	ret = gnutls_privkey_generate(*privkey, GNUTLS_PK_RSA, size, 0);
cd0318
+	if (ret != GNUTLS_E_SUCCESS)
cd0318
+		fail("%d-bit privkey_init (%d)\n", size, ret);
cd0318
+	FIPS_POP_CONTEXT(APPROVED);
cd0318
+
cd0318
+	assert(gnutls_pubkey_init(pubkey) == 0);
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	ret = gnutls_pubkey_import_privkey(*pubkey, *privkey,
cd0318
+					   GNUTLS_KEY_DIGITAL_SIGNATURE, 0);
cd0318
+	if (ret != GNUTLS_E_SUCCESS)
cd0318
+		fail("%d-bit pubkey_import_privkey (%d)\n", size, ret);
cd0318
+	FIPS_POP_CONTEXT(INITIAL);
cd0318
+
cd0318
+	gnutls_fips140_context_deinit(fips_context);
cd0318
+}
cd0318
+
cd0318
+
cd0318
+void generate_unsuccessfully(gnutls_privkey_t* privkey, gnutls_pubkey_t* pubkey,
cd0318
+                             unsigned int size)
cd0318
+{
cd0318
+	int ret;
cd0318
+	gnutls_x509_privkey_t xprivkey;
cd0318
+	gnutls_fips140_context_t fips_context;
cd0318
+	gnutls_fips140_operation_state_t fips_state;
cd0318
+	assert(gnutls_fips140_context_init(&fips_context) == 0);
cd0318
+
cd0318
+	fprintf(stderr, "%d-bit\n", size);
cd0318
+
cd0318
+	/* short x509 generation: ERROR, blocked */
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	assert(gnutls_x509_privkey_init(&xprivkey) == 0);
cd0318
+	ret = gnutls_x509_privkey_generate(xprivkey, GNUTLS_PK_RSA, size, 0);
cd0318
+	if (ret != GNUTLS_E_PK_GENERATION_ERROR)
cd0318
+		fail("%d-bit x509_privkey_init (%d)\n", size, ret);
cd0318
+	FIPS_POP_CONTEXT(ERROR);
cd0318
+	gnutls_x509_privkey_deinit(xprivkey);
cd0318
+
cd0318
+	/* short key generation: ERROR, blocked */
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	assert(gnutls_privkey_init(privkey) == 0);
cd0318
+	ret = gnutls_privkey_generate(*privkey, GNUTLS_PK_RSA, size, 0);
cd0318
+	if (ret != GNUTLS_E_PK_GENERATION_ERROR)
cd0318
+		fail("%d-bit privkey_init (%d)\n", size, ret);
cd0318
+	FIPS_POP_CONTEXT(ERROR);
cd0318
+	gnutls_privkey_deinit(*privkey);
cd0318
+
cd0318
+	/* Disable FIPS to generate them anyway */
cd0318
+	gnutls_fips140_set_mode(GNUTLS_FIPS140_LAX, 0);
cd0318
+	assert(gnutls_fips140_mode_enabled() == GNUTLS_FIPS140_LAX);
cd0318
+
cd0318
+	assert(gnutls_x509_privkey_init(&xprivkey) == 0);
cd0318
+	ret = gnutls_x509_privkey_generate(xprivkey, GNUTLS_PK_RSA, size, 0);
cd0318
+	if (ret != GNUTLS_E_SUCCESS)
cd0318
+		fail("%d-bit x509_privkey_init (%d)\n", size, ret);
cd0318
+	gnutls_x509_privkey_deinit(xprivkey);
cd0318
+
cd0318
+	assert(gnutls_privkey_init(privkey) == 0);
cd0318
+	ret = gnutls_privkey_generate(*privkey, GNUTLS_PK_RSA, size, 0);
cd0318
+	if (ret != GNUTLS_E_SUCCESS)
cd0318
+		fail("%d-bit privkey_init (%d)\n", size, ret);
cd0318
+
cd0318
+	assert(gnutls_pubkey_init(pubkey) == 0);
cd0318
+	ret = gnutls_pubkey_import_privkey(*pubkey, *privkey,
cd0318
+					   GNUTLS_KEY_DIGITAL_SIGNATURE, 0);
cd0318
+	if (ret != GNUTLS_E_SUCCESS)
cd0318
+		fail("%d-bit pubkey_import_privkey (%d)\n", size, ret);
cd0318
+
cd0318
+	gnutls_fips140_set_mode(GNUTLS_FIPS140_STRICT, 0);
cd0318
+	assert(gnutls_fips140_mode_enabled());
cd0318
+
cd0318
+	gnutls_fips140_context_deinit(fips_context);
cd0318
+}
cd0318
+
cd0318
+
cd0318
+void sign_verify_successfully(gnutls_privkey_t privkey, gnutls_pubkey_t pubkey) {
cd0318
+	int ret;
cd0318
+	gnutls_fips140_context_t fips_context;
cd0318
+	gnutls_fips140_operation_state_t fips_state;
cd0318
+
cd0318
+	gnutls_datum_t signature;
cd0318
+	gnutls_datum_t plaintext = {
cd0318
+		.data = (unsigned char* const) "Hello world!",
cd0318
+		.size = 12
cd0318
+	};
cd0318
+	assert(gnutls_fips140_context_init(&fips_context) == 0);
cd0318
+
cd0318
+	/* RSA sign: approved */
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	ret = gnutls_privkey_sign_data(privkey, GNUTLS_DIG_SHA256, 0,
cd0318
+	                               &plaintext, &signature);
cd0318
+	if (ret < 0)
cd0318
+		fail("gnutls_privkey_sign_data failed\n");
cd0318
+	FIPS_POP_CONTEXT(APPROVED);
cd0318
+
cd0318
+	/* RSA verify: approved */
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	ret = gnutls_pubkey_verify_data2(pubkey, GNUTLS_SIGN_RSA_SHA256, 0,
cd0318
+	                                 &plaintext, &signature);
cd0318
+	if (ret < 0)
cd0318
+		fail("gnutls_pubkey_verify_data2 failed\n");
cd0318
+	FIPS_POP_CONTEXT(APPROVED);
cd0318
+
cd0318
+	gnutls_free(signature.data);
cd0318
+	gnutls_fips140_context_deinit(fips_context);
cd0318
+}
cd0318
+
cd0318
+
cd0318
+void sign_verify_unsuccessfully(gnutls_privkey_t privkey,
cd0318
+                                gnutls_pubkey_t pubkey) {
cd0318
+	int ret;
cd0318
+	gnutls_fips140_context_t fips_context;
cd0318
+	gnutls_fips140_operation_state_t fips_state;
cd0318
+
cd0318
+	gnutls_datum_t signature;
cd0318
+	gnutls_datum_t plaintext = {
cd0318
+		.data = (unsigned char* const) "Hello world!",
cd0318
+		.size = 12
cd0318
+	};
cd0318
+	assert(gnutls_fips140_context_init(&fips_context) == 0);
cd0318
+
cd0318
+	/* small key RSA sign: not approved */
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	ret = gnutls_privkey_sign_data(privkey, GNUTLS_DIG_SHA256, 0,
cd0318
+	                               &plaintext, &signature);
cd0318
+	if (ret < 0)
cd0318
+		fail("gnutls_privkey_sign_data failed\n");
cd0318
+	FIPS_POP_CONTEXT(NOT_APPROVED);
cd0318
+
cd0318
+	/* small key RSA verify: not approved */
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	ret = gnutls_pubkey_verify_data2(pubkey, GNUTLS_SIGN_RSA_SHA256, 0,
cd0318
+	                                 &plaintext, &signature);
cd0318
+	if (ret < 0)
cd0318
+		fail("gnutls_pubkey_verify_data2 failed\n");
cd0318
+	FIPS_POP_CONTEXT(NOT_APPROVED);
cd0318
+
cd0318
+	gnutls_free(signature.data);
cd0318
+	gnutls_pubkey_deinit(pubkey);
cd0318
+	gnutls_privkey_deinit(privkey);
cd0318
+	gnutls_fips140_context_deinit(fips_context);
cd0318
+}
cd0318
+
cd0318
+
cd0318
+void nosign_verify(gnutls_privkey_t privkey, gnutls_pubkey_t pubkey) {
cd0318
+	int ret;
cd0318
+	gnutls_fips140_context_t fips_context;
cd0318
+	gnutls_fips140_operation_state_t fips_state;
cd0318
+
cd0318
+	gnutls_datum_t signature;
cd0318
+	gnutls_datum_t plaintext = {
cd0318
+		.data = (unsigned char* const) "Hello world!",
cd0318
+		.size = 12
cd0318
+	};
cd0318
+	assert(gnutls_fips140_context_init(&fips_context) == 0);
cd0318
+
cd0318
+	/* 1024, 1280, 1536, 1792 key RSA sign: not approved */
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	ret = gnutls_privkey_sign_data(privkey, GNUTLS_DIG_SHA256, 0,
cd0318
+	                               &plaintext, &signature);
cd0318
+	if (ret < 0)
cd0318
+		fail("gnutls_privkey_sign_data failed\n");
cd0318
+	FIPS_POP_CONTEXT(NOT_APPROVED);
cd0318
+
cd0318
+	/* Disable FIPS to sign them anyway */
cd0318
+	gnutls_fips140_set_mode(GNUTLS_FIPS140_LAX, 0);
cd0318
+	assert(gnutls_fips140_mode_enabled() == GNUTLS_FIPS140_LAX);
cd0318
+
cd0318
+	ret = gnutls_privkey_sign_data(privkey, GNUTLS_DIG_SHA256, 0,
cd0318
+	                               &plaintext, &signature);
cd0318
+	if (ret < 0)
cd0318
+		fail("gnutls_privkey_sign_data failed\n");
cd0318
+
cd0318
+	gnutls_fips140_set_mode(GNUTLS_FIPS140_STRICT, 0);
cd0318
+	assert(gnutls_fips140_mode_enabled());
cd0318
+
cd0318
+	/* 1024, 1280, 1536, 1792 key RSA verify: approved (exception) */
cd0318
+	FIPS_PUSH_CONTEXT();
cd0318
+	ret = gnutls_pubkey_verify_data2(pubkey, GNUTLS_SIGN_RSA_SHA256, 0,
cd0318
+	                                 &plaintext, &signature);
cd0318
+	if (ret < 0)
cd0318
+		fail("gnutls_pubkey_verify_data2 failed\n");
cd0318
+	FIPS_POP_CONTEXT(APPROVED);
cd0318
+
cd0318
+	gnutls_free(signature.data);
cd0318
+	gnutls_pubkey_deinit(pubkey);
cd0318
+	gnutls_privkey_deinit(privkey);
cd0318
+	gnutls_fips140_context_deinit(fips_context);
cd0318
+}
cd0318
+
cd0318
+
cd0318
+void doit(void)
cd0318
+{
cd0318
+	gnutls_fips140_context_t fips_context;
cd0318
+	gnutls_privkey_t privkey;
cd0318
+	gnutls_pubkey_t pubkey;
cd0318
+
cd0318
+	if (gnutls_fips140_mode_enabled() == 0) {
cd0318
+		success("We are not in FIPS140 mode\n");
cd0318
+		exit(77);  /* SKIP */
cd0318
+	}
cd0318
+
cd0318
+	assert(gnutls_fips140_context_init(&fips_context) == 0);
cd0318
+
cd0318
+	/* 512-bit RSA: no generate, no sign, no verify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 512);
cd0318
+	sign_verify_unsuccessfully(privkey, pubkey);
cd0318
+	/* 512-bit RSA again (to be safer about going in and out of FIPS) */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 512);
cd0318
+	sign_verify_unsuccessfully(privkey, pubkey);
cd0318
+	/* 600-bit RSA: no generate, no sign, no verify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 600);
cd0318
+	sign_verify_unsuccessfully(privkey, pubkey);
cd0318
+
cd0318
+	/* 768-bit RSA not-an-exception: nogenerate, nosign, verify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 768);
cd0318
+	sign_verify_unsuccessfully(privkey, pubkey);
cd0318
+	/* 1024-bit RSA exception: nogenerate, nosign, verify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 1024);
cd0318
+	nosign_verify(privkey, pubkey);
cd0318
+	/* 1280-bit RSA exception: nogenerate, nosign, verify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 1280);
cd0318
+	nosign_verify(privkey, pubkey);
cd0318
+	/* 1500-bit RSA not-an-exception: nogenerate, nosign, noverify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 1500);
cd0318
+	sign_verify_unsuccessfully(privkey, pubkey);
cd0318
+	/* 1536-bit RSA exception: nogenerate, nosign, verify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 1536);
cd0318
+	nosign_verify(privkey, pubkey);
cd0318
+	/* 1792-bit RSA exception: nogenerate, nosign, verify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 1792);
cd0318
+	nosign_verify(privkey, pubkey);
cd0318
+	/* 2000-bit RSA not-an-exception: nogenerate, nosign, noverify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 2000);
cd0318
+	sign_verify_unsuccessfully(privkey, pubkey);
cd0318
+
cd0318
+	/* 2048-bit RSA: generate, sign, verify */
cd0318
+	generate_successfully(&privkey, &pubkey, 2048);
cd0318
+	sign_verify_successfully(privkey, pubkey);
cd0318
+	/* 2432-bit RSA: nogenerate, sign, verify */
cd0318
+	generate_unsuccessfully(&privkey, &pubkey, 2432);
cd0318
+	sign_verify_successfully(privkey, pubkey);
cd0318
+	/* 3072-bit RSA: generate, sign, verify */
cd0318
+	generate_successfully(&privkey, &pubkey, 3072);
cd0318
+	sign_verify_successfully(privkey, pubkey);
cd0318
+
cd0318
+	gnutls_fips140_context_deinit(fips_context);
cd0318
+}
cd0318
-- 
cd0318
2.37.2
cd0318