Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic.h @ 7648:b28ea685a56e quic
Moved all QUIC code into ngx_event_quic.c
Introduced ngx_quic_input() and ngx_quic_output() as interface between
nginx and protocol. They are the only functions that are exported.
While there, added copyrights.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Fri, 28 Feb 2020 16:23:25 +0300 |
parents | 3cb4f16426a5 |
children | 4ae9ac69ab93 |
comparison
equal
deleted
inserted
replaced
7647:3cb4f16426a5 | 7648:b28ea685a56e |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * | 3 * Copyright (C) Nginx, Inc. |
4 */ | 4 */ |
5 | 5 |
6 | 6 |
7 #ifndef _NGX_EVENT_QUIC_H_INCLUDED_ | 7 #ifndef _NGX_EVENT_QUIC_H_INCLUDED_ |
8 #define _NGX_EVENT_QUIC_H_INCLUDED_ | 8 #define _NGX_EVENT_QUIC_H_INCLUDED_ |
9 | 9 |
10 | 10 |
11 #include <ngx_event_openssl.h> | 11 #include <ngx_event_openssl.h> |
12 | 12 |
13 #define quic_version 0xff000018 | 13 /* TODO: get rid somehow of ssl argument? */ |
14 ngx_int_t ngx_quic_input(ngx_connection_t *c, ngx_ssl_t *ssl, ngx_buf_t *b); | |
15 ngx_int_t ngx_quic_output(ngx_connection_t *c); | |
16 | |
17 void ngx_quic_init_ssl_methods(SSL_CTX* ctx); | |
14 | 18 |
15 | 19 |
16 typedef struct { | |
17 ngx_str_t secret; | |
18 ngx_str_t key; | |
19 ngx_str_t iv; | |
20 ngx_str_t hp; | |
21 } ngx_quic_secret_t; | |
22 | |
23 | |
24 struct ngx_quic_connection_s { | |
25 ngx_str_t scid; | |
26 ngx_str_t dcid; | |
27 ngx_str_t token; | |
28 | |
29 ngx_quic_secret_t client_in; | |
30 ngx_quic_secret_t client_hs; | |
31 ngx_quic_secret_t client_ad; | |
32 ngx_quic_secret_t server_in; | |
33 ngx_quic_secret_t server_hs; | |
34 ngx_quic_secret_t server_ad; | |
35 }; | |
36 | |
37 | |
38 uint64_t ngx_quic_parse_pn(u_char **pos, ngx_int_t len, u_char *mask); | |
39 uint64_t ngx_quic_parse_int(u_char **pos); | |
40 void ngx_quic_build_int(u_char **pos, uint64_t value); | |
41 | |
42 ngx_int_t ngx_hkdf_extract(u_char *out_key, size_t *out_len, | |
43 const EVP_MD *digest, const u_char *secret, size_t secret_len, | |
44 const u_char *salt, size_t salt_len); | |
45 ngx_int_t ngx_hkdf_expand(u_char *out_key, size_t out_len, | |
46 const EVP_MD *digest, const u_char *prk, size_t prk_len, | |
47 const u_char *info, size_t info_len); | |
48 | |
49 ngx_int_t ngx_quic_hkdf_expand(ngx_connection_t *c, const EVP_MD *digest, | |
50 ngx_str_t *out, ngx_str_t *label, const uint8_t *prk, size_t prk_len); | |
51 | |
52 ngx_int_t ngx_quic_tls_open(ngx_connection_t *c, | |
53 const EVP_CIPHER *cipher, ngx_quic_secret_t *s, ngx_str_t *out, | |
54 u_char *nonce, ngx_str_t *in, ngx_str_t *ad); | |
55 ngx_int_t ngx_quic_tls_seal(ngx_connection_t *c, | |
56 const EVP_CIPHER *cipher, ngx_quic_secret_t *s, ngx_str_t *out, | |
57 u_char *nonce, ngx_str_t *in, ngx_str_t *ad); | |
58 | |
59 ngx_int_t | |
60 ngx_quic_tls_hp(ngx_connection_t *c, const EVP_CIPHER *cipher, | |
61 ngx_quic_secret_t *s, u_char *out, u_char *in); | |
62 | |
63 | |
64 #if (NGX_HAVE_NONALIGNED) | |
65 | |
66 #define ngx_quic_parse_uint16(p) ntohs(*(uint16_t *) (p)) | |
67 #define ngx_quic_parse_uint32(p) ntohl(*(uint32_t *) (p)) | |
68 | |
69 #else | |
70 | |
71 #define ngx_quic_parse_uint16(p) ((p)[0] << 8 | (p)[1]) | |
72 #define ngx_quic_parse_uint32(p) \ | |
73 ((uint32_t) (p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3]) | |
74 | |
75 #endif | |
76 | |
77 | |
78 #define ngx_quic_write_uint16_aligned(p, s) \ | |
79 (*(uint16_t *) (p) = htons((uint16_t) (s)), (p) + sizeof(uint16_t)) | |
80 #define ngx_quic_write_uint32_aligned(p, s) \ | |
81 (*(uint32_t *) (p) = htonl((uint32_t) (s)), (p) + sizeof(uint32_t)) | |
82 | |
83 #if (NGX_HAVE_NONALIGNED) | |
84 | |
85 #define ngx_quic_write_uint16 ngx_quic_write_uint16_aligned | |
86 #define ngx_quic_write_uint32 ngx_quic_write_uint32_aligned | |
87 | |
88 #else | |
89 | |
90 #define ngx_quic_write_uint16(p, s) \ | |
91 ((p)[0] = (u_char) ((s) >> 8), \ | |
92 (p)[1] = (u_char) (s), \ | |
93 (p) + sizeof(uint16_t)) | |
94 | |
95 #define ngx_quic_write_uint32(p, s) \ | |
96 ((p)[0] = (u_char) ((s) >> 24), \ | |
97 (p)[1] = (u_char) ((s) >> 16), \ | |
98 (p)[2] = (u_char) ((s) >> 8), \ | |
99 (p)[3] = (u_char) (s), \ | |
100 (p) + sizeof(uint32_t)) | |
101 | |
102 #endif | |
103 | |
104 #endif /* _NGX_EVENT_QUIC_H_INCLUDED_ */ | 20 #endif /* _NGX_EVENT_QUIC_H_INCLUDED_ */ |