Fix for trace code: SSL3 doesn't include a length value for
[openssl.git] / ssl / t1_trce.c
index 3571aaacae3e0c62c0be7702cd4444a5454dd2c6..c603134821973d24b03c86b5d80fd60386fe2d93 100644 (file)
@@ -843,10 +843,19 @@ static int ssl_print_client_keyex(BIO *bio, int indent, SSL *ssl,
                {
 
        case SSL_kRSA:
-               if (!ssl_print_hexbuf(bio, indent + 2,
+               if (TLS1_get_version(ssl) == SSL3_VERSION)
+                       {
+                       ssl_print_hex(bio, indent + 2,
+                                               "EncyptedPreMasterSecret",
+                                               msg, msglen);
+                       }
+               else
+                       {
+                       if (!ssl_print_hexbuf(bio, indent + 2,
                                                "EncyptedPreMasterSecret", 2,
                                                &msg, &msglen))
                                return 0;
+                       }
                break;
 
                /* Implicit parameters only allowed for static DH */
@@ -1071,7 +1080,7 @@ static int ssl_print_cert_request(BIO *bio, int indent, SSL *s,
                nm = d2i_X509_NAME(NULL, &p, dlen);
                if (!nm)
                        {
-                       BIO_puts(bio, "<UNPARESABLE DN>\n");
+                       BIO_puts(bio, "<UNPARSEABLE DN>\n");
                        }
                else
                        {
@@ -1203,6 +1212,13 @@ static int ssl_print_heartbeat(BIO *bio, int indent,
        return 1;
        }
 
+const char *SSL_CIPHER_standard_name(const SSL_CIPHER *c)
+       {
+       if (c->algorithm_ssl & SSL_SSLV2)
+               return NULL;
+       return ssl_trace_str(c->id & 0xFFFF, ssl_ciphers_tbl);
+       }
+
 void SSL_trace(int write_p, int version, int content_type,
                const void *buf, size_t msglen, SSL *ssl, void *arg)
        {
@@ -1217,18 +1233,19 @@ void SSL_trace(int write_p, int version, int content_type,
                                msg, msglen);
                return;
                }
-
-       BIO_printf(bio, "%s Record: Version = %s (0x%x)",
-                               write_p ? "Sent" : "Received",
-                               ssl_trace_str(version, ssl_version_tbl),
-                               version);
-       BIO_printf(bio, " Length=%d\n", (int)msglen);
-       BIO_printf(bio, "  Content Type = %s (%d)\n",
-                               ssl_trace_str(content_type, ssl_content_tbl),
-                               content_type);
-
        switch (content_type)
                {
+       case SSL3_RT_HEADER:
+               {
+               int hvers = msg[1] << 8 | msg[2];
+               BIO_puts(bio, write_p ? "Sent" : "Received");
+               BIO_printf(bio, " Record\nHeader:\n  Version = %s (0x%x)\n",
+                               ssl_trace_str(hvers, ssl_version_tbl), hvers);
+               BIO_printf(bio, "  Content Type = %s (%d)\n  Length = %d",
+                               ssl_trace_str(msg[0], ssl_content_tbl), msg[0],
+                               msg[3] << 8 | msg[4]);
+               }
+               break;
        case SSL3_RT_HANDSHAKE:
                if (!ssl_print_handshake(bio, ssl, msg, msglen, 4))
                        BIO_printf(bio, "Message length parse error!\n");