From 88422de1fcfee55f713b86751ef551148e776477 Mon Sep 17 00:00:00 2001 From: Martin Vrachev Date: Mon, 5 Jul 2021 19:03:08 +0300 Subject: [PATCH] Metadata API: Fix keyval "public" requirement Currently, we require that the keyval attribute in the Key class is a dictionary and has "public" as a key, otherwise, we throw KeyError or ValueError. This requirement is too strict given that in the spec for KEYVAL it's only said that KEYVAL is: "A dictionary containing the public portion of the key." See: https://theupdateframework.github.io/specification/latest/index.html#keyval Signed-off-by: Martin Vrachev --- tuf/api/metadata.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tuf/api/metadata.py b/tuf/api/metadata.py index 50a6c31845..24cc80790d 100644 --- a/tuf/api/metadata.py +++ b/tuf/api/metadata.py @@ -424,8 +424,9 @@ def __init__( keyval: Dict[str, str], unrecognized_fields: Optional[Mapping[str, Any]] = None, ) -> None: - val = keyval["public"] - if not all(isinstance(at, str) for at in [keyid, keytype, scheme, val]): + if not all( + isinstance(at, str) for at in [keyid, keytype, scheme] + ) or not isinstance(keyval, Dict): raise ValueError("Unexpected Key attributes types!") self.keyid = keyid self.keytype = keytype