keys.h

Go to the documentation of this file.
00001 /*
00002  * 
00003  * keys.h
00004  *
00005  * priv key definitions
00006  *
00007  * a Net::DNS like library for C
00008  *
00009  * (c) NLnet Labs, 2004, 2005
00010  *
00011  * See the file LICENSE for the license
00012  */
00013 
00014 #ifndef _LDNS_KEYS_H
00015 #define _LDNS_KEYS_H
00016 
00017 #include <openssl/ssl.h>
00018 #include <ldns/dnssec.h>
00019 #include <ldns/util.h>
00020 
00021 extern ldns_lookup_table ldns_signing_algorithms[];
00022 
00023 #define LDNS_KEY_ZONE_KEY 0x0100
00024 #define LDNS_KEY_SEP_KEY 0x0001
00025 
00029 enum ldns_enum_algorithm
00030 {
00031         LDNS_RSAMD5             = 1,
00032         LDNS_DH                 = 2,
00033         LDNS_DSA                = 3,
00034         LDNS_ECC                = 4,
00035         LDNS_RSASHA1            = 5,
00036         LDNS_INDIRECT           = 252,
00037         LDNS_PRIVATEDNS         = 253,
00038         LDNS_PRIVATEOID         = 254
00039 };
00040 typedef enum ldns_enum_algorithm ldns_algorithm;
00041 
00045 enum ldns_enum_signing_algorithm
00046 {
00047         LDNS_SIGN_RSAMD5         = LDNS_RSAMD5,
00048         LDNS_SIGN_RSASHA1        = LDNS_RSASHA1,
00049         LDNS_SIGN_DSA            = LDNS_DSA,
00050         LDNS_SIGN_HMACMD5        = 150  /* not official! */
00051 };
00052 typedef enum ldns_enum_signing_algorithm ldns_signing_algorithm;
00053 
00057 struct ldns_struct_key {
00058         ldns_signing_algorithm _alg;
00060         union {
00061                 RSA     *rsa;
00062                 DSA     *dsa;
00063                 unsigned char *hmac;
00064         } _key;
00066         union {
00067                 struct {
00068                         uint32_t orig_ttl;
00069                         uint32_t inception;
00070                         uint32_t expiration;
00071                         uint16_t keytag;
00072                         uint16_t flags;
00073                 }  dnssec;
00074         } _extra;
00075         ldns_rdf *_pubkey_owner;
00076 };
00077 typedef struct ldns_struct_key ldns_key;
00078 
00082 struct ldns_struct_key_list
00083 {
00084         size_t _key_count;
00085         ldns_key **_keys;
00086 };
00087 typedef struct ldns_struct_key_list ldns_key_list;
00088 
00089 
00093 ldns_key_list *ldns_key_list_new();
00094 
00098 ldns_key *ldns_key_new();
00099 
00107 ldns_key *ldns_key_new_frm_algorithm(ldns_signing_algorithm a, uint16_t size);
00108 
00116 ldns_key *ldns_key_new_frm_fp(FILE *fp);
00117 
00126 ldns_key *ldns_key_new_frm_fp_l(FILE *fp, int *line_nr);
00127 
00134 RSA *ldns_key_new_frm_fp_rsa(FILE *fp);
00135 
00143 RSA *ldns_key_new_frm_fp_rsa_l(FILE *fp, int *line_nr);
00144 
00151 DSA *ldns_key_new_frm_fp_dsa(FILE *fp);
00152 
00160 DSA *ldns_key_new_frm_fp_dsa_l(FILE *fp, int *line_nr);
00161 
00162 /* acces write functions */
00163 void ldns_key_set_algorithm(ldns_key *k, ldns_signing_algorithm l);
00164 void ldns_key_set_rsa_key(ldns_key *k, RSA *r);
00165 void ldns_key_set_dsa_key(ldns_key *k, DSA *d);
00166 void ldns_key_set_hmac_key(ldns_key *k, unsigned char *hmac);
00167 void ldns_key_set_origttl(ldns_key *k, uint32_t t);
00168 void ldns_key_set_inception(ldns_key *k, uint32_t i);
00169 void ldns_key_set_expiration(ldns_key *k, uint32_t e);
00170 void ldns_key_set_pubkey_owner(ldns_key *k, ldns_rdf *r);
00171 void ldns_key_set_keytag(ldns_key *k, uint16_t tag);
00172 void ldns_key_set_flags(ldns_key *k, uint16_t flags);
00173 void ldns_key_list_set_key_count(ldns_key_list *key, size_t count);
00174 
00181 bool ldns_key_list_push_key(ldns_key_list *key_list, ldns_key *key);
00182 
00186 size_t ldns_key_list_key_count(ldns_key_list *key_list);
00187 
00191 ldns_key *ldns_key_list_key(ldns_key_list *key, size_t nr);
00192 
00196 RSA *ldns_key_rsa_key(ldns_key *k);
00197 
00201 DSA *ldns_key_dsa_key(ldns_key *k);
00202 
00203 ldns_signing_algorithm ldns_key_algorithm(ldns_key *k);
00204 unsigned char *ldns_key_hmac_key(ldns_key *k);
00205 uint32_t ldns_key_origttl(ldns_key *k);
00206 uint32_t ldns_key_inception(ldns_key *k);
00207 uint32_t ldns_key_expiration(ldns_key *k);
00208 uint16_t ldns_key_keytag(ldns_key *k);
00209 ldns_rdf *ldns_key_pubkey_owner(ldns_key *k);
00210 uint16_t ldns_key_flags(ldns_key *k);
00211 
00217 ldns_key *ldns_key_list_pop_key(ldns_key_list *key_list);
00218 
00225 ldns_rr *ldns_key2rr(ldns_key *k);
00226 
00233 void ldns_key_print(FILE *output, ldns_key *k);
00234 
00240 void ldns_key_free(ldns_key *key);
00241 
00247 void ldns_key_deep_free(ldns_key *key);
00248 
00253 void ldns_key_list_free(ldns_key_list *key_list);
00254 
00255 #endif /* _LDNS_KEYS_H */

Generated on Fri Sep 14 20:08:41 2007 for ldns by  doxygen 1.5.1