Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
2e9385ac
Commit
2e9385ac
authored
Aug 21, 2013
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #631 from jrossi/master
Add the Socket Identity info to the ZAP Messages
parents
d485404a
19ca8a0f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
0 deletions
+26
-0
curve_server.cpp
src/curve_server.cpp
+8
-0
plain_mechanism.cpp
src/plain_mechanism.cpp
+8
-0
test_security.cpp
tests/test_security.cpp
+5
-0
test_security_curve.cpp
tests/test_security_curve.cpp
+5
-0
No files found.
src/curve_server.cpp
View file @
2e9385ac
...
...
@@ -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
);
...
...
src/plain_mechanism.cpp
View file @
2e9385ac
...
...
@@ -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
);
...
...
tests/test_security.cpp
View file @
2e9385ac
...
...
@@ -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
);
...
...
tests/test_security_curve.cpp
View file @
2e9385ac
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment