Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions core/embed/extmod/modtrezorcrypto/modtrezorcrypto-random.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,43 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_random_uniform_obj,
mod_trezorcrypto_random_uniform);

/// import builtins
/// def bytes(len: int) -> builtins.bytes:
/// def bytes(len: int, source: int = 1) -> builtins.bytes:
/// """
/// Generate random bytes sequence of length len.
/// source: 0 = use random_buffer, 1 = use se_random_encrypted (default)
/// """
STATIC mp_obj_t mod_trezorcrypto_random_bytes(mp_obj_t len) {
uint32_t l = trezor_obj_get_uint(len);
STATIC mp_obj_t mod_trezorcrypto_random_bytes(size_t n_args,
const mp_obj_t *args) {
uint32_t l = trezor_obj_get_uint(args[0]);
if (l > 1024) {
mp_raise_ValueError("Maximum requested size is 1024");
}

// Default to 1 (se_random_encrypted) if source not provided
uint32_t source = 1;
if (n_args > 1) {
source = trezor_obj_get_uint(args[1]);
}

vstr_t vstr = {0};
vstr_init_len(&vstr, l);

if (source == 0) {
random_buffer((uint8_t *)vstr.buf, l);
} else {
#if USE_THD89
if (sectrue != se_random_encrypted((uint8_t *)vstr.buf, l)) {
mp_raise_ValueError("se_random_encrypted failed");
}
if (sectrue != se_random_encrypted((uint8_t *)vstr.buf, l)) {
mp_raise_ValueError("se_random_encrypted failed");
}
#else
random_buffer((uint8_t *)vstr.buf, l);
random_buffer((uint8_t *)vstr.buf, l);
#endif
}

return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_random_bytes_obj,
mod_trezorcrypto_random_bytes);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorcrypto_random_bytes_obj, 1,
2, mod_trezorcrypto_random_bytes);

/// def shuffle(data: list) -> None:
/// """
Expand Down
3 changes: 2 additions & 1 deletion core/mocks/generated/trezorcrypto/random.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import builtins


# extmod/modtrezorcrypto/modtrezorcrypto-random.h
def bytes(len: int) -> builtins.bytes:
def bytes(len: int, source: int = 1) -> builtins.bytes:
"""
Generate random bytes sequence of length len.
source: 0 = use random_buffer, 1 = use se_random_encrypted (default)
"""


Expand Down
13 changes: 10 additions & 3 deletions core/src/apps/management/reset_device/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
_DEFAULT_BACKUP_TYPE = B39


async def reset_device(ctx: wire.GenericContext, msg: ResetDevice) -> Success:
async def reset_device(
ctx: wire.GenericContext, msg: ResetDevice, use_multiple_entropy: bool = False
) -> Success:
# validate parameters and device state
_validate_reset_device(msg)

Expand All @@ -42,8 +44,13 @@ async def reset_device(ctx: wire.GenericContext, msg: ResetDevice) -> Success:
await layout.show_internal_entropy(ctx, int_entropy)

