ECCPSignSM2

Computes a digital signature over a message digest using the SM2 scheme.

Syntax

IppStatus ippsECCPSignSM2(const IppsBigNumState* pMsgDigest, const IppsBigNumState* pRegPrivate, IppsBigNumState* pEphPrivate, IppsBigNumState* pSignR, IppsBigNumState* pSignS, IppsECCPState* pECC);

Include Files

ippcp.h

Parameters

pMsgDigest

Pointer to the message digest msg.

pRegPrivate

Pointer to the regular private key regPrivKey.

pEphPrivate

Pointer to the ephmeral private key ephPrivKey.

pSignR

Pointer to the integer r of the digital signature.

pSignS

Pointer to the integer s of the digital signature.

pECC

Pointer to the context of the elliptic cryptosystem.

Description

The function computes two big numbers r and s that form the digital signature over a message digest msg.

The digital signature is computed using the SM2 scheme [SM2]. The scheme requires that the following cryptosystem keys are set up by the message sender:

regPrivKey

Regular private key.

ephPrivKey

Ephemeral private key.

ephPubKey

Ephemeral public key.

For security reasons, each signature must be generated with the unique ephemeral private key. Because of this, the function clears (sets to zero) the input ephemeral key before return. To generate and set up the keys, call the ECCPGenKeyPair function.

Before calling ECCPSignSM2, set up the domain parameters of the elliptic curve in the *pECC context by calling one of the functions: ECCPSet or ECCPSetStdSM2.

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error or warning.

ippStsNullPtrErr

Indicates an error condition if any of the specified pointers is NULL.

ippStsContextMatchErr

Indicates an error condition if one of the specified contexts is not valid.

ippStsMessageErr

Indicates an error condition if the value of msg pointed by pMsgDigest is negative, or its size (in bits) is more than the order n of the elliptic curve base point G.

ippStsRangeErr

Indicates an error condition if one of the parameters pointed by pSignR or pSignS has memory size smaller than the order n of the elliptic curve base point G.

ippStsEphemeralKeyErr

Indicates an error condition if:

  • The value of the ephemeral key does not belong to the [0, n-1] range, where n is the order of the elliptic curve base point G.

  • The value of r or s component of signature to be computed is equal to zero.

ippStsInvalidPrivateKey

Indicates an error condition if the value of the private key does not belong to the [0, n-1] range, where n is the order of the elliptic curve base point G.