1 /* 2 Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file 3 4 This file is part of libzmq, the ZeroMQ core engine in C++. 5 6 libzmq is free software; you can redistribute it and/or modify it under 7 the terms of the GNU Lesser General Public License (LGPL) as published 8 by the Free Software Foundation; either version 3 of the License, or 9 (at your option) any later version. 10 11 As a special exception, the Contributors give you permission to link 12 this library with independent modules to produce an executable, 13 regardless of the license terms of these independent modules, and to 14 copy and distribute the resulting executable under terms of your choice, 15 provided that you also meet, for each linked independent module, the 16 terms and conditions of the license of that module. An independent 17 module is a module which is not derived from or based on this library. 18 If you modify this library, you must extend this exception to your 19 version of the library. 20 21 libzmq is distributed in the hope that it will be useful, but WITHOUT 22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 23 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 24 License for more details. 25 26 You should have received a copy of the GNU Lesser General Public License 27 along with this program. If not, see <http://www.gnu.org/licenses/>. 28 */ 29 30 #ifndef __ZMQ_CURVE_SERVER_HPP_INCLUDED__ 31 #define __ZMQ_CURVE_SERVER_HPP_INCLUDED__ 32 33 #ifdef ZMQ_HAVE_CURVE 34 35 #include "curve_mechanism_base.hpp" 36 #include "options.hpp" 37 #include "zap_client.hpp" 38 39 namespace zmq 40 { 41 #ifdef _MSC_VER 42 #pragma warning(push) 43 #pragma warning(disable : 4250) 44 #endif 45 class curve_server_t ZMQ_FINAL : public zap_client_common_handshake_t, 46 public curve_mechanism_base_t 47 { 48 public: 49 curve_server_t (session_base_t *session_, 50 const std::string &peer_address_, 51 const options_t &options_, 52 const bool downgrade_sub_); 53 ~curve_server_t (); 54 55 // mechanism implementation 56 int next_handshake_command (msg_t *msg_); 57 int process_handshake_command (msg_t *msg_); 58 int encode (msg_t *msg_); 59 int decode (msg_t *msg_); 60 61 private: 62 // Our secret key (s) 63 uint8_t _secret_key[crypto_box_SECRETKEYBYTES]; 64 65 // Our short-term public key (S') 66 uint8_t _cn_public[crypto_box_PUBLICKEYBYTES]; 67 68 // Our short-term secret key (s') 69 uint8_t _cn_secret[crypto_box_SECRETKEYBYTES]; 70 71 // Client's short-term public key (C') 72 uint8_t _cn_client[crypto_box_PUBLICKEYBYTES]; 73 74 // Key used to produce cookie 75 uint8_t _cookie_key[crypto_secretbox_KEYBYTES]; 76 77 int process_hello (msg_t *msg_); 78 int produce_welcome (msg_t *msg_); 79 int process_initiate (msg_t *msg_); 80 int produce_ready (msg_t *msg_); 81 int produce_error (msg_t *msg_) const; 82 83 void send_zap_request (const uint8_t *key_); 84 }; 85 #ifdef _MSC_VER 86 #pragma warning(pop) 87 #endif 88 } 89 90 #endif 91 92 #endif 93