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
f789177a
Commit
f789177a
authored
Feb 17, 2014
by
Ian Barber
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #898 from hintjens/master
Added temporary CURVE debugging support
parents
0be4a92d
8cca4735
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
curve_server.cpp
src/curve_server.cpp
+27
-0
curve_server.hpp
src/curve_server.hpp
+2
-1
No files found.
src/curve_server.cpp
View file @
f789177a
...
@@ -86,13 +86,18 @@ int zmq::curve_server_t::process_handshake_command (msg_t *msg_)
...
@@ -86,13 +86,18 @@ int zmq::curve_server_t::process_handshake_command (msg_t *msg_)
rc
=
process_hello
(
msg_
);
rc
=
process_hello
(
msg_
);
if
(
rc
==
0
)
if
(
rc
==
0
)
state
=
send_welcome
;
state
=
send_welcome
;
else
state
=
errored
;
break
;
break
;
case
expect_initiate
:
case
expect_initiate
:
rc
=
process_initiate
(
msg_
);
rc
=
process_initiate
(
msg_
);
if
(
rc
==
0
)
if
(
rc
==
0
)
state
=
expecting_zap_reply
?
expect_zap_reply
:
send_ready
;
state
=
expecting_zap_reply
?
expect_zap_reply
:
send_ready
;
else
state
=
errored
;
break
;
break
;
default
:
default
:
state
=
errored
;
errno
=
EPROTO
;
errno
=
EPROTO
;
rc
=
-
1
;
rc
=
-
1
;
break
;
break
;
...
@@ -233,12 +238,16 @@ bool zmq::curve_server_t::is_handshake_complete () const
...
@@ -233,12 +238,16 @@ bool zmq::curve_server_t::is_handshake_complete () const
int
zmq
::
curve_server_t
::
process_hello
(
msg_t
*
msg_
)
int
zmq
::
curve_server_t
::
process_hello
(
msg_t
*
msg_
)
{
{
if
(
msg_
->
size
()
!=
200
)
{
if
(
msg_
->
size
()
!=
200
)
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: client HELLO is not correct size"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
const
uint8_t
*
const
hello
=
static_cast
<
uint8_t
*>
(
msg_
->
data
());
const
uint8_t
*
const
hello
=
static_cast
<
uint8_t
*>
(
msg_
->
data
());
if
(
memcmp
(
hello
,
"
\x05
HELLO"
,
6
))
{
if
(
memcmp
(
hello
,
"
\x05
HELLO"
,
6
))
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: client HELLO has invalid command name"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
...
@@ -247,6 +256,8 @@ int zmq::curve_server_t::process_hello (msg_t *msg_)
...
@@ -247,6 +256,8 @@ int zmq::curve_server_t::process_hello (msg_t *msg_)
const
uint8_t
minor
=
hello
[
7
];
const
uint8_t
minor
=
hello
[
7
];
if
(
major
!=
1
||
minor
!=
0
)
{
if
(
major
!=
1
||
minor
!=
0
)
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: client HELLO has unknown version number"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
...
@@ -269,6 +280,8 @@ int zmq::curve_server_t::process_hello (msg_t *msg_)
...
@@ -269,6 +280,8 @@ int zmq::curve_server_t::process_hello (msg_t *msg_)
sizeof
hello_box
,
sizeof
hello_box
,
hello_nonce
,
cn_client
,
secret_key
);
hello_nonce
,
cn_client
,
secret_key
);
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: cannot open client HELLO -- wrong server key?"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
...
@@ -339,12 +352,16 @@ int zmq::curve_server_t::produce_welcome (msg_t *msg_)
...
@@ -339,12 +352,16 @@ int zmq::curve_server_t::produce_welcome (msg_t *msg_)
int
zmq
::
curve_server_t
::
process_initiate
(
msg_t
*
msg_
)
int
zmq
::
curve_server_t
::
process_initiate
(
msg_t
*
msg_
)
{
{
if
(
msg_
->
size
()
<
257
)
{
if
(
msg_
->
size
()
<
257
)
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: client INITIATE is not correct size"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
const
uint8_t
*
initiate
=
static_cast
<
uint8_t
*>
(
msg_
->
data
());
const
uint8_t
*
initiate
=
static_cast
<
uint8_t
*>
(
msg_
->
data
());
if
(
memcmp
(
initiate
,
"
\x08
INITIATE"
,
9
))
{
if
(
memcmp
(
initiate
,
"
\x08
INITIATE"
,
9
))
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: client INITIATE has invalid command name"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
...
@@ -364,6 +381,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
...
@@ -364,6 +381,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
sizeof
cookie_box
,
sizeof
cookie_box
,
cookie_nonce
,
cookie_key
);
cookie_nonce
,
cookie_key
);
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: cannot open client INITIATE cookie"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
...
@@ -371,6 +390,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
...
@@ -371,6 +390,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
// Check cookie plain text is as expected [C' + s']
// Check cookie plain text is as expected [C' + s']
if
(
memcmp
(
cookie_plaintext
+
crypto_secretbox_ZEROBYTES
,
cn_client
,
32
)
if
(
memcmp
(
cookie_plaintext
+
crypto_secretbox_ZEROBYTES
,
cn_client
,
32
)
||
memcmp
(
cookie_plaintext
+
crypto_secretbox_ZEROBYTES
+
32
,
cn_secret
,
32
))
{
||
memcmp
(
cookie_plaintext
+
crypto_secretbox_ZEROBYTES
+
32
,
cn_secret
,
32
))
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: client INITIATE cookie is not valid"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
...
@@ -392,6 +413,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
...
@@ -392,6 +413,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
rc
=
crypto_box_open
(
initiate_plaintext
,
initiate_box
,
rc
=
crypto_box_open
(
initiate_plaintext
,
initiate_box
,
clen
,
initiate_nonce
,
cn_client
,
cn_secret
);
clen
,
initiate_nonce
,
cn_client
,
cn_secret
);
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: cannot open client INITIATE"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
...
@@ -415,6 +438,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
...
@@ -415,6 +438,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
sizeof
vouch_box
,
sizeof
vouch_box
,
vouch_nonce
,
client_key
,
cn_secret
);
vouch_nonce
,
client_key
,
cn_secret
);
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
// Temporary support for CURVE debugging
puts
(
"CURVE I: cannot open client INITIATE vouch"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
...
@@ -609,6 +634,8 @@ int zmq::curve_server_t::receive_and_process_zap_reply ()
...
@@ -609,6 +634,8 @@ int zmq::curve_server_t::receive_and_process_zap_reply ()
// Status code frame
// Status code frame
if
(
msg
[
3
].
size
()
!=
3
||
memcmp
(
msg
[
3
].
data
(),
"200"
,
3
))
{
if
(
msg
[
3
].
size
()
!=
3
||
memcmp
(
msg
[
3
].
data
(),
"200"
,
3
))
{
rc
=
-
1
;
rc
=
-
1
;
// Temporary support for CURVE debugging
puts
(
"CURVE I: ZAP handler rejected client authentication"
);
errno
=
EACCES
;
errno
=
EACCES
;
goto
error
;
goto
error
;
}
}
...
...
src/curve_server.hpp
View file @
f789177a
...
@@ -70,7 +70,8 @@ namespace zmq
...
@@ -70,7 +70,8 @@ namespace zmq
expect_initiate
,
expect_initiate
,
expect_zap_reply
,
expect_zap_reply
,
send_ready
,
send_ready
,
connected
connected
,
errored
};
};
session_base_t
*
const
session
;
session_base_t
*
const
session
;
...
...
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