MCPcopy Create free account
hub / github.com/assaultcube/AC / saveprivkey

Function saveprivkey

source/src/crypto.cpp:776–799  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

774
775
776void 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
801void authsetup(char **args, int numargs) // set up private and public keys
802{

Callers 1

authsetupFunction · 0.85

Calls 5

loadfileFunction · 0.85
openfileFunction · 0.85
strtok_rFunction · 0.85
bin2hexFunction · 0.85
printfMethod · 0.45

Tested by

no test coverage detected