aes256.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, 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  * --/COPYRIGHT--*/
32 #ifndef AES256_H_
33 #define AES256_H_
34 
35 //*****************************************************************************
36 //
39 //
40 //*****************************************************************************
41 
42 //*****************************************************************************
43 //
44 // If building with a C++ compiler, make all of the definitions in this header
45 // have a C binding.
46 //
47 //*****************************************************************************
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 #include <stdint.h>
54 #include <stdbool.h>
55 #include <ti/devices/msp432p4xx/inc/msp.h>
56 
57 /* Module Defines and macro for easy access */
58 #define AES256_CMSIS(x) ((AES256_Type *) x)
59 
60 //*****************************************************************************
61 //
62 // The following are deprecated values. Please refer to documentation for the
63 // correct values to use.
64 //
65 //*****************************************************************************
66 #define Key_128BIT 128
67 #define Key_192BIT 192
68 #define Key_256BIT 256
69 
70 //*****************************************************************************
71 //
72 // The following are values that can be passed to the keyLength parameter for
73 // functions: AES256_setCipherKey(), AES256_setDecipherKey(), and
74 // AES256_startSetDecipherKey().
75 //
76 //*****************************************************************************
77 #define AES256_KEYLENGTH_128BIT 128
78 #define AES256_KEYLENGTH_192BIT 192
79 #define AES256_KEYLENGTH_256BIT 256
80 
81 //*****************************************************************************
82 //
83 // The following are values that can be passed toThe following are values that
84 // can be returned by the AES256_getErrorFlagStatus() function.
85 //
86 //*****************************************************************************
87 #define AES256_ERROR_OCCURRED AES256_CTL0_ERRFG
88 #define AES256_NO_ERROR 0x00
89 
90 //*****************************************************************************
91 //
92 // The following are values that can be passed toThe following are values that
93 // can be returned by the AES256_isBusy() function.
94 //
95 //*****************************************************************************
96 #define AES256_BUSY AES256_STAT_BUSY
97 #define AES256_NOT_BUSY 0x00
98 
99 //*****************************************************************************
100 //
101 // The following are values that can be passed toThe following are values that
102 // can be returned by the AES256_getInterruptFlagStatus() function.
103 //
104 //*****************************************************************************
105 #define AES256_READY_INTERRUPT 0x01
106 #define AES256_NOTREADY_INTERRUPT 0x00
107 
108 //*****************************************************************************
109 //
110 // Prototypes for the APIs.
111 //
112 //*****************************************************************************
113 
114 //*****************************************************************************
115 //
128 //
129 //*****************************************************************************
130 extern bool AES256_setCipherKey(uint32_t moduleInstance,
131  const uint8_t *cipherKey, uint_fast16_t keyLength);
132 
133 //*****************************************************************************
134 //
147 //
148 //*****************************************************************************
149 extern void AES256_encryptData(uint32_t moduleInstance, const uint8_t *data,
150  uint8_t *encryptedData);
151 
152 //*****************************************************************************
153 //
167 //
168 //*****************************************************************************
169 extern void AES256_decryptData(uint32_t moduleInstance, const uint8_t *data,
170  uint8_t *decryptedData);
171 
172 //*****************************************************************************
173 //
189 //
190 //*****************************************************************************
191 extern bool AES256_setDecipherKey(uint32_t moduleInstance,
192  const uint8_t *cipherKey, uint_fast16_t keyLength);
193 
194 //*****************************************************************************
195 //
203 //
204 //*****************************************************************************
205 extern void AES256_clearInterruptFlag(uint32_t moduleInstance);
206 
207 //*****************************************************************************
208 //
217 //
218 //*****************************************************************************
219 extern uint32_t AES256_getInterruptFlagStatus(uint32_t moduleInstance);
220 
221 //*****************************************************************************
222 //
230 //
231 //*****************************************************************************
232 extern void AES256_enableInterrupt(uint32_t moduleInstance);
233 
234 //*****************************************************************************
235 //
243 //
244 //*****************************************************************************
245 extern void AES256_disableInterrupt(uint32_t moduleInstance);
246 
247 //*****************************************************************************
248 //
256 //
257 //*****************************************************************************
258 extern void AES256_reset(uint32_t moduleInstance);
259 
260 //*****************************************************************************
261 //
275 //
276 //*****************************************************************************
277 extern void AES256_startEncryptData(uint32_t moduleInstance,
278  const uint8_t *data);
279 
280 //*****************************************************************************
281 //
296 //
297 //*****************************************************************************
298 extern void AES256_startDecryptData(uint32_t moduleInstance,
299  const uint8_t *data);
300 
301 //*****************************************************************************
302 //
318 //
319 //*****************************************************************************
320 extern bool AES256_startSetDecipherKey(uint32_t moduleInstance,
321  const uint8_t *cipherKey, uint_fast16_t keyLength);
322 
323 //*****************************************************************************
324 //
336 //
337 //*****************************************************************************
338 extern bool AES256_getDataOut(uint32_t moduleInstance,
339  uint8_t *outputData);
340 
341 //*****************************************************************************
342 //
348 //
349 //*****************************************************************************
350 extern bool AES256_isBusy(uint32_t moduleInstance);
351 
352 //*****************************************************************************
353 //
361 //
362 //*****************************************************************************
363 extern void AES256_clearErrorFlag(uint32_t moduleInstance);
364 
365 //*****************************************************************************
366 //
375 //
376 //*****************************************************************************
377 extern uint32_t AES256_getErrorFlagStatus(uint32_t moduleInstance);
378 
379 //*****************************************************************************
380 //
395 //
396 //*****************************************************************************
397 extern void AES256_registerInterrupt(uint32_t moduleInstance,
398  void (*intHandler)(void));
399 
400 //*****************************************************************************
401 //
414 //
415 //*****************************************************************************
416 extern void AES256_unregisterInterrupt(uint32_t moduleInstance);
417 
418 //*****************************************************************************
419 //
425 //
426 //*****************************************************************************
427 extern uint32_t AES256_getInterruptStatus(uint32_t moduleInstance);
428 
429 //*****************************************************************************
430 //
431 // Mark the end of the C bindings section for C++ compilers.
432 //
433 //*****************************************************************************
434 #ifdef __cplusplus
435 }
436 #endif
437 
438 //*****************************************************************************
439 //
440 // Close the Doxygen group.
442 //
443 //*****************************************************************************
444 
445 #endif /* AES256_H_ */
446 
void AES256_startDecryptData(uint32_t moduleInstance, const uint8_t *data)
Decypts a block of data using the AES256 module.
Definition: aes256.c:238
bool AES256_setCipherKey(uint32_t moduleInstance, const uint8_t *cipherKey, uint_fast16_t keyLength)
Loads a 128, 192 or 256 bit cipher key to AES256 module.
Definition: aes256.c:36
void AES256_clearInterruptFlag(uint32_t moduleInstance)
Clears the AES256 ready interrupt flag.
Definition: aes256.c:192
void AES256_encryptData(uint32_t moduleInstance, const uint8_t *data, uint8_t *encryptedData)
Encrypts a block of data using the AES256 module.
Definition: aes256.c:77
bool AES256_isBusy(uint32_t moduleInstance)
Gets the AES256 module busy status.
Definition: aes256.c:319
bool AES256_getDataOut(uint32_t moduleInstance, uint8_t *outputData)
Reads back the output data from AES256 module.
Definition: aes256.c:299
void AES256_enableInterrupt(uint32_t moduleInstance)
Enables AES256 ready interrupt.
Definition: aes256.c:202
void AES256_registerInterrupt(uint32_t moduleInstance, void(*intHandler)(void))
Definition: aes256.c:334
bool AES256_startSetDecipherKey(uint32_t moduleInstance, const uint8_t *cipherKey, uint_fast16_t keyLength)
Sets the decipher key.
Definition: aes256.c:259
uint32_t AES256_getInterruptFlagStatus(uint32_t moduleInstance)
Gets the AES256 ready interrupt flag status.
Definition: aes256.c:197
void AES256_disableInterrupt(uint32_t moduleInstance)
Disables AES256 ready interrupt.
Definition: aes256.c:207
void AES256_decryptData(uint32_t moduleInstance, const uint8_t *data, uint8_t *decryptedData)
Decrypts a block of data using the AES256 module.
Definition: aes256.c:112
void AES256_reset(uint32_t moduleInstance)
Resets AES256 Module immediately.
Definition: aes256.c:212
bool AES256_setDecipherKey(uint32_t moduleInstance, const uint8_t *cipherKey, uint_fast16_t keyLength)
Sets the decipher key.
Definition: aes256.c:147
uint32_t AES256_getInterruptStatus(uint32_t moduleInstance)
Definition: aes256.c:346
uint32_t AES256_getErrorFlagStatus(uint32_t moduleInstance)
Gets the AES256 error flag status.
Definition: aes256.c:329
void AES256_unregisterInterrupt(uint32_t moduleInstance)
Definition: aes256.c:340
void AES256_clearErrorFlag(uint32_t moduleInstance)
Clears the AES256 error flag.
Definition: aes256.c:324
void AES256_startEncryptData(uint32_t moduleInstance, const uint8_t *data)
Starts an encryption process on the AES256 module.
Definition: aes256.c:217

Copyright 2019, Texas Instruments Incorporated