5

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..? ???

jontro
  • 10,241
  • 6
  • 46
  • 71
  • I'm not sure whether this meets your requirement, but checkout the [BigDigits](http://www.di-mgt.com.au/bigdigits.html) library. – kkrambo May 30 '14 at 13:00
  • You need to be more clear about what is not acceptable in `libc`. You can alter the source to not use an allocator, if that is your problem. I think it would be better to concentrate on the issue, than to ask for a recommendation. Ie, the **method** part of your question is promising. – artless noise Jun 02 '14 at 18:46

1 Answers1

2

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.

Grzegorz Szpetkowski
  • 36,988
  • 6
  • 90
  • 137
  • 2
    The [BigDigits](http://www.di-mgt.com.au/bigdigits.html) library includes a core library for which memory allocations can be disabled with the `NO_ALLOCS` preprocessor definition. The core library will then use fixed arrays and you can adjust the size of these arrays based on knowledge of your application. – kkrambo Jun 04 '14 at 13:42
  • @kkrambo: I didn't notice that, answer is edited, thanks for enlightening :-) – Grzegorz Szpetkowski Jun 04 '14 at 14:04