Build: resolve merge conflicts

release-v0.2.1.0
wowario 6 years ago
parent f2e6a11703
commit 269bfca622
No known key found for this signature in database
GPG Key ID: 24DCBE762DE9C111

2
.gitmodules vendored

@ -5,5 +5,5 @@
branch = monero
[submodule "external/miniupnp"]
path = external/miniupnp
url = https://github.com/anonimal/miniupnp
url = https://github.com/monero-project/miniupnp
branch = monero

@ -39,27 +39,13 @@ find_package(Miniupnpc REQUIRED)
message(STATUS "Using in-tree miniupnpc")
set(UPNP_STATIC false PARENT_SCOPE)
set(UPNP_INCLUDE ${MINIUPNP_INCLUDE_DIR} PARENT_SCOPE)
set(UPNP_LIBRARIES ${MINIUPNP_LIBRARY} PARENT_SCOPE)
else()
if(STATIC)
message(STATUS "Using miniupnpc from local source tree for static build")
else()
message(STATUS "Using miniupnpc from local source tree (/external/miniupnp/miniupnpc)")
endif()
add_subdirectory(miniupnp/miniupnpc)
set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external")
if(MSVC)
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267")
elseif(NOT MSVC)
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
endif()
add_subdirectory(miniupnp/miniupnpc)
set(UPNP_STATIC true PARENT_SCOPE)
set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external")
if(MSVC)
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267")
elseif(NOT MSVC)
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
endif()
set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)

@ -78,6 +78,7 @@ namespace hw {
return false;
}
class device {
protected:
std::string name;
@ -89,10 +90,12 @@ namespace hw {
virtual ~device() {}
explicit virtual operator bool() const = 0;
static const int SIGNATURE_REAL = 0;
static const int SIGNATURE_FAKE = 1;
enum device_mode {
NONE,
TRANSACTION_CREATE_REAL,
TRANSACTION_CREATE_FAKE,
TRANSACTION_PARSE
};
/* ======================================================================= */
/* SETUP/TEARDOWN */
@ -106,6 +109,9 @@ namespace hw {
virtual bool connect(void) = 0;
virtual bool disconnect(void) = 0;
virtual bool set_mode(device_mode mode) = 0;
/* ======================================================================= */
/* LOCKER */
/* ======================================================================= */
@ -198,4 +204,3 @@ namespace hw {
device& get_device(const std::string device_descriptor) ;
}

@ -82,6 +82,9 @@ namespace hw {
dfns();
}
bool device_default::set_mode(device_mode mode) {
return true;
}
/* ======================================================================= */
/* LOCKER */

@ -93,7 +93,7 @@ namespace hw {
bool sc_secret_add(crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b) override;
crypto::secret_key generate_keys(crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false) override;
bool generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) override;
bool conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations);
bool conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations) override;
bool derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) override;
bool derive_secret_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::secret_key &sec, crypto::secret_key &derived_sec) override;
bool derive_public_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &pub, crypto::public_key &derived_pub) override;

