summaryrefslogtreecommitdiffstats
path: root/old_code/keygen.c
diff options
context:
space:
mode:
Diffstat (limited to 'old_code/keygen.c')
-rw-r--r--old_code/keygen.c60
1 files changed, 0 insertions, 60 deletions
diff --git a/old_code/keygen.c b/old_code/keygen.c
deleted file mode 100644
index b03b89c..0000000
--- a/old_code/keygen.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include<stdio.h>
-#include<openssl/rand.h>
-#include<unistd.h>
-
-int main(int argc, char* argv[]) {
-
- int opt;
- int nbytes = 256;
- char* defname = "default.key";
- char* output;
- int defout = 0;
- int defbyte = 0;
- int noopts = 0;
- while ((opt = getopt(argc, argv, "b:o:")) != -1) {
- switch (opt) {
- case 'b':
- nbytes = atoi(optarg);
- defbyte = 1;
- break;
- case 'o':
- output = argv[(optind-1)];
- defout = 1;
- break;
- default:
- fprintf(stderr, "Usage: %s [-b nbytes] [-o output] \n", argv[0]);
- exit(EXIT_FAILURE);
- }
- if (noopts == 0) {
- noopts = 1;
- }
- }
-
- if(noopts == 0) {
- printf("WARNING no option specified usign default values... \n");
- }
- if (nbytes < 0) {
- printf("Negative byte value inserted! \n");
- printf("Exiting... \n");
- exit(EXIT_FAILURE);
- } else if (nbytes != 0) {
- if (defbyte == 0) {
- printf("No byte number specified... using default value: 256 \n");
- }
- unsigned char key[nbytes];
- RAND_bytes(key, nbytes);
- if (defout == 0) {
- output = defname;
- printf("No output name specified... using default value: default.key \n");
- }
- FILE* file = fopen(output, "w");
- fwrite(key, nbytes, 1, file);
- fclose(file);
- printf("Created key file %s of %d bytes \n", output, nbytes);
- } else {
- printf("Byte number specified is 0. \n");
- printf("Doing nothing! \n");
- }
-
- exit(EXIT_SUCCESS);
-}