AESCCM.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-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  */
322 #ifndef ti_drivers_AESCCM__include
323 #define ti_drivers_AESCCM__include
324 
325 #ifdef __cplusplus
326 extern "C" {
327 #endif
328 
329 #include <stdbool.h>
330 #include <stddef.h>
331 #include <stdint.h>
332 
334 
352 #define AESCCM_CMD_RESERVED (32)
353 
366 #define AESCCM_STATUS_RESERVED (-32)
367 
381 #define AESCCM_STATUS_SUCCESS (0)
382 
389 #define AESCCM_STATUS_ERROR (-1)
390 
398 #define AESCCM_STATUS_UNDEFINEDCMD (-2)
399 
408 #define AESCCM_STATUS_RESOURCE_UNAVAILABLE (-3)
409 
417 #define AESCCM_STATUS_MAC_INVALID (-4)
418 
419 
432 /* Add AESCCM_CMD_<commands> here */
433 
442 
480 
484 typedef enum AESCCM_Mode_ {
487 } AESCCM_Mode;
488 
493 typedef struct AESCCM_Operation_ {
495  uint8_t *aad;
499  uint8_t *input;
504  uint8_t *output;
510  uint8_t *nonce;
516  uint8_t *mac;
522  size_t aadLength;
526  size_t inputLength;
530  uint8_t nonceLength;
533  uint8_t macLength;
541 
545 typedef enum AESCCM_OperationType_ {
549 
561 typedef struct AESCCM_Config_ {
563  void *object;
564 
566  void const *hwAttrs;
567 } AESCCM_Config;
568 
584 typedef void (*AESCCM_CallbackFxn) (AESCCM_Handle handle,
585  int_fast16_t returnValue,
586  AESCCM_Operation *operation,
587  AESCCM_OperationType operationType);
588 
597 typedef struct AESCCM_Params_ {
600  uint32_t timeout;
603  void *custom;
606 } AESCCM_Params;
607 
614 
623 void AESCCM_init(void);
624 
637 void AESCCM_Params_init(AESCCM_Params *params);
638 
656 AESCCM_Handle AESCCM_open(uint_least8_t index, AESCCM_Params *params);
657 
667 void AESCCM_close(AESCCM_Handle handle);
668 
706 int_fast16_t AESCCM_control(AESCCM_Handle handle, uint32_t cmd, void *args);
707 
708 
709 
718 void AESCCM_Operation_init(AESCCM_Operation *operationStruct);
719 
736 int_fast16_t AESCCM_oneStepEncrypt(AESCCM_Handle handle, AESCCM_Operation *operationStruct);
737 
754 int_fast16_t AESCCM_oneStepDecrypt(AESCCM_Handle handle, AESCCM_Operation *operationStruct);
755 
756 #ifdef __cplusplus
757 }
758 #endif
759 
760 #endif /* ti_drivers_AESCCM__include */
uint8_t nonceLength
Definition: AESCCM.h:530
CCM Parameters.
Definition: AESCCM.h:597
Definition: AESCCM.h:475
The CryptoKey type is an opaque representation of a cryptographic key.
AESCCM_ReturnBehavior returnBehavior
Definition: AESCCM.h:598
AESCCM_OperationType_
Enum for the operation types supported by the driver.
Definition: AESCCM.h:545
uint8_t macLength
Definition: AESCCM.h:533
int_fast16_t AESCCM_oneStepDecrypt(AESCCM_Handle handle, AESCCM_Operation *operationStruct)
Function to perform an AESCCM decryption + verification operation in one call.
Definition: AESCCM.h:465
void const * hwAttrs
Definition: AESCCM.h:566
CryptoKey datastructure.
Definition: CryptoKey.h:210
const AESCCM_Params AESCCM_defaultParams
Default AESCCM_Params structure.
void * custom
Definition: AESCCM.h:603
enum AESCCM_ReturnBehavior_ AESCCM_ReturnBehavior
The way in which CCM function calls return after performing an encryption + authentication or decrypt...
int_fast16_t AESCCM_oneStepEncrypt(AESCCM_Handle handle, AESCCM_Operation *operationStruct)
Function to perform an AESCCM encryption + authentication operation in one call.
Struct containing the parameters required for encrypting/decrypting and authenticating/verifying a me...
Definition: AESCCM.h:493
struct AESCCM_Config_ * AESCCM_Handle
A handle that is returned from an AESCCM_open() call.
Definition: AESCCM.h:441
uint8_t * output
Definition: AESCCM.h:504
Definition: AESCCM.h:486
void AESCCM_Params_init(AESCCM_Params *params)
Function to initialize the AESCCM_Params struct to its defaults.
struct AESCCM_Params_ AESCCM_Params
CCM Parameters.
uint8_t * mac
Definition: AESCCM.h:516
AESCCM_ReturnBehavior_
The way in which CCM function calls return after performing an encryption + authentication or decrypt...
Definition: AESCCM.h:464
bool nonceInternallyGenerated
Definition: AESCCM.h:536
enum AESCCM_Mode_ AESCCM_Mode
Enum for the direction of the CCM operation.
Definition: AESCCM.h:471
CryptoKey * key
Definition: AESCCM.h:494
uint8_t * input
Definition: AESCCM.h:499
void AESCCM_Operation_init(AESCCM_Operation *operationStruct)
Function to initialize an AESCCM_Operation struct to its defaults.
struct AESCCM_Operation_ AESCCM_Operation
Struct containing the parameters required for encrypting/decrypting and authenticating/verifying a me...
void * object
Definition: AESCCM.h:563
void(* AESCCM_CallbackFxn)(AESCCM_Handle handle, int_fast16_t returnValue, AESCCM_Operation *operation, AESCCM_OperationType operationType)
The definition of a callback function used by the AESCCM driver when used in AESCCM_RETURN_BEHAVIOR_C...
Definition: AESCCM.h:584
void AESCCM_close(AESCCM_Handle handle)
Function to close a CCM peripheral specified by the CCM handle.
struct AESCCM_Config_ AESCCM_Config
AESCCM Global configuration.
int_fast16_t AESCCM_control(AESCCM_Handle handle, uint32_t cmd, void *args)
Function performs implementation specific features on a given AESCCM_Handle.
uint8_t * nonce
Definition: AESCCM.h:510
void AESCCM_init(void)
This function initializes the CCM module.
size_t inputLength
Definition: AESCCM.h:526
Definition: AESCCM.h:547
uint32_t timeout
Definition: AESCCM.h:600
enum AESCCM_OperationType_ AESCCM_OperationType
Enum for the operation types supported by the driver.
Definition: AESCCM.h:546
AESCCM Global configuration.
Definition: AESCCM.h:561
Definition: AESCCM.h:485
AESCCM_CallbackFxn callbackFxn
Definition: AESCCM.h:599
AESCCM_Mode_
Enum for the direction of the CCM operation.
Definition: AESCCM.h:484
AESCCM_Handle AESCCM_open(uint_least8_t index, AESCCM_Params *params)
This function opens a given CCM peripheral.
size_t aadLength
Definition: AESCCM.h:522
uint8_t * aad
Definition: AESCCM.h:495
Copyright 2018, Texas Instruments Incorporated