libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-auth-dns.h
Go to the documentation of this file.
1/*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2026 Andy Green <andy@warmcat.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
25#if defined(LWS_WITH_AUTHORITATIVE_DNS)
26
27struct auth_dns_rr {
28 lws_dll2_t list;
29
30 char *rdata;
31 size_t rdata_len;
32
33 uint8_t *wire_rdata;
34 size_t wire_rdata_len;
35};
36
37struct auth_dns_rrset {
38 lws_dll2_t list;
39 lws_dll2_owner_t rr_list;
40
41 char *name;
42 uint32_t ttl;
43 uint16_t class_;
44 uint16_t type;
45};
46
47struct auth_dns_zone {
48 lws_dll2_owner_t rrset_list;
49 char default_ttl[16];
50 char origin[256];
51};
52
54lws_auth_dns_parse_zone_buf(const char *buf, size_t len, struct auth_dns_zone *zone);
55
57lws_auth_dns_free_zone(struct auth_dns_zone *z);
58
59#define LWS_AUTH_DNS_NSEC3_HASH_LEN 20 /* SHA-1, the only NSEC3 hash */
60
77lws_auth_dns_nsec3_hash(const uint8_t *wire, size_t wire_len,
78 const uint8_t *salt, size_t salt_len,
79 unsigned int iterations, uint8_t *hash);
80
81/* the largest DNSKEY RDATA we express: 4 + 3 + e + 8192-bit RSA n */
82#define LWS_AUTH_DNS_DNSKEY_WIRE_MAX 1040
83
84/*
85 * A key's DNSKEY record, and the DS record for it the parent zone publishes,
86 * as the registrar asks for them
87 */
88
89struct lws_auth_dns_key_records {
90 char dnskey[((LWS_AUTH_DNS_DNSKEY_WIRE_MAX - 4 + 2) / 3) * 4 + 16];
92 char ds[128];
94 char digest[97];
96 uint16_t keytag;
97 uint8_t alg;
98 uint8_t digest_type;
99};
100
117lws_auth_dns_key_records(struct lws_jwk *jwk, const char *origin, int flags,
118 struct lws_auth_dns_key_records *r);
119
120struct lws_auth_dns_sign_info {
121 const char *input_filepath;
122 const char *output_filepath;
123 const char *jws_filepath; /* Path to output signed JWS of the zone */
124 const char *zsk_jwk_filepath; /* Path to ZSK JWK config */
125 const char *ksk_jwk_filepath; /* Path to KSK JWK config */
126 const char * (*subst_cb)(struct lws_auth_dns_sign_info *info, const char *name);
127 void *subst_priv;
128 const char **subst_names; /* For lws_strexp fallback */
129 const char **subst_values;
130 time_t sign_validity_start_time; /* 0 = now */
131 uint32_t sign_validity_duration; /* 0 = 30 days */
132 int num_substs;
133 const char *ipv4; /* detected external addresses, */
134 const char *ipv6; /* for subst_cb's ${EXTIP4} / ${EXTIP6} */
135 struct lws_context *cx; /* For logging/alloc */
136
137 const char *curr_line;
138 size_t curr_line_len;
139 uint8_t skip_line;
140};
141
148lws_auth_dns_sign_zone(struct lws_auth_dns_sign_info *info);
149
156lws_auth_dns_verify_zone(struct lws_auth_dns_sign_info *info);
157
158#endif
struct lws_dll2 lws_dll2_t
struct lws_dll2_owner lws_dll2_owner_t
unsigned short uint16_t
unsigned int uint32_t
#define LWS_EXTERN
unsigned char uint8_t
#define LWS_VISIBLE