///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| 5 | |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | std::shared_ptr<FSecure::C3::Core::NodeRelay> FSecure::C3::Core::NodeRelay::CreateAndRun(LoggerCallback callbackOnLog, InterfaceFactory& interfaceFactory, |
| 8 | Crypto::PublicSignature const& gatewaySignature, Crypto::SymmetricKey const& broadcastKey, std::vector<ByteVector> const& gatewayInitialPackets, BuildId buildId, AgentId agentId, |
| 9 | Crypto::AsymmetricKeys const& asymmetricKeys) |
| 10 | { |
| 11 | // Make one. |
| 12 | auto relay = std::shared_ptr<NodeRelay>{ new NodeRelay{ callbackOnLog, interfaceFactory, gatewaySignature, broadcastKey, buildId, agentId, asymmetricKeys} }; |
| 13 | |
| 14 | // Perform all initial Commands. |
| 15 | if (gatewayInitialPackets.empty()) |
| 16 | throw std::invalid_argument{ OBF("No initial Command") }; |
| 17 | |
| 18 | auto args = ByteView{ gatewayInitialPackets[0] }; |
| 19 | auto isNegChannel = args.Read<bool>(); |
| 20 | auto deviceHash = args.Read<HashT>(); |
| 21 | auto dev = relay->CreateAndAttachDevice(DeviceId{ 0 }, deviceHash, isNegChannel, args, true); |
| 22 | |
| 23 | |
| 24 | // Send IC packet. |
| 25 | if (isNegChannel) |
| 26 | relay->NegotiateChannel(dev); |
| 27 | else |
| 28 | relay->InitializeRoute(); |
| 29 | |
| 30 | // All fine and dandy. |
| 31 | return relay; |
| 32 | } |
| 33 | |
| 34 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 35 | FSecure::C3::Core::NodeRelay::NodeRelay(LoggerCallback callbackOnLog, InterfaceFactory& interfaceFactory, |
nothing calls this directly
no test coverage detected