SHA256
1
0
forked from pool/openCryptoki
openCryptoki/ocki-3.19.0-0035-Fix-compile-error-error-initializer-element-is-not-c.patch

175 lines
7.4 KiB
Diff
Raw Normal View History

Accepting request 1063652 from home:ngueorguiev:branches:security - Added patch for compile errors * ocki-3.19.0-0035-Fix-compile-error-error-initializer-element-is-not-c.patch - Changed spec file to use %autosetup instead of %setup. - Updated the package openCryptoki 3.19.0 (jsc#PED-616, bsc#1207760), added the following patches: * ocki-3.19.0-0001-EP11-Unify-key-pair-generation-functions.patch * ocki-3.19.0-0002-EP11-Do-not-report-DSA-DH-parameter-generation-as-be.patch * ocki-3.19.0-0003-EP11-Do-not-pass-empty-CKA_PUBLIC_KEY_INFO-to-EP11-h.patch * ocki-3.19.0-0004-Mechtable-CKM_IBM_DILITHIUM-can-also-be-used-for-key.patch * ocki-3.19.0-0005-EP11-Remove-DSA-DH-parameter-generation-mechanisms-f.patch * ocki-3.19.0-0006-EP11-Pass-back-chain-code-for-CKM_IBM_BTC_DERIVE.patch * ocki-3.19.0-0007-EP11-Supply-CKA_PUBLIC_KEY_INFO-with-CKM_IBM_BTC_DER.patch * ocki-3.19.0-0008-EP11-Supply-CKA_PUBLIC_KEY_INFO-when-importing-priva.patch * ocki-3.19.0-0009-EP11-Fix-memory-leak-introduced-with-recent-commit.patch * ocki-3.19.0-0010-p11sak-Fix-segfault-when-dilithium-version-is-not-sp.patch * ocki-3.19.0-0011-EP11-remove-dead-code-and-unused-variables.patch * ocki-3.19.0-0012-EP11-Update-EP11-host-library-header-files.patch * ocki-3.19.0-0013-EP11-Support-EP11-host-library-version-4.patch * ocki-3.19.0-0014-EP11-Add-new-control-points.patch * ocki-3.19.0-0015-EP11-Default-unknown-CPs-to-ON.patch * ocki-3.19.0-0016-COMMON-Add-defines-for-Dilithium-round-2-and-3-varia.patch * ocki-3.19.0-0017-COMMON-Add-defines-for-Kyber.patch * ocki-3.19.0-0018-COMMON-Add-post-quantum-algorithm-OIDs.patch * ocki-3.19.0-0019-COMMON-Dilithium-key-BER-encoding-decoding-allow-dif.patch * ocki-3.19.0-0020-COMMON-EP11-Add-CKA_VALUE-holding-SPKI-PKCS-8-of-key.patch * ocki-3.19.0-0021-COMMON-EP11-Allow-to-select-Dilithium-variant-via-mo.patch * ocki-3.19.0-0022-EP11-Query-supported-PQC-variants-and-restrict-usage.patch * ocki-3.19.0-0023-POLICY-Dilithium-strength-and-signature-size-depends.patch * ocki-3.19.0-0024-TESTCASES-Test-Dilithium-variants.patch * ocki-3.19.0-0025-COMMON-EP11-Add-Kyber-key-type-and-mechanism.patch * ocki-3.19.0-0026-EP11-Add-support-for-generating-and-importing-Kyber-.patch * ocki-3.19.0-0027-EP11-Add-support-for-encrypt-decrypt-and-KEM-operati.patch * ocki-3.19.0-0028-POLICY-STATISTICS-Check-for-Kyber-KEM-KDFs-and-count.patch * ocki-3.19.0-0029-TESTCASES-Add-tests-for-CKM_IBM_KYBER.patch * ocki-3.19.0-0030-p11sak-Support-additional-Dilithium-variants.patch * ocki-3.19.0-0031-p11sak-Add-support-for-IBM-Kyber-key-type.patch * ocki-3.19.0-0032-testcase-Enhance-p11sak-testcase-to-generate-IBM-Kyb.patch * ocki-3.19.0-0033-EP11-Supply-CKA_PUBLIC_KEY_INFO-with-CKM_IBM_BTC_DER.patch * ocki-3.19.0-0034-EP11-Fix-setting-unknown-CPs-to-ON.patch OBS-URL: https://build.opensuse.org/request/show/1063652 OBS-URL: https://build.opensuse.org/package/show/security/openCryptoki?expand=0&rev=128
2023-02-07 16:45:43 +01:00
From cb93a1faddd35af3ddb2936e9e7a584b442bff99 Mon Sep 17 00:00:00 2001
From: Ingo Franzki <ifranzki@linux.ibm.com>
Date: Tue, 7 Feb 2023 08:33:01 +0100
Subject: [PATCH] Fix compile error "error: initializer element is not
constant"
Some compiler versions report error "error: initializer element is not
constant" for the PQC initializers.
Use sizeof() directly in the initializer, instead of declaring a global
variable holding the size. Such a global variable is not always considered
as a constant, although it is declared as const.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
---
testcases/crypto/dilithium_func.c | 15 +++++----------
testcases/crypto/kyber_func.c | 6 ++----
usr/lib/common/pqc_defs.h | 7 -------
usr/lib/common/pqc_supported.c | 21 +++++++--------------
4 files changed, 14 insertions(+), 35 deletions(-)
diff --git a/testcases/crypto/dilithium_func.c b/testcases/crypto/dilithium_func.c
index 338efc85..a8a7dd26 100644
--- a/testcases/crypto/dilithium_func.c
+++ b/testcases/crypto/dilithium_func.c
@@ -44,15 +44,10 @@ const _signVerifyParam signVerifyInput[] = {
};
const CK_BYTE dilithium_r2_65[] = OCK_DILITHIUM_R2_65;
-const CK_ULONG dilithium_r2_65_len = sizeof(dilithium_r2_65);
const CK_BYTE dilithium_r2_87[] = OCK_DILITHIUM_R2_87;
-const CK_ULONG dilithium_r2_87_len = sizeof(dilithium_r2_87);
const CK_BYTE dilithium_r3_44[] = OCK_DILITHIUM_R3_44;
-const CK_ULONG dilithium_r3_44_len = sizeof(dilithium_r3_44);
const CK_BYTE dilithium_r3_65[] = OCK_DILITHIUM_R3_65;
-const CK_ULONG dilithium_r3_65_len = sizeof(dilithium_r3_65);
const CK_BYTE dilithium_r3_87[] = OCK_DILITHIUM_R3_87;
-const CK_ULONG dilithium_r3_87_len = sizeof(dilithium_r3_87);
typedef struct variant_info {
const char *name;
@@ -64,15 +59,15 @@ typedef struct variant_info {
const _variant_info variants[] = {
{ "DEFAULT (DILITHIUM_R2_65)", 0, NULL, 0 },
{ "DILITHIUM_R2_65", CK_IBM_DILITHIUM_KEYFORM_ROUND2_65,
- dilithium_r2_65, dilithium_r2_65_len },
+ dilithium_r2_65, sizeof(dilithium_r2_65) },
{ "DILITHIUM_R2_87", CK_IBM_DILITHIUM_KEYFORM_ROUND2_87,
- dilithium_r2_87, dilithium_r2_87_len },
+ dilithium_r2_87, sizeof(dilithium_r2_87) },
{ "DILITHIUM_R3_44", CK_IBM_DILITHIUM_KEYFORM_ROUND3_44,
- dilithium_r3_44, dilithium_r3_44_len },
+ dilithium_r3_44, sizeof(dilithium_r3_44) },
{ "DILITHIUM_R3_65", CK_IBM_DILITHIUM_KEYFORM_ROUND3_65,
- dilithium_r3_65, dilithium_r3_65_len },
+ dilithium_r3_65, sizeof(dilithium_r3_65) },
{ "DILITHIUM_R3_87", CK_IBM_DILITHIUM_KEYFORM_ROUND3_87,
- dilithium_r3_87, dilithium_r3_87_len },
+ dilithium_r3_87, sizeof(dilithium_r3_87) },
};
const CK_ULONG num_variants = sizeof(variants) / sizeof(_variant_info);
diff --git a/testcases/crypto/kyber_func.c b/testcases/crypto/kyber_func.c
index 2e6177b3..22170f71 100644
--- a/testcases/crypto/kyber_func.c
+++ b/testcases/crypto/kyber_func.c
@@ -30,9 +30,7 @@
*/
const CK_BYTE kyber_r2_768[] = OCK_KYBER_R2_768;
-const CK_ULONG kyber_r2_768_len = sizeof(kyber_r2_768);
const CK_BYTE kyber_r2_1024[] = OCK_KYBER_R2_1024;
-const CK_ULONG kyber_r2_1024_len = sizeof(kyber_r2_1024);
const CK_BYTE prime256v1[] = OCK_PRIME256V1;
@@ -46,9 +44,9 @@ typedef struct variant_info {
const _variant_info variants[] = {
{ "DEFAULT (KYBER_R2_1024)", 0, NULL, 0 },
{ "KYBER_R2_768", CK_IBM_KYBER_KEYFORM_ROUND2_768,
- kyber_r2_768, kyber_r2_768_len },
+ kyber_r2_768, sizeof(kyber_r2_768) },
{ "KYBER_R2_1024", CK_IBM_KYBER_KEYFORM_ROUND2_1024,
- kyber_r2_1024, kyber_r2_1024_len },
+ kyber_r2_1024, sizeof(kyber_r2_1024) },
};
const CK_ULONG num_variants = sizeof(variants) / sizeof(_variant_info);
diff --git a/usr/lib/common/pqc_defs.h b/usr/lib/common/pqc_defs.h
index 947f86a7..2c9d6859 100644
--- a/usr/lib/common/pqc_defs.h
+++ b/usr/lib/common/pqc_defs.h
@@ -16,20 +16,13 @@
#include "pqc_oids.h"
extern const CK_BYTE dilithium_r2_65[];
-extern const CK_ULONG dilithium_r2_65_len;
extern const CK_BYTE dilithium_r2_87[];
-extern const CK_ULONG dilithium_r2_87_len;
extern const CK_BYTE dilithium_r3_44[];
-extern const CK_ULONG dilithium_r3_44_len;
extern const CK_BYTE dilithium_r3_56[];
-extern const CK_ULONG dilithium_r3_56_len;
extern const CK_BYTE dilithium_r3_87[];
-extern const CK_ULONG dilithium_r3_87_len;
extern const CK_BYTE kyber_r2_768[];
-extern const CK_ULONG kyber_r2_768_len;
extern const CK_BYTE kyber_r2_1024[];
-extern const CK_ULONG kyber_r2_1024_len;
struct pqc_oid {
const CK_BYTE *oid;
diff --git a/usr/lib/common/pqc_supported.c b/usr/lib/common/pqc_supported.c
index 77970352..5b8b0d42 100644
--- a/usr/lib/common/pqc_supported.c
+++ b/usr/lib/common/pqc_supported.c
@@ -13,30 +13,25 @@
#include "pqc_defs.h"
const CK_BYTE dilithium_r2_65[] = OCK_DILITHIUM_R2_65;
-const CK_ULONG dilithium_r2_65_len = sizeof(dilithium_r2_65);
const CK_BYTE dilithium_r2_87[] = OCK_DILITHIUM_R2_87;
-const CK_ULONG dilithium_r2_87_len = sizeof(dilithium_r2_87);
const CK_BYTE dilithium_r3_44[] = OCK_DILITHIUM_R3_44;
-const CK_ULONG dilithium_r3_44_len = sizeof(dilithium_r3_44);
const CK_BYTE dilithium_r3_65[] = OCK_DILITHIUM_R3_65;
-const CK_ULONG dilithium_r3_65_len = sizeof(dilithium_r3_65);
const CK_BYTE dilithium_r3_87[] = OCK_DILITHIUM_R3_87;
-const CK_ULONG dilithium_r3_87_len = sizeof(dilithium_r3_87);
const struct pqc_oid dilithium_oids[] = {
- { .oid = dilithium_r2_65, .oid_len = dilithium_r2_65_len,
+ { .oid = dilithium_r2_65, .oid_len = sizeof(dilithium_r2_65),
.keyform = CK_IBM_DILITHIUM_KEYFORM_ROUND2_65,
.policy_size = 256, .policy_siglen = 3366 },
- { .oid = dilithium_r2_87, .oid_len = dilithium_r2_87_len,
+ { .oid = dilithium_r2_87, .oid_len = sizeof(dilithium_r2_87),
.keyform = CK_IBM_DILITHIUM_KEYFORM_ROUND2_87,
.policy_size = 256, .policy_siglen = 4668 },
- { .oid = dilithium_r3_44, .oid_len = dilithium_r3_44_len,
+ { .oid = dilithium_r3_44, .oid_len = sizeof(dilithium_r3_44),
.keyform = CK_IBM_DILITHIUM_KEYFORM_ROUND3_44,
.policy_size = 256, .policy_siglen = 2420 },
- { .oid = dilithium_r3_65, .oid_len = dilithium_r3_65_len,
+ { .oid = dilithium_r3_65, .oid_len = sizeof(dilithium_r3_65),
.keyform = CK_IBM_DILITHIUM_KEYFORM_ROUND3_65,
.policy_size = 256, .policy_siglen = 3293 },
- { .oid = dilithium_r3_87, .oid_len = dilithium_r3_87_len,
+ { .oid = dilithium_r3_87, .oid_len = sizeof(dilithium_r3_87),
.keyform = CK_IBM_DILITHIUM_KEYFORM_ROUND3_87,
.policy_size = 256, .policy_siglen = 4595 },
{ .oid = NULL, .oid_len = 0, .keyform = 0,
@@ -44,15 +39,13 @@ const struct pqc_oid dilithium_oids[] = {
};
const CK_BYTE kyber_r2_768[] = OCK_KYBER_R2_768;
-const CK_ULONG kyber_r2_768_len = sizeof(kyber_r2_768);
const CK_BYTE kyber_r2_1024[] = OCK_KYBER_R2_1024;
-const CK_ULONG kyber_r2_1024_len = sizeof(kyber_r2_1024);
const struct pqc_oid kyber_oids[] = {
- { .oid = kyber_r2_768, .oid_len = kyber_r2_768_len,
+ { .oid = kyber_r2_768, .oid_len = sizeof(kyber_r2_768),
.keyform = CK_IBM_KYBER_KEYFORM_ROUND2_768,
.policy_size = 256, .policy_siglen = 0 },
- { .oid = kyber_r2_1024, .oid_len = kyber_r2_1024_len,
+ { .oid = kyber_r2_1024, .oid_len = sizeof(kyber_r2_1024),
.keyform = CK_IBM_KYBER_KEYFORM_ROUND2_1024,
.policy_size = 256, .policy_siglen = 0 },
{ .oid = NULL, .oid_len = 0, .keyform = 0,
--
2.16.2.windows.1