aboutsummaryrefslogtreecommitdiffstats
path: root/src/error.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-04-05 02:17:25 -0400
committerJesse Luehrs <doy@tozt.net>2020-04-05 02:17:25 -0400
commitcd894c27e0b0d5746b95b9c2933da3ba6e9a3f5b (patch)
tree94de4da0e8ac1cea7a855f8fb1d16d6f320e7e72 /src/error.rs
parent070315ce5f80e82fcb5f39c15cd7bbf1682fdf8b (diff)
downloadrbw-cd894c27e0b0d5746b95b9c2933da3ba6e9a3f5b.tar.gz
rbw-cd894c27e0b0d5746b95b9c2933da3ba6e9a3f5b.zip
basic implementation of the cryptographic stuff
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs43
1 files changed, 43 insertions, 0 deletions
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<T> = std::result::Result<T, Error>;