mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-26 07:11:25 +00:00
chore(legacy): drop support for RANDOM_DEV_FILE
Replacing it with trezor-crypto's na(t)ive RNG, which we can reseed over debuglink.
This commit is contained in:
parent
bb71f9f345
commit
658c50fc1f
@ -75,7 +75,6 @@ CFLAGS += $(OPTFLAGS) \
|
|||||||
$(FPUFLAGS) \
|
$(FPUFLAGS) \
|
||||||
$(CONFFLAG) \
|
$(CONFFLAG) \
|
||||||
-DSTM32F2 \
|
-DSTM32F2 \
|
||||||
-DRAND_PLATFORM_INDEPENDENT=1 \
|
|
||||||
-I$(TOOLCHAIN_DIR)/include \
|
-I$(TOOLCHAIN_DIR)/include \
|
||||||
-I$(TOP_DIR) \
|
-I$(TOP_DIR) \
|
||||||
-I$(TOP_DIR)gen \
|
-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)
|
CFLAGS += $(shell pkg-config --cflags sdl2 SDL2_image)
|
||||||
LDLIBS += $(shell pkg-config --libs sdl2 SDL2_image)
|
LDLIBS += $(shell pkg-config --libs sdl2 SDL2_image)
|
||||||
|
|
||||||
ifdef RANDOM_DEV_FILE
|
|
||||||
CFLAGS += -DRANDOM_DEV_FILE=\"$(RANDOM_DEV_FILE)\"
|
|
||||||
endif
|
|
||||||
|
|
||||||
else
|
else
|
||||||
ifdef APPVER
|
ifdef APPVER
|
||||||
CFLAGS += -DAPPVER=$(APPVER)
|
CFLAGS += -DAPPVER=$(APPVER)
|
||||||
@ -118,6 +113,7 @@ LDSCRIPT = $(TOP_DIR)/memory.ld
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -DEMULATOR=0
|
CFLAGS += -DEMULATOR=0
|
||||||
|
CFLAGS += -DRAND_PLATFORM_INDEPENDENT=1
|
||||||
|
|
||||||
LDFLAGS += --static \
|
LDFLAGS += --static \
|
||||||
-Wl,--start-group \
|
-Wl,--start-group \
|
||||||
|
@ -5,7 +5,6 @@ OBJS += setup.o
|
|||||||
OBJS += buttons.o
|
OBJS += buttons.o
|
||||||
OBJS += memory.o
|
OBJS += memory.o
|
||||||
OBJS += oled.o
|
OBJS += oled.o
|
||||||
OBJS += rng.o
|
|
||||||
OBJS += timer.o
|
OBJS += timer.o
|
||||||
OBJS += udp.o
|
OBJS += udp.o
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
void emulatorPoll(void);
|
void emulatorPoll(void);
|
||||||
void emulatorRandom(void *buffer, size_t size);
|
|
||||||
|
|
||||||
void emulatorSocketInit(void);
|
void emulatorSocketInit(void);
|
||||||
size_t emulatorSocketRead(int *iface, void *buffer, size_t size,
|
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"
|
#define EMULATOR_FLASH_FILE "emulator.img"
|
||||||
|
|
||||||
#ifndef RANDOM_DEV_FILE
|
|
||||||
#define RANDOM_DEV_FILE "/dev/urandom"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t *emulator_flash_base = NULL;
|
uint8_t *emulator_flash_base = NULL;
|
||||||
|
|
||||||
uint32_t __stack_chk_guard;
|
uint32_t __stack_chk_guard;
|
||||||
|
|
||||||
static int random_fd = -1;
|
|
||||||
|
|
||||||
static void setup_urandom(void);
|
|
||||||
static void setup_flash(void);
|
static void setup_flash(void);
|
||||||
|
|
||||||
void setup(void) {
|
void setup(void) { setup_flash(); }
|
||||||
setup_urandom();
|
|
||||||
setup_flash();
|
|
||||||
}
|
|
||||||
|
|
||||||
void __attribute__((noreturn)) shutdown(void) {
|
void __attribute__((noreturn)) shutdown(void) {
|
||||||
sleep(5);
|
sleep(5);
|
||||||
exit(4);
|
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) {
|
static void setup_flash(void) {
|
||||||
int fd = open(EMULATOR_FLASH_FILE, O_RDWR | O_SYNC | O_CREAT, 0644);
|
int fd = open(EMULATOR_FLASH_FILE, O_RDWR | O_SYNC | O_CREAT, 0644);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
1
legacy/firmware/.changelog.d/2115.removed
Normal file
1
legacy/firmware/.changelog.d/2115.removed
Normal file
@ -0,0 +1 @@
|
|||||||
|
\[emulator] Removed support for /dev/urandom or custom entropy source.
|
Loading…
Reference in New Issue
Block a user