Skip to content
Draft
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog 26.03.1 - March 2025

### Security Fixes
Reject PSBT inputs with non-standard sighash types before signing
- Reject PSBT inputs with non-standard sighash types before signing
- Warn user before signing raw hashes in message signing

# Changelog 26.03.0 - March 2025

Expand Down
1 change: 1 addition & 0 deletions i18n/translations/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "Signatur:",
"Signed Message": "Signierte Nachricht",
"Signed PSBT": "Signierte PSBT",
"Signing raw hash. Proceed only if you trust the source.": "Signieren von Roh-Hash. Fahren Sie nur fort, wenn Sie der Quelle vertrauen.",
"Signing…": "Unterzeichnung…",
"Single-sig": "Single-Sig",
"Size:": "Größe:",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/es-MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "Firma:",
"Signed Message": "Mensaje Firmado",
"Signed PSBT": "PSBT Firmado",
"Signing raw hash. Proceed only if you trust the source.": "Firmar hash sin procesar. Proceda solo si confía en la fuente.",
"Signing…": "Firma…",
"Single-sig": "Single-sig",
"Size:": "Tamaño:",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "Signature :",
"Signed Message": "Message signé",
"Signed PSBT": "PSBT signé",
"Signing raw hash. Proceed only if you trust the source.": "Signature du hachage brut. Procédez uniquement si vous faites confiance à la source.",
"Signing…": "Signature…",
"Single-sig": "Clé unique",
"Size:": "Capacité :",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "サイン:",
"Signed Message": "サイン付きメッセージ",
"Signed PSBT": "サインされたPSBT",
"Signing raw hash. Proceed only if you trust the source.": "生のハッシュに署名します.ソースを信頼している場合にのみ続行します.",
"Signing…": "署名…",
"Single-sig": "シングルサイン",
"Size:": "サイズ:",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "서명:",
"Signed Message": "서명된 메시지",
"Signed PSBT": "서명된 PSBT",
"Signing raw hash. Proceed only if you trust the source.": "원시 해시에 서명합니다. 소스를 신뢰하는 경우에만 진행합니다.",
"Signing…": "서명…",
"Single-sig": "단일서명",
"Size:": "크기:",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "Handtekening:",
"Signed Message": "Bericht ondertekend",
"Signed PSBT": "PSBT ondertekend",
"Signing raw hash. Proceed only if you trust the source.": "RAW-hash ondertekenen. Ga alleen verder als je de bron vertrouwt.",
"Signing…": "Signing…",
"Single-sig": "Enkele sleutel",
"Size:": "Grootte:",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "Assinatura:",
"Signed Message": "Mensagem assinada",
"Signed PSBT": "PSBT assinada",
"Signing raw hash. Proceed only if you trust the source.": "Assinando hash bruto. Prossiga somente se você confiar na fonte.",
"Signing…": "Assinando…",
"Single-sig": "Single-sig",
"Size:": "Tamanho:",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "Подпись:",
"Signed Message": "Подписанное Сообщение",
"Signed PSBT": "Подписанное PSBT",
"Signing raw hash. Proceed only if you trust the source.": "Подписание необработанного хэша. Продолжайте, только если вы доверяете источнику.",
"Signing…": "Подпись…",
"Single-sig": "Одна подпись",
"Size:": "Размер:",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "İmza:",
"Signed Message": "İmzalı Mesaj",
"Signed PSBT": "İmzalı PSBT",
"Signing raw hash. Proceed only if you trust the source.": "Ham karma imzalanıyor. Yalnızca kaynağa güveniyorsanız devam edin.",
"Signing…": "İmzalama…",
"Single-sig": "Tek-imza",
"Size:": "Boyut:",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/vi-VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "Chữ ký:",
"Signed Message": "Tin nhắn đã ký",
"Signed PSBT": "Đã ký PSBT",
"Signing raw hash. Proceed only if you trust the source.": "Ký mã băm thô. Chỉ tiến hành nếu bạn tin tưởng nguồn.",
"Signing…": "Biển báo…",
"Single-sig": "Khóa đơn",
"Size:": "Dung lượng:",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Signature:": "签名:",
"Signed Message": "签名消息",
"Signed PSBT": "已签名 PSBT",
"Signing raw hash. Proceed only if you trust the source.": "签名原始哈希.仅当您信任源时才继续.",
"Signing…": "签名…",
"Single-sig": "单签",
"Size:": "大小:",
Expand Down
21 changes: 16 additions & 5 deletions src/krux/pages/home_pages/sign_message_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,21 @@ def _sign_at_address_from_sd(self, data):

def sign_standard_message(self, data):
"""Signs a standard message"""
message_hash = self._compute_message_hash(data)
message_hash, is_raw_hash = self._compute_message_hash(data)
if message_hash is None:
return ""

if is_raw_hash:
self.ctx.display.clear()
self.ctx.display.draw_centered_text(
t("Warning:")
+ "\n\n"
+ t("Signing raw hash. Proceed only if you trust the source."),
highlight_prefix=":",
)
if not self.prompt(t("Proceed?"), BOTTOM_PROMPT_LINE):
return ""

