feat: update pkcs11 piv

This commit is contained in:
2024-07-06 19:44:10 +08:00
parent a77e6ff44e
commit 1b174db255
6 changed files with 219 additions and 480 deletions

View File

@@ -16,6 +16,19 @@
#![allow(clippy::missing_safety_doc)]
#![deny(unsafe_op_in_unsafe_fn)]
use std::{
cmp,
slice,
sync::{
atomic::{AtomicBool, Ordering},
Once,
},
};
use tracing::metadata::LevelFilter;
use tracing_error::ErrorLayer;
use tracing_subscriber::{EnvFilter, fmt::format::FmtSpan, prelude::*, Registry};
use native_pkcs11_core::{
attribute::{Attribute, Attributes},
mechanism::{parse_mechanism, SUPPORTED_SIGNATURE_MECHANISMS},
@@ -26,17 +39,6 @@ use native_pkcs11_traits::backend;
use pkcs11_sys::*;
// Export necessary items for registering a custom Backend.
pub use pkcs11_sys::{CK_FUNCTION_LIST, CK_FUNCTION_LIST_PTR_PTR, CK_RV, CKR_OK};
use std::{
cmp,
slice,
sync::{
atomic::{AtomicBool, Ordering},
Once,
},
};
use tracing::metadata::LevelFilter;
use tracing_error::ErrorLayer;
use tracing_subscriber::{EnvFilter, fmt::format::FmtSpan, prelude::*, Registry};
use crate::{
sessions::{FindContext, SignContext},
@@ -48,11 +50,11 @@ mod sessions;
mod utils;
const LIBRARY_DESCRIPTION: &[u8; 32] = b" ";
const MANUFACTURER_ID: &[u8; 32] = b"google ";
const MANUFACTURER_ID: &[u8; 32] = b"hatter ";
const SLOT_DESCRIPTION: &[u8; 64] =
b"Platform Cryptography Support ";
const SLOT_ID: CK_SLOT_ID = 1;
const TOKEN_MODEL: &[u8; 16] = b"software ";
const TOKEN_MODEL: &[u8; 16] = b"hardware ";
const TOKEN_SERIAL_NUMBER: &[u8; 16] = b"0000000000000000";
static INITIALIZED: AtomicBool = AtomicBool::new(false);
@@ -1076,9 +1078,10 @@ cryptoki_fn_not_supported!(
#[cfg(test)]
pub mod tests {
use serial_test::serial;
use std::ptr;
use serial_test::serial;
use super::*;
pub fn test_init() {