Skip to content

Commit e76e7ee

Browse files
replace unmaintained packages
1 parent 8407f4c commit e76e7ee

File tree

5 files changed

+24
-27
lines changed

5 files changed

+24
-27
lines changed

.github/workflows/security-reusable.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ jobs:
1010
security:
1111
name: Security Audit
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
issues: write
1316
steps:
1417
- name: Checkout code
1518
uses: actions/checkout@v4

Cargo.lock

Lines changed: 12 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ base64 = "0.22"
5252
sha2 = "0.10"
5353
blake3 = "1.5"
5454
chrono = { version = "0.4", features = ["serde"] }
55-
cryptoki = "0.10"
55+
cryptoki = "0.11"
5656
rpassword = "7.3"
5757

5858
[dev-dependencies]

src/utils/pkcs11_devices.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Provides unified support for TPM, YubiKey, HSMs, and other PKCS#11-compatible devices.
44
55
use anyhow::{Context, Result};
6-
use cryptoki::context::{CInitializeArgs, Pkcs11};
6+
use cryptoki::context::{CInitializeArgs, CInitializeFlags, Pkcs11};
77
use cryptoki::mechanism::Mechanism;
88
use cryptoki::object::{Attribute, AttributeType, ObjectClass, ObjectHandle};
99
use cryptoki::session::{Session, UserType};
@@ -662,7 +662,7 @@ pub fn init_pkcs11_session(
662662
let pkcs11 = Pkcs11::new(module_path).context("Failed to load PKCS#11 module")?;
663663

664664
pkcs11
665-
.initialize(CInitializeArgs::OsThreads)
665+
.initialize(CInitializeArgs::new(CInitializeFlags::OS_LOCKING_OK))
666666
.context("Failed to initialize PKCS#11")?;
667667

668668
// Find token
@@ -675,7 +675,7 @@ pub fn init_pkcs11_session(
675675

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

707707
pkcs11
708-
.initialize(CInitializeArgs::OsThreads)
708+
.initialize(CInitializeArgs::new(CInitializeFlags::OS_LOCKING_OK))
709709
.context("Failed to initialize PKCS#11")?;
710710

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

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

813813
// Context-specific login for this operation
814814
session

tests/pkcs11_integration_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn test_tpm_connection() {
252252
let _tpm = SwtpmInstance::new().expect("Failed to start TPM simulator");
253253

254254
use avocado_cli::utils::pkcs11_devices::{get_pkcs11_module_path, DeviceType};
255-
use cryptoki::context::{CInitializeArgs, Pkcs11};
255+
use cryptoki::context::{CInitializeArgs, CInitializeFlags, Pkcs11};
256256

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

264264
pkcs11
265-
.initialize(CInitializeArgs::OsThreads)
265+
.initialize(CInitializeArgs::new(CInitializeFlags::OS_LOCKING_OK))
266266
.expect("Failed to initialize PKCS#11");
267267

268268
let slots = pkcs11

0 commit comments

Comments
 (0)