From b6c0cdbe7d20af48b0c2a909a66ff00b093d1542 Mon Sep 17 00:00:00 2001 From: Ken MacKay Date: Tue, 8 Mar 2016 21:29:40 -0800 Subject: [PATCH] Add functions to get the private/public key size for a curve (#73) --- uECC.c | 8 ++++++++ uECC.h | 12 ++++++++++++ 2 files changed, 20 insertions(+) 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.