Commit 4dce8cef authored by Daniel Salzman's avatar Daniel Salzman

rrset-dump: print dnskey info if multiline

refs #230
parent 300bbf46
......@@ -48,3 +48,18 @@ bool knot_dnssec_algorithm_is_zonesign(uint8_t algorithm, bool nsec3_enabled)
return false;
}
}
knot_lookup_table_t knot_dnssec_alg_names[] = {
{ KNOT_DNSSEC_ALG_RSAMD5, "RSAMD5" },
{ KNOT_DNSSEC_ALG_DH, "DH" },
{ KNOT_DNSSEC_ALG_DSA, "DSA" },
{ KNOT_DNSSEC_ALG_RSASHA1, "RSASHA1" },
{ KNOT_DNSSEC_ALG_DSA_NSEC3_SHA1, "DSA_NSEC3_SHA1" },
{ KNOT_DNSSEC_ALG_RSASHA1_NSEC3_SHA1, "RSASHA1_NSEC3_SHA1" },
{ KNOT_DNSSEC_ALG_RSASHA256, "RSASHA256" },
{ KNOT_DNSSEC_ALG_RSASHA512, "RSASHA512" },
{ KNOT_DNSSEC_ALG_ECC_GOST, "ECC_GOST" },
{ KNOT_DNSSEC_ALG_ECDSAP256SHA256, "ECDSAP256SHA256" },
{ KNOT_DNSSEC_ALG_ECDSAP384SHA384, "ECDSAP384SHA384" },
{ 0, NULL }
};
......@@ -30,6 +30,8 @@
#include <stdbool.h>
#include <stdint.h>
#include "libknot/util/utils.h"
/*!
* \brief DNSSEC algorithm numbers.
*
......@@ -52,6 +54,11 @@ typedef enum {
KNOT_DNSSEC_ALG_ECDSAP384SHA384 = 14
} knot_dnssec_algorithm_t;
/*!
* \brief DNSSEC algorithm names.
*/
extern knot_lookup_table_t knot_dnssec_alg_names[];
/*!
* \brief NSEC3 hash algorithm numbers.
*/
......
......@@ -33,6 +33,8 @@
#include "common/base64.h" // base64
#include "common/base32hex.h" // base32hex
#include "common/descriptor.h" // KNOT_RRTYPE
#include "libknot/dnssec/key.h" // knot_keytag
#include "libknot/dnssec/algorithm.h" // knot_dnssec_alg_names
#include "libknot/consts.h" // knot_rcode_names
#include "libknot/util/utils.h" // knot_wire_read_u16
......@@ -1283,6 +1285,26 @@ static void wire_unknown_to_str(rrset_dump_params_t *p)
p->ret = 0;
}
static void dnskey_info(const uint8_t *rdata,
const size_t rdata_len,
char *out,
const size_t out_len)
{
const uint8_t sep = *(rdata + 1) & 0x01;
const uint16_t key_tag = knot_keytag(rdata, rdata_len);
knot_lookup_table_t *alg = NULL;
alg = knot_lookup_by_id(knot_dnssec_alg_names, *(rdata + 3));
int ret = snprintf(out, out_len, "%s, alg = %s, id = %u ",
sep ? "KSK" : "ZSK",
alg ? alg->name : "UNKNOWN",
key_tag );
if (ret <= 0) { // Truncated return is acceptable. Just check for errors.
out = "";
}
}
#define DUMP_PARAMS const uint8_t *in, const size_t in_len, char *out, \
const size_t out_max, const knot_dump_style_t *style
#define DUMP_INIT rrset_dump_params_t p = { .style = style, .in = in, \
......@@ -1295,8 +1317,10 @@ static void wire_unknown_to_str(rrset_dump_params_t *p)
#define WRAP_END dump_string(&p, BLOCK_INDENT ")"); CHECK_RET(p);
#define WRAP_LINE dump_string(&p, BLOCK_INDENT); CHECK_RET(p);
#define COMMENT(s) if (p.style->verbose) { dump_string(&p, "\t; " s); \
CHECK_RET(p); }
#define COMMENT(s) if (p.style->verbose) { \
dump_string(&p, " ; "); CHECK_RET(p); \
dump_string(&p, s); CHECK_RET(p); \
}
#define DUMP_SPACE dump_string(&p, " "); CHECK_RET(p);
#define DUMP_NUM8 wire_num8_to_str(&p); CHECK_RET(p);
......@@ -1424,11 +1448,14 @@ static int dump_dnskey(DUMP_PARAMS)
DUMP_INIT;
if (p.style->wrap) {
char info[512] = "";
dnskey_info(in, in_len, info, sizeof(info));
DUMP_NUM16; DUMP_SPACE;
DUMP_NUM8; DUMP_SPACE;
DUMP_NUM8; DUMP_SPACE; WRAP_INIT;
DUMP_BASE64;
WRAP_END;
WRAP_END; COMMENT(info);
} else {
DUMP_NUM16; DUMP_SPACE;
DUMP_NUM8; DUMP_SPACE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment