A xar archive carries three kinds of integrity data: one checksum of the table of contents,
two checksums for every stored object, and, in a signed archive, a signature of the table of
contents’ checksum. This page says what each one covers. It follows libxar’s
archive.c and signature.c (the mackyle/xar copy),
libarchive’s archive_read_support_format_xar.c and 7-Zip’s XarHandler.cpp,
all read on 2026-11-19, and was checked against archives made by macOS’s own xar (1.8dev) and real
installer packages on one Mac, among them a signed Developer ID package.
The table of contents checksum
- It is the digest of the compressed table of contents: the zlib bytes exactly as they stand in the file, not the XML they inflate to.
- The header’s algorithm code says which digest:
1SHA-1,2MD5, and for3and4the two forms below. Thestyleattribute of the TOC’schecksumelement must name the same digest. - The digest itself is in the heap, at the
offsetandsizethechecksumelement gives. In every archive seen it is the first thing in the heap, at offset 0.sizeis the digest’s length: 20 for SHA-1, 16 for MD5, 32 for SHA-256, 64 for SHA-512. - With algorithm
0there is no checksum, and no signature can be present.
Algorithm codes 3 and 4
The two sources that matter disagree, and real files follow one of them.
- macOS’s own
xar(1.8dev, the one that makes--toc-cksum sha256andsha512archives) writes3for SHA-256 and4for SHA-512 in an ordinary 28-byte header: its--dump-headerprints “3 (SHA256)” and “4 (SHA512)”. libarchive reads them the same way, and accepts only a 28-byte header. - The open-source libxar’s
xar.hdefines3as “another digest, named in the header”: the header is then at least 32 bytes long, a multiple of 4, and holds the digest’s NUL-terminated name after byte 28 (toc_cksum_nameis 36 bytes, so at most 35 characters of name and the NUL, and at most a 64-byte header). It does not define4.
A reader that sees 3 in a 28-byte header should take SHA-256; in a longer header, the name that follows.
Checksums of members
Every data and ea element can carry two checksums, each with a
style attribute naming the digest and the digest in hexadecimal text:
archived-checksum: the digest of the stored bytes, thelengthbytes in the heap.extracted-checksum: the digest of the decoded bytes, the file as it is extracted.
For a member stored as it is (application/octet-stream) the two are equal. The styles seen are
sha1 (macOS’s default), sha256 and sha512; libxar accepts any digest
name OpenSSL knows, and none or a missing element means no check. libarchive checks both
digests while extracting and reports “Checksum error” on a difference; it understands only SHA-1, MD5, SHA-256
and SHA-512. 7-Zip keeps the two as properties of the file.
The reader should also check that the decoded bytes are exactly size long (libarchive:
“Decompressed size error”).
The signature
A signed archive (an installer package from the App Store or a Developer ID) has a
signature element in the TOC, beside checksum:
<signature style="RSA">
<offset>20</offset>
<size>256</size>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<X509Data>
<X509Certificate>MIIFtTCCBJ2g…</X509Certificate>
<X509Certificate>…</X509Certificate>
</X509Data>
</KeyInfo>
</signature>
offsetandsizelocate the signature in the heap: in real packages it follows the checksum (offset 20, 256 bytes for a 2048-bit key).styleisRSAin every signed package seen. (libxar’s source comments mentionSHA1withRSA.)- Each
X509Certificateis a base64 DER certificate, broken into lines. The signer’s own certificate is first, then its issuers; the real packages list three certificates (Developer ID Installer, the Developer ID Certification Authority, Apple Root CA). libxar keeps them in the order they were added. - The signature signs the table of contents checksum, not the file. In the two real packages checked here (a Software Update package and a Microsoft Developer ID package) the 256 bytes, raised to the signer’s public exponent modulo its modulus, give a PKCS #1 v1.5 block whose DigestInfo names SHA-1 and holds exactly the 20-byte checksum from the heap. Changing one byte of that checksum therefore breaks both the checksum test and the signature.
- The signature binds the archive only through the checksums: the table of contents is covered by the checksum, and each member by the
checksums inside the table of contents. libxar therefore refuses an archive that has a signature but header algorithm
0(“Checksum/signature mismatch!”); a signature whose checksum has nooffsetor nosizealso makes it refuse, butxar_openthen returns NULL without printing anything.
Checking that the chain leads to a certificate the system trusts is a separate step, which needs the operating system’s trust settings, a revocation check and the signing time. A reader that only checks the signature against the first certificate proves that the holder of that certificate signed this checksum, not that the certificate is trusted.
The CMS x-signature
A package signed by a recent macOS (observed in a Developer ID package written in July 2025) has a second element after
signature:
<x-signature style="CMS">
<offset>276</offset>
<size>9216</size>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">…the same certificates…</KeyInfo>
</x-signature>
Its heap bytes follow the RSA signature. They are a CMS SignedData (RFC 5652) written with indefinite lengths (the
bytes start 30 80 06 09 2A 86 48 86 F7 0D 01 07 02), with SHA-1 as its digest algorithm, no encapsulated content
(the signature is detached) and the certificates; pkgutil --check-signature reports a trusted timestamp for the
same package. The libxar source read for this site has no such element: it is an addition of Apple’s tools. libarchive
and 7-Zip skip it, as they skip any element they do not know.
What it signs
The content is the same thing the RSA signature covers: the table of contents’ checksum, the 20-byte (or longer) digest in the heap at offset 0. The CMS does not hold it (it is detached); a reader supplies it. In the Developer ID package read for this page the structure is:
- SignedData version 1, one digest algorithm (SHA-1), an encapsulated content type of
datawith no content, the three certificates (Developer ID Installer, Developer ID Certification Authority, Apple Root CA), no revocation lists, and one SignerInfo. The 9,216 bytes of the heap object hold the CMS (8,590 bytes here) and then zero bytes up to the size the table of contents states. - SignerInfo version 1, identifying the signer by issuer and serial number (RFC 5652 version 3 would use the
subject key identifier), digest SHA-1, signature algorithm
sha1WithRSAEncryption, and three signed attributes:contentType(data),signingTimeandmessageDigest. - The
messageDigestis the SHA-1 of the table of contents’ checksum (the 20 bytes, not the table of contents). The signature is RSA PKCS #1 v1.5 over the DER encoding of the signed attributes as aSET(RFC 5652 section 5.4: the[0]tag byteA0is replaced by31for the hash). That is why the two layers matter: the digest attribute ties the signature to the checksum, and the signature ties the attributes, signing time included, to the key. - One unsigned attribute,
id-smime-aa-timeStampToken: a second CMSSignedDatawhose content is an RFC 3161TSTInfo(version 1, a policy OID, a message imprint of the signature value with its hash algorithm, a serial number and the time from the time-stamp authority’s clock), signed by the authority’s certificate, which the token carries. The imprint is what binds the time to this signature: it is the SHA-1 of the SignerInfo’s signature bytes.
A reader can check, with RSA and a hash: the messageDigest attribute against the checksum, the signature against the signer’s
public key, a signingCertificate attribute (RFC 2634, RFC 5035) against the signer’s certificate if there is one, each certificate’s
signature by another one of the set, the time-stamp token’s imprint against the signature, and the token’s own signature. The explorer does all
of these where it has the algorithm (RSA PKCS #1 v1.5 and ECDSA on P-256 and P-384, with SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512 for the
attributes; RSASSA-PSS and other curves are listed as not checked, never as wrong). The signing time is also compared with the signer
certificate’s validity dates, which is a date comparison and not a trust decision.
Trust is not evaluated. Whether the chain leads to a root anyone trusts, whether a certificate was revoked, whether the signer
certificate has the extended key usage an installer needs, and whether the time-stamp authority is trusted are decisions of the operating system
(pkgutil --check-signature makes them). A signature that verifies here says that the holder of the certificate’s key signed these
bytes, and that nothing in the signed data was changed since.
Not described
Known, not yet covered
- Viewer: trust: the chain, revocation, key usage and the time-stamp authority are not evaluated (they need the operating system’s trust settings and network checks); RSASSA-PSS signatures, curves other than P-256 and P-384, MD5 or attribute-certificate and other certificate formats in a SignedData are read and listed but not checked.
- Reference: only one real CMS signature (one signer, SHA-1, one time stamp) was available; countersignatures, several signers, encapsulated content and SHA-2 digests in a xar CMS follow RFC 5652 and are read, but no real archive with them was seen.
Unknown
- Reference: which version of Apple’s tools began writing
x-signature, and whether other styles thanRSAandCMSexist. No source read says.
In the explorer
Drop a .pkg, .xar, .xip or .safariextz file on the explorer. The Xar tab shows the table
of contents checksum, the signature and its verdict, the Certificates section (each certificate opens as a file),
a CMS signature section (the signer, the digest and signature checks, every signed and unsigned attribute, the time stamp) with its
own list of certificates, and a Checks section with both checksums of every stored object, verified.