Compare commits
2 Commits
0488ef274d
...
9711754ff3
Author | SHA1 | Date | |
---|---|---|---|
9711754ff3 | |||
240dfcc091 |
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1318,9 +1318,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tower-http"
|
||||
version = "0.6.5"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cc2d9e086a412a451384326f521c8123a99a466b329941a9403696bff9b0da2"
|
||||
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bytes",
|
||||
|
@ -1,12 +1,10 @@
|
||||
use std::error::Error;
|
||||
use std::io::ErrorKind;
|
||||
|
||||
use aes_gcm::aead::{Aead, OsRng};
|
||||
use aes_gcm::{Aes256Gcm, Key, KeyInit, Nonce};
|
||||
use base64::engine::general_purpose::STANDARD as BASE64_STANDARD;
|
||||
use base64::Engine as _;
|
||||
use bincode::{Decode, Encode};
|
||||
use rand::Rng;
|
||||
use std::error::Error;
|
||||
|
||||
/// The lenght of the nonce used to initialize encryption
|
||||
const NONCE_LEN: usize = 12;
|
||||
@ -45,8 +43,7 @@ impl CryptoWrapper {
|
||||
let bytes = BASE64_STANDARD.decode(input)?;
|
||||
|
||||
if bytes.len() < NONCE_LEN {
|
||||
return Err(Box::new(std::io::Error::new(
|
||||
ErrorKind::Other,
|
||||
return Err(Box::new(std::io::Error::other(
|
||||
"Input string is smaller than nonce!",
|
||||
)));
|
||||
}
|
||||
@ -60,8 +57,7 @@ impl CryptoWrapper {
|
||||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
log::error!("Failed to decrypt wrapped data! {:#?}", e);
|
||||
return Err(Box::new(std::io::Error::new(
|
||||
ErrorKind::Other,
|
||||
return Err(Box::new(std::io::Error::other(
|
||||
"Failed to decrypt wrapped data!",
|
||||
)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user