17#define WHO "curvedns-keygen"
20int rename(
const char *,
const char *);
36 if (stat(
"CURVEDNS_PRIVATE_KEY",&st) == 0) {
37 logmsg(
WHO,0,WARN,
"A private key file already exists; will be renamed as '.{old}'");
38 if (
rename(
"CURVEDNS_PRIVATE_KEY",
"CURVEDNS_PRIVATE_KEY.{old}") == -1)
39 logmsg(
WHO,111,FATAL,
"unable to move CURVEDNS_PRIVATE_KEY to CURVEDNS_PRIVATE_KEY.{old}");
43 logmsg(
WHO,100,FATAL,
"unable to ensure randomness");
47 logmsg(
WHO,100,FATAL,
"unable to generate public/private key pair");
50 byte_copy(dnsname,3,
"uz5");
52 logmsg(
WHO,100,INFO,
"base32_encode of public key failed");
56 logmsg(
WHO,100,ERROR,
"hex_encode of public key failed");
60 logmsg(
WHO,100,ERROR,
"hex_encode of private key failed");
63 hexprivate[64] =
'\0';
66 start(
"CURVEDNS_PRIVATE_KEY");
67 out((
char *)
private,32);
79 logmsg(
WHO,0,INFO,B(
"DNS public key: ",dnsname));
80 logmsg(
WHO,0,INFO,B(
"Hex public key: ",hexpublic));
81 logmsg(
WHO,0,INFO,B(
"Hex secret key: ",hexprivate));
unsigned int base32_serverkey(uint8 *out, const char *in, unsigned int len)
#define crypto_box_keypair
int rename(const char *, const char *)
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)