1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-19 05:58:09 +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
def truncate_names(self) -> None:
if self.rp_name:
self.rp_name = utils.truncate_utf8(self.rp_name, _NAME_MAX_LENGTH)
if self.user_name:
self.user_name = utils.truncate_utf8(self.user_name, _NAME_MAX_LENGTH)
if self.user_display_name:
self.user_display_name = utils.truncate_utf8(
self.user_display_name, _NAME_MAX_LENGTH
)
for name in ("rp_name", "user_name", "user_display_name"):
value = getattr(self, name)
if value:
if value.isspace():
# Don't store blank names.
value = None
else:
# If the name is stored then the WebAuthn spec allows truncation.
value = utils.truncate_utf8(value, _NAME_MAX_LENGTH)
setattr(self, name, value)
def check_required_fields(self) -> bool:
return (