2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single TCP/UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
8 * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program (see the file COPYING included with this
21 * distribution); if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #if defined(USE_CRYPTO) && defined(USE_SSL)
30 #include <openssl/ssl.h>
31 #include <openssl/bio.h>
32 #include <openssl/rand.h>
33 #include <openssl/err.h>
34 #include <openssl/pkcs12.h>
35 #include <openssl/x509v3.h>
40 #include "packet_id.h"
41 #include "session_id.h"
50 * OpenVPN Protocol, taken from ssl.h in OpenVPN source code.
52 * TCP/UDP Packet: This represents the top-level encapsulation.
54 * TCP/UDP packet format:
56 * Packet length (16 bits, unsigned) -- TCP only, always sent as
57 * plaintext. Since TCP is a stream protocol, the packet
58 * length words define the packetization of the stream.
60 * Packet opcode/key_id (8 bits) -- TLS only, not used in
61 * pre-shared secret mode.
62 * packet message type, a P_* constant (high 5 bits)
63 * key_id (low 3 bits, see key_id in struct tls_session
64 * below for comment). The key_id refers to an
65 * already negotiated TLS session. OpenVPN seamlessly
66 * renegotiates the TLS session by using a new key_id
67 * for the new session. Overlap (controlled by
68 * user definable parameters) between old and new TLS
69 * sessions is allowed, providing a seamless transition
70 * during tunnel operation.
72 * Payload (n bytes), which may be a P_CONTROL, P_ACK, or P_DATA
77 * P_CONTROL_HARD_RESET_CLIENT_V1 -- Key method 1, initial key from
78 * client, forget previous state.
80 * P_CONTROL_HARD_RESET_SERVER_V1 -- Key method 2, initial key
81 * from server, forget previous state.
83 * P_CONTROL_SOFT_RESET_V1 -- New key, with a graceful transition
84 * from old to new key in the sense that a transition window
85 * exists where both the old or new key_id can be used. OpenVPN
86 * uses two different forms of key_id. The first form is 64 bits
87 * and is used for all P_CONTROL messages. P_DATA messages on the
88 * other hand use a shortened key_id of 3 bits for efficiency
89 * reasons since the vast majority of OpenVPN packets in an
90 * active tunnel will be P_DATA messages. The 64 bit form
91 * is referred to as a session_id, while the 3 bit form is
92 * referred to as a key_id.
94 * P_CONTROL_V1 -- Control channel packet (usually TLS ciphertext).
96 * P_ACK_V1 -- Acknowledgement for P_CONTROL packets received.
98 * P_DATA_V1 -- Data channel packet containing actual tunnel data
101 * P_CONTROL_HARD_RESET_CLIENT_V2 -- Key method 2, initial key from
102 * client, forget previous state.
104 * P_CONTROL_HARD_RESET_SERVER_V2 -- Key method 2, initial key from
105 * server, forget previous state.
107 * P_CONTROL* and P_ACK Payload: The P_CONTROL message type
108 * indicates a TLS ciphertext packet which has been encapsulated
109 * inside of a reliability layer. The reliability layer is
110 * implemented as a straightforward ACK and retransmit model.
112 * P_CONTROL message format:
114 * local session_id (random 64 bit value to identify TLS session).
115 * HMAC signature of entire encapsulation header for integrity
116 * check if --tls-auth is specified (usually 16 or 20 bytes).
117 * packet-id for replay protection (4 or 8 bytes, includes
118 * sequence number and optional time_t timestamp).
119 * P_ACK packet_id array length (1 byte).
120 * P_ACK packet-id array (if length > 0).
121 * P_ACK remote session_id (if length > 0).
122 * message packet-id (4 bytes).
123 * TLS payload ciphertext (n bytes) (only for P_CONTROL).
125 * Once the TLS session has been initialized and authenticated,
126 * the TLS channel is used to exchange random key material for
127 * bidirectional cipher and HMAC keys which will be
128 * used to secure actual tunnel packets. OpenVPN currently
129 * implements two key methods. Key method 1 directly
130 * derives keys using random bits obtained from the RAND_bytes
131 * OpenSSL function. Key method 2 mixes random key material
132 * from both sides of the connection using the TLS PRF mixing
133 * function. Key method 2 is the preferred method and is the default
136 * TLS plaintext content:
138 * TLS plaintext packet (if key_method == 1):
140 * Cipher key length in bytes (1 byte).
141 * Cipher key (n bytes).
142 * HMAC key length in bytes (1 byte).
143 * HMAC key (n bytes).
144 * Options string (n bytes, null terminated, client/server options
145 * string should match).
147 * TLS plaintext packet (if key_method == 2):
149 * Literal 0 (4 bytes).
150 * key_method type (1 byte).
151 * key_source structure (pre_master only defined for client ->
153 * options_string_length, including null (2 bytes).
154 * Options string (n bytes, null terminated, client/server options
155 * string must match).
156 * [The username/password data below is optional, record can end
158 * username_string_length, including null (2 bytes).
159 * Username string (n bytes, null terminated).
160 * password_string_length, including null (2 bytes).
161 * Password string (n bytes, null terminated).
163 * The P_DATA payload represents encrypted, encapsulated tunnel
164 * packets which tend to be either IP packets or Ethernet frames.
165 * This is essentially the "payload" of the VPN.
167 * P_DATA message content:
168 * HMAC of ciphertext IV + ciphertext (if not disabled by
170 * Ciphertext IV (size is cipher-dependent, if not disabled by
172 * Tunnel packet ciphertext.
175 * packet_id (4 or 8 bytes, if not disabled by --no-replay).
176 * In SSL/TLS mode, 4 bytes are used because the implementation
177 * can force a TLS renegotation before 2^32 packets are sent.
178 * In pre-shared key mode, 8 bytes are used (sequence number
179 * and time_t value) to allow long-term key usage without
180 * packet_id collisions.
181 * User plaintext (n bytes).
184 * (1) ACK messages can be encoded in either the dedicated
185 * P_ACK record or they can be prepended to a P_CONTROL message.
186 * (2) P_DATA and P_CONTROL/P_ACK use independent packet-id
187 * sequences because P_DATA is an unreliable channel while
188 * P_CONTROL/P_ACK is a reliable channel. Each use their
189 * own independent HMAC keys.
190 * (3) Note that when --tls-auth is used, all message types are
191 * protected with an HMAC signature, even the initial packets
192 * of the TLS handshake. This makes it easy for OpenVPN to
193 * throw away bogus packets quickly, without wasting resources
194 * on attempting a TLS handshake which will ultimately fail.
197 /* Used in the TLS PRF function */
198 #define KEY_EXPANSION_ID "OpenVPN"
201 #define UP_TYPE_AUTH "Auth"
202 #define UP_TYPE_PRIVATE_KEY "Private Key"
204 /* packet opcode (high 5 bits) and key-id (low 3 bits) are combined in one byte */
205 #define P_KEY_ID_MASK 0x07
206 #define P_OPCODE_SHIFT 3
208 /* packet opcodes -- the V1 is intended to allow protocol changes in the future */
209 #define P_CONTROL_HARD_RESET_CLIENT_V1 1 /* initial key from client, forget previous state */
210 #define P_CONTROL_HARD_RESET_SERVER_V1 2 /* initial key from server, forget previous state */
211 #define P_CONTROL_SOFT_RESET_V1 3 /* new key, graceful transition from old to new key */
212 #define P_CONTROL_V1 4 /* control channel packet (usually TLS ciphertext) */
213 #define P_ACK_V1 5 /* acknowledgement for packets received */
214 #define P_DATA_V1 6 /* data channel packet */
216 /* indicates key_method >= 2 */
217 #define P_CONTROL_HARD_RESET_CLIENT_V2 7 /* initial key from client, forget previous state */
218 #define P_CONTROL_HARD_RESET_SERVER_V2 8 /* initial key from server, forget previous state */
220 /* define the range of legal opcodes */
221 #define P_FIRST_OPCODE 1
222 #define P_LAST_OPCODE 8
224 /* key negotiation states */
227 #define S_INITIAL 1 /* tls_init() was called */
228 #define S_PRE_START 2 /* waiting for initial reset & acknowledgement */
229 #define S_START 3 /* ready to exchange keys */
230 #define S_SENT_KEY 4 /* client does S_SENT_KEY -> S_GOT_KEY */
231 #define S_GOT_KEY 5 /* server does S_GOT_KEY -> S_SENT_KEY */
232 #define S_ACTIVE 6 /* ready to exchange data channel packets */
233 #define S_NORMAL_OP 7 /* normal operations */
236 * Are we ready to receive data channel packets?
238 * Also, if true, we can safely assume session has been
239 * authenticated by TLS.
241 * NOTE: Assumes S_SENT_KEY + 1 == S_GOT_KEY.
243 #define DECRYPT_KEY_ENABLED(multi, ks) ((ks)->state >= (S_GOT_KEY - (multi)->opt.server))
245 /* Should we aggregate TLS acknowledgements, and tack them onto control packets? */
246 #define TLS_AGGREGATE_ACK
249 * If TLS_AGGREGATE_ACK, set the
250 * max number of acknowledgments that
251 * can "hitch a ride" on an outgoing
252 * non-P_ACK_V1 control packet.
254 #define CONTROL_SEND_ACK_MAX 4
257 * Define number of buffers for send and receive in the reliability layer.
259 #define TLS_RELIABLE_N_SEND_BUFFERS 4 /* also window size for reliablity layer */
260 #define TLS_RELIABLE_N_REC_BUFFERS 8
266 #define TLS_MULTI_REFRESH 15 /* call tls_multi_process once every n seconds */
267 #define TLS_MULTI_HORIZON 2 /* call tls_multi_process frequently for n seconds after
268 every packet sent/received action */
270 /* The SSL/TLS worker thread will wait at most this many seconds for the interprocess
271 communication pipe to the main thread to be ready to accept writes. */
272 #define TLS_MULTI_THREAD_SEND_TIMEOUT 5
274 /* Interval that tls_multi_process should call tls_authentication_status */
275 #define TLS_MULTI_AUTH_STATUS_INTERVAL 10
278 * Buffer sizes (also see mtu.h).
281 /* Maximum length of common name */
282 #define TLS_CN_LEN 64
284 /* Legal characters in an X509 or common name */
285 #define X509_NAME_CHAR_CLASS (CC_ALNUM|CC_UNDERBAR|CC_DASH|CC_DOT|CC_AT|CC_COLON|CC_SLASH|CC_EQUAL)
286 #define COMMON_NAME_CHAR_CLASS (CC_ALNUM|CC_UNDERBAR|CC_DASH|CC_DOT|CC_AT|CC_SLASH)
288 /* Maximum length of OCC options string passed as part of auth handshake */
289 #define TLS_OPTIONS_LEN 512
292 * Range of key exchange methods
294 #define KEY_METHOD_MIN 1
295 #define KEY_METHOD_MAX 2
297 /* key method taken from lower 4 bits */
298 #define KEY_METHOD_MASK 0x0F
301 * Measure success rate of TLS handshakes, for debugging only
303 /* #define MEASURE_TLS_HANDSHAKE_STATS */
306 * Keep track of certificate hashes at various depths
309 /* Maximum certificate depth we will allow */
310 #define MAX_CERT_DEPTH 16
313 unsigned char sha1_hash
[SHA_DIGEST_LENGTH
];
316 struct cert_hash_set
{
317 struct cert_hash
*ch
[MAX_CERT_DEPTH
];
321 * Key material, used as source for PRF-based
326 uint8_t pre_master
[48]; /* client generated */
327 uint8_t random1
[32]; /* generated by both client and server */
328 uint8_t random2
[32]; /* generated by both client and server */
332 struct key_source client
;
333 struct key_source server
;
337 * Represents a single instantiation of a TLS negotiation and
338 * data channel key exchange. 4 keys are kept: encrypt hmac,
339 * decrypt hmac, encrypt cipher, and decrypt cipher. The TLS
340 * control channel is used to exchange these keys.
341 * Each hard or soft reset will build
342 * a fresh key_state. Normally an openvpn session will contain two
343 * key_state objects, one for the current TLS connection, and other
344 * for the retiring or "lame duck" key. The lame duck key_state is
345 * used to maintain transmission continuity on the data-channel while
346 * a key renegotiation is taking place.
351 int key_id
; /* inherited from struct tls_session below */
353 SSL
*ssl
; /* SSL object -- new obj created for each new key */
354 BIO
*ssl_bio
; /* read/write plaintext from here */
355 BIO
*ct_in
; /* write ciphertext to here */
356 BIO
*ct_out
; /* read ciphertext from here */
358 time_t established
; /* when our state went S_ACTIVE */
359 time_t must_negotiate
; /* key negotiation times out if not finished before this time */
360 time_t must_die
; /* this object is destroyed at this time */
362 int initial_opcode
; /* our initial P_ opcode */
363 struct session_id session_id_remote
; /* peer's random session ID */
364 struct link_socket_actual remote_addr
; /* peer's IP addr */
365 struct packet_id packet_id
; /* for data channel, to prevent replay attacks */
367 struct key_ctx_bi key
; /* data channel keys for encrypt/decrypt/hmac */
369 struct key_source2
*key_src
; /* source entropy for key expansion */
371 struct buffer plaintext_read_buf
;
372 struct buffer plaintext_write_buf
;
373 struct buffer ack_write_buf
;
375 struct reliable
*send_reliable
; /* holds a copy of outgoing packets until ACK received */
376 struct reliable
*rec_reliable
; /* order incoming ciphertext packets before we pass to TLS */
377 struct reliable_ack
*rec_ack
; /* buffers all packet IDs we want to ACK back to sender */
379 int n_bytes
; /* how many bytes sent/recvd since last key exchange */
380 int n_packets
; /* how many packets sent/recvd since last key exchange */
383 * If bad username/password, TLS connection will come up but 'authenticated' will be false.
386 time_t auth_deferred_expire
;
388 #ifdef ENABLE_DEF_AUTH
389 /* If auth_deferred is true, authentication is being deferred */
391 #ifdef MANAGEMENT_DEF_AUTH
392 unsigned int mda_key_id
;
393 unsigned int mda_status
;
395 #ifdef PLUGIN_DEF_AUTH
396 unsigned int auth_control_status
;
398 char *auth_control_file
;
404 * Our const options, obtained directly or derived from
405 * command line options.
409 /* our master SSL_CTX from which all SSL objects derived */
412 /* data channel cipher, hmac, and key lengths */
413 struct key_type key_type
;
415 /* true if we are a TLS server, client otherwise */
418 /* if true, don't xmit until first packet from peer is received */
422 /* local and remote options strings
423 that must match between client and server */
424 const char *local_options
;
425 const char *remote_options
;
428 /* from command line */
435 int transition_window
;
436 int handshake_window
;
437 interval_t packet_timeout
;
438 int renegotiate_bytes
;
439 int renegotiate_packets
;
440 interval_t renegotiate_seconds
;
442 /* cert verification parms */
443 const char *verify_command
;
444 const char *verify_x509name
;
445 const char *crl_file
;
447 unsigned remote_cert_ku
[MAX_PARMS
];
448 const char *remote_cert_eku
;
450 /* allow openvpn config info to be
451 passed over control channel */
452 bool pass_config_info
;
454 /* struct crypto_option flags */
455 unsigned int crypto_flags_and
;
456 unsigned int crypto_flags_or
;
458 int replay_window
; /* --replay-window parm */
459 int replay_time
; /* --replay-window parm */
461 /* packet authentication for TLS handshake */
462 struct crypto_options tls_auth
;
463 struct key_ctx_bi tls_auth_key
;
465 /* frame parameters for TLS control channel */
468 /* used for username/password authentication */
469 const char *auth_user_pass_verify_script
;
470 bool auth_user_pass_verify_script_via_file
;
473 /* use the client-config-dir as a positive authenticator */
474 const char *client_config_dir_exclusive
;
476 /* instance-wide environment variable set */
478 const struct plugin_list
*plugins
;
480 /* configuration file boolean options */
481 # define SSLF_CLIENT_CERT_NOT_REQUIRED (1<<0)
482 # define SSLF_USERNAME_AS_COMMON_NAME (1<<1)
483 # define SSLF_AUTH_USER_PASS_OPTIONAL (1<<2)
484 # define SSLF_NO_NAME_REMAPPING (1<<3)
485 # define SSLF_OPT_VERIFY (1<<4)
486 unsigned int ssl_flags
;
488 #ifdef MANAGEMENT_DEF_AUTH
489 struct man_def_auth_context
*mda_context
;
496 /* index into tls_session.key */
497 #define KS_PRIMARY 0 /* the primary key */
498 #define KS_LAME_DUCK 1 /* the key that's going to retire soon */
502 * A tls_session lives through multiple key_state life-cycles. Soft resets
503 * will reuse a tls_session object, but hard resets or errors will require
504 * that a fresh object be built. Normally three tls_session objects are maintained
505 * by an active openvpn session. The first is the current, TLS authenticated
506 * session, the second is used to process connection requests from a new
507 * client that would usurp the current session if successfully authenticated,
508 * and the third is used as a repository for a "lame-duck" key in the event
509 * that the primary session resets due to error while the lame-duck key still
510 * has time left before its expiration. Lame duck keys are used to maintain
511 * the continuity of the data channel connection while a new key is being
516 /* const options and config info */
517 const struct tls_options
*opt
;
519 /* during hard reset used to control burst retransmit */
522 /* authenticate control packets */
523 struct crypto_options tls_auth
;
524 struct packet_id tls_auth_pid
;
526 int initial_opcode
; /* our initial P_ opcode */
527 struct session_id session_id
; /* our random session ID */
528 int key_id
; /* increments with each soft reset (for key renegotiation) */
530 int limit_next
; /* used for traffic shaping on the control channel */
536 struct cert_hash_set
*cert_hash_set
;
539 uint32_t common_name_hashval
;
542 bool verified
; /* true if peer certificate was verified against CA */
544 /* not-yet-authenticated incoming client */
545 struct link_socket_actual untrusted_addr
;
547 struct key_state key
[KS_SIZE
];
550 /* index into tls_multi.session */
552 #define TM_UNTRUSTED 1
553 #define TM_LAME_DUCK 2
557 * The number of keys we will scan on encrypt or decrypt. The first
558 * is the "active" key. The second is the lame_duck or retiring key
559 * associated with the active key's session ID. The third is a detached
560 * lame duck session that only occurs in situations where a key renegotiate
561 * failed on the active key, but a lame duck key was still valid. By
562 * preserving the lame duck session, we can be assured of having a data
563 * channel key available even when network conditions are so bad that
564 * we can't negotiate a new key within the time allotted.
566 #define KEY_SCAN_SIZE 3
569 * An openvpn session running with TLS enabled has one tls_multi object.
573 /* used to coordinate access between main thread and TLS thread */
574 /*MUTEX_PTR_DEFINE (mutex);*/
576 /* const options and config info */
577 struct tls_options opt
;
580 * A list of key_state objects in the order they should be
581 * scanned by data channel encrypt and decrypt routines.
583 struct key_state
* key_scan
[KEY_SCAN_SIZE
];
586 * used by tls_pre_encrypt to communicate the encrypt key
587 * to tls_post_encrypt()
589 struct key_state
*save_ks
; /* temporary pointer used between pre/post routines */
592 * Used to return outgoing address from
595 struct link_socket_actual to_link_addr
;
598 * Number of sessions negotiated thus far.
605 int n_hard_errors
; /* errors due to TLS negotiation failure */
606 int n_soft_errors
; /* errors due to unrecognized or failed-to-authenticate incoming packets */
609 * Our locked common name, username, and cert hashes (cannot change during the life of this tls_multi object)
612 char *locked_username
;
613 struct cert_hash_set
*locked_cert_hash_set
;
615 #ifdef ENABLE_DEF_AUTH
617 * An error message to send to client on AUTH_FAILED
621 /* Time of last call to tls_authentication_status */
626 * Our session objects.
628 struct tls_session session
[TM_SIZE
];
632 * Used in --mode server mode to check tls-auth signature on initial
633 * packets received from new clients.
635 struct tls_auth_standalone
637 struct key_ctx_bi tls_auth_key
;
638 struct crypto_options tls_auth_options
;
642 void init_ssl_lib (void);
643 void free_ssl_lib (void);
645 /* Build master SSL_CTX object that serves for the whole of openvpn instantiation */
646 SSL_CTX
*init_ssl (const struct options
*options
);
648 struct tls_multi
*tls_multi_init (struct tls_options
*tls_options
);
650 struct tls_auth_standalone
*tls_auth_standalone_init (struct tls_options
*tls_options
,
651 struct gc_arena
*gc
);
653 void tls_auth_standalone_finalize (struct tls_auth_standalone
*tas
,
654 const struct frame
*frame
);
656 void tls_multi_init_finalize(struct tls_multi
*multi
,
657 const struct frame
*frame
);
659 void tls_multi_init_set_options(struct tls_multi
* multi
,
663 #define TLSMP_INACTIVE 0
664 #define TLSMP_ACTIVE 1
666 int tls_multi_process (struct tls_multi
*multi
,
667 struct buffer
*to_link
,
668 struct link_socket_actual
**to_link_addr
,
669 struct link_socket_info
*to_link_socket_info
,
672 void tls_multi_free (struct tls_multi
*multi
, bool clear
);
674 bool tls_pre_decrypt (struct tls_multi
*multi
,
675 const struct link_socket_actual
*from
,
677 struct crypto_options
*opt
);
679 bool tls_pre_decrypt_lite (const struct tls_auth_standalone
*tas
,
680 const struct link_socket_actual
*from
,
681 const struct buffer
*buf
);
683 void tls_pre_encrypt (struct tls_multi
*multi
,
684 struct buffer
*buf
, struct crypto_options
*opt
);
686 void tls_post_encrypt (struct tls_multi
*multi
, struct buffer
*buf
);
688 void show_available_tls_ciphers (void);
689 void get_highest_preference_tls_cipher (char *buf
, int size
);
691 void pem_password_setup (const char *auth_file
);
692 int pem_password_callback (char *buf
, int size
, int rwflag
, void *u
);
693 void auth_user_pass_setup (const char *auth_file
);
694 void ssl_set_auth_nocache (void);
695 void ssl_purge_auth (void);
697 void tls_set_verify_command (const char *cmd
);
698 void tls_set_crl_verify (const char *crl
);
699 void tls_set_verify_x509name (const char *x509name
);
701 void tls_adjust_frame_parameters(struct frame
*frame
);
703 bool tls_send_payload (struct tls_multi
*multi
,
707 bool tls_rec_payload (struct tls_multi
*multi
,
710 const char *tls_common_name (const struct tls_multi
* multi
, const bool null
);
711 void tls_set_common_name (struct tls_multi
*multi
, const char *common_name
);
712 void tls_lock_common_name (struct tls_multi
*multi
);
713 void tls_lock_cert_hash_set (struct tls_multi
*multi
);
715 #define TLS_AUTHENTICATION_SUCCEEDED 0
716 #define TLS_AUTHENTICATION_FAILED 1
717 #define TLS_AUTHENTICATION_DEFERRED 2
718 #define TLS_AUTHENTICATION_UNDEFINED 3
719 int tls_authentication_status (struct tls_multi
*multi
, const int latency
);
720 void tls_deauthenticate (struct tls_multi
*multi
);
722 #ifdef MANAGEMENT_DEF_AUTH
723 bool tls_authenticate_key (struct tls_multi
*multi
, const unsigned int mda_key_id
, const bool auth
, const char *client_reason
);
731 tls_initial_packet_received (const struct tls_multi
*multi
)
733 return multi
->n_sessions
> 0;
737 tls_test_auth_deferred_interval (const struct tls_multi
*multi
)
741 const struct key_state
*ks
= &multi
->session
[TM_ACTIVE
].key
[KS_PRIMARY
];
742 return now
< ks
->auth_deferred_expire
;
748 tls_test_payload_len (const struct tls_multi
*multi
)
752 const struct key_state
*ks
= &multi
->session
[TM_ACTIVE
].key
[KS_PRIMARY
];
753 if (ks
->state
>= S_ACTIVE
)
754 return BLEN (&ks
->plaintext_read_buf
);
760 tls_set_single_session (struct tls_multi
*multi
)
763 multi
->opt
.single_session
= true;
766 static inline const char *
767 tls_client_reason (struct tls_multi
*multi
)
769 #ifdef ENABLE_DEF_AUTH
770 return multi
->client_reason
;
779 tls_common_name_hash (const struct tls_multi
*multi
, const char **cn
, uint32_t *cn_hash
)
783 const struct tls_session
*s
= &multi
->session
[TM_ACTIVE
];
784 if (s
->common_name
&& s
->common_name
[0] != '\0')
786 *cn
= s
->common_name
;
787 *cn_hash
= s
->common_name_hashval
;
797 * protocol_dump() flags
799 #define PD_TLS_AUTH_HMAC_SIZE_MASK 0xFF
800 #define PD_SHOW_DATA (1<<8)
801 #define PD_TLS (1<<9)
802 #define PD_VERBOSE (1<<10)
804 const char *protocol_dump (struct buffer
*buffer
,
806 struct gc_arena
*gc
);
812 #ifdef MEASURE_TLS_HANDSHAKE_STATS
813 void show_tls_performance_stats(void);
816 /*#define EXTRACT_X509_FIELD_TEST*/
817 void extract_x509_field_test (void);
819 #endif /* USE_CRYPTO && USE_SSL */