This was my seventh week in AESTE WORKS. As mentioned in previous blog, this week I have to save the payload in flash memory and read it from flash.

Problem I faced this week and solution:

Our board will generate a RSA key pair and store in Flash Memory. Firstly, we will read everything in Flash Memory and checksum. If the result is true, it means the board itself have the key. Else, the board will generate a new key and store to Flash Memory. However, the problem I faced is every time when the board generate a new key, the RSA key  is not random. Every time it only generate 2 different patterns which are either pattern A or B. After discussed with Dr Shawn, he explained to me why is this happening and it solution. He said this is because our RNG (Random Number Generator) is using PRNG (Pseudorandom number generator). There are 2 types of RNG, which are TRNG (True Random Number Generator) and PRNG.  TRNG is also called hardware random number generator, it generates random number from a physical process rather than a computer program. So it will be completely random. For the PRNG, it is not truly random, because it is completely determined by an initial value, called the PRNG’s seed. This is the reason why every time when I wanted to generate a new key, it always show a same result. In order to use TRNG in wolfSSL, we have to define it (#define WOLFSSL_PIC32MZ_RNG). After added this finally the problem is solved! Every time will get a random number instead of only get 2 different pattern’s key.


Luckily by the end of this week I had solved the problem of random number generation. Thus, next week I can continue to move forward with my program.



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.