GenerateRandomDWORD Function

Microchip TCP/IP Stack

Microchip TCP/IP Stack Help
GenerateRandomDWORD Function
C
DWORD GenerateRandomDWORD();
Description

This function generates a random 32-bit integer. It collects randomness by comparing the A/D converter's internal R/C oscillator clock with our main system clock. By passing collected entropy to the LFSRSeedRand()/LFSRRand() functions, the output is normalized (deskewed) in the hopes of meeting statistical randomness tests.

Preconditions

None

Returns

Random 32-bit number.

Side Effects

This function uses the A/D converter (and so you must disable interrupts if you use the A/D converted in your ISR). The LFSRRand() function will be reseeded, and Timer0 (PIC18) and Timer1 (PIC24, dsPIC, and PIC32) will be used. TMR#H:TMR#L will have a new value. Note that this is the same timer used by the Tick module.

Remarks

This function times out after 1 second of attempting to generate the random DWORD. In such a case, the output may not be truly random. Typically, this function executes in around 500,000 instruction cycles. 

The intent of this function is to produce statistically random and cryptographically secure random number. Whether or not this is true on all (or any) devices/voltages/temperatures is not tested.

Microchip TCP/IP Stack 5.42.08 - June 15, 2013
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.