Monero
Loading...
Searching...
No Matches
hw::trezor Namespace Reference

Namespaces

namespace  exc
namespace  protocol

Classes

class  MessageMapper
struct  trezor_usb_desc_t
class  Protocol
class  ProtocolV1
class  Transport
class  BridgeTransport
class  UdpTransport
class  GenericMessage

Typedefs

using json = rapidjson::Document
using json_val = rapidjson::Value
typedef std::vector< std::shared_ptr< Transport > > t_transport_vect

Functions

void register_all (std::map< std::string, std::unique_ptr< device > > &registry)
void register_all ()
template<class t_message = google::protobuf::Message>
std::shared_ptr< t_message > message_ptr_retype (std::shared_ptr< google::protobuf::Message > &in)
template<class t_message = google::protobuf::Message>
std::shared_ptr< t_message > message_ptr_retype_static (std::shared_ptr< google::protobuf::Message > &in)
bool t_serialize (const std::string &in, std::string &out)
bool t_serialize (const epee::wipeable_string &in, std::string &out)
bool t_serialize (const json_val &in, std::string &out)
std::string t_serialize (const json_val &in)
bool t_deserialize (const std::string &in, std::string &out)
bool t_deserialize (std::string &in, epee::wipeable_string &out)
bool t_deserialize (const std::string &in, json &out)
static std::string json_get_string (const rapidjson::Value &in)
uint64_t pack_version (uint32_t major, uint32_t minor, uint32_t patch)
static ssize_t get_device_idx (uint16_t id_vendor, uint16_t id_product)
static bool is_device_supported (ssize_t device_idx)
static size_t message_size (const google::protobuf::Message &req)
static size_t serialize_message_buffer_size (size_t msg_size)
static void serialize_message_header (void *buff, uint16_t tag, uint32_t len)
static void deserialize_message_header (const void *buff, uint16_t &tag, uint32_t &len)
static void serialize_message (const google::protobuf::Message &req, size_t msg_size, uint8_t *buff, size_t buff_size)
static void assert_port_number (uint32_t port)
static void parse_udp_path (std::string &host, int &port, std::string path)
void enumerate (t_transport_vect &res)
void sort_transports_by_env (t_transport_vect &res)
std::shared_ptr< Transporttransport (const std::string &path)
void throw_failure_exception (const messages::common::Failure *failure)
std::ostream & operator<< (std::ostream &o, hw::trezor::Transport const &t)
std::ostream & operator<< (std::ostream &o, std::shared_ptr< hw::trezor::Transport > const &t)
template<class t_req, class t_res, class t_transport>
bool invoke_bridge_http (const boost::string_ref uri, const t_req &out_struct, t_res &result_struct, t_transport &transport, const boost::string_ref method="POST", std::chrono::milliseconds timeout=std::chrono::seconds(180))
template<class t_transport = Transport>
std::shared_ptr< t_transport > transport_typed (const std::string &path)
template<class t_message = google::protobuf::Message>
std::shared_ptr< t_message > exchange_message (Transport &transport, const google::protobuf::Message &req, boost::optional< messages::MessageType > resp_type=boost::none)

Variables

const char * TYPE_PREFIX = "MessageType_"
const char * PACKAGES []
static trezor_usb_desc_t TREZOR_DESC_T1 = {1, 0x534C, 0x0001}
static trezor_usb_desc_t TREZOR_DESC_T2 = {2, 0x1209, 0x53C1}
static trezor_usb_desc_t TREZOR_DESC_T2_BL = {3, 0x1209, 0x53C0}
static trezor_usb_desc_t TREZOR_DESCS []
static size_t TREZOR_DESCS_LEN = sizeof(TREZOR_DESCS)/sizeof(TREZOR_DESCS[0])
const std::string DEFAULT_BRIDGE = "127.0.0.1:21325"

Typedef Documentation

◆ json

using hw::trezor::json = rapidjson::Document

◆ json_val

using hw::trezor::json_val = rapidjson::Value

◆ t_transport_vect

typedef std::vector<std::shared_ptr<Transport> > hw::trezor::t_transport_vect

Function Documentation

◆ assert_port_number()

void hw::trezor::assert_port_number ( uint32_t port)
static

◆ deserialize_message_header()

void hw::trezor::deserialize_message_header ( const void * buff,
uint16_t & tag,
uint32_t & len )
static

◆ enumerate()

void hw::trezor::enumerate ( t_transport_vect & res)

Enumerates all transports

◆ exchange_message()

template<class t_message = google::protobuf::Message>
std::shared_ptr< t_message > hw::trezor::exchange_message ( Transport & transport,
const google::protobuf::Message & req,
boost::optional< messages::MessageType > resp_type = boost::none )

Simple wrapper for write-read message exchange with expected message response type.

Exceptions
UnexpectedMessageExceptionif the response message type is different than expected. Exception contains message type and the message itself.

◆ get_device_idx()

ssize_t hw::trezor::get_device_idx ( uint16_t id_vendor,
uint16_t id_product )
static

◆ invoke_bridge_http()

template<class t_req, class t_res, class t_transport>
bool hw::trezor::invoke_bridge_http ( const boost::string_ref uri,
const t_req & out_struct,
t_res & result_struct,
t_transport & transport,
const boost::string_ref method = "POST",
std::chrono::milliseconds timeout = std::chrono::seconds(180) )

◆ is_device_supported()

bool hw::trezor::is_device_supported ( ssize_t device_idx)
static

◆ json_get_string()

std::string hw::trezor::json_get_string ( const rapidjson::Value & in)
static

◆ message_ptr_retype()

template<class t_message = google::protobuf::Message>
std::shared_ptr< t_message > hw::trezor::message_ptr_retype ( std::shared_ptr< google::protobuf::Message > & in)

◆ message_ptr_retype_static()

template<class t_message = google::protobuf::Message>
std::shared_ptr< t_message > hw::trezor::message_ptr_retype_static ( std::shared_ptr< google::protobuf::Message > & in)

◆ message_size()

size_t hw::trezor::message_size ( const google::protobuf::Message & req)
static

◆ operator<<() [1/2]

std::ostream & hw::trezor::operator<< ( std::ostream & o,
hw::trezor::Transport const & t )

◆ operator<<() [2/2]

std::ostream & hw::trezor::operator<< ( std::ostream & o,
std::shared_ptr< hw::trezor::Transport > const & t )

◆ pack_version()

uint64_t hw::trezor::pack_version ( uint32_t major,
uint32_t minor,
uint32_t patch )

◆ parse_udp_path()

void hw::trezor::parse_udp_path ( std::string & host,
int & port,
std::string path )
static

◆ register_all() [1/2]

void hw::trezor::register_all ( )

◆ register_all() [2/2]

void hw::trezor::register_all ( std::map< std::string, std::unique_ptr< device > > & registry)

◆ serialize_message()

void hw::trezor::serialize_message ( const google::protobuf::Message & req,
size_t msg_size,
uint8_t * buff,
size_t buff_size )
static

◆ serialize_message_buffer_size()

size_t hw::trezor::serialize_message_buffer_size ( size_t msg_size)
static

◆ serialize_message_header()

void hw::trezor::serialize_message_header ( void * buff,
uint16_t tag,
uint32_t len )
static

◆ sort_transports_by_env()

void hw::trezor::sort_transports_by_env ( t_transport_vect & res)

Sorts found transports by TREZOR_PATH environment variable.

◆ t_deserialize() [1/3]

bool hw::trezor::t_deserialize ( const std::string & in,
json & out )

◆ t_deserialize() [2/3]

bool hw::trezor::t_deserialize ( const std::string & in,
std::string & out )

◆ t_deserialize() [3/3]

bool hw::trezor::t_deserialize ( std::string & in,
epee::wipeable_string & out )

◆ t_serialize() [1/4]

bool hw::trezor::t_serialize ( const epee::wipeable_string & in,
std::string & out )

◆ t_serialize() [2/4]

std::string hw::trezor::t_serialize ( const json_val & in)

◆ t_serialize() [3/4]

bool hw::trezor::t_serialize ( const json_val & in,
std::string & out )

◆ t_serialize() [4/4]

bool hw::trezor::t_serialize ( const std::string & in,
std::string & out )

◆ throw_failure_exception()

void hw::trezor::throw_failure_exception ( const messages::common::Failure * failure)

Throws corresponding failure exception.

◆ transport()

std::shared_ptr< Transport > hw::trezor::transport ( const std::string & path)

Transforms path to the transport

◆ transport_typed()

template<class t_transport = Transport>
std::shared_ptr< t_transport > hw::trezor::transport_typed ( const std::string & path)

Transforms path to the particular transport

Variable Documentation

◆ DEFAULT_BRIDGE

const std::string hw::trezor::DEFAULT_BRIDGE = "127.0.0.1:21325"

◆ PACKAGES

const char* hw::trezor::PACKAGES[]
Initial value:
= {
"hw.trezor.messages.",
"hw.trezor.messages.common.",
"hw.trezor.messages.management.",
"hw.trezor.messages.monero."
}

◆ TREZOR_DESC_T1

trezor_usb_desc_t hw::trezor::TREZOR_DESC_T1 = {1, 0x534C, 0x0001}
static

◆ TREZOR_DESC_T2

trezor_usb_desc_t hw::trezor::TREZOR_DESC_T2 = {2, 0x1209, 0x53C1}
static

◆ TREZOR_DESC_T2_BL

trezor_usb_desc_t hw::trezor::TREZOR_DESC_T2_BL = {3, 0x1209, 0x53C0}
static

◆ TREZOR_DESCS

trezor_usb_desc_t hw::trezor::TREZOR_DESCS[]
static
Initial value:
= {
}
static trezor_usb_desc_t TREZOR_DESC_T1
Definition transport.cpp:117
static trezor_usb_desc_t TREZOR_DESC_T2_BL
Definition transport.cpp:119
static trezor_usb_desc_t TREZOR_DESC_T2
Definition transport.cpp:118

◆ TREZOR_DESCS_LEN

size_t hw::trezor::TREZOR_DESCS_LEN = sizeof(TREZOR_DESCS)/sizeof(TREZOR_DESCS[0])
static

◆ TYPE_PREFIX

const char* hw::trezor::TYPE_PREFIX = "MessageType_"