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

const_generate: hardcode CK_TRUE/CK_FALSE to golang bool values #176

Merged
merged 2 commits into from
Nov 15, 2023

Conversation

stlaz
Copy link
Contributor

@stlaz stlaz commented Nov 15, 2023

The PKCS11 constants are most useful when creating attributes with
NewAttribute() in all kinds of different PKCS11 calls. The function
is using generic type handling to decide attribute length.

The CK_TRUE/CK_FALSE constants should evaluate to direct Golang
bool values in order for these to be handled properly by the
NewAttribute() calls, which interprets bool values as
[]byte{0}, []byte{1} for false, true respectively. If these stay
integers, NewAttribtue() considers them 8-byte long byte slices.

Some PKCS11 module implementations actually validate constant-length
arguments size. https://github.com/opendnssec/SoftHSMv2/ is an example
of a commonly used PKCS11-testing module that does that. Without this
change, the module fails to perform certain actions as it errors out
on unexpected attribute size.

The PKCS11 constants are most useful when creating attributes with
`NewAttribute()` in all kinds of different PKCS11 calls. The function
is using generic type handling to decide attribute length.

The CK_TRUE/CK_FALSE constants should evaluate to direct Golang
bool values in order for these to be handled properly by the
`NewAttribute()` calls, which interprets bool values as
[]byte{0}, []byte{1} for false, true respectively. If these stay
integers, `NewAttribtue()` considers them 8-byte long byte slices.

Some PKCS11 module implementations actually validate constant-length
arguments size. https://github.com/opendnssec/SoftHSMv2/ is an example
of a commonly used PKCS11-testing module that does that. Without this
change, the module fails to perform certain actions as it errors out
on unexpected attribute size.
@miekg
Copy link
Owner

miekg commented Nov 15, 2023

thanks, slightly concerned about backwards compatibility, but seems useful enough to merge.

@miekg miekg merged commit 9078ad6 into miekg:master Nov 15, 2023
2 checks passed
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.

2 participants