pub struct CryptoNative;Trait Implementations§
Source§impl Clone for CryptoNative
impl Clone for CryptoNative
Source§fn clone(&self) -> CryptoNative
fn clone(&self) -> CryptoNative
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Crypto for CryptoNative
impl Crypto for CryptoNative
type Sha256Error = ()
Source§fn create_uuid() -> String
fn create_uuid() -> String
Generate a new UUID (version 4). Returns the UUID as a string.
Source§fn hash_sha256<'a>(
to_digest: &'a [u8],
) -> AsyncCryptoResult<'a, [u8; 32], Self::Sha256Error>
fn hash_sha256<'a>( to_digest: &'a [u8], ) -> AsyncCryptoResult<'a, [u8; 32], Self::Sha256Error>
Compute the SHA-256 hash of the input data. Returns the 32-byte hash.
Source§fn hkdf_sha256<'a>(
ikm: &'a [u8],
salt: &'a [u8],
) -> AsyncCryptoResult<'a, [u8; 32], Self::HkdfError>
fn hkdf_sha256<'a>( ikm: &'a [u8], salt: &'a [u8], ) -> AsyncCryptoResult<'a, [u8; 32], Self::HkdfError>
Derive a 32-byte key from the input keying material and salt using HKDF-SHA256.
Source§fn gen_ed25519<'a>() -> AsyncCryptoResult<'a, (Vec<u8>, Vec<u8>), Self::Ed25519GenError>
fn gen_ed25519<'a>() -> AsyncCryptoResult<'a, (Vec<u8>, Vec<u8>), Self::Ed25519GenError>
Generate a new Ed25519 key pair. Returns the public and private keys.
Source§fn sig_ed25519<'a>(
pri_key: &'a [u8],
data: &'a [u8],
) -> AsyncCryptoResult<'a, [u8; 64], Self::Ed25519SignError>
fn sig_ed25519<'a>( pri_key: &'a [u8], data: &'a [u8], ) -> AsyncCryptoResult<'a, [u8; 64], Self::Ed25519SignError>
Sign the given data using the provided Ed25519 private key. Returns the signature.
Source§fn ver_ed25519<'a>(
pub_key: &'a [u8],
sig: &'a [u8],
data: &'a [u8],
) -> AsyncCryptoResult<'a, bool, Self::Ed25519VerifyError>
fn ver_ed25519<'a>( pub_key: &'a [u8], sig: &'a [u8], data: &'a [u8], ) -> AsyncCryptoResult<'a, bool, Self::Ed25519VerifyError>
Verify the given Ed25519 signature against the provided public key and data.
Returns true if the signature is valid, false if it is invalid.
Source§fn aes_ctr_encrypt<'a>(
key: &'a [u8; 32],
iv: &'a [u8; 16],
plaintext: &'a [u8],
) -> AsyncCryptoResult<'a, Vec<u8>, Self::AesCtrError>
fn aes_ctr_encrypt<'a>( key: &'a [u8; 32], iv: &'a [u8; 16], plaintext: &'a [u8], ) -> AsyncCryptoResult<'a, Vec<u8>, Self::AesCtrError>
Encrypt the plaintext using AES-256 in CTR mode with the given key and IV. Returns the ciphertext.
Source§fn aes_ctr_decrypt<'a>(
key: &'a [u8; 32],
iv: &'a [u8; 16],
cipher_text: &'a [u8],
) -> AsyncCryptoResult<'a, Vec<u8>, Self::AesCtrError>
fn aes_ctr_decrypt<'a>( key: &'a [u8; 32], iv: &'a [u8; 16], cipher_text: &'a [u8], ) -> AsyncCryptoResult<'a, Vec<u8>, Self::AesCtrError>
Decrypt the ciphertext using AES-256 in CTR mode with the given key and IV. Returns the plaintext.
Source§fn key_wrap_rfc3394<'a>(
kek_bytes: &'a [u8; 32],
rb: &'a [u8; 32],
) -> AsyncCryptoResult<'a, [u8; 40], Self::KeyWrapError>
fn key_wrap_rfc3394<'a>( kek_bytes: &'a [u8; 32], rb: &'a [u8; 32], ) -> AsyncCryptoResult<'a, [u8; 40], Self::KeyWrapError>
Wrap the given 32-byte key using the provided 32-byte KEK with the RFC3394 algorithm. Returns the wrapped key.
Source§fn key_unwrap_rfc3394<'a>(
kek_bytes: &'a [u8; 32],
cipher: &'a [u8; 40],
) -> AsyncCryptoResult<'a, [u8; 32], Self::KeyUnwrapError>
fn key_unwrap_rfc3394<'a>( kek_bytes: &'a [u8; 32], cipher: &'a [u8; 40], ) -> AsyncCryptoResult<'a, [u8; 32], Self::KeyUnwrapError>
Unwrap the given 40-byte wrapped key using the provided 32-byte KEK with the RFC3394 algorithm.
Returns the unwrapped key.
Source§fn gen_x25519<'a>() -> AsyncCryptoResult<'a, ([u8; 44], [u8; 48]), Self::X25519GenError>
fn gen_x25519<'a>() -> AsyncCryptoResult<'a, ([u8; 44], [u8; 48]), Self::X25519GenError>
Generate a new X25519 key pair. Returns the public key as a base58 string and the private key as bytes.
Source§fn derive_x25519<'a>(
pri_key: &'a [u8; 48],
peer_raw: &'a [u8; 44],
) -> AsyncCryptoResult<'a, [u8; 32], Self::X25519DeriveError>
fn derive_x25519<'a>( pri_key: &'a [u8; 48], peer_raw: &'a [u8; 44], ) -> AsyncCryptoResult<'a, [u8; 32], Self::X25519DeriveError>
Derive a shared secret using the X25519 key agreement protocol with the given private key and peer’s public key.
Returns the derived 32-byte shared secret.
Source§fn dec_b58_32(data: &str) -> Result<[u8; 32], B58DecodeError>
fn dec_b58_32(data: &str) -> Result<[u8; 32], B58DecodeError>
Decode the given Base58 string into a 32-byte array.
Returns an error if the input is not valid Base58 or does not decode to exactly 32 bytes.
type HkdfError = HkdfError
type Ed25519GenError = Ed25519GenError
type Ed25519SignError = Ed25519SignError
type Ed25519VerifyError = Ed25519VerifyError
type AesCtrError = AesCtrError
type KeyWrapError = KeyWrapError
type KeyUnwrapError = KeyUnwrapError
type X25519GenError = X25519GenError
type X25519DeriveError = X25519DeriveError
Source§impl Debug for CryptoNative
impl Debug for CryptoNative
Source§impl PartialEq for CryptoNative
impl PartialEq for CryptoNative
impl StructuralPartialEq for CryptoNative
Auto Trait Implementations§
impl Freeze for CryptoNative
impl RefUnwindSafe for CryptoNative
impl Send for CryptoNative
impl Sync for CryptoNative
impl Unpin for CryptoNative
impl UnsafeUnpin for CryptoNative
impl UnwindSafe for CryptoNative
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
Mutably borrows from an owned value. Read more