diff --git a/src/apps/fido_u2f/__init__.py b/src/apps/fido_u2f/__init__.py index e69de29bb2..7a9be83911 100644 --- a/src/apps/fido_u2f/__init__.py +++ b/src/apps/fido_u2f/__init__.py @@ -0,0 +1,2 @@ +def boot(): + pass diff --git a/src/apps/fido_u2f/knownapps.py b/src/apps/fido_u2f/knownapps.py index 585ac82b5e..d56c729b11 100644 --- a/src/apps/fido_u2f/knownapps.py +++ b/src/apps/fido_u2f/knownapps.py @@ -1,8 +1,10 @@ +from trezor.crypto import hashlib + knownapps = { - b'12743b921297b77f1135e41fdedd4a846afe82e1f36932a9912f3b0d8dfb7d0e': 'Bitbucket', # https://bitbucket.org - b'c50f8a7b708e92f82e7a50e2bdc55d8fd91a22fe6b29c0cdf7805530842af581': 'Dropbox', # https://www.dropbox.com/u2f-app-id.json - b'70617dfed065863af47c15556c91798880828cc407fdf70ae85011569465a075': 'Github', # https://github.com/u2f/trusted_facets - b'e7be96a51bd0192a72840d2e5909f72ba82a2fe93faa624f03396b30e494c804': 'Gitlab', # https://gitlab.com - b'a54672b222c4cf95e151ed8d4d3c767a6cc349435943794e884f3d023a8229fd': 'Google', # https://www.gstatic.com/securitykey/origins.json - b'08b2a3d41939aa31668493cb36cdcc4f16c4d9b4c8238b73c2f672c033007197': 'Slush Pool', # https://slushpool.com/static/security/u2f.json + hashlib.sha256(b'https://bitbucket.org').digest() : 'Bitbucket', + hashlib.sha256(b'https://www.dropbox.com/u2f-app-id.json').digest() : 'Dropbox', + hashlib.sha256(b'https://github.com/u2f/trusted_facets').digest() : 'GitHub', + hashlib.sha256(b'https://gitlab.com').digest() : 'GitLab', + hashlib.sha256(b'https://www.gstatic.com/securitykey/origins.json').digest() : 'Google', + hashlib.sha256(b'https://slushpool.com/static/security/u2f.json').digest() : 'Slush Pool', } diff --git a/src/apps/fido_u2f/layout_u2f.py b/src/apps/fido_u2f/layout_u2f.py new file mode 100644 index 0000000000..27792bb4ae --- /dev/null +++ b/src/apps/fido_u2f/layout_u2f.py @@ -0,0 +1,34 @@ +from ubinascii import hexlify +from trezor import ui, loop, res +from trezor.utils import unimport_gen +from trezor.crypto import random +from . import knownapps + +ids = list(knownapps.knownapps.keys()) +random.shuffle(ids) + +appid = ids[0] +action = 'Register' + +@unimport_gen +def layout_u2f(): + + if appid in knownapps.knownapps: + appname = knownapps.knownapps[appid] + appicon = res.load('apps/fido_u2f/res/u2f_%s.toif' % appname.lower().replace(' ', '_')) + else: + appname = hexlify(appid[:4]) + '...' + hexlify(appid[-4:]) + appicon = res.load('apps/fido_u2f/res/u2f_unknown.toif') + + # paint background black + ui.display.bar(0, 0, 240, 240, ui.BLACK) + + # top header bar + ui.display.text(10, 28, 'U2F Login', ui.BOLD, ui.PM_BLUE, ui.BLACK) + + # content + ui.display.text_center(120, 70, '%s:' % action, ui.BOLD, ui.GREY, ui.BLACK) + ui.display.image((240 - 64) // 2, 90, appicon) + ui.display.text_center(120, 185, appname, ui.MONO, ui.WHITE, ui.BLACK) + + yield loop.Wait([])