Parcourir la source

[3513] added static getVersion for cryptolink

Francis Dupont il y a 10 ans
Parent
commit
dbb8141ba1

+ 6 - 1
src/lib/cryptolink/botan_link.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2011, 2014  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011, 2014, 2015  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
@@ -43,6 +43,11 @@ CryptoLink::initialize() {
     }
 }
 
+std::string
+CryptoLink::getVersion() {
+    return (Botan::version_string());
+}
+
 } // namespace cryptolink
 } // namespace isc
 

+ 4 - 1
src/lib/cryptolink/cryptolink.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2011, 2014  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011, 2014, 2015  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
@@ -161,6 +161,9 @@ public:
     ///
     static void initialize();
 
+    /// \brief Get version string
+    static std::string getVersion();
+
     /// \brief Factory function for Hash objects
     ///
     /// CryptoLink objects cannot be constructed directly. This

+ 8 - 1
src/lib/cryptolink/openssl_link.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014, 2015  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
@@ -16,6 +16,8 @@
 #include <cryptolink/crypto_hash.h>
 #include <cryptolink/crypto_hmac.h>
 
+#include <openssl/crypto.h>
+
 namespace isc {
 namespace cryptolink {
 
@@ -46,6 +48,11 @@ CryptoLink::initialize() {
     }
 }
 
+std::string
+CryptoLink::getVersion() {
+    return (SSLeay_version(SSLEAY_VERSION));
+}
+
 } // namespace cryptolink
 } // namespace isc
 

+ 6 - 1
src/lib/cryptolink/tests/crypto_unittests.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2011, 2014  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011, 2014, 2015  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
@@ -22,6 +22,11 @@
 
 using namespace isc::cryptolink;
 
+// Test get version
+TEST(CryptoLinkTest, Version) {
+    EXPECT_NO_THROW(CryptoLink::getVersion());
+}
+
 // Tests whether getCryptoLink() returns a singleton instance
 TEST(CryptoLinkTest, Singleton) {
     const CryptoLink& c1 = CryptoLink::getCryptoLink();