Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to bcder 0.5 and bytes 0.5. #99

Merged
merged 4 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions src/cert/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down Expand Up @@ -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)}
}
Expand Down
4 changes: 2 additions & 2 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -211,7 +211,7 @@ impl ManifestContent {
this_update,
next_update,
file_hash_alg,
file_list,
file_list: file_list.freeze(),
len
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/sigobj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -356,7 +356,7 @@ impl SignedAttrs {
}
}

SignedAttrs(res)
SignedAttrs(res.freeze())
}

/// Takes the signed attributes from the beginning of a constructed value.
Expand Down Expand Up @@ -545,7 +545,7 @@ impl MessageDigest {

impl From<Digest> for MessageDigest {
fn from(digest: Digest) -> Self {
MessageDigest(Bytes::from(digest.as_ref()))
MessageDigest(Bytes::copy_from_slice(digest.as_ref()))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/tal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl TalUri {
}

pub fn from_slice(slice: &[u8]) -> Result<Self, uri::Error> {
Self::from_bytes(slice.into())
Self::from_bytes(Bytes::copy_from_slice(slice))
}

pub fn from_bytes(bytes: Bytes) -> Result<Self, uri::Error> {
Expand Down Expand Up @@ -188,7 +188,7 @@ impl str::FromStr for TalUri {
type Err = uri::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::from_bytes(Bytes::from(s))
Self::from_bytes(Bytes::copy_from_slice(s.as_ref()))
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -43,7 +43,7 @@ impl Rsync {
}

pub fn from_slice(slice: &[u8]) -> Result<Self, Error> {
Self::from_bytes(slice.into())
Self::from_bytes(Bytes::copy_from_slice(slice))
}

pub fn from_bytes(mut bytes: Bytes) -> Result<Self, Error> {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -205,7 +205,7 @@ impl str::FromStr for Rsync {
type Err = Error;

fn from_str(s: &str) -> Result<Self, Error> {
Self::from_bytes(Bytes::from(s))
Self::from_bytes(Bytes::copy_from_slice(s.as_ref()))
}
}

Expand Down Expand Up @@ -366,7 +366,7 @@ impl Https {
}

pub fn from_slice(slice: &[u8]) -> Result<Self, Error> {
Self::from_bytes(slice.into())
Self::from_bytes(Bytes::copy_from_slice(slice))
}

pub fn from_bytes(bytes: Bytes) -> Result<Self, Error> {
Expand Down Expand Up @@ -457,7 +457,7 @@ impl str::FromStr for Https {
type Err = Error;

fn from_str(s: &str) -> Result<Self, Error> {
Self::from_bytes(Bytes::from(s))
Self::from_bytes(Bytes::copy_from_slice(s.as_ref()))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/xml/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down