Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rng.h « RNG « Inc « cryptographic « ble « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 96a45696752b56d2b8f4f76a0f3efdc2f23e23bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**
  ******************************************************************************
  * @file    rng.h
  * @author  MCD Application Team
  * @brief   Provides the random engine to the crypto library
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Image license SLA0044,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        http://www.st.com/SLA0044
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CRL_RNG_H__
#define __CRL_RNG_H__

#ifdef __cplusplus
extern "C"
{
#endif

  /* Includes ------------------------------------------------------------------*/
#include "DRBG_AES128/drbg.h"


  /** @addtogroup RNG
    * @{
    */
  /* Exported constants ------------------------------------------------------- */

  /* Exported types ----------------------------------------------------------- */
  /**
    * @brief  Structure that contains the RNG stat
    */
  typedef struct
  {
    uint8_t mRNGstate[CRL_DRBG_AES128_STATE_SIZE];  /*!< Underlying DRBG context. It is initialized by \ref RNGinit */

    int32_t mDRBGtype;     /*!< Used to check if the random state has been mFlag */

    uint32_t mFlag;        /*!< Used to check if the random state has been mFlag */
  }
  RNGstate_stt;


  /**
    * @brief  Structure used by RNGinit to initialize a DRBG
    */
  typedef struct
  {

    uint8_t* pmEntropyData;   /*!< The entropy data input */

    int32_t mEntropyDataSize; /*!< Size of the entropy data input */

    uint8_t* pmNonce;         /*!< The Nonce data */

    int32_t mNonceSize;       /*!< Size of the Nonce */

    uint8_t* pmPersData;      /*!< Personalization String */

    int32_t mPersDataSize;    /*!< Size of personalization string*/
  }
  RNGinitInput_stt;


  /**
    * @brief  Structure used by RNGreseed to reseed a DRBG
    */
  typedef struct
  {

    uint8_t* pmEntropyData;   /*!< The entropy data input */

    int32_t mEntropyDataSize; /*!< Size of the entropy data input */

    uint8_t* pmAddInput;      /*!< Additional input */

    int32_t mAddInputSize;    /*!< Size of additional input */
  }
  RNGreInput_stt;

  /**
    * @brief  Structure used by RNGgenBytes or RNGgenWords to provide the optional additional input
    */
  typedef struct
  {
    uint8_t* pmAddInput;      /*!< Additional input */

    int32_t mAddInputSize;    /*!< Size of additional input */
  }
  RNGaddInput_stt;


  /* Exported functions ------------------------------------------------------- */
  /* Reseed random **************************************************************/
  int32_t RNGreseed   (const RNGreInput_stt *P_pInputData, \
                       RNGstate_stt *P_pRandomState);

  /* Initialize random **********************************************************/
  int32_t RNGinit    (const RNGinitInput_stt *P_pInputData, \
                      RNGstate_stt *P_pRandomState);
  /* Free random ****************************************************************/
  int32_t RNGfree    (RNGstate_stt *P_pRandomState );

  /* Generate random octets to a buffer *****************************************/
  int32_t RNGgenBytes(RNGstate_stt *P_pRandomState,      \
                      const RNGaddInput_stt *P_pAddInput, \
                      uint8_t *P_pOutput,                \
                      int32_t P_OutLen);

  /* Return a random int32_t ****************************************************/
  int32_t RNGgenWords(RNGstate_stt *P_pRandomState,      \
                      const RNGaddInput_stt *P_pAddInput, \
                      uint32_t *P_pWordBuf,              \
                      int32_t P_BufSize);

#ifdef __cplusplus
}
#endif

/**
 * @}
 */


#endif /* __CRL_RAND_H__ */


/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/