Trait CryptoSystem
Source pub trait CryptoSystem {
Show 42 methods
// Required methods
fn kind(&self) -> CryptoKind;
fn crypto(&self) -> VeilidComponentGuard<'_, Crypto>;
fn cached_dh(
&self,
key: &PublicKey,
secret: &SecretKey,
) -> VeilidAPIResult<SharedSecret>;
fn random_bytes(&self, len: usize) -> Vec<u8> ⓘ;
fn hash_password(
&self,
password: &[u8],
salt: &[u8],
) -> VeilidAPIResult<String>;
fn verify_password(
&self,
password: &[u8],
password_hash: &str,
) -> VeilidAPIResult<bool>;
fn derive_shared_secret(
&self,
password: &[u8],
salt: &[u8],
) -> VeilidAPIResult<SharedSecret>;
fn random_nonce(&self) -> Nonce;
fn random_shared_secret(&self) -> SharedSecret;
fn compute_dh(
&self,
key: &PublicKey,
secret: &SecretKey,
) -> VeilidAPIResult<SharedSecret>;
fn generate_keypair(&self) -> KeyPair;
fn generate_hash(&self, data: &[u8]) -> HashDigest;
fn generate_hash_reader(
&self,
reader: &mut dyn Read,
) -> VeilidAPIResult<PublicKey>;
fn shared_secret_length(&self) -> usize;
fn nonce_length(&self) -> usize;
fn hash_digest_length(&self) -> usize;
fn public_key_length(&self) -> usize;
fn secret_key_length(&self) -> usize;
fn signature_length(&self) -> usize;
fn default_salt_length(&self) -> usize;
fn aead_overhead(&self) -> usize;
fn validate_keypair(
&self,
key: &PublicKey,
secret: &SecretKey,
) -> VeilidAPIResult<bool>;
fn validate_hash(
&self,
data: &[u8],
hash: &HashDigest,
) -> VeilidAPIResult<bool>;
fn validate_hash_reader(
&self,
reader: &mut dyn Read,
hash: &HashDigest,
) -> VeilidAPIResult<bool>;
fn sign(
&self,
key: &PublicKey,
secret: &SecretKey,
data: &[u8],
) -> VeilidAPIResult<Signature>;
fn verify(
&self,
key: &PublicKey,
data: &[u8],
signature: &Signature,
) -> VeilidAPIResult<bool>;
fn decrypt_in_place_aead(
&self,
body: &mut Vec<u8>,
nonce: &Nonce,
shared_secret: &SharedSecret,
associated_data: Option<&[u8]>,
) -> VeilidAPIResult<()>;
fn decrypt_aead(
&self,
body: &[u8],
nonce: &Nonce,
shared_secret: &SharedSecret,
associated_data: Option<&[u8]>,
) -> VeilidAPIResult<Vec<u8>>;
fn encrypt_in_place_aead(
&self,
body: &mut Vec<u8>,
nonce: &Nonce,
shared_secret: &SharedSecret,
associated_data: Option<&[u8]>,
) -> VeilidAPIResult<()>;
fn encrypt_aead(
&self,
body: &[u8],
nonce: &Nonce,
shared_secret: &SharedSecret,
associated_data: Option<&[u8]>,
) -> VeilidAPIResult<Vec<u8>>;
fn crypt_in_place_no_auth(
&self,
body: &mut [u8],
nonce: &Nonce,
shared_secret: &SharedSecret,
) -> VeilidAPIResult<()>;
fn crypt_b2b_no_auth(
&self,
in_buf: &[u8],
out_buf: &mut [u8],
nonce: &Nonce,
shared_secret: &SharedSecret,
) -> VeilidAPIResult<()>;
fn crypt_no_auth_aligned_8(
&self,
body: &[u8],
nonce: &Nonce,
shared_secret: &SharedSecret,
) -> VeilidAPIResult<Vec<u8>>;
fn crypt_no_auth_unaligned(
&self,
body: &[u8],
nonce: &Nonce,
shared_secret: &SharedSecret,
) -> VeilidAPIResult<Vec<u8>>;
// Provided methods
fn generate_shared_secret(
&self,
key: &PublicKey,
secret: &SecretKey,
domain: &[u8],
) -> VeilidAPIResult<SharedSecret> { ... }
fn check_shared_secret(&self, secret: &SharedSecret) -> VeilidAPIResult<()> { ... }
fn check_nonce(&self, nonce: &Nonce) -> VeilidAPIResult<()> { ... }
fn check_hash_digest(&self, hash: &HashDigest) -> VeilidAPIResult<()> { ... }
fn check_public_key(&self, key: &PublicKey) -> VeilidAPIResult<()> { ... }
fn check_secret_key(&self, key: &SecretKey) -> VeilidAPIResult<()> { ... }
fn check_signature(&self, signature: &Signature) -> VeilidAPIResult<()> { ... }
fn check_keypair(&self, keypair: &KeyPair) -> VeilidAPIResult<()> { ... }
}