tsig.h File Reference
`#include "config.h"`
`#include "status.h"`
`#include "wire/buffer.h"`
`#include <ldns/ldns.h>`

Go to the source code of this file.

## Data Structures

struct | tsig_lookup_table_struct
struct | tsig_key_struct
struct | tsig_algo_struct
struct | tsig_struct
struct | tsig_rr_struct

## Macros

#define | TSIG_ERROR_BADSIG 16
#define | TSIG_ERROR_BADKEY 17
#define | TSIG_ERROR_BADTIME 18
#define | TSIG_HMAC_MD5 157
#define | TSIG_HMAC_SHA1 158
#define | TSIG_HMAC_SHA256 159

## Typedefs

typedef enum tsig_status_enum | tsig_status
typedef struct tsig_lookup_table_struct | tsig_lookup_table
typedef struct tsig_key_struct | tsig_key_type
typedef struct tsig_algo_struct | tsig_algo_type
typedef struct tsig_struct | tsig_type
typedef struct tsig_rr_struct | tsig_rr_type

## Enumerations

enum | tsig_status_enum { TSIG_NOT_PRESENT , TSIG_OK , TSIG_ERROR }

## Functions

ods_status | tsig_handler_init (void)
void | tsig_handler_cleanup (void)
void | tsig_handler_add_key (tsig_key_type *key)
void | tsig_handler_add_algo (tsig_algo_type *algo)
tsig_type * | tsig_create (char *name, char *algo, char *secret)
tsig_type * | tsig_lookup_by_name (tsig_type *tsig, const char *name)
tsig_algo_type * | tsig_lookup_algo (const char *name)
tsig_rr_type * | tsig_rr_create (void)
void | tsig_rr_reset (tsig_rr_type *trr, tsig_algo_type *algo, tsig_key_type *key)
int | tsig_rr_find (tsig_rr_type *trr, buffer_type *buffer)
int | tsig_rr_parse (tsig_rr_type *trr, buffer_type *buffer)
int | tsig_rr_lookup (tsig_rr_type *trr)
void | tsig_rr_prepare (tsig_rr_type *trr)
void | tsig_rr_update (tsig_rr_type *trr, buffer_type *buffer, size_t length)
void | tsig_rr_sign (tsig_rr_type *trr)
int | tsig_rr_verify (tsig_rr_type *trr)
void | tsig_rr_append (tsig_rr_type *trr, buffer_type *buffer)
size_t | tsig_rr_reserved_space (tsig_rr_type *trr)
void | tsig_rr_error (tsig_rr_type *trr)
const char * | tsig_status2str (tsig_status status)
const char * | tsig_strerror (uint16_t error)
void | tsig_rr_free (tsig_rr_type *trr)
void | tsig_rr_cleanup (tsig_rr_type *trr)
void | tsig_cleanup (tsig_type *tsig)

## Macro Definition Documentation

## TSIG_ERROR_BADKEY

#define TSIG_ERROR_BADKEY 17

Definition at line 44 of file tsig.h.

## TSIG_ERROR_BADSIG

#define TSIG_ERROR_BADSIG 16

TSIG.

Definition at line 43 of file tsig.h.

## TSIG_ERROR_BADTIME

#define TSIG_ERROR_BADTIME 18

Definition at line 45 of file tsig.h.

## TSIG_HMAC_MD5

#define TSIG_HMAC_MD5 157

Definition at line 47 of file tsig.h.

## TSIG_HMAC_SHA1

#define TSIG_HMAC_SHA1 158

Definition at line 48 of file tsig.h.

## TSIG_HMAC_SHA256

#define TSIG_HMAC_SHA256 159

Definition at line 49 of file tsig.h.

## Typedef Documentation

## tsig_algo_type

typedef struct tsig_algo_struct tsig_algo_type

TSIG algorithm.

Definition at line 88 of file tsig.h.

## tsig_key_type

typedef struct tsig_key_struct tsig_key_type

TSIG key.

