From cd894c27e0b0d5746b95b9c2933da3ba6e9a3f5b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 5 Apr 2020 02:17:25 -0400 Subject: basic implementation of the cryptographic stuff --- src/error.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/error.rs (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..8ebbfcd --- /dev/null +++ b/src/error.rs @@ -0,0 +1,43 @@ +#[derive(Debug, snafu::Snafu)] +#[snafu(visibility = "pub")] +pub enum Error { + #[snafu(display("failed to create block mode decryptor: {}", source))] + CreateBlockMode { + source: block_modes::InvalidKeyIvLength, + }, + + #[snafu(display("failed to decrypt: {}", source))] + Decrypt { source: block_modes::BlockModeError }, + + // no Error impl + // #[snafu(display("failed to expand with hkdf: {}", source))] + // HkdfExpand { source: hkdf::InvalidLength }, + #[snafu(display("failed to expand with hkdf"))] + HkdfExpand, + + // no Error impl + // #[snafu(display("failed to create hkdf: {}", source))] + // HkdfFromPrk { source: hkdf::InvalidPrkLength }, + #[snafu(display("failed to create hkdf"))] + HkdfFromPrk, + + #[snafu(display("invalid base64: {}", source))] + InvalidBase64 { source: base64::DecodeError }, + + #[snafu(display("invalid cipherstring"))] + InvalidCipherString, + + #[snafu(display("invalid mac"))] + InvalidMac, + + // no Error impl + // #[snafu(display("invalid mac key: {}", source))] + // InvalidMacKey { source: hmac::crypto_mac::InvalidKeyLength }, + #[snafu(display("invalid mac key"))] + InvalidMacKey, + + #[snafu(display("error making api request: {}", source))] + Reqwest { source: reqwest::Error }, +} + +pub type Result = std::result::Result; -- cgit v1.2.3-54-g00ecf