diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-08-04 00:17:22 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-08-04 04:02:32 +0200 |
commit | 151226ab4bf276d60d51864330a99f886b923697 (patch) | |
tree | ddc7c4861c970fe37f92173054a51b2d309c93f2 /src/resolve/resolved-dns-rr.c | |
parent | resolved: add identifiers for dnssec algorithms (diff) | |
download | systemd-151226ab4bf276d60d51864330a99f886b923697.tar.xz systemd-151226ab4bf276d60d51864330a99f886b923697.zip |
resolved: RRSIG records
Diffstat (limited to 'src/resolve/resolved-dns-rr.c')
-rw-r--r-- | src/resolve/resolved-dns-rr.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index bc0cbef92e..c792deda47 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -274,6 +274,11 @@ DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) { free(rr->dnskey.key); break; + case DNS_TYPE_RRSIG: + free(rr->rrsig.signer); + free(rr->rrsig.signature); + break; + case DNS_TYPE_LOC: case DNS_TYPE_A: case DNS_TYPE_AAAA: @@ -418,6 +423,21 @@ int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecor a->dnskey.key_size == b->dnskey.key_size && memcmp(a->dnskey.key, b->dnskey.key, a->dnskey.key_size) == 0; + case DNS_TYPE_RRSIG: + /* do the fast comparisons first */ + if (a->rrsig.type_covered != a->rrsig.type_covered || + a->rrsig.algorithm != a->rrsig.algorithm || + a->rrsig.labels != a->rrsig.labels || + a->rrsig.original_ttl != a->rrsig.original_ttl || + a->rrsig.expiration != a->rrsig.expiration || + a->rrsig.inception != a->rrsig.inception || + a->rrsig.key_tag != a->rrsig.key_tag || + a->rrsig.signature_size != b->rrsig.signature_size || + memcmp(a->rrsig.signature, b->rrsig.signature, a->rrsig.signature_size) != 0) + return false; + + return dns_name_equal(a->rrsig.signer, b->rrsig.signer); + default: return a->generic.size == b->generic.size && memcmp(a->generic.data, b->generic.data, a->generic.size) == 0; @@ -604,6 +624,37 @@ int dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret) { break; } + case DNS_TYPE_RRSIG: { + const char *type, *alg; + + type = dns_type_to_string(rr->rrsig.type_covered); + alg = dnssec_algorithm_to_string(rr->rrsig.algorithm); + + t = hexmem(rr->rrsig.signature, rr->rrsig.signature_size); + if (!t) + return -ENOMEM; + + /* TYPE?? follows + * http://tools.ietf.org/html/rfc3597#section-5 */ + + r = asprintf(&s, "%s %s%.*u %.*s%.*u %u %u %u %u %u %s %s", + k, + type ?: "TYPE", + type ? 0 : 1, type ? 0u : (unsigned) rr->rrsig.type_covered, + alg ? -1 : 0, alg, + alg ? 0 : 1, alg ? 0u : (unsigned) rr->rrsig.algorithm, + rr->rrsig.labels, + rr->rrsig.original_ttl, + rr->rrsig.expiration, + rr->rrsig.inception, + rr->rrsig.key_tag, + rr->rrsig.signer, + t); + if (r < 0) + return -ENOMEM; + break; + } + default: t = hexmem(rr->generic.data, rr->generic.size); if (!t) |