Skip to content

Commit 59b9bce

Browse files
committed
fix: establish sodiumoxide 0.2.7 compatibility
1 parent 8c952ce commit 59b9bce

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/internal/keys.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ pub struct Signature {
555555
impl Signature {
556556
pub fn encode<W: Write>(&self, e: &mut Encoder<W>) -> EncodeResult<()> {
557557
e.object(1)?;
558-
e.u8(0).and(e.bytes(&self.sig.0))?;
558+
e.u8(0).and(e.bytes(&self.sig.to_bytes()))?;
559559
Ok(())
560560
}
561561

@@ -567,7 +567,7 @@ impl Signature {
567567
0 => uniq!(
568568
"Signature::sig",
569569
sig,
570-
Bytes64::decode(d).map(|v| sign::Signature(v.array))?
570+
Bytes64::decode(d).map(|v| sign::Signature::from_bytes(&v.array))??
571571
),
572572
_ => d.skip()?,
573573
}

src/internal/types.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pub type DecodeResult<A> = Result<A, DecodeError>;
9090
#[derive(Debug)]
9191
pub enum DecodeError {
9292
Decoder(cbor::DecodeError),
93+
SodiumoxideDecoder(sodiumoxide::crypto::sign::Error),
9394
InvalidArrayLen(usize),
9495
LocalIdentityChanged(IdentityKey),
9596
InvalidType(u8, &'static str),
@@ -102,6 +103,7 @@ impl fmt::Display for DecodeError {
102103
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
103104
match *self {
104105
DecodeError::Decoder(ref e) => write!(f, "CBOR decoder error: {}", e),
106+
DecodeError::SodiumoxideDecoder(ref e) => write!(f, "Sodiumoxide decoder error: {}", e),
105107
DecodeError::InvalidArrayLen(n) => write!(f, "CBOR array length mismatch: {}", n),
106108
DecodeError::LocalIdentityChanged(_) => write!(f, "Local identity changed"),
107109
DecodeError::InvalidType(t, ref s) => write!(f, "Invalid type {}: {}", t, s),
@@ -130,3 +132,9 @@ impl From<cbor::DecodeError> for DecodeError {
130132
DecodeError::Decoder(err)
131133
}
132134
}
135+
136+
impl From<sodiumoxide::crypto::sign::Error> for DecodeError {
137+
fn from(err: sodiumoxide::crypto::sign::Error) -> DecodeError {
138+
DecodeError::SodiumoxideDecoder(err)
139+
}
140+
}

0 commit comments

Comments
 (0)