annotate src/event/ngx_event_quic.h @ 8178:a9ff4392ecde quic

QUIC header protection routines, introduced ngx_quic_tls_hp().
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 28 Feb 2020 13:09:52 +0300
parents 76e29ff31cd3
children 7ee1ada04c8a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8167
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2 /*
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 *
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 */
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7 #ifndef _NGX_EVENT_QUIC_H_INCLUDED_
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 #define _NGX_EVENT_QUIC_H_INCLUDED_
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10
8170
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
11 #include <ngx_event_openssl.h>
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
12
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
13
8177
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
14 #ifdef OPENSSL_IS_BORINGSSL
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
15 #define ngx_aead_cipher_t EVP_AEAD
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
16 #define NGX_QUIC_INITIAL_CIPHER EVP_aead_aes_128_gcm()
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
17 #else
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
18 #define ngx_aead_cipher_t EVP_CIPHER
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
19 #define NGX_QUIC_INITIAL_CIPHER EVP_aes_128_gcm()
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
20 #endif
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
21
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
22
8175
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
23 typedef struct {
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
24 ngx_str_t secret;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
25 ngx_str_t key;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
26 ngx_str_t iv;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
27 ngx_str_t hp;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
28 } ngx_quic_secret_t;
8167
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
8168
b507592c15a7 Server Initial Keys.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8167
diff changeset
30
8175
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
31 struct ngx_quic_connection_s {
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
32 ngx_str_t scid;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
33 ngx_str_t dcid;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
34 ngx_str_t token;
8167
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35
8175
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
36 ngx_quic_secret_t client_in;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
37 ngx_quic_secret_t client_hs;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
38 ngx_quic_secret_t client_ad;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
39 ngx_quic_secret_t server_in;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
40 ngx_quic_secret_t server_hs;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
41 ngx_quic_secret_t server_ad;
8167
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 };
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44
8170
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
45 uint64_t ngx_quic_parse_pn(u_char **pos, ngx_int_t len, u_char *mask);
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
46 uint64_t ngx_quic_parse_int(u_char **pos);
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
47 void ngx_quic_build_int(u_char **pos, uint64_t value);
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
48
8171
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
49 ngx_int_t ngx_hkdf_extract(u_char *out_key, size_t *out_len,
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
50 const EVP_MD *digest, const u_char *secret, size_t secret_len,
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
51 const u_char *salt, size_t salt_len);
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
52 ngx_int_t ngx_hkdf_expand(u_char *out_key, size_t out_len,
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
53 const EVP_MD *digest, const u_char *prk, size_t prk_len,
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
54 const u_char *info, size_t info_len);
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
55
8177
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
56 ngx_int_t ngx_quic_tls_open(ngx_connection_t *c,
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
57 const ngx_aead_cipher_t *cipher, ngx_quic_secret_t *s, ngx_str_t *out,
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
58 u_char *nonce, ngx_str_t *in, ngx_str_t *ad);
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
59 ngx_int_t ngx_quic_tls_seal(ngx_connection_t *c,
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
60 const ngx_aead_cipher_t *cipher, ngx_quic_secret_t *s, ngx_str_t *out,
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
61 u_char *nonce, ngx_str_t *in, ngx_str_t *ad);
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
62
8178
a9ff4392ecde QUIC header protection routines, introduced ngx_quic_tls_hp().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8177
diff changeset
63 ngx_int_t
a9ff4392ecde QUIC header protection routines, introduced ngx_quic_tls_hp().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8177
diff changeset
64 ngx_quic_tls_hp(ngx_connection_t *c, const EVP_CIPHER *cipher,
a9ff4392ecde QUIC header protection routines, introduced ngx_quic_tls_hp().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8177
diff changeset
65 ngx_quic_secret_t *s, u_char *out, u_char *in);
8170
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
66
8167
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 #endif /* _NGX_EVENT_QUIC_H_INCLUDED_ */