Kea 2.5.8
tsigkey.h
Go to the documentation of this file.
1// Copyright (C) 2010-2024 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
12namespace isc {
13namespace dns {
14
15class Name;
16
56class TSIGKey {
57public:
61
62
111 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 virtual ~TSIGKey();
159
164
165
166 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
210
211 static const Name& HMACMD5_NAME(); // HMAC-MD5 (RFC2845)
212 static const Name& HMACMD5_SHORT_NAME();
213 static const Name& HMACSHA1_NAME(); // HMAC-SHA1 (RFC4635)
214 static const Name& HMACSHA256_NAME(); // HMAC-SHA256 (RFC4635)
215 static const Name& HMACSHA224_NAME(); // HMAC-SHA256 (RFC4635)
216 static const Name& HMACSHA384_NAME(); // HMAC-SHA256 (RFC4635)
217 static const Name& HMACSHA512_NAME(); // HMAC-SHA256 (RFC4635)
218 static const Name& GSSTSIG_NAME(); // GSS-TSIG (RFC3645)
220
221private:
222 struct TSIGKeyImpl;
223 boost::shared_ptr<TSIGKeyImpl> impl_;
224};
225
246public:
248 enum Result {
249 SUCCESS = 0, // The operation is successful.
250 EXIST = 1, // A key is already stored in TSIGKeyRing.
251 NOTFOUND = 2 // The specified key is not found in TSIGKeyRing.
252 };
253
269 struct FindResult {
270 FindResult(Result param_code, const TSIGKey* param_key) :
271 code(param_code), key(param_key) {
272 }
274 const TSIGKey* const key;
275 };
276
289
290private:
291 TSIGKeyRing(const TSIGKeyRing& source);
292 TSIGKeyRing& operator=(const TSIGKeyRing& source);
293public:
297 TSIGKeyRing();
298
300 ~TSIGKeyRing();
302
306 unsigned int size() const;
307
321 Result add(const TSIGKey& key);
322
331 Result remove(const Name& key_name);
332
352 FindResult find(const Name& key_name) const;
353
375 FindResult find(const Name& key_name, const Name& algorithm_name) const;
376
377private:
378 struct TSIGKeyRingImpl;
379 boost::shared_ptr<TSIGKeyRingImpl> impl_;
380};
381}
382}
383
384#endif // TSIGKEY_H
The Name class encapsulates DNS names.
Definition: name.h:219
A simple repository of a set of TSIGKey objects.
Definition: tsigkey.h:245
~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
FindResult find(const Name &key_name) const
Find a TSIGKey for the given name in the TSIGKeyRing.
Definition: tsigkey.cc:283
Result
Result codes of various public methods of TSIGKeyRing.
Definition: tsigkey.h:248
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
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:269
FindResult(Result param_code, const TSIGKey *param_key)
Definition: tsigkey.h:270
const TSIGKey *const key
Definition: tsigkey.h:274