Struct keybob::Key [−][src]
pub struct Key { /* fields omitted */ }
A crytographic key of a certain type
Uses a union
to allow key inlining without heap allocation.
Provides easy to use constructors for generation and derivation
from user input/name.
Also implements serde::{Serialize, Deserialize}
via a custom
serialiser which allows easy encryption of the key itself.
Methods
impl Key
[src]
impl Key
pub fn new(tt: KeyType) -> Self
[src]
pub fn new(tt: KeyType) -> Self
Generate a new, completely random key of a certain type
pub fn from_pw(tt: KeyType, pw: &str, user: &str) -> Self
[src]
pub fn from_pw(tt: KeyType, pw: &str, user: &str) -> Self
Generate a new key based on a user password
This function uses the pbkdf2 algorithm to deterministically expand an input pw/username combination into a key.
pub fn as_slice(&self) -> &[u8]
[src]
pub fn as_slice(&self) -> &[u8]
Read the key as an imutable slice
pub fn as_mut_slice(&mut self) -> &mut [u8]
[src]
pub fn as_mut_slice(&mut self) -> &mut [u8]
Read the key as a mutable slice
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Return the length of the key in bytes
Trait Implementations
impl Serialize for Key
[src]
impl Serialize for Key
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for Key
[src]
impl<'de> Deserialize<'de> for Key
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Clone for Key
[src]
impl Clone for Key
fn clone(&self) -> Key
[src]
fn clone(&self) -> Key
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Key
[src]
impl PartialEq for Key
fn eq(&self, o: &Self) -> bool
[src]
fn eq(&self, o: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for Key
[src]
impl Eq for Key
impl Debug for Key
[src]
impl Debug for Key