]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: test-crypto - Ensure function calls succeed in test_xd25519_keypair
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 18 Jan 2024 07:24:09 +0000 (09:24 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 18 Jan 2024 07:24:31 +0000 (09:24 +0200)
Found by static analysers

src/lib-dcrypt/test-crypto.c

index 2b7c0b1c0c36c018cab690f9d2b063e9bb63ca4f..b297165f7136a01421a2fa0735fcce429891a474 100644 (file)
@@ -1911,6 +1911,8 @@ static void test_xd25519_keypair(void)
        test_begin("X25519 key exchange");
        struct dcrypt_keypair pair;
        const char *error = NULL;
+       bool ret;
+
        if (!dcrypt_keypair_generate(&pair, DCRYPT_KEY_EC, 0, "X25519", &error))
                i_panic("%s", error);
        /* perform ecdh */
@@ -1931,15 +1933,18 @@ static void test_xd25519_keypair(void)
 
        struct dcrypt_keypair pair2;
 
-       dcrypt_key_load_public(&pair2.pub, str_c(pub), &error);
+       ret = dcrypt_key_load_public(&pair2.pub, str_c(pub), &error);
+       test_assert(ret == TRUE);
 
-       dcrypt_key_load_private(&pair2.priv, str_c(priv), NULL, NULL, &error);
+       ret = dcrypt_key_load_private(&pair2.priv, str_c(priv), NULL, NULL, &error);
+       test_assert(ret == TRUE);
 
        struct dcrypt_public_key *pub2;
        dcrypt_key_convert_private_to_public(pair2.priv, &pub2);
 
        str_truncate(pub, 0);
-       dcrypt_key_store_public(pub2, DCRYPT_FORMAT_DOVECOT, pub, &error);
+       ret = dcrypt_key_store_public(pub2, DCRYPT_FORMAT_DOVECOT, pub, &error);
+       test_assert(ret == TRUE);
 
        test_end();
 }