// error - fail
RUNNER_ASSERT_MSG(
ec >= 0,
- "Error: alias list failed, ec: " << ec);
+ "Error: alias list failed, ec: " << CKMCErrorToString(ec));
}
return ec;
RUNNER_CHILD_TEST(T3053_CAPI_create_dsa_key)
{
int temp;
+
+ AccessProvider ap("mylabel");
+ ap.allowAPI("key-manager::api-storage", "rw");
+ ap.applyAndSwithToUser(USER_APP, GROUP_APP);
+
size_t size = 1024;
const char *private_key_alias = "DSA-test-2-priv";
const char *public_key_alias = "DSA-test-2-pub";
namespace
{
-const char* alias_PKCS_collision = "CAPI-test-PKCS-collision";
const char* alias_PKCS_exportable = "CAPI-test-PKCS-export";
const char* alias_PKCS_not_exportable = "CAPI-test-PKCS-no-export";
-const char* alias_PKCS_priv_key_copy = "CAPI-test-PKCS-private-key-copy";
-const char* alias_PKCS_priv_key_wrong = "CAPI-test-PKCS-private-key-wrong";
}
RUNNER_TEST(T3101_CAPI_PKCS12_init)
{
int temp;
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
+ CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
CKMCReadableError(temp));
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "user-pass")),
+ CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "PKCS-pass")),
CKMCReadableError(temp));
-
- ckmc_remove_pkcs12(alias_PKCS_collision);
- ckmc_remove_pkcs12(alias_PKCS_exportable);
- ckmc_remove_pkcs12(alias_PKCS_not_exportable);
- ckmc_remove_pkcs12(alias_PKCS_priv_key_copy);
- ckmc_remove_pkcs12(alias_PKCS_priv_key_wrong);
}
RUNNER_TEST(T3102_CAPI_PKCS12_negative_wrong_password)
ckmc_cert_free(cert_lookup);
}
-RUNNER_TEST(T3103_CAPI_PKCS12_get_PKCS)
+RUNNER_TEST(T3104_CAPI_PKCS12_get_PKCS)
{
int temp;
- auto manager = CKM::Manager::create();
-
ckmc_pkcs12_s *pkcs = NULL;
// fail - no entry
ckmc_pkcs12_free(pkcs);
}
-RUNNER_TEST(T3104_CAPI_PKCS12_create_and_verify_signature)
+RUNNER_TEST(T3105_CAPI_PKCS12_create_and_verify_signature)
{
ckmc_raw_buffer_s msg_buff = prepare_message_buffer("message test");
CKMCReadableError(temp));
}
-RUNNER_TEST(T3105_CAPI_PKCS12_remove_bundle_with_chain_certs)
+RUNNER_TEST(T3106_CAPI_PKCS12_remove_bundle_with_chain_certs)
{
int tmp;
RUNNER_TEST(T3109_CAPI_PKCS12_deinit)
{
int temp;
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
+ RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
+ CKMCReadableError(temp));
+ RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
CKMCReadableError(temp));
}
-RUNNER_TEST_GROUP_INIT(T3110_CAPI_LOCKTYPE_TESTS);
-
-RUNNER_CHILD_TEST(T3111_CAPI_init_lock_key)
-{
- int tmp;
- AccessProvider ap("my-label");
- ap.allowAPI("key-manager::api-control", "rw");
- ap.applyAndSwithToUser(USER_APP, GROUP_APP);
-
- char *null_password = NULL;
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,USER_PASS,null_password)),
- 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)
-{
- AccessProvider ap("my-label");
- ap.allowAPI("key-manager::api-storage", "rw");
- ap.applyAndSwithToUser(USER_APP, GROUP_APP);
-
- int temp;
-
- ckmc_key_s test_key, *test_key2;
- ckmc_policy_s test_policy;
-
- char* password = NULL;
- char alias[20] = "mykey_defpasswd";
-
- std::string keyPem = "-----BEGIN PUBLIC KEY-----\n"
- "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2b1bXDa+S8/MGWnMkru4\n"
- "T4tUddtZNi0NVjQn9RFH1NMa220GsRhRO56F77FlSVFKfSfVZKIiWg6C+DVCkcLf\n"
- "zXJ/Z0pvwOQYBAqVMFjV6efQGN0JzJ1Unu7pPRiZl7RKGEI+cyzzrcDyrLLrQ2W7\n"
- "0ZySkNEOv6Frx9JgC5NExuYY4lk2fQQa38JXiZkfyzif2em0px7mXbyf5LjccsKq\n"
- "v1e+XLtMsL0ZefRcqsP++NzQAI8fKX7WBT+qK0HJDLiHrKOTWYzx6CwJ66LD/vvf\n"
- "j55xtsKDLVDbsotvf8/m6VLMab+vqKk11TP4tq6yo0mwyTADvgl1zowQEO9I1W6o\n"
- "zQIDAQAB\n"
- "-----END PUBLIC KEY-----";
-
- char* char_keypem = new char[keyPem.length() + 1];
-
- std::strcpy(char_keypem, keyPem.c_str());
- test_key.raw_key = (unsigned char *)char_keypem;
- test_key.key_size = keyPem.length();
- test_key.key_type = CKMC_KEY_RSA_PUBLIC;
- test_key.password = password;
-
- test_policy.password = password;
- test_policy.extractable = 1;
-
- test_key2 = &test_key;
-
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_save_key(alias, test_key, test_policy)),
- CKMCReadableError(temp));
-
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_get_key(alias, password, &test_key2)),
- CKMCReadableError(temp));
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_remove_key(alias)),
- CKMCReadableError(temp));
-}
-
-RUNNER_CHILD_TEST(T3113_CAPI_init_change_user_password)
-{
- int tmp;
- AccessProvider ap("my-label");
- ap.allowAPI("key-manager::api-control", "rw");
- ap.applyAndSwithToUser(USER_APP, GROUP_APP);
-
- char *null_password = NULL;
-
- // 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)),
- CKMCReadableError(tmp));
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,null_password,USER_PASS)),
- CKMCReadableError(tmp));
- // get rid of NULL DKEK
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (tmp = ckmc_unlock_user_key(USER_APP,USER_PASS)),
- CKMCReadableError(tmp));
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
- CKMCReadableError(tmp));
-}
-
-RUNNER_CHILD_TEST(T3114_CAPI_unlock_default_passwd_negative)
-{
- AccessProvider ap("my-label");
- ap.allowAPI("key-manager::api-storage", "rw");
- ap.applyAndSwithToUser(USER_APP, GROUP_APP);
-
- int temp;
-
- ckmc_key_s test_key, *test_key2;
- ckmc_policy_s test_policy;
-
- char* password = NULL;
- char alias[20] = "mykey_defpasswd";
-
- std::string keyPem = "-----BEGIN PUBLIC KEY-----\n"
- "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2b1bXDa+S8/MGWnMkru4\n"
- "T4tUddtZNi0NVjQn9RFH1NMa220GsRhRO56F77FlSVFKfSfVZKIiWg6C+DVCkcLf\n"
- "zXJ/Z0pvwOQYBAqVMFjV6efQGN0JzJ1Unu7pPRiZl7RKGEI+cyzzrcDyrLLrQ2W7\n"
- "0ZySkNEOv6Frx9JgC5NExuYY4lk2fQQa38JXiZkfyzif2em0px7mXbyf5LjccsKq\n"
- "v1e+XLtMsL0ZefRcqsP++NzQAI8fKX7WBT+qK0HJDLiHrKOTWYzx6CwJ66LD/vvf\n"
- "j55xtsKDLVDbsotvf8/m6VLMab+vqKk11TP4tq6yo0mwyTADvgl1zowQEO9I1W6o\n"
- "zQIDAQAB\n"
- "-----END PUBLIC KEY-----";
-
- char* char_keypem = new char[keyPem.length() + 1];
-
- std::strcpy(char_keypem, keyPem.c_str());
- test_key.raw_key = (unsigned char *)char_keypem;
- test_key.key_size = keyPem.length();
- test_key.key_type = CKMC_KEY_RSA_PUBLIC;
- test_key.password = password;
-
- test_policy.password = password;
- test_policy.extractable = 1;
-
- test_key2 = &test_key;
-
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_DB_LOCKED == (temp = ckmc_save_key(alias, test_key, test_policy)),
- CKMCReadableError(temp));
-
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_DB_LOCKED == (temp = ckmc_get_key(alias, password, &test_key2)),
- CKMCReadableError(temp));
-}
-
-RUNNER_CHILD_TEST(T3119_CAPI_deinit)
-{
- int temp;
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
- CKMCReadableError(temp));
- RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
- CKMCReadableError(temp));
-}
RUNNER_TEST_GROUP_INIT(T320_CAPI_EMPTY_DATABASE);