1 /* * eap-tls.c - EAP-TLS implementation for PPP
3 * Copyright (c) Beniamino Galvani 2005 All rights reserved.
4 * Jan Just Keijser 2006-2019 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
18 * 3. The name(s) of the authors of this software must not be used to
19 * endorse or promote products derived from this software without
20 * prior written permission.
22 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
23 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
25 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
26 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
27 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
28 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
39 #include <sys/types.h>
43 #include <openssl/conf.h>
44 #ifndef OPENSSL_NO_ENGINE
45 #include <openssl/engine.h>
47 #include <openssl/ssl.h>
48 #include <openssl/hmac.h>
49 #include <openssl/err.h>
50 #include <openssl/ui.h>
51 #include <openssl/x509v3.h>
52 #include <openssl/pkcs12.h>
62 #include "pathnames.h"
64 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
65 #define SSL3_RT_HEADER 0x100
68 typedef struct pw_cb_data
71 const char *prompt_info;
74 #ifndef OPENSSL_NO_ENGINE
75 /* The openssl configuration file and engines can be loaded only once */
76 static CONF *ssl_config = NULL;
77 static ENGINE *cert_engine = NULL;
78 static ENGINE *pkey_engine = NULL;
81 /* TLSv1.3 do we have a session ticket ? */
82 static int have_session_ticket = 0;
84 void ssl_msg_callback(int write_p, int version, int ct, const void *buf,
85 size_t len, SSL * ssl, void *arg);
86 int ssl_new_session_cb(SSL *s, SSL_SESSION *sess);
89 #define EAPTLS_MPPE_KEY_LEN 32
92 * Generate keys according to RFC 2716 and add to reply
94 void eaptls_gen_mppe_keys(struct eaptls_session *ets, int client)
96 unsigned char out[4*EAPTLS_MPPE_KEY_LEN];
97 const char *prf_label;
99 unsigned char eap_tls13_context[] = { EAPT_TLS };
100 unsigned char *context = NULL;
101 size_t context_len = 0;
104 dbglog("EAP-TLS generating MPPE keys");
107 prf_label = "EXPORTER_EAP_TLS_Key_Material";
108 context = eap_tls13_context;
113 prf_label = "client EAP encryption";
116 dbglog("EAP-TLS PRF label = %s", prf_label);
117 prf_size = strlen(prf_label);
118 if (SSL_export_keying_material(ets->ssl, out, sizeof(out), prf_label, prf_size,
119 context, context_len, 0) != 1)
121 warn( "EAP-TLS: Failed generating keying material" );
126 * We now have the master send and receive keys.
127 * From these, generate the session send and receive keys.
128 * (see RFC3079 / draft-ietf-pppext-mppe-keys-03.txt for details)
132 mppe_set_keys(out, out + EAPTLS_MPPE_KEY_LEN, EAPTLS_MPPE_KEY_LEN);
136 mppe_set_keys(out + EAPTLS_MPPE_KEY_LEN, out, EAPTLS_MPPE_KEY_LEN);
140 #endif /* PPP_WITH_MPPE */
142 int password_callback (char *buf, int size, int rwflag, void *u)
146 strlcpy (buf, passwd, size);
153 CONF *eaptls_ssl_load_config( void )
157 long error_line = 33;
159 config = NCONF_new( NULL );
160 dbglog( "Loading OpenSSL config file" );
161 ret_code = NCONF_load( config, PPP_PATH_OPENSSLCONFFILE, &error_line );
164 warn( "EAP-TLS: Error in OpenSSL config file %s at line %d", PPP_PATH_OPENSSLCONFFILE, error_line );
165 NCONF_free( config );
170 dbglog( "Loading OpenSSL built-ins" );
171 #ifndef OPENSSL_NO_ENGINE
172 ENGINE_load_builtin_engines();
174 OPENSSL_load_builtin_modules();
176 dbglog( "Loading OpenSSL configured modules" );
177 if (CONF_modules_load( config, NULL, 0 ) <= 0 )
179 warn( "EAP-TLS: Error loading OpenSSL modules" );
187 #ifndef OPENSSL_NO_ENGINE
188 ENGINE *eaptls_ssl_load_engine( char *engine_name )
192 dbglog( "Enabling OpenSSL auto engines" );
193 ENGINE_register_all_complete();
195 dbglog( "Loading OpenSSL '%s' engine support", engine_name );
196 e = ENGINE_by_id( engine_name );
199 dbglog( "EAP-TLS: Cannot load '%s' engine support, trying 'dynamic'", engine_name );
200 e = ENGINE_by_id( "dynamic" );
203 if (!ENGINE_ctrl_cmd_string(e, "SO_PATH", engine_name, 0)
204 || !ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0))
206 warn( "EAP-TLS: Error loading dynamic engine '%s'", engine_name );
214 warn( "EAP-TLS: Cannot load dynamic engine support" );
220 dbglog( "Initialising engine" );
221 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
223 warn( "EAP-TLS: Cannot use that engine" );
235 #ifndef OPENSSL_NO_ENGINE
236 static int eaptls_UI_writer(UI *ui, UI_STRING *uis)
238 PW_CB_DATA* cb_data = (PW_CB_DATA*)UI_get0_user_data(ui);
239 UI_set_result(ui, uis, cb_data->password);
243 static int eaptls_UI_stub(UI* ui) {
247 static int eaptls_UI_reader(UI *ui, UI_STRING *uis) {
253 * Initialize the SSL stacks and tests if certificates, key and crl
254 * for client or server use can be loaded.
256 SSL_CTX *eaptls_init_ssl(int init_server, char *cacertfile, char *capath,
257 char *certfile, char *privkeyfile, char *pkcs12)
259 #ifndef OPENSSL_NO_ENGINE
260 char *cert_engine_name = NULL;
261 char *pkey_engine_name = NULL;
269 EVP_PKEY *pkey = NULL;
270 STACK_OF(X509) *chain = NULL;
276 * Without these can't continue
280 if (!(cacertfile[0] || capath[0]))
282 error("EAP-TLS: CA certificate file or path missing");
288 error("EAP-TLS: Certificate missing");
294 error("EAP-TLS: Private key missing");
301 #ifndef OPENSSL_NO_ENGINE
302 /* load the openssl config file only once and load it before triggering
303 the loading of a global openssl config file via SSL_CTX_new()
306 ssl_config = eaptls_ssl_load_config();
309 ctx = SSL_CTX_new(tls_method());
311 error("EAP-TLS: Cannot initialize SSL CTX context");
315 #ifndef OPENSSL_NO_ENGINE
316 /* if the certificate filename is of the form engine:id. e.g.
318 then we try to load and use this engine.
319 If the certificate filename starts with a / or . then we
320 ALWAYS assume it is a file and not an engine/pkcs11 identifier
322 if ( (idx = index( certfile, ':' )) != NULL )
324 cert_engine_name = strdup( certfile );
325 cert_engine_name[idx - certfile] = 0;
327 dbglog( "Using engine '%s' for certificate, URI: '%s'",
328 cert_engine_name, certfile );
331 /* if the privatekey filename is of the form engine:id. e.g.
333 then we try to load and use this engine.
334 If the privatekey filename starts with a / or . then we
335 ALWAYS assume it is a file and not an engine/pkcs11 identifier
337 if ( (idx = index( privkeyfile, ':' )) != NULL )
339 pkey_engine_name = strdup( privkeyfile );
340 pkey_engine_name[idx - privkeyfile] = 0;
342 dbglog( "Using engine '%s' for private key, URI: '%s'",
343 pkey_engine_name, privkeyfile );
346 if (cert_engine_name && pkey_engine_name)
348 if (strlen( certfile ) - strlen( cert_engine_name ) == 1)
350 if (strlen( privkeyfile ) - strlen( pkey_engine_name ) == 1)
351 error( "EAP-TLS: both the certificate and privatekey identifiers are missing!" );
354 dbglog( "Substituting privatekey identifier for certificate identifier" );
355 certfile = privkeyfile;
360 if (strlen( privkeyfile ) - strlen( pkey_engine_name ) == 1)
362 dbglog( "Substituting certificate identifier for privatekey identifier" );
363 privkeyfile = certfile;
368 if (ssl_config && cert_engine_name)
369 cert_engine = eaptls_ssl_load_engine( cert_engine_name );
371 if (ssl_config && pkey_engine_name)
373 /* don't load the same engine twice */
374 if ( cert_engine && strcmp( cert_engine_name, pkey_engine_name) == 0 )
375 pkey_engine = cert_engine;
377 pkey_engine = eaptls_ssl_load_engine( pkey_engine_name );
380 if (cert_engine_name)
381 free(cert_engine_name);
383 if (pkey_engine_name)
384 free(pkey_engine_name);
388 SSL_CTX_set_default_passwd_cb (ctx, password_callback);
390 if (tls_set_ca(ctx, capath, cacertfile) != 0) {
395 SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(cacertfile));
397 #ifndef OPENSSL_NO_ENGINE
402 const char *s_slot_cert_id;
406 cert_info.s_slot_cert_id = certfile;
407 cert_info.cert = NULL;
409 if (!ENGINE_ctrl_cmd( cert_engine, "LOAD_CERT_CTRL", 0, &cert_info, NULL, 0 ) )
411 error( "EAP-TLS: Error loading certificate with URI '%s' from engine", certfile );
417 dbglog( "Got the certificate" );
418 dbglog( "subject = %s", X509_NAME_oneline( X509_get_subject_name( cert_info.cert ), NULL, 0 ) );
419 cert = cert_info.cert;
423 warn("EAP-TLS: Cannot load key with URI: '%s'", certfile );
432 input = BIO_new_file(pkcs12, "r");
435 error("EAP-TLS: Cannot open `%s' PKCS12 for input", pkcs12);
439 p12 = d2i_PKCS12_bio(input, NULL);
443 error("EAP-TLS: Cannot load PKCS12 certificate");
447 if (PKCS12_parse(p12, passwd, &pkey, &cert, &chain) != 1)
449 error("EAP-TLS: Cannot parse PKCS12 certificate, invalid password");
458 if (!SSL_CTX_use_certificate_chain_file(ctx, certfile))
460 error( "EAP-TLS: Cannot load certificate %s", certfile );
468 if (!SSL_CTX_use_certificate(ctx, cert))
470 error("EAP-TLS: Cannot use load certificate");
477 for (i = 0; i < sk_X509_num(chain); i++)
479 if (!SSL_CTX_add_extra_chain_cert(ctx, sk_X509_value(chain, i)))
481 error("EAP-TLS: Cannot add extra chain certificate");
489 * Check the Before and After dates of the certificate
492 tmp = SSL_get_certificate(ssl);
494 ret = X509_cmp_time(X509_get_notBefore(tmp), NULL);
497 warn( "EAP-TLS: Failed to read certificate notBefore field.");
501 warn( "EAP-TLS: Your certificate is not yet valid!");
504 ret = X509_cmp_time(X509_get_notAfter(tmp), NULL);
507 warn( "EAP-TLS: Failed to read certificate notAfter field.");
511 warn( "EAP-TLS: Your certificate has expired!");
515 #ifndef OPENSSL_NO_ENGINE
520 cb_data.password = passwd;
521 cb_data.prompt_info = privkeyfile;
525 UI_METHOD* transfer_pin = UI_create_method("transfer_pin");
527 UI_method_set_writer(transfer_pin, eaptls_UI_writer);
528 UI_method_set_opener(transfer_pin, eaptls_UI_stub);
529 UI_method_set_closer(transfer_pin, eaptls_UI_stub);
530 UI_method_set_flusher(transfer_pin, eaptls_UI_stub);
531 UI_method_set_reader(transfer_pin, eaptls_UI_reader);
533 dbglog( "Using our private key URI: '%s' in engine", privkeyfile );
534 pkey = ENGINE_load_private_key(pkey_engine, privkeyfile, transfer_pin, &cb_data);
536 if (transfer_pin) UI_destroy_method(transfer_pin);
539 dbglog( "Loading private key URI: '%s' from engine", privkeyfile );
540 pkey = ENGINE_load_private_key(pkey_engine, privkeyfile, NULL, NULL);
548 input = BIO_new_file(privkeyfile, "r");
551 error("EAP-TLS: Could not open private key, %s", privkeyfile);
555 pkey = PEM_read_bio_PrivateKey(input, NULL, password_callback, NULL);
559 error("EAP-TLS: Cannot load private key, %s", privkeyfile);
565 if (SSL_CTX_use_PrivateKey(ctx, pkey) != 1)
567 error("EAP-TLS: Cannot use private key");
571 if (SSL_CTX_check_private_key(ctx) != 1)
573 error("EAP-TLS: Private key fails security check");
577 /* Configure the default options */
580 /* Set up a SSL Session cache with a callback. This is needed for TLSv1.3+.
581 * During the initial handshake the server signals to the client early on
582 * that the handshake is finished, even before the client has sent its
583 * credentials to the server. The actual connection (and moment that the
584 * client sends its credentials) only starts after the arrival of the first
585 * session ticket. The 'ssl_new_session_cb' catches this ticket.
587 SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_NO_INTERNAL_STORE);
588 SSL_CTX_sess_set_new_cb(ctx, ssl_new_session_cb);
590 /* Configure the maximum SSL version */
591 tls_set_version(ctx, max_tls_version);
593 /* Configure the callback */
594 if (tls_set_verify(ctx, 5)) {
598 /* Configure CRL check (if any) */
599 if (tls_set_crl(ctx, crl_dir, crl_file)) {
614 sk_X509_pop_free(chain, X509_free);
622 * Determine the maximum packet size by looking at the LCP handshake
625 int eaptls_get_mtu(int unit)
629 lcp_options *wo = &lcp_wantoptions[unit];
630 lcp_options *go = &lcp_gotoptions[unit];
631 lcp_options *ho = &lcp_hisoptions[unit];
632 lcp_options *ao = &lcp_allowoptions[unit];
634 mtu = ho->neg_mru? ho->mru: PPP_MRU;
635 mru = go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU;
636 mtu = MIN(MIN(mtu, mru), ao->mru)- PPP_HDRLEN - 10;
638 dbglog("MTU = %d", mtu);
644 * Init the ssl handshake (server mode)
646 int eaptls_init_ssl_server(eap_state * esp)
648 struct eaptls_session *ets;
649 char servcertfile[MAXWORDLEN];
650 char clicertfile[MAXWORDLEN];
651 char cacertfile[MAXWORDLEN];
652 char capath[MAXWORDLEN];
653 char pkfile[MAXWORDLEN];
654 char pkcs12[MAXWORDLEN];
657 * Allocate new eaptls session
659 esp->es_server.ea_session = malloc(sizeof(struct eaptls_session));
660 if (!esp->es_server.ea_session)
661 fatal("Allocation error");
662 ets = esp->es_server.ea_session;
664 if (!esp->es_server.ea_peer) {
665 error("EAP-TLS: Error: client name not set (BUG)");
669 dbglog( "getting eaptls secret" );
670 if (!get_eaptls_secret(esp->es_unit, esp->es_server.ea_peer,
671 esp->es_server.ea_name, clicertfile,
672 servcertfile, cacertfile, capath, pkfile, pkcs12, 1)) {
673 error( "EAP-TLS: Cannot get secret/password for client \"%s\", server \"%s\"",
674 esp->es_server.ea_peer, esp->es_server.ea_name );
678 ets->mtu = eaptls_get_mtu(esp->es_unit);
680 ets->ctx = eaptls_init_ssl(1, cacertfile, capath, servcertfile, pkfile, pkcs12);
684 if (!(ets->ssl = SSL_new(ets->ctx)))
687 if (tls_set_verify_info(ets->ssl, esp->es_server.ea_peer,
688 clicertfile, 0, &ets->info))
692 * Set auto-retry to avoid timeouts on BIO_read
694 SSL_set_mode(ets->ssl, SSL_MODE_AUTO_RETRY);
697 * Initialize the BIOs we use to read/write to ssl engine
699 ets->into_ssl = BIO_new(BIO_s_mem());
700 ets->from_ssl = BIO_new(BIO_s_mem());
701 SSL_set_bio(ets->ssl, ets->into_ssl, ets->from_ssl);
703 SSL_set_msg_callback(ets->ssl, ssl_msg_callback);
704 SSL_set_msg_callback_arg(ets->ssl, ets);
706 SSL_set_accept_state(ets->ssl);
717 SSL_CTX_free(ets->ctx);
722 * Init the ssl handshake (client mode)
724 int eaptls_init_ssl_client(eap_state * esp)
726 struct eaptls_session *ets;
727 char servcertfile[MAXWORDLEN];
728 char clicertfile[MAXWORDLEN];
729 char cacertfile[MAXWORDLEN];
730 char capath[MAXWORDLEN];
731 char pkfile[MAXWORDLEN];
732 char pkcs12[MAXWORDLEN];
735 * Allocate new eaptls session
737 esp->es_client.ea_session = malloc(sizeof(struct eaptls_session));
738 if (!esp->es_client.ea_session)
739 fatal("Allocation error");
740 ets = esp->es_client.ea_session;
741 ets->mtu = eaptls_get_mtu(esp->es_unit);
743 dbglog( "calling get_eaptls_secret" );
744 if (!get_eaptls_secret(esp->es_unit, esp->es_client.ea_name,
745 esp->es_client.ea_peer, clicertfile,
746 servcertfile, cacertfile, capath, pkfile, pkcs12, 0)) {
747 error( "EAP-TLS: Cannot get secret/password for client \"%s\", server \"%s\"",
748 esp->es_client.ea_name, esp->es_client.ea_peer);
752 dbglog( "calling eaptls_init_ssl" );
753 ets->ctx = eaptls_init_ssl(0, cacertfile, capath, clicertfile, pkfile, pkcs12);
757 ets->ssl = SSL_new(ets->ctx);
761 if (tls_set_verify_info(ets->ssl, esp->es_client.ea_peer,
762 servcertfile, 0, &ets->info))
766 * Initialize the BIOs we use to read/write to ssl engine
768 dbglog( "Initializing SSL BIOs" );
769 ets->into_ssl = BIO_new(BIO_s_mem());
770 ets->from_ssl = BIO_new(BIO_s_mem());
771 SSL_set_bio(ets->ssl, ets->into_ssl, ets->from_ssl);
773 SSL_set_msg_callback(ets->ssl, ssl_msg_callback);
774 SSL_set_msg_callback_arg(ets->ssl, ets);
775 SSL_set_connect_state(ets->ssl);
786 dbglog( "eaptls_init_ssl_client: fail" );
787 SSL_CTX_free(ets->ctx);
792 void eaptls_free_session(struct eaptls_session *ets)
798 SSL_CTX_free(ets->ctx);
801 tls_free_verify_info(&ets->info);
807 int eaptls_is_init_finished(struct eaptls_session *ets)
809 if (ets->ssl && SSL_is_init_finished(ets->ssl))
812 return have_session_ticket;
821 * Handle a received packet, reassembling fragmented messages and
822 * passing them to the ssl engine
824 int eaptls_receive(struct eaptls_session *ets, u_char * inp, int len)
831 warn("EAP-TLS: received no or invalid data");
838 if (flags & EAP_TLS_FLAGS_LI && len > 4) {
840 * LenghtIncluded flag set -> this is the first packet of a message
844 * the first 4 octets are the length of the EAP-TLS message
846 GETLONG(tlslen, inp);
851 if (tlslen > EAP_TLS_MAX_LEN) {
852 error("EAP-TLS: TLS message length > %d, truncated", EAP_TLS_MAX_LEN);
853 tlslen = EAP_TLS_MAX_LEN;
857 * Allocate memory for the whole message
859 ets->data = malloc(tlslen);
861 fatal("EAP-TLS: allocation error\n");
864 ets->tlslen = tlslen;
867 warn("EAP-TLS: non-first LI packet? that's odd...");
869 else if (!ets->data) {
871 * A non fragmented message without LI flag
874 ets->data = malloc(len);
876 fatal("EAP-TLS: memory allocation error in eaptls_receive\n");
882 if (flags & EAP_TLS_FLAGS_MF)
888 warn("EAP-TLS: received malformed data");
892 if (len + ets->datalen > ets->tlslen) {
893 warn("EAP-TLS: received data > TLS message length");
897 BCOPY(inp, ets->data + ets->datalen, len);
903 * If we have the whole message, pass it to ssl
906 if (ets->datalen != ets->tlslen) {
907 warn("EAP-TLS: received data != TLS message length");
911 if (BIO_write(ets->into_ssl, ets->data, ets->datalen) == -1)
914 SSL_read(ets->ssl, dummy, 65536);
925 * Return an eap-tls packet in outp.
926 * A TLS message read from the ssl engine is buffered in ets->data.
927 * At each call we control if there is buffered data and send a
928 * packet of mtu bytes.
930 int eaptls_send(struct eaptls_session *ets, u_char ** outp)
934 u_char fromtls[65536];
944 res = SSL_read(ets->ssl, fromtls, 65536);
950 if ((res = BIO_read(ets->from_ssl, fromtls, 65536)) == -1)
952 warn("EAP-TLS send: No data from BIO_read");
958 ets->data = malloc(ets->datalen);
960 fatal("EAP-TLS: memory allocation error in eaptls_send\n");
962 BCOPY(fromtls, ets->data, ets->datalen);
968 size = ets->datalen - ets->offset;
970 if (size > ets->mtu) {
976 PUTCHAR(EAPT_TLS, *outp);
979 * Set right flags and length if necessary
981 if (ets->frag && first) {
982 PUTCHAR(EAP_TLS_FLAGS_LI | EAP_TLS_FLAGS_MF, *outp);
983 PUTLONG(ets->datalen, *outp);
984 } else if (ets->frag) {
985 PUTCHAR(EAP_TLS_FLAGS_MF, *outp);
990 * Copy the data in outp
992 BCOPY(ets->data + ets->offset, *outp, size);
996 * Copy the packet in retransmission buffer
998 BCOPY(start, &ets->rtx[0], *outp - start);
999 ets->rtx_len = *outp - start;
1001 ets->offset += size;
1003 if (ets->offset >= ets->datalen) {
1006 * The whole message has been sent
1019 * Get the sent packet from the retransmission buffer
1021 void eaptls_retransmit(struct eaptls_session *ets, u_char ** outp)
1023 BCOPY(ets->rtx, *outp, ets->rtx_len);
1024 INCPTR(ets->rtx_len, *outp);
1028 * Every sent & received message this callback function is invoked,
1029 * so we know when alert messages have arrived or are sent and
1030 * we can print debug information about TLS handshake.
1033 ssl_msg_callback(int write_p, int version, int content_type,
1034 const void *buf, size_t len, SSL * ssl, void *arg)
1037 struct eaptls_session *ets = (struct eaptls_session *)arg;
1039 const unsigned char*msg = buf;
1040 int hvers = msg[1] << 8 | msg[2];
1043 strcpy(string, " -> ");
1045 strcpy(string, " <- ");
1047 switch(content_type) {
1049 case SSL3_RT_HEADER:
1050 strcat(string, "SSL/TLS Header: ");
1053 strcat(string, "SSL 3.0");
1056 strcat(string, "TLS 1.0");
1058 case TLS1_1_VERSION:
1059 strcat(string, "TLS 1.1");
1061 case TLS1_2_VERSION:
1062 strcat(string, "TLS 1.2");
1065 sprintf(string, "SSL/TLS Header: Unknown version (%d)", hvers);
1070 strcat(string, "Alert: ");
1074 ets->alert_sent = 1;
1075 ets->alert_sent_desc = code;
1077 ets->alert_recv = 1;
1078 ets->alert_recv_desc = code;
1081 strcat(string, SSL_alert_desc_string_long(code));
1084 case SSL3_RT_CHANGE_CIPHER_SPEC:
1085 strcat(string, "ChangeCipherSpec");
1088 #ifdef SSL3_RT_INNER_CONTENT_TYPE
1089 case SSL3_RT_INNER_CONTENT_TYPE:
1090 strcat(string, "InnerContentType (TLS1.3)");
1094 case SSL3_RT_HANDSHAKE:
1096 strcat(string, "Handshake: ");
1100 case SSL3_MT_HELLO_REQUEST:
1101 strcat(string,"Hello Request");
1103 case SSL3_MT_CLIENT_HELLO:
1104 strcat(string,"Client Hello");
1106 case SSL3_MT_SERVER_HELLO:
1107 strcat(string,"Server Hello");
1109 #ifdef SSL3_MT_NEWSESSION_TICKET
1110 case SSL3_MT_NEWSESSION_TICKET:
1111 strcat(string,"New Session Ticket");
1114 #ifdef SSL3_MT_END_OF_EARLY_DATA
1115 case SSL3_MT_END_OF_EARLY_DATA:
1116 strcat(string,"End of Early Data");
1119 #ifdef SSL3_MT_ENCRYPTED_EXTENSIONS
1120 case SSL3_MT_ENCRYPTED_EXTENSIONS:
1121 strcat(string,"Encryped Extensions");
1124 case SSL3_MT_CERTIFICATE:
1125 strcat(string,"Certificate");
1127 case SSL3_MT_SERVER_KEY_EXCHANGE:
1128 strcat(string,"Server Key Exchange");
1130 case SSL3_MT_CERTIFICATE_REQUEST:
1131 strcat(string,"Certificate Request");
1133 case SSL3_MT_SERVER_DONE:
1134 strcat(string,"Server Hello Done");
1136 case SSL3_MT_CERTIFICATE_VERIFY:
1137 strcat(string,"Certificate Verify");
1139 case SSL3_MT_CLIENT_KEY_EXCHANGE:
1140 strcat(string,"Client Key Exchange");
1142 case SSL3_MT_FINISHED:
1143 strcat(string,"Finished: ");
1144 hvers = SSL_version(ssl);
1147 strcat(string, "SSL 3.0");
1150 strcat(string, "TLS 1.0");
1152 case TLS1_1_VERSION:
1153 strcat(string, "TLS 1.1");
1155 case TLS1_2_VERSION:
1156 strcat(string, "TLS 1.2");
1158 #ifdef TLS1_3_VERSION
1159 case TLS1_3_VERSION:
1160 strcat(string, "TLS 1.3 (experimental)");
1165 strcat(string, "Unknown version");
1169 sprintf( string, "Handshake: Unknown SSL3 code received: %d", code );
1174 sprintf( string, "SSL message contains unknown content type: %d", content_type );
1177 /* Alert messages must always be displayed */
1178 if(content_type == SSL3_RT_ALERT)
1179 error("%s", string);
1181 dbglog("%s", string);
1185 ssl_new_session_cb(SSL *s, SSL_SESSION *sess)
1187 dbglog("EAP-TLS: Post-Handshake New Session Ticket arrived:");
1188 have_session_ticket = 1;
1190 /* always return success */