See Signing and Verifying Binaries for an example of how to use the ECDSA ECDSA sign/verify functions.
◆ sharkssl_ECDSA_siglen()
Returns the maximum length (in bytes) of a DER-encoded ECDSA signature generated with the private key 'privkey'.
This function is typically used in combination with sharkssl_ECDSA_sign_hash to compute the maximum length of the signature and to allocate a buffer large enough to hold the signature 'sig'.
- Parameters
-
privkey | is the private key in SharkSslECCKey format. |
◆ sharkssl_ECDSA_sign_hash()
Generate the signature using the ECC private key and a hash.
- Parameters
-
privkey | is the private key in SharkSslECCKey format. |
sig | is a pointer to the buffer where the DER-encoded ECDSA signature will be generated. The size of this buffer must not be smaller than the value returned by sharkssl_ECDSA_siglen for param 'privkey'. The length of this buffer, which may be larger than required, is provided in the next parameter (siglen). |
siglen | is parameter "sig"'s length and is provided as an input parameter. The signature length will be returned as output parameter. |
hash | the message digest obtained from a hash function e.g. SHA256. |
hashlen | the length of the message digest (see above). |
- Returns
- SHARKSSL_ECDSA_OK if the signature generation is successful, or one of the sharkssl_ECDSA_RetVal error codes.
◆ sharkssl_ECDSA_verify_hash()
Verify a message using the ECC public key and a hash algorithm.
- Parameters
-
pubkey | is the public key in SharkSslECCKey format. |
sig | is a pointer to the DER-encoded ECDSA signature that is to be verified. |
siglen | is parameter "sig"'s length. |
hash | the message digest obtained from a hash function e.g. SHA256. |
hashlen | the length of the message digest (see above). |
- Returns
- SHARKSSL_ECDSA_OK if the signature verification is successful, or one of the sharkssl_ECDSA_RetVal error codes.
◆ sharkssl_PEM_to_ECCKey()
SHARKSSL_API SharkSslECCKey sharkssl_PEM_to_ECCKey |
( |
const char * |
PEMKey, |
|
|
const char * |
passphrase |
|
) |
| |
Convert an ECC private or public key in PEM format to the SharkSslECCKey format.
Note: the converted value must be released by calling SharkSslECCKey_free, when no longer needed.
example:
{
...
ECCKey = sharksslPEM_to_ECCKey(key, pass);
if (ECCKey)
{
...
}
}
U8 * SharkSslECCKey
SharkSslECCKey is an alias for the SharkSslCert type and is a private/public key converted by sharkss...
Definition: SharkSSL.h:2211
SHARKSSL_API void SharkSslECCKey_free(SharkSslECCKey key)
Release a SharkSslECCKey allocated by functions sharkssl_PEM_to_ECCKey or SharkSslECCKey_create.
- Returns
- the private/public key in SharkSslECCKey format or NULL if the conversion fails.