TLS-Attacker icon indicating copy to clipboard operation
TLS-Attacker copied to clipboard

Brainpool Curve in ECDSA Certificate

Open SidolFreiburg opened this issue 3 years ago • 2 comments

Hello!

I ran into some difficulties when using a brainpool curve in a certificat during ECDSA. It seems that the X509Certificate class in

https://github.com/tls-attacker/TLS-Attacker/blob/a5e9b78b01026b076152ca9aa2773406ed7a854b/TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/util/CertificateUtils.java#L125

does not support the brainpool curves. In

https://github.com/tls-attacker/TLS-Attacker/blob/a5e9b78b01026b076152ca9aa2773406ed7a854b/TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/constants/NamedGroup.java#L117

the brainpool group was not matched because of a capital letter (brainpoolP256r1 != brainpoolp256r1).

As a quick fix in the CertificateUtils, I replaced the code for extracting the public key as follows, :

            SubjectPublicKeyInfo pkInfo = cert.getCertificateAt(0).getTBSCertificate().getSubjectPublicKeyInfo();
            JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
            PublicKey key = converter.getPublicKey( pkInfo );

Best regards Matthias

SidolFreiburg avatar Apr 30 '21 09:04 SidolFreiburg

The default jdk functionality in

https://github.com/tls-attacker/TLS-Attacker/blob/a5e9b78b01026b076152ca9aa2773406ed7a854b/TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/crypto/SignatureCalculator.java#L84

and

https://github.com/tls-attacker/TLS-Attacker/blob/a5e9b78b01026b076152ca9aa2773406ed7a854b/TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/crypto/keys/CustomECPrivateKey.java#L82

also didn't seem to support the brainpool curves. It works if one uses the bouncy castle provider there.

SidolFreiburg avatar Apr 30 '21 10:04 SidolFreiburg

Hm that is weird. We will look into this

ic0ns avatar Sep 09 '21 16:09 ic0ns