90 lines
2.7 KiB
C
90 lines
2.7 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef _IOT_CRYPTO_SHARE_H_
|
|
#define _IOT_CRYPTO_SHARE_H_
|
|
|
|
/* os shim includes */
|
|
#include "os_types.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct _iot_crypto_share_fifo {
|
|
/* fifo size */
|
|
uint16_t size;
|
|
/* write index */
|
|
uint8_t wr_idx;
|
|
/* read index */
|
|
uint8_t rd_idx;
|
|
/* fifo crypto data buffer list */
|
|
uint8_t **buf;
|
|
} iot_crypto_share_fifo_t;
|
|
|
|
typedef struct _iot_crypto_share {
|
|
/* crypto current data buffer */
|
|
uint8_t *cur_buf;
|
|
/* crypto share request fifo */
|
|
iot_crypto_share_fifo_t req;
|
|
/* crypto share response fifo */
|
|
iot_crypto_share_fifo_t rsp;
|
|
} iot_crypto_share_t;
|
|
|
|
#define iot_crypto_share_is_enable(p_share) ((p_share) != NULL)
|
|
|
|
/**
|
|
* @brief get the number of elements in the fifo
|
|
* @param fifo: fifo address
|
|
*
|
|
* @retval: the number of elements in the fifo
|
|
*/
|
|
uint8_t iot_crypto_share_fifo_elements(iot_crypto_share_fifo_t *fifo);
|
|
|
|
/**
|
|
* @brief write a buffer into the fifo
|
|
* @param fifo: fifo address
|
|
* @param buf: buffer address
|
|
*
|
|
* @retval: error code, see ERR_XXX
|
|
*/
|
|
uint32_t iot_crypto_share_fifo_put(iot_crypto_share_fifo_t *fifo,
|
|
uint8_t *buf);
|
|
|
|
/**
|
|
* @brief read buffer from the fifo
|
|
* @param fifo: fifo address
|
|
*
|
|
* @retval: buffer address
|
|
*/
|
|
uint8_t *iot_crypto_share_fifo_get(iot_crypto_share_fifo_t *fifo);
|
|
|
|
/**
|
|
* @brief init crypto share fifo context
|
|
* @param fifo: fifo address
|
|
* @param size: fifo list buffer size
|
|
* @param buf_list: fifo list buffer
|
|
*
|
|
* @retval: buffer address
|
|
*/
|
|
void iot_crypto_share_fifo_init(iot_crypto_share_fifo_t *fifo, uint8_t size,
|
|
uint8_t **buf_list);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // _IOT_CRYPTO_SHARE_H_
|