[][src]Trait lib3h_crypto_api::CryptoSystem

pub trait CryptoSystem: Sync {
    fn box_clone(&self) -> Box<dyn CryptoSystem>;
fn as_crypto_system(&self) -> &dyn CryptoSystem;
fn buf_new_secure(&self, size: usize) -> Box<dyn Buffer>;
fn randombytes_buf(&self, buffer: &mut Box<dyn Buffer>) -> CryptoResult<()>;
fn hash_sha256_bytes(&self) -> usize;
fn hash_sha512_bytes(&self) -> usize;
fn pwhash_salt_bytes(&self) -> usize;
fn pwhash_bytes(&self) -> usize;
fn pwhash(
        &self,
        hash: &mut Box<dyn Buffer>,
        password: &Box<dyn Buffer>,
        salt: &Box<dyn Buffer>
    ) -> CryptoResult<()>;
fn hash_sha256(
        &self,
        hash: &mut Box<dyn Buffer>,
        data: &Box<dyn Buffer>
    ) -> CryptoResult<()>;
fn hash_sha512(
        &self,
        hash: &mut Box<dyn Buffer>,
        data: &Box<dyn Buffer>
    ) -> CryptoResult<()>;
fn sign_seed_bytes(&self) -> usize;
fn sign_public_key_bytes(&self) -> usize;
fn sign_secret_key_bytes(&self) -> usize;
fn sign_bytes(&self) -> usize;
fn sign_seed_keypair(
        &self,
        seed: &Box<dyn Buffer>,
        public_key: &mut Box<dyn Buffer>,
        secret_key: &mut Box<dyn Buffer>
    ) -> CryptoResult<()>;
fn sign_keypair(
        &self,
        public_key: &mut Box<dyn Buffer>,
        secret_key: &mut Box<dyn Buffer>
    ) -> CryptoResult<()>;
fn sign(
        &self,
        signature: &mut Box<dyn Buffer>,
        message: &Box<dyn Buffer>,
        secret_key: &Box<dyn Buffer>
    ) -> CryptoResult<()>;
fn sign_verify(
        &self,
        signature: &Box<dyn Buffer>,
        message: &Box<dyn Buffer>,
        public_key: &Box<dyn Buffer>
    ) -> CryptoResult<bool>; fn buf_new_insecure(&self, size: usize) -> Box<dyn Buffer> { ... } }

A trait describing a cryptographic system implementation compatible with Lib3h and Holochain.

Required methods

fn box_clone(&self) -> Box<dyn CryptoSystem>

Crypto System is designed to be used as a trait-object Since we can't get a sized clone, provide clone in a Box.

fn as_crypto_system(&self) -> &dyn CryptoSystem

helps work around some sizing issues with rust trait-objects

fn buf_new_secure(&self, size: usize) -> Box<dyn Buffer>

create a new memory secured buffer that is compatible with this crypto system

fn randombytes_buf(&self, buffer: &mut Box<dyn Buffer>) -> CryptoResult<()>

fill all the bytes in the buffer with secure random data

fn hash_sha256_bytes(&self) -> usize

bytelength of sha256 hash

fn hash_sha512_bytes(&self) -> usize

bytelength of sha512 hash

fn pwhash_salt_bytes(&self) -> usize

bytelength of pwhash salt

fn pwhash_bytes(&self) -> usize

bytelength of pwhash

fn pwhash(
    &self,
    hash: &mut Box<dyn Buffer>,
    password: &Box<dyn Buffer>,
    salt: &Box<dyn Buffer>
) -> CryptoResult<()>

run a cpu/memory intensive password hash against password / salt

fn hash_sha256(
    &self,
    hash: &mut Box<dyn Buffer>,
    data: &Box<dyn Buffer>
) -> CryptoResult<()>

compute a sha256 hash for data, storing it in hash

fn hash_sha512(
    &self,
    hash: &mut Box<dyn Buffer>,
    data: &Box<dyn Buffer>
) -> CryptoResult<()>

compute a sha512 hash for data, storing it in hash

fn sign_seed_bytes(&self) -> usize

bytelength of signature seed

fn sign_public_key_bytes(&self) -> usize

bytelength of signature public key

fn sign_secret_key_bytes(&self) -> usize

bytelength of signature secret key

fn sign_bytes(&self) -> usize

bytelength of a digital signature

fn sign_seed_keypair(
    &self,
    seed: &Box<dyn Buffer>,
    public_key: &mut Box<dyn Buffer>,
    secret_key: &mut Box<dyn Buffer>
) -> CryptoResult<()>

generate a deterministic signature public / secret keypair based off the given seed entropy

fn sign_keypair(
    &self,
    public_key: &mut Box<dyn Buffer>,
    secret_key: &mut Box<dyn Buffer>
) -> CryptoResult<()>

generate a pure entropy based signature public / secret keypair

fn sign(
    &self,
    signature: &mut Box<dyn Buffer>,
    message: &Box<dyn Buffer>,
    secret_key: &Box<dyn Buffer>
) -> CryptoResult<()>

generate a digital signature for message with the given secret key

fn sign_verify(
    &self,
    signature: &Box<dyn Buffer>,
    message: &Box<dyn Buffer>,
    public_key: &Box<dyn Buffer>
) -> CryptoResult<bool>

verify that the digital signature is valid for given message and public_key

Loading content...

Provided methods

fn buf_new_insecure(&self, size: usize) -> Box<dyn Buffer>

this is just a helper to create a sized boxed Vec as a Box

Loading content...

Implementors

Loading content...