replace sha-1 with xmpp-parsers for component handshake

This commit is contained in:
Emmanuel Gil Peyrot 2018-08-01 01:07:10 +02:00
parent 7baced0c3f
commit 2e746f89e2
3 changed files with 5 additions and 12 deletions

View file

@ -27,5 +27,4 @@ domain = "0.2"
xmpp-parsers = "0.10" xmpp-parsers = "0.10"
idna = "0.1" idna = "0.1"
try_from = "0.2" try_from = "0.2"
sha-1 = "0.7"
quick-xml = "0.12" quick-xml = "0.12"

View file

@ -2,7 +2,7 @@ use std::mem::replace;
use futures::{Future, Poll, Async, sink, Sink, Stream}; use futures::{Future, Poll, Async, sink, Sink, Stream};
use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::{AsyncRead, AsyncWrite};
use minidom::Element; use minidom::Element;
use sha1::{Sha1, Digest}; use xmpp_parsers::component::Handshake;
use xmpp_codec::Packet; use xmpp_codec::Packet;
use xmpp_stream::XMPPStream; use xmpp_stream::XMPPStream;
@ -28,19 +28,13 @@ impl<S: AsyncWrite> ComponentAuth<S> {
}; };
this.send( this.send(
stream, stream,
"handshake", Handshake::from_password_and_stream_id(&password, &sid)
// TODO: sha1(sid + password)
&format!("{:x}", Sha1::digest((sid + &password).as_bytes()))
); );
return Ok(this); return Ok(this);
} }
fn send(&mut self, stream: XMPPStream<S>, nonza_name: &str, handshake: &str) { fn send(&mut self, stream: XMPPStream<S>, handshake: Handshake) {
let nonza = Element::builder(nonza_name) let nonza = Element::from(handshake);
.ns(NS_JABBER_COMPONENT_ACCEPT)
.append(handshake)
.build();
let send = stream.send(Packet::Stanza(nonza)); let send = stream.send(Packet::Stanza(nonza));
self.state = ComponentAuthState::WaitSend(send); self.state = ComponentAuthState::WaitSend(send);

View file

@ -14,7 +14,7 @@ extern crate rustc_serialize as serialize;
extern crate jid; extern crate jid;
extern crate domain; extern crate domain;
extern crate idna; extern crate idna;
extern crate sha1; extern crate xmpp_parsers;
pub mod xmpp_codec; pub mod xmpp_codec;
pub mod xmpp_stream; pub mod xmpp_stream;