Kea 2.2.0
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
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
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();
221
222private:
223 struct TSIGKeyImpl;
224 const TSIGKeyImpl* impl_;
225};
226
247public:
249 enum Result {
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 {}
275 const TSIGKey* const key;
276 };
277
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
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
380private:
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
A simple repository of a set of TSIGKey objects.
Definition: tsigkey.h:246
~TSIGKeyRing()
The destructor.
Definition: tsigkey.cc:317
unsigned int size() const
Return the number of keys stored in the TSIGKeyRing.
Definition: tsigkey.cc:322
Result remove(const Name &key_name)
Remove a TSIGKey for the given name from the TSIGKeyRing.
Definition: tsigkey.cc:338
TSIGKeyRing()
The default constructor.
Definition: tsigkey.cc:314
Result add(const TSIGKey &key)
Add a TSIGKey to the TSIGKeyRing.
Definition: tsigkey.cc:327
FindResult find(const Name &key_name) const
Find a TSIGKey for the given name in the TSIGKeyRing.
Definition: tsigkey.cc:343
Result
Result codes of various public methods of TSIGKeyRing.
Definition: tsigkey.h:249
@ EXIST
A key is already stored in TSIGKeyRing.
Definition: tsigkey.h:251
@ NOTFOUND
The specified key is not found in TSIGKeyRing.
Definition: tsigkey.h:252
@ SUCCESS
The operation is successful.
Definition: tsigkey.h:250
TSIG key.
Definition: tsigkey.h:56
static const Name & HMACMD5_NAME()
HMAC-MD5 (RFC2845)
Definition: tsigkey.cc:261
static const Name & HMACSHA224_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:285
const Name & getAlgorithmName() const
Return the algorithm name.
Definition: tsigkey.cc:218
virtual ~TSIGKey()
The destructor.
Definition: tsigkey.cc:208
static const Name & GSSTSIG_NAME()
GSS-TSIG (RFC3645)
Definition: tsigkey.cc:303
size_t getDigestbits() const
Return the minimum truncated length.
Definition: tsigkey.cc:228
static const Name & HMACSHA256_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:279
TSIGKey & operator=(const TSIGKey &source)
Assignment operator.
Definition: tsigkey.cc:196
isc::cryptolink::HashAlgorithm getAlgorithm() const
Return the hash algorithm name in the form of cryptolink::HashAlgorithm.
Definition: tsigkey.cc:223
static const Name & HMACSHA1_NAME()
HMAC-SHA1 (RFC4635)
Definition: tsigkey.cc:273
const Name & getKeyName() const
Return the key name.
Definition: tsigkey.cc:213
static const Name & HMACMD5_SHORT_NAME()
Definition: tsigkey.cc:267
static const Name & HMACSHA512_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:297
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
static const Name & HMACSHA384_NAME()
HMAC-SHA256 (RFC4635)
Definition: tsigkey.cc:291
std::string toText() const
Converts the TSIGKey to a string value.
Definition: tsigkey.cc:243
size_t getSecretLength() const
Return the length of the TSIG secret in bytes.
Definition: tsigkey.cc:238
const void * getSecret() const
Return the value of the TSIG secret.
Definition: tsigkey.cc:233
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:270
FindResult(Result param_code, const TSIGKey *param_key)
Definition: tsigkey.h:271
const TSIGKey *const key
Definition: tsigkey.h:275