AESGCM.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018, 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  */
307 #ifndef ti_drivers_AESGCM__include
308 #define ti_drivers_AESGCM__include
309 
310 #include <stdbool.h>
311 #include <stddef.h>
312 #include <stdint.h>
313 
315 
316 #ifdef __cplusplus
317 extern "C" {
318 #endif
319 
332 #define AESGCM_STATUS_RESERVED (-32)
333 
340 #define AESGCM_STATUS_SUCCESS (0)
341 
348 #define AESGCM_STATUS_ERROR (-1)
349 
358 #define AESGCM_STATUS_RESOURCE_UNAVAILABLE (-2)
359 
367 #define AESGCM_STATUS_MAC_INVALID (-3)
368 
372 #define AESGCM_STATUS_CANCELED (-4)
373 
378 
416 
420 typedef enum AESGCM_Mode_ {
423 } AESGCM_Mode;
424 
429 typedef struct AESGCM_Operation_ {
431  uint8_t *aad;
435  uint8_t *input;
440  uint8_t *output;
446  uint8_t *iv;
452  uint8_t *mac;
458  size_t aadLength;
462  size_t inputLength;
466  uint8_t ivLength;
469  uint8_t macLength;
477 
481 typedef enum AESGCM_OperationType_ {
485 
497 typedef struct AESGCM_Config_ {
499  void *object;
500 
502  void const *hwAttrs;
503 } AESGCM_Config;
504 
520 typedef void (*AESGCM_CallbackFxn) (AESGCM_Handle handle,
521  int_fast16_t returnValue,
522  AESGCM_Operation *operation,
523  AESGCM_OperationType operationType);
524 
533 typedef struct AESGCM_Params_ {
536  uint32_t timeout;
539  void *custom;
542 } AESGCM_Params;
543 
550 
559 void AESGCM_init(void);
560 
573 void AESGCM_Params_init(AESGCM_Params *params);
574 
592 AESGCM_Handle AESGCM_open(uint_least8_t index, AESGCM_Params *params);
593 
603 void AESGCM_close(AESGCM_Handle handle);
604 
613 void AESGCM_Operation_init(AESGCM_Operation *operationStruct);
614 
631 int_fast16_t AESGCM_oneStepEncrypt(AESGCM_Handle handle, AESGCM_Operation *operationStruct);
632 
649 int_fast16_t AESGCM_oneStepDecrypt(AESGCM_Handle handle, AESGCM_Operation *operationStruct);
650 
663 int_fast16_t AESGCM_cancelOperation(AESGCM_Handle handle);
664 
665 #ifdef __cplusplus
666 }
667 #endif
668 
669 #endif /* ti_drivers_AESGCM__include */
The CryptoKey type is an opaque representation of a cryptographic key.
size_t aadLength
Definition: AESGCM.h:458
uint8_t * mac
Definition: AESGCM.h:452
uint8_t ivLength
Definition: AESGCM.h:466
int_fast16_t AESGCM_cancelOperation(AESGCM_Handle handle)
Cancels an ongoing AESGCM operation.
struct AESGCM_Operation_ AESGCM_Operation
Struct containing the parameters required for encrypting/decrypting and authenticating/verifying a me...
Struct containing the parameters required for encrypting/decrypting and authenticating/verifying a me...
Definition: AESGCM.h:429
const AESGCM_Params AESGCM_defaultParams
Default AESGCM_Params structure.
Definition: AESGCM.h:482
CryptoKey datastructure.
Definition: CryptoKey.h:210
AESGCM Global configuration.
Definition: AESGCM.h:497
struct AESGCM_Params_ AESGCM_Params
GCM Parameters.
CryptoKey * key
Definition: AESGCM.h:430
enum AESGCM_Mode_ AESGCM_Mode
Enum for the direction of the GCM operation.
size_t inputLength
Definition: AESGCM.h:462
enum AESGCM_ReturnBehavior_ AESGCM_ReturnBehavior
The way in which GCM function calls return after performing an encryption + authentication or decrypt...
Definition: AESGCM.h:422
Definition: AESGCM.h:421
int_fast16_t AESGCM_oneStepEncrypt(AESGCM_Handle handle, AESGCM_Operation *operationStruct)
Function to perform an AESGCM encryption + authentication operation in one call.
void AESGCM_Operation_init(AESGCM_Operation *operationStruct)
Function to initialize an AESGCM_Operation struct to its defaults.
void AESGCM_init(void)
This function initializes the GCM module.
int_fast16_t AESGCM_oneStepDecrypt(AESGCM_Handle handle, AESGCM_Operation *operationStruct)
Function to perform an AESGCM decryption + verification operation in one call.
uint32_t timeout
Definition: AESGCM.h:536
struct AESGCM_Config_ AESGCM_Config
AESGCM Global configuration.
AESGCM_OperationType_
Enum for the operation types supported by the driver.
Definition: AESGCM.h:481
void(* AESGCM_CallbackFxn)(AESGCM_Handle handle, int_fast16_t returnValue, AESGCM_Operation *operation, AESGCM_OperationType operationType)
The definition of a callback function used by the AESGCM driver when used in AESGCM_RETURN_BEHAVIOR_C...
Definition: AESGCM.h:520
uint8_t * input
Definition: AESGCM.h:435
struct AESGCM_Config_ * AESGCM_Handle
A handle that is returned from an AESGCM_open() call.
Definition: AESGCM.h:377
Definition: AESGCM.h:401
AESGCM_ReturnBehavior_
The way in which GCM function calls return after performing an encryption + authentication or decrypt...
Definition: AESGCM.h:400
Definition: AESGCM.h:483
uint8_t * aad
Definition: AESGCM.h:431
uint8_t * iv
Definition: AESGCM.h:446
void AESGCM_close(AESGCM_Handle handle)
Function to close a GCM peripheral specified by the GCM handle.
void AESGCM_Params_init(AESGCM_Params *params)
Function to initialize the AESGCM_Params struct to its defaults.
uint8_t * output
Definition: AESGCM.h:440
enum AESGCM_OperationType_ AESGCM_OperationType
Enum for the operation types supported by the driver.
void * object
Definition: AESGCM.h:499
void * custom
Definition: AESGCM.h:539
AESGCM_Mode_
Enum for the direction of the GCM operation.
Definition: AESGCM.h:420
void const * hwAttrs
Definition: AESGCM.h:502
Definition: AESGCM.h:407
AESGCM_Handle AESGCM_open(uint_least8_t index, AESGCM_Params *params)
This function opens a given GCM peripheral.
GCM Parameters.
Definition: AESGCM.h:533
Definition: AESGCM.h:411
AESGCM_CallbackFxn callbackFxn
Definition: AESGCM.h:535
AESGCM_ReturnBehavior returnBehavior
Definition: AESGCM.h:534
uint8_t macLength
Definition: AESGCM.h:469
bool ivInternallyGenerated
Definition: AESGCM.h:472
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale