Parcourir la source

mostly empty class for Tsig key holding

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1013 e5f2f494-b856-4b98-b285-d166d9295462
Michael Graff il y a 15 ans
Parent
commit
da421b8d5b

+ 1 - 0
src/lib/dns/cpp/Makefile.am

@@ -19,6 +19,7 @@ libdns_la_SOURCES += rrsetlist.h rrsetlist.cc
 libdns_la_SOURCES += question.h question.cc
 libdns_la_SOURCES += message.h message.cc
 libdns_la_SOURCES += base64.h base64.cc
+libdns_la_SOURCES += tsig.h tsig.cc
 libdns_la_SOURCES += dnstime.h dnstime.cc
 libdns_la_SOURCES += hex.h hex.cc
 

+ 1 - 0
src/lib/dns/cpp/tests/Makefile.am

@@ -27,6 +27,7 @@ run_unittests_SOURCES += rrparamregistry_unittest.cc
 run_unittests_SOURCES += message_unittest.cc
 run_unittests_SOURCES += base64_unittest.cc
 run_unittests_SOURCES += hex_unittest.cc
+run_unittests_SOURCES += tsig_unittest.cc
 run_unittests_SOURCES += run_unittests.cc
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)

+ 41 - 0
src/lib/dns/cpp/tests/tsig_unittest.cc

@@ -0,0 +1,41 @@
+// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+// $Id: rrtype_unittest.cc 476 2010-01-19 00:29:28Z jinmei $
+
+#include <gtest/gtest.h>
+
+#include <dns/tsig.h>
+
+#include "unittest_util.h"
+
+using isc::UnitTestUtil;
+using namespace std;
+using namespace isc::dns;
+
+namespace {
+class TsigTest : public ::testing::Test {
+protected:
+    TsigTest() {}
+};
+
+// simple creation test to get the testing ball rolling
+TEST_F(TsigTest, creates) {
+    Tsig tsig(Name("example.com"), Tsig::HMACMD5, "someRandomData");
+    EXPECT_TRUE(1);
+}
+
+} // end namespace
+
+

+ 33 - 0
src/lib/dns/cpp/tsig.cc

@@ -0,0 +1,33 @@
+// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+// $Id$
+
+#include <cctype>
+#include <cassert>
+#include <iterator>
+#include <functional>
+
+#include <algorithm>
+
+#include "tsig.h"
+
+using namespace std;
+using isc::dns::MessageRenderer;
+
+namespace isc {
+namespace dns {
+
+} // namespace dns
+} // namespace isc

+ 72 - 0
src/lib/dns/cpp/tsig.h

@@ -0,0 +1,72 @@
+// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+// $Id$
+
+#ifndef __TSIG_H
+#define __TSIG_H 1
+
+#include <string>
+#include <vector>
+
+#include <exceptions/exceptions.h>
+
+#include "name.h"
+#include "message.h"
+
+namespace isc {
+namespace dns {
+
+class BadTsigKey : public Exception {
+public:
+    BadTsigKey(const char* file, size_t line, const char* what) :
+        isc::Exception(file, line, what) {}
+};
+
+//
+// This class holds a Tsig key, including all its attributes.
+//
+class Tsig {
+public:
+    enum TsigAlgorithm {
+        HMACMD5 = 0,
+        GSS = 1,
+        HMACSHA1 = 2,
+        HMACSHA224 = 3,
+        HMACSHA265 = 4,
+        HMACSHA384 = 5,
+        HMACSHA512 = 6,
+    };
+
+    Tsig(const Name& name, TsigAlgorithm algorithm,
+         const std::string& algorithm_data) :
+         name_(name), algorithm_(algorithm), algorithm_data_(algorithm_data) {};
+
+    bool signMessage(const Message& message);
+    bool verifyMessage(const Message &message);
+
+private:
+    Name name_;
+    TsigAlgorithm algorithm_;
+    std::string algorithm_data_;
+};
+
+}
+}
+
+#endif  // __TSIG_H
+
+// Local Variables: 
+// mode: c++
+// End: