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
3e394fdd
Commit
3e394fdd
authored
Feb 03, 2020
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: naming convention violated by curve_mechanism_base
Solution: change to conform with naming convention
parent
75dfbae0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
31 deletions
+32
-31
curve_client.cpp
src/curve_client.cpp
+7
-7
curve_mechanism_base.cpp
src/curve_mechanism_base.cpp
+12
-12
curve_mechanism_base.hpp
src/curve_mechanism_base.hpp
+7
-6
curve_server.cpp
src/curve_server.cpp
+6
-6
No files found.
src/curve_client.cpp
View file @
3e394fdd
...
...
@@ -137,7 +137,7 @@ int zmq::curve_client_t::produce_hello (msg_t *msg_)
int
rc
=
msg_
->
init_size
(
200
);
errno_assert
(
rc
==
0
);
rc
=
_tools
.
produce_hello
(
msg_
->
data
(),
cn_nonce
);
rc
=
_tools
.
produce_hello
(
msg_
->
data
(),
_
cn_nonce
);
if
(
rc
==
-
1
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC
);
...
...
@@ -150,7 +150,7 @@ int zmq::curve_client_t::produce_hello (msg_t *msg_)
return
-
1
;
}
cn_nonce
++
;
_
cn_nonce
++
;
return
0
;
}
...
...
@@ -158,7 +158,7 @@ int zmq::curve_client_t::produce_hello (msg_t *msg_)
int
zmq
::
curve_client_t
::
process_welcome
(
const
uint8_t
*
msg_data_
,
size_t
msg_size_
)
{
const
int
rc
=
_tools
.
process_welcome
(
msg_data_
,
msg_size_
,
cn_precom
);
const
int
rc
=
_tools
.
process_welcome
(
msg_data_
,
msg_size_
,
_
cn_precom
);
if
(
rc
==
-
1
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
...
...
@@ -186,7 +186,7 @@ int zmq::curve_client_t::produce_initiate (msg_t *msg_)
int
rc
=
msg_
->
init_size
(
msg_size
);
errno_assert
(
rc
==
0
);
rc
=
_tools
.
produce_initiate
(
msg_
->
data
(),
msg_size
,
cn_nonce
,
rc
=
_tools
.
produce_initiate
(
msg_
->
data
(),
msg_size
,
_
cn_nonce
,
&
metadata_plaintext
[
0
],
metadata_length
);
if
(
-
1
==
rc
)
{
...
...
@@ -197,7 +197,7 @@ int zmq::curve_client_t::produce_initiate (msg_t *msg_)
return
-
1
;
}
cn_nonce
++
;
_
cn_nonce
++
;
return
0
;
}
...
...
@@ -227,10 +227,10 @@ int zmq::curve_client_t::process_ready (const uint8_t *msg_data_,
memcpy
(
ready_nonce
,
"CurveZMQREADY---"
,
16
);
memcpy
(
ready_nonce
+
16
,
msg_data_
+
6
,
8
);
cn_peer_nonce
=
get_uint64
(
msg_data_
+
6
);
_
cn_peer_nonce
=
get_uint64
(
msg_data_
+
6
);
int
rc
=
crypto_box_open_afternm
(
&
ready_plaintext
[
0
],
&
ready_box
[
0
],
clen
,
ready_nonce
,
cn_precom
);
ready_nonce
,
_
cn_precom
);
if
(
rc
!=
0
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
...
...
src/curve_mechanism_base.cpp
View file @
3e394fdd
...
...
@@ -42,10 +42,10 @@ zmq::curve_mechanism_base_t::curve_mechanism_base_t (
const
char
*
encode_nonce_prefix_
,
const
char
*
decode_nonce_prefix_
)
:
mechanism_base_t
(
session_
,
options_
),
encode_nonce_prefix
(
encode_nonce_prefix_
),
decode_nonce_prefix
(
decode_nonce_prefix_
),
cn_nonce
(
1
),
cn_peer_nonce
(
1
)
_
encode_nonce_prefix
(
encode_nonce_prefix_
),
_
decode_nonce_prefix
(
decode_nonce_prefix_
),
_
cn_nonce
(
1
),
_
cn_peer_nonce
(
1
)
{
}
...
...
@@ -54,8 +54,8 @@ int zmq::curve_mechanism_base_t::encode (msg_t *msg_)
const
size_t
mlen
=
crypto_box_ZEROBYTES
+
1
+
msg_
->
size
();
uint8_t
message_nonce
[
crypto_box_NONCEBYTES
];
memcpy
(
message_nonce
,
encode_nonce_prefix
,
16
);
put_uint64
(
message_nonce
+
16
,
cn_nonce
);
memcpy
(
message_nonce
,
_
encode_nonce_prefix
,
16
);
put_uint64
(
message_nonce
+
16
,
_
cn_nonce
);
uint8_t
flags
=
0
;
if
(
msg_
->
flags
()
&
msg_t
::
more
)
...
...
@@ -77,7 +77,7 @@ int zmq::curve_mechanism_base_t::encode (msg_t *msg_)
std
::
vector
<
uint8_t
>
message_box
(
mlen
);
int
rc
=
crypto_box_afternm
(
&
message_box
[
0
],
&
message_plaintext
[
0
],
mlen
,
message_nonce
,
cn_precom
);
message_nonce
,
_
cn_precom
);
zmq_assert
(
rc
==
0
);
rc
=
msg_
->
close
();
...
...
@@ -93,7 +93,7 @@ int zmq::curve_mechanism_base_t::encode (msg_t *msg_)
memcpy
(
message
+
16
,
&
message_box
[
crypto_box_BOXZEROBYTES
],
mlen
-
crypto_box_BOXZEROBYTES
);
cn_nonce
++
;
_
cn_nonce
++
;
return
0
;
}
...
...
@@ -123,16 +123,16 @@ int zmq::curve_mechanism_base_t::decode (msg_t *msg_)
}
uint8_t
message_nonce
[
crypto_box_NONCEBYTES
];
memcpy
(
message_nonce
,
decode_nonce_prefix
,
16
);
memcpy
(
message_nonce
,
_
decode_nonce_prefix
,
16
);
memcpy
(
message_nonce
+
16
,
message
+
8
,
8
);
const
uint64_t
nonce
=
get_uint64
(
message
+
8
);
if
(
nonce
<=
cn_peer_nonce
)
{
if
(
nonce
<=
_
cn_peer_nonce
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE
);
errno
=
EPROTO
;
return
-
1
;
}
cn_peer_nonce
=
nonce
;
_
cn_peer_nonce
=
nonce
;
const
size_t
clen
=
crypto_box_BOXZEROBYTES
+
msg_
->
size
()
-
16
;
...
...
@@ -145,7 +145,7 @@ int zmq::curve_mechanism_base_t::decode (msg_t *msg_)
msg_
->
size
()
-
16
);
rc
=
crypto_box_open_afternm
(
&
message_plaintext
[
0
],
&
message_box
[
0
],
clen
,
message_nonce
,
cn_precom
);
message_nonce
,
_
cn_precom
);
if
(
rc
==
0
)
{
rc
=
msg_
->
close
();
zmq_assert
(
rc
==
0
);
...
...
src/curve_mechanism_base.hpp
View file @
3e394fdd
...
...
@@ -64,15 +64,16 @@ class curve_mechanism_base_t : public virtual mechanism_base_t
int
encode
(
msg_t
*
msg_
)
ZMQ_OVERRIDE
;
int
decode
(
msg_t
*
msg_
)
ZMQ_OVERRIDE
;
pr
otected
:
const
char
*
encode_nonce_prefix
;
const
char
*
decode_nonce_prefix
;
pr
ivate
:
const
char
*
_
encode_nonce_prefix
;
const
char
*
_
decode_nonce_prefix
;
uint64_t
cn_nonce
;
uint64_t
cn_peer_nonce
;
protected
:
uint64_t
_cn_nonce
;
uint64_t
_cn_peer_nonce
;
// Intermediary buffer used to speed up boxing and unboxing.
uint8_t
cn_precom
[
crypto_box_BEFORENMBYTES
];
uint8_t
_
cn_precom
[
crypto_box_BEFORENMBYTES
];
};
}
...
...
src/curve_server.cpp
View file @
3e394fdd
...
...
@@ -181,7 +181,7 @@ int zmq::curve_server_t::process_hello (msg_t *msg_)
memcpy
(
hello_nonce
,
"CurveZMQHELLO---"
,
16
);
memcpy
(
hello_nonce
+
16
,
hello
+
112
,
8
);
cn_peer_nonce
=
get_uint64
(
hello
+
112
);
_
cn_peer_nonce
=
get_uint64
(
hello
+
112
);
memset
(
hello_box
,
0
,
crypto_box_BOXZEROBYTES
);
memcpy
(
hello_box
+
crypto_box_BOXZEROBYTES
,
hello
+
120
,
80
);
...
...
@@ -345,7 +345,7 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
memcpy
(
initiate_nonce
,
"CurveZMQINITIATE"
,
16
);
memcpy
(
initiate_nonce
+
16
,
initiate
+
105
,
8
);
cn_peer_nonce
=
get_uint64
(
initiate
+
105
);
_
cn_peer_nonce
=
get_uint64
(
initiate
+
105
);
const
uint8_t
*
client_key
=
&
initiate_plaintext
[
crypto_box_ZEROBYTES
];
...
...
@@ -396,7 +396,7 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
}
// Precompute connection secret from client key
rc
=
crypto_box_beforenm
(
cn_precom
,
_cn_client
,
_cn_secret
);
rc
=
crypto_box_beforenm
(
_
cn_precom
,
_cn_client
,
_cn_secret
);
zmq_assert
(
rc
==
0
);
// Given this is a backward-incompatible change, it's behind a socket
...
...
@@ -449,13 +449,13 @@ int zmq::curve_server_t::produce_ready (msg_t *msg_)
const
size_t
mlen
=
ptr
-
&
ready_plaintext
[
0
];
memcpy
(
ready_nonce
,
"CurveZMQREADY---"
,
16
);
put_uint64
(
ready_nonce
+
16
,
cn_nonce
);
put_uint64
(
ready_nonce
+
16
,
_
cn_nonce
);
std
::
vector
<
uint8_t
>
ready_box
(
crypto_box_BOXZEROBYTES
+
16
+
metadata_length
);
int
rc
=
crypto_box_afternm
(
&
ready_box
[
0
],
&
ready_plaintext
[
0
],
mlen
,
ready_nonce
,
cn_precom
);
ready_nonce
,
_
cn_precom
);
zmq_assert
(
rc
==
0
);
rc
=
msg_
->
init_size
(
14
+
mlen
-
crypto_box_BOXZEROBYTES
);
...
...
@@ -470,7 +470,7 @@ int zmq::curve_server_t::produce_ready (msg_t *msg_)
memcpy
(
ready
+
14
,
&
ready_box
[
crypto_box_BOXZEROBYTES
],
mlen
-
crypto_box_BOXZEROBYTES
);
cn_nonce
++
;
_
cn_nonce
++
;
return
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