1.24 CRYPT_ECC_DSA_HashSign Function
C
int CRYPT_ECC_DSA_HashSign(
CRYPT_ECC_CTX* ecc,
CRYPT_RNG_CTX* rng,
unsigned char* sig,
unsigned int sigSz,
unsigned int* usedSz,
const unsigned char* in,
unsigned int inSz
);
Description
This function takes a message digest and signs it using a private ECC key.
Preconditions
The ECC context must have been initialized with a call to CRYPT_ECC_Initialize. The RNG context must have been initialized with a call to CRYPT_RNG_Initialize. The private key used for the signature must have been imported or created prior to calling this function.
Parameters
Parameters | Description |
---|---|
ecc | Pointer to ECC context which saves state between calls and holds keys. |
rng | Pointer to Random Number Generator context. |
sig | Destination for the signature. |
sigSz | The max size of the signature, in bytes. |
usedSz | The resulting size of the signature, in bytes. |
in | Pointer to the message digest to sign. |
inSz | The length of the digest, in bytes. |
Returns
BAD_FUNC_ARG - An invalid pointer was passed to the function.
0 - An invalid pointer was not passed to the function.
Remarks
None.
Example
CRYPT_ECC_CTX userA;
int ret;
byte sig[100];
unsigned int sigSz = (unsigned int)sizeof(sig);
unsigned int usedA = 0;
ret = CRYPT_ECC_Initialize(&userA);
...
// Import or generate private key
...
ret = CRYPT_ECC_DSA_HashSign(&userA, &mcRng, sig, sigSz, &usedA, ourData, CRYPT_SHA_DIGEST_SIZE);