|
|
@ -394,6 +394,15 @@ static int pubkey_decode(const char *key_str, unsigned char key[32]) {
|
|
|
|
return base64_decode(key_str, 44, key, 32);
|
|
|
|
return base64_decode(key_str, 44, key, 32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int seckey_decode(const char *key_str, unsigned char key[64]) {
|
|
|
|
|
|
|
|
if (!key_str) { errno = EPROTO; return -1; }
|
|
|
|
|
|
|
|
if (!*key_str) { errno = EPROTO; return -1; }
|
|
|
|
|
|
|
|
if (*key_str == '@') key_str++;
|
|
|
|
|
|
|
|
size_t len = strlen(key_str);
|
|
|
|
|
|
|
|
if (len > 8 && memcmp(key_str + len - 8, ".ed25519", 8) == 0) len -= 8;
|
|
|
|
|
|
|
|
return base64_decode(key_str, len, key, 64);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static jsmntok_t *json_lookup(const char *buf, jsmntok_t *tok, const char *prop, size_t prop_len) {
|
|
|
|
static jsmntok_t *json_lookup(const char *buf, jsmntok_t *tok, const char *prop, size_t prop_len) {
|
|
|
|
jsmntok_t *end = tok + tok->size + 1;
|
|
|
|
jsmntok_t *end = tok + tok->size + 1;
|
|
|
|
if (tok->type != JSMN_OBJECT) { errno = EPROTO; return NULL; }
|
|
|
|
if (tok->type != JSMN_OBJECT) { errno = EPROTO; return NULL; }
|
|
|
@ -1134,7 +1143,14 @@ int main(int argc, char *argv[]) {
|
|
|
|
if (rc < 0) errx(0, "unable to convert method name");
|
|
|
|
if (rc < 0) errx(0, "unable to convert method name");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (keypair_seed_str) {
|
|
|
|
if (keypair_seed_str == NULL) {
|
|
|
|
|
|
|
|
read_private_key(app_dir, private_key);
|
|
|
|
|
|
|
|
memcpy(public_key, private_key+32, 32);
|
|
|
|
|
|
|
|
} else if (strlen(keypair_seed_str) > 55) {
|
|
|
|
|
|
|
|
rc = seckey_decode(keypair_seed_str, private_key);
|
|
|
|
|
|
|
|
if (rc < 0) err(1, "unable to decode private key");
|
|
|
|
|
|
|
|
memcpy(public_key, private_key+32, 32);
|
|
|
|
|
|
|
|
} else if (keypair_seed_str) {
|
|
|
|
unsigned char seed[crypto_sign_SEEDBYTES];
|
|
|
|
unsigned char seed[crypto_sign_SEEDBYTES];
|
|
|
|
unsigned char ed25519_skpk[crypto_sign_ed25519_SECRETKEYBYTES];
|
|
|
|
unsigned char ed25519_skpk[crypto_sign_ed25519_SECRETKEYBYTES];
|
|
|
|
|
|
|
|
|
|
|
@ -1144,9 +1160,6 @@ int main(int argc, char *argv[]) {
|
|
|
|
if (rc < 0) err(1, "unable to convert private key to seed");
|
|
|
|
if (rc < 0) err(1, "unable to convert private key to seed");
|
|
|
|
rc = crypto_sign_seed_keypair(public_key, private_key, seed);
|
|
|
|
rc = crypto_sign_seed_keypair(public_key, private_key, seed);
|
|
|
|
if (rc < 0) err(1, "unable to generate keypair from seed");
|
|
|
|
if (rc < 0) err(1, "unable to generate keypair from seed");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
read_private_key(app_dir, private_key);
|
|
|
|
|
|
|
|
memcpy(public_key, private_key+32, 32);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (key) {
|
|
|
|
if (key) {
|
|
|
|