ipconfigRAND32()

Where might I find the source code for ipconfigRAND32() ? Randy

ipconfigRAND32()

Hello Randy, the creator of the application is supposed to provide this macro in FreeRTOSIPConfig.h, often like this: ~~~ extern uint32_t ulRand(); #define ipconfigRAND32() ulRand() ~~~ ipconfigRAND32() is supposed to return a 32-bit value, and it is important that after every reboot of the device, it comes up with a different initial number. Note that when it returns a 0, the library will assume that the RNG is broken, and you can not connect anymore. Zero is a possible random number, but historically, a zero was considered as a failure. Keep that in mind: do not return a zero unless the RNG is broken. It is good to use a RNG module in the hardware, if available. There is also a good implementation within the AWS/FreeRTOS repository here Look for the function uint32_t ulRand( void ). If your application doesn’t care about safety ( LAN-only, educational or hobby purposes ), you could use the standard C rand() function: ~~~c uint32t ulRand() { /* An unsafe example of a 32-bit random number generator. */ /* Assuming rand() returns a 15-bit number. */ uint32t ulResult = ( ( ( ( uint32t ) rand() ) & 0x7fffuL ) ) | ( ( ( ( uint32t ) rand() ) & 0x7fffuL ) << 15 ) | ( ( ( ( uint32_t ) rand() ) & 0x0003uL ) << 30 ); return ulResult; } ~~~ The thing is of course is that the behaviour of TCP/UDP must be unpredictable: the port numbers must be chosen randomly, and also the initial sequence numbers of the TCP packets must start with a random number. The same for the 16-bit ID’s as in the PING and DNS protocols. Mind you, there is a second function needed when you use the TCP-protocol: ~~~c uint32t ulApplicationGetNextSequenceNumber( uint32t ulSourceAddress, uint16t usSourcePort, uint32t ulDestinationAddress, uint16_t usDestinationPort ); ~~~ Of which you also find a cryptographic implementation in iotsecuresockets.c Or, a simpler and less secure implementation would just return a random 32-bit number: ~~~c uint32t ulApplicationGetNextSequenceNumber( uint32t ulSourceAddress, uint16t usSourcePort, uint32t ulDestinationAddress, uint16_t usDestinationPort ) { ( void ) ulSourceAddress; ( void ) usSourcePort; ( void ) ulDestinationAddress; ( void ) usDestinationPort; ulRand(); } ~~~

ipconfigRAND32()

On 8/24/2019 8:19 PM, Hein Tibosch wrote:
Hello Randy, the creator of the application is supposed to provide this macro in |FreeRTOSIPConfig.h|, often like this:
extern uint32_t ulRand();
#define ipconfigRAND32() ulRand()
If you are creating a product device that is intended to be secure then ulRand() should return a true random number, which normally requires hardware support (TRNG peripheral as mentioned in Hein’s reply), so the implementation of ipconfigRAND32() for production hardware is very much dependent on the random number generation facilities provided on your chosen MCU.

ipconfigRAND32()

Richard:Thanks. Randy
On Saturday, August 24, 2019, 10:30:51 PM CDT, Richard Barry wrote:  
On 8/24/2019 8:19 PM, Hein Tibosch wrote: Hello Randy, the creator of the application is supposed to provide this macro in |FreeRTOSIPConfig.h|, often like this: extern uint32_t ulRand();

define ipconfigRAND32() ulRand()

If you are creating a product device that is intended to be secure then ulRand() should return a true random number, which normally requires hardware support (TRNG peripheral as mentioned in Hein’s reply), so the implementation of ipconfigRAND32() for production hardware is very much dependent on the random number generation facilities provided on your chosen MCU. ipconfigRAND32() Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/freertos/discussion/382005/ To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/