From 94a1f758d8fd03c828108b585af4c360b2899bb9 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Mon, 23 Oct 2017 10:06:15 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10885 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/hal_crypto.h | 28 +++++++++++++++++++++++++++- os/hal/src/hal_crypto.c | 2 -- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'os/hal') 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__) -- cgit v1.2.3