/** ****************************************************************************** * @file bleplat.h * @author GPM WBL Application team * @brief This file contains the interface of the Bluetooth LE platform layer * (lower interface of the Bluetooth LE stack library). ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ #ifndef BLEPLAT_H__ #define BLEPLAT_H__ #include #include "bleplat_cntr.h" #define RSSI_INVALID 127 /* Enumerated values used for the return of the functions: */ typedef enum { BLEPLAT_OK = 0, BLEPLAT_FULL = -1, BLEPLAT_BUSY = -2, BLEPLAT_EOF = -3 } BLEPLAT_NvmStatusTypeDef; /* Enumerated values used for the 'type' of NVM functions: */ typedef enum { BLEPLAT_NVM_REC_SEC = 0, BLEPLAT_NVM_REC_GATT = 1, BLEPLAT_NVM_REC_DEVICE_ID = 2, } BLEPLAT_NvmRecordTypeDef; /* Enumerated values used for the 'mode' of NVM functions: */ typedef enum { BLEPLAT_NVM_FIRST = 0, BLEPLAT_NVM_NEXT = 1, BLEPLAT_NVM_CURRENT = 2, BLEPLAT_NVM_ALL = 3 } BLEPLAT_NvmSeekModeTypeDef; typedef enum { BLEPLAT_PKA_SUCCESS = 0, BLEPLAT_PKA_ERROR = -1, BLEPLAT_PKA_ERR_BUSY = -2, BLEPLAT_PKA_ERR_PARAM = -3, BLEPLAT_PKA_ERR_PROCESS = -4 } BLEPLAT_PkaStatusTypeDef; typedef void (*BLEPLAT_PkaFuncCb)(BLEPLAT_PkaStatusTypeDef errorCode, void *args); typedef enum { BLEPLAT_AES_FLAGS_DEFAULT = (uint32_t) (0x00000000), /*!< User Flag: No flag specified. This is the default value that should be set to this flag */ BLEPLAT_AES_FLAGS_DONT_PERFORM_KEY_SCHEDULE = (uint32_t) (0x00000001), /*!< User Flag: Used to force the init to not reperform key schedule.\n The classic example is where the same key is used on a new message, in this case to redo key scheduling is a useless waste of computation, could be particularly useful on GCM, where key schedule is very complicated. */ BLEPLAT_AES_FLAGS_FINAL_APPEND = (uint32_t) (0x00000020), /*!< User Flag: Must be set in CMAC mode before the final Append call occurs. */ BLEPLAT_AES_FLAGS_OPERATION_COMPLETED = (uint32_t) (0x00000002), /*!< Internal Flag (not to be set/read by user): used to check that the Finish function has been already called */ BLEPLAT_AES_FLAGS_NO_MORE_APPEND_ALLOWED = (uint32_t) (0x00000004), /*!< Internal Flag (not to be set/read by user): it is set when the last append has been called. Used where the append is called with an InputSize not multiple of the block size, which means that is the last input.*/ BLEPLAT_AES_FLAGS_NO_MORE_HEADER_APPEND_ALLOWED = (uint32_t) (0x00000010), /*!< Internal Flag (not to be set/read by user): only for authenticated encryption modes. \n It is set when the last header append has been called. Used where the header append is called with an InputSize not multiple of the block size, which means that is the last input.*/ BLEPLAT_AES_FLAGS_APPEND_DONE = (uint32_t) (0x00000040), /*!< Internal Flag (not to be set/read by user): only for CMAC.It is set when the first append has been called */ BLEPLAT_AES_FLAGS_SET_COUNTER = (uint32_t)(0x00000080), /*!< User Flag: With ChaCha20 this is used to indicate a value for the counter, used to process non contiguous blocks (i.e. jump ahead)*/ } AESflagsTypeDef; /*!< Type definitation for Symmetric Key Flags */ #define BLEPLAT_AES_MAX_EXPKEY_SIZE 44 /*!< The max size of the AES expanded key (in uint32_t) */ #define BLEPLAT_AES128_KEY_SIZE 16 /*!< Number of bytes (uint8_t) necessary to store an AES key of 128 bits. */ typedef struct { uint32_t mContextId; /*!< Unique ID of this context. \b Not \b used in current implementation. */ AESflagsTypeDef mFlags; /*!< 32 bit mFlags, used to perform keyschedule and future use */ const uint8_t *pmKey; /*!< Pointer to original Key buffer */ const uint8_t *pmIv; /*!< Pointer to original Initialization Vector buffer */ int32_t mIvSize; /*!< Size of the Initialization Vector in bytes */ uint32_t amIv[4]; /*!< Temporary result/IV */ int32_t mKeySize; /*!< Key length in bytes */ uint32_t amExpKey[BLEPLAT_AES_MAX_EXPKEY_SIZE]; /*!< Expanded AES key */ const uint8_t *pmTag; /*!< Pointer to Authentication TAG. This value must be set in decryption, and this TAG will be verified */ int32_t mTagSize; /*!< Size of the Tag to return. This must be set by the caller prior to calling Init */ } BLEPLAT_AESCMACctxTypeDef; /*