aboutsummaryrefslogtreecommitdiff
path: root/src/cryptoblob.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-05-19 15:14:36 +0200
committerAlex Auvolat <alex@adnab.me>2022-05-19 15:14:36 +0200
commit1dcb11643c783096e1b52bf48d6b76121504e6bd (patch)
tree658f1db34d0e4f91331dabcab85a5898a95d4ad4 /src/cryptoblob.rs
parent6be90936a108d971e0cfa3ddaa9c2d54557e30f3 (diff)
downloadaerogramme-1dcb11643c783096e1b52bf48d6b76121504e6bd.tar.gz
aerogramme-1dcb11643c783096e1b52bf48d6b76121504e6bd.zip
CLI skeleton
Diffstat (limited to 'src/cryptoblob.rs')
-rw-r--r--src/cryptoblob.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/cryptoblob.rs b/src/cryptoblob.rs
index ad05521..5b22ac1 100644
--- a/src/cryptoblob.rs
+++ b/src/cryptoblob.rs
@@ -5,14 +5,16 @@ use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use zstd::stream::{decode_all as zstd_decode, encode_all as zstd_encode};
-use sodiumoxide::crypto::secretbox::xsalsa20poly1305 as secretbox;
use sodiumoxide::crypto::box_ as publicbox;
+use sodiumoxide::crypto::secretbox::xsalsa20poly1305 as secretbox;
+pub use sodiumoxide::crypto::box_::{
+ gen_keypair, PublicKey, SecretKey, PUBLICKEYBYTES, SECRETKEYBYTES,
+};
pub use sodiumoxide::crypto::secretbox::xsalsa20poly1305::{gen_key, Key, KEYBYTES};
-pub use sodiumoxide::crypto::box_::{gen_keypair, PublicKey, SecretKey, PUBLICKEYBYTES, SECRETKEYBYTES};
pub fn open(cryptoblob: &[u8], key: &Key) -> Result<Vec<u8>> {
- use secretbox::{NONCEBYTES, Nonce};
+ use secretbox::{Nonce, NONCEBYTES};
if cryptoblob.len() < NONCEBYTES {
return Err(anyhow!("Cyphertext too short"));
@@ -31,7 +33,7 @@ pub fn open(cryptoblob: &[u8], key: &Key) -> Result<Vec<u8>> {
}
pub fn seal(plainblob: &[u8], key: &Key) -> Result<Vec<u8>> {
- use secretbox::{NONCEBYTES, gen_nonce};
+ use secretbox::{gen_nonce, NONCEBYTES};
// Compress data using zstd
let mut reader = &plainblob[..];