1 1.1 christos /* 2 1.1 christos * Copyright 2012-2025 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos * 4 1.1 christos * Licensed under the Apache License 2.0 (the "License"). You may not use 5 1.1 christos * this file except in compliance with the License. You can obtain a copy 6 1.1 christos * in the file LICENSE in the source distribution or at 7 1.1 christos * https://www.openssl.org/source/license.html 8 1.1 christos */ 9 1.1 christos 10 1.1 christos #include "ssl_local.h" 11 1.1 christos 12 1.1 christos #ifndef OPENSSL_NO_SSL_TRACE 13 1.1 christos 14 1.1 christos /* Packet trace support for OpenSSL */ 15 1.1 christos #include "internal/nelem.h" 16 1.1 christos #include "internal/ssl_unwrap.h" 17 1.1 christos #include "internal/quic_trace.h" 18 1.1 christos 19 1.1 christos typedef struct { 20 1.1 christos int num; 21 1.1 christos const char *name; 22 1.1 christos } ssl_trace_tbl; 23 1.1 christos 24 1.1.1.2 christos #define ssl_trace_str(val, tbl) \ 25 1.1 christos do_ssl_trace_str(val, tbl, OSSL_NELEM(tbl)) 26 1.1 christos 27 1.1.1.2 christos #define ssl_trace_list(bio, indent, msg, msglen, value, table) \ 28 1.1.1.2 christos do_ssl_trace_list(bio, indent, msg, msglen, value, \ 29 1.1.1.2 christos table, OSSL_NELEM(table)) 30 1.1 christos 31 1.1 christos static const char *do_ssl_trace_str(int val, const ssl_trace_tbl *tbl, 32 1.1.1.2 christos size_t ntbl) 33 1.1 christos { 34 1.1 christos size_t i; 35 1.1 christos 36 1.1 christos for (i = 0; i < ntbl; i++, tbl++) { 37 1.1 christos if (tbl->num == val) 38 1.1 christos return tbl->name; 39 1.1 christos } 40 1.1 christos return "UNKNOWN"; 41 1.1 christos } 42 1.1 christos 43 1.1 christos static int do_ssl_trace_list(BIO *bio, int indent, 44 1.1.1.2 christos const unsigned char *msg, size_t msglen, 45 1.1.1.2 christos size_t vlen, const ssl_trace_tbl *tbl, size_t ntbl) 46 1.1 christos { 47 1.1 christos int val; 48 1.1 christos 49 1.1 christos if (msglen % vlen) 50 1.1 christos return 0; 51 1.1 christos while (msglen) { 52 1.1 christos val = msg[0]; 53 1.1 christos if (vlen == 2) 54 1.1 christos val = (val << 8) | msg[1]; 55 1.1 christos BIO_indent(bio, indent, 80); 56 1.1 christos BIO_printf(bio, "%s (%d)\n", do_ssl_trace_str(val, tbl, ntbl), val); 57 1.1 christos msg += vlen; 58 1.1 christos msglen -= vlen; 59 1.1 christos } 60 1.1 christos return 1; 61 1.1 christos } 62 1.1 christos 63 1.1 christos /* Version number */ 64 1.1 christos 65 1.1 christos static const ssl_trace_tbl ssl_version_tbl[] = { 66 1.1.1.2 christos { SSL3_VERSION, "SSL 3.0" }, 67 1.1.1.2 christos { TLS1_VERSION, "TLS 1.0" }, 68 1.1.1.2 christos { TLS1_1_VERSION, "TLS 1.1" }, 69 1.1.1.2 christos { TLS1_2_VERSION, "TLS 1.2" }, 70 1.1.1.2 christos { TLS1_3_VERSION, "TLS 1.3" }, 71 1.1.1.2 christos { DTLS1_VERSION, "DTLS 1.0" }, 72 1.1.1.2 christos { DTLS1_2_VERSION, "DTLS 1.2" }, 73 1.1.1.2 christos { DTLS1_BAD_VER, "DTLS 1.0 (bad)" } 74 1.1 christos }; 75 1.1 christos 76 1.1 christos static const ssl_trace_tbl ssl_content_tbl[] = { 77 1.1.1.2 christos { SSL3_RT_CHANGE_CIPHER_SPEC, "ChangeCipherSpec" }, 78 1.1.1.2 christos { SSL3_RT_ALERT, "Alert" }, 79 1.1.1.2 christos { SSL3_RT_HANDSHAKE, "Handshake" }, 80 1.1.1.2 christos { SSL3_RT_APPLICATION_DATA, "ApplicationData" }, 81 1.1 christos }; 82 1.1 christos 83 1.1 christos /* Handshake types, sorted by ascending id */ 84 1.1 christos static const ssl_trace_tbl ssl_handshake_tbl[] = { 85 1.1.1.2 christos { SSL3_MT_HELLO_REQUEST, "HelloRequest" }, 86 1.1.1.2 christos { SSL3_MT_CLIENT_HELLO, "ClientHello" }, 87 1.1.1.2 christos { SSL3_MT_SERVER_HELLO, "ServerHello" }, 88 1.1.1.2 christos { DTLS1_MT_HELLO_VERIFY_REQUEST, "HelloVerifyRequest" }, 89 1.1.1.2 christos { SSL3_MT_NEWSESSION_TICKET, "NewSessionTicket" }, 90 1.1.1.2 christos { SSL3_MT_END_OF_EARLY_DATA, "EndOfEarlyData" }, 91 1.1.1.2 christos { SSL3_MT_ENCRYPTED_EXTENSIONS, "EncryptedExtensions" }, 92 1.1.1.2 christos { SSL3_MT_CERTIFICATE, "Certificate" }, 93 1.1.1.2 christos { SSL3_MT_SERVER_KEY_EXCHANGE, "ServerKeyExchange" }, 94 1.1.1.2 christos { SSL3_MT_CERTIFICATE_REQUEST, "CertificateRequest" }, 95 1.1.1.2 christos { SSL3_MT_SERVER_DONE, "ServerHelloDone" }, 96 1.1.1.2 christos { SSL3_MT_CERTIFICATE_VERIFY, "CertificateVerify" }, 97 1.1.1.2 christos { SSL3_MT_CLIENT_KEY_EXCHANGE, "ClientKeyExchange" }, 98 1.1.1.2 christos { SSL3_MT_FINISHED, "Finished" }, 99 1.1.1.2 christos { SSL3_MT_CERTIFICATE_URL, "CertificateUrl" }, 100 1.1.1.2 christos { SSL3_MT_CERTIFICATE_STATUS, "CertificateStatus" }, 101 1.1.1.2 christos { SSL3_MT_SUPPLEMENTAL_DATA, "SupplementalData" }, 102 1.1.1.2 christos { SSL3_MT_KEY_UPDATE, "KeyUpdate" }, 103 1.1.1.2 christos { SSL3_MT_COMPRESSED_CERTIFICATE, "CompressedCertificate" }, 104 1.1.1.2 christos #ifndef OPENSSL_NO_NEXTPROTONEG 105 1.1.1.2 christos { SSL3_MT_NEXT_PROTO, "NextProto" }, 106 1.1.1.2 christos #endif 107 1.1.1.2 christos { SSL3_MT_MESSAGE_HASH, "MessageHash" } 108 1.1 christos }; 109 1.1 christos 110 1.1 christos /* Cipher suites */ 111 1.1 christos static const ssl_trace_tbl ssl_ciphers_tbl[] = { 112 1.1.1.2 christos { 0x0000, "TLS_NULL_WITH_NULL_NULL" }, 113 1.1.1.2 christos { 0x0001, "TLS_RSA_WITH_NULL_MD5" }, 114 1.1.1.2 christos { 0x0002, "TLS_RSA_WITH_NULL_SHA" }, 115 1.1.1.2 christos { 0x0003, "TLS_RSA_EXPORT_WITH_RC4_40_MD5" }, 116 1.1.1.2 christos { 0x0004, "TLS_RSA_WITH_RC4_128_MD5" }, 117 1.1.1.2 christos { 0x0005, "TLS_RSA_WITH_RC4_128_SHA" }, 118 1.1.1.2 christos { 0x0006, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5" }, 119 1.1.1.2 christos { 0x0007, "TLS_RSA_WITH_IDEA_CBC_SHA" }, 120 1.1.1.2 christos { 0x0008, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA" }, 121 1.1.1.2 christos { 0x0009, "TLS_RSA_WITH_DES_CBC_SHA" }, 122 1.1.1.2 christos { 0x000A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA" }, 123 1.1.1.2 christos { 0x000B, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA" }, 124 1.1.1.2 christos { 0x000C, "TLS_DH_DSS_WITH_DES_CBC_SHA" }, 125 1.1.1.2 christos { 0x000D, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA" }, 126 1.1.1.2 christos { 0x000E, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA" }, 127 1.1.1.2 christos { 0x000F, "TLS_DH_RSA_WITH_DES_CBC_SHA" }, 128 1.1.1.2 christos { 0x0010, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA" }, 129 1.1.1.2 christos { 0x0011, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" }, 130 1.1.1.2 christos { 0x0012, "TLS_DHE_DSS_WITH_DES_CBC_SHA" }, 131 1.1.1.2 christos { 0x0013, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA" }, 132 1.1.1.2 christos { 0x0014, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA" }, 133 1.1.1.2 christos { 0x0015, "TLS_DHE_RSA_WITH_DES_CBC_SHA" }, 134 1.1.1.2 christos { 0x0016, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA" }, 135 1.1.1.2 christos { 0x0017, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5" }, 136 1.1.1.2 christos { 0x0018, "TLS_DH_anon_WITH_RC4_128_MD5" }, 137 1.1.1.2 christos { 0x0019, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA" }, 138 1.1.1.2 christos { 0x001A, "TLS_DH_anon_WITH_DES_CBC_SHA" }, 139 1.1.1.2 christos { 0x001B, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA" }, 140 1.1.1.2 christos { 0x001D, "SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA" }, 141 1.1.1.2 christos { 0x001E, "SSL_FORTEZZA_KEA_WITH_RC4_128_SHA" }, 142 1.1.1.2 christos { 0x001F, "TLS_KRB5_WITH_3DES_EDE_CBC_SHA" }, 143 1.1.1.2 christos { 0x0020, "TLS_KRB5_WITH_RC4_128_SHA" }, 144 1.1.1.2 christos { 0x0021, "TLS_KRB5_WITH_IDEA_CBC_SHA" }, 145 1.1.1.2 christos { 0x0022, "TLS_KRB5_WITH_DES_CBC_MD5" }, 146 1.1.1.2 christos { 0x0023, "TLS_KRB5_WITH_3DES_EDE_CBC_MD5" }, 147 1.1.1.2 christos { 0x0024, "TLS_KRB5_WITH_RC4_128_MD5" }, 148 1.1.1.2 christos { 0x0025, "TLS_KRB5_WITH_IDEA_CBC_MD5" }, 149 1.1.1.2 christos { 0x0026, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA" }, 150 1.1.1.2 christos { 0x0027, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA" }, 151 1.1.1.2 christos { 0x0028, "TLS_KRB5_EXPORT_WITH_RC4_40_SHA" }, 152 1.1.1.2 christos { 0x0029, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5" }, 153 1.1.1.2 christos { 0x002A, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5" }, 154 1.1.1.2 christos { 0x002B, "TLS_KRB5_EXPORT_WITH_RC4_40_MD5" }, 155 1.1.1.2 christos { 0x002C, "TLS_PSK_WITH_NULL_SHA" }, 156 1.1.1.2 christos { 0x002D, "TLS_DHE_PSK_WITH_NULL_SHA" }, 157 1.1.1.2 christos { 0x002E, "TLS_RSA_PSK_WITH_NULL_SHA" }, 158 1.1.1.2 christos { 0x002F, "TLS_RSA_WITH_AES_128_CBC_SHA" }, 159 1.1.1.2 christos { 0x0030, "TLS_DH_DSS_WITH_AES_128_CBC_SHA" }, 160 1.1.1.2 christos { 0x0031, "TLS_DH_RSA_WITH_AES_128_CBC_SHA" }, 161 1.1.1.2 christos { 0x0032, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA" }, 162 1.1.1.2 christos { 0x0033, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" }, 163 1.1.1.2 christos { 0x0034, "TLS_DH_anon_WITH_AES_128_CBC_SHA" }, 164 1.1.1.2 christos { 0x0035, "TLS_RSA_WITH_AES_256_CBC_SHA" }, 165 1.1.1.2 christos { 0x0036, "TLS_DH_DSS_WITH_AES_256_CBC_SHA" }, 166 1.1.1.2 christos { 0x0037, "TLS_DH_RSA_WITH_AES_256_CBC_SHA" }, 167 1.1.1.2 christos { 0x0038, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA" }, 168 1.1.1.2 christos { 0x0039, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA" }, 169 1.1.1.2 christos { 0x003A, "TLS_DH_anon_WITH_AES_256_CBC_SHA" }, 170 1.1.1.2 christos { 0x003B, "TLS_RSA_WITH_NULL_SHA256" }, 171 1.1.1.2 christos { 0x003C, "TLS_RSA_WITH_AES_128_CBC_SHA256" }, 172 1.1.1.2 christos { 0x003D, "TLS_RSA_WITH_AES_256_CBC_SHA256" }, 173 1.1.1.2 christos { 0x003E, "TLS_DH_DSS_WITH_AES_128_CBC_SHA256" }, 174 1.1.1.2 christos { 0x003F, "TLS_DH_RSA_WITH_AES_128_CBC_SHA256" }, 175 1.1.1.2 christos { 0x0040, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" }, 176 1.1.1.2 christos { 0x0041, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA" }, 177 1.1.1.2 christos { 0x0042, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA" }, 178 1.1.1.2 christos { 0x0043, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA" }, 179 1.1.1.2 christos { 0x0044, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA" }, 180 1.1.1.2 christos { 0x0045, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA" }, 181 1.1.1.2 christos { 0x0046, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA" }, 182 1.1.1.2 christos { 0x0067, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" }, 183 1.1.1.2 christos { 0x0068, "TLS_DH_DSS_WITH_AES_256_CBC_SHA256" }, 184 1.1.1.2 christos { 0x0069, "TLS_DH_RSA_WITH_AES_256_CBC_SHA256" }, 185 1.1.1.2 christos { 0x006A, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" }, 186 1.1.1.2 christos { 0x006B, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256" }, 187 1.1.1.2 christos { 0x006C, "TLS_DH_anon_WITH_AES_128_CBC_SHA256" }, 188 1.1.1.2 christos { 0x006D, "TLS_DH_anon_WITH_AES_256_CBC_SHA256" }, 189 1.1.1.2 christos { 0x0081, "TLS_GOSTR341001_WITH_28147_CNT_IMIT" }, 190 1.1.1.2 christos { 0x0083, "TLS_GOSTR341001_WITH_NULL_GOSTR3411" }, 191 1.1.1.2 christos { 0x0084, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA" }, 192 1.1.1.2 christos { 0x0085, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA" }, 193 1.1.1.2 christos { 0x0086, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA" }, 194 1.1.1.2 christos { 0x0087, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA" }, 195 1.1.1.2 christos { 0x0088, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA" }, 196 1.1.1.2 christos { 0x0089, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA" }, 197 1.1.1.2 christos { 0x008A, "TLS_PSK_WITH_RC4_128_SHA" }, 198 1.1.1.2 christos { 0x008B, "TLS_PSK_WITH_3DES_EDE_CBC_SHA" }, 199 1.1.1.2 christos { 0x008C, "TLS_PSK_WITH_AES_128_CBC_SHA" }, 200 1.1.1.2 christos { 0x008D, "TLS_PSK_WITH_AES_256_CBC_SHA" }, 201 1.1.1.2 christos { 0x008E, "TLS_DHE_PSK_WITH_RC4_128_SHA" }, 202 1.1.1.2 christos { 0x008F, "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA" }, 203 1.1.1.2 christos { 0x0090, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA" }, 204 1.1.1.2 christos { 0x0091, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA" }, 205 1.1.1.2 christos { 0x0092, "TLS_RSA_PSK_WITH_RC4_128_SHA" }, 206 1.1.1.2 christos { 0x0093, "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA" }, 207 1.1.1.2 christos { 0x0094, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA" }, 208 1.1.1.2 christos { 0x0095, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA" }, 209 1.1.1.2 christos { 0x0096, "TLS_RSA_WITH_SEED_CBC_SHA" }, 210 1.1.1.2 christos { 0x0097, "TLS_DH_DSS_WITH_SEED_CBC_SHA" }, 211 1.1.1.2 christos { 0x0098, "TLS_DH_RSA_WITH_SEED_CBC_SHA" }, 212 1.1.1.2 christos { 0x0099, "TLS_DHE_DSS_WITH_SEED_CBC_SHA" }, 213 1.1.1.2 christos { 0x009A, "TLS_DHE_RSA_WITH_SEED_CBC_SHA" }, 214 1.1.1.2 christos { 0x009B, "TLS_DH_anon_WITH_SEED_CBC_SHA" }, 215 1.1.1.2 christos { 0x009C, "TLS_RSA_WITH_AES_128_GCM_SHA256" }, 216 1.1.1.2 christos { 0x009D, "TLS_RSA_WITH_AES_256_GCM_SHA384" }, 217 1.1.1.2 christos { 0x009E, "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" }, 218 1.1.1.2 christos { 0x009F, "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" }, 219 1.1.1.2 christos { 0x00A0, "TLS_DH_RSA_WITH_AES_128_GCM_SHA256" }, 220 1.1.1.2 christos { 0x00A1, "TLS_DH_RSA_WITH_AES_256_GCM_SHA384" }, 221 1.1.1.2 christos { 0x00A2, "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256" }, 222 1.1.1.2 christos { 0x00A3, "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384" }, 223 1.1.1.2 christos { 0x00A4, "TLS_DH_DSS_WITH_AES_128_GCM_SHA256" }, 224 1.1.1.2 christos { 0x00A5, "TLS_DH_DSS_WITH_AES_256_GCM_SHA384" }, 225 1.1.1.2 christos { 0x00A6, "TLS_DH_anon_WITH_AES_128_GCM_SHA256" }, 226 1.1.1.2 christos { 0x00A7, "TLS_DH_anon_WITH_AES_256_GCM_SHA384" }, 227 1.1.1.2 christos { 0x00A8, "TLS_PSK_WITH_AES_128_GCM_SHA256" }, 228 1.1.1.2 christos { 0x00A9, "TLS_PSK_WITH_AES_256_GCM_SHA384" }, 229 1.1.1.2 christos { 0x00AA, "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256" }, 230 1.1.1.2 christos { 0x00AB, "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384" }, 231 1.1.1.2 christos { 0x00AC, "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256" }, 232 1.1.1.2 christos { 0x00AD, "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384" }, 233 1.1.1.2 christos { 0x00AE, "TLS_PSK_WITH_AES_128_CBC_SHA256" }, 234 1.1.1.2 christos { 0x00AF, "TLS_PSK_WITH_AES_256_CBC_SHA384" }, 235 1.1.1.2 christos { 0x00B0, "TLS_PSK_WITH_NULL_SHA256" }, 236 1.1.1.2 christos { 0x00B1, "TLS_PSK_WITH_NULL_SHA384" }, 237 1.1.1.2 christos { 0x00B2, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256" }, 238 1.1.1.2 christos { 0x00B3, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384" }, 239 1.1.1.2 christos { 0x00B4, "TLS_DHE_PSK_WITH_NULL_SHA256" }, 240 1.1.1.2 christos { 0x00B5, "TLS_DHE_PSK_WITH_NULL_SHA384" }, 241 1.1.1.2 christos { 0x00B6, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256" }, 242 1.1.1.2 christos { 0x00B7, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384" }, 243 1.1.1.2 christos { 0x00B8, "TLS_RSA_PSK_WITH_NULL_SHA256" }, 244 1.1.1.2 christos { 0x00B9, "TLS_RSA_PSK_WITH_NULL_SHA384" }, 245 1.1.1.2 christos { 0x00BA, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256" }, 246 1.1.1.2 christos { 0x00BB, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256" }, 247 1.1.1.2 christos { 0x00BC, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256" }, 248 1.1.1.2 christos { 0x00BD, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256" }, 249 1.1.1.2 christos { 0x00BE, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" }, 250 1.1.1.2 christos { 0x00BF, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256" }, 251 1.1.1.2 christos { 0x00C0, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256" }, 252 1.1.1.2 christos { 0x00C1, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256" }, 253 1.1.1.2 christos { 0x00C2, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256" }, 254 1.1.1.2 christos { 0x00C3, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256" }, 255 1.1.1.2 christos { 0x00C4, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256" }, 256 1.1.1.2 christos { 0x00C5, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256" }, 257 1.1.1.2 christos { 0x00FF, "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" }, 258 1.1.1.2 christos { 0x5600, "TLS_FALLBACK_SCSV" }, 259 1.1.1.2 christos { 0xC001, "TLS_ECDH_ECDSA_WITH_NULL_SHA" }, 260 1.1.1.2 christos { 0xC002, "TLS_ECDH_ECDSA_WITH_RC4_128_SHA" }, 261 1.1.1.2 christos { 0xC003, "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA" }, 262 1.1.1.2 christos { 0xC004, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA" }, 263 1.1.1.2 christos { 0xC005, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA" }, 264 1.1.1.2 christos { 0xC006, "TLS_ECDHE_ECDSA_WITH_NULL_SHA" }, 265 1.1.1.2 christos { 0xC007, "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA" }, 266 1.1.1.2 christos { 0xC008, "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA" }, 267 1.1.1.2 christos { 0xC009, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" }, 268 1.1.1.2 christos { 0xC00A, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" }, 269 1.1.1.2 christos { 0xC00B, "TLS_ECDH_RSA_WITH_NULL_SHA" }, 270 1.1.1.2 christos { 0xC00C, "TLS_ECDH_RSA_WITH_RC4_128_SHA" }, 271 1.1.1.2 christos { 0xC00D, "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA" }, 272 1.1.1.2 christos { 0xC00E, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA" }, 273 1.1.1.2 christos { 0xC00F, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA" }, 274 1.1.1.2 christos { 0xC010, "TLS_ECDHE_RSA_WITH_NULL_SHA" }, 275 1.1.1.2 christos { 0xC011, "TLS_ECDHE_RSA_WITH_RC4_128_SHA" }, 276 1.1.1.2 christos { 0xC012, "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" }, 277 1.1.1.2 christos { 0xC013, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" }, 278 1.1.1.2 christos { 0xC014, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" }, 279 1.1.1.2 christos { 0xC015, "TLS_ECDH_anon_WITH_NULL_SHA" }, 280 1.1.1.2 christos { 0xC016, "TLS_ECDH_anon_WITH_RC4_128_SHA" }, 281 1.1.1.2 christos { 0xC017, "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA" }, 282 1.1.1.2 christos { 0xC018, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA" }, 283 1.1.1.2 christos { 0xC019, "TLS_ECDH_anon_WITH_AES_256_CBC_SHA" }, 284 1.1.1.2 christos { 0xC01A, "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA" }, 285 1.1.1.2 christos { 0xC01B, "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA" }, 286 1.1.1.2 christos { 0xC01C, "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA" }, 287 1.1.1.2 christos { 0xC01D, "TLS_SRP_SHA_WITH_AES_128_CBC_SHA" }, 288 1.1.1.2 christos { 0xC01E, "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA" }, 289 1.1.1.2 christos { 0xC01F, "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA" }, 290 1.1.1.2 christos { 0xC020, "TLS_SRP_SHA_WITH_AES_256_CBC_SHA" }, 291 1.1.1.2 christos { 0xC021, "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA" }, 292 1.1.1.2 christos { 0xC022, "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA" }, 293 1.1.1.2 christos { 0xC023, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" }, 294 1.1.1.2 christos { 0xC024, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" }, 295 1.1.1.2 christos { 0xC025, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256" }, 296 1.1.1.2 christos { 0xC026, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384" }, 297 1.1.1.2 christos { 0xC027, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" }, 298 1.1.1.2 christos { 0xC028, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" }, 299 1.1.1.2 christos { 0xC029, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256" }, 300 1.1.1.2 christos { 0xC02A, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384" }, 301 1.1.1.2 christos { 0xC02B, "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" }, 302 1.1.1.2 christos { 0xC02C, "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" }, 303 1.1.1.2 christos { 0xC02D, "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256" }, 304 1.1.1.2 christos { 0xC02E, "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384" }, 305 1.1.1.2 christos { 0xC02F, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" }, 306 1.1.1.2 christos { 0xC030, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" }, 307 1.1.1.2 christos { 0xC031, "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256" }, 308 1.1.1.2 christos { 0xC032, "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384" }, 309 1.1.1.2 christos { 0xC033, "TLS_ECDHE_PSK_WITH_RC4_128_SHA" }, 310 1.1.1.2 christos { 0xC034, "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA" }, 311 1.1.1.2 christos { 0xC035, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA" }, 312 1.1.1.2 christos { 0xC036, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA" }, 313 1.1.1.2 christos { 0xC037, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256" }, 314 1.1.1.2 christos { 0xC038, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384" }, 315 1.1.1.2 christos { 0xC039, "TLS_ECDHE_PSK_WITH_NULL_SHA" }, 316 1.1.1.2 christos { 0xC03A, "TLS_ECDHE_PSK_WITH_NULL_SHA256" }, 317 1.1.1.2 christos { 0xC03B, "TLS_ECDHE_PSK_WITH_NULL_SHA384" }, 318 1.1.1.2 christos { 0xC03C, "TLS_RSA_WITH_ARIA_128_CBC_SHA256" }, 319 1.1.1.2 christos { 0xC03D, "TLS_RSA_WITH_ARIA_256_CBC_SHA384" }, 320 1.1.1.2 christos { 0xC03E, "TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256" }, 321 1.1.1.2 christos { 0xC03F, "TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384" }, 322 1.1.1.2 christos { 0xC040, "TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256" }, 323 1.1.1.2 christos { 0xC041, "TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384" }, 324 1.1.1.2 christos { 0xC042, "TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256" }, 325 1.1.1.2 christos { 0xC043, "TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384" }, 326 1.1.1.2 christos { 0xC044, "TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256" }, 327 1.1.1.2 christos { 0xC045, "TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384" }, 328 1.1.1.2 christos { 0xC046, "TLS_DH_anon_WITH_ARIA_128_CBC_SHA256" }, 329 1.1.1.2 christos { 0xC047, "TLS_DH_anon_WITH_ARIA_256_CBC_SHA384" }, 330 1.1.1.2 christos { 0xC048, "TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256" }, 331 1.1.1.2 christos { 0xC049, "TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384" }, 332 1.1.1.2 christos { 0xC04A, "TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256" }, 333 1.1.1.2 christos { 0xC04B, "TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384" }, 334 1.1.1.2 christos { 0xC04C, "TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256" }, 335 1.1.1.2 christos { 0xC04D, "TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384" }, 336 1.1.1.2 christos { 0xC04E, "TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256" }, 337 1.1.1.2 christos { 0xC04F, "TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384" }, 338 1.1.1.2 christos { 0xC050, "TLS_RSA_WITH_ARIA_128_GCM_SHA256" }, 339 1.1.1.2 christos { 0xC051, "TLS_RSA_WITH_ARIA_256_GCM_SHA384" }, 340 1.1.1.2 christos { 0xC052, "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256" }, 341 1.1.1.2 christos { 0xC053, "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384" }, 342 1.1.1.2 christos { 0xC054, "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256" }, 343 1.1.1.2 christos { 0xC055, "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384" }, 344 1.1.1.2 christos { 0xC056, "TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256" }, 345 1.1.1.2 christos { 0xC057, "TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384" }, 346 1.1.1.2 christos { 0xC058, "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256" }, 347 1.1.1.2 christos { 0xC059, "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384" }, 348 1.1.1.2 christos { 0xC05A, "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256" }, 349 1.1.1.2 christos { 0xC05B, "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384" }, 350 1.1.1.2 christos { 0xC05C, "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256" }, 351 1.1.1.2 christos { 0xC05D, "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384" }, 352 1.1.1.2 christos { 0xC05E, "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256" }, 353 1.1.1.2 christos { 0xC05F, "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384" }, 354 1.1.1.2 christos { 0xC060, "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256" }, 355 1.1.1.2 christos { 0xC061, "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384" }, 356 1.1.1.2 christos { 0xC062, "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256" }, 357 1.1.1.2 christos { 0xC063, "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384" }, 358 1.1.1.2 christos { 0xC064, "TLS_PSK_WITH_ARIA_128_CBC_SHA256" }, 359 1.1.1.2 christos { 0xC065, "TLS_PSK_WITH_ARIA_256_CBC_SHA384" }, 360 1.1.1.2 christos { 0xC066, "TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256" }, 361 1.1.1.2 christos { 0xC067, "TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384" }, 362 1.1.1.2 christos { 0xC068, "TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256" }, 363 1.1.1.2 christos { 0xC069, "TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384" }, 364 1.1.1.2 christos { 0xC06A, "TLS_PSK_WITH_ARIA_128_GCM_SHA256" }, 365 1.1.1.2 christos { 0xC06B, "TLS_PSK_WITH_ARIA_256_GCM_SHA384" }, 366 1.1.1.2 christos { 0xC06C, "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256" }, 367 1.1.1.2 christos { 0xC06D, "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384" }, 368 1.1.1.2 christos { 0xC06E, "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256" }, 369 1.1.1.2 christos { 0xC06F, "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384" }, 370 1.1.1.2 christos { 0xC070, "TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256" }, 371 1.1.1.2 christos { 0xC071, "TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384" }, 372 1.1.1.2 christos { 0xC072, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256" }, 373 1.1.1.2 christos { 0xC073, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384" }, 374 1.1.1.2 christos { 0xC074, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256" }, 375 1.1.1.2 christos { 0xC075, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384" }, 376 1.1.1.2 christos { 0xC076, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" }, 377 1.1.1.2 christos { 0xC077, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384" }, 378 1.1.1.2 christos { 0xC078, "TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256" }, 379 1.1.1.2 christos { 0xC079, "TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384" }, 380 1.1.1.2 christos { 0xC07A, "TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256" }, 381 1.1.1.2 christos { 0xC07B, "TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384" }, 382 1.1.1.2 christos { 0xC07C, "TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256" }, 383 1.1.1.2 christos { 0xC07D, "TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384" }, 384 1.1.1.2 christos { 0xC07E, "TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256" }, 385 1.1.1.2 christos { 0xC07F, "TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384" }, 386 1.1.1.2 christos { 0xC080, "TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256" }, 387 1.1.1.2 christos { 0xC081, "TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384" }, 388 1.1.1.2 christos { 0xC082, "TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256" }, 389 1.1.1.2 christos { 0xC083, "TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384" }, 390 1.1.1.2 christos { 0xC084, "TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256" }, 391 1.1.1.2 christos { 0xC085, "TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384" }, 392 1.1.1.2 christos { 0xC086, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256" }, 393 1.1.1.2 christos { 0xC087, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384" }, 394 1.1.1.2 christos { 0xC088, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256" }, 395 1.1.1.2 christos { 0xC089, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384" }, 396 1.1.1.2 christos { 0xC08A, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256" }, 397 1.1.1.2 christos { 0xC08B, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384" }, 398 1.1.1.2 christos { 0xC08C, "TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256" }, 399 1.1.1.2 christos { 0xC08D, "TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384" }, 400 1.1.1.2 christos { 0xC08E, "TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256" }, 401 1.1.1.2 christos { 0xC08F, "TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384" }, 402 1.1.1.2 christos { 0xC090, "TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256" }, 403 1.1.1.2 christos { 0xC091, "TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384" }, 404 1.1.1.2 christos { 0xC092, "TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256" }, 405 1.1.1.2 christos { 0xC093, "TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384" }, 406 1.1.1.2 christos { 0xC094, "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256" }, 407 1.1.1.2 christos { 0xC095, "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384" }, 408 1.1.1.2 christos { 0xC096, "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" }, 409 1.1.1.2 christos { 0xC097, "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" }, 410 1.1.1.2 christos { 0xC098, "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256" }, 411 1.1.1.2 christos { 0xC099, "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384" }, 412 1.1.1.2 christos { 0xC09A, "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" }, 413 1.1.1.2 christos { 0xC09B, "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" }, 414 1.1.1.2 christos { 0xC09C, "TLS_RSA_WITH_AES_128_CCM" }, 415 1.1.1.2 christos { 0xC09D, "TLS_RSA_WITH_AES_256_CCM" }, 416 1.1.1.2 christos { 0xC09E, "TLS_DHE_RSA_WITH_AES_128_CCM" }, 417 1.1.1.2 christos { 0xC09F, "TLS_DHE_RSA_WITH_AES_256_CCM" }, 418 1.1.1.2 christos { 0xC0A0, "TLS_RSA_WITH_AES_128_CCM_8" }, 419 1.1.1.2 christos { 0xC0A1, "TLS_RSA_WITH_AES_256_CCM_8" }, 420 1.1.1.2 christos { 0xC0A2, "TLS_DHE_RSA_WITH_AES_128_CCM_8" }, 421 1.1.1.2 christos { 0xC0A3, "TLS_DHE_RSA_WITH_AES_256_CCM_8" }, 422 1.1.1.2 christos { 0xC0A4, "TLS_PSK_WITH_AES_128_CCM" }, 423 1.1.1.2 christos { 0xC0A5, "TLS_PSK_WITH_AES_256_CCM" }, 424 1.1.1.2 christos { 0xC0A6, "TLS_DHE_PSK_WITH_AES_128_CCM" }, 425 1.1.1.2 christos { 0xC0A7, "TLS_DHE_PSK_WITH_AES_256_CCM" }, 426 1.1.1.2 christos { 0xC0A8, "TLS_PSK_WITH_AES_128_CCM_8" }, 427 1.1.1.2 christos { 0xC0A9, "TLS_PSK_WITH_AES_256_CCM_8" }, 428 1.1.1.2 christos { 0xC0AA, "TLS_PSK_DHE_WITH_AES_128_CCM_8" }, 429 1.1.1.2 christos { 0xC0AB, "TLS_PSK_DHE_WITH_AES_256_CCM_8" }, 430 1.1.1.2 christos { 0xC0AC, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM" }, 431 1.1.1.2 christos { 0xC0AD, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM" }, 432 1.1.1.2 christos { 0xC0AE, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8" }, 433 1.1.1.2 christos { 0xC0AF, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8" }, 434 1.1.1.2 christos { 0xC102, "IANA-GOST2012-GOST8912-GOST8912" }, 435 1.1.1.2 christos { 0xCCA8, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" }, 436 1.1.1.2 christos { 0xCCA9, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" }, 437 1.1.1.2 christos { 0xCCAA, "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256" }, 438 1.1.1.2 christos { 0xCCAB, "TLS_PSK_WITH_CHACHA20_POLY1305_SHA256" }, 439 1.1.1.2 christos { 0xCCAC, "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256" }, 440 1.1.1.2 christos { 0xCCAD, "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256" }, 441 1.1.1.2 christos { 0xCCAE, "TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256" }, 442 1.1.1.2 christos { 0x1301, "TLS_AES_128_GCM_SHA256" }, 443 1.1.1.2 christos { 0x1302, "TLS_AES_256_GCM_SHA384" }, 444 1.1.1.2 christos { 0x1303, "TLS_CHACHA20_POLY1305_SHA256" }, 445 1.1.1.2 christos { 0x1304, "TLS_AES_128_CCM_SHA256" }, 446 1.1.1.2 christos { 0x1305, "TLS_AES_128_CCM_8_SHA256" }, 447 1.1.1.2 christos { 0xFEFE, "SSL_RSA_FIPS_WITH_DES_CBC_SHA" }, 448 1.1.1.2 christos { 0xFEFF, "SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA" }, 449 1.1.1.2 christos { 0xFF85, "LEGACY-GOST2012-GOST8912-GOST8912" }, 450 1.1.1.2 christos { 0xFF87, "GOST2012-NULL-GOST12" }, 451 1.1.1.2 christos { 0xC0B4, "TLS_SHA256_SHA256" }, 452 1.1.1.2 christos { 0xC0B5, "TLS_SHA384_SHA384" }, 453 1.1.1.2 christos { 0xC100, "GOST2012-KUZNYECHIK-KUZNYECHIKOMAC" }, 454 1.1.1.2 christos { 0xC101, "GOST2012-MAGMA-MAGMAOMAC" }, 455 1.1.1.2 christos { 0xC102, "GOST2012-GOST8912-IANA" }, 456 1.1 christos }; 457 1.1 christos 458 1.1 christos /* Compression methods */ 459 1.1 christos static const ssl_trace_tbl ssl_comp_tbl[] = { 460 1.1.1.2 christos { 0x0000, "No Compression" }, 461 1.1.1.2 christos { 0x0001, "Zlib Compression" } 462 1.1 christos }; 463 1.1 christos 464 1.1 christos /* Extensions sorted by ascending id */ 465 1.1 christos static const ssl_trace_tbl ssl_exts_tbl[] = { 466 1.1.1.2 christos { TLSEXT_TYPE_server_name, "server_name" }, 467 1.1.1.2 christos { TLSEXT_TYPE_max_fragment_length, "max_fragment_length" }, 468 1.1.1.2 christos { TLSEXT_TYPE_client_certificate_url, "client_certificate_url" }, 469 1.1.1.2 christos { TLSEXT_TYPE_trusted_ca_keys, "trusted_ca_keys" }, 470 1.1.1.2 christos { TLSEXT_TYPE_truncated_hmac, "truncated_hmac" }, 471 1.1.1.2 christos { TLSEXT_TYPE_status_request, "status_request" }, 472 1.1.1.2 christos { TLSEXT_TYPE_user_mapping, "user_mapping" }, 473 1.1.1.2 christos { TLSEXT_TYPE_client_authz, "client_authz" }, 474 1.1.1.2 christos { TLSEXT_TYPE_server_authz, "server_authz" }, 475 1.1.1.2 christos { TLSEXT_TYPE_cert_type, "cert_type" }, 476 1.1.1.2 christos { TLSEXT_TYPE_supported_groups, "supported_groups" }, 477 1.1.1.2 christos { TLSEXT_TYPE_ec_point_formats, "ec_point_formats" }, 478 1.1.1.2 christos { TLSEXT_TYPE_srp, "srp" }, 479 1.1.1.2 christos { TLSEXT_TYPE_signature_algorithms, "signature_algorithms" }, 480 1.1.1.2 christos { TLSEXT_TYPE_use_srtp, "use_srtp" }, 481 1.1.1.2 christos { TLSEXT_TYPE_application_layer_protocol_negotiation, 482 1.1.1.2 christos "application_layer_protocol_negotiation" }, 483 1.1.1.2 christos { TLSEXT_TYPE_signed_certificate_timestamp, "signed_certificate_timestamps" }, 484 1.1.1.2 christos { TLSEXT_TYPE_client_cert_type, "client_cert_type" }, 485 1.1.1.2 christos { TLSEXT_TYPE_server_cert_type, "server_cert_type" }, 486 1.1.1.2 christos { TLSEXT_TYPE_padding, "padding" }, 487 1.1.1.2 christos { TLSEXT_TYPE_encrypt_then_mac, "encrypt_then_mac" }, 488 1.1.1.2 christos { TLSEXT_TYPE_extended_master_secret, "extended_master_secret" }, 489 1.1.1.2 christos { TLSEXT_TYPE_compress_certificate, "compress_certificate" }, 490 1.1.1.2 christos { TLSEXT_TYPE_session_ticket, "session_ticket" }, 491 1.1.1.2 christos { TLSEXT_TYPE_psk, "psk" }, 492 1.1.1.2 christos { TLSEXT_TYPE_early_data, "early_data" }, 493 1.1.1.2 christos { TLSEXT_TYPE_supported_versions, "supported_versions" }, 494 1.1.1.2 christos { TLSEXT_TYPE_cookie, "cookie_ext" }, 495 1.1.1.2 christos { TLSEXT_TYPE_psk_kex_modes, "psk_key_exchange_modes" }, 496 1.1.1.2 christos { TLSEXT_TYPE_certificate_authorities, "certificate_authorities" }, 497 1.1.1.2 christos { TLSEXT_TYPE_post_handshake_auth, "post_handshake_auth" }, 498 1.1.1.2 christos { TLSEXT_TYPE_signature_algorithms_cert, "signature_algorithms_cert" }, 499 1.1.1.2 christos { TLSEXT_TYPE_key_share, "key_share" }, 500 1.1.1.2 christos { TLSEXT_TYPE_renegotiate, "renegotiate" }, 501 1.1.1.2 christos #ifndef OPENSSL_NO_NEXTPROTONEG 502 1.1.1.2 christos { TLSEXT_TYPE_next_proto_neg, "next_proto_neg" }, 503 1.1.1.2 christos #endif 504 1.1 christos }; 505 1.1 christos 506 1.1 christos static const ssl_trace_tbl ssl_groups_tbl[] = { 507 1.1.1.2 christos { 1, "sect163k1 (K-163)" }, 508 1.1.1.2 christos { 2, "sect163r1" }, 509 1.1.1.2 christos { 3, "sect163r2 (B-163)" }, 510 1.1.1.2 christos { 4, "sect193r1" }, 511 1.1.1.2 christos { 5, "sect193r2" }, 512 1.1.1.2 christos { 6, "sect233k1 (K-233)" }, 513 1.1.1.2 christos { 7, "sect233r1 (B-233)" }, 514 1.1.1.2 christos { 8, "sect239k1" }, 515 1.1.1.2 christos { 9, "sect283k1 (K-283)" }, 516 1.1.1.2 christos { 10, "sect283r1 (B-283)" }, 517 1.1.1.2 christos { 11, "sect409k1 (K-409)" }, 518 1.1.1.2 christos { 12, "sect409r1 (B-409)" }, 519 1.1.1.2 christos { 13, "sect571k1 (K-571)" }, 520 1.1.1.2 christos { 14, "sect571r1 (B-571)" }, 521 1.1.1.2 christos { 15, "secp160k1" }, 522 1.1.1.2 christos { 16, "secp160r1" }, 523 1.1.1.2 christos { 17, "secp160r2" }, 524 1.1.1.2 christos { 18, "secp192k1" }, 525 1.1.1.2 christos { 19, "secp192r1 (P-192)" }, 526 1.1.1.2 christos { 20, "secp224k1" }, 527 1.1.1.2 christos { 21, "secp224r1 (P-224)" }, 528 1.1.1.2 christos { 22, "secp256k1" }, 529 1.1.1.2 christos { 23, "secp256r1 (P-256)" }, 530 1.1.1.2 christos { 24, "secp384r1 (P-384)" }, 531 1.1.1.2 christos { 25, "secp521r1 (P-521)" }, 532 1.1.1.2 christos { 26, "brainpoolP256r1" }, 533 1.1.1.2 christos { 27, "brainpoolP384r1" }, 534 1.1.1.2 christos { 28, "brainpoolP512r1" }, 535 1.1.1.2 christos { 29, "ecdh_x25519" }, 536 1.1.1.2 christos { 30, "ecdh_x448" }, 537 1.1.1.2 christos { 31, "brainpoolP256r1tls13" }, 538 1.1.1.2 christos { 32, "brainpoolP384r1tls13" }, 539 1.1.1.2 christos { 33, "brainpoolP512r1tls13" }, 540 1.1.1.2 christos { 34, "GC256A" }, 541 1.1.1.2 christos { 35, "GC256B" }, 542 1.1.1.2 christos { 36, "GC256C" }, 543 1.1.1.2 christos { 37, "GC256D" }, 544 1.1.1.2 christos { 38, "GC512A" }, 545 1.1.1.2 christos { 39, "GC512B" }, 546 1.1.1.2 christos { 40, "GC512C" }, 547 1.1.1.2 christos { 256, "ffdhe2048" }, 548 1.1.1.2 christos { 257, "ffdhe3072" }, 549 1.1.1.2 christos { 258, "ffdhe4096" }, 550 1.1.1.2 christos { 259, "ffdhe6144" }, 551 1.1.1.2 christos { 260, "ffdhe8192" }, 552 1.1.1.2 christos { 512, "MLKEM512" }, 553 1.1.1.2 christos { 513, "MLKEM768" }, 554 1.1.1.2 christos { 514, "MLKEM1024" }, 555 1.1.1.2 christos { 4587, "SecP256r1MLKEM768" }, 556 1.1.1.2 christos { 4588, "X25519MLKEM768" }, 557 1.1.1.2 christos { 4589, "SecP384r1MLKEM1024" }, 558 1.1.1.2 christos { 25497, "X25519Kyber768Draft00" }, 559 1.1.1.2 christos { 25498, "SecP256r1Kyber768Draft00" }, 560 1.1.1.2 christos { 0xFF01, "arbitrary_explicit_prime_curves" }, 561 1.1.1.2 christos { 0xFF02, "arbitrary_explicit_char2_curves" } 562 1.1 christos }; 563 1.1 christos 564 1.1 christos static const ssl_trace_tbl ssl_point_tbl[] = { 565 1.1.1.2 christos { 0, "uncompressed" }, 566 1.1.1.2 christos { 1, "ansiX962_compressed_prime" }, 567 1.1.1.2 christos { 2, "ansiX962_compressed_char2" } 568 1.1 christos }; 569 1.1 christos 570 1.1 christos static const ssl_trace_tbl ssl_mfl_tbl[] = { 571 1.1.1.2 christos { 0, "disabled" }, 572 1.1.1.2 christos { 1, "max_fragment_length := 2^9 (512 bytes)" }, 573 1.1.1.2 christos { 2, "max_fragment_length := 2^10 (1024 bytes)" }, 574 1.1.1.2 christos { 3, "max_fragment_length := 2^11 (2048 bytes)" }, 575 1.1.1.2 christos { 4, "max_fragment_length := 2^12 (4096 bytes)" } 576 1.1 christos }; 577 1.1 christos 578 1.1 christos static const ssl_trace_tbl ssl_sigalg_tbl[] = { 579 1.1.1.2 christos { TLSEXT_SIGALG_ecdsa_secp256r1_sha256, TLSEXT_SIGALG_ecdsa_secp256r1_sha256_name }, 580 1.1.1.2 christos { TLSEXT_SIGALG_ecdsa_secp384r1_sha384, TLSEXT_SIGALG_ecdsa_secp384r1_sha384_name }, 581 1.1.1.2 christos { TLSEXT_SIGALG_ecdsa_secp521r1_sha512, TLSEXT_SIGALG_ecdsa_secp521r1_sha512_name }, 582 1.1.1.2 christos { TLSEXT_SIGALG_ecdsa_sha224, TLSEXT_SIGALG_ecdsa_sha224_name }, 583 1.1.1.2 christos { TLSEXT_SIGALG_ed25519, TLSEXT_SIGALG_ed25519_name }, 584 1.1.1.2 christos { TLSEXT_SIGALG_ed448, TLSEXT_SIGALG_ed448_name }, 585 1.1.1.2 christos { TLSEXT_SIGALG_ecdsa_sha1, TLSEXT_SIGALG_ecdsa_sha1_name }, 586 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pss_rsae_sha256, TLSEXT_SIGALG_rsa_pss_rsae_sha256_name }, 587 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pss_rsae_sha384, TLSEXT_SIGALG_rsa_pss_rsae_sha384_name }, 588 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pss_rsae_sha512, TLSEXT_SIGALG_rsa_pss_rsae_sha512_name }, 589 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pss_pss_sha256, TLSEXT_SIGALG_rsa_pss_pss_sha256_name }, 590 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pss_pss_sha384, TLSEXT_SIGALG_rsa_pss_pss_sha384_name }, 591 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pss_pss_sha512, TLSEXT_SIGALG_rsa_pss_pss_sha512_name }, 592 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pkcs1_sha256, TLSEXT_SIGALG_rsa_pkcs1_sha256_name }, 593 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pkcs1_sha384, TLSEXT_SIGALG_rsa_pkcs1_sha384_name }, 594 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pkcs1_sha512, TLSEXT_SIGALG_rsa_pkcs1_sha512_name }, 595 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pkcs1_sha224, TLSEXT_SIGALG_rsa_pkcs1_sha224_name }, 596 1.1.1.2 christos { TLSEXT_SIGALG_rsa_pkcs1_sha1, TLSEXT_SIGALG_rsa_pkcs1_sha1_name }, 597 1.1.1.2 christos { TLSEXT_SIGALG_dsa_sha256, TLSEXT_SIGALG_dsa_sha256_name }, 598 1.1.1.2 christos { TLSEXT_SIGALG_dsa_sha384, TLSEXT_SIGALG_dsa_sha384_name }, 599 1.1.1.2 christos { TLSEXT_SIGALG_dsa_sha512, TLSEXT_SIGALG_dsa_sha512_name }, 600 1.1.1.2 christos { TLSEXT_SIGALG_dsa_sha224, TLSEXT_SIGALG_dsa_sha224_name }, 601 1.1.1.2 christos { TLSEXT_SIGALG_dsa_sha1, TLSEXT_SIGALG_dsa_sha1_name }, 602 1.1.1.2 christos { TLSEXT_SIGALG_gostr34102012_256_intrinsic, TLSEXT_SIGALG_gostr34102012_256_intrinsic_name }, 603 1.1.1.2 christos { TLSEXT_SIGALG_gostr34102012_512_intrinsic, TLSEXT_SIGALG_gostr34102012_512_intrinsic_name }, 604 1.1.1.2 christos { TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256, TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256_name }, 605 1.1.1.2 christos { TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512, TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512_name }, 606 1.1.1.2 christos { TLSEXT_SIGALG_gostr34102001_gostr3411, TLSEXT_SIGALG_gostr34102001_gostr3411_name }, 607 1.1.1.2 christos { TLSEXT_SIGALG_ecdsa_brainpoolP256r1_sha256, TLSEXT_SIGALG_ecdsa_brainpoolP256r1_sha256_name }, 608 1.1.1.2 christos { TLSEXT_SIGALG_ecdsa_brainpoolP384r1_sha384, TLSEXT_SIGALG_ecdsa_brainpoolP384r1_sha384_name }, 609 1.1.1.2 christos { TLSEXT_SIGALG_ecdsa_brainpoolP512r1_sha512, TLSEXT_SIGALG_ecdsa_brainpoolP512r1_sha512_name }, 610 1.1 christos /* 611 1.1 christos * Well known groups that we happen to know about, but only come from 612 1.1 christos * provider capability declarations (hence no macros for the 613 1.1 christos * codepoints/names) 614 1.1 christos */ 615 1.1.1.2 christos { 0x0904, "mldsa44" }, 616 1.1.1.2 christos { 0x0905, "mldsa65" }, 617 1.1.1.2 christos { 0x0906, "mldsa87" } 618 1.1 christos }; 619 1.1 christos 620 1.1 christos static const ssl_trace_tbl ssl_ctype_tbl[] = { 621 1.1.1.2 christos { 1, "rsa_sign" }, 622 1.1.1.2 christos { 2, "dss_sign" }, 623 1.1.1.2 christos { 3, "rsa_fixed_dh" }, 624 1.1.1.2 christos { 4, "dss_fixed_dh" }, 625 1.1.1.2 christos { 5, "rsa_ephemeral_dh" }, 626 1.1.1.2 christos { 6, "dss_ephemeral_dh" }, 627 1.1.1.2 christos { 20, "fortezza_dms" }, 628 1.1.1.2 christos { 64, "ecdsa_sign" }, 629 1.1.1.2 christos { 65, "rsa_fixed_ecdh" }, 630 1.1.1.2 christos { 66, "ecdsa_fixed_ecdh" }, 631 1.1.1.2 christos { 67, "gost_sign256" }, 632 1.1.1.2 christos { 68, "gost_sign512" }, 633 1.1 christos }; 634 1.1 christos 635 1.1 christos static const ssl_trace_tbl ssl_psk_kex_modes_tbl[] = { 636 1.1.1.2 christos { TLSEXT_KEX_MODE_KE, "psk_ke" }, 637 1.1.1.2 christos { TLSEXT_KEX_MODE_KE_DHE, "psk_dhe_ke" } 638 1.1 christos }; 639 1.1 christos 640 1.1 christos static const ssl_trace_tbl ssl_key_update_tbl[] = { 641 1.1.1.2 christos { SSL_KEY_UPDATE_NOT_REQUESTED, "update_not_requested" }, 642 1.1.1.2 christos { SSL_KEY_UPDATE_REQUESTED, "update_requested" } 643 1.1 christos }; 644 1.1 christos 645 1.1 christos static const ssl_trace_tbl ssl_comp_cert_tbl[] = { 646 1.1.1.2 christos { TLSEXT_comp_cert_none, "none" }, 647 1.1.1.2 christos { TLSEXT_comp_cert_zlib, "zlib" }, 648 1.1.1.2 christos { TLSEXT_comp_cert_brotli, "brotli" }, 649 1.1.1.2 christos { TLSEXT_comp_cert_zstd, "zstd" } 650 1.1 christos }; 651 1.1 christos 652 1.1 christos /* 653 1.1 christos * "pgp" and "1609dot2" are defined in RFC7250, 654 1.1 christos * although OpenSSL doesn't support them, it can 655 1.1 christos * at least report them in traces 656 1.1 christos */ 657 1.1 christos static const ssl_trace_tbl ssl_cert_type_tbl[] = { 658 1.1.1.2 christos { TLSEXT_cert_type_x509, "x509" }, 659 1.1.1.2 christos { TLSEXT_cert_type_pgp, "pgp" }, 660 1.1.1.2 christos { TLSEXT_cert_type_rpk, "rpk" }, 661 1.1.1.2 christos { TLSEXT_cert_type_1609dot2, "1609dot2" } 662 1.1 christos }; 663 1.1 christos 664 1.1 christos static void ssl_print_hex(BIO *bio, int indent, const char *name, 665 1.1.1.2 christos const unsigned char *msg, size_t msglen) 666 1.1 christos { 667 1.1 christos size_t i; 668 1.1 christos 669 1.1 christos BIO_indent(bio, indent, 80); 670 1.1 christos BIO_printf(bio, "%s (len=%d): ", name, (int)msglen); 671 1.1 christos for (i = 0; i < msglen; i++) 672 1.1 christos BIO_printf(bio, "%02X", msg[i]); 673 1.1 christos BIO_puts(bio, "\n"); 674 1.1 christos } 675 1.1 christos 676 1.1 christos static int ssl_print_hexbuf(BIO *bio, int indent, const char *name, size_t nlen, 677 1.1.1.2 christos const unsigned char **pmsg, size_t *pmsglen) 678 1.1 christos { 679 1.1 christos size_t blen; 680 1.1 christos const unsigned char *p = *pmsg; 681 1.1 christos 682 1.1 christos if (*pmsglen < nlen) 683 1.1 christos return 0; 684 1.1 christos blen = p[0]; 685 1.1 christos if (nlen > 1) 686 1.1 christos blen = (blen << 8) | p[1]; 687 1.1 christos if (*pmsglen < nlen + blen) 688 1.1 christos return 0; 689 1.1 christos p += nlen; 690 1.1 christos ssl_print_hex(bio, indent, name, p, blen); 691 1.1 christos *pmsg += blen + nlen; 692 1.1 christos *pmsglen -= blen + nlen; 693 1.1 christos return 1; 694 1.1 christos } 695 1.1 christos 696 1.1 christos static int ssl_print_version(BIO *bio, int indent, const char *name, 697 1.1.1.2 christos const unsigned char **pmsg, size_t *pmsglen, 698 1.1.1.2 christos unsigned int *version) 699 1.1 christos { 700 1.1 christos int vers; 701 1.1 christos 702 1.1 christos if (*pmsglen < 2) 703 1.1 christos return 0; 704 1.1 christos vers = ((*pmsg)[0] << 8) | (*pmsg)[1]; 705 1.1 christos if (version != NULL) 706 1.1 christos *version = vers; 707 1.1 christos BIO_indent(bio, indent, 80); 708 1.1 christos BIO_printf(bio, "%s=0x%x (%s)\n", 709 1.1.1.2 christos name, vers, ssl_trace_str(vers, ssl_version_tbl)); 710 1.1 christos *pmsg += 2; 711 1.1 christos *pmsglen -= 2; 712 1.1 christos return 1; 713 1.1 christos } 714 1.1 christos 715 1.1 christos static int ssl_print_random(BIO *bio, int indent, 716 1.1.1.2 christos const unsigned char **pmsg, size_t *pmsglen) 717 1.1 christos { 718 1.1 christos unsigned int tm; 719 1.1 christos const unsigned char *p = *pmsg; 720 1.1 christos 721 1.1 christos if (*pmsglen < 32) 722 1.1 christos return 0; 723 1.1 christos tm = ((unsigned int)p[0] << 24) 724 1.1.1.2 christos | ((unsigned int)p[1] << 16) 725 1.1.1.2 christos | ((unsigned int)p[2] << 8) 726 1.1.1.2 christos | (unsigned int)p[3]; 727 1.1 christos p += 4; 728 1.1 christos BIO_indent(bio, indent, 80); 729 1.1 christos BIO_puts(bio, "Random:\n"); 730 1.1 christos BIO_indent(bio, indent + 2, 80); 731 1.1 christos BIO_printf(bio, "gmt_unix_time=0x%08X\n", tm); 732 1.1 christos ssl_print_hex(bio, indent + 2, "random_bytes", p, 28); 733 1.1 christos *pmsg += 32; 734 1.1 christos *pmsglen -= 32; 735 1.1 christos return 1; 736 1.1 christos } 737 1.1 christos 738 1.1 christos static int ssl_print_signature(BIO *bio, int indent, const SSL_CONNECTION *sc, 739 1.1.1.2 christos const unsigned char **pmsg, size_t *pmsglen) 740 1.1 christos { 741 1.1 christos if (*pmsglen < 2) 742 1.1 christos return 0; 743 1.1 christos if (SSL_USE_SIGALGS(sc)) { 744 1.1 christos const unsigned char *p = *pmsg; 745 1.1 christos unsigned int sigalg = (p[0] << 8) | p[1]; 746 1.1 christos 747 1.1 christos BIO_indent(bio, indent, 80); 748 1.1 christos BIO_printf(bio, "Signature Algorithm: %s (0x%04x)\n", 749 1.1.1.2 christos ssl_trace_str(sigalg, ssl_sigalg_tbl), sigalg); 750 1.1 christos *pmsg += 2; 751 1.1 christos *pmsglen -= 2; 752 1.1 christos } 753 1.1 christos return ssl_print_hexbuf(bio, indent, "Signature", 2, pmsg, pmsglen); 754 1.1 christos } 755 1.1 christos 756 1.1 christos static int ssl_print_extension(BIO *bio, int indent, int server, 757 1.1.1.2 christos unsigned char mt, int extype, 758 1.1.1.2 christos const unsigned char *ext, size_t extlen) 759 1.1 christos { 760 1.1 christos size_t xlen, share_len; 761 1.1 christos unsigned int sigalg; 762 1.1 christos uint32_t max_early_data; 763 1.1 christos 764 1.1 christos BIO_indent(bio, indent, 80); 765 1.1 christos BIO_printf(bio, "extension_type=%s(%d), length=%d\n", 766 1.1.1.2 christos ssl_trace_str(extype, ssl_exts_tbl), extype, (int)extlen); 767 1.1 christos switch (extype) { 768 1.1 christos case TLSEXT_TYPE_compress_certificate: 769 1.1 christos if (extlen < 1) 770 1.1 christos return 0; 771 1.1 christos xlen = ext[0]; 772 1.1 christos if (extlen != xlen + 1) 773 1.1 christos return 0; 774 1.1 christos return ssl_trace_list(bio, indent + 2, ext + 1, xlen, 2, ssl_comp_cert_tbl); 775 1.1 christos 776 1.1 christos case TLSEXT_TYPE_max_fragment_length: 777 1.1 christos if (extlen < 1) 778 1.1 christos return 0; 779 1.1 christos xlen = extlen; 780 1.1 christos return ssl_trace_list(bio, indent + 2, ext, xlen, 1, ssl_mfl_tbl); 781 1.1 christos 782 1.1 christos case TLSEXT_TYPE_ec_point_formats: 783 1.1 christos if (extlen < 1) 784 1.1 christos return 0; 785 1.1 christos xlen = ext[0]; 786 1.1 christos if (extlen != xlen + 1) 787 1.1 christos return 0; 788 1.1 christos return ssl_trace_list(bio, indent + 2, ext + 1, xlen, 1, ssl_point_tbl); 789 1.1 christos 790 1.1 christos case TLSEXT_TYPE_supported_groups: 791 1.1 christos if (extlen < 2) 792 1.1 christos return 0; 793 1.1 christos xlen = (ext[0] << 8) | ext[1]; 794 1.1 christos if (extlen != xlen + 2) 795 1.1 christos return 0; 796 1.1 christos return ssl_trace_list(bio, indent + 2, ext + 2, xlen, 2, ssl_groups_tbl); 797 1.1 christos case TLSEXT_TYPE_application_layer_protocol_negotiation: 798 1.1 christos if (extlen < 2) 799 1.1 christos return 0; 800 1.1 christos xlen = (ext[0] << 8) | ext[1]; 801 1.1 christos if (extlen != xlen + 2) 802 1.1 christos return 0; 803 1.1 christos ext += 2; 804 1.1 christos while (xlen > 0) { 805 1.1 christos size_t plen = *ext++; 806 1.1 christos 807 1.1 christos if (plen + 1 > xlen) 808 1.1 christos return 0; 809 1.1 christos BIO_indent(bio, indent + 2, 80); 810 1.1 christos BIO_write(bio, ext, plen); 811 1.1 christos BIO_puts(bio, "\n"); 812 1.1 christos ext += plen; 813 1.1 christos xlen -= plen + 1; 814 1.1 christos } 815 1.1 christos return 1; 816 1.1 christos 817 1.1 christos case TLSEXT_TYPE_signature_algorithms: 818 1.1 christos 819 1.1 christos if (extlen < 2) 820 1.1 christos return 0; 821 1.1 christos xlen = (ext[0] << 8) | ext[1]; 822 1.1 christos if (extlen != xlen + 2) 823 1.1 christos return 0; 824 1.1 christos if (xlen & 1) 825 1.1 christos return 0; 826 1.1 christos ext += 2; 827 1.1 christos while (xlen > 0) { 828 1.1 christos BIO_indent(bio, indent + 2, 80); 829 1.1 christos sigalg = (ext[0] << 8) | ext[1]; 830 1.1 christos BIO_printf(bio, "%s (0x%04x)\n", 831 1.1.1.2 christos ssl_trace_str(sigalg, ssl_sigalg_tbl), sigalg); 832 1.1 christos xlen -= 2; 833 1.1 christos ext += 2; 834 1.1 christos } 835 1.1 christos break; 836 1.1 christos 837 1.1 christos case TLSEXT_TYPE_renegotiate: 838 1.1 christos if (extlen < 1) 839 1.1 christos return 0; 840 1.1 christos xlen = ext[0]; 841 1.1 christos if (xlen + 1 != extlen) 842 1.1 christos return 0; 843 1.1 christos ext++; 844 1.1 christos if (xlen) { 845 1.1 christos if (server) { 846 1.1 christos if (xlen & 1) 847 1.1 christos return 0; 848 1.1 christos xlen >>= 1; 849 1.1 christos } 850 1.1 christos ssl_print_hex(bio, indent + 4, "client_verify_data", ext, xlen); 851 1.1 christos if (server) { 852 1.1 christos ext += xlen; 853 1.1 christos ssl_print_hex(bio, indent + 4, "server_verify_data", ext, xlen); 854 1.1 christos } 855 1.1 christos } else { 856 1.1 christos BIO_indent(bio, indent + 4, 80); 857 1.1 christos BIO_puts(bio, "<EMPTY>\n"); 858 1.1 christos } 859 1.1 christos break; 860 1.1 christos 861 1.1 christos case TLSEXT_TYPE_session_ticket: 862 1.1 christos if (extlen != 0) 863 1.1 christos ssl_print_hex(bio, indent + 4, "ticket", ext, extlen); 864 1.1 christos break; 865 1.1 christos 866 1.1 christos case TLSEXT_TYPE_key_share: 867 1.1 christos if (server && extlen == 2) { 868 1.1 christos int group_id; 869 1.1 christos 870 1.1 christos /* We assume this is an HRR, otherwise this is an invalid key_share */ 871 1.1 christos group_id = (ext[0] << 8) | ext[1]; 872 1.1 christos BIO_indent(bio, indent + 4, 80); 873 1.1 christos BIO_printf(bio, "NamedGroup: %s (%d)\n", 874 1.1.1.2 christos ssl_trace_str(group_id, ssl_groups_tbl), group_id); 875 1.1 christos break; 876 1.1 christos } 877 1.1 christos if (extlen < 2) 878 1.1 christos return 0; 879 1.1 christos if (server) { 880 1.1 christos xlen = extlen; 881 1.1 christos } else { 882 1.1 christos xlen = (ext[0] << 8) | ext[1]; 883 1.1 christos if (extlen != xlen + 2) 884 1.1 christos return 0; 885 1.1 christos ext += 2; 886 1.1 christos } 887 1.1 christos for (; xlen > 0; ext += share_len, xlen -= share_len) { 888 1.1 christos int group_id; 889 1.1 christos 890 1.1 christos if (xlen < 4) 891 1.1 christos return 0; 892 1.1 christos group_id = (ext[0] << 8) | ext[1]; 893 1.1 christos share_len = (ext[2] << 8) | ext[3]; 894 1.1 christos ext += 4; 895 1.1 christos xlen -= 4; 896 1.1 christos if (xlen < share_len) 897 1.1 christos return 0; 898 1.1 christos BIO_indent(bio, indent + 4, 80); 899 1.1 christos BIO_printf(bio, "NamedGroup: %s (%d)\n", 900 1.1.1.2 christos ssl_trace_str(group_id, ssl_groups_tbl), group_id); 901 1.1 christos ssl_print_hex(bio, indent + 4, "key_exchange: ", ext, share_len); 902 1.1 christos } 903 1.1 christos break; 904 1.1 christos 905 1.1 christos case TLSEXT_TYPE_supported_versions: 906 1.1 christos if (server) { 907 1.1 christos int version; 908 1.1 christos 909 1.1 christos if (extlen != 2) 910 1.1 christos return 0; 911 1.1 christos version = (ext[0] << 8) | ext[1]; 912 1.1 christos BIO_indent(bio, indent + 4, 80); 913 1.1 christos BIO_printf(bio, "%s (%d)\n", 914 1.1.1.2 christos ssl_trace_str(version, ssl_version_tbl), version); 915 1.1 christos break; 916 1.1 christos } 917 1.1 christos if (extlen < 1) 918 1.1 christos return 0; 919 1.1 christos xlen = ext[0]; 920 1.1 christos if (extlen != xlen + 1) 921 1.1 christos return 0; 922 1.1 christos return ssl_trace_list(bio, indent + 2, ext + 1, xlen, 2, 923 1.1.1.2 christos ssl_version_tbl); 924 1.1 christos 925 1.1 christos case TLSEXT_TYPE_psk_kex_modes: 926 1.1 christos if (extlen < 1) 927 1.1 christos return 0; 928 1.1 christos xlen = ext[0]; 929 1.1 christos if (extlen != xlen + 1) 930 1.1 christos return 0; 931 1.1 christos return ssl_trace_list(bio, indent + 2, ext + 1, xlen, 1, 932 1.1.1.2 christos ssl_psk_kex_modes_tbl); 933 1.1 christos 934 1.1 christos case TLSEXT_TYPE_early_data: 935 1.1 christos if (mt != SSL3_MT_NEWSESSION_TICKET) 936 1.1 christos break; 937 1.1 christos if (extlen != 4) 938 1.1 christos return 0; 939 1.1 christos max_early_data = ((unsigned int)ext[0] << 24) 940 1.1.1.2 christos | ((unsigned int)ext[1] << 16) 941 1.1.1.2 christos | ((unsigned int)ext[2] << 8) 942 1.1.1.2 christos | (unsigned int)ext[3]; 943 1.1 christos BIO_indent(bio, indent + 2, 80); 944 1.1 christos BIO_printf(bio, "max_early_data=%u\n", (unsigned int)max_early_data); 945 1.1 christos break; 946 1.1 christos 947 1.1 christos case TLSEXT_TYPE_server_cert_type: 948 1.1 christos case TLSEXT_TYPE_client_cert_type: 949 1.1 christos if (server) { 950 1.1 christos if (extlen != 1) 951 1.1 christos return 0; 952 1.1 christos return ssl_trace_list(bio, indent + 2, ext, 1, 1, ssl_cert_type_tbl); 953 1.1 christos } 954 1.1 christos if (extlen < 1) 955 1.1 christos return 0; 956 1.1 christos xlen = ext[0]; 957 1.1 christos if (extlen != xlen + 1) 958 1.1 christos return 0; 959 1.1 christos return ssl_trace_list(bio, indent + 2, ext + 1, xlen, 1, ssl_cert_type_tbl); 960 1.1 christos 961 1.1 christos default: 962 1.1 christos BIO_dump_indent(bio, (const char *)ext, extlen, indent + 2); 963 1.1 christos } 964 1.1 christos return 1; 965 1.1 christos } 966 1.1 christos 967 1.1 christos static int ssl_print_extensions(BIO *bio, int indent, int server, 968 1.1.1.2 christos unsigned char mt, const unsigned char **msgin, 969 1.1.1.2 christos size_t *msginlen) 970 1.1 christos { 971 1.1 christos size_t extslen, msglen = *msginlen; 972 1.1 christos const unsigned char *msg = *msgin; 973 1.1 christos 974 1.1 christos BIO_indent(bio, indent, 80); 975 1.1 christos if (msglen == 0) { 976 1.1 christos BIO_puts(bio, "No extensions\n"); 977 1.1 christos return 1; 978 1.1 christos } 979 1.1 christos if (msglen < 2) 980 1.1 christos return 0; 981 1.1 christos extslen = (msg[0] << 8) | msg[1]; 982 1.1 christos msglen -= 2; 983 1.1 christos msg += 2; 984 1.1 christos if (extslen == 0) { 985 1.1 christos BIO_puts(bio, "No extensions\n"); 986 1.1 christos *msgin = msg; 987 1.1 christos *msginlen = msglen; 988 1.1 christos return 1; 989 1.1 christos } 990 1.1 christos if (extslen > msglen) 991 1.1 christos return 0; 992 1.1 christos BIO_printf(bio, "extensions, length = %d\n", (int)extslen); 993 1.1 christos msglen -= extslen; 994 1.1 christos while (extslen > 0) { 995 1.1 christos int extype; 996 1.1 christos size_t extlen; 997 1.1 christos if (extslen < 4) 998 1.1 christos return 0; 999 1.1 christos extype = (msg[0] << 8) | msg[1]; 1000 1.1 christos extlen = (msg[2] << 8) | msg[3]; 1001 1.1 christos if (extslen < extlen + 4) { 1002 1.1 christos BIO_printf(bio, "extensions, extype = %d, extlen = %d\n", extype, 1003 1.1.1.2 christos (int)extlen); 1004 1.1 christos BIO_dump_indent(bio, (const char *)msg, extslen, indent + 2); 1005 1.1 christos return 0; 1006 1.1 christos } 1007 1.1 christos msg += 4; 1008 1.1 christos if (!ssl_print_extension(bio, indent + 2, server, mt, extype, msg, 1009 1.1.1.2 christos extlen)) 1010 1.1 christos return 0; 1011 1.1 christos msg += extlen; 1012 1.1 christos extslen -= extlen + 4; 1013 1.1 christos } 1014 1.1 christos 1015 1.1 christos *msgin = msg; 1016 1.1 christos *msginlen = msglen; 1017 1.1 christos return 1; 1018 1.1 christos } 1019 1.1 christos 1020 1.1 christos static int ssl_print_client_hello(BIO *bio, const SSL_CONNECTION *sc, int indent, 1021 1.1.1.2 christos const unsigned char *msg, size_t msglen) 1022 1.1 christos { 1023 1.1 christos size_t len; 1024 1.1 christos unsigned int cs; 1025 1.1 christos 1026 1.1 christos if (!ssl_print_version(bio, indent, "client_version", &msg, &msglen, NULL)) 1027 1.1 christos return 0; 1028 1.1 christos if (!ssl_print_random(bio, indent, &msg, &msglen)) 1029 1.1 christos return 0; 1030 1.1 christos if (!ssl_print_hexbuf(bio, indent, "session_id", 1, &msg, &msglen)) 1031 1.1 christos return 0; 1032 1.1 christos if (SSL_CONNECTION_IS_DTLS(sc)) { 1033 1.1 christos if (!ssl_print_hexbuf(bio, indent, "cookie", 1, &msg, &msglen)) 1034 1.1 christos return 0; 1035 1.1 christos } 1036 1.1 christos if (msglen < 2) 1037 1.1 christos return 0; 1038 1.1 christos len = (msg[0] << 8) | msg[1]; 1039 1.1 christos msg += 2; 1040 1.1 christos msglen -= 2; 1041 1.1 christos BIO_indent(bio, indent, 80); 1042 1.1 christos BIO_printf(bio, "cipher_suites (len=%d)\n", (int)len); 1043 1.1 christos if (msglen < len || len & 1) 1044 1.1 christos return 0; 1045 1.1 christos while (len > 0) { 1046 1.1 christos cs = (msg[0] << 8) | msg[1]; 1047 1.1 christos BIO_indent(bio, indent + 2, 80); 1048 1.1 christos BIO_printf(bio, "{0x%02X, 0x%02X} %s\n", 1049 1.1.1.2 christos msg[0], msg[1], ssl_trace_str(cs, ssl_ciphers_tbl)); 1050 1.1 christos msg += 2; 1051 1.1 christos msglen -= 2; 1052 1.1 christos len -= 2; 1053 1.1 christos } 1054 1.1 christos if (msglen < 1) 1055 1.1 christos return 0; 1056 1.1 christos len = msg[0]; 1057 1.1 christos msg++; 1058 1.1 christos msglen--; 1059 1.1 christos if (msglen < len) 1060 1.1 christos return 0; 1061 1.1 christos BIO_indent(bio, indent, 80); 1062 1.1 christos BIO_printf(bio, "compression_methods (len=%d)\n", (int)len); 1063 1.1 christos while (len > 0) { 1064 1.1 christos BIO_indent(bio, indent + 2, 80); 1065 1.1 christos BIO_printf(bio, "%s (0x%02X)\n", 1066 1.1.1.2 christos ssl_trace_str(msg[0], ssl_comp_tbl), msg[0]); 1067 1.1 christos msg++; 1068 1.1 christos msglen--; 1069 1.1 christos len--; 1070 1.1 christos } 1071 1.1 christos if (!ssl_print_extensions(bio, indent, 0, SSL3_MT_CLIENT_HELLO, &msg, 1072 1.1.1.2 christos &msglen)) 1073 1.1 christos return 0; 1074 1.1 christos return 1; 1075 1.1 christos } 1076 1.1 christos 1077 1.1 christos static int dtls_print_hello_vfyrequest(BIO *bio, int indent, 1078 1.1.1.2 christos const unsigned char *msg, size_t msglen) 1079 1.1 christos { 1080 1.1 christos if (!ssl_print_version(bio, indent, "server_version", &msg, &msglen, NULL)) 1081 1.1 christos return 0; 1082 1.1 christos if (!ssl_print_hexbuf(bio, indent, "cookie", 1, &msg, &msglen)) 1083 1.1 christos return 0; 1084 1.1 christos return 1; 1085 1.1 christos } 1086 1.1 christos 1087 1.1 christos static int ssl_print_server_hello(BIO *bio, int indent, 1088 1.1.1.2 christos const unsigned char *msg, size_t msglen) 1089 1.1 christos { 1090 1.1 christos unsigned int cs; 1091 1.1 christos unsigned int vers; 1092 1.1 christos 1093 1.1 christos if (!ssl_print_version(bio, indent, "server_version", &msg, &msglen, &vers)) 1094 1.1 christos return 0; 1095 1.1 christos if (!ssl_print_random(bio, indent, &msg, &msglen)) 1096 1.1 christos return 0; 1097 1.1 christos if (vers != TLS1_3_VERSION 1098 1.1.1.2 christos && !ssl_print_hexbuf(bio, indent, "session_id", 1, &msg, &msglen)) 1099 1.1 christos return 0; 1100 1.1 christos if (msglen < 2) 1101 1.1 christos return 0; 1102 1.1 christos cs = (msg[0] << 8) | msg[1]; 1103 1.1 christos BIO_indent(bio, indent, 80); 1104 1.1 christos BIO_printf(bio, "cipher_suite {0x%02X, 0x%02X} %s\n", 1105 1.1.1.2 christos msg[0], msg[1], ssl_trace_str(cs, ssl_ciphers_tbl)); 1106 1.1 christos msg += 2; 1107 1.1 christos msglen -= 2; 1108 1.1 christos if (vers != TLS1_3_VERSION) { 1109 1.1 christos if (msglen < 1) 1110 1.1 christos return 0; 1111 1.1 christos BIO_indent(bio, indent, 80); 1112 1.1 christos BIO_printf(bio, "compression_method: %s (0x%02X)\n", 1113 1.1.1.2 christos ssl_trace_str(msg[0], ssl_comp_tbl), msg[0]); 1114 1.1 christos msg++; 1115 1.1 christos msglen--; 1116 1.1 christos } 1117 1.1 christos if (!ssl_print_extensions(bio, indent, 1, SSL3_MT_SERVER_HELLO, &msg, 1118 1.1.1.2 christos &msglen)) 1119 1.1 christos return 0; 1120 1.1 christos return 1; 1121 1.1 christos } 1122 1.1 christos 1123 1.1 christos static int ssl_get_keyex(const char **pname, const SSL_CONNECTION *sc) 1124 1.1 christos { 1125 1.1 christos unsigned long alg_k = sc->s3.tmp.new_cipher->algorithm_mkey; 1126 1.1 christos 1127 1.1 christos if (alg_k & SSL_kRSA) { 1128 1.1 christos *pname = "rsa"; 1129 1.1 christos return SSL_kRSA; 1130 1.1 christos } 1131 1.1 christos if (alg_k & SSL_kDHE) { 1132 1.1 christos *pname = "DHE"; 1133 1.1 christos return SSL_kDHE; 1134 1.1 christos } 1135 1.1 christos if (alg_k & SSL_kECDHE) { 1136 1.1 christos *pname = "ECDHE"; 1137 1.1 christos return SSL_kECDHE; 1138 1.1 christos } 1139 1.1 christos if (alg_k & SSL_kPSK) { 1140 1.1 christos *pname = "PSK"; 1141 1.1 christos return SSL_kPSK; 1142 1.1 christos } 1143 1.1 christos if (alg_k & SSL_kRSAPSK) { 1144 1.1 christos *pname = "RSAPSK"; 1145 1.1 christos return SSL_kRSAPSK; 1146 1.1 christos } 1147 1.1 christos if (alg_k & SSL_kDHEPSK) { 1148 1.1 christos *pname = "DHEPSK"; 1149 1.1 christos return SSL_kDHEPSK; 1150 1.1 christos } 1151 1.1 christos if (alg_k & SSL_kECDHEPSK) { 1152 1.1 christos *pname = "ECDHEPSK"; 1153 1.1 christos return SSL_kECDHEPSK; 1154 1.1 christos } 1155 1.1 christos if (alg_k & SSL_kSRP) { 1156 1.1 christos *pname = "SRP"; 1157 1.1 christos return SSL_kSRP; 1158 1.1 christos } 1159 1.1 christos if (alg_k & SSL_kGOST) { 1160 1.1 christos *pname = "GOST"; 1161 1.1 christos return SSL_kGOST; 1162 1.1 christos } 1163 1.1 christos if (alg_k & SSL_kGOST18) { 1164 1.1 christos *pname = "GOST18"; 1165 1.1 christos return SSL_kGOST18; 1166 1.1 christos } 1167 1.1 christos *pname = "UNKNOWN"; 1168 1.1 christos return 0; 1169 1.1 christos } 1170 1.1 christos 1171 1.1 christos static int ssl_print_client_keyex(BIO *bio, int indent, const SSL_CONNECTION *sc, 1172 1.1.1.2 christos const unsigned char *msg, size_t msglen) 1173 1.1 christos { 1174 1.1 christos const char *algname; 1175 1.1 christos int id = ssl_get_keyex(&algname, sc); 1176 1.1 christos 1177 1.1 christos BIO_indent(bio, indent, 80); 1178 1.1 christos BIO_printf(bio, "KeyExchangeAlgorithm=%s\n", algname); 1179 1.1 christos if (id & SSL_PSK) { 1180 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, 1181 1.1.1.2 christos "psk_identity", 2, &msg, &msglen)) 1182 1.1 christos return 0; 1183 1.1 christos } 1184 1.1 christos switch (id) { 1185 1.1 christos 1186 1.1 christos case SSL_kRSA: 1187 1.1 christos case SSL_kRSAPSK: 1188 1.1 christos if (TLS1_get_version(SSL_CONNECTION_GET_SSL(sc)) == SSL3_VERSION) { 1189 1.1 christos ssl_print_hex(bio, indent + 2, 1190 1.1.1.2 christos "EncryptedPreMasterSecret", msg, msglen); 1191 1.1 christos } else { 1192 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, 1193 1.1.1.2 christos "EncryptedPreMasterSecret", 2, &msg, &msglen)) 1194 1.1 christos return 0; 1195 1.1 christos } 1196 1.1 christos break; 1197 1.1 christos 1198 1.1 christos case SSL_kDHE: 1199 1.1 christos case SSL_kDHEPSK: 1200 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "dh_Yc", 2, &msg, &msglen)) 1201 1.1 christos return 0; 1202 1.1 christos break; 1203 1.1 christos 1204 1.1 christos case SSL_kECDHE: 1205 1.1 christos case SSL_kECDHEPSK: 1206 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "ecdh_Yc", 1, &msg, &msglen)) 1207 1.1 christos return 0; 1208 1.1 christos break; 1209 1.1 christos case SSL_kGOST: 1210 1.1 christos ssl_print_hex(bio, indent + 2, "GostKeyTransportBlob", msg, msglen); 1211 1.1 christos msglen = 0; 1212 1.1 christos break; 1213 1.1 christos case SSL_kGOST18: 1214 1.1 christos ssl_print_hex(bio, indent + 2, 1215 1.1.1.2 christos "GOST-wrapped PreMasterSecret", msg, msglen); 1216 1.1 christos msglen = 0; 1217 1.1 christos break; 1218 1.1 christos } 1219 1.1 christos 1220 1.1 christos return !msglen; 1221 1.1 christos } 1222 1.1 christos 1223 1.1 christos static int ssl_print_server_keyex(BIO *bio, int indent, const SSL_CONNECTION *sc, 1224 1.1.1.2 christos const unsigned char *msg, size_t msglen) 1225 1.1 christos { 1226 1.1 christos const char *algname; 1227 1.1 christos int id = ssl_get_keyex(&algname, sc); 1228 1.1 christos 1229 1.1 christos BIO_indent(bio, indent, 80); 1230 1.1 christos BIO_printf(bio, "KeyExchangeAlgorithm=%s\n", algname); 1231 1.1 christos if (id & SSL_PSK) { 1232 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, 1233 1.1.1.2 christos "psk_identity_hint", 2, &msg, &msglen)) 1234 1.1 christos return 0; 1235 1.1 christos } 1236 1.1 christos switch (id) { 1237 1.1 christos case SSL_kRSA: 1238 1.1 christos 1239 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "rsa_modulus", 2, &msg, &msglen)) 1240 1.1 christos return 0; 1241 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "rsa_exponent", 2, 1242 1.1.1.2 christos &msg, &msglen)) 1243 1.1 christos return 0; 1244 1.1 christos break; 1245 1.1 christos 1246 1.1 christos case SSL_kDHE: 1247 1.1 christos case SSL_kDHEPSK: 1248 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "dh_p", 2, &msg, &msglen)) 1249 1.1 christos return 0; 1250 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "dh_g", 2, &msg, &msglen)) 1251 1.1 christos return 0; 1252 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "dh_Ys", 2, &msg, &msglen)) 1253 1.1 christos return 0; 1254 1.1 christos break; 1255 1.1 christos 1256 1.1 christos case SSL_kECDHE: 1257 1.1 christos case SSL_kECDHEPSK: 1258 1.1 christos if (msglen < 1) 1259 1.1 christos return 0; 1260 1.1 christos BIO_indent(bio, indent + 2, 80); 1261 1.1 christos if (msg[0] == EXPLICIT_PRIME_CURVE_TYPE) 1262 1.1 christos BIO_puts(bio, "explicit_prime\n"); 1263 1.1 christos else if (msg[0] == EXPLICIT_CHAR2_CURVE_TYPE) 1264 1.1 christos BIO_puts(bio, "explicit_char2\n"); 1265 1.1 christos else if (msg[0] == NAMED_CURVE_TYPE) { 1266 1.1 christos int curve; 1267 1.1 christos if (msglen < 3) 1268 1.1 christos return 0; 1269 1.1 christos curve = (msg[1] << 8) | msg[2]; 1270 1.1 christos BIO_printf(bio, "named_curve: %s (%d)\n", 1271 1.1.1.2 christos ssl_trace_str(curve, ssl_groups_tbl), curve); 1272 1.1 christos msg += 3; 1273 1.1 christos msglen -= 3; 1274 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "point", 1, &msg, &msglen)) 1275 1.1 christos return 0; 1276 1.1 christos } else { 1277 1.1 christos BIO_printf(bio, "UNKNOWN CURVE PARAMETER TYPE %d\n", msg[0]); 1278 1.1 christos return 0; 1279 1.1 christos } 1280 1.1 christos break; 1281 1.1 christos 1282 1.1 christos case SSL_kPSK: 1283 1.1 christos case SSL_kRSAPSK: 1284 1.1 christos break; 1285 1.1 christos } 1286 1.1 christos if (!(id & SSL_PSK)) 1287 1.1 christos ssl_print_signature(bio, indent, sc, &msg, &msglen); 1288 1.1 christos return !msglen; 1289 1.1 christos } 1290 1.1 christos 1291 1.1 christos static int ssl_print_certificate(BIO *bio, const SSL_CONNECTION *sc, int indent, 1292 1.1.1.2 christos const unsigned char **pmsg, size_t *pmsglen) 1293 1.1 christos { 1294 1.1 christos size_t msglen = *pmsglen; 1295 1.1 christos size_t clen; 1296 1.1 christos X509 *x; 1297 1.1 christos const unsigned char *p = *pmsg, *q; 1298 1.1 christos SSL_CTX *ctx = SSL_CONNECTION_GET_CTX(sc); 1299 1.1 christos 1300 1.1 christos if (msglen < 3) 1301 1.1 christos return 0; 1302 1.1 christos clen = (p[0] << 16) | (p[1] << 8) | p[2]; 1303 1.1 christos if (msglen < clen + 3) 1304 1.1 christos return 0; 1305 1.1 christos q = p + 3; 1306 1.1 christos BIO_indent(bio, indent, 80); 1307 1.1 christos BIO_printf(bio, "ASN.1Cert, length=%d", (int)clen); 1308 1.1 christos x = X509_new_ex(ctx->libctx, ctx->propq); 1309 1.1 christos if (x != NULL && d2i_X509(&x, &q, clen) == NULL) { 1310 1.1 christos X509_free(x); 1311 1.1 christos x = NULL; 1312 1.1 christos } 1313 1.1.1.2 christos if (x == NULL) 1314 1.1.1.2 christos BIO_puts(bio, "<UNPARSABLE CERTIFICATE>\n"); 1315 1.1 christos else { 1316 1.1 christos BIO_puts(bio, "\n------details-----\n"); 1317 1.1 christos X509_print_ex(bio, x, XN_FLAG_ONELINE, 0); 1318 1.1 christos PEM_write_bio_X509(bio, x); 1319 1.1 christos /* Print certificate stuff */ 1320 1.1 christos BIO_puts(bio, "------------------\n"); 1321 1.1 christos X509_free(x); 1322 1.1 christos } 1323 1.1 christos if (q != p + 3 + clen) { 1324 1.1 christos BIO_puts(bio, "<TRAILING GARBAGE AFTER CERTIFICATE>\n"); 1325 1.1 christos } 1326 1.1 christos *pmsg += clen + 3; 1327 1.1 christos *pmsglen -= clen + 3; 1328 1.1 christos return 1; 1329 1.1 christos } 1330 1.1 christos 1331 1.1 christos static int ssl_print_raw_public_key(BIO *bio, const SSL *ssl, int server, 1332 1.1.1.2 christos int indent, const unsigned char **pmsg, 1333 1.1.1.2 christos size_t *pmsglen) 1334 1.1 christos { 1335 1.1 christos EVP_PKEY *pkey; 1336 1.1 christos size_t clen; 1337 1.1 christos const unsigned char *msg = *pmsg; 1338 1.1 christos size_t msglen = *pmsglen; 1339 1.1 christos 1340 1.1 christos if (msglen < 3) 1341 1.1 christos return 0; 1342 1.1 christos clen = (msg[0] << 16) | (msg[1] << 8) | msg[2]; 1343 1.1 christos if (msglen < clen + 3) 1344 1.1 christos return 0; 1345 1.1 christos 1346 1.1 christos msg += 3; 1347 1.1 christos 1348 1.1 christos BIO_indent(bio, indent, 80); 1349 1.1 christos BIO_printf(bio, "raw_public_key, length=%d\n", (int)clen); 1350 1.1 christos 1351 1.1 christos pkey = d2i_PUBKEY_ex(NULL, &msg, clen, ssl->ctx->libctx, ssl->ctx->propq); 1352 1.1 christos if (pkey == NULL) 1353 1.1 christos return 0; 1354 1.1 christos EVP_PKEY_print_public(bio, pkey, indent + 2, NULL); 1355 1.1 christos EVP_PKEY_free(pkey); 1356 1.1 christos *pmsg += clen + 3; 1357 1.1 christos *pmsglen -= clen + 3; 1358 1.1 christos return 1; 1359 1.1 christos } 1360 1.1 christos 1361 1.1 christos static int ssl_print_certificates(BIO *bio, const SSL_CONNECTION *sc, int server, 1362 1.1.1.2 christos int indent, const unsigned char *msg, 1363 1.1.1.2 christos size_t msglen) 1364 1.1 christos { 1365 1.1 christos size_t clen; 1366 1.1 christos 1367 1.1 christos if (SSL_CONNECTION_IS_TLS13(sc) 1368 1.1.1.2 christos && !ssl_print_hexbuf(bio, indent, "context", 1, &msg, &msglen)) 1369 1.1 christos return 0; 1370 1.1 christos 1371 1.1 christos if (msglen < 3) 1372 1.1 christos return 0; 1373 1.1 christos clen = (msg[0] << 16) | (msg[1] << 8) | msg[2]; 1374 1.1 christos if (msglen != clen + 3) 1375 1.1 christos return 0; 1376 1.1 christos msg += 3; 1377 1.1 christos if ((server && sc->ext.server_cert_type == TLSEXT_cert_type_rpk) 1378 1.1.1.2 christos || (!server && sc->ext.client_cert_type == TLSEXT_cert_type_rpk)) { 1379 1.1 christos if (!ssl_print_raw_public_key(bio, &sc->ssl, server, indent, &msg, &clen)) 1380 1.1 christos return 0; 1381 1.1 christos if (SSL_CONNECTION_IS_TLS13(sc) 1382 1.1 christos && !ssl_print_extensions(bio, indent + 2, server, 1383 1.1.1.2 christos SSL3_MT_CERTIFICATE, &msg, &clen)) 1384 1.1 christos return 0; 1385 1.1 christos return 1; 1386 1.1 christos } 1387 1.1 christos BIO_indent(bio, indent, 80); 1388 1.1 christos BIO_printf(bio, "certificate_list, length=%d\n", (int)clen); 1389 1.1 christos while (clen > 0) { 1390 1.1 christos if (!ssl_print_certificate(bio, sc, indent + 2, &msg, &clen)) 1391 1.1 christos return 0; 1392 1.1 christos if (SSL_CONNECTION_IS_TLS13(sc) 1393 1.1 christos && !ssl_print_extensions(bio, indent + 2, server, 1394 1.1.1.2 christos SSL3_MT_CERTIFICATE, &msg, &clen)) 1395 1.1 christos return 0; 1396 1.1 christos } 1397 1.1 christos return 1; 1398 1.1 christos } 1399 1.1 christos 1400 1.1 christos static int ssl_print_compressed_certificates(BIO *bio, const SSL_CONNECTION *sc, 1401 1.1.1.2 christos int server, int indent, 1402 1.1.1.2 christos const unsigned char *msg, 1403 1.1.1.2 christos size_t msglen) 1404 1.1 christos { 1405 1.1 christos size_t uclen; 1406 1.1 christos size_t clen; 1407 1.1 christos unsigned int alg; 1408 1.1 christos int ret = 1; 1409 1.1 christos #ifndef OPENSSL_NO_COMP_ALG 1410 1.1 christos COMP_METHOD *method; 1411 1.1 christos COMP_CTX *comp = NULL; 1412 1.1.1.2 christos unsigned char *ucdata = NULL; 1413 1.1 christos #endif 1414 1.1 christos 1415 1.1 christos if (msglen < 8) 1416 1.1 christos return 0; 1417 1.1 christos 1418 1.1 christos alg = (msg[0] << 8) | msg[1]; 1419 1.1 christos uclen = (msg[2] << 16) | (msg[3] << 8) | msg[4]; 1420 1.1 christos clen = (msg[5] << 16) | (msg[6] << 8) | msg[7]; 1421 1.1 christos if (msglen != clen + 8) 1422 1.1 christos return 0; 1423 1.1 christos 1424 1.1 christos msg += 8; 1425 1.1 christos BIO_indent(bio, indent, 80); 1426 1.1 christos BIO_printf(bio, "Compression type=%s (0x%04x)\n", ssl_trace_str(alg, ssl_comp_cert_tbl), alg); 1427 1.1 christos BIO_indent(bio, indent, 80); 1428 1.1 christos BIO_printf(bio, "Uncompressed length=%d\n", (int)uclen); 1429 1.1 christos BIO_indent(bio, indent, 80); 1430 1.1 christos if (clen > 0) 1431 1.1 christos BIO_printf(bio, "Compressed length=%d, Ratio=%f:1\n", (int)clen, (float)uclen / (float)clen); 1432 1.1 christos else 1433 1.1 christos BIO_printf(bio, "Compressed length=%d, Ratio=unknown\n", (int)clen); 1434 1.1 christos 1435 1.1 christos BIO_dump_indent(bio, (const char *)msg, clen, indent); 1436 1.1 christos 1437 1.1 christos #ifndef OPENSSL_NO_COMP_ALG 1438 1.1 christos if (!ossl_comp_has_alg(alg)) 1439 1.1 christos return 0; 1440 1.1 christos 1441 1.1 christos /* Check against certificate maximum size (coverity) */ 1442 1.1 christos if (uclen == 0 || uclen > 0xFFFFFF || (ucdata = OPENSSL_malloc(uclen)) == NULL) 1443 1.1 christos return 0; 1444 1.1 christos 1445 1.1 christos switch (alg) { 1446 1.1 christos case TLSEXT_comp_cert_zlib: 1447 1.1 christos method = COMP_zlib(); 1448 1.1 christos break; 1449 1.1 christos case TLSEXT_comp_cert_brotli: 1450 1.1 christos method = COMP_brotli_oneshot(); 1451 1.1 christos break; 1452 1.1 christos case TLSEXT_comp_cert_zstd: 1453 1.1 christos method = COMP_zstd_oneshot(); 1454 1.1 christos break; 1455 1.1 christos default: 1456 1.1 christos goto err; 1457 1.1 christos } 1458 1.1 christos 1459 1.1 christos if ((comp = COMP_CTX_new(method)) == NULL 1460 1.1.1.2 christos || COMP_expand_block(comp, ucdata, uclen, (unsigned char *)msg, clen) != (int)uclen) 1461 1.1 christos goto err; 1462 1.1 christos 1463 1.1 christos ret = ssl_print_certificates(bio, sc, server, indent, ucdata, uclen); 1464 1.1.1.2 christos err: 1465 1.1 christos COMP_CTX_free(comp); 1466 1.1 christos OPENSSL_free(ucdata); 1467 1.1 christos #endif 1468 1.1 christos return ret; 1469 1.1 christos } 1470 1.1 christos 1471 1.1 christos static int ssl_print_cert_request(BIO *bio, int indent, const SSL_CONNECTION *sc, 1472 1.1.1.2 christos const unsigned char *msg, size_t msglen) 1473 1.1 christos { 1474 1.1 christos size_t xlen; 1475 1.1 christos unsigned int sigalg; 1476 1.1 christos 1477 1.1 christos if (SSL_CONNECTION_IS_TLS13(sc)) { 1478 1.1 christos if (!ssl_print_hexbuf(bio, indent, "request_context", 1, &msg, &msglen)) 1479 1.1 christos return 0; 1480 1.1 christos if (!ssl_print_extensions(bio, indent, 1, 1481 1.1.1.2 christos SSL3_MT_CERTIFICATE_REQUEST, &msg, &msglen)) 1482 1.1 christos return 0; 1483 1.1 christos return 1; 1484 1.1 christos } else { 1485 1.1 christos if (msglen < 1) 1486 1.1 christos return 0; 1487 1.1 christos xlen = msg[0]; 1488 1.1 christos if (msglen < xlen + 1) 1489 1.1 christos return 0; 1490 1.1 christos msg++; 1491 1.1 christos BIO_indent(bio, indent, 80); 1492 1.1 christos BIO_printf(bio, "certificate_types (len=%d)\n", (int)xlen); 1493 1.1 christos if (!ssl_trace_list(bio, indent + 2, msg, xlen, 1, ssl_ctype_tbl)) 1494 1.1 christos return 0; 1495 1.1 christos msg += xlen; 1496 1.1 christos msglen -= xlen + 1; 1497 1.1 christos } 1498 1.1 christos if (SSL_USE_SIGALGS(sc)) { 1499 1.1 christos if (msglen < 2) 1500 1.1 christos return 0; 1501 1.1 christos xlen = (msg[0] << 8) | msg[1]; 1502 1.1 christos if (msglen < xlen + 2 || (xlen & 1)) 1503 1.1 christos return 0; 1504 1.1 christos msg += 2; 1505 1.1 christos msglen -= xlen + 2; 1506 1.1 christos BIO_indent(bio, indent, 80); 1507 1.1 christos BIO_printf(bio, "signature_algorithms (len=%d)\n", (int)xlen); 1508 1.1 christos while (xlen > 0) { 1509 1.1 christos BIO_indent(bio, indent + 2, 80); 1510 1.1 christos sigalg = (msg[0] << 8) | msg[1]; 1511 1.1 christos BIO_printf(bio, "%s (0x%04x)\n", 1512 1.1.1.2 christos ssl_trace_str(sigalg, ssl_sigalg_tbl), sigalg); 1513 1.1 christos xlen -= 2; 1514 1.1 christos msg += 2; 1515 1.1 christos } 1516 1.1 christos msg += xlen; 1517 1.1 christos } 1518 1.1 christos 1519 1.1 christos if (msglen < 2) 1520 1.1 christos return 0; 1521 1.1 christos xlen = (msg[0] << 8) | msg[1]; 1522 1.1 christos BIO_indent(bio, indent, 80); 1523 1.1 christos if (msglen < xlen + 2) 1524 1.1 christos return 0; 1525 1.1 christos msg += 2; 1526 1.1 christos msglen -= 2 + xlen; 1527 1.1 christos BIO_printf(bio, "certificate_authorities (len=%d)\n", (int)xlen); 1528 1.1 christos while (xlen > 0) { 1529 1.1 christos size_t dlen; 1530 1.1 christos X509_NAME *nm; 1531 1.1 christos const unsigned char *p; 1532 1.1 christos if (xlen < 2) 1533 1.1 christos return 0; 1534 1.1 christos dlen = (msg[0] << 8) | msg[1]; 1535 1.1 christos if (xlen < dlen + 2) 1536 1.1 christos return 0; 1537 1.1 christos msg += 2; 1538 1.1 christos BIO_indent(bio, indent + 2, 80); 1539 1.1 christos BIO_printf(bio, "DistinguishedName (len=%d): ", (int)dlen); 1540 1.1 christos p = msg; 1541 1.1 christos nm = d2i_X509_NAME(NULL, &p, dlen); 1542 1.1 christos if (!nm) { 1543 1.1.1.2 christos BIO_puts(bio, "<UNPARSABLE DN>\n"); 1544 1.1 christos } else { 1545 1.1 christos X509_NAME_print_ex(bio, nm, 0, XN_FLAG_ONELINE); 1546 1.1 christos BIO_puts(bio, "\n"); 1547 1.1 christos X509_NAME_free(nm); 1548 1.1 christos } 1549 1.1 christos xlen -= dlen + 2; 1550 1.1 christos msg += dlen; 1551 1.1 christos } 1552 1.1 christos if (SSL_CONNECTION_IS_TLS13(sc)) { 1553 1.1 christos if (!ssl_print_hexbuf(bio, indent, "request_extensions", 2, 1554 1.1.1.2 christos &msg, &msglen)) 1555 1.1 christos return 0; 1556 1.1 christos } 1557 1.1 christos return msglen == 0; 1558 1.1 christos } 1559 1.1 christos 1560 1.1 christos static int ssl_print_ticket(BIO *bio, int indent, const SSL_CONNECTION *sc, 1561 1.1.1.2 christos const unsigned char *msg, size_t msglen) 1562 1.1 christos { 1563 1.1 christos unsigned int tick_life; 1564 1.1 christos 1565 1.1 christos if (msglen == 0) { 1566 1.1 christos BIO_indent(bio, indent + 2, 80); 1567 1.1 christos BIO_puts(bio, "No Ticket\n"); 1568 1.1 christos return 1; 1569 1.1 christos } 1570 1.1 christos if (msglen < 4) 1571 1.1 christos return 0; 1572 1.1 christos tick_life = ((unsigned int)msg[0] << 24) 1573 1.1.1.2 christos | ((unsigned int)msg[1] << 16) 1574 1.1.1.2 christos | ((unsigned int)msg[2] << 8) 1575 1.1.1.2 christos | (unsigned int)msg[3]; 1576 1.1 christos msglen -= 4; 1577 1.1 christos msg += 4; 1578 1.1 christos BIO_indent(bio, indent + 2, 80); 1579 1.1 christos BIO_printf(bio, "ticket_lifetime_hint=%u\n", tick_life); 1580 1.1 christos if (SSL_CONNECTION_IS_TLS13(sc)) { 1581 1.1 christos unsigned int ticket_age_add; 1582 1.1 christos 1583 1.1 christos if (msglen < 4) 1584 1.1 christos return 0; 1585 1.1.1.2 christos ticket_age_add = ((unsigned int)msg[0] << 24) 1586 1.1 christos | ((unsigned int)msg[1] << 16) 1587 1.1 christos | ((unsigned int)msg[2] << 8) 1588 1.1 christos | (unsigned int)msg[3]; 1589 1.1 christos msglen -= 4; 1590 1.1 christos msg += 4; 1591 1.1 christos BIO_indent(bio, indent + 2, 80); 1592 1.1 christos BIO_printf(bio, "ticket_age_add=%u\n", ticket_age_add); 1593 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "ticket_nonce", 1, &msg, 1594 1.1.1.2 christos &msglen)) 1595 1.1 christos return 0; 1596 1.1 christos } 1597 1.1 christos if (!ssl_print_hexbuf(bio, indent + 2, "ticket", 2, &msg, &msglen)) 1598 1.1 christos return 0; 1599 1.1 christos if (SSL_CONNECTION_IS_TLS13(sc) 1600 1.1.1.2 christos && !ssl_print_extensions(bio, indent + 2, 0, 1601 1.1.1.2 christos SSL3_MT_NEWSESSION_TICKET, &msg, &msglen)) 1602 1.1 christos return 0; 1603 1.1 christos if (msglen) 1604 1.1 christos return 0; 1605 1.1 christos return 1; 1606 1.1 christos } 1607 1.1 christos 1608 1.1 christos static int ssl_print_handshake(BIO *bio, const SSL_CONNECTION *sc, int server, 1609 1.1.1.2 christos const unsigned char *msg, size_t msglen, 1610 1.1.1.2 christos int indent) 1611 1.1 christos { 1612 1.1 christos size_t hlen; 1613 1.1 christos unsigned char htype; 1614 1.1 christos 1615 1.1 christos if (msglen < 4) 1616 1.1 christos return 0; 1617 1.1 christos htype = msg[0]; 1618 1.1 christos hlen = (msg[1] << 16) | (msg[2] << 8) | msg[3]; 1619 1.1 christos BIO_indent(bio, indent, 80); 1620 1.1 christos BIO_printf(bio, "%s, Length=%d\n", 1621 1.1.1.2 christos ssl_trace_str(htype, ssl_handshake_tbl), (int)hlen); 1622 1.1 christos msg += 4; 1623 1.1 christos msglen -= 4; 1624 1.1 christos if (SSL_CONNECTION_IS_DTLS(sc)) { 1625 1.1 christos if (msglen < 8) 1626 1.1 christos return 0; 1627 1.1 christos BIO_indent(bio, indent, 80); 1628 1.1 christos BIO_printf(bio, "message_seq=%d, fragment_offset=%d, " 1629 1.1.1.2 christos "fragment_length=%d\n", 1630 1.1.1.2 christos (msg[0] << 8) | msg[1], 1631 1.1.1.2 christos (msg[2] << 16) | (msg[3] << 8) | msg[4], 1632 1.1.1.2 christos (msg[5] << 16) | (msg[6] << 8) | msg[7]); 1633 1.1 christos msg += 8; 1634 1.1 christos msglen -= 8; 1635 1.1 christos } 1636 1.1 christos if (msglen < hlen) 1637 1.1 christos return 0; 1638 1.1 christos switch (htype) { 1639 1.1 christos case SSL3_MT_CLIENT_HELLO: 1640 1.1 christos if (!ssl_print_client_hello(bio, sc, indent + 2, msg, msglen)) 1641 1.1 christos return 0; 1642 1.1 christos break; 1643 1.1 christos 1644 1.1 christos case DTLS1_MT_HELLO_VERIFY_REQUEST: 1645 1.1 christos if (!dtls_print_hello_vfyrequest(bio, indent + 2, msg, msglen)) 1646 1.1 christos return 0; 1647 1.1 christos break; 1648 1.1 christos 1649 1.1 christos case SSL3_MT_SERVER_HELLO: 1650 1.1 christos if (!ssl_print_server_hello(bio, indent + 2, msg, msglen)) 1651 1.1 christos return 0; 1652 1.1 christos break; 1653 1.1 christos 1654 1.1 christos case SSL3_MT_SERVER_KEY_EXCHANGE: 1655 1.1 christos if (!ssl_print_server_keyex(bio, indent + 2, sc, msg, msglen)) 1656 1.1 christos return 0; 1657 1.1 christos break; 1658 1.1 christos 1659 1.1 christos case SSL3_MT_CLIENT_KEY_EXCHANGE: 1660 1.1 christos if (!ssl_print_client_keyex(bio, indent + 2, sc, msg, msglen)) 1661 1.1 christos return 0; 1662 1.1 christos break; 1663 1.1 christos 1664 1.1 christos case SSL3_MT_CERTIFICATE: 1665 1.1 christos if (!ssl_print_certificates(bio, sc, server, indent + 2, msg, msglen)) 1666 1.1 christos return 0; 1667 1.1 christos break; 1668 1.1 christos 1669 1.1 christos case SSL3_MT_COMPRESSED_CERTIFICATE: 1670 1.1 christos if (!ssl_print_compressed_certificates(bio, sc, server, indent + 2, msg, msglen)) 1671 1.1 christos return 0; 1672 1.1 christos break; 1673 1.1 christos 1674 1.1 christos case SSL3_MT_CERTIFICATE_VERIFY: 1675 1.1 christos if (!ssl_print_signature(bio, indent + 2, sc, &msg, &msglen)) 1676 1.1 christos return 0; 1677 1.1 christos break; 1678 1.1 christos 1679 1.1 christos case SSL3_MT_CERTIFICATE_REQUEST: 1680 1.1 christos if (!ssl_print_cert_request(bio, indent + 2, sc, msg, msglen)) 1681 1.1 christos return 0; 1682 1.1 christos break; 1683 1.1 christos 1684 1.1 christos case SSL3_MT_FINISHED: 1685 1.1 christos ssl_print_hex(bio, indent + 2, "verify_data", msg, msglen); 1686 1.1 christos break; 1687 1.1 christos 1688 1.1 christos case SSL3_MT_END_OF_EARLY_DATA: 1689 1.1 christos case SSL3_MT_SERVER_DONE: 1690 1.1 christos if (msglen != 0) 1691 1.1 christos ssl_print_hex(bio, indent + 2, "unexpected value", msg, msglen); 1692 1.1 christos break; 1693 1.1 christos 1694 1.1 christos case SSL3_MT_NEWSESSION_TICKET: 1695 1.1 christos if (!ssl_print_ticket(bio, indent + 2, sc, msg, msglen)) 1696 1.1 christos return 0; 1697 1.1 christos break; 1698 1.1 christos 1699 1.1 christos case SSL3_MT_ENCRYPTED_EXTENSIONS: 1700 1.1 christos if (!ssl_print_extensions(bio, indent + 2, 1, 1701 1.1.1.2 christos SSL3_MT_ENCRYPTED_EXTENSIONS, &msg, &msglen)) 1702 1.1 christos return 0; 1703 1.1 christos break; 1704 1.1 christos 1705 1.1 christos case SSL3_MT_KEY_UPDATE: 1706 1.1 christos if (msglen != 1) { 1707 1.1 christos ssl_print_hex(bio, indent + 2, "unexpected value", msg, msglen); 1708 1.1 christos return 0; 1709 1.1 christos } 1710 1.1 christos if (!ssl_trace_list(bio, indent + 2, msg, msglen, 1, 1711 1.1.1.2 christos ssl_key_update_tbl)) 1712 1.1 christos return 0; 1713 1.1 christos break; 1714 1.1 christos 1715 1.1 christos default: 1716 1.1 christos BIO_indent(bio, indent + 2, 80); 1717 1.1 christos BIO_puts(bio, "Unsupported, hex dump follows:\n"); 1718 1.1 christos BIO_dump_indent(bio, (const char *)msg, msglen, indent + 4); 1719 1.1 christos } 1720 1.1 christos return 1; 1721 1.1 christos } 1722 1.1 christos 1723 1.1 christos void SSL_trace(int write_p, int version, int content_type, 1724 1.1.1.2 christos const void *buf, size_t msglen, SSL *ssl, void *arg) 1725 1.1 christos { 1726 1.1 christos const unsigned char *msg = buf; 1727 1.1 christos BIO *bio = arg; 1728 1.1 christos SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(ssl); 1729 1.1 christos #ifndef OPENSSL_NO_QUIC 1730 1.1 christos QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_SSL(ssl); 1731 1.1 christos 1732 1.1 christos if (qc != NULL) { 1733 1.1 christos if (ossl_quic_trace(write_p, version, content_type, buf, msglen, ssl, 1734 1.1.1.2 christos arg)) 1735 1.1 christos return; 1736 1.1 christos /* 1737 1.1 christos * Otherwise ossl_quic_trace didn't handle this content_type so we 1738 1.1 christos * fallback to standard TLS handling 1739 1.1 christos */ 1740 1.1 christos } 1741 1.1 christos #endif 1742 1.1 christos 1743 1.1 christos if (sc == NULL) 1744 1.1 christos return; 1745 1.1 christos 1746 1.1 christos switch (content_type) { 1747 1.1.1.2 christos case SSL3_RT_HEADER: { 1748 1.1.1.2 christos int hvers; 1749 1.1 christos 1750 1.1.1.2 christos /* avoid overlapping with length at the end of buffer */ 1751 1.1.1.2 christos if (msglen < (size_t)(SSL_CONNECTION_IS_DTLS(sc) ? DTLS1_RT_HEADER_LENGTH : SSL3_RT_HEADER_LENGTH)) { 1752 1.1.1.2 christos BIO_puts(bio, write_p ? "Sent" : "Received"); 1753 1.1.1.2 christos ssl_print_hex(bio, 0, " too short message", msg, msglen); 1754 1.1.1.2 christos break; 1755 1.1 christos } 1756 1.1.1.2 christos hvers = msg[1] << 8 | msg[2]; 1757 1.1.1.2 christos BIO_puts(bio, write_p ? "Sent" : "Received"); 1758 1.1.1.2 christos BIO_printf(bio, " TLS Record\nHeader:\n Version = %s (0x%x)\n", 1759 1.1.1.2 christos ssl_trace_str(hvers, ssl_version_tbl), hvers); 1760 1.1.1.2 christos if (SSL_CONNECTION_IS_DTLS(sc)) { 1761 1.1.1.2 christos BIO_printf(bio, 1762 1.1.1.2 christos " epoch=%d, sequence_number=%04x%04x%04x\n", 1763 1.1.1.2 christos (msg[3] << 8 | msg[4]), 1764 1.1.1.2 christos (msg[5] << 8 | msg[6]), 1765 1.1.1.2 christos (msg[7] << 8 | msg[8]), (msg[9] << 8 | msg[10])); 1766 1.1.1.2 christos } 1767 1.1.1.2 christos 1768 1.1.1.2 christos BIO_printf(bio, " Content Type = %s (%d)\n Length = %d", 1769 1.1.1.2 christos ssl_trace_str(msg[0], ssl_content_tbl), msg[0], 1770 1.1.1.2 christos msg[msglen - 2] << 8 | msg[msglen - 1]); 1771 1.1.1.2 christos } break; 1772 1.1 christos 1773 1.1 christos case SSL3_RT_INNER_CONTENT_TYPE: 1774 1.1 christos BIO_printf(bio, " Inner Content Type = %s (%d)", 1775 1.1.1.2 christos ssl_trace_str(msg[0], ssl_content_tbl), msg[0]); 1776 1.1 christos break; 1777 1.1 christos 1778 1.1 christos case SSL3_RT_HANDSHAKE: 1779 1.1 christos if (!ssl_print_handshake(bio, sc, sc->server ? write_p : !write_p, 1780 1.1.1.2 christos msg, msglen, 4)) 1781 1.1 christos BIO_printf(bio, "Message length parse error!\n"); 1782 1.1 christos break; 1783 1.1 christos 1784 1.1 christos case SSL3_RT_CHANGE_CIPHER_SPEC: 1785 1.1 christos if (msglen == 1 && msg[0] == 1) 1786 1.1 christos BIO_puts(bio, " change_cipher_spec (1)\n"); 1787 1.1 christos else 1788 1.1 christos ssl_print_hex(bio, 4, "unknown value", msg, msglen); 1789 1.1 christos break; 1790 1.1 christos 1791 1.1 christos case SSL3_RT_ALERT: 1792 1.1 christos if (msglen != 2) 1793 1.1 christos BIO_puts(bio, " Illegal Alert Length\n"); 1794 1.1 christos else { 1795 1.1 christos BIO_printf(bio, " Level=%s(%d), description=%s(%d)\n", 1796 1.1.1.2 christos SSL_alert_type_string_long(msg[0] << 8), 1797 1.1.1.2 christos msg[0], SSL_alert_desc_string_long(msg[1]), msg[1]); 1798 1.1 christos } 1799 1.1 christos } 1800 1.1 christos 1801 1.1 christos BIO_puts(bio, "\n"); 1802 1.1 christos } 1803 1.1 christos 1804 1.1 christos #endif 1805