| #include <stdlib.h> |
| #include <stdint.h> |
| #include <string.h> |
| #include <stdbool.h> |
| #include <stdio.h> |
| |
| |
| #define GSW_HAL_SUCCESS 0 |
| #define GSW_HAL_FAIL -1 |
| #define GSW_HAL_MEM_INVAILD -2 |
| #define GSW_HAL_NOFOUND -3 |
| |
| typedef enum { |
| GSW_TEE_PARAM_DATA = 1, |
| GSW_TEE_PARAM_FILE |
| }GSW_TEE_PARAM_TYPE; |
| |
| typedef enum { |
| GSW_TEE_DIGEST_MD5 = 1, |
| GSW_TEE_DIGEST_SHA1, |
| GSW_TEE_DIGEST_SHA256, |
| }GSW_TEE_DIGEST_TYPE; |
| |
| typedef enum { |
| GSW_TEE_AES_ECB = 1, |
| GSW_TEE_AES_CBC, |
| GSW_TEE_AES_CMAC, |
| GSW_TEE_AES_GCM, |
| }GSW_TEE_AES_ALGO_TYPE; |
| |
| typedef enum { |
| GSW_TEE_AES_128 = 1, |
| GSW_TEE_AES_192, |
| GSW_TEE_AES_256 |
| }GSW_TEE_AES_ALGO_BITS; |
| |
| typedef enum { |
| GSW_TEE_AES_PADDING_NONE = 1, |
| GSW_TEE_AES_PADDING_PKCS7 |
| }GSW_TEE_AES_PADDING_TYPE; |
| |
| typedef enum { |
| GSW_TEE_CRYPTO_ENCRYPT = 1, |
| GSW_TEE_CRYPTO_DECRYPT, |
| GSW_TEE_CRYPTO_SIGN, |
| GSW_TEE_CRYPTO_VERIFY |
| }GSW_TEE_CRYPTO_TYPE; |
| |
| typedef enum { |
| GSW_TEE_RSA_BITS_2048 = 1, |
| GSW_TEE_RSA_BITS_3072, |
| GSW_TEE_RSA_BITS_4096 |
| }GSW_TEE_RSA_BITS_TYPE; |
| |
| typedef enum { |
| GSW_TEE_RSA_ED_PADDING_NONE = 1, |
| GSW_TEE_RSA_ED_PADDING_PKCS1, |
| GSW_TEE_RSA_ED_PADDING_OAEP |
| }GSW_TEE_RSA_ED_PADDING_TYPE; |
| |
| typedef enum { |
| GSW_TEE_SV_SRC_DATA = 1, |
| GSW_TEE_SV_SRC_SHA256, |
| GSW_TEE_SV_SRC_SHA384, |
| GSW_TEE_SV_SRC_SHA512 |
| }GSW_TEE_SV_SRC_TYPE; |
| |
| typedef enum { |
| GSW_TEE_RSA_SV_PADDING_NONE = 1, |
| GSW_TEE_RSA_SV_PADDING_PKCS1_V1_5, |
| GSW_TEE_RSA_SV_PADDING_PSS |
| }GSW_TEE_RSA_SV_PADDING_TYPE; |
| |
| typedef enum { |
| GSW_TEE_ECC_ED_CURVE_ALGO_NISTP192=1, |
| GSW_TEE_ECC_ED_CURVE_ALGO_NISTP224, |
| GSW_TEE_ECC_ED_CURVE_ALGO_NISTP256, |
| GSW_TEE_ECC_ED_CURVE_ALGO_NISTP384, |
| GSW_TEE_ECC_ED_CURVE_ALGO_NISTP521 |
| }GSW_TEE_ECC_ED_CURVE_ALGO_MODE; |
| |
| typedef enum { |
| GSW_TEE_ECC_BITS_192=1, |
| GSW_TEE_ECC_BITS_224, |
| GSW_TEE_ECC_BITS_256, |
| GSW_TEE_ECC_BITS_384, |
| GSW_TEE_ECC_BITS_521 |
| }GSW_TEE_ECC_BITS_TYPE; |
| |
| typedef enum { |
| GSW_TEE_ECC_SV_CURVE_ALGO_ECDSA = 1, |
| GSW_TEE_ECC_SV_CURVE_ALGO_EDDSA, |
| }GSW_TEE_ECC_SV_CURVE_ALGO_MODE; |
| |
| typedef enum { |
| GSW_TEE_SM4_ECB = 1, |
| GSW_TEE_SM4_CBC, |
| GSW_TEE_SM4_CFB, |
| GSW_TEE_SM4_CTR, |
| GSW_TEE_SM4_OFB, |
| GSW_TEE_SM4_CMAC, |
| GSW_TEE_SM4_GCM, |
| }GSW_TEE_SM4_ALGO_TYPE; |
| |
| typedef enum { |
| GSW_TEE_SM4_PADDING_PKCS5 = 1, |
| GSW_TEE_SM4_PADDING_PKCS7 |
| }GSW_TEE_SM4_PADDING_TYPE; |
| |
| typedef struct |
| { |
| unsigned short len; /**< data len*/ |
| unsigned char data[512]; /**< key data*/ |
| } GSW_TEE_KEY_UNIT_INFO; |
| |
| typedef struct |
| { |
| unsigned int bits; /**< Public key bits*/ |
| GSW_TEE_KEY_UNIT_INFO x; /**< Public key x component*/ |
| GSW_TEE_KEY_UNIT_INFO y; /**< Public key y component*/ |
| } GSW_TEE_SM2_PUB_KEY; |
| |
| typedef struct |
| { |
| unsigned int bits; /**< Public key bits*/ |
| GSW_TEE_KEY_UNIT_INFO x; /**< Public key x component*/ |
| GSW_TEE_KEY_UNIT_INFO y; /**< Public key y component*/ |
| } GSW_TEE_ECC_PUB_KEY; |
| |
| typedef struct |
| { |
| unsigned int bits; /**< Public key bits*/ |
| GSW_TEE_KEY_UNIT_INFO n; /**< Mode of public key*/ |
| unsigned int e; /**< Power of public key*/ |
| } GSW_TEE_RSA_PUB_KEY; |
| |
| typedef struct |
| { |
| unsigned int bits; /**< Public key bits*/ |
| GSW_TEE_KEY_UNIT_INFO d; /**< Private key*/ |
| } GSW_TEE_SM2_PRI_KEY; |
| |
| typedef struct |
| { |
| unsigned int bits; /**< Public key bits*/ |
| GSW_TEE_KEY_UNIT_INFO d; /**< Private key*/ |
| GSW_TEE_ECC_ED_CURVE_ALGO_MODE curve_type; /**< Curve algorithm*/ |
| } GSW_TEE_ECC_PRI_KEY; |
| |
| typedef struct |
| { |
| GSW_TEE_KEY_UNIT_INFO n; /**< Mode of public key*/ |
| GSW_TEE_KEY_UNIT_INFO d; |
| } GSW_TEE_RSA_PRI_KEY_ND; |
| |
| typedef struct |
| { |
| GSW_TEE_KEY_UNIT_INFO p; /**< Prime factor 1*/ |
| GSW_TEE_KEY_UNIT_INFO q; /**< Prime factor 2*/ |
| GSW_TEE_KEY_UNIT_INFO dp; /**< crt powers of p*/ |
| GSW_TEE_KEY_UNIT_INFO dq; /**< crt powers of q*/ |
| GSW_TEE_KEY_UNIT_INFO ce; /**< The inverse modulo p of q*/ |
| } GSW_TEE_RSA_PRI_KEY_PQDC; |
| |
| typedef struct |
| { |
| unsigned int bits; /**< Public key bits*/ |
| union RSA_KEY_INFO{ |
| GSW_TEE_RSA_PRI_KEY_ND ne; |
| GSW_TEE_RSA_PRI_KEY_PQDC pqdc; |
| }key_info; |
| } GSW_TEE_RSA_PRI_KEY; |
| |
| typedef struct |
| { |
| GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| GSW_TEE_AES_ALGO_TYPE algo_type; /**< Algorithm type*/ |
| unsigned int in_iv_len; /**< Vector quantity length*/ |
| unsigned char iv[32]; /**< Vector quantity*/ |
| GSW_TEE_SM4_PADDING_TYPE padding; /**< Filling mode*/ |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int in_data_len; /**< Source data length*/ |
| char data[1]; /**< Source data/file name*/ |
| } GSW_TEE_SM4_IN_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| char data[1]; /**< buf Cache or file path*/ |
| } GSW_TEE_SM4_OUT_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| GSW_TEE_SV_SRC_TYPE src_type; /**< Type of data source*/ |
| GSW_TEE_DIGEST_TYPE digt_type; |
| unsigned int in_data_len; /**< Source data length*/ |
| char data[1]; /**< Source data/file name*/ |
| } GSW_TEE_SM2_SV_IN_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| char data[1]; /**< buf Cache or file path*/ |
| } GSW_TEE_SM2_SV_OUT_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int in_data_len; /**< Source data length*/ |
| char data[1]; /**< Source data/file name*/ |
| } GSW_TEE_SM2_ED_IN_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| char data[1]; /**< buf Cache or file path*/ |
| } GSW_TEE_SM2_ED_OUT_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| GSW_TEE_ECC_BITS_TYPE bits_type; /**< Algorithm bit*/ |
| GSW_TEE_ECC_SV_CURVE_ALGO_MODE curve_type; /**< Curve algorithm*/ |
| GSW_TEE_DIGEST_TYPE digt_type; |
| GSW_TEE_SV_SRC_TYPE src_type; /**< Type of data source*/ |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int in_data_len; /**< Source data length*/ |
| char data[1]; /**< Source data/file name*/ |
| } GSW_TEE_ECC_SV_IN_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| char data[1]; /**< buf Cache or file path*/ |
| } GSW_TEE_ECC_SV_OUT_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| GSW_TEE_ECC_BITS_TYPE bits_type; /**< Algorithm bit*/ |
| GSW_TEE_ECC_ED_CURVE_ALGO_MODE curve_type; /**< Curve algorithm*/ |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int in_data_len; /**< Source data length*/ |
| char data[1]; /**< Source data/file name*/ |
| } GSW_TEE_ECC_ED_IN_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| char data[1]; /**< buf Cache or file path*/ |
| } GSW_TEE_ECC_ED_OUT_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| GSW_TEE_RSA_SV_PADDING_TYPE padding; /**< Filling mode*/ |
| GSW_TEE_RSA_BITS_TYPE bits_type; /**< Algorithm bit*/ |
| GSW_TEE_SV_SRC_TYPE src_type; /**< Type of data source*/ |
| GSW_TEE_DIGEST_TYPE digt_type; |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int in_data_len; /**< Source data length*/ |
| char data[1]; /**< Source data/file name*/ |
| } GSW_TEE_RSA_SV_IN_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| char data[1]; /**< buf Cache or file path*/ |
| } GSW_TEE_RSA_SV_OUT_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| GSW_TEE_RSA_ED_PADDING_TYPE padding; /**< Filling mode*/ |
| GSW_TEE_RSA_BITS_TYPE bits_type; /**< Algorithm bit*/ |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int in_data_len; /**< Source data length*/ |
| char data[1]; /**< Source data/file name*/ |
| } GSW_TEE_RSA_ED_IN_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| char data[1]; /**< buf Cache or file path*/ |
| } GSW_TEE_RSA_ED_OUT_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| GSW_TEE_AES_ALGO_TYPE algo_type; /**< Algorithm type*/ |
| unsigned int in_iv_len; /**< Vector quantity length*/ |
| unsigned char iv[32]; /**< Vector quantity*/ |
| GSW_TEE_AES_PADDING_TYPE padding; /**< Filling mode*/ |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int in_data_len; /**< Source data length*/ |
| char data[1]; /**< Source data/file name*/ |
| } GSW_TEE_AES_IN_PARAM; |
| |
| typedef struct |
| { |
| GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| char data[1]; /**< buf Cache or file path*/ |
| } GSW_TEE_AES_OUT_PARAM; |
| |
| |
| |
| /** |
| * @brief init tee sdk |
| * @param [in] None |
| * @param [out] None |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_sdk_init(void); |
| |
| /** |
| * @brief read sensitive data from tee |
| * @param [in] char* in_obj_name :Sensitive data name |
| * @param [in] unsigned int* p_out_buf_len:The size of sensitive data output cache |
| * @param [out] char* out_buf:Cache of sensitive data output |
| * @param [out] unsigned int* p_out_buf_len:Sensitive data length |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_read_secure_data(const char* in_obj_name, char* out_buf, unsigned int* p_out_buf_len); |
| |
| /** |
| * @brief write sensitive data to tee |
| * @param [in] char* in_obj_name :Sensitive data name |
| * @param [in] char* in_buf:A cache for writing sensitive data |
| * @param [out] unsigned int in_buf_len:Sensitive data length |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_write_secure_data(const char* in_obj_name, char* in_buf, unsigned int in_buf_len); |
| |
| /** |
| * @brief delete sensitive data from tee |
| * @param [in] char* in_obj_name :Sensitive data name |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_delete_secure_data(const char* in_obj_name); |
| |
| /** |
| * @brief check sensitive data from tee |
| * @param [in] char* in_obj_name :Sensitive data name |
| * @retval GSW_HAL_SUCCESS is exist\ other is not exist or fail |
| */ |
| int32_t gsw_tee_check_secure_data(const char* in_obj_name); |
| |
| /** |
| * @brief digest algorithm |
| * @param [in] char* in_data :Source data/file name |
| * @param [in] unsigned int in_data_len :Source data length |
| * @param [in] unsigned int* p_out_buf_len:The size of Destination cache |
| * @param [in] GSW_TEE_PARAM_TYPE in_param: in_data param type |
| * @param [in] GSW_TEE_DIGEST_TYPE in_digest: digest algo type |
| * @param [out] char *out_buf:Destination cache |
| * @param [out] unsigned int* p_out_buf_len:Destination data length |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_digest_algo(char* in_data, unsigned int in_data_len, char *out_buf, unsigned int* p_out_buf_len,GSW_TEE_PARAM_TYPE in_param,GSW_TEE_DIGEST_TYPE in_digest); |
| |
| /** |
| * @brief aes algorithm |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_AES_IN_PARAM* in_param :Entry information |
| * @param [in/out] GSW_TEE_AES_OUT_PARAM out_param :Exit message |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_aes_algo(char* in_obj_name, GSW_TEE_AES_IN_PARAM* in_param, GSW_TEE_AES_OUT_PARAM* out_param); |
| |
| /** |
| * @brief generate random |
| * @param [in] unsigned int in_len :generate random bits |
| * @param [in] GSW_TEE_PARAM_TYPE out_param:out_buf param type |
| * @param [out/in] char *out_buf:Destination cache/file name |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_gen_random(char *out_buf, unsigned int in_len,GSW_TEE_PARAM_TYPE out_param); |
| |
| /** |
| * @brief rsa Encryption and decryption algorithm |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_RSA_ED_IN_PARAM * in_param:Entry information |
| * @param [in/out] GSW_TEE_RSA_ED_OUT_PARAM * out_param:Exit message |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_rsa_ed_algo(char* in_obj_name, GSW_TEE_RSA_ED_IN_PARAM * in_param, GSW_TEE_RSA_ED_OUT_PARAM * out_param); |
| |
| /** |
| * @brief rsa Signature verification algorithm |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_RSA_SV_IN_PARAM* in_param :Source data/file name |
| * @param [in/out] GSW_TEE_RSA_SV_OUT_PARAM* out_param :Source data length |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_rsa_sv_algo(char* in_obj_name, GSW_TEE_RSA_SV_IN_PARAM* in_param, GSW_TEE_RSA_SV_OUT_PARAM* out_param); |
| |
| /** |
| * @brief ecc Encryption and decryption algorithm |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_ECC_ED_IN_PARAM * in_param:Entry information |
| * @param [in/out] GSW_TEE_ECC_ED_OUT_PARAM * out_param:Exit message |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_ecc_ed_algo(char* in_obj_name,GSW_TEE_ECC_ED_IN_PARAM * in_param, GSW_TEE_ECC_ED_OUT_PARAM * out_param); |
| |
| /** |
| * @brief ecc Signature verification algorithm |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_ECC_SV_IN_PARAM* in_param :Source data/file name |
| * @param [in/out] GSW_TEE_ECC_SV_OUT_PARAM* out_param :Source data length |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_ecc_sv_algo(char* in_obj_name,GSW_TEE_ECC_SV_IN_PARAM * in_param, GSW_TEE_ECC_SV_OUT_PARAM * out_param); |
| |
| /** |
| * @brief sm2 Encryption and decryption algorithm |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_SM2_ED_IN_PARAM * in_param:Entry information |
| * @param [in/out] GSW_TEE_SM2_ED_OUT_PARAM * out_param:Exit message |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_sm2_ed_algo(char* in_obj_name, GSW_TEE_SM2_ED_IN_PARAM* in_param, GSW_TEE_SM2_ED_OUT_PARAM *out_param); |
| |
| /** |
| * @brief sm2 Signature verification algorithm |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_SM2_SV_IN_PARAM * in_param:Entry information |
| * @param [in/out] GSW_TEE_SM2_SV_OUT_PARAM * out_param:Exit message |
| * @retval GSW_HAL_SUCCESS is success\other is failL |
| */ |
| int32_t gsw_tee_sm2_sv_algo(char* in_obj_name, GSW_TEE_PARAM_TYPE* in_param, GSW_TEE_PARAM_TYPE* out_param); |
| |
| /** |
| * @brief sm3 algorithm |
| * @param [in] char* in_data :Source data/file name |
| * @param [in] unsigned int in_data_len :Source data length |
| * @param [in] unsigned int* p_out_buf_len:The size of Destination cache |
| * @param [in] GSW_TEE_PARAM_TYPE in_param: in_data param type |
| * @param [out] char *out_buf:Destination cache |
| * @param [out] unsigned int* p_out_buf_len:Destination data length |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_sm3_algo(char* in_data, unsigned int in_data_len, char *out_buf, unsigned int* p_out_buf_len,GSW_TEE_PARAM_TYPE in_param); |
| |
| /** |
| * @brief sm4 algorithm |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_AM4_IN_PARAM* in_param :Entry information |
| * @param [in/out] GSW_TEE_AM4_OUT_PARAM out_param :Exit message |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_sm4_algo(char* in_obj_name, GSW_TEE_SM4_IN_PARAM* in_param, GSW_TEE_SM4_OUT_PARAM *out_param); |
| |
| /** |
| * @brief key import |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] char* in_data :Source data/file name |
| * @param [in] unsigned int in_data_len :Source data length |
| * @param [in] bool permanent :Key import type |
| * @param [out] void *out_buf :Returns key information |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_aes_key_import(char* in_obj_name, char* in_data, unsigned int in_data_len,void *out_buf,bool permanent); |
| |
| /** |
| * @brief rsa key import |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_RSA_PUB_KEY* in_pub_data :Public key information |
| * @param [in] GSW_TEE_RSA_PRI_KEY* in_pri_data :Private key information |
| * @param [in] bool permanent :Key import type |
| * @param [out] void *out_buf :Returns key information |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_rsa_key_import(char* in_obj_name, GSW_TEE_RSA_PUB_KEY* in_pub_data,GSW_TEE_RSA_PRI_KEY* in_pri_data,void *out_buf,bool permanent); |
| |
| /** |
| * @brief ecc key import |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_ECC_PUB_KEY* in_data :Public key information |
| * @param [in] GSW_TEE_ECC_PRI_KEY* in_data :Private key information |
| * @param [in] bool permanent :Key import type |
| * @param [out] void *out_buf :Returns key information |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_ecc_key_import(char* in_obj_name, GSW_TEE_ECC_PUB_KEY* in_pub_data, GSW_TEE_ECC_PRI_KEY* in_pri_data,void *out_buf,bool permanent); |
| |
| /** |
| * @brief ecc key import |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] GSW_TEE_SM2_PUB_KEY* in_data :Public key information |
| * @param [in] GSW_TEE_SM2_PRI_KEY* in_data :Private key information |
| * @param [in] bool permanent :Key import type |
| * @param [out] void *out_buf :Returns key information |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_sm2_key_import(char* in_obj_name, GSW_TEE_SM2_PUB_KEY* in_pub_data, GSW_TEE_SM2_PRI_KEY* in_pri_data,void *out_buf,bool permanent); |
| |
| /** |
| * @brief sm4 key import |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] char* in_data :Source data/file name |
| * @param [in] unsigned int in_data_len :Source data length |
| * @param [in] bool permanent :Key import type |
| * @param [out] void *out_buf :Returns key information |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_sm4_key_import(char* in_obj_name, char* in_data, unsigned int in_data_len,void *out_buf,bool permanent); |
| |
| /** |
| * @brief key export |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] unsigned int* p_out_buf_len:The size of Destination cache |
| * @param [out] char *out_buf:Destination cache/file name |
| * @param [out] unsigned int* p_out_buf_len:Destination data length |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_aes_key_export(char* in_obj_name, char *out_buf, unsigned int* p_out_buf_len); |
| |
| /** |
| * @brief key export |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [out] GSW_TEE_RSA_PUB_KEY*out_buf:Destination cache |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_rsa_pub_key_export(char* in_obj_name, GSW_TEE_RSA_PUB_KEY*out_buf); |
| |
| /** |
| * @brief ecc key export |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [out] GSW_TEE_ECC_PUB_KEY *out_buf:Destination cache |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_ecc_pub_key_export(char* in_obj_name, GSW_TEE_ECC_PUB_KEY*out_buf); |
| |
| /** |
| * @brief sm2 key export |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [out] GSW_TEE_SM2_PUB_KEY *out_buf:Destination cache |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_sm2_pub_key_export(char* in_obj_name, GSW_TEE_SM2_PUB_KEY*out_buf); |
| |
| /** |
| * @brief sm4 key export |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @param [in] unsigned int* p_out_buf_len:The size of Destination cache |
| * @param [out] char *out_buf:Destination cache/file name |
| * @param [out] unsigned int* p_out_buf_len:Destination data length |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_sm4_key_export(char* in_obj_name, char *out_buf, unsigned int* p_out_buf_len); |
| |
| /** |
| * @brief delete key |
| * @param [in] char* in_obj_name :Key name or key information structure |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_key_delete(char* in_obj_name); |
| |
| /** |
| * @brief deinit tee sdk |
| * @param [in] None |
| * @param [out] None |
| * @retval GSW_HAL_SUCCESS is success\other is fail |
| */ |
| int32_t gsw_tee_sdk_deinit(void); |
| |