~mcf/dnssec-rr

818df37a7688d76ebb3585ec64cb7117fa8f9051 — Michael Forney 3 years ago 7187805
Make algorithm an option instead of key prefix
5 files changed, 21 insertions(+), 17 deletions(-)

M dnskey.c
M dnssec.h
M ds.c
M key.c
M rrsig.c
M dnskey.c => dnskey.c +6 -3
@@ 7,18 7,21 @@
static void
usage(void)
{
	fprintf(stderr, "usage: dnskey [-k] [-t ttl] [-c class] domain [algorithm:]keyfile\n");
	fprintf(stderr, "usage: dnskey [-k] [-a algorithm] [-t ttl] [-c class] domain keyfile\n");
	exit(2);
}

int
main(int argc, char *argv[])
{
	int class = CLASS_IN, flags = DNSKEY_ZONE;
	int algorithm = 0, class = CLASS_IN, flags = DNSKEY_ZONE;
	unsigned long ttl = 0;
	char *end;

	ARGBEGIN {
	case 'a':
		algorithm = algorithm_from_string(EARGF(usage()));
		break;
	case 'k':
		flags |= DNSKEY_SEP;
		break;


@@ 36,7 39,7 @@ main(int argc, char *argv[])
	if (argc != 2)
		usage();

	struct key *sk = key_new_from_file(argv[1]);
	struct key *sk = key_new_from_file(argv[1], algorithm);
	struct dnskey *pk = dnskey_new(flags, sk);
	fputs(argv[0], stdout);
	if (ttl)

M dnssec.h => dnssec.h +1 -1
@@ 57,7 57,7 @@ struct key {
	unsigned char data[];
};

struct key *key_new_from_file(const char *);
struct key *key_new_from_file(const char *, int);

/* domain names */
enum {

M ds.c => ds.c +6 -3
@@ 8,14 8,14 @@
static void
usage(void)
{
	fprintf(stderr, "usage: ds [-d digest] [-t ttl] [-c class] domain [algorithm:]keyfile\n");
	fprintf(stderr, "usage: ds [-d digest] [-a algorithm] [-t ttl] [-c class] domain keyfile\n");
	exit(2);
}

int
main(int argc, char *argv[])
{
	int digest = DIGEST_SHA256, class = CLASS_IN;
	int algorithm = 0, digest = DIGEST_SHA256, class = CLASS_IN;
	unsigned long ttl = 0;
	char *end;



@@ 23,6 23,9 @@ main(int argc, char *argv[])
	case 'd':
		digest = digest_from_string(EARGF(usage()));
		break;
	case 'a':
		algorithm = algorithm_from_string(EARGF(usage()));
		break;
	case 't':
		ttl = strtoul(EARGF(usage()), &end, 10);
		if (*end)


@@ 46,7 49,7 @@ main(int argc, char *argv[])
		errx(1, "unsupported digest %d", digest);
	}

	struct key *sk = key_new_from_file(argv[1]);
	struct key *sk = key_new_from_file(argv[1], algorithm);
	struct dnskey *pk = dnskey_new(DNSKEY_ZONE | DNSKEY_SEP, sk);

	unsigned char dname[DNAME_MAX];

M key.c => key.c +2 -7
@@ 65,20 65,15 @@ key_decode(void *ctx, const void *buf, size_t len)
}

struct key *
key_new_from_file(const char *name)
key_new_from_file(const char *name, int algorithm)
{
	br_pem_decoder_context pc;
	br_skey_decoder_context kc;
	char buf[BUFSIZ], *p;
	size_t len = 0, n;
	int done = 0, algorithm = 0;
	int done = 0;
	FILE *f;

	if ((p = strchr(name, ':')) && !strchr(name, '/')) {
		*p = '\0';
		algorithm = algorithm_from_string(name);
		name = p + 1;
	}
	f = fopen(name, "r");
	if (!f)
		err(1, "open %s", name);

M rrsig.c => rrsig.c +6 -3
@@ 10,14 10,14 @@
static void
usage(void)
{
	fprintf(stderr, "usage: rrsig [-kz] [-s start] [-e end] [algorithm:]keyfile [zonefile]\n");
	fprintf(stderr, "usage: rrsig [-kz] [-s start] [-e end] [-a algorithm] keyfile [zonefile]\n");
	exit(2);
}

int
main(int argc, char *argv[])
{
	int kflag = 0, zflag = 0;
	int kflag = 0, zflag = 0, algorithm = 0;
	unsigned long start_time = 0, end_time = 0;

	ARGBEGIN {


@@ 32,6 32,9 @@ main(int argc, char *argv[])
		if (*end)
			usage();
		break;
	case 'a':
		algorithm = algorithm_from_string(EARGF(usage()));
		break;
	case 'k':
		kflag = 1;
		break;


@@ 60,7 63,7 @@ main(int argc, char *argv[])
		errx(1, "zone parse failed");
	}

	struct key *sk = key_new_from_file(argv[0]);
	struct key *sk = key_new_from_file(argv[0], algorithm);
	struct dnskey *pk = dnskey_new(DNSKEY_ZONE | (kflag ? DNSKEY_SEP : 0), sk);

	br_hash_compat_context hc;