Topic: ECC Signing/Encryption with Custom RNG
Hi I am developing firmware for an embedded device, and I would like to use the WolfCrypt library for encryption, and digital signing.
I am trying to make use of the ECC methods however when attempting to use my board's HWRNG I am unable to generate ECC keys.
#undef CUSTOM_RAND_TYPE
#define CUSTOM_RAND_TYPE uint32_t
extern uint32_t custom_rand_generate(byte* data, word32 len);
#undef CUSTOM_RAND_GENERATE
#define CUSTOM_RAND_GENERATE custom_rand_generate
Below is a rough outline of what I have. This will compile however key generation and signing will always fail with -173 and -170 respectively
uint32_t custom_rand_generate(byte* data, word32 len) {
return MXC_TRNG_Random(data, len);
}
int asym_sign(uint8_t *ciphertext, size_t len) {
ecc_key key;
int makeKey, eccInit, rngInit;
int rngCheck;
byte rng;
rngInit = MXC_TRNG_Init();
rngCheck = custom_rand_generate(&rng, 256);
eccInit = wc_ecc_init(&key);
makeKey = wc_ecc_make_key(/* TODO PASS RNG */, ECC_KEY_SIZE, &key);
}