aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2017-12-28 10:33:02 (GMT)
committerJouni Malinen <j@w1.fi>2017-12-28 20:33:12 (GMT)
commit622d4d49e29a8b67399d81d9073759fa2f578c5e (patch)
tree35630208e7175f7fbc7e5340172f7bf9be494a82
parentf8697e81094854e478afdbb85a86e2b27f759b91 (diff)
downloadhostap-622d4d49e29a8b67399d81d9073759fa2f578c5e.zip
hostap-622d4d49e29a8b67399d81d9073759fa2f578c5e.tar.gz
hostap-622d4d49e29a8b67399d81d9073759fa2f578c5e.tar.bz2
GnuTLS: Add TEST_FAIL() to crypto routines for testing purposes
This allows number of hwsim test cases for local error conditions to be executed with GnuTLS-based builds. Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r--src/crypto/crypto_gnutls.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/crypto/crypto_gnutls.c b/src/crypto/crypto_gnutls.c
index 7c036a6..7a797b5 100644
--- a/src/crypto/crypto_gnutls.c
+++ b/src/crypto/crypto_gnutls.c
@@ -24,6 +24,9 @@ static int gnutls_digest_vector(int algo, size_t num_elem,
unsigned char *p;
size_t i;
+ if (TEST_FAIL())
+ return -1;
+
if (gcry_md_open(&hd, algo, 0) != GPG_ERR_NO_ERROR)
return -1;
for (i = 0; i < num_elem; i++)
@@ -103,6 +106,9 @@ static int gnutls_hmac_vector(int algo, const u8 *key, size_t key_len,
unsigned char *p;
size_t i;
+ if (TEST_FAIL())
+ return -1;
+
if (gcry_md_open(&hd, algo, GCRY_MD_FLAG_HMAC) != GPG_ERR_NO_ERROR)
return -1;
if (gcry_md_setkey(hd, key, key_len) != GPG_ERR_NO_ERROR) {
@@ -210,6 +216,9 @@ void * aes_encrypt_init(const u8 *key, size_t len)
{
gcry_cipher_hd_t hd;
+ if (TEST_FAIL())
+ return NULL;
+
if (gcry_cipher_open(&hd, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 0) !=
GPG_ERR_NO_ERROR) {
printf("cipher open failed\n");
@@ -244,6 +253,9 @@ void * aes_decrypt_init(const u8 *key, size_t len)
{
gcry_cipher_hd_t hd;
+ if (TEST_FAIL())
+ return NULL;
+
if (gcry_cipher_open(&hd, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 0) !=
GPG_ERR_NO_ERROR)
return NULL;