]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wolfSSL: Changes for memory allocation failure testing
authorSean Parkinson <sean@wolfssl.com>
Thu, 29 Mar 2018 04:55:55 +0000 (14:55 +1000)
committerJouni Malinen <j@w1.fi>
Wed, 2 May 2018 10:32:51 +0000 (13:32 +0300)
Signed-off-by: Sean Parkinson <sean@wolfssl.com>
src/crypto/crypto_wolfssl.c

index e29a6f5548aa52bca48b7a51e3b032b44f9edc79..3a8c4c5e8f3d0f99b2e4c32e7c021d50533d81b6 100644 (file)
@@ -423,6 +423,9 @@ int aes_wrap(const u8 *kek, size_t kek_len, int n, const u8 *plain, u8 *cipher)
 {
        int ret;
 
+       if (TEST_FAIL())
+               return -1;
+
        ret = wc_AesKeyWrap(kek, kek_len, plain, n * 8, cipher, (n + 1) * 8,
                            NULL);
        return ret != (n + 1) * 8 ? -1 : 0;
@@ -434,6 +437,9 @@ int aes_unwrap(const u8 *kek, size_t kek_len, int n, const u8 *cipher,
 {
        int ret;
 
+       if (TEST_FAIL())
+               return -1;
+
        ret = wc_AesKeyUnWrap(kek, kek_len, cipher, (n + 1) * 8, plain, n * 8,
                              NULL);
        return ret != n * 8 ? -1 : 0;
@@ -787,9 +793,6 @@ int crypto_dh_init(u8 generator, const u8 *prime, size_t prime_len, u8 *privkey,
        DhKey *dh = NULL;
        word32 priv_sz, pub_sz;
 
-       if (TEST_FAIL())
-               return -1;
-
        dh = os_malloc(sizeof(DhKey));
        if (!dh)
                return -1;