Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkcs11.open_session_no_callback against Luna Network HSM crashed with SIGSEGV #72

Closed
hansonchar opened this issue Dec 6, 2021 · 23 comments

Comments

@hansonchar
Copy link

hansonchar commented Dec 6, 2021

It doesn’t seem rust-cryptoki can be used to open a pkcs11 session to the Thales eLab, i.e. Luna Network HSM without ending up in (signal: 11, SIGSEGV: invalid memory reference).

Sample unit test:

extern crate cryptoki;

use cryptoki::Pkcs11;
use cryptoki::types::slot_token::Slot;
use cryptoki::types::locking::CInitializeArgs;
use cryptoki::types::Flags;
use std::env;

fn open_session() -> (Pkcs11, Slot) {
    let pkcs11 = Pkcs11::new(
        env::var("PKCS11_HSM_MODULE")
            .unwrap_or_else(|_| "/usr/safenet/lunaclient/lib/libCryptoki2_64.so".to_string()),
    )
    .unwrap();

    // initialize the library
    pkcs11.initialize(CInitializeArgs::OsThreads).unwrap();

    // find a slot, get the first one
    let slot = pkcs11.get_slots_with_token().unwrap().remove(0);

    println!("slot: {}", slot.id());

    // set flags
    let mut flags = Flags::new();
    let _ = flags.set_rw_session(true).set_serial_session(true);

    {
        pkcs11.open_session_no_callback(slot, flags).unwrap();
    }

    (pkcs11, slot)
}

#[test]
#[serial]
fn test_open_session() {
    open_session();
}

Test run and failure

# Centos 7
$ cargo test -- --nocapture
running 1 test
slot: 0
error: test failed, to rerun pass '--bin xks-proxy'

Caused by:
  process didn't exit successfully: `/local/centos/ThalesElab/rust/target/debug/deps/my_project-be90c88b811a4002 --nocapture` (signal: 11, SIGSEGV: invalid memory reference)

Note

  1. I can open the session in pure C without issue.
  2. Switching between rust stable vs nightly build doesn't seem to make any difference.

Also, changing the libloading dependency to open the .so file from:

Library::open(Some(filename), RTLD_LAZY | RTLD_LOCAL)

to:

Library::open(Some(filename), RTLD_NOW)

doesn't seem to make any difference.

@ionut-arm
Copy link
Member

ionut-arm commented Dec 6, 2021

Hi,

Thanks for reporting the issue! Is there any way for us to reproduce this locally? Otherwise we'll probably need a backtrace for that.

Something that might help is a copy of the code you use in C to do the same thing, as it might be some of our conventions/defaults that are at fault here.

Also, could you please let us know the version of the crate you're using - is it the from crates.io or some commit on main?

@ionut-arm
Copy link
Member

ionut-arm commented Dec 6, 2021

I'm also wondering if it could be related to #70

@ionut-arm
Copy link
Member

Something that might help is a copy of the code you use in C to do the same thing

As an alternative/on top of that, you could try and run both the C and Rust examples using the pkcs11-logger library.

@hansonchar
Copy link
Author

hansonchar commented Dec 6, 2021

Interestingly, the crash is gone (in opening session) when pkcs11-logger is in use, and it crashes again when I remove the use of pkcs11-logger.

$ export PKCS11_HSM_MODULE="/local/centos/pkcs11-logger/build/linux/pkcs11-logger-x64.so"
$ export PKCS11_LOGGER_LIBRARY_PATH="/usr/safenet/lunaclient/lib/libCryptoki2_64.so"
$ export PKCS11_LOGGER_LOG_FILE_PATH="/local/centos/logs/pkcs11-logger-output.log"
$ cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.10s
     Running unittests (target/debug/deps/my_project-8a5e42cd16d7b0c2)

running 1 test
test tests::test_open_session ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.85s

# It crashed again when I removed the use of `pkcs11-logger`
$ export PKCS11_HSM_MODULE="/usr/safenet/lunaclient/lib/libCryptoki2_64.so"
$ cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.10s
     Running unittests (target/debug/deps/my_project-8a5e42cd16d7b0c2)

running 1 test
error: test failed, to rerun pass '--bin my_project'

Caused by:
  process didn't exit successfully: `/local/centos/my_project/rust/target/debug/deps/my_project-8a5e42cd16d7b0c2` (signal: 11, SIGSEGV: invalid memory reference)

This is the pkcs11-logger's output:

