Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching for Embedded C library to operate on Big numbers which do not use standard libc?

I have to operate on Very large numbers may be 2048 bytes for implementation of RSA. As per the rules of Automotive domain i cant use bignum library which uses standard libc. I have searched for GMP and Polarssl but they all uses malloc() and other things.

So is there any library/method available that do not rely on libc and also manages such big numbers..? ???

like image 228
user3679091 Avatar asked Oct 31 '22 22:10

user3679091


1 Answers

I don't think you will find any decent big integer C library, that not use malloc, calloc and possibly realloc or whatever dynamic allocation, because the whole point of arbitrary precision numbers is to go beyond limited, platform-dependent stack size and for second it's much more flexible method than compile-time static memory allocation.

My guess is to adapt mini-gmp package to overcome your specific limitations. (you will find it under main directory along with some tests). It contains one header file and C-source file, so it should be a lot simpler to "cut-off" libc dependency rather than fully-featured release, however it will be not that fast as GMP relies heavily on highly-optimized assembly code for various CPU architectues.

As suggested by kkrambo you may also try BigDigits library with NO_ALLOCS option, that is available since version 2.2:

Added the NO_ALLOCS option to compile the "mp" library without using any memory allocation.

like image 146
Grzegorz Szpetkowski Avatar answered Dec 08 '22 00:12

Grzegorz Szpetkowski