]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
some important fixes and ... a new run-test program
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 22 Mar 2005 12:35:00 +0000 (12:35 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 22 Mar 2005 12:35:00 +0000 (12:35 +0000)
Makefile.in
keys.c
ldns/keys.h
run-test18.c [new file with mode: 0644]

index 0b4cf469d4c98f1b57320e7dafb3c9727da92a71..3171008a36b144f23561b7580f9c10e8e848ff0a 100644 (file)
@@ -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 d9840b95684b8badf04f0f22bcc5d9a1d0754b13..857552270b34247a3ecff48cfc43f99fc94bf8c4 100644 (file)
--- 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;
index d915db9a0b632e4f747b6b6a0fa89b6b6663aeb4..abed64be8772e4785f13d7a4a9181298ae555e47 100644 (file)
@@ -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 (file)
index 0000000..ab64b78
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * mx is a small programs that prints out the mx records
+ * for a particulary domain
+ */
+
+#include <stdio.h>
+#include <config.h>
+#include <ldns/ldns.h>
+
+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;
+}