mirror of
https://github.com/systemd/systemd.git
synced 2025-03-22 06:50:18 +03:00
Remove dnssec_canonicalize function which is no longer used
This commit is contained in:
parent
a63932778c
commit
19be3da991
@ -59,55 +59,6 @@ uint16_t dnssec_keytag(DnsResourceRecord *dnskey, bool mask_revoke) {
|
||||
return sum & UINT32_C(0xFFFF);
|
||||
}
|
||||
|
||||
int dnssec_canonicalize(const char *n, char *buffer, size_t buffer_max) {
|
||||
size_t c = 0;
|
||||
int r;
|
||||
|
||||
/* Converts the specified hostname into DNSSEC canonicalized
|
||||
* form. */
|
||||
|
||||
if (buffer_max < 2)
|
||||
return -ENOBUFS;
|
||||
|
||||
for (;;) {
|
||||
r = dns_label_unescape(&n, buffer, buffer_max, 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
break;
|
||||
|
||||
if (buffer_max < (size_t) r + 2)
|
||||
return -ENOBUFS;
|
||||
|
||||
/* The DNSSEC canonical form is not clear on what to
|
||||
* do with dots appearing in labels, the way DNS-SD
|
||||
* does it. Refuse it for now. */
|
||||
|
||||
if (memchr(buffer, '.', r))
|
||||
return -EINVAL;
|
||||
|
||||
ascii_strlower_n(buffer, (size_t) r);
|
||||
buffer[r] = '.';
|
||||
|
||||
buffer += r + 1;
|
||||
c += r + 1;
|
||||
|
||||
buffer_max -= r + 1;
|
||||
}
|
||||
|
||||
if (c <= 0) {
|
||||
/* Not even a single label: this is the root domain name */
|
||||
|
||||
assert(buffer_max > 2);
|
||||
buffer[0] = '.';
|
||||
buffer[1] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int) c;
|
||||
}
|
||||
|
||||
#if HAVE_GCRYPT
|
||||
|
||||
static int rr_compare(DnsResourceRecord * const *a, DnsResourceRecord * const *b) {
|
||||
|
@ -58,8 +58,6 @@ int dnssec_has_rrsig(DnsAnswer *a, const DnsResourceKey *key);
|
||||
|
||||
uint16_t dnssec_keytag(DnsResourceRecord *dnskey, bool mask_revoke);
|
||||
|
||||
int dnssec_canonicalize(const char *n, char *buffer, size_t buffer_max);
|
||||
|
||||
int dnssec_nsec3_hash(DnsResourceRecord *nsec3, const char *name, void *ret);
|
||||
|
||||
typedef enum DnssecNsecResult {
|
||||
|
@ -13,26 +13,6 @@
|
||||
#include "string-util.h"
|
||||
#include "hexdecoct.h"
|
||||
|
||||
static void test_dnssec_canonicalize_one(const char *original, const char *canonical, int r) {
|
||||
char canonicalized[DNSSEC_CANONICAL_HOSTNAME_MAX];
|
||||
|
||||
assert_se(dnssec_canonicalize(original, canonicalized, sizeof(canonicalized)) == r);
|
||||
if (r < 0)
|
||||
return;
|
||||
|
||||
assert_se(streq(canonicalized, canonical));
|
||||
}
|
||||
|
||||
static void test_dnssec_canonicalize(void) {
|
||||
test_dnssec_canonicalize_one("", ".", 1);
|
||||
test_dnssec_canonicalize_one(".", ".", 1);
|
||||
test_dnssec_canonicalize_one("foo", "foo.", 4);
|
||||
test_dnssec_canonicalize_one("foo.", "foo.", 4);
|
||||
test_dnssec_canonicalize_one("FOO.", "foo.", 4);
|
||||
test_dnssec_canonicalize_one("FOO.bar.", "foo.bar.", 8);
|
||||
test_dnssec_canonicalize_one("FOO..bar.", NULL, -EINVAL);
|
||||
}
|
||||
|
||||
#if HAVE_GCRYPT
|
||||
|
||||
static void test_dnssec_verify_dns_key(void) {
|
||||
@ -499,8 +479,6 @@ static void test_dnssec_nsec3_hash(void) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
test_dnssec_canonicalize();
|
||||
|
||||
#if HAVE_GCRYPT
|
||||
test_dnssec_verify_dns_key();
|
||||
test_dnssec_verify_rfc8080_ed25519_example1();
|
||||
|
Loading…
x
Reference in New Issue
Block a user