From: Miek Gieben Date: Tue, 22 Mar 2005 12:35:00 +0000 (+0000) Subject: some important fixes and ... a new run-test program X-Git-Tag: release-0.50~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f278beffd2f3f080914dfd3d4a839d25d5924473;p=thirdparty%2Fldns.git some important fixes and ... a new run-test program --- diff --git a/Makefile.in b/Makefile.in index 0b4cf469..3171008a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -53,7 +53,7 @@ TEST_SOURCES = run-test0.c run-test1.c run-test2.c run-test3.c \ run-test4.c run-test5.c run-test6.c run-test7.c \ run-test8.c run-test9.c run-test10.c run-test11.c \ run-test13.c run-test14.c run-test15.c run-test16.c \ - run-test17.c + run-test17.c run-test18.c #ALL_SOURCES = $(TEST_SOURCES) $(LIBDNS_SOURCES) $(PROG_SOURCES) ALL_SOURCES = $(LIBDNS_SOURCES) $(PROG_SOURCES) @@ -126,6 +126,8 @@ run-test16: run-test16.o $(LIBDNS_OBJECTS) $(LIBOBJS) $(LINK) ${LIBS} -o $@ $+ run-test17: run-test17.o $(LIBDNS_OBJECTS) $(LIBOBJS) $(LINK) ${LIBS} -o $@ $+ +run-test18: run-test18.o $(LIBDNS_OBJECTS) $(LIBOBJS) + $(LINK) ${LIBS} -o $@ $+ run-test-trace: run-test-trace.o $(LIBDNS_OBJECTS) $(LIBOBJS) $(LINK) ${LIBS} -o $@ $+ @@ -184,8 +186,23 @@ test10: run-test10 ./run-test10 test11: run-test11 ./run-test11 - -test: test0 test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 +test12: run-test12 + ./run-test11 +test13: run-test13 + ./run-test11 +test14: run-test14 + ./run-test11 +test15: run-test15 + ./run-test15 +test16: run-test16 + ./run-test16 +test17: run-test17 + ./run-test17 +test18: run-test18 + ./run-test18 + +test: test0 test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 \ + test13 test14 test15 test16 test17 test18 ## No need for changes here diff --git a/keys.c b/keys.c index d9840b95..85755227 100644 --- a/keys.c +++ b/keys.c @@ -52,7 +52,7 @@ ldns_key_new() * generate a new key based on the algorithm */ ldns_key * -ldns_key_new_frm_algorithm(ldns_signing_algorithm alg, int size) +ldns_key_new_frm_algorithm(ldns_signing_algorithm alg, uint16_t size) { ldns_key *k; DSA *d; @@ -68,15 +68,15 @@ ldns_key_new_frm_algorithm(ldns_signing_algorithm alg, int size) switch(alg) { case LDNS_SIGN_RSAMD5: case LDNS_SIGN_RSASHA1: - r = RSA_generate_key(size, RSA_F4, NULL, NULL); + r = RSA_generate_key((int)size, RSA_F4, NULL, NULL); if (RSA_check_key(r) != 1) { printf("keygen failed\n"); return NULL; } - break; ldns_key_set_rsa_key(k, r); + break; case LDNS_SIGN_DSA: - d = DSA_generate_parameters(size, NULL, 0, NULL, NULL, NULL, NULL); + d = DSA_generate_parameters((int)size, NULL, 0, NULL, NULL, NULL, NULL); DSA_generate_key(d); ldns_key_set_dsa_key(k, d); break; diff --git a/ldns/keys.h b/ldns/keys.h index d915db9a..abed64be 100644 --- a/ldns/keys.h +++ b/ldns/keys.h @@ -95,7 +95,8 @@ ldns_rdf * ldns_key_pubkey_owner(ldns_key *k); bool ldns_key_list_push_key(ldns_key_list *key_list, ldns_key *key); ldns_key * ldns_key_list_pop_key(ldns_key_list *key_list); -ldns_key * ldns_key_new_frm_algorithm(ldns_signing_algorithm a, int size); +ldns_key * ldns_key_new_frm_algorithm(ldns_signing_algorithm a, uint16_t size); +ldns_rr * ldns_key2rr(ldns_key *k); #endif /* _LDNS_KEYS_H */ diff --git a/run-test18.c b/run-test18.c new file mode 100644 index 00000000..ab64b788 --- /dev/null +++ b/run-test18.c @@ -0,0 +1,44 @@ +/* + * mx is a small programs that prints out the mx records + * for a particulary domain + */ + +#include +#include +#include + +int +usage(FILE *fp, char *prog) { + fprintf(fp, "%s keygen\n", prog); + fprintf(fp, " generate a DNSKEY RR \n"); + return 0; +} + +int +main(int argc, char *argv[]) +{ + ldns_rr *dnskey; + ldns_key *privkey; + + privkey = ldns_key_new_frm_algorithm(LDNS_SIGN_RSASHA1, 1024); + if (!privkey) { + printf("Ah, keygen failed"); + exit(1); + } + RSA_print_fp(stdout, ldns_key_rsa_key(privkey), 0); + printf("did it print\n"); + + dnskey = ldns_key2rr(privkey); + if (dnskey) { + ldns_rr_print(stdout, dnskey); + } + printf("\n"); + + if (argc != 2) { + usage(stdout, argv[0]); + exit(1); + } + + + return 0; +}