dnssec-importkey.c revision 0c91911b4d1e872b87eaf6431ed47fe24d18dd43
/*
* Copyright (C) 2008-2012 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*! \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>
#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 newname[1024];
if (result != ISC_R_SUCCESS) {
}
if (setpub)
if (setdel)
if (result != ISC_R_SUCCESS) {
fatal("Failed to build public key filename: %s",
}
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 keyset files\n");
exit (-1);
}
int
char *endp;
int ch;
if (argc == 1)
usage();
if (result != ISC_R_SUCCESS)
fatal("out of memory");
switch (ch) {
case 'D':
if (setdel)
fatal("-D specified more than once");
break;
case 'K':
fatal("directory must be non-empty string");
break;
case 'P':
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':
usage();
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 zone name as the zone file 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);
}