unbound: validator/val_kentry.h File Reference

unbound 0.1

Data Structures | Functions
val_kentry.h File Reference

This file contains functions for dealing with validator key entries. More...

`#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
struct key_entry_key * | key_entry_copy_toregion (struct key_entry_key *kkey, struct regional *region)
| Copy a key entry, to be region-allocated.
struct key_entry_key * | key_entry_copy (struct key_entry_key *kkey)
| Copy a key entry, malloced.
int | key_entry_isnull (struct key_entry_key *kkey)
| See if this is a null entry.
int | key_entry_isgood (struct key_entry_key *kkey)
| See if this entry is good.
int | key_entry_isbad (struct key_entry_key *kkey)
| See if this entry is bad.
void | key_entry_set_reason (struct key_entry_key *kkey, char *reason)
| Set reason why a key is bad.
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).
char * | key_entry_get_reason (struct key_entry_key *kkey)
| Get reason why a key is bad.
sldns_ede_code | key_entry_get_reason_bogus (struct key_entry_key *kkey)
| Get the EDE (RFC8914) code why a key is bad.
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.
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.
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.
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.
size_t | key_entry_keysize (struct key_entry_key *kkey)
| Get keysize of the keyentry.

## 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

  kk | key entry. The lruhash entry.hash value is filled in.

References dname_query_hash(), key_entry_key::entry, lruhash_entry::hash, 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

  kkey | the key entry key (and data pointer) to copy.
  region | where 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

  kkey | the 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

  kkey | must 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(), process_prime_response(), processFindKey(), processInit(), 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

  kkey | must 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(), primeResponseToKE(), process_dnskey_response(), 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

  kkey | must 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_dnskey_response(), process_ds_response(), process_prime_response(), processFindKey(), processInit(), 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

  kkey | bad key.
  reason | string 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

  kkey | bad key.
  ede | EDE code to attach to this key.

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

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

  kkey | bad 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.

Referenced by processInit().

## ◆ 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

  kkey | bad key

Returns
  the ede code.

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

Referenced by processInit().

## ◆ 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

  region | where to allocate
  name | the key name
  namelen | length of name
  dclass | class of key entry. (host order);
  ttl | what ttl should the key have. relative.
  now | current time (added to ttl).

Returns
  new key entry or NULL on alloc failure

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

Referenced by ds_response_to_ke(), primeResponseToKE(), 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

  region | where to allocate.
  name | the key name
  namelen | length of name
  dclass | class of key entry. (host order);
  rrset | data for key entry. This is copied to the region.
  sigalg | signalled algorithm list (or NULL).
  now | current time (added to ttl of rrset)

Returns
  new key entry or NULL on alloc failure

References key_entry_data::algo, lruhash_entry::data, ub_packed_rrset_key::entry, key_entry_data::isbad, key_entry_setup(), packed_rrset_ptr_fixup(), packed_rrset_sizeof(), key_entry_data::reason, key_entry_data::reason_bogus, regional_alloc_init(), regional_strdup(), ub_packed_rrset_key::rk, key_entry_data::rrset_data, key_entry_data::rrset_type, packed_rrset_data::ttl, key_entry_data::ttl, and packed_rrset_key::type.

Referenced by ds_response_to_ke(), 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

  region | where to allocate
  name | the key name
  namelen | length of name
  dclass | class of key entry. (host order);
  ttl | what ttl should the key have. relative.
  now | current time (added to ttl).

Returns
  new key entry or NULL on alloc failure

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

Referenced by ds_response_to_ke(), primeResponseToKE(), process_dnskey_response(), 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

  kkey | key entry to convert to a rrset.
  region | where 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

  kkey | key, must be a good key, with contents.

Returns
  size in bits of the key.

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

Referenced by nsec3_iteration_count_high().