pub trait PivBackend: Backend {
// Required methods
fn list_slots(&self) -> Result<Vec<PivSlotInfo>, BackendError>;
fn verify_pin(&mut self, pin: &[u8]) -> Result<(), BackendError>;
fn change_pin(
&mut self,
current: &[u8],
new: &[u8],
) -> Result<(), BackendError>;
fn pin_retries(&mut self) -> Result<u32, BackendError>;
fn unblock_pin(
&mut self,
puk: &[u8],
new_pin: &[u8],
) -> Result<(), BackendError>;
fn device_info(&self) -> Result<PivDeviceInfo, BackendError>;
}Expand description
Personal Identity Verification (PIV) smart card operations.
Models the PIV card application interface defined by FIPS 201-3 and NIST SP 800-73-5. Methods in this trait correspond to PIV card commands and data model operations; their semantics are defined by the standard and should not diverge.
Backends implementing PivBackend should also implement the generic traits
(KeyStoreBackend, SignBackend) for interoperability with non-PIV-aware actions.
§Standard references
- FIPS 201-3: Personal Identity Verification of Federal Employees and Contractors
- NIST SP 800-73-5 Part 1: PIV Card Application Data Model
- NIST SP 800-73-5 Part 2: PIV Card Application Card Command Interface
- NIST SP 800-78-5: Cryptographic Algorithms and Key Sizes for PIV
Required Methods§
Sourcefn list_slots(&self) -> Result<Vec<PivSlotInfo>, BackendError>
fn list_slots(&self) -> Result<Vec<PivSlotInfo>, BackendError>
List populated PIV slots with metadata.
Enumerates key references defined in SP 800-73-5 Part 1, Table 4b.
Sourcefn verify_pin(&mut self, pin: &[u8]) -> Result<(), BackendError>
fn verify_pin(&mut self, pin: &[u8]) -> Result<(), BackendError>
Verify the PIV Card Application PIN.
Required before private key operations on slots with PIN access rules. The PIN is typically 6–8 digits (ASCII-encoded). [SP 800-73-5 Part 2, §3.3: VERIFY command]
Sourcefn change_pin(&mut self, current: &[u8], new: &[u8]) -> Result<(), BackendError>
fn change_pin(&mut self, current: &[u8], new: &[u8]) -> Result<(), BackendError>
Change the PIV Card Application PIN.
[SP 800-73-5 Part 2, §3.4: CHANGE REFERENCE DATA command]
Sourcefn pin_retries(&mut self) -> Result<u32, BackendError>
fn pin_retries(&mut self) -> Result<u32, BackendError>
Get remaining PIN retry count before lockout.
Sourcefn unblock_pin(
&mut self,
puk: &[u8],
new_pin: &[u8],
) -> Result<(), BackendError>
fn unblock_pin( &mut self, puk: &[u8], new_pin: &[u8], ) -> Result<(), BackendError>
Reset a blocked PIN using the PUK (PIN Unblocking Key).
[SP 800-73-5 Part 2, §3.4: RESET RETRY COUNTER command]
Sourcefn device_info(&self) -> Result<PivDeviceInfo, BackendError>
fn device_info(&self) -> Result<PivDeviceInfo, BackendError>
Return device identity (serial, firmware version, form factor).
Not all fields are available on every PIV card. Serial number retrieval is vendor-specific (not standardized by NIST SP 800-73).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".