0x000054e9 : 0x27c04700 : ****************************** 2021-12-06 18:32:38 ***
0x000054e9 : 0x27c04700 : PKCS11-LOGGER 2.2.0
0x000054e9 : 0x27c04700 : PKCS#11 logging proxy module
0x000054e9 : 0x27c04700 : Developed as a part of the Pkcs11Interop project
0x000054e9 : 0x27c04700 : Please visit www.pkcs11interop.net for more information
0x000054e9 : 0x27c04700 : ****************************** 2021-12-06 18:32:38 ***
0x000054e9 : 0x27c04700 : Successfuly loaded /usr/safenet/lunaclient/lib/libCryptoki2_64.so
0x000054e9 : 0x27c04700 : Memory contents are dumped without endianness conversion
0x000054e9 : 0x27c04700 : ****************************** 2021-12-06 18:32:38 ***
0x000054e9 : 0x27c04700 : Calling C_GetFunctionList
0x000054e9 : 0x27c04700 : Input
0x000054e9 : 0x27c04700 :  ppFunctionList: 0x7f0427c02258
0x000054e9 : 0x27c04700 : Output
0x000054e9 : 0x27c04700 :  Note: Returning function list of PKCS11-LOGGER
0x000054e9 : 0x27c04700 : Returning 0 (CKR_OK)
0x000054e9 : 0x27c04700 : ****************************** 2021-12-06 18:32:38 ***
0x000054e9 : 0x27c04700 : Calling C_Initialize
0x000054e9 : 0x27c04700 : Input
0x000054e9 : 0x27c04700 :  pInitArgs: 0x7f0427c02838
0x000054e9 : 0x27c04700 :   CreateMutex: (nil)
0x000054e9 : 0x27c04700 :   DestroyMutex: (nil)
0x000054e9 : 0x27c04700 :   LockMutex: (nil)
0x000054e9 : 0x27c04700 :   UnlockMutex: (nil)
0x000054e9 : 0x27c04700 :   Flags: 2
0x000054e9 : 0x27c04700 :    CKF_LIBRARY_CANT_CREATE_OS_THREADS: FALSE
0x000054e9 : 0x27c04700 :    CKF_OS_LOCKING_OK: TRUE
0x000054e9 : 0x27c04700 :   pReserved: (nil)
0x000054e9 : 0x27c04700 : Returning 0 (CKR_OK)
0x000054e9 : 0x27c04700 : ****************************** 2021-12-06 18:32:39 ***
0x000054e9 : 0x27c04700 : Calling C_GetSlotList
0x000054e9 : 0x27c04700 : Input
0x000054e9 : 0x27c04700 :  tokenPresent: 1
0x000054e9 : 0x27c04700 :  pSlotList: (nil)
0x000054e9 : 0x27c04700 :  pulCount: 0x7f0427c024d0
0x000054e9 : 0x27c04700 :  *pulCount: 0
0x000054e9 : 0x27c04700 : Output
0x000054e9 : 0x27c04700 :  pSlotList: (nil)
0x000054e9 : 0x27c04700 :  pulCount: 0x7f0427c024d0
0x000054e9 : 0x27c04700 :  *pulCount: 1
0x000054e9 : 0x27c04700 : Returning 0 (CKR_OK)
0x000054e9 : 0x27c04700 : ****************************** 2021-12-06 18:32:39 ***
0x000054e9 : 0x27c04700 : Calling C_GetSlotList
0x000054e9 : 0x27c04700 : Input
0x000054e9 : 0x27c04700 :  tokenPresent: 1
0x000054e9 : 0x27c04700 :  pSlotList: 0x7f04200415c0
0x000054e9 : 0x27c04700 :  pulCount: 0x7f0427c024d0
0x000054e9 : 0x27c04700 :  *pulCount: 1
0x000054e9 : 0x27c04700 : Output
0x000054e9 : 0x27c04700 :  pSlotList: 0x7f04200415c0
0x000054e9 : 0x27c04700 :  pSlotList[0]: 0
0x000054e9 : 0x27c04700 :  pulCount: 0x7f0427c024d0
0x000054e9 : 0x27c04700 :  *pulCount: 1
0x000054e9 : 0x27c04700 : Returning 0 (CKR_OK)
0x000054e9 : 0x27c04700 : ****************************** 2021-12-06 18:32:39 ***
0x000054e9 : 0x27c04700 : Calling C_OpenSession
0x000054e9 : 0x27c04700 : Input
0x000054e9 : 0x27c04700 :  slotID: 0
0x000054e9 : 0x27c04700 :  flags: 6
0x000054e9 : 0x27c04700 :   CKF_RW_SESSION: TRUE
0x000054e9 : 0x27c04700 :   CKF_SERIAL_SESSION: TRUE
0x000054e9 : 0x27c04700 :  pApplication: (nil)
0x000054e9 : 0x27c04700 :  Notify: (nil)
0x000054e9 : 0x27c04700 :  phSession: 0x7f0427c02770
0x000054e9 : 0x27c04700 :  *phSession: 139655823501168
0x000054e9 : 0x27c04700 : Output
0x000054e9 : 0x27c04700 :  phSession: 0x7f0427c02770
0x000054e9 : 0x27c04700 :  *phSession: 1
0x000054e9 : 0x27c04700 : Returning 0 (CKR_OK)
0x000054e9 : 0x27c04700 : ****************************** 2021-12-06 18:32:39 ***
0x000054e9 : 0x27c04700 : Calling C_CloseSession
0x000054e9 : 0x27c04700 : Input
0x000054e9 : 0x27c04700 :  hSession: 1
0x000054e9 : 0x27c04700 : Returning 0 (CKR_OK)
0x000054e9 : 0x27c04700 : ****************************** 2021-12-06 18:32:39 ***
0x000054e9 : 0x27c04700 : Calling C_Finalize
0x000054e9 : 0x27c04700 : Input
0x000054e9 : 0x27c04700 :  pReserved: (nil)
0x000054e9 : 0x27c04700 : Returning 0 (CKR_OK)

@hansonchar
Copy link
Author

hansonchar commented Dec 6, 2021

Also, could you please let us know the version of the crate you're using - is it the from crates.io or some commit on main?

I tried both the one from crates.io, and directly pointing to the latest tip of the git repository. Both ended up with the same crash.

# https://crates.io/crates/cryptoki
cryptoki = "0.2.0"

@hansonchar
Copy link
Author

hansonchar commented Dec 7, 2021

As a temporary stopgap, instead of specifying the target SO file directly from rust-cryptoki, specify the pkcs11-logger's SO file instead and then disable the logging via

export PKCS11_LOGGER_FLAGS="1"

I suspect there is a bug somewhere in how the rust stack is loading or accessing the SO file. Perhaps in the libloading crate?

@hansonchar
Copy link
Author

BTW, I just tried calling session.get_attributes with more than one attribute specified, and got back a failure of NotSupported. This suggests multiple attribute retrieval is not yet supported by this crate. Correct?

Let me check out the current situation with the pkcs11 crate ...

@ionut-arm
Copy link
Member

