diff --git a/src/curve_server.cpp b/src/curve_server.cpp index 4255fa2f..7d0d730c 100644 --- a/src/curve_server.cpp +++ b/src/curve_server.cpp @@ -537,6 +537,14 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key) rc = session->write_zap_msg (&msg); errno_assert (rc == 0); + // identity frame + rc = msg.init_size (options.identity_size); + errno_assert(rc == 0); + memcpy (msg.data (), options.identity, options.identity_size); + msg.set_flags (msg_t::more); + rc = session->write_zap_msg (&msg); + errno_assert (rc == 0); + // Mechanism frame rc = msg.init_size (5); errno_assert (rc == 0); diff --git a/src/plain_mechanism.cpp b/src/plain_mechanism.cpp index 8090909b..85173ffa 100644 --- a/src/plain_mechanism.cpp +++ b/src/plain_mechanism.cpp @@ -380,6 +380,14 @@ void zmq::plain_mechanism_t::send_zap_request (const std::string &username, rc = session->write_zap_msg (&msg); errno_assert (rc == 0); + // identity frame + rc = msg.init_size (options.identity_size); + errno_assert(rc == 0); + memcpy (msg.data (), options.identity, options.identity_size); + msg.set_flags (msg_t::more); + rc = session->write_zap_msg (&msg); + errno_assert (rc == 0); + // Mechanism frame rc = msg.init_size (5); errno_assert (rc == 0); diff --git a/tests/test_security.cpp b/tests/test_security.cpp index e6feed34..29907c47 100644 --- a/tests/test_security.cpp +++ b/tests/test_security.cpp @@ -28,12 +28,15 @@ static void zap_handler (void *zap) char *sequence = s_recv (zap); char *domain = s_recv (zap); char *address = s_recv (zap); + char *identity = s_recv(zap); char *mechanism = s_recv (zap); char *username = s_recv (zap); char *password = s_recv (zap); + printf("identity: %s\n", identity); assert (streq (version, "1.0")); assert (streq (mechanism, "PLAIN")); + assert (streq (identity, "IDENT")); s_sendmore (zap, version); s_sendmore (zap, sequence); @@ -55,6 +58,7 @@ static void zap_handler (void *zap) free (sequence); free (domain); free (address); + free (identity); free (mechanism); free (username); free (password); @@ -115,6 +119,7 @@ int main (void) // Check PLAIN security server = zmq_socket (ctx, ZMQ_DEALER); assert (server); + rc = zmq_setsockopt(server, ZMQ_IDENTITY, "IDENT",6); client = zmq_socket (ctx, ZMQ_DEALER); assert (client); diff --git a/tests/test_security_curve.cpp b/tests/test_security_curve.cpp index 19304c12..7804526c 100644 --- a/tests/test_security_curve.cpp +++ b/tests/test_security_curve.cpp @@ -29,11 +29,13 @@ static void zap_handler (void *zap) char *sequence = s_recv (zap); char *domain = s_recv (zap); char *address = s_recv (zap); + char *identity = s_recv(zap); char *mechanism = s_recv (zap); char *client_key = s_recv (zap); assert (streq (version, "1.0")); assert (streq (mechanism, "CURVE")); + assert (streq (identity, "IDENT")); s_sendmore (zap, version); s_sendmore (zap, sequence); @@ -46,6 +48,7 @@ static void zap_handler (void *zap) free (sequence); free (domain); free (address); + free (identity); free (mechanism); free (client_key); @@ -87,6 +90,8 @@ int main (void) assert (rc == 0); rc = zmq_setsockopt (server, ZMQ_CURVE_SECRETKEY, server_secret, 40); assert (rc == 0); + rc = zmq_setsockopt(server, ZMQ_IDENTITY, "IDENT",6); + assert (rc == 0); rc = zmq_setsockopt (client, ZMQ_CURVE_SERVERKEY, server_public, 40); assert (rc == 0);