mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-19 13:08:14 +00:00
WIP - returning None instead of empty bytes
This commit is contained in:
parent
c9f247b75e
commit
cc02e8892c
@ -12,7 +12,6 @@ use core::convert::{TryFrom, TryInto};
|
||||
|
||||
// MISSING FUNCTIONALITY:
|
||||
// - returning strings into python
|
||||
// - return either bytes or None
|
||||
|
||||
const FLAG_PUBLIC: u8 = 0x80;
|
||||
|
||||
@ -143,7 +142,10 @@ extern "C" fn storagedevice_get_label() -> Obj {
|
||||
let block = || {
|
||||
let key = _get_appkey(_LABEL, true);
|
||||
let result = &storagedevice_storage_get(key) as &[u8];
|
||||
// TODO: return None in case it is empty
|
||||
if result.is_empty() {
|
||||
// TODO: it did not work with None::<&[u8]>, but it should not matter
|
||||
return Ok(None::<u16>.into());
|
||||
}
|
||||
// TODO: how to convert into a string?
|
||||
// let label = StrBuffer::try_from(*result)?;
|
||||
result.try_into()
|
||||
@ -269,6 +271,9 @@ extern "C" fn storagedevice_get_homescreen() -> Obj {
|
||||
let block = || {
|
||||
let key = _get_appkey(_HOMESCREEN, false);
|
||||
let result = &storagedevice_storage_get_homescreen(key) as &[u8];
|
||||
if result.is_empty() {
|
||||
return Ok(None::<u16>.into());
|
||||
}
|
||||
result.try_into()
|
||||
};
|
||||
unsafe { util::try_or_raise(block) }
|
||||
|
@ -1,67 +1,67 @@
|
||||
from typing import *
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def is_version_stored() -> bool:
|
||||
"""Whether version is in storage."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def is_initialized() -> bool:
|
||||
"""Whether device is initialized."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def get_version() -> bytes:
|
||||
"""Get version."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_version(version: bytes) -> bool:
|
||||
"""Set version."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def get_rotation() -> int:
|
||||
"""Get rotation."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_rotation(rotation: int) -> bool:
|
||||
"""Set rotation."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def get_label() -> str | None:
|
||||
"""Get label."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_label(label: str) -> bool:
|
||||
"""Set label."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def get_mnemonic_secret() -> bytes:
|
||||
"""Get mnemonic secret."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def is_passphrase_enabled() -> bool:
|
||||
"""Whether passphrase is enabled."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_passphrase_enabled(enable: bool) -> bool:
|
||||
"""Set whether passphrase is enabled."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def get_passphrase_always_on_device() -> bool:
|
||||
"""Whether passphrase is on device."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_passphrase_always_on_device(enable: bool) -> bool:
|
||||
"""Set whether passphrase is on device.
|
||||
This is backwards compatible with _PASSPHRASE_SOURCE:
|
||||
@ -71,47 +71,47 @@ def set_passphrase_always_on_device(enable: bool) -> bool:
|
||||
"""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def unfinished_backup() -> bool:
|
||||
"""Whether backup is still in progress."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_unfinished_backup(state: bool) -> bool:
|
||||
"""Set backup state."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def needs_backup() -> bool:
|
||||
"""Whether backup is needed."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_backed_up() -> bool:
|
||||
"""Signal that backup is finished."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def no_backup() -> bool:
|
||||
"""Whether there is no backup."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def get_homescreen() -> bytes | None:
|
||||
"""Get homescreen."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_homescreen(homescreen: bytes) -> bool:
|
||||
"""Set homescreen."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def get_slip39_identifier() -> int | None:
|
||||
"""The device's actual SLIP-39 identifier used in passphrase derivation."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_slip39_identifier(identifier: int) -> bool:
|
||||
"""
|
||||
The device's actual SLIP-39 identifier used in passphrase derivation.
|
||||
@ -120,12 +120,12 @@ def set_slip39_identifier(identifier: int) -> bool:
|
||||
"""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def get_slip39_iteration_exponent() -> int | None:
|
||||
"""The device's actual SLIP-39 iteration exponent used in passphrase derivation."""
|
||||
|
||||
|
||||
# rust/src/storagedevice/storagedevice.rs
|
||||
# rust/src/storagedevice/storage_device.rs
|
||||
def set_slip39_iteration_exponent(exponent: int) -> bool:
|
||||
"""
|
||||
The device's actual SLIP-39 iteration exponent used in passphrase derivation.
|
||||
|
Loading…
Reference in New Issue
Block a user