pub struct YubiHsm2Backend<'admin_creds, 'config> {
connector: Connector,
runner: ScenarioRunner,
admin_credentials: &'admin_creds YubiHsm2AdminCredentials,
yubihsm2_config: &'config YubiHsm2Config,
admin_user_mappings_and_creds: UserMappingsAndCredentials<'config, 'admin_creds>,
default_credentials: RefCell<bool>,
}Expand description
A YubiHSM2 backend that provides control over a YubiHSM2 and its data.
Using a specific Connector, it is possible to synchronize a YubiHSM2 with the data provided
by a YubiHsm2AdminCredentials and a YubiHsm2Config.
Fields§
§connector: Connector§runner: ScenarioRunner§admin_credentials: &'admin_creds YubiHsm2AdminCredentials§yubihsm2_config: &'config YubiHsm2Config§admin_user_mappings_and_creds: UserMappingsAndCredentials<'config, 'admin_creds>§default_credentials: RefCell<bool>Indication whether the default credentials are in use currently.
Implementations§
Source§impl<'admin_creds, 'config> YubiHsm2Backend<'admin_creds, 'config>
impl<'admin_creds, 'config> YubiHsm2Backend<'admin_creds, 'config>
Sourcepub fn new(
connector: Connector,
admin_credentials: &'admin_creds YubiHsm2AdminCredentials,
signstar_config: &'config Config,
) -> Result<Option<Self>, Error>
pub fn new( connector: Connector, admin_credentials: &'admin_creds YubiHsm2AdminCredentials, signstar_config: &'config Config, ) -> Result<Option<Self>, Error>
Creates a new YubiHsm2Backend.
Returns Ok(None) if signstar_config contains no YubiHsm2Config.
§Errors
Returns an error if
- the iteration of the
admin_credentialsdoes not match that of thesignstar_config - a set of administrative user mappings and corresponding credentials cannot be created from
the
admin_credentialsandsignstar_config
Sourcepub fn yubihsm2_config(&self) -> &YubiHsm2Config
pub fn yubihsm2_config(&self) -> &YubiHsm2Config
Returns a reference to the YubiHsm2Config used for the backend.
Sourcepub fn default_credentials_in_use(&self) -> bool
pub fn default_credentials_in_use(&self) -> bool
Returns whether the default administrative credentials are in use.
§Note
The default administrative credentials are considered no longer in use, if logging in with them failed once.
Sourcefn check_set_default_credentials(&self) -> bool
fn check_set_default_credentials(&self) -> bool
Checks whether the default credentials are in use and sets up YubiHsm2Backend
accordingly.
Returns true, if YubiHsm2AdminCredentials::default_credentials can be used to connect
to the YubiHSM2 and the authentication key object contains the required capabilities and
domains. Returns false in all other cases.
Sourcepub fn sync(&self, user_credentials: &[Credentials]) -> Result<(), Error>
pub fn sync(&self, user_credentials: &[Credentials]) -> Result<(), Error>
Syncs the state of a Signstar configuration with the backend using credentials for users in non-administrative roles.
Sourcefn add_openpgp_certificates(
&self,
non_admin_user_mappings_and_creds: &UserMappingsAndCredentials<'_, '_>,
) -> Result<(), Error>
fn add_openpgp_certificates( &self, non_admin_user_mappings_and_creds: &UserMappingsAndCredentials<'_, '_>, ) -> Result<(), Error>
Adds the OpenPGP certificates for keys that use them.
§Note
Does not overwrite existing data!
§Errors
Returns an error, if
- a usable administrative authentication key cannot be found
- retrieving of opaque data info fails
- creating an OpenPGP certificate for a signgin key fails
- the scenario of adding OpenPGP certificates as opaque data fails
- the return values of the scenario do not match the requested actions
Sourcefn add_signing_keys(&self) -> Result<(), Error>
fn add_signing_keys(&self) -> Result<(), Error>
Adds the asymmetric signing keys.
§Note
Does not overwrite existing signing keys!
§Errors
Returns an error, if
- a usable administrative authentication key cannot be found
- retrieving of signing key info fails
- the scenario of generating asymmetric signging keys fails
- the return values of the scenario do not match the requested actions
Sourcefn add_non_admin_users(
&self,
non_admin_user_mappings_and_creds: &UserMappingsAndCredentials<'_, '_>,
) -> Result<(), Error>
fn add_non_admin_users( &self, non_admin_user_mappings_and_creds: &UserMappingsAndCredentials<'_, '_>, ) -> Result<(), Error>
Adds non-administrative users.
§Note
Existing authentication keys are replaced!
§Errors
Returns an error, if
- a usable administrative authentication key cannot be found
- the list of authentication key objects cannot be retrieved from the backend
- a new authentication key cannot be created
- the scenario cannot be run successfully
- one or more return values of the scenario do not match the requested actions
Sourcefn add_wrap_key(&self) -> Result<(), Error>
fn add_wrap_key(&self) -> Result<(), Error>
Adds a wrap key based on the backup passphrase.
§Note
Existing wrap keys are replaced!
§Errors
Returns an error, if
- usable administrative credentials cannot be found
- infos about wrap keys cannot be retrieved from the backend
- a wrap key cannot be created from the backup passphrase
- running the scenario against the backend fails
- the scenario’s return values do not match the request
Sourcefn add_admin_users(&self) -> Result<(), Error>
fn add_admin_users(&self) -> Result<(), Error>
Sets up all admin users in the backend.
§Note
Existing authentication keys are replaced!
§Errors
Returns an error, if
- no usable administrative credentials can be found
- currently used authentication keys cannot be retrieved from the backend
- the currently used credentials cannot be found in the set of available credentials
- the scenario for removing and/or adding all relevant administrative authentication keys fails
- the return values for the scenario do not match the requested actions
- the default admin credentials are still usable at the end of this function
Sourcefn usable_admin_creds(&self) -> Result<Credentials, Error>
fn usable_admin_creds(&self) -> Result<Credentials, Error>
Returns the currently usable credentials for an administrative user.
§Errors
Returns an error, if no usable administrative credentials are found.
Sourcepub(crate) fn user_states(&self) -> Result<Vec<YubiHsm2BackendUserData>, Error>
pub(crate) fn user_states(&self) -> Result<Vec<YubiHsm2BackendUserData>, Error>
Returns the list of available authentication key objects in the backend.
§Errors
Returns an error, if
- no usable administrative credentials can be found
- retrieving the information on authentication key objects fails.
Sourcepub(crate) fn key_states(
&self,
) -> Result<Vec<YubiHsm2BackendUserKeyData>, Error>
pub(crate) fn key_states( &self, ) -> Result<Vec<YubiHsm2BackendUserKeyData>, Error>
Returns the list of available non-authentication key objects in the backend.
§Errors
Returns an error if
- no usable administrative credentials can be found
- the fetching of one or more object infos fails
Trait Implementations§
Source§impl<'admin_creds, 'config> Debug for YubiHsm2Backend<'admin_creds, 'config>
impl<'admin_creds, 'config> Debug for YubiHsm2Backend<'admin_creds, 'config>
Source§impl<'admin_creds, 'config> TryFrom<&YubiHsm2Backend<'admin_creds, 'config>> for YubiHsm2BackendState
impl<'admin_creds, 'config> TryFrom<&YubiHsm2Backend<'admin_creds, 'config>> for YubiHsm2BackendState
Source§fn try_from(
value: &YubiHsm2Backend<'admin_creds, 'config>,
) -> Result<Self, Self::Error>
fn try_from( value: &YubiHsm2Backend<'admin_creds, 'config>, ) -> Result<Self, Self::Error>
Creates a new YubiHsm2BackendState from a YubiHsm2Backend.
§Errors
Returns an error if retrieving the user or key states from the backend fails.
Auto Trait Implementations§
impl<'admin_creds, 'config> !Freeze for YubiHsm2Backend<'admin_creds, 'config>
impl<'admin_creds, 'config> !RefUnwindSafe for YubiHsm2Backend<'admin_creds, 'config>
impl<'admin_creds, 'config> !Sync for YubiHsm2Backend<'admin_creds, 'config>
impl<'admin_creds, 'config> !UnwindSafe for YubiHsm2Backend<'admin_creds, 'config>
impl<'admin_creds, 'config> Send for YubiHsm2Backend<'admin_creds, 'config>
impl<'admin_creds, 'config> Unpin for YubiHsm2Backend<'admin_creds, 'config>
impl<'admin_creds, 'config> UnsafeUnpin for YubiHsm2Backend<'admin_creds, 'config>
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.