AESCMAC.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2021, 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  */
497 #ifndef ti_drivers_AESCMAC__include
498 #define ti_drivers_AESCMAC__include
499 
500 #include <stdbool.h>
501 #include <stddef.h>
502 #include <stdint.h>
503 
505 
506 #ifdef __cplusplus
507 extern "C" {
508 #endif
509 
522 #define AESCMAC_STATUS_RESERVED (-32)
523 
530 #define AESCMAC_STATUS_SUCCESS (0)
531 
538 #define AESCMAC_STATUS_ERROR (-1)
539 
548 #define AESCMAC_STATUS_RESOURCE_UNAVAILABLE (-2)
549 
556 #define AESCMAC_STATUS_MAC_INVALID (-3)
557 
561 #define AESCMAC_STATUS_CANCELED (-4)
562 
574 typedef struct {
576  void *object;
577 
579  void const *hwAttrs;
581 
586 
607 typedef enum {
623 
624 
634 typedef enum {
638 
642 typedef struct {
643  uint8_t *input;
647  uint8_t *mac;
652  size_t inputLength;
655  size_t macLength;
660 
664 #define AESCMAC_OP_CODE_MASK 0x0F /* bits 0-3 */
665 
669 typedef enum {
674 
675 
680 #define AESCMAC_OP_FLAG_SIGN 0x10 /* bit 4 */
681 
682 
686 #define AESCMAC_OP_FLAGS_MASK (AESCMAC_OP_FLAG_SIGN | AESCMAC_OP_FLAG_VERIFY)
687 
691 typedef enum {
699 
714 typedef void (*AESCMAC_CallbackFxn)(AESCMAC_Handle handle,
715  int_fast16_t returnValue,
716  AESCMAC_Operation *operation,
717  AESCMAC_OperationType operationType);
718 
727 typedef struct {
731  uint32_t timeout;
734  void *custom;
738 
739 
740 
747 
756 void AESCMAC_init(void);
757 
772 
782 
803 AESCMAC_Handle AESCMAC_open(uint_least8_t index, const AESCMAC_Params *params);
804 
815 void AESCMAC_close(AESCMAC_Handle handle);
816 
839 int_fast16_t AESCMAC_setupSign(AESCMAC_Handle handle, const CryptoKey *key);
840 
863 int_fast16_t AESCMAC_setupVerify(AESCMAC_Handle handle, const CryptoKey *key);
864 
893 int_fast16_t AESCMAC_addData(AESCMAC_Handle handle,
894  AESCMAC_Operation *operation);
895 
933 int_fast16_t AESCMAC_finalize(AESCMAC_Handle handle,
934  AESCMAC_Operation *operation);
935 
936 
965 int_fast16_t AESCMAC_oneStepSign(AESCMAC_Handle handle,
966  AESCMAC_Operation *operation,
967  CryptoKey *key);
968 
999 int_fast16_t AESCMAC_oneStepVerify(AESCMAC_Handle handle,
1000  AESCMAC_Operation *operation,
1001  CryptoKey *key);
1002 
1018 int_fast16_t AESCMAC_cancelOperation(AESCMAC_Handle handle);
1019 
1046 AESCMAC_Handle AESCMAC_construct(AESCMAC_Config *config, const AESCMAC_Params *params);
1047 
1048 #ifdef __cplusplus
1049 }
1050 #endif
1051 
1052 #endif /* ti_drivers_AESCMAC__include */
AESCMAC_OperationalMode operationalMode
Definition: AESCMAC.h:729
size_t inputLength
Definition: AESCMAC.h:652
size_t macLength
Definition: AESCMAC.h:655
ADC_Params params
Definition: Driver_Init.h:11
void AESCMAC_Operation_init(AESCMAC_Operation *operation)
Initializes an AESCMAC_Operation struct to its defaults.
int_fast16_t AESCMAC_oneStepSign(AESCMAC_Handle handle, AESCMAC_Operation *operation, CryptoKey *key)
Performs a AESCMAC signature in one call.
Definition: AESCMAC.h:636
The CryptoKey type is an opaque representation of a cryptographic key.
int_fast16_t AESCMAC_setupSign(AESCMAC_Handle handle, const CryptoKey *key)
Prepares a segmented AESCMAC sign operation.
void * object
Definition: AESCMAC.h:576
Definition: AESCMAC.h:694
void const * hwAttrs
Definition: AESCMAC.h:579
Definition: AESCMAC.h:697
int_fast16_t AESCMAC_setupVerify(AESCMAC_Handle handle, const CryptoKey *key)
Prepares a segmented AESCMAC verify operation.
CryptoKey datastructure.
Definition: CryptoKey.h:192
Definition: AESCMAC.h:671
AESCMAC_OperationType
Enum for the operation types supported by the driver.
Definition: AESCMAC.h:691
void AESCMAC_close(AESCMAC_Handle handle)
Closes a AESCMAC peripheral specified by the CMAC handle.
Definition: AESCMAC.h:695
AESCMAC_Handle AESCMAC_open(uint_least8_t index, const AESCMAC_Params *params)
Opens a given AESCMAC peripheral.
void AESCMAC_Params_init(AESCMAC_Params *params)
Initializes the AESCMAC_Params struct to its defaults.
CMAC Global configuration.
Definition: AESCMAC.h:574
#define AESCMAC_OP_FLAG_SIGN
Flag indicating a sign operation. If this bit is not set, then it is a verify operation.
Definition: AESCMAC.h:680
int_fast16_t AESCMAC_cancelOperation(AESCMAC_Handle handle)
Cancels an ongoing AESCMAC operation.
void AESCMAC_init(void)
Initializes the CMAC module.
void(* AESCMAC_CallbackFxn)(AESCMAC_Handle handle, int_fast16_t returnValue, AESCMAC_Operation *operation, AESCMAC_OperationType operationType)
The definition of a callback function used by the AESCMAC driver when used in AESCMAC_RETURN_BEHAVIOR...
Definition: AESCMAC.h:714
const AESCMAC_Params AESCMAC_defaultParams
Default AESCMAC_Params structure.
AESCMAC_OperationalMode
Defines the operation modes for the AESCMAC driver.
Definition: AESCMAC.h:634
Definition: AESCMAC.h:696
AESCMAC_Config * AESCMAC_Handle
A handle that is returned from an AESCMAC_open() call.
Definition: AESCMAC.h:585
Definition: AESCMAC.h:692
AESCMAC Parameters.
Definition: AESCMAC.h:727
Definition: AESCMAC.h:693
Definition: AESCMAC.h:635
int_fast16_t AESCMAC_finalize(AESCMAC_Handle handle, AESCMAC_Operation *operation)
Finalizes the current segmented operation.
int_fast16_t AESCMAC_oneStepVerify(AESCMAC_Handle handle, AESCMAC_Operation *operation, CryptoKey *key)
Performs a AESCMAC verification in one call.
Definition: AESCMAC.h:608
Definition: AESCMAC.h:670
AESCMAC_CallbackFxn callbackFxn
Definition: AESCMAC.h:730
uint8_t * mac
Definition: AESCMAC.h:647
AESCMAC_ReturnBehavior returnBehavior
Definition: AESCMAC.h:728
AESCMAC_Handle AESCMAC_construct(AESCMAC_Config *config, const AESCMAC_Params *params)
Constructs a new AESCMAC object.
uint8_t * input
Definition: AESCMAC.h:643
Struct containing the parameters required for signing or verifying a message.
Definition: AESCMAC.h:642
Definition: AESCMAC.h:672
int_fast16_t AESCMAC_addData(AESCMAC_Handle handle, AESCMAC_Operation *operation)
Adds data to the current segmented operation.
uint32_t timeout
Definition: AESCMAC.h:731
Definition: AESCMAC.h:614
AESCMAC_ReturnBehavior
The return behavior of AESCMAC functions.
Definition: AESCMAC.h:607
void * custom
Definition: AESCMAC.h:734
AESCMAC_OperationCode
Enum for the operation codes supported by the driver.
Definition: AESCMAC.h:669
Definition: AESCMAC.h:618
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale