Skip to content

Commit

Permalink
update how to add recipient
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Mollard committed Apr 4, 2024
1 parent 7c4c70f commit fed8c42
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions jwcrypto/jwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ def add_recipient(self, key, header=None):
if 'ciphertext' not in self.objects:
self._encrypt(alg, enc, jh)

if self.flattened:
if 'recipients' in self.objects:
self.objects['recipients'].append(rec)
elif 'encrypted_key' in self.objects or 'header' in self.objects:
if 'recipients' in self.objects:
self.objects['recipients'].append(rec)
elif self.flattened:
if 'encrypted_key' in self.objects or 'header' in self.objects:
self.objects['recipients'] = []
n = {}
if 'encrypted_key' in self.objects:
Expand All @@ -268,10 +268,7 @@ def add_recipient(self, key, header=None):
else:
self.objects.update(rec)
else:
if 'recipients' in self.objects:
self.objects['recipients'].append(rec)
else:
self.objects['recipients'] = [rec]
self.objects['recipients'] = [rec]


def serialize(self, compact=False):
Expand Down

0 comments on commit fed8c42

Please sign in to comment.