|
|
971d89 |
From 3247a4f1d1d8a9b8d7f3bc6c1dd85234dd184cbb Mon Sep 17 00:00:00 2001
|
|
|
971d89 |
From: Ingo Franzki <ifranzki@linux.ibm.com>
|
|
|
971d89 |
Date: Wed, 9 Nov 2022 09:45:21 +0100
|
|
|
971d89 |
Subject: [PATCH 32/34] testcase: Enhance p11sak testcase to generate IBM Kyber
|
|
|
971d89 |
keys
|
|
|
971d89 |
|
|
|
971d89 |
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
|
|
|
971d89 |
---
|
|
|
971d89 |
testcases/misc_tests/p11sak_test.sh | 44 +++++++++++++++++++++++++++++++++++++
|
|
|
971d89 |
1 file changed, 44 insertions(+)
|
|
|
971d89 |
|
|
|
971d89 |
diff --git a/testcases/misc_tests/p11sak_test.sh b/testcases/misc_tests/p11sak_test.sh
|
|
|
971d89 |
index a0d3c644..b3374c6a 100755
|
|
|
971d89 |
--- a/testcases/misc_tests/p11sak_test.sh
|
|
|
971d89 |
+++ b/testcases/misc_tests/p11sak_test.sh
|
|
|
971d89 |
@@ -38,6 +38,9 @@ P11SAK_EC_POST=p11sak-ec-post.out
|
|
|
971d89 |
P11SAK_IBM_DIL_PRE=p11sak-ibm-dil-pre.out
|
|
|
971d89 |
P11SAK_IBM_DIL_LONG=p11sak-ibm-dil-long.out
|
|
|
971d89 |
P11SAK_IBM_DIL_POST=p11sak-ibm-dil-post.out
|
|
|
971d89 |
+P11SAK_IBM_KYBER_PRE=p11sak-ibm-kyber-pre.out
|
|
|
971d89 |
+P11SAK_IBM_KYBER_LONG=p11sak-ibm-kyber-long.out
|
|
|
971d89 |
+P11SAK_IBM_KYBER_POST=p11sak-ibm-kyber-post.out
|
|
|
971d89 |
P11SAK_ALL_PINOPT=p11sak-all-pinopt
|
|
|
971d89 |
P11SAK_ALL_PINENV=p11sak-all-pinenv
|
|
|
971d89 |
P11SAK_ALL_PINCON=p11sak-all-pincon
|
|
|
971d89 |
@@ -83,6 +86,12 @@ if [[ -n $( pkcsconf -m -c $SLOT | grep CKM_IBM_DILITHIUM) ]]; then
|
|
|
971d89 |
else
|
|
|
971d89 |
echo "Skip generating ibm-dilithium keys, slot does not support CKM_IBM_DILITHIUM"
|
|
|
971d89 |
fi
|
|
|
971d89 |
+# ibm-kyber
|
|
|
971d89 |
+if [[ -n $( pkcsconf -m -c $SLOT | grep CKM_IBM_KYBER) ]]; then
|
|
|
971d89 |
+ p11sak generate-key ibm-kyber r2_1024 --slot $SLOT --pin $PKCS11_USER_PIN --label p11sak-ibm-kyber
|
|
|
971d89 |
+else
|
|
|
971d89 |
+ echo "Skip generating ibm-kyber keys, slot does not support CKM_IBM_KYBER"
|
|
|
971d89 |
+fi
|
|
|
971d89 |
|
|
|
971d89 |
|
|
|
971d89 |
echo "** Now list keys and redirect output to pre-files - 'p11sak_test.sh'"
|
|
|
971d89 |
@@ -102,6 +111,7 @@ p11sak list-key aes --slot $SLOT --pin $PKCS11_USER_PIN --long &> $P11SAK_AES_LO
|
|
|
971d89 |
p11sak list-key rsa --slot $SLOT --pin $PKCS11_USER_PIN --long &> $P11SAK_RSA_LONG
|
|
|
971d89 |
p11sak list-key ec --slot $SLOT --pin $PKCS11_USER_PIN --long &> $P11SAK_EC_LONG
|
|
|
971d89 |
p11sak list-key ibm-dilithium --slot $SLOT --pin $PKCS11_USER_PIN --long &> $P11SAK_IBM_DIL_LONG
|
|
|
971d89 |
+p11sak list-key ibm-kyber --slot $SLOT --pin $PKCS11_USER_PIN --long &> $P11SAK_IBM_KYBER_LONG
|
|
|
971d89 |
|
|
|
971d89 |
p11sak list-key all --slot $SLOT --pin $PKCS11_USER_PIN &> $P11SAK_ALL_PINOPT
|
|
|
971d89 |
RC_P11SAK_PINOPT=$?
|
|
|
971d89 |
@@ -143,6 +153,9 @@ p11sak remove-key ec --slot $SLOT --pin $PKCS11_USER_PIN --label p11sak-ec-secp5
|
|
|
971d89 |
# remove ibm dilithium keys
|
|
|
971d89 |
p11sak remove-key ibm-dilithium --slot $SLOT --pin $PKCS11_USER_PIN --label p11sak-ibm-dilithium:pub -f
|
|
|
971d89 |
p11sak remove-key ibm-dilithium --slot $SLOT --pin $PKCS11_USER_PIN --label p11sak-ibm-dilithium:prv -f
|
|
|
971d89 |
+# remove ibm kyber keys
|
|
|
971d89 |
+p11sak remove-key ibm-kyber --slot $SLOT --pin $PKCS11_USER_PIN --label p11sak-ibm-kyber:pub -f
|
|
|
971d89 |
+p11sak remove-key ibm-kyber --slot $SLOT --pin $PKCS11_USER_PIN --label p11sak-ibm-kyber:prv -f
|
|
|
971d89 |
|
|
|
971d89 |
|
|
|
971d89 |
echo "** Now list keys and rediirect to post-files - 'p11sak_test.sh'"
|
|
|
971d89 |
@@ -155,6 +168,7 @@ p11sak list-key aes --slot $SLOT --pin $PKCS11_USER_PIN &> $P11SAK_AES_POST
|
|
|
971d89 |
p11sak list-key rsa --slot $SLOT --pin $PKCS11_USER_PIN &> $P11SAK_RSA_POST
|
|
|
971d89 |
p11sak list-key ec --slot $SLOT --pin $PKCS11_USER_PIN &> $P11SAK_EC_POST
|
|
|
971d89 |
p11sak list-key ibm-dilithium --slot $SLOT --pin $PKCS11_USER_PIN &> $P11SAK_IBM_DIL_POST
|
|
|
971d89 |
+p11sak list-key ibm-kyber --slot $SLOT --pin $PKCS11_USER_PIN &> $P11SAK_IBM_KYBER_POST
|
|
|
971d89 |
|
|
|
971d89 |
|
|
|
971d89 |
echo "** Now checking output files to determine PASS/FAIL of tests - 'p11sak_test.sh'"
|
|
|
971d89 |
@@ -670,6 +684,33 @@ else
|
|
|
971d89 |
echo "* TESTCASE list-key ibm-dilithium SKIP Listed random ibm-dilithium public keys CK_BYTE attribute"
|
|
|
971d89 |
fi
|
|
|
971d89 |
|
|
|
971d89 |
+if [[ -n $( pkcsconf -m -c $SLOT | grep CKM_IBM_KYBER) ]]; then
|
|
|
971d89 |
+ # CK_BBOOL
|
|
|
971d89 |
+ if [[ $(grep -A 35 'p11sak-ibm-kyber' $P11SAK_IBM_KYBER_LONG | grep -c 'CK_TRUE') == "12" ]]; then
|
|
|
971d89 |
+ echo "* TESTCASE list-key ibm-kyber PASS Listed random ibm-kyber public keys CK_BBOOL attribute"
|
|
|
971d89 |
+ else
|
|
|
971d89 |
+ echo "* TESTCASE list-key ibm-kyber FAIL Failed to list ibm-kyber public keys CK_BBOOL attribute"
|
|
|
971d89 |
+ status=1
|
|
|
971d89 |
+ fi
|
|
|
971d89 |
+ # CK_ULONG
|
|
|
971d89 |
+ if [[ $(grep -A 35 'p11sak-ibm-kyber' $P11SAK_IBM_KYBER_LONG | grep -c 'CKA_MODULUS_BITS:') == "0" ]]; then
|
|
|
971d89 |
+ echo "* TESTCASE list-key ibm-kyber PASS Listed random ibm-kyber public keys CK_ULONG attribute"
|
|
|
971d89 |
+ else
|
|
|
971d89 |
+ echo "* TESTCASE list-key ibm-kyber FAIL Failed to list ibm-kyber public keys CK_ULONG attribute"
|
|
|
971d89 |
+ status=1
|
|
|
971d89 |
+ fi
|
|
|
971d89 |
+ # CK_BYTE
|
|
|
971d89 |
+ if [[ $(grep -A 35 'p11sak-ibm-kyber' $P11SAK_IBM_KYBER_LONG | grep -c 'CKA_MODULUS:') == "0" ]]; then
|
|
|
971d89 |
+ echo "* TESTCASE list-key ibm-kyber PASS Listed random ibm-kyber public keys CK_BYTE attribute"
|
|
|
971d89 |
+ else
|
|
|
971d89 |
+ echo "* TESTCASE list-key ibm-kyber FAIL Failed to list ibm-kyber public keys CK_BYTE attribute"
|
|
|
971d89 |
+ status=1
|
|
|
971d89 |
+ fi
|
|
|
971d89 |
+else
|
|
|
971d89 |
+ echo "* TESTCASE list-key ibm-kyber SKIP Listed random ibm-kyber public keys CK_BBOOL attribute"
|
|
|
971d89 |
+ echo "* TESTCASE list-key ibm-kyber SKIP Listed random ibm-kyber public keys CK_ULONG attribute"
|
|
|
971d89 |
+ echo "* TESTCASE list-key ibm-kyber SKIP Listed random ibm-kyber public keys CK_BYTE attribute"
|
|
|
971d89 |
+fi
|
|
|
971d89 |
|
|
|
971d89 |
# check token pin handling
|
|
|
971d89 |
if [ $RC_P11SAK_PINOPT = 0 ]; then
|
|
|
971d89 |
@@ -724,6 +765,9 @@ rm -f $P11SAK_EC_POST
|
|
|
971d89 |
rm -f $P11SAK_IBM_DIL_PRE
|
|
|
971d89 |
rm -f $P11SAK_IBM_DIL_LONG
|
|
|
971d89 |
rm -f $P11SAK_IBM_DIL_POST
|
|
|
971d89 |
+rm -f $P11SAK_IBM_KYBER_PRE
|
|
|
971d89 |
+rm -f $P11SAK_IBM_KYBER_LONG
|
|
|
971d89 |
+rm -f $P11SAK_IBM_KYBER_POST
|
|
|
971d89 |
rm -f $P11SAK_ALL_PINOPT
|
|
|
971d89 |
rm -f $P11SAK_ALL_PINENV
|
|
|
971d89 |
rm -f $P11SAK_ALL_PINCON
|
|
|
971d89 |
--
|
|
|
971d89 |
2.16.2.windows.1
|
|
|
971d89 |
|