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
87254abc
Commit
87254abc
authored
Sep 29, 2013
by
MinRK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use zmq_curve_keypair in curve_keygen
parent
d1a927a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
22 deletions
+12
-22
curve_keygen.c
tools/curve_keygen.c
+12
-22
No files found.
tools/curve_keygen.c
View file @
87254abc
...
...
@@ -26,19 +26,11 @@
#include <assert.h>
#include <platform.hpp>
#include <zmq.h>
#include <zmq_utils.h>
#ifdef HAVE_LIBSODIUM
# include <sodium.h>
#endif
int
main
(
void
)
{
#ifdef HAVE_LIBSODIUM
# if crypto_box_PUBLICKEYBYTES != 32 \
|| crypto_box_SECRETKEYBYTES != 32
# error "libsodium not built correctly"
# endif
puts
(
"This tool generates a CurveZMQ keypair, as two printable strings you can"
);
puts
(
"use in configuration files or source code. The encoding uses Z85, which"
);
puts
(
"is a base-85 format that is described in 0MQ RFC 32, and which has an"
);
...
...
@@ -46,23 +38,21 @@ int main (void)
puts
(
"always works with the secret key held by one party and the public key"
);
puts
(
"distributed (securely!) to peers wishing to connect to it."
);
uint8_t
public_key
[
32
];
uint8_t
secret_key
[
32
];
char
public_key
[
41
];
char
secret_key
[
41
];
int
rc
=
zmq_curve_keypair
(
public_key
,
secret_key
);
if
(
rc
!=
0
)
{
if
(
zmq_errno
()
==
ENOTSUP
)
{
puts
(
"To use curve_keygen, please install libsodium and then rebuild libzmq."
);
}
exit
(
1
);
}
int
rc
=
crypto_box_keypair
(
public_key
,
secret_key
);
assert
(
rc
==
0
);
char
encoded
[
41
];
zmq_z85_encode
(
encoded
,
public_key
,
32
);
puts
(
"
\n
== CURVE PUBLIC KEY =="
);
puts
(
encoded
);
puts
(
public_key
);
zmq_z85_encode
(
encoded
,
secret_key
,
32
);
puts
(
"
\n
== CURVE SECRET KEY =="
);
puts
(
encoded
);
puts
(
secret_key
);
#else
puts
(
"To build curve_keygen, please install libsodium and then rebuild libzmq."
);
#endif
exit
(
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