[ITC][key-manager][Non-ACR] Fix pkcs test 53/290853/2
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 4 Apr 2023 07:51:40 +0000 (09:51 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 4 Apr 2023 08:02:25 +0000 (10:02 +0200)
The test uses empty passwords when saving pkcs but it passes non-empty
passwords when getting the pkcs back. The test was passing before
because key-manager silently ignored such cases. Now it returns an
error.

Also the polices were passed in incorrect order.

Fix the test by using passwords both when saving and getting the pkcs
and fixing the policy order.

Change-Id: Ie32cd0102b0be9793d9f749535aadd40937dc8c0

src/itc/key-manager/ITs-key-manager.c

index 9f724daf838a6f6a01a03cde1edb473c678025f9..8187d6ed4e8ff2cd0e666274bb259d89f9e059d9 100755 (executable)
@@ -997,10 +997,10 @@ int ITc_ckmc_get_save_pkcs12_p(void)
        ckmc_policy_s cert_policy;
        ckmc_policy_s policy;
 
-       cert_policy.password = NULL;
+       cert_policy.password = const_cast<char*>(cert_password);
        cert_policy.extractable = true;
 
-       policy.password = NULL;
+       policy.password = const_cast<char*>(key_password);
        policy.extractable = true;
 
        if ( false == KeyManagerAppendToAppDataPath(PATHPFX, pszFilePath) )
@@ -1012,7 +1012,7 @@ int ITc_ckmc_get_save_pkcs12_p(void)
        int nRet = ckmc_pkcs12_load(pszFilePath, PASSPHRASEPFX, &pkcs12); //Target API
        PRINT_RESULT_CLEANUP(CKMC_ERROR_NONE, nRet, "ckmc_pkcs12_load", KeyMngrGetError(nRet), RemoveAlias(pszAlias));
 
-       nRet = ckmc_save_pkcs12(pszAlias, pkcs12, cert_policy, policy);
+       nRet = ckmc_save_pkcs12(pszAlias, pkcs12, policy, cert_policy);
        PRINT_RESULT_CLEANUP(CKMC_ERROR_NONE, nRet, "ckmc_save_pkcs12", KeyMngrGetError(nRet), RemoveAlias(pszAlias));
 
        nRet = ckmc_get_pkcs12(pszAlias, key_password, cert_password, &pkcs12);