]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
mwhoohaha, it works
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 19 May 2005 12:52:02 +0000 (12:52 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 19 May 2005 12:52:02 +0000 (12:52 +0000)
keys.c
tests/run-test20.c

diff --git a/keys.c b/keys.c
index ea3f29d9d5b388e74e3e37ce390b67bdc4531cb1..5c576d45cb2b95b5f606b82abe536c8b9565d579 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -191,7 +191,7 @@ ldns_key_new_frm_fp_rsa(FILE *f)
        }
 
        /* PrivateExponent, rsa->d */
-       if (ldns_fget_keyword_data(f, "PrivateEponent", ": ", d, "\n", LDNS_MAX_LINELEN) == -1) {
+       if (ldns_fget_keyword_data(f, "PrivateExponent", ": ", d, "\n", LDNS_MAX_LINELEN) == -1) {
                goto error;
        }
        i = b64_pton((const char*)d, buf, b64_ntop_calculate_size(strlen(d)));
@@ -494,9 +494,12 @@ ldns_key_list_pop_key(ldns_key_list *key_list)
 {                               
         size_t key_count;
         ldns_key *pop;
+
+       if (!key_list) {
+               return NULL;
+       }
         
         key_count = ldns_key_list_key_count(key_list);
-                                
         if (key_count == 0) {
                 return NULL;
         }       
@@ -515,6 +518,10 @@ ldns_key_list_pop_key(ldns_key_list *key_list)
 static bool
 ldns_key_rsa2bin(unsigned char *data, RSA *k, uint16_t *size)
 {
+       if (!k) {
+               return false;
+       }
+       
         if (BN_num_bytes(k->e) <= 2) {
                 data[0] = (unsigned char) BN_num_bytes(k->e);
 
@@ -539,6 +546,11 @@ static bool
 ldns_key_dsa2bin(unsigned char *data, DSA *k, uint16_t *size)
 {
        uint8_t T;
+
+       if (!k) {
+               return false;
+       }
+       
        /* See RFC2536 */
        *size = (uint16_t)BN_num_bytes(k->g);
        T = (*size - 64) / 8;
index 338e3f386c12ea28d42f06cca99333eeee8718dc..3392a9e2ceae3df055a52906023633b5f178c413 100644 (file)
@@ -115,7 +115,23 @@ main(void)
        printf("Kom ik hier nog wel ofzo?\n");
 
        fclose(f);
+       if (!privkey) { 
+               printf("arrg no key could be found!\n");
+               exit(1);
+       }
 
+       dnskey = ldns_key2rr(privkey);
+       if (dnskey) {
+               ldns_rr_print(stdout, dnskey);
+               /*
+               printf("; {%d}\n", 
+                               (int) ldns_calc_keytag(dnskey));
+                               */
+               printf("\n");
+               ldns_key_set_keytag(privkey, ldns_calc_keytag(dnskey));
+       } else {
+               exit(1);
+       }