blob: f6a9cc5284a581df0e0fd9c0deba3c9abb6be45d [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/***********************************************************************
2* Copyright (C) 2001, ZTE Corporation.
3*
4* File Name: drvs_cipher.h
5* File Mark:
6* Description: Provide cipher module Function prototype declaration
7* and type declaration.
8* Others:
9* Version: v0.5
10* Author: Wangxia
11* Date: 2008-07-06
12*
13* History 1:
14* History 2:
15**********************************************************************/
16#ifndef _DRVS_CIPHER_H
17#define _DRVS_CIPHER_H
18/**************************************************************************
19 * Include files *
20 **************************************************************************/
21
22
23
24
25/**************************************************************************
26 * Macro
27 *
28 **************************************************************************/
29 #define ZDRV_DEV_CIPHER "cipher"
30
31
32 /**************************************************************************
33 * Types *
34 **************************************************************************/
35
36/* param of cipher interface function */
37typedef struct
38{
39 UINT32 uiDirection; /* direction param*/
40 UINT32 uiCount; /* count param for encrypt and integrity check */
41 UINT8 pcKey[16]; /* key param */
42 union
43 {
44 UINT32 uiBearer; /* bearer param for encrypt */
45 UINT32 uiFresh; /* fresh param for integrity check */
46 }uOthers;
47} T_ZDrvCipher_Param;
48
49
50typedef UINT8 aCiphKey[4][16];
51
52/*GPRS cipher struct, GPRS uses GEA1/2,GEA3 algorithm*/
53 typedef struct
54{
55 UINT8 *headerStart_ptr;
56 UINT16 headerLength;
57 UINT8 *payloadStart_ptr;
58 UINT16 payloadLength;
59 UINT16 crcLength;
60 UINT8 *destination_ptr;
61 UINT8 cipherOn;
62 UINT8 *kc_ptr;
63 UINT32 cipherInput;
64} T_ZDrvCipher_GEACipherData;
65
66
67 typedef struct
68{
69 SINT32 Direction_CK_index;
70 UINT32 Count;
71 UINT32 Bearer;
72 UINT32 Length;
73 UINT32 Fresh;
74 UINT32 *Message;
75 UINT32 Direction;
76 SINT32 IK_index;
77 UINT32 MAC_I;
78}T_ZDrvCipher_RequestListType;
79
80typedef struct
81{
82 SINT32 CiphContext;
83 SINT32 CallerId;
84 SINT32 NoRequests;
85 aCiphKey *IK;
86 aCiphKey *CK;
87 T_ZDrvCipher_RequestListType RequestList[2];
88}T_ZDrvCipher_SCiphF8;
89
90typedef T_ZDrvCipher_SCiphF8 T_ZDrvCipher_SCiphF9;
91
92/**************************************************************************
93 * Global Variables *
94 **************************************************************************/
95
96
97
98
99/**************************************************************************
100 * Function Prototypes *
101 **************************************************************************/
102/**************************************************************************
103* Functin: zDrvCipher_Encrypt
104* Description: This function is used to encrypt the input data.
105* Parameters:
106* (IN)
107* pBufferInOut: Data buffer for input and output, and its size must be a multiple of 32
108* uiBitLenInOut: Data length of input and output, 1-20000bit.
109* pPara: Stuct T_ZDrvCipher_PARA
110* (OUT)
111* pBufferInOut: Data buffer for input and output, and its size must be a multiple of 32
112* Returns:
113* T_ZDrv_ErrCode
114* Others:
115* 1. Param pBufferInOut is both for input and output.
116* 2. The data length of input and output is the same.
117 **************************************************************************/
118SINT32 zDrvCipher_Encrypt( CHAR *pBufferInOut, UINT32 uiBitLenInOut, T_ZDrvCipher_Param *pParam );
119
120
121/**************************************************************************
122* Functin: zDrvCipher_Integrity
123* Description: This function is used to chech the integrity.
124* Parameters:
125* (IN)
126* pBufferInOut: Data buffer for input and output, and its size must be a multiple of 32
127* uiBitLenInOut: Data length of input and output.
128* pPara: Stuct T_ZDrvCipher_PARA
129* (OUT)
130* pBufferInOut: Data buffer for input and output, and its size must be a multiple of 32
131* Returns:
132* T_ZDrv_ErrCode
133* Others:
134* 1. Param pBufferInOut is both for input and output.
135* 2. The data length of output is 32bit.
136 **************************************************************************/
137SINT32 zDrvCipher_Integrity( CHAR *pBufferInOut, UINT32 uiBitLenIn, T_ZDrvCipher_Param *pParam );
138
139/***************************************************************************************
140* Function: zDrvCipher_GprsUintInitialise
141* Description: This function is used to initialize ciphering semaphoreme,olny using for GPRS communication
142* Parameters:
143* Input:
144* None
145* Output:
146* None
147* Returns:
148* None
149***************************************************************************************/
150VOID zDrvCipher_GprsUnitInitialise (VOID);
151
152
153/***************************************************************************************
154* Function: zDrvCipher_GprsUnitEncode
155* Description: This function is used to encode data of uplink,olny using for GPRS communication
156* Parameters:
157* Input:
158* pointer of T_ZDrvCipher_GEACipherData struct
159* Output:
160* None
161* Returns:
162* None
163***************************************************************************************/
164VOID zDrvCipher_GprsUnitEncode(T_ZDrvCipher_GEACipherData * ciData_ptr);
165
166/***************************************************************************************
167* Function: zDrvCipher_GgprsUnitEncode
168* Description: This function is used to encode data of uplink,olny using for GPRS communication
169* Parameters:
170* Input:
171* pointer of T_ZDrvCipher_GEACipherData struct
172* Output:
173* None
174* Returns:
175* None
176***************************************************************************************/
177VOID zDrvCipher_GgprsUnitEncode(T_ZDrvCipher_GEACipherData * ciData_ptr);
178
179
180/***************************************************************************************
181* Function: zDrvCipher_GprsUnitDecode
182* Description: This function is used to encode data of downlink,olny using for GPRS communication
183* Parameters:
184* Input:
185* pointer of T_ZDrvCipher_GEACipherData struct
186* Output:
187* None
188* Returns:
189* None
190***************************************************************************************/
191BOOL zDrvCipher_GprsUnitDecode(T_ZDrvCipher_GEACipherData * ciData_ptr);
192
193/****************************************************************************************
194* Function: zDrvCipher_F8
195* Description: This function is used to cipher data using f8 algorithm which be used in UMTS communication
196* Parameters:
197* Input:
198* pointer of T_ZDrvCipher_SCiphF8 struct
199* Output:
200* None
201* Returns:
202* 1: faild
203* 0:success
204****************************************************************************************/
205BOOL zDrvCipher_F8(T_ZDrvCipher_SCiphF8 *f8_ctrl);
206
207
208/***************************************************************************************
209* Function: zDrvCipher_F9
210* Description: This function is used to cipher data using f9 algorithm which be used in UMTS communication
211* Parameters:
212* Input:
213* pointer of T_ZDrvCipher_GEACipherData struct
214* Output:
215* None
216* Returns:
217* None
218***************************************************************************************/
219VOID zDrvCipher_F9(T_ZDrvCipher_SCiphF9 *f9_ctrl);
220
221
222#endif /* _CIPHER_API_H */
223