diff --git a/add-GCRY_MD_SM3_PGP-set-to-109.patch b/add-GCRY_MD_SM3_PGP-set-to-109.patch new file mode 100644 index 0000000000000000000000000000000000000000..8f59d970ecccb66b1dfbc4ebfb7a404263367447 --- /dev/null +++ b/add-GCRY_MD_SM3_PGP-set-to-109.patch @@ -0,0 +1,168 @@ +From 4c1e5cb38485986014c57b77de20c390714c5f1d Mon Sep 17 00:00:00 2001 +From: zhengxiaoxiao +Date: Thu, 10 Oct 2024 07:54:19 +0800 +Subject: [PATCH] add GCRY_MD_SM3_PGP set to 109 + +Co-authored-by: Huaxin Lu +Signed-off-by: zhengxiaoxiao +--- + cipher/md.c | 25 +++++++++++++++++++++++++ + cipher/sm3.c | 15 +++++++++++++++ + config.h.in | 3 +++ + configure.ac | 7 ++++++- + src/cipher.h | 3 +++ + src/gcrypt.h.in | 5 +++++ + 6 files changed, 57 insertions(+), 1 deletion(-) + +diff --git a/cipher/md.c b/cipher/md.c +index 34336b5..c9aeb3c 100644 +--- a/cipher/md.c ++++ b/cipher/md.c +@@ -99,6 +99,9 @@ static const gcry_md_spec_t * const digest_list[] = + #endif + #if USE_SM3 + &_gcry_digest_spec_sm3, ++#endif ++#if USE_SM3_PGP ++ &_gcry_digest_spec_sm3_pgp, + #endif + NULL + }; +@@ -153,6 +156,24 @@ static const gcry_md_spec_t * const digest_list_algo0[] = + #endif + }; + ++#if USE_SM3_PGP ++/* Digest implementations starting with index 100 (enum gcry_md_algos) */ ++static const gcry_md_spec_t * const digest_list_algo100[] = ++ { ++ NULL, /* Private or Experimental Use 100 */ ++ NULL, /* Private or Experimental Use 101 */ ++ NULL, /* Private or Experimental Use 102 */ ++ NULL, /* Private or Experimental Use 103 */ ++ NULL, /* Private or Experimental Use 104 */ ++ NULL, /* Private or Experimental Use 105 */ ++ NULL, /* Private or Experimental Use 106 */ ++ NULL, /* Private or Experimental Use 107 */ ++ NULL, /* Private or Experimental Use 108 */ ++ &_gcry_digest_spec_sm3_pgp, ++ NULL /* Private or Experimental Use 110 */ ++ }; ++#endif ++ + /* Digest implementations starting with index 301 (enum gcry_md_algos) */ + static const gcry_md_spec_t * const digest_list_algo301[] = + { +@@ -307,6 +328,10 @@ spec_from_algo (int algo) + spec = digest_list_algo0[algo]; + else if (algo >= 301 && algo < 301 + DIM(digest_list_algo301)) + spec = digest_list_algo301[algo - 301]; ++#if USE_SM3_PGP ++ else if (algo >= 100 && algo < 100 + DIM(digest_list_algo100)) ++ spec = digest_list_algo100[algo - 100]; ++#endif + + if (spec) + gcry_assert (spec->algo == algo); +diff --git a/cipher/sm3.c b/cipher/sm3.c +index 0ab5f50..d109c7d 100644 +--- a/cipher/sm3.c ++++ b/cipher/sm3.c +@@ -503,6 +503,9 @@ run_selftests (int algo, int extended, selftest_report_func_t report) + switch (algo) + { + case GCRY_MD_SM3: ++#if USE_SM3_PGP ++ case GCRY_MD_SM3_PGP: ++#endif + ec = selftests_sm3 (extended, report); + break; + default: +@@ -535,3 +538,15 @@ const gcry_md_spec_t _gcry_digest_spec_sm3 = + sizeof (SM3_CONTEXT), + run_selftests + }; ++ ++#if USE_SM3_PGP ++const gcry_md_spec_t _gcry_digest_spec_sm3_pgp = ++ { ++ GCRY_MD_SM3_PGP, {0, 0}, ++ "SM3", asn_sm3, DIM (asn_sm3), oid_spec_sm3, 32, ++ sm3_init, _gcry_md_block_write, sm3_final, sm3_read, NULL, ++ _gcry_sm3_hash_buffers, ++ sizeof (SM3_CONTEXT), ++ run_selftests ++ }; ++#endif +diff --git a/config.h.in b/config.h.in +index cfd150f..6aa5992 100644 +--- a/config.h.in ++++ b/config.h.in +@@ -632,6 +632,9 @@ + /* Defined if this module should be included */ + #undef USE_SM3 + ++/* Defined if this module should be included */ ++#undef USE_SM3_PGP ++ + /* Defined if this module should be included */ + #undef USE_SM4 + +diff --git a/configure.ac b/configure.ac +index 24ec2eb..81892ae 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -221,7 +221,7 @@ enabled_pubkey_ciphers="" + # Definitions for message digests. + available_digests="crc gostr3411-94 md2 md4 md5 rmd160 sha1 sha256 sha512" + available_digests="$available_digests sha3 tiger whirlpool stribog blake2" +-available_digests="$available_digests sm3" ++available_digests="$available_digests sm3 sm3_pgp" + enabled_digests="" + + # Definitions for kdfs (optional ones) +@@ -3064,6 +3064,11 @@ if test "$found" = "1" ; then + esac + fi + ++LIST_MEMBER(sm3_pgp, $enabled_digests) ++if test "$found" = "1" ; then ++ AC_DEFINE(USE_SM3_PGP, 1, [Defined if this module should be included]) ++fi ++ + # SHA-1 needs to be included always for example because it is used by + # random-csprng.c. + GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1.lo" +diff --git a/src/cipher.h b/src/cipher.h +index 87f8c4d..03ce82f 100644 +--- a/src/cipher.h ++++ b/src/cipher.h +@@ -208,6 +208,9 @@ extern const gcry_md_spec_t _gcry_digest_spec_blake2s_224; + extern const gcry_md_spec_t _gcry_digest_spec_blake2s_160; + extern const gcry_md_spec_t _gcry_digest_spec_blake2s_128; + extern const gcry_md_spec_t _gcry_digest_spec_sm3; ++#if USE_SM3_PGP ++extern const gcry_md_spec_t _gcry_digest_spec_sm3_pgp; ++#endif + + /* Declarations for the pubkey cipher specifications. */ + extern gcry_pk_spec_t _gcry_pubkey_spec_rsa; +diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in +index 58581da..581f41e 100644 +--- a/src/gcrypt.h.in ++++ b/src/gcrypt.h.in +@@ -1259,6 +1259,11 @@ enum gcry_md_algos + GCRY_MD_SHA512 = 10, + GCRY_MD_SHA224 = 11, + ++#if USE_SM3_PGP ++ /* 100-110 openPGP Private or Experimental Use */ ++ GCRY_MD_SM3_PGP = 109, ++#endif ++ + GCRY_MD_MD4 = 301, + GCRY_MD_CRC32 = 302, + GCRY_MD_CRC32_RFC1510 = 303, +-- +2.43.0 + diff --git a/libgcrypt.spec b/libgcrypt.spec index dc2c827199428929ef36b199d6f0dea2cf653251..1af661f84b90a75d0beb7b774497c4ccc827567c 100644 --- a/libgcrypt.spec +++ b/libgcrypt.spec @@ -4,7 +4,7 @@ Name: libgcrypt Version: 1.10.2 -Release: 2 +Release: 3 Summary: A general-purpose cryptography library License: LGPLv2+ URL: https://www.gnupg.org/ @@ -12,6 +12,7 @@ Source0: https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-%{version}.t Source7: random.conf Patch0: Use-the-compiler-switch-O0-for-compiling-jitterentro.patch +Patch1: add-GCRY_MD_SM3_PGP-set-to-109.patch BuildRequires: gcc texinfo autoconf automake libtool BuildRequires: gawk libgpg-error-devel >= 1.11 pkgconfig @@ -122,6 +123,12 @@ install -m644 %{SOURCE7} $RPM_BUILD_ROOT/etc/gcrypt/random.conf %{_infodir}/gcrypt.info* %changelog +* Sat Oct 26 2024 zhengxiaoxiao - 1.10.2-3 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:add GCRY_MD_SM3_PGP set to 109 + * Thu Sep 12 2024 hugel - 1.10.2-2 - Type:bugfix - ID:NA