tls2app_struct.h
8.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* tls2app_struct.h
*
* Project:
* --------
* Maui
*
* Description:
* ------------
* This file describes the common struct of TLS and applications.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef _TLS2APP_STRUCT_H_
#define _TLS2APP_STRUCT_H_
#ifndef _TLS_CONST_H_
#error "tls_const.h should be included before tls2app_struct.h"
#endif /* !_TFTP_CONST_H_ */
#ifndef _TLS_APP_ENUMS_H_
#error "tls_app_enums.h should be included before tls2app_struct.h"
#endif /* !_TLS_APP_ENUMS_H_ */
#include "tls_const.h"
#include "tls_app_enums.h"
#include "kal_general_types.h"
/***************************************************************************
* <GROUP Structures>
*
* Indication to app for a common event.
* Local parameter of MSG_ID_APP_TLS_NOTIFY_IND.
***************************************************************************/
typedef struct
{
kal_uint8 ref_count;
kal_uint16 msg_len;
kal_int8 sock_id; /* Socket id to handle this notification. */
tls_event_enum event; /* Reported event from TLS task.
Applications should verifiy the event type and calls the corresponding
handler.
* TLS_HANDSHAKE_READY is an indication of the result of connection context
creation procedure. tls_new_conn() might return TLS_ERR_WAITING_CERT for
loading certificates and waiting response from MOD_CERTMAN. After received
this message, application can then call tls_handshake() to start TLS
handshake procedure.
* TLS_HANDSHAKE_DONE is an indication of the handshake result procedure.
Application can call tls_read() to receive data from or call tls_write() to
send data to the peer.
* For TLS_READ, application should call tls_read() repeatedly until
WOULDBLOCK returned.
* For TLS_WRITE, application is allowed to transmit the holding data by
calling tls_write().
* For TLS_CLOSE, application should call tls_delete_conn() to de-associate
the connection with a socket id.
*/
kal_bool result; /* Success or failure of the notification. */
kal_int32 error; /* Error code. */
kal_int32 detail_cause; /* Detail error cause. */
} app_tls_notify_ind_struct;
/***************************************************************************
* <GROUP Structures>
*
* Indication to app for received an alert from peer.
* Local parameter of MSG_ID_APP_TLS_ALERT_IND.
***************************************************************************/
typedef struct
{
kal_uint8 ref_count;
kal_uint16 msg_len;
kal_int8 sock_id; /* Socket id received SSL alert message. */
tls_alert_level_enum alert_level; /* Alert level. */
tls_alert_desc_enum alert_desc; /* Alert description. */
kal_int32 error; /* Error code. */
kal_int32 cause; /* Detail error cause. */
} app_tls_alert_ind_struct;
/***************************************************************************
* <GROUP Structures>
*
* Indication of invalid certificate.
* Local parameter of MSG_ID_APP_TLS_INVALID_CERT_IND.
***************************************************************************/
typedef struct
{
kal_uint8 ref_count;
kal_uint16 msg_len;
kal_int8 sock_id; /* Socket id received an invalid certificate during handshake */
kal_bool result; /* TRUE: user confirms to proceed the handshake against the received invalid certificate */
tls_inval_cert_action action; /* User's decision */
} app_tls_invalid_cert_ind_struct;
/***************************************************************************
* <GROUP Structures>
*
* Indication of client authentication request freom server.
* Local parameter of MSG_ID_APP_TLS_CLIENT_AUTH_IND.
***************************************************************************/
typedef struct
{
kal_uint8 ref_count;
kal_uint16 msg_len;
kal_int8 sock_id; /* Socket id request for client authentication during handshake. */
kal_bool result; /* TRUE: user selects a positive answer to the client authentication */
kal_uint8 auth_mode_num; /* auth modes in the following auth_modes array */
tls_auth_mode_enum auth_modes[TLS_MAX_CLIENT_AUTH]; /* authmodes in the certificate request message from server */
kal_uint32 identity_id; /* user selected certificate id. This field would be zero if no user certificate meets the criteria in the certificate request message. */
} app_tls_client_auth_ind_struct;
/***************************************************************************
* <GROUP Structures>
*
* Structure describes a negotiated SSL connection.
* Ref. tls_get_cipher_info().
***************************************************************************/
typedef struct {
tls_version_enum version; /* SSL version number */
tls_encryption_enum enc; /* bulk encryption algrotithm */
tls_key_exchange_enum key_ex; /* key exchange algorithm */
tls_auth_enum auth; /* authentication algorithm */
tls_hash_enum hash; /* message digest algorithm */
} tls_cipher_info_struct;
/***************************************************************************
* <GROUP Structures>
*
* Data structure holding a certificate in DER.
* Ref. tls_get_peer_cert() and callback function tls_cert_verify_callback().
***************************************************************************/
typedef struct {
kal_uint32 len; /* The size of the certificate in bytes */
kal_uint8 *data; /* Data of the certficate in DER format */
} tls_cert_struct;
#endif /* !_TLS2APP_STRUCT_H_ */