diff options
Diffstat (limited to 'src/lib/libssl/ssl_asn1.c')
-rw-r--r-- | src/lib/libssl/ssl_asn1.c | 634 |
1 files changed, 304 insertions, 330 deletions
diff --git a/src/lib/libssl/ssl_asn1.c b/src/lib/libssl/ssl_asn1.c index 38540be1e5..51668db785 100644 --- a/src/lib/libssl/ssl_asn1.c +++ b/src/lib/libssl/ssl_asn1.c | |||
@@ -89,8 +89,7 @@ | |||
89 | #include <openssl/objects.h> | 89 | #include <openssl/objects.h> |
90 | #include <openssl/x509.h> | 90 | #include <openssl/x509.h> |
91 | 91 | ||
92 | typedef struct ssl_session_asn1_st | 92 | typedef struct ssl_session_asn1_st { |
93 | { | ||
94 | ASN1_INTEGER version; | 93 | ASN1_INTEGER version; |
95 | ASN1_INTEGER ssl_version; | 94 | ASN1_INTEGER ssl_version; |
96 | ASN1_OCTET_STRING cipher; | 95 | ASN1_OCTET_STRING cipher; |
@@ -100,7 +99,7 @@ typedef struct ssl_session_asn1_st | |||
100 | ASN1_OCTET_STRING session_id_context; | 99 | ASN1_OCTET_STRING session_id_context; |
101 | ASN1_OCTET_STRING key_arg; | 100 | ASN1_OCTET_STRING key_arg; |
102 | #ifndef OPENSSL_NO_KRB5 | 101 | #ifndef OPENSSL_NO_KRB5 |
103 | ASN1_OCTET_STRING krb5_princ; | 102 | ASN1_OCTET_STRING krb5_princ; |
104 | #endif /* OPENSSL_NO_KRB5 */ | 103 | #endif /* OPENSSL_NO_KRB5 */ |
105 | ASN1_INTEGER time; | 104 | ASN1_INTEGER time; |
106 | ASN1_INTEGER timeout; | 105 | ASN1_INTEGER timeout; |
@@ -117,169 +116,156 @@ typedef struct ssl_session_asn1_st | |||
117 | #ifndef OPENSSL_NO_SRP | 116 | #ifndef OPENSSL_NO_SRP |
118 | ASN1_OCTET_STRING srp_username; | 117 | ASN1_OCTET_STRING srp_username; |
119 | #endif /* OPENSSL_NO_SRP */ | 118 | #endif /* OPENSSL_NO_SRP */ |
120 | } SSL_SESSION_ASN1; | 119 | } SSL_SESSION_ASN1; |
121 | 120 | ||
122 | int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | 121 | int |
123 | { | 122 | i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) |
123 | { | ||
124 | #define LSIZE2 (sizeof(long)*2) | 124 | #define LSIZE2 (sizeof(long)*2) |
125 | int v1=0,v2=0,v3=0,v4=0,v5=0,v7=0,v8=0; | 125 | int v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0, v7 = 0, v8 = 0; |
126 | unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2]; | 126 | unsigned char buf[4], ibuf1[LSIZE2], ibuf2[LSIZE2]; |
127 | unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2],ibuf5[LSIZE2]; | 127 | unsigned char ibuf3[LSIZE2], ibuf4[LSIZE2], ibuf5[LSIZE2]; |
128 | #ifndef OPENSSL_NO_TLSEXT | 128 | #ifndef OPENSSL_NO_TLSEXT |
129 | int v6=0,v9=0,v10=0; | 129 | int v6 = 0, v9 = 0, v10 = 0; |
130 | unsigned char ibuf6[LSIZE2]; | 130 | unsigned char ibuf6[LSIZE2]; |
131 | #endif | 131 | #endif |
132 | #ifndef OPENSSL_NO_COMP | 132 | #ifndef OPENSSL_NO_COMP |
133 | unsigned char cbuf; | 133 | unsigned char cbuf; |
134 | int v11=0; | 134 | int v11 = 0; |
135 | #endif | 135 | #endif |
136 | #ifndef OPENSSL_NO_SRP | 136 | #ifndef OPENSSL_NO_SRP |
137 | int v12=0; | 137 | int v12 = 0; |
138 | #endif | 138 | #endif |
139 | long l; | 139 | long l; |
140 | SSL_SESSION_ASN1 a; | 140 | SSL_SESSION_ASN1 a; |
141 | M_ASN1_I2D_vars(in); | 141 | M_ASN1_I2D_vars(in); |
142 | 142 | ||
143 | if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0))) | 143 | if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0))) |
144 | return(0); | 144 | return (0); |
145 | 145 | ||
146 | /* Note that I cheat in the following 2 assignments. I know | 146 | /* Note that I cheat in the following 2 assignments. I know |
147 | * that if the ASN1_INTEGER passed to ASN1_INTEGER_set | 147 | * that if the ASN1_INTEGER passed to ASN1_INTEGER_set |
148 | * is > sizeof(long)+1, the buffer will not be re-OPENSSL_malloc()ed. | 148 | * is > sizeof(long)+1, the buffer will not be re-OPENSSL_malloc()ed. |
149 | * This is a bit evil but makes things simple, no dynamic allocation | 149 | * This is a bit evil but makes things simple, no dynamic allocation |
150 | * to clean up :-) */ | 150 | * to clean up :-) */ |
151 | a.version.length=LSIZE2; | 151 | a.version.length = LSIZE2; |
152 | a.version.type=V_ASN1_INTEGER; | 152 | a.version.type = V_ASN1_INTEGER; |
153 | a.version.data=ibuf1; | 153 | a.version.data = ibuf1; |
154 | ASN1_INTEGER_set(&(a.version),SSL_SESSION_ASN1_VERSION); | 154 | ASN1_INTEGER_set(&(a.version), SSL_SESSION_ASN1_VERSION); |
155 | 155 | ||
156 | a.ssl_version.length=LSIZE2; | 156 | a.ssl_version.length = LSIZE2; |
157 | a.ssl_version.type=V_ASN1_INTEGER; | 157 | a.ssl_version.type = V_ASN1_INTEGER; |
158 | a.ssl_version.data=ibuf2; | 158 | a.ssl_version.data = ibuf2; |
159 | ASN1_INTEGER_set(&(a.ssl_version),in->ssl_version); | 159 | ASN1_INTEGER_set(&(a.ssl_version), in->ssl_version); |
160 | 160 | ||
161 | a.cipher.type=V_ASN1_OCTET_STRING; | 161 | a.cipher.type = V_ASN1_OCTET_STRING; |
162 | a.cipher.data=buf; | 162 | a.cipher.data = buf; |
163 | 163 | ||
164 | if (in->cipher == NULL) | 164 | if (in->cipher == NULL) |
165 | l=in->cipher_id; | 165 | l = in->cipher_id; |
166 | else | 166 | else |
167 | l=in->cipher->id; | 167 | l = in->cipher->id; |
168 | if (in->ssl_version == SSL2_VERSION) | 168 | if (in->ssl_version == SSL2_VERSION) { |
169 | { | 169 | a.cipher.length = 3; |
170 | a.cipher.length=3; | 170 | buf[0] = ((unsigned char)(l >> 16L))&0xff; |
171 | buf[0]=((unsigned char)(l>>16L))&0xff; | 171 | buf[1] = ((unsigned char)(l >> 8L))&0xff; |
172 | buf[1]=((unsigned char)(l>> 8L))&0xff; | 172 | buf[2] = ((unsigned char)(l ))&0xff; |
173 | buf[2]=((unsigned char)(l ))&0xff; | 173 | } else { |
174 | } | 174 | a.cipher.length = 2; |
175 | else | 175 | buf[0] = ((unsigned char)(l >> 8L))&0xff; |
176 | { | 176 | buf[1] = ((unsigned char)(l ))&0xff; |
177 | a.cipher.length=2; | 177 | } |
178 | buf[0]=((unsigned char)(l>>8L))&0xff; | ||
179 | buf[1]=((unsigned char)(l ))&0xff; | ||
180 | } | ||
181 | 178 | ||
182 | #ifndef OPENSSL_NO_COMP | 179 | #ifndef OPENSSL_NO_COMP |
183 | if (in->compress_meth) | 180 | if (in->compress_meth) { |
184 | { | ||
185 | cbuf = (unsigned char)in->compress_meth; | 181 | cbuf = (unsigned char)in->compress_meth; |
186 | a.comp_id.length = 1; | 182 | a.comp_id.length = 1; |
187 | a.comp_id.type = V_ASN1_OCTET_STRING; | 183 | a.comp_id.type = V_ASN1_OCTET_STRING; |
188 | a.comp_id.data = &cbuf; | 184 | a.comp_id.data = &cbuf; |
189 | } | 185 | } |
190 | #endif | 186 | #endif |
191 | 187 | ||
192 | a.master_key.length=in->master_key_length; | 188 | a.master_key.length = in->master_key_length; |
193 | a.master_key.type=V_ASN1_OCTET_STRING; | 189 | a.master_key.type = V_ASN1_OCTET_STRING; |
194 | a.master_key.data=in->master_key; | 190 | a.master_key.data = in->master_key; |
195 | 191 | ||
196 | a.session_id.length=in->session_id_length; | 192 | a.session_id.length = in->session_id_length; |
197 | a.session_id.type=V_ASN1_OCTET_STRING; | 193 | a.session_id.type = V_ASN1_OCTET_STRING; |
198 | a.session_id.data=in->session_id; | 194 | a.session_id.data = in->session_id; |
199 | 195 | ||
200 | a.session_id_context.length=in->sid_ctx_length; | 196 | a.session_id_context.length = in->sid_ctx_length; |
201 | a.session_id_context.type=V_ASN1_OCTET_STRING; | 197 | a.session_id_context.type = V_ASN1_OCTET_STRING; |
202 | a.session_id_context.data=in->sid_ctx; | 198 | a.session_id_context.data = in->sid_ctx; |
203 | 199 | ||
204 | a.key_arg.length=in->key_arg_length; | 200 | a.key_arg.length = in->key_arg_length; |
205 | a.key_arg.type=V_ASN1_OCTET_STRING; | 201 | a.key_arg.type = V_ASN1_OCTET_STRING; |
206 | a.key_arg.data=in->key_arg; | 202 | a.key_arg.data = in->key_arg; |
207 | 203 | ||
208 | #ifndef OPENSSL_NO_KRB5 | 204 | #ifndef OPENSSL_NO_KRB5 |
209 | if (in->krb5_client_princ_len) | 205 | if (in->krb5_client_princ_len) { |
210 | { | 206 | a.krb5_princ.length = in->krb5_client_princ_len; |
211 | a.krb5_princ.length=in->krb5_client_princ_len; | 207 | a.krb5_princ.type = V_ASN1_OCTET_STRING; |
212 | a.krb5_princ.type=V_ASN1_OCTET_STRING; | 208 | a.krb5_princ.data = in->krb5_client_princ; |
213 | a.krb5_princ.data=in->krb5_client_princ; | 209 | } |
214 | } | ||
215 | #endif /* OPENSSL_NO_KRB5 */ | 210 | #endif /* OPENSSL_NO_KRB5 */ |
216 | 211 | ||
217 | if (in->time != 0L) | 212 | if (in->time != 0L) { |
218 | { | 213 | a.time.length = LSIZE2; |
219 | a.time.length=LSIZE2; | 214 | a.time.type = V_ASN1_INTEGER; |
220 | a.time.type=V_ASN1_INTEGER; | 215 | a.time.data = ibuf3; |
221 | a.time.data=ibuf3; | 216 | ASN1_INTEGER_set(&(a.time), in->time); |
222 | ASN1_INTEGER_set(&(a.time),in->time); | 217 | } |
223 | } | ||
224 | 218 | ||
225 | if (in->timeout != 0L) | 219 | if (in->timeout != 0L) { |
226 | { | 220 | a.timeout.length = LSIZE2; |
227 | a.timeout.length=LSIZE2; | 221 | a.timeout.type = V_ASN1_INTEGER; |
228 | a.timeout.type=V_ASN1_INTEGER; | 222 | a.timeout.data = ibuf4; |
229 | a.timeout.data=ibuf4; | 223 | ASN1_INTEGER_set(&(a.timeout), in->timeout); |
230 | ASN1_INTEGER_set(&(a.timeout),in->timeout); | 224 | } |
231 | } | ||
232 | 225 | ||
233 | if (in->verify_result != X509_V_OK) | 226 | if (in->verify_result != X509_V_OK) { |
234 | { | 227 | a.verify_result.length = LSIZE2; |
235 | a.verify_result.length=LSIZE2; | 228 | a.verify_result.type = V_ASN1_INTEGER; |
236 | a.verify_result.type=V_ASN1_INTEGER; | 229 | a.verify_result.data = ibuf5; |
237 | a.verify_result.data=ibuf5; | 230 | ASN1_INTEGER_set(&a.verify_result, in->verify_result); |
238 | ASN1_INTEGER_set(&a.verify_result,in->verify_result); | 231 | } |
239 | } | ||
240 | 232 | ||
241 | #ifndef OPENSSL_NO_TLSEXT | 233 | #ifndef OPENSSL_NO_TLSEXT |
242 | if (in->tlsext_hostname) | 234 | if (in->tlsext_hostname) { |
243 | { | 235 | a.tlsext_hostname.length = strlen(in->tlsext_hostname); |
244 | a.tlsext_hostname.length=strlen(in->tlsext_hostname); | 236 | a.tlsext_hostname.type = V_ASN1_OCTET_STRING; |
245 | a.tlsext_hostname.type=V_ASN1_OCTET_STRING; | 237 | a.tlsext_hostname.data = (unsigned char *)in->tlsext_hostname; |
246 | a.tlsext_hostname.data=(unsigned char *)in->tlsext_hostname; | 238 | } |
247 | } | 239 | if (in->tlsext_tick) { |
248 | if (in->tlsext_tick) | 240 | a.tlsext_tick.length = in->tlsext_ticklen; |
249 | { | 241 | a.tlsext_tick.type = V_ASN1_OCTET_STRING; |
250 | a.tlsext_tick.length= in->tlsext_ticklen; | 242 | a.tlsext_tick.data = (unsigned char *)in->tlsext_tick; |
251 | a.tlsext_tick.type=V_ASN1_OCTET_STRING; | 243 | } |
252 | a.tlsext_tick.data=(unsigned char *)in->tlsext_tick; | 244 | if (in->tlsext_tick_lifetime_hint > 0) { |
253 | } | 245 | a.tlsext_tick_lifetime.length = LSIZE2; |
254 | if (in->tlsext_tick_lifetime_hint > 0) | 246 | a.tlsext_tick_lifetime.type = V_ASN1_INTEGER; |
255 | { | 247 | a.tlsext_tick_lifetime.data = ibuf6; |
256 | a.tlsext_tick_lifetime.length=LSIZE2; | 248 | ASN1_INTEGER_set(&a.tlsext_tick_lifetime, in->tlsext_tick_lifetime_hint); |
257 | a.tlsext_tick_lifetime.type=V_ASN1_INTEGER; | 249 | } |
258 | a.tlsext_tick_lifetime.data=ibuf6; | ||
259 | ASN1_INTEGER_set(&a.tlsext_tick_lifetime,in->tlsext_tick_lifetime_hint); | ||
260 | } | ||
261 | #endif /* OPENSSL_NO_TLSEXT */ | 250 | #endif /* OPENSSL_NO_TLSEXT */ |
262 | #ifndef OPENSSL_NO_PSK | 251 | #ifndef OPENSSL_NO_PSK |
263 | if (in->psk_identity_hint) | 252 | if (in->psk_identity_hint) { |
264 | { | 253 | a.psk_identity_hint.length = strlen(in->psk_identity_hint); |
265 | a.psk_identity_hint.length=strlen(in->psk_identity_hint); | 254 | a.psk_identity_hint.type = V_ASN1_OCTET_STRING; |
266 | a.psk_identity_hint.type=V_ASN1_OCTET_STRING; | 255 | a.psk_identity_hint.data = (unsigned char *)(in->psk_identity_hint); |
267 | a.psk_identity_hint.data=(unsigned char *)(in->psk_identity_hint); | 256 | } |
268 | } | 257 | if (in->psk_identity) { |
269 | if (in->psk_identity) | 258 | a.psk_identity.length = strlen(in->psk_identity); |
270 | { | 259 | a.psk_identity.type = V_ASN1_OCTET_STRING; |
271 | a.psk_identity.length=strlen(in->psk_identity); | 260 | a.psk_identity.data = (unsigned char *)(in->psk_identity); |
272 | a.psk_identity.type=V_ASN1_OCTET_STRING; | 261 | } |
273 | a.psk_identity.data=(unsigned char *)(in->psk_identity); | ||
274 | } | ||
275 | #endif /* OPENSSL_NO_PSK */ | 262 | #endif /* OPENSSL_NO_PSK */ |
276 | #ifndef OPENSSL_NO_SRP | 263 | #ifndef OPENSSL_NO_SRP |
277 | if (in->srp_username) | 264 | if (in->srp_username) { |
278 | { | 265 | a.srp_username.length = strlen(in->srp_username); |
279 | a.srp_username.length=strlen(in->srp_username); | 266 | a.srp_username.type = V_ASN1_OCTET_STRING; |
280 | a.srp_username.type=V_ASN1_OCTET_STRING; | 267 | a.srp_username.data = (unsigned char *)(in->srp_username); |
281 | a.srp_username.data=(unsigned char *)(in->srp_username); | 268 | } |
282 | } | ||
283 | #endif /* OPENSSL_NO_SRP */ | 269 | #endif /* OPENSSL_NO_SRP */ |
284 | 270 | ||
285 | M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); | 271 | M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); |
@@ -289,41 +275,41 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | |||
289 | M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING); | 275 | M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING); |
290 | #ifndef OPENSSL_NO_KRB5 | 276 | #ifndef OPENSSL_NO_KRB5 |
291 | if (in->krb5_client_princ_len) | 277 | if (in->krb5_client_princ_len) |
292 | M_ASN1_I2D_len(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); | 278 | M_ASN1_I2D_len(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); |
293 | #endif /* OPENSSL_NO_KRB5 */ | 279 | #endif /* OPENSSL_NO_KRB5 */ |
294 | if (in->key_arg_length > 0) | 280 | if (in->key_arg_length > 0) |
295 | M_ASN1_I2D_len_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING); | 281 | M_ASN1_I2D_len_IMP_opt(&(a.key_arg), i2d_ASN1_OCTET_STRING); |
296 | if (in->time != 0L) | 282 | if (in->time != 0L) |
297 | M_ASN1_I2D_len_EXP_opt(&(a.time),i2d_ASN1_INTEGER,1,v1); | 283 | M_ASN1_I2D_len_EXP_opt(&(a.time), i2d_ASN1_INTEGER, 1, v1); |
298 | if (in->timeout != 0L) | 284 | if (in->timeout != 0L) |
299 | M_ASN1_I2D_len_EXP_opt(&(a.timeout),i2d_ASN1_INTEGER,2,v2); | 285 | M_ASN1_I2D_len_EXP_opt(&(a.timeout), i2d_ASN1_INTEGER, 2, v2); |
300 | if (in->peer != NULL) | 286 | if (in->peer != NULL) |
301 | M_ASN1_I2D_len_EXP_opt(in->peer,i2d_X509,3,v3); | 287 | M_ASN1_I2D_len_EXP_opt(in->peer, i2d_X509, 3, v3); |
302 | M_ASN1_I2D_len_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4,v4); | 288 | M_ASN1_I2D_len_EXP_opt(&a.session_id_context, i2d_ASN1_OCTET_STRING, 4, v4); |
303 | if (in->verify_result != X509_V_OK) | 289 | if (in->verify_result != X509_V_OK) |
304 | M_ASN1_I2D_len_EXP_opt(&(a.verify_result),i2d_ASN1_INTEGER,5,v5); | 290 | M_ASN1_I2D_len_EXP_opt(&(a.verify_result), i2d_ASN1_INTEGER, 5, v5); |
305 | 291 | ||
306 | #ifndef OPENSSL_NO_TLSEXT | 292 | #ifndef OPENSSL_NO_TLSEXT |
307 | if (in->tlsext_tick_lifetime_hint > 0) | 293 | if (in->tlsext_tick_lifetime_hint > 0) |
308 | 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); |
309 | if (in->tlsext_tick) | 295 | if (in->tlsext_tick) |
310 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING,10,v10); | 296 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING, 10, v10); |
311 | if (in->tlsext_hostname) | 297 | if (in->tlsext_hostname) |
312 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING,6,v6); | 298 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); |
313 | #ifndef OPENSSL_NO_COMP | 299 | #ifndef OPENSSL_NO_COMP |
314 | if (in->compress_meth) | 300 | if (in->compress_meth) |
315 | M_ASN1_I2D_len_EXP_opt(&(a.comp_id), i2d_ASN1_OCTET_STRING,11,v11); | 301 | M_ASN1_I2D_len_EXP_opt(&(a.comp_id), i2d_ASN1_OCTET_STRING, 11, v11); |
316 | #endif | 302 | #endif |
317 | #endif /* OPENSSL_NO_TLSEXT */ | 303 | #endif /* OPENSSL_NO_TLSEXT */ |
318 | #ifndef OPENSSL_NO_PSK | 304 | #ifndef OPENSSL_NO_PSK |
319 | if (in->psk_identity_hint) | 305 | if (in->psk_identity_hint) |
320 | M_ASN1_I2D_len_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_STRING,7,v7); | 306 | M_ASN1_I2D_len_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_STRING, 7, v7); |
321 | if (in->psk_identity) | 307 | if (in->psk_identity) |
322 | M_ASN1_I2D_len_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING,8,v8); | 308 | M_ASN1_I2D_len_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING, 8, v8); |
323 | #endif /* OPENSSL_NO_PSK */ | 309 | #endif /* OPENSSL_NO_PSK */ |
324 | #ifndef OPENSSL_NO_SRP | 310 | #ifndef OPENSSL_NO_SRP |
325 | if (in->srp_username) | 311 | if (in->srp_username) |
326 | M_ASN1_I2D_len_EXP_opt(&(a.srp_username), i2d_ASN1_OCTET_STRING,12,v12); | 312 | M_ASN1_I2D_len_EXP_opt(&(a.srp_username), i2d_ASN1_OCTET_STRING, 12, v12); |
327 | #endif /* OPENSSL_NO_SRP */ | 313 | #endif /* OPENSSL_NO_SRP */ |
328 | 314 | ||
329 | M_ASN1_I2D_seq_total(); | 315 | M_ASN1_I2D_seq_total(); |
@@ -335,308 +321,296 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | |||
335 | M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING); | 321 | M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING); |
336 | #ifndef OPENSSL_NO_KRB5 | 322 | #ifndef OPENSSL_NO_KRB5 |
337 | if (in->krb5_client_princ_len) | 323 | if (in->krb5_client_princ_len) |
338 | M_ASN1_I2D_put(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); | 324 | M_ASN1_I2D_put(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); |
339 | #endif /* OPENSSL_NO_KRB5 */ | 325 | #endif /* OPENSSL_NO_KRB5 */ |
340 | if (in->key_arg_length > 0) | 326 | if (in->key_arg_length > 0) |
341 | M_ASN1_I2D_put_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING,0); | 327 | M_ASN1_I2D_put_IMP_opt(&(a.key_arg), i2d_ASN1_OCTET_STRING, 0); |
342 | if (in->time != 0L) | 328 | if (in->time != 0L) |
343 | M_ASN1_I2D_put_EXP_opt(&(a.time),i2d_ASN1_INTEGER,1,v1); | 329 | M_ASN1_I2D_put_EXP_opt(&(a.time), i2d_ASN1_INTEGER, 1, v1); |
344 | if (in->timeout != 0L) | 330 | if (in->timeout != 0L) |
345 | M_ASN1_I2D_put_EXP_opt(&(a.timeout),i2d_ASN1_INTEGER,2,v2); | 331 | M_ASN1_I2D_put_EXP_opt(&(a.timeout), i2d_ASN1_INTEGER, 2, v2); |
346 | if (in->peer != NULL) | 332 | if (in->peer != NULL) |
347 | M_ASN1_I2D_put_EXP_opt(in->peer,i2d_X509,3,v3); | 333 | M_ASN1_I2D_put_EXP_opt(in->peer, i2d_X509, 3, v3); |
348 | M_ASN1_I2D_put_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4, | 334 | M_ASN1_I2D_put_EXP_opt(&a.session_id_context, i2d_ASN1_OCTET_STRING, 4, |
349 | v4); | 335 | v4); |
350 | if (in->verify_result != X509_V_OK) | 336 | if (in->verify_result != X509_V_OK) |
351 | M_ASN1_I2D_put_EXP_opt(&a.verify_result,i2d_ASN1_INTEGER,5,v5); | 337 | M_ASN1_I2D_put_EXP_opt(&a.verify_result, i2d_ASN1_INTEGER, 5, v5); |
352 | #ifndef OPENSSL_NO_TLSEXT | 338 | #ifndef OPENSSL_NO_TLSEXT |
353 | if (in->tlsext_hostname) | 339 | if (in->tlsext_hostname) |
354 | M_ASN1_I2D_put_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING,6,v6); | 340 | M_ASN1_I2D_put_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); |
355 | #endif /* OPENSSL_NO_TLSEXT */ | 341 | #endif /* OPENSSL_NO_TLSEXT */ |
356 | #ifndef OPENSSL_NO_PSK | 342 | #ifndef OPENSSL_NO_PSK |
357 | if (in->psk_identity_hint) | 343 | if (in->psk_identity_hint) |
358 | M_ASN1_I2D_put_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_STRING,7,v7); | 344 | M_ASN1_I2D_put_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_STRING, 7, v7); |
359 | if (in->psk_identity) | 345 | if (in->psk_identity) |
360 | M_ASN1_I2D_put_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING,8,v8); | 346 | M_ASN1_I2D_put_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING, 8, v8); |
361 | #endif /* OPENSSL_NO_PSK */ | 347 | #endif /* OPENSSL_NO_PSK */ |
362 | #ifndef OPENSSL_NO_TLSEXT | 348 | #ifndef OPENSSL_NO_TLSEXT |
363 | if (in->tlsext_tick_lifetime_hint > 0) | 349 | if (in->tlsext_tick_lifetime_hint > 0) |
364 | M_ASN1_I2D_put_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER,9,v9); | 350 | M_ASN1_I2D_put_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER, 9, v9); |
365 | if (in->tlsext_tick) | 351 | if (in->tlsext_tick) |
366 | M_ASN1_I2D_put_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING,10,v10); | 352 | M_ASN1_I2D_put_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING, 10, v10); |
367 | #endif /* OPENSSL_NO_TLSEXT */ | 353 | #endif /* OPENSSL_NO_TLSEXT */ |
368 | #ifndef OPENSSL_NO_COMP | 354 | #ifndef OPENSSL_NO_COMP |
369 | if (in->compress_meth) | 355 | if (in->compress_meth) |
370 | M_ASN1_I2D_put_EXP_opt(&(a.comp_id), i2d_ASN1_OCTET_STRING,11,v11); | 356 | M_ASN1_I2D_put_EXP_opt(&(a.comp_id), i2d_ASN1_OCTET_STRING, 11, v11); |
371 | #endif | 357 | #endif |
372 | #ifndef OPENSSL_NO_SRP | 358 | #ifndef OPENSSL_NO_SRP |
373 | if (in->srp_username) | 359 | if (in->srp_username) |
374 | M_ASN1_I2D_put_EXP_opt(&(a.srp_username), i2d_ASN1_OCTET_STRING,12,v12); | 360 | M_ASN1_I2D_put_EXP_opt(&(a.srp_username), i2d_ASN1_OCTET_STRING, 12, v12); |
375 | #endif /* OPENSSL_NO_SRP */ | 361 | #endif /* OPENSSL_NO_SRP */ |
376 | M_ASN1_I2D_finish(); | 362 | M_ASN1_I2D_finish(); |
377 | } | 363 | } |
378 | 364 | ||
379 | SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, | 365 | SSL_SESSION |
380 | long length) | 366 | *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, |
381 | { | 367 | long length) |
382 | int ssl_version=0,i; | 368 | { |
369 | int ssl_version = 0, i; | ||
383 | long id; | 370 | long id; |
384 | ASN1_INTEGER ai,*aip; | 371 | ASN1_INTEGER ai, *aip; |
385 | ASN1_OCTET_STRING os,*osp; | 372 | ASN1_OCTET_STRING os, *osp; |
386 | M_ASN1_D2I_vars(a,SSL_SESSION *,SSL_SESSION_new); | 373 | M_ASN1_D2I_vars(a, SSL_SESSION *, SSL_SESSION_new); |
387 | 374 | ||
388 | aip= &ai; | 375 | aip = &ai; |
389 | osp= &os; | 376 | osp = &os; |
390 | 377 | ||
391 | M_ASN1_D2I_Init(); | 378 | M_ASN1_D2I_Init(); |
392 | M_ASN1_D2I_start_sequence(); | 379 | M_ASN1_D2I_start_sequence(); |
393 | 380 | ||
394 | ai.data=NULL; ai.length=0; | 381 | ai.data = NULL; |
395 | M_ASN1_D2I_get_x(ASN1_INTEGER,aip,d2i_ASN1_INTEGER); | 382 | ai.length = 0; |
396 | if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; } | 383 | M_ASN1_D2I_get_x(ASN1_INTEGER, aip, d2i_ASN1_INTEGER); |
384 | if (ai.data != NULL) { | ||
385 | OPENSSL_free(ai.data); | ||
386 | ai.data = NULL; | ||
387 | ai.length = 0; | ||
388 | } | ||
397 | 389 | ||
398 | /* we don't care about the version right now :-) */ | 390 | /* we don't care about the version right now :-) */ |
399 | M_ASN1_D2I_get_x(ASN1_INTEGER,aip,d2i_ASN1_INTEGER); | 391 | M_ASN1_D2I_get_x(ASN1_INTEGER, aip, d2i_ASN1_INTEGER); |
400 | ssl_version=(int)ASN1_INTEGER_get(aip); | 392 | ssl_version = (int)ASN1_INTEGER_get(aip); |
401 | ret->ssl_version=ssl_version; | 393 | ret->ssl_version = ssl_version; |
402 | if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; } | 394 | if (ai.data != NULL) { |
403 | 395 | OPENSSL_free(ai.data); | |
404 | os.data=NULL; os.length=0; | 396 | ai.data = NULL; |
405 | M_ASN1_D2I_get_x(ASN1_OCTET_STRING,osp,d2i_ASN1_OCTET_STRING); | 397 | ai.length = 0; |
406 | if (ssl_version == SSL2_VERSION) | 398 | } |
407 | { | 399 | |
408 | if (os.length != 3) | 400 | os.data = NULL; |
409 | { | 401 | os.length = 0; |
410 | c.error=SSL_R_CIPHER_CODE_WRONG_LENGTH; | 402 | M_ASN1_D2I_get_x(ASN1_OCTET_STRING, osp, d2i_ASN1_OCTET_STRING); |
403 | if (ssl_version == SSL2_VERSION) { | ||
404 | if (os.length != 3) { | ||
405 | c.error = SSL_R_CIPHER_CODE_WRONG_LENGTH; | ||
411 | goto err; | 406 | goto err; |
412 | } | ||
413 | id=0x02000000L| | ||
414 | ((unsigned long)os.data[0]<<16L)| | ||
415 | ((unsigned long)os.data[1]<< 8L)| | ||
416 | (unsigned long)os.data[2]; | ||
417 | } | 407 | } |
418 | else if ((ssl_version>>8) >= SSL3_VERSION_MAJOR) | 408 | id = 0x02000000L| |
419 | { | 409 | ((unsigned long)os.data[0]<<16L)| |
420 | if (os.length != 2) | 410 | ((unsigned long)os.data[1]<< 8L)| |
421 | { | 411 | (unsigned long)os.data[2]; |
422 | c.error=SSL_R_CIPHER_CODE_WRONG_LENGTH; | 412 | } else if ((ssl_version >> 8) >= SSL3_VERSION_MAJOR) { |
413 | if (os.length != 2) { | ||
414 | c.error = SSL_R_CIPHER_CODE_WRONG_LENGTH; | ||
423 | goto err; | 415 | goto err; |
424 | } | ||
425 | id=0x03000000L| | ||
426 | ((unsigned long)os.data[0]<<8L)| | ||
427 | (unsigned long)os.data[1]; | ||
428 | } | 416 | } |
429 | else | 417 | id = 0x03000000L| |
430 | { | 418 | ((unsigned long)os.data[0]<<8L)| |
431 | c.error=SSL_R_UNKNOWN_SSL_VERSION; | 419 | (unsigned long)os.data[1]; |
420 | } else { | ||
421 | c.error = SSL_R_UNKNOWN_SSL_VERSION; | ||
432 | goto err; | 422 | goto err; |
433 | } | 423 | } |
434 | 424 | ||
435 | ret->cipher=NULL; | 425 | ret->cipher = NULL; |
436 | ret->cipher_id=id; | 426 | ret->cipher_id = id; |
437 | 427 | ||
438 | M_ASN1_D2I_get_x(ASN1_OCTET_STRING,osp,d2i_ASN1_OCTET_STRING); | 428 | M_ASN1_D2I_get_x(ASN1_OCTET_STRING, osp, d2i_ASN1_OCTET_STRING); |
439 | if ((ssl_version>>8) >= SSL3_VERSION_MAJOR) | 429 | if ((ssl_version >> 8) >= SSL3_VERSION_MAJOR) |
440 | i=SSL3_MAX_SSL_SESSION_ID_LENGTH; | 430 | i = SSL3_MAX_SSL_SESSION_ID_LENGTH; |
441 | else /* if (ssl_version>>8 == SSL2_VERSION_MAJOR) */ | 431 | else /* if (ssl_version>>8 == SSL2_VERSION_MAJOR) */ |
442 | i=SSL2_MAX_SSL_SESSION_ID_LENGTH; | 432 | i = SSL2_MAX_SSL_SESSION_ID_LENGTH; |
443 | 433 | ||
444 | if (os.length > i) | 434 | if (os.length > i) |
445 | os.length = i; | 435 | os.length = i; |
446 | if (os.length > (int)sizeof(ret->session_id)) /* can't happen */ | 436 | if (os.length > (int)sizeof(ret->session_id)) /* can't happen */ |
447 | os.length = sizeof(ret->session_id); | 437 | os.length = sizeof(ret->session_id); |
448 | 438 | ||
449 | ret->session_id_length=os.length; | 439 | ret->session_id_length = os.length; |
450 | OPENSSL_assert(os.length <= (int)sizeof(ret->session_id)); | 440 | OPENSSL_assert(os.length <= (int)sizeof(ret->session_id)); |
451 | memcpy(ret->session_id,os.data,os.length); | 441 | memcpy(ret->session_id, os.data, os.length); |
452 | 442 | ||
453 | M_ASN1_D2I_get_x(ASN1_OCTET_STRING,osp,d2i_ASN1_OCTET_STRING); | 443 | M_ASN1_D2I_get_x(ASN1_OCTET_STRING, osp, d2i_ASN1_OCTET_STRING); |
454 | if (os.length > SSL_MAX_MASTER_KEY_LENGTH) | 444 | if (os.length > SSL_MAX_MASTER_KEY_LENGTH) |
455 | ret->master_key_length=SSL_MAX_MASTER_KEY_LENGTH; | 445 | ret->master_key_length = SSL_MAX_MASTER_KEY_LENGTH; |
456 | else | 446 | else |
457 | ret->master_key_length=os.length; | 447 | ret->master_key_length = os.length; |
458 | memcpy(ret->master_key,os.data,ret->master_key_length); | 448 | memcpy(ret->master_key, os.data, ret->master_key_length); |
459 | 449 | ||
460 | os.length=0; | 450 | os.length = 0; |
461 | 451 | ||
462 | #ifndef OPENSSL_NO_KRB5 | 452 | #ifndef OPENSSL_NO_KRB5 |
463 | os.length=0; | 453 | os.length = 0; |
464 | M_ASN1_D2I_get_opt(osp,d2i_ASN1_OCTET_STRING,V_ASN1_OCTET_STRING); | 454 | M_ASN1_D2I_get_opt(osp, d2i_ASN1_OCTET_STRING, V_ASN1_OCTET_STRING); |
465 | if (os.data) | 455 | if (os.data) { |
466 | { | 456 | if (os.length > SSL_MAX_KRB5_PRINCIPAL_LENGTH) |
467 | if (os.length > SSL_MAX_KRB5_PRINCIPAL_LENGTH) | 457 | ret->krb5_client_princ_len = 0; |
468 | ret->krb5_client_princ_len=0; | ||
469 | else | 458 | else |
470 | ret->krb5_client_princ_len=os.length; | 459 | ret->krb5_client_princ_len = os.length; |
471 | memcpy(ret->krb5_client_princ,os.data,ret->krb5_client_princ_len); | 460 | memcpy(ret->krb5_client_princ, os.data, ret->krb5_client_princ_len); |
472 | OPENSSL_free(os.data); | 461 | OPENSSL_free(os.data); |
473 | os.data = NULL; | 462 | os.data = NULL; |
474 | os.length = 0; | 463 | os.length = 0; |
475 | } | 464 | } else |
476 | else | 465 | ret->krb5_client_princ_len = 0; |
477 | ret->krb5_client_princ_len=0; | ||
478 | #endif /* OPENSSL_NO_KRB5 */ | 466 | #endif /* OPENSSL_NO_KRB5 */ |
479 | 467 | ||
480 | M_ASN1_D2I_get_IMP_opt(osp,d2i_ASN1_OCTET_STRING,0,V_ASN1_OCTET_STRING); | 468 | M_ASN1_D2I_get_IMP_opt(osp, d2i_ASN1_OCTET_STRING, 0, V_ASN1_OCTET_STRING); |
481 | if (os.length > SSL_MAX_KEY_ARG_LENGTH) | 469 | if (os.length > SSL_MAX_KEY_ARG_LENGTH) |
482 | ret->key_arg_length=SSL_MAX_KEY_ARG_LENGTH; | 470 | ret->key_arg_length = SSL_MAX_KEY_ARG_LENGTH; |
483 | else | 471 | else |
484 | ret->key_arg_length=os.length; | 472 | ret->key_arg_length = os.length; |
485 | memcpy(ret->key_arg,os.data,ret->key_arg_length); | 473 | memcpy(ret->key_arg, os.data, ret->key_arg_length); |
486 | if (os.data != NULL) OPENSSL_free(os.data); | 474 | if (os.data != NULL) |
487 | 475 | OPENSSL_free(os.data); | |
488 | ai.length=0; | ||
489 | M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,1); | ||
490 | if (ai.data != NULL) | ||
491 | { | ||
492 | ret->time=ASN1_INTEGER_get(aip); | ||
493 | OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; | ||
494 | } | ||
495 | else | ||
496 | ret->time=(unsigned long)time(NULL); | ||
497 | |||
498 | ai.length=0; | ||
499 | M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,2); | ||
500 | if (ai.data != NULL) | ||
501 | { | ||
502 | ret->timeout=ASN1_INTEGER_get(aip); | ||
503 | OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; | ||
504 | } | ||
505 | else | ||
506 | ret->timeout=3; | ||
507 | 476 | ||
508 | if (ret->peer != NULL) | 477 | ai.length = 0; |
509 | { | 478 | M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 1); |
479 | if (ai.data != NULL) { | ||
480 | ret->time = ASN1_INTEGER_get(aip); | ||
481 | OPENSSL_free(ai.data); | ||
482 | ai.data = NULL; | ||
483 | ai.length = 0; | ||
484 | } else | ||
485 | ret->time = (unsigned long)time(NULL); | ||
486 | |||
487 | ai.length = 0; | ||
488 | M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 2); | ||
489 | if (ai.data != NULL) { | ||
490 | ret->timeout = ASN1_INTEGER_get(aip); | ||
491 | OPENSSL_free(ai.data); | ||
492 | ai.data = NULL; | ||
493 | ai.length = 0; | ||
494 | } else | ||
495 | ret->timeout = 3; | ||
496 | |||
497 | if (ret->peer != NULL) { | ||
510 | X509_free(ret->peer); | 498 | X509_free(ret->peer); |
511 | ret->peer=NULL; | 499 | ret->peer = NULL; |
512 | } | 500 | } |
513 | M_ASN1_D2I_get_EXP_opt(ret->peer,d2i_X509,3); | 501 | M_ASN1_D2I_get_EXP_opt(ret->peer, d2i_X509, 3); |
514 | 502 | ||
515 | os.length=0; | 503 | os.length = 0; |
516 | os.data=NULL; | 504 | os.data = NULL; |
517 | M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,4); | 505 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 4); |
518 | 506 | ||
519 | if(os.data != NULL) | 507 | if (os.data != NULL) { |
520 | { | 508 | if (os.length > SSL_MAX_SID_CTX_LENGTH) { |
521 | if (os.length > SSL_MAX_SID_CTX_LENGTH) | 509 | c.error = SSL_R_BAD_LENGTH; |
522 | { | 510 | goto err; |
523 | c.error=SSL_R_BAD_LENGTH; | 511 | } else { |
524 | goto err; | 512 | ret->sid_ctx_length = os.length; |
525 | } | 513 | memcpy(ret->sid_ctx, os.data, os.length); |
526 | else | ||
527 | { | ||
528 | ret->sid_ctx_length=os.length; | ||
529 | memcpy(ret->sid_ctx,os.data,os.length); | ||
530 | } | ||
531 | OPENSSL_free(os.data); os.data=NULL; os.length=0; | ||
532 | } | ||
533 | else | ||
534 | ret->sid_ctx_length=0; | ||
535 | |||
536 | ai.length=0; | ||
537 | M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,5); | ||
538 | if (ai.data != NULL) | ||
539 | { | ||
540 | ret->verify_result=ASN1_INTEGER_get(aip); | ||
541 | OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; | ||
542 | } | 514 | } |
543 | else | 515 | OPENSSL_free(os.data); |
544 | ret->verify_result=X509_V_OK; | 516 | os.data = NULL; |
517 | os.length = 0; | ||
518 | } else | ||
519 | ret->sid_ctx_length = 0; | ||
520 | |||
521 | ai.length = 0; | ||
522 | M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 5); | ||
523 | if (ai.data != NULL) { | ||
524 | ret->verify_result = ASN1_INTEGER_get(aip); | ||
525 | OPENSSL_free(ai.data); | ||
526 | ai.data = NULL; | ||
527 | ai.length = 0; | ||
528 | } else | ||
529 | ret->verify_result = X509_V_OK; | ||
545 | 530 | ||
546 | #ifndef OPENSSL_NO_TLSEXT | 531 | #ifndef OPENSSL_NO_TLSEXT |
547 | os.length=0; | 532 | os.length = 0; |
548 | os.data=NULL; | 533 | os.data = NULL; |
549 | M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,6); | 534 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 6); |
550 | if (os.data) | 535 | if (os.data) { |
551 | { | ||
552 | ret->tlsext_hostname = BUF_strndup((char *)os.data, os.length); | 536 | ret->tlsext_hostname = BUF_strndup((char *)os.data, os.length); |
553 | OPENSSL_free(os.data); | 537 | OPENSSL_free(os.data); |
554 | os.data = NULL; | 538 | os.data = NULL; |
555 | os.length = 0; | 539 | os.length = 0; |
556 | } | 540 | } else |
557 | else | 541 | ret->tlsext_hostname = NULL; |
558 | ret->tlsext_hostname=NULL; | ||
559 | #endif /* OPENSSL_NO_TLSEXT */ | 542 | #endif /* OPENSSL_NO_TLSEXT */ |
560 | 543 | ||
561 | #ifndef OPENSSL_NO_PSK | 544 | #ifndef OPENSSL_NO_PSK |
562 | os.length=0; | 545 | os.length = 0; |
563 | os.data=NULL; | 546 | os.data = NULL; |
564 | M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,7); | 547 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 7); |
565 | if (os.data) | 548 | if (os.data) { |
566 | { | ||
567 | ret->psk_identity_hint = BUF_strndup((char *)os.data, os.length); | 549 | ret->psk_identity_hint = BUF_strndup((char *)os.data, os.length); |
568 | OPENSSL_free(os.data); | 550 | OPENSSL_free(os.data); |
569 | os.data = NULL; | 551 | os.data = NULL; |
570 | os.length = 0; | 552 | os.length = 0; |
571 | } | 553 | } else |
572 | else | 554 | ret->psk_identity_hint = NULL; |
573 | ret->psk_identity_hint=NULL; | ||
574 | 555 | ||
575 | os.length=0; | 556 | os.length = 0; |
576 | os.data=NULL; | 557 | os.data = NULL; |
577 | M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,8); | 558 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 8); |
578 | if (os.data) | 559 | if (os.data) { |
579 | { | ||
580 | ret->psk_identity = BUF_strndup((char *)os.data, os.length); | 560 | ret->psk_identity = BUF_strndup((char *)os.data, os.length); |
581 | OPENSSL_free(os.data); | 561 | OPENSSL_free(os.data); |
582 | os.data = NULL; | 562 | os.data = NULL; |
583 | os.length = 0; | 563 | os.length = 0; |
584 | } | 564 | } else |
585 | else | 565 | ret->psk_identity = NULL; |
586 | ret->psk_identity=NULL; | ||
587 | #endif /* OPENSSL_NO_PSK */ | 566 | #endif /* OPENSSL_NO_PSK */ |
588 | 567 | ||
589 | #ifndef OPENSSL_NO_TLSEXT | 568 | #ifndef OPENSSL_NO_TLSEXT |
590 | ai.length=0; | 569 | ai.length = 0; |
591 | M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,9); | 570 | M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 9); |
592 | if (ai.data != NULL) | 571 | if (ai.data != NULL) { |
593 | { | 572 | ret->tlsext_tick_lifetime_hint = ASN1_INTEGER_get(aip); |
594 | ret->tlsext_tick_lifetime_hint=ASN1_INTEGER_get(aip); | 573 | OPENSSL_free(ai.data); |
595 | OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; | 574 | ai.data = NULL; |
596 | } | 575 | ai.length = 0; |
597 | else if (ret->tlsext_ticklen && ret->session_id_length) | 576 | } else if (ret->tlsext_ticklen && ret->session_id_length) |
598 | ret->tlsext_tick_lifetime_hint = -1; | 577 | ret->tlsext_tick_lifetime_hint = -1; |
599 | else | 578 | else |
600 | ret->tlsext_tick_lifetime_hint=0; | 579 | ret->tlsext_tick_lifetime_hint = 0; |
601 | os.length=0; | 580 | os.length = 0; |
602 | os.data=NULL; | 581 | os.data = NULL; |
603 | M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,10); | 582 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 10); |
604 | if (os.data) | 583 | if (os.data) { |
605 | { | ||
606 | ret->tlsext_tick = os.data; | 584 | ret->tlsext_tick = os.data; |
607 | ret->tlsext_ticklen = os.length; | 585 | ret->tlsext_ticklen = os.length; |
608 | os.data = NULL; | 586 | os.data = NULL; |
609 | os.length = 0; | 587 | os.length = 0; |
610 | } | 588 | } else |
611 | else | 589 | ret->tlsext_tick = NULL; |
612 | ret->tlsext_tick=NULL; | ||
613 | #endif /* OPENSSL_NO_TLSEXT */ | 590 | #endif /* OPENSSL_NO_TLSEXT */ |
614 | #ifndef OPENSSL_NO_COMP | 591 | #ifndef OPENSSL_NO_COMP |
615 | os.length=0; | 592 | os.length = 0; |
616 | os.data=NULL; | 593 | os.data = NULL; |
617 | M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,11); | 594 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 11); |
618 | if (os.data) | 595 | if (os.data) { |
619 | { | ||
620 | ret->compress_meth = os.data[0]; | 596 | ret->compress_meth = os.data[0]; |
621 | OPENSSL_free(os.data); | 597 | OPENSSL_free(os.data); |
622 | os.data = NULL; | 598 | os.data = NULL; |
623 | } | 599 | } |
624 | #endif | 600 | #endif |
625 | 601 | ||
626 | #ifndef OPENSSL_NO_SRP | 602 | #ifndef OPENSSL_NO_SRP |
627 | os.length=0; | 603 | os.length = 0; |
628 | os.data=NULL; | 604 | os.data = NULL; |
629 | M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,12); | 605 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 12); |
630 | if (os.data) | 606 | if (os.data) { |
631 | { | ||
632 | ret->srp_username = BUF_strndup((char *)os.data, os.length); | 607 | ret->srp_username = BUF_strndup((char *)os.data, os.length); |
633 | OPENSSL_free(os.data); | 608 | OPENSSL_free(os.data); |
634 | os.data = NULL; | 609 | os.data = NULL; |
635 | os.length = 0; | 610 | os.length = 0; |
636 | } | 611 | } else |
637 | else | 612 | ret->srp_username = NULL; |
638 | ret->srp_username=NULL; | ||
639 | #endif /* OPENSSL_NO_SRP */ | 613 | #endif /* OPENSSL_NO_SRP */ |
640 | 614 | ||
641 | M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION); | 615 | M_ASN1_D2I_Finish(a, SSL_SESSION_free, SSL_F_D2I_SSL_SESSION); |
642 | } | 616 | } |