-
Notifications
You must be signed in to change notification settings - Fork 6
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
Unable to select certificate with ONLY Key Encipherment key usage (20). #11
Comments
I've found the culprit in CertManager.DecryptMsg().
I tested just the sequence of generating some random bytes, and called a modified version of DecryptMsg that doesn't open a store and just calls EnvelopedCms.Decrypt() to
This made the snippet work (bytes post and pre encryption are identical). Maybe you could investigate further if that change has any security implications (I find those C# docs horrible and severly lacking in essential details). Regards, |
Hey, |
I've drafted a release for that - after short tests it looks like a possible fix for that problem. |
I checked that 1.4b and it doesn't work, unfortunately. BUT the strange thing is that even with my small test, it fails more often than it works (it DOES work intermittently, though, and I am sure I use the right pin). |
After taking a peek at the source of EnvelopeCms, I... seriously doubt it is fit for public use. Regards, |
Success! After poking some more, it appears to work when changing the encryption algorithm to AES256-CBC OID "2.16.840.1.101.3.4.1.42" (default is DES-EDE3-CBC OID "1.2.840.113549.3.7"). At least I am able to encrypt some random bytes and decrypt them to arrive at the same random bytes. Regards, |
You tried to encrypt random bytes (like the "key" i generate in the plugin) with different cypher modes. So I'v to check what I can change in the code to provide a stable de- and encryption of the random key. |
As I said, the EnvelopedCms class appears unfinished and behaves strangely (not to mention the terrible documentation). I tried various other suggestions and none of them made a difference. FWIW, if I set it to AES, it uses OAEP padding (v2 padding), vs. PKCS#1 1.5 padding when the DES default is used. This post suggests one can influence the internal behavior, but it makes no difference and it fails to work either way. Apart from success in my reduced test, I now compiled the plugin with the algorithm OID set to AES and it works fine, with the SmartCard. |
Thank you for the clarification! 😉 So in my test I can't reproduce this behavior. But I still testing around with the usage of the AES encryption with CBC if nothing breaks here I'll implement this as default cypher mode for the plugin - to avoid problems with other SCs I'll also implement these as configurable option. |
Hey,
I am trying to use KeePass with my corporate-issued SmartCard, and after trying Bodnar's, and markbott's plugins (which I cannot make work), I tried yours.
Yours fails too, unfortunately, but at least the error message makes a bit of sense.
It specifically tells me that the certificate does either not support Key Encipherment or the private key is wrong/missing.
The thing is, in #4 (comment) you wrote that you require Key Encipherment (a0), but a0 would actually be a combination of bits.
Now, the cert on my smart card ONLY has the Key Enciperment bit [microsoft calls this Key Encipherment (20)] set, and I assume this might be why it fails. Now, from quickly looking at the MS docs, I haven't found any mention of it requiring specific other bits, so I am unsure if it might be something you can configure in your calls?
Regards,
M.
The text was updated successfully, but these errors were encountered: