diff --git a/legacy/Makefile.include b/legacy/Makefile.include index 9b1ff42df..8918ef56d 100644 --- a/legacy/Makefile.include +++ b/legacy/Makefile.include @@ -75,7 +75,6 @@ CFLAGS += $(OPTFLAGS) \ $(FPUFLAGS) \ $(CONFFLAG) \ -DSTM32F2 \ - -DRAND_PLATFORM_INDEPENDENT=1 \ -I$(TOOLCHAIN_DIR)/include \ -I$(TOP_DIR) \ -I$(TOP_DIR)gen \ @@ -105,10 +104,6 @@ LIBDEPS += $(TOP_DIR)/libtrezor.a $(TOP_DIR)emulator/libemulator.a CFLAGS += $(shell pkg-config --cflags sdl2 SDL2_image) LDLIBS += $(shell pkg-config --libs sdl2 SDL2_image) -ifdef RANDOM_DEV_FILE -CFLAGS += -DRANDOM_DEV_FILE=\"$(RANDOM_DEV_FILE)\" -endif - else ifdef APPVER CFLAGS += -DAPPVER=$(APPVER) @@ -118,6 +113,7 @@ LDSCRIPT = $(TOP_DIR)/memory.ld endif CFLAGS += -DEMULATOR=0 +CFLAGS += -DRAND_PLATFORM_INDEPENDENT=1 LDFLAGS += --static \ -Wl,--start-group \ diff --git a/legacy/emulator/Makefile b/legacy/emulator/Makefile index 1243a7fe5..0bfe003a9 100644 --- a/legacy/emulator/Makefile +++ b/legacy/emulator/Makefile @@ -5,7 +5,6 @@ OBJS += setup.o OBJS += buttons.o OBJS += memory.o OBJS += oled.o -OBJS += rng.o OBJS += timer.o OBJS += udp.o diff --git a/legacy/emulator/emulator.h b/legacy/emulator/emulator.h index bda59207c..93e0b6e3e 100644 --- a/legacy/emulator/emulator.h +++ b/legacy/emulator/emulator.h @@ -27,7 +27,6 @@ #include void emulatorPoll(void); -void emulatorRandom(void *buffer, size_t size); void emulatorSocketInit(void); size_t emulatorSocketRead(int *iface, void *buffer, size_t size, diff --git a/legacy/emulator/rng.c b/legacy/emulator/rng.c deleted file mode 100644 index 3fa346801..000000000 --- a/legacy/emulator/rng.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the Trezor project, https://trezor.io/ - * - * Copyright (C) 2017 Saleem Rashid - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - */ - -#include "rng.h" - -uint32_t random32(void) { - static uint32_t last = 0; - uint32_t new = 0; - - do { - emulatorRandom(&new, sizeof(new)); - } while (last == new); - - last = new; - return new; -} diff --git a/legacy/emulator/setup.c b/legacy/emulator/setup.c index c300b53e6..b05acbfcf 100644 --- a/legacy/emulator/setup.c +++ b/legacy/emulator/setup.c @@ -34,49 +34,19 @@ #define EMULATOR_FLASH_FILE "emulator.img" -#ifndef RANDOM_DEV_FILE -#define RANDOM_DEV_FILE "/dev/urandom" -#endif - uint8_t *emulator_flash_base = NULL; uint32_t __stack_chk_guard; -static int random_fd = -1; - -static void setup_urandom(void); static void setup_flash(void); -void setup(void) { - setup_urandom(); - setup_flash(); -} +void setup(void) { setup_flash(); } void __attribute__((noreturn)) shutdown(void) { sleep(5); exit(4); } -void emulatorRandom(void *buffer, size_t size) { - ssize_t n = 0, len = 0; - do { - n = read(random_fd, (char *)buffer + len, size - len); - if (n < 0) { - perror("Failed to read " RANDOM_DEV_FILE); - exit(1); - } - len += n; - } while (len != (ssize_t)size); -} - -static void setup_urandom(void) { - random_fd = open(RANDOM_DEV_FILE, O_RDONLY); - if (random_fd < 0) { - perror("Failed to open " RANDOM_DEV_FILE); - exit(1); - } -} - static void setup_flash(void) { int fd = open(EMULATOR_FLASH_FILE, O_RDWR | O_SYNC | O_CREAT, 0644); if (fd < 0) { diff --git a/legacy/firmware/.changelog.d/2115.removed b/legacy/firmware/.changelog.d/2115.removed new file mode 100644 index 000000000..460d39e92 --- /dev/null +++ b/legacy/firmware/.changelog.d/2115.removed @@ -0,0 +1 @@ +\[emulator] Removed support for /dev/urandom or custom entropy source.