Skip to content

Commit

Permalink
Fix endianness issue in pubkey perms handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasValvekens committed Mar 25, 2024
1 parent 3308911 commit 0c14dfe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyhanko/pdf_utils/crypt/pubkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def add_recipients(
new_cms = construct_recipient_cms(
certs,
self._recp_key_seed,
as_signed(perms),
perms & 0xFFFFFFFF,
policy=policy,
include_permissions=self.acts_as_default,
)
Expand Down Expand Up @@ -310,7 +310,7 @@ def construct_envelope_content(
seed: bytes, perms: int, include_permissions=True
):
assert len(seed) == 20
return seed + (struct.pack('<i', perms) if include_permissions else b'')
return seed + (struct.pack('>I', perms) if include_permissions else b'')


def _rsaes_pkcs1v15_recipient(
Expand Down Expand Up @@ -1123,7 +1123,7 @@ def read_seed_from_recipient_cms(
perms: Optional[int] = None
if len(content) == 24:
# permissions are included
perms = struct.unpack('<i', content[20:])[0]
perms = struct.unpack('>I', content[20:])[0]
return seed, perms


Expand Down

0 comments on commit 0c14dfe

Please sign in to comment.