├── .gitignore
├── .gitmodules
├── .travis.yml
├── CMakeLists.txt
├── COPYING
├── README.md
├── VERSION
├── build.sh
├── cert
└── readme.txt
├── cmake
├── Platform-lin32.cmake
├── Platform-lin64.cmake
├── Platform-mac64.cmake
├── Platform-win32.cmake
├── Platform-win64.cmake
└── modules
│ ├── Findjsoncpp.cmake
│ └── Findlibmicrohttpd.cmake
├── release
├── linux
│ ├── .gitignore
│ ├── Dockerfile
│ ├── Makefile
│ ├── dpkg-sig
│ ├── fpm.after-install.sh
│ ├── fpm.before-install.sh
│ ├── fpm.before-remove.sh
│ ├── release.sh
│ ├── trezor.rules
│ ├── trezord.init
│ └── trezord.service
├── mac
│ ├── Dockerfile
│ ├── Makefile
│ ├── dist
│ │ └── Library
│ │ │ └── LaunchAgents
│ │ │ └── com.bitcointrezor.trezorBridge.trezord.plist
│ ├── installer
│ │ ├── TREZOR Bridge.pkgproj
│ │ └── after-install.sh
│ └── release.sh
└── windows
│ ├── .gitignore
│ ├── Dockerfile
│ ├── Makefile
│ ├── release.sh
│ └── trezord.nsis
├── src
├── config
│ ├── config.pb.cc
│ ├── config.pb.h
│ └── keys.h
├── core.hpp
├── crypto.hpp
├── glibc_compat.c
├── hid.hpp
├── http_api.hpp
├── http_client.hpp
├── http_server.hpp
├── main.cpp
├── protobuf
│ ├── json_codec.hpp
│ ├── state.hpp
│ └── wire_codec.hpp
├── trezord.ico
├── trezord.rc
├── utils.hpp
└── wire.hpp
├── tarball.sh
├── test
├── fixtures
│ ├── messages.hpp
│ ├── messages.py
│ ├── messages.txt
│ └── trezor.bin
├── functional
│ ├── .gitignore
│ ├── call_initialize.json
│ └── test.sh
└── protobuf_codecs.cpp
└── vendor
├── easyloggingpp
└── easylogging++.h
└── hidapi
├── AUTHORS.txt
├── CMakeLists.txt
├── LICENSE-bsd.txt
├── LICENSE-gpl3.txt
├── LICENSE-orig.txt
├── LICENSE.txt
├── README.txt
├── hidapi
└── hidapi.h
├── libusb
├── CMakeLists.txt
└── hid.c
├── mac
├── CMakeLists.txt
└── hid.c
└── windows
├── CMakeLists.txt
└── hid.c
/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | build-*/
3 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "vendor/jsoncpp"]
2 | path = vendor/jsoncpp
3 | url = https://github.com/open-source-parsers/jsoncpp.git
4 | [submodule "vendor/trezor-crypto"]
5 | path = vendor/trezor-crypto
6 | url = https://github.com/trezor/trezor-crypto.git
7 | [submodule "vendor/macdylibbundler"]
8 | path = vendor/macdylibbundler
9 | url = https://github.com/jpochyla/macdylibbundler.git
10 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | dist: trusty
3 | language: c
4 |
5 | before_install:
6 | - sudo add-apt-repository -y ppa:ondrej/pkg-nlnetlabs
7 | - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
8 | - sudo apt-get update -q
9 | - sudo apt-get install -y gcc-5 g++-5
10 | - sudo apt-get install -y libprotobuf-dev
11 |
12 | install:
13 | - export CXX="g++-5" CC="gcc-5"
14 |
15 | addons:
16 | apt:
17 | packages:
18 | - libboost-all-dev
19 | - libmicrohttpd-dev
20 | - libusb-1.0-0-dev
21 |
22 | script:
23 | - ./build.sh
24 |
25 | notifications:
26 | webhooks:
27 | urls:
28 | - http://ci-bot.satoshilabs.com:5000/travis
29 | on_success: always
30 | on_failure: always
31 | on_start: always
32 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #
2 | # CMake build file for trezord
3 | #
4 |
5 | cmake_minimum_required(VERSION 2.8)
6 |
7 | project(trezord)
8 |
9 | file (STRINGS "VERSION" VERSION)
10 |
11 | option(BUILD_TESTS "Build tests?" off)
12 |
13 | include_directories(src)
14 |
15 | set (SRCS
16 | src/main.cpp
17 | src/http_api.hpp
18 | src/http_server.hpp
19 | src/http_client.hpp
20 | src/core.hpp
21 | src/wire.hpp
22 | src/utils.hpp
23 | src/protobuf/state.hpp
24 | src/protobuf/json_codec.hpp
25 | src/protobuf/wire_codec.hpp
26 | src/config/config.pb.cc
27 | src/config/config.pb.h)
28 |
29 | if (WIN32)
30 | set (SRCS src/trezord.rc ${SRCS})
31 | endif(WIN32)
32 |
33 | IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
34 | SET(FREEBSD TRUE)
35 | ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
36 |
37 | if (UNIX AND NOT APPLE AND NOT FREEBSD)
38 | set (SRCS src/glibc_compat.c ${SRCS})
39 | endif(UNIX AND NOT APPLE)
40 |
41 | add_executable(trezord ${SRCS})
42 |
43 | # use c++11, add version macro
44 | set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} -DVERSION='\"${VERSION}\"'")
45 |
46 | # use vendored cmake modules
47 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
48 |
49 | if (WIN32)
50 | set(OS_LIBRARIES wsock32 ws2_32 z)
51 | add_definitions(-D_WIN32_WINNT=0x6000)
52 | else(WIN32)
53 | if (APPLE)
54 | set(OS_LIBRARIES pthread)
55 | elseif(FREEBSD)
56 | set(OS_LIBRARIES pthread z)
57 | else(APPLE)
58 | set(OS_LIBRARIES pthread dl z)
59 | endif(APPLE)
60 | endif(WIN32)
61 |
62 | target_link_libraries(trezord ${OS_LIBRARIES})
63 |
64 | # add dynamic libs
65 | find_package(CURL REQUIRED)
66 | find_package(libmicrohttpd REQUIRED)
67 |
68 | # add static libs
69 | if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
70 | set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
71 | set(BUILD_SHARED_LIBS off)
72 | set(Boost_USE_STATIC_LIBS on)
73 | set(CMAKE_FIND_STATIC FIRST)
74 | endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
75 | find_package(Boost 1.53.0 REQUIRED
76 | regex thread system unit_test_framework program_options chrono)
77 | find_package(Protobuf 2.5.0 REQUIRED)
78 | find_package(jsoncpp REQUIRED)
79 |
80 | # add vendored libs
81 | add_subdirectory(vendor/hidapi)
82 | add_subdirectory(vendor/trezor-crypto)
83 |
84 | include_directories(
85 | ${Boost_INCLUDE_DIRS}
86 | ${LIBMICROHTTPD_INCLUDE_DIRS}
87 | ${PROTOBUF_INCLUDE_DIRS}
88 | ${JSONCPP_INCLUDE_DIRS}
89 | ${CURL_INCLUDE_DIRS}
90 | vendor/hidapi/hidapi
91 | vendor/trezor-crypto
92 | vendor/easyloggingpp)
93 |
94 | target_link_libraries(trezord
95 | ${Boost_LIBRARIES}
96 | ${LIBMICROHTTPD_LIBRARIES}
97 | ${CURL_LIBRARIES}
98 | ${PROTOBUF_LIBRARIES}
99 | ${JSONCPP_LIBRARIES}
100 | hidapi
101 | TrezorCrypto)
102 |
103 | if(BUILD_TESTS)
104 |
105 | include_directories(test)
106 |
107 | add_executable(test-protobuf_codecs test/protobuf_codecs.cpp)
108 |
109 | target_link_libraries(test-protobuf_codecs
110 | ${Boost_LIBRARIES}
111 | ${PROTOBUF_LIBRARIES}
112 | ${JSONCPP_LIBRARIES})
113 |
114 | enable_testing()
115 | add_test(ProtobufCodecs test-protobuf_codecs)
116 |
117 | endif(BUILD_TESTS)
118 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # trezord
2 |
3 | [](https://travis-ci.org/trezor/trezord) [](https://gitter.im/trezor/community)
4 |
5 | TREZOR Communication Daemon aka TREZOR Bridge
6 |
7 | **DO NOT USE! This version has been obsoleted by a new generation of TREZOR Bridge available from here: [trezor/trezord-go](https://github.com/trezor/trezord-go)**
8 |
9 | ## What trezord does
10 |
11 | `trezord` (short for TREZOR Daemon), or TREZOR Bridge, is a small piece of software, used for websites (such as our own [TREZOR Wallet](https://wallet.trezor.io)), to talk with TREZOR devices.
12 |
13 | `trezord` starts a local webserver, with which both external applications and local applications can communicate. This webserver then communicates with TREZOR devices and returns their replies as JSON. `trezord` also manages access to devices - two applications cannot use the same device at the same time.
14 |
15 | Communicating with devices using `trezord` is more high-level than communicating with devices directly - `trezord` abstracts away USB communication, Protobuf serialization and platform differences. However, you still need to process individual messages.
16 |
17 | **For development of web apps for TREZOR, it is recommended to use [trezor.js](https://github.com/trezor/trezor.js) javascript API, which has separate javascript calls for most common usecases; or [TREZOR Connect](https://github.com/trezor/connect), which is even more high level.** (`trezor.js` communicates with `trezord` under the hood.)
18 |
19 | ## API documentation
20 |
21 | `trezord` starts server on `localhost`, with port `21324`. You can use `https`, by using `https://localback.net:21324` which redirects to localhost. You can call this web address with standard AJAX calls from websites (see the note about whitelisting).
22 |
23 | Server supports following API calls:
24 |
25 | | url
method | parameters | result type | description |
26 | |-------------|------------|-------------|-------------|
27 | | `/`
GET | | {`version`: string,
`configured`: boolean,
`validUntil`: timestamp} | Returns current version of bridge and info about configuration.
See `/configure` for more info. |
28 | | `/configure`
POST | request body: config, as hex string | {} | Before any advanced call, configuration file needs to be loaded to bridge.
Configuration file is signed by SatoshiLabs and the validity of the signature is limited.
Current config should be [in this repo](https://github.com/trezor/webwallet-data/blob/master/config_signed.bin), or [on AWS here](https://wallet.trezor.io/data/config_signed.bin). |
29 | | `/enumerate`
GET | | Array<{`path`: string,
`session`: string | null}> | Lists devices.
`path` uniquely defines device between more connected devices. It might or might not be unique over time; on some platform it changes, on others given USB port always returns the same path.
If `session` is null, nobody else is using the device; if it's string, it identifies who is using it. |
30 | | `/listen`
POST | request body: previous, as JSON | like `enumerate` | Listen to changes and returns either on change or after 30 second timeout. Compares change from `previous` that is sent as a parameter. "Change" is both connecting/disconnecting and session change. |
31 | | `/acquire/PATH/PREVIOUS`
POST | `PATH`: path of device
`PREVNOUS`: previous session (or string "null") | {`session`: string} | Acquires the device at `PATH`. By "acquiring" the device, you are claiming the device for yourself.
Before acquiring, checks that the current session is `PREVIOUS`.
If two applications call `acquire` on a newly connected device at the same time, only one of them succeed. |
32 | | `/release/SESSION`
POST | `SESSION`: session to release | {} | Releases the device with the given session.
By "releasing" the device, you claim that you don't want to use the device anymore. |
33 | | `/call/SESSION`
POST | `SESSION`: session to call
request body: JSON
{`type`: string, `message`: object} | {`type`: string, `body`: object} | Calls the message and returns the response from TREZOR.
Messages are defined in [this protobuf file](https://github.com/trezor/trezor-common/blob/master/protob/messages.proto).
`type` in request is, for example, `GetFeatures`; `type` in response is, for example, `Features` |
34 |
35 | ### Whitelisting
36 |
37 | You cannot connect to `trezord` from anywhere on the internet. Your URL needs to be specifically whitelisted; whitelist is in the signed config file, that is sent during `configure/` call.
38 |
39 | `localhost` is specifically whitelisted, so you can experiment on `http://localhost`. If you want to add your url in order to make a TREZOR web app, [make a pull request to this file](https://github.com/trezor/trezor-common/blob/master/signer/config.json).
40 |
41 | ## Download latest binary
42 |
43 | Latest build packages are on https://wallet.trezor.io/data/bridge/latest/index.html
44 |
45 | ## Checking out sources
46 |
47 | ```
48 | git clone https://github.com/trezor/trezord.git
49 | cd trezord
50 | git submodule update --init
51 | ```
52 |
53 | ## Building
54 |
55 | Change into `release/linux` or `release/windows` directory and run: `make`.
56 |
57 | Or run `build.sh` to build locally using local dependencies.
58 |
59 | In the latter case, here is a rough list of Debian package build dependencies:
60 |
61 | `build-essential cmake curl libcurl4-gnutls-dev libprotobuf-dev pkg-config libusb-1.0-0 libusb-1.0-0-dev libmicrohttpd-dev libboost-all-dev protobuf-compiler`
62 |
63 | or Fedora (as of 26) build dependencies:
64 |
65 | `boost-devel-static protobuf-compiler cmake gcc-c++ libcurl-devel protobuf-devel libusbx-devel libmicrohttpd-devel protobuf-static`
66 |
67 | Also you might need to regenerate protobuf files if you are using protobuf-3.x:
68 |
69 | ```
70 | cd src/config
71 | wget https://raw.githubusercontent.com/trezor/trezor-common/master/protob/config.proto
72 | protoc -I/usr/include -I. --cpp_out=. config.proto
73 | ```
74 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | 1.2.1
2 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | cd $(dirname $0)
6 |
7 | TARGET=$1
8 | BUILDDIR=build${TARGET:+-$TARGET}
9 | BUILDTYPE=${2-Debug}
10 |
11 | case "$TARGET" in
12 | lin32 | lin64 | win32 | win64 | mac64 ) # cross build
13 | PLATFORM_FILE="-C $(pwd)/cmake/Platform-$TARGET.cmake"
14 | ;;
15 | * ) # native build
16 | JOBS="-j 4"
17 | ;;
18 | esac
19 |
20 | # Compile jsoncpp
21 | if [ \! -f $BUILDDIR/lib/jsoncpp/lib/libjson.a ]; then
22 | mkdir -p $BUILDDIR/lib/jsoncpp && cd $BUILDDIR/lib/jsoncpp
23 | cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE -DJSONCPP_WITH_TESTS=OFF $PLATFORM_FILE ../../../vendor/jsoncpp
24 | make $JOBS
25 | cd ../../..
26 | fi
27 |
28 | mkdir -p $BUILDDIR && cd $BUILDDIR
29 | cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE $PLATFORM_FILE ..
30 | make $JOBS
31 |
--------------------------------------------------------------------------------
/cert/readme.txt:
--------------------------------------------------------------------------------
1 | certs are in webwallet-data repository in /bridge/cert directory
2 |
--------------------------------------------------------------------------------
/cmake/Platform-lin32.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_C_FLAGS "-m32" CACHE STRING "")
2 | set(CMAKE_CXX_FLAGS "-m32" CACHE STRING "")
3 | set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,--wrap=memcpy -Wl,--wrap=secure_getenv" CACHE STRING "")
4 |
--------------------------------------------------------------------------------
/cmake/Platform-lin64.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,--wrap=memcpy -Wl,--wrap=secure_getenv" CACHE STRING "")
2 |
--------------------------------------------------------------------------------
/cmake/Platform-mac64.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_SYSTEM_NAME "Darwin" CACHE STRING "")
2 | set(CMAKE_SYSTEM_VERSION "10.8" CACHE STRING "")
3 | set(TARGET_ARCH "x86_64" CACHE STRING "")
4 |
5 | set(CMAKE_C_COMPILER "o64-gcc" CACHE STRING "")
6 | set(CMAKE_CXX_COMPILER "o64-g++" CACHE STRING "")
7 | set(CMAKE_AR "x86_64-apple-darwin12-ar" CACHE STRING "")
8 | set(CMAKE_RANLIB "x86_64-apple-darwin12-ranlib" CACHE STRING "")
9 | set(PKG_CONFIG_EXECUTABLE "x86_64-apple-darwin12-pkg-config" CACHE STRING "")
10 | set(CMAKE_CXX_FLAGS "-v" CACHE STRING "")
11 |
12 | set(CMAKE_OSX_SYSROOT "/opt/osxcross/target/SDK/MacOSX10.8.sdk" CACHE STRING "")
13 | set(CMAKE_FIND_ROOT_PATH "/opt/osxcross/target/macports/pkgs/opt/local" CACHE STRING "")
14 |
15 | include_directories("/opt/osxcross/target/macports/pkgs/opt/local/include")
16 | link_directories("/opt/osxcross/target/macports/pkgs/opt/local/lib")
17 |
--------------------------------------------------------------------------------
/cmake/Platform-win32.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_SYSTEM_NAME "Windows" CACHE STRING "")
2 | set(TARGET_ARCH "i686-w64-mingw32" CACHE STRING "")
3 | set(CMAKE_C_COMPILER "${TARGET_ARCH}-gcc" CACHE STRING "")
4 | set(CMAKE_CXX_COMPILER "${TARGET_ARCH}-g++" CACHE STRING "")
5 | set(CMAKE_RC_COMPILER_INIT "${TARGET_ARCH}-windres" CACHE STRING "")
6 | set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" CACHE STRING "")
7 | set(CMAKE_FIND_ROOT_PATH "/usr/${TARGET_ARCH}/sys-root/mingw" CACHE STRING "")
8 | set(CMAKE_EXE_LINKER_FLAGS "-mwindows" CACHE STRING "")
9 |
--------------------------------------------------------------------------------
/cmake/Platform-win64.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_SYSTEM_NAME "Windows" CACHE STRING "")
2 | set(TARGET_ARCH "x86_64-w64-mingw32" CACHE STRING "")
3 | set(CMAKE_C_COMPILER "${TARGET_ARCH}-gcc" CACHE STRING "")
4 | set(CMAKE_CXX_COMPILER "${TARGET_ARCH}-g++" CACHE STRING "")
5 | set(CMAKE_RC_COMPILER_INIT "${TARGET_ARCH}-windres" CACHE STRING "")
6 | set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" CACHE STRING "")
7 | set(CMAKE_FIND_ROOT_PATH "/usr/${TARGET_ARCH}/sys-root/mingw" CACHE STRING "")
8 | set(CMAKE_EXE_LINKER_FLAGS "-mwindows" CACHE STRING "")
9 |
--------------------------------------------------------------------------------
/cmake/modules/Findjsoncpp.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # CMake package file for jsoncpp
3 | #
4 |
5 | find_path(JSONCPP_INCLUDE_DIR json
6 | HINTS "${CMAKE_SOURCE_DIR}/vendor/jsoncpp/include")
7 | find_library(JSONCPP_LIBRARY NAMES jsoncpp
8 | HINTS "${CMAKE_BINARY_DIR}/lib/jsoncpp/src/lib_json")
9 |
10 | set(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY})
11 | set(JSONCPP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR})
12 |
13 | include(FindPackageHandleStandardArgs)
14 | find_package_handle_standard_args(JSONCPP
15 | DEFAULT_MSG JSONCPP_LIBRARY JSONCPP_INCLUDE_DIR)
16 |
--------------------------------------------------------------------------------
/cmake/modules/Findlibmicrohttpd.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find libmicrohttpd
2 | # Once done this will define
3 | #
4 | # MICROHTTPD_FOUND - system has libmicrohttpd
5 | # MICROHTTPD_INCLUDE_DIRS - the libmicrohttpd include directory
6 | # MICROHTTPD_LIBRARIES - Link these to use libmicrohttpd
7 | # MICROHTTPD_DEFINITIONS - Compiler switches required for using libmicrohttpd
8 | #
9 | # Copyright (c) 2011 Wesley Moore
10 | #
11 | # Redistribution and use is allowed according to the terms of the New
12 | # BSD license.
13 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 | #
15 |
16 |
17 | if (LIBMICROHTTPD_LIBRARIES AND LIBMICROHTTPD_INCLUDE_DIRS)
18 | # in cache already
19 | set(LIBMICROHTTPD_FOUND TRUE)
20 | else (LIBMICROHTTPD_LIBRARIES AND LIBMICROHTTPD_INCLUDE_DIRS)
21 | # use pkg-config to get the directories and then use these values
22 | # in the FIND_PATH() and FIND_LIBRARY() calls
23 | if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
24 | include(UsePkgConfig)
25 | pkgconfig(libmicrohttpd _LIBMICROHTTPD_INCLUDEDIR _LIBMICROHTTPD_LIBDIR _LIBMICROHTTPD_LDFLAGS _LIBMICROHTTPD_CFLAGS)
26 | else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
27 | find_package(PkgConfig)
28 | if (PKG_CONFIG_FOUND)
29 | pkg_check_modules(_LIBMICROHTTPD libmicrohttpd)
30 | endif (PKG_CONFIG_FOUND)
31 | endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
32 | find_path(LIBMICROHTTPD_INCLUDE_DIR
33 | NAMES
34 | microhttpd.h
35 | PATHS
36 | ${_LIBMICROHTTPD_INCLUDEDIR}
37 | /usr/include
38 | /usr/local/include
39 | /usr/pkg/include
40 | /opt/local/include
41 | /sw/include
42 | )
43 |
44 | find_library(LIBMICROHTTPD_LIBRARY
45 | NAMES
46 | microhttpd
47 | PATHS
48 | ${_LIBMICROHTTPD_LIBDIR}
49 | /usr/lib
50 | /usr/local/lib
51 | /usr/pkg/lib
52 | /opt/local/lib
53 | /sw/lib
54 | )
55 |
56 | if (LIBMICROHTTPD_LIBRARY)
57 | set(LIBMICROHTTPD_FOUND TRUE)
58 | endif (LIBMICROHTTPD_LIBRARY)
59 |
60 | set(LIBMICROHTTPD_INCLUDE_DIRS
61 | ${LIBMICROHTTPD_INCLUDE_DIR}
62 | )
63 |
64 | if (LIBMICROHTTPD_FOUND)
65 | set(LIBMICROHTTPD_LIBRARIES
66 | ${LIBMICROHTTPD_LIBRARIES}
67 | ${LIBMICROHTTPD_LIBRARY}
68 | )
69 | endif (LIBMICROHTTPD_FOUND)
70 |
71 | if (LIBMICROHTTPD_INCLUDE_DIRS AND LIBMICROHTTPD_LIBRARIES)
72 | set(LIBMICROHTTPD_FOUND TRUE)
73 | endif (LIBMICROHTTPD_INCLUDE_DIRS AND LIBMICROHTTPD_LIBRARIES)
74 |
75 | if (LIBMICROHTTPD_FOUND)
76 | if (NOT LIBMICROHTTPD_FIND_QUIETLY)
77 | message(STATUS "Found libmicrohttpd: ${LIBMICROHTTPD_LIBRARIES}")
78 | endif (NOT LIBMICROHTTPD_FIND_QUIETLY)
79 | else (LIBMICROHTTPD_FOUND)
80 | if (LIBMICROHTTPD_FIND_REQUIRED)
81 | message(FATAL_ERROR "Could not find libmicrohttpd")
82 | endif (LIBMICROHTTPD_FIND_REQUIRED)
83 | endif (LIBMICROHTTPD_FOUND)
84 |
85 | # show the LIBMICROHTTPD_INCLUDE_DIRS and LIBMICROHTTPD_LIBRARIES variables only in the advanced view
86 | mark_as_advanced(LIBMICROHTTPD_INCLUDE_DIRS LIBMICROHTTPD_LIBRARIES)
87 |
88 | endif (LIBMICROHTTPD_LIBRARIES AND LIBMICROHTTPD_INCLUDE_DIRS)
89 |
90 |
--------------------------------------------------------------------------------
/release/linux/.gitignore:
--------------------------------------------------------------------------------
1 | privkey.asc
2 |
--------------------------------------------------------------------------------
/release/linux/Dockerfile:
--------------------------------------------------------------------------------
1 | # initialize from the image
2 |
3 | FROM fedora:25
4 |
5 | # update package repositories
6 |
7 | RUN dnf update -y
8 |
9 | # install tools
10 |
11 | RUN dnf install -y cmake make wget
12 | RUN dnf install -y gcc gcc-c++ git make patchutils pkgconfig wget
13 |
14 | # install dependencies for Linux packaging
15 |
16 | RUN dnf install -y ruby-devel rubygems rpm-build
17 | RUN gem install fpm --no-document
18 |
19 | # install dependencies for Linux build
20 |
21 | RUN dnf install -y glibc-devel glibc-static libgcc libstdc++-static zlib-devel
22 | RUN dnf install -y boost-static libusbx-devel protobuf-static
23 |
24 | RUN dnf install -y glibc-devel.i686 glibc-static.i686 libgcc.i686 libstdc++-static.i686 zlib-devel.i686
25 | RUN dnf install -y boost-static.i686 libusbx-devel.i686 protobuf-static.i686
26 |
27 | # install used networking libraries
28 |
29 | RUN dnf install -y libcurl-devel libmicrohttpd-devel
30 | RUN dnf install -y libcurl.i686 libcurl-devel.i686 libmicrohttpd.i686 libmicrohttpd-devel.i686
31 |
32 | # install package signing tools
33 | RUN dnf install -y rpm-sign
34 | RUN ln -s gpg2 /usr/bin/gpg
35 |
--------------------------------------------------------------------------------
/release/linux/Makefile:
--------------------------------------------------------------------------------
1 | PLATFORM = linux
2 | VOL_MOUNT = -v $(shell pwd)/../..:/trezord-src
3 | IMAGETAG = trezord-build-env-$(PLATFORM)
4 |
5 | all: .package64 .package32
6 |
7 | clean:
8 | $(info Cleaning...)
9 | sudo rm -rf ../../build-lin*
10 |
11 | .package64: .binary64
12 | $(info Packaging ...)
13 | docker run -i -t $(VOL_MOUNT) $(IMAGETAG) /trezord-src/release/$(PLATFORM)/release.sh lin64
14 |
15 | .binary64: .docker-image
16 | $(info Building in docker ...)
17 | docker run -t $(VOL_MOUNT) $(IMAGETAG) /trezord-src/build.sh lin64 Release
18 |
19 | .package32: .binary32
20 | $(info Packaging ...)
21 | docker run -i -t $(VOL_MOUNT) $(IMAGETAG) /trezord-src/release/$(PLATFORM)/release.sh lin32
22 |
23 | .binary32: .docker-image
24 | $(info Building in docker ...)
25 | docker run -t $(VOL_MOUNT) $(IMAGETAG) /trezord-src/build.sh lin32 Release
26 |
27 | .docker-image:
28 | $(info Preparing docker image ...)
29 | docker build -t $(IMAGETAG) .
30 |
31 | shell: .docker-image
32 | docker run -i -t $(VOL_MOUNT) $(IMAGETAG) /bin/bash
33 |
34 | privkey:
35 | gpg --armor --export-secret-key > privkey.asc
36 |
--------------------------------------------------------------------------------
/release/linux/fpm.after-install.sh:
--------------------------------------------------------------------------------
1 | if which systemctl > /dev/null ; then
2 | systemctl enable trezord.service
3 | systemctl start trezord.service
4 | else
5 | chkconfig --add trezord || update-rc.d trezord defaults
6 | service trezord start
7 | fi
8 |
--------------------------------------------------------------------------------
/release/linux/fpm.before-install.sh:
--------------------------------------------------------------------------------
1 | getent group trezord >/dev/null || groupadd -r trezord
2 | getent passwd trezord >/dev/null || useradd -r -g trezord -d /var -s /sbin/nologin -c "TREZOR Bridge" trezord
3 | touch /var/log/trezord.log
4 | chown trezord:trezord /var/log/trezord.log
5 | chmod 660 /var/log/trezord.log
6 |
--------------------------------------------------------------------------------
/release/linux/fpm.before-remove.sh:
--------------------------------------------------------------------------------
1 | if which systemctl > /dev/null ; then
2 | systemctl stop trezord.service
3 | systemctl disable trezord.service
4 | else
5 | service trezord stop
6 | chkconfig --del trezord || update-rc.d -f trezord remove
7 | fi
8 |
--------------------------------------------------------------------------------
/release/linux/release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | cd $(dirname $0)
6 |
7 | GPGSIGNKEY=86E6792FC27BFD478860C11091F3B339B9A02A3D
8 | TARGET=$1
9 | BUILDDIR=build${TARGET:+-$TARGET}
10 | VERSION=$(cat ../../VERSION)
11 |
12 | cd ../../$BUILDDIR
13 |
14 | install -D -m 0755 trezord ./usr/bin/trezord
15 | install -D -m 0644 ../release/linux/trezor.rules ./lib/udev/rules.d/51-trezor.rules
16 | install -D -m 0755 ../release/linux/trezord.init ./etc/init.d/trezord
17 | install -D -m 0644 ../release/linux/trezord.service ./usr/lib/systemd/system/trezord.service
18 |
19 | strip ./usr/bin/trezord
20 |
21 | # prepare GPG signing environment
22 | GPG_PRIVKEY=../release/linux/privkey.asc
23 | if [ -r $GPG_PRIVKEY ]; then
24 | export GPG_TTY=$(tty)
25 | export LC_ALL=en_US.UTF-8
26 | gpg --import ../release/linux/privkey.asc
27 | GPG_SIGN=gpg
28 | fi
29 |
30 | NAME=trezor-bridge
31 |
32 | rm -f *.deb *.rpm *.tar.bz2
33 | tar -cjf $NAME-$VERSION.tar.bz2 --exclude=./lib/jsoncpp ./etc ./usr ./lib
34 |
35 | for TYPE in "deb" "rpm"; do
36 | case "$TARGET-$TYPE" in
37 | lin32-deb)
38 | ARCH=i386
39 | DEPS="-d libcurl3 -d libmicrohttpd12 -d libusb-1.0-0"
40 | ;;
41 | lin64-deb)
42 | ARCH=amd64
43 | DEPS="-d libcurl3 -d libmicrohttpd12 -d libusb-1.0-0"
44 | ;;
45 | lin32-rpm)
46 | ARCH=i386
47 | DEPS="--rpm-autoreq"
48 | ;;
49 | lin64-rpm)
50 | ARCH=x86_64
51 | DEPS="--rpm-autoreq"
52 | ;;
53 | esac
54 | fpm \
55 | -s tar \
56 | -t $TYPE \
57 | -a $ARCH \
58 | -n $NAME \
59 | -v $VERSION \
60 | --license "LGPL-3.0" \
61 | --vendor "SatoshiLabs" \
62 | --description "Communication daemon for TREZOR" \
63 | --maintainer "SatoshiLabs " \
64 | --url "https://trezor.io/" \
65 | --category "Productivity/Security" \
66 | --before-install ../release/linux/fpm.before-install.sh \
67 | --after-install ../release/linux/fpm.after-install.sh \
68 | --before-remove ../release/linux/fpm.before-remove.sh \
69 | $DEPS \
70 | $NAME-$VERSION.tar.bz2
71 | case "$TYPE-$GPG_SIGN" in
72 | deb-gpg)
73 | ../release/linux/dpkg-sig -k $GPGSIGNKEY --sign builder trezor-bridge_${VERSION}_${ARCH}.deb
74 | ;;
75 | rpm-gpg)
76 | rpm --addsign -D "%_gpg_name $GPGSIGNKEY" trezor-bridge-${VERSION}-1.${ARCH}.rpm
77 | ;;
78 | esac
79 | done
80 |
81 |
82 | rm -rf ./etc ./usr ./lib
83 |
--------------------------------------------------------------------------------
/release/linux/trezor.rules:
--------------------------------------------------------------------------------
1 | # TREZOR: The Original Hardware Wallet
2 | # https://trezor.io/
3 | # Put this file into /usr/lib/udev/rules.d
4 |
5 | # TREZOR
6 | SUBSYSTEM=="usb", ATTR{idVendor}=="534c", ATTR{idProduct}=="0001", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="trezor%n"
7 | KERNEL=="hidraw*", ATTRS{idVendor}=="534c", ATTRS{idProduct}=="0001", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
8 |
9 | # TREZOR v2
10 | SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c0", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="trezor%n"
11 | SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c1", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="trezor%n"
12 | KERNEL=="hidraw*", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="53c0", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
13 | KERNEL=="hidraw*", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="53c1", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
14 |
--------------------------------------------------------------------------------
/release/linux/trezord.init:
--------------------------------------------------------------------------------
1 | ### BEGIN INIT INFO
2 | # Provides: trezord
3 | # Required-Start: $local_fs $network $named
4 | # Required-Stop: $local_fs $network $named
5 | # Default-Start: 2 3 4 5
6 | # Default-Stop: 0 1 6
7 | # Short-Description: TREZOR Bridge
8 | # Description: This is a daemon that allows webpages to communicate
9 | # with TREZOR devices.
10 | ### END INIT INFO
11 |
12 | . /lib/lsb/init-functions
13 |
14 | NAME=trezord
15 | DAEMON=/usr/bin/trezord
16 | USER=trezord
17 |
18 | test -x $DAEMON || exit 5
19 |
20 | case $1 in
21 |
22 | start)
23 | if pidof $DAEMON > /dev/null ; then
24 | log_warning_msg "$NAME already running"
25 | exit
26 | fi
27 | if su - $USER -s /bin/sh -c $DAEMON > /dev/null ; then
28 | log_success_msg "$NAME started"
29 | else
30 | log_failure_msg "$NAME start failed"
31 | fi
32 | ;;
33 | stop)
34 | if pidof $DAEMON > /dev/null ; then
35 | if killall $DAEMON > /dev/null ; then
36 | log_success_msg "$NAME stopped"
37 | else
38 | log_failure_msg "$NAME stop failed"
39 | fi
40 | else
41 | log_warning_msg "$NAME not running"
42 | fi
43 | ;;
44 | restart)
45 | $0 stop
46 | sleep 2
47 | $0 start
48 | ;;
49 | status)
50 | if pidof $DAEMON > /dev/null ; then
51 | log_success_msg "$NAME is running"
52 | else
53 | log_success_msg "$NAME is not running"
54 | fi
55 | ;;
56 | *)
57 | echo "Usage: $0 {start|stop|restart|status}"
58 | ;;
59 | esac
60 |
--------------------------------------------------------------------------------
/release/linux/trezord.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=TREZOR Bridge
3 | After=network.target
4 |
5 | [Service]
6 | Type=simple
7 | ExecStart=/usr/bin/trezord -f
8 | User=trezord
9 |
10 | [Install]
11 | WantedBy=multi-user.target
12 |
--------------------------------------------------------------------------------
/release/mac/Dockerfile:
--------------------------------------------------------------------------------
1 | # initialize from base image
2 |
3 | FROM ubuntu:latest
4 |
5 | # install dependencies
6 |
7 | RUN apt-get update && apt-get install -y \
8 | git wget cmake \
9 | gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev
10 |
11 | # build and install osxcross and osx sdk
12 |
13 | RUN git clone https://github.com/jpochyla/osxcross.git /opt/osxcross
14 | COPY ./MacOSX10.8.sdk.tar.xz /opt/osxcross/tarballs/
15 |
16 | WORKDIR /opt/osxcross
17 |
18 | ENV MACOSX_DEPLOYMENT_TARGET 10.8
19 | ENV PATH /opt/osxcross/target/bin:$PATH
20 |
21 | RUN ./tools/get_dependencies.sh
22 | RUN echo | ./build.sh
23 | RUN echo | GCC_VERSION=4.9.1 ./build_gcc.sh
24 |
25 | # install trezord dependencies from macports
26 |
27 | RUN osxcross-macports install \
28 | gdbm-1.11 zlib-1.2.8 xz-5.2.1 libgpg-error-1.19 \
29 | protobuf-cpp-2.5.0 curl boost libmicrohttpd
30 |
31 | # make cmake and dylibbundler happy
32 |
33 | RUN mkdir /Applications
34 | RUN ln -s x86_64-apple-darwin12-otool /opt/osxcross/target/bin/otool
35 | RUN ln -s x86_64-apple-darwin12-install_name_tool /opt/osxcross/target/bin/install_name_tool
36 | RUN ln -s /opt/osxcross/target/macports/pkgs/opt/local /opt/local
37 |
--------------------------------------------------------------------------------
/release/mac/Makefile:
--------------------------------------------------------------------------------
1 | PLATFORM = mac
2 | BITS = 64
3 | TARGET = mac$(BITS)
4 | VOL_MOUNT = -v $(shell pwd)/../..:/trezord-src
5 | IMAGETAG = trezord-build-env-$(PLATFORM)
6 | SDK_FILE = MacOSX10.8.sdk.tar.xz
7 | SDK_URL = https://github.com/phracker/MacOSX-SDKs/releases/download/MacOSX10.11.sdk/MacOSX10.8.sdk.tar.xz
8 |
9 | all: .package
10 |
11 | .package: .binary
12 | $(info Packaging ...)
13 | docker run -t $(VOL_MOUNT) $(IMAGETAG) /trezord-src/release/$(PLATFORM)/release.sh $(TARGET)
14 |
15 | .binary: .docker-image
16 | $(info Building in docker ...)
17 | docker run -t $(VOL_MOUNT) $(IMAGETAG) /trezord-src/build.sh $(TARGET) Release
18 |
19 | .docker-image: $(SDK_FILE)
20 | $(info Preparing docker image ...)
21 | docker build -t $(IMAGETAG) .
22 |
23 | $(SDK_FILE):
24 | $(info Downloading OS X SDK ...)
25 | curl -o $(SDK_FILE) -L $(SDK_URL)
26 |
27 | shell: .docker-image
28 | docker run -i -t $(VOL_MOUNT) $(IMAGETAG) /bin/bash
29 |
--------------------------------------------------------------------------------
/release/mac/dist/Library/LaunchAgents/com.bitcointrezor.trezorBridge.trezord.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Label
6 | com.bitcointrezor.trezorBridge.trezord
7 |
8 | KeepAlive
9 |
10 |
11 | ProgramArguments
12 |
13 | sh
14 | -c
15 | /Applications/Utilities/TREZOR\ Bridge/trezord
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/release/mac/installer/TREZOR Bridge.pkgproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PROJECT
6 |
7 | PACKAGE_FILES
8 |
9 | DEFAULT_INSTALL_LOCATION
10 | /
11 | HIERARCHY
12 |
13 | CHILDREN
14 |
15 |
16 | CHILDREN
17 |
18 |
19 | CHILDREN
20 |
21 |
22 | CHILDREN
23 |
24 |
25 | CHILDREN
26 |
27 | GID
28 | 80
29 | PATH
30 | ../../../build-mac64/libs
31 | PATH_TYPE
32 | 1
33 | PERMISSIONS
34 | 493
35 | TYPE
36 | 3
37 | UID
38 | 0
39 |
40 |
41 | CHILDREN
42 |
43 | GID
44 | 80
45 | PATH
46 | ../../../build-mac64/trezord
47 | PATH_TYPE
48 | 1
49 | PERMISSIONS
50 | 493
51 | TYPE
52 | 3
53 | UID
54 | 0
55 |
56 |
57 | GID
58 | 80
59 | PATH
60 | TREZOR Bridge
61 | PATH_TYPE
62 | 0
63 | PERMISSIONS
64 | 493
65 | TYPE
66 | 2
67 | UID
68 | 0
69 |
70 |
71 | GID
72 | 80
73 | PATH
74 | Utilities
75 | PATH_TYPE
76 | 0
77 | PERMISSIONS
78 | 493
79 | TYPE
80 | 1
81 | UID
82 | 0
83 |
84 |
85 | GID
86 | 80
87 | PATH
88 | Applications
89 | PATH_TYPE
90 | 0
91 | PERMISSIONS
92 | 509
93 | TYPE
94 | 1
95 | UID
96 | 0
97 |
98 |
99 | CHILDREN
100 |
101 |
102 | CHILDREN
103 |
104 | GID
105 | 80
106 | PATH
107 | Application Support
108 | PATH_TYPE
109 | 0
110 | PERMISSIONS
111 | 493
112 | TYPE
113 | 1
114 | UID
115 | 0
116 |
117 |
118 | CHILDREN
119 |
120 | GID
121 | 0
122 | PATH
123 | Automator
124 | PATH_TYPE
125 | 0
126 | PERMISSIONS
127 | 493
128 | TYPE
129 | 1
130 | UID
131 | 0
132 |
133 |
134 | CHILDREN
135 |
136 | GID
137 | 0
138 | PATH
139 | Documentation
140 | PATH_TYPE
141 | 0
142 | PERMISSIONS
143 | 493
144 | TYPE
145 | 1
146 | UID
147 | 0
148 |
149 |
150 | CHILDREN
151 |
152 | GID
153 | 0
154 | PATH
155 | Filesystems
156 | PATH_TYPE
157 | 0
158 | PERMISSIONS
159 | 493
160 | TYPE
161 | 1
162 | UID
163 | 0
164 |
165 |
166 | CHILDREN
167 |
168 | GID
169 | 0
170 | PATH
171 | Frameworks
172 | PATH_TYPE
173 | 0
174 | PERMISSIONS
175 | 493
176 | TYPE
177 | 1
178 | UID
179 | 0
180 |
181 |
182 | CHILDREN
183 |
184 | GID
185 | 0
186 | PATH
187 | Input Methods
188 | PATH_TYPE
189 | 0
190 | PERMISSIONS
191 | 493
192 | TYPE
193 | 1
194 | UID
195 | 0
196 |
197 |
198 | CHILDREN
199 |
200 | GID
201 | 0
202 | PATH
203 | Internet Plug-Ins
204 | PATH_TYPE
205 | 0
206 | PERMISSIONS
207 | 493
208 | TYPE
209 | 1
210 | UID
211 | 0
212 |
213 |
214 | CHILDREN
215 |
216 |
217 | CHILDREN
218 |
219 | GID
220 | 0
221 | PATH
222 | ../dist/Library/LaunchAgents/com.bitcointrezor.trezorBridge.trezord.plist
223 | PATH_TYPE
224 | 1
225 | PERMISSIONS
226 | 420
227 | TYPE
228 | 3
229 | UID
230 | 0
231 |
232 |
233 | GID
234 | 0
235 | PATH
236 | LaunchAgents
237 | PATH_TYPE
238 | 0
239 | PERMISSIONS
240 | 493
241 | TYPE
242 | 1
243 | UID
244 | 0
245 |
246 |
247 | CHILDREN
248 |
249 | GID
250 | 0
251 | PATH
252 | LaunchDaemons
253 | PATH_TYPE
254 | 0
255 | PERMISSIONS
256 | 493
257 | TYPE
258 | 1
259 | UID
260 | 0
261 |
262 |
263 | CHILDREN
264 |
265 | GID
266 | 0
267 | PATH
268 | PreferencePanes
269 | PATH_TYPE
270 | 0
271 | PERMISSIONS
272 | 493
273 | TYPE
274 | 1
275 | UID
276 | 0
277 |
278 |
279 | CHILDREN
280 |
281 | GID
282 | 0
283 | PATH
284 | Preferences
285 | PATH_TYPE
286 | 0
287 | PERMISSIONS
288 | 493
289 | TYPE
290 | 1
291 | UID
292 | 0
293 |
294 |
295 | CHILDREN
296 |
297 | GID
298 | 80
299 | PATH
300 | Printers
301 | PATH_TYPE
302 | 0
303 | PERMISSIONS
304 | 493
305 | TYPE
306 | 1
307 | UID
308 | 0
309 |
310 |
311 | CHILDREN
312 |
313 | GID
314 | 0
315 | PATH
316 | PrivilegedHelperTools
317 | PATH_TYPE
318 | 0
319 | PERMISSIONS
320 | 493
321 | TYPE
322 | 1
323 | UID
324 | 0
325 |
326 |
327 | CHILDREN
328 |
329 | GID
330 | 0
331 | PATH
332 | QuickLook
333 | PATH_TYPE
334 | 0
335 | PERMISSIONS
336 | 493
337 | TYPE
338 | 1
339 | UID
340 | 0
341 |
342 |
343 | CHILDREN
344 |
345 | GID
346 | 0
347 | PATH
348 | QuickTime
349 | PATH_TYPE
350 | 0
351 | PERMISSIONS
352 | 493
353 | TYPE
354 | 1
355 | UID
356 | 0
357 |
358 |
359 | CHILDREN
360 |
361 | GID
362 | 0
363 | PATH
364 | Screen Savers
365 | PATH_TYPE
366 | 0
367 | PERMISSIONS
368 | 493
369 | TYPE
370 | 1
371 | UID
372 | 0
373 |
374 |
375 | CHILDREN
376 |
377 | GID
378 | 0
379 | PATH
380 | Scripts
381 | PATH_TYPE
382 | 0
383 | PERMISSIONS
384 | 493
385 | TYPE
386 | 1
387 | UID
388 | 0
389 |
390 |
391 | CHILDREN
392 |
393 | GID
394 | 0
395 | PATH
396 | Services
397 | PATH_TYPE
398 | 0
399 | PERMISSIONS
400 | 493
401 | TYPE
402 | 1
403 | UID
404 | 0
405 |
406 |
407 | CHILDREN
408 |
409 | GID
410 | 0
411 | PATH
412 | Widgets
413 | PATH_TYPE
414 | 0
415 | PERMISSIONS
416 | 493
417 | TYPE
418 | 1
419 | UID
420 | 0
421 |
422 |
423 | GID
424 | 0
425 | PATH
426 | Library
427 | PATH_TYPE
428 | 0
429 | PERMISSIONS
430 | 493
431 | TYPE
432 | 1
433 | UID
434 | 0
435 |
436 |
437 | CHILDREN
438 |
439 |
440 | CHILDREN
441 |
442 |
443 | CHILDREN
444 |
445 | GID
446 | 0
447 | PATH
448 | Extensions
449 | PATH_TYPE
450 | 0
451 | PERMISSIONS
452 | 493
453 | TYPE
454 | 1
455 | UID
456 | 0
457 |
458 |
459 | GID
460 | 0
461 | PATH
462 | Library
463 | PATH_TYPE
464 | 0
465 | PERMISSIONS
466 | 493
467 | TYPE
468 | 1
469 | UID
470 | 0
471 |
472 |
473 | GID
474 | 0
475 | PATH
476 | System
477 | PATH_TYPE
478 | 0
479 | PERMISSIONS
480 | 493
481 | TYPE
482 | 1
483 | UID
484 | 0
485 |
486 |
487 | CHILDREN
488 |
489 |
490 | CHILDREN
491 |
492 | GID
493 | 0
494 | PATH
495 | Shared
496 | PATH_TYPE
497 | 0
498 | PERMISSIONS
499 | 1023
500 | TYPE
501 | 1
502 | UID
503 | 0
504 |
505 |
506 | GID
507 | 80
508 | PATH
509 | Users
510 | PATH_TYPE
511 | 0
512 | PERMISSIONS
513 | 493
514 | TYPE
515 | 1
516 | UID
517 | 0
518 |
519 |
520 | GID
521 | 0
522 | PATH
523 | /
524 | PATH_TYPE
525 | 0
526 | PERMISSIONS
527 | 493
528 | TYPE
529 | 1
530 | UID
531 | 0
532 |
533 | PAYLOAD_TYPE
534 | 0
535 | SPLIT_FORKS
536 |
537 | VERSION
538 | 3
539 |
540 | PACKAGE_SCRIPTS
541 |
542 | POSTINSTALL_PATH
543 |
544 | PATH
545 | after-install.sh
546 | PATH_TYPE
547 | 1
548 |
549 | RESOURCES
550 |
551 |
552 | PACKAGE_SETTINGS
553 |
554 | AUTHENTICATION
555 |
556 | CONCLUSION_ACTION
557 | 0
558 | IDENTIFIER
559 | com.bitcointrezor.pkg.TREZORBridge
560 | NAME
561 | TREZOR Bridge
562 | OVERWRITE_PERMISSIONS
563 |
564 | USE_HFS+_COMPRESSION
565 |
566 | VERSION
567 | 1.1.0
568 |
569 | PROJECT_COMMENTS
570 |
571 | NOTES
572 |
573 | PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1M
574 | IDQuMDEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIvaHRtbDQv
575 | c3RyaWN0LmR0ZCI+CjxodG1sPgo8aGVhZD4KPG1ldGEgaHR0cC1l
576 | cXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7
577 | IGNoYXJzZXQ9VVRGLTgiPgo8bWV0YSBodHRwLWVxdWl2PSJDb250
578 | ZW50LVN0eWxlLVR5cGUiIGNvbnRlbnQ9InRleHQvY3NzIj4KPHRp
579 | dGxlPjwvdGl0bGU+CjxtZXRhIG5hbWU9IkdlbmVyYXRvciIgY29u
580 | dGVudD0iQ29jb2EgSFRNTCBXcml0ZXIiPgo8bWV0YSBuYW1lPSJD
581 | b2NvYVZlcnNpb24iIGNvbnRlbnQ9IjEzNDcuNTciPgo8c3R5bGUg
582 | dHlwZT0idGV4dC9jc3MiPgo8L3N0eWxlPgo8L2hlYWQ+Cjxib2R5
583 | Pgo8L2JvZHk+CjwvaHRtbD4K
584 |
585 |
586 | PROJECT_SETTINGS
587 |
588 | BUILD_PATH
589 |
590 | PATH
591 | ../dist
592 | PATH_TYPE
593 | 1
594 |
595 | EXCLUDED_FILES
596 |
597 |
598 | PATTERNS_ARRAY
599 |
600 |
601 | REGULAR_EXPRESSION
602 |
603 | STRING
604 | .DS_Store
605 | TYPE
606 | 0
607 |
608 |
609 | PROTECTED
610 |
611 | PROXY_NAME
612 | Remove .DS_Store files
613 | PROXY_TOOLTIP
614 | Remove ".DS_Store" files created by the Finder.
615 | STATE
616 |
617 |
618 |
619 | PATTERNS_ARRAY
620 |
621 |
622 | REGULAR_EXPRESSION
623 |
624 | STRING
625 | .pbdevelopment
626 | TYPE
627 | 0
628 |
629 |
630 | PROTECTED
631 |
632 | PROXY_NAME
633 | Remove .pbdevelopment files
634 | PROXY_TOOLTIP
635 | Remove ".pbdevelopment" files created by ProjectBuilder or Xcode.
636 | STATE
637 |
638 |
639 |
640 | PATTERNS_ARRAY
641 |
642 |
643 | REGULAR_EXPRESSION
644 |
645 | STRING
646 | CVS
647 | TYPE
648 | 1
649 |
650 |
651 | REGULAR_EXPRESSION
652 |
653 | STRING
654 | .cvsignore
655 | TYPE
656 | 0
657 |
658 |
659 | REGULAR_EXPRESSION
660 |
661 | STRING
662 | .cvspass
663 | TYPE
664 | 0
665 |
666 |
667 | REGULAR_EXPRESSION
668 |
669 | STRING
670 | .svn
671 | TYPE
672 | 1
673 |
674 |
675 | REGULAR_EXPRESSION
676 |
677 | STRING
678 | .git
679 | TYPE
680 | 1
681 |
682 |
683 | REGULAR_EXPRESSION
684 |
685 | STRING
686 | .gitignore
687 | TYPE
688 | 0
689 |
690 |
691 | PROTECTED
692 |
693 | PROXY_NAME
694 | Remove SCM metadata
695 | PROXY_TOOLTIP
696 | Remove helper files and folders used by the CVS, SVN or Git Source Code Management systems.
697 | STATE
698 |
699 |
700 |
701 | PATTERNS_ARRAY
702 |
703 |
704 | REGULAR_EXPRESSION
705 |
706 | STRING
707 | classes.nib
708 | TYPE
709 | 0
710 |
711 |
712 | REGULAR_EXPRESSION
713 |
714 | STRING
715 | designable.db
716 | TYPE
717 | 0
718 |
719 |
720 | REGULAR_EXPRESSION
721 |
722 | STRING
723 | info.nib
724 | TYPE
725 | 0
726 |
727 |
728 | PROTECTED
729 |
730 | PROXY_NAME
731 | Optimize nib files
732 | PROXY_TOOLTIP
733 | Remove "classes.nib", "info.nib" and "designable.nib" files within .nib bundles.
734 | STATE
735 |
736 |
737 |
738 | PATTERNS_ARRAY
739 |
740 |
741 | REGULAR_EXPRESSION
742 |
743 | STRING
744 | Resources Disabled
745 | TYPE
746 | 1
747 |
748 |
749 | PROTECTED
750 |
751 | PROXY_NAME
752 | Remove Resources Disabled folders
753 | PROXY_TOOLTIP
754 | Remove "Resources Disabled" folders.
755 | STATE
756 |
757 |
758 |
759 | SEPARATOR
760 |
761 |
762 |
763 | NAME
764 | TREZOR Bridge
765 |
766 |
767 | TYPE
768 | 1
769 | VERSION
770 | 1
771 |
772 |
773 |
--------------------------------------------------------------------------------
/release/mac/installer/after-install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -x
4 | set -e
5 |
6 | # find out which user is running the installation
7 | inst_user=`stat /dev/console | cut -f 5 -d ' '`
8 |
9 | # load the agent file into launchd with correct user
10 |
11 | agent_file=/Library/LaunchAgents/com.bitcointrezor.trezorBridge.trezord.plist
12 |
13 | set +e
14 | sudo -u $inst_user launchctl unload $agent_file
15 | set -e
16 | sudo -u $inst_user launchctl load $agent_file
17 |
--------------------------------------------------------------------------------
/release/mac/release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 | set -x
5 |
6 | cd $(dirname $0)
7 |
8 | TARGET=$1
9 | BUILDDIR=build${TARGET:+-$TARGET}
10 | VERSION=$(cat ../../VERSION)
11 |
12 | cd ../../$BUILDDIR
13 |
14 | # bundle dependencies
15 |
16 | make -C ../vendor/macdylibbundler
17 |
18 | ../vendor/macdylibbundler/dylibbundler \
19 | -od -b -x trezord -d libs/ \
20 | -p @executable_path/libs/
21 |
22 | # strip binary and libs
23 |
24 | x86_64-apple-darwin12-strip trezord
25 |
26 | # fix libs permissions
27 |
28 | chmod a+r libs/*
29 |
--------------------------------------------------------------------------------
/release/windows/.gitignore:
--------------------------------------------------------------------------------
1 | authenticode.*
2 |
--------------------------------------------------------------------------------
/release/windows/Dockerfile:
--------------------------------------------------------------------------------
1 | # initialize from the image
2 |
3 | FROM fedora:24
4 |
5 | # update package repositories
6 |
7 | RUN dnf update -y
8 |
9 | # install tools
10 |
11 | RUN dnf install -y cmake make wget
12 | RUN dnf install -y osslsigncode mingw32-nsis
13 |
14 | # install dependencies for Windows build
15 |
16 | RUN dnf install -y mingw32-boost-static
17 | RUN dnf install -y mingw32-curl
18 | RUN dnf install -y mingw32-libmicrohttpd
19 | RUN dnf install -y mingw32-winpthreads
20 | RUN dnf install -y mingw32-zlib-static
21 |
22 | # install dependencies from COPR
23 |
24 | RUN wget https://copr-be.cloud.fedoraproject.org/results/prusnak/private/fedora-24-x86_64/00365081-mingw-protobuf/mingw32-protobuf{,-static}-2.6.1-3.fc24.noarch.rpm
25 | RUN dnf install -y mingw32-protobuf{,-static}-2.6.1-3.fc24.noarch.rpm
26 |
--------------------------------------------------------------------------------
/release/windows/Makefile:
--------------------------------------------------------------------------------
1 | PLATFORM = windows
2 | BITS = 32
3 | TARGET = win$(BITS)
4 | VOL_MOUNT = -v $(shell pwd)/../..:/trezord-src
5 | IMAGETAG = trezord-build-env-$(PLATFORM)
6 |
7 | all: .package
8 |
9 | .package: .binary
10 | $(info Packaging ...)
11 | docker run -t $(VOL_MOUNT) $(IMAGETAG) /trezord-src/release/$(PLATFORM)/release.sh $(TARGET)
12 |
13 | .binary: .docker-image
14 | $(info Building in docker ...)
15 | docker run -t $(VOL_MOUNT) $(IMAGETAG) /trezord-src/build.sh $(TARGET)
16 |
17 | .docker-image:
18 | $(info Preparing docker image ...)
19 | docker build -t $(IMAGETAG) .
20 |
21 | shell: .docker-image
22 | docker run -i -t $(VOL_MOUNT) $(IMAGETAG) /bin/bash
23 |
--------------------------------------------------------------------------------
/release/windows/release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | cd $(dirname $0)
6 |
7 | TARGET=$1
8 | BUILDDIR=build${TARGET:+-$TARGET}
9 | VERSION=$(cat ../../VERSION)
10 |
11 | INSTALLER=trezor-bridge-$VERSION-$TARGET-install.exe
12 |
13 | cd ../../$BUILDDIR
14 |
15 | cp ../release/windows/trezord.nsis trezord.nsis
16 | for i in \
17 | iconv.dll \
18 | libcrypto-10.dll \
19 | libcurl-4.dll \
20 | libffi-6.dll \
21 | libgcc_s_sjlj-1.dll \
22 | libgcrypt-20.dll \
23 | libgmp-10.dll \
24 | libgnutls-30.dll \
25 | libgpg-error-0.dll \
26 | libhogweed-4-2.dll \
27 | libidn-11.dll \
28 | libintl-8.dll \
29 | libmicrohttpd-12.dll \
30 | libnettle-6-2.dll \
31 | libp11-kit-0.dll \
32 | libssh2-1.dll \
33 | libssl-10.dll \
34 | libstdc++-6.dll \
35 | libtasn1-6.dll \
36 | libwinpthread-1.dll \
37 | zlib1.dll \
38 | ; do
39 | if [ $TARGET = win32 ]; then
40 | cp /usr/i686-w64-mingw32/sys-root/mingw/bin/$i .
41 | else
42 | cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/$i .
43 | fi
44 | done
45 |
46 | mingw-strip *.dll *.exe
47 |
48 | SIGNKEY=../release/windows/authenticode
49 |
50 | if [ -r $SIGNKEY.der ]; then
51 | mv trezord.exe trezord.exe.unsigned
52 | osslsigncode sign -certs $SIGNKEY.p7b -key $SIGNKEY.der -n "TREZOR Bridge" -i "https://trezor.io/" -t http://timestamp.comodoca.com -in trezord.exe.unsigned -out trezord.exe
53 | osslsigncode verify -in trezord.exe
54 | fi
55 |
56 | if [ $TARGET = win32 ]; then
57 | makensis -X"OutFile $INSTALLER" -X'InstallDir "$PROGRAMFILES32\TREZOR Bridge"' trezord.nsis
58 | else
59 | makensis -X"OutFile $INSTALLER" -X'InstallDir "$PROGRAMFILES64\TREZOR Bridge"' trezord.nsis
60 | fi
61 |
62 | if [ -r $SIGNKEY.der ]; then
63 | mv $INSTALLER $INSTALLER.unsigned
64 | osslsigncode sign -certs $SIGNKEY.p7b -key $SIGNKEY.der -n "TREZOR Bridge" -i "https://trezor.io/" -t http://timestamp.comodoca.com -in $INSTALLER.unsigned -out $INSTALLER
65 | osslsigncode verify -in $INSTALLER
66 | fi
67 |
--------------------------------------------------------------------------------
/release/windows/trezord.nsis:
--------------------------------------------------------------------------------
1 | !include MUI2.nsh
2 |
3 | RequestExecutionLevel admin
4 |
5 | SetCompressor bzip2
6 |
7 | Name "TREZOR Bridge"
8 | InstallDirRegKey HKLM Software\TREZOR\Bridge InstallDir
9 |
10 | ShowInstDetails hide
11 | ShowUninstDetails hide
12 |
13 | XPStyle on
14 |
15 | Page directory
16 | Page instfiles
17 |
18 | DirText "Please select the installation folder."
19 |
20 | Section "TREZOR Bridge"
21 | SectionIn RO
22 |
23 | DetailPrint "Stopping previous TREZOR Bridge"
24 | nsExec::Exec "taskkill /IM trezord.exe /F"
25 |
26 | SetOutPath "$INSTDIR"
27 | File "iconv.dll"
28 | File "libcrypto-10.dll"
29 | File "libcurl-4.dll"
30 | File "libffi-6.dll"
31 | File "libgcc_s_sjlj-1.dll"
32 | File "libgcrypt-20.dll"
33 | File "libgmp-10.dll"
34 | File "libgnutls-30.dll"
35 | File "libgpg-error-0.dll"
36 | File "libhogweed-4-2.dll"
37 | File "libidn-11.dll"
38 | File "libintl-8.dll"
39 | File "libmicrohttpd-12.dll"
40 | File "libnettle-6-2.dll"
41 | File "libp11-kit-0.dll"
42 | File "libssh2-1.dll"
43 | File "libssl-10.dll"
44 | File "libstdc++-6.dll"
45 | File "libtasn1-6.dll"
46 | File "libwinpthread-1.dll"
47 | File "zlib1.dll"
48 | File "trezord.exe"
49 | SectionEnd
50 |
51 | Section "Start Menu Shortcuts"
52 | CreateDirectory "$SMPROGRAMS\TREZOR Bridge"
53 | CreateShortCut "$SMPROGRAMS\TREZOR Bridge\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
54 | CreateShortCut "$SMPROGRAMS\TREZOR Bridge\TREZOR Bridge.lnk" "$INSTDIR\trezord.exe" "" "$INSTDIR\trezord.exe" 0
55 | CreateShortCut "$SMSTARTUP\TREZOR Bridge.lnk" "$INSTDIR\trezord.exe" "" "$INSTDIR\trezord.exe" 0
56 | SectionEnd
57 |
58 | Section "Uninstall"
59 | ExecWait "taskkill /f /im trezord.exe"
60 |
61 | Delete /rebootok "$SMSTARTUP\TREZOR Bridge.lnk"
62 | Delete /rebootok "$SMPROGRAMS\TREZOR Bridge\TREZOR Bridge.lnk"
63 | Delete /rebootok "$SMPROGRAMS\TREZOR Bridge\Uninstall.lnk"
64 | RMDir "$SMPROGRAMS\TREZOR Bridge"
65 |
66 | Delete /rebootok "$INSTDIR\trezord.exe"
67 | Delete /rebootok "$INSTDIR\Uninstall.exe"
68 | RMDir "$INSTDIR"
69 | SectionEnd
70 |
71 | Section -post
72 | WriteUninstaller "$INSTDIR\Uninstall.exe"
73 | SectionEnd
74 |
75 | !define MUI_FINISHPAGE_RUN
76 | !define MUI_FINISHPAGE_RUN_TEXT "Start TREZOR Bridge"
77 | !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchApplication"
78 | !insertmacro MUI_PAGE_FINISH
79 |
80 | Function LaunchApplication
81 | ExecShell "" "$INSTDIR\trezord.exe"
82 | FunctionEnd
83 |
--------------------------------------------------------------------------------
/src/config/keys.h:
--------------------------------------------------------------------------------
1 | // sample public key "correct horse battery staple"
2 | // "\x04\x78\xd4\x30\x27\x4f\x8c\x5e\xc1\x32\x13\x38\x15\x1e\x9f\x27\xf4\xc6\x76\xa0\x08\xbd\xf8\x63\x8d\x07\xc0\xb6\xbe\x9a\xb3\x5c\x71\xa1\x51\x80\x63\x24\x3a\xcd\x4d\xfe\x96\xb6\x6e\x3f\x2e\xc8\x01\x3c\x8e\x07\x2c\xd0\x9b\x38\x34\xa1\x9f\x81\xf6\x59\xcc\x34\x55"
3 |
4 | // production public keys
5 | "\x04\xd5\x71\xb7\xf1\x48\xc5\xe4\x23\x2c\x38\x14\xf7\x77\xd8\xfa\xea\xf1\xa8\x42\x16\xc7\x8d\x56\x9b\x71\x04\x1f\xfc\x76\x8a\x5b\x2d\x81\x0f\xc3\xbb\x13\x4d\xd0\x26\xb5\x7e\x65\x00\x52\x75\xae\xde\xf4\x3e\x15\x5f\x48\xfc\x11\xa3\x2e\xc7\x90\xa9\x33\x12\xbd\x58",
6 | "\x04\x63\x27\x9c\x0c\x08\x66\xe5\x0c\x05\xc7\x99\xd3\x2b\xd6\xba\xb0\x18\x8b\x6d\xe0\x65\x36\xd1\x10\x9d\x2e\xd9\xce\x76\xcb\x33\x5c\x49\x0e\x55\xae\xe1\x0c\xc9\x01\x21\x51\x32\xe8\x53\x09\x7d\x54\x32\xed\xa0\x6b\x79\x20\x73\xbd\x77\x40\xc9\x4c\xe4\x51\x6c\xb1",
7 | "\x04\x43\xae\xdb\xb6\xf7\xe7\x1c\x56\x3f\x8e\xd2\xef\x64\xec\x99\x81\x48\x25\x19\xe7\xef\x4f\x4a\xa9\x8b\x27\x85\x4e\x8c\x49\x12\x6d\x49\x56\xd3\x00\xab\x45\xfd\xc3\x4c\xd2\x6b\xc8\x71\x0d\xe0\xa3\x1d\xbd\xf6\xde\x74\x35\xfd\x0b\x49\x2b\xe7\x0a\xc7\x5f\xde\x58",
8 | "\x04\x87\x7c\x39\xfd\x7c\x62\x23\x7e\x03\x82\x35\xe9\xc0\x75\xda\xb2\x61\x63\x0f\x78\xee\xb8\xed\xb9\x24\x87\x15\x9f\xff\xed\xfd\xf6\x04\x6c\x6f\x8b\x88\x1f\xa4\x07\xc4\xa4\xce\x6c\x28\xde\x0b\x19\xc1\xf4\xe2\x9f\x1f\xcb\xc5\xa5\x8f\xfd\x14\x32\xa3\xe0\x93\x8a",
9 | "\x04\x73\x84\xc5\x1a\xe8\x1a\xdd\x0a\x52\x3a\xdb\xb1\x86\xc9\x1b\x90\x6f\xfb\x64\xc2\xc7\x65\x80\x2b\xf2\x6d\xbd\x13\xbd\xf1\x2c\x31\x9e\x80\xc2\x21\x3a\x13\x6c\x8e\xe0\x3d\x78\x74\xfd\x22\xb7\x0d\x68\xe7\xde\xe4\x69\xde\xcf\xbb\xb5\x10\xee\x9a\x46\x0c\xda\x45",
10 |
--------------------------------------------------------------------------------
/src/core.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the TREZOR project.
3 | *
4 | * Copyright (C) 2014 SatoshiLabs
5 | *
6 | * This library is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with this library. If not, see .
18 | */
19 |
20 | #include "protobuf/json_codec.hpp"
21 | #include "protobuf/wire_codec.hpp"
22 | #include "config/config.pb.h"
23 | #include "crypto.hpp"
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | namespace trezord
35 | {
36 | namespace core
37 | {
38 |
39 | struct device_kernel
40 | {
41 | using device_path_type = std::string;
42 |
43 | device_path_type device_path;
44 |
45 | device_kernel(device_path_type const &dp)
46 | : device_path{dp}
47 | {}
48 |
49 | void
50 | open()
51 | {
52 | if (device.get() == nullptr) {
53 | CLOG(INFO, "core.device") << "opening: " << device_path;
54 | device.reset(new wire::device{device_path.c_str()});
55 | }
56 | }
57 |
58 | void
59 | close()
60 | {
61 | CLOG(INFO, "core.device") << "closing: " << device_path;
62 | device.reset();
63 | }
64 |
65 | void
66 | call(wire::message const &msg_in, wire::message &msg_out)
67 | {
68 | CLOG(INFO, "core.device") << "calling: " << device_path;
69 | if (!device.get()) {
70 | open();
71 | }
72 | try {
73 | msg_in.write_to(*device);
74 | msg_out.read_from(*device);
75 | }
76 | catch (std::exception const &e) {
77 | CLOG(ERROR, "core.device") << e.what();
78 | close();
79 | throw;
80 | }
81 | }
82 |
83 | private:
84 |
85 | std::unique_ptr< wire::device > device;
86 | };
87 |
88 | struct kernel_config
89 | {
90 | struct invalid_config
91 | : public std::invalid_argument
92 | { using std::invalid_argument::invalid_argument; };
93 |
94 | Configuration c;
95 |
96 | void
97 | parse_from_signed_string(std::string const &str)
98 | {
99 | auto data = verify_signature(str);
100 | c.ParseFromArray(data.first, data.second);
101 | }
102 |
103 | bool
104 | is_initialized()
105 | {
106 | return c.IsInitialized();
107 | }
108 |
109 | bool
110 | is_unexpired()
111 | {
112 | auto current_time = std::time(nullptr);
113 | return !c.has_valid_until() || c.valid_until() > current_time;
114 | }
115 |
116 | bool
117 | is_url_allowed(std::string const &url)
118 | {
119 | bool whitelisted = std::any_of(
120 | c.whitelist_urls().begin(),
121 | c.whitelist_urls().end(),
122 | [&] (std::string const &pattern) {
123 | return boost::regex_match(url, boost::regex{pattern});
124 | });
125 |
126 | bool blacklisted = std::any_of(
127 | c.blacklist_urls().begin(),
128 | c.blacklist_urls().end(),
129 | [&] (std::string const &pattern) {
130 | return boost::regex_match(url, boost::regex{pattern});
131 | });
132 |
133 | return whitelisted && !blacklisted;
134 | }
135 |
136 | std::string
137 | get_debug_string()
138 | {
139 | Configuration c_copy{c};
140 | c_copy.clear_wire_protocol();
141 | return c_copy.DebugString();
142 | }
143 |
144 | private:
145 |
146 | std::pair
147 | verify_signature(std::string const &str)
148 | {
149 | static const std::size_t sig_size = 64;
150 | if (str.size() <= sig_size) {
151 | throw invalid_config{"configuration string is malformed"};
152 | }
153 | auto sig = reinterpret_cast(str.data());
154 | auto msg = sig + sig_size;
155 | auto msg_len = str.size() - sig_size;
156 |
157 | static const char *sig_keys[] = {
158 | #include "config/keys.h"
159 | };
160 | auto keys = reinterpret_cast(sig_keys);
161 | auto keys_len = sizeof(sig_keys) / sizeof(sig_keys[0]);
162 |
163 | if (!crypto::verify_signature(sig, msg, msg_len, keys, keys_len)) {
164 | throw invalid_config{"configuration signature is invalid"};
165 | }
166 |
167 | return std::make_pair(msg, msg_len);
168 | }
169 | };
170 |
171 | struct kernel
172 | {
173 | using session_id_type = std::string;
174 | using device_path_type = std::string;
175 | using device_enumeration_type = std::vector<
176 | std::pair
177 | >;
178 |
179 | struct missing_config
180 | : public std::logic_error
181 | { using std::logic_error::logic_error; };
182 |
183 | struct unknown_session
184 | : public std::invalid_argument
185 | { using std::invalid_argument::invalid_argument; };
186 |
187 | struct wrong_previous_session
188 | : public std::invalid_argument
189 | { using std::invalid_argument::invalid_argument; };
190 |
191 | public:
192 |
193 | kernel()
194 | : pb_state{new protobuf::state{}},
195 | pb_wire_codec{new protobuf::wire_codec{pb_state.get()}},
196 | pb_json_codec{new protobuf::json_codec{pb_state.get()}}
197 | {
198 | hid::init();
199 | }
200 |
201 | ~kernel()
202 | {
203 | hid::exit();
204 | }
205 |
206 | std::string
207 | get_version()
208 | { return VERSION; }
209 |
210 | bool
211 | has_config()
212 | { return config.is_initialized(); }
213 |
214 | kernel_config const &
215 | get_config()
216 | { return config; }
217 |
218 | void
219 | set_config(kernel_config const &new_config)
220 | {
221 | lock_type lock{mutex};
222 |
223 | config = new_config;
224 |
225 | pb_state.reset(new protobuf::state{});
226 | pb_state->load_from_set(config.c.wire_protocol());
227 |
228 | pb_wire_codec.reset(new protobuf::wire_codec{pb_state.get()});
229 | pb_wire_codec->load_protobuf_state();
230 |
231 | pb_json_codec.reset(new protobuf::json_codec{pb_state.get()});
232 | }
233 |
234 | bool
235 | is_allowed(std::string const &url)
236 | {
237 | lock_type lock{mutex};
238 |
239 | if (!has_config()) {
240 | return true;
241 | }
242 |
243 | return config.is_unexpired() && config.is_url_allowed(url);
244 | }
245 |
246 | // device enumeration
247 |
248 | session_id_type
249 | find_session_by_path(device_path_type const &path) {
250 | auto it = sessions.find(path);
251 | if (it != sessions.end()) {
252 | return it->second;
253 | } else {
254 | return "";
255 | }
256 | }
257 |
258 | device_enumeration_type
259 | enumerate_devices()
260 | {
261 | lock_type lock{mutex};
262 |
263 | if (!has_config()) {
264 | throw missing_config{"not configured"};
265 | }
266 |
267 | device_enumeration_type list;
268 |
269 | for (auto const &i: enumerate_supported_devices()) {
270 | auto session_id = find_session_by_path(i.path);
271 | list.emplace_back(i, session_id);
272 | }
273 |
274 | return list;
275 | }
276 |
277 | // device kernels
278 |
279 | device_kernel *
280 | get_device_kernel(device_path_type const &device_path)
281 | {
282 | lock_type lock{mutex};
283 |
284 | if (!has_config()) {
285 | throw missing_config{"not configured"};
286 | }
287 |
288 | auto kernel_r = device_kernels.emplace(
289 | std::piecewise_construct,
290 | std::forward_as_tuple(device_path),
291 | std::forward_as_tuple(device_path));
292 |
293 | return &kernel_r.first->second;
294 | }
295 |
296 | device_kernel *
297 | get_device_kernel_by_session_id(session_id_type const &session_id)
298 | {
299 | lock_type lock{mutex};
300 |
301 | if (!has_config()) {
302 | throw missing_config{"not configured"};
303 | }
304 |
305 | auto session_it = std::find_if(
306 | sessions.begin(),
307 | sessions.end(),
308 | [&] (decltype(sessions)::value_type const &kv) {
309 | return kv.second == session_id;
310 | });
311 |
312 | if (session_it == sessions.end()) {
313 | throw unknown_session{"session not found"};
314 | }
315 |
316 | return get_device_kernel(session_it->first);
317 | }
318 |
319 | // session management
320 |
321 | session_id_type
322 | acquire_session(device_path_type const &device_path)
323 | {
324 | lock_type lock{mutex};
325 |
326 | if (!has_config()) {
327 | throw missing_config{"not configured"};
328 | }
329 |
330 | CLOG(INFO, "core.kernel") << "acquiring session for: " << device_path;
331 | return sessions[device_path] = generate_session_id();
332 | }
333 |
334 | void
335 | release_session(session_id_type const &session_id)
336 | {
337 | lock_type lock{mutex};
338 |
339 | if (!has_config()) {
340 | throw missing_config{"not configured"};
341 | }
342 |
343 | auto session_it = std::find_if(
344 | sessions.begin(),
345 | sessions.end(),
346 | [&] (decltype(sessions)::value_type const &kv) {
347 | return kv.second == session_id;
348 | });
349 |
350 | if (session_it != sessions.end()) {
351 | CLOG(INFO, "core.kernel") << "releasing session: " << session_id;
352 | sessions.erase(session_it);
353 | }
354 | }
355 |
356 |
357 | session_id_type
358 | open_and_acquire_session(device_path_type const &device_path,
359 | session_id_type const &previous_id,
360 | bool check_previous)
361 | {
362 | lock_type lock{mutex};
363 |
364 | auto real_previous_id = find_session_by_path(device_path);
365 | if (check_previous && real_previous_id != previous_id) {
366 | CLOG(INFO, "core.kernel") << "not acquiring session for: " << device_path << " , wrong previous";
367 | throw wrong_previous_session{"wrong previous session"};
368 | }
369 | if (!(real_previous_id.empty())) {
370 | close_and_release_session(real_previous_id);
371 | }
372 |
373 | get_device_kernel(device_path)->open();
374 | return acquire_session(device_path);
375 | }
376 |
377 | void
378 | close_and_release_session(session_id_type const &session_id)
379 | {
380 | lock_type lock{mutex};
381 | get_device_kernel_by_session_id(session_id)->close();
382 | release_session(session_id);
383 | }
384 |
385 | void
386 | call_device(device_kernel *device, wire::message const &msg_in, wire::message &msg_out)
387 | {
388 | lock_type lock{mutex};
389 | device->call(msg_in, msg_out);
390 | }
391 |
392 | // protobuf <-> json codec
393 |
394 | void
395 | json_to_wire(Json::Value const &json, wire::message &wire)
396 | {
397 | lock_type lock{mutex};
398 | protobuf_ptr pbuf{pb_json_codec->typed_json_to_protobuf(json)};
399 | pb_wire_codec->protobuf_to_wire(*pbuf, wire);
400 | }
401 |
402 | void
403 | wire_to_json(wire::message const &wire, Json::Value &json)
404 | {
405 | lock_type lock{mutex};
406 | protobuf_ptr pbuf{pb_wire_codec->wire_to_protobuf(wire)};
407 | json = pb_json_codec->protobuf_to_typed_json(*pbuf);
408 | }
409 |
410 | private:
411 |
412 | using protobuf_ptr = std::unique_ptr;
413 | using lock_type = boost::unique_lock;
414 |
415 | boost::recursive_mutex mutex;
416 |
417 | kernel_config config;
418 | std::unique_ptr pb_state;
419 | std::unique_ptr pb_wire_codec;
420 | std::unique_ptr pb_json_codec;
421 |
422 | std::map device_kernels;
423 | std::map sessions;
424 | boost::uuids::random_generator uuid_generator;
425 |
426 | session_id_type
427 | generate_session_id()
428 | {
429 | return boost::lexical_cast(uuid_generator());
430 | }
431 |
432 | wire::device_info_list
433 | enumerate_supported_devices()
434 | {
435 | return wire::enumerate_connected_devices(
436 | [&] (hid_device_info const *i) {
437 | return is_device_supported(i);
438 | });
439 | }
440 |
441 | bool
442 | is_device_supported(hid_device_info const *info)
443 | {
444 | return std::any_of(
445 | config.c.known_devices().begin(),
446 | config.c.known_devices().end(),
447 | [&] (DeviceDescriptor const &dd) {
448 | return (!dd.has_vendor_id()
449 | || dd.vendor_id() == info->vendor_id)
450 | && (!dd.has_product_id()
451 | || dd.product_id() == info->product_id);
452 | });
453 | }
454 | };
455 |
456 | }
457 | }
458 |
--------------------------------------------------------------------------------
/src/crypto.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the TREZOR project.
3 | *
4 | * Copyright (C) 2014 SatoshiLabs
5 | *
6 | * This library is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with this library. If not, see .
18 | */
19 |
20 | #ifdef _MSC_VER // trezor-crypto gets compiled as C++ on MSVC
21 | extern "C++" {
22 | #else
23 | extern "C" {
24 | #endif
25 | #include
26 | #include
27 | }
28 |
29 | namespace trezord
30 | {
31 | namespace crypto
32 | {
33 |
34 | bool
35 | verify_signature(std::uint8_t const *sig,
36 | std::uint8_t const *msg,
37 | std::size_t msg_len,
38 | std::uint8_t const **keys,
39 | std::size_t keys_len)
40 | {
41 | for (std::size_t i = 0; i < keys_len; i++) {
42 | int ret = ecdsa_verify(&secp256k1, keys[i], sig, msg, msg_len);
43 | if (ret == 0) {
44 | return true;
45 | }
46 | }
47 | return false;
48 | }
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/glibc_compat.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #ifdef __amd64__
4 | #define GLIBC_COMPAT_SYMBOL(X) __asm__(".symver __" #X "_compat," #X "@GLIBC_2.2.5");
5 | #else
6 | #define GLIBC_COMPAT_SYMBOL(X) __asm__(".symver __" #X "_compat," #X "@GLIBC_2.0");
7 | #endif
8 |
9 | // memcpy
10 |
11 | GLIBC_COMPAT_SYMBOL(memcpy)
12 |
13 | void *__memcpy_compat(void *, const void *, size_t);
14 |
15 | void *__wrap_memcpy(void *dest, const void *src, size_t n)
16 | {
17 | return __memcpy_compat(dest, src, n);
18 | }
19 |
20 | // secure_getenv
21 |
22 | GLIBC_COMPAT_SYMBOL(__secure_getenv)
23 |
24 | char *____secure_getenv_compat(const char *);
25 |
26 | char *__wrap_secure_getenv(const char *name)
27 | {
28 | return ____secure_getenv_compat(name);
29 | }
30 |
--------------------------------------------------------------------------------
/src/hid.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the TREZOR project.
3 | *
4 | * Copyright (C) 2014 SatoshiLabs
5 | *
6 | * This library is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with this library. If not, see .
18 | */
19 |
20 | #include
21 |
22 | namespace trezord
23 | {
24 | namespace hid
25 | {
26 |
27 | static std::unique_ptr< utils::async_executor > hid_executor;
28 |
29 | // Init/exit
30 |
31 | void
32 | init()
33 | {
34 | hid_init();
35 | hid_executor.reset(new utils::async_executor());
36 | }
37 |
38 | void
39 | exit()
40 | {
41 | hid_exit();
42 | hid_executor.reset();
43 | }
44 |
45 | // Enumeration
46 |
47 | hid_device_info *
48 | enumerate(unsigned short vendor_id, unsigned short product_id)
49 | {
50 | return hid_executor->await([=] {
51 | return hid_enumerate(vendor_id, product_id);
52 | });
53 | }
54 |
55 | void
56 | free_enumeration(hid_device_info *devs)
57 | {
58 | return hid_executor->await([=] {
59 | return hid_free_enumeration(devs);
60 | });
61 | }
62 |
63 | // Open/close
64 |
65 | hid_device *
66 | open_path(char const *path)
67 | {
68 | return hid_executor->await([=] { return hid_open_path(path); });
69 | }
70 |
71 | void
72 | close(hid_device *device)
73 | {
74 | return hid_executor->await([=] { return hid_close(device); });
75 | }
76 |
77 | // Communication
78 |
79 | int
80 | write(hid_device *device, unsigned char const *data, size_t length)
81 | {
82 | return hid_executor->await([=] {
83 | return hid_write(device, data, length);
84 | });
85 | }
86 |
87 | int
88 | read_timeout(hid_device *device, unsigned char *data, size_t length, int milliseconds)
89 | {
90 | return hid_executor->await([=] {
91 | return hid_read_timeout(device, data, length, milliseconds);
92 | });
93 | }
94 |
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/http_api.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the TREZOR project.
3 | *
4 | * Copyright (C) 2014 SatoshiLabs
5 | *
6 | * This library is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with this library. If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include