diff --git a/Cargo.toml b/Cargo.toml index edf21fa7..42d0644e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,17 +13,17 @@ license = "BSD-3-Clause" [dependencies] base64 = "^0.10.1" -bcder = "^0.4.0" -bytes = "^0.4.12" -chrono = { version = "^0.4.7", features = [ "serde" ] } +bcder = "^0.5.0" +bytes = "^0.5" +chrono = { version = "^0.4.10", features = [ "serde" ] } derive_more = "^0.15.0" log = "^0.4.7" openssl = { version = "^0.10.23", optional = true } -quick-xml = "^0.16.1" +quick-xml = "^0.17.2" ring = "0.16.11" serde = { version = "^1.0.95", features = [ "derive" ] } -slab = { version = "^0.4.2", optional = true } -uuid = "^0.7.4" +slab = { version = "^0.4.1", optional = true } +uuid = "^0.8.1" untrusted = "0.7.0" unwrap = "^1.2.1" diff --git a/Changelog.md b/Changelog.md index bf076f15..983cd336 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,8 +16,11 @@ Bug Fixes Dependencies +* Upgrade to bytes 0.5 and bcder 0.5. ([#99]) + [#95]: https://github.com/NLnetLabs/rpki-rs/pull/95 [#96]: https://github.com/NLnetLabs/rpki-rs/pull/96 +[#99]: https://github.com/NLnetLabs/rpki-rs/pull/99 [@dadepo]: https://github.com/dadepo diff --git a/src/cert/ext.rs b/src/cert/ext.rs index 948ce7a4..7ed50b96 100644 --- a/src/cert/ext.rs +++ b/src/cert/ext.rs @@ -535,7 +535,7 @@ pub struct KeyIdentifier(OctetString); impl KeyIdentifier { pub fn new(key_info: &PublicKey) -> Self { let ki = key_info.key_identifier(); - let b = Bytes::from(ki.as_ref()); + let b = Bytes::copy_from_slice(ki.as_ref()); KeyIdentifier(OctetString::new(b)) } @@ -647,7 +647,7 @@ pub struct AuthorityKeyIdentifier { impl AuthorityKeyIdentifier { pub fn new(key_info: &PublicKey) -> Self { let ki = key_info.key_identifier(); - let b = Bytes::from(ki.as_ref()); + let b = Bytes::copy_from_slice(ki.as_ref()); Self{authority_key_id: OctetString::new(b)} } diff --git a/src/manifest.rs b/src/manifest.rs index a39fce4d..7e5a2438 100644 --- a/src/manifest.rs +++ b/src/manifest.rs @@ -201,7 +201,7 @@ impl ManifestContent { H: AsRef<[u8]>, { let mut len = 0; - let mut file_list = Captured::empty(Mode::Der); + let mut file_list = Captured::builder(Mode::Der); for item in iter.into_iter() { file_list.extend(item.as_ref().encode_ref()); len += 1; @@ -211,7 +211,7 @@ impl ManifestContent { this_update, next_update, file_hash_alg, - file_list, + file_list: file_list.freeze(), len } } diff --git a/src/sigobj.rs b/src/sigobj.rs index 94d03e82..b38de502 100644 --- a/src/sigobj.rs +++ b/src/sigobj.rs @@ -329,7 +329,7 @@ impl SignedAttrs { ]; len.sort_by_key(|&(_, len)| len.unwrap()); - let mut res = Captured::empty(Mode::Der); + let mut res = Captured::builder(Mode::Der); for &(idx, _) in &len { match idx { 0 => { @@ -356,7 +356,7 @@ impl SignedAttrs { } } - SignedAttrs(res) + SignedAttrs(res.freeze()) } /// Takes the signed attributes from the beginning of a constructed value. @@ -545,7 +545,7 @@ impl MessageDigest { impl From for MessageDigest { fn from(digest: Digest) -> Self { - MessageDigest(Bytes::from(digest.as_ref())) + MessageDigest(Bytes::copy_from_slice(digest.as_ref())) } } diff --git a/src/tal.rs b/src/tal.rs index ef0b6529..3cfccdd7 100644 --- a/src/tal.rs +++ b/src/tal.rs @@ -148,7 +148,7 @@ impl TalUri { } pub fn from_slice(slice: &[u8]) -> Result { - Self::from_bytes(slice.into()) + Self::from_bytes(Bytes::copy_from_slice(slice)) } pub fn from_bytes(bytes: Bytes) -> Result { @@ -188,7 +188,7 @@ impl str::FromStr for TalUri { type Err = uri::Error; fn from_str(s: &str) -> Result { - Self::from_bytes(Bytes::from(s)) + Self::from_bytes(Bytes::copy_from_slice(s.as_ref())) } } diff --git a/src/uri.rs b/src/uri.rs index 11a9211b..a959814c 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -6,7 +6,7 @@ use std::str::FromStr; use bcder::encode; use bcder::{Mode, Tag}; use bcder::encode::PrimitiveContent; -use bytes::{BufMut, Bytes, BytesMut}; +use bytes::{Buf, BufMut, Bytes, BytesMut}; use derive_more::Display; use serde::de; use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -43,7 +43,7 @@ impl Rsync { } pub fn from_slice(slice: &[u8]) -> Result { - Self::from_bytes(slice.into()) + Self::from_bytes(Bytes::copy_from_slice(slice)) } pub fn from_bytes(mut bytes: Bytes) -> Result { @@ -131,7 +131,7 @@ impl Rsync { } else { res.path = self.path.slice( - 0, self.path.len() - tail - 1 + 0..self.path.len() - tail - 1 ); } Some(res) @@ -205,7 +205,7 @@ impl str::FromStr for Rsync { type Err = Error; fn from_str(s: &str) -> Result { - Self::from_bytes(Bytes::from(s)) + Self::from_bytes(Bytes::copy_from_slice(s.as_ref())) } } @@ -366,7 +366,7 @@ impl Https { } pub fn from_slice(slice: &[u8]) -> Result { - Self::from_bytes(slice.into()) + Self::from_bytes(Bytes::copy_from_slice(slice)) } pub fn from_bytes(bytes: Bytes) -> Result { @@ -457,7 +457,7 @@ impl str::FromStr for Https { type Err = Error; fn from_str(s: &str) -> Result { - Self::from_bytes(Bytes::from(s)) + Self::from_bytes(Bytes::copy_from_slice(s.as_ref())) } } diff --git a/src/xml/decode.rs b/src/xml/decode.rs index ccbe8df8..99a5d71e 100644 --- a/src/xml/decode.rs +++ b/src/xml/decode.rs @@ -300,7 +300,7 @@ impl<'a> AttrValue<'a> { if !s.is_ascii() { return Err(Error::Malformed) } - Ok(Bytes::from(unsafe { str::from_utf8_unchecked(s.as_ref()) })) + Ok(s.into_owned().into()) } }