summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/TLS')
-rw-r--r--Swiften/TLS/Certificate.cpp8
-rw-r--r--Swiften/TLS/Certificate.h6
-rw-r--r--Swiften/TLS/UnitTest/CertificateTest.cpp6
3 files changed, 12 insertions, 8 deletions
diff --git a/Swiften/TLS/Certificate.cpp b/Swiften/TLS/Certificate.cpp
index a796463..ec268c8 100644
--- a/Swiften/TLS/Certificate.cpp
+++ b/Swiften/TLS/Certificate.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -8,7 +8,7 @@
#include <sstream>
-#include <Swiften/StringCodecs/SHA1.h>
+#include <Swiften/Crypto/CryptoProvider.h>
#include <Swiften/StringCodecs/Hexify.h>
namespace Swift {
@@ -19,8 +19,8 @@ const char* Certificate::ID_ON_DNSSRV_OID = "1.3.6.1.5.5.7.8.7";
Certificate::~Certificate() {
}
-std::string Certificate::getSHA1Fingerprint() const {
- ByteArray hash = SHA1::getHash(toDER());
+std::string Certificate::getSHA1Fingerprint(Certificate::ref certificate, CryptoProvider* crypto) {
+ ByteArray hash = crypto->getSHA1Hash(certificate->toDER());
std::ostringstream s;
for (size_t i = 0; i < hash.size(); ++i) {
if (i > 0) {
diff --git a/Swiften/TLS/Certificate.h b/Swiften/TLS/Certificate.h
index 9aec86c..f558c12 100644
--- a/Swiften/TLS/Certificate.h
+++ b/Swiften/TLS/Certificate.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -13,6 +13,8 @@
#include <Swiften/Base/ByteArray.h>
namespace Swift {
+ class CryptoProvider;
+
class SWIFTEN_API Certificate {
public:
typedef boost::shared_ptr<Certificate> ref;
@@ -32,7 +34,7 @@ namespace Swift {
virtual ByteArray toDER() const = 0;
- virtual std::string getSHA1Fingerprint() const;
+ static std::string getSHA1Fingerprint(Certificate::ref, CryptoProvider* crypto);
protected:
static const char* ID_ON_XMPPADDR_OID;
diff --git a/Swiften/TLS/UnitTest/CertificateTest.cpp b/Swiften/TLS/UnitTest/CertificateTest.cpp
index 5df5639..3352118 100644
--- a/Swiften/TLS/UnitTest/CertificateTest.cpp
+++ b/Swiften/TLS/UnitTest/CertificateTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -12,6 +12,8 @@
#include <Swiften/TLS/Certificate.h>
#include <Swiften/TLS/SimpleCertificate.h>
+#include <Swiften/Crypto/CryptoProvider.h>
+#include <Swiften/Crypto/PlatformCryptoProvider.h>
using namespace Swift;
@@ -25,7 +27,7 @@ class CertificateTest : public CppUnit::TestFixture {
SimpleCertificate::ref testling = boost::make_shared<SimpleCertificate>();
testling->setDER(createByteArray("abcdefg"));
- CPPUNIT_ASSERT_EQUAL(std::string("2f:b5:e1:34:19:fc:89:24:68:65:e7:a3:24:f4:76:ec:62:4e:87:40"), testling->getSHA1Fingerprint());
+ CPPUNIT_ASSERT_EQUAL(std::string("2f:b5:e1:34:19:fc:89:24:68:65:e7:a3:24:f4:76:ec:62:4e:87:40"), Certificate::getSHA1Fingerprint(testling, boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()).get()));
}
};