Struct orion::aead::SecretKey

source ·
pub struct SecretKey { /* private fields */ }
Expand description

A type to represent a secret key.

As default it will randomly generate a SecretKey of 32 bytes.

Note:

Due to the return type of the Default trait, the default() method cannot let the caller handle a failing CSPRNG. If the CSPRNG fails, that function panics. If handling a failing CSPRNG’s error is needed, use instead generate().

Exceptions:

An exception will be thrown if:

  • slice is empty.
  • The OsRng fails to initialize or read from its source.
  • length is 0.

Security:

  • Avoid using unprotected_as_bytes() whenever possible, as it breaks all protections that the type implements.

Implementations§

Make an object from a given byte slice.

Return the object as byte slice. Warning: Should not be used unless strictly needed. This breaks protections that the type implements.

Return the length of the object.

Randomly generate using a CSPRNG. Not available in no_std context.

Trait Implementations§

Formats the value using the given formatter. Read more

Randomly generate using a CSPRNG with recommended size. Not available in no_std context.

Executes the destructor for this type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Completely overwrites this value.

Returns the argument unchanged.

Called to initialize a place to a valid value, after it is set to all-bits-zero. Read more

Calls U::from(self).

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

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.