| 1298 | } |
| 1299 | |
| 1300 | char *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 |
no test coverage detected