chore(legacy): drop support for RANDOM_DEV_FILE

Replacing it with trezor-crypto's na(t)ive RNG, which we can reseed over
debuglink.
mmilata/tt-pin-keyboard
matejcik 2 years ago committed by matejcik
parent bb71f9f345
commit 658c50fc1f

@ -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 \

@ -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

@ -27,7 +27,6 @@
#include <stddef.h>
void emulatorPoll(void);
void emulatorRandom(void *buffer, size_t size);
void emulatorSocketInit(void);
size_t emulatorSocketRead(int *iface, void *buffer, size_t size,

@ -1,32 +0,0 @@
/*
* This file is part of the Trezor project, https://trezor.io/
*
* Copyright (C) 2017 Saleem Rashid <trezor@saleemrashid.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#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;
}

@ -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) {

@ -0,0 +1 @@
\[emulator] Removed support for /dev/urandom or custom entropy source.
Loading…
Cancel
Save