1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-22 12:32:02 +00:00

fixup! feat(core): add libtropic to unix build

This commit is contained in:
Ioan Bizău 2025-01-07 17:35:18 +01:00
parent d3b829ccc5
commit fac69b398e
3 changed files with 15 additions and 34 deletions

View File

@ -48,7 +48,6 @@
#include "extmod/vfs_posix.h"
#include "genhdr/mpversion.h"
#include "input.h"
#include "memzero.h"
#ifdef USE_BUTTON
#include <io/button.h>
@ -506,34 +505,7 @@ static int sdl_event_filter(void *userdata, SDL_Event *event) {
void drivers_init() {
#ifdef USE_TROPIC
uint8_t tropic_secret_trezor_privkey[SECRET_TROPIC_KEY_LEN] = {0};
uint8_t tropic_secret_tropic_pubkey[SECRET_TROPIC_KEY_LEN] = {0};
if (sectrue != secret_tropic_get_trezor_privkey(tropic_secret_trezor_privkey)) {
memzero(tropic_secret_trezor_privkey, sizeof(tropic_secret_trezor_privkey));
ensure(false, "secret_tropic_get_trezor_privkey failed");
}
if (sectrue != secret_tropic_get_tropic_pubkey(tropic_secret_tropic_pubkey)) {
memzero(tropic_secret_trezor_privkey, sizeof(tropic_secret_trezor_privkey));
memzero(tropic_secret_tropic_pubkey, sizeof(tropic_secret_tropic_pubkey));
ensure(false, "secret_tropic_get_tropic_pubkey failed");
}
if (tropic_init() != TROPIC_SUCCESS) {
memzero(tropic_secret_trezor_privkey, sizeof(tropic_secret_trezor_privkey));
memzero(tropic_secret_tropic_pubkey, sizeof(tropic_secret_tropic_pubkey));
ensure(false, "tropic_init failed");
}
if (tropic_handshake(tropic_secret_trezor_privkey, tropic_secret_tropic_pubkey) != TROPIC_SUCCESS) {
memzero(tropic_secret_trezor_privkey, sizeof(tropic_secret_trezor_privkey));
memzero(tropic_secret_tropic_pubkey, sizeof(tropic_secret_tropic_pubkey));
ensure(false, "tropic_handshake failed");
}
memzero(tropic_secret_trezor_privkey, sizeof(tropic_secret_trezor_privkey));
memzero(tropic_secret_tropic_pubkey, sizeof(tropic_secret_tropic_pubkey));
tropic_init();
#endif
}

View File

@ -22,7 +22,6 @@
typedef enum _tropic_result {
TROPIC_SUCCESS = 0, // Operation completed successfully.
TROPIC_ERR_INIT,
TROPIC_ERR_SESSION_START,
} tropic_result;

View File

@ -18,19 +18,29 @@
*/
#include <trezor_rtl.h>
#include <sec/tropic_transport.h>
#include <sec/secret.h>
#include "ed25519-donna/ed25519.h"
#include "memzero.h"
#define PKEY_INDEX_BYTE PAIRING_KEY_SLOT_INDEX_0
STATIC lt_handle_t lt_handle = {0};
tropic_result tropic_init(void) {
lt_ret_t ret = lt_init(&lt_handle);
if (ret != LT_OK) {
return TROPIC_ERR_INIT;
}
uint8_t tropic_secret_tropic_pubkey[SECRET_TROPIC_KEY_LEN] = {0};
uint8_t tropic_secret_trezor_privkey[SECRET_TROPIC_KEY_LEN] = {0};
ensure((lt_init(&lt_handle) == LT_OK) * sectrue, "lt_init failed");
ensure(secret_tropic_get_tropic_pubkey(tropic_secret_tropic_pubkey), "secret_tropic_get_tropic_pubkey failed");
ensure(secret_tropic_get_trezor_privkey(tropic_secret_trezor_privkey), "secret_tropic_get_trezor_privkey failed");
tropic_result result = tropic_handshake(tropic_secret_trezor_privkey, tropic_secret_tropic_pubkey);
memzero(tropic_secret_trezor_privkey, sizeof(tropic_secret_trezor_privkey));
ensure((result == TROPIC_SUCCESS) * sectrue, "tropic_handshake failed");
return TROPIC_SUCCESS;
}