OLD | NEW |
1 /* ssl/ssl_asn1.c */ | 1 /* ssl/ssl_asn1.c */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 * SUCH DAMAGE. | 51 * SUCH DAMAGE. |
52 * | 52 * |
53 * The licence and distribution terms for any publically available version or | 53 * The licence and distribution terms for any publically available version or |
54 * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 * copied and put under another distribution licence | 55 * copied and put under another distribution licence |
56 * [including the GNU Public Licence.] | 56 * [including the GNU Public Licence.] |
57 */ | 57 */ |
| 58 /* ==================================================================== |
| 59 * Copyright 2005 Nokia. All rights reserved. |
| 60 * |
| 61 * The portions of the attached software ("Contribution") is developed by |
| 62 * Nokia Corporation and is licensed pursuant to the OpenSSL open source |
| 63 * license. |
| 64 * |
| 65 * The Contribution, originally written by Mika Kousa and Pasi Eronen of |
| 66 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites |
| 67 * support (see RFC 4279) to OpenSSL. |
| 68 * |
| 69 * No patent licenses or other rights except those expressly stated in |
| 70 * the OpenSSL open source license shall be deemed granted or received |
| 71 * expressly, by implication, estoppel, or otherwise. |
| 72 * |
| 73 * No assurances are provided by Nokia that the Contribution does not |
| 74 * infringe the patent or other intellectual property rights of any third |
| 75 * party or that the license provides you with all the necessary rights |
| 76 * to make use of the Contribution. |
| 77 * |
| 78 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN |
| 79 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA |
| 80 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY |
| 81 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR |
| 82 * OTHERWISE. |
| 83 */ |
58 | 84 |
59 #include <stdio.h> | 85 #include <stdio.h> |
60 #include <stdlib.h> | 86 #include <stdlib.h> |
61 #include "ssl_locl.h" | 87 #include "ssl_locl.h" |
62 #include <openssl/asn1_mac.h> | 88 #include <openssl/asn1_mac.h> |
63 #include <openssl/objects.h> | 89 #include <openssl/objects.h> |
64 #include <openssl/x509.h> | 90 #include <openssl/x509.h> |
65 | 91 |
66 typedef struct ssl_session_asn1_st | 92 typedef struct ssl_session_asn1_st |
67 { | 93 { |
68 ASN1_INTEGER version; | 94 ASN1_INTEGER version; |
69 ASN1_INTEGER ssl_version; | 95 ASN1_INTEGER ssl_version; |
70 ASN1_OCTET_STRING cipher; | 96 ASN1_OCTET_STRING cipher; |
71 ASN1_OCTET_STRING comp_id; | 97 ASN1_OCTET_STRING comp_id; |
72 ASN1_OCTET_STRING master_key; | 98 ASN1_OCTET_STRING master_key; |
73 ASN1_OCTET_STRING session_id; | 99 ASN1_OCTET_STRING session_id; |
74 ASN1_OCTET_STRING session_id_context; | 100 ASN1_OCTET_STRING session_id_context; |
75 ASN1_OCTET_STRING key_arg; | 101 ASN1_OCTET_STRING key_arg; |
76 #ifndef OPENSSL_NO_KRB5 | 102 #ifndef OPENSSL_NO_KRB5 |
77 ASN1_OCTET_STRING krb5_princ; | 103 ASN1_OCTET_STRING krb5_princ; |
78 #endif /* OPENSSL_NO_KRB5 */ | 104 #endif /* OPENSSL_NO_KRB5 */ |
79 ASN1_INTEGER time; | 105 ASN1_INTEGER time; |
80 ASN1_INTEGER timeout; | 106 ASN1_INTEGER timeout; |
81 ASN1_INTEGER verify_result; | 107 ASN1_INTEGER verify_result; |
82 #ifndef OPENSSL_NO_TLSEXT | 108 #ifndef OPENSSL_NO_TLSEXT |
83 ASN1_OCTET_STRING tlsext_hostname; | 109 ASN1_OCTET_STRING tlsext_hostname; |
84 ASN1_INTEGER tlsext_tick_lifetime; | 110 ASN1_INTEGER tlsext_tick_lifetime; |
85 ASN1_OCTET_STRING tlsext_tick; | 111 ASN1_OCTET_STRING tlsext_tick; |
86 #endif /* OPENSSL_NO_TLSEXT */ | 112 #endif /* OPENSSL_NO_TLSEXT */ |
| 113 #ifndef OPENSSL_NO_PSK |
| 114 ASN1_OCTET_STRING psk_identity_hint; |
| 115 ASN1_OCTET_STRING psk_identity; |
| 116 #endif /* OPENSSL_NO_PSK */ |
87 } SSL_SESSION_ASN1; | 117 } SSL_SESSION_ASN1; |
88 | 118 |
89 int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | 119 int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) |
90 { | 120 { |
91 #define LSIZE2 (sizeof(long)*2) | 121 #define LSIZE2 (sizeof(long)*2) |
92 » int v1=0,v2=0,v3=0,v4=0,v5=0; | 122 » int v1=0,v2=0,v3=0,v4=0,v5=0,v7=0,v8=0; |
93 unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2]; | 123 unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2]; |
94 unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2],ibuf5[LSIZE2]; | 124 unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2],ibuf5[LSIZE2]; |
95 #ifndef OPENSSL_NO_TLSEXT | 125 #ifndef OPENSSL_NO_TLSEXT |
96 int v6=0,v9=0,v10=0; | 126 int v6=0,v9=0,v10=0; |
97 unsigned char ibuf6[LSIZE2]; | 127 unsigned char ibuf6[LSIZE2]; |
98 #endif | 128 #endif |
99 #ifndef OPENSSL_NO_COMP | 129 #ifndef OPENSSL_NO_COMP |
| 130 unsigned char cbuf; |
100 int v11=0; | 131 int v11=0; |
101 unsigned char cbuf; | |
102 #endif | 132 #endif |
103 long l; | 133 long l; |
104 SSL_SESSION_ASN1 a; | 134 SSL_SESSION_ASN1 a; |
105 M_ASN1_I2D_vars(in); | 135 M_ASN1_I2D_vars(in); |
106 | 136 |
107 if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0))) | 137 if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0))) |
108 return(0); | 138 return(0); |
109 | 139 |
110 /* Note that I cheat in the following 2 assignments. I know | 140 /* Note that I cheat in the following 2 assignments. I know |
111 * that if the ASN1_INTEGER passed to ASN1_INTEGER_set | 141 * that if the ASN1_INTEGER passed to ASN1_INTEGER_set |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 a.key_arg.data=in->key_arg; | 200 a.key_arg.data=in->key_arg; |
171 | 201 |
172 #ifndef OPENSSL_NO_KRB5 | 202 #ifndef OPENSSL_NO_KRB5 |
173 if (in->krb5_client_princ_len) | 203 if (in->krb5_client_princ_len) |
174 { | 204 { |
175 a.krb5_princ.length=in->krb5_client_princ_len; | 205 a.krb5_princ.length=in->krb5_client_princ_len; |
176 a.krb5_princ.type=V_ASN1_OCTET_STRING; | 206 a.krb5_princ.type=V_ASN1_OCTET_STRING; |
177 a.krb5_princ.data=in->krb5_client_princ; | 207 a.krb5_princ.data=in->krb5_client_princ; |
178 } | 208 } |
179 #endif /* OPENSSL_NO_KRB5 */ | 209 #endif /* OPENSSL_NO_KRB5 */ |
180 | 210 |
181 if (in->time != 0L) | 211 if (in->time != 0L) |
182 { | 212 { |
183 a.time.length=LSIZE2; | 213 a.time.length=LSIZE2; |
184 a.time.type=V_ASN1_INTEGER; | 214 a.time.type=V_ASN1_INTEGER; |
185 a.time.data=ibuf3; | 215 a.time.data=ibuf3; |
186 ASN1_INTEGER_set(&(a.time),in->time); | 216 ASN1_INTEGER_set(&(a.time),in->time); |
187 } | 217 } |
188 | 218 |
189 if (in->timeout != 0L) | 219 if (in->timeout != 0L) |
190 { | 220 { |
(...skipping 25 matching lines...) Expand all Loading... |
216 a.tlsext_tick.data=(unsigned char *)in->tlsext_tick; | 246 a.tlsext_tick.data=(unsigned char *)in->tlsext_tick; |
217 } | 247 } |
218 if (in->tlsext_tick_lifetime_hint > 0) | 248 if (in->tlsext_tick_lifetime_hint > 0) |
219 { | 249 { |
220 a.tlsext_tick_lifetime.length=LSIZE2; | 250 a.tlsext_tick_lifetime.length=LSIZE2; |
221 a.tlsext_tick_lifetime.type=V_ASN1_INTEGER; | 251 a.tlsext_tick_lifetime.type=V_ASN1_INTEGER; |
222 a.tlsext_tick_lifetime.data=ibuf6; | 252 a.tlsext_tick_lifetime.data=ibuf6; |
223 ASN1_INTEGER_set(&a.tlsext_tick_lifetime,in->tlsext_tick_lifetim
e_hint); | 253 ASN1_INTEGER_set(&a.tlsext_tick_lifetime,in->tlsext_tick_lifetim
e_hint); |
224 } | 254 } |
225 #endif /* OPENSSL_NO_TLSEXT */ | 255 #endif /* OPENSSL_NO_TLSEXT */ |
| 256 #ifndef OPENSSL_NO_PSK |
| 257 if (in->psk_identity_hint) |
| 258 { |
| 259 a.psk_identity_hint.length=strlen(in->psk_identity_hint); |
| 260 a.psk_identity_hint.type=V_ASN1_OCTET_STRING; |
| 261 a.psk_identity_hint.data=(unsigned char *)(in->psk_identity_hint
); |
| 262 } |
| 263 if (in->psk_identity) |
| 264 { |
| 265 a.psk_identity.length=strlen(in->psk_identity); |
| 266 a.psk_identity.type=V_ASN1_OCTET_STRING; |
| 267 a.psk_identity.data=(unsigned char *)(in->psk_identity); |
| 268 } |
| 269 #endif /* OPENSSL_NO_PSK */ |
| 270 |
226 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); | 271 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); |
227 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); | 272 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); |
228 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING); | 273 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING); |
229 M_ASN1_I2D_len(&(a.session_id), i2d_ASN1_OCTET_STRING); | 274 M_ASN1_I2D_len(&(a.session_id), i2d_ASN1_OCTET_STRING); |
230 M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING); | 275 M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING); |
231 #ifndef OPENSSL_NO_KRB5 | 276 #ifndef OPENSSL_NO_KRB5 |
232 if (in->krb5_client_princ_len) | 277 if (in->krb5_client_princ_len) |
233 M_ASN1_I2D_len(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); | 278 M_ASN1_I2D_len(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); |
234 #endif /* OPENSSL_NO_KRB5 */ | 279 #endif /* OPENSSL_NO_KRB5 */ |
235 if (in->key_arg_length > 0) | 280 if (in->key_arg_length > 0) |
(...skipping 13 matching lines...) Expand all Loading... |
249 M_ASN1_I2D_len_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER
,9,v9); | 294 M_ASN1_I2D_len_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER
,9,v9); |
250 if (in->tlsext_tick) | 295 if (in->tlsext_tick) |
251 M_ASN1_I2D_len_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING,1
0,v10); | 296 M_ASN1_I2D_len_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING,1
0,v10); |
252 if (in->tlsext_hostname) | 297 if (in->tlsext_hostname) |
253 M_ASN1_I2D_len_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRI
NG,6,v6); | 298 M_ASN1_I2D_len_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRI
NG,6,v6); |
254 #ifndef OPENSSL_NO_COMP | 299 #ifndef OPENSSL_NO_COMP |
255 if (in->compress_meth) | 300 if (in->compress_meth) |
256 M_ASN1_I2D_len_EXP_opt(&(a.comp_id), i2d_ASN1_OCTET_STRING,11,v1
1); | 301 M_ASN1_I2D_len_EXP_opt(&(a.comp_id), i2d_ASN1_OCTET_STRING,11,v1
1); |
257 #endif | 302 #endif |
258 #endif /* OPENSSL_NO_TLSEXT */ | 303 #endif /* OPENSSL_NO_TLSEXT */ |
| 304 #ifndef OPENSSL_NO_PSK |
| 305 if (in->psk_identity_hint) |
| 306 M_ASN1_I2D_len_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_ST
RING,7,v7); |
| 307 if (in->psk_identity) |
| 308 M_ASN1_I2D_len_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING,
8,v8); |
| 309 #endif /* OPENSSL_NO_PSK */ |
| 310 |
259 M_ASN1_I2D_seq_total(); | 311 M_ASN1_I2D_seq_total(); |
260 | 312 |
261 M_ASN1_I2D_put(&(a.version), i2d_ASN1_INTEGER); | 313 M_ASN1_I2D_put(&(a.version), i2d_ASN1_INTEGER); |
262 M_ASN1_I2D_put(&(a.ssl_version), i2d_ASN1_INTEGER); | 314 M_ASN1_I2D_put(&(a.ssl_version), i2d_ASN1_INTEGER); |
263 M_ASN1_I2D_put(&(a.cipher), i2d_ASN1_OCTET_STRING); | 315 M_ASN1_I2D_put(&(a.cipher), i2d_ASN1_OCTET_STRING); |
264 M_ASN1_I2D_put(&(a.session_id), i2d_ASN1_OCTET_STRING); | 316 M_ASN1_I2D_put(&(a.session_id), i2d_ASN1_OCTET_STRING); |
265 M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING); | 317 M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING); |
266 #ifndef OPENSSL_NO_KRB5 | 318 #ifndef OPENSSL_NO_KRB5 |
267 if (in->krb5_client_princ_len) | 319 if (in->krb5_client_princ_len) |
268 M_ASN1_I2D_put(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); | 320 M_ASN1_I2D_put(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); |
269 #endif /* OPENSSL_NO_KRB5 */ | 321 #endif /* OPENSSL_NO_KRB5 */ |
270 if (in->key_arg_length > 0) | 322 if (in->key_arg_length > 0) |
271 M_ASN1_I2D_put_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING,0); | 323 M_ASN1_I2D_put_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING,0); |
272 if (in->time != 0L) | 324 if (in->time != 0L) |
273 M_ASN1_I2D_put_EXP_opt(&(a.time),i2d_ASN1_INTEGER,1,v1); | 325 M_ASN1_I2D_put_EXP_opt(&(a.time),i2d_ASN1_INTEGER,1,v1); |
274 if (in->timeout != 0L) | 326 if (in->timeout != 0L) |
275 M_ASN1_I2D_put_EXP_opt(&(a.timeout),i2d_ASN1_INTEGER,2,v2); | 327 M_ASN1_I2D_put_EXP_opt(&(a.timeout),i2d_ASN1_INTEGER,2,v2); |
276 if (in->peer != NULL) | 328 if (in->peer != NULL) |
277 M_ASN1_I2D_put_EXP_opt(in->peer,i2d_X509,3,v3); | 329 M_ASN1_I2D_put_EXP_opt(in->peer,i2d_X509,3,v3); |
278 M_ASN1_I2D_put_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4, | 330 M_ASN1_I2D_put_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4, |
279 v4); | 331 v4); |
280 if (in->verify_result != X509_V_OK) | 332 if (in->verify_result != X509_V_OK) |
281 M_ASN1_I2D_put_EXP_opt(&a.verify_result,i2d_ASN1_INTEGER,5,v5); | 333 M_ASN1_I2D_put_EXP_opt(&a.verify_result,i2d_ASN1_INTEGER,5,v5); |
282 #ifndef OPENSSL_NO_TLSEXT | 334 #ifndef OPENSSL_NO_TLSEXT |
283 if (in->tlsext_hostname) | 335 if (in->tlsext_hostname) |
284 M_ASN1_I2D_put_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRI
NG,6,v6); | 336 M_ASN1_I2D_put_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRI
NG,6,v6); |
| 337 #endif /* OPENSSL_NO_TLSEXT */ |
| 338 #ifndef OPENSSL_NO_PSK |
| 339 if (in->psk_identity_hint) |
| 340 M_ASN1_I2D_put_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_ST
RING,7,v7); |
| 341 if (in->psk_identity) |
| 342 M_ASN1_I2D_put_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING,
8,v8); |
| 343 #endif /* OPENSSL_NO_PSK */ |
| 344 #ifndef OPENSSL_NO_TLSEXT |
285 if (in->tlsext_tick_lifetime_hint > 0) | 345 if (in->tlsext_tick_lifetime_hint > 0) |
286 M_ASN1_I2D_put_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER
,9,v9); | 346 M_ASN1_I2D_put_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER
,9,v9); |
287 if (in->tlsext_tick) | 347 if (in->tlsext_tick) |
288 M_ASN1_I2D_put_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING,1
0,v10); | 348 M_ASN1_I2D_put_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING,1
0,v10); |
289 #endif /* OPENSSL_NO_TLSEXT */ | 349 #endif /* OPENSSL_NO_TLSEXT */ |
290 #ifndef OPENSSL_NO_COMP | 350 #ifndef OPENSSL_NO_COMP |
291 if (in->compress_meth) | 351 if (in->compress_meth) |
292 M_ASN1_I2D_put_EXP_opt(&(a.comp_id), i2d_ASN1_OCTET_STRING,11,v1
1); | 352 M_ASN1_I2D_put_EXP_opt(&(a.comp_id), i2d_ASN1_OCTET_STRING,11,v1
1); |
293 #endif | 353 #endif |
294 M_ASN1_I2D_finish(); | 354 M_ASN1_I2D_finish(); |
295 } | 355 } |
296 | 356 |
297 SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, | 357 SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, |
298 » long length) | 358 » » » long length) |
299 { | 359 { |
300 » int version,ssl_version=0,i; | 360 » int ssl_version=0,i; |
301 long id; | 361 long id; |
302 ASN1_INTEGER ai,*aip; | 362 ASN1_INTEGER ai,*aip; |
303 ASN1_OCTET_STRING os,*osp; | 363 ASN1_OCTET_STRING os,*osp; |
304 M_ASN1_D2I_vars(a,SSL_SESSION *,SSL_SESSION_new); | 364 M_ASN1_D2I_vars(a,SSL_SESSION *,SSL_SESSION_new); |
305 | 365 |
306 aip= &ai; | 366 aip= &ai; |
307 osp= &os; | 367 osp= &os; |
308 | 368 |
309 M_ASN1_D2I_Init(); | 369 M_ASN1_D2I_Init(); |
310 M_ASN1_D2I_start_sequence(); | 370 M_ASN1_D2I_start_sequence(); |
311 | 371 |
312 ai.data=NULL; ai.length=0; | 372 ai.data=NULL; ai.length=0; |
313 M_ASN1_D2I_get_x(ASN1_INTEGER,aip,d2i_ASN1_INTEGER); | 373 M_ASN1_D2I_get_x(ASN1_INTEGER,aip,d2i_ASN1_INTEGER); |
314 version=(int)ASN1_INTEGER_get(aip); | |
315 if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0;
} | 374 if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0;
} |
316 | 375 |
317 /* we don't care about the version right now :-) */ | 376 /* we don't care about the version right now :-) */ |
318 M_ASN1_D2I_get_x(ASN1_INTEGER,aip,d2i_ASN1_INTEGER); | 377 M_ASN1_D2I_get_x(ASN1_INTEGER,aip,d2i_ASN1_INTEGER); |
319 ssl_version=(int)ASN1_INTEGER_get(aip); | 378 ssl_version=(int)ASN1_INTEGER_get(aip); |
320 ret->ssl_version=ssl_version; | 379 ret->ssl_version=ssl_version; |
321 if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0;
} | 380 if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0;
} |
322 | 381 |
323 os.data=NULL; os.length=0; | 382 os.data=NULL; os.length=0; |
324 M_ASN1_D2I_get_x(ASN1_OCTET_STRING,osp,d2i_ASN1_OCTET_STRING); | 383 M_ASN1_D2I_get_x(ASN1_OCTET_STRING,osp,d2i_ASN1_OCTET_STRING); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,6); | 527 M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,6); |
469 if (os.data) | 528 if (os.data) |
470 { | 529 { |
471 ret->tlsext_hostname = BUF_strndup((char *)os.data, os.length); | 530 ret->tlsext_hostname = BUF_strndup((char *)os.data, os.length); |
472 OPENSSL_free(os.data); | 531 OPENSSL_free(os.data); |
473 os.data = NULL; | 532 os.data = NULL; |
474 os.length = 0; | 533 os.length = 0; |
475 } | 534 } |
476 else | 535 else |
477 ret->tlsext_hostname=NULL; | 536 ret->tlsext_hostname=NULL; |
| 537 #endif /* OPENSSL_NO_TLSEXT */ |
| 538 |
| 539 #ifndef OPENSSL_NO_PSK |
| 540 os.length=0; |
| 541 os.data=NULL; |
| 542 M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,7); |
| 543 if (os.data) |
| 544 { |
| 545 ret->psk_identity_hint = BUF_strndup((char *)os.data, os.length)
; |
| 546 OPENSSL_free(os.data); |
| 547 os.data = NULL; |
| 548 os.length = 0; |
| 549 } |
| 550 else |
| 551 ret->psk_identity_hint=NULL; |
| 552 #endif /* OPENSSL_NO_PSK */ |
| 553 |
| 554 #ifndef OPENSSL_NO_TLSEXT |
478 ai.length=0; | 555 ai.length=0; |
479 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,9); | 556 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,9); |
480 if (ai.data != NULL) | 557 if (ai.data != NULL) |
481 { | 558 { |
482 ret->tlsext_tick_lifetime_hint=ASN1_INTEGER_get(aip); | 559 ret->tlsext_tick_lifetime_hint=ASN1_INTEGER_get(aip); |
483 OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; | 560 OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; |
484 } | 561 } |
485 else if (ret->tlsext_ticklen && ret->session_id_length) | 562 else if (ret->tlsext_ticklen && ret->session_id_length) |
486 ret->tlsext_tick_lifetime_hint = -1; | 563 ret->tlsext_tick_lifetime_hint = -1; |
487 else | 564 else |
488 » » ret->tlsext_tick_lifetime_hint = 0; | 565 » » ret->tlsext_tick_lifetime_hint=0; |
489 » os.length=0; | 566 » os.length=0; |
490 » os.data=NULL; | 567 » os.data=NULL; |
491 » M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,10); | 568 » M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,10); |
492 » if (os.data) | 569 » if (os.data) |
493 » » { | 570 » » { |
494 ret->tlsext_tick = os.data; | 571 ret->tlsext_tick = os.data; |
495 ret->tlsext_ticklen = os.length; | 572 ret->tlsext_ticklen = os.length; |
496 » » os.data = NULL; | 573 » » os.data = NULL; |
497 » » os.length = 0; | 574 » » os.length = 0; |
498 » » } | 575 » » } |
499 else | 576 else |
500 ret->tlsext_tick=NULL; | 577 ret->tlsext_tick=NULL; |
501 #endif /* OPENSSL_NO_TLSEXT */ | 578 #endif /* OPENSSL_NO_TLSEXT */ |
502 #ifndef OPENSSL_NO_COMP | 579 #ifndef OPENSSL_NO_COMP |
503 os.length=0; | 580 os.length=0; |
504 os.data=NULL; | 581 os.data=NULL; |
505 M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,11); | 582 M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,11); |
506 if (os.data) | 583 if (os.data) |
507 { | 584 { |
508 ret->compress_meth = os.data[0]; | 585 ret->compress_meth = os.data[0]; |
509 OPENSSL_free(os.data); | 586 OPENSSL_free(os.data); |
510 os.data = NULL; | 587 os.data = NULL; |
511 } | 588 } |
512 #endif | 589 #endif |
513 | 590 |
514 M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION); | 591 M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION); |
515 } | 592 } |
OLD | NEW |