mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-23 21:02:23 +00:00
Ethereum signing skeleton
This commit is contained in:
parent
9c7e41f15b
commit
a9449520b8
@ -17,6 +17,7 @@ OBJS += recovery.o
|
||||
OBJS += reset.o
|
||||
OBJS += signing.o
|
||||
OBJS += crypto.o
|
||||
OBJS += ethereum.o
|
||||
|
||||
OBJS += debug.o
|
||||
|
||||
|
61
firmware/ethereum.c
Normal file
61
firmware/ethereum.c
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of the TREZOR project.
|
||||
*
|
||||
* Copyright (C) 2016 Alex Beregszaszi <alex@rtfs.hu>
|
||||
*
|
||||
* 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 "ethereum.h"
|
||||
#include "fsm.h"
|
||||
#include "layout2.h"
|
||||
#include "messages.h"
|
||||
#include "transaction.h"
|
||||
#include "ecdsa.h"
|
||||
#include "protect.h"
|
||||
#include "crypto.h"
|
||||
#include "secp256k1.h"
|
||||
#include "sha3.h"
|
||||
|
||||
static bool signing = false;
|
||||
|
||||
void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
|
||||
{
|
||||
(void)node;
|
||||
|
||||
signing = true;
|
||||
|
||||
fsm_sendFailure(FailureType_Failure_Other, "Unsupported feature");
|
||||
}
|
||||
|
||||
void ethereum_signing_txack(EthereumTxAck *tx)
|
||||
{
|
||||
(void)tx;
|
||||
|
||||
if (!signing) {
|
||||
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, "Not in Signing mode");
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
fsm_sendFailure(FailureType_Failure_Other, "Unsupported feature");
|
||||
}
|
||||
|
||||
void ethereum_signing_abort(void)
|
||||
{
|
||||
if (signing) {
|
||||
layoutHome();
|
||||
signing = false;
|
||||
}
|
||||
}
|
32
firmware/ethereum.h
Normal file
32
firmware/ethereum.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of the TREZOR project.
|
||||
*
|
||||
* Copyright (C) 2016 Alex Beregszaszi <alex@rtfs.hu>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef __ETHEREUM_H__
|
||||
#define __ETHEREUM_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bip32.h"
|
||||
#include "messages.pb.h"
|
||||
|
||||
void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node);
|
||||
void ethereum_signing_abort(void);
|
||||
void ethereum_signing_txack(EthereumTxAck *msg);
|
||||
|
||||
#endif
|
@ -47,6 +47,7 @@
|
||||
#include "curves.h"
|
||||
#include "secp256k1.h"
|
||||
#include <libopencm3/stm32/flash.h>
|
||||
#include "ethereum.h"
|
||||
|
||||
// message methods
|
||||
|
||||
@ -433,19 +434,31 @@ void fsm_msgCancel(Cancel *msg)
|
||||
(void)msg;
|
||||
recovery_abort();
|
||||
signing_abort();
|
||||
ethereum_signing_abort();
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Aborted");
|
||||
}
|
||||
|
||||
void fsm_msgEthereumSignTx(EthereumSignTx *msg)
|
||||
{
|
||||
(void)msg;
|
||||
fsm_sendFailure(FailureType_Failure_Other, "Unsupported feature");
|
||||
if (!storage_isInitialized()) {
|
||||
fsm_sendFailure(FailureType_Failure_NotInitialized, "Device not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!protectPin(true)) {
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
const HDNode *node = fsm_getDerivedNode(SECP256K1_NAME, msg->address_n, msg->address_n_count);
|
||||
if (!node) return;
|
||||
|
||||
ethereum_signing_init(msg, node);
|
||||
}
|
||||
|
||||
void fsm_msgEthereumTxAck(EthereumTxAck *msg)
|
||||
{
|
||||
(void)msg;
|
||||
fsm_sendFailure(FailureType_Failure_Other, "Unsupported feature");
|
||||
ethereum_signing_txack(msg);
|
||||
}
|
||||
|
||||
void fsm_msgCipherKeyValue(CipherKeyValue *msg)
|
||||
|
Loading…
Reference in New Issue
Block a user