Skip to content

Commit 10f7efc

Browse files
authored
Merge pull request #467 from dajiaji/fix-recipient-encodding-with-empty-protected-header
Fix recipient encoding with empty protected header.
2 parents d2cb342 + 566d0b5 commit 10f7efc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

cwt/cose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ def _encode_and_encrypt(
728728
b_key = key.to_bytes() if isinstance(key, COSEKeyInterface) else b""
729729
cek: Optional[COSEKeyInterface] = None
730730
for rec in recipients:
731-
aad = self._dumps(["Enc_Recipient", self._dumps(rec.protected), external_aad])
731+
aad = self._dumps(["Enc_Recipient", self._dumps(rec.protected) if len(rec.protected) > 0 else b"", external_aad])
732732
encoded, derived_key = rec.encode(b_key, aad)
733733
cek = derived_key if derived_key else key
734734
recs.append(encoded)

0 commit comments

Comments
 (0)