This commit is contained in:
2025-10-09 10:45:04 -04:00
parent 9d91ec912a
commit 33b34bf5a5
27 changed files with 1552 additions and 106 deletions

View File

@@ -164,36 +164,23 @@ void display_entropy_progress(const entropy_collection_state_t* state);
void draw_progress_bar(double percentage, int width);
void draw_quality_bar(double quality, int width, const char* label);
// TrueRNG Device Constants (updated to match otp.c implementation)
#define TRUERNG_VID "04D8"
#define TRUERNG_PID "F5FE"
#define TRUERNGPRO_VID "16D0"
#define TRUERNGPRO_PID "0AA0"
#define TRUERNGPROV2_VID "04D8"
#define TRUERNGPROV2_PID "EBB5"
// Hardware RNG Device Constants (lowercase to match sysfs output)
#define TRUERNG_VID "04d8"
#define TRUERNG_ORIGINAL_PID "f5fe"
#define TRUERNG_PRO_PID "0aa0"
#define TRUERNG_PRO_V2_PID "ebb5"
// SwiftRNG Device Constants (same VID/PID as TrueRNG devices)
#define SWIFT_RNG_VID "04D8"
#define SWIFT_RNG_PID "F5FE"
#define SWIFT_RNG_PRO_VID "16D0"
#define SWIFT_RNG_PRO_PID "0AA0"
#define SWIFT_RNG_PRO_V2_VID "04D8"
#define SWIFT_RNG_PRO_V2_PID "EBB5"
// TrueRNG/SwiftRNG Device Type enumeration
// Hardware RNG Device Type enumeration
typedef enum {
TRUERNG_ORIGINAL = 1,
TRUERNG_PRO = 2,
TRUERNG_PRO_V2 = 3,
SWIFT_RNG = 4,
SWIFT_RNG_PRO = 5,
SWIFT_RNG_PRO_V2 = 6
} truerng_device_type_t;
TRUERNG_PRO_V2 = 3
} hardware_rng_device_type_t;
// Hardware RNG device information structure
typedef struct {
char port_path[256]; // Device port path (e.g., /dev/ttyUSB0)
truerng_device_type_t device_type; // Device type identifier
hardware_rng_device_type_t device_type; // Device type identifier
char friendly_name[64]; // Human-readable device name
int is_working; // 1 if device passes basic test, 0 otherwise
} hardware_rng_device_t;
@@ -202,21 +189,26 @@ typedef struct {
int detect_all_hardware_rng_devices(hardware_rng_device_t* devices, int max_devices, int* num_devices_found);
int test_hardware_rng_device(const hardware_rng_device_t* device);
int select_hardware_rng_device_interactive(hardware_rng_device_t* devices, int num_devices, hardware_rng_device_t* selected_device);
int find_truerng_port(char* port_path, size_t port_path_size, truerng_device_type_t* device_type); // Legacy function for backward compatibility
int find_truerng_port(char* port_path, size_t port_path_size, hardware_rng_device_type_t* device_type); // Legacy function for backward compatibility
// TrueRNG entropy collection functions (updated to match implementation)
int configure_rng_serial_port(int fd, hardware_rng_device_type_t device_type);
int setup_truerng_serial_port(const char* port_path);
int collect_truerng_entropy(unsigned char* entropy_buffer, size_t target_bytes, size_t* collected_bytes, int display_progress);
int collect_truerng_entropy_from_device(const hardware_rng_device_t* device, unsigned char* entropy_buffer,
size_t target_bytes, size_t* collected_bytes, int display_progress);
int collect_truerng_entropy_streaming_from_device(const hardware_rng_device_t* device, const char* pad_chksum,
size_t total_bytes, int display_progress, int entropy_mode);
const char* get_truerng_device_name(truerng_device_type_t device_type);
const char* get_truerng_device_name(hardware_rng_device_type_t device_type);
int read_usb_device_info(const char* port_name, char* vid, char* pid);
// Dice entropy collection functions (updated to match implementation)
int collect_dice_entropy(unsigned char* entropy_buffer, size_t target_bytes, size_t* collected_bytes, int display_progress);
// File entropy collection functions
int get_file_entropy_info(char* file_path, size_t max_path_len, size_t* file_size, int display_progress);
int collect_file_entropy(unsigned char* entropy_buffer, size_t target_bytes, size_t* collected_bytes, int display_progress);
// Unified entropy collection interface (updated to match implementation)
int collect_entropy_by_source(entropy_source_t source, unsigned char* entropy_buffer, size_t target_bytes, size_t* collected_bytes, int display_progress);