SHA2.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2024, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!****************************************************************************
33  * @file SHA2.h
34  *
35  * @brief SHA2 driver header
36  *
37  * @anchor ti_drivers_SHA2_Overview
38  * # Overview #
39  *
40  * SHA2 (Secure Hash Algorithm 2) is a cryptographic hashing algorithm that
41  * maps an input of arbitrary length to a fixed-length output with negligible
42  * probability of collision. A collision would occur when two different inputs
43  * map to the same output.
44  *
45  * It is not currently technologically feasible to derive an input from
46  * the hash digest (output) itself.
47  *
48  * Hashes are often used to ensure the integrity of messages. They are also
49  * used to as constituent parts of more complicated cryptographic schemes.
50  * HMAC is a message authentication code that is based on hash functions such
51  * as SHA2 rather than a block cipher.
52  * Hashes may themselves be used as or form a part of key derivation functions
53  * used to derive symmetric keys from sources of entropy such as an Elliptic
54  * Curve Diffie-Helman key exchange (ECDH).
55  *
56  * SHA2 is not actually a single algorithm, but a suite of similar algorithms
57  * that produce hash digests of different lengths. 224, 256, 384, and 512-bit
58  * outputs are available.
59  *
60  * "Hash" may refer to either the process of hashing when used as a verb and
61  * the output digest when used as a noun.
62  *
63  * @anchor ti_drivers_SHA2_Usage
64  * # Usage #
65  *
66  * Before starting a SHA2 operation, the application must do the following:
67  * - Call #SHA2_init() to initialize the driver
68  * - Call #SHA2_Params_init() to initialize the SHA2_Params to default values.
69  * - Modify the #SHA2_Params as desired
70  * - Call #SHA2_open() to open an instance of the driver
71  *
72  * There are two general ways to execute a SHA2 operation:
73  *
74  * - one-step (in one operation)
75  * - multi-step (multiple partial operations)
76 
77  * @anchor ti_drivers_SHA2_Synopsis
78  * # Synopsis
79  *
80  * @anchor ti_drivers_SHA2_Synopsis_Code
81  * @code
82  *
83  * // Import SHA2 Driver definitions
84  * #include <ti/drivers/SHA2.h>
85  *
86  * // Define name for SHA2 channel index
87  * #define SHA2_INSTANCE 0
88  *
89  * SHA2_init();
90  *
91  * handle = SHA2_open(SHA2_INSTANCE, NULL);
92  *
93  * // For CC27XX devices only,
94  * // Since the SHA2 driver for CC27XX relies on one HW engine (the HSM) for all of its operations
95  * // If the HSM boot up sequence fails, SHA2_open() will return NULL.
96  * if (!handle) {
97  * // Handle error
98  * }
99  *
100  * result = SHA2_hashData(handle, message, strlen(message), actualDigest);
101  *
102  * SHA2_close(handle);
103  * @endcode
104  *
105  * @anchor ti_drivers_SHA2_Examples
106  * # Examples #
107  *
108  * ## One-step hash operation #
109  *
110  * The #SHA2_hashData() function can perform a SHA2 operation in a single call.
111  * It will always use the most highly optimized routine with the least overhead and
112  * the fastest runtime. However, it requires that the entire input message is
113  * available to the function in a contiguous location at the start of the call.
114  * The single call operation is required when hashing a message with a length smaller
115  * than or equal to one hash-block length. All devices support single call operations.
116  *
117  * After a SHA2 operation completes, the application may either start
118  * another operation or close the driver by calling #SHA2_close().
119  *
120  * @code
121  * SHA2_Params params;
122  * SHA2_Handle handle;
123  * int_fast16_t result;
124  *
125  * char message[] = "A Ferengi without profit is no Ferengi at all.";
126  *
127  * uint8_t actualDigest[SHA2_DIGEST_LENGTH_BYTES_256];
128  * uint8_t expectedDigest[] = {
129  * 0x93, 0xD6, 0x5C, 0x07,
130  * 0xA6, 0x26, 0x88, 0x9C,
131  * 0x87, 0xCC, 0x82, 0x24,
132  * 0x47, 0xC6, 0xE4, 0x28,
133  * 0xC0, 0xBD, 0xC6, 0xED,
134  * 0xAA, 0x8C, 0xD2, 0x53,
135  * 0x77, 0xAA, 0x73, 0x14,
136  * 0xA3, 0xE2, 0xDE, 0x43
137  * };
138  *
139  * SHA2_init();
140  *
141  * SHA2_Params_init(&params);
142  * params.returnBehavior = SHA2_RETURN_BEHAVIOR_BLOCKING;
143  * handle = SHA2_open(0, &params);
144  * assert(handle != NULL);
145  *
146  * result = SHA2_hashData(handle, message, strlen(message), actualDigest);
147  * assert(result == SHA2_STATUS_SUCCESS);
148  *
149  * result = memcmp(actualDigest, expectedDigest, SHA2_DIGEST_LENGTH_BYTES_256);
150  * assert(result == 0);
151  *
152  * SHA2_close(handle);
153  * @endcode
154  *
155  * ## Partial hash operation #
156  *
157  * When trying to operate on data that is too large to fit into available memory,
158  * partial processing is more advisable. The segments are processed with
159  * #SHA2_addData() whereas the final digest is computed by #SHA2_finalize().
160  *
161  * @code
162  * SHA2_Handle handle;
163  * int_fast16_t result;
164  * SHA2_Params params;
165  *
166  * const char message[] =
167  * "Premature optimization is the root of all evil (or at least most of it) in programming.";
168  *
169  * uint8_t actualDigest[SHA2_DIGEST_LENGTH_BYTES_256];
170  * uint8_t expectedDigest[] = {
171  * 0xF2, 0x6A, 0xFF, 0x01,
172  * 0x11, 0x6B, 0xF6, 0x77,
173  * 0x63, 0x91, 0xFE, 0xD9,
174  * 0x47, 0x56, 0x99, 0xB2,
175  * 0xAD, 0x7D, 0x64, 0x16,
176  * 0xF7, 0x40, 0x1A, 0x5B,
177  * 0xCC, 0xC7, 0x08, 0x3D,
178  * 0xE8, 0x6B, 0x35, 0x6D,
179  * };
180  *
181  * SHA2_init();
182  *
183  * SHA2_Params_init(&params);
184  * params.returnBehavior = SHA2_RETURN_BEHAVIOR_BLOCKING;
185  * handle = SHA2_open(0, &params);
186  * assert(handle != NULL);
187  *
188  * // We can configure the driver even after SHA2_open()
189  * result = SHA2_setHashType(handle, SHA2_HASH_TYPE_256);
190  * assert(result == SHA2_STATUS_SUCCESS);
191  *
192  * // Process data in chunks. The driver buffers incomplete blocks internally.
193  * result = SHA2_addData(handle, &message[0], 17);
194  * assert(result == SHA2_STATUS_SUCCESS);
195  *
196  * result = SHA2_addData(handle, &message[17], strlen(message) - 17);
197  * assert(result == SHA2_STATUS_SUCCESS);
198  *
199  * // Compute the resulting digest
200  * result = SHA2_finalize(handle, actualDigest);
201  * assert(result == SHA2_STATUS_SUCCESS);
202  *
203  * // Verify
204  * result = memcmp(actualDigest, expectedDigest, SHA2_DIGEST_LENGTH_BYTES_256);
205  * assert(result == 0);
206  *
207  * SHA2_close(handle);
208  * @endcode
209  *
210  * ## One-step HMAC operation #
211  *
212  * The #SHA2_hmac() function can perform a SHA2 operation in a single call.
213  * It will always use the most highly optimized routine with the least overhead
214  * and the fastest runtime. It requires that the entire input message is
215  * available to the function in a contiguous location at the start of the call.
216  *
217  * After a SHA2 operation completes, the application may either start
218  * another operation or close the driver by calling #SHA2_close().
219  *
220  * @code
221  * SHA2_Params params;
222  * SHA2_Handle handle;
223  * int_fast16_t result;
224  * CryptoKey hmacKey;
225  *
226  * uint8_t message[] = {
227  * 0xb1, 0x68, 0x9c, 0x25, 0x91, 0xea, 0xf3, 0xc9,
228  * 0xe6, 0x60, 0x70, 0xf8, 0xa7, 0x79, 0x54, 0xff,
229  * 0xb8, 0x17, 0x49, 0xf1, 0xb0, 0x03, 0x46, 0xf9,
230  * 0xdf, 0xe0, 0xb2, 0xee, 0x90, 0x5d, 0xcc, 0x28,
231  * 0x8b, 0xaf, 0x4a, 0x92, 0xde, 0x3f, 0x40, 0x01,
232  * 0xdd, 0x9f, 0x44, 0xc4, 0x68, 0xc3, 0xd0, 0x7d,
233  * 0x6c, 0x6e, 0xe8, 0x2f, 0xac, 0xea, 0xfc, 0x97,
234  * 0xc2, 0xfc, 0x0f, 0xc0, 0x60, 0x17, 0x19, 0xd2,
235  * 0xdc, 0xd0, 0xaa, 0x2a, 0xec, 0x92, 0xd1, 0xb0,
236  * 0xae, 0x93, 0x3c, 0x65, 0xeb, 0x06, 0xa0, 0x3c,
237  * 0x9c, 0x93, 0x5c, 0x2b, 0xad, 0x04, 0x59, 0x81,
238  * 0x02, 0x41, 0x34, 0x7a, 0xb8, 0x7e, 0x9f, 0x11,
239  * 0xad, 0xb3, 0x04, 0x15, 0x42, 0x4c, 0x6c, 0x7f,
240  * 0x5f, 0x22, 0xa0, 0x03, 0xb8, 0xab, 0x8d, 0xe5,
241  * 0x4f, 0x6d, 0xed, 0x0e, 0x3a, 0xb9, 0x24, 0x5f,
242  * 0xa7, 0x95, 0x68, 0x45, 0x1d, 0xfa, 0x25, 0x8e};
243  *
244  * // In this case, keyingMaterial is 40 bytes long. It could also be
245  * // any other length.
246  * uint8_t keyingMaterial[] = {
247  * 0x97, 0x79, 0xd9, 0x12, 0x06, 0x42, 0x79, 0x7f,
248  * 0x17, 0x47, 0x02, 0x5d, 0x5b, 0x22, 0xb7, 0xac,
249  * 0x60, 0x7c, 0xab, 0x08, 0xe1, 0x75, 0x8f, 0x2f,
250  * 0x3a, 0x46, 0xc8, 0xbe, 0x1e, 0x25, 0xc5, 0x3b,
251  * 0x8c, 0x6a, 0x8f, 0x58, 0xff, 0xef, 0xa1, 0x76};
252  *
253  *
254  *
255  * uint8_t actualHmac[SHA2_DIGEST_LENGTH_BYTES_256];
256  * uint8_t expectedHmac[] = {
257  * 0x76, 0x9f, 0x00, 0xd3, 0xe6, 0xa6, 0xcc, 0x1f,
258  * 0xb4, 0x26, 0xa1, 0x4a, 0x4f, 0x76, 0xc6, 0x46,
259  * 0x2e, 0x61, 0x49, 0x72, 0x6e, 0x0d, 0xee, 0x0e,
260  * 0xc0, 0xcf, 0x97, 0xa1, 0x66, 0x05, 0xac, 0x8b
261  * };
262  *
263  * SHA2_init();
264  *
265  * SHA2_Params_init(&params);
266  * params.returnBehavior = SHA2_RETURN_BEHAVIOR_BLOCKING;
267  * handle = SHA2_open(0, &params);
268  * assert(handle != NULL);
269  *
270  * CryptoKeyPlaintext_initKey(&hmacKey,
271  * keyingMaterial,
272  * sizeof(keyingMaterial));
273  *
274  * result = SHA2_hmac(handle,
275  * &hmacKey,
276  * message,
277  * sizeof(message),
278  * actualHmac);
279  * assert(result == SHA2_STATUS_SUCCESS);
280  *
281  * result = memcmp(actualHmac, expectedHmac, SHA2_DIGEST_LENGTH_BYTES_256);
282  * assert(result == 0);
283  *
284  * SHA2_close(handle);
285  * @endcode
286  *
287  * ## One-step HMAC operation for CC27XX #
288  *
289  * The #SHA2_hmac() function can perform a SHA2 operation in a single call.
290  * It will always use the most highly optimized routine with the least overhead
291  * and the fastest runtime. It requires that the entire input message is
292  * available to the function in a contiguous location at the start of the call.
293  *
294  * After a SHA2 operation completes, the application may either start
295  * another operation or close the driver by calling #SHA2_close().
296  *
297  * @code
298  * SHA2_Params params;
299  * SHA2_Handle handle;
300  * int_fast16_t result;
301  * CryptoKey hmacKey;
302  *
303  * uint8_t message[] = {
304  * 0xb1, 0x68, 0x9c, 0x25, 0x91, 0xea, 0xf3, 0xc9,
305  * 0xe6, 0x60, 0x70, 0xf8, 0xa7, 0x79, 0x54, 0xff,
306  * 0xb8, 0x17, 0x49, 0xf1, 0xb0, 0x03, 0x46, 0xf9,
307  * 0xdf, 0xe0, 0xb2, 0xee, 0x90, 0x5d, 0xcc, 0x28,
308  * 0x8b, 0xaf, 0x4a, 0x92, 0xde, 0x3f, 0x40, 0x01,
309  * 0xdd, 0x9f, 0x44, 0xc4, 0x68, 0xc3, 0xd0, 0x7d,
310  * 0x6c, 0x6e, 0xe8, 0x2f, 0xac, 0xea, 0xfc, 0x97,
311  * 0xc2, 0xfc, 0x0f, 0xc0, 0x60, 0x17, 0x19, 0xd2,
312  * 0xdc, 0xd0, 0xaa, 0x2a, 0xec, 0x92, 0xd1, 0xb0,
313  * 0xae, 0x93, 0x3c, 0x65, 0xeb, 0x06, 0xa0, 0x3c,
314  * 0x9c, 0x93, 0x5c, 0x2b, 0xad, 0x04, 0x59, 0x81,
315  * 0x02, 0x41, 0x34, 0x7a, 0xb8, 0x7e, 0x9f, 0x11,
316  * 0xad, 0xb3, 0x04, 0x15, 0x42, 0x4c, 0x6c, 0x7f,
317  * 0x5f, 0x22, 0xa0, 0x03, 0xb8, 0xab, 0x8d, 0xe5,
318  * 0x4f, 0x6d, 0xed, 0x0e, 0x3a, 0xb9, 0x24, 0x5f,
319  * 0xa7, 0x95, 0x68, 0x45, 0x1d, 0xfa, 0x25, 0x8e};
320  *
321  * // In this case, keyingMaterial is 40 bytes long. It could also be
322  * // any other length.
323  * uint8_t keyingMaterial[] = {
324  * 0x97, 0x79, 0xd9, 0x12, 0x06, 0x42, 0x79, 0x7f,
325  * 0x17, 0x47, 0x02, 0x5d, 0x5b, 0x22, 0xb7, 0xac,
326  * 0x60, 0x7c, 0xab, 0x08, 0xe1, 0x75, 0x8f, 0x2f,
327  * 0x3a, 0x46, 0xc8, 0xbe, 0x1e, 0x25, 0xc5, 0x3b,
328  * 0x8c, 0x6a, 0x8f, 0x58, 0xff, 0xef, 0xa1, 0x76};
329  *
330  *
331  *
332  * uint8_t actualHmac[SHA2_DIGEST_LENGTH_BYTES_256];
333  * uint8_t expectedHmac[] = {
334  * 0x76, 0x9f, 0x00, 0xd3, 0xe6, 0xa6, 0xcc, 0x1f,
335  * 0xb4, 0x26, 0xa1, 0x4a, 0x4f, 0x76, 0xc6, 0x46,
336  * 0x2e, 0x61, 0x49, 0x72, 0x6e, 0x0d, 0xee, 0x0e,
337  * 0xc0, 0xcf, 0x97, 0xa1, 0x66, 0x05, 0xac, 0x8b
338  * };
339  *
340  * SHA2_init();
341  *
342  * SHA2_Params_init(&params);
343  * params.returnBehavior = SHA2_RETURN_BEHAVIOR_BLOCKING;
344  * handle = SHA2_open(0, &params);
345  *
346  * // For CC27XX devices only,
347  * // Since the SHA2 driver for CC27XX relies on one HW engine (the HSM) for all of its operations
348  * // If the HSM boot up sequence fails, SHA2_open() will return NULL.
349  * assert(handle != NULL);
350  *
351  * CryptoKeyPlaintextHSM_initKey(&hmacKey,
352  * keyingMaterial,
353  * sizeof(keyingMaterial));
354  *
355  * result = SHA2_hmac(handle,
356  * &hmacKey,
357  * message,
358  * sizeof(message),
359  * actualHmac);
360  * assert(result == SHA2_STATUS_SUCCESS);
361  *
362  * result = memcmp(actualHmac, expectedHmac, SHA2_DIGEST_LENGTH_BYTES_256);
363  * assert(result == 0);
364  *
365  * SHA2_close(handle);
366  * @endcode
367  */
368 
369 #ifndef ti_drivers_SHA2__include
370 #define ti_drivers_SHA2__include
371 
372 #include <stdbool.h>
373 #include <stddef.h>
374 #include <stdint.h>
375 
377 
378 #ifdef __cplusplus
379 extern "C" {
380 #endif
381 
394 #define SHA2_STATUS_RESERVED (-32)
395 
402 #define SHA2_STATUS_SUCCESS ((int_fast16_t)0)
403 
410 #define SHA2_STATUS_ERROR ((int_fast16_t)-1)
411 
420 #define SHA2_STATUS_RESOURCE_UNAVAILABLE ((int_fast16_t)-2)
421 
425 #define SHA2_STATUS_CANCELED ((int_fast16_t)-3)
426 
431 #define SHA2_STATUS_UNSUPPORTED ((int_fast16_t)-4)
432 
439 #define SHA2_STATUS_KEYSTORE_ERROR ((int_fast16_t)-5)
440 
449 #define SHA2_STATUS_DMA_ERROR ((int_fast16_t)-6)
450 
472 typedef enum
473 {
489 
493 typedef enum
494 {
499 } SHA2_HashType;
500 
504 typedef enum
505 {
511 
525 typedef enum
526 {
532 
544 typedef struct
545 {
547  void *object;
548 
550  void const *hwAttrs;
551 } SHA2_Config;
552 
557 
568 typedef void (*SHA2_CallbackFxn)(SHA2_Handle handle, int_fast16_t returnStatus);
569 
578 typedef struct
579 {
585  uint32_t timeout;
588 } SHA2_Params;
589 
598 extern const SHA2_Config SHA2_config[];
599 
607 extern const uint_least8_t SHA2_count;
608 
614 extern const SHA2_Params SHA2_defaultParams;
615 
624 void SHA2_init(void);
625 
639 
656 SHA2_Handle SHA2_open(uint_least8_t index, const SHA2_Params *params);
657 
667 void SHA2_close(SHA2_Handle handle);
668 
695 int_fast16_t SHA2_setupHmac(SHA2_Handle handle, const CryptoKey *key);
696 
731 int_fast16_t SHA2_addData(SHA2_Handle handle, const void *data, size_t length);
732 
757 int_fast16_t SHA2_finalize(SHA2_Handle handle, void *digest);
758 
784 int_fast16_t SHA2_finalizeHmac(SHA2_Handle handle, void *hmac);
785 
822 int_fast16_t SHA2_hashData(SHA2_Handle handle, const void *data, size_t dataLength, void *digest);
823 
860 int_fast16_t SHA2_hmac(SHA2_Handle handle, const CryptoKey *key, const void *data, size_t dataLength, void *hmac);
861 
873 void SHA2_reset(SHA2_Handle handle);
874 
887 int_fast16_t SHA2_cancelOperation(SHA2_Handle handle);
888 
908 int_fast16_t SHA2_setHashType(SHA2_Handle handle, SHA2_HashType type);
909 
933 SHA2_Handle SHA2_construct(SHA2_Config *config, const SHA2_Params *params);
934 
935 #ifdef __cplusplus
936 }
937 #endif
938 
939 #endif /* ti_drivers_SHA2__include */
int_fast16_t SHA2_finalizeHmac(SHA2_Handle handle, void *hmac)
Finishes an HMAC operation and writes the result to hmac.
Definition: SHA2.h:509
SHA2_Config * SHA2_Handle
A handle that is returned from an SHA2_open() call.
Definition: SHA2.h:556
ADC_Params params
Definition: Driver_Init.h:11
int_fast16_t SHA2_setupHmac(SHA2_Handle handle, const CryptoKey *key)
Starts an HMAC operation on segmented data.
The CryptoKey type is an opaque representation of a cryptographic key.
SHA2_Handle SHA2_construct(SHA2_Config *config, const SHA2_Params *params)
Constructs a new SHA2 object.
SHA2_HashType hashType
Definition: SHA2.h:580
Definition: SHA2.h:507
const SHA2_Config SHA2_config[]
Global SHA2 configuration struct.
void SHA2_reset(SHA2_Handle handle)
Clears internal buffers and aborts an ongoing SHA2 operation.
Definition: SHA2.h:527
const uint_least8_t SHA2_count
Global SHA2 configuration count.
Definition: SHA2.h:474
const SHA2_Params SHA2_defaultParams
Default SHA2_Params structure.
Definition: SHA2.h:496
Definition: SHA2.h:508
SHA2 Global configuration.
Definition: SHA2.h:544
SHA2_ReturnBehavior returnBehavior
Definition: SHA2.h:583
CryptoKey datastructure.
Definition: CryptoKey.h:208
void SHA2_init(void)
Initializes the SHA2 driver module.
Definition: SHA2.h:480
int_fast16_t SHA2_addData(SHA2_Handle handle, const void *data, size_t length)
Adds a segment of data with a length in bytes to the cryptographic hash or HMAC.
int_fast16_t SHA2_setHashType(SHA2_Handle handle, SHA2_HashType type)
Selects a new hash algorithm type.
Definition: SHA2.h:484
Definition: SHA2.h:529
void SHA2_close(SHA2_Handle handle)
Closes a SHA2 peripheral specified by handle.
Definition: SHA2.h:506
uint32_t timeout
Definition: SHA2.h:585
SHA2_Handle SHA2_open(uint_least8_t index, const SHA2_Params *params)
Initializes a SHA2 driver instance and returns a handle.
SHA2_ReturnBehavior
The way in which SHA2 function calls return after performing an operation.
Definition: SHA2.h:472
SHA2_HashType
Enum for the hash types supported by the driver.
Definition: SHA2.h:493
Definition: SHA2.h:528
SHA2_DigestLengthBytes
Enum for the hash digest lengths in bytes supported by the driver.
Definition: SHA2.h:504
int_fast16_t SHA2_finalize(SHA2_Handle handle, void *digest)
Finishes a hash operation and writes the result to digest.
Definition: SHA2.h:497
int_fast16_t SHA2_hmac(SHA2_Handle handle, const CryptoKey *key, const void *data, size_t dataLength, void *hmac)
Creates a keyed hash of data with key.
void * object
Definition: SHA2.h:547
Definition: SHA2.h:498
int_fast16_t SHA2_hashData(SHA2_Handle handle, const void *data, size_t dataLength, void *digest)
Hashes a segment of data with a size in bytes and writes the resulting hash to digest.
int_fast16_t SHA2_cancelOperation(SHA2_Handle handle)
Aborts an ongoing SHA2 operation and clears internal buffers.
Definition: SHA2.h:530
void const * hwAttrs
Definition: SHA2.h:550
SHA2_CallbackFxn callbackFxn
Definition: SHA2.h:584
SHA2 Parameters.
Definition: SHA2.h:578
void(* SHA2_CallbackFxn)(SHA2_Handle handle, int_fast16_t returnStatus)
The definition of a callback function used by the SHA2 driver when used in SHA2_RETURN_BEHAVIOR_CALLB...
Definition: SHA2.h:568
void SHA2_Params_init(SHA2_Params *params)
Initializes params with default values.
Definition: SHA2.h:495
SHA2_BlockSizeBytes
Enum for the block sizes of the algorithms.
Definition: SHA2.h:525
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale