Compare commits
3 Commits
581babb22b
...
master
Author | SHA1 | Date | |
---|---|---|---|
c394d29fee | |||
9711754ff3 | |||
240dfcc091 |
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -943,9 +943,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.12.16"
|
version = "0.12.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2bf597b113be201cb2269b4c39b39a804d01b99ee95a4278f0ed04e45cff1c71"
|
checksum = "eabf4c97d9130e2bf606614eb937e86edac8292eaa6f422f995d7e8de1eb1813"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bytes",
|
"bytes",
|
||||||
@ -959,12 +959,10 @@ dependencies = [
|
|||||||
"hyper-rustls",
|
"hyper-rustls",
|
||||||
"hyper-tls",
|
"hyper-tls",
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
"ipnet",
|
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"log",
|
"log",
|
||||||
"mime",
|
"mime",
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"once_cell",
|
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
@ -1318,9 +1316,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower-http"
|
name = "tower-http"
|
||||||
version = "0.6.4"
|
version = "0.6.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fdb0c213ca27a9f57ab69ddb290fd80d970922355b83ae380b395d3986b8a2e"
|
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
use std::error::Error;
|
|
||||||
use std::io::ErrorKind;
|
|
||||||
|
|
||||||
use aes_gcm::aead::{Aead, OsRng};
|
use aes_gcm::aead::{Aead, OsRng};
|
||||||
use aes_gcm::{Aes256Gcm, Key, KeyInit, Nonce};
|
use aes_gcm::{Aes256Gcm, Key, KeyInit, Nonce};
|
||||||
use base64::engine::general_purpose::STANDARD as BASE64_STANDARD;
|
use base64::engine::general_purpose::STANDARD as BASE64_STANDARD;
|
||||||
use base64::Engine as _;
|
use base64::Engine as _;
|
||||||
use bincode::{Decode, Encode};
|
use bincode::{Decode, Encode};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
/// The lenght of the nonce used to initialize encryption
|
/// The lenght of the nonce used to initialize encryption
|
||||||
const NONCE_LEN: usize = 12;
|
const NONCE_LEN: usize = 12;
|
||||||
@ -45,8 +43,7 @@ impl CryptoWrapper {
|
|||||||
let bytes = BASE64_STANDARD.decode(input)?;
|
let bytes = BASE64_STANDARD.decode(input)?;
|
||||||
|
|
||||||
if bytes.len() < NONCE_LEN {
|
if bytes.len() < NONCE_LEN {
|
||||||
return Err(Box::new(std::io::Error::new(
|
return Err(Box::new(std::io::Error::other(
|
||||||
ErrorKind::Other,
|
|
||||||
"Input string is smaller than nonce!",
|
"Input string is smaller than nonce!",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@ -60,8 +57,7 @@ impl CryptoWrapper {
|
|||||||
Ok(d) => d,
|
Ok(d) => d,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to decrypt wrapped data! {:#?}", e);
|
log::error!("Failed to decrypt wrapped data! {:#?}", e);
|
||||||
return Err(Box::new(std::io::Error::new(
|
return Err(Box::new(std::io::Error::other(
|
||||||
ErrorKind::Other,
|
|
||||||
"Failed to decrypt wrapped data!",
|
"Failed to decrypt wrapped data!",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user