self.ctx.display.clear()
self.ctx.display.draw_centered_text(
"SHA256:\n\n%s" % binascii.hexlify(message_hash).decode(),
Expand All @@ -251,15 +262,15 @@ def sign_standard_message(self, data):
return sig

def _compute_message_hash(self, data):
"""Computes the hash for the message"""
"""Computes the hash for the message, returns (hash, is_raw_hash)"""
if len(data) == 32:
return data
return data, True
if len(data) == 64:
try:
return binascii.unhexlify(data)
return binascii.unhexlify(data), True
except:
pass
return hashlib.sha256(data).digest()
return hashlib.sha256(data).digest(), False

def _export_signature(
self,
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
1512492264,
1988416729,
3672006076,
2420425663,
1100365444,
2281377987,
2019512665,
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"Signatur:",
"Signierte Nachricht",
"Signierte PSBT",
"Signieren von Roh-Hash. Fahren Sie nur fort, wenn Sie der Quelle vertrauen.",
"Unterzeichnung…",
"Single-Sig",
"Größe:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"Firma:",
"Mensaje Firmado",
"PSBT Firmado",
"Firmar hash sin procesar. Proceda solo si confía en la fuente.",
"Firma…",
"Single-sig",
"Tamaño:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"Signature\u2009:",
"Message signé",
"PSBT signé",
"Signature du hachage brut. Procédez uniquement si vous faites confiance à la source.",
"Signature…",
"Clé unique",
"Capacité\u2009:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/ja.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"サイン:",
"サイン付きメッセージ",
"サインされたPSBT",
"生のハッシュに署名します.ソースを信頼している場合にのみ続行します.",
"署名…",
"シングルサイン",
"サイズ:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/ko.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"서명:",
"서명된 메시지",
"서명된 PSBT",
"원시 해시에 서명합니다. 소스를 신뢰하는 경우에만 진행합니다.",
"서명…",
"단일서명",
"크기:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/nl.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"Handtekening:",
"Bericht ondertekend",
"PSBT ondertekend",
"RAW-hash ondertekenen. Ga alleen verder als je de bron vertrouwt.",
"Signing…",
"Enkele sleutel",
"Grootte:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"Assinatura:",
"Mensagem assinada",
"PSBT assinada",
"Assinando hash bruto. Prossiga somente se você confiar na fonte.",
"Assinando…",
"Single-sig",
"Tamanho:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/ru.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"Подпись:",
"Подписанное Сообщение",
"Подписанное PSBT",
"Подписание необработанного хэша. Продолжайте, только если вы доверяете источнику.",
"Подпись…",
"Одна подпись",
"Размер:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/tr.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"İmza:",
"İmzalı Mesaj",
"İmzalı PSBT",
"Ham karma imzalanıyor. Yalnızca kaynağa güveniyorsanız devam edin.",
"İmzalama…",
"Tek-imza",
"Boyut:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/vi.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"Chữ ký:",
"Tin nhắn đã ký",
"Đã ký PSBT",
"Ký mã băm thô. Chỉ tiến hành nếu bạn tin tưởng nguồn.",
"Biển báo…",
"Khóa đơn",
"Dung lượng:",
Expand Down
1 change: 1 addition & 0 deletions src/krux/translations/zh.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"签名:",
"签名消息",
"已签名 PSBT",
"签名原始哈希.仅当您信任源时才继续.",
"签名…",
"单签",
"大小:",
Expand Down
8 changes: 6 additions & 2 deletions tests/pages/home_pages/test_sign_message_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_sign_message(mocker, m5stickv, tdata):
# 3 btn_seq
[
BUTTON_ENTER, # Load from camera
BUTTON_ENTER, # Raw hash warning - Proceed
BUTTON_ENTER, # Confirm to Sign SHA
BUTTON_ENTER, # Check signature
BUTTON_ENTER, # Sign to QR code
Expand All @@ -41,6 +42,7 @@ def test_sign_message(mocker, m5stickv, tdata):
None,
[
BUTTON_ENTER, # Load from camera
BUTTON_ENTER, # Raw hash warning - Proceed
BUTTON_ENTER, # Confirm to Sign SHA
BUTTON_ENTER, # Check signature
BUTTON_ENTER, # Sign to QR code
Expand Down Expand Up @@ -95,6 +97,7 @@ def test_sign_message(mocker, m5stickv, tdata):
MockPrinter(),
[
BUTTON_ENTER, # Load from camera
BUTTON_ENTER, # Raw hash warning - Proceed
BUTTON_ENTER, # Confirm to Sign SHA
BUTTON_ENTER, # Check signature
BUTTON_ENTER, # Sign to QR code
Expand All @@ -115,6 +118,7 @@ def test_sign_message(mocker, m5stickv, tdata):
MockPrinter(),
[
BUTTON_ENTER, # Load from camera
BUTTON_ENTER, # Raw hash warning - Proceed
BUTTON_ENTER, # Confirm to Sign SHA
BUTTON_ENTER, # Check signature
BUTTON_ENTER, # Sign to QR code
Expand All @@ -128,14 +132,14 @@ def test_sign_message(mocker, m5stickv, tdata):
"02707a62fdacc26ea9b63b1c197906f56ee0180d0bcf1966e1a2da34f5f3a09a9b",
None,
),
# 6 Hex-encoded hash, Decline to sign
# 6 Hex-encoded hash, Decline at raw hash warning
(
"1af9487b14714080ce5556b4455fd06c4e0a5f719d8c0ea2b5a884e5ebfc6de7",
FORMAT_NONE,
None,
[
BUTTON_ENTER, # Load from camera
BUTTON_PAGE, # Decline to sign
BUTTON_PAGE, # Decline raw hash warning
],
None,
None,
Expand Down
Loading