PLSM2Sign

Cryptography

Description

Generates a GB/T 32918.2 signature over ZA || Message with a caller-supplied nonce source

Syntax

Delphi

Function PLSM2Sign(Const Curve: TPLSM2Curve; Const PrivateKey: TPLSM2Int;
  Const Message, ZA: AnsiString; Const RandomK: TPLSM2RandomK;
  Out R, S: AnsiString): Boolean;

Parameters

CurveCurve parameters, normally the SM2P256V1 constant
PrivateKeyPrivate scalar d
MessageRaw message bytes; ZA must be prepended by the caller
ZAUser-ID digest from PLSM2ComputeZA
RandomKCallback returning a fresh nonce per round as a 32-byte big-endian value; degenerate rounds are retried with a new nonce automatically
RReceives the 32-byte big-endian signature part r
SReceives the 32-byte big-endian signature part s

Return values

FalseThe nonce source failed or the private key is out of range
TrueR and S hold the DER-ready signature pair in big-endian form

Remarks

Part of the pure-Pascal SM2 suite (GB/T 32918) covering 256-bit prime-field arithmetic, Jacobian point operations and the SM3-based ZA derivation; the recommended sm2p256v1 curve ships as the SM2P256V1 constant and the specification appendix curve as SM2ExampleCurve

The nonce policy stays in the integrator's control, so CSPRNG and deterministic schemes are both possible; the published example-curve signature verifies byte-for-byte

See also

PLSM2Verify, PLSM2ComputeZA, PLSM2PublicKeyFromPrivate, PLValidateSM2Identity