Reputation: 3907
I was trying to find way to edit the supported cipher suite in a Java SSL client so I can offer a specific list of cipher suites.
One suggested solution was to use the SSLSocketFactoryEx class that was posted by @jww in this link: Which Cipher Suites to enable for SSL Socket?
I did added the SSLSocketFactoryEx class and run the code that lists the supported ciphers by this class (NOTE: I used GetCipherList(); instead of the getSupportedCipheSuites(); because the first is what I found in the SSLSocketFactoryEx) . The code is:
import java.io.IOException;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.util.Arrays;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
public class ListCiphers {
public static void main(String[] args) throws UnknownHostException, IOException, KeyManagementException, NoSuchAlgorithmException
{
Security.addProvider(new BouncyCastleProvider());
//BC is the ID for the Bouncy Castle provider;
if (Security.getProvider("BC") == null){
System.out.println("Bouncy Castle provider is NOT available");
}
else{
System.out.println("Bouncy Castle provider is available");
}
SSLSocketFactoryEx factory = new SSLSocketFactoryEx();
String[] cipherSuites = factory.GetCipherList();
System.out.println(Arrays.toString(cipherSuites));
} //end main
}
My code is supported by Bouncy Castle (BC) provider which says that it supports ChaCha cipher in the specification. See: https://www.bouncycastle.org/specifications.html
the result of the code (the supported ciphers) are:
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
TLS_DHE_DSS_WITH_AES_256_GCM_SHA384
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_DHE_DSS_WITH_AES_128_GCM_SHA256
TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
TLS_DHE_RSA_WITH_AES_128_CBC_SHA
TLS_DHE_DSS_WITH_AES_128_CBC_SHA
TLS_RSA_WITH_AES_256_CBC_SHA256
TLS_RSA_WITH_AES_256_CBC_SHA
TLS_RSA_WITH_AES_128_CBC_SHA256
TLS_RSA_WITH_AES_128_CBC_SHA
TLS_EMPTY_RENEGOTIATION_INFO_SCSV
Why I can not see the ciphers with ChaCha cipher??
If you look at the SSLSocketFactoryEx code, it includes several cipher suites with ChaCha.
Why I can not get them in the supported cipher suites list after using BC provider? How can I add the following cipher suites in the supported cipher suites list so I can include them in the client hello message??
ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
Please, help.
Upvotes: 2
Views: 2010
Reputation: 94058
The problem is that the JSSE implementation (which implements the Java TLS support) does not support ChaCha20. That the ChaCha20 implementation is now available through a JCE provider does not change that.
These kind of cipher classes cannot just be dropped in; ciphers have specific requirements with regards to the key, IV, padding etc. etc. to be used. So you need to write code around the cipher to have it supported by your particular implementation of TLS.
So you need to either wait until it is supported (if ever) or use a JSSE (Java Secure Socket Extensions, TLS) provider that does support it. I guess that it may become available after 1.3 is finalized as that standardizes on AEAD (authenticated) ciphers, and ChaCha20 + Poly 1305 would be a pretty fast configuration.
Upvotes: 2