-
Notifications
You must be signed in to change notification settings - Fork 803
Pss salt len fix #2478
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
Pss salt len fix #2478
Conversation
popovec
commented
Jan 5, 2022
- Documentation is added or updated
- PKCS#11 module is tested
|
I just merged the #2475. I am not sure this is a good idea to change the meaning of the salt length in the pkcs11 API. I think the original intention was for pkcs11-tool to handle these special values similarly as the openssl, but the pkcs11 API should not change and accept only "positive" values for the salt length to adhere to the pkcs11 specification. But its already some time since I was looking into this code. Also the passing of the pkcs11 mechanisms information down the libopensc is something that I do not like much. Please, see how I did the salt length handling in the p11test: |
sLen is paramer for PSS .. from: https://www.cryptsoft.com/pkcs11doc/v220/group__SEC__12__1__9__PKCS____1__RSA__PSS__MECHANISM__PARAMETERS.html "sLen length, in bytes, of the salt value used in the PSS encoding; typical values are the length of the message hash and zero" Actual OpenSC code does not allow us to use arbitrary sLen ... sLen is always same as hash length. In this PR sLen is always positive value, but there is one special value - maximal value for CK_ULONG - an this value is handled in special way only in PSS verify. In this case autorecovery of sLen from signature is requested from openssl. I don't think there will be a situation where someone needs to enter such a large value for sLen (for verify operation). pkcs11-tool accepts negative values for salt_lenght, but negative value is never passed to pkcs#11 module. As discussed in #2474 (comment) - there is no way to pass the salt_len to sc_pkcs15_compute_signature .. I am also not excited about transferring pMechanism to libopensc code. But let's try to build on |
|
I don't see a problem in using a standard PKCS11 structure in libopensc. It is a way to pass the information to a lower level. The use of the pkcs11.h is already used in a number of routines. |
doc/tools/pkcs11-tool.1.xml
Outdated
| "-1" means salt length equals to digest length, | ||
| "-2" means use maximum permissible length. | ||
| "-2" or "-3" means use maximum permissible length. | ||
| For verify operation "-2" means that the salt length is autorecovered thom signature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| For verify operation "-2" means that the salt length is autorecovered thom signature. | |
| For verify operation "-2" means that the salt length is automatically recovered from signature. |
doc/tools/pkcs11-tool.1.xml
Outdated
| "-2" means use maximum permissible length. | ||
| "-2" or "-3" means use maximum permissible length. | ||
| For verify operation "-2" means that the salt length is autorecovered thom signature. | ||
| This is supported for opensc pkcs#11 module only. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should clarify that it applies only for the -2 with verification. Other special values should work with any module
Oh. I forgot this limitation.
Thanks for clarification. If this is only the ULONG_MAX value, it should be quite ok. It would be probably easier to catch it if the PR would have some description from the beginning though.
Thanks for clarification. Makes sense. I was not aware of that discussion. But note, that using this will prevent any card driver control to signalize support for some parameters. Right now, the driver can decide if the card supports particular digest/padding on card. |
I agree, it would be appropriate for the card driver to be able to signal arbitrary PSS is (partially) supported in It would be a good idea to add I can add: And do something similar in |
5c4627b to
9b1e80a
Compare
|
Can you rebase on top of current master? There is a new conflict. |
Also implements support for autorecovery of salt length from signature.
modified: src/tests/p11test/virt_cacard_ref.json
9b1e80a to
267f382
Compare
|
Rebased, fixed build with libressl. |
|
FYI, this broke the OpenSCToken build on master, because it is using the We can either change the OpenSCToken to use the new signature (preferred -- unless it needs to work with older OpenSC versions) or provide some compatibility API (we are not making any commitments about the libopensc API/ABI stability). What do you think @frankmorgner ? |
|
fixed. |
Thanks! I was not sure if using just |
|
NULL was used as default in minidriver, so I hope we're fine here as well. the token doesn't have support for PSS, so the parameter is currently of no use. We'll see how to integrate |