Skip to main content

SecurityConstants

Struct SecurityConstants 

Source
pub struct SecurityConstants { /* private fields */ }
Expand description

Security constants for lib-Q

This struct provides access to security-related constants used throughout the library for validation and configuration.

Implementations§

Source§

impl SecurityConstants

Source

pub fn new() -> Self

Create a new SecurityConstants instance

§Returns

A new instance of SecurityConstants with default values.

Source§

impl SecurityConstants

Source

pub fn max_aead_message_size(&self) -> usize

Maximum plaintext, ciphertext, or AAD size for one AEAD call.

Source

pub fn max_hash_message_size(&self) -> usize

Maximum hash input length and signature message length.

Source

pub fn standard_nonce_size(&self) -> usize

Get the standard nonce size

§Returns

Returns the standard nonce size in bytes.

Source

pub fn min_randomness_size(&self) -> usize

Get the minimum randomness size

§Returns

Returns the minimum required randomness size in bytes.

Source

pub fn get_expected_key_size( &self, algorithm: Algorithm, is_secret: bool, ) -> Result<usize>

Get the expected key size for a given algorithm

§Arguments
  • algorithm - The algorithm to get the key size for
  • is_secret - Whether this is a secret key (affects expected size)
§Returns

Returns the expected key size in bytes, or an error if the algorithm doesn’t use keys or is not supported.

Source

pub fn get_expected_ciphertext_size( &self, algorithm: Algorithm, ) -> Result<usize>

Get the expected ciphertext size for a given algorithm

§Arguments
  • algorithm - The algorithm to get the ciphertext size for
§Returns

Returns the expected ciphertext size in bytes, or an error if the algorithm doesn’t produce ciphertext or is not supported.

Source

pub fn get_expected_signature_size(&self, algorithm: Algorithm) -> Result<usize>

Get the expected signature size for a given algorithm

§Arguments
  • algorithm - The algorithm to get the signature size for
§Returns

Returns the expected signature size in bytes, or an error if the algorithm doesn’t produce signatures or is not supported.

Source

pub fn set_max_aead_message_size(&mut self, max_size: usize)

Set the maximum AEAD plaintext, ciphertext, or AAD size (bytes) for one operation.

Source

pub fn set_max_hash_message_size(&mut self, max_size: usize)

Set the maximum hash input and signature message size (bytes).

Source

pub fn set_standard_nonce_size(&mut self, nonce_size: usize)

Set the standard nonce size

§Arguments
  • nonce_size - The standard nonce size in bytes
Source

pub fn set_min_randomness_size(&mut self, min_size: usize)

Set the minimum randomness size

§Arguments
  • min_size - The minimum randomness size in bytes

Trait Implementations§

Source§

impl Clone for SecurityConstants

Source§

fn clone(&self) -> SecurityConstants

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for SecurityConstants

Available on crate feature alloc only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more