yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | #ifndef __OSSL_ECIES_H__ |
| 2 | #define __OSSL_ECIES_H__ |
| 3 | |
| 4 | #include "kal_general_types.h" |
| 5 | |
| 6 | /* support scheme */ |
| 7 | typedef enum { |
| 8 | ECIES_PROFILE_A = 1, |
| 9 | ECIES_PROFILE_B, |
| 10 | } sim_suci_scheme_enum; |
| 11 | |
| 12 | /* ECIES error code */ |
| 13 | typedef enum { |
| 14 | ECIES_ERROR_NONE, |
| 15 | ECIES_ERROR_SCHEME_NOT_SUPPORT, |
| 16 | ECIES_ERROR_PUBKEY_NOT_EXIST, |
| 17 | ECIES_ERROR_PUBKEY_LENGTH_WRONG, |
| 18 | ECIES_ERROR_PUBKEY_FORMAT_WRONG, |
| 19 | ECIES_ERROR_SUPI_NOT_EXIST, |
| 20 | ECIES_ERROR_OUTPUT_NOT_EXIST, |
| 21 | ECIES_ERROR_ECC_GENKEY_FAILED, |
| 22 | ECIES_ERROR_ECC_EXPORT_PUBKEY_FAILED, |
| 23 | ECIES_ERROR_ECC_GENSECRET_FAILED, |
| 24 | ECIES_ERROR_KDF, |
| 25 | ECIES_ERROR_AES_ENC, |
| 26 | ECIES_ERROR_CALCULATE_MAC |
| 27 | } ECIES_ERROR; |
| 28 | |
| 29 | extern kal_uint8 g_ecies_dump_log; |
| 30 | |
| 31 | /* ECIES encryption */ |
| 32 | /***************************************************************************** |
| 33 | * FUNCTION |
| 34 | * sim_supi_enc |
| 35 | * DESCRIPTION |
| 36 | * This function is to get the scheme ouput (None null scheme) with specified key and plaintext. |
| 37 | * PARAMETERS |
| 38 | * scheme [IN] |
| 39 | * peer_pub_key_ptr [IN] |
| 40 | * peer_pub_keylen [IN] |
| 41 | * supi [IN] |
| 42 | * supi_len [IN] |
| 43 | * enc_out [OUT] |
| 44 | * enc_out_len [OUT] |
| 45 | * exported_public_key [OUT] |
| 46 | * exported_public_key_len [OUT] |
| 47 | * RETURNS |
| 48 | * 0 : successfully |
| 49 | * otherwise : failure (reference to enum ECIES_ERROR for error code) |
| 50 | *****************************************************************************/ |
| 51 | kal_uint32 sim_supi_enc(sim_suci_scheme_enum scheme, const kal_uint8 *peer_pub_key_ptr, kal_uint16 peer_pub_keylen, const kal_uint8 *supi, kal_uint16 supi_len, kal_uint8 *enc_out, kal_uint16 *enc_out_len, kal_uint8 *exported_public_key, kal_uint8 *exported_public_key_len); |
| 52 | |
| 53 | /***************************************************************************** |
| 54 | * FUNCTION |
| 55 | * sim_check_suci_enc_support |
| 56 | * DESCRIPTION |
| 57 | * This function is to check the ME support SUCI protection scheme. |
| 58 | * PARAMETERS |
| 59 | * scheme [IN] The scheme ID to be check, refer to 33.501 Annex C.1 |
| 60 | * RETURNS |
| 61 | * TRUE - ME support the scheme |
| 62 | *****************************************************************************/ |
| 63 | kal_bool sim_check_suci_enc_support(sim_suci_scheme_enum scheme); |
| 64 | |
| 65 | void enable_ecies_dump_log(); |
| 66 | |
| 67 | #endif /* __OSSL_ECIES_H__ */ |