device_trezor: reject incompatible firmware versions

This commit is contained in:
jpk68
2026-08-01 13:21:25 -04:00
parent e8dd781e19
commit 8d4f888132
3 changed files with 17 additions and 0 deletions
+4
View File
@@ -172,6 +172,8 @@ namespace trezor {
pubkey = info.address;
return true;
} catch(exc::FirmwareNotSupportedException const&){
throw;
} catch(std::exception const& e){
MERROR("Get public address exception: " << e.what());
return false;
@@ -207,6 +209,8 @@ namespace trezor {
} catch(const exc::proto::CancelledException &){
CHECK_AND_ASSERT_THROW_MES(false, "Key export rejected on device");
} catch(exc::FirmwareNotSupportedException const&){
throw;
} catch(std::exception const& e){
MERROR("Get secret keys exception: " << e.what());
return false;
+7
View File
@@ -29,6 +29,7 @@
#include "device_trezor_base.hpp"
#include "memwipe.h"
#include <algorithm>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/predicate.hpp>
@@ -240,6 +241,12 @@ namespace trezor {
if (!m_features->has_initialized() || !m_features->initialized()){
throw exc::TrezorException("Device is not initialized");
}
// Reject firmware that doesn't have the Monero feature/capability
const auto& capabilities = m_features->capabilities();
if (std::find(capabilities.begin(), capabilities.end(), messages::management::Features::Capability_Monero) == capabilities.end()){
throw exc::FirmwareNotSupportedException();
}
}
void device_trezor_base::call_ping_unsafe(){
+6
View File
@@ -118,6 +118,12 @@ namespace exc {
ProtocolException(): CommunicationException("Trezor protocol error"){}
};
class FirmwareNotSupportedException: public TrezorException {
public:
using TrezorException::TrezorException;
FirmwareNotSupportedException(): TrezorException("Trezor firmware version does not support Monero"){}
};
// Communication protocol namespace
// Separated to distinguish between client and Trezor side exceptions.
namespace proto {