]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OpenSSL: Make msg_callback debug prints easier to read
authorJouni Malinen <j@w1.fi>
Sun, 11 Oct 2015 08:35:35 +0000 (11:35 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 11 Oct 2015 08:35:35 +0000 (11:35 +0300)
Write a text version of the content type and handshake type in debug log
to make it easier to follow TLS exchange.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/crypto/tls_openssl.c

index 1d5c742ef0c3ad2de7132fe0770e253da79678f3..c2bb8c5ffd67d019547e3d4e81e095f8eb6d7517 100644 (file)
@@ -1126,6 +1126,65 @@ int tls_get_errors(void *ssl_ctx)
 }
 
 
+static const char * openssl_content_type(int content_type)
+{
+       switch (content_type) {
+       case 20:
+               return "change cipher spec";
+       case 21:
+               return "alert";
+       case 22:
+               return "handshake";
+       case 23:
+               return "application data";
+       case 24:
+               return "heartbeat";
+       case 256:
+               return "TLS header info"; /* pseudo content type */
+       default:
+               return "?";
+       }
+}
+
+
+static const char * openssl_handshake_type(int content_type, const u8 *buf,
+                                          size_t len)
+{
+       if (content_type != 22 || !buf || len == 0)
+               return "";
+       switch (buf[0]) {
+       case 0:
+               return "hello request";
+       case 1:
+               return "client hello";
+       case 2:
+               return "server hello";
+       case 4:
+               return "new session ticket";
+       case 11:
+               return "certificate";
+       case 12:
+               return "server key exchange";
+       case 13:
+               return "certificate request";
+       case 14:
+               return "server hello done";
+       case 15:
+               return "certificate verify";
+       case 16:
+               return "client key exchange";
+       case 20:
+               return "finished";
+       case 21:
+               return "certificate url";
+       case 22:
+               return "certificate status";
+       default:
+               return "?";
+       }
+}
+
+
 static void tls_msg_cb(int write_p, int version, int content_type,
                       const void *buf, size_t len, SSL *ssl, void *arg)
 {
@@ -1140,8 +1199,10 @@ static void tls_msg_cb(int write_p, int version, int content_type,
                return;
        }
 
-       wpa_printf(MSG_DEBUG, "OpenSSL: %s ver=0x%x content_type=%d",
-                  write_p ? "TX" : "RX", version, content_type);
+       wpa_printf(MSG_DEBUG, "OpenSSL: %s ver=0x%x content_type=%d (%s/%s)",
+                  write_p ? "TX" : "RX", version, content_type,
+                  openssl_content_type(content_type),
+                  openssl_handshake_type(content_type, buf, len));
        wpa_hexdump_key(MSG_MSGDUMP, "OpenSSL: Message", buf, len);
        if (content_type == 24 && len >= 3 && pos[0] == 1) {
                size_t payload_len = WPA_GET_BE16(pos + 1);