Definition at line 77 of file tsig.h.

## tsig_lookup_table

typedef struct tsig_lookup_table_struct tsig_lookup_table

TSIG lookup table.

Definition at line 66 of file tsig.h.

## tsig_rr_type

typedef struct tsig_rr_struct tsig_rr_type

TSIG RR.

Definition at line 122 of file tsig.h.

## tsig_status

typedef enum tsig_status_enum tsig_status

Definition at line 60 of file tsig.h.

## tsig_type

typedef struct tsig_struct tsig_type

TSIG configuration.

Definition at line 109 of file tsig.h.

## Enumeration Type Documentation

## tsig_status_enum

enum tsig_status_enum

TSIG status.

Enumerator
TSIG_NOT_PRESENT |
TSIG_OK |
TSIG_ERROR |

Definition at line 55 of file tsig.h.

## Function Documentation

## tsig_cleanup()

void tsig_cleanup | ( | tsig_type * | tsig | ) |

extern

Clean up TSIG.

Parameters

  [in] | tsig | TSIG
  [in] | allocator | memory allocator

Clean up TSIG.

Definition at line 847 of file tsig.c.

References tsig_struct::algorithm, tsig_struct::name, tsig_struct::next, tsig_struct::secret, and tsig_cleanup().

Referenced by dnsin_cleanup(), dnsout_cleanup(), tsig_cleanup(), and tsig_create().

## tsig_create()

tsig_type * tsig_create | ( | char * | name,
|  | char * | algo,
|  | char * | secret
| ) |  |

extern

Create new TSIG.

Parameters

  [in] | allocator | memory allocator
  [in] | name | tsig name
  [in] | algo | tsig algorithm
  [in] | secret | tsig secret

Returns
  tsig_type* TSIG

Create new TSIG.

Definition at line 208 of file tsig.c.

References tsig_struct::algorithm, tsig_struct::key, tsig_struct::name, tsig_struct::next, tsig_struct::secret, and tsig_cleanup().

## tsig_handler_add_algo()

void tsig_handler_add_algo | ( | tsig_algo_type * | algo | ) |

extern

Add algorithm to TSIG handler.

Parameters

  [in] | algo | tsig algorithm

Add algorithm to TSIG handler.

Definition at line 93 of file tsig.c.

References tsig_algo_table_struct::algorithm, tsig_algo_struct::max_digest_size, and tsig_algo_table_struct::next.

## tsig_handler_add_key()

void tsig_handler_add_key | ( | tsig_key_type * | key | ) |

extern

Add key to TSIG handler.

Parameters

  [in] | key | tsig key

Add key to TSIG handler.

Definition at line 73 of file tsig.c.

References tsig_key_table_struct::key, and tsig_key_table_struct::next.

## tsig_handler_cleanup()

void tsig_handler_cleanup | ( | void |  | ) |

extern

Clean up TSIG handler.

Definition at line 135 of file tsig.c.

References tsig_algo_table_struct::algorithm, tsig_key_struct::data, tsig_key_struct::dname, tsig_key_table_struct::key, tsig_key_table_struct::next, tsig_algo_table_struct::next, and tsig_algo_struct::wf_name.

Referenced by engine_start().

## tsig_handler_init()

ods_status tsig_handler_init | ( | void |  | ) |

extern

Initialize TSIG handler.

Parameters

  [in] | allocator | memory allocator

Returns
  ods_status status

Initialize TSIG handler.

Definition at line 116 of file tsig.c.

## tsig_lookup_algo()

tsig_algo_type * tsig_lookup_algo | ( | const char * | name | ) |

extern

Lookup TSIG algorithm by name.

Parameters

  [in] | name | algorithm name

Returns
  tsig_algo_type* TSIG algorithm

Lookup TSIG algorithm by name.

Definition at line 257 of file tsig.c.

References tsig_algo_table_struct::algorithm, tsig_algo_table_struct::next, and tsig_algo_struct::txt_name.

