blob: 0c863572a470d4a340ebcd5459c49e23a1d00757 [file] [log] [blame]
Emeric Brunfc0421f2012-09-07 17:30:07 +02001/*
2 * include/types/ssl_sock.h
3 * SSL settings for listeners and servers
4 *
5 * Copyright (C) 2012 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef _TYPES_SSL_SOCK_H
23#define _TYPES_SSL_SOCK_H
Willy Tarreauc125cef2019-05-10 09:58:43 +020024#ifdef USE_OPENSSL
Emeric Brunfc0421f2012-09-07 17:30:07 +020025
Emeric Brunfc0421f2012-09-07 17:30:07 +020026#include <ebmbtree.h>
27
Christopher Faulet16f45c82018-02-16 11:23:49 +010028#include <common/hathreads.h>
Willy Tarreau55994562019-05-09 14:52:44 +020029#include <common/openssl-compat.h>
Christopher Faulet16f45c82018-02-16 11:23:49 +010030
Emmanuel Hocdetddc090b2017-10-27 18:43:29 +020031struct pkey_info {
32 uint8_t sig; /* TLSEXT_signature_[rsa,ecdsa,...] */
33 uint16_t bits; /* key size in bits */
34};
35
Emeric Brunfc0421f2012-09-07 17:30:07 +020036struct sni_ctx {
37 SSL_CTX *ctx; /* context associated to the certificate */
38 int order; /* load order for the certificate */
Emmanuel Hocdet05942112017-02-20 16:11:50 +010039 uint8_t neg; /* reject if match */
Emmanuel Hocdetddc090b2017-10-27 18:43:29 +020040 struct pkey_info kinfo; /* pkey info */
Emmanuel Hocdet98263292016-12-29 18:26:15 +010041 struct ssl_bind_conf *conf; /* ssl "bind" conf for the certificate */
Emeric Brunfc0421f2012-09-07 17:30:07 +020042 struct ebmb_node name; /* node holding the servername value */
43};
44
Emmanuel Hocdet5db33cb2017-03-30 19:19:37 +020045struct tls_version_filter {
46 uint16_t flags; /* ssl options */
47 uint8_t min; /* min TLS version */
48 uint8_t max; /* max TLS version */
49};
50
Nenad Merdanovic200b0fa2015-05-09 08:46:01 +020051extern struct list tlskeys_reference;
52
Emeric Brun9e754772019-01-10 17:51:55 +010053struct tls_sess_key_128 {
Nenad Merdanovic05552d42015-02-27 19:56:49 +010054 unsigned char name[16];
55 unsigned char aes_key[16];
56 unsigned char hmac_key[16];
57} __attribute__((packed));
58
Emeric Brun9e754772019-01-10 17:51:55 +010059struct tls_sess_key_256 {
60 unsigned char name[16];
61 unsigned char aes_key[32];
62 unsigned char hmac_key[32];
63} __attribute__((packed));
64
65union tls_sess_key{
66 unsigned char name[16];
Nenad Merdanovic8ef70652019-04-14 16:06:46 +020067 struct tls_sess_key_128 key_128;
Emeric Brun9e754772019-01-10 17:51:55 +010068 struct tls_sess_key_256 key_256;
69} __attribute__((packed));
70
Nenad Merdanovic146defa2015-05-09 08:46:00 +020071struct tls_keys_ref {
72 struct list list; /* Used to chain refs. */
73 char *filename;
74 int unique_id; /* Each pattern reference have unique id. */
Willy Tarreau17b4aa12018-07-17 10:05:32 +020075 int refcount; /* number of users of this tls_keys_ref. */
Emeric Brun9e754772019-01-10 17:51:55 +010076 union tls_sess_key *tlskeys;
Nenad Merdanovic146defa2015-05-09 08:46:00 +020077 int tls_ticket_enc_index;
Emeric Brun9e754772019-01-10 17:51:55 +010078 int key_size_bits;
Christopher Faulet16f45c82018-02-16 11:23:49 +010079 __decl_hathreads(HA_RWLOCK_T lock); /* lock used to protect the ref */
Nenad Merdanovic146defa2015-05-09 08:46:00 +020080};
81
William Lallemand4f45bb92017-10-30 20:08:51 +010082/* shared ssl session */
83struct sh_ssl_sess_hdr {
84 struct ebmb_node key;
85 unsigned char key_data[SSL_MAX_SSL_SESSION_ID_LENGTH];
86};
87
Willy Tarreauc125cef2019-05-10 09:58:43 +020088#endif /* USE_OPENSSL */
Emeric Brunfc0421f2012-09-07 17:30:07 +020089#endif /* _TYPES_SSL_SOCK_H */