Skip to main content

Algorithm

Trait Algorithm 

Source
pub trait Algorithm:
    Sealed
    + Sized
    + 'static {
    type Hasher: Digest + Clone;

    const NAME: &'static str;
    const HASH_ALG: HashAlg;
    const SIG_SIZE: usize;
    const PUB_SIZE: usize;
    const PRV_SIZE: usize;
}
Expand description

Trait for Coz-supported cryptographic algorithms.

This trait is sealed and cannot be implemented outside this crate. It provides associated types and constants for each algorithm.

Required Associated Constants§

Source

const NAME: &'static str

Algorithm name as it appears in JSON (e.g., “ES256”).

Source

const HASH_ALG: HashAlg

The runtime hash algorithm identifier.

This must match the Hasher type (e.g., if Hasher = Sha256, then HASH_ALG = HashAlg::Sha256).

Source

const SIG_SIZE: usize

Signature size in bytes.

Source

const PUB_SIZE: usize

Public key size in bytes.

Source

const PRV_SIZE: usize

Private key size in bytes.

Required Associated Types§

Source

type Hasher: Digest + Clone

The hashing algorithm used for digests (compile-time type).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Algorithm for ES256

Source§

const NAME: &'static str = "ES256"

Source§

const HASH_ALG: HashAlg = HashAlg::Sha256

Source§

const PRV_SIZE: usize = 32

Source§

const PUB_SIZE: usize = 64

Source§

const SIG_SIZE: usize = 64

Source§

type Hasher = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>

Source§

impl Algorithm for ES384

Source§

const NAME: &'static str = "ES384"

Source§

const HASH_ALG: HashAlg = HashAlg::Sha384

Source§

const PRV_SIZE: usize = 48

Source§

const PUB_SIZE: usize = 96

Source§

const SIG_SIZE: usize = 96

Source§

type Hasher = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B0>, B0>, OidSha384>>

Source§

impl Algorithm for ES512

Source§

const NAME: &'static str = "ES512"

Source§

const HASH_ALG: HashAlg = HashAlg::Sha512

Source§

const PRV_SIZE: usize = 66

Source§

const PUB_SIZE: usize = 132

Source§

const SIG_SIZE: usize = 132

Source§

type Hasher = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, OidSha512>>

Source§

impl Algorithm for Ed25519

Source§

const NAME: &'static str = "Ed25519"

Source§

const HASH_ALG: HashAlg = HashAlg::Sha512

Source§

const PRV_SIZE: usize = 32

Source§

const PUB_SIZE: usize = 32

Source§

const SIG_SIZE: usize = 64

Source§

type Hasher = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, OidSha512>>