@ -135,6 +135,10 @@ namespace hw {
return sec == crypto::null_skey;
}
bool operator==(const crypto::key_derivation &d0, const crypto::key_derivation &d1) {
return !memcmp(&d0, &d1, sizeof(d0));
}
/* ===================================================================== */
/* === Device ==== */
/* ===================================================================== */
@ -511,12 +515,13 @@ namespace hw {
return true;
}
bool device_ledger::get_secret_keys(crypto::secret_key &viewkey , crypto::secret_key &spendkey) {
bool device_ledger::get_secret_keys(crypto::secret_key &vkey , crypto::secret_key &skey) {
AUTO_LOCK_CMD();
memset(viewkey.data, 0x00, 32);
memset(spendkey.data, 0xFF, 32);
#ifdef DEBUG_HWDEVICE
//secret key are represented as fake key on the wallet side
memset(vkey.data, 0x00, 32);
memset(skey.data, 0xFF, 32);
//spcialkey, normal conf handled in decrypt
int offset;
reset_buffer();
@ -535,12 +540,22 @@ namespace hw {
this->length_send = offset;
this->exchange();
//clear key
memmove(ledger::viewkey.data, this->buffer_recv+64, 32);
memmove(ledger::spendkey.data, this->buffer_recv+96, 32);
//View key is retrievied, if allowed, to speed up blockchain parsing
memmove(this->viewkey.data, this->buffer_recv+0, 32);
if (is_fake_view_key(this->viewkey)) {
MDEBUG("Have Not view key");
this->has_view_key = false;
} else {
MDEBUG("Have view key");
this->has_view_key = true;
}
#ifdef DEBUG_HWDEVICE
memmove(dbg_viewkey.data, this->buffer_recv+0, 32);
memmove(dbg_spendkey.data, this->buffer_recv+32, 32);
#endif
#endif
return true;
return true;
}
bool device_ledger::generate_chacha_key(const cryptonote::account_keys &keys, crypto::chacha_key &key) {
@ -585,8 +600,6 @@ namespace hw {
bool device_ledger::derive_subaddress_public_key(const crypto::public_key &pub, const crypto::key_derivation &derivation, const std::size_t output_index, crypto::public_key &derived_pub){
AUTO_LOCK_CMD();
int offset;
#ifdef DEBUG_HWDEVICE
const crypto::public_key pub_x = pub;
crypto::key_derivation derivation_x;
@ -643,10 +656,10 @@ namespace hw {
//pub key
memmove(derived_pub.data, &this->buffer_recv[0], 32);
#ifdef DEBUG_HWDEVICE
hw::ledger::check32("derive_subaddress_public_key", "derived_pub", derived_pub_x.data, derived_pub.data);
#endif
}
#ifdef DEBUG_HWDEVICE
hw::ledger::check32("derive_subaddress_public_key", "derived_pub", derived_pub_x.data, derived_pub.data);
#endif
return true;
}
@ -1033,7 +1046,7 @@ namespace hw {
bool device_ledger::generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) {
AUTO_LOCK_CMD();
int offset;
bool r = false;
#ifdef DEBUG_HWDEVICE
const crypto::public_key pub_x = pub;
@ -1080,16 +1093,39 @@ namespace hw {
//derivattion data
memmove(derivation.data, &this->buffer_recv[0], 32);
r = true;
}
#ifdef DEBUG_HWDEVICE
crypto::key_derivation derivation_clear ;
if ((this->mode == TRANSACTION_PARSE) && has_view_key) {
derivation_clear = derivation;
}else {
derivation_clear = hw::ledger::decrypt(derivation);
}
hw::ledger::check32("generate_key_derivation", "derivation", derivation_x.data, derivation_clear.data);
#endif
#ifdef DEBUG_HWDEVICE
crypto::key_derivation derivation_clear = hw::ledger::decrypt(derivation);
hw::ledger::check32("generate_key_derivation", "derivation", derivation_x.data, derivation_clear.data);
#endif
return true;
return r;
}
bool device_ledger::conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations) {
const crypto::public_key *pkey=NULL;
if (derivation == main_derivation) {
pkey = &tx_pub_key;
MDEBUG("conceal derivation with main tx pub key");
} else {
for(size_t n=0; n < additional_derivations.size();++n) {
if(derivation == additional_derivations[n]) {
pkey = &additional_tx_pub_keys[n];
MDEBUG("conceal derivation with additionnal tx pub key");
break;
}
}
}
ASSERT_X(pkey, "Mismatched derivation on scan info");
return this->generate_key_derivation(*pkey, crypto::null_skey, derivation);
}
bool device_ledger::derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) {
AUTO_LOCK_CMD();
int offset;
@ -1375,32 +1411,6 @@ namespace hw {
return true;
}
bool device_ledger::set_signature_mode(unsigned int sig_mode) {
AUTO_LOCK_CMD();
int offset ;
reset_buffer();
this->buffer_send[0] = 0x00;
this->buffer_send[1] = INS_SET_SIGNATURE_MODE;
this->buffer_send[2] = 0x01;
this->buffer_send[3] = 0x00;
this->buffer_send[4] = 0x00;
offset = 5;
//options
this->buffer_send[offset] = 0x00;
offset += 1;
//account
this->buffer_send[offset] = sig_mode;
offset += 1;
this->buffer_send[4] = offset-5;
this->length_send = offset;
this->exchange();
return true;
}
bool device_ledger::encrypt_payment_id(crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key) {
AUTO_LOCK_CMD();
int offset;

@ -39,6 +39,7 @@
#else
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
#endif
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
@ -138,6 +139,7 @@ namespace hw {
bool connect(void) override;
bool disconnect() override;
bool set_mode(device_mode mode) override;
/* ======================================================================= */
/* LOCKER */
@ -172,7 +174,7 @@ namespace hw {
bool sc_secret_add(crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b) override;
crypto::secret_key generate_keys(crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false) override;
bool generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) override;
bool conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations);
bool conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations) override;
bool derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) override;
bool derive_secret_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::secret_key &sec, crypto::secret_key &derived_sec) override;
bool derive_public_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &pub, crypto::public_key &derived_pub) override;

@ -1,3 +1,4 @@
// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.

@ -49,16 +49,9 @@
#include "storages/levin_abstract_invoke2.h"
#include "cryptonote_core/cryptonote_core.h"
// We have to look for miniupnpc headers in different places, dependent on if its compiled or external
#ifdef UPNP_STATIC
#include <miniupnp/miniupnpc/miniupnpc.h>
#include <miniupnp/miniupnpc/upnpcommands.h>
#include <miniupnp/miniupnpc/upnperrors.h>
#else
#include "miniupnpc.h"
#include "upnpcommands.h"
#include "upnperrors.h"
#endif
#include <miniupnp/miniupnpc/miniupnpc.h>
#include <miniupnp/miniupnpc/upnpcommands.h>
#include <miniupnp/miniupnpc/upnperrors.h>
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.p2p"

Loading…
Cancel
Save