| 25 | #include "TcWrapper.h" |
| 26 | |
| 27 | int main(int ac, char** av) |
| 28 | { |
| 29 | try |
| 30 | { |
| 31 | int len = ac > 1 ? atoi(av[1]) : 2048; |
| 32 | |
| 33 | PseudoRandom pseudoRand; |
| 34 | pseudoRand.init(NULL); |
| 35 | |
| 36 | rsa_key key; |
| 37 | check(NULL, rsa_make_key(&pseudoRand.state, pseudoRand.index, len / 8, 65537, &key), |
| 38 | "Error making RSA key"); |
| 39 | |
| 40 | unsigned char outbuf[4096]; |
| 41 | unsigned long outlen = sizeof outbuf; |
| 42 | check(NULL, rsa_export(outbuf, &outlen, PK_PRIVATE, &key), |
| 43 | "Error exporting private RSA key"); |
| 44 | |
| 45 | const char* const file = "fbSampleExtAuth.conf"; |
| 46 | FILE* conf = fopen(file, "w"); |
| 47 | if (!conf) |
| 48 | { |
| 49 | perror(file); |
| 50 | return 1; |
| 51 | } |
| 52 | |
| 53 | fprintf(conf, "Key = "); |
| 54 | for (unsigned i = 0; i < outlen; ++i) |
| 55 | fprintf(conf, "%02x", outbuf[i]); |
| 56 | fprintf(conf, "\n#IgnoreLogin = No\n#IgnorePassword = No\n"); |
| 57 | |
| 58 | if (fclose(conf) != 0) |
| 59 | { |
| 60 | perror(file); |
| 61 | return 1; |
| 62 | } |
| 63 | printf("Wrote configuration file %s\n", file); |
| 64 | } |
| 65 | catch (const char* message) |
| 66 | { |
| 67 | fprintf(stderr, "%s\n", message); |
| 68 | return 1; |
| 69 | } |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 |
nothing calls this directly
no test coverage detected