tests: Replace ssh_key_free() with SSH_KEY_FREE()

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Anderson Toshiyuki Sasaki
2018-09-24 18:42:22 +02:00
committed by Andreas Schneider
parent 143b5e2e50
commit 2eaa23a20e
8 changed files with 129 additions and 152 deletions

View File

@@ -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);
}