pub struct HsmKeyPair { /* private fields */ }Expand description
HSM key pair reference.
Implementations§
Source§impl HsmKeyPair
impl HsmKeyPair
Sourcepub fn generate(
slot: &HsmSlot,
algorithm: KeyAlgorithm,
label: &str,
id: &[u8],
provider_config: &HsmProviderConfig,
pqc_mechanisms: &PqcMechanismIds,
) -> HsmResult<Self>
pub fn generate( slot: &HsmSlot, algorithm: KeyAlgorithm, label: &str, id: &[u8], provider_config: &HsmProviderConfig, pqc_mechanisms: &PqcMechanismIds, ) -> HsmResult<Self>
Generate a new key pair.
§Arguments
slot- HSM slotalgorithm- Key algorithmlabel- Key label (CKA_LABEL)id- Key ID (CKA_ID), typically SHA-1 hash of public keyprovider_config- Provider configuration (for PQC mechanism IDs)
§NIAP CA PP Compliance
Generated keys MUST have:
CKA_EXTRACTABLE = false(FCS_CKM.1)CKA_SENSITIVE = true(FCS_CKM.1)
§Errors
Returns HsmError::PqcNotSupported if the HSM does not support the requested
PQC algorithm and fallback to software is not enabled.
Sourcepub fn find_by_label(
slot: &HsmSlot,
label: &str,
algorithm: KeyAlgorithm,
) -> HsmResult<Self>
pub fn find_by_label( slot: &HsmSlot, label: &str, algorithm: KeyAlgorithm, ) -> HsmResult<Self>
Find a key pair by label.
Sourcepub fn find_by_id(
slot: &HsmSlot,
id: &[u8],
algorithm: KeyAlgorithm,
) -> HsmResult<Self>
pub fn find_by_id( slot: &HsmSlot, id: &[u8], algorithm: KeyAlgorithm, ) -> HsmResult<Self>
Find a key pair by CKA_ID.
Sourcepub fn from_uri(
slot: &HsmSlot,
uri: &str,
algorithm: KeyAlgorithm,
) -> HsmResult<Self>
pub fn from_uri( slot: &HsmSlot, uri: &str, algorithm: KeyAlgorithm, ) -> HsmResult<Self>
Parse a PKCS#11 URI and find the corresponding key.
§URI Format
pkcs11:token=MyToken;object=MyKey;type=private
Supported attributes:
token- Token labelobject- Key label (CKA_LABEL)id- Key ID (CKA_ID, hex-encoded)type- Object type (private, public, cert)
Sourcepub fn private_key(&self) -> ObjectHandle
pub fn private_key(&self) -> ObjectHandle
Get the private key handle.
Sourcepub fn public_key(&self) -> ObjectHandle
pub fn public_key(&self) -> ObjectHandle
Get the public key handle.
Sourcepub fn algorithm(&self) -> KeyAlgorithm
pub fn algorithm(&self) -> KeyAlgorithm
Get the key algorithm.
Auto Trait Implementations§
impl Freeze for HsmKeyPair
impl !RefUnwindSafe for HsmKeyPair
impl Send for HsmKeyPair
impl !Sync for HsmKeyPair
impl Unpin for HsmKeyPair
impl UnsafeUnpin for HsmKeyPair
impl !UnwindSafe for HsmKeyPair
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