Hello everyone, I am using WolfCrypt on a very limited bare metal microcontroller and I need to use RSA3072 due to customer request.
Using the sp math library I get the smallest flash footprint but the RsaKey structure weighs 1572 bytes (as per sizeof()). I checked the struct and saw that the exponent is defined as mp_int, which becomes an sp_int, which is always an array of 193 32-bit words. That's 772 bytes when e->used is always 1.
struct RsaKey { mp_int n, e; //...Is it necessary to have so much space dedicated to the exponent?
Just to add a bit of context, I am working on a system with 32 kB of RAM, which is already huge (normally we use 3 or 6 kB chips) and with the other requirements of the piece of software I am writing I am down to only 3624 bytes of available RAM.
Since this topic is already a few months old, you may have found a workaround by now; however, the memory allocation for large numbers is a common issue when using WolfCrypt’s math implementation on small MCUs.
The reason for this size is that `sp_int` is designed as a fixed-size structure optimized for performance with large operands, rather than for minimizing RAM usage. Even though the public exponent is typically 65537, the structure still reserves space for the maximum size supported by this math implementation.
RSA-3072 is quite demanding for a 32KB MCU, so it might be worth discussing with the client whether an algorithm more suitable for embedded systems (such as ECC-based signatures) would be acceptable. If RSA-3072 is mandatory, you will likely need to optimize the library configuration, not just the key size. It is good that there are no issues when using the mostbet app bangladesh login.