#include #include #include #include #include "include/otp.h" int main(int argc, char* argv[]) { (void)argc; (void)argv; // Suppress unused parameter warnings hardware_rng_device_t device; snprintf(device.port_path, sizeof(device.port_path), "/dev/ttyUSB0"); device.device_type = TRUERNG_ORIGINAL; snprintf(device.friendly_name, sizeof(device.friendly_name), "TrueRNG"); device.is_working = 1; printf("Debug: Device type set to: %d (TRUERNG_ORIGINAL should be %d)\n", device.device_type, TRUERNG_ORIGINAL); printf("Debug: Comparison result: device.device_type == SWIFTRNG is %s\n", (device.device_type == SWIFTRNG) ? "TRUE" : "FALSE"); // Test with small buffer (1KB) and short timeout const size_t test_bytes = 1024; unsigned char* test_buffer = malloc(test_bytes); if (!test_buffer) { printf("ERROR: Cannot allocate test buffer\n"); return 1; } size_t collected = 0; time_t start_time = time(NULL); printf("Testing TrueRNG device at %s...\n", device.port_path); // Test device connectivity with timeout int result = collect_truerng_entropy_from_device(&device, test_buffer, test_bytes, &collected, 1); time_t end_time = time(NULL); double test_duration = difftime(end_time, start_time); if (result == 0 && collected > 0) { double speed_kbps = (collected / 1024.0) / (test_duration > 0 ? test_duration : 1.0); printf("SUCCESS: Collected %zu bytes in %.2f seconds (%.2f KB/s)\n", collected, test_duration, speed_kbps); // Show first few bytes as hex printf("First 16 bytes: "); for (int i = 0; i < 16 && i < (int)collected; i++) { printf("%02x ", test_buffer[i]); } printf("\n"); } else { printf("FAILED: Error code %d, collected %zu bytes in %.2f seconds\n", result, collected, test_duration); } free(test_buffer); return result; }