dnssec-keyfromlabel.c revision 553ead32ff5b00284e574dcabc39115d4d74ec66
/*
* Copyright (C) 2007-2009 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.
*/
/* $Id: dnssec-keyfromlabel.c,v 1.9 2009/07/19 04:18:04 each Exp $ */
/*! \file */
#include <config.h>
#include <stdlib.h>
#include <isc/commandline.h>
#include <dns/fixedname.h>
#include <dns/keyvalues.h>
#include <dns/rdataclass.h>
#include "dnssectool.h"
const char *program = "dnssec-keyfromlabel";
int verbose;
static const char *algs = "RSA | RSAMD5 | DH | DSA | RSASHA1 |"
" NSEC3DSA | NSEC3RSASHA1";
static void
usage(void) {
program);
"key files\n");
"AUTHCONF | NOAUTHCONF | NOAUTH | NOCONF "
"(default: AUTHCONF)\n");
"default: 3 [dnssec]\n");
"K<name>+<alg>+<id>.private\n");
exit (-1);
}
int
char *endp;
int ch;
char filename[255];
if (argc == 1)
usage();
"a:c:f:K:kl:n:p:t:v:Fh")) != -1)
{
switch (ch) {
case 'a':
break;
case 'c':
break;
case 'f':
else if (strcasecmp(isc_commandline_argument,
"REVOKE") == 0)
else
fatal("unknown flag '%s'",
break;
case 'K':
break;
case 'k':
options |= DST_TYPE_KEY;
break;
case 'l':
break;
case 'n':
break;
case 'p':
fatal("-p must be followed by a number "
"[0..255]");
break;
case 't':
break;
case 'v':
if (*endp != '\0')
fatal("-v must be followed by a number");
break;
case 'F':
/* Reserved for FIPS mode */
/* FALLTHROUGH */
case '?':
if (isc_commandline_option != '?')
/* FALLTHROUGH */
case 'h':
usage();
default:
exit(1);
}
}
if (ret != ISC_R_SUCCESS)
fatal("could not initialize dst");
fatal("the key label was not specified");
fatal("the key name was not specified");
fatal("extraneous arguments");
fatal("no algorithm was specified");
"If you still wish to use RSA (RSAMD5) please "
"specify \"-a RSAMD5\"\n");
return (1);
} else {
if (ret != ISC_R_SUCCESS)
if (alg == DST_ALG_DH)
options |= DST_TYPE_KEY;
}
}
/* nothing */;
else
}
fatal("no nametype specified");
else
}
if (protocol == -1)
else if ((options & DST_TYPE_KEY) == 0 &&
if ((flags & DNS_KEYFLAG_SIGNATORYMASK) != 0)
fatal("specified null key with signing authority");
}
alg == DNS_KEYALG_DH)
fatal("a key with algorithm '%s' cannot be a zone key",
algname);
if (ret != ISC_R_SUCCESS)
/* associate the key */
if (ret != ISC_R_SUCCESS) {
char namestr[DNS_NAME_FORMATSIZE];
char algstr[ALG_FORMATSIZE];
fatal("failed to generate key %s/%s: %s\n",
exit(-1);
}
/*
* Try to read a key with the same name, alg and id from disk.
* If there is one we must continue generating a new one
* unless we were asked to generate a null key, in which
* case we return failure.
*/
/* do not overwrite an existing key */
if (ret == ISC_R_SUCCESS) {
dst_key_free(&key);
exit (1);
}
if (ret != ISC_R_SUCCESS) {
char keystr[KEY_FORMATSIZE];
}
dst_key_free(&key);
if (verbose > 10)
return (0);
}