diff -Nru python-trezor-0.7.16/debian/changelog python-trezor-0.9.0/debian/changelog --- python-trezor-0.7.16/debian/changelog 2017-12-24 11:46:32.000000000 +0000 +++ python-trezor-0.9.0/debian/changelog 2018-03-10 17:16:36.000000000 +0000 @@ -1,3 +1,18 @@ +python-trezor (0.9.0-1) unstable; urgency=medium + + [ Ondřej Nový ] + * d/control: Set Vcs-* to salsa.debian.org + * d/copyright: Use https protocol in Format field + + [ Tristan Seligmann ] + * New upstream release. + * Bump Standards-Version to 4.1.3 (no changes). + * Fix Depends/Breaks/Replaces to handle move of trezorctl from + python-trezor to trezor (closes: #884417). + * Bump debhelper comat level to 11. + + -- Tristan Seligmann Sat, 10 Mar 2018 19:16:36 +0200 + python-trezor (0.7.16-3) unstable; urgency=medium * Fix Build-Depends on python{,3}-hidapi; these should be python{,3}-hid diff -Nru python-trezor-0.7.16/debian/compat python-trezor-0.9.0/debian/compat --- python-trezor-0.7.16/debian/compat 2017-12-24 11:46:32.000000000 +0000 +++ python-trezor-0.9.0/debian/compat 2018-03-10 17:16:36.000000000 +0000 @@ -1 +1 @@ -9 +11 diff -Nru python-trezor-0.7.16/debian/control python-trezor-0.9.0/debian/control --- python-trezor-0.7.16/debian/control 2017-12-24 11:46:32.000000000 +0000 +++ python-trezor-0.9.0/debian/control 2018-03-10 17:16:36.000000000 +0000 @@ -6,7 +6,7 @@ Priority: optional Build-Depends: bash-completion, - debhelper (>=9), + debhelper (>= 11), dh-python, python-all, python-ecdsa, @@ -22,14 +22,16 @@ python3-protobuf, python3-requests, python3-setuptools, -Standards-Version: 4.1.2 -Vcs-Browser: https://anonscm.debian.org/git/python-modules/packages/python-trezor.git -Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/python-trezor.git +Standards-Version: 4.1.3 +Vcs-Browser: https://salsa.debian.org/python-team/modules/python-trezor +Vcs-Git: https://salsa.debian.org/python-team/modules/python-trezor.git Package: trezor Architecture: all -Depends: python3-trezor, ${misc:Depends}, ${python3:Depends} +Depends: python3-trezor, ${misc:Depends}, ${python:Depends} Section: utils +Breaks: python-trezor (<< 0.7.16-1) +Replaces: python-trezor (<< 0.7.16-1) Description: utilities for communicating with TREZOR Bitcoin HW wallet No matter how unprotected your computer or internet connection might be, your coins always stay safe with TREZOR as it never exposes your private keys. @@ -43,6 +45,7 @@ Package: python-trezor Architecture: all Depends: ${misc:Depends}, ${python:Depends} +Breaks: electrum (<< 3.1.0) Description: library for communicating with TREZOR Bitcoin HW wallet (Python 2) No matter how unprotected your computer or internet connection might be, your coins always stay safe with TREZOR as it never exposes your private keys. @@ -55,6 +58,7 @@ Package: python3-trezor Architecture: all Depends: ${misc:Depends}, ${python3:Depends} +Breaks: electrum (<< 3.1.0) Description: library for communicating with TREZOR Bitcoin HW wallet (Python 3) No matter how unprotected your computer or internet connection might be, your coins always stay safe with TREZOR as it never exposes your private keys. diff -Nru python-trezor-0.7.16/debian/copyright python-trezor-0.9.0/debian/copyright --- python-trezor-0.7.16/debian/copyright 2017-12-24 11:46:32.000000000 +0000 +++ python-trezor-0.9.0/debian/copyright 2018-03-10 17:16:36.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: python-trezor Source: https://github.com/trezor/python-trezor @@ -8,10 +8,6 @@ 2016 Jochen Hoenicke License: LGPL-3 -Files: trezorlib/protobuf_json.py -Copyright: 2009 Paul Dovbush -License: BSD-3-clause - Files: debian/* Copyright: 2014-2015 Richard Ulrich License: GPL-3+ @@ -21,34 +17,6 @@ License version 3 can be found in the file `/usr/share/common-licenses/LGPL-3'. -License: BSD-3-clause - Copyright (c) The Regents of the University of California. - All rights reserved. - . - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - . - THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - License: GPL-3+ On Debian systems, the full text of the GNU General Public License version 3 can be found in the file diff -Nru python-trezor-0.7.16/debian/.git-dpm python-trezor-0.9.0/debian/.git-dpm --- python-trezor-0.7.16/debian/.git-dpm 2017-12-24 11:46:32.000000000 +0000 +++ python-trezor-0.9.0/debian/.git-dpm 2018-03-10 17:16:36.000000000 +0000 @@ -1,11 +1,11 @@ # see git-dpm(1) from git-dpm package -c52e25930910981695d7e159b1e6b6540a445a50 -c52e25930910981695d7e159b1e6b6540a445a50 -c52e25930910981695d7e159b1e6b6540a445a50 -c52e25930910981695d7e159b1e6b6540a445a50 -python-trezor_0.7.16.orig.tar.gz -003f5edeea0b4bb9ca76f13a4d835d2a3a2df4a6 -107178 +d4826fd2b42fc6b7cb21451f73c1b3b68bfb6c40 +d4826fd2b42fc6b7cb21451f73c1b3b68bfb6c40 +d4826fd2b42fc6b7cb21451f73c1b3b68bfb6c40 +d4826fd2b42fc6b7cb21451f73c1b3b68bfb6c40 +python-trezor_0.9.0.orig.tar.gz +e590999dc4816b81594b114f1b9a8120b60554a9 +119088 debianTag="debian/%e%v" patchedTag="patched/%e%v" upstreamTag="upstream/%e%u" diff -Nru python-trezor-0.7.16/MANIFEST.in python-trezor-0.9.0/MANIFEST.in --- python-trezor-0.7.16/MANIFEST.in 2016-11-28 13:33:00.000000000 +0000 +++ python-trezor-0.9.0/MANIFEST.in 2017-12-19 13:18:15.000000000 +0000 @@ -1,3 +1,3 @@ -recursive-include tests *.py *.sh *.json recursive-include bash_completion.d *.sh +include trezorlib/tests/txcache/*.json include COPYING diff -Nru python-trezor-0.7.16/PKG-INFO python-trezor-0.9.0/PKG-INFO --- python-trezor-0.7.16/PKG-INFO 2017-07-05 10:54:20.000000000 +0000 +++ python-trezor-0.9.0/PKG-INFO 2018-02-06 21:13:34.000000000 +0000 @@ -1,11 +1,12 @@ Metadata-Version: 1.1 Name: trezor -Version: 0.7.16 +Version: 0.9.0 Summary: Python library for communicating with TREZOR Hardware Wallet Home-page: https://github.com/trezor/python-trezor Author: TREZOR Author-email: info@trezor.io License: UNKNOWN +Description-Content-Type: UNKNOWN Description: UNKNOWN Platform: UNKNOWN Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3) diff -Nru python-trezor-0.7.16/README.rst python-trezor-0.9.0/README.rst --- python-trezor-0.7.16/README.rst 2017-06-28 11:40:41.000000000 +0000 +++ python-trezor-0.9.0/README.rst 2018-02-02 19:00:39.000000000 +0000 @@ -7,85 +7,55 @@ .. image:: https://badges.gitter.im/trezor/community.svg :target: https://gitter.im/trezor/community -Python library for communicating with TREZOR Hardware Wallet +Python library and commandline client for communicating with TREZOR Hardware Wallet See https://trezor.io for more information Install ------- -(Run with sudo if not running in superuser mode under Linux) +Linux requirements: .. code:: - pip install trezor + sudo apt-get install python3-dev cython3 libusb-1.0-0-dev libudev-dev git -On Linux you might need to run these commands first: +Linux & Mac Python requirements: .. code:: - sudo apt-get install python-dev cython libusb-1.0-0-dev libudev-dev git - sudo pip install setuptools + sudo -H pip3 install setuptools + sudo -H pip3 install -r requirements.txt + sudo -H pip3 install trezor -Usage ------ - -There is a command line tool called ``trezorctl`` which can perform various tasks. Use the following to learn about its commands: +On FreeBSD you can install the packages: .. code:: - trezorctl --help + pkg install security/py-trezor -or to learn options of a particular command: +or build via ports: .. code:: - trezorctl commands --help - -or visit `usage `_ page for more info. - -To use the library in your application look at the following example. - -Example -------- - -also found in ``tools/helloworld.py`` - -.. code:: python - - #!/usr/bin/env python - - from trezorlib.client import TrezorClient - from trezorlib.transport_hid import HidTransport + cd /usr/ports/security/py-trezor + make install clean - def main(): - # List all connected TREZORs on USB - devices = HidTransport.enumerate() - # Check whether we found any - if len(devices) == 0: - print('No TREZOR found') - return +Commandline client (trezorctl) +--------------------------- - # Use first connected device - transport = HidTransport(devices[0]) +The included ``trezorctl`` python script can perform various tasks such as changing setting in the Trezor, signing transactions, retrieving account info and addresses. See the `docs/ `_ sub folder for detailed examples and options. - # Creates object for manipulating TREZOR - client = TrezorClient(transport) +NOTE: An older version of the ``trezorctl`` command is `available for Debian Stretch `_ (and comes pre-installed on `Tails OS `_). - # Print out TREZOR's features and settings - print(client.features) - # Get the first address of first BIP44 account - # (should be the same address as shown in wallet.trezor.io) - bip32_path = client.expand_path("44'/0'/0'/0/0") - address = client.get_address('Bitcoin', bip32_path) - print('Bitcoin address:', address) +Python Library +-------------- - client.close() +You can use this python library to interact with a Bitcoin Trezor and use its capabilities in your application. +See examples here in the `tools/ `_ sub folder. - if __name__ == '__main__': - main() PIN Entering ------------ diff -Nru python-trezor-0.7.16/setup.py python-trezor-0.9.0/setup.py --- python-trezor-0.7.16/setup.py 2017-07-05 10:52:21.000000000 +0000 +++ python-trezor-0.9.0/setup.py 2018-02-02 19:00:39.000000000 +0000 @@ -1,12 +1,13 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from setuptools import setup install_requires = [ + 'setuptools>=19.0', 'ecdsa>=0.9', - 'protobuf>=3.1.0', 'mnemonic>=0.17', - 'setuptools>=19.0', 'requests>=2.4.0', + 'click>=6.2', + 'pyblake2>=0.9.3', ] import sys @@ -15,29 +16,26 @@ else: install_requires.append('hidapi>=0.7.99.post20') +if '--disable-libusb' in sys.argv: + sys.argv.remove('--disable-libusb') +else: + install_requires.append('libusb1>=1.6.4') + +from trezorlib import __version__ as VERSION + setup( name='trezor', - version='0.7.16', + version=VERSION, author='TREZOR', author_email='info@trezor.io', description='Python library for communicating with TREZOR Hardware Wallet', url='https://github.com/trezor/python-trezor', - py_modules=[ - 'trezorlib.ckd_public', - 'trezorlib.client', - 'trezorlib.debuglink', - 'trezorlib.mapping', - 'trezorlib.messages_pb2', - 'trezorlib.protobuf_json', - 'trezorlib.qt.pinmatrix', - 'trezorlib.tools', - 'trezorlib.transport', - 'trezorlib.transport_bridge', - 'trezorlib.transport_hid', - 'trezorlib.transport_pipe', - 'trezorlib.transport_udp', - 'trezorlib.tx_api', - 'trezorlib.types_pb2', + packages=[ + 'trezorlib', + 'trezorlib.messages', + 'trezorlib.qt', + 'trezorlib.tests.device_tests', + 'trezorlib.tests.unit_tests', ], scripts=['trezorctl'], install_requires=install_requires, diff -Nru python-trezor-0.7.16/tests/device_tests/common.py python-trezor-0.9.0/tests/device_tests/common.py --- python-trezor-0.7.16/tests/device_tests/common.py 2017-07-05 10:51:58.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/common.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -from __future__ import print_function - -import unittest -import hashlib - -from trezorlib.client import TrezorClient, TrezorDebugClient -from trezorlib import tx_api -import config - - -tx_api.cache_dir = '../txcache' - - -class TrezorTest(unittest.TestCase): - - def setUp(self): - transport = config.TRANSPORT(*config.TRANSPORT_ARGS, **config.TRANSPORT_KWARGS) - if hasattr(config, 'DEBUG_TRANSPORT'): - debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS, **config.DEBUG_TRANSPORT_KWARGS) - self.client = TrezorDebugClient(transport) - self.client.set_debuglink(debug_transport) - else: - self.client = TrezorClient(transport) - self.client.set_tx_api(tx_api.TxApiBitcoin) - # self.client.set_buttonwait(3) - - # 1 2 3 4 5 6 7 8 9 10 11 12 - self.mnemonic12 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle' - self.mnemonic18 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel' - self.mnemonic24 = 'dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk host tomato cradle drill spread actor shine dismiss champion exotic' - self.mnemonic_all = ' '.join(['all'] * 12) - - self.pin4 = '1234' - self.pin6 = '789456' - self.pin8 = '45678978' - - self.client.wipe_device() - - print("Setup finished") - print("--------------") - - def setup_mnemonic_allallall(self): - self.client.load_device_by_mnemonic(mnemonic=self.mnemonic_all, pin='', passphrase_protection=False, label='test', language='english') - - def setup_mnemonic_nopin_nopassphrase(self): - self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin='', passphrase_protection=False, label='test', language='english') - - def setup_mnemonic_pin_nopassphrase(self): - self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin=self.pin4, passphrase_protection=False, label='test', language='english') - - def setup_mnemonic_pin_passphrase(self): - self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin=self.pin4, passphrase_protection=True, label='test', language='english') - - def tearDown(self): - self.client.close() - - -def generate_entropy(strength, internal_entropy, external_entropy): - ''' - strength - length of produced seed. One of 128, 192, 256 - random - binary stream of random data from external HRNG - ''' - if strength not in (128, 192, 256): - raise Exception("Invalid strength") - - if not internal_entropy: - raise Exception("Internal entropy is not provided") - - if len(internal_entropy) < 32: - raise Exception("Internal entropy too short") - - if not external_entropy: - raise Exception("External entropy is not provided") - - if len(external_entropy) < 32: - raise Exception("External entropy too short") - - entropy = hashlib.sha256(internal_entropy + external_entropy).digest() - entropy_stripped = entropy[:strength // 8] - - if len(entropy_stripped) * 8 != strength: - raise Exception("Entropy length mismatch") - - return entropy_stripped diff -Nru python-trezor-0.7.16/tests/device_tests/config.py python-trezor-0.9.0/tests/device_tests/config.py --- python-trezor-0.7.16/tests/device_tests/config.py 2017-06-23 18:58:22.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/config.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -from __future__ import print_function - -import sys -sys.path = ['../../'] + sys.path - - -try: - from trezorlib.transport_hid import HidTransport - HID_ENABLED = True -except Exception as e: - print('HID transport disabled:', e.message, e.args) - HID_ENABLED = False - -try: - from trezorlib.transport_pipe import PipeTransport - PIPE_ENABLED = True -except Exception as e: - print('PIPE transport disabled:', e.message, e.args) - PIPE_ENABLED = False - -try: - from trezorlib.transport_udp import UdpTransport - UDP_ENABLED = True -except Exception as e: - print('UDP transport disabled:', e.message, e.args) - UDP_ENABLED = False - - -def pipe_exists(path): - import os - import stat - try: - return stat.S_ISFIFO(os.stat(path).st_mode) - except: - return False - - -if HID_ENABLED and len(HidTransport.enumerate()) > 0: - - devices = HidTransport.enumerate() - print('Using TREZOR') - TRANSPORT = HidTransport - TRANSPORT_ARGS = (devices[0],) - TRANSPORT_KWARGS = {'debug_link': False} - DEBUG_TRANSPORT = HidTransport - DEBUG_TRANSPORT_ARGS = (devices[0],) - DEBUG_TRANSPORT_KWARGS = {'debug_link': True} - -elif PIPE_ENABLED and pipe_exists('/tmp/pipe.trezor.to'): - - print('Using Emulator (v1=pipe)') - TRANSPORT = PipeTransport - TRANSPORT_ARGS = ('/tmp/pipe.trezor', False) - TRANSPORT_KWARGS = {} - DEBUG_TRANSPORT = PipeTransport - DEBUG_TRANSPORT_ARGS = ('/tmp/pipe.trezor_debug', False) - DEBUG_TRANSPORT_KWARGS = {} - -elif UDP_ENABLED: - - print('Using Emulator (v2=udp)') - TRANSPORT = UdpTransport - TRANSPORT_ARGS = ('', ) - TRANSPORT_KWARGS = {} - DEBUG_TRANSPORT = UdpTransport - DEBUG_TRANSPORT_ARGS = ('', ) - DEBUG_TRANSPORT_KWARGS = {} diff -Nru python-trezor-0.7.16/tests/device_tests/run-separate.sh python-trezor-0.9.0/tests/device_tests/run-separate.sh --- python-trezor-0.7.16/tests/device_tests/run-separate.sh 2016-01-12 23:16:40.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/run-separate.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -#!/bin/bash -for i in test_*.py; do - echo Starting: $i - python $i > $i.out 2> $i.err -done diff -Nru python-trezor-0.7.16/tests/device_tests/run.sh python-trezor-0.9.0/tests/device_tests/run.sh --- python-trezor-0.7.16/tests/device_tests/run.sh 2016-01-12 23:16:40.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/run.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -#!/bin/bash - -python -m unittest discover diff -Nru python-trezor-0.7.16/tests/device_tests/test_basic.py python-trezor-0.9.0/tests/device_tests/test_basic.py --- python-trezor-0.7.16/tests/device_tests/test_basic.py 2017-06-23 18:56:07.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_basic.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - -from trezorlib import messages_pb2 as messages - - -class TestBasic(common.TrezorTest): - - def test_features(self): - features = self.client.call(messages.Initialize()) - self.assertEqual(features, self.client.features) - - def test_ping(self): - ping = self.client.call(messages.Ping(message='ahoj!')) - self.assertEqual(ping, messages.Success(message='ahoj!')) - - def test_device_id_same(self): - id1 = self.client.get_device_id() - self.client.init_device() - id2 = self.client.get_device_id() - - # ID must be at least 12 characters - self.assertTrue(len(id1) >= 12) - - # Every resulf of UUID must be the same - self.assertEqual(id1, id2) - - def test_device_id_different(self): - id1 = self.client.get_device_id() - self.client.wipe_device() - id2 = self.client.get_device_id() - - # Device ID must be fresh after every reset - self.assertNotEqual(id1, id2) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_bip32_speed.py python-trezor-0.9.0/tests/device_tests/test_bip32_speed.py --- python-trezor-0.7.16/tests/device_tests/test_bip32_speed.py 2017-06-23 18:56:25.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_bip32_speed.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -from __future__ import print_function - -import unittest -import common -import time - - -class TestBip32Speed(common.TrezorTest): - - def test_public_ckd(self): - self.setup_mnemonic_nopin_nopassphrase() - - self.client.get_address('Bitcoin', []) # to compute root node via BIP39 - - for depth in range(8): - start = time.time() - self.client.get_address('Bitcoin', range(depth)) - delay = time.time() - start - expected = (depth + 1) * 0.26 - print("DEPTH", depth, "EXPECTED DELAY", expected, "REAL DELAY", delay) - self.assertLessEqual(delay, expected) - - def test_private_ckd(self): - self.setup_mnemonic_nopin_nopassphrase() - - self.client.get_address('Bitcoin', []) # to compute root node via BIP39 - - for depth in range(8): - start = time.time() - self.client.get_address('Bitcoin', range(-depth, 0)) - delay = time.time() - start - expected = (depth + 1) * 0.26 - print("DEPTH", depth, "EXPECTED DELAY", expected, "REAL DELAY", delay) - self.assertLessEqual(delay, expected) - - def test_cache(self): - self.setup_mnemonic_nopin_nopassphrase() - - start = time.time() - for x in range(10): - self.client.get_address('Bitcoin', [x, 2, 3, 4, 5, 6, 7, 8]) - nocache_time = time.time() - start - - start = time.time() - for x in range(10): - self.client.get_address('Bitcoin', [1, 2, 3, 4, 5, 6, 7, x]) - cache_time = time.time() - start - - print("NOCACHE TIME", nocache_time) - print("CACHED TIME", cache_time) - - # Cached time expected to be at least 2x faster - self.assertLessEqual(cache_time, nocache_time / 2.) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_debuglink.py python-trezor-0.9.0/tests/device_tests/test_debuglink.py --- python-trezor-0.7.16/tests/device_tests/test_debuglink.py 2017-06-23 18:57:21.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_debuglink.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - -from trezorlib import messages_pb2 as proto - - -class TestDebugLink(common.TrezorTest): - - def test_layout(self): - layout = self.client.debug.read_layout() - self.assertEqual(len(layout), 1024) - - def test_mnemonic(self): - self.setup_mnemonic_nopin_nopassphrase() - mnemonic = self.client.debug.read_mnemonic() - self.assertEqual(mnemonic, self.mnemonic12) - - def test_node(self): - self.setup_mnemonic_nopin_nopassphrase() - node = self.client.debug.read_node() - self.assertIsNotNone(node) - - def test_pin(self): - self.setup_mnemonic_pin_passphrase() - - # Manually trigger PinMatrixRequest - resp = self.client.call_raw(proto.Ping(message='test', pin_protection=True)) - self.assertIsInstance(resp, proto.PinMatrixRequest) - - pin = self.client.debug.read_pin() - self.assertEqual(pin[0], '1234') - self.assertNotEqual(pin[1], '') - - pin_encoded = self.client.debug.read_pin_encoded() - resp = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - self.assertIsInstance(resp, proto.Success) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_applysettings.py python-trezor-0.9.0/tests/device_tests/test_msg_applysettings.py --- python-trezor-0.7.16/tests/device_tests/test_msg_applysettings.py 2017-06-23 18:57:11.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_applysettings.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - -from trezorlib import messages_pb2 as proto - - -class TestMsgApplysettings(common.TrezorTest): - - def test_apply_settings(self): - self.setup_mnemonic_pin_passphrase() - self.assertEqual(self.client.features.label, 'test') - - with self.client: - self.client.set_expected_responses([proto.PinMatrixRequest(), - proto.ButtonRequest(), - proto.Success(), - proto.Features()]) - self.client.apply_settings(label='new label') - - self.assertEqual(self.client.features.label, 'new label') - - def test_invalid_language(self): - self.setup_mnemonic_pin_passphrase() - self.assertEqual(self.client.features.language, 'english') - - with self.client: - self.client.set_expected_responses([proto.PinMatrixRequest(), - proto.ButtonRequest(), - proto.Success(), - proto.Features()]) - self.client.apply_settings(language='nonexistent') - - self.assertEqual(self.client.features.language, 'english') - - def test_apply_settings_passphrase(self): - self.setup_mnemonic_pin_nopassphrase() - - self.assertEqual(self.client.features.passphrase_protection, False) - - with self.client: - self.client.set_expected_responses([proto.PinMatrixRequest(), - proto.ButtonRequest(), - proto.Success(), - proto.Features()]) - self.client.apply_settings(use_passphrase=True) - - self.assertEqual(self.client.features.passphrase_protection, True) - - with self.client: - self.client.set_expected_responses([proto.ButtonRequest(), - proto.Success(), - proto.Features()]) - self.client.apply_settings(use_passphrase=False) - - self.assertEqual(self.client.features.passphrase_protection, False) - - with self.client: - self.client.set_expected_responses([proto.ButtonRequest(), - proto.Success(), - proto.Features()]) - self.client.apply_settings(use_passphrase=True) - - self.assertEqual(self.client.features.passphrase_protection, True) - - def test_apply_homescreen(self): - self.setup_mnemonic_pin_passphrase() - - img = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x04\x88\x02\x00\x00\x00\x02\x91\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x90@\x00\x11@\x00\x00\x00\x00\x00\x00\x08\x00\x10\x92\x12\x04\x00\x00\x05\x12D\x00\x00\x00\x00\x00 \x00\x00\x08\x00Q\x00\x00\x02\xc0\x00\x00\x00\x00\x00\x00\x00\x10\x02 \x01\x04J\x00)$\x00\x00\x00\x00\x80\x00\x00\x00\x00\x08\x10\xa1\x00\x00\x02\x81 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\tP\x00\x00\x00\x00\x00\x00 \x00\x00\xa0\x00\xa0R \x12\x84\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x08\x00\tP\x00\x00\x00\x00 \x00\x04 \x00\x80\x02\x00@\x02T\xc2 \x00\x00\x00\x00\x00\x00\x00\x10@\x00)\t@\n\xa0\x80\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x80@\x14\xa9H\x04\x00\x00\x88@\x00\x00\x00\x00\x00\x02\x02$\x00\x15B@\x00\nP\x00\x00\x00\x00\x00\x80\x00\x00\x91\x01UP\x00\x00 \x02\x00\x00\x00\x00\x00\x00\x02\x08@ Z\xa5 \x00\x00\x80\x00\x00\x00\x00\x00\x00\x08\xa1%\x14*\xa0\x00\x00\x02\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xaa\x91 \x00\x05E\x80\x00\x00\x00\x00\x00\x02*T\x05-D\x00\x00\x05 @\x00\x00\x00\x00\x00%@\x80\x11V\xa0\x88\x00\x05@\xb0\x00\x00\x00\x00\x00\x818$\x04\xabD \x00\x06\xa1T\x00\x00\x00\x00\x02\x03\xb8\x01R\xd5\x01\x00\x00\x05AP\x00\x00\x00\x00\x08\xadT\x00\x05j\xa4@\x00\x87ah\x00\x00\x00\x00\x02\x8d\xb8\x08\x00.\x01\x00\x00\x02\xa5\xa8\x10\x00\x00\x00*\xc1\xec \n\xaa\x88 \x02@\xf6\xd0\x02\x00\x00\x00\x0bB\xb6\x14@U"\x80\x00\x01{`\x00\x00\x00\x00M\xa3\xf8 \x15*\x00\x00\x00\x10n\xc0\x04\x00\x00\x02\x06\xc2\xa8)\x00\x96\x84\x80\x00\x00\x1b\x00\x00\x80@\x10\x87\xa7\xf0\x84\x10\xaa\x10\x00\x00D\x00\x00\x02 \x00\x8a\x06\xfa\xe0P\n-\x02@\x00\x12\x00\x00\x00\x00\x10@\x83\xdf\xa0\x00\x08\xaa@\x00\x00\x01H\x00\x05H\x04\x12\x01\xf7\x81P\x02T\t\x00\x00\x00 \x00\x00\x84\x10\x00\x00z\x00@)* \x00\x00\x01\n\xa0\x02 \x05\n\x00\x00\x05\x10\x84\xa8\x84\x80\x00\x00@\x14\x00\x92\x10\x80\x00\x04\x11@\tT\x00\x00\x00\x00\n@\x00\x08\x84@$\x00H\x00\x12Q\x02\x00\x00\x00\x00\x90\x02A\x12\xa8\n\xaa\x92\x10\x04\xa8\x10@\x00\x00\x04\x04\x00\x04I\x00\x04\x14H\x80"R\x01\x00\x00\x00!@\x00\x00$\xa0EB\x80\x08\x95hH\x00\x00\x00\x84\x10 \x05Z\x00\x00(\x00\x02\x00\xa1\x01\x00\x00\x04\x00@\x82\x00\xadH*\x92P\x00\xaaP\x00\x00\x00\x00\x11\x02\x01*\xad\x01\x00\x01\x01"\x11D\x08\x00\x00\x10\x80 \x00\x81W\x80J\x94\x04\x08\xa5 !\x00\x00\x00\x02\x00B*\xae\xa1\x00\x80\x10\x01\x08\xa4\x00\x00\x00\x00\x00\x84\x00\t[@"HA\x04E\x00\x84\x00\x00\x00\x10\x00\x01J\xd5\x82\x90\x02\x00!\x02\xa2\x00\x00\x00\x00\x00\x00\x00\x05~\xa0\x00 \x10\n)\x00\x11\x00\x00\x00\x00\x00\x00!U\x80\xa8\x88\x82\x80\x01\x00\x00\x00\x00\x00\x00H@\x11\xaa\xc0\x82\x00 *\n\x00\x00\x00\x00\x00\x00\x00\x00\n\xabb@ \x04\x00! \x84\x00\x00\x00\x00\x02@\xa5\x15A$\x04\x81(\n\x00\x00\x00\x00\x00\x00 \x01\x10\x02\xe0\x91\x02\x00\x00\x04\x00\x00\x00\x00\x00\x00\x01 \xa9\tQH@\x91 P\x00\x00\x00\x00\x00\x00\x08\x00\x00\xa0T\xa5\x00@\x80\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\xa2\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00 T\xa0\t\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00@\x02\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00*\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x10\x00\x00\x10\x02\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00@\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x08@\x10\x00\x00\x00\x00' - - with self.client: - self.client.set_expected_responses([proto.PinMatrixRequest(), - proto.ButtonRequest(), - proto.Success(), - proto.Features()]) - self.client.apply_settings(homescreen=img) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_changepin.py python-trezor-0.9.0/tests/device_tests/test_msg_changepin.py --- python-trezor-0.7.16/tests/device_tests/test_msg_changepin.py 2017-06-23 18:57:04.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_changepin.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,222 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - -from trezorlib import messages_pb2 as proto - - -class TestMsgChangepin(common.TrezorTest): - - def test_set_pin(self): - self.setup_mnemonic_nopin_nopassphrase() - features = self.client.call_raw(proto.Initialize()) - self.assertFalse(features.pin_protection) - - # Check that there's no PIN protection - ret = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(ret, proto.Success) - - # Let's set new PIN - ret = self.client.call_raw(proto.ChangePin()) - self.assertIsInstance(ret, proto.ButtonRequest) - - # Press button - self.client.debug.press_yes() - ret = self.client.call_raw(proto.ButtonAck()) - - # Send the PIN for first time - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Send the PIN for second time - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Now we're done - self.assertIsInstance(ret, proto.Success) - - # Check that there's PIN protection now - features = self.client.call_raw(proto.Initialize()) - self.assertTrue(features.pin_protection) - ret = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(ret, proto.PinMatrixRequest) - self.client.call_raw(proto.Cancel()) - - # Check that the PIN is correct - self.assertEqual(self.client.debug.read_pin()[0], self.pin6) - - def test_change_pin(self): - self.setup_mnemonic_pin_passphrase() - features = self.client.call_raw(proto.Initialize()) - self.assertTrue(features.pin_protection) - - # Check that there's PIN protection - ret = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(ret, proto.PinMatrixRequest) - self.client.call_raw(proto.Cancel()) - - # Check current PIN value - self.assertEqual(self.client.debug.read_pin()[0], self.pin4) - - # Let's change PIN - ret = self.client.call_raw(proto.ChangePin()) - self.assertIsInstance(ret, proto.ButtonRequest) - - # Press button - self.client.debug.press_yes() - ret = self.client.call_raw(proto.ButtonAck()) - - # Send current PIN - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.read_pin_encoded() - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Send new PIN for first time - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Send the PIN for second time - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Now we're done - self.assertIsInstance(ret, proto.Success) - - # Check that there's still PIN protection now - features = self.client.call_raw(proto.Initialize()) - self.assertTrue(features.pin_protection) - ret = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(ret, proto.PinMatrixRequest) - self.client.call_raw(proto.Cancel()) - - # Check that the PIN is correct - self.assertEqual(self.client.debug.read_pin()[0], self.pin6) - - def test_remove_pin(self): - self.setup_mnemonic_pin_passphrase() - features = self.client.call_raw(proto.Initialize()) - self.assertTrue(features.pin_protection) - - # Check that there's PIN protection - ret = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(ret, proto.PinMatrixRequest) - self.client.call_raw(proto.Cancel()) - - # Let's remove PIN - ret = self.client.call_raw(proto.ChangePin(remove=True)) - self.assertIsInstance(ret, proto.ButtonRequest) - - # Press button - self.client.debug.press_yes() - ret = self.client.call_raw(proto.ButtonAck()) - - # Send current PIN - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.read_pin_encoded() - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Now we're done - self.assertIsInstance(ret, proto.Success) - - # Check that there's no PIN protection now - features = self.client.call_raw(proto.Initialize()) - self.assertFalse(features.pin_protection) - ret = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(ret, proto.Success) - - def test_set_failed(self): - self.setup_mnemonic_nopin_nopassphrase() - features = self.client.call_raw(proto.Initialize()) - self.assertFalse(features.pin_protection) - - # Check that there's no PIN protection - ret = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(ret, proto.Success) - - # Let's set new PIN - ret = self.client.call_raw(proto.ChangePin()) - self.assertIsInstance(ret, proto.ButtonRequest) - - # Press button - self.client.debug.press_yes() - ret = self.client.call_raw(proto.ButtonAck()) - - # Send the PIN for first time - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Send the PIN for second time, but with typo - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.encode_pin(self.pin4) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Now it should fail, because pins are different - self.assertIsInstance(ret, proto.Failure) - - # Check that there's still no PIN protection now - features = self.client.call_raw(proto.Initialize()) - self.assertFalse(features.pin_protection) - ret = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(ret, proto.Success) - - def test_set_failed_2(self): - self.setup_mnemonic_pin_passphrase() - features = self.client.call_raw(proto.Initialize()) - self.assertTrue(features.pin_protection) - - # Let's set new PIN - ret = self.client.call_raw(proto.ChangePin()) - self.assertIsInstance(ret, proto.ButtonRequest) - - # Press button - self.client.debug.press_yes() - ret = self.client.call_raw(proto.ButtonAck()) - - # Send current PIN - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.read_pin_encoded() - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Send the PIN for first time - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Send the PIN for second time, but with typo - self.assertIsInstance(ret, proto.PinMatrixRequest) - pin_encoded = self.client.debug.encode_pin(self.pin6 + '3') - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Now it should fail, because pins are different - self.assertIsInstance(ret, proto.Failure) - - # Check that there's still old PIN protection - features = self.client.call_raw(proto.Initialize()) - self.assertTrue(features.pin_protection) - self.assertEqual(self.client.debug.read_pin()[0], self.pin4) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_cipherkeyvalue.py python-trezor-0.9.0/tests/device_tests/test_msg_cipherkeyvalue.py --- python-trezor-0.7.16/tests/device_tests/test_msg_cipherkeyvalue.py 2017-06-23 19:01:35.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_cipherkeyvalue.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common -import binascii - - -class TestMsgCipherkeyvalue(common.TrezorTest): - - def test_encrypt(self): - self.setup_mnemonic_nopin_nopassphrase() - - # different ask values - res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=True) - self.assertEqual(binascii.hexlify(res), b'676faf8f13272af601776bc31bc14e8f') - - res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=False) - self.assertEqual(binascii.hexlify(res), b'5aa0fbcb9d7fa669880745479d80c622') - - res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=False, ask_on_decrypt=True) - self.assertEqual(binascii.hexlify(res), b'958d4f63269b61044aaedc900c8d6208') - - res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=False, ask_on_decrypt=False) - self.assertEqual(binascii.hexlify(res), b'e0cf0eb0425947000eb546cc3994bc6c') - - # different key - res = self.client.encrypt_keyvalue([0, 1, 2], b"test2", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=True) - self.assertEqual(binascii.hexlify(res), b'de247a6aa6be77a134bb3f3f925f13af') - - # different message - res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message! it is different", ask_on_encrypt=True, ask_on_decrypt=True) - self.assertEqual(binascii.hexlify(res), b'676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d') - - # different path - res = self.client.encrypt_keyvalue([0, 1, 3], b"test", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=True) - self.assertEqual(binascii.hexlify(res), b'b4811a9d492f5355a5186ddbfccaae7b') - - def test_decrypt(self): - self.setup_mnemonic_nopin_nopassphrase() - - # different ask values - res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("676faf8f13272af601776bc31bc14e8f"), ask_on_encrypt=True, ask_on_decrypt=True) - self.assertEqual(res, b'testing message!') - - res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("5aa0fbcb9d7fa669880745479d80c622"), ask_on_encrypt=True, ask_on_decrypt=False) - self.assertEqual(res, b'testing message!') - - res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("958d4f63269b61044aaedc900c8d6208"), ask_on_encrypt=False, ask_on_decrypt=True) - self.assertEqual(res, b'testing message!') - - res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("e0cf0eb0425947000eb546cc3994bc6c"), ask_on_encrypt=False, ask_on_decrypt=False) - self.assertEqual(res, b'testing message!') - - # different key - res = self.client.decrypt_keyvalue([0, 1, 2], b"test2", binascii.unhexlify("de247a6aa6be77a134bb3f3f925f13af"), ask_on_encrypt=True, ask_on_decrypt=True) - self.assertEqual(res, b'testing message!') - - # different message - res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d"), ask_on_encrypt=True, ask_on_decrypt=True) - self.assertEqual(res, b'testing message! it is different') - - # different path - res = self.client.decrypt_keyvalue([0, 1, 3], b"test", binascii.unhexlify("b4811a9d492f5355a5186ddbfccaae7b"), ask_on_encrypt=True, ask_on_decrypt=True) - self.assertEqual(res, b'testing message!') - - def test_encrypt_badlen(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertRaises(Exception, self.client.encrypt_keyvalue, [0, 1, 2], b"test", b"testing") - - def test_decrypt_badlen(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertRaises(Exception, self.client.decrypt_keyvalue, [0, 1, 2], b"test", b"testing") - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_clearsession.py python-trezor-0.9.0/tests/device_tests/test_msg_clearsession.py --- python-trezor-0.7.16/tests/device_tests/test_msg_clearsession.py 2017-06-23 19:01:36.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_clearsession.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - -from trezorlib import messages_pb2 as proto -from trezorlib import types_pb2 as proto_types - - -class TestMsgClearsession(common.TrezorTest): - - def test_clearsession(self): - self.setup_mnemonic_pin_passphrase() - - with self.client: - self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()]) - res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True) - self.assertEqual(res, 'random data') - - with self.client: - # pin and passphrase are cached - self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()]) - res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True) - self.assertEqual(res, 'random data') - - self.client.clear_session() - - # session cache is cleared - with self.client: - self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()]) - res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True) - self.assertEqual(res, 'random data') - - with self.client: - # pin and passphrase are cached - self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()]) - res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True) - self.assertEqual(res, 'random data') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_estimatetxsize.py python-trezor-0.9.0/tests/device_tests/test_msg_estimatetxsize.py --- python-trezor-0.7.16/tests/device_tests/test_msg_estimatetxsize.py 2017-06-26 13:30:49.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_estimatetxsize.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import binascii -import common - -import trezorlib.types_pb2 as proto_types - - -class TestMsgEstimatetxsize(common.TrezorTest): - - def test_estimate_size(self): - self.setup_mnemonic_nopin_nopassphrase() - - inp1 = proto_types.TxInputType( - address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e - # amount=390000, - prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'), - prev_index=0, - ) - - out1 = proto_types.TxOutputType( - address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1', - amount=390000 - 10000, - script_type=proto_types.PAYTOADDRESS, - ) - - est_size = self.client.estimate_tx_size('Bitcoin', [inp1, ], [out1, ]) - self.assertEqual(est_size, 194) - - (_, tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ]) - real_size = len(tx) - - self.assertGreaterEqual(est_size, real_size) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_ethereum_getaddress.py python-trezor-0.9.0/tests/device_tests/test_msg_ethereum_getaddress.py --- python-trezor-0.7.16/tests/device_tests/test_msg_ethereum_getaddress.py 2017-06-23 18:57:32.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_ethereum_getaddress.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common -import binascii - - -class TestMsgEthereumGetaddress(common.TrezorTest): - - def test_ethereum_getaddress(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([])), b'1d1c328764a41bda0492b66baa30c4a339ff85ef') - self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([1])), b'437207ca3cf43bf2e47dea0756d736c5df4f597a') - self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([0, -1])), b'e5d96dfa07bcf1a3ae43677840c31394258861bf') - self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([-9, 0])), b'f68804ac9eca9483ab4241d3e4751590d2c05102') - self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([0, 9999999])), b'7a6366ecfcaf0d5dcc1539c171696c6cdd1eb8ed') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_ethereum_signtx.py python-trezor-0.9.0/tests/device_tests/test_msg_ethereum_signtx.py --- python-trezor-0.7.16/tests/device_tests/test_msg_ethereum_signtx.py 2017-06-23 19:06:42.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_ethereum_signtx.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,250 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common -import binascii - - -class TestMsgEthereumSigntx(common.TrezorTest): - - def test_ethereum_signtx_nodata(self): - self.setup_mnemonic_nopin_nopassphrase() - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0, 0], - nonce=0, - gas_price=20, - gas_limit=20, - to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), - value=10) - self.assertEqual(sig_v, 27) - self.assertEqual(binascii.hexlify(sig_r), '9b61192a161d056c66cfbbd331edb2d783a0193bd4f65f49ee965f791d898f72') - self.assertEqual(binascii.hexlify(sig_s), '49c0bbe35131592c6ed5c871ac457feeb16a1493f64237387fab9b83c1a202f7') - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0, 0], - nonce=123456, - gas_price=20000, - gas_limit=20000, - to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), - value=12345678901234567890) - self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), '6de597b8ec1b46501e5b159676e132c1aa78a95bd5892ef23560a9867528975a') - self.assertEqual(binascii.hexlify(sig_s), '6e33c4230b1ecf96a8dbb514b4aec0a6d6ba53f8991c8143f77812aa6daa993f') - - def test_ethereum_signtx_data(self): - self.setup_mnemonic_nopin_nopassphrase() - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0, 0], - nonce=0, - gas_price=20, - gas_limit=20, - to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), - value=10, - data='abcdefghijklmnop' * 16) - self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), '6da89ed8627a491bedc9e0382f37707ac4e5102e25e7a1234cb697cedb7cd2c0') - self.assertEqual(binascii.hexlify(sig_s), '691f73b145647623e2d115b208a7c3455a6a8a83e3b4db5b9c6d9bc75825038a') - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0, 0], - nonce=123456, - gas_price=20000, - gas_limit=20000, - to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), - value=12345678901234567890, - data='ABCDEFGHIJKLMNOP' * 256 + '!!!') - self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), '4e90b13c45c6a9bf4aaad0e5427c3e62d76692b36eb727c78d332441b7400404') - self.assertEqual(binascii.hexlify(sig_s), '3ff236e7d05f0f9b1ee3d70599bb4200638f28388a8faf6bb36db9e04dc544be') - - def test_ethereum_signtx_message(self): - self.setup_mnemonic_nopin_nopassphrase() - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0, 0], - nonce=0, - gas_price=20000, - gas_limit=20000, - to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), - value=0, - data='ABCDEFGHIJKLMNOP' * 256 + '!!!') - self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), '070e9dafda4d9e733fa7b6747a75f8a4916459560efb85e3e73cd39f31aa160d') - self.assertEqual(binascii.hexlify(sig_s), '7842db33ef15c27049ed52741db41fe3238a6fa3a6a0888fcfb74d6917600e41') - - def test_ethereum_signtx_newcontract(self): - self.setup_mnemonic_nopin_nopassphrase() - - # contract creation without data should fail. - self.assertRaises( - Exception, - self.client.ethereum_sign_tx, - n=[0, 0], - nonce=123456, - gas_price=20000, - gas_limit=20000, - to='', - value=12345678901234567890 - ) - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0, 0], - nonce=0, - gas_price=20000, - gas_limit=20000, - to='', - value=12345678901234567890, - data='ABCDEFGHIJKLMNOP' * 256 + '!!!') - self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), 'b401884c10ae435a2e792303b5fc257a09f94403b2883ad8c0ac7a7282f5f1f9') - self.assertEqual(binascii.hexlify(sig_s), '4742fc9e6a5fa8db3db15c2d856914a7f3daab21603a6c1ce9e9927482f8352e') - - def test_ethereum_sanity_checks(self): - # gas overflow - self.assertRaises( - Exception, - self.client.ethereum_sign_tx, - n=[0, 0], - nonce=123456, - gas_price=0xffffffffffffffffffffffffffffffff, - gas_limit=0xffffffffffffffffffffffffffffff, - to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), - value=12345678901234567890 - ) - - # no gas price - self.assertRaises( - Exception, - self.client.ethereum_sign_tx, - n=[0, 0], - nonce=123456, - gas_limit=10000, - to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), - value=12345678901234567890 - ) - - # no gas limit - self.assertRaises( - Exception, - self.client.ethereum_sign_tx, - n=[0, 0], - nonce=123456, - gas_price=10000, - to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), - value=12345678901234567890 - ) - - # no nonce - self.assertRaises( - Exception, - self.client.ethereum_sign_tx, - n=[0, 0], - gas_price=10000, - gas_limit=123456, - to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), - value=12345678901234567890 - ) - - def test_ethereum_signtx_nodata_eip155(self): - self.setup_mnemonic_allallall() - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], - nonce=0, - gas_price=20000000000, - gas_limit=21000, - to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), - value=100000000000000000, - chain_id=3) - self.assertEqual(sig_v, 41) - self.assertEqual(binascii.hexlify(sig_r), 'a90d0bc4f8d63be69453dd62f2bb5fff53c610000abf956672564d8a654d401a') - self.assertEqual(binascii.hexlify(sig_s), '544a2e57bc8b4da18660a1e6036967ea581cc635f5137e3ba97a750867c27cf2') - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], - nonce=1, - gas_price=20000000000, - gas_limit=21000, - to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), - value=100000000000000000, - chain_id=3) - self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), '699428a6950e23c6843f1bf3754f847e64e047e829978df80d55187d19a401ce') - self.assertEqual(binascii.hexlify(sig_s), '087343d0a3a2f10842218ffccb146b59a8431b6245ab389fde22dc833f171e6e') - - def test_ethereum_signtx_data_eip155(self): - self.setup_mnemonic_allallall() - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], - nonce=2, - gas_price=20000000000, - gas_limit=21004, - to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), - value=100000000000000000, - data='\0', - chain_id=3) - self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), 'ba85b622a8bb82606ba96c132e81fa8058172192d15bc41d7e57c031bca17df4') - self.assertEqual(binascii.hexlify(sig_s), '6473b75997634b6f692f8d672193591d299d5bf1c2d6e51f1a14ed0530b91c7d') - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], - nonce=3, - gas_price=20000000000, - gas_limit=299732, - to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), - value=100000000000000000, - data='ABCDEFGHIJKLMNOP' * 256 + '!!!', - chain_id=3) - self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), 'd021c98f92859c8db5e4de2f0e410a8deb0c977eb1a631e323ebf7484bd0d79a') - self.assertEqual(binascii.hexlify(sig_s), '2c0e9defc9b1e895dc9520ff25ba3c635b14ad70aa86a5ad6c0a3acb82b569b6') - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], - nonce=4, - gas_price=20000000000, - gas_limit=21004, - to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), - value=0, - data='\0', - chain_id=3) - self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), 'dd52f026972a83c56b7dea356836fcfc70a68e3b879cdc8ef2bb5fea23e0a7aa') - self.assertEqual(binascii.hexlify(sig_s), '079285fe579c9a2da25c811b1c5c0a74cd19b6301ee42cf20ef7b3b1353f7242') - - sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( - n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], - nonce=5, - gas_price=0, - gas_limit=21004, - to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), - value=0, - data='\0', - chain_id=3) - self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), 'f7505f709d5999343aea3c384034c62d0514336ff6c6af65582006f708f81503') - self.assertEqual(binascii.hexlify(sig_s), '44e09e29a4b6247000b46ddc94fe391e94deb2b39ad6ac6398e6db5bec095ba9') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_getaddress.py python-trezor-0.9.0/tests/device_tests/test_msg_getaddress.py --- python-trezor-0.7.16/tests/device_tests/test_msg_getaddress.py 2017-06-23 19:04:15.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_getaddress.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common -import trezorlib.ckd_public as bip32 - - -class TestMsgGetaddress(common.TrezorTest): - - def test_btc(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertEqual(self.client.get_address('Bitcoin', []), '1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK') - self.assertEqual(self.client.get_address('Bitcoin', [1]), '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb') - self.assertEqual(self.client.get_address('Bitcoin', [0, -1]), '1JVq66pzRBvqaBRFeU9SPVvg3er4ZDgoMs') - self.assertEqual(self.client.get_address('Bitcoin', [-9, 0]), '1F4YdQdL9ZQwvcNTuy5mjyQxXkyCfMcP2P') - self.assertEqual(self.client.get_address('Bitcoin', [0, 9999999]), '1GS8X3yc7ntzwGw9vXwj9wqmBWZkTFewBV') - - def test_ltc(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertEqual(self.client.get_address('Litecoin', []), 'LYtGrdDeqYUQnTkr5sHT2DKZLG7Hqg7HTK') - self.assertEqual(self.client.get_address('Litecoin', [1]), 'LKRGNecThFP3Q6c5fosLVA53Z2hUDb1qnE') - self.assertEqual(self.client.get_address('Litecoin', [0, -1]), 'LcinMK8pVrAtpz7Qpc8jfWzSFsDLgLYfG6') - self.assertEqual(self.client.get_address('Litecoin', [-9, 0]), 'LZHVtcwAEDf1BR4d67551zUijyLUpDF9EX') - self.assertEqual(self.client.get_address('Litecoin', [0, 9999999]), 'Laf5nGHSCT94C5dK6fw2RxuXPiw2ZuRR9S') - - def test_tbtc(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertEqual(self.client.get_address('Testnet', [111, 42]), 'moN6aN6NP1KWgnPSqzrrRPvx2x1UtZJssa') - - def test_public_ckd(self): - self.setup_mnemonic_nopin_nopassphrase() - - node = self.client.get_public_node([]).node - node_sub1 = self.client.get_public_node([1]).node - node_sub2 = bip32.public_ckd(node, [1]) - - self.assertEqual(node_sub1.chain_code, node_sub2.chain_code) - self.assertEqual(node_sub1.public_key, node_sub2.public_key) - - address1 = self.client.get_address('Bitcoin', [1]) - address2 = bip32.get_address(node_sub2, 0) - - self.assertEqual(address2, '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb') - self.assertEqual(address1, address2) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_getaddress_segwit_native.py python-trezor-0.9.0/tests/device_tests/test_msg_getaddress_segwit_native.py --- python-trezor-0.7.16/tests/device_tests/test_msg_getaddress_segwit_native.py 2017-06-23 19:06:51.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_getaddress_segwit_native.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -import unittest -import common -import trezorlib.ckd_public as bip32 -import trezorlib.types_pb2 as proto_types - - -class TestMsgGetaddressSegwitNative(common.TrezorTest): - - def test_show_segwit(self): - self.setup_mnemonic_allallall() - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"), - True, None, script_type=proto_types.SPENDWITNESS), - 'QWywnqNMsMNavbCgMYiQLa91ApvsVRoaqt1i') - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"), - False, None, script_type=proto_types.SPENDWITNESS), - 'QWzGpyMkAEvmkSVprBzRRVQMP6UPp17q4kQn') - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), - False, None, script_type=proto_types.SPENDWITNESS), - 'QWzCpc1NeTN7hNDzK9sQQ9yrTQP8zh5Hef5J') - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), - False, None, script_type=proto_types.SPENDADDRESS), - 'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q') - - def test_show_multisig_3(self): - self.setup_mnemonic_allallall() - nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4)) - multisig1 = proto_types.MultisigRedeemScriptType( - pubkeys=map(lambda n: proto_types.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 0]), nodes), - signatures=[b'', b'', b''], - m=2, - ) - multisig2 = proto_types.MultisigRedeemScriptType( - pubkeys=map(lambda n: proto_types.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes), - signatures=[b'', b'', b''], - m=2, - ) - for i in [1, 2, 3]: - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/1" % i), - False, multisig2, script_type=proto_types.SPENDWITNESS), - 'T7nZJt6QbGJy6Hok4EF2LqtJPcT7z7VFSrSysGS3tEqCfDPwizqy4') - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i), - False, multisig1, script_type=proto_types.SPENDWITNESS), - 'T7nY3A3kewpDKumsdhonP4TBDfTXFSc2RNhZxkqmeeszRDHjM5yUn') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_getaddress_segwit.py python-trezor-0.9.0/tests/device_tests/test_msg_getaddress_segwit.py --- python-trezor-0.7.16/tests/device_tests/test_msg_getaddress_segwit.py 2017-06-23 19:01:04.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_getaddress_segwit.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -import unittest -import common -import trezorlib.ckd_public as bip32 -import trezorlib.types_pb2 as proto_types - - -class TestMsgGetaddressSegwit(common.TrezorTest): - - def test_show_segwit(self): - self.setup_mnemonic_allallall() - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"), - True, None, script_type=proto_types.SPENDP2SHWITNESS), - '2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX') - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"), - False, None, script_type=proto_types.SPENDP2SHWITNESS), - '2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp') - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), - False, None, script_type=proto_types.SPENDP2SHWITNESS), - '2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc') - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), - False, None, script_type=proto_types.SPENDADDRESS), - 'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q') - - def test_show_multisig_3(self): - self.setup_mnemonic_allallall() - nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4)) - multisig1 = proto_types.MultisigRedeemScriptType( - pubkeys=map(lambda n: proto_types.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 0]), nodes), - signatures=[b'', b'', b''], - m=2, - ) - # multisig2 = proto_types.MultisigRedeemScriptType( - # pubkeys=map(lambda n: proto_types.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes), - # signatures=[b'', b'', b''], - # m=2, - # ) - for i in [1, 2, 3]: - self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i), - False, multisig1, script_type=proto_types.SPENDP2SHWITNESS), - '2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_getaddress_show.py python-trezor-0.9.0/tests/device_tests/test_msg_getaddress_show.py --- python-trezor-0.7.16/tests/device_tests/test_msg_getaddress_show.py 2017-06-23 19:03:57.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_getaddress_show.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common -import trezorlib.ckd_public as bip32 -import trezorlib.types_pb2 as proto_types - - -class TestMsgGetaddress(common.TrezorTest): - - def test_show(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertEqual(self.client.get_address('Bitcoin', [1], show_display=True), '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb') - self.assertEqual(self.client.get_address('Bitcoin', [2], show_display=True), '15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG') - self.assertEqual(self.client.get_address('Bitcoin', [3], show_display=True), '1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5') - - def test_show_multisig_3(self): - self.setup_mnemonic_nopin_nopassphrase() - - node = bip32.deserialize('xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy') - multisig = proto_types.MultisigRedeemScriptType( - pubkeys=[ - proto_types.HDNodePathType(node=node, address_n=[1]), - proto_types.HDNodePathType(node=node, address_n=[2]), - proto_types.HDNodePathType(node=node, address_n=[3]) - ], - signatures=[b'', b'', b''], - m=2, - ) - - for i in [1, 2, 3]: - self.assertEqual(self.client.get_address('Bitcoin', [i], show_display=True, multisig=multisig), '3E7GDtuHqnqPmDgwH59pVC7AvySiSkbibz') - - def test_show_multisig_15(self): - self.setup_mnemonic_nopin_nopassphrase() - - node = bip32.deserialize('xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy') - - pubs = [] - for x in range(15): - pubs.append(proto_types.HDNodePathType(node=node, address_n=[x])) - - multisig = proto_types.MultisigRedeemScriptType( - pubkeys=pubs, - signatures=[b''] * 15, - m=15, - ) - - for i in range(15): - self.assertEqual(self.client.get_address('Bitcoin', [i], show_display=True, multisig=multisig), '3QaKF8zobqcqY8aS6nxCD5ZYdiRfL3RCmU') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_getentropy.py python-trezor-0.9.0/tests/device_tests/test_msg_getentropy.py --- python-trezor-0.7.16/tests/device_tests/test_msg_getentropy.py 2017-06-23 19:00:40.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_getentropy.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -from __future__ import print_function - -import unittest -import math -import common - -import trezorlib.messages_pb2 as proto -import trezorlib.types_pb2 as proto_types - - -def entropy(data): - counts = {} - for c in data: - if c in counts: - counts[c] += 1 - else: - counts[c] = 1 - e = 0 - for _, v in counts.items(): - p = 1.0 * v / len(data) - e -= p * math.log(p, 256) - return e - - -class TestMsgGetentropy(common.TrezorTest): - - def test_entropy(self): - for l in [0, 1, 2, 3, 4, 5, 8, 9, 16, 17, 32, 33, 64, 65, 128, 129, 256, 257, 512, 513, 1024]: - with self.client: - self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Entropy()]) - ent = self.client.get_entropy(l) - self.assertTrue(len(ent) == l) - print('entropy = ', entropy(ent)) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_getpublickey.py python-trezor-0.9.0/tests/device_tests/test_msg_getpublickey.py --- python-trezor-0.7.16/tests/device_tests/test_msg_getpublickey.py 2017-06-23 19:01:21.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_getpublickey.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common -import trezorlib.ckd_public as bip32 - - -class TestMsgGetpublic_key(common.TrezorTest): - - def test_btc(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertEqual(bip32.serialize(self.client.get_public_node([]).node, 0x0488B21E), 'xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy') - self.assertEqual(bip32.serialize(self.client.get_public_node([1]).node, 0x0488B21E), 'xpub68zNxjsTrV8y9AadThLW7dTAqEpZ7xBLFSyJ3X9pjTv6Njg6kxgjXJkzxq8u3ttnjBw1jupQHMP3gpGZzZqd1eh5S4GjkaMhPR18vMyUi8N') - self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]).node, 0x0488B21E), 'xpub6A3FoZqYXj1AbW4thRwBh26YwZWbmoyjTaZwwxJjY1oKUpefLepL3RFS9DHKQrjAfxDrzDepYMDZPqXN6upQm3bHQ9xaXD5a3mqni3goF4v') - self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]).node, 0x0488B21E), 'xpub6A2h5mzLDfYginoD7q7wCWbq18wTbN9gducRr2w5NRTwdLeoT3cJSwefFqW7uXTpVFGtpUyDMBNYs3DNvvXx6NPjF9YEbUQrtxFSWnPtVrv') - self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]).node, 0x0488B21E), 'xpub6A3FoZqQEK6iwLZ4HFkqSo5fb35BH4bpjC4SPZ63prfLdGYPwYxEuC6o91bUvFFdMzKWe5rs3axHRUjxJaSvBnKKFtnfLwDACRxPxabsv2r') - - def test_ltc(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertEqual(bip32.serialize(self.client.get_public_node([]).node, 0x019dA462), 'Ltub2SSUS19CirucVPGDKDBatBDBEM2s9UbH66pBURfaKrMocCPLhQ7Z7hecy5VYLHA5fRdXwB2e61j2VJCNzVsqKTCVEU1vECjqi5EyczFX9xp') - self.assertEqual(bip32.serialize(self.client.get_public_node([1]).node, 0x019dA462), 'Ltub2VRVRP5VjvSyPXra4BLVyVZPv397sjhUNjBGsbtw6xko77JuQyBULxFSKheviJJ3KQLbL3Cx8P2RnudguTw4raUVjCACRG7jsumUptYx55C') - self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]).node, 0x019dA462), 'Ltub2WUNGD3aRAKAqsLqHuwBYtCn2MqAXbVsarmvn33quWe2DCHTzfK4s4jsW5oM5G8RGAdSaM3NPNrwVvtV1ourbyNhhHr3BtqcYGc8caf5GoT') - self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]).node, 0x019dA462), 'Ltub2WToYRCN76rgyA59iK7w4Ni45wG2M9fpmBpQg7gBjvJeMiHc7473Gb96ci29Zvs55TgUQcMmCD1vy8aVqpdPwJB9YHRhGAAuPT1nRLLXmFu') - self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]).node, 0x019dA462), 'Ltub2WUNGD3S7kQjBhpzsjkqJfBtfqPk2r7xrUGRDdqACMW3MeBCbZSyiqbEVt7WaeesxCj6EDFQtcbfXa75DUYN2i6jZ2g81cyCgvijs9J2u2n') - - def test_tbtc(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertEqual(bip32.serialize(self.client.get_public_node([111, 42]).node, 0x043587CF), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_loaddevice.py python-trezor-0.9.0/tests/device_tests/test_msg_loaddevice.py --- python-trezor-0.7.16/tests/device_tests/test_msg_loaddevice.py 2017-06-23 19:01:32.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_loaddevice.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - - -class TestDeviceLoad(common.TrezorTest): - - def test_load_device_1(self): - self.setup_mnemonic_nopin_nopassphrase() - - mnemonic = self.client.debug.read_mnemonic() - self.assertEqual(mnemonic, self.mnemonic12) - - pin = self.client.debug.read_pin()[0] - self.assertEqual(pin, '') - - passphrase_protection = self.client.debug.read_passphrase_protection() - self.assertEqual(passphrase_protection, False) - - address = self.client.get_address('Bitcoin', []) - self.assertEqual(address, '1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK') - - def test_load_device_2(self): - self.setup_mnemonic_pin_passphrase() - self.client.set_passphrase('passphrase') - - mnemonic = self.client.debug.read_mnemonic() - self.assertEqual(mnemonic, self.mnemonic12) - - pin = self.client.debug.read_pin()[0] - self.assertEqual(pin, self.pin4) - - passphrase_protection = self.client.debug.read_passphrase_protection() - self.assertEqual(passphrase_protection, True) - - address = self.client.get_address('Bitcoin', []) - self.assertEqual(address, '15fiTDFwZd2kauHYYseifGi9daH2wniDHH') - - def test_load_device_utf(self): - words_nfkd = u'Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a' - words_nfc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f' - words_nfkc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f' - words_nfd = u'Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a' - - passphrase_nfkd = u'Neuve\u030cr\u030citelne\u030c bezpec\u030cne\u0301 hesli\u0301c\u030cko' - passphrase_nfc = u'Neuv\u011b\u0159iteln\u011b bezpe\u010dn\xe9 hesl\xed\u010dko' - passphrase_nfkc = u'Neuv\u011b\u0159iteln\u011b bezpe\u010dn\xe9 hesl\xed\u010dko' - passphrase_nfd = u'Neuve\u030cr\u030citelne\u030c bezpec\u030cne\u0301 hesli\u0301c\u030cko' - - self.client.wipe_device() - self.client.load_device_by_mnemonic(mnemonic=words_nfkd, pin='', passphrase_protection=True, label='test', language='english', skip_checksum=True) - self.client.set_passphrase(passphrase_nfkd) - address_nfkd = self.client.get_address('Bitcoin', []) - - self.client.wipe_device() - self.client.load_device_by_mnemonic(mnemonic=words_nfc, pin='', passphrase_protection=True, label='test', language='english', skip_checksum=True) - self.client.set_passphrase(passphrase_nfc) - address_nfc = self.client.get_address('Bitcoin', []) - - self.client.wipe_device() - self.client.load_device_by_mnemonic(mnemonic=words_nfkc, pin='', passphrase_protection=True, label='test', language='english', skip_checksum=True) - self.client.set_passphrase(passphrase_nfkc) - address_nfkc = self.client.get_address('Bitcoin', []) - - self.client.wipe_device() - self.client.load_device_by_mnemonic(mnemonic=words_nfd, pin='', passphrase_protection=True, label='test', language='english', skip_checksum=True) - self.client.set_passphrase(passphrase_nfd) - address_nfd = self.client.get_address('Bitcoin', []) - - self.assertEqual(address_nfkd, address_nfc) - self.assertEqual(address_nfkd, address_nfkc) - self.assertEqual(address_nfkd, address_nfd) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_loaddevice_xprv.py python-trezor-0.9.0/tests/device_tests/test_msg_loaddevice_xprv.py --- python-trezor-0.7.16/tests/device_tests/test_msg_loaddevice_xprv.py 2017-06-23 18:58:17.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_loaddevice_xprv.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - - -class TestDeviceLoadXprv(common.TrezorTest): - - def test_load_device_xprv_1(self): - self.client.load_device_by_xprv(xprv='xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8imbZKLYVBxFPND1pniTZ81vKfd45EHKX73', pin='', passphrase_protection=False, label='test', language='english') - - passphrase_protection = self.client.debug.read_passphrase_protection() - self.assertEqual(passphrase_protection, False) - - address = self.client.get_address('Bitcoin', []) - self.assertEqual(address, '128RdrAkJDmqasgvfRf6MC5VcX4HKqH4mR') - - def test_load_device_xprv_2(self): - self.client.load_device_by_xprv(xprv='xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8imbZKLYVBxFPND1pniTZ81vKfd45EHKX73', pin='', passphrase_protection=True, label='test', language='english') - - self.client.set_passphrase('passphrase') - - passphrase_protection = self.client.debug.read_passphrase_protection() - self.assertEqual(passphrase_protection, True) - - address = self.client.get_address('Bitcoin', []) - self.assertEqual(address, '1CHUbFa4wTTPYgkYaw2LHSd5D4qJjMU8ri') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_ping.py python-trezor-0.9.0/tests/device_tests/test_msg_ping.py --- python-trezor-0.7.16/tests/device_tests/test_msg_ping.py 2017-06-23 19:01:23.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_ping.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - -from trezorlib import messages_pb2 as proto -from trezorlib import types_pb2 as proto_types - - -class TestPing(common.TrezorTest): - - def test_ping(self): - self.setup_mnemonic_pin_passphrase() - - with self.client: - self.client.set_expected_responses([proto.Success()]) - res = self.client.ping('random data') - self.assertEqual(res, 'random data') - - with self.client: - self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()]) - res = self.client.ping('random data', button_protection=True) - self.assertEqual(res, 'random data') - - with self.client: - self.client.set_expected_responses([proto.PinMatrixRequest(), proto.Success()]) - res = self.client.ping('random data', pin_protection=True) - self.assertEqual(res, 'random data') - - with self.client: - self.client.set_expected_responses([proto.PassphraseRequest(), proto.Success()]) - res = self.client.ping('random data', passphrase_protection=True) - self.assertEqual(res, 'random data') - - def test_ping_caching(self): - self.setup_mnemonic_pin_passphrase() - - with self.client: - self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()]) - res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True) - self.assertEqual(res, 'random data') - - with self.client: - # pin and passphrase are cached - self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()]) - res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True) - self.assertEqual(res, 'random data') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_recoverydevice_dryrun.py python-trezor-0.9.0/tests/device_tests/test_msg_recoverydevice_dryrun.py --- python-trezor-0.7.16/tests/device_tests/test_msg_recoverydevice_dryrun.py 2017-06-28 14:39:41.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_recoverydevice_dryrun.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -from __future__ import print_function - -import unittest -import common - -from trezorlib import messages_pb2 as proto - - -class TestDeviceRecoveryDryRun(common.TrezorTest): - - def recovery_loop(self, mnemonic, result): - ret = self.client.call_raw(proto.RecoveryDevice(word_count=12, - passphrase_protection=False, - pin_protection=False, - label='label', - language='english', - enforce_wordlist=True, - dry_run=True)) - - fakes = 0 - for _ in range(int(12 * 2)): - self.assertIsInstance(ret, proto.WordRequest) - (word, pos) = self.client.debug.read_recovery_word() - - if pos != 0: - ret = self.client.call_raw(proto.WordAck(word=mnemonic[pos - 1])) - mnemonic[pos - 1] = None - else: - ret = self.client.call_raw(proto.WordAck(word=word)) - fakes += 1 - - print(mnemonic) - - self.assertIsInstance(ret, proto.ButtonRequest) - self.client.debug.press_yes() - - ret = self.client.call_raw(proto.ButtonAck()) - self.assertIsInstance(ret, result) - - def test_correct_notsame(self): - self.setup_mnemonic_nopin_nopassphrase() - mnemonic = ['all'] * 12 - self.recovery_loop(mnemonic, proto.Failure) - - def test_correct_same(self): - self.setup_mnemonic_nopin_nopassphrase() - mnemonic = self.mnemonic12.split(' ') - self.recovery_loop(mnemonic, proto.Success) - - def test_incorrect(self): - self.setup_mnemonic_nopin_nopassphrase() - mnemonic = ['stick'] * 12 - self.recovery_loop(mnemonic, proto.Failure) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_recoverydevice.py python-trezor-0.9.0/tests/device_tests/test_msg_recoverydevice.py --- python-trezor-0.7.16/tests/device_tests/test_msg_recoverydevice.py 2017-06-26 13:31:10.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_recoverydevice.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -from __future__ import print_function - -import unittest -import common - -from trezorlib import messages_pb2 as proto - - -class TestDeviceRecovery(common.TrezorTest): - - def test_pin_passphrase(self): - mnemonic = self.mnemonic12.split(' ') - ret = self.client.call_raw(proto.RecoveryDevice(word_count=12, - passphrase_protection=True, - pin_protection=True, - label='label', - language='english', - enforce_wordlist=True)) - - self.assertIsInstance(ret, proto.PinMatrixRequest) - - # Enter PIN for first time - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - self.assertIsInstance(ret, proto.PinMatrixRequest) - - # Enter PIN for second time - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - fakes = 0 - for _ in range(int(12 * 2)): - self.assertIsInstance(ret, proto.WordRequest) - (word, pos) = self.client.debug.read_recovery_word() - - if pos != 0: - ret = self.client.call_raw(proto.WordAck(word=mnemonic[pos - 1])) - mnemonic[pos - 1] = None - else: - ret = self.client.call_raw(proto.WordAck(word=word)) - fakes += 1 - - print(mnemonic) - - # Workflow succesfully ended - self.assertIsInstance(ret, proto.Success) - - # 12 expected fake words and all words of mnemonic are used - self.assertEqual(fakes, 12) - self.assertEqual(mnemonic, [None] * 12) - - # Mnemonic is the same - self.client.init_device() - self.assertEqual(self.client.debug.read_mnemonic(), self.mnemonic12) - - self.assertTrue(self.client.features.pin_protection) - self.assertTrue(self.client.features.passphrase_protection) - - # Do passphrase-protected action, PassphraseRequest should be raised - resp = self.client.call_raw(proto.Ping(passphrase_protection=True)) - self.assertIsInstance(resp, proto.PassphraseRequest) - self.client.call_raw(proto.Cancel()) - - # Do PIN-protected action, PinRequest should be raised - resp = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(resp, proto.PinMatrixRequest) - self.client.call_raw(proto.Cancel()) - - def test_nopin_nopassphrase(self): - mnemonic = self.mnemonic12.split(' ') - ret = self.client.call_raw(proto.RecoveryDevice(word_count=12, - passphrase_protection=False, - pin_protection=False, - label='label', - language='english', - enforce_wordlist=True)) - - fakes = 0 - for _ in range(int(12 * 2)): - self.assertIsInstance(ret, proto.WordRequest) - (word, pos) = self.client.debug.read_recovery_word() - - if pos != 0: - ret = self.client.call_raw(proto.WordAck(word=mnemonic[pos - 1])) - mnemonic[pos - 1] = None - else: - ret = self.client.call_raw(proto.WordAck(word=word)) - fakes += 1 - - print(mnemonic) - - # Workflow succesfully ended - self.assertIsInstance(ret, proto.Success) - - # 12 expected fake words and all words of mnemonic are used - self.assertEqual(fakes, 12) - self.assertEqual(mnemonic, [None] * 12) - - # Mnemonic is the same - self.client.init_device() - self.assertEqual(self.client.debug.read_mnemonic(), self.mnemonic12) - - self.assertFalse(self.client.features.pin_protection) - self.assertFalse(self.client.features.passphrase_protection) - - # Do passphrase-protected action, PassphraseRequest should NOT be raised - resp = self.client.call_raw(proto.Ping(passphrase_protection=True)) - self.assertIsInstance(resp, proto.Success) - - # Do PIN-protected action, PinRequest should NOT be raised - resp = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(resp, proto.Success) - - def test_word_fail(self): - ret = self.client.call_raw(proto.RecoveryDevice(word_count=12, - passphrase_protection=False, - pin_protection=False, - label='label', - language='english', - enforce_wordlist=True)) - - self.assertIsInstance(ret, proto.WordRequest) - for _ in range(int(12 * 2)): - (word, pos) = self.client.debug.read_recovery_word() - if pos != 0: - ret = self.client.call_raw(proto.WordAck(word='kwyjibo')) - self.assertIsInstance(ret, proto.Failure) - break - else: - self.client.call_raw(proto.WordAck(word=word)) - - def test_pin_fail(self): - ret = self.client.call_raw(proto.RecoveryDevice(word_count=12, - passphrase_protection=True, - pin_protection=True, - label='label', - language='english', - enforce_wordlist=True)) - - self.assertIsInstance(ret, proto.PinMatrixRequest) - - # Enter PIN for first time - pin_encoded = self.client.debug.encode_pin(self.pin4) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - self.assertIsInstance(ret, proto.PinMatrixRequest) - - # Enter PIN for second time, but different one - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Failure should be raised - self.assertIsInstance(ret, proto.Failure) - - def test_already_initialized(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertRaises(Exception, self.client.recovery_device, 12, False, False, 'label', 'english') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_resetdevice.py python-trezor-0.9.0/tests/device_tests/test_msg_resetdevice.py --- python-trezor-0.7.16/tests/device_tests/test_msg_resetdevice.py 2017-06-28 15:54:26.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_resetdevice.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,209 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - -from trezorlib import messages_pb2 as proto -from mnemonic import Mnemonic - - -class TestDeviceReset(common.TrezorTest): - - def test_reset_device(self): - - # No PIN, no passphrase - external_entropy = b'zlutoucky kun upel divoke ody' * 2 - strength = 128 - - ret = self.client.call_raw(proto.ResetDevice( - display_random=False, - strength=strength, - passphrase_protection=False, - pin_protection=False, - language='english', - label='test' - )) - - # Provide entropy - self.assertIsInstance(ret, proto.EntropyRequest) - internal_entropy = self.client.debug.read_reset_entropy() - ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy)) - - # Generate mnemonic locally - entropy = common.generate_entropy(strength, internal_entropy, external_entropy) - expected_mnemonic = Mnemonic('english').to_mnemonic(entropy) - - mnemonic = [] - for _ in range(strength // 32 * 3): - self.assertIsInstance(ret, proto.ButtonRequest) - mnemonic.append(self.client.debug.read_reset_word()) - self.client.debug.press_yes() - self.client.call_raw(proto.ButtonAck()) - - mnemonic = ' '.join(mnemonic) - - # Compare that device generated proper mnemonic for given entropies - self.assertEqual(mnemonic, expected_mnemonic) - - mnemonic = [] - for _ in range(strength // 32 * 3): - self.assertIsInstance(ret, proto.ButtonRequest) - mnemonic.append(self.client.debug.read_reset_word()) - self.client.debug.press_yes() - resp = self.client.call_raw(proto.ButtonAck()) - - self.assertIsInstance(resp, proto.Success) - - mnemonic = ' '.join(mnemonic) - - # Compare that second pass printed out the same mnemonic once again - self.assertEqual(mnemonic, expected_mnemonic) - - # Check if device is properly initialized - resp = self.client.call_raw(proto.Initialize()) - self.assertTrue(resp.initialized) - self.assertFalse(resp.needs_backup) - self.assertFalse(resp.pin_protection) - self.assertFalse(resp.passphrase_protection) - - # Do passphrase-protected action, PassphraseRequest should NOT be raised - resp = self.client.call_raw(proto.Ping(passphrase_protection=True)) - self.assertIsInstance(resp, proto.Success) - - # Do PIN-protected action, PinRequest should NOT be raised - resp = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(resp, proto.Success) - - def test_reset_device_pin(self): - external_entropy = b'zlutoucky kun upel divoke ody' * 2 - strength = 128 - - ret = self.client.call_raw(proto.ResetDevice( - display_random=True, - strength=strength, - passphrase_protection=True, - pin_protection=True, - language='english', - label='test' - )) - - self.assertIsInstance(ret, proto.ButtonRequest) - self.client.debug.press_yes() - ret = self.client.call_raw(proto.ButtonAck()) - - self.assertIsInstance(ret, proto.PinMatrixRequest) - - # Enter PIN for first time - pin_encoded = self.client.debug.encode_pin('654') - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - self.assertIsInstance(ret, proto.PinMatrixRequest) - - # Enter PIN for second time - pin_encoded = self.client.debug.encode_pin('654') - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - # Provide entropy - self.assertIsInstance(ret, proto.EntropyRequest) - internal_entropy = self.client.debug.read_reset_entropy() - ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy)) - - # Generate mnemonic locally - entropy = common.generate_entropy(strength, internal_entropy, external_entropy) - expected_mnemonic = Mnemonic('english').to_mnemonic(entropy) - - mnemonic = [] - for _ in range(strength // 32 * 3): - self.assertIsInstance(ret, proto.ButtonRequest) - mnemonic.append(self.client.debug.read_reset_word()) - self.client.debug.press_yes() - self.client.call_raw(proto.ButtonAck()) - - mnemonic = ' '.join(mnemonic) - - # Compare that device generated proper mnemonic for given entropies - self.assertEqual(mnemonic, expected_mnemonic) - - mnemonic = [] - for _ in range(strength // 32 * 3): - self.assertIsInstance(ret, proto.ButtonRequest) - mnemonic.append(self.client.debug.read_reset_word()) - self.client.debug.press_yes() - resp = self.client.call_raw(proto.ButtonAck()) - - self.assertIsInstance(resp, proto.Success) - - mnemonic = ' '.join(mnemonic) - - # Compare that second pass printed out the same mnemonic once again - self.assertEqual(mnemonic, expected_mnemonic) - - # Check if device is properly initialized - resp = self.client.call_raw(proto.Initialize()) - self.assertTrue(resp.initialized) - self.assertFalse(resp.needs_backup) - self.assertTrue(resp.pin_protection) - self.assertTrue(resp.passphrase_protection) - - # Do passphrase-protected action, PassphraseRequest should be raised - resp = self.client.call_raw(proto.Ping(passphrase_protection=True)) - self.assertIsInstance(resp, proto.PassphraseRequest) - self.client.call_raw(proto.Cancel()) - - # Do PIN-protected action, PinRequest should be raised - resp = self.client.call_raw(proto.Ping(pin_protection=True)) - self.assertIsInstance(resp, proto.PinMatrixRequest) - self.client.call_raw(proto.Cancel()) - - def test_failed_pin(self): - # external_entropy = b'zlutoucky kun upel divoke ody' * 2 - strength = 128 - - ret = self.client.call_raw(proto.ResetDevice( - display_random=True, - strength=strength, - passphrase_protection=True, - pin_protection=True, - language='english', - label='test' - )) - - self.assertIsInstance(ret, proto.ButtonRequest) - self.client.debug.press_yes() - ret = self.client.call_raw(proto.ButtonAck()) - - self.assertIsInstance(ret, proto.PinMatrixRequest) - - # Enter PIN for first time - pin_encoded = self.client.debug.encode_pin(self.pin4) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - self.assertIsInstance(ret, proto.PinMatrixRequest) - - # Enter PIN for second time - pin_encoded = self.client.debug.encode_pin(self.pin6) - ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) - - self.assertIsInstance(ret, proto.Failure) - - def test_already_initialized(self): - self.setup_mnemonic_nopin_nopassphrase() - self.assertRaises(Exception, self.client.reset_device, False, 128, True, True, 'label', 'english') - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_resetdevice_skipbackup.py python-trezor-0.9.0/tests/device_tests/test_msg_resetdevice_skipbackup.py --- python-trezor-0.7.16/tests/device_tests/test_msg_resetdevice_skipbackup.py 2017-06-28 16:03:45.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_resetdevice_skipbackup.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -import unittest -import common - -from trezorlib import messages_pb2 as proto -from mnemonic import Mnemonic - - -class TestDeviceResetSkipBackup(common.TrezorTest): - - def test_reset_device_skip_backup(self): - - external_entropy = b'zlutoucky kun upel divoke ody' * 2 - strength = 128 - - ret = self.client.call_raw(proto.ResetDevice( - display_random=False, - strength=strength, - passphrase_protection=False, - pin_protection=False, - language='english', - label='test', - skip_backup=True - )) - - # Provide entropy - self.assertIsInstance(ret, proto.EntropyRequest) - internal_entropy = self.client.debug.read_reset_entropy() - ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy)) - self.assertIsInstance(ret, proto.Success) - - # Check if device is properly initialized - resp = self.client.call_raw(proto.Initialize()) - self.assertTrue(resp.initialized) - self.assertTrue(resp.needs_backup) - - # Generate mnemonic locally - entropy = common.generate_entropy(strength, internal_entropy, external_entropy) - expected_mnemonic = Mnemonic('english').to_mnemonic(entropy) - - # start Backup workflow - ret = self.client.call_raw(proto.BackupDevice()) - - mnemonic = [] - for _ in range(strength // 32 * 3): - self.assertIsInstance(ret, proto.ButtonRequest) - mnemonic.append(self.client.debug.read_reset_word()) - self.client.debug.press_yes() - self.client.call_raw(proto.ButtonAck()) - - mnemonic = ' '.join(mnemonic) - - # Compare that device generated proper mnemonic for given entropies - self.assertEqual(mnemonic, expected_mnemonic) - - mnemonic = [] - for _ in range(strength // 32 * 3): - self.assertIsInstance(ret, proto.ButtonRequest) - mnemonic.append(self.client.debug.read_reset_word()) - self.client.debug.press_yes() - resp = self.client.call_raw(proto.ButtonAck()) - - self.assertIsInstance(resp, proto.Success) - - mnemonic = ' '.join(mnemonic) - - # Compare that second pass printed out the same mnemonic once again - self.assertEqual(mnemonic, expected_mnemonic) - - # start backup again - should fail - ret = self.client.call_raw(proto.BackupDevice()) - self.assertIsInstance(ret, proto.Failure) - - def test_initialized_device_backup_fail(self): - self.setup_mnemonic_nopin_nopassphrase() - ret = self.client.call_raw(proto.BackupDevice()) - self.assertIsInstance(ret, proto.Failure) - - -if __name__ == '__main__': - unittest.main() diff -Nru python-trezor-0.7.16/tests/device_tests/test_msg_signidentity.py python-trezor-0.9.0/tests/device_tests/test_msg_signidentity.py --- python-trezor-0.7.16/tests/device_tests/test_msg_signidentity.py 2017-06-23 19:02:49.000000000 +0000 +++ python-trezor-0.9.0/tests/device_tests/test_msg_signidentity.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -# This file is part of the TREZOR project. -# -# Copyright (C) 2012-2016 Marek Palatinus -# Copyright (C) 2012-2016 Pavol Rusnak -# -# This library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . - -from __future__ import print_function - -import unittest -import binascii -import hashlib -import struct -import common - -import trezorlib.types_pb2 as proto_types - - -def check_path(identity): - m = hashlib.sha256() - m.update(struct.pack("