Do not return CKR_OK with CK_UNAVAILABLE_INFORMATION - #436
Conversation
|
Would you be willing to add a small test that ensure this new code branch works correctly ? |
7540546 to
cae37fe
Compare
|
Judging by how the CI went red, the code path was covered. cae37fe adjusts the tests |
ffab910 to
3e6bda5
Compare
|
Not clear to me why, but this is making pkcs11-provider fail, this means there are pkcs#11 application that depends on not getting an error when an attribute is simply missing ... |
|
The tls test failure is with the RSA-PSS key. The last log line is: |
I wonder if the issue here is trying to get a CKA_ALLOWED_MECHANISM attribute that is not present. But the point is, i seem this commit makes use behave differently than the other tokens, is this a step too far in being "too much" spec compliant? |
most likely yes as this does not demonstrate in the kryoptic.nss, but only in kryoptic now. NSS does not have a support for this attribute at all and softhsm has the support broken with a workaround in pkcs11-provider so I would not say this necessarily mean that we would be bad at merging this. But we need to dig into what is going on there in pkcs11-provider to be able to catch this. |
Well what is going on, I think, is that I was convinced a missing attribute would just show up as an impossible length but the get attribute would still return CKR_OK ? So I think we first need to fix pkcs11-provider to properly handle the case of a missing attribute by not blowing up the whole search when the attribute is simply missing, if that is what is happening here. Then once pkcs11-provider is "fixed" we can merge this. |
|
I managed to reproduce this locally. The error on the server is now: (for the RSA-PSS key) Going through the log of this particular test does not show any issue. but printing the certificate on token through openssl shows: Which looks like the certificate is already generated wrong (and written to the token). In the setup log I can see the query for this attribute on private key fails for unknown reason to me (while on the previous commands, I clearly see that the keys were generated with this attribute and query for this attribute worked just ok on both public and private keys). The current kryoptic version 1.5.0 (without this patch) dumps the following in the log but somehow manages to get the allowed mechanisms list: But this looks like we were getting UNAVAILABLE Information from the After further inspection, this is the query for the caCert on the token, which does not have ALLOWED_MECHANISM at the moment. And this return value is contributing to ignoring the ALLOWED_MECHANISMS entirely (on all objects in the session). The follow-up query on the key with ALLOWED_MECHANISM would work, but is not tried by pkcs11-provider due to this failure blocking further queries. So I guess we will have to formalize what is the expected return value (and if this is it) adjust pkcs11 provider to not consider missing attribute (CKR_ATTRIBUTE_TYPE_INVALID) on one object as not working at all for any other object (even for the price of querying it repetitively on tokens that do not support this). I think this is not explicitly described in the specs so it might be something @simo5 could bring up to the PKCS#11 WG (I think we discussed this before, but not sure if we came up with sufficient outcome). The hackish "fix" for pkcs11-provider confirming this issue and verifying this is the problem: The other option would be defining what "empty" CKA_ALLOWED_MECHANISMS attribute looks like (something else than empty value?) and using that to differentiate from token that does not support this attribute at all and the object not having this attribute explicitly set (that would be for a fix in kryoptic). |
We need to make sure that the mere presence, w/o any value does not cause pkcs11-provider to reject all mechanisms, ie, present but empty must mean 'all mechanism are allowed'. I think this would basically require kryoptic to always synthesize empty attributes if they are requested and allowed by the object type, but are not stored in the token. |
That was my naive understanding when I firstly implemented this in softhsm, but at the time when we looked into this in pkcs11-provider, you were not that convinced that this is the right approach. I can not find notes about that anymore. There is also no discussion about this in the TC.
Or ignore these failures on pkcs11-provder and not expect missing attribute means no support. For buggy pkcs11 tokens, there is a quirk |
Ok let's start with this part. |
|
To reiterate, that yes upon Nth reading the semantics are correct, we really ought to return CKR_ATTRIBUTE_TYPE_INVALID if any attribute is not available ... therefore we definitely need to fix pkcs11-provider to deal with it appropriately. |
…t support the attribute at all This return code means just the attribute is not present on the CURRENT object so assuming from this return code that this attribute is not supported at all is wrong and was just accidentally working for kryoptic, because we did not return the correct value when searching for attributes: latchset/kryoptic#436 Signed-off-by: Jakub Jelen <[email protected]>
…t support the attribute at all This return code means just the attribute is not present on the CURRENT object so assuming from this return code that this attribute is not supported at all is wrong and was just accidentally working for kryoptic, because we did not return the correct value when searching for attributes: latchset/kryoptic#436 Signed-off-by: Jakub Jelen <[email protected]>
…t support the attribute at all This return code means just the attribute is not present on the CURRENT object so assuming from this return code that this attribute is not supported at all is wrong and was just accidentally working for kryoptic, because we did not return the correct value when searching for attributes: latchset/kryoptic#436 Signed-off-by: Jakub Jelen <[email protected]>
…t support the attribute at all This return code means just the attribute is not present on the CURRENT object so assuming from this return code that this attribute is not supported at all is wrong and was just accidentally working for kryoptic, because we did not return the correct value when searching for attributes: latchset/kryoptic#436 Signed-off-by: Jakub Jelen <[email protected]>
3e6bda5 to
e54ea90
Compare
e54ea90 to
a4b54e9
Compare
The TLS test has been failing due to changes in kryoptic introduced in latchset/kryoptic#436 . This was a bug in pkcs11-provider that was fixed in openssl-projects/pkcs11-provider#722 . So we need to update provider to fix that test.
The TLS test has been failing due to changes in kryoptic introduced in latchset/kryoptic#436 . This was a bug in pkcs11-provider that was fixed in openssl-projects/pkcs11-provider#722 . So we need to update provider to fix that test. Reviewed-by: Nikola Pajkovsky <[email protected]> Reviewed-by: Milan Broz <[email protected]> Reviewed-by: Matt Caswell <[email protected]> MergeDate: Wed Jun 17 08:07:21 2026 (Merged from #31546)
The TLS test has been failing due to changes in kryoptic introduced in latchset/kryoptic#436 . This was a bug in pkcs11-provider that was fixed in openssl-projects/pkcs11-provider#722 . So we need to update provider to fix that test. Reviewed-by: Nikola Pajkovsky <[email protected]> Reviewed-by: Milan Broz <[email protected]> Reviewed-by: Matt Caswell <[email protected]> MergeDate: Wed Jun 17 08:07:21 2026 (Merged from #31546) (cherry picked from commit dd19d23)
The pkcs11-provider was disabled due to fixed issues in PQC sigalgs. This re-enables it and update provider to the latest version to also fix the TLS test has been failing due to changes in kryoptic introduced in latchset/kryoptic#436 . This was a bug in pkcs11-provider that was fixed in openssl-projects/pkcs11-provider#722 . Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Nikola Pajkovsky <[email protected]> MergeDate: Thu Jun 18 13:20:31 2026 (Merged from #31556)
Fixes: #435
Description
Checklist
Reviewer's checklist: