build.sh created

This commit is contained in:
2025-08-10 08:21:41 -04:00
parent 9edfa5f379
commit 4b822962bb
6 changed files with 410 additions and 245 deletions

15
otp.c
View File

@@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200809L
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <stdlib.h>
@@ -17,11 +18,11 @@
#include <openssl/buffer.h>
#include <openssl/kdf.h>
#include <openssl/hmac.h>
#include "src/version.h"
#define MAX_INPUT_SIZE 4096
#define MAX_LINE_LENGTH 1024
#define MAX_HASH_LENGTH 65
#define VERSION_STRING "OTP-CIPHER 2.0"
#define PROGRESS_UPDATE_INTERVAL (64 * 1024 * 1024) // 64MB intervals
#define PADS_DIR "pads"
#define MAX_ENTROPY_BUFFER 32768 // 32KB entropy buffer
@@ -81,8 +82,7 @@ int main(int argc, char* argv[]) {
}
int interactive_mode(void) {
printf("=== OTP Cipher Interactive Mode ===\n");
printf("Version: %s\n\n", VERSION_STRING);
printf("=== OTP Cipher %s ===\n\n", get_version());
while (1) {
show_main_menu();
@@ -364,7 +364,7 @@ int list_available_pads(void) {
hash[64] = '\0';
// Get pad file size
char full_path[MAX_HASH_LENGTH + 20];
char full_path[300]; // Increased buffer size to accommodate longer paths
snprintf(full_path, sizeof(full_path), "%s/%s", PADS_DIR, entry->d_name);
struct stat st;
if (stat(full_path, &st) == 0) {
@@ -639,7 +639,6 @@ int generate_pad_with_entropy(uint64_t size_bytes, int display_progress, int use
unsigned char urandom_buffer[64 * 1024]; // 64KB buffer
unsigned char output_buffer[64 * 1024];
uint64_t bytes_written = 0;
time_t start_time = time(NULL);
if (display_progress) {
printf("Generating pad...\n");
@@ -803,7 +802,6 @@ int encrypt_text(const char* pad_identifier) {
return 1;
}
char pad_filename[MAX_HASH_LENGTH + 10];
char input_text[MAX_INPUT_SIZE];
char hash_hex[MAX_HASH_LENGTH];
uint64_t current_offset;
@@ -913,7 +911,7 @@ int encrypt_text(const char* pad_identifier) {
// Output in ASCII armor format
printf("\n-----BEGIN OTP MESSAGE-----\n");
printf("Version: %s\n", VERSION_STRING);
printf("Version: %s\n", get_version());
printf("Pad-Hash: %s\n", hash_hex);
printf("Pad-Offset: %lu\n", current_offset);
printf("\n");
@@ -1334,7 +1332,8 @@ unsigned char* base64_decode(const char* input, int* output_length) {
}
void print_usage(const char* program_name) {
printf("OTP Cipher - One Time Pad Implementation v2.0\n");
printf("OTP Cipher - One Time Pad Implementation %s\n", get_version());
printf("%s\n", get_build_info());
printf("Usage:\n");
printf(" %s - Interactive mode\n", program_name);
printf(" %s generate <size> - Generate new pad\n", program_name);