Blame SOURCES/0016-COMMON-Add-defines-for-Dilithium-round-2-and-3-varia.patch

447573
From 95f64e0c9f30ea8e0712e554418230659dabe1ec Mon Sep 17 00:00:00 2001
447573
From: Ingo Franzki <ifranzki@linux.ibm.com>
447573
Date: Wed, 16 Feb 2022 13:44:10 +0100
447573
Subject: [PATCH 16/34] COMMON: Add defines for Dilithium round 2 and 3
447573
 variants
447573
447573
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
447573
---
447573
 usr/include/pkcs11types.h | 12 ++++++++++--
447573
 usr/lib/common/p11util.c  |  6 ++++++
447573
 2 files changed, 16 insertions(+), 2 deletions(-)
447573
447573
diff --git a/usr/include/pkcs11types.h b/usr/include/pkcs11types.h
447573
index bc53e672..6bf9c1fa 100644
447573
--- a/usr/include/pkcs11types.h
447573
+++ b/usr/include/pkcs11types.h
447573
@@ -437,6 +437,7 @@ typedef CK_ULONG CK_KEY_TYPE;
447573
 #ifndef OCK_NO_EP11_DEFINES
447573
 #define CKK_IBM_PQC_DILITHIUM    CKK_VENDOR_DEFINED + 0x10023
447573
 #endif
447573
+#define CKK_IBM_DILITHIUM        CKK_IBM_PQC_DILITHIUM
447573
 
447573
 /* CK_CERTIFICATE_TYPE is a value that identifies a certificate
447573
  * type */
447573
@@ -594,8 +595,15 @@ typedef CK_ULONG CK_ATTRIBUTE_TYPE;
447573
 #define CKA_IBM_PROTKEY_NEVER_EXTRACTABLE  (CKA_VENDOR_DEFINED +0x1000d)
447573
 #define CKA_IBM_OPAQUE_PKEY       (CKA_VENDOR_DEFINED + 0xd0100)
447573
 
447573
-/* For Dilithium, oid = 1.3.6.1.4.1.2.267.1.6.5 */
447573
-#define IBM_DILITHIUM_KEYFORM_ROUND2        1
447573
+#define CK_IBM_DILITHIUM_KEYFORM_ROUND2_65              1
447573
+#define CK_IBM_DILITHIUM_KEYFORM_ROUND2_87              2
447573
+#define CK_IBM_DILITHIUM_KEYFORM_ROUND3_44              3
447573
+#define CK_IBM_DILITHIUM_KEYFORM_ROUND3_65              4
447573
+#define CK_IBM_DILITHIUM_KEYFORM_ROUND3_87              5
447573
+
447573
+#define IBM_DILITHIUM_KEYFORM_ROUND2    CK_IBM_DILITHIUM_KEYFORM_ROUND2_65
447573
+
447573
+#define CKA_IBM_DILITHIUM_MODE    (CKA_VENDOR_DEFINED + 0x00010)
447573
 
447573
 #define CKA_IBM_DILITHIUM_KEYFORM (CKA_VENDOR_DEFINED + 0xd0001)
447573
 #define CKA_IBM_DILITHIUM_RHO     (CKA_VENDOR_DEFINED + 0xd0002)
447573
diff --git a/usr/lib/common/p11util.c b/usr/lib/common/p11util.c
447573
index 4ef33306..f3a031e3 100644
447573
--- a/usr/lib/common/p11util.c
447573
+++ b/usr/lib/common/p11util.c
447573
@@ -123,6 +123,10 @@ const char *p11_get_ckr(CK_RV rc)
447573
     }
447573
 }
447573
 
447573
+#ifndef CKA_IBM_PQC_PARAMS
447573
+#define CKA_IBM_PQC_PARAMS (CKA_VENDOR_DEFINED +0x1000e)
447573
+#endif
447573
+
447573
 //
447573
 // p11_get_cka - return textual interpretation of an attribute type
447573
 // only simple types - no arrays. For unknown a ptr to a static
447573
@@ -221,6 +225,7 @@ const char *p11_get_cka(CK_ATTRIBUTE_TYPE atype)
447573
         _sym2str(CKA_IBM_PROTKEY_NEVER_EXTRACTABLE);
447573
         _sym2str(CKA_IBM_OPAQUE_PKEY);
447573
         _sym2str(CKA_IBM_DILITHIUM_KEYFORM);
447573
+        _sym2str(CKA_IBM_DILITHIUM_MODE);
447573
         _sym2str(CKA_IBM_DILITHIUM_RHO);
447573
         _sym2str(CKA_IBM_DILITHIUM_SEED);
447573
         _sym2str(CKA_IBM_DILITHIUM_TR);
447573
@@ -228,6 +233,7 @@ const char *p11_get_cka(CK_ATTRIBUTE_TYPE atype)
447573
         _sym2str(CKA_IBM_DILITHIUM_S2);
447573
         _sym2str(CKA_IBM_DILITHIUM_T0);
447573
         _sym2str(CKA_IBM_DILITHIUM_T1);
447573
+        _sym2str(CKA_IBM_PQC_PARAMS);
447573
     default:
447573
         sprintf(buf, "unknown attribute type 0x%08lx", atype);
447573
         return buf;
447573
-- 
447573
2.16.2.windows.1
447573