|
int | wc_SignatureGetSize (enum wc_SignatureType sig_type, const void *key, word32 key_len) |
| This function returns the maximum size of the resulting signature. More...
|
|
int | wc_SignatureVerify (enum wc_HashType hash_type, enum wc_SignatureType sig_type, const byte *data, word32 data_len, const byte *sig, word32 sig_len, const void *key, word32 key_len) |
| This function validates a signature by hashing the data and using the resulting hash and key to verify the signature. More...
|
|
int | wc_SignatureGenerate (enum wc_HashType hash_type, enum wc_SignatureType sig_type, const byte *data, word32 data_len, byte *sig, word32 *sig_len, const void *key, word32 key_len, WC_RNG *rng) |
| This function generates a signature from the data using a key. It first creates a hash of the data then signs the hash using the key. More...
|
|
◆ wc_SignatureGenerate()
int wc_SignatureGenerate |
( |
enum wc_HashType |
hash_type, |
|
|
enum wc_SignatureType |
sig_type, |
|
|
const byte * |
data, |
|
|
word32 |
data_len, |
|
|
byte * |
sig, |
|
|
word32 * |
sig_len, |
|
|
const void * |
key, |
|
|
word32 |
key_len, |
|
|
WC_RNG * |
rng |
|
) |
| |
This function generates a signature from the data using a key. It first creates a hash of the data then signs the hash using the key.
- Returns
- 0 Success
-
SIG_TYPE_E -231, signature type not enabled/ available
-
BAD_FUNC_ARG -173, bad function argument provided
-
BUFFER_E -132, output buffer too small or input too large.
- Parameters
-
hash_type | A hash type from the “enum wc_HashType” such as “WC_HASH_TYPE_SHA256”. |
sig_type | A signature type enum value such as WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA. |
data | Pointer to buffer containing the data to hash. |
data_len | Length of the data buffer. |
sig | Pointer to buffer to output signature. |
sig_len | Length of the signature output buffer. |
key | Pointer to a key structure such as ecc_key or RsaKey. |
key_len | Size of the key structure. |
rng | Pointer to an initialized RNG structure. |
Example
int ret;
WC_RNG rng;
ecc_key eccKey;
sigBuf = malloc(sigLen);
WC_HASH_TYPE_SHA256, WC_SIGNATURE_TYPE_ECC,
fileBuf, fileLen,
sigBuf, &sigLen,
&eccKey, sizeof(eccKey),
&rng);
printf("Signature Generation: %s
(%d)\n", (ret == 0) ? "Pass" : "Fail", ret);
free(sigBuf);
- See also
- wc_SignatureGetSize
-
wc_SignatureVerify
◆ wc_SignatureGetSize()
int wc_SignatureGetSize |
( |
enum wc_SignatureType |
sig_type, |
|
|
const void * |
key, |
|
|
word32 |
key_len |
|
) |
| |
This function returns the maximum size of the resulting signature.
- Returns
- Returns SIG_TYPE_E if sig_type is not supported. Returns BAD_FUNC_ARG if sig_type was invalid. A positive return value indicates the maximum size of a signature.
- Parameters
-
sig_type | A signature type enum value such as WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA. |
key | Pointer to a key structure such as ecc_key or RsaKey. |
key_len | Size of the key structure. |
Example
enum wc_SignatureType sig_type = WC_SIGNATURE_TYPE_ECC;
ecc_key eccKey;
word32 sigLen;
if (sigLen > 0) {
}
- See also
- wc_HashGetDigestSize
-
wc_SignatureGenerate
-
wc_SignatureVerify
◆ wc_SignatureVerify()
int wc_SignatureVerify |
( |
enum wc_HashType |
hash_type, |
|
|
enum wc_SignatureType |
sig_type, |
|
|
const byte * |
data, |
|
|
word32 |
data_len, |
|
|
const byte * |
sig, |
|
|
word32 |
sig_len, |
|
|
const void * |
key, |
|
|
word32 |
key_len |
|
) |
| |
This function validates a signature by hashing the data and using the resulting hash and key to verify the signature.
- Returns
- 0 Success
-
SIG_TYPE_E -231, signature type not enabled/ available
-
BAD_FUNC_ARG -173, bad function argument provided
-
BUFFER_E -132, output buffer too small or input too large.
- Parameters
-
hash_type | A hash type from the “enum wc_HashType” such as “WC_HASH_TYPE_SHA256”. |
sig_type | A signature type enum value such as WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA. |
data | Pointer to buffer containing the data to hash. |
data_len | Length of the data buffer. |
sig | Pointer to buffer to output signature. |
sig_len | Length of the signature output buffer. |
key | Pointer to a key structure such as ecc_key or RsaKey. |
key_len | Size of the key structure. |
Example
int ret;
ecc_key eccKey;
WC_HASH_TYPE_SHA256, WC_SIGNATURE_TYPE_ECC,
fileBuf, fileLen,
sigBuf, sigLen,
&eccKey, sizeof(eccKey));
printf("Signature Verification: %s
(%d)\n", (ret == 0) ? "Pass" : "Fail", ret);
- See also
- wc_SignatureGetSize
-
wc_SignatureGenerate
int wc_ecc_init(ecc_key *key)
This function initializes an ecc_key object for future use with message verification or key negotiati...
int wc_SignatureGetSize(enum wc_SignatureType sig_type, const void *key, word32 key_len)
This function returns the maximum size of the resulting signature.
int wc_SignatureGenerate(enum wc_HashType hash_type, enum wc_SignatureType sig_type, const byte *data, word32 data_len, byte *sig, word32 *sig_len, const void *key, word32 key_len, WC_RNG *rng)
This function generates a signature from the data using a key. It first creates a hash of the data th...
int wc_ecc_import_x963(const byte *in, word32 inLen, ecc_key *key)
This function imports a public ECC key from a buffer containing the key stored in ANSI X9....
int wc_SignatureVerify(enum wc_HashType hash_type, enum wc_SignatureType sig_type, const byte *data, word32 data_len, const byte *sig, word32 sig_len, const void *key, word32 key_len)
This function validates a signature by hashing the data and using the resulting hash and key to verif...
int wc_ecc_free(ecc_key *key)
This function frees an ecc_key object after it has been used.
int wc_FreeRng(WC_RNG *)
Should be called when RNG no longer needed in order to securely free drgb. Zeros and XFREEs rng-drbg.
int wc_InitRng(WC_RNG *)
Gets the seed (from OS) and key cipher for rng. rng->drbg (deterministic random bit generator) alloca...
int wc_ecc_make_key(WC_RNG *rng, int keysize, ecc_key *key)
This function generates a new ecc_key and stores it in key.