You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VBA projects signed by EPPlus got a V3 signature (vbaProjectSignatureV3.bin) that Excel rejects. There were two independent causes:
The SpcIndirectDataContent structure in the Agile and V3 signatures was not valid DER, because several hand-calculated lengths were wrong.
The V3 content hash ([MS-OVBA] 2.4.2.7) was computed from the wrong input data, so it never matched the hash Excel computes from the saved project.
Fixes
DER writer: replaced the hand-calculated lengths in CreateContentInfo with a small DER writer (Sequence/Oid/OctetString/Tlv) that computes every length from its content and supports long-form lengths. Removed WriteSequenceLength, GetByteSize and GetContentInfoTotalSize.
PROJECT stream: ExcelVbaProject.Save() now sets ProjectStreamText from the PROJECT stream it writes, before the signatures are created.
Unicode module name: the ExcelVBAModule.Name setter now updates NameUnicode. The dir stream (MODULENAMEUNICODE) and PROJECTwm are written from NameUnicode, so the written data and the hash input always match.
CMS digest: CmsSigner.DigestAlgorithm is set explicitly from the signature context for Agile/V3. For Legacy, the MD5 project hash and the CMS signing digest are kept separate.
SpcSpOpusInfo: added the attribute (1.3.6.1.4.1.311.2.1.12) with an empty program name (30 04 A0 02 A0 00), identical to Office.
Header: removed the extra trailing ushort in CertUtil.CreateBinarySignature and replaced the magic number 44 with named constants (8-byte DigSigBlob header + 36-byte DigSigInfoSerialized header).
Activity
Fixes issue #2622
Fix for issue (#2623)