diff --git a/demos/STM32/RT-STM32F746G-DISCOVERY/halconf.h b/demos/STM32/RT-STM32F746G-DISCOVERY/halconf.h index d7793e22c..a551b35b6 100644 --- a/demos/STM32/RT-STM32F746G-DISCOVERY/halconf.h +++ b/demos/STM32/RT-STM32F746G-DISCOVERY/halconf.h @@ -55,7 +55,7 @@ * @brief Enables the cryptographic subsystem. */ #if !defined(HAL_USE_CRY) || defined(__DOXYGEN__) -#define HAL_USE_CRY FALSE +#define HAL_USE_CRY TRUE #endif /** @@ -227,7 +227,7 @@ * @note Fall-back implementations may not be present for all algorithms. */ #if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__) -#define HAL_CRY_USE_FALLBACK FALSE +#define HAL_CRY_USE_FALLBACK TRUE #endif /** diff --git a/os/hal/include/hal_crypto.h b/os/hal/include/hal_crypto.h index cc2ca5fdf..433953e45 100644 --- a/os/hal/include/hal_crypto.h +++ b/os/hal/include/hal_crypto.h @@ -71,6 +71,13 @@ /* Driver data structures and types. */ /*===========================================================================*/ +/** + * @brief Size, in bits, of a crypto field or message. + * @note It is assumed, for simplicity, that this type is equivalent to + * a @p size_t. + */ +typedef size_t bitsize_t; + /** * @brief Driver state machine possible states. */ @@ -88,7 +95,8 @@ typedef enum { CRY_ERR_INV_ALGO = 1, /**< Invalid cypher/mode. */ CRY_ERR_INV_KEY_SIZE = 2, /**< Invalid key size. */ CRY_ERR_INV_KEY_TYPE = 3, /**< Invalid key type. */ - CRY_ERR_INV_KEY_ID = 4 /**< Invalid key type. */ + CRY_ERR_INV_KEY_ID = 4, /**< Invalid key type. */ + CRY_ERR_AUTH_FAILED = 5 /**< Authentication failed. */ } cryerror_t; /** @@ -210,6 +218,24 @@ extern "C" { uint8_t *out, const uint8_t *nonce, uint8_t *cnt); + cryerror_t cryEncryptAES_GCM(CRYDriver *cryp, + crykey_t key_id, + bitsize_t size, + const uint8_t *in, + uint8_t *out, + bitsize_t ivsize, + const uint8_t *iv, + bitsize_t authsize, + uint8_t *authout); + cryerror_t cryDecryptAES_GCM(CRYDriver *cryp, + crykey_t key_id, + bitsize_t size, + const uint8_t *in, + uint8_t *out, + bitsize_t ivsize, + const uint8_t *iv, + bitsize_t authsize, + const uint8_t *authin); #ifdef __cplusplus } #endif diff --git a/os/hal/src/hal_crypto.c b/os/hal/src/hal_crypto.c index de516dc72..710495343 100644 --- a/os/hal/src/hal_crypto.c +++ b/os/hal/src/hal_crypto.c @@ -22,8 +22,6 @@ * @{ */ -#include - #include "hal.h" #if (HAL_USE_CRY == TRUE) || defined(__DOXYGEN__)