EVP_SIGNATURE-SM2(7SSL)

πŸ“¦
version 4.0.3 Β· 2 versions
, in ubuntu stonking

πŸ’– 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:


πŸŽ€ 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 to 1234567812345678 if 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 πŸ’ž


🌟 HISTORY 🌟

Two things, and both of them are glow-ups:

  • The default value of the SM2 distinguishing identifier changed from empty to 1234567812345678 as 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_VERSION parameter was added in OpenSSL 4.0.

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