1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-19 14:08:11 +00:00

add layout to u2f app

This commit is contained in:
Pavol Rusnak 2016-07-04 17:01:34 +02:00
parent cd28103b75
commit 545e93d1b4
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 44 additions and 6 deletions

View File

@ -0,0 +1,2 @@
def boot():
pass

View File

@ -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',
}

View File

@ -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([])