pub enum CryptographicKeyContext {
OpenPgp {
user_ids: OpenPgpUserIdList,
version: OpenPgpVersion,
},
Raw,
}
Expand description
The cryptographic context in which a key is used
Each key can only be used in one cryptographic context. This is because the NetHSM offers only a single certificate slot per key, which can be used to attach certificates for a specific cryptographic use.
Variants§
Implementations§
source§impl CryptographicKeyContext
impl CryptographicKeyContext
sourcepub fn validate_signing_key_setup(
&self,
key_type: KeyType,
key_mechanisms: &[KeyMechanism],
signature_type: SignatureType,
) -> Result<(), Error>
pub fn validate_signing_key_setup( &self, key_type: KeyType, key_mechanisms: &[KeyMechanism], signature_type: SignatureType, ) -> Result<(), Error>
Validates the cryptographic context against a signing key setup
§Errors
Returns an Error::Key
if the key setup can not be used for signing
operations in the respective cryptographic context.
§Examples
use nethsm::{
CryptographicKeyContext,
KeyMechanism,
KeyType,
OpenPgpUserIdList,
OpenPgpVersion,
SignatureType,
};
CryptographicKeyContext::Raw.validate_signing_key_setup(
KeyType::Curve25519,
&[KeyMechanism::EdDsaSignature],
SignatureType::EdDsa,
)?;
CryptographicKeyContext::OpenPgp {
user_ids: OpenPgpUserIdList::new(vec!["Foobar McFooface <foobar@mcfooface.org>".parse()?])?,
version: OpenPgpVersion::V4,
}
.validate_signing_key_setup(
KeyType::Curve25519,
&[KeyMechanism::EdDsaSignature],
SignatureType::EdDsa,
)?;
// OpenPGP does not support ECDSA P224
assert!(CryptographicKeyContext::OpenPgp {
user_ids: OpenPgpUserIdList::new(vec!["Foobar McFooface <foobar@mcfooface.org>".parse()?])?,
version: OpenPgpVersion::V4,
}
.validate_signing_key_setup(
KeyType::EcP224,
&[KeyMechanism::EcdsaSignature],
SignatureType::EcdsaP224,
)
.is_err());
Trait Implementations§
source§impl Clone for CryptographicKeyContext
impl Clone for CryptographicKeyContext
source§fn clone(&self) -> CryptographicKeyContext
fn clone(&self) -> CryptographicKeyContext
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for CryptographicKeyContext
impl Debug for CryptographicKeyContext
source§impl<'de> Deserialize<'de> for CryptographicKeyContext
impl<'de> Deserialize<'de> for CryptographicKeyContext
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Hash for CryptographicKeyContext
impl Hash for CryptographicKeyContext
source§impl PartialEq for CryptographicKeyContext
impl PartialEq for CryptographicKeyContext
source§impl Serialize for CryptographicKeyContext
impl Serialize for CryptographicKeyContext
impl Eq for CryptographicKeyContext
impl StructuralPartialEq for CryptographicKeyContext
Auto Trait Implementations§
impl Freeze for CryptographicKeyContext
impl RefUnwindSafe for CryptographicKeyContext
impl Send for CryptographicKeyContext
impl Sync for CryptographicKeyContext
impl Unpin for CryptographicKeyContext
impl UnwindSafe for CryptographicKeyContext
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)