MCPcopy Index your code
hub / github.com/assaultcube/AC / sign

Method sign

source/src/crypto.cpp:1300–1316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1298}
1299
1300char *makecert::sign(const uchar *keypair, const char *com)
1301{
1302 char hextemp[129];
1303 vector<char> msg;
1304 cvecprintf(msg, "signed-by: %s%s%s\n", bin2hex(hextemp, keypair + 32, 32), com && *com ? " // " : "", com ? com : "");
1305 loopv(c->lines) cvecprintf(msg, "%s: %s%s%s\n", c->lines[i].key, c->lines[i].val, c->lines[i].comment[0] ? " // " : "", c->lines[i].comment);
1306 cvecprintf(msg, "signed-date: %d // %s\n", (c->signeddate = aktcerttime()), timestring("%c"));
1307 int len = msg.length();
1308 loopi(64) msg.add(0); // make room for the signature
1309 uchar *msgbuf = (uchar*)msg.getbuf();
1310 ed25519_sign(msgbuf, NULL, msgbuf, len, keypair);
1311 char *signedmsg = new char[certheaderlenfull + len + 1];
1312 sprintf(signedmsg, "%s%s\n", certheader, bin2hex(hextemp, msgbuf, 64)); // header line
1313 memcpy(signedmsg + certheaderlenfull, msgbuf + 64, len); // body
1314 signedmsg[certheaderlenfull + len] = '\0';
1315 return signedmsg;
1316}
1317
1318#ifndef STANDALONE
1319

Callers 1

crypto.cppFile · 0.80

Calls 10

cvecprintfFunction · 0.85
bin2hexFunction · 0.85
aktcerttimeFunction · 0.85
ed25519_signFunction · 0.85
loopvFunction · 0.70
timestringFunction · 0.70
loopiFunction · 0.70
lengthMethod · 0.45
addMethod · 0.45
getbufMethod · 0.45

Tested by

no test coverage detected