Skip to content
Open
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
114 changes: 21 additions & 93 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "GPL-3.0"
[dependencies]
cbor-codec = ">= 0.7.0"
hkdf = { git = "https://github.com/wireapp/hkdf", tag = "v0.3.2"}
sodiumoxide = { version = "^0.2.5", default-features = false, features = ["std"] }
sodiumoxide = { version = "^0.2.7", default-features = false, features = ["std"] }

[dev-dependencies]
criterion = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions src/internal/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ pub struct Signature {
impl Signature {
pub fn encode<W: Write>(&self, e: &mut Encoder<W>) -> EncodeResult<()> {
e.object(1)?;
e.u8(0).and(e.bytes(&self.sig.0))?;
e.u8(0).and(e.bytes(&self.sig.to_bytes()))?;
Ok(())
}

Expand All @@ -567,7 +567,7 @@ impl Signature {
0 => uniq!(
"Signature::sig",
sig,
Bytes64::decode(d).map(|v| sign::Signature(v.array))?
Bytes64::decode(d).map(|v| sign::Signature::from_bytes(&v.array))??
),
_ => d.skip()?,
}
Expand Down
8 changes: 8 additions & 0 deletions src/internal/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub type DecodeResult<A> = Result<A, DecodeError>;
#[derive(Debug)]
pub enum DecodeError {
Decoder(cbor::DecodeError),
SodiumoxideDecoder(sodiumoxide::crypto::sign::Error),
InvalidArrayLen(usize),
LocalIdentityChanged(IdentityKey),
InvalidType(u8, &'static str),
Expand All @@ -102,6 +103,7 @@ impl fmt::Display for DecodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
DecodeError::Decoder(ref e) => write!(f, "CBOR decoder error: {}", e),
DecodeError::SodiumoxideDecoder(ref e) => write!(f, "Sodiumoxide decoder error: {}", e),
DecodeError::InvalidArrayLen(n) => write!(f, "CBOR array length mismatch: {}", n),
DecodeError::LocalIdentityChanged(_) => write!(f, "Local identity changed"),
DecodeError::InvalidType(t, ref s) => write!(f, "Invalid type {}: {}", t, s),
Expand Down Expand Up @@ -130,3 +132,9 @@ impl From<cbor::DecodeError> for DecodeError {
DecodeError::Decoder(err)
}
}

impl From<sodiumoxide::crypto::sign::Error> for DecodeError {
fn from(err: sodiumoxide::crypto::sign::Error) -> DecodeError {
DecodeError::SodiumoxideDecoder(err)
}
}