///
virtual void resetStats();
+ /// @brief Create TSIG context.
+ ///
+ /// @note Derived classes can implement their own specific context.
+ ///
+ /// @return The specific @ref TSIGContext of the @ref TSIGKey.
+ virtual dns::TSIGContextPtr createContext();
+
private:
/// @brief Initialize key statistics.
void initStats();
/// @brief Type of pointer to a D2 TSIG key.
typedef boost::shared_ptr<D2TsigKey> D2TsigKeyPtr;
-/// @brief TSIGContext factory type.
-typedef dns::TSIGContextPtr (*TSIGContextFactory)(D2TsigKeyPtr);
-
-/// @brief The TSIGContext factory.
-extern TSIGContextFactory tsigContextFactory;
-
-/// @brief Default TSIGContext factory.
-///
-/// @param tsig_key a D2 TSIG key.
-/// @return a pointer to a TSIG context.
-dns::TSIGContextPtr defaultTsigContextFactory(D2TsigKeyPtr tsig_key);
-
} // namespace d2
} // namespace isc
TSIGError error = TSIGError::NOERROR()) :
state_(INIT), key_(key), error_(error),
previous_timesigned_(0), digest_len_(0),
- last_sig_dist_(-1)
- {
+ last_sig_dist_(-1) {
if (error == TSIGError::NOERROR()) {
// In normal (NOERROR) case, the key should be valid, and we
// should be able to pre-create a corresponding HMAC object,
TSIGContext::TSIGContextImpl::digestTSIGVariables(
HMACPtr hmac, uint16_t rrclass, uint32_t rrttl, uint64_t time_signed,
uint16_t fudge, uint16_t error, uint16_t otherlen, const void* otherdata,
- bool time_variables_only) const
-{
+ bool time_variables_only) const {
// It's bit complicated, but we can still predict the necessary size of
// the data to be digested. So we precompute it to avoid possible
// reallocation inside OutputBuffer (not absolutely necessary, but this
namespace {
const size_t MESSAGE_HEADER_LEN = 12;
}
+
void
TSIGContext::TSIGContextImpl::digestDNSMessage(HMACPtr hmac,
uint16_t qid, const void* data,
- size_t data_len) const
-{
+ size_t data_len) const {
OutputBuffer buffer(MESSAGE_HEADER_LEN);
const uint8_t* msgptr = static_cast<const uint8_t*>(data);
hmac->update(msgptr, data_len - MESSAGE_HEADER_LEN);
}
-TSIGContext::TSIGContext(const TSIGKey& key) : impl_(new TSIGContextImpl(key))
-{
+TSIGContext::TSIGContext(const TSIGKey& key) : impl_(new TSIGContextImpl(key)) {
}
TSIGContext::TSIGContext(const Name& key_name, const Name& algorithm_name,
- const TSIGKeyRing& keyring) : impl_(NULL)
-{
+ const TSIGKeyRing& keyring) : impl_(NULL) {
const TSIGKeyRing::FindResult result(keyring.find(key_name,
algorithm_name));
if (result.code == TSIGKeyRing::NOTFOUND) {
ConstTSIGRecordPtr
TSIGContext::sign(const uint16_t qid, const void* const data,
- const size_t data_len)
-{
+ const size_t data_len) {
if (impl_->state_ == VERIFIED_RESPONSE) {
isc_throw(TSIGContextError,
"TSIG sign attempt after verifying a response");
TSIGError
TSIGContext::verify(const TSIGRecord* const record, const void* const data,
- const size_t data_len)
-{
+ const size_t data_len) {
if (impl_->state_ == SENT_RESPONSE) {
isc_throw(TSIGContextError,
"TSIG verify attempt after sending a response");
TSIGKey::TSIGKey(const Name& key_name, const Name& algorithm_name,
const void* secret, size_t secret_len,
- size_t digestbits /*= 0*/) : impl_(NULL)
-{
+ size_t digestbits /*= 0*/) : impl_(NULL) {
const HashAlgorithm algorithm = convertAlgorithmName(algorithm_name);
if ((secret != NULL && secret_len == 0) ||
(secret == NULL && secret_len != 0)) {
}
-TSIGKey::TSIGKey(const TSIGKey& source) : impl_(new TSIGKeyImpl(*source.impl_))
-{}
+TSIGKey::TSIGKey(const TSIGKey& source) : impl_(new TSIGKeyImpl(*source.impl_)) {
+}
TSIGKey&
TSIGKey::operator=(const TSIGKey& source) {