-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add brainpool curves for EC key generation/cypher (main branch) #293
Conversation
Looks fine to me. @seanjmullan can you review please? |
Looks fine. It would be nice if there was also a test using the |
@seanjmullan you mean, something like org.apache.xml.security.test.dom.signature.EDDSASignatureTest ? I could try in the next days create such test |
Yes, something like that would be great. |
@seanjmullan I've added the test. I have some problem to run org.apache.xml.security.utils.KeyUtilsTest unter jdk17 with profile bouncecastle. The "DH" Case for generateEphemeralDHKeyPair seems to be broken. org.apache.xml.security.utils.KeyUtils.KeyType#DH declaration use 1.2.840.113549.1.3.1 oid, but 1.2.840.10046.2.1 seems to be the correct one (http://oid-info.com/get/1.2.840.10046.2.1). Or may be I'm wrong? |
@yklymenko good catch: Looks like SunJCE returns different OID for generated (and then encoded) keys with algorithm name 'DH' than the BouncyCastle: The result for test below is : Expected :1.2.840.113549.1.3.1
|
My suggestion is The Diffie-Hellman key agreement using RSA keys is gradually becoming obsolete and currently, it is not supported by the xmlsec key agreement method implementation. I included it there primarily for the sake of completeness, anticipating that someone might (but not very likely) add support for Diffie-Hellman in the future. |
In general, I've looked in BC how they decide, which oid should be used. They have both oid's as aliases and select one of them depending on configuration in org.bouncycastle.jcajce.provider.asymmetric.dh.BCDHPublicKey#getEncoded (see both return statements) |
@yklymenko, you have a good point. |
* Add brainpool curves * Add test for brainpool signature --------- Co-authored-by: Yevgen Klymenko <coneva@klymenko.de>
This is still using the Santuario API (org.apache.xml.security). Sorry, I missed the package name of the test you said above when I said that would be great. What I meant is something like test/java/org/apache/xml/security/test/javax/xml/crypto/dsig/XMLSignatureEdDSATest.java |
@yklymenko @seanjmullan |
It would be nice to define the curves in one place. Right now they are duplicated in DOMKeyValue, ECKeyValue, and ECDSAUtils. If you have time, please consider it. |
|
||
|
||
/** | ||
* |
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.
Add a description of the test.
} | ||
|
||
/** | ||
* Test that encrypt and decrypt using ECDH-ES for key encryption |
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.
Nit: remove "that", add period at end of sentence.
/** | ||
* Test that encrypt and decrypt using ECDH-ES for key encryption | ||
* <p/> | ||
* @throws Exception Thrown when there is any problem in signing or verification |
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.
should this be "... any problem in encryption or decryption"?
names = {"BRAINPOOLP256R1", "BRAINPOOLP384R1", "BRAINPOOLP512R1"}) | ||
void testAES128ElementEcdhEsKWCipher(KeyUtils.KeyType keyType) throws Exception { | ||
Assumptions.assumeTrue(bcInstalled); | ||
// Skip test for IBM JDK |
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.
I would remove "IBM JDK" and say algorithms ... that are required are not supported.
String source = null; | ||
String target = null; | ||
|
||
source = toString(d); |
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.
Can combine lines 163 and 166.
Files.write(Paths.get("target","test-enc-"+keyType.name()+".xml"), toString(ed).getBytes()); | ||
|
||
//decrypt | ||
ee = (Element) ed.getElementsByTagName("xenc:EncryptedData").item(0); |
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.
Can combine lines 162 and 213.
cipherDecData.init(XMLCipher.DECRYPT_MODE, null); | ||
cipherDecData.setKEK(privRecipientKey); | ||
cipherDecData.setSecureValidation(true); | ||
dd = cipherDecData.doFinal(ed, ee); |
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.
Can combine lines 160 and 218.
} | ||
builderKeyInfo.add(encryptedKey); | ||
|
||
ed = cipherEncData.doFinal(d, e); |
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.
Can combine lines 159 and 208.
class ECBrainpoolSignatureTest { | ||
|
||
private static final String ECDSA_JKS = | ||
"src/test/resources/org/apache/xml/security/samples/input/ecbrainpool.jks"; |
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.
Can you create this KeyStore as part of the test? We should stop storing binary files in the repository. I know that there are already existing ones, but I would like to stop doing that going forward.
The protocol for the communication between energy market participants in Germany enforce to use Brainpool P256r1 elliptic curve for signing and encryption of the soap parts (headers and attachments) .
This is a part (BDEW-profile) of the bigger AS4 Standart for the communication.
It would be nice to introduce this curves in santuario-xml-security to be able to use it with wss4j library.
The same as #292, but for main branch