pub struct Crypto { /* private fields */ }Expand description
Crypto factory implementation
Implementations§
Source§impl Crypto
impl Crypto
Sourcepub fn get(&self, kind: CryptoKind) -> Option<CryptoSystemGuard<'_>>
pub fn get(&self, kind: CryptoKind) -> Option<CryptoSystemGuard<'_>>
Factory method to get a specific crypto version
Returns a guard borrowing this Crypto; the cryptosystem stays reachable for the guard’s
lifetime. Non-blocking (clones an Arc).
Sourcepub fn get_async(&self, kind: CryptoKind) -> Option<AsyncCryptoSystemGuard<'_>>
pub fn get_async(&self, kind: CryptoKind) -> Option<AsyncCryptoSystemGuard<'_>>
Factory method to get a specific crypto version for async use
Returns a guard borrowing this Crypto; the cryptosystem stays reachable for the guard’s
lifetime. Non-blocking (clones an Arc).
Validate a shared secret against the cryptosystem named by its kind. Fails if the kind is unsupported.
Errors VeilidAPIError::Generic if secret’s kind is unsupported or its length is wrong.
Sourcepub fn check_hash_digest(&self, hash: &HashDigest) -> VeilidAPIResult<()>
pub fn check_hash_digest(&self, hash: &HashDigest) -> VeilidAPIResult<()>
Validate a hash digest against the cryptosystem named by its kind. Fails if the kind is unsupported.
Errors VeilidAPIError::Generic if hash’s kind is unsupported or its length is wrong.
Sourcepub fn check_public_key(&self, key: &PublicKey) -> VeilidAPIResult<()>
pub fn check_public_key(&self, key: &PublicKey) -> VeilidAPIResult<()>
Validate a public key against the cryptosystem named by its kind. Fails if the kind is unsupported.
Errors VeilidAPIError::Generic if key’s kind is unsupported or its length is wrong.
Sourcepub fn check_secret_key(&self, key: &SecretKey) -> VeilidAPIResult<()>
pub fn check_secret_key(&self, key: &SecretKey) -> VeilidAPIResult<()>
Validate a secret key against the cryptosystem named by its kind. Fails if the kind is unsupported.
Errors VeilidAPIError::Generic if key’s kind is unsupported or its length is wrong.
Sourcepub fn check_signature(&self, signature: &Signature) -> VeilidAPIResult<()>
pub fn check_signature(&self, signature: &Signature) -> VeilidAPIResult<()>
Validate a signature against the cryptosystem named by its kind. Fails if the kind is unsupported.
Errors VeilidAPIError::Generic if signature’s kind is unsupported or its length is wrong.
Sourcepub fn check_keypair(&self, key_pair: &KeyPair) -> VeilidAPIResult<()>
pub fn check_keypair(&self, key_pair: &KeyPair) -> VeilidAPIResult<()>
Validate a keypair against the cryptosystem named by its kind. Fails if the kind is unsupported.
Errors VeilidAPIError::Generic if key_pair’s kind is unsupported, or if the pair or either
key has the wrong length.
Sourcepub fn verify_signatures(
&self,
public_keys: &[PublicKey],
data: &[u8],
signatures: &[Signature],
) -> VeilidAPIResult<Option<PublicKeyGroup>>
pub fn verify_signatures( &self, public_keys: &[PublicKey], data: &[u8], signatures: &[Signature], ) -> VeilidAPIResult<Option<PublicKeyGroup>>
BareSignature set verification Returns Some() the set of signature cryptokinds that validate and are supported Returns None if any cryptokinds are supported and do not validate
Local CPU only; verifies each signature inline (no offload).
A supported signature that does not match returns Ok(None), not an error. Errors
VeilidAPIError::Generic or VeilidAPIError::ParseError if a matching public key or
signature is malformed (propagated from the underlying verify).
Sourcepub fn generate_signatures<F, R>(
&self,
data: &[u8],
key_pairs: &[KeyPair],
transform: F,
) -> VeilidAPIResult<Vec<R>>
pub fn generate_signatures<F, R>( &self, data: &[u8], key_pairs: &[KeyPair], transform: F, ) -> VeilidAPIResult<Vec<R>>
BareSignature set generation Generates the set of signatures that are supported Any cryptokinds that are not supported are silently dropped
Local CPU only; signs inline for each keypair (no offload).
Errors VeilidAPIError::Generic, VeilidAPIError::ParseError, or VeilidAPIError::Internal
if a supported keypair is malformed (propagated from the underlying sign).
Sourcepub fn generate_keypair(crypto_kind: CryptoKind) -> VeilidAPIResult<KeyPair>
pub fn generate_keypair(crypto_kind: CryptoKind) -> VeilidAPIResult<KeyPair>
Generate keypair Does not require startup/init
Errors VeilidAPIError::Generic if crypto_kind is not a supported cryptosystem.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Crypto
impl !RefUnwindSafe for Crypto
impl !UnwindSafe for Crypto
impl Send for Crypto
impl Sync for Crypto
impl Unpin for Crypto
impl UnsafeUnpin for Crypto
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more