summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-05-22 16:39:14 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2017-05-22 23:25:51 +0200
commitf036d7e93887b4885072cdb2e7dfd2de499ccb3c (patch)
treec9b13fd8524d088772b77676fedd2129af5516c1
parent09f9aa8e9c8f648a085cb0aea7faaa14fa4f8755 (diff)
downloadgnutls-f036d7e93887b4885072cdb2e7dfd2de499ccb3c.tar.gz
self-tests: all parameter was replaced by flags
This allows to introduce more options than just check all ciphers. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--lib/crypto-selftests-pk.c14
-rw-r--r--lib/crypto-selftests.c26
-rw-r--r--lib/includes/gnutls/self-test.h10
3 files changed, 26 insertions, 24 deletions
diff --git a/lib/crypto-selftests-pk.c b/lib/crypto-selftests-pk.c
index 84a9963cea..9a7f3505bf 100644
--- a/lib/crypto-selftests-pk.c
+++ b/lib/crypto-selftests-pk.c
@@ -475,7 +475,7 @@ static int test_known_sig(gnutls_pk_algorithm_t pk, unsigned bits,
gnutls_assert(); \
goto cleanup; \
} \
- if (all == 0) \
+ if (!(flags & GNUTLS_SELF_TEST_FLAG_ALL)) \
return 0
#define PK_KNOWN_TEST(pk, det, bits, dig, pkey, sig) \
@@ -484,7 +484,7 @@ static int test_known_sig(gnutls_pk_algorithm_t pk, unsigned bits,
gnutls_assert(); \
goto cleanup; \
} \
- if (all == 0) \
+ if (!(flags & GNUTLS_SELF_TEST_FLAG_ALL)) \
return 0
@@ -683,7 +683,7 @@ cleanup:
/*-
* gnutls_pk_self_test:
- * @all: if non-zero then tests to all public key algorithms are performed.
+ * @flags: GNUTLS_SELF_TEST_FLAG flags
* @pk: the algorithm to use
*
* This function will run self tests on the provided public key algorithm.
@@ -692,11 +692,11 @@ cleanup:
*
* Since: 3.3.0-FIPS140
-*/
-int gnutls_pk_self_test(unsigned all, gnutls_pk_algorithm_t pk)
+int gnutls_pk_self_test(unsigned flags, gnutls_pk_algorithm_t pk)
{
int ret;
- if (all != 0)
+ if (flags & GNUTLS_SELF_TEST_FLAG_ALL)
pk = GNUTLS_PK_UNKNOWN;
switch (pk) {
@@ -710,7 +710,7 @@ int gnutls_pk_self_test(unsigned all, gnutls_pk_algorithm_t pk)
goto cleanup;
}
- if (all == 0)
+ if (!(flags & GNUTLS_SELF_TEST_FLAG_ALL))
return 0;
#endif
case GNUTLS_PK_RSA:
@@ -731,7 +731,7 @@ int gnutls_pk_self_test(unsigned all, gnutls_pk_algorithm_t pk)
goto cleanup;
}
- if (all == 0)
+ if (!(flags & GNUTLS_SELF_TEST_FLAG_ALL))
return 0;
#endif
diff --git a/lib/crypto-selftests.c b/lib/crypto-selftests.c
index b9d14a5538..255654b0a5 100644
--- a/lib/crypto-selftests.c
+++ b/lib/crypto-selftests.c
@@ -1089,40 +1089,40 @@ static int test_mac(gnutls_mac_algorithm_t mac,
#define CASE(x, func, vectors) case x: \
ret = func(x, V(vectors)); \
- if (all == 0 || ret < 0) \
+ if (!(flags & GNUTLS_SELF_TEST_FLAG_ALL) || ret < 0) \
return ret
#define NON_FIPS_CASE(x, func, vectors) case x: \
if (_gnutls_fips_mode_enabled() == 0) { \
ret = func(x, V(vectors)); \
- if (all == 0 || ret < 0) \
+ if (!(flags & GNUTLS_SELF_TEST_FLAG_ALL) || ret < 0) \
return ret; \
}
#define FIPS_STARTUP_ONLY_TEST_CASE(x, func, vectors) case x: \
if (_gnutls_fips_mode_enabled() != 1) { \
ret = func(x, V(vectors)); \
- if (all == 0 || ret < 0) \
+ if (!(flags & GNUTLS_SELF_TEST_FLAG_ALL) || ret < 0) \
return ret; \
}
/*-
* gnutls_cipher_self_test:
- * @all: if non-zero then tests to all ciphers are performed.
+ * @flags: GNUTLS_SELF_TEST_FLAG flags
* @cipher: the encryption algorithm to use
*
* This function will run self tests on the provided cipher or all
- * available ciphers if @all is non-zero.
+ * available ciphers if @flags is %GNUTLS_SELF_TEST_FLAG_ALL.
*
* Returns: Zero or a negative error code on error.
*
* Since: 3.3.0-FIPS140
-*/
-int gnutls_cipher_self_test(unsigned all, gnutls_cipher_algorithm_t cipher)
+int gnutls_cipher_self_test(unsigned flags, gnutls_cipher_algorithm_t cipher)
{
int ret;
- if (all != 0)
+ if (flags & GNUTLS_SELF_TEST_FLAG_ALL)
cipher = GNUTLS_CIPHER_UNKNOWN;
switch (cipher) {
@@ -1157,7 +1157,7 @@ int gnutls_cipher_self_test(unsigned all, gnutls_cipher_algorithm_t cipher)
/*-
* gnutls_mac_self_test:
- * @all: if non-zero then tests to all ciphers are performed.
+ * @flags: GNUTLS_SELF_TEST_FLAG flags
* @mac: the message authentication algorithm to use
*
* This function will run self tests on the provided mac.
@@ -1166,11 +1166,11 @@ int gnutls_cipher_self_test(unsigned all, gnutls_cipher_algorithm_t cipher)
*
* Since: 3.3.0-FIPS140
-*/
-int gnutls_mac_self_test(unsigned all, gnutls_mac_algorithm_t mac)
+int gnutls_mac_self_test(unsigned flags, gnutls_mac_algorithm_t mac)
{
int ret;
- if (all != 0)
+ if (flags & GNUTLS_SELF_TEST_FLAG_ALL)
mac = GNUTLS_MAC_UNKNOWN;
switch (mac) {
@@ -1192,7 +1192,7 @@ int gnutls_mac_self_test(unsigned all, gnutls_mac_algorithm_t mac)
/*-
* gnutls_digest_self_test:
- * @all: if non-zero then tests to all ciphers are performed.
+ * @flags: GNUTLS_SELF_TEST_FLAG flags
* @digest: the digest algorithm to use
*
* This function will run self tests on the provided digest.
@@ -1201,11 +1201,11 @@ int gnutls_mac_self_test(unsigned all, gnutls_mac_algorithm_t mac)
*
* Since: 3.3.0-FIPS140
-*/
-int gnutls_digest_self_test(unsigned all, gnutls_digest_algorithm_t digest)
+int gnutls_digest_self_test(unsigned flags, gnutls_digest_algorithm_t digest)
{
int ret;
- if (all != 0)
+ if (flags & GNUTLS_SELF_TEST_FLAG_ALL)
digest = GNUTLS_DIG_UNKNOWN;
switch (digest) {
diff --git a/lib/includes/gnutls/self-test.h b/lib/includes/gnutls/self-test.h
index c3fd84cd06..e87d99eab1 100644
--- a/lib/includes/gnutls/self-test.h
+++ b/lib/includes/gnutls/self-test.h
@@ -27,9 +27,11 @@
/* Self checking functions */
-int gnutls_cipher_self_test(unsigned all, gnutls_cipher_algorithm_t cipher);
-int gnutls_mac_self_test(unsigned all, gnutls_mac_algorithm_t mac);
-int gnutls_digest_self_test(unsigned all, gnutls_digest_algorithm_t digest);
-int gnutls_pk_self_test(unsigned all, gnutls_pk_algorithm_t pk);
+#define GNUTLS_SELF_TEST_FLAG_ALL 1
+
+int gnutls_cipher_self_test(unsigned flags, gnutls_cipher_algorithm_t cipher);
+int gnutls_mac_self_test(unsigned flags, gnutls_mac_algorithm_t mac);
+int gnutls_digest_self_test(unsigned flags, gnutls_digest_algorithm_t digest);
+int gnutls_pk_self_test(unsigned flags, gnutls_pk_algorithm_t pk);
#endif