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
2cdfa1ff
Commit
2cdfa1ff
authored
May 08, 2014
by
Frank
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initialize libsodium and tweetnacl
parent
ba22eff6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
3 deletions
+26
-3
curve_client.cpp
src/curve_client.cpp
+12
-2
curve_client.hpp
src/curve_client.hpp
+2
-0
curve_server.cpp
src/curve_server.cpp
+11
-1
curve_server.hpp
src/curve_server.hpp
+1
-0
No files found.
src/curve_client.cpp
View file @
2cdfa1ff
...
...
@@ -33,11 +33,21 @@
zmq
::
curve_client_t
::
curve_client_t
(
const
options_t
&
options_
)
:
mechanism_t
(
options_
),
state
(
send_hello
)
state
(
send_hello
),
sync
()
{
memcpy
(
public_key
,
options_
.
curve_public_key
,
crypto_box_PUBLICKEYBYTES
);
memcpy
(
secret_key
,
options_
.
curve_secret_key
,
crypto_box_SECRETKEYBYTES
);
memcpy
(
server_key
,
options_
.
curve_server_key
,
crypto_box_PUBLICKEYBYTES
);
scoped_lock_t
lock
(
sync
);
#if defined(HAVE_TWEETNACL)
// allow opening of /dev/urandom
unsigned
char
tmpbytes
[
4
];
randombytes
(
tmpbytes
,
4
);
#else
const
int
si
=
sodium_init
();
zmq_assert
(
is
==
0
);
#endif
// Generate short-term key pair
const
int
rc
=
crypto_box_keypair
(
cn_public
,
cn_secret
);
...
...
@@ -318,7 +328,7 @@ int zmq::curve_client_t::produce_initiate (msg_t *msg_)
// Create Box [C + vouch + metadata](C'->S')
memset
(
initiate_plaintext
,
0
,
crypto_box_ZEROBYTES
);
memcpy
(
initiate_plaintext
+
crypto_box_ZEROBYTES
,
memcpy
(
initiate_plaintext
+
crypto_box_ZEROBYTES
,
public_key
,
32
);
memcpy
(
initiate_plaintext
+
crypto_box_ZEROBYTES
+
32
,
vouch_nonce
+
8
,
16
);
...
...
src/curve_client.hpp
View file @
2cdfa1ff
...
...
@@ -21,6 +21,7 @@
#define __ZMQ_CURVE_CLIENT_HPP_INCLUDED__
#include "platform.hpp"
#include "mutex.hpp"
#ifdef HAVE_LIBSODIUM
#ifdef HAVE_TWEETNACL
...
...
@@ -105,6 +106,7 @@ namespace zmq
int
process_welcome
(
msg_t
*
msg_
);
int
produce_initiate
(
msg_t
*
msg_
);
int
process_ready
(
msg_t
*
msg_
);
mutex_t
sync
;
};
}
...
...
src/curve_server.cpp
View file @
2cdfa1ff
...
...
@@ -39,10 +39,20 @@ zmq::curve_server_t::curve_server_t (session_base_t *session_,
peer_address
(
peer_address_
),
state
(
expect_hello
),
expecting_zap_reply
(
false
),
cn_nonce
(
1
)
cn_nonce
(
1
),
sync
()
{
// Fetch our secret key from socket options
memcpy
(
secret_key
,
options_
.
curve_secret_key
,
crypto_box_SECRETKEYBYTES
);
scoped_lock_t
lock
(
sync
);
#if defined(HAVE_TWEETNACL)
// allow opening of /dev/urandom
unsigned
char
tmpbytes
[
4
];
randombytes
(
tmpbytes
,
4
);
#else
const
int
si
=
sodium_init
();
zmq_assert
(
is
==
0
);
#endif
// Generate short-term key pair
const
int
rc
=
crypto_box_keypair
(
cn_public
,
cn_secret
);
...
...
src/curve_server.hpp
View file @
2cdfa1ff
...
...
@@ -115,6 +115,7 @@ namespace zmq
void
send_zap_request
(
const
uint8_t
*
key
);
int
receive_and_process_zap_reply
();
mutex_t
sync
;
};
}
...
...
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