val_kentry.h File Reference
#include "util/storage/lruhash.h"
#include "sldns/rrdef.h"

Data Structures

struct  key_entry_key
 A key entry for the validator. More...
 
struct  key_entry_data
 Key entry for the validator. More...
 

Functions

size_t key_entry_sizefunc (void *key, void *data)
 function for lruhash operation
 
int key_entry_compfunc (void *k1, void *k2)
 function for lruhash operation
 
void key_entry_delkeyfunc (void *key, void *userarg)
 function for lruhash operation
 
void key_entry_deldatafunc (void *data, void *userarg)
 function for lruhash operation
 
void key_entry_hash (struct key_entry_key *kk)
 calculate hash for key entry More...
 
struct key_entry_keykey_entry_copy_toregion (struct key_entry_key *kkey, struct regional *region)
 Copy a key entry, to be region-allocated. More...
 
struct key_entry_keykey_entry_copy (struct key_entry_key *kkey)
 Copy a key entry, malloced. More...
 
int key_entry_isnull (struct key_entry_key *kkey)
 See if this is a null entry. More...
 
int key_entry_isgood (struct key_entry_key *kkey)
 See if this entry is good. More...
 
int key_entry_isbad (struct key_entry_key *kkey)
 See if this entry is bad. More...
 
void key_entry_set_reason (struct key_entry_key *kkey, char *reason)
 Set reason why a key is bad. More...
 
void key_entry_set_reason_bogus (struct key_entry_key *kkey, sldns_ede_code ede)
 Set the EDE (RFC8914) code why the key is bad, if it exists (so not LDNS_EDE_NONE). More...
 
char * key_entry_get_reason (struct key_entry_key *kkey)
 Get reason why a key is bad. More...
 
sldns_ede_code key_entry_get_reason_bogus (struct key_entry_key *kkey)
 Get the EDE (RFC8914) code why a key is bad. More...
 
struct key_entry_keykey_entry_create_null (struct regional *region, uint8_t *name, size_t namelen, uint16_t dclass, time_t ttl, time_t now)
 Create a null entry, in the given region. More...
 
struct key_entry_keykey_entry_create_rrset (struct regional *region, uint8_t *name, size_t namelen, uint16_t dclass, struct ub_packed_rrset_key *rrset, uint8_t *sigalg, time_t now)
 Create a key entry from an rrset, in the given region. More...
 
struct key_entry_keykey_entry_create_bad (struct regional *region, uint8_t *name, size_t namelen, uint16_t dclass, time_t ttl, time_t now)
 Create a bad entry, in the given region. More...
 
struct ub_packed_rrset_keykey_entry_get_rrset (struct key_entry_key *kkey, struct regional *region)
 Obtain rrset from a key entry, allocated in region. More...
 
size_t key_entry_keysize (struct key_entry_key *kkey)
 Get keysize of the keyentry. More...
 

Detailed Description

This file contains functions for dealing with validator key entries.

Function Documentation

◆ key_entry_hash()

void key_entry_hash ( struct key_entry_key kk)

calculate hash for key entry

Parameters
kkkey entry. The lruhash entry.hash value is filled in.

References dname_query_hash(), key_entry_key::entry, lruhash_entry::hash, hashlittle(), key_entry_key::key_class, and key_entry_key::name.

Referenced by key_cache_insert(), key_cache_remove(), and key_cache_search().

◆ key_entry_copy_toregion()

struct key_entry_key* key_entry_copy_toregion ( struct key_entry_key kkey,
struct regional region 
)

Copy a key entry, to be region-allocated.

Parameters
kkeythe key entry key (and data pointer) to copy.
regionwhere to allocate it
Returns
newly region-allocated entry or NULL on a failure to allocate.

References key_entry_data::algo, lruhash_entry::data, key_entry_key::entry, lruhash_entry::key, key_entry_key::name, key_entry_key::namelen, packed_rrset_ptr_fixup(), packed_rrset_sizeof(), key_entry_data::reason, regional_alloc_init(), regional_strdup(), and key_entry_data::rrset_data.

Referenced by key_cache_obtain().

◆ key_entry_copy()

struct key_entry_key* key_entry_copy ( struct key_entry_key kkey)

Copy a key entry, malloced.

Parameters
kkeythe key entry key (and data pointer) to copy.
Returns
newly allocated entry or NULL on a failure to allocate memory.

References key_entry_data::algo, lruhash_entry::data, key_entry_key::entry, lruhash_entry::key, lruhash_entry::lock, memdup(), key_entry_key::name, key_entry_key::namelen, packed_rrset_ptr_fixup(), packed_rrset_sizeof(), key_entry_data::reason, and key_entry_data::rrset_data.

Referenced by key_cache_insert().

◆ key_entry_isnull()

int key_entry_isnull ( struct key_entry_key kkey)

See if this is a null entry.

Does not do locking.

Parameters
kkeymust have data pointer set correctly
Returns
true if it is a NULL rrset entry.

References lruhash_entry::data, key_entry_key::entry, key_entry_data::isbad, and key_entry_data::rrset_data.

Referenced by iter_indicates_dnssec(), processFindKey(), and processValidate().

◆ key_entry_isgood()

int key_entry_isgood ( struct key_entry_key kkey)

See if this entry is good.

Does not do locking.

Parameters
kkeymust have data pointer set correctly
Returns
true if it is good.

References lruhash_entry::data, key_entry_key::entry, key_entry_data::isbad, and key_entry_data::rrset_data.

Referenced by iter_indicates_dnssec(), key_entry_keysize(), nsec3_prove_nameerror(), nsec3_prove_nodata(), nsec3_prove_nods(), nsec3_prove_nxornodata(), nsec3_prove_wildcard(), and process_ds_response().

