- int v1=0,v2=0,v3=0,v4=0,v5=0,v6=0,v7=0,v8=0,v9=0;
- unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2];
- unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2],ibuf5[LSIZE2];
- long l;
- SSL_SESSION_ASN1 a;
- M_ASN1_I2D_vars(in);
-
- if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0)))
- return(0);
-
- /* Note that I cheat in the following 2 assignments. I know
- * that if the ASN1_INTEGER passed to ASN1_INTEGER_set
- * is > sizeof(long)+1, the buffer will not be re-OPENSSL_malloc()ed.
- * This is a bit evil but makes things simple, no dynamic allocation
- * to clean up :-) */
- a.version.length=LSIZE2;
- a.version.type=V_ASN1_INTEGER;
- a.version.data=ibuf1;
- ASN1_INTEGER_set(&(a.version),SSL_SESSION_ASN1_VERSION);
-
- a.ssl_version.length=LSIZE2;
- a.ssl_version.type=V_ASN1_INTEGER;
- a.ssl_version.data=ibuf2;
- ASN1_INTEGER_set(&(a.ssl_version),in->ssl_version);
-
- a.cipher.type=V_ASN1_OCTET_STRING;
- a.cipher.data=buf;
-
- if (in->cipher == NULL)
- l=in->cipher_id;
- else
- l=in->cipher->id;
- if (in->ssl_version == SSL2_VERSION)
- {
- a.cipher.length=3;
- buf[0]=((unsigned char)(l>>16L))&0xff;
- buf[1]=((unsigned char)(l>> 8L))&0xff;
- buf[2]=((unsigned char)(l ))&0xff;
- }
- else
- {
- a.cipher.length=2;
- buf[0]=((unsigned char)(l>>8L))&0xff;
- buf[1]=((unsigned char)(l ))&0xff;
- }
-
- a.master_key.length=in->master_key_length;
- a.master_key.type=V_ASN1_OCTET_STRING;
- a.master_key.data=in->master_key;
-
- a.session_id.length=in->session_id_length;
- a.session_id.type=V_ASN1_OCTET_STRING;
- a.session_id.data=in->session_id;
-
- a.session_id_context.length=in->sid_ctx_length;
- a.session_id_context.type=V_ASN1_OCTET_STRING;
- a.session_id_context.data=in->sid_ctx;
-
- a.key_arg.length=in->key_arg_length;
- a.key_arg.type=V_ASN1_OCTET_STRING;
- a.key_arg.data=in->key_arg;
+ int v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0;
+ unsigned char buf[4], ibuf1[LSIZE2], ibuf2[LSIZE2];
+ unsigned char ibuf3[LSIZE2], ibuf4[LSIZE2], ibuf5[LSIZE2];
+#ifndef OPENSSL_NO_TLSEXT
+ int v6 = 0, v9 = 0, v10 = 0;
+ unsigned char ibuf6[LSIZE2];
+#endif
+#ifndef OPENSSL_NO_PSK
+ int v7 = 0, v8 = 0;
+#endif
+#ifndef OPENSSL_NO_COMP
+ unsigned char cbuf;
+ int v11 = 0;
+#endif
+#ifndef OPENSSL_NO_SRP
+ int v12 = 0;
+#endif
+ long l;
+ SSL_SESSION_ASN1 a;
+ M_ASN1_I2D_vars(in);
+
+ if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0)))
+ return (0);
+
+ /*
+ * Note that I cheat in the following 2 assignments. I know that if the
+ * ASN1_INTEGER passed to ASN1_INTEGER_set is > sizeof(long)+1, the
+ * buffer will not be re-OPENSSL_malloc()ed. This is a bit evil but makes
+ * things simple, no dynamic allocation to clean up :-)
+ */
+ a.version.length = LSIZE2;
+ a.version.type = V_ASN1_INTEGER;
+ a.version.data = ibuf1;
+ ASN1_INTEGER_set(&(a.version), SSL_SESSION_ASN1_VERSION);
+
+ a.ssl_version.length = LSIZE2;
+ a.ssl_version.type = V_ASN1_INTEGER;
+ a.ssl_version.data = ibuf2;
+ ASN1_INTEGER_set(&(a.ssl_version), in->ssl_version);
+
+ a.cipher.type = V_ASN1_OCTET_STRING;
+ a.cipher.data = buf;
+
+ if (in->cipher == NULL)
+ l = in->cipher_id;
+ else
+ l = in->cipher->id;
+ if (in->ssl_version == SSL2_VERSION) {
+ a.cipher.length = 3;
+ buf[0] = ((unsigned char)(l >> 16L)) & 0xff;
+ buf[1] = ((unsigned char)(l >> 8L)) & 0xff;
+ buf[2] = ((unsigned char)(l)) & 0xff;
+ } else {
+ a.cipher.length = 2;
+ buf[0] = ((unsigned char)(l >> 8L)) & 0xff;
+ buf[1] = ((unsigned char)(l)) & 0xff;
+ }
+
+#ifndef OPENSSL_NO_COMP
+ if (in->compress_meth) {
+ cbuf = (unsigned char)in->compress_meth;
+ a.comp_id.length = 1;
+ a.comp_id.type = V_ASN1_OCTET_STRING;
+ a.comp_id.data = &cbuf;
+ }
+#endif
+
+ a.master_key.length = in->master_key_length;
+ a.master_key.type = V_ASN1_OCTET_STRING;
+ a.master_key.data = in->master_key;
+
+ a.session_id.length = in->session_id_length;
+ a.session_id.type = V_ASN1_OCTET_STRING;
+ a.session_id.data = in->session_id;
+
+ a.session_id_context.length = in->sid_ctx_length;
+ a.session_id_context.type = V_ASN1_OCTET_STRING;
+ a.session_id_context.data = in->sid_ctx;
+
+ a.key_arg.length = in->key_arg_length;
+ a.key_arg.type = V_ASN1_OCTET_STRING;
+ a.key_arg.data = in->key_arg;