feat: update pkcs11 piv

This commit is contained in:
2024-07-06 21:42:41 +08:00
parent 1b174db255
commit a7bfda9cbf
5 changed files with 92 additions and 422 deletions

View File

@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::fmt::Debug;
use std::fmt::{Debug, Formatter};
pub use backend::YubikeyPivBackend;
use core_foundation::error::CFError;
use native_pkcs11_traits::SignatureAlgorithm;
use thiserror::Error;
use tracing_error::SpanTrace;
pub use backend::YubikeyPivBackend;
use native_pkcs11_traits::SignatureAlgorithm;
mod backend;
pub mod certificate;
pub mod key;
@@ -32,7 +32,7 @@ pub struct Error {
}
impl Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
writeln!(f, "{:?}", self.error)?;
self.context.fmt(f)
}
@@ -50,7 +50,7 @@ impl<E: Into<ErrorKind>> From<E> for Error {
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
writeln!(f, "{}", self.error)?;
std::fmt::Display::fmt(&self.context, f)
}
@@ -80,12 +80,6 @@ pub enum ErrorKind {
UnsupportedSignatureAlgorithm(SignatureAlgorithm),
}
impl From<CFError> for ErrorKind {
fn from(e: CFError) -> Self {
ErrorKind::SecurityFramework(security_framework::base::Error::from_code(e.code() as i32))
}
}
impl From<&str> for ErrorKind {
fn from(s: &str) -> Self {
ErrorKind::Generic(s.to_string())