Projects
Mega:23.09
libtpms
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 3
View file
_service:tar_scm:libtpms.spec
Changed
@@ -2,7 +2,7 @@ %define name libtpms %define version 0.9.5 -%define release 2 +%define release 4 # Valid crypto subsystems are 'freebl' and 'openssl' %if "%{?crypto_subsystem}" == "" @@ -23,6 +23,7 @@ Provides: libtpms-%{crypto_subsystem} = %{version}-%{release} Patch0: 0001-tpm2-Check-size-of-buffer-before-accessing-it-CVE-20.patch +Patch1: 0002-tpm2-add-SM3-and-SM4-support.patch %if "%{crypto_subsystem}" == "openssl" BuildRequires: openssl-devel @@ -77,6 +78,10 @@ %build +%if "%toolchain" == "clang" +export CFLAGS="${CFLAGS} -Wno-self-assign" +%endif + %if "%{crypto_subsystem}" == "openssl" %define _with_openssl --with-openssl %endif @@ -115,6 +120,12 @@ %postun -p /sbin/ldconfig %changelog +* Sat Nov 04 2023 fly2x <fly2x@hitls.org> - 0.9.5-4 +- Add SM3 and SM4 support + +* Tue Oct 10 2023 zhoujing <zhoujing106@huawei.com> - 0.9.5-3 +- Add -Wno-self-assign for building with clang + * Tue Mar 07 2023 jiangfangjie <jiangfangjie@huawei.com> - 0.9.5-2 - fix CVE-2023--1018 and CVE-2023-1017
View file
_service:tar_scm:0002-tpm2-add-SM3-and-SM4-support.patch
Added
@@ -0,0 +1,830 @@ +From 88d5468aaa577566eb5384d4e65f092adaf85afd Mon Sep 17 00:00:00 2001 +From: fly2x <fly2x@hitls.org> +Date: Thu, 2 Nov 2023 08:17:38 +0800 +Subject: PATCH tpm2 add SM3 and SM4 support + +--- + configure.ac | 14 +++ + src/tpm2/AlgorithmTests.c | 1 + + src/tpm2/HashTestData.h | 6 +- + src/tpm2/Marshal.c | 11 +- + src/tpm2/Marshal_fp.h | 4 + + src/tpm2/NVMarshal.c | 156 ++++++++++++++++++++++-- + src/tpm2/StateMarshal.c | 2 - + src/tpm2/SymmetricTest.h | 2 +- + src/tpm2/SymmetricTestData.h | 4 +- + src/tpm2/TpmProfile.h | 1 + + src/tpm2/Unmarshal_fp.h | 4 + + src/tpm2/Volatile.c | 2 - + src/tpm2/crypto/CryptSym.h | 4 + + src/tpm2/crypto/openssl/CryptCmac.c | 11 +- + src/tpm2/crypto/openssl/CryptSym.c | 18 +++ + src/tpm2/crypto/openssl/Helpers.c | 101 ++++++++++++++- + src/tpm2/crypto/openssl/TpmToOsslHash.h | 25 ++-- + src/tpm2/crypto/openssl/TpmToOsslSym.h | 33 ++--- + src/tpm_tpm2_interface.c | 3 + + 19 files changed, 351 insertions(+), 51 deletions(-) + +diff --git a/configure.ac b/configure.ac +index d6a6c5e..f488467 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -106,6 +106,20 @@ AC_ARG_WITH(openssl, + + ) + ++AC_ARG_WITH(openssl-SM, ++ AS_HELP_STRING(--with-openssl-SM, libtpms supports SM3 and SM4, default not support), with_openssl_SM=yes, with_openssl_SM=no ++) ++ ++AS_IF(test "x$with_openssl_SM" != "xno", ++ AC_DEFINE(ALG_SM3_256, 1, 1 denotes to support SM3, and 0 not support) ++ AC_DEFINE(ALG_SM4, 1, 1 denotes to support SM4, and 0 not support) ++) ++ ++AS_IF(test "x$with_openssl_SM" = "xno", ++ AC_DEFINE(ALG_SM3_256, 0, 1 denotes to support SM3, and 0 not support) ++ AC_DEFINE(ALG_SM4, 0, 1 denotes to support SM4, and 0 not support) ++) ++ + case "$cryptolib" in + freebl) + AM_CONDITIONAL(LIBTPMS_USE_FREEBL, true) +diff --git a/src/tpm2/AlgorithmTests.c b/src/tpm2/AlgorithmTests.c +index 08ee6b0..9cb2e29 100644 +--- a/src/tpm2/AlgorithmTests.c ++++ b/src/tpm2/AlgorithmTests.c +@@ -846,6 +846,7 @@ TestAlgorithm( + // if SM4 is implemented, its test is like other block ciphers but there + // aren't any test vectors for it yet + // case TPM_ALG_SM4: ++ case TPM_ALG_SM4: /* libtpms added */ + #endif + #if ALG_CAMELLIA + case TPM_ALG_CAMELLIA: // libtpms activated +diff --git a/src/tpm2/HashTestData.h b/src/tpm2/HashTestData.h +index ea0b0af..fe5d25d 100644 +--- a/src/tpm2/HashTestData.h ++++ b/src/tpm2/HashTestData.h +@@ -130,7 +130,11 @@ TPM2B_SHA512 c_SHA512_digest = {{64, { + TPM2B_TYPE(EMPTY, 1); + + #if ALG_SM3_256 == YES +-TPM2B_EMPTY c_SM3_256_digest = {{0, {0}}}; ++TPM2B_TYPE(SM3_256, 32); ++TPM2B_SM3_256 c_SM3_256_digest = {{32, { ++ 0xbb,0x9e,0x23,0x79,0xfe,0xbb,0xf8,0xb0,0x1d,0x27,0x5f,0x30,0x71,0xbe,0xce,0x8a, ++ 0xb7,0x3f,0xee,0x6b,0xed,0xd7,0xee,0x45,0x4f,0x80,0xca,0x70,0x6c,0x09,0xb6,0x1a ++ }}}; + #endif + + #if ALG_SHA3_256 == YES +diff --git a/src/tpm2/Marshal.c b/src/tpm2/Marshal.c +index fe83b21..706acdc 100644 +--- a/src/tpm2/Marshal.c ++++ b/src/tpm2/Marshal.c +@@ -1178,7 +1178,15 @@ TPMI_AES_KEY_BITS_Marshal(TPMI_AES_KEY_BITS *source, BYTE **buffer, INT32 *size) + written += TPM_KEY_BITS_Marshal(source, buffer, size); + return written; + } +- ++#if ALG_SM4 // libtpms add ++UINT16 ++TPMI_SM4_KEY_BITS_Marshal(TPMI_SM4_KEY_BITS *source, BYTE **buffer, INT32 *size) ++{ ++ UINT16 written = 0; ++ written += TPM_KEY_BITS_Marshal(source, buffer, size); ++ return written; ++} ++#endif + UINT16 // libtpms added begin + TPMI_TDES_KEY_BITS_Marshal(TPMI_TDES_KEY_BITS *source, BYTE **buffer, INT32 *size) + { +@@ -1186,7 +1194,6 @@ TPMI_TDES_KEY_BITS_Marshal(TPMI_TDES_KEY_BITS *source, BYTE **buffer, INT32 *siz + written += TPM_KEY_BITS_Marshal(source, buffer, size); + return written; + } +- + #if ALG_CAMELLIA + UINT16 + TPMI_CAMELLIA_KEY_BITS_Marshal(TPMI_CAMELLIA_KEY_BITS *source, BYTE **buffer, INT32 *size) +diff --git a/src/tpm2/Marshal_fp.h b/src/tpm2/Marshal_fp.h +index d52f497..e7562ef 100644 +--- a/src/tpm2/Marshal_fp.h ++++ b/src/tpm2/Marshal_fp.h +@@ -238,6 +238,10 @@ extern "C" { + TPM2B_ATTEST_Marshal(TPM2B_ATTEST *source, BYTE **buffer, INT32 *size); + UINT16 + TPMI_AES_KEY_BITS_Marshal(TPMI_AES_KEY_BITS *source, BYTE **buffer, INT32 *size); ++#if ALG_SM4 // libtpms added ++ UINT16 ++ TPMI_SM4_KEY_BITS_Marshal(TPMI_SM4_KEY_BITS *source, BYTE **buffer, INT32 *size); ++#endif + UINT16 // libtpms added + TPMI_TDES_KEY_BITS_Marshal(TPMI_TDES_KEY_BITS *source, BYTE **buffer, INT32 *size); + UINT16 +diff --git a/src/tpm2/NVMarshal.c b/src/tpm2/NVMarshal.c +index c7cd1e0..e2f83de 100644 +--- a/src/tpm2/NVMarshal.c ++++ b/src/tpm2/NVMarshal.c +@@ -774,8 +774,8 @@ PCR_SAVE_Marshal(PCR_SAVE *data, BYTE **buffer, INT32 *size) + written += Array_Marshal((BYTE *)&data->Sm3_256, array_size, + buffer, size); + #endif +-#if ALG_SHA3_256 || ALG_SHA3_384 || ALG_SHA3_512 || ALG_SM3_256 +-#error SHA3 and SM3 are not supported ++#if ALG_SHA3_256 || ALG_SHA3_384 || ALG_SHA3_512 ++#error SHA3 is not supported + #endif + + /* end marker */ +@@ -879,8 +879,8 @@ PCR_SAVE_Unmarshal(PCR_SAVE *data, BYTE **buffer, INT32 *size, + t = (BYTE *)&data->Sm3_256; + break; + #endif +-#if ALG_SHA3_256 || ALG_SHA3_384 || ALG_SHA3_512 || ALG_SM3_256 +-#error SHA3 and SM3 are not supported ++#if ALG_SHA3_256 || ALG_SHA3_384 || ALG_SHA3_512 ++#error SHA3 is not supported + #endif + case TPM_ALG_NULL: + /* end marker */ +@@ -990,8 +990,8 @@ PCR_Marshal(PCR *data, BYTE **buffer, INT32 *size) + written += Array_Marshal((BYTE *)&data->Sm3_256Pcr, array_size, + buffer, size); + #endif +-#if ALG_SHA3_256 || ALG_SHA3_384 || ALG_SHA3_512 || ALG_SM3_256 +-#error SHA3 and SM3 are not supported ++#if ALG_SHA3_256 || ALG_SHA3_384 || ALG_SHA3_512 ++#error SHA3 is not supported + #endif + + /* end marker */ +@@ -1061,8 +1061,8 @@ PCR_Unmarshal(PCR *data, BYTE **buffer, INT32 *size, + t = (BYTE *)&data->Sm3_256Pcr; + break; + #endif +-#if ALG_SHA3_256 || ALG_SHA3_384 || ALG_SHA3_512 || ALG_SM3_256 +-#error SHA3 and SM3 are not supported ++#if ALG_SHA3_256 || ALG_SHA3_384 || ALG_SHA3_512 ++#error SHA3 is not supported + #endif + case TPM_ALG_NULL: + /* end marker */ +@@ -2032,6 +2032,134 @@ skip_future_versions: + } + #endif + ++#if ALG_SM3_256 ++ ++#define HASH_STATE_SM3_256_MAGIC 0x10854a09 ++#define HASH_STATE_SM3_256_VERSION 2 ++ ++static UINT16 ++tpmHashStateSM3_256_Marshal(tpmHashStateSM3_256_t *data, BYTE **buffer, INT32 *size, ++ UINT16 hashAlg) ++{ ++ UINT16 written = 0; ++ UINT16 array_size; ++ SM3_CTX *sm3_ctx = NULL; ++ BLOCK_SKIP_INIT; ++ ++ sm3_ctx = EVP_MD_CTX_md_data(*data); ++ written = NV_HEADER_Marshal(buffer, size, ++ HASH_STATE_SM3_256_VERSION, ++ HASH_STATE_SM3_256_MAGIC, 1); ++ written += UINT32_Marshal(&sm3_ctx->A, buffer, size); ++ written += UINT32_Marshal(&sm3_ctx->B, buffer, size); ++ written += UINT32_Marshal(&sm3_ctx->C, buffer, size); ++ written += UINT32_Marshal(&sm3_ctx->D, buffer, size);
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="url">git@gitee.com:src-openeuler/libtpms.git</param> <param name="scm">git</param> - <param name="revision">openEuler-23.09</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2