I suspect there is a bug somewhere in how the rust stack is loading or accessing the SO file. Perhaps in the libloading crate?

Interestingly, there's this open issue on their repo. Their workaround seems to be to use RTLD_NODELETE along with RTLD_NOW.

BTW, I just tried calling session.get_attributes with more than one attribute specified, and got back a failure of NotSupported. This suggests multiple attribute retrieval is not yet supported by this crate. Correct?

That's... odd. We do support multiple attributes - the one thing we don't support, I think, is vendor-defined attributes, but I don't think there's a way to pass that to get_attributes in the first place (for now). I'm guessing the pkcs11 crate will work because it doesn't do any conversions in the middle, which is probably what's going on here. Could you share the list of attribute types you're calling that with?

@hansonchar
Copy link
Author

hansonchar commented Dec 7, 2021

That's... odd. We do support multiple attributes

Running the unit test below would result in the NotSupported failure when trying to get multiple attributes in a single call.

Environment

$ cargo tree | grep cryptoki
├── cryptoki v0.2.0
│   ├── cryptoki-sys v0.1.2

$ hostnamectl
  ...
  Operating System: CentOS Linux 7 (Core)
  CPE OS Name: cpe:/o:centos:centos:7
  Kernel: Linux 3.10.0-1160.45.1.el7.x86_64
  Architecture: x86-64

$ rustc --version
rustc 1.57.0 (f1edd0429 2021-11-29)

Unit Test

extern crate cryptoki;

use cryptoki::Pkcs11;
use cryptoki::types::slot_token::Slot;
use cryptoki::types::locking::CInitializeArgs;
use cryptoki::types::Flags;
use cryptoki::types::session::UserType;
use cryptoki::types::object::Attribute;
use cryptoki::types::object::AttributeType;
use cryptoki::types::object::ObjectClass;
use cryptoki::types::Bbool;
use std::env;

#[derive(Debug)]
struct ErrorWithStacktrace;

impl<T: std::error::Error> From<T> for ErrorWithStacktrace {
    fn from(p: T) -> Self {
        panic!("Error: {:#?}", p);
    }
}

type Result<T> = std::result::Result<T, ErrorWithStacktrace>;

fn init_pkcs11() -> (Pkcs11, Slot) {
    let pkcs11 = Pkcs11::new(
        env::var("PKCS11_HSM_MODULE")
            .unwrap_or_else(|_| "/usr/safenet/lunaclient/lib/libCryptoki2_64.so".to_string()),
    ).unwrap();

    // initialize the library
    pkcs11.initialize(CInitializeArgs::OsThreads).unwrap();

    // find a slot, get the first one
    let slot = pkcs11.get_slots_with_token().unwrap().remove(0);
    println!("slot: {}", slot.id());

    let passwd = env::var("passwd").unwrap_or_else(|_| "".to_string());
    let _ = pkcs11.set_pin(slot, &passwd);

    (pkcs11, slot)
}

#[test]
#[serial]
fn find_secret_key_by_label() -> Result<()> {
    let (pkcs11, slot) = init_pkcs11();
    // set flags
    let mut flags = Flags::new();
    flags.set_rw_session(true).set_serial_session(true);
    // open a session
    let session = pkcs11.open_session_no_callback(slot, flags).unwrap();

    // log in the session
    session.login(UserType::User).unwrap();
    let key_label: String = "foo".to_owned();

    let template = vec![
        Attribute::Token(Bbool::True),
        Attribute::Class(ObjectClass::SECRET_KEY),
        Attribute::Label(key_label.into_bytes())
    ];

    let secret_key = session.find_objects(&template)?.remove(0);

    let attributes_result = session
        .get_attributes(secret_key, &[AttributeType::KeyType, AttributeType::ValueLen]);

    match attributes_result {
        Ok(attributes) => println!("working with version: {:?}", attributes),
        Err(e) => println!("error getting attributes: {:?}", e),
    }

    Ok(())
}

Running

export PKCS11_HSM_MODULE="/local/centos/pkcs11-logger/build/linux/pkcs11-logger-x64.so"
export PKCS11_LOGGER_LIBRARY_PATH="/usr/safenet/lunaclient/lib/libCryptoki2_64.so"
export PKCS11_LOGGER_LOG_FILE_PATH="/local/centos/logs/pkcs11-logger-output.log"
export passwd="<omitted>"
$ cargo test -- --nocapture
    Finished test [unoptimized + debuginfo] target(s) in 0.11s
     Running unittests (target/debug/deps/my_project-8a5e42cd16d7b0c2)

running 1 test
slot: 0
error getting attributes: NotSupported
test tests::find_secret_key_by_label ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.46s

pkcs11-logger-output.log

