1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 
4 #include "tomcrypt_private.h"
5 
6 /**
7   @file ecc_sizes.c
8   ECC Crypto, Tom St Denis
9 */
10 
11 #ifdef LTC_MECC
12 
ecc_sizes(int * low,int * high)13 void ecc_sizes(int *low, int *high)
14 {
15   int i, size;
16   void *prime;
17 
18   LTC_ARGCHKVD(low  != NULL);
19   LTC_ARGCHKVD(high != NULL);
20 
21   *low = INT_MAX;
22   *high = 0;
23 
24   if (mp_init(&prime) == CRYPT_OK) {
25     for (i = 0; ltc_ecc_curves[i].prime != NULL; i++) {
26        if (mp_read_radix(prime, ltc_ecc_curves[i].prime, 16) == CRYPT_OK) {
27          size = mp_unsigned_bin_size(prime);
28          if (size < *low)  *low  = size;
29          if (size > *high) *high = size;
30        }
31     }
32     mp_clear(prime);
33   }
34 }
35 
36 #endif
37