annotate src/event/ngx_event_quic.h @ 8181:3cb4f16426a5 quic

Introduced quic_version macro, uint16/uint32 routines ported.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 28 Feb 2020 13:09:52 +0300
parents 01dc595de244
children b28ea685a56e
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
8181
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
13 #define quic_version 0xff000018
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
14
8170
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
15
8175
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
16 typedef struct {
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
17 ngx_str_t secret;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
18 ngx_str_t key;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
19 ngx_str_t iv;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
20 ngx_str_t hp;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
21 } ngx_quic_secret_t;
8167
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
8168
b507592c15a7 Server Initial Keys.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8167
diff changeset
23
8175
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
24 struct ngx_quic_connection_s {
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
25 ngx_str_t scid;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
26 ngx_str_t dcid;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
27 ngx_str_t token;
8167
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28
8175
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
29 ngx_quic_secret_t client_in;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
30 ngx_quic_secret_t client_hs;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
31 ngx_quic_secret_t client_ad;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
32 ngx_quic_secret_t server_in;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
33 ngx_quic_secret_t server_hs;
72f632f90a17 Introduced ngx_quic_secret_t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8171
diff changeset
34 ngx_quic_secret_t server_ad;
8167
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 };
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
8170
53a5cdbe500c QUIC add_handshake_data callback, varint routines.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8169
diff changeset
38 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
39 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
40 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
41
8171
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
42 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
43 const EVP_MD *digest, const u_char *secret, size_t secret_len,
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
44 const u_char *salt, size_t salt_len);
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
45 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
46 const EVP_MD *digest, const u_char *prk, size_t prk_len,
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
47 const u_char *info, size_t info_len);
4daf03d2bd0a OpenSSL compatibility.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8170
diff changeset
48
8179
7ee1ada04c8a Generic function for HKDF expansion.
Vladimir Homutov <vl@nginx.com>
parents: 8178
diff changeset
49 ngx_int_t ngx_quic_hkdf_expand(ngx_connection_t *c, const EVP_MD *digest,
8180
01dc595de244 Cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8179
diff changeset
50 ngx_str_t *out, ngx_str_t *label, const uint8_t *prk, size_t prk_len);
8179
7ee1ada04c8a Generic function for HKDF expansion.
Vladimir Homutov <vl@nginx.com>
parents: 8178
diff changeset
51
8177
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
52 ngx_int_t ngx_quic_tls_open(ngx_connection_t *c,
8180
01dc595de244 Cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8179
diff changeset
53 const EVP_CIPHER *cipher, ngx_quic_secret_t *s, ngx_str_t *out,
8177
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
54 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
55 ngx_int_t ngx_quic_tls_seal(ngx_connection_t *c,
8180
01dc595de244 Cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8179
diff changeset
56 const EVP_CIPHER *cipher, ngx_quic_secret_t *s, ngx_str_t *out,
8177
76e29ff31cd3 AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8175
diff changeset
57 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
58
8178
a9ff4392ecde QUIC header protection routines, introduced ngx_quic_tls_hp().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8177
diff changeset
59 ngx_int_t
a9ff4392ecde QUIC header protection routines, introduced ngx_quic_tls_hp().
Sergey Kandaurov <pluknet@nginx.com>
parents: 8177
diff changeset
60 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
61 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
62
8181
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
63
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
64 #if (NGX_HAVE_NONALIGNED)
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
65
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
66 #define ngx_quic_parse_uint16(p) ntohs(*(uint16_t *) (p))
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
67 #define ngx_quic_parse_uint32(p) ntohl(*(uint32_t *) (p))
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
68
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
69 #else
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
70
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
71 #define ngx_quic_parse_uint16(p) ((p)[0] << 8 | (p)[1])
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
72 #define ngx_quic_parse_uint32(p) \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
73 ((uint32_t) (p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
74
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
75 #endif
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
76
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
77
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
78 #define ngx_quic_write_uint16_aligned(p, s) \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
79 (*(uint16_t *) (p) = htons((uint16_t) (s)), (p) + sizeof(uint16_t))
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
80 #define ngx_quic_write_uint32_aligned(p, s) \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
81 (*(uint32_t *) (p) = htonl((uint32_t) (s)), (p) + sizeof(uint32_t))
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
82
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
83 #if (NGX_HAVE_NONALIGNED)
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
84
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
85 #define ngx_quic_write_uint16 ngx_quic_write_uint16_aligned
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
86 #define ngx_quic_write_uint32 ngx_quic_write_uint32_aligned
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
87
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
88 #else
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
89
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
90 #define ngx_quic_write_uint16(p, s) \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
91 ((p)[0] = (u_char) ((s) >> 8), \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
92 (p)[1] = (u_char) (s), \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
93 (p) + sizeof(uint16_t))
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
94
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
95 #define ngx_quic_write_uint32(p, s) \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
96 ((p)[0] = (u_char) ((s) >> 24), \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
97 (p)[1] = (u_char) ((s) >> 16), \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
98 (p)[2] = (u_char) ((s) >> 8), \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
99 (p)[3] = (u_char) (s), \
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
100 (p) + sizeof(uint32_t))
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
101
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
102 #endif
3cb4f16426a5 Introduced quic_version macro, uint16/uint32 routines ported.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8180
diff changeset
103
8167
5d91389e0fd3 Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 #endif /* _NGX_EVENT_QUIC_H_INCLUDED_ */