]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
debugging the keysingin. Our DNSKEY are 3 bytes _larger_ than bind9's...??
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 17 May 2005 13:14:55 +0000 (13:14 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 17 May 2005 13:14:55 +0000 (13:14 +0000)
dnssec.c
keys.c
tests/run-test20.c

index e2b82e26612421e0fb19da7392e11cd8f98f79ab..755317e2bd018ac9a3fb4e2873ee893848d04733 100644 (file)
--- a/dnssec.c
+++ b/dnssec.c
@@ -884,6 +884,8 @@ ldns_sign_public(ldns_rr_list *rrset, ldns_key_list *keys)
        key_count = 0;
        signatures = ldns_rr_list_new();
 
+       ldns_rr_list_print(stdout, rrset);
+
        /* prepare a signature and add all the know data
         * prepare the rrset. Sign this together.  */
        rrset_clone = ldns_rr_list_deep_clone(rrset);
@@ -892,6 +894,14 @@ ldns_sign_public(ldns_rr_list *rrset, ldns_key_list *keys)
        }
 
        /* make it canonical */
+       
+       printf("Printing rrset\n[");
+       ldns_rr_list_print(stdout, rrset);
+
+       printf("]\n");
+
+       printf("Dus hier komen we niet meer\n");
+       
        for(i = 0; i < ldns_rr_list_rr_count(rrset_clone); i++) {
                ldns_rr2canonical(ldns_rr_list_rr(rrset_clone, i));
        }
diff --git a/keys.c b/keys.c
index 3c50a5ccb92b4545309adaa658aa0fdd78828591..8c6dbefa44d40a20679bb60f0e112b5b7659782b 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -68,7 +68,7 @@ ldns_key_new_frm_algorithm(ldns_signing_algorithm alg, uint16_t size)
        switch(alg) {
                case LDNS_SIGN_RSAMD5:
                case LDNS_SIGN_RSASHA1:
-                       r = RSA_generate_key((int)size, RSA_F4, NULL, NULL);
+                       r = RSA_generate_key((int)size, RSA_3, NULL, NULL);
                        if (RSA_check_key(r) != 1) {
                                return NULL;
                        }
@@ -290,6 +290,7 @@ ldns_key_rsa2bin(unsigned char *data, RSA *k, uint16_t *size)
                 BN_bn2bin(k->e, data + 1);  
                 BN_bn2bin(k->n, data + *(data + 1) + 2);
                *size = (uint16_t) BN_num_bytes(k->n) + 4;
+               printf("size %d\n", *size);
         } else if (BN_num_bytes(k->e) <= 16) {
                 data[0] = 0;
                /* this writing is not endian save or is it? */
@@ -336,13 +337,12 @@ ldns_key2rr(ldns_key *k)
         * much as it can, but it does not know about key-flags
         * for instance
         */
-
        ldns_rr *pubkey;
        ldns_rdf *keybin;
        unsigned char *bin;
        uint16_t size;
-       pubkey = ldns_rr_new();
 
+       pubkey = ldns_rr_new();
        if (!k) {
                return NULL;
        }
@@ -375,6 +375,7 @@ ldns_key2rr(ldns_key *k)
                case LDNS_SIGN_RSASHA1:
                        ldns_rr_push_rdf(pubkey,
                                        ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, LDNS_RSASHA1));
+                       printf("Entering here I\n");
                        if (!ldns_key_rsa2bin(bin, ldns_key_rsa_key(k), &size)) {
                                return NULL;
                        }
@@ -391,7 +392,7 @@ ldns_key2rr(ldns_key *k)
                        break;
        }
        /* fourth the key bin material */
-       keybin = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, size+1, bin);
+       keybin = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, size + 1, bin);
        LDNS_FREE(bin);
        ldns_rr_push_rdf(pubkey, keybin);
        return pubkey;
index 66f28b7fb2312861becf3b9d95ca9e68044ebc3e..257445b2dfbb76e17f287e183d728e0af087d085 100644 (file)
@@ -52,10 +52,13 @@ main(void)
        ldns_key_set_pubkey_owner(privkey, owner);
 
        ldns_key_set_origttl(privkey, 1800);
-       /*      SSL_load_error_strings();*/
+       SSL_load_error_strings();
 
        ldns_key_list_push_key(keys, privkey);
 
+       rr = ldns_rr_new_frm_str("www.miek.nl IN A 127.0.0.1");
+       ldns_rr_print(stdout, rr);
+       
        ldns_rr_list_push_rr(rrs, rr);
        
        dnskey = ldns_key2rr(privkey);
@@ -70,13 +73,21 @@ main(void)
        }
        ldns_rr_list_push_rr(dnskeys, dnskey);
 
+       ldns_rr_list_print(stdout, dnskeys);
+       printf("\n Trying to sign\n");
+
+       
        signatures = ldns_sign_public(rrs, keys);
 
        ldns_rr_list_print(stdout, signatures);
 
        printf("Now we are going to verify\n");
 
-/*     printf("\n[%d]\n", ldns_verify(rrs, signatures, dnskeys));*/
+       if (ldns_verify(rrs, signatures, dnskeys)) {
+               printf("SUCESS\n\n");
+       } else {
+               printf("FAILURE\n\n");
+       }
        
         return 0;
 }