17#define WHO "curvedns-keygen"
30 if (chdir(
"env") == -1)
31 logmsg(
WHO,111,FATAL,
"unable to switch to: ./env");
33 if (stat(
"CURVEDNS_PRIVATE_KEY",&st) == 0)
34 logmsg(
WHO,100,ERROR,
"A private key file already exists; remove that first.");
37 logmsg(
WHO,100,FATAL,
"unable to ensure randomness");
41 logmsg(
WHO,100,FATAL,
"unable to generate public/private key pair");
44 byte_copy(dnsname,3,
"uz5");
46 logmsg(
WHO,100,INFO,
"base32_encode of public key failed");
50 logmsg(
WHO,100,ERROR,
"hex_encode of public key failed");
54 logmsg(
WHO,100,ERROR,
"hex_encode of private key failed");
57 hexprivate[64] =
'\0';
60 start(
"CURVEDNS_PRIVATE_KEY");
73 logmsg(
WHO,INFO,0,B(
"DNS public key: ",dnsname));
74 logmsg(
WHO,INFO,0,B(
"Hex public key: ",hexpublic));
75 logmsg(
WHO,INFO,0,B(
"Hex secret key: ",hexprivate));
unsigned int base32_serverkey(uint8 *out, const char *in, unsigned int len)
#define crypto_box_keypair
int crypto_random_init(void)
void start(const char *s)
void out(const char *s, unsigned int len)
int hex_encode(const uint8 *src, int srclen, char *dst, int dstlen)