forked from wolfSSL/wolfssl
Merge pull request #2627 from SparkiDev/rsa_sign_vfy
Change signature generation to verify by default
This commit is contained in:
@ -319,6 +319,16 @@ int wc_SignatureGenerateHash(
|
|||||||
const byte* hash_data, word32 hash_len,
|
const byte* hash_data, word32 hash_len,
|
||||||
byte* sig, word32 *sig_len,
|
byte* sig, word32 *sig_len,
|
||||||
const void* key, word32 key_len, WC_RNG* rng)
|
const void* key, word32 key_len, WC_RNG* rng)
|
||||||
|
{
|
||||||
|
return wc_SignatureGenerateHash_ex(hash_type, sig_type, hash_data, hash_len,
|
||||||
|
sig, sig_len, key, key_len, rng, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int wc_SignatureGenerateHash_ex(
|
||||||
|
enum wc_HashType hash_type, enum wc_SignatureType sig_type,
|
||||||
|
const byte* hash_data, word32 hash_len,
|
||||||
|
byte* sig, word32 *sig_len,
|
||||||
|
const void* key, word32 key_len, WC_RNG* rng, int verify)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -393,6 +403,11 @@ int wc_SignatureGenerateHash(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret == 0 && verify) {
|
||||||
|
ret = wc_SignatureVerifyHash(hash_type, sig_type, hash_data, hash_len,
|
||||||
|
sig, *sig_len, key, key_len);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,6 +416,16 @@ int wc_SignatureGenerate(
|
|||||||
const byte* data, word32 data_len,
|
const byte* data, word32 data_len,
|
||||||
byte* sig, word32 *sig_len,
|
byte* sig, word32 *sig_len,
|
||||||
const void* key, word32 key_len, WC_RNG* rng)
|
const void* key, word32 key_len, WC_RNG* rng)
|
||||||
|
{
|
||||||
|
return wc_SignatureGenerate_ex(hash_type, sig_type, data, data_len, sig,
|
||||||
|
sig_len, key, key_len, rng, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int wc_SignatureGenerate_ex(
|
||||||
|
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, int verify)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
word32 hash_len, hash_enc_len;
|
word32 hash_len, hash_enc_len;
|
||||||
@ -467,6 +492,11 @@ int wc_SignatureGenerate(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret == 0 && verify) {
|
||||||
|
ret = wc_SignatureVerifyHash(hash_type, sig_type, hash_data,
|
||||||
|
hash_enc_len, sig, *sig_len, key, key_len);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
XFREE(hash_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(hash_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,12 +62,23 @@ WOLFSSL_API int wc_SignatureGenerateHash(
|
|||||||
const byte* hash_data, word32 hash_len,
|
const byte* hash_data, word32 hash_len,
|
||||||
byte* sig, word32 *sig_len,
|
byte* sig, word32 *sig_len,
|
||||||
const void* key, word32 key_len, WC_RNG* rng);
|
const void* key, word32 key_len, WC_RNG* rng);
|
||||||
|
WOLFSSL_API int wc_SignatureGenerateHash_ex(
|
||||||
|
enum wc_HashType hash_type, enum wc_SignatureType sig_type,
|
||||||
|
const byte* hash_data, word32 hash_len,
|
||||||
|
byte* sig, word32 *sig_len,
|
||||||
|
const void* key, word32 key_len, WC_RNG* rng, int verify);
|
||||||
WOLFSSL_API int wc_SignatureGenerate(
|
WOLFSSL_API int wc_SignatureGenerate(
|
||||||
enum wc_HashType hash_type, enum wc_SignatureType sig_type,
|
enum wc_HashType hash_type, enum wc_SignatureType sig_type,
|
||||||
const byte* data, word32 data_len,
|
const byte* data, word32 data_len,
|
||||||
byte* sig, word32 *sig_len,
|
byte* sig, word32 *sig_len,
|
||||||
const void* key, word32 key_len,
|
const void* key, word32 key_len,
|
||||||
WC_RNG* rng);
|
WC_RNG* rng);
|
||||||
|
WOLFSSL_API int wc_SignatureGenerate_ex(
|
||||||
|
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, int verify);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
Reference in New Issue
Block a user