/** * Reads the next bytes as the SerializedPublicKey and writes them in the * message * * @param msg * Message to write in */ private void parseSerializedPublicKey(ECDHClientKeyExchangeMessage msg) { msg.setPublicKey(parseByteArrayField(msg.getPublicKeyLength().getValue())); LOGGER.debug("SerializedPublicKey: " + ArrayConverter.bytesToHexString(msg.getPublicKey().getValue())); }
protected void prepareSerializedPublicKey(T msg) { msg.setPublicKey(ArrayConverter.concatenate(new byte[] { msg.getEcPointFormat().getValue() }, msg .getEcPointEncoded().getValue())); LOGGER.debug("SerializedPublicKey: " + ArrayConverter.bytesToHexString(msg.getPublicKey().getValue())); }
private WorkflowTrace executeProtocolFlow() { Config tlsConfig = getTlsConfig(); WorkflowTrace trace = new WorkflowConfigurationFactory(tlsConfig).createWorkflowTrace(WorkflowTraceType.HELLO, RunningModeType.CLIENT); trace.addTlsAction(new SendAction(new ECDHClientKeyExchangeMessage(tlsConfig), new ChangeCipherSpecMessage( tlsConfig), new FinishedMessage(tlsConfig))); trace.addTlsAction(new ReceiveAction(new ChangeCipherSpecMessage(), new FinishedMessage())); State state = new State(tlsConfig, trace); WorkflowExecutor workflowExecutor = WorkflowExecutorFactory.createWorkflowExecutor( tlsConfig.getWorkflowExecutorType(), state); ECDHClientKeyExchangeMessage message = (ECDHClientKeyExchangeMessage) WorkflowTraceUtil.getFirstSendMessage( HandshakeMessageType.CLIENT_KEY_EXCHANGE, trace); ModifiableByteArray serializedPublicKey = ModifiableVariableFactory.createByteArrayModifiableVariable(); byte[] points = ArrayConverter.concatenate(ArrayConverter.bigIntegerToByteArray(config.getPublicPointBaseX()), ArrayConverter.bigIntegerToByteArray(config.getPublicPointBaseY())); byte[] serialized = ArrayConverter.concatenate(new byte[] { 4 }, points); serializedPublicKey.setModification(ByteArrayModificationFactory.explicitValue(serialized)); message.setPublicKey(serializedPublicKey); ModifiableByteArray pms = ModifiableVariableFactory.createByteArrayModifiableVariable(); byte[] explicitPMS = BigIntegers.asUnsignedByteArray(config.getCurveFieldSize(), premasterSecret); pms.setModification(ByteArrayModificationFactory.explicitValue(explicitPMS)); message.prepareComputations(); message.getComputations().setPremasterSecret(pms); LOGGER.info("working with the follwoing premaster secret: " + ArrayConverter.bytesToHexString(explicitPMS)); workflowExecutor.executeWorkflow(); return trace; } }