ip-192-0-0-138.ec2.internal:~/logs$ cat pkcs11-logger-output.log
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:13 ***
0x000172a2 : 0xeb75b700 : PKCS11-LOGGER 2.2.0
0x000172a2 : 0xeb75b700 : PKCS#11 logging proxy module
0x000172a2 : 0xeb75b700 : Developed as a part of the Pkcs11Interop project
0x000172a2 : 0xeb75b700 : Please visit www.pkcs11interop.net for more information
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:13 ***
0x000172a2 : 0xeb75b700 : Successfuly loaded /usr/safenet/lunaclient/lib/libCryptoki2_64.so
0x000172a2 : 0xeb75b700 : Memory contents are dumped without endianness conversion
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:13 ***
0x000172a2 : 0xeb75b700 : Calling C_GetFunctionList
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  ppFunctionList: 0x7fbdeb758b08
0x000172a2 : 0xeb75b700 : Output
0x000172a2 : 0xeb75b700 :  Note: Returning function list of PKCS11-LOGGER
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:13 ***
0x000172a2 : 0xeb75b700 : Calling C_Initialize
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  pInitArgs: 0x7fbdeb7590e8
0x000172a2 : 0xeb75b700 :   CreateMutex: (nil)
0x000172a2 : 0xeb75b700 :   DestroyMutex: (nil)
0x000172a2 : 0xeb75b700 :   LockMutex: (nil)
0x000172a2 : 0xeb75b700 :   UnlockMutex: (nil)
0x000172a2 : 0xeb75b700 :   Flags: 2
0x000172a2 : 0xeb75b700 :    CKF_LIBRARY_CANT_CREATE_OS_THREADS: FALSE
0x000172a2 : 0xeb75b700 :    CKF_OS_LOCKING_OK: TRUE
0x000172a2 : 0xeb75b700 :   pReserved: (nil)
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_GetSlotList
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  tokenPresent: 1
0x000172a2 : 0xeb75b700 :  pSlotList: (nil)
0x000172a2 : 0xeb75b700 :  pulCount: 0x7fbdeb758d80
0x000172a2 : 0xeb75b700 :  *pulCount: 0
0x000172a2 : 0xeb75b700 : Output
0x000172a2 : 0xeb75b700 :  pSlotList: (nil)
0x000172a2 : 0xeb75b700 :  pulCount: 0x7fbdeb758d80
0x000172a2 : 0xeb75b700 :  *pulCount: 1
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_GetSlotList
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  tokenPresent: 1
0x000172a2 : 0xeb75b700 :  pSlotList: 0x7fbde4040540
0x000172a2 : 0xeb75b700 :  pulCount: 0x7fbdeb758d80
0x000172a2 : 0xeb75b700 :  *pulCount: 1
0x000172a2 : 0xeb75b700 : Output
0x000172a2 : 0xeb75b700 :  pSlotList: 0x7fbde4040540
0x000172a2 : 0xeb75b700 :  pSlotList[0]: 0
0x000172a2 : 0xeb75b700 :  pulCount: 0x7fbdeb758d80
0x000172a2 : 0xeb75b700 :  *pulCount: 1
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_OpenSession
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  slotID: 0
0x000172a2 : 0xeb75b700 :  flags: 6
0x000172a2 : 0xeb75b700 :   CKF_RW_SESSION: TRUE
0x000172a2 : 0xeb75b700 :   CKF_SERIAL_SESSION: TRUE
0x000172a2 : 0xeb75b700 :  pApplication: (nil)
0x000172a2 : 0xeb75b700 :  Notify: (nil)
0x000172a2 : 0xeb75b700 :  phSession: 0x7fbdeb759ae0
0x000172a2 : 0xeb75b700 :  *phSession: 140453675899616
0x000172a2 : 0xeb75b700 : Output
0x000172a2 : 0xeb75b700 :  phSession: 0x7fbdeb759ae0
0x000172a2 : 0xeb75b700 :  *phSession: 1
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_Login
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  hSession: 1
0x000172a2 : 0xeb75b700 :  userType: 1 (CKU_USER)
0x000172a2 : 0xeb75b700 :  pPin: 0x7fbde4040540
0x000172a2 : 0xeb75b700 :  *pPin: *** Intentionally hidden ***
0x000172a2 : 0xeb75b700 :  ulPinLen: 8
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_FindObjectsInit
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  hSession: 1
0x000172a2 : 0xeb75b700 :  pTemplate: 0x7fbde4030c30
0x000172a2 : 0xeb75b700 :  ulCount: 3
0x000172a2 : 0xeb75b700 :   *** Begin attribute template ***
0x000172a2 : 0xeb75b700 :   Attribute 0
0x000172a2 : 0xeb75b700 :    Attribute: 1 (CKA_TOKEN)
0x000172a2 : 0xeb75b700 :    pValue: 0x7fbde4030bc1
0x000172a2 : 0xeb75b700 :    ulValueLen: 1
0x000172a2 : 0xeb75b700 :    *pValue: HEX(01)
0x000172a2 : 0xeb75b700 :   Attribute 1
0x000172a2 : 0xeb75b700 :    Attribute: 0 (CKA_CLASS)
0x000172a2 : 0xeb75b700 :    pValue: 0x7fbde4030be8
0x000172a2 : 0xeb75b700 :    ulValueLen: 8
0x000172a2 : 0xeb75b700 :    *pValue: HEX(0400000000000000)
0x000172a2 : 0xeb75b700 :   Attribute 2
0x000172a2 : 0xeb75b700 :    Attribute: 3 (CKA_LABEL)
0x000172a2 : 0xeb75b700 :    pValue: 0x7fbde4040560
0x000172a2 : 0xeb75b700 :    ulValueLen: 3
0x000172a2 : 0xeb75b700 :    *pValue: HEX(666F6F)
0x000172a2 : 0xeb75b700 :   *** End attribute template ***
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_FindObjects
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  hSession: 1
0x000172a2 : 0xeb75b700 :  phObject: 0x7fbdeb7595c0
0x000172a2 : 0xeb75b700 :  ulMaxObjectCount: 10
0x000172a2 : 0xeb75b700 :  pulObjectCount: 0x7fbdeb759610
0x000172a2 : 0xeb75b700 :  *pulObjectCount: 0
0x000172a2 : 0xeb75b700 :   *phObject[0]: 0
0x000172a2 : 0xeb75b700 :   *phObject[1]: 0
0x000172a2 : 0xeb75b700 :   *phObject[2]: 0
0x000172a2 : 0xeb75b700 :   *phObject[3]: 0
0x000172a2 : 0xeb75b700 :   *phObject[4]: 0
0x000172a2 : 0xeb75b700 :   *phObject[5]: 0
0x000172a2 : 0xeb75b700 :   *phObject[6]: 0
0x000172a2 : 0xeb75b700 :   *phObject[7]: 0
0x000172a2 : 0xeb75b700 :   *phObject[8]: 0
0x000172a2 : 0xeb75b700 :   *phObject[9]: 0
0x000172a2 : 0xeb75b700 : Output
0x000172a2 : 0xeb75b700 :  phObject: 0x7fbdeb7595c0
0x000172a2 : 0xeb75b700 :  ulMaxObjectCount: 10
0x000172a2 : 0xeb75b700 :  pulObjectCount: 0x7fbdeb759610
0x000172a2 : 0xeb75b700 :  *pulObjectCount: 1
0x000172a2 : 0xeb75b700 :   *phObject[0]: 1090
0x000172a2 : 0xeb75b700 :   *phObject[1]: 0
0x000172a2 : 0xeb75b700 :   *phObject[2]: 0
0x000172a2 : 0xeb75b700 :   *phObject[3]: 0
0x000172a2 : 0xeb75b700 :   *phObject[4]: 0
0x000172a2 : 0xeb75b700 :   *phObject[5]: 0
0x000172a2 : 0xeb75b700 :   *phObject[6]: 0
0x000172a2 : 0xeb75b700 :   *phObject[7]: 0
0x000172a2 : 0xeb75b700 :   *phObject[8]: 0
0x000172a2 : 0xeb75b700 :   *phObject[9]: 0
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_FindObjects
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  hSession: 1
0x000172a2 : 0xeb75b700 :  phObject: 0x7fbdeb7595c0
0x000172a2 : 0xeb75b700 :  ulMaxObjectCount: 10
0x000172a2 : 0xeb75b700 :  pulObjectCount: 0x7fbdeb759610
0x000172a2 : 0xeb75b700 :  *pulObjectCount: 1
0x000172a2 : 0xeb75b700 :   *phObject[0]: 1090
0x000172a2 : 0xeb75b700 :   *phObject[1]: 0
0x000172a2 : 0xeb75b700 :   *phObject[2]: 0
0x000172a2 : 0xeb75b700 :   *phObject[3]: 0
0x000172a2 : 0xeb75b700 :   *phObject[4]: 0
0x000172a2 : 0xeb75b700 :   *phObject[5]: 0
0x000172a2 : 0xeb75b700 :   *phObject[6]: 0
0x000172a2 : 0xeb75b700 :   *phObject[7]: 0
0x000172a2 : 0xeb75b700 :   *phObject[8]: 0
0x000172a2 : 0xeb75b700 :   *phObject[9]: 0
0x000172a2 : 0xeb75b700 : Output
0x000172a2 : 0xeb75b700 :  phObject: 0x7fbdeb7595c0
0x000172a2 : 0xeb75b700 :  ulMaxObjectCount: 10
0x000172a2 : 0xeb75b700 :  pulObjectCount: 0x7fbdeb759610
0x000172a2 : 0xeb75b700 :  *pulObjectCount: 0
0x000172a2 : 0xeb75b700 :   *phObject[0]: 1090
0x000172a2 : 0xeb75b700 :   *phObject[1]: 0
0x000172a2 : 0xeb75b700 :   *phObject[2]: 0
0x000172a2 : 0xeb75b700 :   *phObject[3]: 0
0x000172a2 : 0xeb75b700 :   *phObject[4]: 0
0x000172a2 : 0xeb75b700 :   *phObject[5]: 0
0x000172a2 : 0xeb75b700 :   *phObject[6]: 0
0x000172a2 : 0xeb75b700 :   *phObject[7]: 0
0x000172a2 : 0xeb75b700 :   *phObject[8]: 0
0x000172a2 : 0xeb75b700 :   *phObject[9]: 0
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_FindObjectsFinal
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  hSession: 1
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_GetAttributeValue
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  hSession: 1
0x000172a2 : 0xeb75b700 :  hObject: 1090
0x000172a2 : 0xeb75b700 :  pTemplate: 0x7fbde4060640
0x000172a2 : 0xeb75b700 :  ulCount: 2
0x000172a2 : 0xeb75b700 :   *** Begin attribute template ***
0x000172a2 : 0xeb75b700 :   Attribute 0
0x000172a2 : 0xeb75b700 :    Attribute: 256 (CKA_KEY_TYPE)
0x000172a2 : 0xeb75b700 :    pValue: (nil)
0x000172a2 : 0xeb75b700 :    ulValueLen: 0
0x000172a2 : 0xeb75b700 :   Attribute 1
0x000172a2 : 0xeb75b700 :    Attribute: 353 (CKA_VALUE_LEN)
0x000172a2 : 0xeb75b700 :    pValue: (nil)
0x000172a2 : 0xeb75b700 :    ulValueLen: 0
0x000172a2 : 0xeb75b700 :   *** End attribute template ***
0x000172a2 : 0xeb75b700 : Output
0x000172a2 : 0xeb75b700 :  pTemplate: 0x7fbde4060640
0x000172a2 : 0xeb75b700 :  ulCount: 2
0x000172a2 : 0xeb75b700 :   *** Begin attribute template ***
0x000172a2 : 0xeb75b700 :   Attribute 0
0x000172a2 : 0xeb75b700 :    Attribute: 256 (CKA_KEY_TYPE)
0x000172a2 : 0xeb75b700 :    pValue: (nil)
0x000172a2 : 0xeb75b700 :    ulValueLen: 8
0x000172a2 : 0xeb75b700 :   Attribute 1
0x000172a2 : 0xeb75b700 :    Attribute: 353 (CKA_VALUE_LEN)
0x000172a2 : 0xeb75b700 :    pValue: (nil)
0x000172a2 : 0xeb75b700 :    ulValueLen: 8
0x000172a2 : 0xeb75b700 :   *** End attribute template ***
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_GetAttributeValue
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  hSession: 1
0x000172a2 : 0xeb75b700 :  hObject: 1090
0x000172a2 : 0xeb75b700 :  pTemplate: 0x7fbde4060a20
0x000172a2 : 0xeb75b700 :  ulCount: 2
0x000172a2 : 0xeb75b700 :   *** Begin attribute template ***
0x000172a2 : 0xeb75b700 :   Attribute 0
0x000172a2 : 0xeb75b700 :    Attribute: 256 (CKA_KEY_TYPE)
0x000172a2 : 0xeb75b700 :    pValue: 0x7fbde40608e0
0x000172a2 : 0xeb75b700 :    ulValueLen: 8
0x000172a2 : 0xeb75b700 :    *pValue: HEX(0000000000000000)
0x000172a2 : 0xeb75b700 :   Attribute 1
0x000172a2 : 0xeb75b700 :    Attribute: 353 (CKA_VALUE_LEN)
0x000172a2 : 0xeb75b700 :    pValue: 0x7fbde4060900
0x000172a2 : 0xeb75b700 :    ulValueLen: 8
0x000172a2 : 0xeb75b700 :    *pValue: HEX(0000000000000000)
0x000172a2 : 0xeb75b700 :   *** End attribute template ***
0x000172a2 : 0xeb75b700 : Output
0x000172a2 : 0xeb75b700 :  pTemplate: 0x7fbde4060a20
0x000172a2 : 0xeb75b700 :  ulCount: 2
0x000172a2 : 0xeb75b700 :   *** Begin attribute template ***
0x000172a2 : 0xeb75b700 :   Attribute 0
0x000172a2 : 0xeb75b700 :    Attribute: 256 (CKA_KEY_TYPE)
0x000172a2 : 0xeb75b700 :    pValue: 0x7fbde40608e0
0x000172a2 : 0xeb75b700 :    ulValueLen: 8
0x000172a2 : 0xeb75b700 :    *pValue: HEX(1F00000000000000)
0x000172a2 : 0xeb75b700 :   Attribute 1
0x000172a2 : 0xeb75b700 :    Attribute: 353 (CKA_VALUE_LEN)
0x000172a2 : 0xeb75b700 :    pValue: 0x7fbde4060900
0x000172a2 : 0xeb75b700 :    ulValueLen: 8
0x000172a2 : 0xeb75b700 :    *pValue: HEX(2000000000000000)
0x000172a2 : 0xeb75b700 :   *** End attribute template ***
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_Logout
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  hSession: 1
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_CloseSession
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  hSession: 1
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)
0x000172a2 : 0xeb75b700 : ****************************** 2021-12-07 17:42:14 ***
0x000172a2 : 0xeb75b700 : Calling C_Finalize
0x000172a2 : 0xeb75b700 : Input
0x000172a2 : 0xeb75b700 :  pReserved: (nil)
0x000172a2 : 0xeb75b700 : Returning 0 (CKR_OK)