# request external entropy and compute the master secret
entropy_ack = await ctx.call(EntropyRequest(), EntropyAck)
ext_entropy = entropy_ack.entropy if entropy_ack else b""
if use_multiple_entropy:
# Use MCU random number generator (source=0) for external entropy
ext_entropy = random.bytes(32, 0)
else:
# Request external entropy from host
entropy_ack = await ctx.call(EntropyRequest(), EntropyAck)
ext_entropy = entropy_ack.entropy if entropy_ack else b""
# If either of skip_backup or no_backup is specified, we are not doing backup now.
# Otherwise, we try to do it.
perform_backup = not msg.no_backup and not msg.skip_backup
Expand Down
16 changes: 12 additions & 4 deletions core/src/trezor/lvglui/i18n/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2295,10 +2295,10 @@
# BTC, TRON, SOL, ETH, BNB ...
CONTENT__BTC_TRON_SOL_ETH_BNB = 1041
# Some crypto assets and hardware features are unavailable in QR Code communic
# ation mode. \nThis mode is intended only for a small number of users who rar
# ely operate their hardware wallet and is not compatible with other connectio
# n methods. \nIf you wish to connect your hardware wallet via Bluetooth or US
# B, please re-add the wallet to switch the communication mode.
# ation mode. \n\nThis mode is intended only for a small number of users who r
# arely operate their hardware wallet and is not compatible with other connect
# ion methods. \n\nIf you wish to connect your hardware wallet via Bluetooth o
# r USB, please re-add the wallet to switch the communication mode.
TITLE__QR_CODE_CONNECT_DESC = 1042
# Select the way to connect. \nTo use the QR code connection, tap "More" in th
# e top right corner.
Expand All @@ -2311,4 +2311,12 @@
BUTTON__CONTINUE_WITH_QR_CODE = 1046
# Connect OneKey App Wallet
TITLE_BTC_ONLY_CONNECT_WALLET = 1047
# Advanced Options
TITLE__ADVANCED_OPTIONS = 1048
# Use multiple sources of entropy
BUTTON__USE_MULTIPLE_SOURCES_OF_ENTROPY = 1049
# By default, the device uses the secure element to generate mnemonic phrases.
# When enabled, entropy from both the MCU and secure element will be combined
# . Both methods meet cryptographic security standards.
BUTTON__USE_MULTIPLE_SOURCES_OF_ENTROPY_DESC = 1050
# fmt: on
5 changes: 4 additions & 1 deletion core/src/trezor/lvglui/i18n/locales/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,14 @@
"Die Anzahl der Wörter in deiner Seed-Phrase beeinträchtigt ihre Sicherheit nicht; alle sind kryptografisch sicher.",
"Dynamischer QR-Code",
"BTC, TRON, SOL, ETH, BNB ...",
"Einige Krypto-Assets und Hardware-Funktionen sind im QR-Code-Kommunikationsmodus nicht verfügbar. \nDieser Modus ist nur für eine kleine Anzahl von Benutzern gedacht, die ihr Hardware-Wallet selten verwenden, und ist nicht mit anderen Verbindungsmethoden kompatibel. \nWenn Sie Ihr Hardware-Wallet über Bluetooth oder USB verbinden möchten, fügen Sie das Wallet bitte erneut hinzu, um den Kommunikationsmodus zu wechseln.",
"Einige Krypto-Assets und Hardware-Funktionen sind im QR-Code-Kommunikationsmodus nicht verfügbar. \n\nDieser Modus ist nur für eine kleine Anzahl von Benutzern gedacht, die ihr Hardware-Wallet selten verwenden, und ist nicht mit anderen Verbindungsmethoden kompatibel. \n\nWenn Sie Ihr Hardware-Wallet über Bluetooth oder USB verbinden möchten, fügen Sie das Wallet bitte erneut hinzu, um den Kommunikationsmodus zu wechseln.",
"Wählen Sie die Verbindungsart aus. \nUm die Verbindung per QR-Code zu verwenden, tippen Sie oben rechts auf \"Mehr\".",
"Fortschrittlich",
"Gefahrenzone",
"Mit QR-Code fortfahren",
"OneKey App Wallet verbinden",
"Erweiterte Optionen",
"Verwenden Sie mehrere Entropiequellen",
"Standardmäßig verwendet das Gerät das Secure Element, um mnemonische Phrasen zu erzeugen. Wenn aktiviert, wird Entropie sowohl vom MCU als auch vom Secure Element kombiniert. Beide Methoden erfüllen kryptografische Sicherheitsstandards.",
]
# fmt: on
5 changes: 4 additions & 1 deletion core/src/trezor/lvglui/i18n/locales/en.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,14 @@
"The number of words in your seed phrase doesn't affect its security, all are cryptographically secure.",
"Show Dynamic QR Code",
"BTC, TRON, SOL, ETH, BNB ...",
"Some crypto assets and hardware features are unavailable in QR Code communication mode. \nThis mode is intended only for a small number of users who rarely operate their hardware wallet and is not compatible with other connection methods. \nIf you wish to connect your hardware wallet via Bluetooth or USB, please re-add the wallet to switch the communication mode.",
"Some crypto assets and hardware features are unavailable in QR Code communication mode. \n\nThis mode is intended only for a small number of users who rarely operate their hardware wallet and is not compatible with other connection methods. \n\nIf you wish to connect your hardware wallet via Bluetooth or USB, please re-add the wallet to switch the communication mode.",
"Select the way to connect. \nTo use the QR code connection, tap \"More\" in the top right corner.",
"Advanced",
"Danger Zone",
"Continue with QR Code",
"Connect OneKey App Wallet",
"Advanced Options",
"Use multiple sources of entropy",
"By default, the device uses the secure element to generate mnemonic phrases. When enabled, entropy from both the MCU and secure element will be combined. Both methods meet cryptographic security standards.",
]
# fmt: on
5 changes: 4 additions & 1 deletion core/src/trezor/lvglui/i18n/locales/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,14 @@
"La cantidad de palabras en tu frase semilla no afecta su seguridad; todas son criptográficamente seguras.",
"Mostrar código QR dinámico",
"BTC, TRON, SOL, ETH, BNB ...",
"Algunos activos cripto y funciones de hardware no están disponibles en el modo de comunicación por código QR. \nEste modo está destinado únicamente a un pequeño número de usuarios que operan raramente su billetera de hardware y no es compatible con otros métodos de conexión. \nSi desea conectar su billetera de hardware a través de Bluetooth o USB, vuelva a agregar la billetera para cambiar el modo de comunicación.",
"Algunos activos cripto y funciones de hardware no están disponibles en el modo de comunicación por código QR. \n\nEste modo está destinado únicamente a un pequeño número de usuarios que operan raramente su billetera de hardware y no es compatible con otros métodos de conexión. \n\nSi desea conectar su billetera de hardware a través de Bluetooth o USB, vuelva a agregar la billetera para cambiar el modo de comunicación.",
"Selecciona la forma de conectarte. \nPara usar la conexión mediante código QR, toca \"Más\" en la esquina superior derecha.",
"Avanzado",
"Zona peligrosa",
"Continuar con código QR",
"Conectar OneKey App Wallet",
"Opciones avanzadas",
"Usa múltiples fuentes de entropía",
"De forma predeterminada, el dispositivo utiliza el elemento seguro para generar frases mnemotécnicas. Cuando está habilitado, se combinará la entropía tanto del MCU como del elemento seguro. Ambos métodos cumplen con los estándares de seguridad criptográfica.",
]
# fmt: on
5 changes: 4 additions & 1 deletion core/src/trezor/lvglui/i18n/locales/fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,14 @@
"Le nombre de mots dans votre phrase de récupération n'affecte pas sa sécurité, toutes sont cryptographiquement sécurisées.",
"Code QR dynamique",
"BTC, TRON, SOL, ETH, BNB ...",
"Certains actifs cryptographiques et fonctionnalités matérielles ne sont pas disponibles en mode de communication par code QR. \nCe mode est destiné uniquement à un petit nombre d'utilisateurs qui utilisent rarement leur portefeuille matériel et n'est pas compatible avec d'autres méthodes de connexion. \nSi vous souhaitez connecter votre portefeuille matériel via Bluetooth ou USB, veuillez rajouter le portefeuille pour changer le mode de communication.",
"Certains actifs cryptographiques et fonctionnalités matérielles ne sont pas disponibles en mode de communication par code QR. \n\nCe mode est destiné uniquement à un petit nombre d'utilisateurs qui utilisent rarement leur portefeuille matériel et n'est pas compatible avec d'autres méthodes de connexion. \n\nSi vous souhaitez connecter votre portefeuille matériel via Bluetooth ou USB, veuillez rajouter le portefeuille pour changer le mode de communication.",
"Sélectionnez le mode de connexion. \nPour utiliser la connexion par code QR, appuyez sur « Plus » dans le coin supérieur droit.",
"Avancé",
"Zone de danger",
"Continuer avec le code QR",
"Connecter le portefeuille OneKey App",
"Options avancées",
"Utiliser plusieurs sources d'entropie",
"Par défaut, l'appareil utilise l'élément sécurisé pour générer des phrases mnémoniques. Lorsque cette option est activée, l'entropie du MCU et de l'élément sécurisé sera combinée. Les deux méthodes répondent aux normes de sécurité cryptographique.",
]
# fmt: on
5 changes: 4 additions & 1 deletion core/src/trezor/lvglui/i18n/locales/it.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,14 @@
"Il numero di parole nella tua seed phrase non influisce sulla sua sicurezza: tutte sono crittograficamente sicure.",
"Mostra codice QR dinamico",
"BTC, TRON, SOL, ETH, BNB ...",
"Alcuni asset crypto e funzionalità hardware non sono disponibili nella modalità di comunicazione tramite codice QR. \nQuesta modalità è destinata solo a un numero limitato di utenti che utilizzano raramente il proprio portafoglio hardware e non è compatibile con altri metodi di connessione. \nSe desideri connettere il tuo portafoglio hardware tramite Bluetooth o USB, aggiungi nuovamente il portafoglio per cambiare la modalità di comunicazione.",
"Alcuni asset crypto e funzionalità hardware non sono disponibili nella modalità di comunicazione tramite codice QR. \n\nQuesta modalità è destinata solo a un numero limitato di utenti che utilizzano raramente il proprio portafoglio hardware e non è compatibile con altri metodi di connessione. \n\nSe desideri connettere il tuo portafoglio hardware tramite Bluetooth o USB, aggiungi nuovamente il portafoglio per cambiare la modalità di comunicazione.",
"Seleziona il modo di connetterti. \nPer usare la connessione tramite QR code, tocca \"Altro\" nell'angolo in alto a destra.",
"Avanzate",
"Zona pericolosa",
"Continua con codice QR",
"Collega il wallet OneKey App",
"Opzioni avanzate",
"Usa più fonti di entropia",
"Per impostazione predefinita, il dispositivo utilizza l’elemento sicuro per generare frasi mnemoniche. Quando abilitata, l’entropia sia della MCU che dell’elemento sicuro verrà combinata. Entrambi i metodi soddisfano gli standard di sicurezza crittografica.",
]
# fmt: on
5 changes: 4 additions & 1 deletion core/src/trezor/lvglui/i18n/locales/ja.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,14 @@
"シードフレーズの単語数はセキュリティに影響しません。どの長さでも暗号学的に安全です。",
"動的QRコードを表示",
"BTC、TRON、SOL、ETH、BNB ...",
"一部の暗号資産とハードウェア機能は、QRコード通信モードでは利用できません。 \nこのモードは、ハードウェアウォレットをほとんど操作しない少数のユーザーのみを対象としており、他の接続方法とは互換性がありません。 \nBluetoothまたはUSB経由でハードウェアウォレットを接続する場合は、ウォレットを再度追加して通信モードを切り替えてください。",
"一部の暗号資産とハードウェア機能は、QRコード通信モードでは利用できません。 \n\nこのモードは、ハードウェアウォレットをほとんど操作しない少数のユーザーのみを対象としており、他の接続方法とは互換性がありません。 \n\nBluetoothまたはUSB経由でハードウェアウォレットを接続する場合は、ウォレットを再度追加して通信モードを切り替えてください。",
"接続方法を選択してください。 \nQRコード接続を使用するには、右上の「その他」をタップしてください。",
"高度な",
"危険地帯",
"QRコードで続行",
"OneKey Appウォレットを接続",
"詳細オプション",
"複数のエントロピー源を使用する",
"デフォルトでは、デバイスはセキュアエレメントを使用してニーモニックフレーズを生成します。有効にすると、MCUとセキュアエレメントの両方からのエントロピーが組み合わされます。どちらの方法も暗号セキュリティ標準を満たしています。",
]
# fmt: on
5 changes: 4 additions & 1 deletion core/src/trezor/lvglui/i18n/locales/ko.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,14 @@
"시드 구문의 단어 수는 보안성에 영향을 미치지 않습니다. 모든 시드는 암호학적으로 안전합니다.",
"동적 QR 코드 표시",
"BTC, TRON, SOL, ETH, BNB ...",
"일부 암호화폐 자산 및 하드웨어 기능은 QR 코드 통신 모드에서 사용할 수 없습니다. \n이 모드는 하드웨어 지갑을 거의 사용하지 않는 소수의 사용자만을 위한 것이며 다른 연결 방법과 호환되지 않습니다. \n블루투스 또는 USB를 통해 하드웨어 지갑을 연결하려면 지갑을 다시 추가하여 통신 모드를 전환하세요.",
"일부 암호화폐 자산 및 하드웨어 기능은 QR 코드 통신 모드에서 사용할 수 없습니다. \n\n이 모드는 하드웨어 지갑을 거의 사용하지 않는 소수의 사용자만을 위한 것이며 다른 연결 방법과 호환되지 않습니다. \n\n블루투스 또는 USB를 통해 하드웨어 지갑을 연결하려면 지갑을 다시 추가하여 통신 모드를 전환하세요.",
"연결 방법을 선택하세요. \nQR 코드 연결을 사용하려면 오른쪽 상단의 \"더보기\"를 탭하세요.",
"고급",
"위험 구역",
"QR 코드로 계속하기",
"OneKey App 지갑 연결",
"고급 옵션",
"여러 출처의 엔트로피를 사용하세요",
"기본적으로 기기는 보안 요소를 사용해 니모닉 구문을 생성합니다. 이 기능을 활성화하면 MCU와 보안 요소의 엔트로피가 결합됩니다. 두 방식 모두 암호학적 보안 표준을 충족합니다.",
]
# fmt: on
5 changes: 4 additions & 1 deletion core/src/trezor/lvglui/i18n/locales/pt_br.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,14 @@
"O número de palavras na sua frase semente não afeta sua segurança, todas são criptograficamente seguras.",
"Mostrar Código QR Dinâmico",
"BTC, TRON, SOL, ETH, BNB ...",
"Alguns ativos de criptomoedas e recursos de hardware não estão disponíveis no modo de comunicação por QR Code. \nEste modo é destinado apenas a um pequeno número de usuários que raramente operam sua carteira de hardware e não é compatível com outros métodos de conexão. \nSe você deseja conectar sua carteira de hardware via Bluetooth ou USB, por favor, adicione novamente a carteira para alternar o modo de comunicação.",
"Alguns ativos de criptomoedas e recursos de hardware não estão disponíveis no modo de comunicação por QR Code. \n\nEste modo é destinado apenas a um pequeno número de usuários que raramente operam sua carteira de hardware e não é compatível com outros métodos de conexão. \n\nSe você deseja conectar sua carteira de hardware via Bluetooth ou USB, por favor, adicione novamente a carteira para alternar o modo de comunicação.",
"Selecione a forma de conexão. \nPara usar a conexão por código QR, toque em \"Mais\" no canto superior direito.",
"Avançado",
"Zona de perigo",
"Continuar com código QR",
"Conectar Carteira OneKey App",
"Opções Avançadas",
"Use múltiplas fontes de entropia",
"Por padrão, o dispositivo usa o elemento seguro para gerar frases mnemônicas. Quando ativado, a entropia do MCU e do elemento seguro serão combinadas. Ambos os métodos atendem aos padrões de segurança criptográfica.",
]
# fmt: on
Loading
Loading