summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-01-12 04:12:27 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-01-13 20:11:36 +0100
commit48b4f7b83f9f8e6d89d56f5e24f0ed1d7c4676a1 (patch)
tree0d8b34dd628d2c5d74a3c39263d2a0e6d6be0d40 /src/xmpp
parentfef9c8193ddf8cdf81978874be788af9441e2286 (diff)
downloadbiboumi-48b4f7b83f9f8e6d89d56f5e24f0ed1d7c4676a1.tar.gz
biboumi-48b4f7b83f9f8e6d89d56f5e24f0ed1d7c4676a1.tar.bz2
biboumi-48b4f7b83f9f8e6d89d56f5e24f0ed1d7c4676a1.tar.xz
biboumi-48b4f7b83f9f8e6d89d56f5e24f0ed1d7c4676a1.zip
Remove cryptopp dependency, directly include a simple sha1 implementation
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/xmpp_component.cpp25
1 files changed, 14 insertions, 11 deletions
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 <xmpp/xmpp_component.hpp>
#include <xmpp/jid.hpp>
+#include <utils/sha1.hpp>
+
#include <iostream>
-// CryptoPP
-#include <filters.h>
-#include <hex.h>
-#include <sha.h>
+#include <stdio.h>
#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);