@hansonchar
Copy link
Author

hansonchar commented Dec 7, 2021

Interestingly, there's this open issue on their repo. Their workaround seems to be to use RTLD_NODELETE along with RTLD_NOW.

RTLD_NODELETE doesn't seem to exist any more in the latest crate libloading v0.7.2. There are only RTLD_{NOW,LAZY,LOCAL,GLOBAL}. The default appears to be RTLD_LAZY | RTLD_LOCAL.

I tried various combinations, including:

  • RTLD_NOW | RTLD_GLOBAL
  • RTLD_NOW (only)
  • RTLD_GLOBAL (only)
  • RTLD_NOW | RTLD_LOCAL
  • RTLD_LAZY | RTLD_GLOBAL
  • RTLD_GLOBAL (only)
  • RTLD_LOCAL (only)

So far none of it works. (I verified the change was in effect as I saw the debug message such as "Opening SO with RTLD_GLOBAL | RTLD_NOW" being output during cargo test -- --nocapture).

Sample diff for such change:

diff --git a/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs b/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs
index 16599f4..86d8697 100644
--- a/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs
+++ b/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs
@@ -2884,6 +2884,8 @@ pub type CK_DES_CBC_ENCRYPT_DATA_PARAMS_PTR = *mut ck_des_cbc_encrypt_data_param
 pub type CK_AES_CBC_ENCRYPT_DATA_PARAMS = ck_aes_cbc_encrypt_data_params;
 pub type CK_AES_CBC_ENCRYPT_DATA_PARAMS_PTR = *mut ck_aes_cbc_encrypt_data_params;
 extern crate libloading;
