Topic: [SOLVED] fastmath memset for RSA-Key corrupts memory on eCos-Port WIP
Hi all,
I'm working on an eCos-port of the wolfSSL library (v 2.7.0) for embedded SSL. The target CPU we're using is a Freescale SPC5668.
So far a couple of the tests worked, but now I'm stuck in the "rsa_test" of the API tests.
I have USE_FAST_MATH defined, so memory allocations are used.
Inside this test, an RSA key is created:
RsaKey key;
Strangely, key points to an address in RAM instantly which has a couple of bytes 0ed (I assume unused), but after some dozen bytes, various variables used by eCos are stored (I especially found some bitmasks for strlen-function and a counter for malloc-function).
The system crashes when the function memset is called from within RsaPrivateKeyDecode -> GetInt -> mp_init with the following parameters:
s = 0x400033F4 (the target address of key)
c = 0
n = 552
This call overwrites 552 bytes of memory starting from address 0x400033F4. This results in various variables needed by eCos in being 0ed and thus corrupting the system context, causing a reboot of my hardware.
I'm not sure if this is a bug in wolfSSL or in eCos instead.
I am wondering though, why there is no previous malloc or similar for key to allocate free memory for the whole key.
Any help is greatly appreciated!
- Daniel
PS: The test worked when I had NOT defined USE_FAST_MATH. It crashed later, but this is another issue.