Struct fog_crypto::identity::IdentityKey
source · pub struct IdentityKey { /* private fields */ }
Expand description
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 key = IdentityKey::new();
// Sign some data with it
let hash = Hash::new(b"I am data, about to be signed");
let signature = key.sign(&hash);
Implementations§
source§impl IdentityKey
impl IdentityKey
sourcepub fn from_interface(interface: Arc<dyn SignInterface>) -> IdentityKey
pub fn from_interface(interface: Arc<dyn SignInterface>) -> IdentityKey
Create a new IdentityKey
, given a wrapped object that can implement a
SignInterface.
sourcepub fn new() -> IdentityKey
pub fn new() -> IdentityKey
Generate a temporary IdentityKey
that exists in program memory.
sourcepub fn with_rng<R>(csprng: &mut R) -> IdentityKeywhere
R: CryptoRng + RngCore,
pub fn with_rng<R>(csprng: &mut R) -> IdentityKeywhere R: CryptoRng + RngCore,
Generate a temporary IdentityKey
that exists in program memory, using
the provided cryptographic RNG.
sourcepub fn with_rng_and_version<R>(
csprng: &mut R,
version: u8
) -> Result<IdentityKey, CryptoError>where
R: CryptoRng + RngCore,
pub fn with_rng_and_version<R>( csprng: &mut R, version: u8 ) -> Result<IdentityKey, CryptoError>where R: CryptoRng + RngCore,
Generate a temporary IdentityKey
that exists in program memory. Uses the specified
version instead of the default, and fails if the version is unsupported.
sourcepub fn sign(&self, hash: &Hash) -> Signature
pub fn sign(&self, hash: &Hash) -> Signature
Sign a hash. Signing should be fast and always succeed.
sourcepub fn max_signature_size(&self) -> usize
pub fn max_signature_size(&self) -> usize
The maximum expected size of a signature from this key
sourcepub fn export_for_lock(&self, lock: &LockId) -> Option<IdentityLockbox>
pub fn export_for_lock(&self, lock: &LockId) -> Option<IdentityLockbox>
Pack this key into a Lockbox
, meant for the recipient specified by lock
. Returns None if
this key cannot be exported.
sourcepub fn export_for_lock_with_rng<R: CryptoRng + RngCore>(
&self,
csprng: &mut R,
lock: &LockId
) -> Option<IdentityLockbox>
pub fn export_for_lock_with_rng<R: CryptoRng + RngCore>( &self, csprng: &mut R, lock: &LockId ) -> Option<IdentityLockbox>
Pack this key into a Lockbox
, meant for the recipient specified by lock
. Returns None if
this key cannot be exported.
sourcepub fn export_for_stream(&self, stream: &StreamKey) -> Option<IdentityLockbox>
pub fn export_for_stream(&self, stream: &StreamKey) -> Option<IdentityLockbox>
Pack this key into a Lockbox
, meant for the recipient specified by stream
. Returns None
if this key cannot be exported.
sourcepub fn export_for_stream_with_rng<R: CryptoRng + RngCore>(
&self,
csprng: &mut R,
stream: &StreamKey
) -> Option<IdentityLockbox>
pub fn export_for_stream_with_rng<R: CryptoRng + RngCore>( &self, csprng: &mut R, stream: &StreamKey ) -> Option<IdentityLockbox>
Pack this key into a Lockbox
, meant for the recipient specified by stream
. Returns None
if this key cannot be exported.
Trait Implementations§
source§impl Clone for IdentityKey
impl Clone for IdentityKey
source§fn clone(&self) -> IdentityKey
fn clone(&self) -> IdentityKey
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more