From 34733baa75559bcb2d95496a746cc03506130bf4 Mon Sep 17 00:00:00 2001 From: johannesd3 Date: Sat, 13 Feb 2021 19:10:34 +0100 Subject: [PATCH] Bump crypto crates --- Cargo.lock | 189 +++++++++++++++++-------------- audio/Cargo.toml | 2 +- audio/src/decrypt.rs | 4 +- connect/Cargo.toml | 8 +- connect/src/discovery.rs | 16 +-- core/Cargo.toml | 8 +- core/src/authentication.rs | 6 +- core/src/connection/handshake.rs | 12 +- 8 files changed, 131 insertions(+), 114 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68c3440a..32762686 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,47 +23,45 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "aes" -version = "0.3.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" +checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" dependencies = [ "aes-soft", "aesni", - "block-cipher-trait", + "cipher", ] [[package]] name = "aes-ctr" -version = "0.3.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" +checksum = "7729c3cde54d67063be556aeac75a81330d802f0259500ca40cb52967f975763" dependencies = [ "aes-soft", "aesni", + "cipher", "ctr", - "stream-cipher", ] [[package]] name = "aes-soft" -version = "0.3.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" dependencies = [ - "block-cipher-trait", - "byteorder", - "opaque-debug", + "cipher", + "opaque-debug 0.3.0", ] [[package]] name = "aesni" -version = "0.6.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" dependencies = [ - "block-cipher-trait", - "opaque-debug", - "stream-cipher", + "cipher", + "opaque-debug 0.3.0", ] [[package]] @@ -199,29 +197,29 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding", + "block-padding 0.1.5", "byte-tools", "byteorder", - "generic-array", + "generic-array 0.12.3", ] [[package]] -name = "block-cipher-trait" -version = "0.6.2" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array", + "generic-array 0.14.4", ] [[package]] name = "block-modes" -version = "0.3.3" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31aa8410095e39fdb732909fb5730a48d5bd7c2e3cd76bd1b07b3dbea130c529" +checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" dependencies = [ - "block-cipher-trait", - "block-padding", + "block-padding 0.2.1", + "cipher", ] [[package]] @@ -233,6 +231,12 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + [[package]] name = "bumpalo" version = "3.6.0" @@ -319,6 +323,15 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e" +[[package]] +name = "cipher" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +dependencies = [ + "generic-array 0.14.4", +] + [[package]] name = "clang-sys" version = "1.0.3" @@ -446,6 +459,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "cpuid-bool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + [[package]] name = "crc32fast" version = "1.2.1" @@ -524,22 +543,21 @@ dependencies = [ [[package]] name = "crypto-mac" -version = "0.7.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" dependencies = [ - "generic-array", + "generic-array 0.14.4", "subtle", ] [[package]] name = "ctr" -version = "0.3.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" +checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" dependencies = [ - "block-cipher-trait", - "stream-cipher", + "cipher", ] [[package]] @@ -594,7 +612,16 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array", + "generic-array 0.12.3", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.4", ] [[package]] @@ -808,6 +835,16 @@ dependencies = [ "typenum", ] +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getopts" version = "0.2.21" @@ -1031,12 +1068,12 @@ checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" [[package]] name = "hmac" -version = "0.7.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", - "digest", + "digest 0.9.0", ] [[package]] @@ -1410,7 +1447,7 @@ dependencies = [ "protobuf", "rand 0.7.3", "rpassword", - "sha-1", + "sha-1 0.8.2", "tokio-core", "tokio-io", "tokio-process", @@ -1459,7 +1496,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha-1", + "sha-1 0.9.3", "tokio-core", "url 1.7.2", ] @@ -1490,7 +1527,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha-1", + "sha-1 0.9.3", "shannon", "tokio-codec", "tokio-core", @@ -1964,6 +2001,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "parking_lot" version = "0.9.0" @@ -2023,17 +2066,12 @@ checksum = "c5d65c4d95931acda4498f675e332fcbdc9a06705cd07086c510e9b6009cd1c1" [[package]] name = "pbkdf2" -version = "0.3.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" +checksum = "309c95c5f738c85920eb7062a2de29f3840d4f96974453fc9ac1ba078da9c627" dependencies = [ - "base64 0.9.3", - "byteorder", "crypto-mac", "hmac", - "rand 0.5.6", - "sha2", - "subtle", ] [[package]] @@ -2244,19 +2282,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.7.3" @@ -2602,10 +2627,23 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" dependencies = [ - "block-buffer", - "digest", + "block-buffer 0.7.3", + "digest 0.8.1", "fake-simd", - "opaque-debug", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha-1" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4b312c3731e3fe78a185e6b9b911a7aa715b8e31cce117975219aab2acf285d" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpuid-bool", + "digest 0.9.0", + "opaque-debug 0.3.0", ] [[package]] @@ -2614,18 +2652,6 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - [[package]] name = "shannon" version = "0.2.0" @@ -2770,15 +2796,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" -[[package]] -name = "stream-cipher" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" -dependencies = [ - "generic-array", -] - [[package]] name = "strsim" version = "0.9.3" @@ -2805,9 +2822,9 @@ dependencies = [ [[package]] name = "subtle" -version = "1.0.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" diff --git a/audio/Cargo.toml b/audio/Cargo.toml index f6d16f61..2dae1a8d 100644 --- a/audio/Cargo.toml +++ b/audio/Cargo.toml @@ -11,6 +11,7 @@ path = "../core" version = "0.1.3" [dependencies] +aes-ctr = "0.6" bit-set = "0.5" byteorder = "1.3" bytes = "0.4" @@ -20,7 +21,6 @@ log = "0.4" num-bigint = "0.3" num-traits = "0.2" tempfile = "3.1" -aes-ctr = "0.3" librespot-tremor = { version = "0.2.0", optional = true } vorbis = { version ="0.0.14", optional = true } diff --git a/audio/src/decrypt.rs b/audio/src/decrypt.rs index 818eb34e..616ef4f6 100644 --- a/audio/src/decrypt.rs +++ b/audio/src/decrypt.rs @@ -1,7 +1,7 @@ use std::io; -use aes_ctr::stream_cipher::generic_array::GenericArray; -use aes_ctr::stream_cipher::{NewStreamCipher, SyncStreamCipher, SyncStreamCipherSeek}; +use aes_ctr::cipher::generic_array::GenericArray; +use aes_ctr::cipher::{NewStreamCipher, SyncStreamCipher, SyncStreamCipherSeek}; use aes_ctr::Aes128Ctr; use librespot_core::audio_key::AudioKey; diff --git a/connect/Cargo.toml b/connect/Cargo.toml index 8235870a..063d9bef 100644 --- a/connect/Cargo.toml +++ b/connect/Cargo.toml @@ -18,8 +18,11 @@ path = "../protocol" version = "0.1.3" [dependencies] +aes-ctr = "0.6" base64 = "0.13" +block-modes = "0.7" futures = "0.1" +hmac = "0.10" hyper = "0.11" log = "0.4" num-bigint = "0.3" @@ -28,12 +31,9 @@ rand = "0.7" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" +sha-1 = "0.9" tokio-core = "0.1" url = "1.7" -sha-1 = "0.8" -hmac = "0.7" -aes-ctr = "0.3" -block-modes = "0.3" dns-sd = { version = "0.1.3", optional = true } libmdns = { version = "0.2.7", optional = true } diff --git a/connect/src/discovery.rs b/connect/src/discovery.rs index b53070d7..d3e3f709 100644 --- a/connect/src/discovery.rs +++ b/connect/src/discovery.rs @@ -1,10 +1,10 @@ -use aes_ctr::stream_cipher::generic_array::GenericArray; -use aes_ctr::stream_cipher::{NewStreamCipher, SyncStreamCipher}; +use aes_ctr::cipher::generic_array::GenericArray; +use aes_ctr::cipher::{NewStreamCipher, SyncStreamCipher}; use aes_ctr::Aes128Ctr; use base64; use futures::sync::mpsc; use futures::{Future, Poll, Stream}; -use hmac::{Hmac, Mac}; +use hmac::{Hmac, Mac, NewMac}; use hyper::server::{Http, Request, Response, Service}; use hyper::{self, Get, Post, StatusCode}; use sha1::{Digest, Sha1}; @@ -118,18 +118,18 @@ impl Discovery { let checksum_key = { let mut h = HmacSha1::new_varkey(base_key).expect("HMAC can take key of any size"); - h.input(b"checksum"); - h.result().code() + h.update(b"checksum"); + h.finalize().into_bytes() }; let encryption_key = { let mut h = HmacSha1::new_varkey(&base_key).expect("HMAC can take key of any size"); - h.input(b"encryption"); - h.result().code() + h.update(b"encryption"); + h.finalize().into_bytes() }; let mut h = HmacSha1::new_varkey(&checksum_key).expect("HMAC can take key of any size"); - h.input(encrypted); + h.update(encrypted); if let Err(_) = h.verify(cksum) { warn!("Login error for user {:?}: MAC mismatch", username); let result = json!({ diff --git a/core/Cargo.toml b/core/Cargo.toml index 8511878c..9b9678cf 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -13,11 +13,13 @@ path = "../protocol" version = "0.1.3" [dependencies] +aes = "0.6" base64 = "0.13" byteorder = "1.3" bytes = "0.4" error-chain = { version = "0.12", default_features = false } futures = "0.1" +hmac = "0.10" httparse = "1.3" hyper = "0.11" hyper-proxy = { version = "0.4", default_features = false } @@ -26,21 +28,19 @@ log = "0.4" num-bigint = "0.3" num-integer = "0.1" num-traits = "0.2" +pbkdf2 = { version = "0.7", default_features = false, features = ["hmac"] } protobuf = "~2.14.0" rand = "0.7" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" +sha-1 = "0.9" shannon = "0.2.0" tokio-codec = "0.1" tokio-core = "0.1" tokio-io = "0.1" url = "1.7" uuid = { version = "0.8", features = ["v4"] } -sha-1 = "0.8" -hmac = "0.7" -pbkdf2 = "0.3" -aes = "0.3" [build-dependencies] rand = "0.7" diff --git a/core/src/authentication.rs b/core/src/authentication.rs index b2b4f544..5394ff35 100644 --- a/core/src/authentication.rs +++ b/core/src/authentication.rs @@ -71,9 +71,9 @@ impl Credentials { // decrypt data using ECB mode without padding let blob = { - use aes::block_cipher_trait::generic_array::typenum::Unsigned; - use aes::block_cipher_trait::generic_array::GenericArray; - use aes::block_cipher_trait::BlockCipher; + use aes::cipher::generic_array::typenum::Unsigned; + use aes::cipher::generic_array::GenericArray; + use aes::cipher::{BlockCipher, NewBlockCipher}; let mut data = base64::decode(encrypted_blob).unwrap(); let cipher = Aes192::new(GenericArray::from_slice(&key)); diff --git a/core/src/connection/handshake.rs b/core/src/connection/handshake.rs index 220ab6e8..abd6a169 100644 --- a/core/src/connection/handshake.rs +++ b/core/src/connection/handshake.rs @@ -1,6 +1,6 @@ use byteorder::{BigEndian, ByteOrder, WriteBytesExt}; use futures::{Async, Future, Poll}; -use hmac::{Hmac, Mac}; +use hmac::{Hmac, Mac, NewMac}; use protobuf::{self, Message}; use rand::thread_rng; use sha1::Sha1; @@ -195,16 +195,16 @@ fn compute_keys(shared_secret: &[u8], packets: &[u8]) -> (Vec, Vec, Vec< let mut data = Vec::with_capacity(0x64); for i in 1..6 { let mut mac = HmacSha1::new_varkey(&shared_secret).expect("HMAC can take key of any size"); - mac.input(packets); - mac.input(&[i]); - data.extend_from_slice(&mac.result().code()); + mac.update(packets); + mac.update(&[i]); + data.extend_from_slice(&mac.finalize().into_bytes()); } let mut mac = HmacSha1::new_varkey(&data[..0x14]).expect("HMAC can take key of any size"); - mac.input(packets); + mac.update(packets); ( - mac.result().code().to_vec(), + mac.finalize().into_bytes().to_vec(), data[0x14..0x34].to_vec(), data[0x34..0x54].to_vec(), )