summaryrefslogtreecommitdiff
path: root/lib/dns/rdata/generic/key_25.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dns/rdata/generic/key_25.c')
-rw-r--r--lib/dns/rdata/generic/key_25.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/lib/dns/rdata/generic/key_25.c b/lib/dns/rdata/generic/key_25.c
index 9acfe95f..7ae8e4eb 100644
--- a/lib/dns/rdata/generic/key_25.c
+++ b/lib/dns/rdata/generic/key_25.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: key_25.c,v 1.51 2007/06/19 23:47:17 tbox Exp $ */
+/* $Id: key_25.c,v 1.53 2009/12/04 22:06:37 tbox Exp $ */
/*
* Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley.
@@ -76,6 +76,7 @@ totext_key(ARGS_TOTEXT) {
char buf[sizeof("64000")];
unsigned int flags;
unsigned char algorithm;
+ char namebuf[DNS_NAME_FORMATSIZE];
REQUIRE(rdata->type == 25);
REQUIRE(rdata->length != 0);
@@ -105,6 +106,15 @@ totext_key(ARGS_TOTEXT) {
if ((flags & 0xc000) == 0xc000)
return (ISC_R_SUCCESS);
+ if ((tctx->flags & DNS_STYLEFLAG_COMMENT) != 0 &&
+ algorithm == DNS_KEYALG_PRIVATEDNS) {
+ dns_name_t name;
+ dns_name_init(&name, NULL);
+ dns_name_fromregion(&name, &sr);
+ dns_name_format(&name, namebuf, sizeof(namebuf));
+ } else
+ namebuf[0] = 0;
+
/* key */
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" (", target));
@@ -127,12 +137,18 @@ totext_key(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &tmpr);
sprintf(buf, "%u", dst_region_computeid(&tmpr, algorithm));
RETERR(str_totext(buf, target));
+ if (algorithm == DNS_KEYALG_PRIVATEDNS) {
+ RETERR(str_totext(tctx->linebreak, target));
+ RETERR(str_totext("; alg = ", target));
+ RETERR(str_totext(namebuf, target));
+ }
}
return (ISC_R_SUCCESS);
}
static inline isc_result_t
fromwire_key(ARGS_FROMWIRE) {
+ unsigned char algorithm;
isc_region_t sr;
REQUIRE(type == 25);
@@ -146,6 +162,18 @@ fromwire_key(ARGS_FROMWIRE) {
if (sr.length < 4)
return (ISC_R_UNEXPECTEDEND);
+ algorithm = sr.base[3];
+ RETERR(mem_tobuffer(target, sr.base, 4));
+ isc_region_consume(&sr, 4);
+ isc_buffer_forward(source, 4);
+
+ if (algorithm == DNS_KEYALG_PRIVATEDNS) {
+ dns_name_t name;
+ dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
+ dns_name_init(&name, NULL);
+ RETERR(dns_name_fromwire(&name, source, dctx, options, target));
+ }
+ isc_buffer_activeregion(source, &sr);
isc_buffer_forward(source, sr.length);
return (mem_tobuffer(target, sr.base, sr.length));
}
@@ -309,4 +337,9 @@ checknames_key(ARGS_CHECKNAMES) {
return (ISC_TRUE);
}
+static inline int
+casecompare_key(ARGS_COMPARE) {
+ return (compare_key(rdata1, rdata2));
+}
+
#endif /* RDATA_GENERIC_KEY_25_C */