| 774 | |
| 775 | |
| 776 | void saveprivkey(const char *filename, uchar *privkey, uchar *pubkey, uchar salt[16], uint privpwdcfg) { |
| 777 | char hextemp[65]; |
| 778 | char *oldfile = loadfile(filename, NULL), *b; |
| 779 | stream *f = openfile(filename, "wb"); |
| 780 | if(f) |
| 781 | { |
| 782 | if(oldfile) |
| 783 | { |
| 784 | for(char *l = strtok_r(oldfile, "\n\r", &b); l; l = strtok_r(NULL, "\n\r", &b)) |
| 785 | { |
| 786 | if(*l && l[0] != '/') |
| 787 | f->printf("// %s\n", l); |
| 788 | if(*l && l[0] == '/') |
| 789 | f->printf("%s\n", l); |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | f->printf("\nauthsetup priv %s", bin2hex(hextemp, privkey, 32)); |
| 794 | if(privpwdcfg) f->printf(" %s %u", bin2hex(hextemp, salt, 16), privpwdcfg); |
| 795 | f->printf("\nauthsetup pub %s\n\n", bin2hex(hextemp, pubkey, 32)); |
| 796 | delete f; |
| 797 | } |
| 798 | DELETEA(oldfile); |
| 799 | } |
| 800 | |
| 801 | void authsetup(char **args, int numargs) // set up private and public keys |
| 802 | { |