ssl_asn1.c (59191) | ssl_asn1.c (68651) |
---|---|
1/* ssl/ssl_asn1.c */ 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * --- 78 unchanged lines hidden (view full) --- 87 SSL_SESSION_ASN1 a; 88 M_ASN1_I2D_vars(in); 89 90 if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0))) 91 return(0); 92 93 /* Note that I cheat in the following 2 assignments. I know 94 * that if the ASN1_INTEGER passed to ASN1_INTEGER_set | 1/* ssl/ssl_asn1.c */ 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * --- 78 unchanged lines hidden (view full) --- 87 SSL_SESSION_ASN1 a; 88 M_ASN1_I2D_vars(in); 89 90 if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0))) 91 return(0); 92 93 /* Note that I cheat in the following 2 assignments. I know 94 * that if the ASN1_INTEGER passed to ASN1_INTEGER_set |
95 * is > sizeof(long)+1, the buffer will not be re-Malloc()ed. | 95 * is > sizeof(long)+1, the buffer will not be re-OPENSSL_malloc()ed. |
96 * This is a bit evil but makes things simple, no dynamic allocation 97 * to clean up :-) */ 98 a.version.length=LSIZE2; 99 a.version.type=V_ASN1_INTEGER; 100 a.version.data=ibuf1; 101 ASN1_INTEGER_set(&(a.version),SSL_SESSION_ASN1_VERSION); 102 103 a.ssl_version.length=LSIZE2; --- 114 unchanged lines hidden (view full) --- 218 osp= &os; 219 220 M_ASN1_D2I_Init(); 221 M_ASN1_D2I_start_sequence(); 222 223 ai.data=NULL; ai.length=0; 224 M_ASN1_D2I_get(aip,d2i_ASN1_INTEGER); 225 version=(int)ASN1_INTEGER_get(aip); | 96 * This is a bit evil but makes things simple, no dynamic allocation 97 * to clean up :-) */ 98 a.version.length=LSIZE2; 99 a.version.type=V_ASN1_INTEGER; 100 a.version.data=ibuf1; 101 ASN1_INTEGER_set(&(a.version),SSL_SESSION_ASN1_VERSION); 102 103 a.ssl_version.length=LSIZE2; --- 114 unchanged lines hidden (view full) --- 218 osp= &os; 219 220 M_ASN1_D2I_Init(); 221 M_ASN1_D2I_start_sequence(); 222 223 ai.data=NULL; ai.length=0; 224 M_ASN1_D2I_get(aip,d2i_ASN1_INTEGER); 225 version=(int)ASN1_INTEGER_get(aip); |
226 if (ai.data != NULL) { Free(ai.data); ai.data=NULL; ai.length=0; } | 226 if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; } |
227 228 /* we don't care about the version right now :-) */ 229 M_ASN1_D2I_get(aip,d2i_ASN1_INTEGER); 230 ssl_version=(int)ASN1_INTEGER_get(aip); 231 ret->ssl_version=ssl_version; | 227 228 /* we don't care about the version right now :-) */ 229 M_ASN1_D2I_get(aip,d2i_ASN1_INTEGER); 230 ssl_version=(int)ASN1_INTEGER_get(aip); 231 ret->ssl_version=ssl_version; |
232 if (ai.data != NULL) { Free(ai.data); ai.data=NULL; ai.length=0; } | 232 if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; } |
233 234 os.data=NULL; os.length=0; 235 M_ASN1_D2I_get(osp,d2i_ASN1_OCTET_STRING); 236 if (ssl_version == SSL2_VERSION) 237 { 238 if (os.length != 3) 239 { 240 c.error=SSL_R_CIPHER_CODE_WRONG_LENGTH; --- 45 unchanged lines hidden (view full) --- 286 287 os.length=0; 288 M_ASN1_D2I_get_IMP_opt(osp,d2i_ASN1_OCTET_STRING,0,V_ASN1_OCTET_STRING); 289 if (os.length > SSL_MAX_KEY_ARG_LENGTH) 290 ret->key_arg_length=SSL_MAX_KEY_ARG_LENGTH; 291 else 292 ret->key_arg_length=os.length; 293 memcpy(ret->key_arg,os.data,ret->key_arg_length); | 233 234 os.data=NULL; os.length=0; 235 M_ASN1_D2I_get(osp,d2i_ASN1_OCTET_STRING); 236 if (ssl_version == SSL2_VERSION) 237 { 238 if (os.length != 3) 239 { 240 c.error=SSL_R_CIPHER_CODE_WRONG_LENGTH; --- 45 unchanged lines hidden (view full) --- 286 287 os.length=0; 288 M_ASN1_D2I_get_IMP_opt(osp,d2i_ASN1_OCTET_STRING,0,V_ASN1_OCTET_STRING); 289 if (os.length > SSL_MAX_KEY_ARG_LENGTH) 290 ret->key_arg_length=SSL_MAX_KEY_ARG_LENGTH; 291 else 292 ret->key_arg_length=os.length; 293 memcpy(ret->key_arg,os.data,ret->key_arg_length); |
294 if (os.data != NULL) Free(os.data); | 294 if (os.data != NULL) OPENSSL_free(os.data); |
295 296 ai.length=0; 297 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,1); 298 if (ai.data != NULL) 299 { 300 ret->time=ASN1_INTEGER_get(aip); | 295 296 ai.length=0; 297 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,1); 298 if (ai.data != NULL) 299 { 300 ret->time=ASN1_INTEGER_get(aip); |
301 Free(ai.data); ai.data=NULL; ai.length=0; | 301 OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; |
302 } 303 else 304 ret->time=time(NULL); 305 306 ai.length=0; 307 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,2); 308 if (ai.data != NULL) 309 { 310 ret->timeout=ASN1_INTEGER_get(aip); | 302 } 303 else 304 ret->time=time(NULL); 305 306 ai.length=0; 307 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,2); 308 if (ai.data != NULL) 309 { 310 ret->timeout=ASN1_INTEGER_get(aip); |
311 Free(ai.data); ai.data=NULL; ai.length=0; | 311 OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; |
312 } 313 else 314 ret->timeout=3; 315 316 if (ret->peer != NULL) 317 { 318 X509_free(ret->peer); 319 ret->peer=NULL; --- 5 unchanged lines hidden (view full) --- 325 M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,4); 326 327 if(os.data != NULL) 328 { 329 if (os.length > SSL_MAX_SID_CTX_LENGTH) 330 SSLerr(SSL_F_D2I_SSL_SESSION,SSL_R_BAD_LENGTH); 331 ret->sid_ctx_length=os.length; 332 memcpy(ret->sid_ctx,os.data,os.length); | 312 } 313 else 314 ret->timeout=3; 315 316 if (ret->peer != NULL) 317 { 318 X509_free(ret->peer); 319 ret->peer=NULL; --- 5 unchanged lines hidden (view full) --- 325 M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,4); 326 327 if(os.data != NULL) 328 { 329 if (os.length > SSL_MAX_SID_CTX_LENGTH) 330 SSLerr(SSL_F_D2I_SSL_SESSION,SSL_R_BAD_LENGTH); 331 ret->sid_ctx_length=os.length; 332 memcpy(ret->sid_ctx,os.data,os.length); |
333 Free(os.data); os.data=NULL; os.length=0; | 333 OPENSSL_free(os.data); os.data=NULL; os.length=0; |
334 } 335 else 336 ret->sid_ctx_length=0; 337 338 ai.length=0; 339 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,5); 340 if (ai.data != NULL) 341 { 342 ret->verify_result=ASN1_INTEGER_get(aip); | 334 } 335 else 336 ret->sid_ctx_length=0; 337 338 ai.length=0; 339 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,5); 340 if (ai.data != NULL) 341 { 342 ret->verify_result=ASN1_INTEGER_get(aip); |
343 Free(ai.data); ai.data=NULL; ai.length=0; | 343 OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; |
344 } 345 else 346 ret->verify_result=X509_V_OK; 347 348 M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION); 349 } | 344 } 345 else 346 ret->verify_result=X509_V_OK; 347 348 M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION); 349 } |