For sequence generators that are difficult or costly to reseed or if you don't have the source so are unsure how effective seeding it is it is often better to simply XOR the rand() result with the currently accumulated entropy before use. For intermediate numbers of random bits, shift them into a 16 bit integer as you get them, and use it XORed with rand() for reseeding.If you are only getting one or two bits of true randomness at a time as you are running, use them to decide how many rand() results to discard before the next one you actually use.If you can accumulate 16 bits of true randomness before you need to use rand() simply seed with it.the LSB of whatever ADC channels you have connected. You may also be able to pick up a few bits here and there from other peripherals e.g. As the timer is stopped by the reset, this allows you to measure the WDT period which is sensitive to supply voltage and temperature, so again the low order bits are reasonably random as long as the WDT period is a couple of orders of magnitude greater than the rollover period of the chosen number of low order bits. Techniques include timing user input and discarding all except a few low order bits, or setting a high clock speed and allowing a 16 bit timer to increment until a WDT reset. The sourcecode for srand() and rand() is: Incrementing it by one each time does nothing useful. (to receive an activation key that will unlock the Standard or Pro optimization features) Use the Pro. MPLAB XC8 C Compiler 1.41 is available as a free. You ideally need 16 bits of entropy for the seed. Microchip MPLAB XC8 C Compiler (PRO Mode) V1.32 XC16 StandardPROOptimization level().
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |