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
00816875
Commit
00816875
authored
Aug 17, 2017
by
sigiesec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: no ZAP tests for NULL mechanism
Solution: added ZAP tests for NULL
parent
f107b537
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
7 deletions
+44
-7
test_security_zap.cpp
tests/test_security_zap.cpp
+5
-0
testutil_security.hpp
tests/testutil_security.hpp
+39
-7
No files found.
tests/test_security_zap.cpp
View file @
00816875
...
...
@@ -197,7 +197,12 @@ int main (void)
{
setup_test_environment
();
fprintf
(
stderr
,
"NULL mechanism
\n
"
);
test_zap_errors
(
&
socket_config_null_server
,
NULL
,
&
socket_config_null_client
,
NULL
);
if
(
zmq_has
(
"curve"
))
{
fprintf
(
stderr
,
"CURVE mechanism
\n
"
);
setup_testutil_security_curve
();
curve_client_data_t
curve_client_data
=
{
...
...
tests/testutil_security.hpp
View file @
00816875
...
...
@@ -36,6 +36,19 @@
typedef
void
(
socket_config_fn
)
(
void
*
,
void
*
);
const
char
*
test_zap_domain
=
"ZAPTEST"
;
// NULL specific functions
void
socket_config_null_client
(
void
*
server
,
void
*
server_secret
)
{
}
void
socket_config_null_server
(
void
*
server
,
void
*
server_secret
)
{
int
rc
=
zmq_setsockopt
(
server
,
ZMQ_ZAP_DOMAIN
,
test_zap_domain
,
7
);
assert
(
rc
==
0
);
}
// CURVE specific functions
// We'll generate random test keys at startup
...
...
@@ -148,15 +161,34 @@ void zap_handler_generic (void *ctx,
char
*
address
=
s_recv
(
handler
);
char
*
identity
=
s_recv
(
handler
);
char
*
mechanism
=
s_recv
(
handler
);
uint8_t
client_key
[
32
];
int
size
=
zmq_recv
(
handler
,
client_key
,
32
,
0
);
assert
(
size
==
32
);
bool
authentication_succeeded
=
false
;
if
(
streq
(
mechanism
,
"CURVE"
))
{
uint8_t
client_key
[
32
];
int
size
=
zmq_recv
(
handler
,
client_key
,
32
,
0
);
assert
(
size
==
32
);
char
client_key_text
[
41
];
zmq_z85_encode
(
client_key_text
,
client_key
,
32
);
char
client_key_text
[
41
];
zmq_z85_encode
(
client_key_text
,
client_key
,
32
);
authentication_succeeded
=
streq
(
client_key_text
,
valid_client_public
);
}
else
if
(
streq
(
mechanism
,
"PLAIN"
))
{
// TODO
authentication_succeeded
=
true
;
}
else
if
(
streq
(
mechanism
,
"NULL"
))
{
authentication_succeeded
=
true
;
}
else
{
fprintf
(
stderr
,
"Unsupported mechanism: %s
\n
"
,
mechanism
);
assert
(
false
);
}
assert
(
streq
(
version
,
"1.0"
));
assert
(
streq
(
mechanism
,
"CURVE"
));
assert
(
streq
(
identity
,
expected_identity
));
s_sendmore
(
handler
,
zap_protocol
==
zap_wrong_version
...
...
@@ -166,7 +198,7 @@ void zap_handler_generic (void *ctx,
?
"invalid_request_id"
:
sequence
);
if
(
streq
(
client_key_text
,
valid_client_public
)
)
{
if
(
authentication_succeeded
)
{
const
char
*
status_code
;
switch
(
zap_protocol
)
{
case
zap_status_internal_error
:
...
...
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