#include <ckmc/ckmc-type.h>
#include <ckmc/ckmc-error.h>
+#include <ckm-common.h>
+
#include <string>
#include <string.h>
#include <stdio.h>
static const int USER_APP = 5000;
static const int GROUP_APP = 5000;
-namespace
-{
+namespace {
typedef enum {
ALIAS_KEY,
retval.size = strlen(input);
return retval;
}
-}
+
+} // namespace anonymous
RUNNER_TEST_GROUP_INIT (T301_CKMC_CONTROL_C_API);
int temp;
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3012_Control_C_API)
int temp;
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3013_Control_C_API)
int temp;
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3014_Control_C_API)
int temp;
const uid_t UNIQUE_USER = 15;
- // clean up environment
- RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
- "Error=" << temp);
- // unlock with default password
- RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(UNIQUE_USER, NULL)),
- "Error=" << temp);
+ // clean up environment
+ RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
+ CKMCReadableError(temp));
+ // unlock with default password
+ RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(UNIQUE_USER, NULL)),
+ CKMCReadableError(temp));
// reset password (NULL, "simple-password")
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_reset_user_password(UNIQUE_USER, "simple-password")),
- "Error=" << temp);
+ CKMCReadableError(temp));
// get rid of NULL DKEK
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(UNIQUE_USER, "simple-password")),
- "Error=" << temp);
+ CKMCReadableError(temp));
// lock db
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(UNIQUE_USER)),
- "Error=" << temp);
+ CKMCReadableError(temp));
// try to reset password when db locked
RUNNER_ASSERT_MSG( CKMC_ERROR_BAD_REQUEST == (temp = ckmc_reset_user_password(UNIQUE_USER, "simple-password")),
- "Error=" << temp);
- // clean up environment
- RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
- "Error=" << temp);
+ CKMCReadableError(temp));
+ // clean up environment
+ RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3015_Control_C_API)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(20, "test-pass")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_change_user_password(20, "test-pass", "new-pass")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(20)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(20)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3016_Control_C_API)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(20)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(20)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST_GROUP_INIT (T302_CKMC_QUICK_SET_GET_TESTS_C_API);
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3022_key_C_API)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(alias, test_key, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(alias, password, &test_key2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3023_certificate_C_API)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert(alias, cert, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_cert(alias, password, &cert2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_cert_free(cert2);
}
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_cert(alias, password, &cert2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_cert_free(cert2);
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_cert(alias)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE != (temp = ckmc_get_cert(alias, password, &cert2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3025_certificate_list_C_API)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert("cert_test1", cert, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert("cert_test2", cert, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert("cert_test3", cert, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
(current_aliases_num+3) == (temp = count_aliases(ALIAS_CERT)),
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(alias, test_key, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(alias, passwordPolicy, &test_key2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
// RUNNER_ASSERT_MSG(
// key.getDER() == key2.getDER(), "Key value has been changed by service");
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key("appkey1", test_key, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NOT_EXPORTABLE == (temp = ckmc_get_key("appkey1", password, &test_key2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
const char *alias = "test-cert-1-DSA";
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert(alias, cert, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_cert(alias, password, &cert2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_cert_free(cert2);
}
int temp;
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "simple-password")),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3032_save_keys_get_alias_C_API)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key("rootkey1", test_key, test_policy1)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key("rootkey2", test_key, test_policy2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key("rootkey3", test_key, test_policy3)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
(current_aliases_num+3) == (temp = count_aliases(ALIAS_KEY)),
ckmc_key_s *test_key2;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key("rootkey1", password, &test_key2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_key("rootkey1")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE != (temp = ckmc_get_key("rootkey1", password, &test_key2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3034_deinit_C_API)
int temp;
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST_GROUP_INIT (T3040_CKMC_QUICK_REMOVE_BIN_DATA_TEST_C_API);
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "simple-password")),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3042_save_get_bin_data_C_API)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_data("data1", testData1, test_policy1)), // should change it as null value
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_data("data2", testData2, test_policy1)), // should change it as null value
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_data("data3", testData3, test_policy2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_INVALID_PARAMETER == (temp = ckmc_save_data("data4", testData3, test_policy3)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
(current_aliases_num+3) == (temp = count_aliases(ALIAS_DATA)),
ckmc_raw_buffer_s *testData4;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_data("data2", password, &testData4)),
- "Error=" << temp);
+ CKMCReadableError(temp));
int compareResult;
compareResult = (strcmp((const char *)testData2.data, (const char *)testData4->data));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_data("appdata1", testData1, test_policy1)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_data("appdata2", testData1, test_policy1)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_data("appdata3", testData1, test_policy2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
(current_aliases_num+3) == (temp = count_aliases(ALIAS_DATA)),
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_data("data1")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_data("data3")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
(current_aliases_num-2) == (temp = count_aliases(ALIAS_DATA)),
CKM::RawBuffer buffer;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_data("data2", password, &testData1)),
- "Error=" << temp);
+ CKMCReadableError(temp));
int compareResult;
compareResult = (strcmp((const char *)testData2.data, (const char *)testData1->data));
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_UNKNOWN == (temp = ckmc_get_data("data3", password, &testData1)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3045_deinit_C_API)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST_GROUP_INIT(T305_CKMC_QUICK_CREATE_PAIR_CAPI);
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_CHILD_TEST(T3052_CAPI_create_rsa_key)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_rsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
(current_aliases_num+2) == (temp = count_aliases(ALIAS_KEY)),
ckmc_key_s *privateKey;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(private_key_alias, policy_private_key.password,&privateKey)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
privateKey->key_type == CKMC_KEY_RSA_PRIVATE,
"Key Type Error: expected =" << static_cast<int>(CKMC_KEY_RSA_PRIVATE) << ", actual=" << static_cast<int>(privateKey->key_type));
RUNNER_ASSERT_MSG(
privateKey != NULL && privateKey->key_size > 0 && privateKey->raw_key != NULL,
- "Error=" << temp);
+ "Private key is broken.");
ckmc_key_s *publicKey;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(public_key_alias, policy_public_key.password, &publicKey)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
publicKey->key_type == CKMC_KEY_RSA_PUBLIC,
"Key Type Error: expected =" << static_cast<int>(CKMC_KEY_RSA_PUBLIC) << ", actual=" << static_cast<int>(publicKey->key_type));
RUNNER_ASSERT_MSG(
publicKey != NULL && publicKey->key_size > 0 && publicKey->raw_key != NULL,
- "Error=" << temp);
+ "Public key is broken.");
// on next attempt to generate keys with the same alias, expect fail (alias exists)
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_create_key_pair_rsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
- "Error=" << temp << ", ret=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_CHILD_TEST(T3053_CAPI_create_dsa_key)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_dsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
(current_aliases_num+2) == (temp = count_aliases(ALIAS_KEY)),
ckmc_key_s *privateKey = 0;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(private_key_alias, policy_private_key.password,&privateKey)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
privateKey != NULL && privateKey->key_size > 0 && privateKey->raw_key != NULL,
- "Error=" << temp);
+ "Private key is broken.");
RUNNER_ASSERT_MSG(
privateKey->key_type == CKMC_KEY_DSA_PRIVATE,
"Key Type Error: expected =" << static_cast<int>(CKMC_KEY_DSA_PRIVATE) << ", actual=" << static_cast<int>(privateKey->key_type));
ckmc_key_s *pubKey = 0;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(public_key_alias, policy_public_key.password, &pubKey)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
pubKey != NULL && pubKey->key_size > 0 && pubKey->raw_key != NULL,
- "Error=" << temp);
+ "Public key is broken.");
RUNNER_ASSERT_MSG(
pubKey->key_type == CKMC_KEY_DSA_PUBLIC,
"Key Type Error: expected =" << static_cast<int>(CKMC_KEY_DSA_PUBLIC) << ", actual=" << static_cast<int>(pubKey->key_type));
// on next attempt to generate keys with the same alias, expect fail (alias exists)
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_create_key_pair_dsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
- "Error=" << temp << ", ret=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3062_CAPI_CreateKeyPairRSA)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_rsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
- "Error=" << temp);
+ CKMCReadableError(temp));
// on next attempt to generate keys with the same alias, expect fail (alias exists)
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_create_key_pair_rsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
- "Error=" << temp << ", ret=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3063_CAPI_CreateKeyPairDSA)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_dsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3064_CAPI_CreateKeyPairECDSA)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_ecdsa(ectype, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3065_CAPI_deinit)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
// TODO
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3072_CAPI_get_chain)
tmp = ckmc_get_cert_chain(&c_cert, &untrustedcerts, &cert_chain_list);
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == tmp, "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+ CKMC_ERROR_NONE == tmp, CKMCReadableError(tmp));
int cnt = 0;
ckmc_cert_list_s *current;
ckmc_cert_list_s *untrustedcerts2 = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_VERIFICATION_FAILED == (tmp = ckmc_get_cert_chain(&c_cert, untrustedcerts2, &cert_chain_list2)),
- "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+ CKMCReadableError(tmp));
RUNNER_ASSERT_MSG(
cert_chain_list2 == NULL,
int tmp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_save_cert(untrusted_alias, c_cert1, test_policy)),
- "Error=" << tmp);
+ CKMCReadableError(tmp));
CharPtr top_label = get_label();
std::string full_address = aliasWithLabel(top_label.get(), untrusted_alias);
ckmc_cert_s *c_cert_tmp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_get_cert(full_address.c_str(), NULL, &c_cert_tmp)),
- "Error=" << tmp);
+ CKMCReadableError(tmp));
ckmc_cert_free(c_cert_tmp);
// get cert chain using alias in full "label alias" form
ckmc_cert_list_s *cert_chain_list;
tmp = ckmc_get_cert_chain_with_alias(&c_cert, untrustedcerts, &cert_chain_list);
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == tmp, "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+ RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == tmp, CKMCReadableError(tmp));
ckmc_alias_list_free(untrustedcerts);
ckmc_alias_list_s *untrustedcerts2 = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_VERIFICATION_FAILED == (tmp = ckmc_get_cert_chain_with_alias(&c_cert, untrustedcerts2, &cert_chain_list2)),
- "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+ CKMCReadableError(tmp));
RUNNER_ASSERT_MSG(
cert_chain_list2 == NULL,
int tmp = ckmc_get_cert_chain(&c_cert, &untrustedcerts, &cert_chain_list);
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == tmp, "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+ CKMC_ERROR_NONE == tmp, CKMCReadableError(tmp));
RUNNER_ASSERT_MSG(cert_chain_list != NULL, "Wrong size of certificate chain.");
ckmc_ocsp_status_e ocsp_status;
- RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (tmp = ckmc_ocsp_check(cert_chain_list, &ocsp_status)), "Error: " << tmp);
+ RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (tmp = ckmc_ocsp_check(cert_chain_list, &ocsp_status)), CKMCReadableError(tmp));
RUNNER_ASSERT_MSG(ocsp_status == CKMC_OCSP_STATUS_GOOD, "Wrong status: " << static_cast<int>(ocsp_status));
}
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3082_CAPI__rsa_key_create_verify)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pub_alias, pubkey, pubpolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_signature(
hash_algo,
pad_algo,
&signature)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3083_CAPI__rsa_key_create_verify_negative)
hash_algo,
pad_algo,
&signature)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(signature->size > 6, "Signature is too small");
memcpy((void*)signature->data, "BROKEN", 6);
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3084_CAPI__ec_key_create_verify)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pub_alias, pubkey, pubpolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_signature(
hash_algo,
pad_algo,
&signature)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(signature->size > 6, "Signature is too small");
memcpy((void*)signature->data, "BROKEN", 6);
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3085_CAPI__rsa_cert_create_verify_signature)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert(pub_alias, cert, certpolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
hash_algo,
pad_algo,
&signature)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(signature->size > 6, "Signature is too small");
memcpy((void*)signature->data, "BROKEN", 6);
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3086_CAPI__dsa_ext_key_create_verify_with_negative)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pub_alias, pubkey, pubpolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_signature(
hash_algo,
pad_algo,
&signature)),
- "Error=" << temp);
+ CKMCReadableError(temp));
// positive test
RUNNER_ASSERT_MSG(
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
// negative test
ckmc_raw_buffer_s invalid_msg_buff = prepare_message_buffer("invalid message test");
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_buffer_free(signature);
}
ckmc_key_s *prikey = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(pri_alias, 0, &prikey)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(pub_alias, 0, &pubkey)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_signature(
hash_algo,
pad_algo,
&signature)),
- "Error=" << temp);
+ CKMCReadableError(temp));
// positive test
RUNNER_ASSERT_MSG(
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
// negative test
ckmc_raw_buffer_s invalid_msg_buff = prepare_message_buffer("invalid message test");
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_key_free(prikey);
ckmc_key_free(pubkey);
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert(pub_alias, cert, certpolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_create_signature(
hash_algo,
pad_algo,
&signature)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(signature->size > 6, "Signature is too small");
memcpy((void*)signature->data, "BROKEN", 6);
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3089_CAPI__deinit)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3092_CAPI_TYPE_KEY)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (ret = ckmc_load_cert_from_file(file_name, &pcert)),
- "Error=" << CKM::ErrorToString(ret));
+ CKMCReadableError(ret));
RUNNER_ASSERT_MSG(
pcert != NULL && pcert->cert_size > 0,"Fail to load cert from file.");
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (ret = ckmc_save_cert(lcert_alias, *pcert, policy)),
- "Error=" << CKM::ErrorToString(ret));
+ CKMCReadableError(ret));
remove(file_name);
}
const char *pkey_alias = "pkey_alias";
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pkey_alias, *private_key, policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
const char *cert_alias = "cert_alias";
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert(cert_alias, *cert, policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
std::string caCertAlias = "ca_cert_alias_";
const char *idx = "0";
int cnt = 0;
caCertAlias.append(idx);
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert(caCertAlias.c_str(), *(tmpList->cert), policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
tmpList = tmpList->next;
cnt ++;
}
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_load_from_pkcs12_file2(p12file, password, &ppkcs12)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(ppkcs12->priv_key != NULL, "Null private_key");
RUNNER_ASSERT_MSG(ppkcs12->cert != NULL, "Null cert");
RUNNER_ASSERT_MSG(ppkcs12->ca_chain != NULL, "Null ca_cert_list");
const char *pkey_alias = "pkey_alias2";
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(pkey_alias, *(ppkcs12->priv_key), policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
const char *cert_alias = "cert_alias2";
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert(cert_alias, *(ppkcs12->cert), policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
std::string caCertAlias = "ca_cert_alias_2_";
const char *idx = "0";
int cnt = 0;
caCertAlias.append(idx);
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_cert(caCertAlias.c_str(), *(tmpList->cert), policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
tmpList = tmpList->next;
cnt ++;
}
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST_GROUP_INIT(T310_CKMC_CAPI_PKCS12);
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "user-pass")),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_remove_pkcs12(alias_PKCS_collision);
ckmc_remove_pkcs12(alias_PKCS_exportable);
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_INVALID_FORMAT == (temp = ckmc_load_from_pkcs12_file2("/usr/share/ckm-test/test1801.pkcs12", wrong_passwd, &ppkcs12)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3103_CAPI_PKCS12_add_bundle_with_chain_certs)
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_load_from_pkcs12_file2("/usr/share/ckm-test/pkcs.p12", NULL, &ppkcs12)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(NULL != ppkcs12->cert, "no certificate in PKCS12");
RUNNER_ASSERT_MSG(NULL != ppkcs12->priv_key, "no private key in PKCS12");
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_pkcs12(alias_PKCS_exportable, ppkcs12, exportable, exportable)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_save_pkcs12(alias_PKCS_exportable, ppkcs12, exportable, exportable)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_pkcs12(alias_PKCS_not_exportable, ppkcs12, notExportable, notExportable)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_save_pkcs12(alias_PKCS_not_exportable, ppkcs12, notExportable, notExportable)),
- "Error=" << temp);
+ CKMCReadableError(temp));
// try to lookup key
ckmc_key_s *key_lookup = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(alias_PKCS_exportable, NULL, &key_lookup)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_key_free(key_lookup);
key_lookup = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NOT_EXPORTABLE == (temp = ckmc_get_key(alias_PKCS_not_exportable, "", &key_lookup)),
- "Error=" << temp << " CKMC_ERROR_NOT_EXPORTABLE=" << CKMC_ERROR_NOT_EXPORTABLE << " CKMC_ERROR_DB_ERROR=" << CKMC_ERROR_DB_ERROR);
+ CKMCReadableError(temp));
ckmc_key_free(key_lookup);
// try to lookup certificate
ckmc_cert_s *cert_lookup = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_cert(alias_PKCS_exportable, NULL, &cert_lookup)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_cert_free(cert_lookup);
cert_lookup = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NOT_EXPORTABLE == (temp = ckmc_get_cert(alias_PKCS_not_exportable, NULL, &cert_lookup)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_cert_free(cert_lookup);
}
// fail - no entry
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_UNKNOWN == (temp = ckmc_get_pkcs12("i-do-not-exist", &pkcs)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_pkcs12_free(pkcs);
pkcs = NULL;
// fail - not exportable
RUNNER_ASSERT_MSG(
CKMC_ERROR_NOT_EXPORTABLE == (temp = ckmc_get_pkcs12(alias_PKCS_not_exportable, &pkcs)),
- "Error=" << temp);
+ CKMCReadableError(temp));
ckmc_pkcs12_free(pkcs);
pkcs = NULL;
// success - exportable
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_pkcs12(alias_PKCS_exportable, &pkcs)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(NULL != pkcs->cert, "no certificate in PKCS12");
RUNNER_ASSERT_MSG(NULL != pkcs->priv_key, "no private key in PKCS12");
hash_algo,
pad_algo,
&signature)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
*signature,
hash_algo,
pad_algo)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST(T3105_CAPI_PKCS12_remove_bundle_with_chain_certs)
// remove the whole PKCS12 bundles
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_remove_pkcs12(alias_PKCS_exportable)),
- "Error=" << tmp);
+ CKMCReadableError(tmp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_remove_pkcs12(alias_PKCS_not_exportable)),
- "Error=" << tmp);
+ CKMCReadableError(tmp));
// expect lookup fails due to unknown alias
// try to lookup key
ckmc_key_s *key_lookup = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_UNKNOWN == (tmp = ckmc_get_key(alias_PKCS_exportable, NULL, &key_lookup)),
- "Error=" << tmp);
+ CKMCReadableError(tmp));
ckmc_key_free(key_lookup);
key_lookup = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_UNKNOWN == (tmp = ckmc_get_key(alias_PKCS_not_exportable, NULL, &key_lookup)),
- "Error=" << tmp);
+ CKMCReadableError(tmp));
ckmc_key_free(key_lookup);
// try to lookup certificate
ckmc_cert_s *cert_lookup = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_UNKNOWN == (tmp = ckmc_get_cert(alias_PKCS_exportable, NULL, &cert_lookup)),
- "Error=" << tmp);
+ CKMCReadableError(tmp));
ckmc_cert_free(cert_lookup);
cert_lookup = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_ALIAS_UNKNOWN == (tmp = ckmc_get_cert(alias_PKCS_not_exportable, NULL, &cert_lookup)),
- "Error=" << tmp);
+ CKMCReadableError(tmp));
ckmc_cert_free(cert_lookup);
}
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST_GROUP_INIT(T3110_CAPI_LOCKTYPE_TESTS);
char *null_password = NULL;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,USER_PASS,null_password)),
- CKM::ErrorToString(tmp));
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
- CKM::ErrorToString(tmp));
+ CKMCReadableError(tmp));
+ RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)), CKMCReadableError(tmp));
}
RUNNER_CHILD_TEST(T3112_CAPI_unlock_default_passwd)
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_save_key(alias, test_key, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_get_key(alias, password, &test_key2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_key(alias)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_CHILD_TEST(T3113_CAPI_init_change_user_password)
// database has been automatically unlocked with NULL pw in previous test. Lock it now
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
- CKM::ErrorToString(tmp));
+ CKMCReadableError(tmp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,null_password,USER_PASS)),
- CKM::ErrorToString(tmp));
+ CKMCReadableError(tmp));
// get rid of NULL DKEK
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_unlock_user_key(USER_APP,USER_PASS)),
- CKM::ErrorToString(tmp));
+ CKMCReadableError(tmp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
- CKM::ErrorToString(tmp));
+ CKMCReadableError(tmp));
}
RUNNER_CHILD_TEST(T3114_CAPI_unlock_default_passwd_negative)
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_LOCKED == (temp = ckmc_save_key(alias, test_key, test_policy)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_LOCKED == (temp = ckmc_get_key(alias, password, &test_key2)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_CHILD_TEST(T3119_CAPI_deinit)
int temp;
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_TEST_GROUP_INIT(T320_CAPI_EMPTY_DATABASE);
{
int temp;
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_CHILD_TEST(T3202_CAPI_get_data_from_empty_database)
{
int temp;
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}
RUNNER_CHILD_TEST(T3204_CAPI_get_data_from_locked_database)
RUNNER_ASSERT_MSG(
CKMC_ERROR_DB_LOCKED == (temp = ckmc_get_key(alias, password, &test_key)),
- "Error=" << temp);
+ CKMCReadableError(temp));
RUNNER_ASSERT_MSG(NULL == test_key, "Key value should not be changed");
}
{
int temp;
RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
- "Error=" << temp);
+ CKMCReadableError(temp));
}