b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame^] | 1 | #include <stdlib.h> |
| 2 | #include <stdint.h> |
| 3 | #include <string.h> |
| 4 | #include <stdbool.h> |
| 5 | #include <stdio.h> |
| 6 | |
| 7 | |
| 8 | #define GSW_HAL_SUCCESS 0 |
| 9 | #define GSW_HAL_FAIL -1 |
| 10 | #define GSW_HAL_MEM_INVAILD -2 |
| 11 | #define GSW_HAL_NOFOUND -3 |
| 12 | |
| 13 | typedef enum { |
| 14 | GSW_TEE_PARAM_DATA = 1, |
| 15 | GSW_TEE_PARAM_FILE |
| 16 | }GSW_TEE_PARAM_TYPE; |
| 17 | |
| 18 | typedef enum { |
| 19 | GSW_TEE_DIGEST_MD5 = 1, |
| 20 | GSW_TEE_DIGEST_SHA1, |
| 21 | GSW_TEE_DIGEST_SHA256, |
| 22 | }GSW_TEE_DIGEST_TYPE; |
| 23 | |
| 24 | typedef enum { |
| 25 | GSW_TEE_AES_ECB = 1, |
| 26 | GSW_TEE_AES_CBC, |
| 27 | GSW_TEE_AES_CMAC, |
| 28 | GSW_TEE_AES_GCM, |
| 29 | }GSW_TEE_AES_ALGO_TYPE; |
| 30 | |
| 31 | typedef enum { |
| 32 | GSW_TEE_AES_128 = 1, |
| 33 | GSW_TEE_AES_192, |
| 34 | GSW_TEE_AES_256 |
| 35 | }GSW_TEE_AES_ALGO_BITS; |
| 36 | |
| 37 | typedef enum { |
| 38 | GSW_TEE_AES_PADDING_NONE = 1, |
| 39 | GSW_TEE_AES_PADDING_PKCS7 |
| 40 | }GSW_TEE_AES_PADDING_TYPE; |
| 41 | |
| 42 | typedef enum { |
| 43 | GSW_TEE_CRYPTO_ENCRYPT = 1, |
| 44 | GSW_TEE_CRYPTO_DECRYPT, |
| 45 | GSW_TEE_CRYPTO_SIGN, |
| 46 | GSW_TEE_CRYPTO_VERIFY |
| 47 | }GSW_TEE_CRYPTO_TYPE; |
| 48 | |
| 49 | typedef enum { |
| 50 | GSW_TEE_RSA_BITS_2048 = 1, |
| 51 | GSW_TEE_RSA_BITS_3072, |
| 52 | GSW_TEE_RSA_BITS_4096 |
| 53 | }GSW_TEE_RSA_BITS_TYPE; |
| 54 | |
| 55 | typedef enum { |
| 56 | GSW_TEE_RSA_ED_PADDING_NONE = 1, |
| 57 | GSW_TEE_RSA_ED_PADDING_PKCS1, |
| 58 | GSW_TEE_RSA_ED_PADDING_OAEP |
| 59 | }GSW_TEE_RSA_ED_PADDING_TYPE; |
| 60 | |
| 61 | typedef enum { |
| 62 | GSW_TEE_SV_SRC_DATA = 1, |
| 63 | GSW_TEE_SV_SRC_SHA256, |
| 64 | GSW_TEE_SV_SRC_SHA384, |
| 65 | GSW_TEE_SV_SRC_SHA512 |
| 66 | }GSW_TEE_SV_SRC_TYPE; |
| 67 | |
| 68 | typedef enum { |
| 69 | GSW_TEE_RSA_SV_PADDING_NONE = 1, |
| 70 | GSW_TEE_RSA_SV_PADDING_PKCS1_V1_5, |
| 71 | GSW_TEE_RSA_SV_PADDING_PSS |
| 72 | }GSW_TEE_RSA_SV_PADDING_TYPE; |
| 73 | |
| 74 | typedef enum { |
| 75 | GSW_TEE_ECC_ED_CURVE_ALGO_NISTP192=1, |
| 76 | GSW_TEE_ECC_ED_CURVE_ALGO_NISTP224, |
| 77 | GSW_TEE_ECC_ED_CURVE_ALGO_NISTP256, |
| 78 | GSW_TEE_ECC_ED_CURVE_ALGO_NISTP384, |
| 79 | GSW_TEE_ECC_ED_CURVE_ALGO_NISTP521 |
| 80 | }GSW_TEE_ECC_ED_CURVE_ALGO_MODE; |
| 81 | |
| 82 | typedef enum { |
| 83 | GSW_TEE_ECC_BITS_192=1, |
| 84 | GSW_TEE_ECC_BITS_224, |
| 85 | GSW_TEE_ECC_BITS_256, |
| 86 | GSW_TEE_ECC_BITS_384, |
| 87 | GSW_TEE_ECC_BITS_521 |
| 88 | }GSW_TEE_ECC_BITS_TYPE; |
| 89 | |
| 90 | typedef enum { |
| 91 | GSW_TEE_ECC_SV_CURVE_ALGO_ECDSA = 1, |
| 92 | GSW_TEE_ECC_SV_CURVE_ALGO_EDDSA, |
| 93 | }GSW_TEE_ECC_SV_CURVE_ALGO_MODE; |
| 94 | |
| 95 | typedef enum { |
| 96 | GSW_TEE_SM4_ECB = 1, |
| 97 | GSW_TEE_SM4_CBC, |
| 98 | GSW_TEE_SM4_CFB, |
| 99 | GSW_TEE_SM4_CTR, |
| 100 | GSW_TEE_SM4_OFB, |
| 101 | GSW_TEE_SM4_CMAC, |
| 102 | GSW_TEE_SM4_GCM, |
| 103 | }GSW_TEE_SM4_ALGO_TYPE; |
| 104 | |
| 105 | typedef enum { |
| 106 | GSW_TEE_SM4_PADDING_PKCS5 = 1, |
| 107 | GSW_TEE_SM4_PADDING_PKCS7 |
| 108 | }GSW_TEE_SM4_PADDING_TYPE; |
| 109 | |
| 110 | typedef struct |
| 111 | { |
| 112 | unsigned short len; /**< data len*/ |
| 113 | unsigned char data[512]; /**< key data*/ |
| 114 | } GSW_TEE_KEY_UNIT_INFO; |
| 115 | |
| 116 | typedef struct |
| 117 | { |
| 118 | unsigned int bits; /**< Public key bits*/ |
| 119 | GSW_TEE_KEY_UNIT_INFO x; /**< Public key x component*/ |
| 120 | GSW_TEE_KEY_UNIT_INFO y; /**< Public key y component*/ |
| 121 | } GSW_TEE_SM2_PUB_KEY; |
| 122 | |
| 123 | typedef struct |
| 124 | { |
| 125 | unsigned int bits; /**< Public key bits*/ |
| 126 | GSW_TEE_KEY_UNIT_INFO x; /**< Public key x component*/ |
| 127 | GSW_TEE_KEY_UNIT_INFO y; /**< Public key y component*/ |
| 128 | } GSW_TEE_ECC_PUB_KEY; |
| 129 | |
| 130 | typedef struct |
| 131 | { |
| 132 | unsigned int bits; /**< Public key bits*/ |
| 133 | GSW_TEE_KEY_UNIT_INFO n; /**< Mode of public key*/ |
| 134 | unsigned int e; /**< Power of public key*/ |
| 135 | } GSW_TEE_RSA_PUB_KEY; |
| 136 | |
| 137 | typedef struct |
| 138 | { |
| 139 | unsigned int bits; /**< Public key bits*/ |
| 140 | GSW_TEE_KEY_UNIT_INFO d; /**< Private key*/ |
| 141 | } GSW_TEE_SM2_PRI_KEY; |
| 142 | |
| 143 | typedef struct |
| 144 | { |
| 145 | unsigned int bits; /**< Public key bits*/ |
| 146 | GSW_TEE_KEY_UNIT_INFO d; /**< Private key*/ |
| 147 | GSW_TEE_ECC_ED_CURVE_ALGO_MODE curve_type; /**< Curve algorithm*/ |
| 148 | } GSW_TEE_ECC_PRI_KEY; |
| 149 | |
| 150 | typedef struct |
| 151 | { |
| 152 | GSW_TEE_KEY_UNIT_INFO n; /**< Mode of public key*/ |
| 153 | GSW_TEE_KEY_UNIT_INFO d; |
| 154 | } GSW_TEE_RSA_PRI_KEY_ND; |
| 155 | |
| 156 | typedef struct |
| 157 | { |
| 158 | GSW_TEE_KEY_UNIT_INFO p; /**< Prime factor 1*/ |
| 159 | GSW_TEE_KEY_UNIT_INFO q; /**< Prime factor 2*/ |
| 160 | GSW_TEE_KEY_UNIT_INFO dp; /**< crt powers of p*/ |
| 161 | GSW_TEE_KEY_UNIT_INFO dq; /**< crt powers of q*/ |
| 162 | GSW_TEE_KEY_UNIT_INFO ce; /**< The inverse modulo p of q*/ |
| 163 | } GSW_TEE_RSA_PRI_KEY_PQDC; |
| 164 | |
| 165 | typedef struct |
| 166 | { |
| 167 | unsigned int bits; /**< Public key bits*/ |
| 168 | union RSA_KEY_INFO{ |
| 169 | GSW_TEE_RSA_PRI_KEY_ND ne; |
| 170 | GSW_TEE_RSA_PRI_KEY_PQDC pqdc; |
| 171 | }key_info; |
| 172 | } GSW_TEE_RSA_PRI_KEY; |
| 173 | |
| 174 | typedef struct |
| 175 | { |
| 176 | GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| 177 | GSW_TEE_AES_ALGO_TYPE algo_type; /**< Algorithm type*/ |
| 178 | unsigned int in_iv_len; /**< Vector quantity length*/ |
| 179 | unsigned char iv[32]; /**< Vector quantity*/ |
| 180 | GSW_TEE_SM4_PADDING_TYPE padding; /**< Filling mode*/ |
| 181 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 182 | unsigned int in_data_len; /**< Source data length*/ |
| 183 | char data[1]; /**< Source data/file name*/ |
| 184 | } GSW_TEE_SM4_IN_PARAM; |
| 185 | |
| 186 | typedef struct |
| 187 | { |
| 188 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 189 | unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| 190 | char data[1]; /**< buf Cache or file path*/ |
| 191 | } GSW_TEE_SM4_OUT_PARAM; |
| 192 | |
| 193 | typedef struct |
| 194 | { |
| 195 | GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| 196 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 197 | GSW_TEE_SV_SRC_TYPE src_type; /**< Type of data source*/ |
| 198 | GSW_TEE_DIGEST_TYPE digt_type; |
| 199 | unsigned int in_data_len; /**< Source data length*/ |
| 200 | char data[1]; /**< Source data/file name*/ |
| 201 | } GSW_TEE_SM2_SV_IN_PARAM; |
| 202 | |
| 203 | typedef struct |
| 204 | { |
| 205 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 206 | unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| 207 | char data[1]; /**< buf Cache or file path*/ |
| 208 | } GSW_TEE_SM2_SV_OUT_PARAM; |
| 209 | |
| 210 | typedef struct |
| 211 | { |
| 212 | GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| 213 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 214 | unsigned int in_data_len; /**< Source data length*/ |
| 215 | char data[1]; /**< Source data/file name*/ |
| 216 | } GSW_TEE_SM2_ED_IN_PARAM; |
| 217 | |
| 218 | typedef struct |
| 219 | { |
| 220 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 221 | unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| 222 | char data[1]; /**< buf Cache or file path*/ |
| 223 | } GSW_TEE_SM2_ED_OUT_PARAM; |
| 224 | |
| 225 | typedef struct |
| 226 | { |
| 227 | GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| 228 | GSW_TEE_ECC_BITS_TYPE bits_type; /**< Algorithm bit*/ |
| 229 | GSW_TEE_ECC_SV_CURVE_ALGO_MODE curve_type; /**< Curve algorithm*/ |
| 230 | GSW_TEE_DIGEST_TYPE digt_type; |
| 231 | GSW_TEE_SV_SRC_TYPE src_type; /**< Type of data source*/ |
| 232 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 233 | unsigned int in_data_len; /**< Source data length*/ |
| 234 | char data[1]; /**< Source data/file name*/ |
| 235 | } GSW_TEE_ECC_SV_IN_PARAM; |
| 236 | |
| 237 | typedef struct |
| 238 | { |
| 239 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 240 | unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| 241 | char data[1]; /**< buf Cache or file path*/ |
| 242 | } GSW_TEE_ECC_SV_OUT_PARAM; |
| 243 | |
| 244 | typedef struct |
| 245 | { |
| 246 | GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| 247 | GSW_TEE_ECC_BITS_TYPE bits_type; /**< Algorithm bit*/ |
| 248 | GSW_TEE_ECC_ED_CURVE_ALGO_MODE curve_type; /**< Curve algorithm*/ |
| 249 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 250 | unsigned int in_data_len; /**< Source data length*/ |
| 251 | char data[1]; /**< Source data/file name*/ |
| 252 | } GSW_TEE_ECC_ED_IN_PARAM; |
| 253 | |
| 254 | typedef struct |
| 255 | { |
| 256 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 257 | unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| 258 | char data[1]; /**< buf Cache or file path*/ |
| 259 | } GSW_TEE_ECC_ED_OUT_PARAM; |
| 260 | |
| 261 | typedef struct |
| 262 | { |
| 263 | GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| 264 | GSW_TEE_RSA_SV_PADDING_TYPE padding; /**< Filling mode*/ |
| 265 | GSW_TEE_RSA_BITS_TYPE bits_type; /**< Algorithm bit*/ |
| 266 | GSW_TEE_SV_SRC_TYPE src_type; /**< Type of data source*/ |
| 267 | GSW_TEE_DIGEST_TYPE digt_type; |
| 268 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 269 | unsigned int in_data_len; /**< Source data length*/ |
| 270 | char data[1]; /**< Source data/file name*/ |
| 271 | } GSW_TEE_RSA_SV_IN_PARAM; |
| 272 | |
| 273 | typedef struct |
| 274 | { |
| 275 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 276 | unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| 277 | char data[1]; /**< buf Cache or file path*/ |
| 278 | } GSW_TEE_RSA_SV_OUT_PARAM; |
| 279 | |
| 280 | typedef struct |
| 281 | { |
| 282 | GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| 283 | GSW_TEE_RSA_ED_PADDING_TYPE padding; /**< Filling mode*/ |
| 284 | GSW_TEE_RSA_BITS_TYPE bits_type; /**< Algorithm bit*/ |
| 285 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 286 | unsigned int in_data_len; /**< Source data length*/ |
| 287 | char data[1]; /**< Source data/file name*/ |
| 288 | } GSW_TEE_RSA_ED_IN_PARAM; |
| 289 | |
| 290 | typedef struct |
| 291 | { |
| 292 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 293 | unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| 294 | char data[1]; /**< buf Cache or file path*/ |
| 295 | } GSW_TEE_RSA_ED_OUT_PARAM; |
| 296 | |
| 297 | typedef struct |
| 298 | { |
| 299 | GSW_TEE_CRYPTO_TYPE crypto_type; /**< Type of operation*/ |
| 300 | GSW_TEE_AES_ALGO_TYPE algo_type; /**< Algorithm type*/ |
| 301 | unsigned int in_iv_len; /**< Vector quantity length*/ |
| 302 | unsigned char iv[32]; /**< Vector quantity*/ |
| 303 | GSW_TEE_AES_PADDING_TYPE padding; /**< Filling mode*/ |
| 304 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 305 | unsigned int in_data_len; /**< Source data length*/ |
| 306 | char data[1]; /**< Source data/file name*/ |
| 307 | } GSW_TEE_AES_IN_PARAM; |
| 308 | |
| 309 | typedef struct |
| 310 | { |
| 311 | GSW_TEE_PARAM_TYPE data_type; /**< data type*/ |
| 312 | unsigned int* p_out_buf_len; /**< File length or buf size*/ |
| 313 | char data[1]; /**< buf Cache or file path*/ |
| 314 | } GSW_TEE_AES_OUT_PARAM; |
| 315 | |
| 316 | |
| 317 | |
| 318 | /** |
| 319 | * @brief init tee sdk |
| 320 | * @param [in] None |
| 321 | * @param [out] None |
| 322 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 323 | */ |
| 324 | int32_t gsw_tee_sdk_init(void); |
| 325 | |
| 326 | /** |
| 327 | * @brief read sensitive data from tee |
| 328 | * @param [in] char* in_obj_name :Sensitive data name |
| 329 | * @param [in] unsigned int* p_out_buf_len:The size of sensitive data output cache |
| 330 | * @param [out] char* out_buf:Cache of sensitive data output |
| 331 | * @param [out] unsigned int* p_out_buf_len:Sensitive data length |
| 332 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 333 | */ |
| 334 | int32_t gsw_tee_read_secure_data(const char* in_obj_name, char* out_buf, unsigned int* p_out_buf_len); |
| 335 | |
| 336 | /** |
| 337 | * @brief write sensitive data to tee |
| 338 | * @param [in] char* in_obj_name :Sensitive data name |
| 339 | * @param [in] char* in_buf:A cache for writing sensitive data |
| 340 | * @param [out] unsigned int in_buf_len:Sensitive data length |
| 341 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 342 | */ |
| 343 | int32_t gsw_tee_write_secure_data(const char* in_obj_name, char* in_buf, unsigned int in_buf_len); |
| 344 | |
| 345 | /** |
| 346 | * @brief delete sensitive data from tee |
| 347 | * @param [in] char* in_obj_name :Sensitive data name |
| 348 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 349 | */ |
| 350 | int32_t gsw_tee_delete_secure_data(const char* in_obj_name); |
| 351 | |
| 352 | /** |
| 353 | * @brief check sensitive data from tee |
| 354 | * @param [in] char* in_obj_name :Sensitive data name |
| 355 | * @retval GSW_HAL_SUCCESS is exist\ other is not exist or fail |
| 356 | */ |
| 357 | int32_t gsw_tee_check_secure_data(const char* in_obj_name); |
| 358 | |
| 359 | /** |
| 360 | * @brief digest algorithm |
| 361 | * @param [in] char* in_data :Source data/file name |
| 362 | * @param [in] unsigned int in_data_len :Source data length |
| 363 | * @param [in] unsigned int* p_out_buf_len:The size of Destination cache |
| 364 | * @param [in] GSW_TEE_PARAM_TYPE in_param: in_data param type |
| 365 | * @param [in] GSW_TEE_DIGEST_TYPE in_digest: digest algo type |
| 366 | * @param [out] char *out_buf:Destination cache |
| 367 | * @param [out] unsigned int* p_out_buf_len:Destination data length |
| 368 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 369 | */ |
| 370 | 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); |
| 371 | |
| 372 | /** |
| 373 | * @brief aes algorithm |
| 374 | * @param [in] char* in_obj_name :Key name or key information structure |
| 375 | * @param [in] GSW_TEE_AES_IN_PARAM* in_param :Entry information |
| 376 | * @param [in/out] GSW_TEE_AES_OUT_PARAM out_param :Exit message |
| 377 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 378 | */ |
| 379 | int32_t gsw_tee_aes_algo(char* in_obj_name, GSW_TEE_AES_IN_PARAM* in_param, GSW_TEE_AES_OUT_PARAM* out_param); |
| 380 | |
| 381 | /** |
| 382 | * @brief generate random |
| 383 | * @param [in] unsigned int in_len :generate random bits |
| 384 | * @param [in] GSW_TEE_PARAM_TYPE out_param:out_buf param type |
| 385 | * @param [out/in] char *out_buf:Destination cache/file name |
| 386 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 387 | */ |
| 388 | int32_t gsw_tee_gen_random(char *out_buf, unsigned int in_len,GSW_TEE_PARAM_TYPE out_param); |
| 389 | |
| 390 | /** |
| 391 | * @brief rsa Encryption and decryption algorithm |
| 392 | * @param [in] char* in_obj_name :Key name or key information structure |
| 393 | * @param [in] GSW_TEE_RSA_ED_IN_PARAM * in_param:Entry information |
| 394 | * @param [in/out] GSW_TEE_RSA_ED_OUT_PARAM * out_param:Exit message |
| 395 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 396 | */ |
| 397 | 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); |
| 398 | |
| 399 | /** |
| 400 | * @brief rsa Signature verification algorithm |
| 401 | * @param [in] char* in_obj_name :Key name or key information structure |
| 402 | * @param [in] GSW_TEE_RSA_SV_IN_PARAM* in_param :Source data/file name |
| 403 | * @param [in/out] GSW_TEE_RSA_SV_OUT_PARAM* out_param :Source data length |
| 404 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 405 | */ |
| 406 | 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); |
| 407 | |
| 408 | /** |
| 409 | * @brief ecc Encryption and decryption algorithm |
| 410 | * @param [in] char* in_obj_name :Key name or key information structure |
| 411 | * @param [in] GSW_TEE_ECC_ED_IN_PARAM * in_param:Entry information |
| 412 | * @param [in/out] GSW_TEE_ECC_ED_OUT_PARAM * out_param:Exit message |
| 413 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 414 | */ |
| 415 | 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); |
| 416 | |
| 417 | /** |
| 418 | * @brief ecc Signature verification algorithm |
| 419 | * @param [in] char* in_obj_name :Key name or key information structure |
| 420 | * @param [in] GSW_TEE_ECC_SV_IN_PARAM* in_param :Source data/file name |
| 421 | * @param [in/out] GSW_TEE_ECC_SV_OUT_PARAM* out_param :Source data length |
| 422 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 423 | */ |
| 424 | 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); |
| 425 | |
| 426 | /** |
| 427 | * @brief sm2 Encryption and decryption algorithm |
| 428 | * @param [in] char* in_obj_name :Key name or key information structure |
| 429 | * @param [in] GSW_TEE_SM2_ED_IN_PARAM * in_param:Entry information |
| 430 | * @param [in/out] GSW_TEE_SM2_ED_OUT_PARAM * out_param:Exit message |
| 431 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 432 | */ |
| 433 | 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); |
| 434 | |
| 435 | /** |
| 436 | * @brief sm2 Signature verification algorithm |
| 437 | * @param [in] char* in_obj_name :Key name or key information structure |
| 438 | * @param [in] GSW_TEE_SM2_SV_IN_PARAM * in_param:Entry information |
| 439 | * @param [in/out] GSW_TEE_SM2_SV_OUT_PARAM * out_param:Exit message |
| 440 | * @retval GSW_HAL_SUCCESS is success\other is failL |
| 441 | */ |
| 442 | int32_t gsw_tee_sm2_sv_algo(char* in_obj_name, GSW_TEE_PARAM_TYPE* in_param, GSW_TEE_PARAM_TYPE* out_param); |
| 443 | |
| 444 | /** |
| 445 | * @brief sm3 algorithm |
| 446 | * @param [in] char* in_data :Source data/file name |
| 447 | * @param [in] unsigned int in_data_len :Source data length |
| 448 | * @param [in] unsigned int* p_out_buf_len:The size of Destination cache |
| 449 | * @param [in] GSW_TEE_PARAM_TYPE in_param: in_data param type |
| 450 | * @param [out] char *out_buf:Destination cache |
| 451 | * @param [out] unsigned int* p_out_buf_len:Destination data length |
| 452 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 453 | */ |
| 454 | 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); |
| 455 | |
| 456 | /** |
| 457 | * @brief sm4 algorithm |
| 458 | * @param [in] char* in_obj_name :Key name or key information structure |
| 459 | * @param [in] GSW_TEE_AM4_IN_PARAM* in_param :Entry information |
| 460 | * @param [in/out] GSW_TEE_AM4_OUT_PARAM out_param :Exit message |
| 461 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 462 | */ |
| 463 | int32_t gsw_tee_sm4_algo(char* in_obj_name, GSW_TEE_SM4_IN_PARAM* in_param, GSW_TEE_SM4_OUT_PARAM *out_param); |
| 464 | |
| 465 | /** |
| 466 | * @brief key import |
| 467 | * @param [in] char* in_obj_name :Key name or key information structure |
| 468 | * @param [in] char* in_data :Source data/file name |
| 469 | * @param [in] unsigned int in_data_len :Source data length |
| 470 | * @param [in] bool permanent :Key import type |
| 471 | * @param [out] void *out_buf :Returns key information |
| 472 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 473 | */ |
| 474 | int32_t gsw_tee_aes_key_import(char* in_obj_name, char* in_data, unsigned int in_data_len,void *out_buf,bool permanent); |
| 475 | |
| 476 | /** |
| 477 | * @brief rsa key import |
| 478 | * @param [in] char* in_obj_name :Key name or key information structure |
| 479 | * @param [in] GSW_TEE_RSA_PUB_KEY* in_pub_data :Public key information |
| 480 | * @param [in] GSW_TEE_RSA_PRI_KEY* in_pri_data :Private key information |
| 481 | * @param [in] bool permanent :Key import type |
| 482 | * @param [out] void *out_buf :Returns key information |
| 483 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 484 | */ |
| 485 | 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); |
| 486 | |
| 487 | /** |
| 488 | * @brief ecc key import |
| 489 | * @param [in] char* in_obj_name :Key name or key information structure |
| 490 | * @param [in] GSW_TEE_ECC_PUB_KEY* in_data :Public key information |
| 491 | * @param [in] GSW_TEE_ECC_PRI_KEY* in_data :Private key information |
| 492 | * @param [in] bool permanent :Key import type |
| 493 | * @param [out] void *out_buf :Returns key information |
| 494 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 495 | */ |
| 496 | 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); |
| 497 | |
| 498 | /** |
| 499 | * @brief ecc key import |
| 500 | * @param [in] char* in_obj_name :Key name or key information structure |
| 501 | * @param [in] GSW_TEE_SM2_PUB_KEY* in_data :Public key information |
| 502 | * @param [in] GSW_TEE_SM2_PRI_KEY* in_data :Private key information |
| 503 | * @param [in] bool permanent :Key import type |
| 504 | * @param [out] void *out_buf :Returns key information |
| 505 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 506 | */ |
| 507 | 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); |
| 508 | |
| 509 | /** |
| 510 | * @brief sm4 key import |
| 511 | * @param [in] char* in_obj_name :Key name or key information structure |
| 512 | * @param [in] char* in_data :Source data/file name |
| 513 | * @param [in] unsigned int in_data_len :Source data length |
| 514 | * @param [in] bool permanent :Key import type |
| 515 | * @param [out] void *out_buf :Returns key information |
| 516 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 517 | */ |
| 518 | int32_t gsw_tee_sm4_key_import(char* in_obj_name, char* in_data, unsigned int in_data_len,void *out_buf,bool permanent); |
| 519 | |
| 520 | /** |
| 521 | * @brief key export |
| 522 | * @param [in] char* in_obj_name :Key name or key information structure |
| 523 | * @param [in] unsigned int* p_out_buf_len:The size of Destination cache |
| 524 | * @param [out] char *out_buf:Destination cache/file name |
| 525 | * @param [out] unsigned int* p_out_buf_len:Destination data length |
| 526 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 527 | */ |
| 528 | int32_t gsw_tee_aes_key_export(char* in_obj_name, char *out_buf, unsigned int* p_out_buf_len); |
| 529 | |
| 530 | /** |
| 531 | * @brief key export |
| 532 | * @param [in] char* in_obj_name :Key name or key information structure |
| 533 | * @param [out] GSW_TEE_RSA_PUB_KEY*out_buf:Destination cache |
| 534 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 535 | */ |
| 536 | int32_t gsw_tee_rsa_pub_key_export(char* in_obj_name, GSW_TEE_RSA_PUB_KEY*out_buf); |
| 537 | |
| 538 | /** |
| 539 | * @brief ecc key export |
| 540 | * @param [in] char* in_obj_name :Key name or key information structure |
| 541 | * @param [out] GSW_TEE_ECC_PUB_KEY *out_buf:Destination cache |
| 542 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 543 | */ |
| 544 | int32_t gsw_tee_ecc_pub_key_export(char* in_obj_name, GSW_TEE_ECC_PUB_KEY*out_buf); |
| 545 | |
| 546 | /** |
| 547 | * @brief sm2 key export |
| 548 | * @param [in] char* in_obj_name :Key name or key information structure |
| 549 | * @param [out] GSW_TEE_SM2_PUB_KEY *out_buf:Destination cache |
| 550 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 551 | */ |
| 552 | int32_t gsw_tee_sm2_pub_key_export(char* in_obj_name, GSW_TEE_SM2_PUB_KEY*out_buf); |
| 553 | |
| 554 | /** |
| 555 | * @brief sm4 key export |
| 556 | * @param [in] char* in_obj_name :Key name or key information structure |
| 557 | * @param [in] unsigned int* p_out_buf_len:The size of Destination cache |
| 558 | * @param [out] char *out_buf:Destination cache/file name |
| 559 | * @param [out] unsigned int* p_out_buf_len:Destination data length |
| 560 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 561 | */ |
| 562 | int32_t gsw_tee_sm4_key_export(char* in_obj_name, char *out_buf, unsigned int* p_out_buf_len); |
| 563 | |
| 564 | /** |
| 565 | * @brief delete key |
| 566 | * @param [in] char* in_obj_name :Key name or key information structure |
| 567 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 568 | */ |
| 569 | int32_t gsw_tee_key_delete(char* in_obj_name); |
| 570 | |
| 571 | /** |
| 572 | * @brief deinit tee sdk |
| 573 | * @param [in] None |
| 574 | * @param [out] None |
| 575 | * @retval GSW_HAL_SUCCESS is success\other is fail |
| 576 | */ |
| 577 | int32_t gsw_tee_sdk_deinit(void); |
| 578 | |