[ITC][key-manager][Non-ACR] Fix pkcs test 26/293826/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, 6 Jun 2023 07:16:11 +0000 (09:16 +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 c495f37a7f09257c4952b91d504d1fb428af65bc..f51a6354cf2fbb375db1e291167b574989b068db 100755 (executable)
@@ -1041,10 +1041,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) )
@@ -1056,7 +1056,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);