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.