diff --git a/Cargo.toml b/Cargo.toml index 2faf4fb..fab462b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,5 +27,4 @@ domain = "0.2" xmpp-parsers = "0.10" idna = "0.1" try_from = "0.2" -sha-1 = "0.7" quick-xml = "0.12" diff --git a/src/component/auth.rs b/src/component/auth.rs index bd1c9aa..2149da8 100644 --- a/src/component/auth.rs +++ b/src/component/auth.rs @@ -2,7 +2,7 @@ use std::mem::replace; use futures::{Future, Poll, Async, sink, Sink, Stream}; use tokio_io::{AsyncRead, AsyncWrite}; use minidom::Element; -use sha1::{Sha1, Digest}; +use xmpp_parsers::component::Handshake; use xmpp_codec::Packet; use xmpp_stream::XMPPStream; @@ -28,19 +28,13 @@ impl ComponentAuth { }; this.send( stream, - "handshake", - // TODO: sha1(sid + password) - &format!("{:x}", Sha1::digest((sid + &password).as_bytes())) + Handshake::from_password_and_stream_id(&password, &sid) ); return Ok(this); } - fn send(&mut self, stream: XMPPStream, nonza_name: &str, handshake: &str) { - let nonza = Element::builder(nonza_name) - .ns(NS_JABBER_COMPONENT_ACCEPT) - .append(handshake) - .build(); - + fn send(&mut self, stream: XMPPStream, handshake: Handshake) { + let nonza = Element::from(handshake); let send = stream.send(Packet::Stanza(nonza)); self.state = ComponentAuthState::WaitSend(send); diff --git a/src/lib.rs b/src/lib.rs index 7c42c37..222b3c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ extern crate rustc_serialize as serialize; extern crate jid; extern crate domain; extern crate idna; -extern crate sha1; +extern crate xmpp_parsers; pub mod xmpp_codec; pub mod xmpp_stream;