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

Function savepreprivkey

source/src/crypto.cpp:744–773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742}
743
744void savepreprivkey(const char *filename, uchar *preprivkey, uchar preprivlen, uchar *psalt, uint preprivpwdcfg) {
745 char hextemp[128 * 2 + 1];
746 char *oldfile = loadfile(filename, NULL), *b;
747 stream *f = openfile(filename, "wb");
748 if(f)
749 {
750 if(!oldfile)
751 {
752 f->printf("\n" "// remove this file from your computer immediately!\n"
753 "// either print it out and delete it or move it to a thumbdrive.\n"
754 "// YOU DO NOT NEED THIS FILE TO PLAY AC!\n" "\n");
755 }
756 else
757 {
758 for(char *l = strtok_r(oldfile, "\n\r", &b); l; l = strtok_r(NULL, "\n\r", &b))
759 {
760 if(*l && l[0] != '/')
761 f->printf("// %s\n", l);
762 if(*l && l[0] == '/')
763 f->printf("%s\n", l);
764 }
765 }
766
767 f->printf("authsetup pre %s", bin2hex(hextemp, preprivkey, preprivlen));
768 if(preprivpwdcfg) f->printf(" %s %u", bin2hex(hextemp, psalt, 16), preprivpwdcfg & ~1);
769 f->printf("\n\n");
770 delete f;
771 }
772 DELETEA(oldfile);
773}
774
775
776void saveprivkey(const char *filename, uchar *privkey, uchar *pubkey, uchar salt[16], uint privpwdcfg) {

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