Skip to content

Implement SM2 & ML-DSA-65 Hybrid Signature Algorithm - #756

Closed
HOCOOH wants to merge 620 commits into
Tongsuo-Project:masterfrom
HOCOOH:sm2_mldsa65_hybrid
Closed

Implement SM2 & ML-DSA-65 Hybrid Signature Algorithm#756
HOCOOH wants to merge 620 commits into
Tongsuo-Project:masterfrom
HOCOOH:sm2_mldsa65_hybrid

Conversation

@HOCOOH

@HOCOOH HOCOOH commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

This PR implements an experimental SM2 and ML-DSA-65 hybrid signature algorithm.

The hybrid signature scheme is based on the IETF draft. The OID for this algorithm is temporarily assigned to an unused field under the CompSig domain proposed in the draft, namely <CompSig>.21 (2.16.840.1.114027.80.9.1.21). All other signature details follow the draft specification.

For easier review, the implementation is split into multiple commits, each corresponding to a specific functional change.

The corresponding documentation can be found in PR.

wa5i and others added 30 commits July 19, 2023 23:46
通过独立的provider提供商用密码算法和协议,后续用于申请商用密码产品认证。

SMTC provider包括软件完整性验证,身份认证,kats自测试,测试随机数、杂凑、
对称加密、签名等基础密码学算法,随机数自检,熵源健康测试;
增加mod app, 包括生成SMTC配置、自测试功能。

目前SMTC provider以builtin module方式实现。
The AES-SIV mode allows for multiple associated data items
authenticated separately with any of these being 0 length.

The provided implementation ignores such empty associated data
which is incorrect in regards to the RFC 5297 and is also
a security issue because such empty associated data then become
unauthenticated if an application expects to authenticate them.

Fixes CVE-2023-2975

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from openssl/openssl#21384)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from openssl/openssl#21384)
The DH_check() function checks numerous aspects of the key or parameters
that have been supplied. Some of those checks use the supplied modulus
value even if it is excessively large.

There is already a maximum DH modulus size (10,000 bits) over which
OpenSSL will not generate or derive keys. DH_check() will however still
perform various tests for validity on such a large modulus. We introduce a
new maximum (32,768) over which DH_check() will just fail.

An application that calls DH_check() and supplies a key or parameters
obtained from an untrusted source could be vulnerable to a Denial of
Service attack.

The function DH_check() is itself called by a number of other OpenSSL
functions. An application calling any of those other functions may
similarly be affected. The other functions affected by this are
DH_check_ex() and EVP_PKEY_param_check().

CVE-2023-3446

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21451)

(cherry picked from commit 9e0094e2aa1b3428a12d5095132f133c078d3c3d)
Confirm that the only errors DH_check() finds with DH parameters with an
excessively long modulus is that the modulus is too large. We should not
be performing time consuming checks using that modulus.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21451)
If the public key type is EVP_PKEY_KEYMGMT, errors may occur in
some cases. It is necessary to obtain the exact type of the public
key from keymgmt.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
If  |q| >= |p| then the q value is obviously wrong as q
is supposed to be a prime divisor of p-1.

We check if p is overly large so this added test implies that
q is not large either when performing subsequent tests using that
q value.

Otherwise if it is too large these additional checks of the q value
such as the primality test can then trigger DoS by doing overly long
computations.

Fixes CVE-2023-3817

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from openssl/openssl#21550)
This must fail with DH_CHECK_INVALID_Q_VALUE and
with DH_CHECK_Q_NOT_PRIME unset.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from openssl/openssl#21550)
pkcs7: support sm2 public algorithm
Absolute symlink path will cause unexpected error in rpmbuild.
use relative path can solve this issue.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
use relative path for tongsuo symlink
Implement the NIZKPoK algorithm and zkp_range_proof gadget.
增加商用密码检测和认证Provider
Move the EC_POINT_from_string to ec_lib.c to make it more generic.
Update the certificate
kafei-cy and others added 18 commits September 2, 2025 16:08
…tensions

This PR adds support for the subjectDirectoryAttributes and associatedInformation X.509v3 extensions. These extensions allow an X.509 public key certificate to include arbitrary directory attributes: the former associated with the subject, and the latter containing arbitrary information that does not necessarily describe the subject.
Remove unnecessary items
Use command 'make update' to refresh .num file
…o-3.0.4

Optimize the method mechanism.
1. Refactor the method store mechanism to remove unnecessary operations of clearing all operation_bits for all providers.
2. Improve the mapping of methods with new pre-checking functions which support "no_store" parameter, so as to bypass the checking of stores when the method should not exist in any store.
This PR supports parsing SubjectDirectoryAttributes and AssociatedInformation X.509v3 extensions, which fixes issue Tongsuo-Project#685.
@HOCOOH

HOCOOH commented Sep 18, 2025

Copy link
Copy Markdown
Contributor Author

rebase to master

@pr000000f

Copy link
Copy Markdown
Collaborator

@HOCOOH Please rebase this PR to current master (8.5.0) or 8.4.1-dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.