From 2bc59c8d8b68eaf83e329d929d2ad76d6680bc53 Mon Sep 17 00:00:00 2001 From: Joy Latten Date: Fri, 4 Dec 2015 16:24:42 -0500 Subject: [PATCH] Fix copyobjects test for cca and ep11 token by checking CKA_VALUE to be zero Signed-off-by: Joy Latten --- testcases/pkcs11/copyobjects.c | 40 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/testcases/pkcs11/copyobjects.c b/testcases/pkcs11/copyobjects.c index 568b2526..00492c14 100644 --- a/testcases/pkcs11/copyobjects.c +++ b/testcases/pkcs11/copyobjects.c @@ -102,23 +102,29 @@ CK_RV do_CopyObjects(void) } // Step thru template to see if new object matches original... - if ((memcmp - (test_tmpl[0].pValue, aes_tmpl[0].pValue, - aes_tmpl[0].ulValueLen) == 0) - && - (memcmp - (test_tmpl[1].pValue, aes_tmpl[1].pValue, - aes_tmpl[1].ulValueLen) == 0) - && - (memcmp - (test_tmpl[2].pValue, aes_tmpl[2].pValue, - aes_tmpl[2].ulValueLen) == 0) - && - (memcmp - (test_tmpl[3].pValue, aes_tmpl[3].pValue, - aes_tmpl[3].ulValueLen) == 0)) - testcase_pass("Copied object's attributes are the same."); - else + if ((memcmp(test_tmpl[0].pValue, aes_tmpl[0].pValue, + aes_tmpl[0].ulValueLen) == 0) && + (memcmp(test_tmpl[1].pValue, aes_tmpl[1].pValue, + aes_tmpl[1].ulValueLen) == 0) && + (memcmp(test_tmpl[3].pValue, aes_tmpl[3].pValue, + aes_tmpl[3].ulValueLen) == 0)) { + + /* CKA_VALUE is suppose to be zeroed out for + * secure key tokens after importing the key. + */ + if ((is_cca_token(SLOT_ID)) || (is_ep11_token(SLOT_ID))) { + if (*(CK_BYTE *)test_tmpl[2].pValue == 0) + testcase_pass("Copied object's attributes are correct"); + else + testcase_fail("Copied object's attributes are incorrect."); + } else { + if (memcmp(test_tmpl[2].pValue, aes_tmpl[2].pValue, + aes_tmpl[2].ulValueLen) == 0) + testcase_pass("Copied object's attributes are the same."); + else + testcase_fail("Copied object's attributes are different."); + } + } else testcase_fail("Copied object's attributes are different.");