Struct fog_crypto::identity::IdentityKey[][src]

pub struct IdentityKey { /* fields omitted */ }

Identity Key that allows signing hashes as a given Identity.

This acts as a wrapper for a specific cryptographic private key, and it is only be used for a specific corresponding signature algorithm. The underlying private key may be located in a hardware module or some other private keystore; in this case, it may be impossible to export the key.

Example


// Make a new temporary key
let mut csprng = rand::rngs::OsRng {};
let key = IdentityKey::new_temp(&mut csprng);

// Sign some data with it
let hash = Hash::new(b"I am data, about to be signed");
let signature = key.sign(&hash);

Implementations

impl IdentityKey[src]

pub fn new_temp<R>(csprng: &mut R) -> IdentityKey where
    R: CryptoRng + RngCore
[src]

Generate a temporary IdentityKey that exists in program memory.

pub fn new_temp_with_version<R>(
    csprng: &mut R,
    version: u8
) -> Result<IdentityKey, CryptoError> where
    R: CryptoRng + RngCore
[src]

Generate a temporary IdentityKey that exists in program memory. Uses the specified version instead of the default, and fails if the version is unsupported.

pub fn version(&self) -> u8[src]

Get the signature algorithm version used by this key.

pub fn id(&self) -> &Identity[src]

Get the associated Identity for this key.

pub fn sign(&self, hash: &Hash) -> Signature[src]

Sign a hash. Signing should be fast and always succeed.

pub fn export_for_lock<R: CryptoRng + RngCore>(
    &self,
    csprng: &mut R,
    lock: &LockId
) -> Option<IdentityLockbox>
[src]

Pack this key into a Lockbox, meant for the recipient specified by lock. Returns None if this key cannot be exported.

pub fn export_for_stream<R: CryptoRng + RngCore>(
    &self,
    csprng: &mut R,
    stream: &StreamKey
) -> Option<IdentityLockbox>
[src]

Pack this key into a Lockbox, meant for the recipient specified by stream. Returns None if this key cannot be exported.

Trait Implementations

impl Clone for IdentityKey[src]

impl Debug for IdentityKey[src]

impl Display for IdentityKey[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Display just the Identity (never the underlying key).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,