Replies: 8 comments 33 replies
-
ECDH support for xmlsec-openssl and xmlsec-mscng will be included in the next release (April 2023) and is already available in the github master. Feel free to try it out (master should be pretty stable) and let me know if you run into any problems! |
Beta Was this translation helpful? Give feedback.
-
I have a couple ECDH tests from XMLEnc 1.1 interop, for example this one. I plan to add more test for various permutations of algorithms soon too, but in general I would recommend ECDH plus ConcatKDF with SHA256 as this is the most portable combination (see implementation requirements). For example, I cannot make XMLEnc interop tests for ECDH + PBKDF work (and given that I am testing against several crypto libraries, I suspect a bug in the Oracle's PBKDF implementation). For keys selection, my high level take is that the simplest thing to do is to use key names on both signing and verification sides. I will try to add dsig11:X509Digest support before the next release as well and this would enable using X509Data instead of key names too. |
Beta Was this translation helpful? Give feedback.
-
You need to specify the key names when you encrypt and decrypt or it might find the wrong key. Something like this should work (btw there are tests in tests/testEnc.sh that show how to do it as well):
Note: I think I got key names correct but if not, then try to swap names in the command line :) |
Beta Was this translation helpful? Give feedback.
-
BTW, after PR #548 lands, you should be able to use X509Digest or any other X509Data elements to select keys (including private keys). I think it will make it much easier to do key agreements. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, I'm failing to repeat the same when private key for decryption is in softhsm2. This was actually my primary motivation to switch from RSA to EC, since I was getting "unsupported padding" error on RSA-OAEP decryption with xmlsec.
|
Beta Was this translation helpful? Give feedback.
-
I think the issue is that the EC key is specified in XML document by value and loading it into HSM fails because HSM doesn't support direct keys loading. In general, I would not recommend using KeyValue for any real production use cases anyway. I see a few possible options (in the order of "easy to try" to "harder to try"):
|
Beta Was this translation helpful? Give feedback.
-
@lsh123 if xmlsec1 will move to use the store API from OpenSSL 3+ to load keys, and you can pass a URI to it, then that would be the preferred method to deal with HSMs, as you can pass a pkcs11: URI which allows to uniquely identify keys preloaded into an HSM. In terms of loading keys, it makes no sense whatsoever to use an HSM that way. With OpenSSL < 3.0 you need to use the openssl-pkcs11 engine (or similar) and the engine API to be able to use URIs and HSMs. With OpenSSL >= 3 using the store API will allow to transparently use providers (like https://github.com/latchset/pkcs11-provider), assuming only EVP APIs are then used for key operations, and not the legacy APIs. HTH. |
Beta Was this translation helpful? Give feedback.
-
The following is a complete solution (requires xmlsec 1.3.0 or greater): PreparationInstall prerequisites
If you are compiling xmlsec library from sources, make sure to specify Configure softhsm
Create a pair of EC keys
Create xml file to encrypt
Option 1: use key names in the XML filePrepare template and encrypt the file using keys from files
Reset softhsm and load private / public keys into softhsm2
Decrypt the file using public/private keys in softhsm2
Option 2: use DEREncodedKeyValue for the originator public keyPrepare template and encrypt the file using keys from files
Reset softhsm and load private / public keys into softhsm2
Decrypt the file using public key in the XML file and private key in softhsm2
|
Beta Was this translation helpful? Give feedback.
-
Hello,
i tried to search mailing list for these keywords but didn't find anything. Does it mean this encryption method is not supported?
Regards,
Jaromir
Beta Was this translation helpful? Give feedback.
All reactions