diff --git a/tools/sxtkeygen.c b/tools/sxtkeygen.c index b5cb37e..a573d92 100644 --- a/tools/sxtkeygen.c +++ b/tools/sxtkeygen.c @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -166,10 +167,10 @@ int main(int argc, char **argv) } /* check type */ - if(keytype) type = sxt_key_type_fname(keytype); + if(keytype) type = sxtkey_type_fname(keytype); else type = PPKP_ED25519; - keytype = (char *)sxt_key_name(type); + keytype = (char *)sxtkey_name(type); if(!type) { fprintf(stderr, "Illegal keytype.\nAborting.\n"); @@ -228,64 +229,64 @@ int main(int argc, char **argv) } /* generate a key first */ - if(!(pair = sxt_key_alloc())) { + if(!(pair = sxtkey_alloc())) { fprintf(stderr, "Not enough memory to allocate a key.\nAborting.\n"); abort(); } fprintf(stdout, "Generating key pair ..."); - if((r = sxt_key_generate(pair, type, 0)) != SXT_SUCCESS) { + if((r = sxtkey_generate(pair, type, 0)) != SXT_SUCCESS) { fprintf(stderr, "FAIL.\nError (%d).\nAborting.\n", r); - sxt_key_free(pair); + sxtkey_free(pair); abort(); } else fprintf(stdout, "DONE.\n"); /* hash */ - if(hash) sxt_key_assign_hash(pair, hash); + if(hash) sxtkey_assign_hash(pair, hash); /* duplicate private */ - if((r = sxt_key_dup_private(pair, &privkey)) != SXT_SUCCESS) { + if((r = sxtkey_dup_private(pair, &privkey)) != SXT_SUCCESS) { fprintf(stderr, "Unable to duplicate private key(%d).\nAborting.\n", r); - sxt_key_free(pair); + sxtkey_free(pair); abort(); } /* get public duplicate */ - if((r = sxt_key_dup_public(pair, &pubkey)) != SXT_SUCCESS) { + if((r = sxtkey_dup_public(pair, &pubkey)) != SXT_SUCCESS) { fprintf(stderr, "Unable to duplicate public key(%d).\nAborting.\n", r); - sxt_key_free(pair); - sxt_key_free(privkey); + sxtkey_free(pair); + sxtkey_free(privkey); abort(); } /* ok, output private key first */ snprintf(fullpath, MAX_PATHNAME, "%s/%s", dir, privname); if(!encrypt) { /* will not encrypt */ - r = sxt_key_export_priv_file(privkey, fullpath, NULL, NULL, NULL); + r = sxtkey_export_priv_file(privkey, fullpath, NULL, NULL, NULL); } else { - r = sxt_key_export_priv_file(privkey, fullpath, NULL, __passkey_promt, - (void *)"Enter passkey phrase:"); + r = sxtkey_export_priv_file(privkey, fullpath, NULL, __passkey_promt, + (void *)"Enter passkey phrase:"); } if(r != SXT_SUCCESS) { __failed_export: fprintf(stderr, "Unable to perform key export (%d).\nAborting.\n", r); - sxt_key_burn(pair); - sxt_key_burn(privkey); - sxt_key_free(pair); - sxt_key_free(privkey); + sxtkey_burn(pair); + sxtkey_burn(privkey); + sxtkey_free(pair); + sxtkey_free(privkey); abort(); } /* ok, output public key */ snprintf(fullpath, MAX_PATHNAME, "%s/%s", dir, pubname); - r = sxt_key_export_public_file(pubkey, fullpath); + r = sxtkey_export_public_file(pubkey, fullpath); if(r != SXT_SUCCESS) goto __failed_export; - sxt_key_burn(pair); - sxt_key_burn(privkey); - sxt_key_burn(pubkey); - sxt_key_free(pair); - sxt_key_free(privkey); - sxt_key_free(pubkey); + sxtkey_burn(pair); + sxtkey_burn(privkey); + sxtkey_burn(pubkey); + sxtkey_free(pair); + sxtkey_free(privkey); + sxtkey_free(pubkey); return 0; }