+use libloading::os::unix::RTLD_NOW;
+use libloading::os::unix::RTLD_GLOBAL;
 pub struct Pkcs11 {
     __library: ::libloading::Library,
     pub C_GetFunctionList: Result<
@@ -2896,7 +2898,10 @@ impl Pkcs11 {
     where
         P: AsRef<::std::ffi::OsStr>,
     {
-        let __library = ::libloading::Library::new(path)?;
+        // let __library = ::libloading::Library::new(path)?;
+        println!("Opening SO with RTLD_GLOBAL | RTLD_NOW");
+        let os_lib = libloading::os::unix::Library::open(Some(path), RTLD_GLOBAL | RTLD_NOW)?;
+        let __library = libloading::Library::from(os_lib);
         let C_GetFunctionList = __library
             .get("C_GetFunctionList".as_bytes())
             .map(|sym| *sym);

@hansonchar
Copy link
Author

This work around fixes the SIGSEG crash. Yay!

diff --combined cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs
index 4b98321,16599f4..0000000
--- a/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs
+++ b/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs
@@@ -2896,10 -2896,7 +2896,10 @@@ impl Pkcs11
      where
          P: AsRef<::std::ffi::OsStr>,
      {
 -        let __library = ::libloading::Library::new(path)?;
 +        // https://github.com/nagisa/rust_libloading/issues/41#issuecomment-448303856
 +        println!("Opening SO with 0x2 | 0x1000");
 +        let os_lib = libloading::os::unix::Library::open(Some(path), 0x2 | 0x1000)?;
 +        let __library = libloading::Library::from(os_lib);
          let C_GetFunctionList = __library
              .get("C_GetFunctionList".as_bytes())
              .map(|sym| *sym);

@hansonchar
Copy link
Author

hansonchar commented Dec 7, 2021

I wonder if this works across all x86_64 Linux platforms. If so, a simple change to x86_64-unknown-linux-gnu.rs would fix the issue. If not, then perhaps some API can be added to rust-cryptoki for the users to configure?

@ionut-arm
Copy link
Member

Hmmm, I've been looking at your log for the get_attribute, I think the error is coming from the key type conversion instead. In the log the value appears to be in little endian encoding (I'm assuming it's an AES key?), however we treat those bytes as network endian. Looking through the spec I can't tell which one CK_ULONG should be following, as CKA_KEY_TYPE uses CK_KEY_TYPE, which is a ulong...

Unfortunately I can't properly link, posting this on a phone 😅 but I'll look into it more tomorrow morning (and into the libloading issue as well)

@hansonchar
Copy link
Author

I'm assuming it's an AES key?

Affirmative.

hansonchar added a commit to hansonchar/rust-cryptoki that referenced this issue Dec 8, 2021
@ionut-arm
Copy link
Member

Hmm, ok, now I'm stumped. I ran the following test locally (with the current tip of main):

#[test]
#[serial]
fn aes_key() -> Result<()> {
    let (pkcs11, slot) = init_pins();

    // set flags
    let mut flags = SessionFlags::new();
    let _ = flags.set_rw_session(true).set_serial_session(true);

    // open a session
    let session = pkcs11.open_session_no_callback(slot, flags)?;

    // log in the session
    session.login(UserType::User, Some(USER_PIN))?;

    // get mechanism
    let mechanism = Mechanism::AesKeyGen;

    // pub key template
    let key_template = vec![
        Attribute::Class(ObjectClass::SECRET_KEY),
        Attribute::Token(true),
        Attribute::Sensitive(true),
        Attribute::ValueLen(16.into()),
        Attribute::KeyType(KeyType::AES),
        Attribute::Label(b"testAES".to_vec()),
        Attribute::Private(true),
    ];

    // generate a key pair
    let key = session.generate_key(&mechanism, &key_template)?;

    let attributes_result =
        session.get_attributes(key, &[AttributeType::KeyType, AttributeType::ValueLen]);

    match attributes_result {
        Ok(attributes) => println!("working with version: {:?}", attributes),
        Err(e) => println!("error getting attributes: {:?}", e),
    }
    Ok(())
}

And it worked:

~/code/work/rust-cryptoki(main)$ c t aes_key -- --nocapture
   Compiling cryptoki v0.3.0 (/home/xeno/code/work/rust-cryptoki/cryptoki)
    Finished test [unoptimized + debuginfo] target(s) in 1.21s
     Running unittests (target/debug/deps/cryptoki-2f4193b1c5c37646)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/basic.rs (target/debug/deps/basic-8e46cad26ea5a1bb)

running 1 test
working with version: [KeyType(KeyType { val: 31 }), ValueLen(Ulong { val: 16 })]
test aes_key ... ok

Got the following from pkcs11-logger (just the GetAttributes part; the values got printed in the same way for me as well, so it's probably not that):

0x00001506 : 0x57167700 : ****************************** 2021-12-08 10:20:33 ***
0x00001506 : 0x57167700 : Calling C_GetAttributeValue
0x00001506 : 0x57167700 : Input
0x00001506 : 0x57167700 :  hSession: 2
0x00001506 : 0x57167700 :  hObject: 3
0x00001506 : 0x57167700 :  pTemplate: 0x7f4c50035770
0x00001506 : 0x57167700 :  ulCount: 1
0x00001506 : 0x57167700 :   *** Begin attribute template ***
0x00001506 : 0x57167700 :   Attribute 0
0x00001506 : 0x57167700 :    Attribute: 256 (CKA_KEY_TYPE)
0x00001506 : 0x57167700 :    pValue: (nil)
0x00001506 : 0x57167700 :    ulValueLen: 0
0x00001506 : 0x57167700 :   *** End attribute template ***
0x00001506 : 0x57167700 : Output
0x00001506 : 0x57167700 :  pTemplate: 0x7f4c50035770
0x00001506 : 0x57167700 :  ulCount: 1
0x00001506 : 0x57167700 :   *** Begin attribute template ***
0x00001506 : 0x57167700 :   Attribute 0
0x00001506 : 0x57167700 :    Attribute: 256 (CKA_KEY_TYPE)
0x00001506 : 0x57167700 :    pValue: (nil)
0x00001506 : 0x57167700 :    ulValueLen: 8
0x00001506 : 0x57167700 :   *** End attribute template ***
0x00001506 : 0x57167700 : Returning 0 (CKR_OK)
0x00001506 : 0x57167700 : ****************************** 2021-12-08 10:20:33 ***
0x00001506 : 0x57167700 : Calling C_GetAttributeValue
0x00001506 : 0x57167700 : Input
0x00001506 : 0x57167700 :  hSession: 2
0x00001506 : 0x57167700 :  hObject: 3
0x00001506 : 0x57167700 :  pTemplate: 0x7f4c50035770
0x00001506 : 0x57167700 :  ulCount: 1
0x00001506 : 0x57167700 :   *** Begin attribute template ***
0x00001506 : 0x57167700 :   Attribute 0
0x00001506 : 0x57167700 :    Attribute: 353 (CKA_VALUE_LEN)
0x00001506 : 0x57167700 :    pValue: (nil)
0x00001506 : 0x57167700 :    ulValueLen: 0
0x00001506 : 0x57167700 :   *** End attribute template ***
0x00001506 : 0x57167700 : Output
0x00001506 : 0x57167700 :  pTemplate: 0x7f4c50035770
0x00001506 : 0x57167700 :  ulCount: 1
0x00001506 : 0x57167700 :   *** Begin attribute template ***
0x00001506 : 0x57167700 :   Attribute 0
0x00001506 : 0x57167700 :    Attribute: 353 (CKA_VALUE_LEN)
0x00001506 : 0x57167700 :    pValue: (nil)
0x00001506 : 0x57167700 :    ulValueLen: 8
0x00001506 : 0x57167700 :   *** End attribute template ***
0x00001506 : 0x57167700 : Returning 0 (CKR_OK)
0x00001602 : 0xa1ab8700 : ****************************** 2021-12-08 10:28:08 ***
0x00001602 : 0xa1ab8700 : Calling C_GetAttributeValue
0x00001602 : 0xa1ab8700 : Input
0x00001602 : 0xa1ab8700 :  hSession: 2
0x00001602 : 0xa1ab8700 :  hObject: 3
0x00001602 : 0xa1ab8700 :  pTemplate: 0x7fac9c03ad70
0x00001602 : 0xa1ab8700 :  ulCount: 2
0x00001602 : 0xa1ab8700 :   *** Begin attribute template ***
0x00001602 : 0xa1ab8700 :   Attribute 0
0x00001602 : 0xa1ab8700 :    Attribute: 256 (CKA_KEY_TYPE)
0x00001602 : 0xa1ab8700 :    pValue: 0x7fac9c0345d0
0x00001602 : 0xa1ab8700 :    ulValueLen: 8
0x00001602 : 0xa1ab8700 :    *pValue: HEX(0000000000000000)
0x00001602 : 0xa1ab8700 :   Attribute 1
0x00001602 : 0xa1ab8700 :    Attribute: 353 (CKA_VALUE_LEN)
0x00001602 : 0xa1ab8700 :    pValue: 0x7fac9c036b20
0x00001602 : 0xa1ab8700 :    ulValueLen: 8
0x00001602 : 0xa1ab8700 :    *pValue: HEX(0000000000000000)
0x00001602 : 0xa1ab8700 :   *** End attribute template ***
0x00001602 : 0xa1ab8700 : Output
0x00001602 : 0xa1ab8700 :  pTemplate: 0x7fac9c03ad70
0x00001602 : 0xa1ab8700 :  ulCount: 2
0x00001602 : 0xa1ab8700 :   *** Begin attribute template ***
0x00001602 : 0xa1ab8700 :   Attribute 0
0x00001602 : 0xa1ab8700 :    Attribute: 256 (CKA_KEY_TYPE)
0x00001602 : 0xa1ab8700 :    pValue: 0x7fac9c0345d0
0x00001602 : 0xa1ab8700 :    ulValueLen: 8
0x00001602 : 0xa1ab8700 :    *pValue: HEX(1F00000000000000)
0x00001602 : 0xa1ab8700 :   Attribute 1
0x00001602 : 0xa1ab8700 :    Attribute: 353 (CKA_VALUE_LEN)
0x00001602 : 0xa1ab8700 :    pValue: 0x7fac9c036b20
0x00001602 : 0xa1ab8700 :    ulValueLen: 8
0x00001602 : 0xa1ab8700 :    *pValue: HEX(1000000000000000)
0x00001602 : 0xa1ab8700 :   *** End attribute template ***
0x00001602 : 0xa1ab8700 : Returning 0 (CKR_OK)

The first two calls are done separately now (used to be one call in 0.2.0), but I tried with the crates.io version and it worked as well.

So if you run two calls with KeyType and ValueLen separately it works?

@ionut-arm
Copy link
Member

then perhaps some API can be added to rust-cryptoki for the users to configure?

I think that's what I'd lean towards that, we can maybe put a handrolled implementation that's similar to the existing pub unsafe fn new<P>(path: P), just that the caller can pass some dlopen flags to this new one.

@hansonchar
Copy link
Author

Hmm, ok, now I'm stumped. I ran the following test locally (with the current tip of main):

Using the latest tip of main seems to work, so the NotSupported problem seems to have been fixed since v0.2.0.

@ionut-arm
Copy link
Member

Nice!! That's great to hear. How tied are you to this fix being upstreamed to crates.io?

@hansonchar
Copy link
Author

hansonchar commented Dec 9, 2021

Strangely though if I tried to access the StartDate or EndDate attribute value of an existing secret key (which in this case is AES) that resides in a Luna Network HSM, I'd get the SIGSEGV crash even with the use of pkcs11-logger or with the RTLD_NOW | RTLD_NODELETE changes.

I know the StartDate and EndDate are rather useless, so this isn't of any priority. (Note there is no such crash when I retrieve them in C.)

@ionut-arm
Copy link
Member

Oh, yes, I get the same, I think our way of handling Date does something wrong, thanks for catching that!

We should really invest in more testing :)

@hug-dev
Copy link
Member

hug-dev commented Jan 4, 2022

I read through this rapidly, would it be ok to close it then if it's working with main? We can open a new issue about the Date handling maybe

edit: ah you did here Ionut 👍 #74

@hansonchar
Copy link
Author

hansonchar commented Jan 4, 2022 via email

@hug-dev hug-dev closed this as completed Jan 4, 2022
@ionut-arm
Copy link
Member

@hansonchar - quick note, I've released v0.3.0 of cryptoki today, don't know if that makes any difference to your setup. Unfortunately it doesn't contain a fix for the Date segfault, that'd have to go out in 0.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants