From 48b4f7b83f9f8e6d89d56f5e24f0ed1d7c4676a1 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 12 Jan 2014 04:12:27 +0100 Subject: Remove cryptopp dependency, directly include a simple sha1 implementation --- src/xmpp/xmpp_component.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/xmpp/xmpp_component.cpp') diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index b370daa..1ef2f37 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -4,12 +4,11 @@ #include #include +#include + #include -// CryptoPP -#include -#include -#include +#include #define STREAM_NS "http://etherx.jabber.org/streams" #define COMPONENT_NS "jabber:component:accept" @@ -119,13 +118,17 @@ void XmppComponent::on_remote_stream_open(const XmlNode& node) } // Try to authenticate - CryptoPP::SHA1 sha1; - std::string digest; - CryptoPP::StringSource foo(this->stream_id + this->secret, true, - new CryptoPP::HashFilter(sha1, - new CryptoPP::HexEncoder( - new CryptoPP::StringSink(digest), false))); - Stanza handshake("handshake", nullptr); + char digest[HASH_LENGTH * 2 + 1]; + sha1nfo sha1; + sha1_init(&sha1); + sha1_write(&sha1, this->stream_id.data(), this->stream_id.size()); + sha1_write(&sha1, this->secret.data(), this->secret.size()); + const uint8_t* result = sha1_result(&sha1); + for (int i=0; i < HASH_LENGTH; i++) + sprintf(digest + (i*2), "%02x", result[i]); + digest[HASH_LENGTH * 2] = '\0'; + + Stanza handshake("handshake"); handshake.set_inner(digest); handshake.close(); this->send_stanza(handshake); -- cgit v1.2.3