Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/security-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:
security:
name: Security Audit
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
30 changes: 12 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ base64 = "0.22"
sha2 = "0.10"
blake3 = "1.5"
chrono = { version = "0.4", features = ["serde"] }
cryptoki = "0.10"
cryptoki = "0.11"
rpassword = "7.3"

[dev-dependencies]
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions src/utils/pkcs11_devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Provides unified support for TPM, YubiKey, HSMs, and other PKCS#11-compatible devices.

use anyhow::{Context, Result};
use cryptoki::context::{CInitializeArgs, Pkcs11};
use cryptoki::context::{CInitializeArgs, CInitializeFlags, Pkcs11};
use cryptoki::mechanism::Mechanism;
use cryptoki::object::{Attribute, AttributeType, ObjectClass, ObjectHandle};
use cryptoki::session::{Session, UserType};
Expand Down Expand Up @@ -662,7 +662,7 @@ pub fn init_pkcs11_session(
let pkcs11 = Pkcs11::new(module_path).context("Failed to load PKCS#11 module")?;

pkcs11
.initialize(CInitializeArgs::OsThreads)
.initialize(CInitializeArgs::new(CInitializeFlags::OS_LOCKING_OK))
.context("Failed to initialize PKCS#11")?;

// Find token
Expand All @@ -675,7 +675,7 @@ pub fn init_pkcs11_session(

// Login - auth should contain the PIN already
if !auth.is_empty() {
let auth_pin = AuthPin::new(auth.to_string());
let auth_pin = AuthPin::new(auth.to_string().into());
session
.login(UserType::User, Some(&auth_pin))
.context("Failed to login to PKCS#11 device")?;
Expand Down Expand Up @@ -705,7 +705,7 @@ pub fn delete_pkcs11_key(uri: &str) -> Result<()> {
let pkcs11 = Pkcs11::new(module_path).context("Failed to load PKCS#11 module")?;

pkcs11
.initialize(CInitializeArgs::OsThreads)
.initialize(CInitializeArgs::new(CInitializeFlags::OS_LOCKING_OK))
.context("Failed to initialize PKCS#11")?;

// Find the token
Expand All @@ -719,7 +719,7 @@ pub fn delete_pkcs11_key(uri: &str) -> Result<()> {
// For deletion, we need to login with PIN
let pin_str = rpassword::prompt_password("Enter PIN to delete hardware key: ")
.context("Failed to read PIN")?;
let auth_pin = AuthPin::new(pin_str.clone());
let auth_pin = AuthPin::new(pin_str.clone().into());

session
.login(UserType::User, Some(&auth_pin))
Expand Down Expand Up @@ -808,7 +808,7 @@ pub fn sign_with_pkcs11_device(
if requires_auth {
// Key requires per-operation authentication (common with YubiKey)
// Use the provided PIN for context-specific login
let auth_pin = AuthPin::new(pin.to_string());
let auth_pin = AuthPin::new(pin.to_string().into());

// Context-specific login for this operation
session
Expand Down
4 changes: 2 additions & 2 deletions tests/pkcs11_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ fn test_tpm_connection() {
let _tpm = SwtpmInstance::new().expect("Failed to start TPM simulator");

use avocado_cli::utils::pkcs11_devices::{get_pkcs11_module_path, DeviceType};
use cryptoki::context::{CInitializeArgs, Pkcs11};
use cryptoki::context::{CInitializeArgs, CInitializeFlags, Pkcs11};

let module_path =
get_pkcs11_module_path(&DeviceType::Tpm).expect("Failed to find PKCS#11 module path");
Expand All @@ -262,7 +262,7 @@ fn test_tpm_connection() {
let pkcs11 = Pkcs11::new(module_path).expect("Failed to load PKCS#11 module");

pkcs11
.initialize(CInitializeArgs::OsThreads)
.initialize(CInitializeArgs::new(CInitializeFlags::OS_LOCKING_OK))
.expect("Failed to initialize PKCS#11");

let slots = pkcs11
Expand Down