AESCMAC.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2023, 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  */
548 #ifndef ti_drivers_AESCMAC__include
549 #define ti_drivers_AESCMAC__include
550 
551 #include <stdbool.h>
552 #include <stddef.h>
553 #include <stdint.h>
554 
555 #include <ti/drivers/AESCommon.h>
557 
558 #ifdef __cplusplus
559 extern "C" {
560 #endif
561 
574 #define AESCMAC_STATUS_RESERVED AES_STATUS_RESERVED
575 
582 #define AESCMAC_STATUS_SUCCESS AES_STATUS_SUCCESS
583 
590 #define AESCMAC_STATUS_ERROR AES_STATUS_ERROR
591 
600 #define AESCMAC_STATUS_RESOURCE_UNAVAILABLE AES_STATUS_RESOURCE_UNAVAILABLE
601 
608 #define AESCMAC_STATUS_MAC_INVALID AES_STATUS_MAC_INVALID
609 
613 #define AESCMAC_STATUS_CANCELED AES_STATUS_CANCELED
614 
619 #define AESCMAC_STATUS_FEATURE_NOT_SUPPORTED AES_STATUS_FEATURE_NOT_SUPPORTED
620 
624 #define AESCMAC_STATUS_KEYSTORE_INVALID_ID AES_STATUS_KEYSTORE_INVALID_ID
625 
630 #define AESCMAC_STATUS_KEYSTORE_GENERIC_ERROR AES_STATUS_KEYSTORE_GENERIC_ERROR
631 
638 #define AESCMAC_STATUS_UNALIGNED_IO_NOT_SUPPORTED AES_STATUS_UNALIGNED_IO_NOT_SUPPORTED
639 
652 
656 typedef AESCMAC_Config *AESCMAC_Handle;
657 
678 typedef enum
679 {
698 
708 typedef enum
709 {
713 
717 typedef struct
718 {
719  uint8_t *input;
724  uint8_t *mac;
730  size_t inputLength;
735  size_t macLength;
741 
745 #define AESCMAC_OP_CODE_MASK 0x0F /* bits 0-3 */
746 
750 typedef enum
751 {
756 
761 #define AESCMAC_OP_FLAG_SIGN 0x10 /* bit 4 */
762 
766 #define AESCMAC_OP_FLAGS_MASK (AESCMAC_OP_FLAG_SIGN | AESCMAC_OP_FLAG_VERIFY)
767 
771 typedef enum
772 {
780 
795 typedef void (*AESCMAC_CallbackFxn)(AESCMAC_Handle handle,
796  int_fast16_t returnValue,
797  AESCMAC_Operation *operation,
798  AESCMAC_OperationType operationType);
799 
808 typedef struct
809 {
810  AESCMAC_ReturnBehavior returnBehavior;
813  uint32_t timeout;
816  void *custom;
820 
827 
836 void AESCMAC_init(void);
837 
852 
862 
883 AESCMAC_Handle AESCMAC_open(uint_least8_t index, const AESCMAC_Params *params);
884 
895 void AESCMAC_close(AESCMAC_Handle handle);
896 
919 int_fast16_t AESCMAC_setupSign(AESCMAC_Handle handle, const CryptoKey *key);
920 
943 int_fast16_t AESCMAC_setupVerify(AESCMAC_Handle handle, const CryptoKey *key);
944 
973 int_fast16_t AESCMAC_addData(AESCMAC_Handle handle, AESCMAC_Operation *operation);
974 
1013 int_fast16_t AESCMAC_finalize(AESCMAC_Handle handle, AESCMAC_Operation *operation);
1014 
1044 int_fast16_t AESCMAC_oneStepSign(AESCMAC_Handle handle, AESCMAC_Operation *operation, CryptoKey *key);
1045 
1077 int_fast16_t AESCMAC_oneStepVerify(AESCMAC_Handle handle, AESCMAC_Operation *operation, CryptoKey *key);
1078 
1094 int_fast16_t AESCMAC_cancelOperation(AESCMAC_Handle handle);
1095 
1122 AESCMAC_Handle AESCMAC_construct(AESCMAC_Config *config, const AESCMAC_Params *params);
1123 
1124 #ifdef __cplusplus
1125 }
1126 #endif
1127 
1128 #endif /* ti_drivers_AESCMAC__include */
AESCMAC_OperationalMode operationalMode
Definition: AESCMAC.h:811
size_t inputLength
Definition: AESCMAC.h:730
size_t macLength
Definition: AESCMAC.h:735
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:711
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.
Definition: AESCMAC.h:775
Definition: AESCMAC.h:778
int_fast16_t AESCMAC_setupVerify(AESCMAC_Handle handle, const CryptoKey *key)
Prepares a segmented AESCMAC verify operation.
AES Global configuration.
Definition: AESCommon.h:154
CryptoKey datastructure.
Definition: CryptoKey.h:208
Definition: AESCMAC.h:753
Definition: AESCommon.h:186
AESCMAC_OperationType
Enum for the operation types supported by the driver.
Definition: AESCMAC.h:771
void AESCMAC_close(AESCMAC_Handle handle)
Closes a AESCMAC peripheral specified by the CMAC handle.
Definition: AESCMAC.h:776
Definition: AESCommon.h:196
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.
#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:761
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:795
const AESCMAC_Params AESCMAC_defaultParams
Default AESCMAC_Params structure.
Definition: AESCommon.h:192
AESCMAC_OperationalMode
Defines the operation modes for the AESCMAC driver.
Definition: AESCMAC.h:708
Definition: AESCMAC.h:777
AESCommon_Config AESCMAC_Config
CMAC Global configuration.
Definition: AESCMAC.h:651
AESCMAC_Config * AESCMAC_Handle
A handle that is returned from an AESCMAC_open() call.
Definition: AESCMAC.h:656
Definition: AESCMAC.h:773
AESCMAC Parameters.
Definition: AESCMAC.h:808
Definition: AESCMAC.h:774
Definition: AESCMAC.h:710
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:680
Definition: AESCMAC.h:752
AESCMAC_CallbackFxn callbackFxn
Definition: AESCMAC.h:812
uint8_t * mac
Definition: AESCMAC.h:724
AES common module header for all devices.
AESCMAC_ReturnBehavior returnBehavior
Definition: AESCMAC.h:810
AESCMAC_Handle AESCMAC_construct(AESCMAC_Config *config, const AESCMAC_Params *params)
Constructs a new AESCMAC object.
uint8_t * input
Definition: AESCMAC.h:719
Struct containing the parameters required for signing or verifying a message.
Definition: AESCMAC.h:717
Definition: AESCMAC.h:754
int_fast16_t AESCMAC_addData(AESCMAC_Handle handle, AESCMAC_Operation *operation)
Adds data to the current segmented operation.
uint32_t timeout
Definition: AESCMAC.h:813
Definition: AESCMAC.h:687
AESCMAC_ReturnBehavior
The return behavior of AESCMAC functions.
Definition: AESCMAC.h:678
void * custom
Definition: AESCMAC.h:816
AESCMAC_OperationCode
Enum for the operation codes supported by the driver.
Definition: AESCMAC.h:750
Definition: AESCMAC.h:692
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale