Deleted Added
full compact
val_kentry.c (256281) val_kentry.c (269257)
1/*
2 * validator/val_kentry.c - validator key entry definition.
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 7 unchanged lines hidden (view full) ---

16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1/*
2 * validator/val_kentry.c - validator key entry definition.
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 7 unchanged lines hidden (view full) ---

16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/**
37 * \file
38 *
39 * This file contains functions for dealing with validator key entries.
40 */
41#include "config.h"
34 */
35
36/**
37 * \file
38 *
39 * This file contains functions for dealing with validator key entries.
40 */
41#include "config.h"
42#include <ldns/ldns.h>
43#include "validator/val_kentry.h"
44#include "util/data/packed_rrset.h"
45#include "util/data/dname.h"
46#include "util/storage/lookup3.h"
47#include "util/regional.h"
48#include "util/net_help.h"
42#include "validator/val_kentry.h"
43#include "util/data/packed_rrset.h"
44#include "util/data/dname.h"
45#include "util/storage/lookup3.h"
46#include "util/regional.h"
47#include "util/net_help.h"
48#include "ldns/rrdef.h"
49#include "ldns/keyraw.h"
49
50size_t
51key_entry_sizefunc(void* key, void* data)
52{
53 struct key_entry_key* kk = (struct key_entry_key*)key;
54 struct key_entry_data* kd = (struct key_entry_data*)data;
55 size_t s = sizeof(*kk) + kk->namelen;
56 s += sizeof(*kd) + lock_get_mem(&kk->entry.lock);

--- 213 unchanged lines hidden (view full) ---

270 if(!*d)
271 return 0;
272 (*k)->entry.data = *d;
273 return 1;
274}
275
276struct key_entry_key*
277key_entry_create_null(struct regional* region,
50
51size_t
52key_entry_sizefunc(void* key, void* data)
53{
54 struct key_entry_key* kk = (struct key_entry_key*)key;
55 struct key_entry_data* kd = (struct key_entry_data*)data;
56 size_t s = sizeof(*kk) + kk->namelen;
57 s += sizeof(*kd) + lock_get_mem(&kk->entry.lock);

--- 213 unchanged lines hidden (view full) ---

271 if(!*d)
272 return 0;
273 (*k)->entry.data = *d;
274 return 1;
275}
276
277struct key_entry_key*
278key_entry_create_null(struct regional* region,
278 uint8_t* name, size_t namelen, uint16_t dclass, uint32_t ttl,
279 uint32_t now)
279 uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl,
280 time_t now)
280{
281 struct key_entry_key* k;
282 struct key_entry_data* d;
283 if(!key_entry_setup(region, name, namelen, dclass, &k, &d))
284 return NULL;
285 d->ttl = now + ttl;
286 d->isbad = 0;
287 d->reason = NULL;
288 d->rrset_type = LDNS_RR_TYPE_DNSKEY;
289 d->rrset_data = NULL;
290 d->algo = NULL;
291 return k;
292}
293
294struct key_entry_key*
295key_entry_create_rrset(struct regional* region,
296 uint8_t* name, size_t namelen, uint16_t dclass,
281{
282 struct key_entry_key* k;
283 struct key_entry_data* d;
284 if(!key_entry_setup(region, name, namelen, dclass, &k, &d))
285 return NULL;
286 d->ttl = now + ttl;
287 d->isbad = 0;
288 d->reason = NULL;
289 d->rrset_type = LDNS_RR_TYPE_DNSKEY;
290 d->rrset_data = NULL;
291 d->algo = NULL;
292 return k;
293}
294
295struct key_entry_key*
296key_entry_create_rrset(struct regional* region,
297 uint8_t* name, size_t namelen, uint16_t dclass,
297 struct ub_packed_rrset_key* rrset, uint8_t* sigalg, uint32_t now)
298 struct ub_packed_rrset_key* rrset, uint8_t* sigalg, time_t now)
298{
299 struct key_entry_key* k;
300 struct key_entry_data* d;
301 struct packed_rrset_data* rd = (struct packed_rrset_data*)
302 rrset->entry.data;
303 if(!key_entry_setup(region, name, namelen, dclass, &k, &d))
304 return NULL;
305 d->ttl = rd->ttl + now;

--- 10 unchanged lines hidden (view full) ---

316 return NULL;
317 } else d->algo = NULL;
318 packed_rrset_ptr_fixup(d->rrset_data);
319 return k;
320}
321
322struct key_entry_key*
323key_entry_create_bad(struct regional* region,
299{
300 struct key_entry_key* k;
301 struct key_entry_data* d;
302 struct packed_rrset_data* rd = (struct packed_rrset_data*)
303 rrset->entry.data;
304 if(!key_entry_setup(region, name, namelen, dclass, &k, &d))
305 return NULL;
306 d->ttl = rd->ttl + now;

--- 10 unchanged lines hidden (view full) ---

317 return NULL;
318 } else d->algo = NULL;
319 packed_rrset_ptr_fixup(d->rrset_data);
320 return k;
321}
322
323struct key_entry_key*
324key_entry_create_bad(struct regional* region,
324 uint8_t* name, size_t namelen, uint16_t dclass, uint32_t ttl,
325 uint32_t now)
325 uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl,
326 time_t now)
326{
327 struct key_entry_key* k;
328 struct key_entry_data* d;
329 if(!key_entry_setup(region, name, namelen, dclass, &k, &d))
330 return NULL;
331 d->ttl = now + ttl;
332 d->isbad = 1;
333 d->reason = NULL;

--- 38 unchanged lines hidden (view full) ---

372 unsigned char* pk;
373 unsigned int pklen = 0;
374 int algo;
375 if(data->rr_len[idx] < 2+5)
376 return 0;
377 algo = (int)data->rr_data[idx][2+3];
378 pk = (unsigned char*)data->rr_data[idx]+2+4;
379 pklen = (unsigned)data->rr_len[idx]-2-4;
327{
328 struct key_entry_key* k;
329 struct key_entry_data* d;
330 if(!key_entry_setup(region, name, namelen, dclass, &k, &d))
331 return NULL;
332 d->ttl = now + ttl;
333 d->isbad = 1;
334 d->reason = NULL;

--- 38 unchanged lines hidden (view full) ---

373 unsigned char* pk;
374 unsigned int pklen = 0;
375 int algo;
376 if(data->rr_len[idx] < 2+5)
377 return 0;
378 algo = (int)data->rr_data[idx][2+3];
379 pk = (unsigned char*)data->rr_data[idx]+2+4;
380 pklen = (unsigned)data->rr_len[idx]-2-4;
380 return ldns_rr_dnskey_key_size_raw(pk, pklen, algo);
381 return sldns_rr_dnskey_key_size_raw(pk, pklen, algo);
381}
382
383/** get dnskey flags from data */
384static uint16_t
385kd_get_flags(struct packed_rrset_data* data, size_t idx)
386{
387 uint16_t f;
388 if(data->rr_len[idx] < 2+2)

--- 24 unchanged lines hidden ---
382}
383
384/** get dnskey flags from data */
385static uint16_t
386kd_get_flags(struct packed_rrset_data* data, size_t idx)
387{
388 uint16_t f;
389 if(data->rr_len[idx] < 2+2)

--- 24 unchanged lines hidden ---