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 
504 #include <ti/drivers/AESCommon.h>
506 
507 #ifdef __cplusplus
508 extern "C" {
509 #endif
510 
523 #define AESCMAC_STATUS_RESERVED AES_STATUS_RESERVED
524 
531 #define AESCMAC_STATUS_SUCCESS AES_STATUS_SUCCESS
532 
539 #define AESCMAC_STATUS_ERROR AES_STATUS_ERROR
540 
549 #define AESCMAC_STATUS_RESOURCE_UNAVAILABLE AES_STATUS_RESOURCE_UNAVAILABLE
550 
557 #define AESCMAC_STATUS_MAC_INVALID AES_STATUS_MAC_INVALID
558 
562 #define AESCMAC_STATUS_CANCELED AES_STATUS_CANCELED
563 
567 #define AESCMAC_STATUS_KEYSTORE_INVALID_ID AES_STATUS_KEYSTORE_INVALID_ID
568 
573 #define AESCMAC_STATUS_KEYSTORE_GENERIC_ERROR AES_STATUS_KEYSTORE_GENERIC_ERROR
574 
581 #define AESCMAC_STATUS_UNALIGNED_IO_NOT_SUPPORTED AES_STATUS_UNALIGNED_IO_NOT_SUPPORTED
582 
595 
599 typedef AESCMAC_Config *AESCMAC_Handle;
600 
621 typedef enum {
640 
641 
651 typedef enum {
655 
659 typedef struct {
660  uint8_t *input;
665  uint8_t *mac;
671  size_t inputLength;
676  size_t macLength;
682 
686 #define AESCMAC_OP_CODE_MASK 0x0F /* bits 0-3 */
687 
691 typedef enum {
696 
701 #define AESCMAC_OP_FLAG_SIGN 0x10 /* bit 4 */
702 
706 #define AESCMAC_OP_FLAGS_MASK (AESCMAC_OP_FLAG_SIGN | AESCMAC_OP_FLAG_VERIFY)
707 
711 typedef enum {
719 
734 typedef void (*AESCMAC_CallbackFxn)(AESCMAC_Handle handle,
735  int_fast16_t returnValue,
736  AESCMAC_Operation *operation,
737  AESCMAC_OperationType operationType);
738 
747 typedef struct {
748  AESCMAC_ReturnBehavior returnBehavior;
751  uint32_t timeout;
754  void *custom;
758 
759 
760 
767 
776 void AESCMAC_init(void);
777 
792 
802 
823 AESCMAC_Handle AESCMAC_open(uint_least8_t index, const AESCMAC_Params *params);
824 
835 void AESCMAC_close(AESCMAC_Handle handle);
836 
859 int_fast16_t AESCMAC_setupSign(AESCMAC_Handle handle, const CryptoKey *key);
860 
883 int_fast16_t AESCMAC_setupVerify(AESCMAC_Handle handle, const CryptoKey *key);
884 
913 int_fast16_t AESCMAC_addData(AESCMAC_Handle handle,
914  AESCMAC_Operation *operation);
915 
954 int_fast16_t AESCMAC_finalize(AESCMAC_Handle handle,
955  AESCMAC_Operation *operation);
956 
957 
987 int_fast16_t AESCMAC_oneStepSign(AESCMAC_Handle handle,
988  AESCMAC_Operation *operation,
989  CryptoKey *key);
990 
1022 int_fast16_t AESCMAC_oneStepVerify(AESCMAC_Handle handle,
1023  AESCMAC_Operation *operation,
1024  CryptoKey *key);
1025 
1041 int_fast16_t AESCMAC_cancelOperation(AESCMAC_Handle handle);
1042 
1069 AESCMAC_Handle AESCMAC_construct(AESCMAC_Config *config, const AESCMAC_Params *params);
1070 
1071 #ifdef __cplusplus
1072 }
1073 #endif
1074 
1075 #endif /* ti_drivers_AESCMAC__include */
AESCMAC_OperationalMode operationalMode
Definition: AESCMAC.h:749
size_t inputLength
Definition: AESCMAC.h:671
size_t macLength
Definition: AESCMAC.h:676
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:653
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:714
Definition: AESCMAC.h:717
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:693
Definition: AESCommon.h:184
AESCMAC_OperationType
Enum for the operation types supported by the driver.
Definition: AESCMAC.h:711
void AESCMAC_close(AESCMAC_Handle handle)
Closes a AESCMAC peripheral specified by the CMAC handle.
Definition: AESCMAC.h:715
Definition: AESCommon.h:194
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:701
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:734
const AESCMAC_Params AESCMAC_defaultParams
Default AESCMAC_Params structure.
Definition: AESCommon.h:190
AESCMAC_OperationalMode
Defines the operation modes for the AESCMAC driver.
Definition: AESCMAC.h:651
Definition: AESCMAC.h:716
AESCommon_Config AESCMAC_Config
CMAC Global configuration.
Definition: AESCMAC.h:594
AESCMAC_Config * AESCMAC_Handle
A handle that is returned from an AESCMAC_open() call.
Definition: AESCMAC.h:599
Definition: AESCMAC.h:712
AESCMAC Parameters.
Definition: AESCMAC.h:747
Definition: AESCMAC.h:713
Definition: AESCMAC.h:652
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:622
Definition: AESCMAC.h:692
AESCMAC_CallbackFxn callbackFxn
Definition: AESCMAC.h:750
uint8_t * mac
Definition: AESCMAC.h:665
AES common module header for all devices.
AESCMAC_ReturnBehavior returnBehavior
Definition: AESCMAC.h:748
AESCMAC_Handle AESCMAC_construct(AESCMAC_Config *config, const AESCMAC_Params *params)
Constructs a new AESCMAC object.
uint8_t * input
Definition: AESCMAC.h:660
Struct containing the parameters required for signing or verifying a message.
Definition: AESCMAC.h:659
Definition: AESCMAC.h:694
int_fast16_t AESCMAC_addData(AESCMAC_Handle handle, AESCMAC_Operation *operation)
Adds data to the current segmented operation.
uint32_t timeout
Definition: AESCMAC.h:751
Definition: AESCMAC.h:629
AESCMAC_ReturnBehavior
The return behavior of AESCMAC functions.
Definition: AESCMAC.h:621
void * custom
Definition: AESCMAC.h:754
AESCMAC_OperationCode
Enum for the operation codes supported by the driver.
Definition: AESCMAC.h:691
Definition: AESCMAC.h:634
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale