DHEServerKeyExchangeSerializer extends
        ServerKeyExchangeSerializer<T> { @Override public byte[] serializeHandshakeMessageContent() { LOGGER.debug("Serializing DHEServerKeyExchangeMessage"); writePLength(msg); writeP(msg); writeGLength(msg); writeG(msg); writeSerializedPublicKeyLength(msg); writeSerializedPublicKey(msg); if (isTLS12() || isDTLS12()) { writeSignatureAndHashAlgorithm(msg); } writeSignatureLength(msg); writeSignature(msg); return getAlreadySerialized(); } DHEServerKeyExchangeSerializer(T message, ProtocolVersion version); @Override byte[] serializeHandshakeMessageContent();  }
@Test public void testSerializeHandshakeMessageContent() { DHEServerKeyExchangeMessage msg = new DHEServerKeyExchangeMessage(); msg.setCompleteResultingMessage(expectedPart); msg.setType(type.getValue()); msg.setLength(length); msg.setModulusLength(pLength); msg.setModulus(p); msg.setGeneratorLength(gLength); msg.setGenerator(g); msg.setPublicKey(serializedKey); msg.setPublicKeyLength(serializedKeyLength); msg.setSignature(signature); if (signatureAndHashAlgo != null) { msg.setSignatureAndHashAlgorithm(signatureAndHashAlgo); } msg.setSignatureLength(sigLength); DHEServerKeyExchangeSerializer serializer = new DHEServerKeyExchangeSerializer(msg, version); assertArrayEquals(expectedPart, serializer.serialize()); }