Commit 1f8f904a authored by Brian Wellington's avatar Brian Wellington
Browse files

Added support for non-IN classes.

parent 5c290477
......@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-keygen.c,v 1.38 2000/08/14 04:43:12 bwelling Exp $ */
/* $Id: dnssec-keygen.c,v 1.39 2000/09/12 10:07:46 bwelling Exp $ */
#include <config.h>
......@@ -35,6 +35,7 @@
#include <dns/keyvalues.h>
#include <dns/log.h>
#include <dns/name.h>
#include <dns/rdataclass.h>
#include <dns/result.h>
#include <dns/secalg.h>
......@@ -67,6 +68,7 @@ usage(void) {
printf(" -n nametype: ZONE | HOST | ENTITY | USER\n");
printf(" name: owner of the key\n");
printf("Other options:\n");
printf(" -c class (IN)\n");
printf(" -e use large exponent (RSA only)\n");
printf(" -g use specified generator (DH only)\n");
printf(" -t type: AUTHCONF | NOAUTHCONF | NOAUTH | NOCONF\n");
......@@ -86,6 +88,7 @@ usage(void) {
int
main(int argc, char **argv) {
char *algname = NULL, *nametype = NULL, *type = NULL;
char *classname = NULL;
char *randomfile = NULL;
char *prog, *endp;
dst_key_t *key = NULL, *oldkey;
......@@ -103,6 +106,7 @@ main(int argc, char **argv) {
isc_buffer_t buf;
isc_log_t *log = NULL;
isc_entropy_t *ectx = NULL;
dns_rdataclass_t rdclass;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
......@@ -119,20 +123,20 @@ main(int argc, char **argv) {
dns_result_register();
while ((ch = isc_commandline_parse(argc, argv,
"a:b:eg:n:t:p:s:hr:v:")) != -1)
"a:b:c:eg:n:t:p:s:hr:v:")) != -1)
{
switch (ch) {
case 'a':
algname = isc_mem_strdup(mctx,
isc_commandline_argument);
if (algname == NULL)
fatal("out of memory");
algname = isc_commandline_argument;
break;
case 'b':
size = strtol(isc_commandline_argument, &endp, 10);
if (*endp != '\0' || size < 0)
fatal("-b requires a non-negative number");
break;
case 'c':
classname = isc_commandline_argument;
break;
case 'e':
rsa_exp = 1;
break;
......@@ -143,13 +147,12 @@ main(int argc, char **argv) {
fatal("-g requires a positive number");
break;
case 'n':
nametype = isc_mem_strdup(mctx,
isc_commandline_argument);
nametype = isc_commandline_argument;
if (nametype == NULL)
fatal("out of memory");
break;
case 't':
type = isc_mem_strdup(mctx, isc_commandline_argument);
type = isc_commandline_argument;
if (type == NULL)
fatal("out of memory");
break;
......@@ -167,8 +170,7 @@ main(int argc, char **argv) {
"[0..15]");
break;
case 'r':
randomfile = isc_mem_strdup(mctx,
isc_commandline_argument);
randomfile = isc_commandline_argument;
if (randomfile == NULL)
fatal("out of memory");
break;
......@@ -275,6 +277,15 @@ main(int argc, char **argv) {
else
fatal("invalid nametype %s", nametype);
if (classname != NULL) {
r.base = classname;
r.length = strlen(classname);
ret = dns_rdataclass_fromtext(&rdclass, &r);
if (ret != ISC_R_SUCCESS)
fatal("unknown class %s",classname);
} else
rdclass = dns_rdataclass_in;
flags |= signatory;
if (protocol == -1) {
......@@ -325,7 +336,7 @@ main(int argc, char **argv) {
/* generate the key */
ret = dst_key_generate(name, alg, size, param, flags, protocol,
mctx, &key);
rdclass, mctx, &key);
isc_entropy_stopcallbacksources(ectx);
if (ret != ISC_R_SUCCESS) {
......@@ -382,11 +393,7 @@ main(int argc, char **argv) {
isc_buffer_clear(&buf);
ret = dst_key_buildfilename(key, 0, NULL, &buf);
printf("%s\n", filename);
isc_mem_free(mctx, algname);
isc_mem_free(mctx, nametype);
isc_mem_free(mctx, prog);
if (type != NULL)
isc_mem_free(mctx, type);
dst_key_free(&key);
if (log != NULL)
......
......@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-makekeyset.c,v 1.38 2000/09/08 14:11:53 bwelling Exp $ */
/* $Id: dnssec-makekeyset.c,v 1.39 2000/09/12 10:07:47 bwelling Exp $ */
#include <config.h>
......@@ -205,7 +205,7 @@ main(int argc, char *argv[]) {
setup_logging(verbose, mctx, &log);
dns_rdatalist_init(&rdatalist);
rdatalist.rdclass = dns_rdataclass_in;
rdatalist.rdclass = 0;
rdatalist.type = dns_rdatatype_key;
rdatalist.covers = 0;
rdatalist.ttl = ttl;
......@@ -221,6 +221,8 @@ main(int argc, char *argv[]) {
mctx, &key);
if (result != ISC_R_SUCCESS)
fatal("error loading key from %s", argv[i]);
if (rdatalist.rdclass == 0)
rdatalist.rdclass = dst_key_class(key);
isc_buffer_init(&namebuf, namestr, sizeof namestr);
result = dns_name_totext(dst_key_name(key), ISC_FALSE,
......@@ -293,7 +295,7 @@ main(int argc, char *argv[]) {
fatal("failed to convert key %s to a DNS KEY: %s",
argv[i], isc_result_totext(result));
isc_buffer_usedregion(&b, &r);
dns_rdata_fromregion(rdata, dns_rdataclass_in,
dns_rdata_fromregion(rdata, rdatalist.rdclass,
dns_rdatatype_key, &r);
ISC_LIST_APPEND(rdatalist.rdata, rdata, link);
dst_key_free(&key);
......@@ -304,7 +306,7 @@ main(int argc, char *argv[]) {
check_result(result, "dns_rdatalist_tordataset()");
dns_rdatalist_init(&sigrdatalist);
sigrdatalist.rdclass = dns_rdataclass_in;
sigrdatalist.rdclass = rdatalist.rdclass;
sigrdatalist.type = dns_rdatatype_sig;
sigrdatalist.covers = dns_rdatatype_key;
sigrdatalist.ttl = ttl;
......@@ -342,7 +344,7 @@ main(int argc, char *argv[]) {
db = NULL;
result = dns_db_create(mctx, "rbt", domain, dns_dbtype_zone,
dns_rdataclass_in, 0, NULL, &db);
rdataset.rdclass, 0, NULL, &db);
if (result != ISC_R_SUCCESS) {
char domainstr[DNS_NAME_FORMATSIZE];
dns_name_format(domain, domainstr, sizeof domainstr);
......
......@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-signkey.c,v 1.34 2000/09/08 14:15:10 bwelling Exp $ */
/* $Id: dnssec-signkey.c,v 1.35 2000/09/12 10:07:48 bwelling Exp $ */
#include <config.h>
......@@ -34,6 +34,7 @@
#include <dns/fixedname.h>
#include <dns/log.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
......@@ -71,6 +72,7 @@ usage(void) {
fprintf(stderr, "\n");
fprintf(stderr, "Options: (default value in parenthesis) \n");
fprintf(stderr, "\t-c class (IN)\n");
fprintf(stderr, "\t-s YYYYMMDDHHMMSS|+offset:\n");
fprintf(stderr, "\t\tSIG start time - absolute|offset (from keyset)\n");
fprintf(stderr, "\t-e YYYYMMDDHHMMSS|+offset|\"now\"+offset]:\n");
......@@ -142,7 +144,7 @@ findkey(dns_rdata_sig_t *sig) {
int
main(int argc, char *argv[]) {
int i, ch;
char *startstr = NULL, *endstr = NULL;
char *startstr = NULL, *endstr = NULL, *classname = NULL;
char tdomain[1025];
dns_fixedname_t fdomain;
dns_name_t *domain;
......@@ -161,19 +163,25 @@ main(int argc, char *argv[]) {
isc_result_t result;
isc_buffer_t b;
isc_region_t r;
isc_textregion_t tr;
isc_log_t *log = NULL;
keynode_t *keynode;
isc_boolean_t pseudorandom = ISC_FALSE;
unsigned int eflags;
dns_rdataclass_t rdclass;
result = isc_mem_create(0, 0, &mctx);
check_result(result, "isc_mem_create()");
dns_result_register();
while ((ch = isc_commandline_parse(argc, argv, "s:e:pr:v:h")) != -1)
while ((ch = isc_commandline_parse(argc, argv, "c:s:e:pr:v:h")) != -1)
{
switch (ch) {
case 'c':
classname = isc_commandline_argument;
break;
case 's':
startstr = isc_commandline_argument;
break;
......@@ -213,6 +221,15 @@ main(int argc, char *argv[]) {
if (argc < 2)
usage();
if (classname != NULL) {
tr.base = classname;
tr.length = strlen(classname);
result = dns_rdataclass_fromtext(&rdclass, &tr);
if (result != ISC_R_SUCCESS)
fatal("unknown class %s",classname);
} else
rdclass = dns_rdataclass_in;
setup_entropy(mctx, randomfile, &ectx);
if (randomfile != NULL)
isc_mem_free(mctx, randomfile);
......@@ -257,7 +274,7 @@ main(int argc, char *argv[]) {
db = NULL;
result = dns_db_create(mctx, "rbt", domain, dns_dbtype_zone,
dns_rdataclass_in, 0, NULL, &db);
rdclass, 0, NULL, &db);
check_result(result, "dns_db_create()");
result = dns_db_load(db, argv[0]);
......
......@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-signzone.c,v 1.97 2000/09/08 14:16:43 bwelling Exp $ */
/* $Id: dnssec-signzone.c,v 1.98 2000/09/12 10:07:50 bwelling Exp $ */
#include <config.h>
......@@ -42,6 +42,7 @@
#include <dns/nxt.h>
#include <dns/rdata.h>
#include <dns/rdataset.h>
#include <dns/rdataclass.h>
#include <dns/rdatasetiter.h>
#include <dns/rdatastruct.h>
#include <dns/rdatatype.h>
......@@ -1081,8 +1082,8 @@ signzone(dns_db_t *db, dns_dbversion_t *version) {
fatal("iterating through the database failed: %s",
isc_result_totext(result));
}
nxtresult = dns_buildnxt(db, version, node, target, zonettl);
check_result(nxtresult, "dns_buildnxt()");
nxtresult = dns_nxt_build(db, version, node, target, zonettl);
check_result(nxtresult, "dns_nxt_build()");
signname(db, version, node, name);
dresult = dns_master_dumpnodetostream(mctx, db, version,
node, name,
......@@ -1107,7 +1108,7 @@ signzone(dns_db_t *db, dns_dbversion_t *version) {
* Load the zone file from disk
*/
static void
loadzone(char *file, char *origin, dns_db_t **db) {
loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) {
isc_buffer_t b, b2;
unsigned char namedata[1024];
int len;
......@@ -1127,7 +1128,7 @@ loadzone(char *file, char *origin, dns_db_t **db) {
origin, isc_result_totext(result));
result = dns_db_create(mctx, "rbt", &name, dns_dbtype_zone,
dns_rdataclass_in, 0, NULL, db);
rdclass, 0, NULL, db);
check_result(result, "dns_db_create()");
result = dns_db_load(*db, file);
......@@ -1190,14 +1191,15 @@ usage(void) {
fprintf(stderr, "\n");
fprintf(stderr, "Options: (default value in parenthesis) \n");
fprintf(stderr, "\t-c class (IN)\n");
fprintf(stderr, "\t-s YYYYMMDDHHMMSS|+offset:\n");
fprintf(stderr, "\t\tSIG start time - absolute|offset (now)\n");
fprintf(stderr, "\t-e YYYYMMDDHHMMSS|+offset|\"now\"+offset]:\n");
fprintf(stderr, "\t\tSIG end time - absolute|from start|from now "
"(now + 30 days)\n");
fprintf(stderr, "\t-c ttl:\n");
fprintf(stderr, "\t\tcycle period - regenerate "
"if < cycle from end ( (end-start)/4 )\n");
fprintf(stderr, "\t-i interval:\n");
fprintf(stderr, "\t\tcycle interval - resign "
"if < interval from end ( (end-start)/4 )\n");
fprintf(stderr, "\t-v level:\n");
fprintf(stderr, "\t\tverbose level (0)\n");
fprintf(stderr, "\t-o origin:\n");
......@@ -1223,7 +1225,7 @@ usage(void) {
int
main(int argc, char *argv[]) {
int i, ch;
char *startstr = NULL, *endstr = NULL;
char *startstr = NULL, *endstr = NULL, *classname;
char *origin = NULL, *file = NULL, *output = NULL;
char *randomfile = NULL;
char *endp;
......@@ -1235,6 +1237,8 @@ main(int argc, char *argv[]) {
isc_boolean_t pseudorandom = ISC_FALSE;
unsigned int eflags;
isc_boolean_t free_output = ISC_FALSE;
dns_rdataclass_t rdclass;
isc_textregion_t r;
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS)
......@@ -1242,9 +1246,13 @@ main(int argc, char *argv[]) {
dns_result_register();
while ((ch = isc_commandline_parse(argc, argv, "s:e:c:v:o:f:ahpr:"))
while ((ch = isc_commandline_parse(argc, argv, "c:s:e:i:v:o:f:ahpr:"))
!= -1) {
switch (ch) {
case 'c':
classname = isc_commandline_argument;
break;
case 's':
startstr = isc_commandline_argument;
break;
......@@ -1253,7 +1261,7 @@ main(int argc, char *argv[]) {
endstr = isc_commandline_argument;
break;
case 'c':
case 'i':
endp = NULL;
cycle = strtol(isc_commandline_argument, &endp, 0);
if (*endp != '\0' || cycle < 0)
......@@ -1318,6 +1326,16 @@ main(int argc, char *argv[]) {
if (cycle == -1)
cycle = (endtime - starttime) / 4;
if (classname != NULL) {
r.base = classname;
r.length = strlen(classname);
result = dns_rdataclass_fromtext(&rdclass, &r);
if (result != ISC_R_SUCCESS)
fatal("unknown class %s",classname);
} else
rdclass = dns_rdataclass_in;
setup_logging(verbose, mctx, &log);
argc -= isc_commandline_index;
......@@ -1344,7 +1362,7 @@ main(int argc, char *argv[]) {
origin = file;
db = NULL;
loadzone(file, origin, &db);
loadzone(file, origin, rdclass, &db);
ISC_LIST_INIT(keylist);
loadzonekeys(db);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment