1 /***************************************************************************//**
2 * \file cy_crypto_core_crc.h
3 * \version 2.90
4 *
5 * \brief
6 * This file provides the headers for CRC API
7 * in the Crypto driver.
8 *
9 ********************************************************************************
10 * \copyright
11 * Copyright (c) (2020-2022), Cypress Semiconductor Corporation (an Infineon company) or
12 * an affiliate of Cypress Semiconductor Corporation.
13 * SPDX-License-Identifier: Apache-2.0
14 *
15 * Licensed under the Apache License, Version 2.0 (the "License");
16 * you may not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
18 *
19 * http://www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
26 *******************************************************************************/
27
28
29 #if !defined (CY_CRYPTO_CORE_CRC_H)
30 #define CY_CRYPTO_CORE_CRC_H
31
32 #include "cy_device.h"
33
34 #if defined (CY_IP_MXCRYPTO)
35
36 #include "cy_crypto_common.h"
37
38 #if defined(__cplusplus)
39 extern "C" {
40 #endif
41
42 #if (CPUSS_CRYPTO_CRC == 1) && defined(CY_CRYPTO_CFG_CRC_C)
43
44 #include "cy_crypto_core_crc_v1.h"
45 #include "cy_crypto_core_crc_v2.h"
46
47 typedef cy_en_crypto_status_t (*cy_crypto_crc_init_func_t)(CRYPTO_Type *base,
48 uint32_t polynomial,
49 uint32_t dataReverse,
50 uint32_t dataXor,
51 uint32_t remReverse,
52 uint32_t remXor);
53
54 typedef cy_en_crypto_status_t (*cy_crypto_crc_func_t)(CRYPTO_Type *base,
55 uint32_t *crc,
56 void const *data,
57 uint32_t dataSize,
58 uint32_t lfsrInitState);
59
60 /**
61 * \addtogroup group_crypto_lld_crc_functions
62 * \{
63 */
64
65 /*******************************************************************************
66 * Function Name: Cy_Crypto_Core_Crc_Init
67 ****************************************************************************//**
68 *
69 * Initializes the CRC calculation.
70 *
71 * Call to initialize this encryption technique before using any associated
72 * functions. You must initialize this technique again after using any other
73 * encryption technique.
74 *
75 * Below is the table with known polynomials with different parameters and their
76 * calculated CRCs from the string <b>"123456789"</b>:
77 * | Name | Width | Poly | Init | Data Rev | Data XOR | Rem Rev | Rem XOR | Expected CRC |
78 * |:-------------------|:-----:|:----------:|:----------:|:--------:|:--------:|:-------:|:----------:|:------------:|
79 * | CRC-3 / ROHC | 3 | 0x3 | 0x7 | 1 | 0 | 1 | 0x0 | 0x6 |
80 * | CRC-4 / ITU | 4 | 0x3 | 0x0 | 1 | 0 | 1 | 0x0 | 0x7 |
81 * | CRC-5 / EPC | 5 | 0x9 | 0x9 | 0 | 0 | 0 | 0x0 | 0x0 |
82 * | CRC-5 / ITU | 5 | 0x15 | 0x0 | 1 | 0 | 1 | 0x0 | 0x7 |
83 * | CRC-5 / USB | 5 | 0x5 | 0x1F | 1 | 0 | 1 | 0x1F | 0x19 |
84 * | CRC-6 / CDMA2000-A | 6 | 0x27 | 0x3F | 0 | 0 | 0 | 0x0 | 0xD |
85 * | CRC-6 / CDMA2000-B | 6 | 0x7 | 0x3F | 0 | 0 | 0 | 0x0 | 0x3B |
86 * | CRC-6 / DARC | 6 | 0x19 | 0x0 | 1 | 0 | 1 | 0x0 | 0x26 |
87 * | CRC-6 / ITU | 6 | 0x3 | 0x0 | 1 | 0 | 1 | 0x0 | 0x6 |
88 * | CRC-7 | 7 | 0x9 | 0x0 | 0 | 0 | 0 | 0x0 | 0x75 |
89 * | CRC-7 / ROHC | 7 | 0x4F | 0x7F | 1 | 0 | 1 | 0x0 | 0x53 |
90 * | CRC-8 | 8 | 0x7 | 0x0 | 0 | 0 | 0 | 0x0 | 0xF4 |
91 * | CRC-8 / CDMA2000 | 8 | 0x9B | 0xFF | 0 | 0 | 0 | 0x0 | 0xDA |
92 * | CRC-8 / DARC | 8 | 0x39 | 0x0 | 1 | 0 | 1 | 0x0 | 0x15 |
93 * | CRC-8 / DVB-S2 | 8 | 0xD5 | 0x0 | 0 | 0 | 0 | 0x0 | 0xBC |
94 * | CRC-8 / EBU | 8 | 0x1D | 0xFF | 1 | 0 | 1 | 0x0 | 0x97 |
95 * | CRC-8 / I-CODE | 8 | 0x1D | 0xFD | 0 | 0 | 0 | 0x0 | 0x7E |
96 * | CRC-8 / ITU | 8 | 0x7 | 0x0 | 0 | 0 | 0 | 0x55 | 0xA1 |
97 * | CRC-8 / MAXIM | 8 | 0x31 | 0x0 | 1 | 0 | 1 | 0x0 | 0xA1 |
98 * | CRC-8 / ROHC | 8 | 0x7 | 0xFF | 1 | 0 | 1 | 0x0 | 0xD0 |
99 * | CRC-8 / WCDMA | 8 | 0x9B | 0x0 | 1 | 0 | 1 | 0x0 | 0x25 |
100 * | CRC-10 | 10 | 0x233 | 0x0 | 0 | 0 | 0 | 0x0 | 0x199 |
101 * | CRC-10 / CDMA2000 | 10 | 0x3D9 | 0x3FF | 0 | 0 | 0 | 0x0 | 0x233 |
102 * | CRC-11 | 11 | 0x385 | 0x1A | 0 | 0 | 0 | 0x0 | 0x5A3 |
103 * | CRC-12 / 3GPP | 12 | 0x80F | 0x0 | 0 | 0 | 1 | 0x0 | 0xDAF |
104 * | CRC-12 / CDMA2000 | 12 | 0xF13 | 0xFFF | 0 | 0 | 0 | 0x0 | 0xD4D |
105 * | CRC-12 / DECT | 12 | 0x80F | 0x0 | 0 | 0 | 0 | 0x0 | 0xF5B |
106 * | CRC-13 / BBC | 13 | 0x1CF5 | 0x0 | 0 | 0 | 0 | 0x0 | 0x4FA |
107 * | CRC-14 / DARC | 14 | 0x805 | 0x0 | 1 | 0 | 1 | 0x0 | 0x82D |
108 * | CRC-15 | 15 | 0x4599 | 0x0 | 0 | 0 | 0 | 0x0 | 0x59E |
109 * | CRC-15 / MPT1327 | 15 | 0x6815 | 0x0 | 0 | 0 | 0 | 0x1 | 0x2566 |
110 * | CRC-24 | 24 | 0x0864CFB | 0x00B704CE | 0 | 0 | 0 | 0x0 | 0x21CF02 |
111 * | CRC-24 / FLEXRAY-A | 24 | 0x05D6DCB | 0x00FEDCBA | 0 | 0 | 0 | 0x0 | 0x7979BD |
112 * | CRC-24 / FLEXRAY-B | 24 | 0x05D6DCB | 0x00ABCDEF | 0 | 0 | 0 | 0x0 | 0x1F23B8 |
113 * | CRC-31 / PHILIPS | 31 | 0x4C11DB7 | 0x7FFFFFFF | 0 | 0 | 0 | 0x7FFFFFFF | 0xCE9E46C |
114 * | CRC-16 / ARC | 16 | 0x8005 | 0x0000 | 1 | 0 | 1 | 0x0000 | 0xBB3D |
115 * | CRC-16 / AUG-CCITT | 16 | 0x1021 | 0x1D0F | 0 | 0 | 0 | 0x0000 | 0xE5CC |
116 * | CRC-16 / BUYPASS | 16 | 0x8005 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0xFEE8 |
117 * | CRC-16 / CCITT-0 | 16 | 0x1021 | 0xFFFF | 0 | 0 | 0 | 0x0000 | 0x29B1 |
118 * | CRC-16 / CDMA2000 | 16 | 0xC867 | 0xFFFF | 0 | 0 | 0 | 0x0000 | 0x4C06 |
119 * | CRC-16 / DDS-110 | 16 | 0x8005 | 0x800D | 0 | 0 | 0 | 0x0000 | 0x9ECF |
120 * | CRC-16 / DECT-R | 16 | 0x0589 | 0x0000 | 0 | 0 | 0 | 0x0001 | 0x007E |
121 * | CRC-16 / DECT-X | 16 | 0x0589 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0x007F |
122 * | CRC-16 / DNP | 16 | 0x3D65 | 0x0000 | 1 | 0 | 1 | 0xFFFF | 0xEA82 |
123 * | CRC-16 / EN-13757 | 16 | 0x3D65 | 0x0000 | 0 | 0 | 0 | 0xFFFF | 0xC2B7 |
124 * | CRC-16 / GENIBUS | 16 | 0x1021 | 0xFFFF | 0 | 0 | 0 | 0xFFFF | 0xD64E |
125 * | CRC-16 / MAXIM | 16 | 0x8005 | 0x0000 | 1 | 0 | 1 | 0xFFFF | 0x44C2 |
126 * | CRC-16 / MCRF4XX | 16 | 0x1021 | 0xFFFF | 1 | 0 | 1 | 0x0000 | 0x6F91 |
127 * | CRC-16 / RIELLO | 16 | 0x1021 | 0xB2AA | 1 | 0 | 1 | 0x0000 | 0x63D0 |
128 * | CRC-16 / T10-DIF | 16 | 0x8BB7 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0xD0DB |
129 * | CRC-16 / TELEDISK | 16 | 0xA097 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0x0FB3 |
130 * | CRC-16 / TMS37157 | 16 | 0x1021 | 0x89EC | 1 | 0 | 1 | 0x0000 | 0x26B1 |
131 * | CRC-16 / USB | 16 | 0x8005 | 0xFFFF | 1 | 0 | 1 | 0xFFFF | 0xB4C8 |
132 * | CRC-A | 16 | 0x1021 | 0xC6C6 | 1 | 0 | 1 | 0x0000 | 0xBF05 |
133 * | CRC-16 / KERMIT | 16 | 0x1021 | 0x0000 | 1 | 0 | 1 | 0x0000 | 0x2189 |
134 * | CRC-16 / MODBUS | 16 | 0x8005 | 0xFFFF | 1 | 0 | 1 | 0x0000 | 0x4B37 |
135 * | CRC-16 / X-25 | 16 | 0x1021 | 0xFFFF | 1 | 0 | 1 | 0xFFFF | 0x906E |
136 * | CRC-16 / XMODEM | 16 | 0x1021 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0x31C3 |
137 * | CRC-32 | 32 | 0x04C11DB7 | 0xFFFFFFFF | 1 | 0 | 1 | 0xFFFFFFFF | 0xCBF43926 |
138 * | CRC-32 / BZIP2 | 32 | 0x04C11DB7 | 0xFFFFFFFF | 0 | 0 | 0 | 0xFFFFFFFF | 0xFC891918 |
139 * | CRC-32C | 32 | 0x1EDC6F41 | 0xFFFFFFFF | 1 | 0 | 1 | 0xFFFFFFFF | 0xE3069283 |
140 * | CRC-32D | 32 | 0xA833982B | 0xFFFFFFFF | 1 | 0 | 1 | 0xFFFFFFFF | 0x87315576 |
141 * | CRC-32 / MPEG-2 | 32 | 0x04C11DB7 | 0xFFFFFFFF | 0 | 0 | 0 | 0x00000000 | 0x0376E6E7 |
142 * | CRC-32 / POSIX | 32 | 0x04C11DB7 | 0x00000000 | 0 | 0 | 0 | 0xFFFFFFFF | 0x765E7680 |
143 * | CRC-32Q | 32 | 0x814141AB | 0x00000000 | 0 | 0 | 0 | 0x00000000 | 0x3010BF7F |
144 * | CRC-32 / JAMCRC | 32 | 0x04C11DB7 | 0xFFFFFFFF | 1 | 0 | 1 | 0x00000000 | 0x340BC6D9 |
145 * | CRC-32 / XFER | 32 | 0x000000AF | 0x00000000 | 0 | 0 | 0 | 0x00000000 | 0xBD0BE338 |
146 *
147 * \param base
148 * The pointer to the CRYPTO instance.
149 *
150 * \param polynomial
151 * The polynomial (specified using 32 bits) used in the computing CRC.
152 *
153 * \param dataReverse
154 * The order in which data bytes are processed. 0 - MSB first; 1- LSB first.
155 *
156 * \param dataXor
157 * The byte mask for XORing data.
158 *
159 * \param remReverse
160 * A remainder reverse: 0 means the remainder is not reversed. 1 means reversed.
161 *
162 * \param remXor
163 * Specifies the mask with which the LFSR32 register is XORed to produce a remainder.
164 *
165 * \return
166 * \ref cy_en_crypto_status_t
167 *
168 *******************************************************************************/
Cy_Crypto_Core_Crc_Init(CRYPTO_Type * base,uint32_t polynomial,uint32_t dataReverse,uint32_t dataXor,uint32_t remReverse,uint32_t remXor)169 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_Init(CRYPTO_Type *base,
170 uint32_t polynomial,
171 uint32_t dataReverse,
172 uint32_t dataXor,
173 uint32_t remReverse,
174 uint32_t remXor)
175 {
176 cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED;
177
178 if (CY_CRYPTO_V1)
179 {
180 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
181 tmpResult = Cy_Crypto_Core_V1_Crc_Init(base, polynomial, dataReverse, dataXor, remReverse, remXor);
182 #endif /* defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */
183 }
184 else
185 {
186 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
187 tmpResult = Cy_Crypto_Core_V2_Crc_Init(base, polynomial, dataReverse, dataXor, remReverse, remXor);
188 #endif /* defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
189 }
190
191 return tmpResult;
192 }
193
194 /*******************************************************************************
195 * Function Name: Cy_Crypto_Core_Crc
196 ****************************************************************************//**
197 *
198 * Performs the CRC calculation on a message.
199 *
200 * \param base
201 * The pointer to the CRYPTO instance.
202 *
203 * \param crc
204 * The pointer to a computed CRC value. Must be 4-byte aligned.
205 *
206 * \param data
207 * The pointer to the message whose CRC is being computed.
208 *
209 * \param dataSize
210 * The size of a message in bytes.
211 *
212 * \param lfsrInitState
213 * The initial state of the LFSR.
214 *
215 * \return
216 * \ref cy_en_crypto_status_t
217 *
218 *******************************************************************************/
Cy_Crypto_Core_Crc(CRYPTO_Type * base,uint32_t * crc,void const * data,uint32_t dataSize,uint32_t lfsrInitState)219 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc(CRYPTO_Type *base,
220 uint32_t *crc,
221 void const *data,
222 uint32_t dataSize,
223 uint32_t lfsrInitState)
224 {
225 cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED;
226
227 if (CY_CRYPTO_V1)
228 {
229 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
230 tmpResult = Cy_Crypto_Core_V1_Crc(base, crc, data, dataSize, lfsrInitState);
231 #endif /* defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */
232 }
233 else
234 {
235 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
236 tmpResult = Cy_Crypto_Core_V2_Crc(base, crc, data, dataSize, lfsrInitState);
237 #endif /* defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
238 }
239
240 return tmpResult;
241 }
242
243 /*******************************************************************************
244 * Function Name: Cy_Crypto_Core_Crc_CalcInit
245 ****************************************************************************//**
246 *
247 * Initializes the CRC calculation.
248 *
249 * \param base
250 * The pointer to the CRYPTO instance.
251 *
252 * \param width
253 * The CRC width in bits.
254 *
255 * \param polynomial
256 * The polynomial (specified using 32 bits) used in the computing CRC.
257 *
258 * \param dataReverse
259 * The order in which data bytes are processed. 0 - MSB first; 1 - LSB first.
260 *
261 * \param dataXor
262 * The byte mask for XORing data
263 *
264 * \param remReverse
265 * A remainder reverse: 0 means the remainder is not reversed. 1 means reversed.
266 *
267 * \param remXor
268 * Specifies the mask with which the LFSR32 register is XORed to produce a remainder.
269 *
270 * \param lfsrInitState
271 * The initial state of the LFSR.
272 *
273 * \return
274 * \ref cy_en_crypto_status_t
275 *
276 * \funcusage
277 * \snippet crypto/snippet/main.c snippet_myCryptoCoreCrcUse
278 *
279 *******************************************************************************/
Cy_Crypto_Core_Crc_CalcInit(CRYPTO_Type * base,uint32_t width,uint32_t polynomial,uint32_t dataReverse,uint32_t dataXor,uint32_t remReverse,uint32_t remXor,uint32_t lfsrInitState)280 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcInit(CRYPTO_Type *base,
281 uint32_t width,
282 uint32_t polynomial,
283 uint32_t dataReverse,
284 uint32_t dataXor,
285 uint32_t remReverse,
286 uint32_t remXor,
287 uint32_t lfsrInitState)
288 {
289 cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED;
290
291 if (CY_CRYPTO_V1)
292 {
293 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
294 tmpResult = Cy_Crypto_Core_V1_Crc_CalcInit(base, width, polynomial, dataReverse, dataXor,
295 remReverse, remXor, lfsrInitState);
296 #endif /* defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */
297 }
298 else
299 {
300 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
301 tmpResult = Cy_Crypto_Core_V2_Crc_CalcInit(base, width, polynomial, dataReverse, dataXor,
302 remReverse, remXor, lfsrInitState);
303 #endif /* defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
304 }
305
306 return tmpResult;
307 }
308
309 /*******************************************************************************
310 * Function Name: Cy_Crypto_Core_Crc_CalcStart
311 ****************************************************************************//**
312 *
313 * Prepares the CRC calculation by setting an initial seed value.
314 *
315 * \param base
316 * The pointer to the CRYPTO instance.
317 *
318 * \param width
319 * The CRC width in bits.
320 *
321 * \param lfsrInitState
322 * The initial state of the LFSR.
323 *
324 * \return
325 * \ref cy_en_crypto_status_t
326 *
327 *******************************************************************************/
Cy_Crypto_Core_Crc_CalcStart(CRYPTO_Type * base,uint32_t width,uint32_t lfsrInitState)328 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcStart(CRYPTO_Type *base,
329 uint32_t width, uint32_t lfsrInitState)
330 {
331 cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED;
332
333 if (CY_CRYPTO_V1)
334 {
335 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
336 tmpResult = Cy_Crypto_Core_V1_Crc_CalcStart(base, width, lfsrInitState);
337 #endif /* defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */
338 }
339 else
340 {
341 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
342 tmpResult = Cy_Crypto_Core_V2_Crc_CalcStart(base, width, lfsrInitState);
343 #endif /* defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
344 }
345
346 return tmpResult;
347 }
348
349 /*******************************************************************************
350 * Function Name: Cy_Crypto_Core_Crc_CalcPartial
351 ****************************************************************************//**
352 *
353 * Performs the CRC calculation of a message part.
354 *
355 * \param base
356 * The pointer to the CRYPTO instance.
357 *
358 * \param data
359 * The pointer to the message whose CRC is being computed.
360 *
361 * \param dataSize
362 * The size of a message in bytes.
363 *
364 * \return
365 * \ref cy_en_crypto_status_t
366 *
367 *******************************************************************************/
Cy_Crypto_Core_Crc_CalcPartial(CRYPTO_Type * base,void const * data,uint32_t dataSize)368 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcPartial(CRYPTO_Type *base,
369 void const *data, uint32_t dataSize)
370 {
371 cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED;
372
373 if (CY_CRYPTO_V1)
374 {
375 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
376 tmpResult = Cy_Crypto_Core_V1_Crc_CalcPartial(base, data, dataSize);
377 #endif /* defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */
378 }
379 else
380 {
381 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
382 tmpResult = Cy_Crypto_Core_V2_Crc_CalcPartial(base, data, dataSize);
383 #endif /* defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
384 }
385
386 return tmpResult;
387 }
388
389 /*******************************************************************************
390 * Function Name: Cy_Crypto_Core_Crc_CalcFinish
391 ****************************************************************************//**
392 *
393 * Finalizes the CRC calculation.
394 *
395 * \param base
396 * The pointer to the CRYPTO instance.
397 *
398 * \param width
399 * The CRC width in bits.
400 *
401 * \param crc
402 * The pointer to a computed CRC value. Must be 4-byte aligned.
403 *
404 * \return
405 * \ref cy_en_crypto_status_t
406 *
407 *******************************************************************************/
Cy_Crypto_Core_Crc_CalcFinish(CRYPTO_Type * base,uint32_t width,uint32_t * crc)408 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcFinish(CRYPTO_Type *base, uint32_t width, uint32_t *crc)
409 {
410 cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED;
411
412 if (CY_CRYPTO_V1)
413 {
414 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
415 tmpResult = Cy_Crypto_Core_V1_Crc_CalcFinish(base, width, crc);
416 #endif /* defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */
417 }
418 else
419 {
420 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
421 tmpResult = Cy_Crypto_Core_V2_Crc_CalcFinish(base, width, crc);
422 #endif /* defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
423 }
424
425 return tmpResult;
426 }
427
428 /*******************************************************************************
429 * Function Name: Cy_Crypto_Core_Crc_Calc
430 ****************************************************************************//**
431 *
432 * Performs the CRC calculation on a message.
433 *
434 * \param base
435 * The pointer to the CRYPTO instance.
436 *
437 * \param width
438 * The CRC width in bits.
439 *
440 * \param crc
441 * The pointer to a computed CRC value. Must be 4-byte aligned.
442 *
443 * \param data
444 * The pointer to the message whose CRC is being computed.
445 *
446 * \param dataSize
447 * The size of a message in bytes.
448 *
449 * \return
450 * \ref cy_en_crypto_status_t
451 *
452 * \funcusage
453 * \snippet crypto/snippet/main.c snippet_myCryptoCoreCrcUse
454 *
455 *******************************************************************************/
Cy_Crypto_Core_Crc_Calc(CRYPTO_Type * base,uint32_t width,uint32_t * crc,void const * data,uint32_t dataSize)456 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_Calc(CRYPTO_Type *base,
457 uint32_t width, uint32_t *crc,
458 void const *data, uint32_t dataSize)
459 {
460 cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED;
461
462 if (CY_CRYPTO_V1)
463 {
464 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
465 tmpResult = Cy_Crypto_Core_V1_Crc_Calc(base, width, crc, data, dataSize);
466 #endif /* defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */
467 }
468 else
469 {
470 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
471 tmpResult = Cy_Crypto_Core_V2_Crc_Calc(base, width, crc, data, dataSize);
472 #endif /* defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
473 }
474
475 return tmpResult;
476 }
477
478 /** \} group_crypto_lld_crc_functions */
479
480 #endif /* (CPUSS_CRYPTO_CRC == 1) && defined(CY_CRYPTO_CFG_CRC_C) */
481
482 #if defined(__cplusplus)
483 }
484 #endif
485
486 #endif /* CY_IP_MXCRYPTO */
487
488 #endif /* #if !defined (CY_CRYPTO_CORE_CRC_H) */
489
490
491
492 /* [] END OF FILE */
493