◆ key_entry_isbad()

int key_entry_isbad ( struct key_entry_key kkey)

See if this entry is bad.

Does not do locking.

Parameters
kkeymust have data pointer set correctly
Returns
true if it is bad.

References lruhash_entry::data, key_entry_key::entry, and key_entry_data::isbad.

Referenced by iter_indicates_dnssec(), key_cache_insert(), process_ds_response(), processFindKey(), and processValidate().

◆ key_entry_set_reason()

void key_entry_set_reason ( struct key_entry_key kkey,
char *  reason 
)

Set reason why a key is bad.

Parameters
kkeybad key.
reasonstring to attach, you must allocate it. Not safe to call twice unless you deallocate it yourself.

References lruhash_entry::data, key_entry_key::entry, and key_entry_data::reason.

Referenced by key_cache_insert().

◆ key_entry_set_reason_bogus()

void key_entry_set_reason_bogus ( struct key_entry_key kkey,
sldns_ede_code  ede 
)

Set the EDE (RFC8914) code why the key is bad, if it exists (so not LDNS_EDE_NONE).

Parameters
kkeybad key.
edeEDE code to attach to this key.

References lruhash_entry::data, and key_entry_key::entry.

Referenced by key_cache_insert().

◆ key_entry_get_reason()

char* key_entry_get_reason ( struct key_entry_key kkey)

Get reason why a key is bad.

Parameters
kkeybad key
Returns
pointer to string. String is part of key entry and is deleted with it.

References lruhash_entry::data, key_entry_key::entry, and key_entry_data::reason.

◆ key_entry_get_reason_bogus()

sldns_ede_code key_entry_get_reason_bogus ( struct key_entry_key kkey)

Get the EDE (RFC8914) code why a key is bad.

Can return LDNS_EDE_NONE.

Parameters
kkeybad key
Returns
the ede code.

References lruhash_entry::data, key_entry_key::entry, and key_entry_data::reason_bogus.

◆ key_entry_create_null()

struct key_entry_key* key_entry_create_null ( struct regional region,
uint8_t *  name,
size_t  namelen,
uint16_t  dclass,
time_t  ttl,
time_t  now 
)

Create a null entry, in the given region.

Parameters
regionwhere to allocate
namethe key name
namelenlength of name
dclassclass of key entry. (host order);
ttlwhat ttl should the key have. relative.
nowcurrent time (added to ttl).
Returns
new key entry or NULL on alloc failure

References key_entry_data::isbad, key_entry_setup(), key_entry_data::reason, key_entry_data::reason_bogus, and key_entry_data::ttl.

Referenced by val_verify_new_DNSKEYs(), and val_verify_new_DNSKEYs_with_ta().

◆ key_entry_create_rrset()

struct key_entry_key* key_entry_create_rrset ( struct regional region,
uint8_t *  name,
size_t  namelen,
uint16_t  dclass,
struct ub_packed_rrset_key rrset,
uint8_t *  sigalg,
time_t  now 
)

Create a key entry from an rrset, in the given region.

Parameters
regionwhere to allocate.
namethe key name
namelenlength of name
dclassclass of key entry. (host order);
rrsetdata for key entry. This is copied to the region.
sigalgsignalled algorithm list (or NULL).
nowcurrent time (added to ttl of rrset)
Returns
new key entry or NULL on alloc failure

References lruhash_entry::data, ub_packed_rrset_key::entry, key_entry_data::isbad, key_entry_setup(), key_entry_data::reason, key_entry_data::reason_bogus, key_entry_data::ttl, and packed_rrset_data::ttl.

Referenced by val_verify_new_DNSKEYs(), and val_verify_new_DNSKEYs_with_ta().

◆ key_entry_create_bad()

struct key_entry_key* key_entry_create_bad ( struct regional region,
uint8_t *  name,
size_t  namelen,
uint16_t  dclass,
time_t  ttl,
time_t  now 
)

Create a bad entry, in the given region.

Parameters
regionwhere to allocate
namethe key name
namelenlength of name
dclassclass of key entry. (host order);
ttlwhat ttl should the key have. relative.
nowcurrent time (added to ttl).
Returns
new key entry or NULL on alloc failure

References key_entry_data::isbad, key_entry_setup(), key_entry_data::reason, key_entry_data::reason_bogus, and key_entry_data::ttl.

Referenced by val_verify_new_DNSKEYs(), and val_verify_new_DNSKEYs_with_ta().

◆ key_entry_get_rrset()

struct ub_packed_rrset_key* key_entry_get_rrset ( struct key_entry_key kkey,
struct regional region 
)

Obtain rrset from a key entry, allocated in region.

Parameters
kkeykey entry to convert to a rrset.
regionwhere to allocate rrset
Returns
rrset copy; if no rrset or alloc error returns NULL.

References lruhash_entry::data, key_entry_key::entry, key_entry_key::key_class, key_entry_key::name, key_entry_key::namelen, packed_rrset_ptr_fixup(), packed_rrset_sizeof(), regional_alloc(), regional_alloc_init(), key_entry_data::rrset_data, and key_entry_data::rrset_type.

Referenced by process_ds_response().

◆ key_entry_keysize()

size_t key_entry_keysize ( struct key_entry_key kkey)

Get keysize of the keyentry.

Parameters
kkeykey, must be a good key, with contents.
Returns
size in bits of the key.

References packed_rrset_data::count, lruhash_entry::data, DNSKEY_BIT_ZSK, dnskey_get_keysize(), key_entry_key::entry, kd_get_flags(), and key_entry_isgood().

Referenced by nsec3_iteration_count_high().