Kea  1.9.9-git
nsec3hash.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef NSEC3HASH_H
8 #define NSEC3HASH_H 1
9 
10 #include <string>
11 #include <vector>
12 #include <stdint.h>
13 #include <exceptions/exceptions.h>
14 
15 namespace isc {
16 namespace dns {
17 class Name;
18 class LabelSequence;
19 
20 namespace rdata {
21 namespace generic {
22 class NSEC3;
23 class NSEC3PARAM;
24 }
25 }
26 
34 public:
35  UnknownNSEC3HashAlgorithm(const char* file, size_t line,
36  const char* what) :
37  isc::Exception(file, line, what) {}
38 };
39 
74 class NSEC3Hash {
75 protected:
81  NSEC3Hash() {}
82 
83 public:
104  static NSEC3Hash* create(const rdata::generic::NSEC3PARAM& param);
105 
110  static NSEC3Hash* create(const rdata::generic::NSEC3& nsec3);
111 
119  static NSEC3Hash* create(uint8_t algorithm, uint16_t iterations,
120  const uint8_t* salt_data, size_t salt_length);
121 
123  virtual ~NSEC3Hash() {}
124 
136  virtual std::string calculate(const Name& name) const = 0;
137 
150  virtual std::string calculate(const LabelSequence& ls) const = 0;
151 
166  virtual bool match(const rdata::generic::NSEC3& nsec3) const = 0;
167 
172  virtual bool match(const rdata::generic::NSEC3PARAM& nsec3param) const = 0;
173 };
174 
204 protected:
210 
211 public:
216  virtual ~NSEC3HashCreator() {}
217 
222  virtual NSEC3Hash* create(const rdata::generic::NSEC3PARAM& nsec3param)
223  const = 0;
224 
229  virtual NSEC3Hash* create(const rdata::generic::NSEC3& nsec3)
230  const = 0;
231 
244  virtual NSEC3Hash* create(uint8_t algorithm, uint16_t iterations,
245  const uint8_t* salt_data, size_t salt_length)
246  const = 0;
247 };
248 
259 public:
260  virtual NSEC3Hash* create(const rdata::generic::NSEC3PARAM& param) const;
261  virtual NSEC3Hash* create(const rdata::generic::NSEC3& nsec3) const;
262  virtual NSEC3Hash* create(uint8_t algorithm, uint16_t iterations,
263  const uint8_t* salt_data,
264  size_t salt_length) const;
265 };
266 
282 void setNSEC3HashCreator(const NSEC3HashCreator* new_creator);
283 
284 }
285 }
286 #endif // NSEC3HASH_H
287 
288 // Local Variables:
289 // mode: c++
290 // End:
The Name class encapsulates DNS names.
Definition: name.h:223
void setNSEC3HashCreator(const NSEC3HashCreator *new_creator)
The registrar of NSEC3HashCreator.
Definition: nsec3hash.cc:263
virtual std::string calculate(const Name &name) const =0
Calculate the NSEC3 hash (Name variant).
A calculator of NSEC3 hashes.
Definition: nsec3hash.h:74
virtual NSEC3Hash * create(const rdata::generic::NSEC3PARAM &nsec3param) const =0
Factory method of NSECHash from NSEC3PARAM RDATA.
An exception that is thrown for when an NSEC3Hash object is constructed with an unknown hash algorith...
Definition: nsec3hash.h:33
virtual bool match(const rdata::generic::NSEC3 &nsec3) const =0
Match given NSEC3 parameters with that of the hash.
Factory class of NSEC3Hash.
Definition: nsec3hash.h:203
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
NSEC3Hash()
The default constructor.
Definition: nsec3hash.h:81
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
UnknownNSEC3HashAlgorithm(const char *file, size_t line, const char *what)
Definition: nsec3hash.h:35
The default NSEC3Hash creator.
Definition: nsec3hash.h:258
virtual ~NSEC3Hash()
The destructor.
Definition: nsec3hash.h:123
static NSEC3Hash * create(const rdata::generic::NSEC3PARAM &param)
Factory method of NSECHash from NSEC3PARAM RDATA.
Definition: nsec3hash.cc:221
NSEC3HashCreator()
The default constructor.
Definition: nsec3hash.h:209
virtual ~NSEC3HashCreator()
The destructor.
Definition: nsec3hash.h:216
Light-weight Accessor to Name data.
Definition: labelsequence.h:35
virtual NSEC3Hash * create(const rdata::generic::NSEC3PARAM &param) const
Factory method of NSECHash from NSEC3PARAM RDATA.
Definition: nsec3hash.cc:238