Kea 3.3.3
tsigkey.h
Go to the documentation of this file.
1// Copyright (C) 2010-2026 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
9
11
12#include <cstdint>
13
14namespace isc {
15namespace dns {
16
17class Name;
18
58class TSIGKey {
59public:
63
64
113 TSIGKey(const Name& key_name, const Name& algorithm_name,
114 const void* secret, size_t secret_len, size_t digestbits = 0);
115
138 explicit TSIGKey(const std::string& str);
139
145 TSIGKey(const TSIGKey& source);
146
156 TSIGKey& operator=(const TSIGKey& source);
157
159 virtual ~TSIGKey();
161
166
167
168 const Name& getKeyName() const;
169
171 const Name& getAlgorithmName() const;
172
175
177 size_t getDigestbits() const;
178
180 size_t getSecretLength() const;
181
192 const void* getSecret() const;
194
205 std::string toText() const;
206
212
213 static const Name& HMACMD5_NAME(); // HMAC-MD5 (RFC2845)
214 static const Name& HMACMD5_SHORT_NAME();
215 static const Name& HMACSHA1_NAME(); // HMAC-SHA1 (RFC4635)
216 static const Name& HMACSHA256_NAME(); // HMAC-SHA256 (RFC4635)
217 static const Name& HMACSHA224_NAME(); // HMAC-SHA256 (RFC4635)
218 static const Name& HMACSHA384_NAME(); // HMAC-SHA256 (RFC4635)
219 static const Name& HMACSHA512_NAME(); // HMAC-SHA256 (RFC4635)
220 static const Name& GSSTSIG_NAME(); // GSS-TSIG (RFC3645)
222
223private:
224 struct TSIGKeyImpl;
225 boost::shared_ptr<TSIGKeyImpl> impl_;
226};
227
247class TSIGKeyRing {
248public:
250 enum Result : uint16_t {
251 SUCCESS = 0, // The operation is successful.
252 EXIST = 1, // A key is already stored in TSIGKeyRing.
253 NOTFOUND = 2 // The specified key is not found in TSIGKeyRing.
254 };
255
271 struct FindResult {
272 FindResult(Result param_code, const TSIGKey* param_key) :
273 code(param_code), key(param_key) {
274 }
276 const TSIGKey* const key;
277 };
278
291
292private:
293 TSIGKeyRing(const TSIGKeyRing& source);
294 TSIGKeyRing& operator=(const TSIGKeyRing& source);
295public:
299 TSIGKeyRing();
300
302 ~TSIGKeyRing();
304
308 unsigned int size() const;
309
323 Result add(const TSIGKey& key);
324
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
379private:
380 struct TSIGKeyRingImpl;
381 boost::shared_ptr<TSIGKeyRingImpl> impl_;
382};
383}
384}
385
386#endif // TSIGKEY_H
The Name class encapsulates DNS names.
Definition name.h:217
~TSIGKeyRing()
The destructor.
Definition tsigkey.cc:260
unsigned int size() const
Return the number of keys stored in the TSIGKeyRing.
Definition tsigkey.cc:264
Result remove(const Name &key_name)
Remove a TSIGKey for the given name from the TSIGKeyRing.
Definition tsigkey.cc:278
TSIGKeyRing()
The default constructor.
Definition tsigkey.cc:257
Result add(const TSIGKey &key)
Add a TSIGKey to the TSIGKeyRing.
Definition tsigkey.cc:269
Result
Result codes of various public methods of TSIGKeyRing.
Definition tsigkey.h:250
FindResult find(const Name &key_name) const
Find a TSIGKey for the given name in the TSIGKeyRing.
Definition tsigkey.cc:283
TSIG key.
Definition tsigkey.h:58
static const Name & HMACMD5_NAME()
Well known algorithm names as defined in RFC2845 and RFC4635.
Definition tsigkey.cc:304
static const Name & HMACSHA224_NAME()
Definition tsigkey.cc:322
const Name & getAlgorithmName() const
Return the algorithm name.
Definition tsigkey.cc:209
virtual ~TSIGKey()
The destructor.
Definition tsigkey.cc:200
static const Name & GSSTSIG_NAME()
Definition tsigkey.cc:346
size_t getDigestbits() const
Return the minimum truncated length.
Definition tsigkey.cc:219
static const Name & HMACSHA256_NAME()
Definition tsigkey.cc:328
TSIGKey & operator=(const TSIGKey &source)
Assignment operator.
Definition tsigkey.cc:191
isc::cryptolink::HashAlgorithm getAlgorithm() const
Return the hash algorithm name in the form of cryptolink::HashAlgorithm.
Definition tsigkey.cc:214
static const Name & HMACSHA1_NAME()
Definition tsigkey.cc:316
const Name & getKeyName() const
Getter Methods.
Definition tsigkey.cc:204
static const Name & HMACMD5_SHORT_NAME()
Definition tsigkey.cc:310
static const Name & HMACSHA512_NAME()
Definition tsigkey.cc:340
TSIGKey(const Name &key_name, const Name &algorithm_name, const void *secret, size_t secret_len, size_t digestbits=0)
Constructors, Assignment Operator and Destructor.
Definition tsigkey.cc:95
static const Name & HMACSHA384_NAME()
Definition tsigkey.cc:334
std::string toText() const
Converts the TSIGKey to a string value.
Definition tsigkey.cc:234
size_t getSecretLength() const
Return the length of the TSIG secret in bytes.
Definition tsigkey.cc:229
const void * getSecret() const
Return the value of the TSIG secret.
Definition tsigkey.cc:224
Defines the logger used by the top-level component of kea-lfc.
A helper structure to represent the search result of TSIGKeyRing::find().
Definition tsigkey.h:271
FindResult(Result param_code, const TSIGKey *param_key)
Definition tsigkey.h:272
const TSIGKey *const key
Definition tsigkey.h:276