1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-03 03:50:58 +00:00

feat(core): Don't store blank names in FIDO2 credentials.

This commit is contained in:
Andrew Kozlik 2023-03-10 14:22:37 +01:00 committed by Andrew Kozlik
parent c21cf87c53
commit 32dec18366

View File

@ -240,16 +240,16 @@ class Fido2Credential(Credential):
return cred return cred
def truncate_names(self) -> None: def truncate_names(self) -> None:
if self.rp_name: for name in ("rp_name", "user_name", "user_display_name"):
self.rp_name = utils.truncate_utf8(self.rp_name, _NAME_MAX_LENGTH) value = getattr(self, name)
if value:
if self.user_name: if value.isspace():
self.user_name = utils.truncate_utf8(self.user_name, _NAME_MAX_LENGTH) # Don't store blank names.
value = None
if self.user_display_name: else:
self.user_display_name = utils.truncate_utf8( # If the name is stored then the WebAuthn spec allows truncation.
self.user_display_name, _NAME_MAX_LENGTH value = utils.truncate_utf8(value, _NAME_MAX_LENGTH)
) setattr(self, name, value)
def check_required_fields(self) -> bool: def check_required_fields(self) -> bool:
return ( return (