-
Notifications
You must be signed in to change notification settings - Fork 54
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
RSA decrypt failed #316
Comments
The same with openssl command & engine is working: |
This works for me, except I have to leave out the -pkeyopt rsa_mgf1_md:sha512 since it is not applicable to pkcs1. Also, to get pkeyutl to work with this command line I have to use openssl 1.1. I do get a similar error if I use a different public key that doesn't correspond to the private key. This is expected since the padding will be incorrect if the decryption fails. Since the removal of padding is done by the HSM that's where the error will happen. Add 'debug' to the yubihsm_pkcs11.conf file to see more info about the error. |
I'm using OpenSSL 3.0.5
|
This could be caused by using unmatched public/private key, see explanation above. Can you confirm if that is what is occurring ? |
I wrote the steps to reproduce the problem. |
Again, this works for me just as you have written.. This time I can leave the -pkeyopt rsa_mgf1_md:sha512 and it still works. Im now using openssl 3.0.8 from homebrew. |
فشل رجوع الملف لشكله الأصلي بعد فك تشفيره بخوارزمية RSA ما السبب لان اجد الملف الذي تم فكه محتواه مسار الملف الأصلي قبل التشفير |
If the file was not found for some reason then the path will be used as input instead, this might be what happened during encryption |
General Info:
$ pkcs11-tool --module yubihsm_pkcs11.so -I
$ pkcs11-tool --module /home/g/work/yubihsm-shell/build/pkcs11/yubihsm_pkcs11.so -L
Steps to reproduce the problem:
yubihsm> generate asymmetric 0 100 label_mytest 1,2,3 exportable-under-wrap,decrypt-pkcs,decrypt-oaep rsa2048
YHSM_MODULE="yubihsm_pkcs11.so"
$ pkcs11-tool --module "${YHSM_MODULE}" --pin 0001password --read-object --type pubkey --id 0064 -o rsa_key.pub
$ echo '0123456789' | openssl pkeyutl -encrypt -pubin
-inkey rsa_key.pub
-keyform der
-pkeyopt rsa_padding_mode:pkcs1
-pkeyopt rsa_mgf1_md:sha512
-out encrypted.data
$ pkcs11-tool --module "${YHSM_MODULE}" --decrypt
--pin 0001password
--input-file encrypted.data
--label label_mytest
yubihsm> decrypt pkcs1v1_5 0 0x0064 encrypted.data
The text was updated successfully, but these errors were encountered: