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 md[EVP_MAX_MD_SIZE];
336 unsigned char *sha1_hash;
350 sha1_hash = SHA1((
unsigned char*)ldns_buffer_begin(to_sign),
351 ldns_buffer_position(to_sign), md);
357 sig = DSA_do_sign(sha1_hash, SHA_DIGEST_LENGTH, key);
363 data =
LDNS_XMALLOC(uint8_t, 1 + 2 * SHA_DIGEST_LENGTH);
371 # ifdef HAVE_DSA_SIG_GET0
372 DSA_SIG_get0(sig, &
R, &S);
377 pad = 20 - (size_t) BN_num_bytes(
R);
379 memset(data + 1, 0, pad);
381 BN_bn2bin(
R, (
unsigned char *) (data + 1) + pad);
383 pad = 20 - (size_t) BN_num_bytes(S);
385 memset(data + 1 + SHA_DIGEST_LENGTH, 0, pad);
387 BN_bn2bin(S, (
unsigned char *) (data + 1 + SHA_DIGEST_LENGTH + pad));
390 1 + 2 * SHA_DIGEST_LENGTH,
399 (void)to_sign; (void)key;
408 ldns_pkey_is_ecdsa(EVP_PKEY* pkey)
412 #ifdef HAVE_EVP_PKEY_GET_BASE_ID
413 if(EVP_PKEY_get_base_id(pkey) != EVP_PKEY_EC)
415 #elif defined(HAVE_EVP_PKEY_BASE_ID)
416 if(EVP_PKEY_base_id(pkey) != EVP_PKEY_EC)
419 if(EVP_PKEY_type(pkey->type) != EVP_PKEY_EC)
422 ec = EVP_PKEY_get1_EC_KEY(pkey);
423 g = EC_KEY_get0_group(ec);
428 if(EC_GROUP_get_curve_name(g) == NID_X9_62_prime256v1) {
432 if(EC_GROUP_get_curve_name(g) == NID_secp384r1) {
446 const EVP_MD *digest_type)
452 const EVP_MD *md_type;
462 md_type = digest_type;
464 if(EVP_PKEY_id(key) == NID_ED25519) {
470 if(EVP_PKEY_id(key) == NID_ED448) {
480 #ifdef HAVE_EVP_MD_CTX_NEW
481 ctx = EVP_MD_CTX_new();
483 ctx = (EVP_MD_CTX*)malloc(
sizeof(*ctx));
484 if(ctx) EVP_MD_CTX_init(ctx);
491 #if defined(USE_ED25519) || defined(USE_ED448)
492 if(md_type == NULL) {
494 r = EVP_DigestSignInit(ctx, NULL, md_type, NULL, key);
496 size_t siglen_sizet = ldns_buffer_capacity(b64sig);
497 r = EVP_DigestSign(ctx,
498 (
unsigned char*)ldns_buffer_begin(b64sig),
500 (
unsigned char*)ldns_buffer_begin(to_sign),
501 ldns_buffer_position(to_sign));
502 siglen = (
unsigned int)siglen_sizet;
507 if(md_type != NULL) {
509 r = EVP_SignInit(ctx, md_type);
511 r = EVP_SignUpdate(ctx, (
unsigned char*)
512 ldns_buffer_begin(to_sign),
513 ldns_buffer_position(to_sign));
516 r = EVP_SignFinal(ctx, (
unsigned char*)
517 ldns_buffer_begin(b64sig), &siglen, key);
522 EVP_MD_CTX_destroy(ctx);
531 # ifdef HAVE_EVP_PKEY_GET_BASE_ID
532 if (EVP_PKEY_get_base_id(key) == EVP_PKEY_DSA) {
533 # elif defined(HAVE_EVP_PKEY_BASE_ID)
534 if (EVP_PKEY_base_id(key) == EVP_PKEY_DSA) {
536 if (EVP_PKEY_type(key->type) == EVP_PKEY_DSA) {
543 #if defined(USE_ECDSA)
546 EVP_PKEY_get_base_id(key)
548 EVP_PKEY_base_id(key)
550 EVP_PKEY_type(key->type)
554 if(ldns_pkey_is_ecdsa(key)) {
557 b64sig, (
long)siglen, ldns_pkey_is_ecdsa(key));
565 ldns_buffer_begin(b64sig));
568 EVP_MD_CTX_destroy(ctx);
575 unsigned char md[EVP_MAX_MD_SIZE];
576 unsigned char *sha1_hash;
588 sha1_hash = SHA1((
unsigned char*)ldns_buffer_begin(to_sign),
589 ldns_buffer_position(to_sign), md);
595 result = RSA_sign(NID_sha1, sha1_hash, SHA_DIGEST_LENGTH,
596 (
unsigned char*)ldns_buffer_begin(b64sig),
604 ldns_buffer_begin(b64sig));
612 unsigned char md[EVP_MAX_MD_SIZE];
613 unsigned char *md5_hash;
623 md5_hash = MD5((
unsigned char*)ldns_buffer_begin(to_sign),
624 ldns_buffer_position(to_sign), md);
630 RSA_sign(NID_md5, md5_hash, MD5_DIGEST_LENGTH,
631 (
unsigned char*)ldns_buffer_begin(b64sig),
635 ldns_buffer_begin(b64sig));
645 ldns_dnssec_addresses_on_glue_list(
653 for (cur_rrs = cur_rrset->
rrs;
655 cur_rrs = cur_rrs->
next) {
669 cur_rrset = cur_rrset->
next;
685 int below_delegation = -1;
688 if (!zone || !zone->
names) {
713 if (below_delegation && glue_list) {
714 s = ldns_dnssec_addresses_on_glue_list(
736 below_delegation = 1;
738 s = ldns_dnssec_addresses_on_glue_list(
747 below_delegation = 0;
807 if (soa && soa->
rrs && soa->
rrs->
rr) {
811 nsec_ttl = min_rdf == NULL
820 cur_node = first_node;
828 while (cur_node && next_node) {
840 cur_node = next_node;
847 if (cur_node && !next_node) {
868 ldns_hashed_names_node_free(
ldns_rbnode_t *node,
void *arg) {
893 if (!zone || !new_rrs || !zone->
names) {
908 if (soa && soa->
rrs && soa->
rrs->
rr) {
912 nsec_ttl = min_rdf == NULL
925 ldns_hashed_names_node_free, NULL);
936 current_name_node = first_name_node;
952 if (!current_name->
rrsets) {
960 if (hashmap_node == NULL) {
971 hashmap_node->
data = current_name;
988 if (nsec3_list == NULL) {
1011 uint16_t iterations,
1012 uint8_t salt_length,
1015 return ldns_dnssec_zone_create_nsec3s_mkmap(zone, new_rrs, algorithm,
1016 flags, iterations, salt_length, salt, NULL);
1024 ,
int (*func)(
ldns_rr *,
void *)
1037 switch(func(NULL, arg)) {
1047 fprintf(stderr,
"[XX] unknown return value from callback\n");
1053 (void)func(cur_rr->
rr, arg);
1056 next_rr = cur_rr->
next;
1058 switch (func(cur_rr->
rr, arg)) {
1085 prev_rr->
next = next_rr;
1093 prev_rr->
next = next_rr;
1101 fprintf(stderr,
"[XX] unknown return value from callback\n");
1116 int (*func)(
ldns_rr *,
void*),
1125 ldns_key_list_filter_for_dnskey(
ldns_key_list *key_list,
int flags)
1172 ldns_key_list_filter_for_non_dnskey(
ldns_key_list *key_list,
int flags)
1221 ,
int (*func)(
ldns_rr *,
void*)
1239 int on_delegation_point = 0;
1259 cur_rrset = cur_name->
rrsets;
1275 ldns_key_list_filter_for_dnskey(key_list, flags);
1278 ldns_key_list_filter_for_non_dnskey(key_list, flags);
1284 cur_rr = cur_rrset->
rrs;
1287 cur_rr = cur_rr->
next;
1293 if (!on_delegation_point ||
1322 cur_rrset = cur_rrset->
next;
1332 ldns_key_list_filter_for_non_dnskey(key_list, flags);
1367 int (*func)(
ldns_rr *,
void *),
1379 int (*func)(
ldns_rr *,
void *),
1385 bool zonemd_added =
false;
1387 if (!zone || !new_rrs || !key_list) {
1395 rrsets_ref = &(*rrsets_ref)->
next;
1398 zonemd_rrset.
rrs = NULL;
1401 zonemd_rrset.
next = *rrsets_ref;
1402 *rrsets_ref = &zonemd_rrset;
1403 zonemd_added =
true;
1416 else if (zone->
names
1437 rrsets_ref = &(*rrsets_ref)->
next;
1438 *rrsets_ref = zonemd_rrset.
next;
1449 int (*func)(
ldns_rr *,
void *),
1453 uint16_t iterations,
1454 uint8_t salt_length,
1458 func, arg, algorithm, flags, iterations, salt_length, salt, 0,
1466 int (*func)(
ldns_rr *,
void *),
1470 uint16_t iterations,
1471 uint8_t salt_length,
1478 bool zonemd_added =
false;
1537 rrsets_ref = &(*rrsets_ref)->
next;
1540 zonemd_rrset.
rrs = NULL;
1543 zonemd_rrset.
next = *rrsets_ref;
1544 *rrsets_ref = &zonemd_rrset;
1545 zonemd_added =
true;
1548 result = ldns_dnssec_zone_create_nsec3s_mkmap(zone,
1562 rrsets_ref = &(*rrsets_ref)->
next;
1563 *rrsets_ref = zonemd_rrset.
next;
1577 if (result || !zone->
names)
1589 int (*func)(
ldns_rr *,
void *),
1593 uint16_t iterations,
1594 uint8_t salt_length,
1599 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_compare_v(const void *a, const void *b)
Given in dnssec_zone.c, also used in dnssec_sign.c:w.
int ldns_dname_is_wildcard(const ldns_rdf *dname)
Check if dname is a wildcard, starts with *.
signed char 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 *rdf)
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.
This module contains base functions for DNSSEC operations (RFC4033 t/m RFC4035).
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...
#define LDNS_DEFAULT_EXP_TIME
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...
#define LDNS_SIGNATURE_LEAVE_ADD_NEW
return values for the old-signature callback
ldns_rr * ldns_dnssec_create_nsec(const ldns_dnssec_name *from, const ldns_dnssec_name *to, ldns_rr_type nsec_type)
Creates NSEC.
#define LDNS_SIGNATURE_REMOVE_NO_ADD
int ldns_dnssec_default_replace_signatures(ldns_rr *sig, void *n)
Default callback function to always leave present signatures, and add new ones.
ldns_status ldns_dnssec_chain_nsec3_list(ldns_rr_list *nsec3_rrs)
chains nsec3 list
#define LDNS_SIGNATURE_REMOVE_ADD_NEW
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.
#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.
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_rrsig2buffer_wire(ldns_buffer *output, const ldns_rr *sigrr)
Converts a rrsig to wireformat BUT EXCLUDE the rrsig rdata This is needed in DNSSEC verification.
ldns_status ldns_rr_list2buffer_wire(ldns_buffer *output, const ldns_rr_list *rrlist)
Copies the rr_list data to the buffer in wire format.
uint32_t ldns_key_expiration(const ldns_key *k)
return the key's expiration date
void ldns_key_list_set_use(ldns_key_list *keys, signed char v)
Set the 'use' flag for all keys in the list.
void ldns_key_set_use(ldns_key *k, signed char v)
set the use flag
EVP_PKEY * ldns_key_evp_key(const ldns_key *k)
returns the (openssl) EVP struct contained in the key
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,...
enum ldns_enum_signing_algorithm ldns_signing_algorithm
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
@ LDNS_SIGN_ECDSAP256SHA256
@ LDNS_SIGN_RSASHA1_NSEC3
@ LDNS_SIGN_ECDSAP384SHA384
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
signed char ldns_key_use(const ldns_key *k)
return the use flag
uint16_t ldns_key_flags(const ldns_key *k)
return the flag of the key
#define LDNS_KEY_ZONE_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
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.
ldns_rbnode_t * ldns_rbtree_next(ldns_rbnode_t *rbtree)
Returns next larger node in the tree.
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.
#define LDNS_RBTREE_NULL
The nullpointer, points to empty node.
ldns_rbnode_t * ldns_rbtree_insert(ldns_rbtree_t *rbtree, ldns_rbnode_t *data)
Insert data into the tree.
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.
@ 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
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.
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).
@ 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
signed char ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
pushes an rr to an rrlist.
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.
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
enum ldns_enum_rr_class ldns_rr_class
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.
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)
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.
signed char 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 * 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.
#define LDNS_MALLOC(type)
Memory management macros.
void ldns_set_bit(uint8_t *byte, int bit_nr, signed char 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_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
signed char ldns_zone_push_rr(ldns_zone *z, ldns_rr *rr)
push an single rr to a zone structure.
ldns_rr_list * ldns_zone_rrs(const ldns_zone *z)
Get a list of a zone's content.
ldns_rr * ldns_zone_soa(const ldns_zone *z)
Return the soa record of a zone.