pub use crate::EzNaclError;
pub use crate::CryptoString;
pub enum KeyUsage {
Sign,
Verify,
SignVerify,
Encrypt,
Decrypt,
EncryptDecrypt
}
pub trait CryptoInfo {
fn get_usage(&self) -> KeyUsage;
fn get_algorithm(&self) -> String;
}
pub trait PublicKey {
fn get_public_key(&self) -> CryptoString;
fn get_public_str(&self) -> String;
fn get_public_bytes(&self) -> Vec<u8>;
}
pub trait PrivateKey {
fn get_private_key(&self) -> CryptoString;
fn get_private_str(&self) -> String;
fn get_private_bytes(&self) -> Vec<u8>;
}
pub trait Encryptor {
fn encrypt(&self, data: &[u8]) -> Result<CryptoString, EzNaclError>;
}
pub trait Decryptor {
fn decrypt(&self, encdata: &CryptoString) -> Result<Vec<u8>, EzNaclError>;
}
pub trait Sign {
fn sign(&self, data: &[u8]) -> Result<CryptoString, EzNaclError>;
}
pub trait VerifySignature {
fn verify(&self, data: &[u8], signature: &CryptoString) -> Result<bool, EzNaclError>;
}
pub fn is_supported_algorithm(name: &str) -> bool {
match name {
"XSALSA20" => true,
"CURVE25519" => true,
"ED25519" => true,
"BLAKE2B-256" | "BLAKE2B-512" | "BLAKE3-256" => true,
"K12-256" | "SHA-256" | "SHA-512" | "SHA3-256" | "SHA3-512" => true,
_ => false
}
}