diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c index df7f2714..5f4a4ed8 100644 --- a/tests/client/torture_auth.c +++ b/tests/client/torture_auth.c @@ -534,8 +534,8 @@ static void torture_auth_cert(void **state) { rc = ssh_userauth_publickey(session, NULL, privkey); assert_int_equal(rc, SSH_AUTH_SUCCESS); - ssh_key_free(privkey); - ssh_key_free(cert); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(cert); } static void torture_auth_agent_cert(void **state) { diff --git a/tests/unittests/torture_hashes.c b/tests/unittests/torture_hashes.c index 76149dc2..59e23d28 100644 --- a/tests/unittests/torture_hashes.c +++ b/tests/unittests/torture_hashes.c @@ -41,7 +41,7 @@ static int setup_rsa_key(void **state) static int teardown(void **state) { - ssh_key_free(*state); + SSH_KEY_FREE(*state); return 0; } diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c index d9cd6e2a..7addce76 100644 --- a/tests/unittests/torture_options.c +++ b/tests/unittests/torture_options.c @@ -560,7 +560,7 @@ static void torture_bind_options_import_key(void **state) /* set invalid key */ rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_IMPORT_KEY, key); assert_int_equal(rc, -1); - ssh_key_free(key); + SSH_KEY_FREE(key); /* set rsa key */ base64_key = torture_get_testkey(SSH_KEYTYPE_RSA, 0, 0); diff --git a/tests/unittests/torture_pki_dsa.c b/tests/unittests/torture_pki_dsa.c index ebb3c8b2..37348511 100644 --- a/tests/unittests/torture_pki_dsa.c +++ b/tests/unittests/torture_pki_dsa.c @@ -82,7 +82,7 @@ static void torture_pki_dsa_import_pubkey_file(void **state) assert_return_code(rc, errno); assert_non_null(pubkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_dsa_import_pubkey_from_openssh_privkey(void **state) @@ -97,7 +97,7 @@ static void torture_pki_dsa_import_pubkey_from_openssh_privkey(void **state) assert_return_code(rc, errno); assert_non_null(pubkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_dsa_import_privkey_base64(void **state) @@ -115,7 +115,7 @@ static void torture_pki_dsa_import_privkey_base64(void **state) &key); assert_true(rc == 0); - ssh_key_free(key); + SSH_KEY_FREE(key); } #ifdef HAVE_LIBCRYPTO @@ -154,8 +154,8 @@ static void torture_pki_dsa_write_privkey(void **state) rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(origkey); - ssh_key_free(privkey); + SSH_KEY_FREE(origkey); + SSH_KEY_FREE(privkey); /* Test with passphrase */ rc = ssh_pki_import_privkey_file(LIBSSH_DSA_TESTKEY_PASSPHRASE, @@ -192,8 +192,8 @@ static void torture_pki_dsa_write_privkey(void **state) rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(origkey); - ssh_key_free(privkey); + SSH_KEY_FREE(origkey); + SSH_KEY_FREE(privkey); } #endif @@ -215,8 +215,7 @@ static void torture_pki_dsa_import_privkey_base64_passphrase(void **state) rc = ssh_key_is_private(key); assert_true(rc == 1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); /* test if it returns -1 if passphrase is wrong */ rc = ssh_pki_import_privkey_base64(torture_get_testkey(SSH_KEYTYPE_DSS, 0, 1), @@ -247,8 +246,7 @@ static void torture_pki_dsa_import_privkey_base64_passphrase(void **state) rc = ssh_key_is_private(key); assert_true(rc == 1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); /* test if it returns -1 if passphrase is wrong */ rc = ssh_pki_import_privkey_base64(torture_get_testkey(SSH_KEYTYPE_DSS, 0, 1), @@ -259,7 +257,7 @@ static void torture_pki_dsa_import_privkey_base64_passphrase(void **state) assert_true(rc == -1); /* This free in unnecessary, but the static analyser does not know */ - ssh_key_free(key); + SSH_KEY_FREE(key); #ifndef HAVE_LIBCRYPTO /* test if it returns -1 if passphrase is NULL */ @@ -272,7 +270,7 @@ static void torture_pki_dsa_import_privkey_base64_passphrase(void **state) assert_true(rc == -1); /* This free in unnecessary, but the static analyser does not know */ - ssh_key_free(key); + SSH_KEY_FREE(key); #endif /* HAVE_LIBCRYPTO */ } @@ -299,8 +297,7 @@ torture_pki_dsa_import_openssh_privkey_base64_passphrase(void **state) rc = ssh_key_is_private(key); assert_true(rc == 1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); /* test if it returns -1 if passphrase is wrong */ rc = ssh_pki_import_privkey_base64(keystring, @@ -328,8 +325,7 @@ torture_pki_dsa_import_openssh_privkey_base64_passphrase(void **state) rc = ssh_key_is_private(key); assert_true(rc == 1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); /* test if it returns -1 if passphrase is wrong */ rc = ssh_pki_import_privkey_base64(keystring, @@ -371,8 +367,8 @@ static void torture_pki_dsa_publickey_from_privatekey(void **state) rc = ssh_pki_export_privkey_to_pubkey(key, &pubkey); assert_true(rc == SSH_OK); - ssh_key_free(key); - ssh_key_free(pubkey); + SSH_KEY_FREE(key); + SSH_KEY_FREE(pubkey); } static void torture_pki_dsa_import_cert_file(void **state) @@ -392,7 +388,7 @@ static void torture_pki_dsa_import_cert_file(void **state) rc = ssh_key_is_public(cert); assert_true(rc == 1); - ssh_key_free(cert); + SSH_KEY_FREE(cert); } static void torture_pki_dsa_publickey_base64(void **state) @@ -443,7 +439,7 @@ static void torture_pki_dsa_publickey_base64(void **state) free(b64_key); free(key_buf); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_dsa_generate_pubkey_from_privkey(void **state) @@ -482,8 +478,8 @@ static void torture_pki_dsa_generate_pubkey_from_privkey(void **state) pubkey_generated, len); - ssh_key_free(privkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_dsa_duplicate_key(void **state) @@ -503,7 +499,7 @@ static void torture_pki_dsa_duplicate_key(void **state) rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key); assert_true(rc == 0); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); rc = ssh_pki_import_privkey_file(LIBSSH_DSA_TESTKEY, NULL, @@ -530,9 +526,9 @@ static void torture_pki_dsa_duplicate_key(void **state) rc = ssh_key_cmp(privkey, privkey_dup, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(pubkey); - ssh_key_free(privkey); - ssh_key_free(privkey_dup); + SSH_KEY_FREE(pubkey); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(privkey_dup); SSH_STRING_FREE_CHAR(b64_key); SSH_STRING_FREE_CHAR(b64_key_gen); } @@ -553,8 +549,7 @@ static void torture_pki_dsa_generate_key(void **state) rc = pki_signature_verify(session,sign,key,DSA_HASH,20); assert_true(rc == SSH_OK); ssh_signature_free(sign); - ssh_key_free(key); - key=NULL; + SSH_KEY_FREE(key); rc = ssh_pki_generate(SSH_KEYTYPE_DSS, 2048, &key); assert_true(rc == SSH_OK); @@ -564,8 +559,7 @@ static void torture_pki_dsa_generate_key(void **state) rc = pki_signature_verify(session,sign,key,DSA_HASH,20); assert_true(rc == SSH_OK); ssh_signature_free(sign); - ssh_key_free(key); - key=NULL; + SSH_KEY_FREE(key); rc = ssh_pki_generate(SSH_KEYTYPE_DSS, 3072, &key); assert_true(rc == SSH_OK); @@ -575,8 +569,7 @@ static void torture_pki_dsa_generate_key(void **state) rc = pki_signature_verify(session,sign,key,DSA_HASH,20); assert_true(rc == SSH_OK); ssh_signature_free(sign); - ssh_key_free(key); - key=NULL; + SSH_KEY_FREE(key); ssh_free(session); } diff --git a/tests/unittests/torture_pki_ecdsa.c b/tests/unittests/torture_pki_ecdsa.c index 43d9fadb..7ef354f7 100644 --- a/tests/unittests/torture_pki_ecdsa.c +++ b/tests/unittests/torture_pki_ecdsa.c @@ -121,7 +121,7 @@ static void torture_pki_ecdsa_import_pubkey_file(void **state) assert_return_code(rc, errno); assert_non_null(pubkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_ecdsa_import_pubkey_from_openssh_privkey(void **state) @@ -136,7 +136,7 @@ static void torture_pki_ecdsa_import_pubkey_from_openssh_privkey(void **state) assert_return_code(rc, errno); assert_non_null(pubkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_ecdsa_import_privkey_base64(void **state) @@ -158,7 +158,7 @@ static void torture_pki_ecdsa_import_privkey_base64(void **state) assert_true(rc == 1); free(key_str); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_ecdsa_publickey_from_privatekey(void **state) @@ -181,8 +181,8 @@ static void torture_pki_ecdsa_publickey_from_privatekey(void **state) assert_true(rc == SSH_OK); free(key_str); - ssh_key_free(key); - ssh_key_free(pubkey); + SSH_KEY_FREE(key); + SSH_KEY_FREE(pubkey); } static void torture_pki_ecdsa_publickey_base64(void **state) @@ -219,7 +219,7 @@ static void torture_pki_ecdsa_publickey_base64(void **state) free(b64_key); free(key_buf); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_ecdsa_generate_pubkey_from_privkey(void **state) @@ -261,8 +261,8 @@ static void torture_pki_ecdsa_generate_pubkey_from_privkey(void **state) len = torture_pubkey_len(pubkey_original); assert_int_equal(strncmp(pubkey_original, pubkey_generated, len), 0); - ssh_key_free(privkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_ecdsa_duplicate_key(void **state) @@ -281,7 +281,7 @@ static void torture_pki_ecdsa_duplicate_key(void **state) rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key); assert_true(rc == 0); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); rc = ssh_pki_import_privkey_file(LIBSSH_ECDSA_TESTKEY, NULL, @@ -307,9 +307,9 @@ static void torture_pki_ecdsa_duplicate_key(void **state) rc = ssh_key_cmp(privkey, privkey_dup, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(pubkey); - ssh_key_free(privkey); - ssh_key_free(privkey_dup); + SSH_KEY_FREE(pubkey); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(privkey_dup); SSH_STRING_FREE_CHAR(b64_key); SSH_STRING_FREE_CHAR(b64_key_gen); } @@ -342,9 +342,9 @@ static void torture_pki_ecdsa_duplicate_then_demote(void **state) assert_true(rc == 0); assert_int_equal(pubkey->ecdsa_nid, privkey->ecdsa_nid); - ssh_key_free(pubkey); - ssh_key_free(privkey); - ssh_key_free(privkey_dup); + SSH_KEY_FREE(pubkey); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(privkey_dup); } static void torture_pki_generate_key_ecdsa(void **state) @@ -373,8 +373,7 @@ static void torture_pki_generate_key_ecdsa(void **state) assert_true(strcmp(etype_char, "ecdsa-sha2-nistp256") == 0); ssh_signature_free(sign); - ssh_key_free(key); - key=NULL; + SSH_KEY_FREE(key); rc = ssh_pki_generate(SSH_KEYTYPE_ECDSA, 384, &key); assert_true(rc == SSH_OK); @@ -391,8 +390,7 @@ static void torture_pki_generate_key_ecdsa(void **state) assert_true(strcmp(etype_char, "ecdsa-sha2-nistp384") == 0); ssh_signature_free(sign); - ssh_key_free(key); - key=NULL; + SSH_KEY_FREE(key); rc = ssh_pki_generate(SSH_KEYTYPE_ECDSA, 512, &key); assert_true(rc == SSH_OK); @@ -409,8 +407,7 @@ static void torture_pki_generate_key_ecdsa(void **state) assert_true(strcmp(etype_char, "ecdsa-sha2-nistp521") == 0); ssh_signature_free(sign); - ssh_key_free(key); - key=NULL; + SSH_KEY_FREE(key); ssh_free(session); } @@ -451,8 +448,8 @@ static void torture_pki_ecdsa_write_privkey(void **state) rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(origkey); - ssh_key_free(privkey); + SSH_KEY_FREE(origkey); + SSH_KEY_FREE(privkey); /* Test with passphrase */ rc = ssh_pki_import_privkey_file(LIBSSH_ECDSA_TESTKEY_PASSPHRASE, @@ -489,8 +486,8 @@ static void torture_pki_ecdsa_write_privkey(void **state) rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(origkey); - ssh_key_free(privkey); + SSH_KEY_FREE(origkey); + SSH_KEY_FREE(privkey); } #endif /* HAVE_LIBCRYPTO */ @@ -508,7 +505,7 @@ static void torture_pki_ecdsa_name(void **state, const char *expected_name) etype_char =ssh_pki_key_ecdsa_name(key); assert_true(strcmp(etype_char, expected_name) == 0); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_ecdsa_name256(void **state) diff --git a/tests/unittests/torture_pki_ed25519.c b/tests/unittests/torture_pki_ed25519.c index 39012168..16bd91f3 100644 --- a/tests/unittests/torture_pki_ed25519.c +++ b/tests/unittests/torture_pki_ed25519.c @@ -62,7 +62,7 @@ static void torture_pki_ed25519_import_pubkey_file(void **state) assert_return_code(rc, errno); assert_non_null(pubkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_ed25519_import_pubkey_from_openssh_privkey(void **state) @@ -77,7 +77,7 @@ static void torture_pki_ed25519_import_pubkey_from_openssh_privkey(void **state) assert_return_code(rc, errno); assert_non_null(pubkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_ed25519_import_privkey_base64(void **state) @@ -106,7 +106,7 @@ static void torture_pki_ed25519_import_privkey_base64(void **state) assert_true(rc == 1); free(key_str); - ssh_key_free(key); + SSH_KEY_FREE(key); } @@ -141,7 +141,7 @@ static void torture_pki_ed25519_import_export_privkey_base64(void **state) NULL, &b64_key); assert_return_code(rc, errno); - ssh_key_free(key); + SSH_KEY_FREE(key); rc = ssh_pki_import_privkey_base64(b64_key, passphrase, @@ -157,7 +157,7 @@ static void torture_pki_ed25519_import_export_privkey_base64(void **state) assert_true(rc == 1); SSH_STRING_FREE_CHAR(b64_key); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_ed25519_publickey_from_privatekey(void **state) @@ -184,8 +184,8 @@ static void torture_pki_ed25519_publickey_from_privatekey(void **state) rc = ssh_pki_export_privkey_to_pubkey(key, &pubkey); assert_true(rc == SSH_OK); - ssh_key_free(key); - ssh_key_free(pubkey); + SSH_KEY_FREE(key); + SSH_KEY_FREE(pubkey); } static void torture_pki_ed25519_publickey_base64(void **state) @@ -222,7 +222,7 @@ static void torture_pki_ed25519_publickey_base64(void **state) free(b64_key); free(key_buf); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_ed25519_generate_pubkey_from_privkey(void **state) @@ -261,8 +261,8 @@ static void torture_pki_ed25519_generate_pubkey_from_privkey(void **state) pubkey_generated, len); - ssh_key_free(privkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_ed25519_generate_key(void **state) @@ -293,8 +293,7 @@ static void torture_pki_ed25519_generate_key(void **state) assert_true(rc == SSH_ERROR); ssh_signature_free(sign); - ssh_key_free(key); - key=NULL; + SSH_KEY_FREE(key); ssh_free(session); } @@ -336,7 +335,7 @@ static void torture_pki_ed25519_write_privkey(void **state) assert_true(rc == 0); unlink(LIBSSH_ED25519_TESTKEY); - ssh_key_free(privkey); + SSH_KEY_FREE(privkey); /* do the same with passphrase */ rc = ssh_pki_export_privkey_file(origkey, torture_get_testkey_passphrase(), @@ -365,8 +364,8 @@ static void torture_pki_ed25519_write_privkey(void **state) assert_true(rc == 0); unlink(LIBSSH_ED25519_TESTKEY); - ssh_key_free(origkey); - ssh_key_free(privkey); + SSH_KEY_FREE(origkey); + SSH_KEY_FREE(privkey); /* Test with passphrase */ rc = ssh_pki_import_privkey_file(LIBSSH_ED25519_TESTKEY_PASSPHRASE, @@ -404,8 +403,8 @@ static void torture_pki_ed25519_write_privkey(void **state) rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(origkey); - ssh_key_free(privkey); + SSH_KEY_FREE(origkey); + SSH_KEY_FREE(privkey); } static void torture_pki_ed25519_sign(void **state) @@ -441,7 +440,7 @@ static void torture_pki_ed25519_sign(void **state) assert_memory_equal(ssh_string_data(blob), ref_signature, sizeof(ref_signature)); /* ssh_print_hexa("signature", ssh_string_data(blob), ssh_string_len(blob)); */ ssh_signature_free(sig); - ssh_key_free(privkey); + SSH_KEY_FREE(privkey); ssh_string_free(blob); } @@ -473,7 +472,7 @@ static void torture_pki_ed25519_verify(void **state){ ssh_signature_free(sig); /* alter signature and expect false result */ - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); ssh_string_free(blob); free(pkey_ptr); } @@ -509,7 +508,7 @@ static void torture_pki_ed25519_verify_bad(void **state){ ssh_signature_free(sig); } - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); ssh_string_free(blob); free(pkey_ptr); } @@ -535,8 +534,7 @@ static void torture_pki_ed25519_import_privkey_base64_passphrase(void **state) rc = ssh_key_is_private(key); assert_true(rc == 1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); /* test if it returns -1 if passphrase is wrong */ rc = ssh_pki_import_privkey_base64(testkey, @@ -545,7 +543,7 @@ static void torture_pki_ed25519_import_privkey_base64_passphrase(void **state) NULL, &key); assert_true(rc == -1); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_ed25519_privkey_dup(void **state) @@ -572,8 +570,8 @@ static void torture_pki_ed25519_privkey_dup(void **state) dup = ssh_key_dup(key); assert_non_null(dup); - ssh_key_free(key); - ssh_key_free(dup); + SSH_KEY_FREE(key); + SSH_KEY_FREE(dup); } static void torture_pki_ed25519_pubkey_dup(void **state) @@ -609,8 +607,8 @@ static void torture_pki_ed25519_pubkey_dup(void **state) assert_true(rc == 1); SAFE_FREE(pub_str); - ssh_key_free(pubkey); - ssh_key_free(dup); + SSH_KEY_FREE(pubkey); + SSH_KEY_FREE(dup); } int torture_run_tests(void) { diff --git a/tests/unittests/torture_pki_rsa.c b/tests/unittests/torture_pki_rsa.c index d0203545..15ad6466 100644 --- a/tests/unittests/torture_pki_rsa.c +++ b/tests/unittests/torture_pki_rsa.c @@ -84,7 +84,7 @@ static void torture_pki_rsa_import_pubkey_file(void **state) assert_return_code(rc, errno); assert_non_null(pubkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_rsa_import_pubkey_from_openssh_privkey(void **state) @@ -99,7 +99,7 @@ static void torture_pki_rsa_import_pubkey_from_openssh_privkey(void **state) assert_return_code(rc, errno); assert_non_null(pubkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_rsa_import_privkey_base64_NULL_key(void **state) @@ -131,7 +131,7 @@ static void torture_pki_rsa_import_privkey_base64_NULL_str(void **state) rc = ssh_pki_import_privkey_base64(NULL, passphrase, NULL, NULL, &key); assert_true(rc == -1); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_rsa_import_privkey_base64(void **state) @@ -160,7 +160,7 @@ static void torture_pki_rsa_import_privkey_base64(void **state) assert_true(rc == 1); free(key_str); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_rsa_publickey_from_privatekey(void **state) @@ -185,8 +185,8 @@ static void torture_pki_rsa_publickey_from_privatekey(void **state) rc = ssh_pki_export_privkey_to_pubkey(key, &pubkey); assert_true(rc == SSH_OK); - ssh_key_free(key); - ssh_key_free(pubkey); + SSH_KEY_FREE(key); + SSH_KEY_FREE(pubkey); } static void torture_pki_rsa_copy_cert_to_privkey(void **state) @@ -239,9 +239,9 @@ static void torture_pki_rsa_copy_cert_to_privkey(void **state) rc = ssh_pki_copy_cert_to_privkey(cert, privkey); assert_true(rc == SSH_ERROR); - ssh_key_free(cert); - ssh_key_free(privkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(cert); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_rsa_import_cert_file(void **state) { @@ -260,7 +260,7 @@ static void torture_pki_rsa_import_cert_file(void **state) { rc = ssh_key_is_public(cert); assert_true(rc == 1); - ssh_key_free(cert); + SSH_KEY_FREE(cert); } static void torture_pki_rsa_publickey_base64(void **state) @@ -297,7 +297,7 @@ static void torture_pki_rsa_publickey_base64(void **state) free(b64_key); free(key_buf); - ssh_key_free(key); + SSH_KEY_FREE(key); } static void torture_pki_rsa_generate_pubkey_from_privkey(void **state) { @@ -335,8 +335,8 @@ static void torture_pki_rsa_generate_pubkey_from_privkey(void **state) { pubkey_generated, len); - ssh_key_free(privkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(pubkey); } static void torture_pki_rsa_duplicate_key(void **state) @@ -356,7 +356,7 @@ static void torture_pki_rsa_duplicate_key(void **state) rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key); assert_true(rc == 0); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); rc = ssh_pki_import_privkey_file(LIBSSH_RSA_TESTKEY, NULL, @@ -382,9 +382,9 @@ static void torture_pki_rsa_duplicate_key(void **state) rc = ssh_key_cmp(privkey, privkey_dup, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(pubkey); - ssh_key_free(privkey); - ssh_key_free(privkey_dup); + SSH_KEY_FREE(pubkey); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(privkey_dup); SSH_STRING_FREE_CHAR(b64_key); SSH_STRING_FREE_CHAR(b64_key_gen); } @@ -405,7 +405,7 @@ static void torture_pki_rsa_generate_key(void **state) rc = pki_signature_verify(session,sign,key,RSA_HASH,20); assert_true(rc == SSH_OK); ssh_signature_free(sign); - ssh_key_free(key); + SSH_KEY_FREE(key); key=NULL; rc = ssh_pki_generate(SSH_KEYTYPE_RSA, 2048, &key); @@ -416,7 +416,7 @@ static void torture_pki_rsa_generate_key(void **state) rc = pki_signature_verify(session,sign,key,RSA_HASH,20); assert_true(rc == SSH_OK); ssh_signature_free(sign); - ssh_key_free(key); + SSH_KEY_FREE(key); key=NULL; rc = ssh_pki_generate(SSH_KEYTYPE_RSA, 4096, &key); @@ -427,7 +427,7 @@ static void torture_pki_rsa_generate_key(void **state) rc = pki_signature_verify(session,sign,key,RSA_HASH,20); assert_true(rc == SSH_OK); ssh_signature_free(sign); - ssh_key_free(key); + SSH_KEY_FREE(key); key=NULL; ssh_free(session); @@ -477,7 +477,7 @@ static void torture_pki_rsa_sha2(void **state) ssh_signature_free(sign); /* Cleanup */ - ssh_key_free(key); + SSH_KEY_FREE(key); ssh_free(session); } @@ -518,8 +518,8 @@ static void torture_pki_rsa_write_privkey(void **state) rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(origkey); - ssh_key_free(privkey); + SSH_KEY_FREE(origkey); + SSH_KEY_FREE(privkey); /* Test with passphrase */ rc = ssh_pki_import_privkey_file(LIBSSH_RSA_TESTKEY_PASSPHRASE, @@ -557,8 +557,8 @@ static void torture_pki_rsa_write_privkey(void **state) rc = ssh_key_cmp(origkey, privkey, SSH_KEY_CMP_PRIVATE); assert_true(rc == 0); - ssh_key_free(origkey); - ssh_key_free(privkey); + SSH_KEY_FREE(origkey); + SSH_KEY_FREE(privkey); } #endif /* HAVE_LIBCRYPTO */ @@ -581,8 +581,7 @@ static void torture_pki_rsa_import_privkey_base64_passphrase(void **state) rc = ssh_key_is_private(key); assert_true(rc == 1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); /* test if it returns -1 if passphrase is wrong */ rc = ssh_pki_import_privkey_base64(torture_get_testkey(SSH_KEYTYPE_RSA, 0, 1), @@ -591,8 +590,7 @@ static void torture_pki_rsa_import_privkey_base64_passphrase(void **state) NULL, &key); assert_true(rc == -1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); #ifndef HAVE_LIBCRYPTO /* test if it returns -1 if passphrase is NULL */ @@ -603,8 +601,7 @@ static void torture_pki_rsa_import_privkey_base64_passphrase(void **state) NULL, &key); assert_true(rc == -1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); #endif } @@ -631,8 +628,7 @@ torture_pki_rsa_import_openssh_privkey_base64_passphrase(void **state) rc = ssh_key_is_private(key); assert_true(rc == 1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); /* test if it returns -1 if passphrase is wrong */ rc = ssh_pki_import_privkey_base64(keystring, @@ -641,8 +637,7 @@ torture_pki_rsa_import_openssh_privkey_base64_passphrase(void **state) NULL, &key); assert_true(rc == -1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); /* test if it returns -1 if passphrase is NULL */ /* libcrypto asks for a passphrase, so skip this test */ @@ -652,8 +647,7 @@ torture_pki_rsa_import_openssh_privkey_base64_passphrase(void **state) NULL, &key); assert_true(rc == -1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); } int torture_run_tests(void) { diff --git a/tests/unittests/torture_threads_pki_rsa.c b/tests/unittests/torture_threads_pki_rsa.c index 33478a37..1313f566 100644 --- a/tests/unittests/torture_threads_pki_rsa.c +++ b/tests/unittests/torture_threads_pki_rsa.c @@ -143,7 +143,7 @@ static void *thread_pki_rsa_import_pubkey_file(void *threadid) assert_return_code(rc, errno); assert_non_null(pubkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); pthread_exit(NULL); } @@ -201,7 +201,7 @@ static void *thread_pki_rsa_import_privkey_base64_NULL_str(void *threadid) rc = ssh_pki_import_privkey_base64(NULL, passphrase, NULL, NULL, &key); assert_true(rc == -1); - ssh_key_free(key); + SSH_KEY_FREE(key); pthread_exit(NULL); } @@ -242,7 +242,7 @@ static void *thread_pki_rsa_import_privkey_base64(void *threadid) assert_true(ok); free(key_str); - ssh_key_free(key); + SSH_KEY_FREE(key); pthread_exit(NULL); } @@ -283,8 +283,8 @@ static void *thread_pki_rsa_publickey_from_privatekey(void *threadid) assert_true(rc == SSH_OK); assert_non_null(pubkey); - ssh_key_free(key); - ssh_key_free(pubkey); + SSH_KEY_FREE(key); + SSH_KEY_FREE(pubkey); pthread_exit(NULL); } @@ -349,9 +349,9 @@ static void *thread_pki_rsa_copy_cert_to_privkey(void *threadid) rc = ssh_pki_copy_cert_to_privkey(cert, privkey); assert_true(rc == SSH_ERROR); - ssh_key_free(cert); - ssh_key_free(privkey); - ssh_key_free(pubkey); + SSH_KEY_FREE(cert); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(pubkey); pthread_exit(NULL); } @@ -383,7 +383,7 @@ static void *thread_pki_rsa_import_cert_file(void *threadid) rc = ssh_key_is_public(cert); assert_true(rc == 1); - ssh_key_free(cert); + SSH_KEY_FREE(cert); pthread_exit(NULL); } @@ -432,7 +432,7 @@ static void *thread_pki_rsa_publickey_base64(void *threadid) free(b64_key); free(key_buf); - ssh_key_free(key); + SSH_KEY_FREE(key); pthread_exit(NULL); } @@ -464,7 +464,7 @@ static void *thread_pki_rsa_duplicate_key(void *threadid) rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key); assert_true(rc == 0); - ssh_key_free(pubkey); + SSH_KEY_FREE(pubkey); rc = ssh_pki_import_privkey_file(LIBSSH_RSA_TESTKEY, NULL, @@ -489,9 +489,9 @@ static void *thread_pki_rsa_duplicate_key(void *threadid) cmp = ssh_key_cmp(privkey, privkey_dup, SSH_KEY_CMP_PRIVATE); assert_true(cmp == 0); - ssh_key_free(pubkey); - ssh_key_free(privkey); - ssh_key_free(privkey_dup); + SSH_KEY_FREE(pubkey); + SSH_KEY_FREE(privkey); + SSH_KEY_FREE(privkey_dup); SSH_STRING_FREE_CHAR(b64_key); SSH_STRING_FREE_CHAR(b64_key_gen); pthread_exit(NULL); @@ -531,8 +531,7 @@ static void *thread_pki_rsa_generate_key(void *threadid) assert_ssh_return_code(session, rc); ssh_signature_free(sign); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); rc = ssh_pki_generate(SSH_KEYTYPE_RSA, 2048, &key); assert_ssh_return_code(session, rc); @@ -545,8 +544,7 @@ static void *thread_pki_rsa_generate_key(void *threadid) assert_ssh_return_code(session, rc); ssh_signature_free(sign); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); rc = ssh_pki_generate(SSH_KEYTYPE_RSA, 4096, &key); @@ -560,7 +558,7 @@ static void *thread_pki_rsa_generate_key(void *threadid) assert_true(rc == SSH_OK); ssh_signature_free(sign); - ssh_key_free(key); + SSH_KEY_FREE(key); key = NULL; ssh_free(session); @@ -596,8 +594,7 @@ static void *thread_pki_rsa_import_privkey_base64_passphrase(void *threadid) rc = ssh_key_is_private(key); assert_true(rc == 1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); /* test if it returns -1 if passphrase is wrong */ rc = ssh_pki_import_privkey_base64(torture_get_testkey(SSH_KEYTYPE_RSA, 0, 1), @@ -606,8 +603,7 @@ static void *thread_pki_rsa_import_privkey_base64_passphrase(void *threadid) NULL, &key); assert_true(rc == -1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); #ifndef HAVE_LIBCRYPTO /* test if it returns -1 if passphrase is NULL */ @@ -618,8 +614,7 @@ static void *thread_pki_rsa_import_privkey_base64_passphrase(void *threadid) NULL, &key); assert_true(rc == -1); - ssh_key_free(key); - key = NULL; + SSH_KEY_FREE(key); #endif pthread_exit(NULL); }