1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 #include "alloc-util.h"
6 #include "dns-domain.h"
10 #include "resolved-dns-dnssec.h"
11 #include "resolved-dns-packet.h"
12 #include "resolved-dns-rr.h"
13 #include "string-table.h"
14 #include "string-util.h"
16 #include "terminal-util.h"
18 DnsResourceKey
* dns_resource_key_new(uint16_t class, uint16_t type
, const char *name
) {
25 k
= malloc0(sizeof(DnsResourceKey
) + l
+ 1);
33 strcpy((char*) k
+ sizeof(DnsResourceKey
), name
);
38 DnsResourceKey
* dns_resource_key_new_redirect(const DnsResourceKey
*key
, const DnsResourceRecord
*cname
) {
44 assert(IN_SET(cname
->key
->type
, DNS_TYPE_CNAME
, DNS_TYPE_DNAME
));
46 if (cname
->key
->type
== DNS_TYPE_CNAME
)
47 return dns_resource_key_new(key
->class, key
->type
, cname
->cname
.name
);
50 char *destination
= NULL
;
52 r
= dns_name_change_suffix(dns_resource_key_name(key
), dns_resource_key_name(cname
->key
), cname
->dname
.name
, &destination
);
56 return dns_resource_key_ref((DnsResourceKey
*) key
);
58 k
= dns_resource_key_new_consume(key
->class, key
->type
, destination
);
60 return mfree(destination
);
66 int dns_resource_key_new_append_suffix(DnsResourceKey
**ret
, DnsResourceKey
*key
, char *name
) {
67 DnsResourceKey
*new_key
;
75 if (dns_name_is_root(name
)) {
76 *ret
= dns_resource_key_ref(key
);
80 r
= dns_name_concat(dns_resource_key_name(key
), name
, &joined
);
84 new_key
= dns_resource_key_new_consume(key
->class, key
->type
, joined
);
94 DnsResourceKey
* dns_resource_key_new_consume(uint16_t class, uint16_t type
, char *name
) {
99 k
= new0(DnsResourceKey
, 1);
111 DnsResourceKey
* dns_resource_key_ref(DnsResourceKey
*k
) {
116 /* Static/const keys created with DNS_RESOURCE_KEY_CONST will
117 * set this to -1, they should not be reffed/unreffed */
118 assert(k
->n_ref
!= (unsigned) -1);
120 assert(k
->n_ref
> 0);
126 DnsResourceKey
* dns_resource_key_unref(DnsResourceKey
*k
) {
130 assert(k
->n_ref
!= (unsigned) -1);
131 assert(k
->n_ref
> 0);
142 const char* dns_resource_key_name(const DnsResourceKey
*key
) {
151 name
= (char*) key
+ sizeof(DnsResourceKey
);
153 if (dns_name_is_root(name
))
159 bool dns_resource_key_is_address(const DnsResourceKey
*key
) {
162 /* Check if this is an A or AAAA resource key */
164 return key
->class == DNS_CLASS_IN
&& IN_SET(key
->type
, DNS_TYPE_A
, DNS_TYPE_AAAA
);
167 bool dns_resource_key_is_dnssd_ptr(const DnsResourceKey
*key
) {
170 /* Check if this is a PTR resource key used in
171 Service Instance Enumeration as described in RFC6763 p4.1. */
173 if (key
->type
!= DNS_TYPE_PTR
)
176 return dns_name_endswith(dns_resource_key_name(key
), "_tcp.local") ||
177 dns_name_endswith(dns_resource_key_name(key
), "_udp.local");
180 int dns_resource_key_equal(const DnsResourceKey
*a
, const DnsResourceKey
*b
) {
186 r
= dns_name_equal(dns_resource_key_name(a
), dns_resource_key_name(b
));
190 if (a
->class != b
->class)
193 if (a
->type
!= b
->type
)
199 int dns_resource_key_match_rr(const DnsResourceKey
*key
, DnsResourceRecord
*rr
, const char *search_domain
) {
208 /* Checks if an rr matches the specified key. If a search
209 * domain is specified, it will also be checked if the key
210 * with the search domain suffixed might match the RR. */
212 if (rr
->key
->class != key
->class && key
->class != DNS_CLASS_ANY
)
215 if (rr
->key
->type
!= key
->type
&& key
->type
!= DNS_TYPE_ANY
)
218 r
= dns_name_equal(dns_resource_key_name(rr
->key
), dns_resource_key_name(key
));
223 _cleanup_free_
char *joined
= NULL
;
225 r
= dns_name_concat(dns_resource_key_name(key
), search_domain
, &joined
);
229 return dns_name_equal(dns_resource_key_name(rr
->key
), joined
);
235 int dns_resource_key_match_cname_or_dname(const DnsResourceKey
*key
, const DnsResourceKey
*cname
, const char *search_domain
) {
241 if (cname
->class != key
->class && key
->class != DNS_CLASS_ANY
)
244 if (cname
->type
== DNS_TYPE_CNAME
)
245 r
= dns_name_equal(dns_resource_key_name(key
), dns_resource_key_name(cname
));
246 else if (cname
->type
== DNS_TYPE_DNAME
)
247 r
= dns_name_endswith(dns_resource_key_name(key
), dns_resource_key_name(cname
));
255 _cleanup_free_
char *joined
= NULL
;
257 r
= dns_name_concat(dns_resource_key_name(key
), search_domain
, &joined
);
261 if (cname
->type
== DNS_TYPE_CNAME
)
262 return dns_name_equal(joined
, dns_resource_key_name(cname
));
263 else if (cname
->type
== DNS_TYPE_DNAME
)
264 return dns_name_endswith(joined
, dns_resource_key_name(cname
));
270 int dns_resource_key_match_soa(const DnsResourceKey
*key
, const DnsResourceKey
*soa
) {
274 /* Checks whether 'soa' is a SOA record for the specified key. */
276 if (soa
->class != key
->class)
279 if (soa
->type
!= DNS_TYPE_SOA
)
282 return dns_name_endswith(dns_resource_key_name(key
), dns_resource_key_name(soa
));
285 static void dns_resource_key_hash_func(const void *i
, struct siphash
*state
) {
286 const DnsResourceKey
*k
= i
;
290 dns_name_hash_func(dns_resource_key_name(k
), state
);
291 siphash24_compress(&k
->class, sizeof(k
->class), state
);
292 siphash24_compress(&k
->type
, sizeof(k
->type
), state
);
295 static int dns_resource_key_compare_func(const void *a
, const void *b
) {
296 const DnsResourceKey
*x
= a
, *y
= b
;
299 ret
= dns_name_compare_func(dns_resource_key_name(x
), dns_resource_key_name(y
));
303 ret
= CMP(x
->type
, y
->type
);
307 ret
= CMP(x
->class, y
->class);
314 const struct hash_ops dns_resource_key_hash_ops
= {
315 .hash
= dns_resource_key_hash_func
,
316 .compare
= dns_resource_key_compare_func
319 char* dns_resource_key_to_string(const DnsResourceKey
*key
, char *buf
, size_t buf_size
) {
323 /* If we cannot convert the CLASS/TYPE into a known string,
324 use the format recommended by RFC 3597, Section 5. */
326 c
= dns_class_to_string(key
->class);
327 t
= dns_type_to_string(key
->type
);
329 snprintf(buf
, buf_size
, "%s %s%s%.0u %s%s%.0u",
330 dns_resource_key_name(key
),
331 strempty(c
), c
? "" : "CLASS", c
? 0 : key
->class,
332 strempty(t
), t
? "" : "TYPE", t
? 0 : key
->type
);
337 bool dns_resource_key_reduce(DnsResourceKey
**a
, DnsResourceKey
**b
) {
341 /* Try to replace one RR key by another if they are identical, thus saving a bit of memory. Note that we do
342 * this only for RR keys, not for RRs themselves, as they carry a lot of additional metadata (where they come
343 * from, validity data, and suchlike), and cannot be replaced so easily by other RRs that have the same
344 * superficial data. */
351 /* We refuse merging const keys */
352 if ((*a
)->n_ref
== (unsigned) -1)
354 if ((*b
)->n_ref
== (unsigned) -1)
357 /* Already the same? */
361 /* Are they really identical? */
362 if (dns_resource_key_equal(*a
, *b
) <= 0)
365 /* Keep the one which already has more references. */
366 if ((*a
)->n_ref
> (*b
)->n_ref
) {
367 dns_resource_key_unref(*b
);
368 *b
= dns_resource_key_ref(*a
);
370 dns_resource_key_unref(*a
);
371 *a
= dns_resource_key_ref(*b
);
377 DnsResourceRecord
* dns_resource_record_new(DnsResourceKey
*key
) {
378 DnsResourceRecord
*rr
;
380 rr
= new0(DnsResourceRecord
, 1);
385 rr
->key
= dns_resource_key_ref(key
);
386 rr
->expiry
= USEC_INFINITY
;
387 rr
->n_skip_labels_signer
= rr
->n_skip_labels_source
= (unsigned) -1;
392 DnsResourceRecord
* dns_resource_record_new_full(uint16_t class, uint16_t type
, const char *name
) {
393 _cleanup_(dns_resource_key_unrefp
) DnsResourceKey
*key
= NULL
;
395 key
= dns_resource_key_new(class, type
, name
);
399 return dns_resource_record_new(key
);
402 static DnsResourceRecord
* dns_resource_record_free(DnsResourceRecord
*rr
) {
406 switch(rr
->key
->type
) {
426 dns_txt_item_free_all(rr
->txt
.items
);
435 free(rr
->mx
.exchange
);
443 free(rr
->sshfp
.fingerprint
);
446 case DNS_TYPE_DNSKEY
:
447 free(rr
->dnskey
.key
);
451 free(rr
->rrsig
.signer
);
452 free(rr
->rrsig
.signature
);
456 free(rr
->nsec
.next_domain_name
);
457 bitmap_free(rr
->nsec
.types
);
461 free(rr
->nsec3
.next_hashed_name
);
462 free(rr
->nsec3
.salt
);
463 bitmap_free(rr
->nsec3
.types
);
480 case DNS_TYPE_OPENPGPKEY
:
482 if (!rr
->unparseable
)
483 free(rr
->generic
.data
);
487 free(rr
->generic
.data
);
489 free(rr
->wire_format
);
490 dns_resource_key_unref(rr
->key
);
497 DEFINE_TRIVIAL_REF_UNREF_FUNC(DnsResourceRecord
, dns_resource_record
, dns_resource_record_free
);
499 int dns_resource_record_new_reverse(DnsResourceRecord
**ret
, int family
, const union in_addr_union
*address
, const char *hostname
) {
500 _cleanup_(dns_resource_key_unrefp
) DnsResourceKey
*key
= NULL
;
501 _cleanup_(dns_resource_record_unrefp
) DnsResourceRecord
*rr
= NULL
;
502 _cleanup_free_
char *ptr
= NULL
;
509 r
= dns_name_reverse(family
, address
, &ptr
);
513 key
= dns_resource_key_new_consume(DNS_CLASS_IN
, DNS_TYPE_PTR
, ptr
);
519 rr
= dns_resource_record_new(key
);
523 rr
->ptr
.name
= strdup(hostname
);
532 int dns_resource_record_new_address(DnsResourceRecord
**ret
, int family
, const union in_addr_union
*address
, const char *name
) {
533 DnsResourceRecord
*rr
;
539 if (family
== AF_INET
) {
541 rr
= dns_resource_record_new_full(DNS_CLASS_IN
, DNS_TYPE_A
, name
);
545 rr
->a
.in_addr
= address
->in
;
547 } else if (family
== AF_INET6
) {
549 rr
= dns_resource_record_new_full(DNS_CLASS_IN
, DNS_TYPE_AAAA
, name
);
553 rr
->aaaa
.in6_addr
= address
->in6
;
555 return -EAFNOSUPPORT
;
562 #define FIELD_EQUAL(a, b, field) \
563 ((a).field ## _size == (b).field ## _size && \
564 memcmp((a).field, (b).field, (a).field ## _size) == 0)
566 int dns_resource_record_equal(const DnsResourceRecord
*a
, const DnsResourceRecord
*b
) {
575 r
= dns_resource_key_equal(a
->key
, b
->key
);
579 if (a
->unparseable
!= b
->unparseable
)
582 switch (a
->unparseable
? _DNS_TYPE_INVALID
: a
->key
->type
) {
585 r
= dns_name_equal(a
->srv
.name
, b
->srv
.name
);
589 return a
->srv
.priority
== b
->srv
.priority
&&
590 a
->srv
.weight
== b
->srv
.weight
&&
591 a
->srv
.port
== b
->srv
.port
;
597 return dns_name_equal(a
->ptr
.name
, b
->ptr
.name
);
600 return strcaseeq(a
->hinfo
.cpu
, b
->hinfo
.cpu
) &&
601 strcaseeq(a
->hinfo
.os
, b
->hinfo
.os
);
603 case DNS_TYPE_SPF
: /* exactly the same as TXT */
605 return dns_txt_item_equal(a
->txt
.items
, b
->txt
.items
);
608 return memcmp(&a
->a
.in_addr
, &b
->a
.in_addr
, sizeof(struct in_addr
)) == 0;
611 return memcmp(&a
->aaaa
.in6_addr
, &b
->aaaa
.in6_addr
, sizeof(struct in6_addr
)) == 0;
614 r
= dns_name_equal(a
->soa
.mname
, b
->soa
.mname
);
617 r
= dns_name_equal(a
->soa
.rname
, b
->soa
.rname
);
621 return a
->soa
.serial
== b
->soa
.serial
&&
622 a
->soa
.refresh
== b
->soa
.refresh
&&
623 a
->soa
.retry
== b
->soa
.retry
&&
624 a
->soa
.expire
== b
->soa
.expire
&&
625 a
->soa
.minimum
== b
->soa
.minimum
;
628 if (a
->mx
.priority
!= b
->mx
.priority
)
631 return dns_name_equal(a
->mx
.exchange
, b
->mx
.exchange
);
634 assert(a
->loc
.version
== b
->loc
.version
);
636 return a
->loc
.size
== b
->loc
.size
&&
637 a
->loc
.horiz_pre
== b
->loc
.horiz_pre
&&
638 a
->loc
.vert_pre
== b
->loc
.vert_pre
&&
639 a
->loc
.latitude
== b
->loc
.latitude
&&
640 a
->loc
.longitude
== b
->loc
.longitude
&&
641 a
->loc
.altitude
== b
->loc
.altitude
;
644 return a
->ds
.key_tag
== b
->ds
.key_tag
&&
645 a
->ds
.algorithm
== b
->ds
.algorithm
&&
646 a
->ds
.digest_type
== b
->ds
.digest_type
&&
647 FIELD_EQUAL(a
->ds
, b
->ds
, digest
);
650 return a
->sshfp
.algorithm
== b
->sshfp
.algorithm
&&
651 a
->sshfp
.fptype
== b
->sshfp
.fptype
&&
652 FIELD_EQUAL(a
->sshfp
, b
->sshfp
, fingerprint
);
654 case DNS_TYPE_DNSKEY
:
655 return a
->dnskey
.flags
== b
->dnskey
.flags
&&
656 a
->dnskey
.protocol
== b
->dnskey
.protocol
&&
657 a
->dnskey
.algorithm
== b
->dnskey
.algorithm
&&
658 FIELD_EQUAL(a
->dnskey
, b
->dnskey
, key
);
661 /* do the fast comparisons first */
662 return a
->rrsig
.type_covered
== b
->rrsig
.type_covered
&&
663 a
->rrsig
.algorithm
== b
->rrsig
.algorithm
&&
664 a
->rrsig
.labels
== b
->rrsig
.labels
&&
665 a
->rrsig
.original_ttl
== b
->rrsig
.original_ttl
&&
666 a
->rrsig
.expiration
== b
->rrsig
.expiration
&&
667 a
->rrsig
.inception
== b
->rrsig
.inception
&&
668 a
->rrsig
.key_tag
== b
->rrsig
.key_tag
&&
669 FIELD_EQUAL(a
->rrsig
, b
->rrsig
, signature
) &&
670 dns_name_equal(a
->rrsig
.signer
, b
->rrsig
.signer
);
673 return dns_name_equal(a
->nsec
.next_domain_name
, b
->nsec
.next_domain_name
) &&
674 bitmap_equal(a
->nsec
.types
, b
->nsec
.types
);
677 return a
->nsec3
.algorithm
== b
->nsec3
.algorithm
&&
678 a
->nsec3
.flags
== b
->nsec3
.flags
&&
679 a
->nsec3
.iterations
== b
->nsec3
.iterations
&&
680 FIELD_EQUAL(a
->nsec3
, b
->nsec3
, salt
) &&
681 FIELD_EQUAL(a
->nsec3
, b
->nsec3
, next_hashed_name
) &&
682 bitmap_equal(a
->nsec3
.types
, b
->nsec3
.types
);
685 return a
->tlsa
.cert_usage
== b
->tlsa
.cert_usage
&&
686 a
->tlsa
.selector
== b
->tlsa
.selector
&&
687 a
->tlsa
.matching_type
== b
->tlsa
.matching_type
&&
688 FIELD_EQUAL(a
->tlsa
, b
->tlsa
, data
);
691 return a
->caa
.flags
== b
->caa
.flags
&&
692 streq(a
->caa
.tag
, b
->caa
.tag
) &&
693 FIELD_EQUAL(a
->caa
, b
->caa
, value
);
695 case DNS_TYPE_OPENPGPKEY
:
697 return FIELD_EQUAL(a
->generic
, b
->generic
, data
);
701 static char* format_location(uint32_t latitude
, uint32_t longitude
, uint32_t altitude
,
702 uint8_t size
, uint8_t horiz_pre
, uint8_t vert_pre
) {
704 char NS
= latitude
>= 1U<<31 ? 'N' : 'S';
705 char EW
= longitude
>= 1U<<31 ? 'E' : 'W';
707 int lat
= latitude
>= 1U<<31 ? (int) (latitude
- (1U<<31)) : (int) ((1U<<31) - latitude
);
708 int lon
= longitude
>= 1U<<31 ? (int) (longitude
- (1U<<31)) : (int) ((1U<<31) - longitude
);
709 double alt
= altitude
>= 10000000u ? altitude
- 10000000u : -(double)(10000000u - altitude
);
710 double siz
= (size
>> 4) * exp10((double) (size
& 0xF));
711 double hor
= (horiz_pre
>> 4) * exp10((double) (horiz_pre
& 0xF));
712 double ver
= (vert_pre
>> 4) * exp10((double) (vert_pre
& 0xF));
714 if (asprintf(&s
, "%d %d %.3f %c %d %d %.3f %c %.2fm %.2fm %.2fm %.2fm",
717 (lat
% 60000) / 1000.,
721 (lon
% 60000) / 1000.,
732 static int format_timestamp_dns(char *buf
, size_t l
, time_t sec
) {
736 assert(l
> STRLEN("YYYYMMDDHHmmSS"));
738 if (!gmtime_r(&sec
, &tm
))
741 if (strftime(buf
, l
, "%Y%m%d%H%M%S", &tm
) <= 0)
747 static char *format_types(Bitmap
*types
) {
748 _cleanup_strv_free_
char **strv
= NULL
;
749 _cleanup_free_
char *str
= NULL
;
754 BITMAP_FOREACH(type
, types
, i
) {
755 if (dns_type_to_string(type
)) {
756 r
= strv_extend(&strv
, dns_type_to_string(type
));
762 r
= asprintf(&t
, "TYPE%u", type
);
766 r
= strv_consume(&strv
, t
);
772 str
= strv_join(strv
, " ");
776 return strjoin("( ", str
, " )");
779 static char *format_txt(DnsTxtItem
*first
) {
784 LIST_FOREACH(items
, i
, first
)
785 c
+= i
->length
* 4 + 3;
787 p
= s
= new(char, c
);
791 LIST_FOREACH(items
, i
, first
) {
799 for (j
= 0; j
< i
->length
; j
++) {
800 if (i
->data
[j
] < ' ' || i
->data
[j
] == '"' || i
->data
[j
] >= 127) {
802 *(p
++) = '0' + (i
->data
[j
] / 100);
803 *(p
++) = '0' + ((i
->data
[j
] / 10) % 10);
804 *(p
++) = '0' + (i
->data
[j
] % 10);
816 const char *dns_resource_record_to_string(DnsResourceRecord
*rr
) {
817 _cleanup_free_
char *t
= NULL
;
818 char *s
, k
[DNS_RESOURCE_KEY_STRING_MAX
];
824 return rr
->to_string
;
826 dns_resource_key_to_string(rr
->key
, k
, sizeof(k
));
828 switch (rr
->unparseable
? _DNS_TYPE_INVALID
: rr
->key
->type
) {
831 r
= asprintf(&s
, "%s %u %u %u %s",
836 strna(rr
->srv
.name
));
845 s
= strjoin(k
, " ", rr
->ptr
.name
);
852 s
= strjoin(k
, " ", rr
->hinfo
.cpu
, " ", rr
->hinfo
.os
);
857 case DNS_TYPE_SPF
: /* exactly the same as TXT */
859 t
= format_txt(rr
->txt
.items
);
863 s
= strjoin(k
, " ", t
);
869 _cleanup_free_
char *x
= NULL
;
871 r
= in_addr_to_string(AF_INET
, (const union in_addr_union
*) &rr
->a
.in_addr
, &x
);
875 s
= strjoin(k
, " ", x
);
882 r
= in_addr_to_string(AF_INET6
, (const union in_addr_union
*) &rr
->aaaa
.in6_addr
, &t
);
886 s
= strjoin(k
, " ", t
);
892 r
= asprintf(&s
, "%s %s %s %u %u %u %u %u",
894 strna(rr
->soa
.mname
),
895 strna(rr
->soa
.rname
),
906 r
= asprintf(&s
, "%s %u %s",
915 assert(rr
->loc
.version
== 0);
917 t
= format_location(rr
->loc
.latitude
,
926 s
= strjoin(k
, " ", t
);
932 t
= hexmem(rr
->ds
.digest
, rr
->ds
.digest_size
);
936 r
= asprintf(&s
, "%s %u %u %u %s",
947 t
= hexmem(rr
->sshfp
.fingerprint
, rr
->sshfp
.fingerprint_size
);
951 r
= asprintf(&s
, "%s %u %u %s",
960 case DNS_TYPE_DNSKEY
: {
961 _cleanup_free_
char *alg
= NULL
;
966 key_tag
= dnssec_keytag(rr
, true);
968 r
= dnssec_algorithm_to_string_alloc(rr
->dnskey
.algorithm
, &alg
);
972 r
= asprintf(&s
, "%s %u %u %s %n",
981 r
= base64_append(&s
, n
,
982 rr
->dnskey
.key
, rr
->dnskey
.key_size
,
987 r
= asprintf(&ss
, "%s\n"
991 rr
->dnskey
.flags
& DNSKEY_FLAG_SEP
? " SEP" : "",
992 rr
->dnskey
.flags
& DNSKEY_FLAG_REVOKE
? " REVOKE" : "",
993 rr
->dnskey
.flags
& DNSKEY_FLAG_ZONE_KEY
? " ZONE_KEY" : "",
1003 case DNS_TYPE_RRSIG
: {
1004 _cleanup_free_
char *alg
= NULL
;
1005 char expiration
[STRLEN("YYYYMMDDHHmmSS") + 1], inception
[STRLEN("YYYYMMDDHHmmSS") + 1];
1009 type
= dns_type_to_string(rr
->rrsig
.type_covered
);
1011 r
= dnssec_algorithm_to_string_alloc(rr
->rrsig
.algorithm
, &alg
);
1015 r
= format_timestamp_dns(expiration
, sizeof(expiration
), rr
->rrsig
.expiration
);
1019 r
= format_timestamp_dns(inception
, sizeof(inception
), rr
->rrsig
.inception
);
1024 * http://tools.ietf.org/html/rfc3597#section-5 */
1026 r
= asprintf(&s
, "%s %s%.*u %s %u %u %s %s %u %s %n",
1029 type
? 0 : 1, type
? 0u : (unsigned) rr
->rrsig
.type_covered
,
1032 rr
->rrsig
.original_ttl
,
1041 r
= base64_append(&s
, n
,
1042 rr
->rrsig
.signature
, rr
->rrsig
.signature_size
,
1051 t
= format_types(rr
->nsec
.types
);
1055 r
= asprintf(&s
, "%s %s %s",
1057 rr
->nsec
.next_domain_name
,
1063 case DNS_TYPE_NSEC3
: {
1064 _cleanup_free_
char *salt
= NULL
, *hash
= NULL
;
1066 if (rr
->nsec3
.salt_size
> 0) {
1067 salt
= hexmem(rr
->nsec3
.salt
, rr
->nsec3
.salt_size
);
1072 hash
= base32hexmem(rr
->nsec3
.next_hashed_name
, rr
->nsec3
.next_hashed_name_size
, false);
1076 t
= format_types(rr
->nsec3
.types
);
1080 r
= asprintf(&s
, "%s %"PRIu8
" %"PRIu8
" %"PRIu16
" %s %s %s",
1082 rr
->nsec3
.algorithm
,
1084 rr
->nsec3
.iterations
,
1085 rr
->nsec3
.salt_size
> 0 ? salt
: "-",
1094 case DNS_TYPE_TLSA
: {
1095 const char *cert_usage
, *selector
, *matching_type
;
1097 cert_usage
= tlsa_cert_usage_to_string(rr
->tlsa
.cert_usage
);
1098 selector
= tlsa_selector_to_string(rr
->tlsa
.selector
);
1099 matching_type
= tlsa_matching_type_to_string(rr
->tlsa
.matching_type
);
1101 t
= hexmem(rr
->sshfp
.fingerprint
, rr
->sshfp
.fingerprint_size
);
1107 " -- Cert. usage: %s\n"
1108 " -- Selector: %s\n"
1109 " -- Matching type: %s",
1111 rr
->tlsa
.cert_usage
,
1113 rr
->tlsa
.matching_type
,
1124 case DNS_TYPE_CAA
: {
1125 _cleanup_free_
char *value
;
1127 value
= octescape(rr
->caa
.value
, rr
->caa
.value_size
);
1131 r
= asprintf(&s
, "%s %u %s \"%s\"%s%s%s%.0u",
1136 rr
->caa
.flags
? "\n -- Flags:" : "",
1137 rr
->caa
.flags
& CAA_FLAG_CRITICAL
? " critical" : "",
1138 rr
->caa
.flags
& ~CAA_FLAG_CRITICAL
? " " : "",
1139 rr
->caa
.flags
& ~CAA_FLAG_CRITICAL
);
1146 case DNS_TYPE_OPENPGPKEY
: {
1149 r
= asprintf(&s
, "%s %n",
1155 r
= base64_append(&s
, n
,
1156 rr
->generic
.data
, rr
->generic
.data_size
,
1164 t
= hexmem(rr
->generic
.data
, rr
->generic
.data_size
);
1168 /* Format as documented in RFC 3597, Section 5 */
1169 r
= asprintf(&s
, "%s \\# %zu %s", k
, rr
->generic
.data_size
, t
);
1179 ssize_t
dns_resource_record_payload(DnsResourceRecord
*rr
, void **out
) {
1183 switch(rr
->unparseable
? _DNS_TYPE_INVALID
: rr
->key
->type
) {
1187 case DNS_TYPE_CNAME
:
1188 case DNS_TYPE_DNAME
:
1189 case DNS_TYPE_HINFO
:
1198 case DNS_TYPE_DNSKEY
:
1199 case DNS_TYPE_RRSIG
:
1201 case DNS_TYPE_NSEC3
:
1204 case DNS_TYPE_SSHFP
:
1205 *out
= rr
->sshfp
.fingerprint
;
1206 return rr
->sshfp
.fingerprint_size
;
1209 *out
= rr
->tlsa
.data
;
1210 return rr
->tlsa
.data_size
;
1212 case DNS_TYPE_OPENPGPKEY
:
1214 *out
= rr
->generic
.data
;
1215 return rr
->generic
.data_size
;
1219 int dns_resource_record_to_wire_format(DnsResourceRecord
*rr
, bool canonical
) {
1221 DnsPacket packet
= {
1223 .protocol
= DNS_PROTOCOL_DNS
,
1225 .refuse_compression
= true,
1226 .canonical_form
= canonical
,
1234 /* Generates the RR in wire-format, optionally in the
1235 * canonical form as discussed in the DNSSEC RFC 4034, Section
1236 * 6.2. We allocate a throw-away DnsPacket object on the stack
1237 * here, because we need some book-keeping for memory
1238 * management, and can reuse the DnsPacket serializer, that
1239 * can generate the canonical form, too, but also knows label
1240 * compression and suchlike. */
1242 if (rr
->wire_format
&& rr
->wire_format_canonical
== canonical
)
1245 r
= dns_packet_append_rr(&packet
, rr
, 0, &start
, &rds
);
1250 assert(packet
._data
);
1252 free(rr
->wire_format
);
1253 rr
->wire_format
= packet
._data
;
1254 rr
->wire_format_size
= packet
.size
;
1255 rr
->wire_format_rdata_offset
= rds
;
1256 rr
->wire_format_canonical
= canonical
;
1258 packet
._data
= NULL
;
1259 dns_packet_unref(&packet
);
1264 int dns_resource_record_signer(DnsResourceRecord
*rr
, const char **ret
) {
1271 /* Returns the RRset's signer, if it is known. */
1273 if (rr
->n_skip_labels_signer
== (unsigned) -1)
1276 n
= dns_resource_key_name(rr
->key
);
1277 r
= dns_name_skip(n
, rr
->n_skip_labels_signer
, &n
);
1287 int dns_resource_record_source(DnsResourceRecord
*rr
, const char **ret
) {
1294 /* Returns the RRset's synthesizing source, if it is known. */
1296 if (rr
->n_skip_labels_source
== (unsigned) -1)
1299 n
= dns_resource_key_name(rr
->key
);
1300 r
= dns_name_skip(n
, rr
->n_skip_labels_source
, &n
);
1310 int dns_resource_record_is_signer(DnsResourceRecord
*rr
, const char *zone
) {
1316 r
= dns_resource_record_signer(rr
, &signer
);
1320 return dns_name_equal(zone
, signer
);
1323 int dns_resource_record_is_synthetic(DnsResourceRecord
*rr
) {
1328 /* Returns > 0 if the RR is generated from a wildcard, and is not the asterisk name itself */
1330 if (rr
->n_skip_labels_source
== (unsigned) -1)
1333 if (rr
->n_skip_labels_source
== 0)
1336 if (rr
->n_skip_labels_source
> 1)
1339 r
= dns_name_startswith(dns_resource_key_name(rr
->key
), "*");
1346 void dns_resource_record_hash_func(const void *i
, struct siphash
*state
) {
1347 const DnsResourceRecord
*rr
= i
;
1351 dns_resource_key_hash_func(rr
->key
, state
);
1353 switch (rr
->unparseable
? _DNS_TYPE_INVALID
: rr
->key
->type
) {
1356 siphash24_compress(&rr
->srv
.priority
, sizeof(rr
->srv
.priority
), state
);
1357 siphash24_compress(&rr
->srv
.weight
, sizeof(rr
->srv
.weight
), state
);
1358 siphash24_compress(&rr
->srv
.port
, sizeof(rr
->srv
.port
), state
);
1359 dns_name_hash_func(rr
->srv
.name
, state
);
1364 case DNS_TYPE_CNAME
:
1365 case DNS_TYPE_DNAME
:
1366 dns_name_hash_func(rr
->ptr
.name
, state
);
1369 case DNS_TYPE_HINFO
:
1370 string_hash_func(rr
->hinfo
.cpu
, state
);
1371 string_hash_func(rr
->hinfo
.os
, state
);
1375 case DNS_TYPE_SPF
: {
1378 LIST_FOREACH(items
, j
, rr
->txt
.items
) {
1379 siphash24_compress(j
->data
, j
->length
, state
);
1381 /* Add an extra NUL byte, so that "a" followed by "b" doesn't result in the same hash as "ab"
1382 * followed by "". */
1383 siphash24_compress_byte(0, state
);
1389 siphash24_compress(&rr
->a
.in_addr
, sizeof(rr
->a
.in_addr
), state
);
1393 siphash24_compress(&rr
->aaaa
.in6_addr
, sizeof(rr
->aaaa
.in6_addr
), state
);
1397 dns_name_hash_func(rr
->soa
.mname
, state
);
1398 dns_name_hash_func(rr
->soa
.rname
, state
);
1399 siphash24_compress(&rr
->soa
.serial
, sizeof(rr
->soa
.serial
), state
);
1400 siphash24_compress(&rr
->soa
.refresh
, sizeof(rr
->soa
.refresh
), state
);
1401 siphash24_compress(&rr
->soa
.retry
, sizeof(rr
->soa
.retry
), state
);
1402 siphash24_compress(&rr
->soa
.expire
, sizeof(rr
->soa
.expire
), state
);
1403 siphash24_compress(&rr
->soa
.minimum
, sizeof(rr
->soa
.minimum
), state
);
1407 siphash24_compress(&rr
->mx
.priority
, sizeof(rr
->mx
.priority
), state
);
1408 dns_name_hash_func(rr
->mx
.exchange
, state
);
1412 siphash24_compress(&rr
->loc
.version
, sizeof(rr
->loc
.version
), state
);
1413 siphash24_compress(&rr
->loc
.size
, sizeof(rr
->loc
.size
), state
);
1414 siphash24_compress(&rr
->loc
.horiz_pre
, sizeof(rr
->loc
.horiz_pre
), state
);
1415 siphash24_compress(&rr
->loc
.vert_pre
, sizeof(rr
->loc
.vert_pre
), state
);
1416 siphash24_compress(&rr
->loc
.latitude
, sizeof(rr
->loc
.latitude
), state
);
1417 siphash24_compress(&rr
->loc
.longitude
, sizeof(rr
->loc
.longitude
), state
);
1418 siphash24_compress(&rr
->loc
.altitude
, sizeof(rr
->loc
.altitude
), state
);
1421 case DNS_TYPE_SSHFP
:
1422 siphash24_compress(&rr
->sshfp
.algorithm
, sizeof(rr
->sshfp
.algorithm
), state
);
1423 siphash24_compress(&rr
->sshfp
.fptype
, sizeof(rr
->sshfp
.fptype
), state
);
1424 siphash24_compress(rr
->sshfp
.fingerprint
, rr
->sshfp
.fingerprint_size
, state
);
1427 case DNS_TYPE_DNSKEY
:
1428 siphash24_compress(&rr
->dnskey
.flags
, sizeof(rr
->dnskey
.flags
), state
);
1429 siphash24_compress(&rr
->dnskey
.protocol
, sizeof(rr
->dnskey
.protocol
), state
);
1430 siphash24_compress(&rr
->dnskey
.algorithm
, sizeof(rr
->dnskey
.algorithm
), state
);
1431 siphash24_compress(rr
->dnskey
.key
, rr
->dnskey
.key_size
, state
);
1434 case DNS_TYPE_RRSIG
:
1435 siphash24_compress(&rr
->rrsig
.type_covered
, sizeof(rr
->rrsig
.type_covered
), state
);
1436 siphash24_compress(&rr
->rrsig
.algorithm
, sizeof(rr
->rrsig
.algorithm
), state
);
1437 siphash24_compress(&rr
->rrsig
.labels
, sizeof(rr
->rrsig
.labels
), state
);
1438 siphash24_compress(&rr
->rrsig
.original_ttl
, sizeof(rr
->rrsig
.original_ttl
), state
);
1439 siphash24_compress(&rr
->rrsig
.expiration
, sizeof(rr
->rrsig
.expiration
), state
);
1440 siphash24_compress(&rr
->rrsig
.inception
, sizeof(rr
->rrsig
.inception
), state
);
1441 siphash24_compress(&rr
->rrsig
.key_tag
, sizeof(rr
->rrsig
.key_tag
), state
);
1442 dns_name_hash_func(rr
->rrsig
.signer
, state
);
1443 siphash24_compress(rr
->rrsig
.signature
, rr
->rrsig
.signature_size
, state
);
1447 dns_name_hash_func(rr
->nsec
.next_domain_name
, state
);
1448 /* FIXME: we leave out the type bitmap here. Hash
1449 * would be better if we'd take it into account
1454 siphash24_compress(&rr
->ds
.key_tag
, sizeof(rr
->ds
.key_tag
), state
);
1455 siphash24_compress(&rr
->ds
.algorithm
, sizeof(rr
->ds
.algorithm
), state
);
1456 siphash24_compress(&rr
->ds
.digest_type
, sizeof(rr
->ds
.digest_type
), state
);
1457 siphash24_compress(rr
->ds
.digest
, rr
->ds
.digest_size
, state
);
1460 case DNS_TYPE_NSEC3
:
1461 siphash24_compress(&rr
->nsec3
.algorithm
, sizeof(rr
->nsec3
.algorithm
), state
);
1462 siphash24_compress(&rr
->nsec3
.flags
, sizeof(rr
->nsec3
.flags
), state
);
1463 siphash24_compress(&rr
->nsec3
.iterations
, sizeof(rr
->nsec3
.iterations
), state
);
1464 siphash24_compress(rr
->nsec3
.salt
, rr
->nsec3
.salt_size
, state
);
1465 siphash24_compress(rr
->nsec3
.next_hashed_name
, rr
->nsec3
.next_hashed_name_size
, state
);
1466 /* FIXME: We leave the bitmaps out */
1470 siphash24_compress(&rr
->tlsa
.cert_usage
, sizeof(rr
->tlsa
.cert_usage
), state
);
1471 siphash24_compress(&rr
->tlsa
.selector
, sizeof(rr
->tlsa
.selector
), state
);
1472 siphash24_compress(&rr
->tlsa
.matching_type
, sizeof(rr
->tlsa
.matching_type
), state
);
1473 siphash24_compress(rr
->tlsa
.data
, rr
->tlsa
.data_size
, state
);
1477 siphash24_compress(&rr
->caa
.flags
, sizeof(rr
->caa
.flags
), state
);
1478 string_hash_func(rr
->caa
.tag
, state
);
1479 siphash24_compress(rr
->caa
.value
, rr
->caa
.value_size
, state
);
1482 case DNS_TYPE_OPENPGPKEY
:
1484 siphash24_compress(rr
->generic
.data
, rr
->generic
.data_size
, state
);
1489 static int dns_resource_record_compare_func(const void *a
, const void *b
) {
1490 const DnsResourceRecord
*x
= a
, *y
= b
;
1493 ret
= dns_resource_key_compare_func(x
->key
, y
->key
);
1497 if (dns_resource_record_equal(x
, y
))
1500 /* We still use CMP() here, even though don't implement proper
1501 * ordering, since the hashtable doesn't need ordering anyway. */
1505 const struct hash_ops dns_resource_record_hash_ops
= {
1506 .hash
= dns_resource_record_hash_func
,
1507 .compare
= dns_resource_record_compare_func
,
1510 DnsResourceRecord
*dns_resource_record_copy(DnsResourceRecord
*rr
) {
1511 _cleanup_(dns_resource_record_unrefp
) DnsResourceRecord
*copy
= NULL
;
1512 DnsResourceRecord
*t
;
1516 copy
= dns_resource_record_new(rr
->key
);
1520 copy
->ttl
= rr
->ttl
;
1521 copy
->expiry
= rr
->expiry
;
1522 copy
->n_skip_labels_signer
= rr
->n_skip_labels_signer
;
1523 copy
->n_skip_labels_source
= rr
->n_skip_labels_source
;
1524 copy
->unparseable
= rr
->unparseable
;
1526 switch (rr
->unparseable
? _DNS_TYPE_INVALID
: rr
->key
->type
) {
1529 copy
->srv
.priority
= rr
->srv
.priority
;
1530 copy
->srv
.weight
= rr
->srv
.weight
;
1531 copy
->srv
.port
= rr
->srv
.port
;
1532 copy
->srv
.name
= strdup(rr
->srv
.name
);
1533 if (!copy
->srv
.name
)
1539 case DNS_TYPE_CNAME
:
1540 case DNS_TYPE_DNAME
:
1541 copy
->ptr
.name
= strdup(rr
->ptr
.name
);
1542 if (!copy
->ptr
.name
)
1546 case DNS_TYPE_HINFO
:
1547 copy
->hinfo
.cpu
= strdup(rr
->hinfo
.cpu
);
1548 if (!copy
->hinfo
.cpu
)
1551 copy
->hinfo
.os
= strdup(rr
->hinfo
.os
);
1552 if (!copy
->hinfo
.os
)
1558 copy
->txt
.items
= dns_txt_item_copy(rr
->txt
.items
);
1559 if (!copy
->txt
.items
)
1568 copy
->aaaa
= rr
->aaaa
;
1572 copy
->soa
.mname
= strdup(rr
->soa
.mname
);
1573 if (!copy
->soa
.mname
)
1575 copy
->soa
.rname
= strdup(rr
->soa
.rname
);
1576 if (!copy
->soa
.rname
)
1578 copy
->soa
.serial
= rr
->soa
.serial
;
1579 copy
->soa
.refresh
= rr
->soa
.refresh
;
1580 copy
->soa
.retry
= rr
->soa
.retry
;
1581 copy
->soa
.expire
= rr
->soa
.expire
;
1582 copy
->soa
.minimum
= rr
->soa
.minimum
;
1586 copy
->mx
.priority
= rr
->mx
.priority
;
1587 copy
->mx
.exchange
= strdup(rr
->mx
.exchange
);
1588 if (!copy
->mx
.exchange
)
1593 copy
->loc
= rr
->loc
;
1596 case DNS_TYPE_SSHFP
:
1597 copy
->sshfp
.algorithm
= rr
->sshfp
.algorithm
;
1598 copy
->sshfp
.fptype
= rr
->sshfp
.fptype
;
1599 copy
->sshfp
.fingerprint
= memdup(rr
->sshfp
.fingerprint
, rr
->sshfp
.fingerprint_size
);
1600 if (!copy
->sshfp
.fingerprint
)
1602 copy
->sshfp
.fingerprint_size
= rr
->sshfp
.fingerprint_size
;
1605 case DNS_TYPE_DNSKEY
:
1606 copy
->dnskey
.flags
= rr
->dnskey
.flags
;
1607 copy
->dnskey
.protocol
= rr
->dnskey
.protocol
;
1608 copy
->dnskey
.algorithm
= rr
->dnskey
.algorithm
;
1609 copy
->dnskey
.key
= memdup(rr
->dnskey
.key
, rr
->dnskey
.key_size
);
1610 if (!copy
->dnskey
.key
)
1612 copy
->dnskey
.key_size
= rr
->dnskey
.key_size
;
1615 case DNS_TYPE_RRSIG
:
1616 copy
->rrsig
.type_covered
= rr
->rrsig
.type_covered
;
1617 copy
->rrsig
.algorithm
= rr
->rrsig
.algorithm
;
1618 copy
->rrsig
.labels
= rr
->rrsig
.labels
;
1619 copy
->rrsig
.original_ttl
= rr
->rrsig
.original_ttl
;
1620 copy
->rrsig
.expiration
= rr
->rrsig
.expiration
;
1621 copy
->rrsig
.inception
= rr
->rrsig
.inception
;
1622 copy
->rrsig
.key_tag
= rr
->rrsig
.key_tag
;
1623 copy
->rrsig
.signer
= strdup(rr
->rrsig
.signer
);
1624 if (!copy
->rrsig
.signer
)
1626 copy
->rrsig
.signature
= memdup(rr
->rrsig
.signature
, rr
->rrsig
.signature_size
);
1627 if (!copy
->rrsig
.signature
)
1629 copy
->rrsig
.signature_size
= rr
->rrsig
.signature_size
;
1633 copy
->nsec
.next_domain_name
= strdup(rr
->nsec
.next_domain_name
);
1634 if (!copy
->nsec
.next_domain_name
)
1636 copy
->nsec
.types
= bitmap_copy(rr
->nsec
.types
);
1637 if (!copy
->nsec
.types
)
1642 copy
->ds
.key_tag
= rr
->ds
.key_tag
;
1643 copy
->ds
.algorithm
= rr
->ds
.algorithm
;
1644 copy
->ds
.digest_type
= rr
->ds
.digest_type
;
1645 copy
->ds
.digest
= memdup(rr
->ds
.digest
, rr
->ds
.digest_size
);
1646 if (!copy
->ds
.digest
)
1648 copy
->ds
.digest_size
= rr
->ds
.digest_size
;
1651 case DNS_TYPE_NSEC3
:
1652 copy
->nsec3
.algorithm
= rr
->nsec3
.algorithm
;
1653 copy
->nsec3
.flags
= rr
->nsec3
.flags
;
1654 copy
->nsec3
.iterations
= rr
->nsec3
.iterations
;
1655 copy
->nsec3
.salt
= memdup(rr
->nsec3
.salt
, rr
->nsec3
.salt_size
);
1656 if (!copy
->nsec3
.salt
)
1658 copy
->nsec3
.salt_size
= rr
->nsec3
.salt_size
;
1659 copy
->nsec3
.next_hashed_name
= memdup(rr
->nsec3
.next_hashed_name
, rr
->nsec3
.next_hashed_name_size
);
1660 if (!copy
->nsec3
.next_hashed_name_size
)
1662 copy
->nsec3
.next_hashed_name_size
= rr
->nsec3
.next_hashed_name_size
;
1663 copy
->nsec3
.types
= bitmap_copy(rr
->nsec3
.types
);
1664 if (!copy
->nsec3
.types
)
1669 copy
->tlsa
.cert_usage
= rr
->tlsa
.cert_usage
;
1670 copy
->tlsa
.selector
= rr
->tlsa
.selector
;
1671 copy
->tlsa
.matching_type
= rr
->tlsa
.matching_type
;
1672 copy
->tlsa
.data
= memdup(rr
->tlsa
.data
, rr
->tlsa
.data_size
);
1673 if (!copy
->tlsa
.data
)
1675 copy
->tlsa
.data_size
= rr
->tlsa
.data_size
;
1679 copy
->caa
.flags
= rr
->caa
.flags
;
1680 copy
->caa
.tag
= strdup(rr
->caa
.tag
);
1683 copy
->caa
.value
= memdup(rr
->caa
.value
, rr
->caa
.value_size
);
1684 if (!copy
->caa
.value
)
1686 copy
->caa
.value_size
= rr
->caa
.value_size
;
1691 copy
->generic
.data
= memdup(rr
->generic
.data
, rr
->generic
.data_size
);
1692 if (!copy
->generic
.data
)
1694 copy
->generic
.data_size
= rr
->generic
.data_size
;
1703 int dns_resource_record_clamp_ttl(DnsResourceRecord
**rr
, uint32_t max_ttl
) {
1704 DnsResourceRecord
*old_rr
, *new_rr
;
1710 if (old_rr
->key
->type
== DNS_TYPE_OPT
)
1713 new_ttl
= MIN(old_rr
->ttl
, max_ttl
);
1714 if (new_ttl
== old_rr
->ttl
)
1717 if (old_rr
->n_ref
== 1) {
1718 /* Patch in place */
1719 old_rr
->ttl
= new_ttl
;
1723 new_rr
= dns_resource_record_copy(old_rr
);
1727 new_rr
->ttl
= new_ttl
;
1729 dns_resource_record_unref(*rr
);
1735 DnsTxtItem
*dns_txt_item_free_all(DnsTxtItem
*i
) {
1744 return dns_txt_item_free_all(n
);
1747 bool dns_txt_item_equal(DnsTxtItem
*a
, DnsTxtItem
*b
) {
1758 if (a
->length
!= b
->length
)
1761 if (memcmp(a
->data
, b
->data
, a
->length
) != 0)
1764 return dns_txt_item_equal(a
->items_next
, b
->items_next
);
1767 DnsTxtItem
*dns_txt_item_copy(DnsTxtItem
*first
) {
1768 DnsTxtItem
*i
, *copy
= NULL
, *end
= NULL
;
1770 LIST_FOREACH(items
, i
, first
) {
1773 j
= memdup(i
, offsetof(DnsTxtItem
, data
) + i
->length
+ 1);
1775 dns_txt_item_free_all(copy
);
1779 LIST_INSERT_AFTER(items
, copy
, end
, j
);
1786 int dns_txt_item_new_empty(DnsTxtItem
**ret
) {
1789 /* RFC 6763, section 6.1 suggests to treat
1790 * empty TXT RRs as equivalent to a TXT record
1791 * with a single empty string. */
1793 i
= malloc0(offsetof(DnsTxtItem
, data
) + 1); /* for safety reasons we add an extra NUL byte */
1802 static const char* const dnssec_algorithm_table
[_DNSSEC_ALGORITHM_MAX_DEFINED
] = {
1803 /* Mnemonics as listed on https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml */
1804 [DNSSEC_ALGORITHM_RSAMD5
] = "RSAMD5",
1805 [DNSSEC_ALGORITHM_DH
] = "DH",
1806 [DNSSEC_ALGORITHM_DSA
] = "DSA",
1807 [DNSSEC_ALGORITHM_ECC
] = "ECC",
1808 [DNSSEC_ALGORITHM_RSASHA1
] = "RSASHA1",
1809 [DNSSEC_ALGORITHM_DSA_NSEC3_SHA1
] = "DSA-NSEC3-SHA1",
1810 [DNSSEC_ALGORITHM_RSASHA1_NSEC3_SHA1
] = "RSASHA1-NSEC3-SHA1",
1811 [DNSSEC_ALGORITHM_RSASHA256
] = "RSASHA256",
1812 [DNSSEC_ALGORITHM_RSASHA512
] = "RSASHA512",
1813 [DNSSEC_ALGORITHM_ECC_GOST
] = "ECC-GOST",
1814 [DNSSEC_ALGORITHM_ECDSAP256SHA256
] = "ECDSAP256SHA256",
1815 [DNSSEC_ALGORITHM_ECDSAP384SHA384
] = "ECDSAP384SHA384",
1816 [DNSSEC_ALGORITHM_ED25519
] = "ED25519",
1817 [DNSSEC_ALGORITHM_ED448
] = "ED448",
1818 [DNSSEC_ALGORITHM_INDIRECT
] = "INDIRECT",
1819 [DNSSEC_ALGORITHM_PRIVATEDNS
] = "PRIVATEDNS",
1820 [DNSSEC_ALGORITHM_PRIVATEOID
] = "PRIVATEOID",
1822 DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(dnssec_algorithm
, int, 255);
1824 static const char* const dnssec_digest_table
[_DNSSEC_DIGEST_MAX_DEFINED
] = {
1825 /* Names as listed on https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml */
1826 [DNSSEC_DIGEST_SHA1
] = "SHA-1",
1827 [DNSSEC_DIGEST_SHA256
] = "SHA-256",
1828 [DNSSEC_DIGEST_GOST_R_34_11_94
] = "GOST_R_34.11-94",
1829 [DNSSEC_DIGEST_SHA384
] = "SHA-384",
1831 DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(dnssec_digest
, int, 255);