EVP_SIGNATURE-SM2(7SSL)
π EVP_SIGNATURE-SM2 π
okay bestie, so this page is from the OpenSSL manual set β it's an EVP_SIGNATURE-SM2(7SSL) joint, aka a subsection of the OpenSSL docs, and it's all about the EVP_PKEY SM2 signature implementation. Yes that's a mouthful. We'll get through it together. π«Ά
β¨ NAME β¨
EVP_SIGNATURE-SM2 β the EVP_PKEY SM2 signature implementation, no cap.
πΈ DESCRIPTION πΈ
So basically: this is the support for computing SM2 signatures. If you wanna know stuff about SM2 keys specifically (as opposed to signatures), that's a whole different page, babe β go look at EVP_PKEY-SM2(7). This page is signatures only. π
Now here's the fetch tea β β this signature algorithm can be fetched two ways:
- Explicitly, with
EVP_PKEY_sign_init_ex2(3) - Implicitly (sneaking in through SM2 keys), with
EVP_DigestSignInit_ex(3)andEVP_DigestVerifyInit_ex(3)
π SM2 Signature Parameters π
These are the ones you set. You do it with EVP_PKEY_CTX_set_params(3), EVP_DigestSignInit_ex(3), or EVP_DigestVerifyInit_ex(3). Three options, pick your fighter. π
"digest"(OSSL_SIGNATURE_PARAM_DIGEST) <UTF8 string> β the digest in question. If you don't say anything explicitly, it just defaults to the"SM3"digest. She has a favourite and it's SM3. β¨"digest-size"(OSSL_SIGNATURE_PARAM_DIGEST) <size_t> β the size of the digest. Defaults to 32 bytes if you don't specify it. And heads up: digests of a different size are not supported with SM2. So don't try it, the algorithm will simply not be having it. π"distid"(OSSL_PKEY_PARAM_DIST_ID) <UTF8 string> β the distinguishing identifier. Defaults to1234567812345678if you don't set it explicitly.
Now this one has lore π« β you may need to explicitly use an empty distinguishing identifier value to verify or create signatures that are compatible with versions of OpenSSL prior to 4.0. And if you're doing it with the commandline tools, you specify that empty value using either the -pkeyopt option (openssl-pkeyutl(1)) or the -sigopt option (openssl-dgst(1)), with a value of "distid:". That trailing colon is doing a LOT of work there, don't lose it. π
"tls-version"(OSSL_SIGNATURE_PARAM_TLS_VERSION) <uint> β the OpenSSL 4.0-or-later TLS protocol engine passes this parameter down to the underlying signature algorithm when it's signing or verifying TLS CertificateVerify messages. And here's the plot twist: when the protocol version is TLS 1.3 (0x0304), the SM2 signature algorithm will use the RFC8998 distinguished identifier instead of the default value we just talked about above. Iconic behaviour, honestly. π
And these are the ones you retrieve, bestie, using EVP_PKEY_CTX_get_params():
"algorithm-id"(OSSL_SIGNATURE_PARAM_ALGORITHM_ID) <octet string> β this hands you back the DER encoding of the SM2-with-SM3 signature OID. Very demure. Very DER."digest"(OSSL_SIGNATURE_PARAM_DIGEST) <UTF8 string>"digest-size"(OSSL_SIGNATURE_PARAM_DIGEST) <size_t>
π¦ SEE ALSO π¦
The besties this page is linking hands with π
EVP_PKEY_CTX_set_params(3)EVP_PKEY_sign(3)EVP_PKEY_verify(3)EVP_DigestSignInit_ex(3)EVP_DigestVerifyInit_ex(3)provider-signature(7)
π HISTORY π
Two things, and both of them are glow-ups:
- The default value of the SM2 distinguishing identifier changed from empty to
1234567812345678as of OpenSSL 4.0. So if you were vibing with the empty default, that's an old-era thing now. - Support for the
OSSL_SIGNATURE_PARAM_TLS_VERSIONparameter was added in OpenSSL 4.0.
π COPYRIGHT π
Copyright 2020-2026 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
fr fr read the license, bestie, it's literally right there π«Ά
And that's the whole page, periodt. β¨ This one's from OpenSSL 4.0.3, dated 2026-09-29, and it lives in the 7SSL section of the manual β so if you ever need to cite her, that's the fit she's wearing. πππ
π¦ where this page comes from
- ubuntu stonking: openssl 4.0.3-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms