mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
parent
0cf11dae5c
commit
e276d39704
7 changed files with 52 additions and 51 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -398,7 +398,6 @@ dependencies = [
|
||||||
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"protobuf_macros 0.6.0 (git+https://github.com/plietar/rust-protobuf-macros)",
|
|
||||||
"rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rpassword 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rpassword 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rust-crypto 0.2.36 (git+https://github.com/awmath/rust-crypto.git?branch=avx2)",
|
"rust-crypto 0.2.36 (git+https://github.com/awmath/rust-crypto.git?branch=avx2)",
|
||||||
|
|
|
@ -32,6 +32,5 @@ tokio-io = "0.1"
|
||||||
uuid = { version = "0.4", features = ["v4"] }
|
uuid = { version = "0.4", features = ["v4"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
protobuf_macros = { git = "https://github.com/plietar/rust-protobuf-macros", features = ["with-syntex"] }
|
|
||||||
rand = "0.3.13"
|
rand = "0.3.13"
|
||||||
vergen = "0.1.0"
|
vergen = "0.1.0"
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
extern crate protobuf_macros;
|
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate vergen;
|
extern crate vergen;
|
||||||
|
|
||||||
|
@ -34,11 +33,4 @@ pub fn build_id() -> &'static str {{
|
||||||
if let Err(e) = version_file.write_all(build_id_fn.as_bytes()) {
|
if let Err(e) = version_file.write_all(build_id_fn.as_bytes()) {
|
||||||
println!("{}", e);
|
println!("{}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protobuf_macros::expand("src/lib.in.rs", &out.join("lib.rs")).unwrap();
|
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed=src/lib.in.rs");
|
|
||||||
println!("cargo:rerun-if-changed=src/connection/mod.rs");
|
|
||||||
println!("cargo:rerun-if-changed=src/connection/codec.rs");
|
|
||||||
println!("cargo:rerun-if-changed=src/connection/handshake.rs");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,22 +82,27 @@ impl<T: AsyncRead + AsyncWrite> Future for Handshake<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn client_hello<T: AsyncWrite>(connection: T, gc: Vec<u8>) -> WriteAll<T, Vec<u8>> {
|
fn client_hello<T: AsyncWrite>(connection: T, gc: Vec<u8>) -> WriteAll<T, Vec<u8>> {
|
||||||
let packet = protobuf_init!(ClientHello::new(), {
|
let mut packet = ClientHello::new();
|
||||||
build_info => {
|
packet
|
||||||
product: protocol::keyexchange::Product::PRODUCT_PARTNER,
|
.mut_build_info()
|
||||||
platform: protocol::keyexchange::Platform::PLATFORM_LINUX_X86,
|
.set_product(protocol::keyexchange::Product::PRODUCT_PARTNER);
|
||||||
version: 0x10800000000,
|
packet
|
||||||
},
|
.mut_build_info()
|
||||||
cryptosuites_supported => [
|
.set_platform(protocol::keyexchange::Platform::PLATFORM_LINUX_X86);
|
||||||
protocol::keyexchange::Cryptosuite::CRYPTO_SUITE_SHANNON,
|
packet.mut_build_info().set_version(0x10800000000);
|
||||||
],
|
packet
|
||||||
login_crypto_hello.diffie_hellman => {
|
.mut_cryptosuites_supported()
|
||||||
gc: gc,
|
.push(protocol::keyexchange::Cryptosuite::CRYPTO_SUITE_SHANNON);
|
||||||
server_keys_known: 1,
|
packet
|
||||||
},
|
.mut_login_crypto_hello()
|
||||||
client_nonce: util::rand_vec(&mut thread_rng(), 0x10),
|
.mut_diffie_hellman()
|
||||||
padding: vec![0x1e],
|
.set_gc(gc);
|
||||||
});
|
packet
|
||||||
|
.mut_login_crypto_hello()
|
||||||
|
.mut_diffie_hellman()
|
||||||
|
.set_server_keys_known(1);
|
||||||
|
packet.set_client_nonce(util::rand_vec(&mut thread_rng(), 0x10));
|
||||||
|
packet.set_padding(vec![0x1e]);
|
||||||
|
|
||||||
let mut buffer = vec![0, 4];
|
let mut buffer = vec![0, 4];
|
||||||
let size = 2 + 4 + packet.compute_size();
|
let size = 2 + 4 + packet.compute_size();
|
||||||
|
@ -108,13 +113,13 @@ fn client_hello<T: AsyncWrite>(connection: T, gc: Vec<u8>) -> WriteAll<T, Vec<u8
|
||||||
}
|
}
|
||||||
|
|
||||||
fn client_response<T: AsyncWrite>(connection: T, challenge: Vec<u8>) -> WriteAll<T, Vec<u8>> {
|
fn client_response<T: AsyncWrite>(connection: T, challenge: Vec<u8>) -> WriteAll<T, Vec<u8>> {
|
||||||
let packet = protobuf_init!(ClientResponsePlaintext::new(), {
|
let mut packet = ClientResponsePlaintext::new();
|
||||||
login_crypto_response.diffie_hellman => {
|
packet
|
||||||
hmac: challenge
|
.mut_login_crypto_response()
|
||||||
},
|
.mut_diffie_hellman()
|
||||||
pow_response => {},
|
.set_hmac(challenge);
|
||||||
crypto_response => {},
|
packet.mut_pow_response();
|
||||||
});
|
packet.mut_crypto_response();
|
||||||
|
|
||||||
let mut buffer = vec![];
|
let mut buffer = vec![];
|
||||||
let size = 4 + packet.compute_size();
|
let size = 4 + packet.compute_size();
|
||||||
|
|
|
@ -35,20 +35,29 @@ pub fn authenticate(
|
||||||
) -> Box<Future<Item = (Transport, Credentials), Error = io::Error>> {
|
) -> Box<Future<Item = (Transport, Credentials), Error = io::Error>> {
|
||||||
use protocol::authentication::{APWelcome, ClientResponseEncrypted, CpuFamily, Os};
|
use protocol::authentication::{APWelcome, ClientResponseEncrypted, CpuFamily, Os};
|
||||||
|
|
||||||
let packet = protobuf_init!(ClientResponseEncrypted::new(), {
|
let mut packet = ClientResponseEncrypted::new();
|
||||||
login_credentials => {
|
packet
|
||||||
username: credentials.username,
|
.mut_login_credentials()
|
||||||
typ: credentials.auth_type,
|
.set_username(credentials.username);
|
||||||
auth_data: credentials.auth_data,
|
packet
|
||||||
},
|
.mut_login_credentials()
|
||||||
system_info => {
|
.set_typ(credentials.auth_type);
|
||||||
cpu_family: CpuFamily::CPU_UNKNOWN,
|
packet
|
||||||
os: Os::OS_UNKNOWN,
|
.mut_login_credentials()
|
||||||
system_information_string: format!("librespot_{}_{}", version::short_sha(), version::build_id()),
|
.set_auth_data(credentials.auth_data);
|
||||||
device_id: device_id,
|
packet
|
||||||
},
|
.mut_system_info()
|
||||||
version_string: version::version_string(),
|
.set_cpu_family(CpuFamily::CPU_UNKNOWN);
|
||||||
});
|
packet.mut_system_info().set_os(Os::OS_UNKNOWN);
|
||||||
|
packet
|
||||||
|
.mut_system_info()
|
||||||
|
.set_system_information_string(format!(
|
||||||
|
"librespot_{}_{}",
|
||||||
|
version::short_sha(),
|
||||||
|
version::build_id()
|
||||||
|
));
|
||||||
|
packet.mut_system_info().set_device_id(device_id);
|
||||||
|
packet.set_version_string(version::version_string());
|
||||||
|
|
||||||
let cmd = 0xab;
|
let cmd = 0xab;
|
||||||
let data = packet.write_to_bytes().unwrap();
|
let data = packet.write_to_bytes().unwrap();
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#[allow(unused_mut)]
|
|
||||||
mod connection;
|
|
|
@ -39,11 +39,10 @@ pub mod authentication;
|
||||||
pub mod cache;
|
pub mod cache;
|
||||||
pub mod channel;
|
pub mod channel;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
mod connection;
|
||||||
pub mod diffie_hellman;
|
pub mod diffie_hellman;
|
||||||
pub mod keymaster;
|
pub mod keymaster;
|
||||||
pub mod mercury;
|
pub mod mercury;
|
||||||
pub mod session;
|
pub mod session;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
pub mod version;
|
pub mod version;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/lib.rs"));
|
|
||||||
|
|
Loading…
Reference in a new issue