[ITC][key-manager][Non-ACR] Fix pkcs test 84/291584/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 4 Apr 2023 07:51:40 +0000 (09:51 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 18 Apr 2023 19:52:43 +0000 (21:52 +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: I8963a73c0e7cf3547dc5dba1db55960edd9f3d3b

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

index 9f724daf838a6f6a01a03cde1edb473c678025f9..7d1fded5260f91ebf5f6e0b2d25ed4b0f1dfac3a 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 = (char*)cert_password;
        cert_policy.extractable = true;
 
-       policy.password = NULL;
+       policy.password = (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);