Skip to content

EVP_SIGNATURE-SM2

NAME

EVP_SIGNATURE-SM2 - The EVP_PKEY SM2 signature implementation.

DESCRIPTION

Support for computing SM2 signatures. See EVP_PKEY-SM2(7) for information related to SM2 keys.

This signature algorithm can be explicitly fetched with EVP_PKEY_sign_init_ex2(3), and implicitly fetched (through SM2 keys) with EVP_DigestSignInit_ex(3) and EVP_DigestVerifyInit_ex(3).

SM2 Signature Parameters

The following signature parameters can be set using EVP_PKEY_CTX_set_params(3), EVP_DigestSignInit_ex(3) or EVP_DigestVerifyInit_ex(3).

  • "digest" (OSSL_SIGNATURE_PARAM_DIGEST) <UTF8 string>

    This defaults to the SM3 digest if not explicitly specified.

  • "digest-size" (OSSL_SIGNATURE_PARAM_DIGEST) <size_t>

    This defaults to 32 bytes if not explicitly specified. Digests of a different size are not supported with SM2.

  • "distid" (OSSL_PKEY_PARAM_DIST_ID) <UTF8 string>

    The distinguishing identifier defaults to 1234567812345678 if not explicitly specified.

    An explicit empty distinguishing identifier value may need to be used to verify or create signatures that are compatible with versions of OpenSSL prior to 4.0. With the commandline tools an empty value can be specified with the use of either the -pkeyopt (openssl-pkeyutl(1)) or -sigopt (openssl-dgst(1)) option with a value of distid:.

  • "tls-version" (OSSL_SIGNATURE_PARAM_TLS_VERSION) <uint>

    The OpenSSL 4.0 or later TLS protocol engine passes this parameter to the underlying signature algorithm when signing or verifying TLS CertificateVerify messages. When the protocol version is TLS 1.3 (0x0304), the SM2 signature algorithm will use the RFC8998 distinguished identifier instead of the default value noted above.

The following signature parameters can be retrieved using EVP_PKEY_CTX_get_params().

  • "algorithm-id" (OSSL_SIGNATURE_PARAM_ALGORITHM_ID) <octet string>

    This returns the DER encoding of the SM2-with-SM3 signature OID.

  • "digest" (OSSL_SIGNATURE_PARAM_DIGEST) <UTF8 string>

  • "digest-size" (OSSL_SIGNATURE_PARAM_DIGEST) <size_t>

SEE ALSO

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

The default value of the SM2 distinguishing identifier changed from empty to 1234567812345678 as of OpenSSL 4.0.

Support for the OSSL_SIGNATURE_PARAM_TLS_VERSION parameter was added in OpenSSL 4.0.

Copyright 2020-2024 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.