dnssec-importkey.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*! \file */
#include <config.h>
#include <stdlib.h>
#include <isc/commandline.h>
#include <dns/callbacks.h>
#include <dns/dbiterator.h>
#include <dns/fixedname.h>
#include <dns/keyvalues.h>
#include <dns/rdataclass.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/rdatatype.h>
#ifdef PKCS11CRYPTO
#endif
#include "dnssectool.h"
#ifndef PATH_MAX
#endif
const char *program = "dnssec-importkey";
int verbose;
static dns_rdataclass_t rdclass;
static dns_fixedname_t fixed;
static isc_result_t
return (result);
}
static void
if (result != ISC_R_SUCCESS)
if (result != ISC_R_SUCCESS)
if (result != ISC_R_SUCCESS)
}
static isc_result_t
char setname[DNS_NAME_FORMATSIZE];
if (result != ISC_R_SUCCESS)
fatal("can't create database");
filename = "input";
} else {
}
if (result != ISC_R_SUCCESS)
if (result == ISC_R_NOTFOUND)
else if (result != ISC_R_SUCCESS)
fatal("dns_db_findrdataset");
dns_db_detach(&db);
return (result);
}
static void
{
isc_region_t r;
if (result != ISC_R_SUCCESS)
fatal("invalid keyfile name %s: %s",
if (verbose > 2) {
char keystr[DST_KEY_FORMATSIZE];
}
if (result != ISC_R_SUCCESS)
fatal("can't decode key");
isc_buffer_usedregion(&keyb, &r);
dns_rdatatype_dnskey, &r);
if (result != ISC_R_SUCCESS)
fatal("can't copy name");
dst_key_free(&key);
}
static void
char keystr[DST_KEY_FORMATSIZE];
char pubname[1024];
char priname[1024];
if (result != ISC_R_SUCCESS) {
}
if (result != ISC_R_SUCCESS) {
fatal("Failed to build public key filename: %s",
}
if (result != ISC_R_SUCCESS) {
fatal("Failed to build private key filename: %s",
}
if (result == ISC_R_SUCCESS) {
dst_key_free(&tmp);
}
if (setpub)
if (setdel)
if (setsyncadd)
if (setsyncdel)
if (setttl)
dir);
if (result != ISC_R_SUCCESS) {
}
if (result != ISC_R_SUCCESS) {
fatal("Failed to build private key filename: %s",
}
dst_key_free(&key);
}
ISC_PLATFORM_NORETURN_PRE static void
usage(void) ISC_PLATFORM_NORETURN_POST;
static void
usage(void) {
"the key files\n");
"publication date\n");
"CDS and CDNSKEY publication date\n");
"deletion date\n");
"CDS and CDNSKEY deletion date\n");
exit (-1);
}
int
char *endp;
int ch;
if (argc == 1)
usage();
if (result != ISC_R_SUCCESS)
fatal("out of memory");
#ifdef PKCS11CRYPTO
#endif
#define CMDLINE_FLAGS "D:f:hK:L:P:v:V"
switch (ch) {
case 'D':
/* -Dsync ? */
if (setsyncdel)
fatal("-D sync specified more than "
"once");
break;
}
/* -Ddnskey ? */
if (setdel)
fatal("-D specified more than once");
break;
case 'K':
fatal("directory must be non-empty string");
break;
case 'L':
break;
case 'P':
/* -Psync ? */
if (setsyncadd)
fatal("-P sync specified more than "
"once");
break;
}
/* -Pdnskey ? */
if (setpub)
fatal("-P specified more than once");
break;
case 'f':
break;
case 'v':
if (*endp != '\0')
fatal("-v must be followed by a number");
break;
case '?':
if (isc_commandline_option != '?')
/* FALLTHROUGH */
case 'h':
/* Does not return. */
usage();
case 'V':
/* Does not return. */
default:
exit(1);
}
}
fatal("the key file name was not specified");
fatal("extraneous arguments");
if (result != ISC_R_SUCCESS)
fatal("could not initialize hash");
if (result != ISC_R_SUCCESS)
fatal("could not initialize dst: %s",
/* using filename as zone name */
} else
if (result != ISC_R_SUCCESS)
if (result != ISC_R_SUCCESS)
fatal("could not load DNSKEY set: %s\n",
result == ISC_R_SUCCESS;
}
} else {
unsigned char key_buf[DST_KEY_MAXSIZE];
DST_KEY_MAXSIZE, &rdata);
}
if (verbose > 10)
return (1);
} else
return (0);
}