38 #include <boost/thread/mutex.hpp> 39 #include <boost/thread/recursive_mutex.hpp> 46 #define MINIMAL_APP_VERSION_MAJOR 1 47 #define MINIMAL_APP_VERSION_MINOR 8 48 #define MINIMAL_APP_VERSION_MICRO 0 50 #define VERSION(M,m,u) ((M)<<16|(m)<<8|(u)) 51 #define VERSION_MAJOR(v) (((v)>>16)&0xFF) 52 #define VERSION_MINOR(v) (((v)>>8)&0xFF) 53 #define VERSION_MICRO(v) (((v)>>0)&0xFF) 55 #define MINIMAL_APP_VERSION VERSION(MINIMAL_APP_VERSION_MAJOR, MINIMAL_APP_VERSION_MINOR, MINIMAL_APP_VERSION_MICRO) 59 #ifdef WITH_DEVICE_LEDGER 63 #define SW_WRONG_LENGTH 0x6700 64 #define SW_SECURITY_PIN_LOCKED 0x6910 65 #define SW_SECURITY_LOAD_KEY 0x6911 66 #define SW_SECURITY_COMMITMENT_CONTROL 0x6912 67 #define SW_SECURITY_AMOUNT_CHAIN_CONTROL 0x6913 68 #define SW_SECURITY_COMMITMENT_CHAIN_CONTROL 0x6914 69 #define SW_SECURITY_OUTKEYS_CHAIN_CONTROL 0x6915 70 #define SW_SECURITY_MAXOUTPUT_REACHED 0x6916 71 #define SW_SECURITY_HMAC 0x6917 72 #define SW_SECURITY_RANGE_VALUE 0x6918 73 #define SW_SECURITY_INTERNAL 0x6919 74 #define SW_SECURITY_MAX_SIGNATURE_REACHED 0x691A 75 #define SW_SECURITY_PREFIX_HASH 0x691B 76 #define SW_SECURITY_LOCKED 0x69EE 77 #define SW_COMMAND_NOT_ALLOWED 0x6980 78 #define SW_SUBCOMMAND_NOT_ALLOWED 0x6981 79 #define SW_DENY 0x6982 80 #define SW_KEY_NOT_SET 0x6983 81 #define SW_WRONG_DATA 0x6984 82 #define SW_WRONG_DATA_RANGE 0x6985 83 #define SW_IO_FULL 0x6986 84 #define SW_CLIENT_NOT_SUPPORTED 0x6A30 85 #define SW_WRONG_P1P2 0x6b00 86 #define SW_INS_NOT_SUPPORTED 0x6d00 87 #define SW_PROTOCOL_NOT_SUPPORTED 0x6e00 88 #define SW_UNKNOWN 0x6f00 91 bool apdu_verbose =
true;
94 void set_apdu_verbose(
bool verbose);
101 bool is_change_address;
102 bool additional_key ;
107 ABPkeys(
const ABPkeys& keys) ;
108 ABPkeys() {index=0;is_subaddress=
false;is_change_address=
false;additional_key=
false;}
109 ABPkeys &operator=(
const ABPkeys &keys);
114 std::vector<ABPkeys> ABP;
116 bool find(
const rct::key& P, ABPkeys& keys)
const;
117 void add(
const ABPkeys& keys);
133 std::vector<SecHMAC> hmacs;
141 #define BUFFER_SEND_SIZE 262 142 #define BUFFER_RECV_SIZE 262 147 mutable boost::recursive_mutex device_locker;
148 mutable boost::mutex command_locker;
151 hw::io::device_io_hid hw_device;
152 unsigned int length_send;
153 unsigned char buffer_send[BUFFER_SEND_SIZE];
154 unsigned int length_recv;
155 unsigned char buffer_recv[BUFFER_RECV_SIZE];
160 unsigned int exchange(
unsigned int ok=SW_OK,
unsigned int mask=0xFFFF);
161 unsigned int exchange_wait_on_input(
unsigned int ok=SW_OK,
unsigned int mask=0xFFFF);
162 void reset_buffer(
void);
163 int set_command_header(
unsigned char ins,
unsigned char p1 = 0x00,
unsigned char p2 = 0x00);
164 int set_command_header_noopt(
unsigned char ins,
unsigned char p1 = 0x00,
unsigned char p2 = 0x00);
165 void send_simple(
unsigned char ins,
unsigned char p1 = 0x00);
166 void send_secret(
const unsigned char sec[32],
int &offset);
167 void receive_secret(
unsigned char sec[32],
int &offset);
174 const bool need_additional,
const size_t real_output_index,
189 device_ledger(
const device_ledger &
device) = delete ;
190 device_ledger& operator=(
const device_ledger &
device) =
delete;
192 explicit operator bool()
const override {
return this->connected(); }
202 bool init(
void)
override;
204 bool connect(
void)
override;
205 bool disconnect()
override;
206 bool connected(
void)
const;
208 bool set_mode(device_mode
mode)
override;
210 device_type get_type()
const override {
return device_type::LEDGER;};
211 device_protocol_t device_protocol()
const override {
return PROTOCOL_PROXY; };
216 void lock(
void)
override;
217 void unlock(
void)
override;
218 bool try_lock(
void)
override;
274 const bool &need_additional_txkeys,
const std::vector<crypto::secret_key> &additional_tx_keys,
275 std::vector<crypto::public_key> &additional_tx_public_keys,
276 std::vector<rct::key> &amount_keys,
291 bool close_tx(
void)
override;
296 #ifdef DEBUG_HWDEVICE 301 #endif //WITH_DEVICE_LEDGER const char * res
Definition: hmac_keccak.cpp:42
void derivation_to_scalar(const key_derivation &derivation, size_t output_index, ec_scalar &res)
Definition: crypto.h:239
static int init(int argc, char **argv, struct runtime_vars *v)
Definition: miniupnpd.c:1149
static const key H
Definition: rctTypes.h:633
void derive_secret_key(const key_derivation &derivation, std::size_t output_index, const secret_key &base, secret_key &derived_key)
Definition: crypto.h:242
def release
Definition: support.py:307
enum upnpconfigoptions id
Definition: options.c:29
::std::string string
Definition: gtest-port.h:1097
POD_CLASS key_derivation
Definition: crypto.h:88
void scalarmultKey(key &aP, const key &P, const key &a)
Definition: rctOps.cpp:368
bool generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key, const cryptonote::tx_destination_entry &dst_entr, const boost::optional< cryptonote::account_public_address > &change_addr, const size_t output_index, const bool &need_additional_txkeys, const std::vector< crypto::secret_key > &additional_tx_keys, std::vector< crypto::public_key > &additional_tx_public_keys, std::vector< rct::key > &amount_keys, crypto::public_key &out_eph_public_key, const bool use_view_tags, crypto::view_tag &view_tag)
std::string data
Definition: base58.cpp:37
const char * key
Definition: hmac_keccak.cpp:40
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:72
void register_all(std::map< std::string, std::unique_ptr< device >> ®istry)
Definition: device_ledger.cpp:2372
const char * s
Definition: minissdp.c:596
POD_CLASS view_tag
Definition: crypto.h:103
Definition: rctTypes.h:140
unsigned char uint8_t
Definition: stdint.h:124
void ecdhEncode(ecdhTuple &unmasked, const key &sharedSec, bool v2)
Definition: rctOps.cpp:698
struct hash_func hashes[]
key genCommitmentMask(const key &sk)
Definition: rctOps.cpp:688
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
Definition: crypto.h:232
Definition: minissdpd.c:75
std::vector< key > keyV
Definition: rctTypes.h:89
Definition: cryptonote_basic.h:170
void generate_tx_proof(const hash &prefix_hash, const public_key &R, const public_key &A, const boost::optional< public_key > &B, const public_key &D, const secret_key &r, signature &sig)
Definition: crypto.h:263
constexpr uint32_t B
Definition: jit_compiler_a64.cpp:38
static void add(ge_p3 &p3, const ge_cached &other)
Definition: multiexp.cc:144
Definition: chaingen.h:294
unsigned int uint32_t
Definition: stdint.h:126
cryptonote::simple_wallet sw
Definition: simplewallet.cpp:95
void get_transaction_prefix_hash(const transaction_prefix &tx, crypto::hash &h, hw::device &hwdev)
Definition: cryptonote_format_utils.cpp:131
POD_CLASS ec_scalar
Definition: crypto.h:59
static void log()
Definition: logging.cpp:81
bool derive_subaddress_public_key(const public_key &out_key, const key_derivation &derivation, std::size_t output_index, public_key &result)
Definition: crypto.h:246
void derive_view_tag(const key_derivation &derivation, std::size_t output_index, view_tag &vt)
Definition: crypto.h:312
std::vector< ctkey > ctkeyV
Definition: rctTypes.h:109
Definition: rctTypes.h:79
unsigned __int64 uint64_t
Definition: stdint.h:136
Definition: subaddress_index.h:38
secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key &recovery_key=secret_key(), bool recover=false)
Definition: crypto.h:210
Definition: device.cpp:38
Definition: device.hpp:87
static crypto::key_image generate_key_image()
Definition: ringdb.cpp:55
POD_CLASS public_key
Definition: crypto.h:61
enum modes mode
Definition: minihttptestserver.c:268
crypto::secret_key spendkey
Definition: cold-outputs.cpp:44
void ecdhDecode(ecdhTuple &masked, const key &sharedSec, bool v2)
Definition: rctOps.cpp:713
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
r
Definition: testupnpigd.py:61
void scalarmultBase(key &aG, const key &a)
Definition: rctOps.cpp:350
POD_CLASS signature
Definition: crypto.h:98
Definition: cryptonote_basic.h:511
POD_CLASS hash8
Definition: hash.h:52
POD_CLASS key_image
Definition: crypto.h:92
Matcher< T > A()
Definition: gmock-matchers.h:3732
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
Definition: crypto.h:235
int bool
Definition: stdbool.h:35
cryptonote::transaction tx
Definition: transaction.cpp:40
Definition: cryptonote_tx_utils.h:74
p
Definition: pymoduletest.py:75
static crypto::chacha_key generate_chacha_key()
Definition: ringdb.cpp:47
POD_CLASS hash
Definition: hash.h:49
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
Definition: crypto.h:222
const char * name
Definition: options.c:30
static uint64_t h
Definition: blockchain_stats.cpp:55
c
Definition: pymoduletest.py:79
cryptonote::block b
Definition: block.cpp:40
int rows
Definition: crypto.h:76