15 #include <openssl/ssl.h>
16 #include <openssl/evp.h>
17 #include <openssl/rand.h>
18 #include <openssl/err.h>
19 #include <openssl/md5.h>
20 #include <openssl/bn.h>
21 #include <openssl/rsa.h>
23 #include <openssl/dsa.h>
27 #define LDNS_SIGN_WITH_ZONEMD ( LDNS_SIGN_WITH_ZONEMD_SIMPLE_SHA384 \
28 | LDNS_SIGN_WITH_ZONEMD_SIMPLE_SHA512 )
139 # ifdef HAVE_EVP_DSS1
173 EVP_get_digestbyname(
"md_gost94"));
214 printf(
"unknown algorithm, ");
215 printf(
"is the one used available on this system?\n");
335 unsigned char *sha1_hash;
349 sha1_hash = SHA1((
unsigned char*)ldns_buffer_begin(to_sign),
350 ldns_buffer_position(to_sign), NULL);
356 sig = DSA_do_sign(sha1_hash, SHA_DIGEST_LENGTH, key);
362 data =
LDNS_XMALLOC(uint8_t, 1 + 2 * SHA_DIGEST_LENGTH);
370 # ifdef HAVE_DSA_SIG_GET0
371 DSA_SIG_get0(sig, &
R, &S);
376 pad = 20 - (size_t) BN_num_bytes(
R);
378 memset(data + 1, 0, pad);
380 BN_bn2bin(
R, (
unsigned char *) (data + 1) + pad);
382 pad = 20 - (size_t) BN_num_bytes(S);
384 memset(data + 1 + SHA_DIGEST_LENGTH, 0, pad);
386 BN_bn2bin(S, (
unsigned char *) (data + 1 + SHA_DIGEST_LENGTH + pad));
389 1 + 2 * SHA_DIGEST_LENGTH,
398 (void)to_sign; (void)key;
407 ldns_pkey_is_ecdsa(EVP_PKEY* pkey)
411 #ifdef HAVE_EVP_PKEY_GET_BASE_ID
412 if(EVP_PKEY_get_base_id(pkey) != EVP_PKEY_EC)
414 #elif defined(HAVE_EVP_PKEY_BASE_ID)
415 if(EVP_PKEY_base_id(pkey) != EVP_PKEY_EC)
418 if(EVP_PKEY_type(pkey->type) != EVP_PKEY_EC)
421 ec = EVP_PKEY_get1_EC_KEY(pkey);
422 g = EC_KEY_get0_group(ec);
427 if(EC_GROUP_get_curve_name(g) == NID_X9_62_prime256v1) {
431 if(EC_GROUP_get_curve_name(g) == NID_secp384r1) {
445 const EVP_MD *digest_type)
451 const EVP_MD *md_type;
461 md_type = digest_type;
463 if(EVP_PKEY_id(key) == NID_ED25519) {
469 if(EVP_PKEY_id(key) == NID_ED448) {
479 #ifdef HAVE_EVP_MD_CTX_NEW
480 ctx = EVP_MD_CTX_new();
482 ctx = (EVP_MD_CTX*)malloc(
sizeof(*ctx));
483 if(ctx) EVP_MD_CTX_init(ctx);
490 #if defined(USE_ED25519) || defined(USE_ED448)
491 if(md_type == NULL) {
493 r = EVP_DigestSignInit(ctx, NULL, md_type, NULL, key);
495 size_t siglen_sizet = ldns_buffer_capacity(b64sig);
496 r = EVP_DigestSign(ctx,
497 (
unsigned char*)ldns_buffer_begin(b64sig),
499 (
unsigned char*)ldns_buffer_begin(to_sign),
500 ldns_buffer_position(to_sign));
501 siglen = (
unsigned int)siglen_sizet;
506 if(md_type != NULL) {
508 r = EVP_SignInit(ctx, md_type);
510 r = EVP_SignUpdate(ctx, (
unsigned char*)
511 ldns_buffer_begin(to_sign),
512 ldns_buffer_position(to_sign));
515 r = EVP_SignFinal(ctx, (
unsigned char*)
516 ldns_buffer_begin(b64sig), &siglen, key);
521 EVP_MD_CTX_destroy(ctx);
530 # ifdef HAVE_EVP_PKEY_GET_BASE_ID
531 if (EVP_PKEY_get_base_id(key) == EVP_PKEY_DSA) {
532 # elif defined(HAVE_EVP_PKEY_BASE_ID)
533 if (EVP_PKEY_base_id(key) == EVP_PKEY_DSA) {
535 if (EVP_PKEY_type(key->type) == EVP_PKEY_DSA) {
542 #if defined(USE_ECDSA)
545 EVP_PKEY_get_base_id(key)
547 EVP_PKEY_base_id(key)
549 EVP_PKEY_type(key->type)
553 if(ldns_pkey_is_ecdsa(key)) {
556 b64sig, (
long)siglen, ldns_pkey_is_ecdsa(key));
564 ldns_buffer_begin(b64sig));
567 EVP_MD_CTX_destroy(ctx);
574 unsigned char *sha1_hash;
586 sha1_hash = SHA1((
unsigned char*)ldns_buffer_begin(to_sign),
587 ldns_buffer_position(to_sign), NULL);
593 result = RSA_sign(NID_sha1, sha1_hash, SHA_DIGEST_LENGTH,
594 (
unsigned char*)ldns_buffer_begin(b64sig),
602 ldns_buffer_begin(b64sig));
610 unsigned char *md5_hash;
620 md5_hash = MD5((
unsigned char*)ldns_buffer_begin(to_sign),
621 ldns_buffer_position(to_sign), NULL);
627 RSA_sign(NID_md5, md5_hash, MD5_DIGEST_LENGTH,
628 (
unsigned char*)ldns_buffer_begin(b64sig),
632 ldns_buffer_begin(b64sig));
642 ldns_dnssec_addresses_on_glue_list(
650 for (cur_rrs = cur_rrset->
rrs;
652 cur_rrs = cur_rrs->
next) {
666 cur_rrset = cur_rrset->
next;
682 int below_delegation = -1;
685 if (!zone || !zone->
names) {
710 if (below_delegation && glue_list) {
711 s = ldns_dnssec_addresses_on_glue_list(
733 below_delegation = 1;
735 s = ldns_dnssec_addresses_on_glue_list(
744 below_delegation = 0;
804 if (soa && soa->
rrs && soa->
rrs->
rr) {
808 nsec_ttl = min_rdf == NULL
817 cur_node = first_node;
825 while (cur_node && next_node) {
837 cur_node = next_node;
844 if (cur_node && !next_node) {
865 ldns_hashed_names_node_free(
ldns_rbnode_t *node,
void *arg) {
890 if (!zone || !new_rrs || !zone->
names) {
905 if (soa && soa->
rrs && soa->
rrs->
rr) {
909 nsec_ttl = min_rdf == NULL
922 ldns_hashed_names_node_free, NULL);
933 current_name_node = first_name_node;
949 if (!current_name->
rrsets) {
957 if (hashmap_node == NULL) {
968 hashmap_node->
data = current_name;
985 if (nsec3_list == NULL) {
1008 uint16_t iterations,
1009 uint8_t salt_length,
1012 return ldns_dnssec_zone_create_nsec3s_mkmap(zone, new_rrs, algorithm,
1013 flags, iterations, salt_length, salt, NULL);
1021 ,
int (*func)(
ldns_rr *,
void *)
1034 switch(func(NULL, arg)) {
1044 fprintf(stderr,
"[XX] unknown return value from callback\n");
1050 (void)func(cur_rr->
rr, arg);
1053 next_rr = cur_rr->
next;
1055 switch (func(cur_rr->
rr, arg)) {
1082 prev_rr->
next = next_rr;
1090 prev_rr->
next = next_rr;
1098 fprintf(stderr,
"[XX] unknown return value from callback\n");
1113 int (*func)(
ldns_rr *,
void*),
1122 ldns_key_list_filter_for_dnskey(
ldns_key_list *key_list,
int flags)
1169 ldns_key_list_filter_for_non_dnskey(
ldns_key_list *key_list,
int flags)
1218 ,
int (*func)(
ldns_rr *,
void*)
1236 int on_delegation_point = 0;
1256 cur_rrset = cur_name->
rrsets;
1272 ldns_key_list_filter_for_dnskey(key_list, flags);
1275 ldns_key_list_filter_for_non_dnskey(key_list, flags);
1281 cur_rr = cur_rrset->
rrs;
1284 cur_rr = cur_rr->
next;
1290 if (!on_delegation_point ||
1319 cur_rrset = cur_rrset->
next;
1329 ldns_key_list_filter_for_non_dnskey(key_list, flags);
1364 int (*func)(
ldns_rr *,
void *),
1376 int (*func)(
ldns_rr *,
void *),
1382 bool zonemd_added =
false;
1384 if (!zone || !new_rrs || !key_list) {
1392 rrsets_ref = &(*rrsets_ref)->
next;
1395 zonemd_rrset.
rrs = NULL;
1398 zonemd_rrset.
next = *rrsets_ref;
1399 *rrsets_ref = &zonemd_rrset;
1400 zonemd_added =
true;
1413 else if (zone->
names
1434 rrsets_ref = &(*rrsets_ref)->
next;
1435 *rrsets_ref = zonemd_rrset.
next;
1446 int (*func)(
ldns_rr *,
void *),
1450 uint16_t iterations,
1451 uint8_t salt_length,
1455 func, arg, algorithm, flags, iterations, salt_length, salt, 0,
1463 int (*func)(
ldns_rr *,
void *),
1467 uint16_t iterations,
1468 uint8_t salt_length,
1475 bool zonemd_added =
false;
1534 rrsets_ref = &(*rrsets_ref)->
next;
1537 zonemd_rrset.
rrs = NULL;
1540 zonemd_rrset.
next = *rrsets_ref;
1541 *rrsets_ref = &zonemd_rrset;
1542 zonemd_added =
true;
1545 result = ldns_dnssec_zone_create_nsec3s_mkmap(zone,
1559 rrsets_ref = &(*rrsets_ref)->
next;
1560 *rrsets_ref = zonemd_rrset.
next;
1574 if (result || !zone->
names)
1586 int (*func)(
ldns_rr *,
void *),
1590 uint16_t iterations,
1591 uint8_t salt_length,
1596 func, arg, algorithm, flags, iterations, salt_length, salt,
void ldns_buffer_free(ldns_buffer *buffer)
frees the buffer.
ldns_buffer * ldns_buffer_new(size_t capacity)
creates a new buffer with the specified capacity.
#define HAVE_EVP_PKEY_GET_BASE_ID
#define HAVE_EVP_PKEY_BASE_ID
int ldns_dname_is_wildcard(const ldns_rdf *dname)
Check if dname is a wildcard, starts with *.
bool ldns_dname_is_subdomain(const ldns_rdf *sub, const ldns_rdf *parent)
test whether the name sub falls under parent (i.e.
void ldns_dname2canonical(const ldns_rdf *rd)
Put a dname into canonical fmt - ie.
uint8_t ldns_dname_label_count(const ldns_rdf *r)
count the number of labels inside a LDNS_RDF_DNAME type rdf.
ldns_rdf * ldns_dname_label(const ldns_rdf *rdf, uint8_t labelpos)
look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try and retrieve a specific label.
ldns_rr * ldns_dnssec_create_nsec3(const ldns_dnssec_name *from, const ldns_dnssec_name *to, const ldns_rdf *zone_name, uint8_t algorithm, uint8_t flags, uint16_t iterations, uint8_t salt_length, const uint8_t *salt)
Creates NSEC3.
ldns_rdf * ldns_convert_dsa_rrsig_asn12rdf(const ldns_buffer *sig, const long sig_len)
Converts the DSA signature from ASN1 representation (RFC2459, as used by OpenSSL) to raw signature da...
int ldns_dnssec_default_replace_signatures(ldns_rr *sig __attribute__((unused)), void *n __attribute__((unused)))
void ldns_nsec3_add_param_rdfs(ldns_rr *rr, uint8_t algorithm, uint8_t flags, uint16_t iterations, uint8_t salt_length, const uint8_t *salt)
Sets all the NSEC3 options.
ldns_rdf * ldns_convert_ecdsa_rrsig_asn1len2rdf(const ldns_buffer *sig, const long sig_len, int num_bytes)
Converts the ECDSA signature from ASN1 representation (as used by OpenSSL) to raw signature data as u...
ldns_rr * ldns_dnssec_create_nsec(const ldns_dnssec_name *from, const ldns_dnssec_name *to, ldns_rr_type nsec_type)
Creates NSEC.
ldns_status ldns_dnssec_chain_nsec3_list(ldns_rr_list *nsec3_rrs)
chains nsec3 list
int ldns_dnssec_rrsets_contains_type(const ldns_dnssec_rrsets *rrsets, ldns_rr_type type)
returns whether a rrset of the given type is found in the rrsets.
This module contains base functions for DNSSEC operations (RFC4033 t/m RFC4035).
#define LDNS_DEFAULT_EXP_TIME
#define LDNS_SIGNATURE_LEAVE_ADD_NEW
return values for the old-signature callback
#define LDNS_SIGNATURE_REMOVE_NO_ADD
#define LDNS_SIGNATURE_REMOVE_ADD_NEW
#define LDNS_SIGNATURE_LEAVE_NO_ADD
ldns_rr_list * ldns_sign_public(ldns_rr_list *rrset, ldns_key_list *keys)
use this function to sign with a public/private key alg return the created signatures
ldns_rr * ldns_create_empty_rrsig(const ldns_rr_list *rrset, const ldns_key *current_key)
Create an empty RRSIG RR (i.e.
#define LDNS_SIGN_WITH_ZONEMD
ldns_rdf * ldns_sign_public_rsamd5(ldns_buffer *to_sign, RSA *key)
Sign a buffer with the RSA key (hash with MD5)
ldns_rbnode_t * ldns_dnssec_name_node_next_nonglue(ldns_rbnode_t *node)
Finds the first dnssec_name node in the rbtree that is not occluded.
ldns_zone * ldns_zone_sign(const ldns_zone *zone, ldns_key_list *key_list)
Signs the zone, and returns a newly allocated signed zone.
ldns_status ldns_dnssec_zone_mark_glue(ldns_dnssec_zone *zone)
Marks the names in the zone that are occluded.
ldns_rdf * ldns_sign_public_evp(ldns_buffer *to_sign, EVP_PKEY *key, const EVP_MD *digest_type)
Sign data with EVP (general method for different algorithms)
ldns_status ldns_dnssec_zone_mark_and_get_glue(ldns_dnssec_zone *zone, ldns_rr_list *glue_list)
Marks the names in the zone that are occluded.
ldns_status ldns_dnssec_zone_create_nsec3s(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, uint8_t algorithm, uint8_t flags, uint16_t iterations, uint8_t salt_length, uint8_t *salt)
Adds NSEC3 records to the zone.
ldns_status ldns_dnssec_zone_sign(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int(*func)(ldns_rr *, void *), void *arg)
signs the given zone with the given keys
ldns_status dnssec_zone_equip_zonemd(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int flags)
ldns_status ldns_dnssec_zone_sign_nsec3_flg(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int(*func)(ldns_rr *, void *), void *arg, uint8_t algorithm, uint8_t flags, uint16_t iterations, uint8_t salt_length, uint8_t *salt, int signflags)
signs the given zone with the given new zone, with NSEC3
ldns_status ldns_dnssec_zone_create_rrsigs(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int(*func)(ldns_rr *, void *), void *arg)
Adds signatures to the zone.
ldns_status ldns_dnssec_zone_sign_nsec3_flg_mkmap(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int(*func)(ldns_rr *, void *), void *arg, uint8_t algorithm, uint8_t flags, uint16_t iterations, uint8_t salt_length, uint8_t *salt, int signflags, ldns_rbtree_t **map)
signs the given zone with the given new zone, with NSEC3
ldns_dnssec_rrs * ldns_dnssec_remove_signatures(ldns_dnssec_rrs *signatures, ldns_key_list *key_list __attribute__((unused)), int(*func)(ldns_rr *, void *), void *arg)
ldns_status ldns_dnssec_zone_sign_flg(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int(*func)(ldns_rr *, void *), void *arg, int flags)
signs the given zone with the given keys
ldns_rdf * ldns_sign_public_dsa(ldns_buffer *to_sign, DSA *key)
Sign a buffer with the DSA key (hash with SHA1)
ldns_zone * ldns_zone_sign_nsec3(ldns_zone *zone, ldns_key_list *key_list, uint8_t algorithm, uint8_t flags, uint16_t iterations, uint8_t salt_length, uint8_t *salt)
Signs the zone with NSEC3, and returns a newly allocated signed zone.
ldns_status ldns_dnssec_zone_create_nsecs(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs)
Adds NSEC records to the given dnssec_zone.
ldns_status ldns_dnssec_zone_sign_nsec3(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int(*func)(ldns_rr *, void *), void *arg, uint8_t algorithm, uint8_t flags, uint16_t iterations, uint8_t salt_length, uint8_t *salt)
signs the given zone with the given new zone, with NSEC3
ldns_status ldns_dnssec_zone_create_rrsigs_flg(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int(*func)(ldns_rr *, void *), void *arg, int flags)
Adds signatures to the zone.
ldns_rdf * ldns_sign_public_rsasha1(ldns_buffer *to_sign, RSA *key)
Sign a buffer with the RSA key (hash with SHA1)
ldns_rdf * ldns_sign_public_buffer(ldns_buffer *sign_buf, ldns_key *current_key)
Sign the buffer which contains the wiredata of an rrset, and the corresponding empty rrsig rr with th...
#define LDNS_SIGN_DNSKEY_WITH_ZSK
dnssec_verify
#define LDNS_SIGN_WITH_ALL_ALGORITHMS
#define LDNS_SIGN_NO_KEYS_NO_NSECS
ldns_dnssec_rrsets * ldns_dnssec_zone_find_rrset(const ldns_dnssec_zone *zone, const ldns_rdf *dname, ldns_rr_type type)
Find the RRset with the given name and type in the zone.
ldns_status ldns_dnssec_rrs_add_rr(ldns_dnssec_rrs *rrs, ldns_rr *rr)
Adds an RR to the list of RRs.
ldns_status ldns_dnssec_name_add_rr(ldns_dnssec_name *name, ldns_rr *rr)
Inserts the given rr at the right place in the current dnssec_name No checking is done whether the na...
ldns_status ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone, ldns_rr *rr)
Adds the given RR to the zone.
ldns_status ldns_dnssec_zone_add_empty_nonterminals(ldns_dnssec_zone *zone)
Adds explicit dnssec_name structures for the empty nonterminals in this zone.
ldns_rdf * ldns_dnssec_name_name(const ldns_dnssec_name *name)
Returns the domain name of the given dnssec_name structure.
void ldns_dnssec_zone_free(ldns_dnssec_zone *zone)
Frees the given zone structure, and its rbtree of dnssec_names Individual ldns_rr RRs within those na...
ldns_dnssec_rrs * ldns_dnssec_rrs_new(void)
Creates a new entry for 1 pointer to an rr and 1 pointer to the next rrs.
ldns_dnssec_rrsets * ldns_dnssec_name_find_rrset(const ldns_dnssec_name *name, ldns_rr_type type)
Find the RRset with the given type in within this name structure.
int ldns_dname_compare_v(const void *a, const void *b)
Given in dnssec_zone.c, also used in dnssec_sign.c:w.
ldns_dnssec_zone * ldns_dnssec_zone_new(void)
Creates a new dnssec_zone structure.
@ LDNS_STATUS_NSEC3_DOMAINNAME_OVERFLOW
enum ldns_enum_status ldns_status
ldns_status ldns_rr_list2buffer_wire(ldns_buffer *buffer, const ldns_rr_list *rr_list)
Copies the rr_list data to the buffer in wire format.
ldns_status ldns_rrsig2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr)
Converts a rrsig to wireformat BUT EXCLUDE the rrsig rdata This is needed in DNSSEC verification.
uint32_t ldns_key_expiration(const ldns_key *k)
return the key's expiration date
EVP_PKEY * ldns_key_evp_key(const ldns_key *k)
returns the (openssl) EVP struct contained in the key
void ldns_key_set_use(ldns_key *k, bool v)
set the use flag
void ldns_key_list_set_use(ldns_key_list *keys, bool v)
Set the 'use' flag for all keys in the list.
ldns_rr * ldns_key2rr(const ldns_key *k)
converts a ldns_key to a public key rr If the key data exists at an external point,...
uint16_t ldns_key_keytag(const ldns_key *k)
return the keytag
ldns_signing_algorithm ldns_key_algorithm(const ldns_key *k)
return the signing alg of the key
uint32_t ldns_key_inception(const ldns_key *k)
return the key's inception date
ldns_rdf * ldns_key_pubkey_owner(const ldns_key *k)
return the public key's owner
uint16_t ldns_key_flags(const ldns_key *k)
return the flag of the key
size_t ldns_key_list_key_count(const ldns_key_list *key_list)
returns the number of keys in the key list
ldns_key * ldns_key_list_key(const ldns_key_list *key, size_t nr)
returns a pointer to the key in the list at the given position
bool ldns_key_use(const ldns_key *k)
return the use flag
enum ldns_enum_signing_algorithm ldns_signing_algorithm
@ LDNS_SIGN_ECDSAP256SHA256
@ LDNS_SIGN_RSASHA1_NSEC3
@ LDNS_SIGN_ECDSAP384SHA384
#define LDNS_KEY_ZONE_KEY
Including this file will include all ldns files, and define some lookup tables.
#define LDNS_MAX_PACKETLEN
ldns_rbtree_t * ldns_rbtree_create(int(*cmpf)(const void *, const void *))
Create new tree (malloced) with given key compare function.
void ldns_traverse_postorder(ldns_rbtree_t *tree, void(*func)(ldns_rbnode_t *, void *), void *arg)
Call function for all elements in the redblack tree, such that leaf elements are called before parent...
ldns_rbnode_t * ldns_rbtree_first(const ldns_rbtree_t *rbtree)
Returns first (smallest) node in the tree.
ldns_rbnode_t * ldns_rbtree_next(ldns_rbnode_t *node)
Returns next larger node in the tree.
ldns_rbnode_t * ldns_rbtree_insert(ldns_rbtree_t *rbtree, ldns_rbnode_t *data)
Insert data into the tree.
#define LDNS_RBTREE_NULL
The nullpointer, points to empty node.
ldns_rdf * ldns_native2rdf_int8(ldns_rdf_type type, uint8_t value)
returns the rdf containing the native uint8_t repr.
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
uint32_t ldns_rdf2native_int32(const ldns_rdf *rd)
returns the native uint32_t representation from the rdf.
uint16_t ldns_rdf2native_int16(const ldns_rdf *rd)
returns the native uint16_t representation from the rdf.
ldns_rdf * ldns_native2rdf_int16(ldns_rdf_type type, uint16_t value)
returns the rdf containing the native uint16_t representation.
size_t ldns_rdf_size(const ldns_rdf *rd)
returns the size of the rdf.
uint8_t * ldns_rdf_data(const ldns_rdf *rd)
returns the data of the rdf.
ldns_rdf * ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value)
returns an rdf that contains the given int32 value.
void ldns_rdf_free(ldns_rdf *rd)
frees a rdf structure, leaving the data pointer intact.
ldns_rdf * ldns_rdf_clone(const ldns_rdf *rd)
clones a rdf structure.
ldns_rdf * ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data)
allocates a new rdf structure and fills it.
@ LDNS_RDF_TYPE_INT32
32 bits
@ LDNS_RDF_TYPE_B64
b64 string
@ LDNS_RDF_TYPE_TIME
time (32 bits)
@ LDNS_RDF_TYPE_INT8
8 bits
@ LDNS_RDF_TYPE_INT16
16 bits
@ LDNS_RDF_TYPE_ALG
a key algorithm
@ LDNS_RDF_TYPE_TYPE
a RR type
void ldns_rr_list_free(ldns_rr_list *rr_list)
frees an rr_list structure.
ldns_rr * ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
returns a specific rr of an rrlist.
uint32_t ldns_rr_ttl(const ldns_rr *rr)
returns the ttl of an rr structure.
ldns_rdf * ldns_rr_owner(const ldns_rr *rr)
returns the owner name of an rr structure.
void ldns_rr_list_deep_free(ldns_rr_list *rr_list)
frees an rr_list structure and all rrs contained therein.
void ldns_rr_free(ldns_rr *rr)
frees an RR structure
void ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner)
sets the owner in the rr structure.
ldns_rr_type ldns_rr_list_type(const ldns_rr_list *rr_list)
Returns the type of the first element of the RR If there are no elements present, 0 is returned.
ldns_rr * ldns_rr_new_frm_type(ldns_rr_type t)
creates a new rr structure, based on the given type.
void ldns_rr_list_sort(ldns_rr_list *unsorted)
sorts an rr_list (canonical wire format).
void ldns_rr2canonical(ldns_rr *rr)
converts each dname in a rr to its canonical form.
size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
returns the number of rr's in an rr_list.
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
void ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
sets the ttl in the rr structure.
bool ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
pushes an rr to an rrlist.
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
void ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class)
sets the class in the rr.
ldns_rr_list * ldns_rr_list_new(void)
creates a new rr_list structure.
ldns_rr * ldns_rr_clone(const ldns_rr *rr)
clones a rr and all its data
ldns_rr_list * ldns_rr_list_clone(const ldns_rr_list *rrlist)
clones an rrlist.
ldns_rdf * ldns_rr_rdf(const ldns_rr *rr, size_t nr)
returns the rdata field member counter.
ldns_rdf * ldns_rr_pop_rdf(ldns_rr *rr)
removes a rd_field member, it will be popped from the last position.
@ LDNS_RR_TYPE_RRSIG
DNSSEC.
@ LDNS_RR_TYPE_A
a host address
@ LDNS_RR_TYPE_SOA
marks the start of a zone of authority
@ LDNS_RR_TYPE_DNAME
RFC2672.
@ LDNS_RR_TYPE_DS
RFC4034, RFC3658.
@ LDNS_RR_TYPE_NSEC3PARAM
@ LDNS_RR_TYPE_AAAA
ipv6 address
@ LDNS_RR_TYPE_NS
an authoritative name server
enum ldns_enum_rr_class ldns_rr_class
bool ldns_rr_rrsig_set_expiration(ldns_rr *r, ldns_rdf *f)
sets the expiration date of a LDNS_RR_TYPE_RRSIG rr
bool ldns_rr_rrsig_set_keytag(ldns_rr *r, ldns_rdf *f)
sets the keytag of a LDNS_RR_TYPE_RRSIG rr
bool ldns_rr_rrsig_set_algorithm(ldns_rr *r, ldns_rdf *f)
sets the algorithm of a LDNS_RR_TYPE_RRSIG rr
ldns_rdf * ldns_rr_rrsig_keytag(const ldns_rr *r)
returns the keytag of a LDNS_RR_TYPE_RRSIG RR
bool ldns_rr_rrsig_set_typecovered(ldns_rr *r, ldns_rdf *f)
sets the typecovered of a LDNS_RR_TYPE_RRSIG rr
bool ldns_rr_rrsig_set_labels(ldns_rr *r, ldns_rdf *f)
sets the number of labels of a LDNS_RR_TYPE_RRSIG rr
bool ldns_rr_rrsig_set_inception(ldns_rr *r, ldns_rdf *f)
sets the inception date of a LDNS_RR_TYPE_RRSIG rr
bool ldns_rr_rrsig_set_signame(ldns_rr *r, ldns_rdf *f)
sets the signers name of a LDNS_RR_TYPE_RRSIG rr
bool ldns_rr_rrsig_set_sig(ldns_rr *r, ldns_rdf *f)
sets the signature data of a LDNS_RR_TYPE_RRSIG rr
bool ldns_rr_rrsig_set_origttl(ldns_rr *r, ldns_rdf *f)
sets the original TTL of a LDNS_RR_TYPE_RRSIG rr
The rbnode_t struct definition.
const void * data
pointer to data
const void * key
pointer to sorting key
definition for tree struct
ldns_rbnode_t * root
The root of the red-black tree.
implementation of buffers to ease operations
ldns_dnssec_rrs * nsec_signatures
signatures for the NSEC record
ldns_rr * nsec
NSEC pointing to the next name (or NSEC3 pointing to the next NSEC3)
bool is_glue
Unlike what the name is_glue suggests, this field is set to true by ldns_dnssec_zone_mark_glue() or l...
ldns_rdf * hashed_name
pointer to store the hashed name (only used when in an NSEC3 zone
ldns_dnssec_rrsets * rrsets
The rrsets for this name.
ldns_rdf * name
pointer to a dname containing the name.
ldns_dnssec_rrs * signatures
ldns_dnssec_rrsets * next
Structure containing a dnssec zone.
ldns_rbtree_t * hashed_names
tree of ldns_dnssec_names by nsec3 hashes (when applicable)
ldns_rbtree_t * names
tree of ldns_dnssec_names
ldns_dnssec_name * soa
points to the name containing the SOA RR
Same as rr_list, but now for keys.
General key structure, can contain all types of keys that are used in DNSSEC.
Resource record data field.
List or Set of Resource Records.
void ldns_set_bit(uint8_t *byte, int bit_nr, bool value)
sets the specified bit in the specified byte to 1 if value is true, 0 if false The bits are counted f...
#define LDNS_MALLOC(type)
Memory management macros.
#define LDNS_XMALLOC(type, count)
void ldns_zone_set_soa(ldns_zone *z, ldns_rr *soa)
Set the zone's soa record.
ldns_zone * ldns_zone_new(void)
create a new ldns_zone structure
ldns_rr_list * ldns_zone_rrs(const ldns_zone *z)
Get a list of a zone's content.
bool ldns_zone_push_rr(ldns_zone *z, ldns_rr *rr)
push an single rr to a zone structure.
ldns_rr * ldns_zone_soa(const ldns_zone *z)
Return the soa record of a zone.