pub trait EcdhArrayref<const RAND_LEN: usize, const SECRET_LEN: usize, const PUBLIC_LEN: usize> {
// Required methods
fn generate_secret(
secret: &mut [u8; SECRET_LEN],
rand: &[u8; RAND_LEN],
) -> Result<(), GenerateSecretError>;
fn secret_to_public(
public: &mut [u8; PUBLIC_LEN],
secret: &[u8; SECRET_LEN],
) -> Result<(), SecretToPublicError>;
fn derive_ecdh(
derived: &mut [u8; PUBLIC_LEN],
public: &[u8; PUBLIC_LEN],
secret: &[u8; SECRET_LEN],
) -> Result<(), DeriveError>;
fn validate_secret(
secret: &[u8; SECRET_LEN],
) -> Result<(), ValidateSecretError>;
// Provided method
fn generate_pair(
public: &mut [u8; PUBLIC_LEN],
secret: &mut [u8; SECRET_LEN],
rand: &[u8; RAND_LEN],
) -> Result<(), GenerateSecretError> { ... }
}Expand description
An Elliptic Curve Diffie-Hellman (ECDH) key exchange. This trait is the most low-level and mostly used in the implementation of other, more usabe APIs on top.
Required Methods§
Sourcefn generate_secret(
secret: &mut [u8; SECRET_LEN],
rand: &[u8; RAND_LEN],
) -> Result<(), GenerateSecretError>
fn generate_secret( secret: &mut [u8; SECRET_LEN], rand: &[u8; RAND_LEN], ) -> Result<(), GenerateSecretError>
Generate a Diffie-Hellman secret value.
It is the responsibility of the caller to ensure that the rand argument is actually
random.
Sourcefn secret_to_public(
public: &mut [u8; PUBLIC_LEN],
secret: &[u8; SECRET_LEN],
) -> Result<(), SecretToPublicError>
fn secret_to_public( public: &mut [u8; PUBLIC_LEN], secret: &[u8; SECRET_LEN], ) -> Result<(), SecretToPublicError>
Derive a Diffie-Hellman public value from a secret value.
Sourcefn derive_ecdh(
derived: &mut [u8; PUBLIC_LEN],
public: &[u8; PUBLIC_LEN],
secret: &[u8; SECRET_LEN],
) -> Result<(), DeriveError>
fn derive_ecdh( derived: &mut [u8; PUBLIC_LEN], public: &[u8; PUBLIC_LEN], secret: &[u8; SECRET_LEN], ) -> Result<(), DeriveError>
Derive a Diffie-Hellman shared secret from a public and a secret value.
This value is NOT (!) safe for use as a key and needs to be processed in a round of key derivation, to ensure both that the output is uniformly random and that unkown key share attacks can not happen.
Sourcefn validate_secret(secret: &[u8; SECRET_LEN]) -> Result<(), ValidateSecretError>
fn validate_secret(secret: &[u8; SECRET_LEN]) -> Result<(), ValidateSecretError>
Check the validity of a Diffie-Hellman secret value.
Provided Methods§
Sourcefn generate_pair(
public: &mut [u8; PUBLIC_LEN],
secret: &mut [u8; SECRET_LEN],
rand: &[u8; RAND_LEN],
) -> Result<(), GenerateSecretError>
fn generate_pair( public: &mut [u8; PUBLIC_LEN], secret: &mut [u8; SECRET_LEN], rand: &[u8; RAND_LEN], ) -> Result<(), GenerateSecretError>
Generate a Diffie-Hellman secret value and derive the corresponding public value in one step.
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.