revert changed to listUSBDevices, for now it just print to stdout
This commit is contained in:
@@ -27,13 +27,15 @@ daemon.o: daemon.c
|
|||||||
writeentropy.o: writeentropy.c
|
writeentropy.o: writeentropy.c
|
||||||
$(CC) $(CFLAGS) -c writeentropy.c
|
$(CC) $(CFLAGS) -c writeentropy.c
|
||||||
|
|
||||||
|
# static lib compiled into infnoise binary
|
||||||
libinfnoise.o: libinfnoise.c libinfnoise.h libinfnoise_private.h healthcheck.c healthcheck.h Keccak/brg_endian.h Keccak/KeccakF-1600-reference.c
|
libinfnoise.o: libinfnoise.c libinfnoise.h libinfnoise_private.h healthcheck.c healthcheck.h Keccak/brg_endian.h Keccak/KeccakF-1600-reference.c
|
||||||
$(CC) $(CFLAGS) -c libinfnoise.c healthcheck.c Keccak/KeccakF-1600-reference.c
|
$(CC) $(CFLAGS) -c libinfnoise.c healthcheck.c
|
||||||
|
|
||||||
libinfnoise.a: libinfnoise.o healthcheck.o KeccakF-1600-reference.o writeentropy.o
|
libinfnoise.a: libinfnoise.o healthcheck.o KeccakF-1600-reference.o writeentropy.o
|
||||||
ar rcs libinfnoise.a libinfnoise.o healthcheck.o KeccakF-1600-reference.o writeentropy.o
|
ar rcs libinfnoise.a libinfnoise.o healthcheck.o KeccakF-1600-reference.o writeentropy.o
|
||||||
ranlib libinfnoise.a
|
ranlib libinfnoise.a
|
||||||
|
|
||||||
|
# shared lib
|
||||||
libinfnoise.so: libinfnoise.o healthcheck.o KeccakF-1600-reference.o writeentropy.o
|
libinfnoise.so: libinfnoise.o healthcheck.o KeccakF-1600-reference.o writeentropy.o
|
||||||
$(CC) $(CFLAGS) -fvisibility=hidden -o libinfnoise.so libinfnoise.o healthcheck.o KeccakF-1600-reference.o writeentropy.o -Wl,--version-script=libinfnoise.version $(FTDI) -lm -shared
|
$(CC) $(CFLAGS) -fvisibility=hidden -o libinfnoise.so libinfnoise.o healthcheck.o KeccakF-1600-reference.o writeentropy.o -Wl,--version-script=libinfnoise.version $(FTDI) -lm -shared
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,3 @@ void startDaemon(struct opt_struct* opts) {
|
|||||||
// Child
|
// Child
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSuperUser(void) {
|
|
||||||
return (geteuid() == 0);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -150,24 +150,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
char *message;
|
char *message;
|
||||||
if (opts.listDevices) {
|
if (opts.listDevices) {
|
||||||
struct inm_devlist *device_list;
|
if(!listUSBDevices(&ftdic, &message)) {
|
||||||
device_list = malloc(sizeof(struct inm_devlist));
|
|
||||||
|
|
||||||
if(!listUSBDevices(&ftdic, device_list, &message)) {
|
|
||||||
fputs(message, stderr);
|
fputs(message, stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// debug:
|
|
||||||
uint8_t i=0;
|
|
||||||
struct inm_devlist_node *tmp;
|
|
||||||
for ( tmp = device_list->head; tmp != NULL; tmp=tmp->next) {
|
|
||||||
if (tmp->device->serial != NULL) {
|
|
||||||
printf("%s\n", tmp->device->serial);
|
|
||||||
}
|
|
||||||
printf("%d\n", i);
|
|
||||||
i+=1;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,20 +158,9 @@ uint32_t processBytes(uint8_t *keccakState, uint8_t *bytes, uint8_t *result, uin
|
|||||||
fprintf(stderr, "bytes written: %d\n", bytesWritten);
|
fprintf(stderr, "bytes written: %d\n", bytesWritten);
|
||||||
return bytesWritten;
|
return bytesWritten;
|
||||||
}
|
}
|
||||||
void add_to_list(struct inm_devlist *list, struct infnoise_device **dev) {
|
|
||||||
struct inm_devlist_node *tmp = malloc(sizeof(struct inm_devlist_node ) );
|
|
||||||
tmp->device = (*dev);
|
|
||||||
printf("added serial1: %s\n", (*dev)->serial);
|
|
||||||
tmp->next = list->head;
|
|
||||||
printf("added serial2: %s\n", tmp->device->serial);
|
|
||||||
list->head = tmp;
|
|
||||||
printf("added serial3: %s\n", list->head->device->serial);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Return a list of all infinite noise multipliers found.
|
// Return a list of all infinite noise multipliers found.
|
||||||
bool listUSBDevices(struct ftdi_context *ftdic, struct inm_devlist *result, char** message) {
|
bool listUSBDevices(struct ftdi_context *ftdic, char** message) {
|
||||||
ftdi_init(ftdic);
|
ftdi_init(ftdic);
|
||||||
|
|
||||||
struct ftdi_device_list *devlist;
|
struct ftdi_device_list *devlist;
|
||||||
@@ -196,31 +185,14 @@ bool listUSBDevices(struct ftdi_context *ftdic, struct inm_devlist *result, char
|
|||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (!isSuperUser()) {
|
if (!isSuperUser()) {
|
||||||
*message = "Can't find Infinite Noise Multiplier. Try running as super user?\n";
|
*message = "Can't find Infinite Noise Multiplier. Try running as super user?\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
//todo: fprintf(stderr, "ftdi_usb_get_strings failed: %d (%s)\n", rc, ftdi_get_error_string(ftdic));
|
//*message = "ftdi_usb_get_strings failed: %d (%s)\n", rc, ftdi_get_error_string(ftdic));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// build struct of device descriptor & add to list
|
// print to stdout
|
||||||
printf("Manufacturer: %s, Description: %s, Serial: %s\n", manufacturer, description, serial);
|
printf("Manufacturer: %s, Description: %s, Serial: %s\n", manufacturer, description, serial);
|
||||||
|
|
||||||
struct infnoise_device *result_dev = malloc(sizeof(struct infnoise_device));
|
|
||||||
|
|
||||||
result_dev->index = i;
|
|
||||||
result_dev->manufacturer = manufacturer;
|
|
||||||
result_dev->product = description;
|
|
||||||
result_dev->serial = serial;
|
|
||||||
|
|
||||||
//printf("debug: %s\n", result_dev);
|
|
||||||
add_to_list(result, &result_dev);
|
|
||||||
|
|
||||||
struct inm_devlist_node *tmp;
|
|
||||||
for ( tmp = result->head; tmp != NULL; tmp=tmp->next) {
|
|
||||||
if (tmp->device->serial != NULL) {
|
|
||||||
printf("%s\n", tmp->device->serial);
|
|
||||||
}
|
|
||||||
//tmp = tmp->next;
|
|
||||||
}
|
|
||||||
curdev = curdev->next;
|
curdev = curdev->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,27 +8,7 @@
|
|||||||
// We also write this in one go to the Keccak sponge, which is at most 1600 bits
|
// We also write this in one go to the Keccak sponge, which is at most 1600 bits
|
||||||
#define BUFLEN 512u
|
#define BUFLEN 512u
|
||||||
|
|
||||||
// struct for ftdi_device_descriptor
|
bool listUSBDevices(struct ftdi_context *ftdic, char **message);
|
||||||
struct infnoise_device {
|
|
||||||
uint8_t index;
|
|
||||||
char *manufacturer;
|
|
||||||
char *product;
|
|
||||||
char *serial;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct inm_devlist_node
|
|
||||||
{
|
|
||||||
struct infnoise_device *device;
|
|
||||||
struct inm_devlist_node *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct inm_devlist
|
|
||||||
{
|
|
||||||
struct inm_devlist_node *head;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
bool listUSBDevices(struct ftdi_context *ftdic, struct inm_devlist *result, char **message);
|
|
||||||
|
|
||||||
bool initInfnoise(struct ftdi_context *ftdic, char *serial, char **message, bool debug);
|
bool initInfnoise(struct ftdi_context *ftdic, char *serial, char **message, bool debug);
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void inmWriteEntropyStart(uint32_t bufLen, bool debug);
|
|||||||
void inmWriteEntropyToPool(uint8_t *bytes, uint32_t length, uint32_t entropy);
|
void inmWriteEntropyToPool(uint8_t *bytes, uint32_t length, uint32_t entropy);
|
||||||
void inmWaitForPoolToHaveRoom(void);
|
void inmWaitForPoolToHaveRoom(void);
|
||||||
void inmDumpStats(void);
|
void inmDumpStats(void);
|
||||||
bool isSuperUser(void);
|
//bool isSuperUser(void);
|
||||||
|
|
||||||
extern double inmK, inmExpectedEntropyPerBit;
|
extern double inmK, inmExpectedEntropyPerBit;
|
||||||
struct timespec;
|
struct timespec;
|
||||||
|
|||||||
Reference in New Issue
Block a user