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

Add support for new dehydrated device format #199

Merged
merged 1 commit into from
Jan 17, 2025
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ arrayvec = { version = "0.7.6", features = ["serde"] }
base64 = "0.22.1"
base64ct = { version = "1.6.0", features = ["std", "alloc"] }
cbc = { version = "0.1.2", features = ["std"] }
chacha20poly1305 = "0.10.1"
chacha20poly1305 = { version = "0.10.1", features = ["std"] }
curve25519-dalek = { version = "4.1.3", default-features = false, features = ["zeroize"] }
ed25519-dalek = { version = "2.1.1", default-features = false, features = ["rand_core", "std", "serde", "hazmat", "zeroize"] }
getrandom = "0.2.15"
Expand Down
15 changes: 15 additions & 0 deletions afl/rehydrate-device/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "rehydrate-device"
version = "0.1.0"
publish = false
edition = "2021"

[dependencies]
afl = "*"

[dependencies.vodozemac]
path = "../.."

# Prevent this from interfering with workspaces
[workspace]
members = ["."]
Binary file added afl/rehydrate-device/in/dehydrated1
Binary file not shown.
Binary file added afl/rehydrate-device/in/dehydrated2
Binary file not shown.
2 changes: 2 additions & 0 deletions afl/rehydrate-device/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"
8 changes: 8 additions & 0 deletions afl/rehydrate-device/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use afl::fuzz;
use vodozemac::olm::Account;

fn main() {
fuzz!(|data: &[u8]| {
let _ = Account::from_decrypted_dehydrated_device(data);
});
}
25 changes: 24 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ pub enum PickleError {

/// Error type describing the various ways libolm pickles can fail to be
/// decoded.
#[cfg(feature = "libolm-compat")]
#[derive(Debug, thiserror::Error)]
pub enum LibolmPickleError {
/// The pickle is missing a valid version.
Expand Down Expand Up @@ -262,6 +261,30 @@ pub enum LibolmPickleError {
Encode(#[from] matrix_pickle::EncodeError),
}

/// Error type describing the various ways dehydrated devices can fail to be
/// decoded.
#[derive(Debug, thiserror::Error)]
pub enum DehydratedDeviceError {
/// The pickle is missing a valid version.
#[error("The pickle doesn't contain a version")]
MissingVersion,
/// The pickle has a unsupported version.
#[error("The pickle uses an unsupported version, expected {0}, got {1}")]
Version(u32, u32),
/// Invalid nonce.
#[error("The nonce was invalid")]
InvalidNonce,
/// The pickle wasn't valid base64.
#[error("The pickle wasn't valid base64: {0}")]
Base64(#[from] Base64DecodeError),
/// The pickle could not have been decrypted.
#[error("The pickle couldn't be decrypted: {0}")]
Decryption(#[from] chacha20poly1305::aead::Error),
/// There was an error with the libolm pickle format
#[error(transparent)]
LibolmPickle(#[from] LibolmPickleError),
}

/// Error type describing the different ways message decoding can fail.
#[derive(Debug, thiserror::Error)]
pub enum DecodeError {
Expand Down
Loading
Loading