@Test public void testAdjustTLSContext() { FinishedMessage message = new FinishedMessage(); message.setVerifyData(new byte[] { 0, 1, 2, 3, 4 }); handler.adjustTLSContext(message); assertArrayEquals(new byte[] { 0, 1, 2, 3, 4 }, context.getLastClientVerifyData()); assertArrayEquals(null, context.getLastServerVerifyData()); assertEquals(Tls13KeySetType.NONE, context.getActiveServerKeySetType()); assertEquals(Tls13KeySetType.NONE, context.getActiveClientKeySetType()); assertArrayEquals(null, context.getClientApplicationTrafficSecret()); assertArrayEquals(null, context.getServerApplicationTrafficSecret()); assertArrayEquals(null, context.getMasterSecret()); }
@Override public void adjustTLSContext(FinishedMessage message) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.SERVER) { adjustApplicationTrafficSecrets(); setServerRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } else { setClientRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } } else if (tlsContext.getChooser().getConnectionEndType() == ConnectionEndType.CLIENT || !tlsContext.isExtensionNegotiated(ExtensionType.EARLY_DATA)) { setClientRecordCipher(Tls13KeySetType.HANDSHAKE_TRAFFIC_SECRETS); } } if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.CLIENT) { tlsContext.setLastClientVerifyData(message.getVerifyData().getValue()); } else { tlsContext.setLastServerVerifyData(message.getVerifyData().getValue()); } }
FinishedHandler extends HandshakeMessageHandler<FinishedMessage> { @Override public void adjustTLSContext(FinishedMessage message) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.SERVER) { adjustApplicationTrafficSecrets(); setServerRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } else { setClientRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } } else if (tlsContext.getChooser().getConnectionEndType() == ConnectionEndType.CLIENT || !tlsContext.isExtensionNegotiated(ExtensionType.EARLY_DATA)) { setClientRecordCipher(Tls13KeySetType.HANDSHAKE_TRAFFIC_SECRETS); } } if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.CLIENT) { tlsContext.setLastClientVerifyData(message.getVerifyData().getValue()); } else { tlsContext.setLastServerVerifyData(message.getVerifyData().getValue()); } } }
FinishedHandler extends HandshakeMessageHandler<FinishedMessage> { @Override public void adjustTLSContext(FinishedMessage message) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.SERVER) { adjustApplicationTrafficSecrets(); setServerRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } else { setClientRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } } else if (tlsContext.getChooser().getConnectionEndType() == ConnectionEndType.CLIENT || !tlsContext.isExtensionNegotiated(ExtensionType.EARLY_DATA)) { setClientRecordCipher(Tls13KeySetType.HANDSHAKE_TRAFFIC_SECRETS); } } if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.CLIENT) { tlsContext.setLastClientVerifyData(message.getVerifyData().getValue()); } else { tlsContext.setLastServerVerifyData(message.getVerifyData().getValue()); } } FinishedHandler(TlsContext context); }
FinishedHandler extends HandshakeMessageHandler<FinishedMessage> { @Override public void adjustTLSContext(FinishedMessage message) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.SERVER) { adjustApplicationTrafficSecrets(); setServerRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } else { setClientRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } } else if (tlsContext.getChooser().getConnectionEndType() == ConnectionEndType.CLIENT || !tlsContext.isExtensionNegotiated(ExtensionType.EARLY_DATA)) { setClientRecordCipher(Tls13KeySetType.HANDSHAKE_TRAFFIC_SECRETS); } } if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.CLIENT) { tlsContext.setLastClientVerifyData(message.getVerifyData().getValue()); } else { tlsContext.setLastServerVerifyData(message.getVerifyData().getValue()); } } FinishedHandler(TlsContext context); @Override FinishedParser getParser(byte[] message, int pointer); @Override FinishedPreparator getPreparator(FinishedMessage message); @Override FinishedSerializer getSerializer(FinishedMessage message); @Override void adjustTLSContext(FinishedMessage message); @Override void adjustTlsContextAfterSerialize(FinishedMessage message); }
FinishedHandler extends HandshakeMessageHandler<FinishedMessage> { @Override public void adjustTLSContext(FinishedMessage message) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.SERVER) { adjustApplicationTrafficSecrets(); setServerRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } else { setClientRecordCipher(Tls13KeySetType.APPLICATION_TRAFFIC_SECRETS); } } else if (tlsContext.getChooser().getConnectionEndType() == ConnectionEndType.CLIENT || !tlsContext.isExtensionNegotiated(ExtensionType.EARLY_DATA)) { setClientRecordCipher(Tls13KeySetType.HANDSHAKE_TRAFFIC_SECRETS); } } if (tlsContext.getTalkingConnectionEndType() == ConnectionEndType.CLIENT) { tlsContext.setLastClientVerifyData(message.getVerifyData().getValue()); } else { tlsContext.setLastServerVerifyData(message.getVerifyData().getValue()); } } FinishedHandler(TlsContext context); @Override FinishedParser getParser(byte[] message, int pointer); @Override FinishedPreparator getPreparator(FinishedMessage message); @Override FinishedSerializer getSerializer(FinishedMessage message); @Override void adjustTLSContext(FinishedMessage message); @Override void adjustTlsContextAfterSerialize(FinishedMessage message);  }