OpenDNSSEC-signer
1.4.1
Main Page
Data Structures
Files
File List
Globals
signer
src
wire
tsig.h
Go to the documentation of this file.
1
/*
2
* $Id: tsig.h 4958 2011-04-18 07:11:09Z matthijs $
3
*
4
* Copyright (c) 2011 NLNet Labs. All rights reserved.
5
*
6
* Taken from NSD3 and adjusted for OpenDNSSEC, NLnet Labs.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
10
* are met:
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
*
29
*/
30
36
#ifndef WIRE_TSIG_H
37
#define WIRE_TSIG_H
38
39
#include "config.h"
40
#include "
shared/allocator.h
"
41
#include "
shared/status.h
"
42
#include "
wire/buffer.h
"
43
44
#include <ldns/ldns.h>
45
46
#define TSIG_ERROR_BADSIG 16
47
#define TSIG_ERROR_BADKEY 17
48
#define TSIG_ERROR_BADTIME 18
49
50
#define TSIG_HMAC_MD5 157
51
#define TSIG_HMAC_SHA1 158
52
#define TSIG_HMAC_SHA256 159
53
58
enum
tsig_status_enum
{
59
TSIG_NOT_PRESENT
,
60
TSIG_OK
,
61
TSIG_ERROR
62
};
63
typedef
enum
tsig_status_enum
tsig_status
;
64
69
typedef
struct
tsig_lookup_table_struct
tsig_lookup_table
;
70
struct
tsig_lookup_table_struct
71
{
72
uint8_t
id
;
73
const
char
*
short_name
;
74
};
75
80
typedef
struct
tsig_key_struct
tsig_key_type
;
81
struct
tsig_key_struct
{
82
ldns_rdf*
dname
;
83
size_t
size
;
84
const
uint8_t*
data
;
85
};
86
91
typedef
struct
tsig_algo_struct
tsig_algo_type
;
92
struct
tsig_algo_struct
{
93
const
char
*
txt_name
;
94
ldns_rdf*
wf_name
;
95
size_t
max_digest_size
;
96
const
void
*
data
;
97
/* create a new HMAC context */
98
void
*(*hmac_create)(
allocator_type
* allocator);
99
/* initialize an HMAC context */
100
void(*
hmac_init
)(
void
* context,
tsig_algo_type
* algo,
101
tsig_key_type
* key);
102
/* update the HMAC context */
103
void(*
hmac_update
)(
void
* context,
const
void
*
data
,
size_t
size);
104
/* finalize digest */
105
void(*
hmac_final
)(
void
* context, uint8_t* digest,
size_t
* size);
106
};
107
112
typedef
struct
tsig_struct
tsig_type
;
113
struct
tsig_struct
{
114
tsig_type
*
next
;
115
const
char
*
name
;
116
const
char
*
algorithm
;
117
const
char
*
secret
;
118
tsig_key_type
*
key
;
119
};
120
125
typedef
struct
tsig_rr_struct
tsig_rr_type
;
126
struct
tsig_rr_struct
{
127
allocator_type
*
allocator
;
128
tsig_status
status
;
129
size_t
position
;
130
size_t
response_count
;
131
size_t
update_since_last_prepare
;
132
void
*
context
;
133
tsig_algo_type
*
algo
;
134
tsig_key_type
*
key
;
135
size_t
prior_mac_size
;
136
uint8_t*
prior_mac_data
;
137
138
ldns_rdf*
key_name
;
139
ldns_rdf*
algo_name
;
140
uint16_t
signed_time_high
;
141
uint32_t
signed_time_low
;
142
uint16_t
signed_time_fudge
;
143
uint16_t
mac_size
;
144
uint8_t*
mac_data
;
145
uint16_t
original_query_id
;
146
uint16_t
error_code
;
147
uint16_t
other_size
;
148
uint8_t*
other_data
;
149
};
150
157
ods_status
tsig_handler_init
(
allocator_type
* allocator);
158
163
void
tsig_handler_cleanup
(
void
);
164
170
void
tsig_handler_add_key
(
tsig_key_type
* key);
171
177
void
tsig_handler_add_algo
(
tsig_algo_type
* algo);
178
188
tsig_type
*
tsig_create
(
allocator_type
* allocator,
char
* name,
char
* algo,
189
char
* secret);
190
198
tsig_type
*
tsig_lookup_by_name
(
tsig_type
* tsig,
const
char
* name);
199
206
tsig_algo_type
*
tsig_lookup_algo
(
const
char
* name);
207
214
tsig_rr_type
*
tsig_rr_create
(
allocator_type
* allocator);
215
223
void
tsig_rr_reset
(
tsig_rr_type
* trr,
tsig_algo_type
* algo,
tsig_key_type
* key);
224
232
int
tsig_rr_find
(
tsig_rr_type
* trr,
buffer_type
* buffer);
233
241
int
tsig_rr_parse
(
tsig_rr_type
* trr,
buffer_type
* buffer);
242
249
int
tsig_rr_lookup
(
tsig_rr_type
* trr);
250
256
void
tsig_rr_prepare
(
tsig_rr_type
* trr);
257
267
void
tsig_rr_update
(
tsig_rr_type
* trr,
buffer_type
* buffer,
size_t
length);
268
274
void
tsig_rr_sign
(
tsig_rr_type
* trr);
275
282
int
tsig_rr_verify
(
tsig_rr_type
* trr);
283
290
void
tsig_rr_append
(
tsig_rr_type
* trr,
buffer_type
* buffer);
291
292
/*
293
* The amount of space to reserve in the response for the TSIG data.
294
* \param[in] trr TSIG RR
295
* \return size_t reserved space size
296
*
297
*/
298
size_t
tsig_rr_reserved_space
(
tsig_rr_type
*trr);
299
305
void
tsig_rr_error
(
tsig_rr_type
* trr);
306
313
const
char
*
tsig_status2str
(
tsig_status
status);
314
321
const
char
*
tsig_strerror
(uint16_t error);
322
328
void
tsig_rr_free
(
tsig_rr_type
* trr);
329
335
void
tsig_rr_cleanup
(
tsig_rr_type
* trr);
336
343
void
tsig_cleanup
(
tsig_type
* tsig,
allocator_type
* allocator);
344
345
#endif
/* WIRE_TSIG_H */
Generated on Wed Jul 17 2013 07:14:23 for OpenDNSSEC-signer by
1.8.4