Mercurial > hg > nginx-quic
diff 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 |
line wrap: on
line diff
--- a/src/event/ngx_event_quic.h +++ b/src/event/ngx_event_quic.h @@ -1,6 +1,6 @@ /* - * + * Copyright (C) Nginx, Inc. */ @@ -10,95 +10,11 @@ #include <ngx_event_openssl.h> -#define quic_version 0xff000018 - - -typedef struct { - ngx_str_t secret; - ngx_str_t key; - ngx_str_t iv; - ngx_str_t hp; -} ngx_quic_secret_t; - +/* TODO: get rid somehow of ssl argument? */ +ngx_int_t ngx_quic_input(ngx_connection_t *c, ngx_ssl_t *ssl, ngx_buf_t *b); +ngx_int_t ngx_quic_output(ngx_connection_t *c); -struct ngx_quic_connection_s { - ngx_str_t scid; - ngx_str_t dcid; - ngx_str_t token; - - ngx_quic_secret_t client_in; - ngx_quic_secret_t client_hs; - ngx_quic_secret_t client_ad; - ngx_quic_secret_t server_in; - ngx_quic_secret_t server_hs; - ngx_quic_secret_t server_ad; -}; +void ngx_quic_init_ssl_methods(SSL_CTX* ctx); -uint64_t ngx_quic_parse_pn(u_char **pos, ngx_int_t len, u_char *mask); -uint64_t ngx_quic_parse_int(u_char **pos); -void ngx_quic_build_int(u_char **pos, uint64_t value); - -ngx_int_t ngx_hkdf_extract(u_char *out_key, size_t *out_len, - const EVP_MD *digest, const u_char *secret, size_t secret_len, - const u_char *salt, size_t salt_len); -ngx_int_t ngx_hkdf_expand(u_char *out_key, size_t out_len, - const EVP_MD *digest, const u_char *prk, size_t prk_len, - const u_char *info, size_t info_len); - -ngx_int_t ngx_quic_hkdf_expand(ngx_connection_t *c, const EVP_MD *digest, - ngx_str_t *out, ngx_str_t *label, const uint8_t *prk, size_t prk_len); - -ngx_int_t ngx_quic_tls_open(ngx_connection_t *c, - const EVP_CIPHER *cipher, ngx_quic_secret_t *s, ngx_str_t *out, - u_char *nonce, ngx_str_t *in, ngx_str_t *ad); -ngx_int_t ngx_quic_tls_seal(ngx_connection_t *c, - const EVP_CIPHER *cipher, ngx_quic_secret_t *s, ngx_str_t *out, - u_char *nonce, ngx_str_t *in, ngx_str_t *ad); - -ngx_int_t -ngx_quic_tls_hp(ngx_connection_t *c, const EVP_CIPHER *cipher, - ngx_quic_secret_t *s, u_char *out, u_char *in); - - -#if (NGX_HAVE_NONALIGNED) - -#define ngx_quic_parse_uint16(p) ntohs(*(uint16_t *) (p)) -#define ngx_quic_parse_uint32(p) ntohl(*(uint32_t *) (p)) - -#else - -#define ngx_quic_parse_uint16(p) ((p)[0] << 8 | (p)[1]) -#define ngx_quic_parse_uint32(p) \ - ((uint32_t) (p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3]) - -#endif - - -#define ngx_quic_write_uint16_aligned(p, s) \ - (*(uint16_t *) (p) = htons((uint16_t) (s)), (p) + sizeof(uint16_t)) -#define ngx_quic_write_uint32_aligned(p, s) \ - (*(uint32_t *) (p) = htonl((uint32_t) (s)), (p) + sizeof(uint32_t)) - -#if (NGX_HAVE_NONALIGNED) - -#define ngx_quic_write_uint16 ngx_quic_write_uint16_aligned -#define ngx_quic_write_uint32 ngx_quic_write_uint32_aligned - -#else - -#define ngx_quic_write_uint16(p, s) \ - ((p)[0] = (u_char) ((s) >> 8), \ - (p)[1] = (u_char) (s), \ - (p) + sizeof(uint16_t)) - -#define ngx_quic_write_uint32(p, s) \ - ((p)[0] = (u_char) ((s) >> 24), \ - (p)[1] = (u_char) ((s) >> 16), \ - (p)[2] = (u_char) ((s) >> 8), \ - (p)[3] = (u_char) (s), \ - (p) + sizeof(uint32_t)) - -#endif - #endif /* _NGX_EVENT_QUIC_H_INCLUDED_ */