Menu

ATtiny13 – pseudo random numbers

Many applications require random data to feed their algorithms. One would say that it’s quite easy when we can use a function from an existing cryptographic library. However, even if we can use such function like for example rand() from stdlib, it can quickly turn out, that this feature consume more then a half of program space – 60.4% (618 bytes) on such small chip like ATtiny13. This project aims to show how to implement a simple and lightweight PRNG (Pseudo Random Number Generator) which require only a 11.3% (116 bytes) of program space. Presented implementation of PRNG is based on Galois LFSR (Linear Feedback Shift Register) and implements extra feature to generate pseudo random seed on boot time (to enable this feature set compiler flag USE_RANDOM_SEED). However, library is unusable as a CSPRNG (Cryptographically Secure PRNG) and should not be used for any of cryptographic purposes. The complete code, as always, is available on GitHub – click here.

Library Code

This library is under a BSD license and can be applied to almost all Atmel AVR microcontrollers without modification.