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
f06bf8d2
Commit
f06bf8d2
authored
Sep 25, 2013
by
Richard Newton
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/zeromq/libzmq
parents
9db0791c
b0b2567f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
27 deletions
+86
-27
.gitignore
.gitignore
+2
-0
configure.ac
configure.ac
+41
-1
zmq.h
include/zmq.h
+3
-0
zmq_utils.h
include/zmq_utils.h
+14
-1
curve_client.cpp
src/curve_client.cpp
+14
-11
curve_server.cpp
src/curve_server.cpp
+12
-14
No files found.
.gitignore
View file @
f06bf8d2
...
...
@@ -68,6 +68,8 @@ tests/test_inproc_connect
tests/test_linger
tests/test_security_null
tests/test_security_plain
tests/test*.log
tests/test*.trs
src/platform.hpp*
src/stamp-h1
perf/local_lat
...
...
configure.ac
View file @
f06bf8d2
...
...
@@ -29,9 +29,10 @@ AC_SUBST(PACKAGE_VERSION)
# ZeroMQ versions 2.1.x: 1:0:0 (ABI version 1)
# ZeroMQ version 3.0: 2:0:0 (ABI version 2)
# ZeroMQ version 3.1: 3:0:0 (ABI version 3)
# ZeroMQ version 4.0: 4:0:1 (ABI version 4)
#
# libzmq -version-info current:revision:age
LTVER="
3:0:0
"
LTVER="
4:0:1
"
AC_SUBST(LTVER)
# Take a copy of original flags
...
...
@@ -62,6 +63,45 @@ LIBZMQ_CHECK_ENABLE_DEBUG
# Check wheter to enable code coverage
LIBZMQ_WITH_GCOV
# Allow libsodium to be installed in a custom path:
AC_ARG_WITH([libsodium],
[AS_HELP_STRING([--with-libsodium],
[Specify libsodium prefix])],
[zmq_search_libsodium="yes"],
[])
if test "x$zmq_search_libsodium" = "xyes"; then
if test -r "${with_libsodium}/include/sodium.h"; then
CXXFLAGS="-I${with_libsodium}/include ${CXXFLAGS}"
LDFLAGS="-L${with_libsodium}/lib ${LDFLAGS}"
fi
fi
AC_ARG_WITH([libsodium-include-dir],
[AS_HELP_STRING([--with-libsodium-include-dir],
[Specify libsodium include prefix])],
[zmq_search_libsodium_include="yes"],
[])
if test "x$zmq_search_libsodium_include" = "xyes"; then
if test -r "${with_libsodium_include_dir}/sodium.h"; then
CXXFLAGS="-I${with_libsodium_include_dir}/include ${CXXFLAGS}"
fi
fi
AC_ARG_WITH([libsodium_lib_dir],
[AS_HELP_STRING([--with-libsodium-lib-dir],
[Specify libsodium library prefix])],
[zmq_search_libsodium_lib="yes"],
[])
if test "x$zmq_search_libsodium_lib" = "xyes"; then
if test -r "${with_libsodium_lib_dir}/libsodium.{a|so|dylib}"; then
LDFLAGS="-L${with_libsodium}/lib ${LDFLAGS}"
fi
fi
# Checks for libraries
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([rt], [clock_gettime])
...
...
include/zmq.h
View file @
f06bf8d2
...
...
@@ -62,6 +62,9 @@ typedef __int32 int32_t;
# ifndef uint16_t
typedef
unsigned
__int16
uint16_t
;
# endif
# ifndef uint8_t
typedef
unsigned
__int8
uint8_t
;
# endif
#else
# include <stdint.h>
#endif
...
...
include/zmq_utils.h
View file @
f06bf8d2
...
...
@@ -22,9 +22,22 @@
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
/* Define integer types needed for event interface */
#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS
# include <inttypes.h>
#elif defined _MSC_VER && _MSC_VER < 1600
# ifndef int32_t
typedef
__int32
int32_t
;
# endif
# ifndef uint16_t
typedef
unsigned
__int16
uint16_t
;
# endif
#else
# include <stdint.h>
#endif
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
src/curve_client.cpp
View file @
f06bf8d2
...
...
@@ -297,34 +297,38 @@ int zmq::curve_client_t::process_welcome (msg_t *msg_)
int
zmq
::
curve_client_t
::
produce_initiate
(
msg_t
*
msg_
)
{
uint8_t
vouch_nonce
[
crypto_box_NONCEBYTES
];
uint8_t
vouch_plaintext
[
crypto_box_ZEROBYTES
+
32
];
uint8_t
vouch_box
[
crypto_box_BOXZEROBYTES
+
48
];
uint8_t
vouch_plaintext
[
crypto_box_ZEROBYTES
+
64
];
uint8_t
vouch_box
[
crypto_box_BOXZEROBYTES
+
80
];
// Create vouch = Box [C'
](C->S
)
// Create vouch = Box [C'
,S](C->S'
)
memset
(
vouch_plaintext
,
0
,
crypto_box_ZEROBYTES
);
memcpy
(
vouch_plaintext
+
crypto_box_ZEROBYTES
,
cn_public
,
32
);
memcpy
(
vouch_plaintext
+
crypto_box_ZEROBYTES
+
32
,
server_key
,
32
);
memcpy
(
vouch_nonce
,
"VOUCH---"
,
8
);
randombytes
(
vouch_nonce
+
8
,
16
);
int
rc
=
crypto_box
(
vouch_box
,
vouch_plaintext
,
sizeof
vouch_plaintext
,
vouch_nonce
,
server_key
,
secret_key
);
vouch_nonce
,
cn_server
,
secret_key
);
zmq_assert
(
rc
==
0
);
// Assume here that metadata is limited to 256 bytes
uint8_t
initiate_nonce
[
crypto_box_NONCEBYTES
];
uint8_t
initiate_plaintext
[
crypto_box_ZEROBYTES
+
96
+
256
];
uint8_t
initiate_box
[
crypto_box_BOXZEROBYTES
+
1
12
+
256
];
uint8_t
initiate_plaintext
[
crypto_box_ZEROBYTES
+
128
+
256
];
uint8_t
initiate_box
[
crypto_box_BOXZEROBYTES
+
1
44
+
256
];
// Create Box [C + vouch + metadata](C'->S')
memset
(
initiate_plaintext
,
0
,
crypto_box_ZEROBYTES
);
memcpy
(
initiate_plaintext
+
crypto_box_ZEROBYTES
,
public_key
,
32
);
memcpy
(
initiate_plaintext
+
crypto_box_ZEROBYTES
,
public_key
,
32
);
memcpy
(
initiate_plaintext
+
crypto_box_ZEROBYTES
+
32
,
vouch_nonce
+
8
,
16
);
memcpy
(
initiate_plaintext
+
crypto_box_ZEROBYTES
+
48
,
vouch_box
+
crypto_box_BOXZEROBYTES
,
48
);
vouch_box
+
crypto_box_BOXZEROBYTES
,
80
);
uint8_t
*
ptr
=
initiate_plaintext
+
crypto_box_ZEROBYTES
+
96
;
// Metadata starts after vouch
uint8_t
*
ptr
=
initiate_plaintext
+
crypto_box_ZEROBYTES
+
128
;
// Add socket type property
const
char
*
socket_type
=
socket_type_string
(
options
.
type
);
...
...
@@ -335,7 +339,7 @@ int zmq::curve_client_t::produce_initiate (msg_t *msg_)
||
options
.
type
==
ZMQ_DEALER
||
options
.
type
==
ZMQ_ROUTER
)
ptr
+=
add_property
(
ptr
,
"Identity"
,
options
.
identity
,
options
.
identity_size
);
options
.
identity
,
options
.
identity_size
);
const
size_t
mlen
=
ptr
-
initiate_plaintext
;
...
...
@@ -359,7 +363,6 @@ int zmq::curve_client_t::produce_initiate (msg_t *msg_)
// Box [C + vouch + metadata](C'->S')
memcpy
(
initiate
+
113
,
initiate_box
+
crypto_box_BOXZEROBYTES
,
mlen
-
crypto_box_BOXZEROBYTES
);
cn_nonce
++
;
return
0
;
...
...
src/curve_server.cpp
View file @
f06bf8d2
...
...
@@ -338,7 +338,7 @@ int zmq::curve_server_t::produce_welcome (msg_t *msg_)
int
zmq
::
curve_server_t
::
process_initiate
(
msg_t
*
msg_
)
{
if
(
msg_
->
size
()
<
2
25
)
{
if
(
msg_
->
size
()
<
2
57
)
{
errno
=
EPROTO
;
return
-
1
;
}
...
...
@@ -369,10 +369,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
}
// Check cookie plain text is as expected [C' + s']
if
(
memcmp
(
cookie_plaintext
+
crypto_secretbox_ZEROBYTES
,
cn_client
,
32
)
||
memcmp
(
cookie_plaintext
+
crypto_secretbox_ZEROBYTES
+
32
,
cn_secret
,
32
))
{
if
(
memcmp
(
cookie_plaintext
+
crypto_secretbox_ZEROBYTES
,
cn_client
,
32
)
||
memcmp
(
cookie_plaintext
+
crypto_secretbox_ZEROBYTES
+
32
,
cn_secret
,
32
))
{
errno
=
EAGAIN
;
return
-
1
;
}
...
...
@@ -380,8 +378,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
const
size_t
clen
=
(
msg_
->
size
()
-
113
)
+
crypto_box_BOXZEROBYTES
;
uint8_t
initiate_nonce
[
crypto_box_NONCEBYTES
];
uint8_t
initiate_plaintext
[
crypto_box_ZEROBYTES
+
96
+
256
];
uint8_t
initiate_box
[
crypto_box_BOXZEROBYTES
+
1
12
+
256
];
uint8_t
initiate_plaintext
[
crypto_box_ZEROBYTES
+
128
+
256
];
uint8_t
initiate_box
[
crypto_box_BOXZEROBYTES
+
1
44
+
256
];
// Open Box [C + vouch + metadata](C'->S')
memset
(
initiate_box
,
0
,
crypto_box_BOXZEROBYTES
);
...
...
@@ -401,13 +399,13 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
const
uint8_t
*
client_key
=
initiate_plaintext
+
crypto_box_ZEROBYTES
;
uint8_t
vouch_nonce
[
crypto_box_NONCEBYTES
];
uint8_t
vouch_plaintext
[
crypto_box_ZEROBYTES
+
32
];
uint8_t
vouch_box
[
crypto_box_BOXZEROBYTES
+
48
];
uint8_t
vouch_plaintext
[
crypto_box_ZEROBYTES
+
64
];
uint8_t
vouch_box
[
crypto_box_BOXZEROBYTES
+
80
];
// Open Box
[C'](C->S
) and check contents
// Open Box
Box [C',S](C->S'
) and check contents
memset
(
vouch_box
,
0
,
crypto_box_BOXZEROBYTES
);
memcpy
(
vouch_box
+
crypto_box_BOXZEROBYTES
,
initiate_plaintext
+
crypto_box_ZEROBYTES
+
48
,
48
);
initiate_plaintext
+
crypto_box_ZEROBYTES
+
48
,
80
);
memcpy
(
vouch_nonce
,
"VOUCH---"
,
8
);
memcpy
(
vouch_nonce
+
8
,
...
...
@@ -415,7 +413,7 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
rc
=
crypto_box_open
(
vouch_plaintext
,
vouch_box
,
sizeof
vouch_box
,
vouch_nonce
,
client_key
,
secret_key
);
vouch_nonce
,
client_key
,
cn_secret
);
if
(
rc
!=
0
)
{
errno
=
EPROTO
;
return
-
1
;
...
...
@@ -443,8 +441,8 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
}
}
return
parse_metadata
(
initiate_plaintext
+
crypto_box_ZEROBYTES
+
96
,
clen
-
crypto_box_ZEROBYTES
-
96
);
return
parse_metadata
(
initiate_plaintext
+
crypto_box_ZEROBYTES
+
128
,
clen
-
crypto_box_ZEROBYTES
-
128
);
}
int
zmq
::
curve_server_t
::
produce_ready
(
msg_t
*
msg_
)
...
...
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