AlgorithmResolver { public static HKDFAlgorithm getHKDFAlgorithm(CipherSuite cipherSuite) { HKDFAlgorithm result = null; String cipher = cipherSuite.toString(); if (cipher.endsWith("SHA256")) { result = HKDFAlgorithm.TLS_HKDF_SHA256; } else if (cipher.endsWith("SHA384")) { result = HKDFAlgorithm.TLS_HKDF_SHA384; } if (result != null) { LOGGER.debug("Using the following HKDF Algorithm: {}", result); return result; } else { LOGGER.warn("The HKDF algorithm for cipher suite " + cipherSuite + " is not supported yet or is undefined. Using \"TLS_HKDF_SHA256\""); return HKDFAlgorithm.TLS_HKDF_SHA256; } } 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);  }
@Test public void testGetHKDFAlgorithm() { CipherSuite cipherSuite = CipherSuite.TLS_AES_128_GCM_SHA256; HKDFAlgorithm result = AlgorithmResolver.getHKDFAlgorithm(cipherSuite); HKDFAlgorithm result_correct = HKDFAlgorithm.TLS_HKDF_SHA256; assertTrue(result == result_correct); }