CryptoDit/main.c
2026-01-31 16:45:53 +01:00

64 lines
1.7 KiB
C

#include <stdio.h>
#include <string.h>
#include "argparse.h"
#include "certificate.h"
#include "speed.h"
#include "entropy.h"
#define BUF_MODULE_SIZE 64
static void usage(const char *);
int main(int argc, char *argv[]){
int res = -1;
char modules[BUF_MODULE_SIZE];
memset(modules, 0, BUF_MODULE_SIZE);
res = check_arguments(argv, argc, modules, BUF_MODULE_SIZE);
if (res == -1){
usage(argv[0]);
return -1;
}
printf("Module: %s\n", modules);
if (strncmp(modules, "speed", BUF_MODULE_SIZE) == 0){
res = speed(argv, argc);
if (res == -1){
usage(argv[0]);
return -1;
}
}
if (strncmp(modules, "certificate", BUF_MODULE_SIZE) == 0){
res = certificate(argv, argc);
if (res == -1){
usage(argv[0]);
return -1;
}
}
if (strncmp(modules, "entropy", BUF_MODULE_SIZE) == 0){
res = entropy(argv, argc);
if (res == -1){
usage(argv[0]);
return -1;
}
}
return 0;
}
static void usage(const char *script){
printf("Usage %s -m <modules>\n", script);
printf("Modules:\n");
printf("\tcertificate: Check if the certificate is compliant with FIP 140-3 and check the certificate security file\n");
printf("\tspeed: Check the time for creating the certificate\n");
printf("\tentropy: Check the entropy in the kernel\n\n");
printf("Certificate Modules:\n");
printf("\t-type <rsa,x509>\n");
printf("\t-pubin <public certificate>\n");
printf("\t-privin <private certificate>\n");
printf("\t-text: print in text the certificate\n\n");
printf("Speed Modules:\n");
printf("\t-type <rsa, elliptic, all>\n");
}