Skip to content

Commit

Permalink
fix: reading args on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nponsard committed Aug 30, 2023
1 parent a78e6f9 commit 607fdd3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pkcs11/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,20 @@ pub extern "C" fn C_Initialize(pInitArgs: CK_VOID_PTR) -> CK_RV {
return cryptoki_sys::CKR_ARGUMENTS_BAD;
}

trace!(
"C_Initialize() called with CKF_OS_LOCKING: {:?}",
args.flags
);
trace!(
"C_Initialize() called with CreateMutex: {:?}",
args.CreateMutex
);
let flags = args.flags;
let CreateMutex = args.CreateMutex;

trace!("C_Initialize() called with flags: {:?}", flags);
trace!("C_Initialize() called with CreateMutex: {:?}", CreateMutex);

// currently we don't support custom locking
// if the flag is not set and the mutex functions are not null, the program asks us to use only the mutex functions, we can't do that
if args.flags & cryptoki_sys::CKF_OS_LOCKING_OK == 0 && args.CreateMutex.is_some() {
if flags & cryptoki_sys::CKF_OS_LOCKING_OK == 0 && CreateMutex.is_some() {
return cryptoki_sys::CKR_CANT_LOCK;
}

// currently we are using tokio that needs to create threads, so if the programs forbids us to create threads we return an error
if args.flags & cryptoki_sys::CKF_LIBRARY_CANT_CREATE_OS_THREADS != 0 {
if flags & cryptoki_sys::CKF_LIBRARY_CANT_CREATE_OS_THREADS != 0 {
return cryptoki_sys::CKR_NEED_TO_CREATE_THREADS;
}
}
Expand Down

0 comments on commit 607fdd3

Please sign in to comment.