Skip to content

Commit 11bab82

Browse files
authored
Merge pull request #452 from dajiaji/fix-to_cis
Fix to_cis to convert protected from Dict[str, Any] to Dict[int, Any].
2 parents afc9fbc + db9f458 commit 11bab82

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

cwt/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def to_cis(context: Dict[str, Any], recipient_alg: Optional[int] = None) -> List
150150
if "protected" in context["supp_pub"]:
151151
if not isinstance(context["supp_pub"]["protected"], dict):
152152
raise ValueError("supp_pub.protected should be dict.")
153-
protected = context["supp_pub"]["protected"]
153+
protected = to_cose_header(context["supp_pub"]["protected"])
154154
supp_pub[1] = cbor2.dumps(protected)
155155
if "other" in context["supp_pub"]:
156156
if not isinstance(context["supp_pub"]["other"], str):

tests/test_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def test_to_cis(self):
4949
}
5050
)
5151
assert isinstance(res, list)
52+
assert len(res) == 4
53+
assert res[3][0] == 128
54+
assert res[3][1] == b"\xa1\x01)"
55+
assert res[3][2] == b"Encryption Example 02"
5256

5357
def test_to_cis_without_supp_pub_other(self):
5458
res = to_cis(

0 commit comments

Comments
 (0)