le_rand.h

Go to the documentation of this file.
1 /**
2  * @page c_rand Random Number API
3  *
4  * @ref le_rand.h "API Reference"
5  *
6  * <HR>
7  *
8  * This Random Number API is a wrapper around a cryptographic pseudo-random number generator (CPRNG)
9  * that is properly seeded with entropy.
10  *
11  * The random numbers returned by this API may be used for cryptographic purposes such as encryption
12  * keys, initialization vectors, etc.
13  *
14  * <HR>
15  *
16  * Copyright (C) Sierra Wireless Inc.
17  */
18 
19 //--------------------------------------------------------------------------------------------------
20 /** @file le_rand.h
21  *
22  * Legato @ref c_rand include file.
23  *
24  * Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
25  */
26 
27 #ifndef LEGATO_RAND_INCLUDE_GUARD
28 #define LEGATO_RAND_INCLUDE_GUARD
29 
30 
31 //--------------------------------------------------------------------------------------------------
32 /**
33  * Get a random number within the specified range, min to max inclusive.
34  *
35  * @warning The max value must be greater than the min value, if not this function will log the
36  * error and kill the calling process.
37  *
38  * @return The random number.
39  */
40 //--------------------------------------------------------------------------------------------------
41 uint32_t le_rand_GetNumBetween
42 (
43  uint32_t min, ///< [IN] Minimum value in range (inclusive).
44  uint32_t max ///< [IN] Maximum value in range (inclusive).
45 );
46 
47 
48 //--------------------------------------------------------------------------------------------------
49 /**
50  * Get a buffer of random numbers.
51  */
52 //--------------------------------------------------------------------------------------------------
54 (
55  uint8_t* bufPtr, ///< [OUT] Buffer to store the random numbers in.
56  size_t bufSize ///< [IN] Number of random numbers to get.
57 );
58 
59 
60 #endif // LEGATO_RAND_INCLUDE_GUARD
uint32_t le_rand_GetNumBetween(uint32_t min, uint32_t max)
void le_rand_GetBuffer(uint8_t *bufPtr, size_t bufSize)