blob: 42452547db55af4ed845adcef1ddf09fc989a8b4 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2005
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*****************************************************************************
37 *
38 * Filename:
39 * ---------
40 * msm_service.h
41 *
42 * Project:
43 * --------
44 * UMOLYE
45 *
46 * Description:
47 * ------------
48 * The source is for software management
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *============================================================================
55 * HISTORY
56 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
57 *------------------------------------------------------------------------------
58 * removed!
59 * removed!
60 * removed!
61 *
62 * removed!
63 * removed!
64 * removed!
65 * removed!
66 *
67 * removed!
68 * removed!
69 * removed!
70 * removed!
71 *
72 * removed!
73 * removed!
74 * removed!
75 *
76 * removed!
77 * removed!
78 * removed!
79 *
80 * removed!
81 * removed!
82 * removed!
83 *
84 *------------------------------------------------------------------------------
85 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
86 *============================================================================
87 ****************************************************************************/
88
89#ifndef __MSM_SERVICE__
90#define __MSM_SERVICE__
91
92#define MSM_RSA_KEY_SIZE 256 //RSA 2048
93#define MSM_AES_KEY_SIZE 16
94
95#define MSM_RND_LEN 16
96#define MSM_ENC_RND_LEN MSM_RSA_KEY_SIZE
97
98#define MSM_CERT_MAGIC 0x00534D43 // "SMC"
99#define MSM_AUTH_MAGIC 0x00534D41 // "SMA"
100#define MSM_PLAT_MAGIC 0x5041 //"PA"
101#define MSM_GET_MAGIC(magic_ver) ((magic_ver)&0x00FFFFFF)
102#define MSM_GET_VER(magic_ver) ((magic_ver)>>24)
103
104#define MSM_FEATURE_MAX 16
105#define MSM_PLAT_MAX 32
106
107#define MSM_DEV_ID_LEN 20
108#define MSM_DEV_ID_HRID_OFFSET 4
109
110typedef enum{
111 MSM_ERROR_NONE = 0x0000,
112
113 MSM_ERROR_START = 0x600,
114
115 /* General error */
116 MSM_GEN_RND_ERR = 0x601,
117 MSM_CONTEXT_FULL_ERR = 0x602,
118 MSM_BLOCKING_ERR = 0x603,
119 MSM_DEAD_ERR = 0x604,
120 MSM_UNEXPECT_STATE_ERR = 0x605,
121 MSM_NULL_PTR_ERR = 0x606,
122
123 /* Receive command in wrong state, the last 4bit indicates the state information */
124 MSM_WRONG_STATE_ERR = 0x610,
125
126 /* CERT verification error */
127 MSM_CERT_VERIFY_ERR = 0x620,
128 MSM_CERT_MAGIC_ERR = 0x621,
129 MSM_CERT_SIZE_ERR = 0x622,
130 MSM_CERT_TOTAL_SIZE_ERR = 0x623,
131 MSM_CERT_RKEY_N_SIZE_ERR = 0x624,
132 MSM_CERT_RKEY_E_SIZE_ERR = 0x625,
133 MSM_CERT_PLAT_MATCH_ERR = 0x626,
134 MSM_CERT_EXPIRED_ERR = 0x627,
135
136 /* customer key verification error */
137 MSM_CUST_KEY_DEC_ERR = 0x630,
138 MSM_CUST_KEY_N_LEN_ERR = 0x631,
139 MSM_CUST_KEY_E_LEN_ERR = 0x632,
140 MSM_CUST_KEY_SIZE_ERR = 0x633,
141 MSM_CUST_KEY_RND_BUF_LEN_ERR = 0x634,
142
143 /* AUTH msg verification error */
144 MSM_AUTH_RND_DEC_ERR = 0x640,
145 MSM_AUTH_RND_LEN_ERR = 0x641,
146 MSM_AUTH_RND_COMPARE_ERR = 0x642,
147 MSM_AUTH_MSG_SIZE_ERR = 0x643,
148 MSM_AUTH_KEY_SIZE_ERR = 0x644,
149 MSM_AUTH_MAGIC_ERR = 0x645,
150 MSM_AUTH_GEN_KEY_ERR = 0x646,
151 MSM_AUTH_PLAT_MSG_SIZE_ERR = 0x647,
152 MSM_AUTH_PLAT_MSG_DEC_ERR = 0x648,
153 MSM_AUTH_PLAT_MSG_MAGIC_ERR = 0x649,
154 MSM_AUTH_PLAT_MSG_VER_ERR = 0x650,
155 MSM_AUTH_PLAT_MSG_SP_VER_ERR = 0x651,
156 MSM_AUTH_PLAT_MSG_CERT_EXPIRED_ERR = 0x652,
157
158 /* CERT cancel error */
159 MSM_CERT_CANCEL_DEC_ERR = 0x650,
160 MSM_CERT_CANCEL_COMPARE_ERR = 0x651,
161 MSM_CERT_CANCEL_ID_SIZE_ERR = 0x652,
162
163 /* AT command decryption error */
164 MSM_AT_DEC_ECMD_SIZE_ERR = 0x660,
165 MSM_AT_DEC_OUT_BUF_SIZE_ERR = 0x661,
166 MSM_AT_DEC_CTX_NOT_FOUND_ERR = 0x662,
167 MSM_AT_DEC_FAIL_ERR = 0x663,
168
169 /* Feature checking error */
170 MSM_FEATURE_CTX_NOT_FOUND_ERR = 0x671,
171 MSM_FEATURE_NOT_SUPPORT_ERR = 0x672,
172 MSM_FEATURE_DENIED = 0x673,
173
174 MSM_FEATURE_NOT_EXIST = 0x680,
175
176 MSM_ERROR_END = 0x6FF
177}MSM_ERROR_E;
178
179typedef struct MSM_DEV_INFO
180{
181 kal_uint32 m_feature_support;
182 kal_uint8 m_dev_id[MSM_DEV_ID_LEN];
183}MSM_DEV_INFO_t;
184
185/*****************************************************************************
186 * FUNCTION
187 * MSM_Rcv_Auth_0
188 * DESCRIPTION
189 *
190 * PARAMETERS
191 * p_cert [IN] pointer of CERT(X)
192 * c_size [IN] size of CERT
193 * p_cust_id [OUT] Customer id <CUST_ID>
194 * RETURNS
195 * 0 : successfully
196 * otherwise : failure (reference to enum TYPE_CUST_CHL_ERROR for error code)
197 *****************************************************************************/
198kal_uint32 MSM_Rcv_Auth_0(kal_uint8 *p_cert, kal_uint32 c_size, kal_uint32 *p_cust_id);
199
200/*****************************************************************************
201 * FUNCTION
202 * MSM_Rcv_Auth_1
203 * DESCRIPTION
204 *
205 * PARAMETERS
206 * cust_id [IN] Customer id <CUST_ID>
207 * p_e_cust_key [IN] pointer of "E(K(XR)pri, K(XD)pub)"
208 * e_size [IN] size of e_cust_key
209 * p_rnd_buf [IN/OUT] Input the buffer pointer / function stores <RND(M)> into this buffer
210 * rnd_buf_len [IN] size of rnd_buf (must be MSM_RND_LEN )
211 * RETURNS
212 * 0 : successfully
213 * otherwise : failure (reference to enum TYPE_CUST_CHL_ERROR for error code)
214 *****************************************************************************/
215kal_uint32 MSM_Rcv_Auth_1(kal_uint32 cust_id, kal_uint8 *p_e_cust_key, kal_uint32 e_size, kal_uint8 *p_rnd_buf, kal_uint32 rnd_buf_len);
216
217/*****************************************************************************
218 * FUNCTION
219 * MSM_Rcv_Auth_2
220 * DESCRIPTION
221 *
222 * PARAMETERS
223 * p_auth_msg [IN] pointer of "AUTH_MSG"
224 * a_size [IN] size of auth_msg
225 * p_sym_key [IN/OUT] Input the buffer pointer / function stores K(M)sym into this buffer
226 * s_size [IN] size of sym_key (must be MSM_AES_KEY_SIZE)
227 * p_cust_id [OUT] Customer id <CUST_ID>
228 * p_dev_info [OUT] function stores the device information
229 * RETURNS
230 * 0 : successfully
231 * otherwise : failure (reference to enum TYPE_CUST_CHL_ERROR for error code)
232 *****************************************************************************/
233kal_uint32 MSM_Rcv_Auth_2(kal_uint8 *p_auth_msg, kal_uint32 a_size, kal_uint8 *p_plat_msg, kal_uint32 p_size, kal_uint8 *p_sym_key, kal_uint32 s_size, kal_uint32 *p_cust_id, MSM_DEV_INFO_t *p_dev_info);
234
235/*****************************************************************************
236 * FUNCTION
237 * MSM_Rcv_Auth_3
238 * DESCRIPTION
239 *
240 * PARAMETERS
241 * cust_id [IN] Customer id <CUST_ID>
242 * p_e_cust_id [IN] pointer of "AES(E(K(M)sym, CUST_ID))"
243 * e_size [IN] size of e_cust_id
244 * RETURNS
245 * 0 : successfully
246 * otherwise : failure (reference to enum TYPE_CUST_CHL_ERROR for error code)
247 *****************************************************************************/
248kal_uint32 MSM_Rcv_Auth_3(kal_uint32 cust_id, kal_uint8 *p_e_cust_id , kal_uint32 e_size);
249
250/*****************************************************************************
251 * FUNCTION
252 * MSM_Decrypt_Cmd
253 * DESCRIPTION
254 *
255 * PARAMETERS
256 * cust_id [IN] Customer id <CUST_ID>
257 * p_e_cmd [IN] pointer of encrypted command
258 * in_size [IN] size of e_cmd
259 * p_cmd [IN/OUT] Input the buffer pointer / function stores descrypted command into this buffer
260 * p_out_size [IN] size of cmd buffer
261 * RETURNS
262 * 0 : successfully
263 * otherwise : failure (reference to enum TYPE_CUST_CHL_ERROR for error code)
264 *****************************************************************************/
265kal_uint32 MSM_Decrypt_Cmd(kal_uint32 cust_id, kal_uint8 *p_e_cmd, kal_uint32 in_size, kal_uint8 *p_cmd, kal_uint32 out_size);
266
267/*****************************************************************************
268 * FUNCTION
269 * MSM_Decrypt_Cmd
270 * DESCRIPTION
271 *
272 * PARAMETERS
273 * cust_id [IN] Customer id <CUST_ID>
274 * feature [IN] feature "XXXX"
275 * RETURNS
276 * 0 : successfully
277 * otherwise : failure (reference to enum TYPE_CUST_CHL_ERROR for error code)
278 *****************************************************************************/
279kal_uint32 MSM_Check_Feature_Sts(kal_uint32 cust_id, kal_uint32 feature);
280
281#endif /*__MSM_SERVICE__*/