## tsig_lookup_by_name()

tsig_type * tsig_lookup_by_name | ( | tsig_type * | tsig,
|  | const char * | name
| ) |  |

extern

Lookup TSIG by key name.

Parameters

  [in] | tsig | TSIG list
  [in] | naem | TSIG name

Returns
  tsig_type* TSIG

Lookup TSIG by key name.

Definition at line 235 of file tsig.c.

References tsig_struct::name, and tsig_struct::next.

Referenced by acl_create().

## tsig_rr_append()

void tsig_rr_append | ( | tsig_rr_type * | trr,
|  | buffer_type * | buffer
| ) |  |

extern

Append TSIG RR.

Parameters

  [in] | trr | TSIG RR
  [in] | buffer | packet buffer

Append TSIG RR.

Definition at line 672 of file tsig.c.

References tsig_rr_struct::algo_name, buffer_position(), buffer_skip(), buffer_write(), buffer_write_rdf(), buffer_write_u16(), buffer_write_u16_at(), buffer_write_u32(), buffer_write_u8(), tsig_rr_struct::error_code, tsig_rr_struct::key_name, tsig_rr_struct::mac_data, tsig_rr_struct::mac_size, tsig_rr_struct::original_query_id, tsig_rr_struct::other_data, tsig_rr_struct::other_size, tsig_rr_struct::signed_time_fudge, tsig_rr_struct::signed_time_high, and tsig_rr_struct::signed_time_low.

Referenced by query_add_optional().

## tsig_rr_cleanup()

void tsig_rr_cleanup | ( | tsig_rr_type * | trr | ) |

extern

Cleanup TSIG RR

Parameters

  [in] | trr | TSIG RR

Cleanup TSIG RR.

Definition at line 832 of file tsig.c.

References tsig_rr_free().

Referenced by notify_cleanup(), query_cleanup(), and xfrd_cleanup().

## tsig_rr_create()

tsig_rr_type * tsig_rr_create | ( | void |  | ) |

extern

Create new TSIG RR.

Parameters

  [in] | allocator | memory allocator

Returns
  tsig_rr_type* TSIG RR

Create new TSIG RR.

Definition at line 274 of file tsig.c.

References tsig_rr_struct::algo_name, tsig_rr_struct::key_name, tsig_rr_struct::mac_data, tsig_rr_struct::other_data, and tsig_rr_reset().

Referenced by notify_create(), query_create(), and xfrd_create().

## tsig_rr_error()

void tsig_rr_error | ( | tsig_rr_type * | trr | ) |

extern

Reply with error TSIG RR.

Parameters

  [in] | trr | TSIG RR

Reply with error TSIG RR.

Definition at line 742 of file tsig.c.

References tsig_rr_struct::mac_data, and tsig_rr_struct::mac_size.

Referenced by query_add_optional().

## tsig_rr_find()

int tsig_rr_find | ( | tsig_rr_type * | trr,
|  | buffer_type * | buffer
| ) |  |

extern

Find TSIG RR.

Parameters

  [in] | trr | TSIG RR
  [in] | buffer | packet buffer

Returns
  int 1 if not present or present and valid, 0 otherwise.

Find TSIG RR.

Definition at line 435 of file tsig.c.

References buffer_pkt_ancount(), buffer_pkt_arcount(), BUFFER_PKT_HEADER_SIZE, buffer_pkt_nscount(), buffer_pkt_qdcount(), buffer_position(), buffer_set_position(), buffer_skip_rr(), tsig_rr_struct::status, TSIG_NOT_PRESENT, and tsig_rr_parse().

## tsig_rr_free()

void tsig_rr_free | ( | tsig_rr_type * | trr | ) |

extern

Free TSIG RR.

Parameters

  [in] | trr | TSIG RR

Free TSIG RR.

Definition at line 811 of file tsig.c.

References tsig_rr_struct::algo_name, tsig_rr_struct::key_name, tsig_rr_struct::mac_data, and tsig_rr_struct::other_data.

Referenced by tsig_rr_cleanup(), and tsig_rr_reset().

## tsig_rr_lookup()

int tsig_rr_lookup | ( | tsig_rr_type * | trr | ) |

extern

Lookup TSIG RR.

Parameters

  [in] | trr | TSIG RR

Returns
  int 1 if succeeded, 0 if unknown

Lookup TSIG RR.

Definition at line 469 of file tsig.c.

References tsig_rr_struct::algo, tsig_rr_struct::algo_name, tsig_algo_table_struct::algorithm, tsig_key_struct::dname, tsig_rr_struct::error_code, tsig_key_table_struct::key, tsig_rr_struct::key, tsig_rr_struct::key_name, tsig_key_table_struct::next, tsig_algo_table_struct::next, tsig_rr_struct::other_data, tsig_rr_struct::other_size, tsig_rr_struct::prior_mac_size, tsig_rr_struct::response_count, tsig_rr_struct::signed_time_fudge, tsig_rr_struct::signed_time_high, tsig_rr_struct::signed_time_low, tsig_rr_struct::status, TSIG_ERROR_BADKEY, TSIG_ERROR_BADTIME, TSIG_OK, and tsig_algo_struct::wf_name.

## tsig_rr_parse()

int tsig_rr_parse | ( | tsig_rr_type * | trr,
|  | buffer_type * | buffer
| ) |  |

extern

Parse TSIG RR.

Parameters

  [in] | trr | TSIG RR
  [in] | buffer | packet buffer

Returns
  int 1 if not TSIG RR or TSIG RR and valid, 0 otherwise.

Parse TSIG RR.

Definition at line 322 of file tsig.c.

References tsig_rr_struct::algo_name, buffer_available(), buffer_current(), buffer_position(), buffer_read_u16(), buffer_read_u32(), buffer_set_position(), buffer_skip(), buffer_skip_dname(), tsig_rr_struct::error_code, tsig_rr_struct::key_name, tsig_rr_struct::mac_data, tsig_rr_struct::mac_size, tsig_rr_struct::original_query_id, tsig_rr_struct::other_data, tsig_rr_struct::other_size, tsig_rr_struct::position, tsig_rr_struct::signed_time_fudge, tsig_rr_struct::signed_time_high, tsig_rr_struct::signed_time_low, tsig_rr_struct::status, TSIG_ERROR, TSIG_NOT_PRESENT, and TSIG_OK.

Referenced by tsig_rr_find().

## tsig_rr_prepare()

void tsig_rr_prepare | ( | tsig_rr_type * | trr | ) |

extern

Prepare TSIG RR.

Parameters

  [in] | trr | TSIG RR

Prepare TSIG RR.

Definition at line 537 of file tsig.c.

References tsig_rr_struct::algo, tsig_rr_struct::context, tsig_algo_struct::hmac_create, tsig_algo_struct::hmac_init, tsig_algo_struct::hmac_update, tsig_rr_struct::key, tsig_algo_struct::max_digest_size, tsig_rr_struct::prior_mac_data, tsig_rr_struct::prior_mac_size, and tsig_rr_struct::update_since_last_prepare.

Referenced by query_add_optional().

## tsig_rr_reserved_space()

size_t tsig_rr_reserved_space | ( | tsig_rr_type * | trr | ) |

extern

Definition at line 713 of file tsig.c.

References tsig_rr_struct::algo_name, tsig_rr_struct::key_name, tsig_rr_struct::other_size, tsig_rr_struct::status, and TSIG_NOT_PRESENT.

Referenced by query_prepare().

## tsig_rr_reset()

void tsig_rr_reset | ( | tsig_rr_type * | trr,
|  | tsig_algo_type * | algo,
|  | tsig_key_type * | key
| ) |  |

extern

Reset TSIG RR.

Parameters

  [in] | trr | TSIG RR
  [in] | algo | tsig algorithm
  [in] | key | tsig key

