Kea  1.9.9-git
tsigkey.h
Go to the documentation of this file.
1 // Copyright (C) 2010-2021 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  static const Name& GSSTSIG_NAME();
220 
221 
222 private:
223  struct TSIGKeyImpl;
224  const TSIGKeyImpl* impl_;
225 };
226 
246 class TSIGKeyRing {
247 public:
249  enum Result {
250  SUCCESS = 0,
251  EXIST = 1,
252  NOTFOUND = 2
253  };
254 
270  struct FindResult {
271  FindResult(Result param_code, const TSIGKey* param_key) :
272  code(param_code), key(param_key)
273  {}
274  const Result code;
275  const TSIGKey* const key;
276  };
277 
291 
292 private:
293  TSIGKeyRing(const TSIGKeyRing& source);
294  TSIGKeyRing& operator=(const TSIGKeyRing& source);
295 public:
299  TSIGKeyRing();
300 
302  ~TSIGKeyRing();
304 
308  unsigned int size() const;
309 
323  Result add(const TSIGKey& key);
324 
334  Result remove(const Name& key_name);
335 
355  FindResult find(const Name& key_name) const;
356 
378  FindResult find(const Name& key_name, const Name& algorithm_name) const;
379 
380 private:
381  struct TSIGKeyRingImpl;
382  TSIGKeyRingImpl* impl_;
383 };
384 }
385 }
386 
387 #endif // TSIGKEY_H
388 
389 // Local Variables:
390 // mode: c++
391 // End:
The Name class encapsulates DNS names.
Definition: name.h:223
isc::cryptolink::HashAlgorithm getAlgorithm() const
Return the hash algorithm name in the form of cryptolink::HashAlgorithm.
Definition: tsigkey.cc:224
The operation is successful.
Definition: tsigkey.h:250
const void * getSecret() const
Return the value of the TSIG secret.
Definition: tsigkey.cc:234
Result
Result codes of various public methods of TSIGKeyRing.
Definition: tsigkey.h:249
TSIG key.
Definition: tsigkey.h:56
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
const TSIGKey *const key
Definition: tsigkey.h:275
A helper structure to represent the search result of TSIGKeyRing::find().
Definition: tsigkey.h:270
static const Name & HMACSHA224_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:286
static const Name & HMACSHA1_NAME()
HMAC-SHA1 (RFC4635)
Definition: tsigkey.cc:274
~TSIGKey()
The destructor.
Definition: tsigkey.cc:209
static const Name & HMACSHA256_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:280
const Name & getAlgorithmName() const
Return the algorithm name.
Definition: tsigkey.cc:219
static const Name & HMACSHA512_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:298
Result add(const TSIGKey &key)
Add a TSIGKey to the TSIGKeyRing.
Definition: tsigkey.cc:328
static const Name & HMACMD5_NAME()
HMAC-MD5 (RFC2845)
Definition: tsigkey.cc:262
size_t getDigestbits() const
Return the minimum truncated length.
Definition: tsigkey.cc:229
const Name & getKeyName() const
Return the key name.
Definition: tsigkey.cc:214
FindResult find(const Name &key_name) const
Find a TSIGKey for the given name in the TSIGKeyRing.
Definition: tsigkey.cc:344
TSIGKey & operator=(const TSIGKey &source)
Assignment operator.
Definition: tsigkey.cc:197
Defines the logger used by the top-level component of kea-dhcp-ddns.
FindResult(Result param_code, const TSIGKey *param_key)
Definition: tsigkey.h:271
TSIGKeyRing()
The default constructor.
Definition: tsigkey.cc:315
size_t getSecretLength() const
Return the length of the TSIG secret in bytes.
Definition: tsigkey.cc:239
A simple repository of a set of TSIGKey objects.
Definition: tsigkey.h:246
static const Name & HMACMD5_SHORT_NAME()
Definition: tsigkey.cc:268
static const Name & GSSTSIG_NAME()
GSS-TSIG (RFC3645)
Definition: tsigkey.cc:304
~TSIGKeyRing()
The destructor.
Definition: tsigkey.cc:318
The specified key is not found in TSIGKeyRing.
Definition: tsigkey.h:252
unsigned int size() const
Return the number of keys stored in the TSIGKeyRing.
Definition: tsigkey.cc:323
std::string toText() const
Converts the TSIGKey to a string value.
Definition: tsigkey.cc:244
static const Name & HMACSHA384_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:292
A key is already stored in TSIGKeyRing.
Definition: tsigkey.h:251