Deleted Added
sdiff udiff text old ( 256281 ) new ( 269257 )
full compact
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
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"
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"
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,
279 uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl,
280 time_t now)
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,
298 struct ub_packed_rrset_key* rrset, uint8_t* sigalg, time_t now)
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,
325 uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl,
326 time_t now)
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;
381 return sldns_rr_dnskey_key_size_raw(pk, pklen, algo);
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 ---