Skip to content

Commit

Permalink
Correct definition of PdfMacIntegrityInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasValvekens committed Apr 27, 2024
1 parent e305208 commit a5dcf64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyhanko/pdf_utils/crypt/_iso32004_asn1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class PdfMacIntegrityInfo(Sequence):
_fields = [
('version', Integer, {'default': 0}),
('version', Integer),
('data_digest', OctetString),
('signature_digest', OctetString, {'implicit': 0, 'optional': True}),
]
Expand Down
5 changes: 3 additions & 2 deletions pyhanko/pdf_utils/crypt/pdfmac.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import secrets
from hmac import compare_digest
from typing import FrozenSet, Optional, Tuple, Type
from typing import Any, Dict, FrozenSet, Optional, Tuple, Type

from asn1crypto import algos, cms, core
from asn1crypto.core import VOID
Expand Down Expand Up @@ -210,9 +210,10 @@ def _get_mac_keying_info(
def _format_message(
self, document_digest: bytes, signature_digest: Optional[bytes]
) -> Tuple[bytes, bytes]:
message_kwargs = {'data_digest': document_digest}
message_kwargs: Dict[str, Any] = {'data_digest': document_digest}
if signature_digest is not None:
message_kwargs['signature_digest'] = signature_digest
message_kwargs['version'] = 0

message = PdfMacIntegrityInfo(message_kwargs)
message_bytes = message.dump()
Expand Down

0 comments on commit a5dcf64

Please sign in to comment.