[−][src]Struct yubihsm::client::Client
YubiHSM client: main API in this crate for accessing functions of the HSM hardware device.
Methods
impl Client
[src]
pub fn open(
connector: Connector,
credentials: Credentials,
reconnect: bool
) -> Result<Self, Error>
[src]
connector: Connector,
credentials: Credentials,
reconnect: bool
) -> Result<Self, Error>
Open a connection via a Connector to a YubiHSM, returning a yubihsm::Client
.
Valid Connector
types are: HttpConnector, UsbConnector, and MockHsm.
pub fn create(
connector: Connector,
credentials: Credentials
) -> Result<Self, Error>
[src]
connector: Connector,
credentials: Credentials
) -> Result<Self, Error>
Create a yubihsm::Client
, but defer connecting until connect()
is called.
pub fn connector(&self) -> &Connector
[src]
Borrow this client's YubiHSM connector (which is Clone
able)
pub fn connect(&self) -> Result<(), Error>
[src]
Connect to the HSM (idempotently, i.e. returns success if we have an open connection already)
pub fn session(&self) -> Result<Guard, Error>
[src]
Get current Session
(either opening a new one or returning an already
open one).
pub fn ping(&self) -> Result<Duration, Error>
[src]
Ping the HSM, ensuring we have a live connection and returning the end-to-end latency.
pub fn blink_device(&self, num_seconds: u8) -> Result<(), Error>
[src]
Blink the HSM's LEDs (to identify it) for the given number of seconds.
https://developers.yubico.com/YubiHSM2/Commands/Blink_Device.html
pub fn delete_object(
&self,
object_id: Id,
object_type: Type
) -> Result<(), Error>
[src]
&self,
object_id: Id,
object_type: Type
) -> Result<(), Error>
Delete an object of the given ID and type.
https://developers.yubico.com/YubiHSM2/Commands/Delete_Object.html
pub fn device_info(&self) -> Result<Info, Error>
[src]
Get information about the HSM device.
https://developers.yubico.com/YubiHSM2/Commands/Device_Info.html
pub fn echo<M>(&self, msg: M) -> Result<Vec<u8>, Error> where
M: Into<Vec<u8>>,
[src]
M: Into<Vec<u8>>,
Echo a message sent to the HSM.
pub fn export_wrapped(
&self,
wrap_key_id: Id,
object_type: Type,
object_id: Id
) -> Result<Message, Error>
[src]
&self,
wrap_key_id: Id,
object_type: Type,
object_id: Id
) -> Result<Message, Error>
Export an encrypted object from the HSM using the given key-wrapping key.
https://developers.yubico.com/YubiHSM2/Commands/Export_Wrapped.html
pub fn generate_asymmetric_key(
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm
) -> Result<Id, Error>
[src]
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm
) -> Result<Id, Error>
Generate a new asymmetric key within the HSM.
https://developers.yubico.com/YubiHSM2/Commands/Generate_Asymmetric_Key.html
pub fn generate_hmac_key(
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm
) -> Result<Id, Error>
[src]
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm
) -> Result<Id, Error>
Generate a new HMAC key within the HSM.
https://developers.yubico.com/YubiHSM2/Commands/Generate_Hmac_Key.html
pub fn generate_wrap_key(
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
delegated_capabilities: Capability,
algorithm: Algorithm
) -> Result<Id, Error>
[src]
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
delegated_capabilities: Capability,
algorithm: Algorithm
) -> Result<Id, Error>
Generate a new wrap key within the HSM.
Delegated capabilities are the set of Capability
bits that an object is allowed to have
when imported or exported using the wrap key.
https://developers.yubico.com/YubiHSM2/Commands/Generate_Wrap_Key.html
pub fn get_log_entries(&self) -> Result<LogEntries, Error>
[src]
Get audit logs from the HSM device.
https://developers.yubico.com/YubiHSM2/Commands/Get_Log_Entries.html
pub fn get_object_info(
&self,
object_id: Id,
object_type: Type
) -> Result<Info, Error>
[src]
&self,
object_id: Id,
object_type: Type
) -> Result<Info, Error>
Get information about an object.
https://developers.yubico.com/YubiHSM2/Commands/Get_Object_Info.html
pub fn get_opaque(&self, object_id: Id) -> Result<Vec<u8>, Error>
[src]
Get an opaque object stored in the HSM.
https://developers.yubico.com/YubiHSM2/Commands/Get_Opaque.html
pub fn get_command_audit_option(
&self,
command: Code
) -> Result<AuditOption, Error>
[src]
&self,
command: Code
) -> Result<AuditOption, Error>
Get the audit policy setting for a particular command.
https://developers.yubico.com/YubiHSM2/Commands/Get_Option.html
pub fn get_commands_audit_options(&self) -> Result<Vec<AuditCommand>, Error>
[src]
Get the audit policy settings for all commands.
https://developers.yubico.com/YubiHSM2/Commands/Get_Option.html
pub fn get_force_audit_option(&self) -> Result<AuditOption, Error>
[src]
Get the forced auditing global option: when enabled, the device will refuse operations if the [log store] becomes full.
https://developers.yubico.com/YubiHSM2/Commands/Get_Option.html [log store]: https://developers.yubico.com/YubiHSM2/Concepts/Logs.html
pub fn get_pseudo_random(&self, bytes: usize) -> Result<Vec<u8>, Error>
[src]
Get some number of bytes of pseudo random data generated on the device.
https://developers.yubico.com/YubiHSM2/Commands/Get_Pseudo_Random.html
pub fn get_public_key(&self, key_id: Id) -> Result<PublicKey, Error>
[src]
Get the public key for an asymmetric key stored on the device.
https://developers.yubico.com/YubiHSM2/Commands/Get_Public_Key.html
pub fn get_storage_info(&self) -> Result<StorageInfo, Error>
[src]
Get storage status (i.e. currently free storage) from the HSM device.
https://developers.yubico.com/YubiHSM2/Commands/Get_Storage_Info.html
pub fn import_wrapped<M>(
&self,
wrap_key_id: Id,
wrap_message: M
) -> Result<Handle, Error> where
M: Into<Message>,
[src]
&self,
wrap_key_id: Id,
wrap_message: M
) -> Result<Handle, Error> where
M: Into<Message>,
Import an encrypted object from the HSM using the given key-wrapping key.
https://developers.yubico.com/YubiHSM2/Commands/Import_Wrapped.html
pub fn list_objects(&self, filters: &[Filter]) -> Result<Vec<Entry>, Error>
[src]
List objects visible from the current session.
Optionally apply a set of provided filters
which select objects
based on their attributes.
https://developers.yubico.com/YubiHSM2/Commands/List_Objects.html
pub fn put_asymmetric_key<K>(
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm,
key_bytes: K
) -> Result<Id, Error> where
K: Into<Vec<u8>>,
[src]
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm,
key_bytes: K
) -> Result<Id, Error> where
K: Into<Vec<u8>>,
Put an existing asymmetric key into the HSM.
https://developers.yubico.com/YubiHSM2/Commands/Put_Asymmetric.html
pub fn put_authentication_key<K>(
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
delegated_capabilities: Capability,
algorithm: Algorithm,
authentication_key: K
) -> Result<Id, Error> where
K: Into<Key>,
[src]
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
delegated_capabilities: Capability,
algorithm: Algorithm,
authentication_key: K
) -> Result<Id, Error> where
K: Into<Key>,
Put an existing authentication::Key
into the HSM.
https://developers.yubico.com/YubiHSM2/Commands/Put_Authentication_Key.html
pub fn put_hmac_key<K>(
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm,
key_bytes: K
) -> Result<Id, Error> where
K: Into<Vec<u8>>,
[src]
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm,
key_bytes: K
) -> Result<Id, Error> where
K: Into<Vec<u8>>,
Put an existing HMAC key into the HSM.
https://developers.yubico.com/YubiHSM2/Commands/Put_Hmac_Key.html
pub fn put_opaque<B>(
&self,
object_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm,
opaque_data: B
) -> Result<Id, Error> where
B: Into<Vec<u8>>,
[src]
&self,
object_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm,
opaque_data: B
) -> Result<Id, Error> where
B: Into<Vec<u8>>,
Put an opaque object (X.509 certificate or other bytestring) into the HSM.
https://developers.yubico.com/YubiHSM2/Commands/Put_Opaque.html
pub fn put_otp_aead_key<K>(
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm,
key_bytes: K
) -> Result<Id, Error> where
K: Into<Vec<u8>>,
[src]
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
algorithm: Algorithm,
key_bytes: K
) -> Result<Id, Error> where
K: Into<Vec<u8>>,
Put an existing OTP AEAD key into the HSM.
https://developers.yubico.com/YubiHSM2/Commands/Put_Otp_Aead_Key.html
pub fn put_wrap_key<K>(
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
delegated_capabilities: Capability,
algorithm: Algorithm,
key_bytes: K
) -> Result<Id, Error> where
K: Into<Vec<u8>>,
[src]
&self,
key_id: Id,
label: Label,
domains: Domain,
capabilities: Capability,
delegated_capabilities: Capability,
algorithm: Algorithm,
key_bytes: K
) -> Result<Id, Error> where
K: Into<Vec<u8>>,
Put an existing wrap key into the HSM.
https://developers.yubico.com/YubiHSM2/Commands/Put_Wrap_Key.html
pub fn reset_device(&self) -> Result<(), Error>
[src]
Reset the HSM to a factory default state and reboot, clearing all stored objects and restoring the default auth key.
WARNING: This wipes all keys and other data from the HSM! Make absolutely sure you want to use this!
https://developers.yubico.com/YubiHSM2/Commands/Reset_Device.html
pub fn reset_device_and_reconnect(
&mut self,
timeout: Duration
) -> Result<(), Error>
[src]
&mut self,
timeout: Duration
) -> Result<(), Error>
Reset the HSM to a factory default state and reboot, clearing all stored objects and restoring the default auth key. This method further attempts to wait for the HSM to finish resetting and then attempts to reauthenticate with the default credentials.
Upon successfully resetting the device and autenticating using the
default administrator credentials in key slot 0x01, a new
yubihsm::Client
is returned.
WARNING: This wipes all keys and other data from the HSM! Make absolutely sure you want to use this!
https://developers.yubico.com/YubiHSM2/Commands/Reset_Device.html
pub fn set_command_audit_option(
&self,
command: Code,
audit_option: AuditOption
) -> Result<(), Error>
[src]
&self,
command: Code,
audit_option: AuditOption
) -> Result<(), Error>
Configure the audit policy settings for a particular command, e.g. auditing
should be On
, Off
, or Fix
(i.e. fixed permanently on).
https://developers.yubico.com/YubiHSM2/Commands/Set_Option.html
pub fn set_force_audit_option(&self, option: AuditOption) -> Result<(), Error>
[src]
Put the forced auditing global option: when enabled, the device will refuse operations if the log store becomes full.
Options are On
, Off
, or Fix
(i.e. fixed permanently on)
https://developers.yubico.com/YubiHSM2/Commands/Put_Option.html
pub fn set_log_index(&self, log_index: u16) -> Result<(), Error>
[src]
Set the index of the last consumed index of the HSM audit log.
https://developers.yubico.com/YubiHSM2/Commands/Set_Log_Index.html
pub fn sign_attestation_certificate(
&self,
key_id: Id,
attestation_key_id: Option<Id>
) -> Result<Certificate, Error>
[src]
&self,
key_id: Id,
attestation_key_id: Option<Id>
) -> Result<Certificate, Error>
Obtain an X.509 attestation certificate for a key within the HSM. This can be used to demonstrate that a given key was generated by and stored within a HSM in a non-exportable manner.
The key_id
is the subject key for which an attestation certificate
is created, and theattestation_key_id
will be used to sign the
attestation certificate.
If no attestation key is given, the device's default attestation key will be used, and can be verified against Yubico's certificate.
https://developers.yubico.com/YubiHSM2/Commands/Sign_Attestation_Certificate.html
pub fn sign_ecdsa<T>(&self, key_id: Id, digest: T) -> Result<Signature, Error> where
T: Into<Vec<u8>>,
[src]
T: Into<Vec<u8>>,
Compute an ECDSA signature of the given digest (i.e. a precomputed SHA-2 digest)
https://developers.yubico.com/YubiHSM2/Commands/Sign_Ecdsa.html
secp256k1 notes
The YubiHSM 2 does not produce signatures in "low S" form, which is expected for most cryptocurrency applications (the typical use case for secp256k1).
If your application demands this (e.g. Bitcoin), you'll need to normalize
the signatures. One option for this is the secp256k1
crate's
[Signature::normalize_s] function.
Normalization functionality is built into the yubihsm::signatory
API
found in this crate (when the secp256k1
feature is enabled).
pub fn sign_ed25519<T>(&self, key_id: Id, data: T) -> Result<Signature, Error> where
T: Into<Vec<u8>>,
[src]
T: Into<Vec<u8>>,
Compute an Ed25519 signature with the given key ID.
https://developers.yubico.com/YubiHSM2/Commands/Sign_Eddsa.html
pub fn sign_hmac<M>(&self, key_id: Id, msg: M) -> Result<Tag, Error> where
M: Into<Vec<u8>>,
[src]
M: Into<Vec<u8>>,
Compute an HMAC tag of the given data with the given key ID.
https://developers.yubico.com/YubiHSM2/Commands/Sign_Hmac.html
pub fn sign_rsa_pkcs1v15_sha256(
&self,
key_id: Id,
data: &[u8]
) -> Result<Signature, Error>
[src]
&self,
key_id: Id,
data: &[u8]
) -> Result<Signature, Error>
Compute an RSASSA-PKCS#1v1.5 signature of the SHA-256 hash of the given data.
WARNING: This method has not been tested and is not confirmed to actually work! Use at your own risk!
https://developers.yubico.com/YubiHSM2/Commands/Sign_Pkcs1.html
pub fn sign_rsa_pss_sha256(
&self,
key_id: Id,
data: &[u8]
) -> Result<Signature, Error>
[src]
&self,
key_id: Id,
data: &[u8]
) -> Result<Signature, Error>
Compute an RSASSA-PSS signature of the SHA-256 hash of the given data with the given key ID.
WARNING: This method has not been tested and is not confirmed to actually work! Use at your own risk!
https://developers.yubico.com/YubiHSM2/Commands/Sign_Pss.html
pub fn unwrap_data<M>(
&self,
wrap_key_id: Id,
wrap_message: M
) -> Result<Vec<u8>, Error> where
M: Into<Message>,
[src]
&self,
wrap_key_id: Id,
wrap_message: M
) -> Result<Vec<u8>, Error> where
M: Into<Message>,
Decrypt data which was encrypted (using AES-CCM) under a wrap key.
https://developers.yubico.com/YubiHSM2/Commands/Unwrap_Data.html
pub fn verify_hmac<M, T>(&self, key_id: Id, msg: M, tag: T) -> Result<(), Error> where
M: Into<Vec<u8>>,
T: Into<Tag>,
[src]
M: Into<Vec<u8>>,
T: Into<Tag>,
Verify an HMAC tag of the given data with the given key ID.
https://developers.yubico.com/YubiHSM2/Commands/Verify_Hmac.html
pub fn wrap_data(
&self,
wrap_key_id: Id,
plaintext: Vec<u8>
) -> Result<Message, Error>
[src]
&self,
wrap_key_id: Id,
plaintext: Vec<u8>
) -> Result<Message, Error>
Encrypt data (with AES-CCM) using the given wrap key.
https://developers.yubico.com/YubiHSM2/Commands/Wrap_Data.html
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self