I have to make a RSA signature (on a state machine) in C
on a 32bit board. I am limited on memory so I can not store decimals in a vector or something like that.
The best thing would be if I could store bits and to have easy access to them; what storage method would be best?
I made this one:
#if (CPU_TYPE == CPU_TYPE_32)
typedef uint32_t word;
#define word_length 32
typedef struct BigNumber {
word words[64];
} BigNumber;
#elif (CPU_TYPE == CPU_TYPE_16)
typedef uint16_t word;
#define word_length 16
typedef struct BigNumber {
word words[128];
} BigNumber;
#else
#error Unsupported CPU_TYPE
#endif
This seems hard to use. How can I simplify it?
You may simply use the BigNumber API from OpenSSL. You can find the full API here.
And, you can use this code sample as a start:
Compile it with:
You should get something like this when executing it: