OpenDNSSEC-signer  1.4.6
Data Structures | Macros | Typedefs | Enumerations | Functions
tsig.h File Reference
#include "config.h"
#include "shared/allocator.h"
#include "shared/status.h"
#include "wire/buffer.h"
#include <ldns/ldns.h>
Include dependency graph for tsig.h:
This graph shows which files directly or indirectly include this file:

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 (allocator_type *allocator)
 
void tsig_handler_cleanup (void)
 
void tsig_handler_add_key (tsig_key_type *key)
 
void tsig_handler_add_algo (tsig_algo_type *algo)
 
tsig_typetsig_create (allocator_type *allocator, char *name, char *algo, char *secret)
 
tsig_typetsig_lookup_by_name (tsig_type *tsig, const char *name)
 
tsig_algo_typetsig_lookup_algo (const char *name)
 
tsig_rr_typetsig_rr_create (allocator_type *allocator)
 
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, allocator_type *allocator)
 

Macro Definition Documentation

#define TSIG_ERROR_BADKEY   17

Definition at line 45 of file tsig.h.

Referenced by tsig_rr_lookup(), and tsig_strerror().

#define TSIG_ERROR_BADSIG   16

TSIG.

Definition at line 44 of file tsig.h.

Referenced by tsig_rr_verify(), and tsig_strerror().

#define TSIG_ERROR_BADTIME   18

Definition at line 46 of file tsig.h.

Referenced by tsig_rr_lookup(), and tsig_strerror().

#define TSIG_HMAC_MD5   157

Definition at line 48 of file tsig.h.

#define TSIG_HMAC_SHA1   158

Definition at line 49 of file tsig.h.

#define TSIG_HMAC_SHA256   159

Definition at line 50 of file tsig.h.

Typedef Documentation

TSIG algorithm.

Definition at line 89 of file tsig.h.

TSIG key.

Definition at line 78 of file tsig.h.

TSIG lookup table.

Definition at line 67 of file tsig.h.

typedef struct tsig_rr_struct tsig_rr_type

TSIG RR.

Definition at line 123 of file tsig.h.

Definition at line 61 of file tsig.h.

typedef struct tsig_struct tsig_type

TSIG configuration.

Definition at line 110 of file tsig.h.

Enumeration Type Documentation

TSIG status.

Enumerator
TSIG_NOT_PRESENT 
TSIG_OK 
TSIG_ERROR 

Definition at line 56 of file tsig.h.

Function Documentation

void tsig_cleanup ( tsig_type tsig,
allocator_type allocator 
)

Clean up TSIG.

Parameters
[in]tsigTSIG
[in]allocatormemory allocator

Clean up TSIG.

Definition at line 901 of file tsig.c.

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

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

tsig_type* tsig_create ( allocator_type allocator,
char *  name,
char *  algo,
char *  secret 
)

Create new TSIG.

Parameters
[in]allocatormemory allocator
[in]nametsig name
[in]algotsig algorithm
[in]secrettsig secret
Returns
tsig_type* TSIG

Create new TSIG.

Definition at line 234 of file tsig.c.

References tsig_struct::algorithm, allocator_alloc(), allocator_strdup(), tsig_struct::key, tsig_struct::name, tsig_struct::next, ods_log_error(), tsig_struct::secret, tsig_cleanup(), and tsig_key_create().

void tsig_handler_add_algo ( tsig_algo_type algo)

Add algorithm to TSIG handler.

Parameters
[in]algotsig algorithm

Add algorithm to TSIG handler.

Definition at line 108 of file tsig.c.

References tsig_algo_table_struct::algorithm, allocator_alloc(), tsig_algo_struct::max_digest_size, and tsig_algo_table_struct::next.

void tsig_handler_add_key ( tsig_key_type key)

Add key to TSIG handler.

Parameters
[in]keytsig key

Add key to TSIG handler.

Definition at line 86 of file tsig.c.

References allocator_alloc(), tsig_key_table_struct::key, and tsig_key_table_struct::next.

Referenced by tsig_key_create().

void tsig_handler_cleanup ( void  )
ods_status tsig_handler_init ( allocator_type allocator)

Initialize TSIG handler.

Parameters
[in]allocatormemory allocator
Returns
ods_status status

Initialize TSIG handler.

Definition at line 133 of file tsig.c.

References ods_log_debug(), ODS_STATUS_ERR, and ODS_STATUS_OK.

tsig_algo_type* tsig_lookup_algo ( const char *  name)

Lookup TSIG algorithm by name.

Parameters
[in]namealgorithm name
Returns
tsig_algo_type* TSIG algorithm

Lookup TSIG algorithm by name.

Definition at line 288 of file tsig.c.

References tsig_algo_table_struct::algorithm, tsig_algo_table_struct::next, ods_strlowercmp(), and tsig_algo_struct::txt_name.

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

Lookup TSIG by key name.

Parameters
[in]tsigTSIG list
[in]naemTSIG name
Returns
tsig_type* TSIG

Lookup TSIG by key name.

Definition at line 266 of file tsig.c.

References tsig_struct::name, tsig_struct::next, and ods_strlowercmp().

Referenced by acl_create().

void tsig_rr_append ( tsig_rr_type trr,
buffer_type buffer 
)
void tsig_rr_cleanup ( tsig_rr_type trr)

Cleanup TSIG RR

Parameters
[in]trrTSIG RR

Cleanup TSIG RR.

Definition at line 883 of file tsig.c.

References tsig_rr_struct::allocator, allocator_deallocate(), and tsig_rr_free().

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

tsig_rr_type* tsig_rr_create ( allocator_type allocator)

Create new TSIG RR.

Parameters
[in]allocatormemory allocator
Returns
tsig_rr_type* TSIG RR

Create new TSIG RR.

Definition at line 305 of file tsig.c.

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

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

void tsig_rr_error ( tsig_rr_type trr)

Reply with error TSIG RR.

Parameters
[in]trrTSIG RR

Reply with error TSIG RR.

Definition at line 791 of file tsig.c.

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

Referenced by query_add_optional().

int tsig_rr_find ( tsig_rr_type trr,
buffer_type buffer 
)

Find TSIG RR.

Parameters
[in]trrTSIG RR
[in]bufferpacket buffer
Returns
int 1 if not present or present and valid, 0 otherwise.

Find TSIG RR.

Definition at line 477 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(), ods_log_assert, tsig_rr_struct::status, TSIG_NOT_PRESENT, and tsig_rr_parse().

void tsig_rr_free ( tsig_rr_type trr)

Free TSIG RR.

Parameters
[in]trrTSIG RR

Free TSIG RR.

Definition at line 861 of file tsig.c.

References tsig_rr_struct::algo_name, tsig_rr_struct::allocator, allocator_deallocate(), 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().

int tsig_rr_lookup ( tsig_rr_type trr)
int tsig_rr_parse ( tsig_rr_type trr,
buffer_type buffer 
)
void tsig_rr_prepare ( tsig_rr_type trr)
size_t tsig_rr_reserved_space ( tsig_rr_type trr)
void tsig_rr_reset ( tsig_rr_type trr,
tsig_algo_type algo,
tsig_key_type key 
)
void tsig_rr_sign ( tsig_rr_type trr)
void tsig_rr_update ( tsig_rr_type trr,
buffer_type buffer,
size_t  length 
)

Update TSIG RR.

Parameters
[in]trrTSIG RR
[in]bufferpacket buffer
[in]lengthnumber 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 604 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, ods_log_assert, tsig_rr_struct::original_query_id, tsig_rr_struct::response_count, and tsig_rr_struct::update_since_last_prepare.

Referenced by query_add_optional().

int tsig_rr_verify ( tsig_rr_type trr)
const char* tsig_status2str ( tsig_status  status)

Get human readable TSIG error code.

Parameters
[in]statusTSIG status
Returns
const char* TSIG status

Print TSIG status.

Definition at line 809 of file tsig.c.

References TSIG_ERROR, TSIG_NOT_PRESENT, and TSIG_OK.

Referenced by query_process().

const char* tsig_strerror ( uint16_t  error)

Get human readable TSIG error code.

Parameters
[in]errorTSIG error code
Returns
const char* readable error code

Get human readable TSIG error code.

Definition at line 828 of file tsig.c.

References TSIG_ERROR_BADKEY, TSIG_ERROR_BADSIG, and TSIG_ERROR_BADTIME.