Go to the documentation of this file.
6 #define __STDC_LIMIT_MACROS
8 #if defined ZMQ_CUSTOM_PLATFORM_HPP
9 #include "platform.hpp"
11 #include "../src/platform.hpp"
14 #ifndef ZMQ_USE_LIBSODIUM
15 #define ZMQ_USE_LIBSODIUM
22 #include "../src/curve_client_tools.hpp"
23 #include "../src/random.hpp"
49 "0123456789012345678901234567890123456789"
50 "0123456789012345678901234567890123456789"
51 "0123456789012345678901234567890123456789"
52 "0123456789012345678901234567890123456789"
53 "0123456789012345678901234567890123456789"
62 const char *client_public_,
63 const char *client_secret_,
66 void **client_mon_ =
NULL,
67 int expected_client_event_ = 0,
68 int expected_client_value_ = 0)
74 client_mon_, expected_client_event_, expected_client_value_);
85 client_secret_, my_endpoint_, server_);
87 int handshake_failed_encryption_event_count =
100 "ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL/"
101 "ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC events: %i\n",
102 handshake_failed_encryption_event_count);
131 char bogus_public[41];
132 char bogus_secret[41];
139 int server_event_count = 0;
189 send (
s,
"\x01\x00", 2, 0);
191 send (
s,
"\x08\x00sneaky\0", 9, 0);
226 send (
s,
"\x04\x06\x05HELLO");
240 uint8_t valid_client_secret_decoded[32];
241 uint8_t valid_client_public_decoded[32];
246 uint8_t valid_server_public_decoded[32];
249 return zmq::curve_client_tools_t (valid_client_public_decoded,
250 valid_client_secret_decoded,
251 valid_server_public_decoded);
258 static const int num = 42;
261 if (*
reinterpret_cast<const char *
> (&num) == num) {
262 const uint32_t high_part = htonl (
static_cast<uint32_t
> (
value_ >> 32));
263 const uint32_t low_part =
264 htonl (
static_cast<uint32_t
> (
value_ & 0xFFFFFFFFLL));
266 return (
static_cast<uint64_t
> (low_part) << 32) | high_part;
334 while ((res = recv (fd_,
buf, 256, 0)) == 256) {
342 while (received < len_) {
343 int res = recv (fd_,
reinterpret_cast<char *
> (
data_), len_, 0);
359 char *my_endpoint_, zmq::curve_client_tools_t &tools_)
386 send (
s,
"\x04\x09\x08INITIATE");
399 zmq::curve_client_tools_t &tools_)
407 uint8_t cn_precom[crypto_box_BEFORENMBYTES];
425 tools.produce_initiate (initiate, 257, 1,
NULL, 0);
445 tools.produce_initiate (initiate, 257, 1,
NULL, 0);
447 initiate[30] = !initiate[30];
465 tools.produce_initiate (initiate, 257, 1,
NULL, 0);
467 initiate[150] = !initiate[150];
497 char null_key[] =
"0000000000000000000000000000000000000000";
527 printf (
"CURVE encryption not installed, skipping test\n");
560 "test_curve_security_with_valid_credentials (large routing id)\n");
void flush_read(fd_t fd_)
static void bounce(void *socket_)
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE
void test_null_client_secret_key()
#define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual)
void test_curve_security_invalid_keysize(void *ctx_)
void test_curve_security_invalid_hello_wrong_length()
void expect_new_client_bounce_fail(char *my_endpoint_, void *server_, socket_config_fn socket_config_, void *socket_config_data_, void **client_mon_, int expected_client_event_, int expected_client_value_)
void test_null_client_public_key()
#define ZMQ_EVENT_HANDSHAKE_FAILED_AUTH
ZMQ_EXPORT uint8_t * zmq_z85_decode(uint8_t *dest_, const char *string_)
#define ZMQ_PLAIN_USERNAME
#define ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND
void test_null_server_key()
void setup_context_and_server_side(void **zap_control_, void **zap_thread_, void **server_, void **server_mon_, char *my_endpoint_, zmq_thread_fn zap_handler_, socket_config_fn socket_config_, void *socket_config_data_, const char *routing_id_)
#define ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC
ZMQ_EXPORT void * zmq_ctx_new(void)
#define ZMQ_CURVE_SECRETKEY
int get_monitor_event_with_timeout(void *monitor_, int *value_, char **address_, int timeout_)
void expect_zmtp_mechanism_mismatch(void *client_, char *my_endpoint_, void *server_, void *server_mon_)
void test_curve_security_invalid_initiate_command_encrypted_content()
void zap_handler_generic(zap_protocol_t zap_protocol_, const char *expected_routing_id_)
ZMQ_EXPORT int zmq_has(const char *capability_)
#define ZMQ_PLAIN_PASSWORD
void setup_test_context()
#define ZMQ_CURVE_SERVERKEY
void test_curve_security_invalid_initiate_command_name()
const char large_routing_id[]
void teardown_test_context()
void send(fd_t fd_, const char(&data_)[N])
static NULL curve_client_data_t curve_client_data
void * test_context_socket_close_zero_linger(void *socket_)
char * s_recv(void *socket_)
#define TEST_ASSERT(condition)
ZMQ_EXPORT int zmq_connect(void *s_, const char *addr_)
#define TEST_ASSERT_NOT_EQUAL(expected, actual)
const size_t hello_length
void send_all(fd_t fd_, const char *data_, socket_size_t size_)
void test_curve_security_invalid_hello_command_name()
fd_t connect_exchange_greeting_and_hello_welcome(char *my_endpoint_, void *server_mon_, int timeout_, zmq::curve_client_tools_t &tools_)
void expect_new_client_curve_bounce_fail(const char *server_public_, const char *client_public_, const char *client_secret_, char *my_endpoint_, void *server_, void **client_mon_=NULL, int expected_client_event_=0, int expected_client_value_=0)
#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual)
#define ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH
char valid_server_secret[41]
#define ZMQ_EVENT_HANDSHAKE_SUCCEEDED
void test_curve_security_unauthenticated_message()
void test_curve_security_with_valid_credentials()
ZMQ_EXPORT int zmq_setsockopt(void *s_, int option_, const void *optval_, size_t optvallen_)
void socket_config_curve_server(void *server_, void *server_secret_)
void recv_greeting(fd_t fd_)
fd_t connect_exchange_greeting_and_send_hello(char *my_endpoint_, zmq::curve_client_tools_t &tools_)
#define assert_no_more_monitor_events_with_timeout(monitor, timeout)
void test_null_key(void *server_, void *server_mon_, char *my_endpoint_, char *server_public_, char *client_public_, char *client_secret_)
char valid_client_public[41]
fd_t connect_socket(const char *endpoint_, const int af_, const int protocol_)
void shutdown_context_and_server_side(void *zap_thread_, void *server_, void *server_mon_, void *zap_control_, bool zap_handler_stopped_)
char my_endpoint[MAX_SOCKET_STRING]
#define MAX_SOCKET_STRING
void recv_all(fd_t fd_, uint8_t *data_, socket_size_t len_)
GLbitfield GLuint64 timeout
ZMQ_EXPORT void * zmq_socket(void *, int type_)
static uint64_t host_to_network(uint64_t value_)
void * test_context_socket(int type_)
void test_curve_security_invalid_hello_version()
void send_command(fd_t s_, char(&command_)[N])
GLenum GLuint GLenum GLsizei const GLchar * buf
static void zap_handler_large_routing_id(void *)
#define TEST_ASSERT_EQUAL_INT(expected, actual)
char error_message_buffer[256]
#define TEST_ASSERT_NULL_MESSAGE(pointer, message)
ZMQ_EXPORT int zmq_close(void *s_)
ZMQ_EXPORT int zmq_curve_keypair(char *z85_public_key_, char *z85_secret_key_)
void expect_bounce_fail(void *server_, void *client_)
const uint8_t zmtp_greeting_curve[64]
void * create_and_connect_client(char *my_endpoint_, socket_config_fn socket_config_, void *socket_config_data_, void **client_mon_)
int expect_monitor_event_multiple(void *server_mon_, int expected_event_, int expected_err_, bool optional_)
void test_curve_security_with_bogus_client_credentials()
void test_curve_security_with_null_client_credentials()
ZMQ_EXPORT int zmq_atomic_counter_value(void *counter_)
void test_curve_security_with_plain_client_credentials()
char valid_server_public[41]
void setup_test_environment(int timeout_seconds_)
char valid_client_secret[41]
#define ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL
void socket_config_curve_client(void *client_, void *data_)
void test_curve_security_invalid_initiate_wrong_length()
static zmtp_greeting_t greeting
zmq::curve_client_tools_t make_curve_client_tools()
const size_t welcome_length
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO
ZMQ_EXPORT int zmq_ctx_term(void *context_)
void * test_context_socket_close(void *socket_)
#define TEST_ASSERT_NOT_NULL(pointer)
#define TEST_ASSERT_SUCCESS_ERRNO(expr)
#define ZMQ_CURVE_PUBLICKEY
void test_curve_security_invalid_initiate_command_encrypted_cookie()
void setup_testutil_security_curve()
void * zap_requests_handled
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:59