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

C set attribute value #1343

Closed

Conversation

konstantinpersidskiy
Copy link
Contributor

Checklist
  • PKCS#11 module is tested
  • Windows minidriver is tested
  • macOS tokend is tested

Hello,
PKCS11 standard v. 2.40 (https://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.pdf) states that default value for CKO_DATA object's CKA_VALUE is empty (4.5.2, page 42). That points to the possibility of modifying this attribute for these objects via C_SetAttributeValue (same can be seen in the current code for object's id).
These commits allow creating data objects with empty CKA_VALUE and modifying it later.

@frankmorgner
Copy link
Member

The change looks OK in general, but I don't know how to test this. What tests did you run?

@konstantinpersidskiy
Copy link
Contributor Author

I wrote a small test using opensc-pkcs11 that creates a data object with empty CKA_VALUE, then finds this object and modifies it's CKA_VALUE to non-empty. I ran it on RutokenS and RutokenECP tokens and checked tokens' file structure for data object EF and changes I expected in DODF.
I can upload my test if you like

@konstantinpersidskiy
Copy link
Contributor Author

https://gist.github.com/konstantinpersidskiy/bc6824101a85fb2e8ce11743183d04a9
That's my test, to compile change path to opensc-pkcs11.so in dlopen.
@frankmorgner , is that enough?

profile->dirty = 1;
LOG_TEST_RET(ctx, r, "Failed to store new data");

nv = (u8 *) malloc (new_len * sizeof(u8));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing error check. you could also use realloc()

@frankmorgner
Copy link
Member

@konstantinpersidskiy for testing, the example is more than I've expected. Actually, I was referring to the checklist above and wanted to know what card you tested with what functionality.

Anyway, please see the above comment about the missing error check.

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

Successfully merging this pull request may close these issues.

None yet

2 participants