mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 12:28:09 +00:00
feat(core): Implement GetNonce command.
This commit is contained in:
parent
0959947a88
commit
2ac3d0acb4
@ -332,8 +332,6 @@ apps.homescreen.homescreen
|
|||||||
import apps.homescreen.homescreen
|
import apps.homescreen.homescreen
|
||||||
apps.homescreen.lockscreen
|
apps.homescreen.lockscreen
|
||||||
import apps.homescreen.lockscreen
|
import apps.homescreen.lockscreen
|
||||||
apps.management
|
|
||||||
import apps.management
|
|
||||||
apps.management.apply_flags
|
apps.management.apply_flags
|
||||||
import apps.management.apply_flags
|
import apps.management.apply_flags
|
||||||
apps.management.apply_settings
|
apps.management.apply_settings
|
||||||
@ -348,6 +346,8 @@ apps.management.change_wipe_code
|
|||||||
import apps.management.change_wipe_code
|
import apps.management.change_wipe_code
|
||||||
apps.management.get_next_u2f_counter
|
apps.management.get_next_u2f_counter
|
||||||
import apps.management.get_next_u2f_counter
|
import apps.management.get_next_u2f_counter
|
||||||
|
apps.management.get_nonce
|
||||||
|
import apps.management.get_nonce
|
||||||
apps.management.recovery_device
|
apps.management.recovery_device
|
||||||
import apps.management.recovery_device
|
import apps.management.recovery_device
|
||||||
apps.management.recovery_device.homescreen
|
apps.management.recovery_device.homescreen
|
||||||
|
10
core/src/apps/management/get_nonce.py
Normal file
10
core/src/apps/management/get_nonce.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from storage import cache
|
||||||
|
from trezor import wire
|
||||||
|
from trezor.crypto import random
|
||||||
|
from trezor.messages import GetNonce, Nonce
|
||||||
|
|
||||||
|
|
||||||
|
async def get_nonce(ctx: wire.Context, msg: GetNonce) -> Nonce:
|
||||||
|
nonce = random.bytes(32)
|
||||||
|
cache.set(cache.APP_COMMON_NONCE, nonce)
|
||||||
|
return Nonce(nonce=nonce)
|
@ -18,11 +18,12 @@ _SESSION_ID_LENGTH = 32
|
|||||||
APP_COMMON_SEED = 0
|
APP_COMMON_SEED = 0
|
||||||
APP_COMMON_AUTHORIZATION_TYPE = 1
|
APP_COMMON_AUTHORIZATION_TYPE = 1
|
||||||
APP_COMMON_AUTHORIZATION_DATA = 2
|
APP_COMMON_AUTHORIZATION_DATA = 2
|
||||||
|
APP_COMMON_NONCE = 3
|
||||||
if not utils.BITCOIN_ONLY:
|
if not utils.BITCOIN_ONLY:
|
||||||
APP_COMMON_DERIVE_CARDANO = 3
|
APP_COMMON_DERIVE_CARDANO = 4
|
||||||
APP_CARDANO_ICARUS_SECRET = 4
|
APP_CARDANO_ICARUS_SECRET = 5
|
||||||
APP_CARDANO_ICARUS_TREZOR_SECRET = 5
|
APP_CARDANO_ICARUS_TREZOR_SECRET = 6
|
||||||
APP_MONERO_LIVE_REFRESH = 6
|
APP_MONERO_LIVE_REFRESH = 7
|
||||||
|
|
||||||
# Keys that are valid across sessions
|
# Keys that are valid across sessions
|
||||||
APP_COMMON_SEED_WITHOUT_PASSPHRASE = 0 | _SESSIONLESS_FLAG
|
APP_COMMON_SEED_WITHOUT_PASSPHRASE = 0 | _SESSIONLESS_FLAG
|
||||||
@ -95,12 +96,14 @@ class SessionCache(DataCache):
|
|||||||
64, # APP_COMMON_SEED
|
64, # APP_COMMON_SEED
|
||||||
2, # APP_COMMON_AUTHORIZATION_TYPE
|
2, # APP_COMMON_AUTHORIZATION_TYPE
|
||||||
128, # APP_COMMON_AUTHORIZATION_DATA
|
128, # APP_COMMON_AUTHORIZATION_DATA
|
||||||
|
32, # APP_COMMON_NONCE
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.fields = (
|
self.fields = (
|
||||||
64, # APP_COMMON_SEED
|
64, # APP_COMMON_SEED
|
||||||
2, # APP_COMMON_AUTHORIZATION_TYPE
|
2, # APP_COMMON_AUTHORIZATION_TYPE
|
||||||
128, # APP_COMMON_AUTHORIZATION_DATA
|
128, # APP_COMMON_AUTHORIZATION_DATA
|
||||||
|
32, # APP_COMMON_NONCE
|
||||||
1, # APP_COMMON_DERIVE_CARDANO
|
1, # APP_COMMON_DERIVE_CARDANO
|
||||||
96, # APP_CARDANO_ICARUS_SECRET
|
96, # APP_CARDANO_ICARUS_SECRET
|
||||||
96, # APP_CARDANO_ICARUS_TREZOR_SECRET
|
96, # APP_CARDANO_ICARUS_TREZOR_SECRET
|
||||||
|
Loading…
Reference in New Issue
Block a user