curve_keygen.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #include <stdlib.h>
4 #include <assert.h>
5 #include <zmq.h>
6 
7 int main (void)
8 {
9  puts ("This tool generates a CurveZMQ keypair, as two printable strings "
10  "you can");
11  puts ("use in configuration files or source code. The encoding uses Z85, "
12  "which");
13  puts (
14  "is a base-85 format that is described in 0MQ RFC 32, and which has an");
15  puts ("implementation in the z85_codec.h source used by this tool. The "
16  "keypair");
17  puts (
18  "always works with the secret key held by one party and the public key");
19  puts ("distributed (securely!) to peers wishing to connect to it.");
20 
21  char public_key[41];
22  char secret_key[41];
23  if (zmq_curve_keypair (public_key, secret_key)) {
24  if (zmq_errno () == ENOTSUP)
25  puts ("To use curve_keygen, please install libsodium and then "
26  "rebuild libzmq.");
27  exit (1);
28  }
29 
30  puts ("\n== CURVE PUBLIC KEY ==");
31  puts (public_key);
32 
33  puts ("\n== CURVE SECRET KEY ==");
34  puts (secret_key);
35 
36  exit (0);
37 }
ENOTSUP
#define ENOTSUP
Definition: zmq.h:104
zmq_errno
ZMQ_EXPORT int zmq_errno(void)
Definition: zmq.cpp:101
zmq.h
zmq_curve_keypair
ZMQ_EXPORT int zmq_curve_keypair(char *z85_public_key_, char *z85_secret_key_)
Definition: zmq_utils.cpp:190
main
int main(void)
Definition: curve_keygen.cpp:7
assert.h


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:49