dnssec-keygen.c revision f66c8eed515745b9bb81bfcd8af7dfeba3736aad
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * Portions Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * Portions Copyright (C) 1999-2003 Internet Software Consortium.
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * Permission to use, copy, modify, and/or distribute this software for any
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * purpose with or without fee is hereby granted, provided that the above
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * copyright notice and this permission notice appear in all copies.
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * Portions Copyright (C) 1995-2000 by Network Associates, Inc.
e419f613d8591885df608cb73065921be07dd12eBob Halley * Permission to use, copy, modify, and/or distribute this software for any
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * purpose with or without fee is hereby granted, provided that the above
fca5f81ad69098ea8abba130c7f841c951ef91c2Bob Halley * copyright notice and this permission notice appear in all copies.
e419f613d8591885df608cb73065921be07dd12eBob Halley * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
9695ae1c24b168996e3a267855dc754971ccb32cBob Halley * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
1c776a2909632bc755f3fddd3b53addd792ab4d0Brian Wellington * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
e419f613d8591885df608cb73065921be07dd12eBob Halley * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley/* $Id: dnssec-keygen.c,v 1.87 2009/06/30 23:48:00 tbox Exp $ */
e419f613d8591885df608cb73065921be07dd12eBob Halley#define MAX_RSA 4096 /* should be long enough... */
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic const char *algs = "RSA | RSAMD5 | DH | DSA | RSASHA1 | NSEC3DSA |"
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington " NSEC3RSASHA1 | HMAC-MD5 |"
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley " HMAC-SHA1 | HMAC-SHA224 | HMAC-SHA256 |"
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley " HMAC-SHA384 | HMAC-SHA512";
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington return (ISC_TF(size >= 512 && size <= 1024 && size % 64 == 0));
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington fprintf(stderr, " -a algorithm: %s (default RSASHA1)\n", algs);
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington fprintf(stderr, " -b key size, in bits:\n");
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington fprintf(stderr, " RSAMD5:\t\t[512..%d]\n", MAX_RSA);
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington fprintf(stderr, " RSASHA1:\t\t[512..%d]\n", MAX_RSA);
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington fprintf(stderr, " NSEC3RSASHA1:\t\t[512..%d]\n", MAX_RSA);
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington fprintf(stderr, " DSA:\t\t[512..1024] and divisible by 64\n");
e83cae7fa837e4757c687035d6f6c0900f152749Brian Wellington fprintf(stderr, " NSEC3DSA:\t\t[512..1024] and divisible by 64\n");
d325d53d03013a50a286b0066c9647370466ae26Andreas Gustafsson fprintf(stderr, " HMAC-SHA1:\t[1..160]\n");
d325d53d03013a50a286b0066c9647370466ae26Andreas Gustafsson fprintf(stderr, " HMAC-SHA224:\t[1..224]\n");
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington fprintf(stderr, " HMAC-SHA256:\t[1..256]\n");
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson fprintf(stderr, " HMAC-SHA384:\t[1..384]\n");
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson fprintf(stderr, " HMAC-SHA512:\t[1..512]\n");
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson fprintf(stderr, " (default 1024 for RSASHA1 ZSK, 2048 for KSK\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley fprintf(stderr, " -n nametype: ZONE | HOST | ENTITY | USER | OTHER\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley fprintf(stderr, " (DNSKEY generation defaults to ZONE)\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley fprintf(stderr, " -d <digest bits> (0 => max, default)\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley fprintf(stderr, " -e use large exponent (RSAMD5/RSASHA1 only)\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley fprintf(stderr, " -f keyflag (KSK or REVOKE)\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley fprintf(stderr, " -g <generator> use specified generator "
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence "(DH only)\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "AUTHCONF | NOAUTHCONF | NOAUTH | NOCONF "
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "(default: AUTHCONF)\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "default: 3 [dnssec]\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley fprintf(stderr, " -s <strength> strength value this key signs DNS "
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "records with (default: 0)\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley fprintf(stderr, " -r <randomdev>: a file containing random data\n");
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence fprintf(stderr, " -k : generate a TYPE=KEY key\n");
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence "K<name>+<alg>+<id>.private\n");
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley char *algname = NULL, *nametype = NULL, *type = NULL;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington isc_uint16_t flags = 0, ksk = 0, revoke = 0;
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff isc_boolean_t conflict = ISC_FALSE, null_key = ISC_FALSE;
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff int ch, rsa_exp = 0, generator = 0, param = 0;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington int options = DST_TYPE_PRIVATE | DST_TYPE_PUBLIC;
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington while ((ch = isc_commandline_parse(argc, argv,
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington size = strtol(isc_commandline_argument, &endp, 10);
777ac454c0cdec27dc11d80b9b2a8d7239d833a8Brian Wellington fatal("-b requires a non-negative number");
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington dbits = strtol(isc_commandline_argument, &endp, 10);
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson fatal("-d requires a non-negative number");
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence if (strcasecmp(isc_commandline_argument, "KSK") == 0)
fe5ba8ddb55b2b3ee139e13b7891817117ad4e63Brian Wellington else if (strcasecmp(isc_commandline_argument,
fe5ba8ddb55b2b3ee139e13b7891817117ad4e63Brian Wellington "REVOKE") == 0)
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington generator = strtol(isc_commandline_argument,
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington protocol = strtol(isc_commandline_argument, &endp, 10);
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington if (*endp != '\0' || protocol < 0 || protocol > 255)
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington signatory = strtol(isc_commandline_argument,
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington if (*endp != '\0' || signatory < 0 || signatory > 15)
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington setup_entropy(mctx, isc_commandline_argument, &ectx);
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington verbose = strtol(isc_commandline_argument, &endp, 0);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence /* Reserved for FIPS mode */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence /* FALLTHROUGH */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence fprintf(stderr, "%s: invalid argument -%c\n",
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington /* FALLTHROUGH */
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington fprintf(stderr, "%s: unhandled option -%c\n",
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence fprintf(stderr, "The use of RSA (RSAMD5) is not recommended.\n"
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence "If you still wish to use RSA (RSAMD5) please "
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington "specify \"-a RSAMD5\"\n");
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington } else if (strcasecmp(algname, "HMAC-MD5") == 0) {
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington } else if (strcasecmp(algname, "HMAC-SHA1") == 0) {
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington } else if (strcasecmp(algname, "HMAC-SHA224") == 0) {
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington } else if (strcasecmp(algname, "HMAC-SHA256") == 0) {
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington } else if (strcasecmp(algname, "HMAC-SHA384") == 0) {
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff } else if (strcasecmp(algname, "HMAC-SHA512") == 0) {
538fea1c91c68c0a5569c7b8552c8fd0490055efBrian Wellington if (type != NULL && (options & DST_TYPE_KEY) != 0) {
777ac454c0cdec27dc11d80b9b2a8d7239d833a8Brian Wellington else if (strcasecmp(type, "NOAUTHCONF") == 0) {
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington flags |= (DNS_KEYTYPE_NOAUTH | DNS_KEYTYPE_NOCONF);
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington else if (strcasecmp(type, "AUTHCONF") == 0)
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington /* nothing */;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington fatal("key size not specified (-b option)");
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (size != 0 && (size < 512 || size > MAX_RSA))
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("RSA key size %d out of range", size);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (size != 0 && (size < 128 || size > 4096))
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("DH key size %d out of range", size);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-MD5 key size %d out of range", size);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (dbits != 0 && (dbits < 80 || dbits > 128))
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-MD5 digest bits %d out of range", dbits);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-MD5 digest bits %d not divisible by 8",
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA1 key size %d out of range", size);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (dbits != 0 && (dbits < 80 || dbits > 160))
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA1 digest bits %d out of range", dbits);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA1 digest bits %d not divisible by 8",
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA224 key size %d out of range", size);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (dbits != 0 && (dbits < 112 || dbits > 224))
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA224 digest bits %d out of range", dbits);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA224 digest bits %d not divisible by 8",
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA256 key size %d out of range", size);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (dbits != 0 && (dbits < 128 || dbits > 256))
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA256 digest bits %d out of range", dbits);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA256 digest bits %d not divisible by 8",
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-384 key size %d out of range", size);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (dbits != 0 && (dbits < 192 || dbits > 384))
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA384 digest bits %d out of range", dbits);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA384 digest bits %d not divisible by 8",
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA512 key size %d out of range", size);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (dbits != 0 && (dbits < 256 || dbits > 512))
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA512 digest bits %d out of range", dbits);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("HMAC-SHA512 digest bits %d not divisible by 8",
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (!(alg == DNS_KEYALG_RSAMD5 || alg == DNS_KEYALG_RSASHA1 ||
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington alg == DNS_KEYALG_NSEC3RSASHA1) && rsa_exp != 0)
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("specified RSA exponent for a non-RSA key");
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (alg != DNS_KEYALG_DH && generator != 0)
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("specified DH generator for a non-DH key");
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if ((options & DST_TYPE_KEY) != 0) /* KEY / HMAC */
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington } else if (strcasecmp(nametype, "zone") == 0)
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington else if ((options & DST_TYPE_KEY) != 0) { /* KEY / HMAC */
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington else if (strcasecmp(nametype, "user") == 0)
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("invalid KEY nametype %s", nametype);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington } else if (strcasecmp(nametype, "other") != 0) /* DNSKEY */
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fatal("invalid DNSKEY nametype %s", nametype);
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington if ((options & DST_TYPE_KEY) != 0) /* KEY / HMAC */
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington else if ((flags & DNS_KEYOWNER_ZONE) != 0) { /* DNSKEY */
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington fatal("invalid DNSKEY protocol: %d", protocol);
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington if ((flags & DNS_KEYFLAG_TYPEMASK) == DNS_KEYTYPE_NOKEY) {
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington fatal("specified null key with non-zero size");
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington if ((flags & DNS_KEYFLAG_SIGNATORYMASK) != 0)
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington fatal("specified null key with signing authority");
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington if ((flags & DNS_KEYFLAG_OWNERMASK) == DNS_KEYOWNER_ZONE &&
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington (alg == DNS_KEYALG_DH || alg == DST_ALG_HMACMD5 ||
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington alg == DST_ALG_HMACSHA1 || alg == DST_ALG_HMACSHA224 ||
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington alg == DST_ALG_HMACSHA256 || alg == DST_ALG_HMACSHA384 ||
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington fatal("a key with algorithm '%s' cannot be a zone key",
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington isc_buffer_init(&buf, argv[isc_commandline_index],
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington isc_buffer_add(&buf, strlen(argv[isc_commandline_index]));
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington ret = dns_name_fromtext(name, &buf, dns_rootname, ISC_FALSE, NULL);
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington fatal("invalid key name %s: %s", argv[isc_commandline_index],
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington if ((flags & DNS_KEYFLAG_TYPEMASK) == DNS_KEYTYPE_NOKEY)
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington isc_buffer_init(&buf, filename, sizeof(filename) - 1);
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington /* generate the key */
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington ret = dst_key_generate(name, alg, size, param, flags, protocol,
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson dns_name_format(name, namestr, sizeof(namestr));
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson fatal("failed to generate key %s/%s: %s\n",
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson namestr, algstr, isc_result_totext(ret));
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * Try to read a key with the same name, alg and id from disk.
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * If there is one we must continue generating a new one
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * unless we were asked to generate a null key, in which
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * case we return failure.
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley ret = dst_key_fromfile(name, dst_key_id(key), alg,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley /* do not overwrite an existing key */
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "%s: %s already exists, "
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "generating a new key\n",
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley fatal("cannot generate a null key when a key with id 0 "
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "already exists");
63bf060be4ff2a7ade02fd86abb98694a5afc250Brian Wellington fatal("failed to write key %s: %s\n", keystr,