comparison src/event/ngx_event_quic_protection.h @ 8221:69345a26ba69 quic

Split transport and crypto parts into separate files. New files: src/event/ngx_event_quic_protection.h src/event/ngx_event_quic_protection.c The protection.h header provides interface to the crypto part of the QUIC: 2 functions to initialize corresponding secrets: ngx_quic_set_initial_secret() ngx_quic_set_encryption_secret() and 2 functions to deal with packet processing: ngx_quic_encrypt() ngx_quic_decrypt() Also, structures representing secrets are defined there. All functions require SSL connection and a pool, only crypto operations inside, no access to nginx connections or events. Currently pool->log is used for the logging (instead of original c->log).
author Vladimir Homutov <vl@nginx.com>
date Mon, 16 Mar 2020 19:00:47 +0300
parents
children ae35ccba7aa6
comparison
equal deleted inserted replaced
8220:7ada2feeac18 8221:69345a26ba69
1
2 /*
3 * Copyright (C) Nginx, Inc.
4 */
5
6
7 #ifndef _NGX_EVENT_QUIC_PROTECTION_H_INCLUDED_
8 #define _NGX_EVENT_QUIC_PROTECTION_H_INCLUDED_
9
10
11 struct ngx_quic_secret_s {
12 ngx_str_t secret;
13 ngx_str_t key;
14 ngx_str_t iv;
15 ngx_str_t hp;
16 };
17
18
19 typedef struct {
20 ngx_quic_secret_t in;
21 ngx_quic_secret_t hs;
22 ngx_quic_secret_t ad;
23 } ngx_quic_peer_secrets_t;
24
25
26 typedef struct {
27 ngx_quic_peer_secrets_t client;
28 ngx_quic_peer_secrets_t server;
29 } ngx_quic_secrets_t;
30
31
32 ngx_int_t ngx_quic_set_initial_secret(ngx_pool_t *pool,
33 ngx_quic_secrets_t *secrets, ngx_str_t *secret);
34
35 int ngx_quic_set_encryption_secret(ngx_pool_t *pool, ngx_ssl_conn_t *ssl_conn,
36 enum ssl_encryption_level_t level, const uint8_t *secret, size_t secret_len,
37 ngx_quic_peer_secrets_t *qsec);
38
39 ngx_int_t ngx_quic_encrypt(ngx_pool_t *pool, ngx_ssl_conn_t *ssl_conn,
40 ngx_quic_header_t *pkt, ngx_str_t *payload, ngx_str_t *res);
41
42 ngx_int_t ngx_quic_decrypt(ngx_pool_t *pool, ngx_ssl_conn_t *ssl_conn,
43 ngx_quic_header_t *pkt);
44
45
46 #endif /* _NGX_EVENT_QUIC_PROTECTION_H_INCLUDED_ */