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

Pkcs11Interop data object #143

Open
bartengine27 opened this issue Oct 8, 2023 · 3 comments
Open

Pkcs11Interop data object #143

bartengine27 opened this issue Oct 8, 2023 · 3 comments

Comments

@bartengine27
Copy link

Dear,

Adding data objects on a Gemalto ID Prime MD with the Pkcs11Interop library succeeds as far that the data objects are visible in the SafeNet Authentication Client. Querying the data objects with the Pkcs11Interop library or with Pkcs11Admin fails (no data objects are visible).

Is this a known issue?

Thanks,
Bart

@anugram
Copy link
Contributor

anugram commented Oct 9, 2023

@bartengine27, I am getting someone to have a look at this and get back to you soon.

Thanks and I appreciate your patience.
Anurag

@bartengine27
Copy link
Author

Dear Anugram,

Thanks for the feedback!

Below some more information to reproduce the issue.

Regards,
Bart

        private static void GenerateDataObject()
        {
            using (IPkcs11Library pkcs11Library = factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, pkcs11LibraryPath, AppType.MultiThreaded))
            {
                // Find first slot with token present
                ISlot slot = Helpers.GetUsableSlot(pkcs11Library);

                // Open RW session
                using (ISession session = slot.OpenSession(SessionType.ReadWrite))
                {
                    // Login as normal user
                    session.Login(CKU.CKU_USER, Settings.NormalUserPin);
                    byte[] encryptedBackupSecret = ConvertUtils.Utf8StringToBytes("my secret");                    
                    // https://thalesdocs.com/gphsm/ptk/5.9/docs/Content/PTK-C_Program/Obj_Classes/create_mod_copy_del.htm
                    // check CKF_LOGIN_REQUIRED 
                    List<IObjectAttribute> createObjectAttributes = new List<IObjectAttribute>();
                    createObjectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, CKO.CKO_DATA));
                    createObjectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_TOKEN, true));
                    createObjectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_PRIVATE, true));
                    createObjectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_LABEL, "data_object_test"));
                    createObjectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_APPLICATION, "element"));
                    createObjectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_VALUE, encryptedBackupSecret));
                    var createdObject = session.CreateObject(createObjectAttributes);            

                    session.Logout();
                }
            }
        }

@bartengine27
Copy link
Author

Dear @anugram

Do you have an update? Anything I can do to help?

Thanks,
Bart

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

2 participants