arc4random is a ChaCha20-based random number generation library. arc4random is ideal for embedded systems: it only needs to hit the hardware random number generator every few million bytes!

This library is likely not a straight import into your embedded project: you will need to set it up to use your locks and talk to your hardware random number generator. In a future article I will demonstrate how to port this to your system.

There are a variety of sources for arc4random. Apple has also ported this to their platform and uses it multiple places. Here are some example implementations to use as a starting point:

Further Reading