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  */
498 #ifndef ti_drivers_AESCMAC__include
499 #define ti_drivers_AESCMAC__include
500 
501 #include <stdbool.h>
502 #include <stddef.h>
503 #include <stdint.h>
504 
505 #include <ti/drivers/AESCommon.h>
507 
508 #ifdef __cplusplus
509 extern "C" {
510 #endif
511 
524 #define AESCMAC_STATUS_RESERVED AES_STATUS_RESERVED
525 
532 #define AESCMAC_STATUS_SUCCESS AES_STATUS_SUCCESS
533 
540 #define AESCMAC_STATUS_ERROR AES_STATUS_ERROR
541 
550 #define AESCMAC_STATUS_RESOURCE_UNAVAILABLE AES_STATUS_RESOURCE_UNAVAILABLE
551 
558 #define AESCMAC_STATUS_MAC_INVALID AES_STATUS_MAC_INVALID
559 
563 #define AESCMAC_STATUS_CANCELED AES_STATUS_CANCELED
564 
568 #define AESCMAC_STATUS_KEYSTORE_INVALID_ID AES_STATUS_KEYSTORE_INVALID_ID
569 
574 #define AESCMAC_STATUS_KEYSTORE_GENERIC_ERROR AES_STATUS_KEYSTORE_GENERIC_ERROR
575 
582 #define AESCMAC_STATUS_UNALIGNED_IO_NOT_SUPPORTED AES_STATUS_UNALIGNED_IO_NOT_SUPPORTED
583 
596 
600 typedef AESCMAC_Config *AESCMAC_Handle;
601 
622 typedef enum
623 {
642 
652 typedef enum
653 {
657 
661 typedef struct
662 {
663  uint8_t *input;
668  uint8_t *mac;
674  size_t inputLength;
679  size_t macLength;
685 
689 #define AESCMAC_OP_CODE_MASK 0x0F /* bits 0-3 */
690 
694 typedef enum
695 {
700 
705 #define AESCMAC_OP_FLAG_SIGN 0x10 /* bit 4 */
706 
710 #define AESCMAC_OP_FLAGS_MASK (AESCMAC_OP_FLAG_SIGN | AESCMAC_OP_FLAG_VERIFY)
711 
715 typedef enum
716 {
724 
739 typedef void (*AESCMAC_CallbackFxn)(AESCMAC_Handle handle,
740  int_fast16_t returnValue,
741  AESCMAC_Operation *operation,
742  AESCMAC_OperationType operationType);
743 
752 typedef struct
753 {
754  AESCMAC_ReturnBehavior returnBehavior;
757  uint32_t timeout;
760  void *custom;
764 
771 
780 void AESCMAC_init(void);
781 
796 
806 
827 AESCMAC_Handle AESCMAC_open(uint_least8_t index, const AESCMAC_Params *params);
828 
839 void AESCMAC_close(AESCMAC_Handle handle);
840 
863 int_fast16_t AESCMAC_setupSign(AESCMAC_Handle handle, const CryptoKey *key);
864 
887 int_fast16_t AESCMAC_setupVerify(AESCMAC_Handle handle, const CryptoKey *key);
888 
917 int_fast16_t AESCMAC_addData(AESCMAC_Handle handle, AESCMAC_Operation *operation);
918 
957 int_fast16_t AESCMAC_finalize(AESCMAC_Handle handle, AESCMAC_Operation *operation);
958 
988 int_fast16_t AESCMAC_oneStepSign(AESCMAC_Handle handle, AESCMAC_Operation *operation, CryptoKey *key);
989 
1021 int_fast16_t AESCMAC_oneStepVerify(AESCMAC_Handle handle, AESCMAC_Operation *operation, CryptoKey *key);
1022 
1038 int_fast16_t AESCMAC_cancelOperation(AESCMAC_Handle handle);
1039 
1066 AESCMAC_Handle AESCMAC_construct(AESCMAC_Config *config, const AESCMAC_Params *params);
1067 
1068 #ifdef __cplusplus
1069 }
1070 #endif
1071 
1072 #endif /* ti_drivers_AESCMAC__include */
AESCMAC_OperationalMode operationalMode
Definition: AESCMAC.h:755
size_t inputLength
Definition: AESCMAC.h:674
size_t macLength
Definition: AESCMAC.h:679
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:655
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:719
Definition: AESCMAC.h:722
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:192
Definition: AESCMAC.h:697
Definition: AESCommon.h:186
AESCMAC_OperationType
Enum for the operation types supported by the driver.
Definition: AESCMAC.h:715
void AESCMAC_close(AESCMAC_Handle handle)
Closes a AESCMAC peripheral specified by the CMAC handle.
Definition: AESCMAC.h:720
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:705
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:739
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:652
Definition: AESCMAC.h:721
AESCommon_Config AESCMAC_Config
CMAC Global configuration.
Definition: AESCMAC.h:595
AESCMAC_Config * AESCMAC_Handle
A handle that is returned from an AESCMAC_open() call.
Definition: AESCMAC.h:600
Definition: AESCMAC.h:717
AESCMAC Parameters.
Definition: AESCMAC.h:752
Definition: AESCMAC.h:718
Definition: AESCMAC.h:654
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:624
Definition: AESCMAC.h:696
AESCMAC_CallbackFxn callbackFxn
Definition: AESCMAC.h:756
uint8_t * mac
Definition: AESCMAC.h:668
AES common module header for all devices.
AESCMAC_ReturnBehavior returnBehavior
Definition: AESCMAC.h:754
AESCMAC_Handle AESCMAC_construct(AESCMAC_Config *config, const AESCMAC_Params *params)
Constructs a new AESCMAC object.
uint8_t * input
Definition: AESCMAC.h:663
Struct containing the parameters required for signing or verifying a message.
Definition: AESCMAC.h:661
Definition: AESCMAC.h:698
int_fast16_t AESCMAC_addData(AESCMAC_Handle handle, AESCMAC_Operation *operation)
Adds data to the current segmented operation.
uint32_t timeout
Definition: AESCMAC.h:757
Definition: AESCMAC.h:631
AESCMAC_ReturnBehavior
The return behavior of AESCMAC functions.
Definition: AESCMAC.h:622
void * custom
Definition: AESCMAC.h:760
AESCMAC_OperationCode
Enum for the operation codes supported by the driver.
Definition: AESCMAC.h:694
Definition: AESCMAC.h:636
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale