blob: 6b0185775edcb35d109c69382812f96bb17132a9 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001#ifndef __OSSL_ECIES_H__
2#define __OSSL_ECIES_H__
3
4#include "kal_general_types.h"
5
6/* support scheme */
7typedef enum {
8ECIES_PROFILE_A = 1,
9ECIES_PROFILE_B,
10} sim_suci_scheme_enum;
11
12/* ECIES error code */
13typedef enum {
14ECIES_ERROR_NONE,
15ECIES_ERROR_SCHEME_NOT_SUPPORT,
16ECIES_ERROR_PUBKEY_NOT_EXIST,
17ECIES_ERROR_PUBKEY_LENGTH_WRONG,
18ECIES_ERROR_PUBKEY_FORMAT_WRONG,
19ECIES_ERROR_SUPI_NOT_EXIST,
20ECIES_ERROR_OUTPUT_NOT_EXIST,
21ECIES_ERROR_ECC_GENKEY_FAILED,
22ECIES_ERROR_ECC_EXPORT_PUBKEY_FAILED,
23ECIES_ERROR_ECC_GENSECRET_FAILED,
24ECIES_ERROR_KDF,
25ECIES_ERROR_AES_ENC,
26ECIES_ERROR_CALCULATE_MAC
27} ECIES_ERROR;
28
29extern 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*****************************************************************************/
51kal_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*****************************************************************************/
63kal_bool sim_check_suci_enc_support(sim_suci_scheme_enum scheme);
64
65void enable_ecies_dump_log();
66
67#endif /* __OSSL_ECIES_H__ */