xtest: pkcs11: Verify that bad arguments is reported for cipher finals
Verify that CKR_BAD_ARGUMENT is reported properly for:
- C_EncryptFinal with invalid arguments
- C_DecryptFinal with invalid arguments
Test here is expected to fail always with same error so check for that and
then clear the error code so that only expected return value is checked.
Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
diff --git a/host/xtest/pkcs11_1000.c b/host/xtest/pkcs11_1000.c
index 66a9ee3..b4ed6f4 100644
--- a/host/xtest/pkcs11_1000.c
+++ b/host/xtest/pkcs11_1000.c
@@ -1265,9 +1265,16 @@
if (mode == TEE_MODE_DECRYPT)
rv = C_DecryptFinal(session, NULL, NULL);
- /* Only check that the operation is no more active */
- if (!ADBG_EXPECT_TRUE(c, rv != CKR_BUFFER_TOO_SMALL))
+ /*
+ * Check that return value is expected so that operation is
+ * released
+ */
+ if (!ADBG_EXPECT_CK_RESULT(c, CKR_ARGUMENTS_BAD, rv)) {
rv = CKR_GENERAL_ERROR;
+ goto out;
+ }
+
+ rv = CKR_OK;
}
out: