@Test(expected = UnsupportedOperationException.class) public void testUnresolvableCipherFallback() { AlgorithmResolver.getCipher(CipherSuite.TLS_FALLBACK_SCSV); }
public static CipherAlgorithm getCipher(CipherSuite cipherSuite) { String cipher = cipherSuite.toString().toUpperCase(); if (cipher.contains("NULL")) { return CipherAlgorithm.NULL; } else if (cipher.contains("IDEA")) { return CipherAlgorithm.IDEA_128; } else if (cipher.contains("RC2")) { return CipherAlgorithm.RC2_128; } else if (cipher.contains("RC4")) { return CipherAlgorithm.RC4_128; } else if (cipher.contains("DES_EDE_CBC")) { return CipherAlgorithm.DES_EDE_CBC; } else if (cipher.contains("AES_128_CBC")) { return CipherAlgorithm.AES_128_CBC; } else if (cipher.contains("AES_256_CBC")) { return CipherAlgorithm.AES_256_CBC; } else if (cipher.contains("AES_128_GCM")) { return CipherAlgorithm.AES_128_GCM; } else if (cipher.contains("AES_256_GCM")) { return CipherAlgorithm.AES_256_GCM; } else if (cipher.contains("AES_128_CCM")) { return CipherAlgorithm.AES_128_CCM; } else if (cipher.contains("AES_256_CCM")) { return CipherAlgorithm.AES_256_CCM; } else if (cipher.contains("CAMELLIA_128_CBC")) { return CipherAlgorithm.CAMELLIA_128_CBC; } else if (cipher.contains("CAMELLIA_256_CBC")) { return CipherAlgorithm.CAMELLIA_256_CBC; } else if (cipher.contains("CAMELLIA_128_GCM")) { return CipherAlgorithm.CAMELLIA_128_GCM; } else if (cipher.contains("CAMELLIA_256_GCM")) { return CipherAlgorithm.CAMELLIA_256_GCM; } else if (cipher.contains("SEED_CBC")) { return CipherAlgorithm.SEED_CBC; } else if (cipher.contains("DES40_CBC")) { return CipherAlgorithm.DES40_CBC; } else if (cipher.contains("DES_CBC")) { return CipherAlgorithm.DES_CBC; } else if (cipher.contains("WITH_FORTEZZA_CBC")) { return CipherAlgorithm.FORTEZZA_CBC; } else if (cipher.contains("ARIA_128_CBC")) { return CipherAlgorithm.ARIA_128_CBC; } else if (cipher.contains("ARIA_256_CBC")) { return CipherAlgorithm.ARIA_256_CBC; } else if (cipher.contains("ARIA_128_GCM")) { return CipherAlgorithm.ARIA_128_GCM; } else if (cipher.contains("ARIA_256_GCM")) { return CipherAlgorithm.ARIA_256_GCM; } else if (cipher.contains("28147_CNT")) { return CipherAlgorithm.GOST_28147_CNT; } else if (cipher.contains("CHACHA20_POLY1305")) { return CipherAlgorithm.ChaCha20Poly1305; } if (cipherSuite == CipherSuite.TLS_FALLBACK_SCSV || cipherSuite == CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV) { throw new UnsupportedOperationException("The CipherSuite:" + cipherSuite.name() + " does not specify a Cipher"); } throw new UnsupportedOperationException("The cipher algorithm in " + cipherSuite + " is not supported yet."); }
AlgorithmResolver { public static CipherAlgorithm getCipher(CipherSuite cipherSuite) { String cipher = cipherSuite.toString().toUpperCase(); if (cipher.contains("NULL")) { return CipherAlgorithm.NULL; } else if (cipher.contains("IDEA")) { return CipherAlgorithm.IDEA_128; } else if (cipher.contains("RC2")) { return CipherAlgorithm.RC2_128; } else if (cipher.contains("RC4")) { return CipherAlgorithm.RC4_128; } else if (cipher.contains("DES_EDE_CBC")) { return CipherAlgorithm.DES_EDE_CBC; } else if (cipher.contains("AES_128_CBC")) { return CipherAlgorithm.AES_128_CBC; } else if (cipher.contains("AES_256_CBC")) { return CipherAlgorithm.AES_256_CBC; } else if (cipher.contains("AES_128_GCM")) { return CipherAlgorithm.AES_128_GCM; } else if (cipher.contains("AES_256_GCM")) { return CipherAlgorithm.AES_256_GCM; } else if (cipher.contains("AES_128_CCM")) { return CipherAlgorithm.AES_128_CCM; } else if (cipher.contains("AES_256_CCM")) { return CipherAlgorithm.AES_256_CCM; } else if (cipher.contains("CAMELLIA_128_CBC")) { return CipherAlgorithm.CAMELLIA_128_CBC; } else if (cipher.contains("CAMELLIA_256_CBC")) { return CipherAlgorithm.CAMELLIA_256_CBC; } else if (cipher.contains("CAMELLIA_128_GCM")) { return CipherAlgorithm.CAMELLIA_128_GCM; } else if (cipher.contains("CAMELLIA_256_GCM")) { return CipherAlgorithm.CAMELLIA_256_GCM; } else if (cipher.contains("SEED_CBC")) { return CipherAlgorithm.SEED_CBC; } else if (cipher.contains("DES40_CBC")) { return CipherAlgorithm.DES40_CBC; } else if (cipher.contains("DES_CBC")) { return CipherAlgorithm.DES_CBC; } else if (cipher.contains("WITH_FORTEZZA_CBC")) { return CipherAlgorithm.FORTEZZA_CBC; } else if (cipher.contains("ARIA_128_CBC")) { return CipherAlgorithm.ARIA_128_CBC; } else if (cipher.contains("ARIA_256_CBC")) { return CipherAlgorithm.ARIA_256_CBC; } else if (cipher.contains("ARIA_128_GCM")) { return CipherAlgorithm.ARIA_128_GCM; } else if (cipher.contains("ARIA_256_GCM")) { return CipherAlgorithm.ARIA_256_GCM; } else if (cipher.contains("28147_CNT")) { return CipherAlgorithm.GOST_28147_CNT; } else if (cipher.contains("CHACHA20_POLY1305")) { return CipherAlgorithm.ChaCha20Poly1305; } if (cipherSuite == CipherSuite.TLS_FALLBACK_SCSV || cipherSuite == CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV) { throw new UnsupportedOperationException("The CipherSuite:" + cipherSuite.name() + " does not specify a Cipher"); } throw new UnsupportedOperationException("The cipher algorithm in " + cipherSuite + " is not supported yet."); } }
AlgorithmResolver { public static CipherAlgorithm getCipher(CipherSuite cipherSuite) { String cipher = cipherSuite.toString().toUpperCase(); if (cipher.contains("NULL")) { return CipherAlgorithm.NULL; } else if (cipher.contains("IDEA")) { return CipherAlgorithm.IDEA_128; } else if (cipher.contains("RC2")) { return CipherAlgorithm.RC2_128; } else if (cipher.contains("RC4")) { return CipherAlgorithm.RC4_128; } else if (cipher.contains("DES_EDE_CBC")) { return CipherAlgorithm.DES_EDE_CBC; } else if (cipher.contains("AES_128_CBC")) { return CipherAlgorithm.AES_128_CBC; } else if (cipher.contains("AES_256_CBC")) { return CipherAlgorithm.AES_256_CBC; } else if (cipher.contains("AES_128_GCM")) { return CipherAlgorithm.AES_128_GCM; } else if (cipher.contains("AES_256_GCM")) { return CipherAlgorithm.AES_256_GCM; } else if (cipher.contains("AES_128_CCM")) { return CipherAlgorithm.AES_128_CCM; } else if (cipher.contains("AES_256_CCM")) { return CipherAlgorithm.AES_256_CCM; } else if (cipher.contains("CAMELLIA_128_CBC")) { return CipherAlgorithm.CAMELLIA_128_CBC; } else if (cipher.contains("CAMELLIA_256_CBC")) { return CipherAlgorithm.CAMELLIA_256_CBC; } else if (cipher.contains("CAMELLIA_128_GCM")) { return CipherAlgorithm.CAMELLIA_128_GCM; } else if (cipher.contains("CAMELLIA_256_GCM")) { return CipherAlgorithm.CAMELLIA_256_GCM; } else if (cipher.contains("SEED_CBC")) { return CipherAlgorithm.SEED_CBC; } else if (cipher.contains("DES40_CBC")) { return CipherAlgorithm.DES40_CBC; } else if (cipher.contains("DES_CBC")) { return CipherAlgorithm.DES_CBC; } else if (cipher.contains("WITH_FORTEZZA_CBC")) { return CipherAlgorithm.FORTEZZA_CBC; } else if (cipher.contains("ARIA_128_CBC")) { return CipherAlgorithm.ARIA_128_CBC; } else if (cipher.contains("ARIA_256_CBC")) { return CipherAlgorithm.ARIA_256_CBC; } else if (cipher.contains("ARIA_128_GCM")) { return CipherAlgorithm.ARIA_128_GCM; } else if (cipher.contains("ARIA_256_GCM")) { return CipherAlgorithm.ARIA_256_GCM; } else if (cipher.contains("28147_CNT")) { return CipherAlgorithm.GOST_28147_CNT; } else if (cipher.contains("CHACHA20_POLY1305")) { return CipherAlgorithm.ChaCha20Poly1305; } if (cipherSuite == CipherSuite.TLS_FALLBACK_SCSV || cipherSuite == CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV) { throw new UnsupportedOperationException("The CipherSuite:" + cipherSuite.name() + " does not specify a Cipher"); } throw new UnsupportedOperationException("The cipher algorithm in " + cipherSuite + " is not supported yet."); } private  AlgorithmResolver(); }
AlgorithmResolver { public static CipherAlgorithm getCipher(CipherSuite cipherSuite) { String cipher = cipherSuite.toString().toUpperCase(); if (cipher.contains("NULL")) { return CipherAlgorithm.NULL; } else if (cipher.contains("IDEA")) { return CipherAlgorithm.IDEA_128; } else if (cipher.contains("RC2")) { return CipherAlgorithm.RC2_128; } else if (cipher.contains("RC4")) { return CipherAlgorithm.RC4_128; } else if (cipher.contains("DES_EDE_CBC")) { return CipherAlgorithm.DES_EDE_CBC; } else if (cipher.contains("AES_128_CBC")) { return CipherAlgorithm.AES_128_CBC; } else if (cipher.contains("AES_256_CBC")) { return CipherAlgorithm.AES_256_CBC; } else if (cipher.contains("AES_128_GCM")) { return CipherAlgorithm.AES_128_GCM; } else if (cipher.contains("AES_256_GCM")) { return CipherAlgorithm.AES_256_GCM; } else if (cipher.contains("AES_128_CCM")) { return CipherAlgorithm.AES_128_CCM; } else if (cipher.contains("AES_256_CCM")) { return CipherAlgorithm.AES_256_CCM; } else if (cipher.contains("CAMELLIA_128_CBC")) { return CipherAlgorithm.CAMELLIA_128_CBC; } else if (cipher.contains("CAMELLIA_256_CBC")) { return CipherAlgorithm.CAMELLIA_256_CBC; } else if (cipher.contains("CAMELLIA_128_GCM")) { return CipherAlgorithm.CAMELLIA_128_GCM; } else if (cipher.contains("CAMELLIA_256_GCM")) { return CipherAlgorithm.CAMELLIA_256_GCM; } else if (cipher.contains("SEED_CBC")) { return CipherAlgorithm.SEED_CBC; } else if (cipher.contains("DES40_CBC")) { return CipherAlgorithm.DES40_CBC; } else if (cipher.contains("DES_CBC")) { return CipherAlgorithm.DES_CBC; } else if (cipher.contains("WITH_FORTEZZA_CBC")) { return CipherAlgorithm.FORTEZZA_CBC; } else if (cipher.contains("ARIA_128_CBC")) { return CipherAlgorithm.ARIA_128_CBC; } else if (cipher.contains("ARIA_256_CBC")) { return CipherAlgorithm.ARIA_256_CBC; } else if (cipher.contains("ARIA_128_GCM")) { return CipherAlgorithm.ARIA_128_GCM; } else if (cipher.contains("ARIA_256_GCM")) { return CipherAlgorithm.ARIA_256_GCM; } else if (cipher.contains("28147_CNT")) { return CipherAlgorithm.GOST_28147_CNT; } else if (cipher.contains("CHACHA20_POLY1305")) { return CipherAlgorithm.ChaCha20Poly1305; } if (cipherSuite == CipherSuite.TLS_FALLBACK_SCSV || cipherSuite == CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV) { throw new UnsupportedOperationException("The CipherSuite:" + cipherSuite.name() + " does not specify a Cipher"); } throw new UnsupportedOperationException("The cipher algorithm in " + cipherSuite + " is not supported yet."); } private  AlgorithmResolver(); static PRFAlgorithm getPRFAlgorithm(ProtocolVersion protocolVersion, CipherSuite cipherSuite); static DigestAlgorithm getDigestAlgorithm(ProtocolVersion protocolVersion, CipherSuite cipherSuite); static KeyExchangeAlgorithm getKeyExchangeAlgorithm(CipherSuite cipherSuite); static Set<PublicKeyAlgorithm> getRequiredKeystoreAlgorithms(CipherSuite cipherSuite); static CipherAlgorithm getCipher(CipherSuite cipherSuite); static BulkCipherAlgorithm getBulkCipherAlgorithm(CipherSuite cipherSuite); static CipherType getCipherType(CipherSuite cipherSuite); static MacAlgorithm getMacAlgorithm(ProtocolVersion protocolVersion, CipherSuite cipherSuite); static HKDFAlgorithm getHKDFAlgorithm(CipherSuite cipherSuite); }
AlgorithmResolver { public static CipherAlgorithm getCipher(CipherSuite cipherSuite) { String cipher = cipherSuite.toString().toUpperCase(); if (cipher.contains("NULL")) { return CipherAlgorithm.NULL; } else if (cipher.contains("IDEA")) { return CipherAlgorithm.IDEA_128; } else if (cipher.contains("RC2")) { return CipherAlgorithm.RC2_128; } else if (cipher.contains("RC4")) { return CipherAlgorithm.RC4_128; } else if (cipher.contains("DES_EDE_CBC")) { return CipherAlgorithm.DES_EDE_CBC; } else if (cipher.contains("AES_128_CBC")) { return CipherAlgorithm.AES_128_CBC; } else if (cipher.contains("AES_256_CBC")) { return CipherAlgorithm.AES_256_CBC; } else if (cipher.contains("AES_128_GCM")) { return CipherAlgorithm.AES_128_GCM; } else if (cipher.contains("AES_256_GCM")) { return CipherAlgorithm.AES_256_GCM; } else if (cipher.contains("AES_128_CCM")) { return CipherAlgorithm.AES_128_CCM; } else if (cipher.contains("AES_256_CCM")) { return CipherAlgorithm.AES_256_CCM; } else if (cipher.contains("CAMELLIA_128_CBC")) { return CipherAlgorithm.CAMELLIA_128_CBC; } else if (cipher.contains("CAMELLIA_256_CBC")) { return CipherAlgorithm.CAMELLIA_256_CBC; } else if (cipher.contains("CAMELLIA_128_GCM")) { return CipherAlgorithm.CAMELLIA_128_GCM; } else if (cipher.contains("CAMELLIA_256_GCM")) { return CipherAlgorithm.CAMELLIA_256_GCM; } else if (cipher.contains("SEED_CBC")) { return CipherAlgorithm.SEED_CBC; } else if (cipher.contains("DES40_CBC")) { return CipherAlgorithm.DES40_CBC; } else if (cipher.contains("DES_CBC")) { return CipherAlgorithm.DES_CBC; } else if (cipher.contains("WITH_FORTEZZA_CBC")) { return CipherAlgorithm.FORTEZZA_CBC; } else if (cipher.contains("ARIA_128_CBC")) { return CipherAlgorithm.ARIA_128_CBC; } else if (cipher.contains("ARIA_256_CBC")) { return CipherAlgorithm.ARIA_256_CBC; } else if (cipher.contains("ARIA_128_GCM")) { return CipherAlgorithm.ARIA_128_GCM; } else if (cipher.contains("ARIA_256_GCM")) { return CipherAlgorithm.ARIA_256_GCM; } else if (cipher.contains("28147_CNT")) { return CipherAlgorithm.GOST_28147_CNT; } else if (cipher.contains("CHACHA20_POLY1305")) { return CipherAlgorithm.ChaCha20Poly1305; } if (cipherSuite == CipherSuite.TLS_FALLBACK_SCSV || cipherSuite == CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV) { throw new UnsupportedOperationException("The CipherSuite:" + cipherSuite.name() + " does not specify a Cipher"); } throw new UnsupportedOperationException("The cipher algorithm in " + cipherSuite + " is not supported yet."); } private  AlgorithmResolver(); static PRFAlgorithm getPRFAlgorithm(ProtocolVersion protocolVersion, CipherSuite cipherSuite); static DigestAlgorithm getDigestAlgorithm(ProtocolVersion protocolVersion, CipherSuite cipherSuite); static KeyExchangeAlgorithm getKeyExchangeAlgorithm(CipherSuite cipherSuite); static Set<PublicKeyAlgorithm> getRequiredKeystoreAlgorithms(CipherSuite cipherSuite); static CipherAlgorithm getCipher(CipherSuite cipherSuite); static BulkCipherAlgorithm getBulkCipherAlgorithm(CipherSuite cipherSuite); static CipherType getCipherType(CipherSuite cipherSuite); static MacAlgorithm getMacAlgorithm(ProtocolVersion protocolVersion, CipherSuite cipherSuite); static HKDFAlgorithm getHKDFAlgorithm(CipherSuite cipherSuite);  }