/* * CryptoPlayer.h * */ #ifndef NETWORKING_CRYPTOPLAYER_H_ #define NETWORKING_CRYPTOPLAYER_H_ #include "ssl_sockets.h" #include "Networking/Player.h" #include #include /** * Encrypted multi-party communication. * Uses OpenSSL and certificates issued to "P". * Sending and receiving is done in separate threads to allow * for bidirectional communication. */ class CryptoPlayer : public MultiPlayer { ssl_ctx ctx; boost::asio::io_service io_service; vector other_sockets; vector*> senders; vector*> receivers; void connect(int other, vector* plaintext_sockets); public: /** * Start a new set of encrypted connections. * @param Nms network setup * @param id unique identifier */ CryptoPlayer(const Names& Nms, const string& id); // legacy interface CryptoPlayer(const Names& Nms, int id_base = 0); ~CryptoPlayer(); bool is_encrypted() { return true; } void send_to_no_stats(int other, const octetStream& o) const; void receive_player_no_stats(int other, octetStream& o) const; size_t send_no_stats(int player, const PlayerBuffer& buffer, bool block) const; size_t recv_no_stats(int player, const PlayerBuffer& buffer, bool block) const; void exchange_no_stats(int other, const octetStream& to_send, octetStream& to_receive) const; void pass_around_no_stats(const octetStream& to_send, octetStream& to_receive, int offset) const; void send_receive_all_no_stats(const vector>& channels, const vector& to_send, vector& to_receive) const; void partial_broadcast(const vector& my_senders, const vector& my_receivers, vector& os) const; void Broadcast_Receive_no_stats(vector& os) const; }; #endif /* NETWORKING_CRYPTOPLAYER_H_ */