diff --git a/uECC.c b/uECC.c index 63ec6f9..7717533 100644 --- a/uECC.c +++ b/uECC.c @@ -195,6 +195,14 @@ uECC_RNG_Function uECC_get_rng(void) { return g_rng_function; } +int uECC_curve_private_key_size(uECC_Curve curve) { + return BITS_TO_BYTES(curve->num_n_bits); +} + +int uECC_curve_public_key_size(uECC_Curve curve) { + return 2 * curve->num_bytes; +} + #if !asm_clear uECC_VLI_API void uECC_vli_clear(uECC_word_t *vli, wordcount_t num_words) { wordcount_t i; diff --git a/uECC.h b/uECC.h index dcc8e82..1193ce8 100644 --- a/uECC.h +++ b/uECC.h @@ -130,6 +130,18 @@ Returns the function that will be used to generate random bytes. */ uECC_RNG_Function uECC_get_rng(void); +/* uECC_curve_private_key_size() function. + +Returns the size of a private key for the curve in bytes. +*/ +int uECC_curve_private_key_size(uECC_Curve curve); + +/* uECC_curve_public_key_size() function. + +Returns the size of a public key for the curve in bytes. +*/ +int uECC_curve_public_key_size(uECC_Curve curve); + /* uECC_make_key() function. Create a public/private key pair.