public static CipherSuite getCipherSuite(byte[] value) { return getCipherSuite(valueToInt(value)); }
public static List<CipherSuite> getCiphersuites(byte[] values) { List<CipherSuite> cipherSuites = new LinkedList<>(); int pointer = 0; if (values.length % 2 != 0) { throw new UnknownCiphersuiteException("Last CipherSuit are unknown!"); } while (pointer < values.length) { byte[] suite = new byte[2]; suite[0] = values[pointer]; suite[1] = values[pointer + 1]; cipherSuites.add(getCipherSuite(suite)); pointer += 2; } return cipherSuites; }
private List<CipherSuite> convertCipherSuites(byte[] bytesToConvert) { if (bytesToConvert.length % 2 != 0) { LOGGER.warn("Cannot convert:" + ArrayConverter.bytesToHexString(bytesToConvert, false) + " to a List<CipherSuite>"); return null; } List<CipherSuite> list = new LinkedList<>(); for (int i = 0; i < bytesToConvert.length; i += 2) { byte[] copied = new byte[2]; copied[0] = bytesToConvert[i]; copied[1] = bytesToConvert[i + 1]; CipherSuite suite = CipherSuite.getCipherSuite(copied); if (suite == null) { LOGGER.warn("Cannot convert:" + ArrayConverter.bytesToHexString(copied) + " to a CipherSuite"); } else { list.add(suite); } } return list; }
private void adjustSelectedCiphersuite(HelloRetryRequestMessage message) { CipherSuite suite = CipherSuite.getCipherSuite(message.getSelectedCipherSuite().getValue()); tlsContext.setSelectedCipherSuite(suite); if (suite != null) { LOGGER.debug("Set SelectedCipherSuite in Context to " + suite.name()); } else { LOGGER.warn("Could not determine selected CipherSuite. Not Adjusting Context"); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("HelloRetryRequestMessage:"); sb.append("\n Protocol Version: "); if (protocolVersion != null && protocolVersion.getValue() != null) { sb.append(ProtocolVersion.getProtocolVersion(protocolVersion.getValue())); } else { sb.append("null"); } sb.append("\n Selected Cipher Suite: "); if (selectedCipherSuite != null && selectedCipherSuite.getValue() != null) { sb.append(CipherSuite.getCipherSuite(selectedCipherSuite.getValue())).append("\n Extensions: "); } else { sb.append("null"); } sb.append("\n Extensions: "); if (getExtensions() == null) { sb.append("null"); } else { for (ExtensionMessage e : getExtensions()) { sb.append("\n ").append(e.toString()); } } return sb.toString(); }
private void adjustSelectedCiphersuite(ServerHelloMessage message) { CipherSuite suite = null; if (message.getSelectedCipherSuite() != null) { suite = CipherSuite.getCipherSuite(message.getSelectedCipherSuite().getValue()); } if (suite != null) { tlsContext.setSelectedCipherSuite(suite); LOGGER.debug("Set SelectedCipherSuite in Context to " + suite.name()); } else { LOGGER.warn("Unknown CipherSuite, did not adjust Context"); } }
private void writeCipherSuite(StatePlaintext statePlaintext) { appendInt(statePlaintext.getCipherSuite().getValue(), HandshakeByteLength.CIPHER_SUITE); LOGGER.debug("CipherSuite: " + CipherSuite.getCipherSuite(statePlaintext.getCipherSuite().getValue()).name()); }
sb.append(CipherSuite.getCipherSuite(selectedCipherSuite.getValue())); } else { sb.append("null");