Struct yubihsm::session::Session [−][src]
pub struct Session<A: Adapter> { /* fields omitted */ }
Encrypted session with a YubiHSM. A session is needed to perform any command.
Sessions are eneric over Adapter
types in case a different one needs to
be swapped in, which is primarily useful for substituting the MockHsm
.
Sessions are automatically closed on Drop
, releasing YubiHSM2
session
resources and wiping the ephemeral keys used to encrypt the session.
Methods
impl<A: Adapter> Session<A>
[src]
impl<A: Adapter> Session<A>
pub fn create(
config: A::Config,
credentials: Credentials,
reconnect: bool
) -> Result<Self, SessionError>
[src]
pub fn create(
config: A::Config,
credentials: Credentials,
reconnect: bool
) -> Result<Self, SessionError>
Create a new session, eagerly connecting to the YubiHSM
pub fn new(
config: A::Config,
credentials: Credentials
) -> Result<Self, SessionError>
[src]
pub fn new(
config: A::Config,
credentials: Credentials
) -> Result<Self, SessionError>
Initialize a new encrypted session, deferring actually establishing
a session until open()
is called
pub fn open(&mut self) -> Result<(), SessionError>
[src]
pub fn open(&mut self) -> Result<(), SessionError>
Connect to the YubiHSM (if we aren't already connected)
pub fn id(&self) -> Option<SessionId>
[src]
pub fn id(&self) -> Option<SessionId>
Get the current session ID
pub fn is_open(&self) -> bool
[src]
pub fn is_open(&self) -> bool
Do we currently have an open session with the HSM?
pub fn adapter(&mut self) -> Result<&A, SessionError>
[src]
pub fn adapter(&mut self) -> Result<&A, SessionError>
Borrow the adapter for this session (if available)
pub fn serial_number(&mut self) -> Result<SerialNumber, SessionError>
[src]
pub fn serial_number(&mut self) -> Result<SerialNumber, SessionError>
Get the serial number of the underlying HSM, if it's available
Trait Implementations
impl<A: Adapter> Drop for Session<A>
[src]
impl<A: Adapter> Drop for Session<A>
Close session automatically on drop
fn drop(&mut self)
[src]
fn drop(&mut self)
Make a best effort to close the session
NOTE: this runs the potential of panicking in a drop handler, which results in the following when it occurs (Aieee!):
"thread panicked while panicking. aborting"
Because of this, it's very important send_encrypted_command
and
everything it calls be panic-free.