hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @file : gsw_secrypt_ss_interface.h |
| 3 | * @brief : tee storage |
| 4 | * @date : 2022-07-05 |
| 5 | * @author : Wind |
| 6 | * @version : v1.0 |
| 7 | * @copyright Copyright(C) 2022,Geely |
| 8 | */ |
| 9 | #ifndef __GSW_SECRYPT_SS_INTERFACE_H__ |
| 10 | #define __GSW_SECRYPT_SS_INTERFACE_H__ |
| 11 | |
| 12 | #if defined(__cplusplus) |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | #include "gsw_hal_errcode.h" |
| 17 | |
| 18 | #undef SS_DATA_MAXSIZE |
| 19 | #define SS_DATA_MAXSIZE (4000U) /*double check at sfs_common.h*/ |
| 20 | |
| 21 | #undef SECRYPT_RET_SUCCESS |
| 22 | #define SECRYPT_RET_SUCCESS GSW_HAL_SUCCESS |
| 23 | #undef SECRYPT_RET_NORMAL_FAIL |
| 24 | #define SECRYPT_RET_NORMAL_FAIL GSW_HAL_NORMAL_FAIL |
| 25 | #undef SECRYPT_RET_ARG_INVALID |
| 26 | #define SECRYPT_RET_ARG_INVALID GSW_HAL_ARG_INVALID |
| 27 | #undef SECRYPT_RET_NO_MEMORY |
| 28 | #define SECRYPT_RET_NO_MEMORY GSW_HAL_NO_MEMORY |
| 29 | |
| 30 | /** |
| 31 | * @brief check data in secure storage region |
| 32 | * |
| 33 | * @param[in] objname object name you want to check |
| 34 | * @param[out] exist_state exist state of the object, 1:exist, 0:not exist |
| 35 | * |
| 36 | * @return 0 on success, negative on failure |
| 37 | * |
| 38 | */ |
| 39 | int32_t gsw_secure_storage_query(const char *objname, int32_t *exist_state); |
| 40 | |
| 41 | /** |
| 42 | * @brief read plaintext in secure storage region |
| 43 | * |
| 44 | * @param[in] objname object name you want to read |
| 45 | * @param[out] outbuf pointer of out data buffer |
| 46 | * @param[in] buflen length of out data buffer |
| 47 | * @param[out] outlen length of out data |
| 48 | * |
| 49 | * @return 0 on success, negative on failure |
| 50 | */ |
| 51 | int32_t gsw_secure_storage_read(const char *objname, uint8_t *outbuf, |
| 52 | uint32_t buflen, uint32_t *outlen); |
| 53 | |
| 54 | /** |
| 55 | * @brief store data to secure storage region |
| 56 | * |
| 57 | * @param[in] objname input data identifier |
| 58 | * @param[in] inbuf pointer to input data |
| 59 | * @param[in] inlen length of the input data |
| 60 | * |
| 61 | * @return 0 on success, negative on failure |
| 62 | */ |
| 63 | int32_t gsw_secure_storage_write(const char *objname, const uint8_t *inbuf, |
| 64 | uint32_t inlen); |
| 65 | |
| 66 | /** |
| 67 | * @brief delete data from secure storage region |
| 68 | * |
| 69 | * @param[in] objname delete data identifier |
| 70 | * |
| 71 | * @return 0 on success, negative on failure |
| 72 | */ |
| 73 | int32_t gsw_secure_storage_delete(const char *objname); |
| 74 | |
| 75 | |
| 76 | #if defined(__cplusplus) |
| 77 | } |
| 78 | #endif |
| 79 | |
| 80 | #endif /* __GSW_SECRYPT_SS_INTERFACE_H__ */ |