3
votes

"TLS_RSA_WITH_AES_128_CBC_SHA256" cipher suite is supported by java 8 default providers. Ref - https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJSSEProvider.

Also I have following program to verify that. But when I try to get the cipher for the same algorithm it gives error.

import java.security.NoSuchAlgorithmException;

import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;

public class CipherSuitesInfoGenerator {

  public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPaddingException {

    SSLContext context = SSLContext.getDefault();
    SSLSocketFactory sf = context.getSocketFactory();
    String[] cipherSuites = sf.getSupportedCipherSuites();

    String cipherName = "TLS_RSA_WITH_AES_128_CBC_SHA256";

    for (String s : cipherSuites) {
      if (s.equals(cipherName)) {
        System.out.println(cipherName + " is supported");

        try {
          Cipher cipher = Cipher.getInstance(cipherName);
        } catch (Exception e) {
          System.out.println(e.getMessage());
        }

        break;
      }

    }
  }
}

The output is:

TLS_RSA_WITH_AES_128_CBC_SHA256 is supported
Cannot find any provider supporting TLS_RSA_WITH_AES_128_CBC_SHA256
1
This may be a silly question, but are you sure you're running your code on Java 8?Gagravarr
Yes. I am sure. And I think this program had worked as per expectation. But now its giving error. I don't know whether something has got changed in development environment. Code and output I have copy pasted as it is.Manojkumar Khotele
ciphersuite != cipher. They aren't the same thing.President James K. Polk

1 Answers

3
votes

A ciphersuite is something that is used internally in a JSSE provider, it defines the primitives used within the TLS protocol. It's not a Cipher, a Cipher instance in Java represents one primitive used for encryption/decryption such as AES or RSA.