Reset TSIG RR.

Definition at line 292 of file tsig.c.

References tsig_rr_struct::algo, tsig_rr_struct::context, tsig_rr_struct::error_code, tsig_rr_struct::key, tsig_rr_struct::mac_size, tsig_rr_struct::original_query_id, tsig_rr_struct::other_size, tsig_rr_struct::position, tsig_rr_struct::prior_mac_data, tsig_rr_struct::prior_mac_size, tsig_rr_struct::response_count, tsig_rr_struct::signed_time_fudge, tsig_rr_struct::signed_time_high, tsig_rr_struct::signed_time_low, tsig_rr_struct::status, TSIG_NOT_PRESENT, tsig_rr_free(), and tsig_rr_struct::update_since_last_prepare.

Referenced by query_reset(), and tsig_rr_create().

## tsig_rr_sign()

void tsig_rr_sign | ( | tsig_rr_type * | trr | ) |

extern

Sign TSIG RR.

Parameters

  [in] | trr | TSIG RR

Sign TSIG RR.

Definition at line 629 of file tsig.c.

References tsig_rr_struct::algo, tsig_rr_struct::context, tsig_algo_struct::hmac_final, tsig_rr_struct::mac_data, tsig_rr_struct::mac_size, tsig_rr_struct::prior_mac_data, tsig_rr_struct::prior_mac_size, tsig_rr_struct::response_count, tsig_rr_struct::signed_time_fudge, tsig_rr_struct::signed_time_high, tsig_rr_struct::signed_time_low, and TSIG_SIGNED_TIME_FUDGE.

Referenced by query_add_optional().

## tsig_rr_update()

void tsig_rr_update | ( | tsig_rr_type * | trr,
|  | buffer_type * | buffer,
|  | size_t | length
| ) |  |

extern

Update TSIG RR.

Parameters

  [in] | trr | TSIG RR
  [in] | buffer | packet buffer
  [in] | length | number of octets of buffer to add to the TSIG hash, replacing the buffer's id with the original query idfrom TSIG.

Update TSIG RR.

Definition at line 559 of file tsig.c.

References tsig_rr_struct::algo, buffer_at(), buffer_limit(), buffer_pkt_qr(), tsig_rr_struct::context, tsig_algo_struct::hmac_update, tsig_rr_struct::original_query_id, tsig_rr_struct::response_count, and tsig_rr_struct::update_since_last_prepare.

Referenced by query_add_optional().

## tsig_rr_verify()

int tsig_rr_verify | ( | tsig_rr_type * | trr | ) |

extern

Verify TSIG RR.

Parameters

  [in] | trr | TSIG RR

Returns
  int 1 if verified, 0 on error

Verify TSIG RR.

Definition at line 650 of file tsig.c.

References tsig_rr_struct::algo, tsig_rr_struct::context, tsig_rr_struct::error_code, tsig_algo_struct::hmac_final, tsig_rr_struct::mac_data, tsig_rr_struct::mac_size, tsig_rr_struct::prior_mac_data, tsig_rr_struct::prior_mac_size, tsig_rr_struct::response_count, and TSIG_ERROR_BADSIG.

## tsig_status2str()

const char * tsig_status2str | ( | tsig_status | status | ) |

extern

Get human readable TSIG error code.

Parameters

  [in] | status | TSIG status

Returns
  const char* TSIG status

Print TSIG status.

Definition at line 759 of file tsig.c.

References TSIG_ERROR, TSIG_NOT_PRESENT, and TSIG_OK.

Referenced by query_process().

## tsig_strerror()

const char * tsig_strerror | ( | uint16_t | error | ) |

extern

Get human readable TSIG error code.

Parameters

  [in] | error | TSIG error code

Returns
  const char* readable error code

Get human readable TSIG error code.

Definition at line 778 of file tsig.c.

References TSIG_ERROR_BADKEY, TSIG_ERROR_BADSIG, and TSIG_ERROR_BADTIME.