Kea  1.5.0
tsigkey.h
Go to the documentation of this file.
1 // Copyright (C) 2010-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 TSIGKEY_H
8 #define TSIGKEY_H 1
9 
10 #include <cryptolink/cryptolink.h>
11 
12 namespace isc {
13 namespace dns {
14 
15 class Name;
16 
56 class TSIGKey {
57 public:
61 
62  TSIGKey(const Name& key_name, const Name& algorithm_name,
112  const void* secret, size_t secret_len, size_t digestbits = 0);
113 
136  explicit TSIGKey(const std::string& str);
137 
143  TSIGKey(const TSIGKey& source);
144 
154  TSIGKey& operator=(const TSIGKey& source);
155 
157  ~TSIGKey();
159 
164 
165  const Name& getKeyName() const;
167 
169  const Name& getAlgorithmName() const;
170 
173 
175  size_t getDigestbits() const;
176 
178  size_t getSecretLength() const;
179 
190  const void* getSecret() const;
192 
203  std::string toText() const;
204 
211 
212  static const Name& HMACMD5_NAME();
213  static const Name& HMACMD5_SHORT_NAME();
214  static const Name& HMACSHA1_NAME();
215  static const Name& HMACSHA256_NAME();
216  static const Name& HMACSHA224_NAME();
217  static const Name& HMACSHA384_NAME();
218  static const Name& HMACSHA512_NAME();
219 
220 
221 private:
222  struct TSIGKeyImpl;
223  const TSIGKeyImpl* impl_;
224 };
225 
245 class TSIGKeyRing {
246 public:
248  enum Result {
249  SUCCESS = 0,
250  EXIST = 1,
251  NOTFOUND = 2
252  };
253 
269  struct FindResult {
270  FindResult(Result param_code, const TSIGKey* param_key) :
271  code(param_code), key(param_key)
272  {}
273  const Result code;
274  const TSIGKey* const key;
275  };
276 
290 
291 private:
292  TSIGKeyRing(const TSIGKeyRing& source);
293  TSIGKeyRing& operator=(const TSIGKeyRing& source);
294 public:
298  TSIGKeyRing();
299 
301  ~TSIGKeyRing();
303 
307  unsigned int size() const;
308 
322  Result add(const TSIGKey& key);
323 
333  Result remove(const Name& key_name);
334 
354  FindResult find(const Name& key_name) const;
355 
377  FindResult find(const Name& key_name, const Name& algorithm_name) const;
378 
379 private:
380  struct TSIGKeyRingImpl;
381  TSIGKeyRingImpl* impl_;
382 };
383 }
384 }
385 
386 #endif // TSIGKEY_H
387 
388 // Local Variables:
389 // mode: c++
390 // End:
isc::dns::TSIGKeyRing::FindResult::key
const TSIGKey *const key
Definition: tsigkey.h:274
isc::dns::TSIGKeyRing::find
FindResult find(const Name &key_name) const
Find a TSIGKey for the given name in the TSIGKeyRing.
Definition: tsigkey.cc:338
isc::dns::TSIGKey::HMACMD5_NAME
static const Name & HMACMD5_NAME()
HMAC-MD5 (RFC2845)
Definition: tsigkey.cc:262
isc::dns::TSIGKey::TSIGKey
TSIGKey(const Name &key_name, const Name &algorithm_name, const void *secret, size_t secret_len, size_t digestbits=0)
Constructor from key parameters.
Definition: tsigkey.cc:99
isc::dns::TSIGKey::HMACSHA384_NAME
static const Name & HMACSHA384_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:292
isc::dns::TSIGKeyRing::FindResult
A helper structure to represent the search result of TSIGKeyRing::find().
Definition: tsigkey.h:269
isc::dns::TSIGKeyRing::FindResult::FindResult
FindResult(Result param_code, const TSIGKey *param_key)
Definition: tsigkey.h:270
isc::dns::TSIGKey::getKeyName
const Name & getKeyName() const
Return the key name.
Definition: tsigkey.cc:214
isc::dns::TSIGKey::getSecretLength
size_t getSecretLength() const
Return the length of the TSIG secret in bytes.
Definition: tsigkey.cc:239
isc::dns::TSIGKey::getDigestbits
size_t getDigestbits() const
Return the minimum truncated length.
Definition: tsigkey.cc:229
isc::dns::TSIGKey::HMACSHA1_NAME
static const Name & HMACSHA1_NAME()
HMAC-SHA1 (RFC4635)
Definition: tsigkey.cc:274
isc::dns::TSIGKeyRing::TSIGKeyRing
TSIGKeyRing()
The default constructor.
Definition: tsigkey.cc:309
isc::dns::TSIGKeyRing::~TSIGKeyRing
~TSIGKeyRing()
The destructor.
Definition: tsigkey.cc:312
isc::dns::TSIGKey
TSIG key.
Definition: tsigkey.h:56
isc::dns::TSIGKey::getSecret
const void * getSecret() const
Return the value of the TSIG secret.
Definition: tsigkey.cc:234
isc::dns::TSIGKeyRing::Result
Result
Result codes of various public methods of TSIGKeyRing.
Definition: tsigkey.h:248
isc::dns::TSIGKey::TSIGKeyImpl
Definition: tsigkey.cc:59
isc::dns::TSIGKeyRing::SUCCESS
@ SUCCESS
The operation is successful.
Definition: tsigkey.h:249
isc::dns::TSIGKey::getAlgorithm
isc::cryptolink::HashAlgorithm getAlgorithm() const
Return the hash algorithm name in the form of cryptolink::HashAlgorithm.
Definition: tsigkey.cc:224
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::dns::TSIGKeyRing::TSIGKeyRingImpl
Definition: tsigkey.cc:303
isc::dns::Name
The Name class encapsulates DNS names.
Definition: name.h:223
isc::dns::TSIGKey::HMACSHA512_NAME
static const Name & HMACSHA512_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:298
isc::dns::TSIGKey::HMACMD5_SHORT_NAME
static const Name & HMACMD5_SHORT_NAME()
Definition: tsigkey.cc:268
isc::dns::TSIGKey::HMACSHA256_NAME
static const Name & HMACSHA256_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:280
isc::dns::TSIGKey::operator=
TSIGKey & operator=(const TSIGKey &source)
Assignment operator.
Definition: tsigkey.cc:197
isc::dns::TSIGKeyRing::add
Result add(const TSIGKey &key)
Add a TSIGKey to the TSIGKeyRing.
Definition: tsigkey.cc:322
isc::dns::TSIGKeyRing::size
unsigned int size() const
Return the number of keys stored in the TSIGKeyRing.
Definition: tsigkey.cc:317
isc::dns::TSIGKey::~TSIGKey
~TSIGKey()
The destructor.
Definition: tsigkey.cc:209
isc::dns::TSIGKey::getAlgorithmName
const Name & getAlgorithmName() const
Return the algorithm name.
Definition: tsigkey.cc:219
isc::dns::TSIGKeyRing::EXIST
@ EXIST
A key is already stored in TSIGKeyRing.
Definition: tsigkey.h:250
isc::dns::TSIGKeyRing::NOTFOUND
@ NOTFOUND
The specified key is not found in TSIGKeyRing.
Definition: tsigkey.h:251
isc::dns::TSIGKeyRing::FindResult::code
const Result code
Definition: tsigkey.h:273
isc::dns::TSIGKey::HMACSHA224_NAME
static const Name & HMACSHA224_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:286
isc::dns::TSIGKeyRing::remove
Result remove(const Name &key_name)
Remove a TSIGKey for the given name from the TSIGKeyRing.
Definition: tsigkey.cc:333
isc::dns::TSIGKey::toText
std::string toText() const
Converts the TSIGKey to a string value.
Definition: tsigkey.cc:244
isc::dns::TSIGKeyRing
A simple repository of a set of TSIGKey objects.
Definition: tsigkey.h:245