pk: function to calculate the signature size

Expose a function mbedtls_pk_signature_size to calculate the maximum
size of a signature made with a given key. Document that this is the
buffer size that mbedtls_pk_sign requires.

Add a corresponding field signature_size_func to the mbedtls_pk_info
structure.
This commit is contained in:
Gilles Peskine
2017-11-02 17:16:43 +01:00
committed by Andrzej Kurek
parent bce41d373a
commit cd062d84d6
5 changed files with 50 additions and 1 deletions

View File

@@ -270,6 +270,8 @@ void pk_sign_verify( int type, int sign_ret, int verify_ret )
TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, sizeof hash,
sig, &sig_len, rnd_std_rand, NULL ) == sign_ret );
if( sign_ret == 0 )
TEST_ASSERT( sig_len <= mbedtls_pk_signature_size( &pk ) );
TEST_ASSERT( mbedtls_pk_verify( &pk, MBEDTLS_MD_SHA256,
hash, sizeof hash, sig, sig_len ) == verify_ret );