ProsecCoAP 🥂
 
Loading...
Searching...
No Matches
Functions

CoAP helper functions. More...

Functions

ErrorCode Coap::getRandomToken (size_t length, uint8_t *buffer)
 Generate a random token of the given length.
 

Detailed Description

CoAP helper functions.

Function Documentation

◆ getRandomToken()

ErrorCode Coap::getRandomToken ( size_t length,
uint8_t * buffer )

Generate a random token of the given length.

Parameters
[in]lengthThe length of the token to generate in bytes. The maximum length is COAP_MAX_TOKEN_LENGTH.
[out]bufferThe buffer to store the generated token. It must be at least length bytes long.
Returns
An error code indicating success or failure. Particularly, it returns ErrorCode::INVALID_ARGUMENT if the token length exceeds COAP_MAX_TOKEN_LENGTH.
See also
Message::addRandomToken(size_t length) for a method that generates a random token and directly adds it to a message.
Note
As per protocol specifications, a client sending a request without using Transport Layer Security SHOULD use a nontrivial, randomized token to guard against spoofing of responses.