dnssec-keygen.c revision cda383abe000119e7db0c71e2bfc7d30bfc56452
a134177ed9f82189504191d90f3ed9e97c2b47cbTinderbox User * Portions Copyright (C) 2000, 2001 Internet Software Consortium.
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews * Portions Copyright (C) 1995-2000 by Network Associates, Inc.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews * copyright notice and this permission notice appear in all copies.
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM AND
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews * NETWORK ASSOCIATES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
00b872e4f76587584a2359e9001e9cf08b195ccfMark Andrews * SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews * FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE CONSORTIUM OR NETWORK
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews * ASSOCIATES BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews/* $Id: dnssec-keygen.c,v 1.48 2001/07/10 18:53:09 bwelling Exp $ */
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews#define MAX_RSA 4096 /* should be long enough... */
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews return (ISC_TF(size >= 512 && size <= 1024 && size % 64 == 0));
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman fprintf(stderr, " %s -a alg -b bits -n type [options] name\n\n",
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews fprintf(stderr, " -a algorithm: RSA | RSAMD5 | DH | DSA | HMAC-MD5"
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews fprintf(stderr, " RSA:\t\t[512..%d]\n", MAX_RSA);
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews fprintf(stderr, " DSA:\t\t[512..1024] and divisible by 64\n");
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews fprintf(stderr, " -n nametype: ZONE | HOST | ENTITY | USER\n");
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews fprintf(stderr, " -e use large exponent (RSA only)\n");
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews fprintf(stderr, " -g use specified generator (DH only)\n");
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews fprintf(stderr, " -t type: AUTHCONF | NOAUTHCONF | NOAUTH | NOCONF "
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews "(default: AUTHCONF)\n");
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews "(default: 2 [email] for USER, 3 [dnssec] otherwise)\n");
ad1317338af79edad878c9c3e4361798503310baMark Andrews fprintf(stderr, " -s strength value this key signs DNS records "
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews "with (default: 0)\n");
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews fprintf(stderr, " -r randomdev (a file containing random data)\n");
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews "K<name>+<alg>+<id>.private\n");
9a859983d7059a6eb9c877c1d2ac6a3a5b7170f7Evan Hunt char *algname = NULL, *nametype = NULL, *type = NULL;
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews isc_boolean_t conflict = ISC_FALSE, null_key = ISC_FALSE;
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews size = strtol(isc_commandline_argument, &endp, 10);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman fatal("-b requires a non-negative number");
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews protocol = strtol(isc_commandline_argument, &endp, 10);
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews if (*endp != '\0' || protocol < 0 || protocol > 255)
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews "[0..255]");
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews if (*endp != '\0' || signatory < 0 || signatory > 15)
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews verbose = strtol(isc_commandline_argument, &endp, 0);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman else if (strcasecmp(algname, "HMAC-MD5") == 0)
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews else if (strcasecmp(type, "NOAUTHCONF") == 0) {
89639a5e13cace9166bf14931b9e1ce9dc8c47a3Mark Andrews flags |= (DNS_KEYTYPE_NOAUTH | DNS_KEYTYPE_NOCONF);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews /* nothing */;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (size != 0 && (size < 512 || size > MAX_RSA))
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman fatal("DH key size %d out of range", size);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews fatal("HMAC-MD5 key size %d out of range", size);
if (size > 0)
switch(alg) {
case DNS_KEYALG_RSA:
case DNS_KEYALG_DH:
case DNS_KEYALG_DSA:
case DST_ALG_HMACMD5:
param = 0;
if (null_key)
if (verbose > 0) {
if (conflict)