]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
it does _something_
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 22 Mar 2005 12:52:24 +0000 (12:52 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 22 Mar 2005 12:52:24 +0000 (12:52 +0000)
keys.c
ldns/dnssec.h
run-test18.c

diff --git a/keys.c b/keys.c
index 857552270b34247a3ecff48cfc43f99fc94bf8c4..db633b0f5273bdec7ff8037e2e66c681496222e0 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -44,6 +44,7 @@ ldns_key_new()
        if (!newkey) {
                return NULL;
        } else {
+               ldns_key_set_pubkey_owner(newkey, NULL);
                return newkey;
        }
 }
@@ -328,13 +329,6 @@ ldns_key_dsa2bin(unsigned char *data, DSA *k, uint16_t *size)
 ldns_rr *
 ldns_key2rr(ldns_key *k)
 {
-       /* need a owner, 
-        * keytag
-        * pub key values
-        * proto
-        * algorthm
-        */
-
        /* this function will convert a the keydata contained in
         * rsa/dsa pointers to a DNSKEY rr. It will fill in as
         * much as it can, but it does not know about key-flags
@@ -357,28 +351,33 @@ ldns_key2rr(ldns_key *k)
        }
 
        ldns_rr_set_type(pubkey, LDNS_RR_TYPE_DNSKEY);
+       /* zero-th rdf - flags */
+       ldns_rr_push_rdf(pubkey,
+                       ldns_native2rdf_int16(LDNS_RDF_TYPE_INT16, 0));
+       /* first - proto */
+       ldns_rr_push_rdf(pubkey, 
+                       ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8, DNSSEC_KEYPROTO));
        
-       if (!ldns_key_pubkey_owner(k)) {
-               ldns_rr_set_owner(pubkey, ldns_key_pubkey_owner(k));
-       }
+       ldns_rr_set_owner(pubkey, ldns_key_pubkey_owner(k));
 
+       /* third - da algorithm */
        switch(ldns_key_algorithm(k)) {
                case LDNS_SIGN_RSAMD5:
-                       ldns_rr_dnskey_set_algorithm(pubkey,
+                       ldns_rr_push_rdf(pubkey,
                                        ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, LDNS_RSAMD5));
                        if (!ldns_key_rsa2bin(bin, ldns_key_rsa_key(k), &size)) {
                                return NULL;
                        }
                        break;
                case LDNS_SIGN_RSASHA1:
-                       ldns_rr_dnskey_set_algorithm(pubkey,
+                       ldns_rr_push_rdf(pubkey,
                                        ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, LDNS_RSASHA1));
                        if (!ldns_key_rsa2bin(bin, ldns_key_rsa_key(k), &size)) {
                                return NULL;
                        }
                        break;
                case LDNS_SIGN_DSA:
-                       ldns_rr_dnskey_set_algorithm(pubkey,
+                       ldns_rr_push_rdf(pubkey,
                                        ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, LDNS_DSA));
                        if (!ldns_key_dsa2bin(bin, ldns_key_dsa_key(k), &size)) {
                                return NULL;
@@ -388,9 +387,10 @@ ldns_key2rr(ldns_key *k)
                        /* tja */
                        break;
        }
+       /* fourth the key bin material */
        keybin = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, size, bin);
-       FREE(bin);
-       ldns_rr_dnskey_set_key(pubkey, keybin);
+       /*FREE(bin);*/
+       ldns_rr_push_rdf(pubkey, keybin);
        return pubkey;
 }
 
index 316a8322d3b42a51b8ede495a706f3198693b91f..478d6143928ebf554144ff31f7f37714d2236cde 100644 (file)
@@ -18,6 +18,7 @@
 #include <ldns/packet.h>
 
 #define MAX_KEYLEN     2048
+#define DNSSEC_KEYPROTO        3
 
 /**
  * algorigthms used in dns
index ab64b78844740c81698796657ff807fdc38fcbea..d21a2c3f99e131280a7d8c6b0c8470e80de13def 100644 (file)
@@ -19,26 +19,29 @@ main(int argc, char *argv[])
 {
        ldns_rr *dnskey;
        ldns_key *privkey;
+       ldns_rdf *owner;
 
        privkey = ldns_key_new_frm_algorithm(LDNS_SIGN_RSASHA1, 1024);
        if (!privkey) {
                printf("Ah, keygen failed");
                exit(1);
        }
+
+       owner = ldns_dname_new_frm_str("miek.nl");
+       ldns_key_set_pubkey_owner(privkey, owner);
+       
+       /*
        RSA_print_fp(stdout, ldns_key_rsa_key(privkey), 0);
        printf("did it print\n");
+       */
 
        dnskey = ldns_key2rr(privkey);
        if (dnskey) {
+               printf("[\n");
                ldns_rr_print(stdout, dnskey);
+               printf("]\n");
        }
        printf("\n");
        
-       if (argc != 2) {
-               usage(stdout, argv[0]);
-               exit(1);
-       } 
-
-        
         return 0;
 }