#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)
ckmc_raw_buffer_s testData1, testData2, testData3;
char* password = NULL;
-
+
std::string binData1 = "My bin data1";
std::string binData2 = "My bin data2";
std::string binData3 = "My bin data3";
testData3.size = binData3.length()+1;
ckmc_policy_s test_policy1, test_policy2, test_policy3;
-
+
test_policy1.password = password;
test_policy1.extractable = 1;
test_policy2.password = password;
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)),
"Error: expecting " << (current_aliases_num+3) << " aliases, while found " << temp);
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( compareResult == 0,
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
-RUNNER_TEST_GROUP_INIT(T307_CKMC_CAPI_QUICK_SET_GET_TESTS);
+RUNNER_TEST_GROUP_INIT(T307_CKMC_CAPI_OCSP_TESTS);
RUNNER_TEST(T3071_CAPI_init)
{
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)
+RUNNER_TEST(T3074_CAPI_ckmc_ocsp_check)
{
std::string ee =
"-----BEGIN CERTIFICATE-----\n"
ckmc_cert_list_s *cert_chain_list;
- int tmp;
-
- tmp = ckmc_get_cert_chain(&c_cert, &untrustedcerts, &cert_chain_list);
+ 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));
- int cnt = 0;
- ckmc_cert_list_s *current;
- ckmc_cert_list_s *next =cert_chain_list;
- do{
- current = next;
- next = current->next;
- cnt ++;
- }while(next != NULL);
- RUNNER_ASSERT_MSG(cnt == 3, "Wrong size of certificate chain.");
+ RUNNER_ASSERT_MSG(cert_chain_list != NULL, "Wrong size of certificate chain.");
- ckmc_cert_list_s *cert_chain_list2 = NULL;
- 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));
-
- RUNNER_ASSERT_MSG(
- cert_chain_list2 == 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)), CKMCReadableError(tmp));
+ RUNNER_ASSERT_MSG(ocsp_status == CKMC_OCSP_STATUS_GOOD, "Wrong status: " << static_cast<int>(ocsp_status));
}
-RUNNER_TEST(T3073_CAPI_get_chain_with_alias)
-{
- std::string ee =
- "-----BEGIN CERTIFICAT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VeyrDHhlyQjyRNddOVG7wl8nuGZMQoIeRuPcZ8XZsg4\n"
- "z+6Ml7YGuXNG5NOUweVgtSV1LdlpMezNlsOjdv3odESsErlNv1HoudRETifLriDR\n"
- "fip8tmNHnna6l9AW5wtsbfdDbzMLKTB3+p359U64drPNGLT5IO892+bKrZvQTtKH\n"
- "qQ2mRHNQ3XBb7a1+Srwi1agm5MKFIA3Z\n"
- "-----END CERTIFICATE-----\n";
-
- ckmc_cert_s c_cert;
- c_cert.raw_cert = reinterpret_cast<unsigned char *>(const_cast<char *>(ee.c_str()));
- c_cert.cert_size = ee.size();
- c_cert.data_format = CKMC_FORM_PEM;
-
- // save untrusted certificate
- ckmc_cert_s c_cert1;
- c_cert1.raw_cert = reinterpret_cast<unsigned char *>(const_cast<char *>(im.c_str()));
- c_cert1.cert_size = im.size();
- c_cert1.data_format = CKMC_FORM_PEM;
- ckmc_policy_s test_policy;
- test_policy.password = NULL;
- test_policy.extractable = 1;
-
- const char *untrusted_alias = "untrusted_certificate";
- int tmp;
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (tmp = ckmc_save_cert(untrusted_alias, c_cert1, test_policy)),
- "Error=" << tmp);
-
- CharPtr top_label = get_label();
- std::string full_address = aliasWithLabel(top_label.get(), untrusted_alias);
-
- // check if exists (access with full path)
- 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);
- ckmc_cert_free(c_cert_tmp);
-
- // get cert chain using alias in full "label alias" form
- ckmc_alias_list_s *untrustedcerts = (ckmc_alias_list_s *)malloc(sizeof(ckmc_alias_list_s));
- untrustedcerts->alias = strdup(full_address.c_str());
- untrustedcerts->next = NULL;
- 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));
- ckmc_alias_list_free(untrustedcerts);
-
-
- int cnt = 0;
- ckmc_cert_list_s *current;
- ckmc_cert_list_s *next = cert_chain_list;
- do{
- current = next;
- next = current->next;
- cnt ++;
- }while(next != NULL);
- RUNNER_ASSERT_MSG(cnt == 3, "Wrong size of certificate chain.");
-
- ckmc_cert_list_s *cert_chain_list2 = NULL;
- 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));
-
- RUNNER_ASSERT_MSG(
- cert_chain_list2 == NULL,
- "Wrong size of certificate chain.");
-}
-
-RUNNER_TEST(T3074_CAPI_deinit)
+RUNNER_TEST(T3075_CAPI_deinit)
{
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_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);
}
RUNNER_TEST(T3096_CAPI_TYPE_load_p12_file) {
- std::string p12Base64 =
- "MIINaQIBAzCCDS8GCSqGSIb3DQEHAaCCDSAEgg0cMIINGDCCChcGCSqGSIb3DQEH\n"
- "BqCCCggwggoEAgEAMIIJ/QYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIvO01\n"
- "D2ODdkYCAggAgIIJ0NscvWq3hmXai5DQcleOgELPbu2c97d+KJnRGCK7K3eRb0/v\n"
- "4F3f3LFSFFT9OAK0/OS1ZYCiO+IuZ6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3V6i\n"
- "5c7RlIJLMtHrvpB5UxRpZgWSdXvCuTCBEzlZAeWJ11I4DAeioqJ1V3h2KcUjNKf1\n"
- "z8mTJrzAycuhm8npaC0Gj6JU7jiYPZLvj+cK/e/gjadWggHFYsjAKhACDbAtG64N\n"
- "Gu9PWJszvhSO8ga7TOVEzdbe2jm4oWtqPe3gb6eYl2Ma6GTfj/PUEDpNAOnr99qV\n"
- "g3uKIXMBp2115bfUf5sbfPdMbnH12XILXR9Va+JjeQHexa64QWlsiRgtXEAXxoEb\n"
- "D2aTlfdsJpgilyj31Y45xOdN7FI+Ltfhudxt1kABPdmKwRMxJTAjBgkqhkiG9w0B\n"
- "CRUxFgQUMvxYuPi3XpEeXbzAkXaNbAw7P5gwMTAhMAkGBSsOAwIaBQAEFOBC4ppE\n"
- "AXO+xdzSBKimvjBBTLbEBAjlaWiC5IVtmAICCAA=\n";
-
- // write file
- const char *p12base64file = "/tmp/ckmc_test_p12.p12.b64";
- const char *p12file = "/tmp/ckmc_test_p12.p12";
+ const char *p12file = "/usr/share/ckm-test/capi-t3096.p12";
const char *password = "password";
- remove(p12base64file);
- remove(p12file);
-
- FILE* b64_file;
- b64_file = fopen(p12base64file, "w");
- fprintf(b64_file, "%s",p12Base64.c_str());
- fclose(b64_file);
-
- std::string cmd("openssl base64 -d -in ");
- cmd.append(p12base64file);
- cmd.append(" -out ");
- cmd.append(p12file);
- system(cmd.c_str());
-
int temp;
ckmc_key_s *private_key = NULL;
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 ++;
}
ckmc_key_free(private_key);
ckmc_cert_free(cert);
ckmc_cert_list_all_free(ca_cert_list);
-
- remove(p12base64file);
- remove(p12file);
}
RUNNER_TEST(T3097_CAPI_TYPE_load_p12_file2) {
- std::string p12Base64 =
- "MIINaQIBAzCCDS8GCSqGSIb3DQEHAaCCDSAEgg0cMIINGDCCChcGCSqGSIb3DQEH\n"
- "BqCCCggwggoEAgEAMIIJ/QYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIvO01\n"
- "D2ODdkYCAggAgIIJ0NscvWq3hmXai5DQcleOgELPbu2c97d+KJnRGCK7K3eRb0/v\n"
- "4F3f3LFSFFT9OAK0/OS1ZYCiO+IuZ6Rpc8Baqe89xVcOHrQ0dQ7sIvbq10dnp5nY\n"
- "fEcrt7qPXcRa3IdOX4PFo4aCOFq5bHv5M3quHldKRh4itosjsAGuF/xtnVnO6lU5\n"
- "UlPhtAdr2Mpr4SHh+oBbJknLvyd6n/4xZ2elEA8ui4Qt5GfiHwWs2J7KO3Z8M1vW\n"
- "yukuyVTaZ6RNkj8dkq/RttvVinlgATYLoosjCsH7VVcd+/z9JqD37QQ89pzdjvJg\n"
- "CtXFVbqsOIbjPMkQMYtMdaPsLDDzw6l+q7BJreGIoJmTHbhTtNOJo03XPEnlVXUq\n"
- "Q+224ibNKzLAvpSWOo8BUHK7ZDc1oaLODDZ+WAA6jfgHkuhhWYr9dxce6UdhMghJ\n"
- "M7ixWwa350psdACREdGxNQzxmucmueprbDumVPAnnJfnKfgRXdKpTDFWS4TaYRc/\n"
- "TE4lKSBZpFFduy/gdpLGCHdklTs33aWZ/mEVZJnk2PggKyvSKH9oL3DxkZIFkGdQ\n"
- "wcy8gAuLBirdWB/q4JWqW7sH8kMfEwXACEm1z4SzCik8afam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VkZ0Zx6r\n"
- "ZMnBPIN4GaHYufCGPyAlPXgEGjlBr3g6Sxr8j50vsWtfspwiILsyte+nQ3kE1nV4\n"
- "TjNBnayXmCMnEkf4kKu+dlLFbd1OY/fQJbiT+f9YtMfcfp2IR+7bXb23UIv8Wt1I\n"
- "XyqsYTcUjIvnByKSDrvVu941x1EN5DF1964qQbAZb/z5ueTl8tCpaCFlGbZcXz7X\n"
- "7L3k0YWdymx1J+szd6heQJrzqMjcHK3XWC7YlDytWB59j0eNMx42XEFP0pAO+gt9\n"
- "Iny2XL+sxJC/xzf6apYMmmGwEXrZkkudsSVMgLCtYyin4zM7PFzLAPK9ryEhsxaP\n"
- "g077MJ/aIaZ7PLi7cABz/g+gQ1dSXakNOof6EjRUADHpav9UKeKwWdR8ycB/8AQV\n"
- "XxQTpEsFJ7izdNZDNC/ZeOhc/ohnei169rfH0shVeeckjf++c8zlh/Y5UWIi3V6i\n"
- "5c7RlIJLMtHrvpB5UxRpZgWSdXvCuTCBEzlZAeWJ11I4DAeioqJ1V3h2KcUjNKf1\n"
- "z8mTJrzAycuhm8npaC0Gj6JU7jiYPZLvj+cK/e/gjadWggHFYsjAKhACDbAtG64N\n"
- "Gu9PWJszvhSO8ga7TOVEzdbe2jm4oWtqPe3gb6eYl2Ma6GTfj/PUEDpNAOnr99qV\n"
- "g3uKIXMBp2115bfUf5sbfPdMbnH12XILXR9Va+JjeQHexa64QWlsiRgtXEAXxoEb\n"
- "D2aTlfdsJpgilyj31Y45xOdN7FI+Ltfhudxt1kABPdmKwRMxJTAjBgkqhkiG9w0B\n"
- "CRUxFgQUMvxYuPi3XpEeXbzAkXaNbAw7P5gwMTAhMAkGBSsOAwIaBQAEFOBC4ppE\n"
- "AXO+xdzSBKimvjBBTLbEBAjlaWiC5IVtmAICCAA=\n";
-
- // write file
- const char *p12base64file = "/tmp/ckmc_test_p12.p12.b64";
- const char *p12file = "/tmp/ckmc_test_p12.p12";
+ const char *p12file = "/usr/share/ckm-test/capi-t3096.p12";
const char *password = "password";
- remove(p12base64file);
- remove(p12file);
-
- FILE* b64_file;
- b64_file = fopen(p12base64file, "w");
- fprintf(b64_file, "%s",p12Base64.c_str());
- fclose(b64_file);
-
- std::string cmd("openssl base64 -d -in ");
- cmd.append(p12base64file);
- cmd.append(" -out ");
- cmd.append(p12file);
- system(cmd.c_str());
-
int temp;
ckmc_pkcs12_s *ppkcs12 = NULL;
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 ++;
}
RUNNER_ASSERT_MSG(cnt == 2, "Invalid CA Cert Count");
ckmc_pkcs12_free(ppkcs12);
-
- remove(p12base64file);
- remove(p12file);
}
RUNNER_TEST(T3098_CAPI_TYPE_deinit)
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));
}