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

hash_common.h « Common « HASH « 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: 622034b7cc2b50fa204702d0be42aa5bbe7eae24 (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
138
139
140
141
142
143
144
145
146
/**
  ******************************************************************************
  * @file    hash_common.h
  * @author  MCD Application Team
  * @version V3.0.0
  * @date    05-June-2015
  * @brief   Provides common HASH/HMAC definitions
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Image SW License Agreement V2, (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/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

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

#ifdef __cplusplus
extern "C"
{
#endif

  /* Exported types ------------------------------------------------------------*/
  /** @addtogroup HASH
    * @{
    */

  /**
    * @brief  Enumeration of possible hash functions
    */
  typedef enum HashType_e
  {
    E_MD5,          /*!< MD5     */
    E_SHA1,         /*!< SHA-1   */
    E_SHA224,       /*!< SHA-224 */
    E_SHA256,       /*!< SHA-256 */
    E_SHA384,       /*!< SHA-384 */
    E_SHA512,       /*!< SHA-512 */
  } hashType_et;


  /**
    * @brief  Type definitation for Hash/Hmac Flags
    */

  typedef enum HashFlags_e
  {
    E_HASH_DEFAULT = (uint32_t) (0x00000000),   /*!< User Flag: No flag specified.
                                                   This is the default value that should be set to this flag  */
    E_HASH_DONT_PERFORM_KEY_SCHEDULE = (uint32_t) (0x00000001), /*!< User Flag: Used to force the init to not reperform key processing in HMAC mode. */
    E_HASH_OPERATION_COMPLETED = (uint32_t) (0x00000002),  /*!< Internal Flag: used to check that the Finish function has been already called */
    E_HASH_NO_MORE_APPEND_ALLOWED = (uint32_t) (0x00000004),  /*!< Internal Flag: it is set when the last append has been called.
                                                                Used where the append is called with an InputSize not multiple of the block size,
                                                                which means that is the last input.*/
  } HashFlags_et;

  /**
    * @brief  Structure for HASH contextlags
    */

  typedef struct
  {
    uint32_t   mContextId;   /*!<  Unique ID of this context. \b Not \b used in current implementation. */
    HashFlags_et mFlags;     /*!<  32 bit mFlags, used to perform keyschedule */
    int32_t  mTagSize;       /*!<  Size of the required Digest */
    uint8_t amBuffer[64];    /*!<  Internal: It's a buffer with the data to be hashed */
    uint32_t amCount[2];     /*!<  Internal: Keeps the count of processed bits */
    uint32_t amState[8];     /*!<  Internal: Keeps the internal state */
  }
  HASHctx_stt;
  /**
    * @brief  Structure for Large (SHA-512 based) HASH contexts
    */

  typedef struct
  {
    uint32_t   mContextId;   /*!<  Unique ID of this context. \b Not \b used in current implementation. */
    HashFlags_et mFlags;     /*!<  32 bit mFlags, used to perform keyschedule */
    int32_t  mTagSize;       /*!<  Size of the required Digest */
    uint8_t amBuffer[128];    /*!<  Internal: It's a buffer with the data to be hashed */
    uint32_t amCount[2];     /*!<  Internal: Keeps the count of processed bits */
    uint64_t amState[8];     /*!<  Internal: Keeps the internal state */
  }
  HASHLctx_stt;


  /**
    * @brief  Structure for HMAC context
    */
  typedef struct
  {
    uint32_t   mContextId;   /*!< Unique ID of this context. \b Not \b used in current implementation. */
    HashFlags_et mFlags;     /*!< 32 bit mFlags, used to perform keyschedule */
    int32_t  mTagSize;       /*!< Size of the required Digest */
    const uint8_t  *pmKey;   /*!< Pointer for the HMAC key */
    int32_t  mKeySize;       /*!< Size, in uint8_t (bytes) of the HMAC key */
    uint8_t amKey[64];       /*!< Internal: The HMAC key */
    HASHctx_stt mHASHctx_st; /*!< Internal: Hash Context */
  }
  HMACctx_stt;
  /**
    * @brief  Structure for Large (SHA-512 based) HMAC context
    */
  typedef struct
  {
    uint32_t   mContextId;   /*!< Unique ID of this context. \b Not \b used in current implementation. */
    HashFlags_et mFlags;     /*!< 32 bit mFlags, used to perform keyschedule */
    int32_t  mTagSize;       /*!< Size of the required Digest */
    const uint8_t  *pmKey;   /*!< Pointer for the HMAC key */
    int32_t  mKeySize;       /*!< Size, in uint8_t (bytes) of the HMAC key */
    uint8_t amKey[128];       /*!< Internal: The HMAC key */
    HASHLctx_stt mHASHctx_st; /*!< Internal: Hash Context */
  }
  HMACLctx_stt;

  /**
    * @}
    */

#ifdef __cplusplus
}
#endif

#endif   /*__CRL_HASH_COMMON_H__*/

/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */



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