-
Notifications
You must be signed in to change notification settings - Fork 803
symmetric decryption #2607
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
symmetric decryption #2607
Conversation
…tions. The C_Decrypt() and pkcs15_prkey_decrypt() functions have been changed to allow pkcs15_prkey_decrypt() to be called from C_DecryptInit(), C_DecryptUpdate() and C_DecryptFinalize().
pkcs#11: C_DecryptUpdate() and C_DecryptFinal() implementation pkcs#15: pkcs15_skey_decrypt, sc_pkcs15_decrypt_sym also implements: sc_decrypt_sym
|
Do you have some strong opinion if this should go into 0.23.0 or later? We have the encryption part there already so for completeness I would probably like to have also this one in the release unless somebody else would be strongly against. |
|
Sounds OK to add to 0.23.0. |
|
I would like to point out one thing about asymmetric decryption which is affected by this PR. Before applying this PR, it is possible to use only I don't know if there is any application that uses that sequence. If so, it should work without any problems. But the problem arises if the application calls If none of the OpenSC maintainers have reservations about the extension of asymmetric decryption applied in this way, I think it is appropriate to use this PR in OpenSC 0.23. |
|
The pkcs11-tool https://github.com/OpenSC/OpenSC/blob/master/src/tools/pkcs11-tool.c#L2607-L2632 will call Is the problem with implementing this on a card? |
Already implemented ... symmetric encrypt/decrypt allows the use of streaming (C_EncryptUpdate/C_DecryptUpdate) or "one-time" call (C_Encrypt/C_Decrypt). Relevant tests are performed via github actions (.github/test-oseid.sh). As for asymmetric decryption, considering that we only implemented RSA decryption and that for a maximum of 4096-bit key, we don't really have a reason to use streaming - there is no need to call C_DecryptUpdate multiple times. If someone uses "streaming" for RSA decrypt and really uses several C_DecryptUpdate calls, this will not work in the current OpenSC implementation with or without this PR. |
|
I think the discussion in the previous comments is completely unrelated to this PR as they are talking about asymmetric decryption while this implements a symmetric decryption. The streaming input for asymmetric decryption is a corner case, which should be probably opened as a new issue and fixed eventually (but RSA encryption decryption is not much used for anything useful anyway). So unless there are some other comments to the code, I will merge it later this week. |
pkcs#11 - new functions: C_DecryptUpdate() and C_DecryptFinal()
adapted functions: C_DecryptInit(), C_Decrypt()
pkcs#15 - new functions: pkcs15_skey_decrypt, sc_pkcs15_decrypt_sym
adapted function: pkcs15_prkey_decrypt()
also implements: sc_decrypt_sym
MyEID driver: support for symmetric decrypt (AES-ECB, AES-CBC, AES-CBC-PAD).