Run a virtual iPhone on an Apple Silicon Mac.
Swift
p2: sign tests stop needing ldid, and the signer stops accepting x86
Lakrb940266a399f
diff --git a/AGENTS.md b/AGENTS.mdindex 104cf2d8..f02244d5 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -96,7 +96,7 @@ sources/│ ├── VPhoneCodeSignature.swift # SuperBlob / CodeDirectory construction│ ├── VPhoneSignEntitlements.swift # Entitlements plist blob (+ …Reader for reading one back)│ ├── VPhoneSignDER.swift # The DER entitlements blob-│ └── VPhoneSignLdid.swift # The `--use-ldid` escape hatch; last ldid site in Swift+│ └── VPhoneMachOImage.swift # Slice parsing. ARM only — an x86 slice is refused│├── MobileRecoveryCore/ # libirecovery 1.3.1, vendored C. IOKit USB, not libusb│ ├── libirecovery.c # Upstream's bytes, unmodifieddiff --git a/Package.swift b/Package.swiftindex 252da8d7..1c12aa73 100644--- a/Package.swift+++ b/Package.swift@@ -283,7 +283,13 @@ let package = Package(.testTarget(name: "VPhoneSignTests",dependencies: ["VPhoneSign"],- path: "tests/VPhoneSignTests"+ path: "tests/VPhoneSignTests",+ // Mach-O files to sign and the C they were built from. Excluded+ // rather than declared as resources: the tests reach them through+ // `#filePath`, so they need to be on disk and not in a bundle,+ // and left in place SwiftPM would try to compile the .c and refuse+ // the target for mixing languages.+ exclude: ["Fixtures"]),// Everything here runs without a device attached: argument parsing,// the restore-tree rules, the .shsh naming and the C struct thediff --git a/research/intg_update_status.md b/research/intg_update_status.mdindex b459c4e5..28d0a333 100644--- a/research/intg_update_status.md+++ b/research/intg_update_status.md@@ -38,7 +38,7 @@ is 2,396 lines against 2,410 at the branch base.| **P0** | 455 lines of Python | ✅ **complete** || P0.5 | `VPhoneArchive` + `vphone-archive` | ✅ library, binary, tests, fingerprint tool || P0.5 | switch the archive call sites | ◐ **package side done, shell side not.** `FirmwarePatcher` has no `tar` calls left; `$TAR` in `cfw_install*.sh` and `cfw-kit/lib/common.sh` still finds `gtar` |-| P0.5 | `VPhoneSign`, drop `ldid` | ◐ **bundle clean.** `--use-ldid` (`VPhoneSignLdid.swift:27`) and the shell's own `ldid` lookups remain |+| P0.5 | `VPhoneSign`, drop `ldid` | ◐ **Swift side done.** `--use-ldid` and `VPhoneSignLdid.swift` deleted at `a779f4e`; the tests compare against frozen ldid digests rather than a live one. `cfw-kit` and the Makefile still look `ldid` up on `PATH` || P0.5 | admission gates 1–3 | ✅ `make check-aux`; gate 1 now passes || **P1.0–1.5** | CFW patchers | ✅ **complete** — `scripts/patchers/` deleted at `d90371a`, 26 files / 6,539 lines into 24 `vphone-cli cfw` verbs || **P2.0** | can libirecovery see the virtual DFU endpoint? | ✅ **yes** — `research/p2_dfu_spike.md` |diff --git a/scripts/cfw_install_host.sh b/scripts/cfw_install_host.shindex 0884efc0..ddb3c168 100755--- a/scripts/cfw_install_host.sh+++ b/scripts/cfw_install_host.sh@@ -46,9 +46,10 @@ IMG="$VM_DIR/Disk.img"[[ -f "$IMG" ]] || { echo "[-] no Disk.img at $IMG" >&2; exit 1; }# Host-side install toolchain (gnu-tar/ipsw/aea/ldid/zstd).-# No python entry: the installers call `vphone-cli cfw <verb>` for every patch,-# and nothing they run comes out of the venv. VPHONE_PYTHON used to be prepended-# here for the Python patchers and is no longer read by anything downstream.+# No python entry, at either end: the installers call `vphone-cli cfw <verb>`+# for every patch, and as of P2.4 there is no interpreter on this machine's+# behalf to find. VPHONE_PYTHON used to be prepended here for the Python+# patchers; nothing reads it downstream and `cfw install` no longer sets it.P="$PROJ/.tools/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin"export PATH="$P"diff --git a/sources/VPhoneSign/VPhoneMachOImage.swift b/sources/VPhoneSign/VPhoneMachOImage.swiftindex afb1863c..8c87ec21 100644--- a/sources/VPhoneSign/VPhoneMachOImage.swift+++ b/sources/VPhoneSign/VPhoneMachOImage.swift@@ -52,6 +52,11 @@ struct VPhoneMachOImage {// MARK: Parsing/// Parses the slice at `range` of `file`.+ /// What `init` accepts. `CPU_TYPE_ARM` is 32-bit and cannot get past the+ /// MH_MAGIC_64 check above it; it is here so the set reads as "ARM",+ /// rather than as a list someone has to work out the gaps in.+ static let armCPUTypes: Set<cpu_type_t> = [CPU_TYPE_ARM, CPU_TYPE_ARM64, CPU_TYPE_ARM64_32]+init(file: Data, range: Range<Int>) throws {guard file.holds(range.lowerBound, range.count), range.count >= Self.headerSize else {throw VPhoneSignError.malformed("slice at \(range.lowerBound) runs past the end of the file")@@ -68,6 +73,19 @@ struct VPhoneMachOImage {self.range = rangeself.image = imagecpuType = cpu_type_t(bitPattern: image.littleEndianValue(at: 4) as UInt32)+ // ARM only, deliberately. Everything this signs is either a guest+ // binary — iOS arm64, out of an IPSW — or one of this project's own+ // host products, which are arm64 because the host has to be an Apple+ // silicon Mac to run a virtual iPhone at all. An x86 slice reaching+ // here is a file that came from somewhere unexpected, and signing it+ // on a guess is worse than saying so: page size, the `__LINKEDIT`+ // alignment and the deployment-target load commands all differ, and+ // none of that is exercised by anything.+ guard Self.armCPUTypes.contains(cpuType) else {+ throw VPhoneSignError.unsupportedSlice(+ "slice at \(range.lowerBound) is cputype \(cpuType); this signer is ARM only"+ )+ }fileType = image.littleEndianValue(at: 12)commandCount = image.littleEndianValue(at: 16)commandsSize = Int(image.littleEndianValue(at: 20) as UInt32)@@ -207,12 +225,10 @@ struct VPhoneMachOImage {default:return [.sha1, .sha256]}- case UInt32(LC_VERSION_MIN_MACOSX):- guard size >= MemoryLayout<version_min_command>.size else {- throw VPhoneSignError.malformed("LC_VERSION_MIN_MACOSX is \(size) bytes")- }- let (major, minor) = version(image.littleEndianValue(at: start + 8))- return major >= 10 && minor >= 12 ? [.sha256] : [.sha1, .sha256]+ // LC_VERSION_MIN_MACOSX is not read. It is the load command that+ // predates LC_BUILD_VERSION, and arm64 macOS starts at 11.0, which is+ // years after the changeover — so on an ARM-only signer the pair+ // (this command, a slice we accept) does not occur.case UInt32(LC_VERSION_MIN_IPHONEOS), UInt32(LC_VERSION_MIN_TVOS):guard size >= MemoryLayout<version_min_command>.size else {throw VPhoneSignError.malformed("a version command is \(size) bytes")@@ -282,13 +298,9 @@ struct VPhoneMachOImage {/// The alignment ldid rounds `__LINKEDIT`'s vmsize to: the slice's own/// in a fat file, and in a thin one what it takes the CPU's page to be.- var linkeditAlignment: Int {- switch cpuType {- case CPU_TYPE_ARM, CPU_TYPE_ARM64, CPU_TYPE_ARM64_32: 14- case CPU_TYPE_X86, CPU_TYPE_X86_64, CPU_TYPE_POWERPC, CPU_TYPE_POWERPC64: 12- default: 0- }- }+ /// ldid's table has an entry per CPU; only the ARM one can be reached+ /// here, because `init` refuses everything else.+ var linkeditAlignment: Int { 14 }// MARK: Rewritingdiff --git a/sources/vphone-cli/VPhoneSignCLI.swift b/sources/vphone-cli/VPhoneSignCLI.swiftindex 19f02da0..fa59d078 100644--- a/sources/vphone-cli/VPhoneSignCLI.swift+++ b/sources/vphone-cli/VPhoneSignCLI.swift@@ -13,8 +13,10 @@// environment variable behind it are gone: an escape hatch that shells out to a// Homebrew binary is a dependency whether or not the default path takes it, and// this project is meant to be self-contained. What guarded the replacement stays-// where it belongs — tests/VPhoneSignTests compares these bytes against the real-// ldid when one is installed, and skips rather than passes when one is not.+// where it belongs — tests/VPhoneSignTests holds these bytes against digests+// taken from the real ldid and frozen into the suite, over committed fixtures.+// It needs no ldid installed and no system binary to sign, so it cannot skip+// itself into passing on a machine that has neither.import ArgumentParserimport Foundationdiff --git a/tests/VPhoneSignTests/Fixtures/entitlements/lsd.plist b/tests/VPhoneSignTests/Fixtures/entitlements/lsd.plistnew file mode 100644index 00000000..55042ee8--- /dev/null+++ b/tests/VPhoneSignTests/Fixtures/entitlements/lsd.plist@@ -0,0 +1,270 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.coreservices.lsd</key>+ <true/>+ <key>com.apple.launchservices.clearadvertisingid</key>+ <true/>+ <key>com.apple.lsapplicationproxy.deviceidentifierforvendor</key>+ <true/>+ <key>com.apple.ondemandd.LaunchServices</key>+ <true/>+ <key>com.apple.private.MobileContainerManager.allowed</key>+ <true/>+ <key>com.apple.private.amfi.can-check-trust-cache</key>+ <true/>+ <key>com.apple.private.apfs.get-graft-info</key>+ <true/>+ <key>com.apple.private.coreservices.canforcedatabasegc</key>+ <true/>+ <key>com.apple.private.coreservices.canmaplsdatabase</key>+ <true/>+ <key>com.apple.private.coreservices.canopenactivity</key>+ <true/>+ <key>com.apple.private.coreservices.canresetserverstore</key>+ <true/>+ <key>com.apple.private.coreservices.lsd</key>+ <true/>+ <key>com.apple.private.dmd.policy</key>+ <true/>+ <key>com.apple.private.kernel.set-package-extensions</key>+ <true/>+ <key>com.apple.private.launchservices.cansetapplicationstrusted</key>+ <true/>+ <key>com.apple.private.mobileinstall.allowedSPI</key>+ <array>+ <string>InstallForDataMigrator</string>+ <string>InstallLocalProvisioned</string>+ <string>EnumerateInstalledAppsForLaunchServices</string>+ <string>CopyInstalledAppsForLaunchServices</string>+ <string>CopyDiskUsageForLaunchServices</string>+ <string>UninstallForLaunchServices</string>+ <string>InstallForLaunchServices</string>+ <string>RebuildMapsForLaunchServices</string>+ <string>CopyContainerizedAppInfoForLaunchServices</string>+ <string>CopyAppInfoForLaunchServicesWithWrapperURL</string>+ </array>+ <key>com.apple.private.nullfs_allow</key>+ <true/>+ <key>com.apple.private.security.daemon-container</key>+ <true/>+ <key>com.apple.private.security.storage.FileProvider</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.tcc.allow</key>+ <array>+ <string>kTCCServiceSystemPolicyAllFiles</string>+ </array>+ <key>com.apple.private.vfs.allow-low-space-writes</key>+ <true/>+ <key>com.apple.rootless.storage.com.apple.LaunchServices.dv</key>+ <true/>+ <key>com.apple.runningboard.launch_extensions</key>+ <true/>+ <key>com.apple.security.enterprise-volume-access</key>+ <true/>+ <key>com.apple.security.system-groups</key>+ <array>+ <string>systemgroup.com.apple.lsd.iconscache</string>+ <string>systemgroup.com.apple.lsd</string>+ </array>+ <key>com.apple.usermanagerd.persona.bundlemap.migration</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetch</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetchbundle</key>+ <true/>+ <key>com.apple.usermanagerd.persona.observer</key>+ <true/>+ <key>fairplay-client</key>+ <integer>2033844765</integer>+ <key>keychain-access-groups</key>+ <array>+ <string>com.apple.LaunchServices.TrustedSignature</string>+ <string>com.apple.LaunchServices.DeviceIdentifier</string>+ <string>com.apple.LaunchServices.secrets</string>+ </array>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.coreservices.lsd</key>+ <true/>+ <key>com.apple.launchservices.clearadvertisingid</key>+ <true/>+ <key>com.apple.lsapplicationproxy.deviceidentifierforvendor</key>+ <true/>+ <key>com.apple.ondemandd.LaunchServices</key>+ <true/>+ <key>com.apple.private.MobileContainerManager.allowed</key>+ <true/>+ <key>com.apple.private.amfi.can-check-trust-cache</key>+ <true/>+ <key>com.apple.private.apfs.get-graft-info</key>+ <true/>+ <key>com.apple.private.coreservices.canforcedatabasegc</key>+ <true/>+ <key>com.apple.private.coreservices.canmaplsdatabase</key>+ <true/>+ <key>com.apple.private.coreservices.canopenactivity</key>+ <true/>+ <key>com.apple.private.coreservices.canresetserverstore</key>+ <true/>+ <key>com.apple.private.coreservices.lsd</key>+ <true/>+ <key>com.apple.private.dmd.policy</key>+ <true/>+ <key>com.apple.private.kernel.set-package-extensions</key>+ <true/>+ <key>com.apple.private.launchservices.cansetapplicationstrusted</key>+ <true/>+ <key>com.apple.private.mobileinstall.allowedSPI</key>+ <array>+ <string>InstallForDataMigrator</string>+ <string>InstallLocalProvisioned</string>+ <string>EnumerateInstalledAppsForLaunchServices</string>+ <string>CopyInstalledAppsForLaunchServices</string>+ <string>CopyDiskUsageForLaunchServices</string>+ <string>UninstallForLaunchServices</string>+ <string>InstallForLaunchServices</string>+ <string>RebuildMapsForLaunchServices</string>+ <string>CopyContainerizedAppInfoForLaunchServices</string>+ <string>CopyAppInfoForLaunchServicesWithWrapperURL</string>+ </array>+ <key>com.apple.private.nullfs_allow</key>+ <true/>+ <key>com.apple.private.security.daemon-container</key>+ <true/>+ <key>com.apple.private.security.storage.FileProvider</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.tcc.allow</key>+ <array>+ <string>kTCCServiceSystemPolicyAllFiles</string>+ </array>+ <key>com.apple.private.vfs.allow-low-space-writes</key>+ <true/>+ <key>com.apple.rootless.storage.com.apple.LaunchServices.dv</key>+ <true/>+ <key>com.apple.runningboard.launch_extensions</key>+ <true/>+ <key>com.apple.security.enterprise-volume-access</key>+ <true/>+ <key>com.apple.security.system-groups</key>+ <array>+ <string>systemgroup.com.apple.lsd.iconscache</string>+ <string>systemgroup.com.apple.lsd</string>+ </array>+ <key>com.apple.usermanagerd.persona.bundlemap.migration</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetch</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetchbundle</key>+ <true/>+ <key>com.apple.usermanagerd.persona.observer</key>+ <true/>+ <key>fairplay-client</key>+ <integer>2033844765</integer>+ <key>keychain-access-groups</key>+ <array>+ <string>com.apple.LaunchServices.TrustedSignature</string>+ <string>com.apple.LaunchServices.DeviceIdentifier</string>+ <string>com.apple.LaunchServices.secrets</string>+ </array>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.coreservices.lsd</key>+ <true/>+ <key>com.apple.launchservices.clearadvertisingid</key>+ <true/>+ <key>com.apple.lsapplicationproxy.deviceidentifierforvendor</key>+ <true/>+ <key>com.apple.ondemandd.LaunchServices</key>+ <true/>+ <key>com.apple.private.MobileContainerManager.allowed</key>+ <true/>+ <key>com.apple.private.amfi.can-check-trust-cache</key>+ <true/>+ <key>com.apple.private.apfs.get-graft-info</key>+ <true/>+ <key>com.apple.private.coreservices.canforcedatabasegc</key>+ <true/>+ <key>com.apple.private.coreservices.canmaplsdatabase</key>+ <true/>+ <key>com.apple.private.coreservices.canopenactivity</key>+ <true/>+ <key>com.apple.private.coreservices.canresetserverstore</key>+ <true/>+ <key>com.apple.private.coreservices.lsd</key>+ <true/>+ <key>com.apple.private.dmd.policy</key>+ <true/>+ <key>com.apple.private.kernel.set-package-extensions</key>+ <true/>+ <key>com.apple.private.launchservices.cansetapplicationstrusted</key>+ <true/>+ <key>com.apple.private.mobileinstall.allowedSPI</key>+ <array>+ <string>InstallForDataMigrator</string>+ <string>InstallLocalProvisioned</string>+ <string>EnumerateInstalledAppsForLaunchServices</string>+ <string>CopyInstalledAppsForLaunchServices</string>+ <string>CopyDiskUsageForLaunchServices</string>+ <string>UninstallForLaunchServices</string>+ <string>InstallForLaunchServices</string>+ <string>RebuildMapsForLaunchServices</string>+ <string>CopyContainerizedAppInfoForLaunchServices</string>+ <string>CopyAppInfoForLaunchServicesWithWrapperURL</string>+ </array>+ <key>com.apple.private.nullfs_allow</key>+ <true/>+ <key>com.apple.private.security.daemon-container</key>+ <true/>+ <key>com.apple.private.security.storage.FileProvider</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.tcc.allow</key>+ <array>+ <string>kTCCServiceSystemPolicyAllFiles</string>+ </array>+ <key>com.apple.private.vfs.allow-low-space-writes</key>+ <true/>+ <key>com.apple.rootless.storage.com.apple.LaunchServices.dv</key>+ <true/>+ <key>com.apple.runningboard.launch_extensions</key>+ <true/>+ <key>com.apple.security.enterprise-volume-access</key>+ <true/>+ <key>com.apple.security.system-groups</key>+ <array>+ <string>systemgroup.com.apple.lsd.iconscache</string>+ <string>systemgroup.com.apple.lsd</string>+ </array>+ <key>com.apple.usermanagerd.persona.bundlemap.migration</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetch</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetchbundle</key>+ <true/>+ <key>com.apple.usermanagerd.persona.observer</key>+ <true/>+ <key>fairplay-client</key>+ <integer>2033844765</integer>+ <key>keychain-access-groups</key>+ <array>+ <string>com.apple.LaunchServices.TrustedSignature</string>+ <string>com.apple.LaunchServices.DeviceIdentifier</string>+ <string>com.apple.LaunchServices.secrets</string>+ </array>+</dict>+</plist>diff --git a/tests/VPhoneSignTests/Fixtures/entitlements/promotedcontentd.plist b/tests/VPhoneSignTests/Fixtures/entitlements/promotedcontentd.plistnew file mode 100644index 00000000..cf9a67bf--- /dev/null+++ b/tests/VPhoneSignTests/Fixtures/entitlements/promotedcontentd.plist@@ -0,0 +1,510 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>adi-client</key>+ <string>2463478364</string>+ <key>com.apple.CommCenter.fine-grained</key>+ <array>+ <string>spi</string>+ </array>+ <key>com.apple.ap.signingservice.client</key>+ <true/>+ <key>com.apple.assertiond.app-state-monitor</key>+ <true/>+ <key>com.apple.duet.activityscheduler.allow</key>+ <true/>+ <key>com.apple.private.accounts.allaccounts</key>+ <true/>+ <key>com.apple.private.ap.idmanager</key>+ <true/>+ <key>com.apple.private.applemediaservices</key>+ <true/>+ <key>com.apple.private.appstored</key>+ <array>+ <string>AppCapabilities</string>+ </array>+ <key>com.apple.private.calendar.has-adopted-modern-request-access-methods</key>+ <true/>+ <key>com.apple.private.fairplay.FPDI</key>+ <dict>+ <key>capabilities</key>+ <array>+ <integer>4014732562</integer>+ </array>+ <key>client-identifier</key>+ <string>com.apple.ap.promotedcontentd</string>+ </dict>+ <key>com.apple.private.fpsd.client</key>+ <true/>+ <key>com.apple.private.iad.opt-in-control</key>+ <true/>+ <key>com.apple.private.intelligenceplatform.client-identifier</key>+ <string>com.apple.ap.promotedcontentd</string>+ <key>com.apple.private.intelligenceplatform.use-cases</key>+ <dict>+ <key>PolicyInstrumentation</key>+ <dict>+ <key>Streams</key>+ <dict>+ <key>AdPlatforms.PolicyInstrumentation.Candidate</key>+ <dict>+ <key>mode</key>+ <string>read-write</string>+ </dict>+ <key>AdPlatforms.PolicyInstrumentation.Opportunity</key>+ <dict>+ <key>mode</key>+ <string>read-write</string>+ </dict>+ </dict>+ </dict>+ </dict>+ <key>com.apple.private.keychain.sysbound</key>+ <true/>+ <key>com.apple.private.network.socket-delegate</key>+ <true/>+ <key>com.apple.private.tcc.allow</key>+ <array>+ <string>kTCCServiceUserTracking</string>+ </array>+ <key>com.apple.private.tcc.manager.access.read</key>+ <array>+ <string>kTCCServiceAll</string>+ </array>+ <key>com.apple.private.tcc.manager.check-by-audit-token</key>+ <array>+ <string>kTCCServiceUserTracking</string>+ </array>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/usr/libexec</string>+ <string>/private/var/containers/Bundle/Application/</string>+ </array>+ <key>com.apple.security.exception.files.home-relative-path.read-only</key>+ <array>+ <string>/Library/Trial/</string>+ <string>/Library/UserConfigurationProfiles/Truth.plist</string>+ </array>+ <key>com.apple.security.exception.files.home-relative-path.read-write</key>+ <array>+ <string>/Library/Application Support/com.apple.ap.promotedcontentd/</string>+ <string>/Library/Caches/com.apple.ap.promotedcontentd/</string>+ <string>/Library/HTTPStorages</string>+ <string>/Library/HTTPStorages/com.apple.ap.promotedcontentd/</string>+ </array>+ <key>com.apple.security.exception.mach-lookup.global-name</key>+ <array>+ <string>com.apple.biome.compute.source.user</string>+ <string>com.apple.fairplaydeviceidentityd</string>+ <string>com.apple.commcenter.coretelephony.xpc</string>+ <string>com.apple.fairplayd.versioned</string>+ <string>com.apple.fpsd</string>+ <string>com.apple.fairplayd</string>+ <string>com.apple.fairplayd.xpc</string>+ <string>com.apple.ap.adprivacyd.opt-out</string>+ <string>com.apple.ap.adprivacyd.idmanager</string>+ <string>com.apple.adid</string>+ <string>com.apple.symptom_diagnostics</string>+ <string>com.apple.appstored.xpc</string>+ <string>com.apple.ak.auth.xpc</string>+ <string>com.apple.biome.access.user</string>+ </array>+ <key>com.apple.security.exception.process-info</key>+ <true/>+ <key>com.apple.security.exception.shared-preference.read-only</key>+ <array>+ <string>com.apple.AdLib</string>+ <string>com.apple.springboard</string>+ <string>com.apple.ap.promotedcontentd</string>+ <string>com.apple.security</string>+ <string>com.apple.CFNetwork</string>+ <string>com.apple.itunesstored</string>+ <string>com.apple.amsengagementd</string>+ </array>+ <key>com.apple.security.exception.shared-preference.read-write</key>+ <array>+ <string>com.apple.AdPlatforms</string>+ <string>com.apple.ap.config</string>+ </array>+ <key>com.apple.security.network.client</key>+ <true/>+ <key>com.apple.security.temporary-exception.mach-lookup.global-name</key>+ <array>+ <string>com.apple.fpsd</string>+ <string>com.apple.fairplayd</string>+ <string>com.apple.fairplayd.xpc</string>+ <string>com.apple.ak.auth.xpc</string>+ </array>+ <key>com.apple.security.ts.mobile-keybag-access</key>+ <true/>+ <key>com.apple.security.ts.tmpdir</key>+ <string>com.apple.ap.promotedcontentd</string>+ <key>com.apple.trial.client</key>+ <array>+ <string>513</string>+ <string>514</string>+ <string>AD_PLATFORMS_TODAY_TAB</string>+ <string>AD_PLATFORMS_SEARCH_RESULTS_PAGE</string>+ <string>AD_PLATFORMS_SEARCH_LANDING_PAGE</string>+ <string>AD_PLATFORMS_PRODUCT_PAGE</string>+ <string>AD_PLATFORMS_APPSTORE_ALL_PLACEMENTS</string>+ <string>AD_PLATFORMS_APPSTORE_SLP_INCREMENTALITYAPPSTORE</string>+ <string>AD_PLATFORMS_APPSTORE_SRP_INCREMENTALITYAPPSTORE</string>+ <string>AD_PLATFORMS_APPSTORE_TT_INCREMENTALITYAPPSTORE</string>+ <string>AD_PLATFORMS_APPSTORE_PP_INCREMENTALITYAPPSTORE</string>+ </array>+ <key>fairplay-client</key>+ <string>700802717</string>+ <key>keychain-access-groups</key>+ <array>+ <string>apple</string>+ </array>+ <key>platform-application</key>+ <true/>+ <key>seatbelt-profiles</key>+ <array>+ <string>temporary-sandbox</string>+ </array>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>adi-client</key>+ <string>2463478364</string>+ <key>com.apple.CommCenter.fine-grained</key>+ <array>+ <string>spi</string>+ </array>+ <key>com.apple.ap.signingservice.client</key>+ <true/>+ <key>com.apple.assertiond.app-state-monitor</key>+ <true/>+ <key>com.apple.duet.activityscheduler.allow</key>+ <true/>+ <key>com.apple.private.accounts.allaccounts</key>+ <true/>+ <key>com.apple.private.ap.idmanager</key>+ <true/>+ <key>com.apple.private.applemediaservices</key>+ <true/>+ <key>com.apple.private.appstored</key>+ <array>+ <string>AppCapabilities</string>+ </array>+ <key>com.apple.private.calendar.has-adopted-modern-request-access-methods</key>+ <true/>+ <key>com.apple.private.fairplay.FPDI</key>+ <dict>+ <key>capabilities</key>+ <array>+ <integer>4014732562</integer>+ </array>+ <key>client-identifier</key>+ <string>com.apple.ap.promotedcontentd</string>+ </dict>+ <key>com.apple.private.fpsd.client</key>+ <true/>+ <key>com.apple.private.iad.opt-in-control</key>+ <true/>+ <key>com.apple.private.intelligenceplatform.client-identifier</key>+ <string>com.apple.ap.promotedcontentd</string>+ <key>com.apple.private.intelligenceplatform.use-cases</key>+ <dict>+ <key>PolicyInstrumentation</key>+ <dict>+ <key>Streams</key>+ <dict>+ <key>AdPlatforms.PolicyInstrumentation.Candidate</key>+ <dict>+ <key>mode</key>+ <string>read-write</string>+ </dict>+ <key>AdPlatforms.PolicyInstrumentation.Opportunity</key>+ <dict>+ <key>mode</key>+ <string>read-write</string>+ </dict>+ </dict>+ </dict>+ </dict>+ <key>com.apple.private.keychain.sysbound</key>+ <true/>+ <key>com.apple.private.network.socket-delegate</key>+ <true/>+ <key>com.apple.private.tcc.allow</key>+ <array>+ <string>kTCCServiceUserTracking</string>+ </array>+ <key>com.apple.private.tcc.manager.access.read</key>+ <array>+ <string>kTCCServiceAll</string>+ </array>+ <key>com.apple.private.tcc.manager.check-by-audit-token</key>+ <array>+ <string>kTCCServiceUserTracking</string>+ </array>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/usr/libexec</string>+ <string>/private/var/containers/Bundle/Application/</string>+ </array>+ <key>com.apple.security.exception.files.home-relative-path.read-only</key>+ <array>+ <string>/Library/Trial/</string>+ <string>/Library/UserConfigurationProfiles/Truth.plist</string>+ </array>+ <key>com.apple.security.exception.files.home-relative-path.read-write</key>+ <array>+ <string>/Library/Application Support/com.apple.ap.promotedcontentd/</string>+ <string>/Library/Caches/com.apple.ap.promotedcontentd/</string>+ <string>/Library/HTTPStorages</string>+ <string>/Library/HTTPStorages/com.apple.ap.promotedcontentd/</string>+ </array>+ <key>com.apple.security.exception.mach-lookup.global-name</key>+ <array>+ <string>com.apple.biome.compute.source.user</string>+ <string>com.apple.fairplaydeviceidentityd</string>+ <string>com.apple.commcenter.coretelephony.xpc</string>+ <string>com.apple.fairplayd.versioned</string>+ <string>com.apple.fpsd</string>+ <string>com.apple.fairplayd</string>+ <string>com.apple.fairplayd.xpc</string>+ <string>com.apple.ap.adprivacyd.opt-out</string>+ <string>com.apple.ap.adprivacyd.idmanager</string>+ <string>com.apple.adid</string>+ <string>com.apple.symptom_diagnostics</string>+ <string>com.apple.appstored.xpc</string>+ <string>com.apple.ak.auth.xpc</string>+ <string>com.apple.biome.access.user</string>+ </array>+ <key>com.apple.security.exception.process-info</key>+ <true/>+ <key>com.apple.security.exception.shared-preference.read-only</key>+ <array>+ <string>com.apple.AdLib</string>+ <string>com.apple.springboard</string>+ <string>com.apple.ap.promotedcontentd</string>+ <string>com.apple.security</string>+ <string>com.apple.CFNetwork</string>+ <string>com.apple.itunesstored</string>+ <string>com.apple.amsengagementd</string>+ </array>+ <key>com.apple.security.exception.shared-preference.read-write</key>+ <array>+ <string>com.apple.AdPlatforms</string>+ <string>com.apple.ap.config</string>+ </array>+ <key>com.apple.security.network.client</key>+ <true/>+ <key>com.apple.security.temporary-exception.mach-lookup.global-name</key>+ <array>+ <string>com.apple.fpsd</string>+ <string>com.apple.fairplayd</string>+ <string>com.apple.fairplayd.xpc</string>+ <string>com.apple.ak.auth.xpc</string>+ </array>+ <key>com.apple.security.ts.mobile-keybag-access</key>+ <true/>+ <key>com.apple.security.ts.tmpdir</key>+ <string>com.apple.ap.promotedcontentd</string>+ <key>com.apple.trial.client</key>+ <array>+ <string>513</string>+ <string>514</string>+ <string>AD_PLATFORMS_TODAY_TAB</string>+ <string>AD_PLATFORMS_SEARCH_RESULTS_PAGE</string>+ <string>AD_PLATFORMS_SEARCH_LANDING_PAGE</string>+ <string>AD_PLATFORMS_PRODUCT_PAGE</string>+ <string>AD_PLATFORMS_APPSTORE_ALL_PLACEMENTS</string>+ <string>AD_PLATFORMS_APPSTORE_SLP_INCREMENTALITYAPPSTORE</string>+ <string>AD_PLATFORMS_APPSTORE_SRP_INCREMENTALITYAPPSTORE</string>+ <string>AD_PLATFORMS_APPSTORE_TT_INCREMENTALITYAPPSTORE</string>+ <string>AD_PLATFORMS_APPSTORE_PP_INCREMENTALITYAPPSTORE</string>+ </array>+ <key>fairplay-client</key>+ <string>700802717</string>+ <key>keychain-access-groups</key>+ <array>+ <string>apple</string>+ </array>+ <key>platform-application</key>+ <true/>+ <key>seatbelt-profiles</key>+ <array>+ <string>temporary-sandbox</string>+ </array>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>adi-client</key>+ <string>2463478364</string>+ <key>com.apple.CommCenter.fine-grained</key>+ <array>+ <string>spi</string>+ </array>+ <key>com.apple.ap.signingservice.client</key>+ <true/>+ <key>com.apple.assertiond.app-state-monitor</key>+ <true/>+ <key>com.apple.duet.activityscheduler.allow</key>+ <true/>+ <key>com.apple.private.accounts.allaccounts</key>+ <true/>+ <key>com.apple.private.ap.idmanager</key>+ <true/>+ <key>com.apple.private.applemediaservices</key>+ <true/>+ <key>com.apple.private.appstored</key>+ <array>+ <string>AppCapabilities</string>+ </array>+ <key>com.apple.private.calendar.has-adopted-modern-request-access-methods</key>+ <true/>+ <key>com.apple.private.fairplay.FPDI</key>+ <dict>+ <key>capabilities</key>+ <array>+ <integer>4014732562</integer>+ </array>+ <key>client-identifier</key>+ <string>com.apple.ap.promotedcontentd</string>+ </dict>+ <key>com.apple.private.fpsd.client</key>+ <true/>+ <key>com.apple.private.iad.opt-in-control</key>+ <true/>+ <key>com.apple.private.intelligenceplatform.client-identifier</key>+ <string>com.apple.ap.promotedcontentd</string>+ <key>com.apple.private.intelligenceplatform.use-cases</key>+ <dict>+ <key>PolicyInstrumentation</key>+ <dict>+ <key>Streams</key>+ <dict>+ <key>AdPlatforms.PolicyInstrumentation.Candidate</key>+ <dict>+ <key>mode</key>+ <string>read-write</string>+ </dict>+ <key>AdPlatforms.PolicyInstrumentation.Opportunity</key>+ <dict>+ <key>mode</key>+ <string>read-write</string>+ </dict>+ </dict>+ </dict>+ </dict>+ <key>com.apple.private.keychain.sysbound</key>+ <true/>+ <key>com.apple.private.network.socket-delegate</key>+ <true/>+ <key>com.apple.private.tcc.allow</key>+ <array>+ <string>kTCCServiceUserTracking</string>+ </array>+ <key>com.apple.private.tcc.manager.access.read</key>+ <array>+ <string>kTCCServiceAll</string>+ </array>+ <key>com.apple.private.tcc.manager.check-by-audit-token</key>+ <array>+ <string>kTCCServiceUserTracking</string>+ </array>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/usr/libexec</string>+ <string>/private/var/containers/Bundle/Application/</string>+ </array>+ <key>com.apple.security.exception.files.home-relative-path.read-only</key>+ <array>+ <string>/Library/Trial/</string>+ <string>/Library/UserConfigurationProfiles/Truth.plist</string>+ </array>+ <key>com.apple.security.exception.files.home-relative-path.read-write</key>+ <array>+ <string>/Library/Application Support/com.apple.ap.promotedcontentd/</string>+ <string>/Library/Caches/com.apple.ap.promotedcontentd/</string>+ <string>/Library/HTTPStorages</string>+ <string>/Library/HTTPStorages/com.apple.ap.promotedcontentd/</string>+ </array>+ <key>com.apple.security.exception.mach-lookup.global-name</key>+ <array>+ <string>com.apple.biome.compute.source.user</string>+ <string>com.apple.fairplaydeviceidentityd</string>+ <string>com.apple.commcenter.coretelephony.xpc</string>+ <string>com.apple.fairplayd.versioned</string>+ <string>com.apple.fpsd</string>+ <string>com.apple.fairplayd</string>+ <string>com.apple.fairplayd.xpc</string>+ <string>com.apple.ap.adprivacyd.opt-out</string>+ <string>com.apple.ap.adprivacyd.idmanager</string>+ <string>com.apple.adid</string>+ <string>com.apple.symptom_diagnostics</string>+ <string>com.apple.appstored.xpc</string>+ <string>com.apple.ak.auth.xpc</string>+ <string>com.apple.biome.access.user</string>+ </array>+ <key>com.apple.security.exception.process-info</key>+ <true/>+ <key>com.apple.security.exception.shared-preference.read-only</key>+ <array>+ <string>com.apple.AdLib</string>+ <string>com.apple.springboard</string>+ <string>com.apple.ap.promotedcontentd</string>+ <string>com.apple.security</string>+ <string>com.apple.CFNetwork</string>+ <string>com.apple.itunesstored</string>+ <string>com.apple.amsengagementd</string>+ </array>+ <key>com.apple.security.exception.shared-preference.read-write</key>+ <array>+ <string>com.apple.AdPlatforms</string>+ <string>com.apple.ap.config</string>+ </array>+ <key>com.apple.security.network.client</key>+ <true/>+ <key>com.apple.security.temporary-exception.mach-lookup.global-name</key>+ <array>+ <string>com.apple.fpsd</string>+ <string>com.apple.fairplayd</string>+ <string>com.apple.fairplayd.xpc</string>+ <string>com.apple.ak.auth.xpc</string>+ </array>+ <key>com.apple.security.ts.mobile-keybag-access</key>+ <true/>+ <key>com.apple.security.ts.tmpdir</key>+ <string>com.apple.ap.promotedcontentd</string>+ <key>com.apple.trial.client</key>+ <array>+ <string>513</string>+ <string>514</string>+ <string>AD_PLATFORMS_TODAY_TAB</string>+ <string>AD_PLATFORMS_SEARCH_RESULTS_PAGE</string>+ <string>AD_PLATFORMS_SEARCH_LANDING_PAGE</string>+ <string>AD_PLATFORMS_PRODUCT_PAGE</string>+ <string>AD_PLATFORMS_APPSTORE_ALL_PLACEMENTS</string>+ <string>AD_PLATFORMS_APPSTORE_SLP_INCREMENTALITYAPPSTORE</string>+ <string>AD_PLATFORMS_APPSTORE_SRP_INCREMENTALITYAPPSTORE</string>+ <string>AD_PLATFORMS_APPSTORE_TT_INCREMENTALITYAPPSTORE</string>+ <string>AD_PLATFORMS_APPSTORE_PP_INCREMENTALITYAPPSTORE</string>+ </array>+ <key>fairplay-client</key>+ <string>700802717</string>+ <key>keychain-access-groups</key>+ <array>+ <string>apple</string>+ </array>+ <key>platform-application</key>+ <true/>+ <key>seatbelt-profiles</key>+ <array>+ <string>temporary-sandbox</string>+ </array>+</dict>+</plist>diff --git a/tests/VPhoneSignTests/Fixtures/entitlements/runningboardd.plist b/tests/VPhoneSignTests/Fixtures/entitlements/runningboardd.plistnew file mode 100644index 00000000..b9cf15b3--- /dev/null+++ b/tests/VPhoneSignTests/Fixtures/entitlements/runningboardd.plist@@ -0,0 +1,327 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.PerfPowerServices.data-donation</key>+ <true/>+ <key>com.apple.agx.gpurole</key>+ <true/>+ <key>com.apple.frontboardservices.display-layout-monitor</key>+ <true/>+ <key>com.apple.private.MobileContainerManager.otherIdLookup</key>+ <true/>+ <key>com.apple.private.coalition-policy</key>+ <true/>+ <key>com.apple.private.coreservices.canmaplsdatabase</key>+ <true/>+ <key>com.apple.private.iokit.assertion-suspendresume</key>+ <true/>+ <key>com.apple.private.jetsam.modify-priority</key>+ <integer>100</integer>+ <key>com.apple.private.kernel.override-cpumon</key>+ <true/>+ <key>com.apple.private.kernel.setpriority-darwin-role</key>+ <true/>+ <key>com.apple.private.memorystatus</key>+ <true/>+ <key>com.apple.private.osanalytics.write-logs.allow</key>+ <true/>+ <key>com.apple.private.pluginkit.manager</key>+ <true/>+ <key>com.apple.private.process.suspend-resume.any</key>+ <true/>+ <key>com.apple.private.runningboard.reconnect</key>+ <true/>+ <key>com.apple.private.runningboard.wake-for-process-state-update</key>+ <true/>+ <key>com.apple.private.security.datavault.controller</key>+ <true/>+ <key>com.apple.private.security.storage.Safari</key>+ <true/>+ <key>com.apple.private.security.storage.driverkitd</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.set-carplay-mode</key>+ <true/>+ <key>com.apple.private.set-gpu-role</key>+ <true/>+ <key>com.apple.private.spawn-driver</key>+ <true/>+ <key>com.apple.private.task_policy</key>+ <true/>+ <key>com.apple.private.vfs.allow-low-space-writes</key>+ <true/>+ <key>com.apple.private.vfs.rdadvisev-noage</key>+ <true/>+ <key>com.apple.private.xpc.allowed-launch-types</key>+ <array>+ <integer>3</integer>+ </array>+ <key>com.apple.private.xpc.conclave.submit</key>+ <true/>+ <key>com.apple.private.xpc.domain-extension.proxy</key>+ <true/>+ <key>com.apple.private.xpc.launchd.allow-posixspawn-telemetry</key>+ <true/>+ <key>com.apple.private.xpc.launchd.allow-set-bundle-path</key>+ <true/>+ <key>com.apple.private.xpc.launchd.app-server</key>+ <true/>+ <key>com.apple.private.xpc.launchd.job-manager</key>+ <string>com.apple.runningboard</string>+ <key>com.apple.private.xpc.persona-manager</key>+ <true/>+ <key>com.apple.rootless.datavault.metadata</key>+ <true/>+ <key>com.apple.runningboard.primitiveattribute</key>+ <true/>+ <key>com.apple.runningboard.targetidentities</key>+ <true/>+ <key>com.apple.security.enterprise-volume-access</key>+ <true/>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/private/var/db/os_eligibility/eligibility.plist</string>+ </array>+ <key>com.apple.security.exception.files.absolute-path.read-write</key>+ <array>+ <string>/private/var/root/Library/Caches/com.apple.runningboardd/</string>+ </array>+ <key>com.apple.security.exception.shared-preference.read-write</key>+ <array>+ <string>com.apple.runningboardd</string>+ <string>com.apple.coreos.fast</string>+ </array>+ <key>com.apple.spd.anypidmonitoring</key>+ <true/>+ <key>com.apple.tailspin.dump-output</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetch</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetchbundle</key>+ <true/>+ <key>seatbelt-profiles</key>+ <array>+ <string>runningboardd</string>+ </array>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.PerfPowerServices.data-donation</key>+ <true/>+ <key>com.apple.agx.gpurole</key>+ <true/>+ <key>com.apple.frontboardservices.display-layout-monitor</key>+ <true/>+ <key>com.apple.private.MobileContainerManager.otherIdLookup</key>+ <true/>+ <key>com.apple.private.coalition-policy</key>+ <true/>+ <key>com.apple.private.coreservices.canmaplsdatabase</key>+ <true/>+ <key>com.apple.private.iokit.assertion-suspendresume</key>+ <true/>+ <key>com.apple.private.jetsam.modify-priority</key>+ <integer>100</integer>+ <key>com.apple.private.kernel.override-cpumon</key>+ <true/>+ <key>com.apple.private.kernel.setpriority-darwin-role</key>+ <true/>+ <key>com.apple.private.memorystatus</key>+ <true/>+ <key>com.apple.private.osanalytics.write-logs.allow</key>+ <true/>+ <key>com.apple.private.pluginkit.manager</key>+ <true/>+ <key>com.apple.private.process.suspend-resume.any</key>+ <true/>+ <key>com.apple.private.runningboard.reconnect</key>+ <true/>+ <key>com.apple.private.runningboard.wake-for-process-state-update</key>+ <true/>+ <key>com.apple.private.security.datavault.controller</key>+ <true/>+ <key>com.apple.private.security.storage.Safari</key>+ <true/>+ <key>com.apple.private.security.storage.driverkitd</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.set-carplay-mode</key>+ <true/>+ <key>com.apple.private.set-gpu-role</key>+ <true/>+ <key>com.apple.private.spawn-driver</key>+ <true/>+ <key>com.apple.private.task_policy</key>+ <true/>+ <key>com.apple.private.vfs.allow-low-space-writes</key>+ <true/>+ <key>com.apple.private.vfs.rdadvisev-noage</key>+ <true/>+ <key>com.apple.private.xpc.allowed-launch-types</key>+ <array>+ <integer>3</integer>+ </array>+ <key>com.apple.private.xpc.conclave.submit</key>+ <true/>+ <key>com.apple.private.xpc.domain-extension.proxy</key>+ <true/>+ <key>com.apple.private.xpc.launchd.allow-posixspawn-telemetry</key>+ <true/>+ <key>com.apple.private.xpc.launchd.allow-set-bundle-path</key>+ <true/>+ <key>com.apple.private.xpc.launchd.app-server</key>+ <true/>+ <key>com.apple.private.xpc.launchd.job-manager</key>+ <string>com.apple.runningboard</string>+ <key>com.apple.private.xpc.persona-manager</key>+ <true/>+ <key>com.apple.rootless.datavault.metadata</key>+ <true/>+ <key>com.apple.runningboard.primitiveattribute</key>+ <true/>+ <key>com.apple.runningboard.targetidentities</key>+ <true/>+ <key>com.apple.security.enterprise-volume-access</key>+ <true/>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/private/var/db/os_eligibility/eligibility.plist</string>+ </array>+ <key>com.apple.security.exception.files.absolute-path.read-write</key>+ <array>+ <string>/private/var/root/Library/Caches/com.apple.runningboardd/</string>+ </array>+ <key>com.apple.security.exception.shared-preference.read-write</key>+ <array>+ <string>com.apple.runningboardd</string>+ <string>com.apple.coreos.fast</string>+ </array>+ <key>com.apple.spd.anypidmonitoring</key>+ <true/>+ <key>com.apple.tailspin.dump-output</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetch</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetchbundle</key>+ <true/>+ <key>seatbelt-profiles</key>+ <array>+ <string>runningboardd</string>+ </array>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.PerfPowerServices.data-donation</key>+ <true/>+ <key>com.apple.agx.gpurole</key>+ <true/>+ <key>com.apple.frontboardservices.display-layout-monitor</key>+ <true/>+ <key>com.apple.private.MobileContainerManager.otherIdLookup</key>+ <true/>+ <key>com.apple.private.coalition-policy</key>+ <true/>+ <key>com.apple.private.coreservices.canmaplsdatabase</key>+ <true/>+ <key>com.apple.private.iokit.assertion-suspendresume</key>+ <true/>+ <key>com.apple.private.jetsam.modify-priority</key>+ <integer>100</integer>+ <key>com.apple.private.kernel.override-cpumon</key>+ <true/>+ <key>com.apple.private.kernel.setpriority-darwin-role</key>+ <true/>+ <key>com.apple.private.memorystatus</key>+ <true/>+ <key>com.apple.private.osanalytics.write-logs.allow</key>+ <true/>+ <key>com.apple.private.pluginkit.manager</key>+ <true/>+ <key>com.apple.private.process.suspend-resume.any</key>+ <true/>+ <key>com.apple.private.runningboard.reconnect</key>+ <true/>+ <key>com.apple.private.runningboard.wake-for-process-state-update</key>+ <true/>+ <key>com.apple.private.security.datavault.controller</key>+ <true/>+ <key>com.apple.private.security.storage.Safari</key>+ <true/>+ <key>com.apple.private.security.storage.driverkitd</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.set-carplay-mode</key>+ <true/>+ <key>com.apple.private.set-gpu-role</key>+ <true/>+ <key>com.apple.private.spawn-driver</key>+ <true/>+ <key>com.apple.private.task_policy</key>+ <true/>+ <key>com.apple.private.vfs.allow-low-space-writes</key>+ <true/>+ <key>com.apple.private.vfs.rdadvisev-noage</key>+ <true/>+ <key>com.apple.private.xpc.allowed-launch-types</key>+ <array>+ <integer>3</integer>+ </array>+ <key>com.apple.private.xpc.conclave.submit</key>+ <true/>+ <key>com.apple.private.xpc.domain-extension.proxy</key>+ <true/>+ <key>com.apple.private.xpc.launchd.allow-posixspawn-telemetry</key>+ <true/>+ <key>com.apple.private.xpc.launchd.allow-set-bundle-path</key>+ <true/>+ <key>com.apple.private.xpc.launchd.app-server</key>+ <true/>+ <key>com.apple.private.xpc.launchd.job-manager</key>+ <string>com.apple.runningboard</string>+ <key>com.apple.private.xpc.persona-manager</key>+ <true/>+ <key>com.apple.rootless.datavault.metadata</key>+ <true/>+ <key>com.apple.runningboard.primitiveattribute</key>+ <true/>+ <key>com.apple.runningboard.targetidentities</key>+ <true/>+ <key>com.apple.security.enterprise-volume-access</key>+ <true/>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/private/var/db/os_eligibility/eligibility.plist</string>+ </array>+ <key>com.apple.security.exception.files.absolute-path.read-write</key>+ <array>+ <string>/private/var/root/Library/Caches/com.apple.runningboardd/</string>+ </array>+ <key>com.apple.security.exception.shared-preference.read-write</key>+ <array>+ <string>com.apple.runningboardd</string>+ <string>com.apple.coreos.fast</string>+ </array>+ <key>com.apple.spd.anypidmonitoring</key>+ <true/>+ <key>com.apple.tailspin.dump-output</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetch</key>+ <true/>+ <key>com.apple.usermanagerd.persona.fetchbundle</key>+ <true/>+ <key>seatbelt-profiles</key>+ <array>+ <string>runningboardd</string>+ </array>+</dict>+</plist>diff --git a/tests/VPhoneSignTests/Fixtures/entitlements/seserviced.plist b/tests/VPhoneSignTests/Fixtures/entitlements/seserviced.plistnew file mode 100644index 00000000..a6090489--- /dev/null+++ b/tests/VPhoneSignTests/Fixtures/entitlements/seserviced.plist@@ -0,0 +1,632 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>allow-softwareupdated</key>+ <true/>+ <key>application-identifier</key>+ <string>com.apple.seserviced</string>+ <key>com.apple.BTServer.allowLEConnectionHandleQuery</key>+ <true/>+ <key>com.apple.CommCenter.fine-grained</key>+ <array>+ <string>cellular-plan</string>+ </array>+ <key>com.apple.NPKCompanionAgent.client</key>+ <true/>+ <key>com.apple.aop.rose.controller.admin</key>+ <true/>+ <key>com.apple.application-identifier</key>+ <string>com.apple.seserviced</string>+ <key>com.apple.authkit.client.private</key>+ <true/>+ <key>com.apple.bluetooth.custom.properties.writable</key>+ <true/>+ <key>com.apple.bluetooth.pairedInfoSecurity</key>+ <true/>+ <key>com.apple.bluetooth.system</key>+ <true/>+ <key>com.apple.cards.all-access</key>+ <true/>+ <key>com.apple.developer.hardened-process</key>+ <true/>+ <key>com.apple.developer.homekit</key>+ <true/>+ <key>com.apple.duet.activityscheduler.allow</key>+ <true/>+ <key>com.apple.feedbackd.client-forms</key>+ <array>+ <string>framework-car-key</string>+ </array>+ <key>com.apple.frontboard.launchapplications</key>+ <true/>+ <key>com.apple.internal.seserviced.all.endpoints.and.cas</key>+ <true/>+ <key>com.apple.keystore.access-keychain-keys</key>+ <true/>+ <key>com.apple.keystore.sik.access</key>+ <true/>+ <key>com.apple.mobileactivationd.bridge</key>+ <true/>+ <key>com.apple.mobileactivationd.device-identifiers</key>+ <true/>+ <key>com.apple.mobileactivationd.spi</key>+ <true/>+ <key>com.apple.nano.nanoregistry.generalaccess</key>+ <true/>+ <key>com.apple.nearbyd.diagnostics</key>+ <true/>+ <key>com.apple.nearbyd.xpc</key>+ <true/>+ <key>com.apple.nearbyinteraction.background</key>+ <true/>+ <key>com.apple.nfcd.event.notification</key>+ <true/>+ <key>com.apple.nfcd.hce</key>+ <true/>+ <key>com.apple.nfcd.hwmanager</key>+ <true/>+ <key>com.apple.nfcd.session.credential.manager</key>+ <true/>+ <key>com.apple.nfcd.session.fieldOperations</key>+ <true/>+ <key>com.apple.nfcd.session.lpemConfig</key>+ <true/>+ <key>com.apple.nfcd.session.se</key>+ <true/>+ <key>com.apple.nfcd.session.trust</key>+ <true/>+ <key>com.apple.payment.all-access</key>+ <true/>+ <key>com.apple.peerpayment.all-access</key>+ <true/>+ <key>com.apple.private.MobileGestalt.AllowedProtectedKeys</key>+ <array>+ <string>UniqueDeviceID</string>+ <string>BootManifestHash</string>+ <string>ArrowChipID</string>+ <string>ArrowUniqueChipID</string>+ <string>UniqueChipID</string>+ <string>SerialNumber</string>+ </array>+ <key>com.apple.private.accounts.allaccounts</key>+ <true/>+ <key>com.apple.private.applecredentialmanager.allow</key>+ <true/>+ <key>com.apple.private.applesse.allow</key>+ <true/>+ <key>com.apple.private.assets.accessible-asset-types</key>+ <array>+ <string>com.apple.MobileAsset.SecureElementServiceAssets</string>+ </array>+ <key>com.apple.private.biome.client-identifier</key>+ <string>com.apple.seserviced</string>+ <key>com.apple.private.biome.read-only</key>+ <array>+ <string>CarKey.ProvisioningData</string>+ <string>CarPlay.Connected</string>+ </array>+ <key>com.apple.private.carkit.pairing</key>+ <true/>+ <key>com.apple.private.ckks</key>+ <true/>+ <key>com.apple.private.credential-state-access</key>+ <true/>+ <key>com.apple.private.homekit</key>+ <true/>+ <key>com.apple.private.homekit.home-location</key>+ <true/>+ <key>com.apple.private.homekit.location</key>+ <true/>+ <key>com.apple.private.ids.messaging</key>+ <array>+ <string>com.apple.private.alloy.keysharing</string>+ </array>+ <key>com.apple.private.ids.messaging.urgent-priority</key>+ <array>+ <string>com.apple.private.alloy.keysharing</string>+ </array>+ <key>com.apple.private.ids.remotecredentials</key>+ <true/>+ <key>com.apple.private.imcore.imremoteurlconnection</key>+ <true/>+ <key>com.apple.private.nearbyinteraction.privileged</key>+ <true/>+ <key>com.apple.private.octagon</key>+ <true/>+ <key>com.apple.private.octagon.secureelement</key>+ <true/>+ <key>com.apple.private.security.bootpolicy</key>+ <true/>+ <key>com.apple.private.security.storage.SecureElementService</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.seserviced.sereservation.client</key>+ <true/>+ <key>com.apple.private.tcc.allow</key>+ <array>+ <string>kTCCServiceBluetoothAlways</string>+ <string>kTCCServiceWillow</string>+ </array>+ <key>com.apple.private.tcc.manager.access.read</key>+ <array>+ <string>kTCCServiceAll</string>+ </array>+ <key>com.apple.private.tcc.manager.check-by-audit-token</key>+ <array>+ <string>kTCCServiceAll</string>+ </array>+ <key>com.apple.runningboard.private.se.credential</key>+ <true/>+ <key>com.apple.runningboard.process-state</key>+ <true/>+ <key>com.apple.runningboard.seserviced</key>+ <true/>+ <key>com.apple.security.attestation.access</key>+ <true/>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/System/AppleInternal/Library/</string>+ <string>/System/Library/Preferences/Logging/</string>+ <string>/AppleInternal/Library/Preferences/Logging/</string>+ <string>/Library/Preferences/Logging/</string>+ <string>/usr/local/SLAM/</string>+ <string>/private/var/hardware/FactoryData/System/Library/Caches/com.apple.factorydata/</string>+ <string>/usr/libexec/</string>+ <string>/usr/standalone/firmware/SLAM/</string>+ <string>/private/preboot/</string>+ <string>/private/var/db/os_eligibility/eligibility.plist</string>+ <string>/private/var/db/nearbyd/</string>+ </array>+ <key>com.apple.security.exception.files.home-relative-path.read-write</key>+ <array>+ <string>Library/HTTPStorages/com.apple.secureelementservice/</string>+ <string>Library/HTTPStorages</string>+ <string>Library/Caches/com.apple.secureelementservice/</string>+ <string>Library/Logs/AppleSSE.log</string>+ <string>Library/SecureElementService/</string>+ <string>Library/Caches/com.apple.seserviced/</string>+ </array>+ <key>com.apple.security.exception.iokit-user-client-class</key>+ <array>+ <string>AppleSSEUserClient</string>+ <string>AppleCredentialManagerUserClient</string>+ <string>AppleSPURoseDriverUserClient</string>+ <string>AppleSPUUserClient</string>+ <string>IOHIDEventServiceFastPathUserClient</string>+ <string>IOReportUserClient</string>+ </array>+ <key>com.apple.security.exception.mach-lookup.global-name</key>+ <array>+ <string>com.apple.symptom_diagnostics</string>+ <string>com.apple.NPKCompanionAgent.Server</string>+ <string>com.apple.softposreaderd</string>+ <string>com.apple.SBUserNotification</string>+ <string>com.apple.carkit.pairing.service</string>+ <string>com.apple.NPKCompanionAgent.library</string>+ <string>com.apple.passd.library</string>+ <string>com.apple.bluetooth.xpc</string>+ <string>com.apple.powerlog.plxpclogger.xpc</string>+ <string>com.apple.securityd.ckks</string>+ <string>com.apple.security.octagon</string>+ <string>com.apple.nearbyd.xpc.diagnostics</string>+ <string>com.apple.secureelementservice.test.events</string>+ <string>com.apple.seservicetests.credential-events</string>+ <string>com.apple.passd.nf-events</string>+ <string>com.apple.nfcd.credential-events</string>+ <string>com.apple.seld.tsmmanager</string>+ <string>com.apple.passd.payment</string>+ <string>com.apple.identityservicesd.embedded.auth</string>+ <string>com.apple.server.bluetooth.le.pipe.xpc</string>+ <string>com.apple.server.bluetooth.le.att.xpc</string>+ <string>com.apple.nearbyd.xpc.ranging</string>+ <string>com.apple.nfcd.hwmanager</string>+ <string>com.apple.CoreAuthentication.daemon</string>+ <string>com.apple.ak.auth.xpc</string>+ <string>com.apple.PowerManagement.control</string>+ <string>com.apple.idsremoteurlconnectionagent.embedded.auth</string>+ <string>com.apple.nearbyd.xpc.nearbyinteraction</string>+ <string>com.apple.commcenter.coretelephony.xpc</string>+ <string>com.apple.carousel.connectionstatusservice</string>+ <string>com.apple.SBUserNotification</string>+ <string>com.apple.wallet.application-authorization</string>+ <string>com.apple.duet.activityscheduler</string>+ <string>com.apple.frontboard.systemappservices</string>+ <string>com.apple.SESAngel.mach</string>+ <string>com.apple.passd.device-registration</string>+ <string>com.apple.mobileactivationd</string>+ <string>com.apple.seserviced.sereservation.client</string>+ <string>com.apple.CellularPlanDaemon.xpc</string>+ <string>com.apple.surfboard.applicationservice</string>+ <string>com.apple.surfboard.scenesessionservice</string>+ <string>com.apple.spotlight.IndexAgent</string>+ <string>com.apple.feedbackd.xpc</string>+ <string>com.apple.biome.PublicStreamAccessService</string>+ <string>com.apple.biome.compute.publisher.service.user</string>+ <string>com.apple.biome.access.user</string>+ </array>+ <key>com.apple.security.exception.process-info</key>+ <true/>+ <key>com.apple.security.exception.shared-preference.read-only</key>+ <array>+ <string>com.apple.mobileactivationd</string>+ <string>com.apple.nsurlcache</string>+ <string>com.apple.facetime.bag</string>+ <string>com.apple.imessage.bag</string>+ <string>com.apple.AppSupport.plist</string>+ <string>com.apple.stockholm</string>+ </array>+ <key>com.apple.security.exception.shared-preference.read-write</key>+ <array>+ <string>com.apple.seserviced.shared</string>+ <string>com.apple.seserviced</string>+ <string>com.apple.secureelementservice</string>+ <string>com.apple.seserviced.contactlessCredential.settings</string>+ <string>com.apple.seserviced.designatedkeys</string>+ <string>com.apple.carkey.settings</string>+ </array>+ <key>com.apple.security.network.client</key>+ <true/>+ <key>com.apple.security.ts.identity-services-client</key>+ <true/>+ <key>com.apple.security.ts.power-assertions</key>+ <true/>+ <key>com.apple.security.ts.read-factory-files</key>+ <true/>+ <key>com.apple.security.ts.springboard-services</key>+ <true/>+ <key>com.apple.security.ts.tmpdir</key>+ <string>com.apple.secureelementservice</string>+ <key>com.apple.seld.tsmmanager</key>+ <true/>+ <key>com.apple.seserviced.SESUIServiceApp.session</key>+ <true/>+ <key>com.apple.seserviced.seendpoints</key>+ <true/>+ <key>com.apple.seserviced.seendpoints.certificateauthorities</key>+ <true/>+ <key>com.apple.softposreaderd</key>+ <integer>2</integer>+ <key>com.apple.softposreaderd.provision</key>+ <integer>2</integer>+ <key>com.apple.springboard.monitorAppSwitcherUserQuit</key>+ <true/>+ <key>com.apple.springboard.remote-alert</key>+ <true/>+ <key>com.apple.sts.xpcservice.client</key>+ <true/>+ <key>com.apple.wallet.application-authorization</key>+ <true/>+ <key>keychain-access-groups</key>+ <array>+ <string>com.apple.internal.seserviced.keysync.recoveryblobs</string>+ <string>com.apple.internal.seserviced.fidokeys</string>+ <string>lockdown-identities</string>+ <string>com.apple.seserviced</string>+ <string>com.apple.private.seserviced.privacykeys</string>+ </array>+ <key>platform-application</key>+ <true/>+ <key>seatbelt-profiles</key>+ <array>+ <string>temporary-sandbox</string>+ </array>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>allow-softwareupdated</key>+ <true/>+ <key>application-identifier</key>+ <string>com.apple.seserviced</string>+ <key>com.apple.BTServer.allowLEConnectionHandleQuery</key>+ <true/>+ <key>com.apple.CommCenter.fine-grained</key>+ <array>+ <string>cellular-plan</string>+ </array>+ <key>com.apple.NPKCompanionAgent.client</key>+ <true/>+ <key>com.apple.aop.rose.controller.admin</key>+ <true/>+ <key>com.apple.application-identifier</key>+ <string>com.apple.seserviced</string>+ <key>com.apple.authkit.client.private</key>+ <true/>+ <key>com.apple.bluetooth.custom.properties.writable</key>+ <true/>+ <key>com.apple.bluetooth.pairedInfoSecurity</key>+ <true/>+ <key>com.apple.bluetooth.system</key>+ <true/>+ <key>com.apple.cards.all-access</key>+ <true/>+ <key>com.apple.developer.hardened-process</key>+ <true/>+ <key>com.apple.developer.homekit</key>+ <true/>+ <key>com.apple.duet.activityscheduler.allow</key>+ <true/>+ <key>com.apple.feedbackd.client-forms</key>+ <array>+ <string>framework-car-key</string>+ </array>+ <key>com.apple.frontboard.launchapplications</key>+ <true/>+ <key>com.apple.internal.seserviced.all.endpoints.and.cas</key>+ <true/>+ <key>com.apple.keystore.access-keychain-keys</key>+ <true/>+ <key>com.apple.keystore.sik.access</key>+ <true/>+ <key>com.apple.mobileactivationd.bridge</key>+ <true/>+ <key>com.apple.mobileactivationd.device-identifiers</key>+ <true/>+ <key>com.apple.mobileactivationd.spi</key>+ <true/>+ <key>com.apple.nano.nanoregistry.generalaccess</key>+ <true/>+ <key>com.apple.nearbyd.diagnostics</key>+ <true/>+ <key>com.apple.nearbyd.xpc</key>+ <true/>+ <key>com.apple.nearbyinteraction.background</key>+ <true/>+ <key>com.apple.nfcd.event.notification</key>+ <true/>+ <key>com.apple.nfcd.hce</key>+ <true/>+ <key>com.apple.nfcd.hwmanager</key>+ <true/>+ <key>com.apple.nfcd.session.credential.manager</key>+ <true/>+ <key>com.apple.nfcd.session.fieldOperations</key>+ <true/>+ <key>com.apple.nfcd.session.lpemConfig</key>+ <true/>+ <key>com.apple.nfcd.session.se</key>+ <true/>+ <key>com.apple.nfcd.session.trust</key>+ <true/>+ <key>com.apple.payment.all-access</key>+ <true/>+ <key>com.apple.peerpayment.all-access</key>+ <true/>+ <key>com.apple.private.MobileGestalt.AllowedProtectedKeys</key>+ <array>+ <string>UniqueDeviceID</string>+ <string>BootManifestHash</string>+ <string>ArrowChipID</string>+ <string>ArrowUniqueChipID</string>+ <string>UniqueChipID</string>+ <string>SerialNumber</string>+ </array>+ <key>com.apple.private.accounts.allaccounts</key>+ <true/>+ <key>com.apple.private.applecredentialmanager.allow</key>+ <true/>+ <key>com.apple.private.applesse.allow</key>+ <true/>+ <key>com.apple.private.assets.accessible-asset-types</key>+ <array>+ <string>com.apple.MobileAsset.SecureElementServiceAssets</string>+ </array>+ <key>com.apple.private.biome.client-identifier</key>+ <string>com.apple.seserviced</string>+ <key>com.apple.private.biome.read-only</key>+ <array>+ <string>CarKey.ProvisioningData</string>+ <string>CarPlay.Connected</string>+ </array>+ <key>com.apple.private.carkit.pairing</key>+ <true/>+ <key>com.apple.private.ckks</key>+ <true/>+ <key>com.apple.private.credential-state-access</key>+ <true/>+ <key>com.apple.private.homekit</key>+ <true/>+ <key>com.apple.private.homekit.home-location</key>+ <true/>+ <key>com.apple.private.homekit.location</key>+ <true/>+ <key>com.apple.private.ids.messaging</key>+ <array>+ <string>com.apple.private.alloy.keysharing</string>+ </array>+ <key>com.apple.private.ids.messaging.urgent-priority</key>+ <array>+ <string>com.apple.private.alloy.keysharing</string>+ </array>+ <key>com.apple.private.ids.remotecredentials</key>+ <true/>+ <key>com.apple.private.imcore.imremoteurlconnection</key>+ <true/>+ <key>com.apple.private.nearbyinteraction.privileged</key>+ <true/>+ <key>com.apple.private.octagon</key>+ <true/>+ <key>com.apple.private.octagon.secureelement</key>+ <true/>+ <key>com.apple.private.security.bootpolicy</key>+ <true/>+ <key>com.apple.private.security.storage.SecureElementService</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.seserviced.sereservation.client</key>+ <true/>+ <key>com.apple.private.tcc.allow</key>+ <array>+ <string>kTCCServiceBluetoothAlways</string>+ <string>kTCCServiceWillow</string>+ </array>+ <key>com.apple.private.tcc.manager.access.read</key>+ <array>+ <string>kTCCServiceAll</string>+ </array>+ <key>com.apple.private.tcc.manager.check-by-audit-token</key>+ <array>+ <string>kTCCServiceAll</string>+ </array>+ <key>com.apple.runningboard.private.se.credential</key>+ <true/>+ <key>com.apple.runningboard.process-state</key>+ <true/>+ <key>com.apple.runningboard.seserviced</key>+ <true/>+ <key>com.apple.security.attestation.access</key>+ <true/>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/System/AppleInternal/Library/</string>+ <string>/System/Library/Preferences/Logging/</string>+ <string>/AppleInternal/Library/Preferences/Logging/</string>+ <string>/Library/Preferences/Logging/</string>+ <string>/usr/local/SLAM/</string>+ <string>/private/var/hardware/FactoryData/System/Library/Caches/com.apple.factorydata/</string>+ <string>/usr/libexec/</string>+ <string>/usr/standalone/firmware/SLAM/</string>+ <string>/private/preboot/</string>+ <string>/private/var/db/os_eligibility/eligibility.plist</string>+ <string>/private/var/db/nearbyd/</string>+ </array>+ <key>com.apple.security.exception.files.home-relative-path.read-write</key>+ <array>+ <string>Library/HTTPStorages/com.apple.secureelementservice/</string>+ <string>Library/HTTPStorages</string>+ <string>Library/Caches/com.apple.secureelementservice/</string>+ <string>Library/Logs/AppleSSE.log</string>+ <string>Library/SecureElementService/</string>+ <string>Library/Caches/com.apple.seserviced/</string>+ </array>+ <key>com.apple.security.exception.iokit-user-client-class</key>+ <array>+ <string>AppleSSEUserClient</string>+ <string>AppleCredentialManagerUserClient</string>+ <string>AppleSPURoseDriverUserClient</string>+ <string>AppleSPUUserClient</string>+ <string>IOHIDEventServiceFastPathUserClient</string>+ <string>IOReportUserClient</string>+ </array>+ <key>com.apple.security.exception.mach-lookup.global-name</key>+ <array>+ <string>com.apple.symptom_diagnostics</string>+ <string>com.apple.NPKCompanionAgent.Server</string>+ <string>com.apple.softposreaderd</string>+ <string>com.apple.SBUserNotification</string>+ <string>com.apple.carkit.pairing.service</string>+ <string>com.apple.NPKCompanionAgent.library</string>+ <string>com.apple.passd.library</string>+ <string>com.apple.bluetooth.xpc</string>+ <string>com.apple.powerlog.plxpclogger.xpc</string>+ <string>com.apple.securityd.ckks</string>+ <string>com.apple.security.octagon</string>+ <string>com.apple.nearbyd.xpc.diagnostics</string>+ <string>com.apple.secureelementservice.test.events</string>+ <string>com.apple.seservicetests.credential-events</string>+ <string>com.apple.passd.nf-events</string>+ <string>com.apple.nfcd.credential-events</string>+ <string>com.apple.seld.tsmmanager</string>+ <string>com.apple.passd.payment</string>+ <string>com.apple.identityservicesd.embedded.auth</string>+ <string>com.apple.server.bluetooth.le.pipe.xpc</string>+ <string>com.apple.server.bluetooth.le.att.xpc</string>+ <string>com.apple.nearbyd.xpc.ranging</string>+ <string>com.apple.nfcd.hwmanager</string>+ <string>com.apple.CoreAuthentication.daemon</string>+ <string>com.apple.ak.auth.xpc</string>+ <string>com.apple.PowerManagement.control</string>+ <string>com.apple.idsremoteurlconnectionagent.embedded.auth</string>+ <string>com.apple.nearbyd.xpc.nearbyinteraction</string>+ <string>com.apple.commcenter.coretelephony.xpc</string>+ <string>com.apple.carousel.connectionstatusservice</string>+ <string>com.apple.SBUserNotification</string>+ <string>com.apple.wallet.application-authorization</string>+ <string>com.apple.duet.activityscheduler</string>+ <string>com.apple.frontboard.systemappservices</string>+ <string>com.apple.SESAngel.mach</string>+ <string>com.apple.passd.device-registration</string>+ <string>com.apple.mobileactivationd</string>+ <string>com.apple.seserviced.sereservation.client</string>+ <string>com.apple.CellularPlanDaemon.xpc</string>+ <string>com.apple.surfboard.applicationservice</string>+ <string>com.apple.surfboard.scenesessionservice</string>+ <string>com.apple.spotlight.IndexAgent</string>+ <string>com.apple.feedbackd.xpc</string>+ <string>com.apple.biome.PublicStreamAccessService</string>+ <string>com.apple.biome.compute.publisher.service.user</string>+ <string>com.apple.biome.access.user</string>+ </array>+ <key>com.apple.security.exception.process-info</key>+ <true/>+ <key>com.apple.security.exception.shared-preference.read-only</key>+ <array>+ <string>com.apple.mobileactivationd</string>+ <string>com.apple.nsurlcache</string>+ <string>com.apple.facetime.bag</string>+ <string>com.apple.imessage.bag</string>+ <string>com.apple.AppSupport.plist</string>+ <string>com.apple.stockholm</string>+ </array>+ <key>com.apple.security.exception.shared-preference.read-write</key>+ <array>+ <string>com.apple.seserviced.shared</string>+ <string>com.apple.seserviced</string>+ <string>com.apple.secureelementservice</string>+ <string>com.apple.seserviced.contactlessCredential.settings</string>+ <string>com.apple.seserviced.designatedkeys</string>+ <string>com.apple.carkey.settings</string>+ </array>+ <key>com.apple.security.network.client</key>+ <true/>+ <key>com.apple.security.ts.identity-services-client</key>+ <true/>+ <key>com.apple.security.ts.power-assertions</key>+ <true/>+ <key>com.apple.security.ts.read-factory-files</key>+ <true/>+ <key>com.apple.security.ts.springboard-services</key>+ <true/>+ <key>com.apple.security.ts.tmpdir</key>+ <string>com.apple.secureelementservice</string>+ <key>com.apple.seld.tsmmanager</key>+ <true/>+ <key>com.apple.seserviced.SESUIServiceApp.session</key>+ <true/>+ <key>com.apple.seserviced.seendpoints</key>+ <true/>+ <key>com.apple.seserviced.seendpoints.certificateauthorities</key>+ <true/>+ <key>com.apple.softposreaderd</key>+ <integer>2</integer>+ <key>com.apple.softposreaderd.provision</key>+ <integer>2</integer>+ <key>com.apple.springboard.monitorAppSwitcherUserQuit</key>+ <true/>+ <key>com.apple.springboard.remote-alert</key>+ <true/>+ <key>com.apple.sts.xpcservice.client</key>+ <true/>+ <key>com.apple.wallet.application-authorization</key>+ <true/>+ <key>keychain-access-groups</key>+ <array>+ <string>com.apple.internal.seserviced.keysync.recoveryblobs</string>+ <string>com.apple.internal.seserviced.fidokeys</string>+ <string>lockdown-identities</string>+ <string>com.apple.seserviced</string>+ <string>com.apple.private.seserviced.privacykeys</string>+ </array>+ <key>platform-application</key>+ <true/>+ <key>seatbelt-profiles</key>+ <array>+ <string>temporary-sandbox</string>+ </array>+</dict>+</plist>diff --git a/tests/VPhoneSignTests/Fixtures/entitlements/spindump.plist b/tests/VPhoneSignTests/Fixtures/entitlements/spindump.plistnew file mode 100644index 00000000..f0b6ccc6--- /dev/null+++ b/tests/VPhoneSignTests/Fixtures/entitlements/spindump.plist@@ -0,0 +1,164 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.diagnosticpipeline.request</key>+ <true/>+ <key>com.apple.duet.activityscheduler.allow</key>+ <true/>+ <key>com.apple.lsapplicationproxy.deviceidentifierforvendor</key>+ <true/>+ <key>com.apple.modelmanager.query</key>+ <true/>+ <key>com.apple.private.applesmc.user-access</key>+ <true/>+ <key>com.apple.private.biome.client-identifier</key>+ <string>com.apple.spindump</string>+ <key>com.apple.private.biome.read-only</key>+ <array>+ <string>GenerativeModels.GenerativeFunctions.Instrumentation</string>+ <string>GenerativeModels.GenerativeFunctions.SystemInstrumentation</string>+ </array>+ <key>com.apple.private.intelligenceplatform.use-cases</key>+ <dict>+ <key>com.apple.SampleAnalysis</key>+ <dict>+ <key>Streams</key>+ <array>+ <string>GenerativeModels.GenerativeFunctions.Instrumentation</string>+ <string>GenerativeModels.GenerativeFunctions.SystemInstrumentation</string>+ </array>+ </dict>+ </dict>+ <key>com.apple.private.kernel.get-kext-info</key>+ <true/>+ <key>com.apple.private.logging.diagnostic</key>+ <true/>+ <key>com.apple.private.logging.stream</key>+ <true/>+ <key>com.apple.private.osanalytics.defaults.allow</key>+ <true/>+ <key>com.apple.private.roots-installed-read-only</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.security.storage.spindump</key>+ <true/>+ <key>com.apple.private.stackshot</key>+ <true/>+ <key>com.apple.private.xpc.launchd.per-user-lookup</key>+ <true/>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/private/var/db/eligibilityd/eligibility.plist</string>+ <string>/private/var/db/os_eligibility/eligibility.plist</string>+ </array>+ <key>com.apple.security.exception.iokit-user-client-class</key>+ <array>+ <string>IOReportUserClient</string>+ </array>+ <key>com.apple.security.system-groups</key>+ <array>+ <string>systemgroup.com.apple.osanalytics</string>+ </array>+ <key>com.apple.security.temporary-exception.files.absolute-path.read-only</key>+ <array>+ <string>/private/var/db/eligibilityd/eligibility.plist</string>+ <string>/private/var/db/os_eligibility/eligibility.plist</string>+ </array>+ <key>com.apple.signpostsupport.notification.listen</key>+ <true/>+ <key>com.apple.system-task-ports.read</key>+ <true/>+ <key>com.apple.tailspin.dump-output</key>+ <true/>+ <key>com.apple.trial.status.deployment-environment.allow</key>+ <array>+ <integer>0</integer>+ </array>+ <key>com.apple.usermanagerd.persona.fetch</key>+ <true/>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.diagnosticpipeline.request</key>+ <true/>+ <key>com.apple.duet.activityscheduler.allow</key>+ <true/>+ <key>com.apple.lsapplicationproxy.deviceidentifierforvendor</key>+ <true/>+ <key>com.apple.modelmanager.query</key>+ <true/>+ <key>com.apple.private.applesmc.user-access</key>+ <true/>+ <key>com.apple.private.biome.client-identifier</key>+ <string>com.apple.spindump</string>+ <key>com.apple.private.biome.read-only</key>+ <array>+ <string>GenerativeModels.GenerativeFunctions.Instrumentation</string>+ <string>GenerativeModels.GenerativeFunctions.SystemInstrumentation</string>+ </array>+ <key>com.apple.private.intelligenceplatform.use-cases</key>+ <dict>+ <key>com.apple.SampleAnalysis</key>+ <dict>+ <key>Streams</key>+ <array>+ <string>GenerativeModels.GenerativeFunctions.Instrumentation</string>+ <string>GenerativeModels.GenerativeFunctions.SystemInstrumentation</string>+ </array>+ </dict>+ </dict>+ <key>com.apple.private.kernel.get-kext-info</key>+ <true/>+ <key>com.apple.private.logging.diagnostic</key>+ <true/>+ <key>com.apple.private.logging.stream</key>+ <true/>+ <key>com.apple.private.osanalytics.defaults.allow</key>+ <true/>+ <key>com.apple.private.roots-installed-read-only</key>+ <true/>+ <key>com.apple.private.security.storage.os_eligibility.readonly</key>+ <true/>+ <key>com.apple.private.security.storage.spindump</key>+ <true/>+ <key>com.apple.private.stackshot</key>+ <true/>+ <key>com.apple.private.xpc.launchd.per-user-lookup</key>+ <true/>+ <key>com.apple.security.exception.files.absolute-path.read-only</key>+ <array>+ <string>/private/var/db/eligibilityd/eligibility.plist</string>+ <string>/private/var/db/os_eligibility/eligibility.plist</string>+ </array>+ <key>com.apple.security.exception.iokit-user-client-class</key>+ <array>+ <string>IOReportUserClient</string>+ </array>+ <key>com.apple.security.system-groups</key>+ <array>+ <string>systemgroup.com.apple.osanalytics</string>+ </array>+ <key>com.apple.security.temporary-exception.files.absolute-path.read-only</key>+ <array>+ <string>/private/var/db/eligibilityd/eligibility.plist</string>+ <string>/private/var/db/os_eligibility/eligibility.plist</string>+ </array>+ <key>com.apple.signpostsupport.notification.listen</key>+ <true/>+ <key>com.apple.system-task-ports.read</key>+ <true/>+ <key>com.apple.tailspin.dump-output</key>+ <true/>+ <key>com.apple.trial.status.deployment-environment.allow</key>+ <array>+ <integer>0</integer>+ </array>+ <key>com.apple.usermanagerd.persona.fetch</key>+ <true/>+</dict>+</plist>diff --git a/tests/VPhoneSignTests/Fixtures/entitlements/sshd.plist b/tests/VPhoneSignTests/Fixtures/entitlements/sshd.plistnew file mode 100644index 00000000..0456c1cb--- /dev/null+++ b/tests/VPhoneSignTests/Fixtures/entitlements/sshd.plist@@ -0,0 +1,20 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.private.endpoint-security.submit.openssh</key>+ <true/>+ <key>com.apple.private.security.clear-library-validation</key>+ <true/>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.private.endpoint-security.submit.openssh</key>+ <true/>+ <key>com.apple.private.security.clear-library-validation</key>+ <true/>+</dict>+</plist>diff --git a/tests/VPhoneSignTests/Fixtures/entitlements/sysdiagnose_helper.plist b/tests/VPhoneSignTests/Fixtures/entitlements/sysdiagnose_helper.plistnew file mode 100644index 00000000..f8f43076--- /dev/null+++ b/tests/VPhoneSignTests/Fixtures/entitlements/sysdiagnose_helper.plist@@ -0,0 +1,408 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>application-identifier</key>+ <string>com.apple.sysdiagnose_helper</string>+ <key>com.apple.aiml.rapidresourcedelivery.read-config</key>+ <true/>+ <key>com.apple.centaurid.xpc</key>+ <true/>+ <key>com.apple.corecapture.manager-access</key>+ <true/>+ <key>com.apple.generativeexperiences.sysdiagnose</key>+ <true/>+ <key>com.apple.hid.AppleDeviceManagementHIDFilter.entitlement</key>+ <true/>+ <key>com.apple.hid.manager.user-access-protected</key>+ <true/>+ <key>com.apple.intelligenceplatform.Sysdiagnose</key>+ <true/>+ <key>com.apple.managedconfiguration.profiled.profile</key>+ <true/>+ <key>com.apple.modelmanager.inference</key>+ <true/>+ <key>com.apple.nearbyd.diagnostics</key>+ <true/>+ <key>com.apple.networkrelay.diagnostic</key>+ <true/>+ <key>com.apple.nfcd.hwmanager</key>+ <true/>+ <key>com.apple.nfcd.session.se</key>+ <true/>+ <key>com.apple.nfcd.session.selogging</key>+ <true/>+ <key>com.apple.polaris.client</key>+ <true/>+ <key>com.apple.private.CoreRepairCore.repairInfo</key>+ <true/>+ <key>com.apple.private.ZhuGeSupport.CopyValue</key>+ <true/>+ <key>com.apple.private.appmanagedfeatures.configuration</key>+ <true/>+ <key>com.apple.private.container.debug</key>+ <true/>+ <key>com.apple.private.eligibilityd.dumpSysdiagnoseDataToDir</key>+ <true/>+ <key>com.apple.private.endpoint-security.xpc</key>+ <true/>+ <key>com.apple.private.eyecandy.sysdiagnose</key>+ <true/>+ <key>com.apple.private.iokit.batterydata</key>+ <true/>+ <key>com.apple.private.iokit.batterydataprecise</key>+ <true/>+ <key>com.apple.private.libnotify.statecapture</key>+ <true/>+ <key>com.apple.private.logging.diagnostic</key>+ <true/>+ <key>com.apple.private.managedclient.configurationprofiles</key>+ <true/>+ <key>com.apple.private.notificationcenter-system</key>+ <array>+ <dict>+ <key>identifier</key>+ <string>com.apple.sysdiagnose_helper</string>+ </dict>+ </array>+ <key>com.apple.private.osanalytics.defaults.allow</key>+ <true/>+ <key>com.apple.private.psg.internal</key>+ <true/>+ <key>com.apple.private.tcc.allow-prompting</key>+ <array>+ <string>ktccservicesystempolicyallfiles</string>+ </array>+ <key>com.apple.private.wifivelocity</key>+ <true/>+ <key>com.apple.proactive.PersonalizationPortrait.Internal</key>+ <true/>+ <key>com.apple.proactive.eventtracker</key>+ <true/>+ <key>com.apple.runningboard.statecapture</key>+ <true/>+ <key>com.apple.security.application-groups</key>+ <array>+ <string>group.com.apple.cv3d.dgn</string>+ </array>+ <key>com.apple.security.exception.mach-lookup.global-name</key>+ <string>com.apple.intelligenceplatform.Sysdiagnose</string>+ <key>com.apple.security.exception.shared-preference.read-only</key>+ <array>+ <string>com.apple.voicetrigger.notbackedup</string>+ </array>+ <key>com.apple.security.iokit-user-client-class</key>+ <array>+ <string>AppleNVMeUpdateUC</string>+ <string>ASPUserClient</string>+ <string>AGXDeviceUserClient</string>+ <string>IOSurfaceRootUserClient</string>+ </array>+ <key>com.apple.security.system-groups</key>+ <array>+ <string>systemgroup.com.apple.powerlog</string>+ <string>systemgroup.com.apple.ReportMemoryException</string>+ <string>systemgroup.com.apple.configurationprofiles</string>+ <string>systemgroup.com.apple.lsd</string>+ </array>+ <key>com.apple.springboard.statedump</key>+ <true/>+ <key>com.apple.sysmond.client</key>+ <true/>+ <key>com.apple.tailspin.dump-output</key>+ <true/>+ <key>com.apple.tailspin.symbolication</key>+ <true/>+ <key>com.apple.trial.status.deployment-environment.allow</key>+ <array>+ <integer>0</integer>+ <integer>1</integer>+ <integer>2</integer>+ <integer>3</integer>+ <integer>4</integer>+ <integer>5</integer>+ </array>+ <key>com.apple.triald.internal</key>+ <true/>+ <key>com.apple.triald.system.internal</key>+ <true/>+ <key>com.apple.wifi.manager-access</key>+ <true/>+ <key>com.apple.wifivelocity</key>+ <true/>+ <key>com.apple.wirelessinsightsd.manager-access</key>+ <true/>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>application-identifier</key>+ <string>com.apple.sysdiagnose_helper</string>+ <key>com.apple.aiml.rapidresourcedelivery.read-config</key>+ <true/>+ <key>com.apple.centaurid.xpc</key>+ <true/>+ <key>com.apple.corecapture.manager-access</key>+ <true/>+ <key>com.apple.generativeexperiences.sysdiagnose</key>+ <true/>+ <key>com.apple.hid.AppleDeviceManagementHIDFilter.entitlement</key>+ <true/>+ <key>com.apple.hid.manager.user-access-protected</key>+ <true/>+ <key>com.apple.intelligenceplatform.Sysdiagnose</key>+ <true/>+ <key>com.apple.managedconfiguration.profiled.profile</key>+ <true/>+ <key>com.apple.modelmanager.inference</key>+ <true/>+ <key>com.apple.nearbyd.diagnostics</key>+ <true/>+ <key>com.apple.networkrelay.diagnostic</key>+ <true/>+ <key>com.apple.nfcd.hwmanager</key>+ <true/>+ <key>com.apple.nfcd.session.se</key>+ <true/>+ <key>com.apple.nfcd.session.selogging</key>+ <true/>+ <key>com.apple.polaris.client</key>+ <true/>+ <key>com.apple.private.CoreRepairCore.repairInfo</key>+ <true/>+ <key>com.apple.private.ZhuGeSupport.CopyValue</key>+ <true/>+ <key>com.apple.private.appmanagedfeatures.configuration</key>+ <true/>+ <key>com.apple.private.container.debug</key>+ <true/>+ <key>com.apple.private.eligibilityd.dumpSysdiagnoseDataToDir</key>+ <true/>+ <key>com.apple.private.endpoint-security.xpc</key>+ <true/>+ <key>com.apple.private.eyecandy.sysdiagnose</key>+ <true/>+ <key>com.apple.private.iokit.batterydata</key>+ <true/>+ <key>com.apple.private.iokit.batterydataprecise</key>+ <true/>+ <key>com.apple.private.libnotify.statecapture</key>+ <true/>+ <key>com.apple.private.logging.diagnostic</key>+ <true/>+ <key>com.apple.private.managedclient.configurationprofiles</key>+ <true/>+ <key>com.apple.private.notificationcenter-system</key>+ <array>+ <dict>+ <key>identifier</key>+ <string>com.apple.sysdiagnose_helper</string>+ </dict>+ </array>+ <key>com.apple.private.osanalytics.defaults.allow</key>+ <true/>+ <key>com.apple.private.psg.internal</key>+ <true/>+ <key>com.apple.private.tcc.allow-prompting</key>+ <array>+ <string>ktccservicesystempolicyallfiles</string>+ </array>+ <key>com.apple.private.wifivelocity</key>+ <true/>+ <key>com.apple.proactive.PersonalizationPortrait.Internal</key>+ <true/>+ <key>com.apple.proactive.eventtracker</key>+ <true/>+ <key>com.apple.runningboard.statecapture</key>+ <true/>+ <key>com.apple.security.application-groups</key>+ <array>+ <string>group.com.apple.cv3d.dgn</string>+ </array>+ <key>com.apple.security.exception.mach-lookup.global-name</key>+ <string>com.apple.intelligenceplatform.Sysdiagnose</string>+ <key>com.apple.security.exception.shared-preference.read-only</key>+ <array>+ <string>com.apple.voicetrigger.notbackedup</string>+ </array>+ <key>com.apple.security.iokit-user-client-class</key>+ <array>+ <string>AppleNVMeUpdateUC</string>+ <string>ASPUserClient</string>+ <string>AGXDeviceUserClient</string>+ <string>IOSurfaceRootUserClient</string>+ </array>+ <key>com.apple.security.system-groups</key>+ <array>+ <string>systemgroup.com.apple.powerlog</string>+ <string>systemgroup.com.apple.ReportMemoryException</string>+ <string>systemgroup.com.apple.configurationprofiles</string>+ <string>systemgroup.com.apple.lsd</string>+ </array>+ <key>com.apple.springboard.statedump</key>+ <true/>+ <key>com.apple.sysmond.client</key>+ <true/>+ <key>com.apple.tailspin.dump-output</key>+ <true/>+ <key>com.apple.tailspin.symbolication</key>+ <true/>+ <key>com.apple.trial.status.deployment-environment.allow</key>+ <array>+ <integer>0</integer>+ <integer>1</integer>+ <integer>2</integer>+ <integer>3</integer>+ <integer>4</integer>+ <integer>5</integer>+ </array>+ <key>com.apple.triald.internal</key>+ <true/>+ <key>com.apple.triald.system.internal</key>+ <true/>+ <key>com.apple.wifi.manager-access</key>+ <true/>+ <key>com.apple.wifivelocity</key>+ <true/>+ <key>com.apple.wirelessinsightsd.manager-access</key>+ <true/>+</dict>+</plist>+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>application-identifier</key>+ <string>com.apple.sysdiagnose_helper</string>+ <key>com.apple.aiml.rapidresourcedelivery.read-config</key>+ <true/>+ <key>com.apple.centaurid.xpc</key>+ <true/>+ <key>com.apple.corecapture.manager-access</key>+ <true/>+ <key>com.apple.generativeexperiences.sysdiagnose</key>+ <true/>+ <key>com.apple.hid.AppleDeviceManagementHIDFilter.entitlement</key>+ <true/>+ <key>com.apple.hid.manager.user-access-protected</key>+ <true/>+ <key>com.apple.intelligenceplatform.Sysdiagnose</key>+ <true/>+ <key>com.apple.managedconfiguration.profiled.profile</key>+ <true/>+ <key>com.apple.modelmanager.inference</key>+ <true/>+ <key>com.apple.nearbyd.diagnostics</key>+ <true/>+ <key>com.apple.networkrelay.diagnostic</key>+ <true/>+ <key>com.apple.nfcd.hwmanager</key>+ <true/>+ <key>com.apple.nfcd.session.se</key>+ <true/>+ <key>com.apple.nfcd.session.selogging</key>+ <true/>+ <key>com.apple.polaris.client</key>+ <true/>+ <key>com.apple.private.CoreRepairCore.repairInfo</key>+ <true/>+ <key>com.apple.private.ZhuGeSupport.CopyValue</key>+ <true/>+ <key>com.apple.private.appmanagedfeatures.configuration</key>+ <true/>+ <key>com.apple.private.container.debug</key>+ <true/>+ <key>com.apple.private.eligibilityd.dumpSysdiagnoseDataToDir</key>+ <true/>+ <key>com.apple.private.endpoint-security.xpc</key>+ <true/>+ <key>com.apple.private.eyecandy.sysdiagnose</key>+ <true/>+ <key>com.apple.private.iokit.batterydata</key>+ <true/>+ <key>com.apple.private.iokit.batterydataprecise</key>+ <true/>+ <key>com.apple.private.libnotify.statecapture</key>+ <true/>+ <key>com.apple.private.logging.diagnostic</key>+ <true/>+ <key>com.apple.private.managedclient.configurationprofiles</key>+ <true/>+ <key>com.apple.private.notificationcenter-system</key>+ <array>+ <dict>+ <key>identifier</key>+ <string>com.apple.sysdiagnose_helper</string>+ </dict>+ </array>+ <key>com.apple.private.osanalytics.defaults.allow</key>+ <true/>+ <key>com.apple.private.psg.internal</key>+ <true/>+ <key>com.apple.private.tcc.allow-prompting</key>+ <array>+ <string>ktccservicesystempolicyallfiles</string>+ </array>+ <key>com.apple.private.wifivelocity</key>+ <true/>+ <key>com.apple.proactive.PersonalizationPortrait.Internal</key>+ <true/>+ <key>com.apple.proactive.eventtracker</key>+ <true/>+ <key>com.apple.runningboard.statecapture</key>+ <true/>+ <key>com.apple.security.application-groups</key>+ <array>+ <string>group.com.apple.cv3d.dgn</string>+ </array>+ <key>com.apple.security.exception.mach-lookup.global-name</key>+ <string>com.apple.intelligenceplatform.Sysdiagnose</string>+ <key>com.apple.security.exception.shared-preference.read-only</key>+ <array>+ <string>com.apple.voicetrigger.notbackedup</string>+ </array>+ <key>com.apple.security.iokit-user-client-class</key>+ <array>+ <string>AppleNVMeUpdateUC</string>+ <string>ASPUserClient</string>+ <string>AGXDeviceUserClient</string>+ <string>IOSurfaceRootUserClient</string>+ </array>+ <key>com.apple.security.system-groups</key>+ <array>+ <string>systemgroup.com.apple.powerlog</string>+ <string>systemgroup.com.apple.ReportMemoryException</string>+ <string>systemgroup.com.apple.configurationprofiles</string>+ <string>systemgroup.com.apple.lsd</string>+ </array>+ <key>com.apple.springboard.statedump</key>+ <true/>+ <key>com.apple.sysmond.client</key>+ <true/>+ <key>com.apple.tailspin.dump-output</key>+ <true/>+ <key>com.apple.tailspin.symbolication</key>+ <true/>+ <key>com.apple.trial.status.deployment-environment.allow</key>+ <array>+ <integer>0</integer>+ <integer>1</integer>+ <integer>2</integer>+ <integer>3</integer>+ <integer>4</integer>+ <integer>5</integer>+ </array>+ <key>com.apple.triald.internal</key>+ <true/>+ <key>com.apple.triald.system.internal</key>+ <true/>+ <key>com.apple.wifi.manager-access</key>+ <true/>+ <key>com.apple.wifivelocity</key>+ <true/>+ <key>com.apple.wirelessinsightsd.manager-access</key>+ <true/>+</dict>+</plist>diff --git a/tests/VPhoneSignTests/Fixtures/hello-arm64 b/tests/VPhoneSignTests/Fixtures/hello-arm64new file mode 100755index 00000000..b6499609Binary files /dev/null and b/tests/VPhoneSignTests/Fixtures/hello-arm64 differdiff --git a/tests/VPhoneSignTests/Fixtures/hello-arm64e b/tests/VPhoneSignTests/Fixtures/hello-arm64enew file mode 100755index 00000000..1cae97c5Binary files /dev/null and b/tests/VPhoneSignTests/Fixtures/hello-arm64e differdiff --git a/tests/VPhoneSignTests/Fixtures/hello-dylib b/tests/VPhoneSignTests/Fixtures/hello-dylibnew file mode 100755index 00000000..2eb96091Binary files /dev/null and b/tests/VPhoneSignTests/Fixtures/hello-dylib differdiff --git a/tests/VPhoneSignTests/Fixtures/hello-fat b/tests/VPhoneSignTests/Fixtures/hello-fatnew file mode 100755index 00000000..cba483c2Binary files /dev/null and b/tests/VPhoneSignTests/Fixtures/hello-fat differdiff --git a/tests/VPhoneSignTests/Fixtures/hello-ios b/tests/VPhoneSignTests/Fixtures/hello-iosnew file mode 100755index 00000000..6fdb3843Binary files /dev/null and b/tests/VPhoneSignTests/Fixtures/hello-ios differdiff --git a/tests/VPhoneSignTests/Fixtures/hello.c b/tests/VPhoneSignTests/Fixtures/hello.cnew file mode 100644index 00000000..48573600--- /dev/null+++ b/tests/VPhoneSignTests/Fixtures/hello.c@@ -0,0 +1,19 @@+// The signing corpus, as a program rather than as whatever /bin/ls happens to+// be on this machine's macOS. It is never run; only its bytes are signed.+//+// It is deliberately not empty. A main() that only returns 0 compiles to a+// __TEXT small enough that a signature's page table is one page, and a+// one-page CodeDirectory exercises none of the offset arithmetic that a real+// binary does. The array below pushes __TEXT past 4 KiB so there are several+// page hashes to get right.++#include <stdio.h>++static const char padding[8192] = "vphone-sign fixture";++int main(int argc, char **argv)+{+ (void)argv;+ printf("%d %c\n", argc, padding[argc & 0x1fff]);+ return 0;+}diff --git a/tests/VPhoneSignTests/Fixtures/library.c b/tests/VPhoneSignTests/Fixtures/library.cnew file mode 100644index 00000000..0540ede8--- /dev/null+++ b/tests/VPhoneSignTests/Fixtures/library.c@@ -0,0 +1,16 @@+// A dylib rather than a program. It differs from hello.c in the two places+// this signer has to get right on its own: MH_DYLIB rather than MH_EXECUTE,+// and an executable segment whose flags do not carry the main-binary bit.++#include <stddef.h>++static const char padding[8192] = "vphone-sign fixture (dylib)";++size_t vphone_fixture_length(void);++size_t vphone_fixture_length(void)+{+ size_t n = 0;+ while (n < sizeof(padding) && padding[n] != '\0') n++;+ return n;+}diff --git a/tests/VPhoneSignTests/Fixtures/seeded-lsd b/tests/VPhoneSignTests/Fixtures/seeded-lsdnew file mode 100755index 00000000..e094ce1cBinary files /dev/null and b/tests/VPhoneSignTests/Fixtures/seeded-lsd differdiff --git a/tests/VPhoneSignTests/Fixtures/seeded-promotedcontentd b/tests/VPhoneSignTests/Fixtures/seeded-promotedcontentdnew file mode 100755index 00000000..041ca903Binary files /dev/null and b/tests/VPhoneSignTests/Fixtures/seeded-promotedcontentd differdiff --git a/tests/VPhoneSignTests/Fixtures/seeded-runningboardd b/tests/VPhoneSignTests/Fixtures/seeded-runningboarddnew file mode 100755index 00000000..d711e447Binary files /dev/null and b/tests/VPhoneSignTests/Fixtures/seeded-runningboardd differdiff --git a/tests/VPhoneSignTests/Fixtures/seeded-seserviced b/tests/VPhoneSignTests/Fixtures/seeded-seservicednew file mode 100755index 00000000..490c95a1Binary files /dev/null and b/tests/VPhoneSignTests/Fixtures/seeded-seserviced differdiff --git a/tests/VPhoneSignTests/Fixtures/seeded-spindump b/tests/VPhoneSignTests/Fixtures/seeded-spindumpnew file mode 100755index 00000000..f0f1025aBinary files /dev/null and b/tests/VPhoneSignTests/Fixtures/seeded-spindump differdiff --git a/tests/VPhoneSignTests/Fixtures/seeded-sshd b/tests/VPhoneSignTests/Fixtures/seeded-sshdnew file mode 100755index 00000000..4daa7b74Binary files /dev/null and b/tests/VPhoneSignTests/Fixtures/seeded-sshd differdiff --git a/tests/VPhoneSignTests/Fixtures/seeded-sysdiagnose_helper b/tests/VPhoneSignTests/Fixtures/seeded-sysdiagnose_helpernew file mode 100755index 00000000..9fa3e7fdBinary files /dev/null and b/tests/VPhoneSignTests/Fixtures/seeded-sysdiagnose_helper differdiff --git a/tests/VPhoneSignTests/VPhoneSignBlobs.swift b/tests/VPhoneSignTests/VPhoneSignBlobs.swiftindex 41ce3737..fbd8ac1c 100644--- a/tests/VPhoneSignTests/VPhoneSignBlobs.swift+++ b/tests/VPhoneSignTests/VPhoneSignBlobs.swift@@ -38,6 +38,18 @@ struct VPhoneSignBlobs {self.slices = slices}+ /// The signing identifier out of a CodeDirectory blob. `identOffset` is+ /// the sixth big-endian word of the structure and counts from the blob's+ /// own start; the string it points at is NUL-terminated.+ static func identifier(ofCodeDirectory blob: Data) -> String? {+ let bytes = [UInt8](blob)+ guard bytes.count >= 24 else { return nil }+ let offset = Int(be32(blob, 20))+ guard offset > 0, offset < bytes.count else { return nil }+ guard let end = bytes[offset...].firstIndex(of: 0) else { return nil }+ return String(decoding: bytes[offset ..< end], as: UTF8.self)+ }+// MARK: Walking the fileprivate static func be32(_ data: Data, _ offset: Int) -> UInt32 {diff --git a/tests/VPhoneSignTests/VPhoneSignEntitlementsTests.swift b/tests/VPhoneSignTests/VPhoneSignEntitlementsTests.swiftindex abfda0f3..ad5a3647 100644--- a/tests/VPhoneSignTests/VPhoneSignEntitlementsTests.swift+++ b/tests/VPhoneSignTests/VPhoneSignEntitlementsTests.swift@@ -12,34 +12,33 @@ struct VPhoneSignEntitlementsTests {/// `ldid -e`, which the installers use a dozen times over to carry a/// binary's entitlements across a re-sign. It prints each slice's blob/// one after another, so a fat file prints several and a file with none- /// prints nothing.+ /// prints nothing — `e3b0c442…b855` in the table is the digest of the+ /// empty string, which is what ldid prints for a file carrying none.+ ///+ /// The seeded fixtures carry the interesting cases: a long sandbox profile+ /// in a `<data>`, arrays, and the integers.@Test("dump matches ldid -e byte for byte")func dumpMatchesLdid() throws {- let ldid = try #require(VPhoneSignLdidHarness.ldid, "ldid is not installed")- // the ones with entitlements carry the interesting cases: a long- // sandbox profile in a <data>, arrays, integers, and several slices- let corpus = VPhoneSignLdidHarness.carryingEntitlements- .filter { FileManager.default.fileExists(atPath: $0) }- .map { URL(fileURLWithPath: $0) } + VPhoneSignLdidHarness.corpus+ let corpus = try VPhoneSignFixtures.fixtures+ #expect(corpus.count >= 12, "only \(corpus.count) fixtures: too few to say anything")var withEntitlements = 0for source in corpus {- let theirs = try VPhoneSignLdidHarness.run(ldid, ["-e", source.path]).out- let ours = try VPhoneSigner.entitlements(ofFileAt: source)- .reduce(Data(), +)- #expect(theirs == ours, "\(source.lastPathComponent): \(theirs.count) vs \(ours.count) bytes")- if !theirs.isEmpty { withEntitlements += 1 }+ let name = source.lastPathComponent+ let ours = try VPhoneSigner.entitlements(ofFileAt: source).reduce(Data(), +)+ try VPhoneSignFixtures.expect("\(name).dump", matches: ours)+ if !ours.isEmpty { withEntitlements += 1 }}- #expect(withEntitlements > 0, "nothing in the corpus had entitlements, so nothing was compared")+ #expect(withEntitlements >= 7, "only \(withEntitlements) fixtures had entitlements to print")}@Test("a file this signed reads back the entitlements it was given")func roundTrip() throws {- let source = try #require(VPhoneSignLdidHarness.corpus.first)- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let file = try VPhoneSignLdidHarness.copy(source, into: directory, as: "binary")let plist = VPhoneSignParityTests.sampleEntitlements- try VPhoneSigner.sign(fileAt: file, options: .init(identifier: "binary", entitlements: plist))+ let file = try VPhoneSignFixtures.sign(+ try VPhoneSignFixtures.url("hello-arm64"), in: directory, entitlements: plist+ )let read = try VPhoneSigner.entitlements(ofFileAt: file)let slices = try VPhoneSignBlobs(fileAt: file).slices.count@@ -118,9 +117,9 @@ struct VPhoneSignEntitlementsTests {// MARK: - <integer>, which is where the reader was wrong- /// Every spelling of an `<integer>` that ldid takes, compared against the- /// blobs ldid writes for it rather than against what this signer thinks- /// it should write.+ /// Every spelling of an `<integer>` that ldid takes, compared against what+ /// ldid wrote for it rather than against what this signer thinks it should+ /// write.////// This is the test that was missing. The reader used to accept only a/// positive decimal, justified by a comment saying ldid's DER "cannot@@ -128,7 +127,14 @@ struct VPhoneSignEntitlementsTests {/// asserting `<integer>0</integer>` must be refused, without ever asking/// ldid. ldid spells zero `020100` and minus one `0208ffffffffffffffff`,/// and `/usr/sbin/spindump` ships a zero, so the production path failed- /// on real input while the tests stayed green.+ /// on real input while the tests stayed green. `seeded-spindump` carries+ /// that array now.+ ///+ /// The whole file is what is frozen, because a difference in either blob+ /// moves every CDHash with it and so shows up here anyway. Slot 5 is the+ /// XML the next `-M` reads back and slot 7 the DER AMFI reads; both are+ /// asserted present, since a signature that wrote neither would have+ /// nothing to disagree about.@Test("every <integer> ldid takes is carried the way ldid carries it",arguments: [@@ -155,46 +161,28 @@ struct VPhoneSignEntitlementsTests {])func integerSpellingsMatchLdid(_ spelling: String) throws {- let ldid = try #require(VPhoneSignLdidHarness.ldid, "ldid is not installed")- let source = try #require(VPhoneSignLdidHarness.corpus.first)- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let plist = Data("""<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict><key>k</key><integer>\(spelling)</integer></dict></plist>""".utf8)- let file = directory.appendingPathComponent("entitlements.plist")- try plist.write(to: file)-- let theirs = try VPhoneSignLdidHarness.copy(source, into: directory, as: "binary")- let result = try VPhoneSignLdidHarness.run(ldid, ["-S\(file.path)", theirs.path])- #expect(result.status == 0, "ldid refused <integer>\(spelling)</integer>: \(result.error)")-- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: "ours-binary")- try VPhoneSigner.sign(fileAt: ours, options: .init(identifier: "binary", entitlements: plist))-- // the whole file, since a difference in either blob moves every- // CDHash with it; the two blobs are then named individually, because- // the DER drops the sign and the XML keeps it, so a reader that got- // one right could still have the other wrong- let whole = try Data(contentsOf: theirs), oursWhole = try Data(contentsOf: ours)- #expect(- whole == oursWhole,- "<integer>\(spelling)</integer>: \(VPhoneSignLdidHarness.difference(whole, oursWhole))"+ // `binary` is the identifier these rows were frozen under; see the+ // regeneration note in VPhoneSignFixtures+ let ours = try VPhoneSignFixtures.sign(+ try VPhoneSignFixtures.url("hello-arm64"),+ in: directory,+ identifier: "binary",+ entitlements: plist)- let left = try VPhoneSignBlobs(fileAt: theirs), right = try VPhoneSignBlobs(fileAt: ours)- #expect(left.slices.count == right.slices.count)- for (index, pair) in zip(left.slices, right.slices).enumerated() {- // slot 5 is the XML the next `-M` reads back, slot 7 the DER AMFI reads+ try VPhoneSignFixtures.expect("integer.\(spelling)", matches: Data(contentsOf: ours))++ for (index, slice) in try VPhoneSignBlobs(fileAt: ours).slices.enumerated() {for slot in [UInt32(5), 7] {- #expect(pair.0[slot] != nil, "ldid wrote no slot \(slot)")#expect(- pair.0[slot] == pair.1[slot],- """- <integer>\(spelling)</integer> slice \(index) slot \(slot): \- \(VPhoneSignLdidHarness.difference(pair.0[slot] ?? Data(), pair.1[slot] ?? Data()))- """+ slice[slot] != nil,+ "<integer>\(spelling)</integer> slice \(index): no slot \(slot)")}}@@ -205,8 +193,12 @@ struct VPhoneSignEntitlementsTests {/// different things from what the file said.////// ldid refuses both of these itself — `der(plist_t)` answers "Invalid- /// plist entry type" and exits 1 for `PLIST_REAL` and `PLIST_DATE` — so- /// the claim is checked against ldid here rather than asserted.+ /// plist entry type" for `PLIST_REAL` and `PLIST_DATE`. That was checked+ /// against the installed ldid when the frozen table was taken: both exit 1+ /// and print `ldid: Invalid plist entry type`, so neither has a row in the+ /// table and refusing them is agreement, not divergence. It is a frozen+ /// observation for the same reason every other row is — running ldid to+ /// re-confirm it would put the dependency back.@Test("what ldid's DER has no room for is refused, as ldid refuses it",arguments: ["<date>2020-01-01T00:00:00Z</date>", "<real>1.5</real>"]@@ -219,16 +211,6 @@ struct VPhoneSignEntitlementsTests {#expect(throws: VPhoneSignError.self) {_ = try VPhoneSignEntitlements(xml: plist)}-- let ldid = try #require(VPhoneSignLdidHarness.ldid, "ldid is not installed")- let source = try #require(VPhoneSignLdidHarness.corpus.first)- let directory = try VPhoneSignLdidHarness.temporaryDirectory()- defer { try? FileManager.default.removeItem(at: directory) }- let file = directory.appendingPathComponent("entitlements.plist")- try plist.write(to: file)- let binary = try VPhoneSignLdidHarness.copy(source, into: directory, as: "binary")- let result = try VPhoneSignLdidHarness.run(ldid, ["-S\(file.path)", binary.path])- #expect(result.status != 0, "ldid accepted \(value), so refusing it is wrong")}/// The spellings the two libplists read differently.diff --git a/tests/VPhoneSignTests/VPhoneSignFixtures.swift b/tests/VPhoneSignTests/VPhoneSignFixtures.swiftnew file mode 100644index 00000000..d0cda5ac--- /dev/null+++ b/tests/VPhoneSignTests/VPhoneSignFixtures.swift@@ -0,0 +1,471 @@+// VPhoneSignFixtures.swift — the corpus, and the ldid digests frozen over it.+//+// The digests in `expected` and the byte counts in `expectedLengths` are+// ldid's. They are frozen constants, not a live comparison, and nothing in+// this file runs or looks for ldid.+//+// This replaced a harness that ran Homebrew's ldid at test time over+// /bin/ls, /usr/libexec/lsd and whatever else the host happened to ship. That+// had two holes. It skipped rather than failed when ldid was absent, so on a+// clean machine the parity gate proved nothing while reporting green. And its+// corpus was this macOS version's system binaries, which is not a corpus so+// much as a coincidence — it changes under the suite with every OS update, and+// most of those files are fat with an x86_64 slice, which `VPhoneSign` now+// refuses outright (`VPhoneMachOImage.armCPUTypes`). The fixtures beside this+// file are committed instead: five hand-built Mach-Os covering the shapes that+// matter, and seven copies of the dylib that ldid has already signed with a+// real daemon's real entitlements.+//+// The bar is byte identity, not "the signature verifies". The signature's own+// size lands in the load commands, which are hashed, so one byte of slack more+// than ldid reserves and every CDHash moves. It is also the only bar that+// carries: the device this signs for runs an AMFI this project patched, and+// what that accepts cannot be re-derived from first principles. It accepts+// ldid's bytes, so ldid's bytes are the specification.+//+// KEY SHAPES+//+// <fixture>.adhoc after `ldid -S <file>`+// <fixture>.entitlements after `ldid -S<sample.plist> <file>`+// <fixture>.mergeOwn after `ldid -S -M <file>`+// <fixture>.mergeSample after `ldid -S<sample.plist> -M <file>`+// <fixture>.identifier after `ldid -S -Icom.apple.seputil <file>`+// <fixture>.dump sha256 of `ldid -e <file>` on stdout+// (e3b0c442…b855 is the empty string: no+// entitlements)+// <fixture>.sealed.<slice>.<slot>+// one blob of one slice after+// `ldid -S -M -K<signcert.p12> <file>`; slot 0+// and slot 4096 are the two CodeDirectories,+// slot 2 the designated requirement+// integer.<spelling> after `ldid -S<one-key.plist> <file>` on+// hello-arm64 copied in as `binary`+//+// `<sample.plist>` is `VPhoneSignParityTests.sampleEntitlements` written to a+// file. The whole `-K` file cannot be frozen — a CMS carries a signing time —+// so only the blobs AMFI seals are, alongside the file's size and the CMS+// length in `expectedLengths`.+//+// TO RE-DERIVE THE TABLE+//+// ldid is deliberately not a dependency of this repository: there is no+// Homebrew formula in the admission gates, nothing resolves an `ldid` on PATH,+// and `--use-ldid` is gone. So the table is re-derived the way the keystone+// constants in tests/FirmwarePatcherTests/ARM64EncoderTests.swift are — from a+// throwaway environment OUTSIDE this repository.+//+// 1. `brew install ldid-procursus` on a machine, not into this tree.+// 2. Write a temporary test beside this file that walks `fixtures`, runs+// ldid over a copy of each, and prints one line per case:+//+// let file = try copy(fixture, into: directory, as: name)+// _ = try run(ldid, ["-S", "-I\(name)", file.path])+// print("\"\(name).adhoc\": \"\(digest(try Data(contentsOf: file)))\",")+//+// `-I<fixture name>` is not decoration. ldid defaults the signing+// identifier to the file's basename, and the identifier is hashed into+// the CodeDirectory, so without the flag every digest here depends on+// what the working copy happened to be called and a generator that+// copied to `x` or `theirs-lsd` silently produces a table that will+// never reproduce. Passing it makes each row a function of the fixture's+// bytes, the identifier and the options, and of nothing else. The+// assertions pin it the same way, in `sign(_:in:…)` below.+// For the `-K` rows read the blobs back with `VPhoneSignBlobs`, which is+// the same parser the assertions use and is not `VPhoneSign`'s own.+// 3. Run it once, paste what it printed over the table below, and delete the+// temporary test. Run it twice first: ldid's `-K` output has a signing+// time in it, and the rows frozen here are the ones that do not move.+//+// Adding a live `ldid` call back — a `which`, a hardcoded Homebrew path, an+// environment variable — is the same regression the "Python" section of+// AGENTS.md forbids for an interpreter: a dependency `make check-aux` cannot+// see, and a silent skip when it is missing.++import CryptoKit+import Foundation+import Testing+@testable import VPhoneSign++enum VPhoneSignFixtures {+ // MARK: - The files++ static var root: URL {+ URL(fileURLWithPath: #filePath).deletingLastPathComponent().appendingPathComponent("Fixtures")+ }++ /// The hand-built Mach-Os. Between them: thin arm64 and thin arm64e, a fat+ /// file, an iOS binary whose deployment target is new enough that ldid+ /// drops SHA-1 and writes one CodeDirectory rather than two, and a dylib,+ /// which differs from a program in the executable-segment flags and in+ /// whether the main-binary bit is set.+ static let builtNames = ["hello-arm64", "hello-arm64e", "hello-fat", "hello-ios", "hello-dylib"]++ /// `hello-dylib`, signed by ldid with a real daemon's real entitlements.+ /// They are listed apart because a corpus of files carrying nothing makes+ /// every merge test pass without merging anything — and because what the+ /// merge has to survive is entitlement XML nobody here wrote. See+ /// `VPhoneSignParityTests.mergedWithoutAFile` for why that distinction is+ /// not a matter of taste.+ static let seededNames = [+ "seeded-lsd",+ "seeded-sshd",+ "seeded-spindump",+ "seeded-sysdiagnose_helper",+ "seeded-runningboardd",+ "seeded-promotedcontentd",+ "seeded-seserviced",+ ]++ /// Every fixture. A name that is not on disk fails here rather than+ /// quietly shrinking the corpus, which is the hole the old harness had.+ static var fixtures: [URL] {+ get throws {+ try (builtNames + seededNames).map { try url($0) }+ }+ }++ /// Just the seven that arrive carrying entitlements ldid put there.+ static var seeded: [URL] {+ get throws {+ try seededNames.map { try url($0) }+ }+ }++ static func url(_ name: String) throws -> URL {+ let url = root.appendingPathComponent(name)+ try #require(+ FileManager.default.fileExists(atPath: url.path),+ "fixture \"\(name)\" is missing from \(root.path); the corpus is committed, not built"+ )+ return url+ }++ // MARK: - Holding output against the table++ static func digest(_ data: Data) -> String {+ SHA256.hash(data: data).map { String(format: "%02x", $0) }.joined()+ }++ /// `data` against the digest frozen under `key`.+ ///+ /// A key that is not in the table fails. It must: a typo in a key would+ /// otherwise look up nothing, compare nothing and pass, which is the same+ /// failure mode as the old harness skipping when ldid was absent.+ static func expect(+ _ key: String,+ matches data: Data,+ sourceLocation: SourceLocation = #_sourceLocation+ ) throws {+ let frozen = try #require(+ expected[key],+ "no frozen digest for \"\(key)\" — a typo, or a row the table never had",+ sourceLocation: sourceLocation+ )+ let ours = digest(data)+ #expect(+ ours == frozen,+ """+ \(key): \(data.count) bytes+ ldid \(frozen)+ ours \(ours)+ """,+ sourceLocation: sourceLocation+ )+ }++ /// The same, for the two rows that are a length rather than a digest.+ static func expect(+ length key: String,+ is length: Int,+ sourceLocation: SourceLocation = #_sourceLocation+ ) throws {+ let frozen = try #require(+ expectedLengths[key],+ "no frozen length for \"\(key)\"",+ sourceLocation: sourceLocation+ )+ #expect(length == frozen, "\(key): ldid \(frozen) bytes, ours \(length)", sourceLocation: sourceLocation)+ }++ /// Whether the table has a row at all, for the cases that assert a blob is+ /// present exactly when ldid wrote one.+ static func isFrozen(_ key: String) -> Bool { expected[key] != nil }++ // MARK: - Working files++ /// Runs a verifier — `/usr/bin/codesign`, `/usr/bin/openssl` — over what+ /// this signer wrote. Nothing here runs a signer.+ @discardableResult+ static func run(_ tool: URL, _ arguments: [String]) throws -> (status: Int32, out: Data, error: String) {+ let process = Process()+ process.executableURL = tool+ process.arguments = arguments+ let out = Pipe(), error = Pipe()+ process.standardOutput = out+ process.standardError = error+ try process.run()+ // read before waiting: a pipe that fills would deadlock the child+ let output = out.fileHandleForReading.readDataToEndOfFile()+ let diagnostics = error.fileHandleForReading.readDataToEndOfFile()+ process.waitUntilExit()+ return (process.terminationStatus, output, String(decoding: diagnostics, as: UTF8.self))+ }++ /// A directory that goes away with the test.+ static func temporaryDirectory() throws -> URL {+ let url = FileManager.default.temporaryDirectory+ .appendingPathComponent("vphone-sign-\(UUID().uuidString)")+ try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)+ return url+ }++ /// `source` copied in as `name`. The name matters: ldid signs under the+ /// file's own name unless told otherwise, so the frozen digests are only+ /// reproducible over a copy called what the fixture is called.+ static func copy(_ source: URL, into directory: URL, as name: String) throws -> URL {+ let url = directory.appendingPathComponent(name)+ try? FileManager.default.removeItem(at: url)+ try FileManager.default.copyItem(at: source, to: url)+ return url+ }++ /// Signs a copy of `fixture` in `directory`, and hands back the file it+ /// wrote.+ ///+ /// Every assertion goes through here so that the signing identifier is+ /// pinned in one place. `VPhoneSigner.sign(fileAt:)` fills an unset+ /// identifier in from `url.lastPathComponent`, the way ldid does, and the+ /// identifier is hashed into the CodeDirectory — so left to default it is+ /// a hidden input to every digest in the table, taken from whatever the+ /// working copy happens to be called. A table generated against temp+ /// copies named anything else does not reproduce, and says nothing about+ /// where it went wrong. Pinning it costs nothing and removes the+ /// coupling: `identifier` defaults to the fixture's own name, which is the+ /// string the table's keys are built from.+ ///+ /// The default is exercised on its own, once, in+ /// `VPhoneSignParityTests.identifierDefaultsToTheFileName`.+ @discardableResult+ static func sign(+ _ fixture: URL,+ in directory: URL,+ identifier: String? = nil,+ entitlements: Data? = nil,+ mergesExisting: Bool = false,+ style: VPhoneSignOptions.Style = .ldid,+ identity: (any VPhoneSigningIdentity)? = nil+ ) throws -> URL {+ let name = fixture.lastPathComponent+ let file = try copy(fixture, into: directory, as: name)+ try VPhoneSigner.sign(fileAt: file, options: .init(+ identifier: identifier ?? name,+ entitlements: entitlements,+ mergesExisting: mergesExisting,+ style: style,+ identity: identity+ ))+ return file+ }++ /// Where two files first differ, for a failure message worth reading.+ static func difference(_ left: Data, _ right: Data) -> String {+ guard left != right else { return "identical" }+ let shared = min(left.count, right.count)+ for offset in 0 ..< shared where left[offset] != right[offset] {+ let window = offset ..< min(offset + 16, shared)+ return """+ \(left.count) vs \(right.count) bytes, first difference at \(offset) \+ (0x\(String(offset, radix: 16))): \+ \(left[window].map { String(format: "%02x", $0) }.joined()) vs \+ \(right[window].map { String(format: "%02x", $0) }.joined())+ """+ }+ return "\(left.count) vs \(right.count) bytes, identical up to the shorter one"+ }++ // MARK: - The frozen table++ static let expected: [String: String] = [+ "hello-arm64.adhoc": "0d867f9539eb1e589a3e1e76ce1185df69f46549c9037c908dea61ea164310d7",+ "hello-arm64.entitlements": "d0d84d266aef6145247c65c56995d132ddeafcf45db60dfb82792d0047b63274",+ "hello-arm64.mergeOwn": "0d867f9539eb1e589a3e1e76ce1185df69f46549c9037c908dea61ea164310d7",+ "hello-arm64.mergeSample": "d0d84d266aef6145247c65c56995d132ddeafcf45db60dfb82792d0047b63274",+ "hello-arm64.identifier": "6c8faceb90c95a56de9c47b481544af0295ddcd1c7c05dba501b4e635acfc29a",+ "hello-arm64.dump": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",+ "hello-arm64.sealed.0.0": "7000dc5ce45ad8c41740f8d1608315c86def95971cff6c021b09090cc7636aee",+ "hello-arm64.sealed.0.2": "56df2d7c39d1dafec30312d6d60010331133c3ed34e49163d120e8fa4aac71f0",+ "hello-arm64.sealed.0.4096": "963018fc53a62908a3d258eb9dc8d5f816201469d6b28f434080bae3bee9e905",++ "hello-arm64e.adhoc": "1205cdc6e3b7a015c7faa8e589d80a1b52b9b750789caedbc25f948ad60375dd",+ "hello-arm64e.entitlements": "26ba87b649265f51b24268cfba0add33584d9a4418903acdaf7f3e0ab3273828",+ "hello-arm64e.mergeOwn": "1205cdc6e3b7a015c7faa8e589d80a1b52b9b750789caedbc25f948ad60375dd",+ "hello-arm64e.mergeSample": "26ba87b649265f51b24268cfba0add33584d9a4418903acdaf7f3e0ab3273828",+ "hello-arm64e.identifier": "b975db8c5cc84838cbded51dc9a4378c2094901fb757f7bb62cc8c34d64df4ff",+ "hello-arm64e.dump": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",+ "hello-arm64e.sealed.0.0": "ba4239dedf25fc225252558bf2143bd77147a9b8f1e4e719a6e5c65808727589",+ "hello-arm64e.sealed.0.2": "be24f4898d79c5331187b8bb701d1c00b29687caaa813bd2f8e167e4afa30a80",+ "hello-arm64e.sealed.0.4096": "f9fc81be3406c91d1ef7b82e09dfdd31395ac0b8054703684247b6a1b0f0ce46",++ "hello-fat.adhoc": "5d29290d6336b51d4340c462a6d4688c3ecdbbf970397d9aa05aa9896fa6dbc1",+ "hello-fat.entitlements": "11007eceecac970081f7fc763b83de15c4ba2904bfee662ee42739b7a1fa48b5",+ "hello-fat.mergeOwn": "5d29290d6336b51d4340c462a6d4688c3ecdbbf970397d9aa05aa9896fa6dbc1",+ "hello-fat.mergeSample": "11007eceecac970081f7fc763b83de15c4ba2904bfee662ee42739b7a1fa48b5",+ "hello-fat.identifier": "2b767540f816150a308a4366b455e0e317bc419c1451d50a23f69d8b0538e7b7",+ "hello-fat.dump": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",+ "hello-fat.sealed.0.0": "47d93fa448587e1e6ecffc88651a15bdc36f4857d95dac69b3eb062939e225bc",+ "hello-fat.sealed.0.2": "70f361565650c8a8e72985e2055b0fadb83f25831563b6bf6b62017270535540",+ "hello-fat.sealed.0.4096": "4bf4fd75338c8ee5220f5497141bc2d84632607ac66fe3e5642987a56d81a758",+ "hello-fat.sealed.1.0": "d5d8bd44aaaed12553b8e50e9ee9abc5c6d2beb4d7bb10cbe3e7b3f87a3aa4f1",+ "hello-fat.sealed.1.2": "70f361565650c8a8e72985e2055b0fadb83f25831563b6bf6b62017270535540",+ "hello-fat.sealed.1.4096": "e6c0f177fcbc8c827b2840004c3134e4a6606e1c98f15bdbbfbb9c4affc0c0d9",++ "hello-ios.adhoc": "8c421ac9b0cbd6f39f61cd6490915e111ba39daea5dbcf19c5c7474025a66f0d",+ "hello-ios.entitlements": "3dadd4e4df010a28fc34e3c6b490c0fe166d3a9b07ee0d2adf581dbe8dd447f5",+ "hello-ios.mergeOwn": "8c421ac9b0cbd6f39f61cd6490915e111ba39daea5dbcf19c5c7474025a66f0d",+ "hello-ios.mergeSample": "3dadd4e4df010a28fc34e3c6b490c0fe166d3a9b07ee0d2adf581dbe8dd447f5",+ "hello-ios.identifier": "676e138bedf69015cb96d923353beab6f47fbea8b2fd540463ff03263b7f55e8",+ "hello-ios.dump": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",+ "hello-ios.sealed.0.0": "009aa84e21744a6a76d58886103ec4e80f225ca2b92a8826a32e90b628679ff8",+ "hello-ios.sealed.0.2": "352b75882b048bc8598e0ffb4fd74fb5150134cb801b9cb144e9aab52be6b7c7",+ // no hello-ios.sealed.0.4096: its deployment target is new enough that+ // ldid drops SHA-1 and writes one CodeDirectory, in slot 0++ "hello-dylib.adhoc": "e1b6a4120269fe8f6ec02338628c6381aa6a1622f9b7f908eef424cea71fa396",+ "hello-dylib.entitlements": "ba34c07b84510688eddf37619faf017640d193652ac828e2028f754322d9d7ce",+ "hello-dylib.mergeOwn": "e1b6a4120269fe8f6ec02338628c6381aa6a1622f9b7f908eef424cea71fa396",+ "hello-dylib.mergeSample": "ba34c07b84510688eddf37619faf017640d193652ac828e2028f754322d9d7ce",+ "hello-dylib.identifier": "2e413f5b67786c53e4120257ffd2891cd1c4639c393ba3c557d6095b1b44c336",+ "hello-dylib.dump": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",+ "hello-dylib.sealed.0.0": "26b74990d9e841ccaf79b7f272b9e05f0da8efff8ff310f43901305fd77e7e7d",+ "hello-dylib.sealed.0.2": "325c672072d1d1d260b9ace6f1375623df9cc15cbd0f113158a4682a53bcece6",+ "hello-dylib.sealed.0.4096": "7325013e5e7eaea295811f768ae2e4f62a711fd6825c9270787f7e23a477911b",++ "seeded-lsd.adhoc": "b75865daa2a6bbf961aff7a6dd2fc459fd48398344edbc417343ff9915e03505",+ "seeded-lsd.entitlements": "5a58e561bc889f60b812d6841ffb796c6f7c1b28f9cca5987a6469a9fe782155",+ "seeded-lsd.mergeOwn": "374243d92856a422fa9e509c3235120f45f3a90e54856f893e549fa149832b6a",+ "seeded-lsd.mergeSample": "e4b391757d0918e6e0fab0bc883df4168a9c15fc434374b29e4e76949da8ea74",+ "seeded-lsd.identifier": "2e413f5b67786c53e4120257ffd2891cd1c4639c393ba3c557d6095b1b44c336",+ "seeded-lsd.dump": "03f79da2e8bbb9b0a14e28287ed4db3356b0bcd91a98a8b61a21f0aaff05b23d",+ "seeded-lsd.sealed.0.0": "87791b3159ae2922d6a8dd4f1d74302de20eb733d64b304301efcfad9ec92c4f",+ "seeded-lsd.sealed.0.2": "38a19160f022629395db4097ebbd1df707acb17bad32e5d20c05800359a38e47",+ "seeded-lsd.sealed.0.4096": "828517d3165d0f86a57d0824a5a10a4df6fcfbacd30d24c10ad2df7668016ff5",++ "seeded-sshd.adhoc": "59bfe57991238b9729f5d49153a88d3405876ca9ff1a023f14d130ed68879765",+ "seeded-sshd.entitlements": "8f8359417aa759412827d34db5fcb32531f7be9048a62d5915ea87d21b129c19",+ "seeded-sshd.mergeOwn": "b44de957acf5791c27b835960f33b4b9ad994e5fe2d9c6479c940e948a0bdcf7",+ "seeded-sshd.mergeSample": "acdc4e97a5ea948e0164182d8c9014d0317330254640efd95060811be5ef7048",+ "seeded-sshd.identifier": "2e413f5b67786c53e4120257ffd2891cd1c4639c393ba3c557d6095b1b44c336",+ "seeded-sshd.dump": "238db087d3cc5e94fbedaf707da33ea09f4b7b725f8af8e5841f3e9a3a6321ee",+ "seeded-sshd.sealed.0.0": "e01b21184f987edb8f2510a4eb74c723f023442b9e2c51cdc79d5a7e7a7971f6",+ "seeded-sshd.sealed.0.2": "451c5e1f01dc6ab4918de17ef406408e8702d0d969cdb1808a8ded85d8ab1a2f",+ "seeded-sshd.sealed.0.4096": "f70b05e63a5daf10d9381db4f8785bbea37325fd2385ceea30da2b1505156a16",++ "seeded-spindump.adhoc": "908ee56bf1ebc6ee4e8868ec7f12e58983484787d588b90039b05cdfa7d8269f",+ "seeded-spindump.entitlements": "d8373f3691f9defb6a71bf18f9681949f60fa3b596a56dff679f9c769e5c1b2c",+ "seeded-spindump.mergeOwn": "b6b662e901f3c1f1e397cf165ebb6519f96fe394ab73d185d48d644c74449788",+ "seeded-spindump.mergeSample": "51ff525437d9375c37bd80e86a721c258b30f9f287bf3318f1773891fd135594",+ "seeded-spindump.identifier": "2e413f5b67786c53e4120257ffd2891cd1c4639c393ba3c557d6095b1b44c336",+ "seeded-spindump.dump": "3d5d3b68deb2cf105e3a9863f672fc185383288484d47ae3b9812aa9a3e921e1",+ "seeded-spindump.sealed.0.0": "3244e7d7c5ab5556a5b3b313859ed13e9cd7ddd5274a613365056fae878be8aa",+ "seeded-spindump.sealed.0.2": "a911d0d54a8fc8662c80603d6c554a730d9c035258636aad859074111097a36d",+ "seeded-spindump.sealed.0.4096": "1abc8354901482ca2015426a311668a9286a64b656a4fa3add2a2fd543000220",++ "seeded-sysdiagnose_helper.adhoc": "d51083c4dcd9831860fec772c44a28417f2506a6ff0dd62d12339cd5f48ce044",+ "seeded-sysdiagnose_helper.entitlements": "b6d35156375cf3edcdb7d2ecb76fdf2ab5a7d1b52ad062948e4ff9649a215f49",+ "seeded-sysdiagnose_helper.mergeOwn": "7da7f83530016532ed594a85fdd283518eba0e05c7f9dbfae93bec5a364cfcd9",+ "seeded-sysdiagnose_helper.mergeSample": "c956aec3769a25a33b5974a691f8ce66d9fea726e1c1830eaf62806a73efe345",+ "seeded-sysdiagnose_helper.identifier": "2e413f5b67786c53e4120257ffd2891cd1c4639c393ba3c557d6095b1b44c336",+ "seeded-sysdiagnose_helper.dump": "5b9242e28d3e22a7cb231025d87132364af26860cbf6c1e5fc374f9aba32fcd6",+ "seeded-sysdiagnose_helper.sealed.0.0": "77a63b99c0af2678ff478cae61285696d9ba704da7486417eea12e005ba8894e",+ "seeded-sysdiagnose_helper.sealed.0.2": "a7dcb962998db6319752e24aeddec356a1cb05e58bebd958ce8c2874ec748a34",+ "seeded-sysdiagnose_helper.sealed.0.4096": "86756ed1a7353d9f3e451ed1ec6403bf5a5b0a5b8d68a8135420c8c69afb869c",++ "seeded-runningboardd.adhoc": "47eb4fc3e42abe3387d134e3050c5ce4e3022e86b8b507cfd332990035a1df26",+ "seeded-runningboardd.entitlements": "788000ebce992cc7c7644a72c139d8f3dbf588107b26945ed6ebcacb7fedb3b9",+ "seeded-runningboardd.mergeOwn": "d9f88ef88705e2cc78587ee1b288dccebcd1bc4f6a05b93fab2530d8827dbfb9",+ "seeded-runningboardd.mergeSample": "c7bdcf8e3b1aed1950e19a20ff8c08ab069340e1b12f642619e4d754f5d8f21a",+ "seeded-runningboardd.identifier": "2e413f5b67786c53e4120257ffd2891cd1c4639c393ba3c557d6095b1b44c336",+ "seeded-runningboardd.dump": "c4d27ee51ecc2fe15839687c8b4bdd127379f7ef865f4b8192ed26a0f4a3ff8d",+ "seeded-runningboardd.sealed.0.0": "ece7108f377e238802680df60d21d015f855b93d18a4deea4fc9b1ef657facb8",+ "seeded-runningboardd.sealed.0.2": "211b9b442e58c341ab3a749fcd685499e142422411d7cccc87fa62409b556f33",+ "seeded-runningboardd.sealed.0.4096": "01837980ff82700381ae3b4d276e9d56cbd83c8b306abb7f2534d6827631912d",++ "seeded-promotedcontentd.adhoc": "12e35ee8e4b2af9d9707ab57ef323d13ef37c5149b6ec96726bbe5efb03bd6b6",+ "seeded-promotedcontentd.entitlements": "254b33ba1a9a146935ab14fbe8b5f4037d59cbb31e41d3b6926a4d796b72b660",+ "seeded-promotedcontentd.mergeOwn": "3367c8f0eade36706116e6247818ce2743cb5edffff5f3d0cce76eb99f6abf55",+ "seeded-promotedcontentd.mergeSample": "da829eb5bd753041565795e55461b93fa5473497cab8e7f0316c088f12df267a",+ "seeded-promotedcontentd.identifier": "2e413f5b67786c53e4120257ffd2891cd1c4639c393ba3c557d6095b1b44c336",+ "seeded-promotedcontentd.dump": "15128d76126ff2f72ae252d4b4bbddbc314bdf813d17fa4cd89e9e2743229ca7",+ "seeded-promotedcontentd.sealed.0.0": "ddb90967d3ab281a2d84b9427946d8566fd6bb4e5e145a4a91b6ed4e5f43d0ae",+ "seeded-promotedcontentd.sealed.0.2": "9e075a6b694728c7ffe2ac9856ac7c69051e8125f060c4397704f048201d6f09",+ "seeded-promotedcontentd.sealed.0.4096": "10b3b9e55924d0228ddcc7df1360921512a8e72d6ec53760c265b040fabe83ba",++ "seeded-seserviced.adhoc": "e9a9020cd7cf9505e7b83a6a9ee87265f031463c61859fe0847886c5de04276e",+ "seeded-seserviced.entitlements": "0ed50260b214935c9776e5eb241631f2d256f7210bf9824060014f245eb494cb",+ "seeded-seserviced.mergeOwn": "3baefc92a9b0d81f2be8ae1b2fde442aedcd04ef6ef91f6c72d5bb523238de35",+ "seeded-seserviced.mergeSample": "2738f7bdff96ba44ed32093a6575d28a362c3f93466776ce9ef5584715c47208",+ "seeded-seserviced.identifier": "2e413f5b67786c53e4120257ffd2891cd1c4639c393ba3c557d6095b1b44c336",+ "seeded-seserviced.dump": "956de5a3455b78d5884cdb7595de932cf5ad160643e9d49791bfd10c7c4b9d7b",+ "seeded-seserviced.sealed.0.0": "373ee2b148f2049b5977364dac6c25a4f1a623163824a9e5205134e2a2919cb7",+ "seeded-seserviced.sealed.0.2": "2d82270e0c3807d9f38fd1fe80af5c34d9b57e66117da1f48dc9a5956dbc2e78",+ "seeded-seserviced.sealed.0.4096": "5d7588251220816ff003b82dbfed38d6ed0c25dc34e7a34b836344a6f149ca79",++ // Every `<integer>` spelling ldid takes, over hello-arm64 signed as+ // `binary`. `0`, `-0` and `+42` are not decoration: see+ // `VPhoneSignEntitlementsTests.integerSpellingsMatchLdid`.+ "integer.0": "d528a24a152ba3fb92cd563cf9f7a9dba62ed0e3b97b9eadc150589838d94c61",+ "integer.-1": "a5872164069d5e7d842afe5756a50080985cba26847d7511b5db972e82352afe",+ "integer.007": "8efe05b0ee70de5ace3571a4c573a1c1f59589f8b9b225d3c0db099a86fcc22b",+ "integer.0x10": "54b173c63ede3cb0c8c0eba6b128799257d7fda0ab70997ba92ecb1c159611d7",+ "integer.0777": "05227d8ca49e4b29a5a867125ee751f4ca4a11b4a09eee7193e7ef33618c7fcf",+ "integer.0X1F": "c33e239fce7268d87876a7017d8fff7fac4c7cacaa7e15738f171daf5240ff3f",+ "integer.+42": "ff15ea9b5e6f844b54091d1fe3e8b3e8c973e2a609ad4e1c797b474b4c7e3d08",+ "integer.-0": "d528a24a152ba3fb92cd563cf9f7a9dba62ed0e3b97b9eadc150589838d94c61",+ "integer.-0x10": "b776d9e5fa9162995a4fde6f896f5c6b4ea25cb50e2e9d0130e7c87c492bc8ee",+ "integer.1": "8597f68f6a462e65f5bd23761b568d3e8ea56c30852968758ddacd96f192bc66",+ "integer.42": "ff15ea9b5e6f844b54091d1fe3e8b3e8c973e2a609ad4e1c797b474b4c7e3d08",+ "integer.128": "d340a144ec82f451aab110e01bc183dfe12beb66e457a406936319c59e075592",+ "integer.256": "4ace6020446dd7897cecc2ca215901a16dd246832b4b74b57ce37fcc6696190d",+ "integer.2033844765": "63645cdf2608c02e191b05c9284c63ff231b37132c046cdaa6d95bc5a74ff095",+ "integer.4014732562": "72c0413f04e1d09fdb0016cf56d872f3e0f9306f5d720fd85feb56d0232b89db",+ "integer.9223372036854775807": "4af3c2b5b0631a7bc23776887e6b3b082ed19f383d8060e8eba8dcbda60f87b6",+ "integer.-9223372036854775808": "d79dcc4e26d02f41f6fe47e5e948c67cbb7042e89a49419effaf42806aef41cf",+ "integer.9223372036854775808": "52d0f381447f9754726ff63445122565643ff71392f836b433be8b358e76cdfc",+ "integer.18446744073709551615": "b59cdd1859a27174b159bfff24e5938592ec864871874edf9b1b866877f3fde3",+ "integer. 42 ": "ff15ea9b5e6f844b54091d1fe3e8b3e8c973e2a609ad4e1c797b474b4c7e3d08",+ ]++ /// The `-K` rows that are a byte count rather than a digest: the whole+ /// signed file's size, and the length of the CMS blob ldid wrote into slot+ /// 0x10000 of each slice. A CMS carries a signing time, so its bytes move+ /// between runs and its length does not — and the length is the one that+ /// matters, because the reservation is fixed and overflowing it would move+ /// `__LINKEDIT` in the load commands and change every CDHash.+ static let expectedLengths: [String: Int] = [+ "hello-arm64.sealedSize": 62976,+ "hello-arm64.cms.0": 4792,+ "hello-arm64e.sealedSize": 46352,+ "hello-arm64e.cms.0": 4792,+ "hello-fat.sealedSize": 128_272,+ "hello-fat.cms.0": 4792,+ "hello-fat.cms.1": 4792,+ "hello-ios.sealedSize": 62528,+ "hello-ios.cms.0": 4711,+ "hello-dylib.sealedSize": 29616,+ "hello-dylib.cms.0": 4792,+ "seeded-lsd.sealedSize": 35104,+ "seeded-lsd.cms.0": 4792,+ "seeded-sshd.sealedSize": 30368,+ "seeded-sshd.cms.0": 4792,+ "seeded-spindump.sealedSize": 34464,+ "seeded-spindump.cms.0": 4792,+ "seeded-sysdiagnose_helper.sealedSize": 36800,+ "seeded-sysdiagnose_helper.cms.0": 4792,+ "seeded-runningboardd.sealedSize": 35856,+ "seeded-runningboardd.cms.0": 4792,+ "seeded-promotedcontentd.sealedSize": 39040,+ "seeded-promotedcontentd.cms.0": 4792,+ "seeded-seserviced.sealedSize": 48672,+ "seeded-seserviced.cms.0": 4792,+ ]+}diff --git a/tests/VPhoneSignTests/VPhoneSignIdentityTests.swift b/tests/VPhoneSignTests/VPhoneSignIdentityTests.swiftindex 14b508ac..40168207 100644--- a/tests/VPhoneSignTests/VPhoneSignIdentityTests.swift+++ b/tests/VPhoneSignTests/VPhoneSignIdentityTests.swift@@ -12,6 +12,10 @@ import Testing/// the CodeDirectory, and it is the only part that has to: everything AMFI/// seals is in there, and the CDHash is computed over it. The CMS is then/// held to a verifier nobody here wrote.+///+/// So what is frozen from ldid is the part that does not move — the blobs, in+/// `VPhoneSignFixtures.expected`, and the two byte counts, in+/// `expectedLengths`.@Suite("VPhoneSign signs with a PKCS#12")struct VPhoneSignIdentityTests {/// The certificate this repository signs its guest daemon with. It is@@ -49,92 +53,86 @@ struct VPhoneSignIdentityTests {}/// The hard gate for `-K`: the CodeDirectories are ldid's, byte for byte.+ ///+ /// Slot 0 and slot 4096 are the two CodeDirectories; slot 2 is in the same+ /// claim because under `-K` the designated requirement carries the leaf's+ /// common name. A slot the table has no row for must not be written, and a+ /// slot it has a row for must be — otherwise a signature missing a+ /// CodeDirectory entirely would sail past a loop that only compares what+ /// it finds.@Test("every CodeDirectory matches ldid -K")func codeDirectoriesMatchLdid() throws {- let ldid = try #require(VPhoneSignLdidHarness.ldid, "ldid is not installed")let identity = try identity()- for source in VPhoneSignLdidHarness.corpus {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let corpus = try VPhoneSignFixtures.fixtures+ #expect(corpus.count >= 12, "only \(corpus.count) fixtures: too few to say anything")+ var compared = 0+ for source in corpus {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent- let theirs = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- let result = try VPhoneSignLdidHarness.run(ldid, ["-S", "-M", "-K\(Self.p12.path)", theirs.path])- #expect(result.status == 0, "ldid -K \(name): \(result.error)")-- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: "ours-\(name)")- try VPhoneSigner.sign(fileAt: ours, options: .init(- identifier: name, mergesExisting: true, identity: identity- ))-- let left = try VPhoneSignBlobs(fileAt: theirs), right = try VPhoneSignBlobs(fileAt: ours)- #expect(left.slices.count == right.slices.count, "\(name): different slice counts")- for (index, pair) in zip(left.slices, right.slices).enumerated() {- for slot in [UInt32(0), 0x1000] where pair.0[slot] != nil || pair.1[slot] != nil {- #expect(- pair.0[slot] == pair.1[slot],- "\(name) slice \(index) slot 0x\(String(slot, radix: 16)): CodeDirectory differs"- )+ let ours = try VPhoneSignFixtures.sign(+ source, in: directory, mergesExisting: true, identity: identity+ )+ for (index, slice) in try VPhoneSignBlobs(fileAt: ours).slices.enumerated() {+ for slot in [UInt32(0), 2, 0x1000] {+ let key = "\(name).sealed.\(index).\(slot)"+ guard VPhoneSignFixtures.isFrozen(key) else {+ #expect(slice[slot] == nil, "\(key): ldid wrote no such blob, this signer did")+ continue+ }+ let blob = try #require(slice[slot], "\(key): ldid wrote this blob, this signer did not")+ try VPhoneSignFixtures.expect(key, matches: blob)+ compared += 1}- // the designated requirement carries the leaf's common name- // under -K, so it is part of the same claim- #expect(pair.0[2] == pair.1[2], "\(name) slice \(index): requirements differ")}}+ // every frozen row has to have been reached, or a corpus that lost a+ // fixture — or a signature that lost a slice — compares less and passes+ let frozen = VPhoneSignFixtures.expected.keys.count { $0.contains(".sealed.") }+ #expect(compared == frozen, "compared \(compared) of the \(frozen) frozen CodeDirectory blobs")}/// The seal, checked by `codesign --verify`, which is an action and not/// the verbosity flag that `-d -vvv` turns out to be.///- /// Both signers pass outright, entitlements or not: `codesign --verify`- /// exits 0 and prints "satisfies its Designated Requirement" for ldid's- /// output and for this one. An earlier note here said the DR clause fails- /// for both whenever entitlements are present, because ldid compiles a DR- /// naming a leaf that expired in 2018. That does not reproduce in any- /// configuration tried — `--verify` does not build a trust chain, so the- /// expiry never comes into it — so the run is asserted rather than only- /// compared against ldid's.+ /// This signer passes outright, entitlements or not: `codesign --verify`+ /// exits 0 and prints "satisfies its Designated Requirement". An earlier+ /// note here said the DR clause fails whenever entitlements are present,+ /// because ldid compiles a DR naming a leaf that expired in 2018. That+ /// does not reproduce in any configuration tried — `--verify` does not+ /// build a trust chain, so the expiry never comes into it.+ ///+ /// `/usr/bin/codesign` is the one system binary this suite still calls,+ /// and it is called as a verifier rather than as a source of input.@Test("codesign --verify accepts the seal, with entitlements and without")func codesignVerifiesTheSeal() throws {- let ldid = try #require(VPhoneSignLdidHarness.ldid, "ldid is not installed")let identity = try identity()let codesign = URL(fileURLWithPath: "/usr/bin/codesign")- // the corpus's first files carry no entitlements and- // `carryingEntitlements` is the half that does, which is the case the- // old note claimed was different- // Filter before the prefix, not after. The other order takes the first- // four names and *then* drops the missing ones, so a machine without- // one of lsd/sshd/trustd/pkd quietly shrinks the entitlement-carrying- // half — possibly to nothing — and the test still passes.- let entitled = VPhoneSignLdidHarness.carryingEntitlements- .filter { FileManager.default.fileExists(atPath: $0) }- .prefix(4)- .map { URL(fileURLWithPath: $0) }- #expect(entitled.count == 4, "expected four entitlement-carrying binaries, found \(entitled.count)")- let corpus = VPhoneSignLdidHarness.corpus.prefix(4) + entitled+ let corpus = try VPhoneSignFixtures.fixtures+ var entitled = 0for source in corpus {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent+ if try VPhoneSigner.entitlements(ofFileAt: source).contains(where: { !$0.isEmpty }) {+ entitled += 1+ }- let theirs = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- let seal = try VPhoneSignLdidHarness.run(ldid, ["-S", "-M", "-K\(Self.p12.path)", theirs.path])- #expect(seal.status == 0, "ldid -S -M -K \(name): \(seal.error)")- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: "ours-\(name)")- try VPhoneSigner.sign(fileAt: ours, options: .init(- identifier: name, mergesExisting: true, identity: identity- ))-- let mine = try VPhoneSignLdidHarness.run(codesign, ["--verify", "--no-strict", "-vvv", ours.path])- let theirsResult = try VPhoneSignLdidHarness.run(codesign, ["--verify", "--no-strict", "-vvv", theirs.path])- #expect(theirsResult.status == 0, "ldid's own output: \(theirsResult.error)")- #expect(mine.status == 0, "\(name): \(mine.error)")- #expect(mine.error.contains("valid on disk"), "\(name): \(mine.error)")+ let ours = try VPhoneSignFixtures.sign(+ source, in: directory, mergesExisting: true, identity: identity+ )+ let result = try VPhoneSignFixtures.run(codesign, ["--verify", "--no-strict", "-vvv", ours.path])+ #expect(result.status == 0, "\(name): \(result.error)")+ #expect(result.error.contains("valid on disk"), "\(name): \(result.error)")#expect(- mine.error.contains("satisfies its Designated Requirement"),- "\(name): ours [\(mine.error)] ldid [\(theirsResult.error)]"+ result.error.contains("satisfies its Designated Requirement"),+ "\(name): \(result.error)")}+ // the entitlement-carrying half is the case the old note claimed was+ // different, so it has to be in the run+ #expect(entitled >= 7, "only \(entitled) of the fixtures carried entitlements")}/// The two files are the same size, and their CMS blobs are the same@@ -147,29 +145,21 @@ struct VPhoneSignIdentityTests {/// commands and change every CDHash.@Test("the CMS is the same length as ldid's, and so is the file")func cmsIsTheSameLengthAsLdids() throws {- let ldid = try #require(VPhoneSignLdidHarness.ldid, "ldid is not installed")let identity = try identity()- for source in VPhoneSignLdidHarness.corpus.prefix(8) {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ for source in try VPhoneSignFixtures.fixtures {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent- let theirs = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- _ = try VPhoneSignLdidHarness.run(ldid, ["-S", "-M", "-K\(Self.p12.path)", theirs.path])- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: "ours-\(name)")- try VPhoneSigner.sign(fileAt: ours, options: .init(- identifier: name, mergesExisting: true, identity: identity- ))-- #expect(- try Data(contentsOf: theirs).count == Data(contentsOf: ours).count,- "\(name): the signed files are different sizes"+ let ours = try VPhoneSignFixtures.sign(+ source, in: directory, mergesExisting: true, identity: identity+ )+ try VPhoneSignFixtures.expect(+ length: "\(name).sealedSize", is: Data(contentsOf: ours).count)- let left = try VPhoneSignBlobs(fileAt: theirs), right = try VPhoneSignBlobs(fileAt: ours)- for (index, pair) in zip(left.slices, right.slices).enumerated() {- let mine = try #require(pair.1[0x10000], "\(name) slice \(index) has no CMS")- let theirs = try #require(pair.0[0x10000], "\(name) slice \(index): ldid wrote no CMS")- #expect(mine.count == theirs.count, "\(name) slice \(index): \(mine.count) vs \(theirs.count)")+ for (index, slice) in try VPhoneSignBlobs(fileAt: ours).slices.enumerated() {+ let cms = try #require(slice[0x10000], "\(name) slice \(index) has no CMS")+ try VPhoneSignFixtures.expect(length: "\(name).cms.\(index)", is: cms.count)}}}@@ -180,14 +170,14 @@ struct VPhoneSignIdentityTests {/// says nothing about whether the signature is sound.@Test("openssl cms -verify accepts the signature")func opensslVerifiesTheCMS() throws {- let openssl = try #require(VPhoneSignLdidHarness.which("openssl"), "openssl is not installed")+ let openssl = URL(fileURLWithPath: "/usr/bin/openssl")+ try #require(FileManager.default.isExecutableFile(atPath: openssl.path), "openssl is not installed")let identity = try identity()- for source in VPhoneSignLdidHarness.corpus.prefix(6) {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ for source in try VPhoneSignFixtures.fixtures.prefix(6) {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- try VPhoneSigner.sign(fileAt: ours, options: .init(identifier: name, identity: identity))+ let ours = try VPhoneSignFixtures.sign(source, in: directory, identity: identity)let blobs = try VPhoneSignBlobs(fileAt: ours)for (index, slice) in blobs.slices.enumerated() {@@ -199,7 +189,7 @@ struct VPhoneSignIdentityTests {try cms.dropFirst(8).write(to: cmsFile)try directoryBlob.write(to: contentFile)- let result = try VPhoneSignLdidHarness.run(openssl, [+ let result = try VPhoneSignFixtures.run(openssl, ["cms", "-verify", "-inform", "DER", "-in", cmsFile.path,"-content", contentFile.path, "-noverify", "-binary", "-out", "/dev/null",])diff --git a/tests/VPhoneSignTests/VPhoneSignLdidHarness.swift b/tests/VPhoneSignTests/VPhoneSignLdidHarness.swiftdeleted file mode 100644index d73b6dc1..00000000--- a/tests/VPhoneSignTests/VPhoneSignLdidHarness.swift+++ /dev/null@@ -1,171 +0,0 @@-import Foundation-import Testing--/// Running the real `ldid` and holding this signer's output against it.-///-/// The bar for `VPhoneSign` is not "the signature verifies" — ldid's own-/// ad-hoc output does not verify, because it sets no ad-hoc flag and writes-/// no CMS blob, and the guest's AMFI takes it anyway. The bar is that the-/// bytes are the same, which is the only claim that carries over to a-/// patched AMFI nobody here can re-derive. So these tests need ldid, and-/// skip rather than pretend when it is not installed.-enum VPhoneSignLdidHarness {- /// Where Homebrew's ldid is, or nil. Its absence skips the comparisons;- /// it must never make them pass.- static let ldid: URL? = {- for candidate in ["/opt/homebrew/bin/ldid", "/usr/local/bin/ldid"] {- if FileManager.default.isExecutableFile(atPath: candidate) {- return URL(fileURLWithPath: candidate)- }- }- return which("ldid")- }()-- static func which(_ name: String) -> URL? {- let process = Process()- process.executableURL = URL(fileURLWithPath: "/usr/bin/env")- process.arguments = ["which", name]- let pipe = Pipe()- process.standardOutput = pipe- process.standardError = FileHandle.nullDevice- guard (try? process.run()) != nil else { return nil }- let data = pipe.fileHandleForReading.readDataToEndOfFile()- process.waitUntilExit()- let path = String(decoding: data, as: UTF8.self).trimmingCharacters(in: .whitespacesAndNewlines)- return process.terminationStatus == 0 && !path.isEmpty ? URL(fileURLWithPath: path) : nil- }-- /// The Mach-O files to compare on. System binaries cover the shapes this- /// signer has to get right and nothing else on the machine does: fat- /// files, several architectures, a deployment target old enough that- /// ldid drops SHA-1, and one new enough that it does not. The built- /// products are the thin arm64 case.- static var corpus: [URL] {- let candidates = [- "/bin/ls", // fat, and minos 10.14 on x86_64: ldid writes SHA-256 only- "/bin/cat", // fat, minos 27.0: ldid writes both- "/bin/echo",- "/usr/bin/true",- "/usr/bin/grep",- "/usr/bin/head",- ] + carryingEntitlements + toolchainLibraries + built- return candidates- .filter { FileManager.default.fileExists(atPath: $0) }- .map { URL(fileURLWithPath: $0) }- }-- /// Binaries that already carry entitlements, which is what `-M` has to- /// re-serialise. They are listed apart because a corpus of files with no- /// entitlements makes every merge test pass without merging anything.- ///- /// The `<integer>` spellings are the reason for most of this list: an- /// earlier reader here took only a positive decimal, so a merge over- /// `spindump` — whose- /// `com.apple.trial.status.deployment-environment.allow` is- /// `<array><integer>0</integer></array>` — failed where ldid completed.- /// `promotedcontentd` is above `Int32.max`, `runningboardd` carries two- /// different values, and `sysdiagnose_helper` carries six.- static var carryingEntitlements: [String] {- [- "/usr/libexec/lsd", // carries __TEXT,__info_plist and entitlements- "/usr/sbin/sshd",- "/usr/libexec/trustd",- "/usr/libexec/pkd",- "/usr/sbin/spindump", // <integer>0</integer>- "/usr/libexec/sysdiagnose_helper",- "/usr/libexec/runningboardd",- "/usr/libexec/promotedcontentd",- "/usr/libexec/seserviced",- "/usr/libexec/tailspind",- "/usr/bin/tailspin",- "/usr/sbin/cfprefsd",- "/usr/sbin/securityd",- "/usr/libexec/opendirectoryd",- "/usr/bin/shortcuts",- ]- }-- /// Dylibs rather than programs, which differ in the executable segment- /// flags and in whether the main-binary bit is set. The system's own are- /// in the shared cache and not on disk; the toolchain's are real files.- static var toolchainLibraries: [String] {- let toolchain = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib"- let names = ["libLTO.dylib", "libswiftDemangle.dylib", "libcodedirectory.dylib"]- guard let installed = try? FileManager.default.contentsOfDirectory(atPath: "/Applications") else {- return names.map { "\(toolchain)/\($0)" }- }- // whichever Xcode is installed, including a versioned one beside it- return installed.filter { $0.hasPrefix("Xcode") }.flatMap { application in- names.map {- "/Applications/\(application)/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/\($0)"- }- }- }-- /// This project's own binaries, when they have been built. `vphoned` is- /// the one that matters most: it is iOS arm64, cross-compiled, and the- /// binary the guest actually loads.- ///- /// `vphone-letmein` was on this list until it was removed from the- /// project. It brought no shape the others do not — the host products are- /// all thin arm64 and ad-hoc signed — so nothing replaced it.- static var built: [String] {- let root = URL(fileURLWithPath: #filePath)- .deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()- return [root.appendingPathComponent("scripts/vphoned/vphoned").path]- + ["vphone-archive", "vphone-vm", "vphone-cli"].flatMap { name in- ["release", "debug"].map { root.appendingPathComponent(".build/\($0)/\(name)").path }- }- }-- // MARK: Running things-- @discardableResult- static func run(_ tool: URL, _ arguments: [String]) throws -> (status: Int32, out: Data, error: String) {- let process = Process()- process.executableURL = tool- process.arguments = arguments- let out = Pipe(), error = Pipe()- process.standardOutput = out- process.standardError = error- try process.run()- // read before waiting: a pipe that fills would deadlock the child- let output = out.fileHandleForReading.readDataToEndOfFile()- let diagnostics = error.fileHandleForReading.readDataToEndOfFile()- process.waitUntilExit()- return (process.terminationStatus, output, String(decoding: diagnostics, as: UTF8.self))- }-- /// A directory that goes away with the test.- static func temporaryDirectory() throws -> URL {- let url = FileManager.default.temporaryDirectory- .appendingPathComponent("vphone-sign-\(UUID().uuidString)")- try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)- return url- }-- /// `source` copied in as `name`, since ldid signs under the file's name- /// and both sides have to be called the same thing.- static func copy(_ source: URL, into directory: URL, as name: String) throws -> URL {- let url = directory.appendingPathComponent(name)- try? FileManager.default.removeItem(at: url)- try FileManager.default.copyItem(at: source, to: url)- return url- }-- /// Where two files first differ, for a failure message worth reading.- static func difference(_ left: Data, _ right: Data) -> String {- guard left != right else { return "identical" }- let shared = min(left.count, right.count)- for offset in 0 ..< shared where left[offset] != right[offset] {- let window = offset ..< min(offset + 16, shared)- return """- \(left.count) vs \(right.count) bytes, first difference at \(offset) \- (0x\(String(offset, radix: 16))): \- \(left[window].map { String(format: "%02x", $0) }.joined()) vs \- \(right[window].map { String(format: "%02x", $0) }.joined())- """- }- return "\(left.count) vs \(right.count) bytes, identical up to the shorter one"- }-}diff --git a/tests/VPhoneSignTests/VPhoneSignParityTests.swift b/tests/VPhoneSignTests/VPhoneSignParityTests.swiftindex 9c9cf86c..f9db1dcb 100644--- a/tests/VPhoneSignTests/VPhoneSignParityTests.swift+++ b/tests/VPhoneSignTests/VPhoneSignParityTests.swift@@ -11,40 +11,31 @@ import Testing/// is also the only bar that carries: the device this signs for runs an AMFI/// this project patched, and what that accepts cannot be re-derived from/// first principles. It accepts ldid's bytes.+///+/// ldid is not run here. Every expectation is a digest frozen in+/// `VPhoneSignFixtures`, taken from the real ldid over the committed fixtures;+/// the header of that file says how to re-derive them and why they are frozen+/// rather than compared live.@Suite("VPhoneSign is byte-identical to ldid")struct VPhoneSignParityTests {- private var ldid: URL {- get throws {- try #require(VPhoneSignLdidHarness.ldid, "ldid is not installed; install ldid-procursus to run the parity gate")- }- }-// MARK: - Ad-hoc, which is nearly every call@Test("ldid -S")func adHoc() throws {- let ldid = try ldid- let corpus = VPhoneSignLdidHarness.corpus+ let corpus = try VPhoneSignFixtures.fixtures// a corpus that shrank to nothing would make every one of these pass- #expect(corpus.count >= 10, "only \(corpus.count) files: too few to say anything")+ #expect(corpus.count >= 12, "only \(corpus.count) fixtures: too few to say anything")#expect(corpus.contains { (try? Data(contentsOf: $0).prefix(4)) == Data([0xCA, 0xFE, 0xBA, 0xBE]) },"no fat binary in the corpus")for source in corpus {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent- let theirs = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- let result = try VPhoneSignLdidHarness.run(ldid, ["-S", theirs.path])- #expect(result.status == 0, "ldid -S \(name): \(result.error)")-- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: "ours-\(name)")- try VPhoneSigner.sign(fileAt: ours, options: .init(identifier: name))-- let left = try Data(contentsOf: theirs), right = try Data(contentsOf: ours)- #expect(left == right, "\(name): \(VPhoneSignLdidHarness.difference(left, right))")+ let ours = try VPhoneSignFixtures.sign(source, in: directory)+ try VPhoneSignFixtures.expect("\(name).adhoc", matches: Data(contentsOf: ours))}}@@ -52,136 +43,131 @@ struct VPhoneSignParityTests {@Test("ldid -S<entitlements>")func entitlements() throws {- let ldid = try ldid- for source in VPhoneSignLdidHarness.corpus {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let corpus = try VPhoneSignFixtures.fixtures+ #expect(corpus.count >= 12, "only \(corpus.count) fixtures: too few to say anything")+ for source in corpus {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent- let plist = directory.appendingPathComponent("entitlements.plist")- try Self.sampleEntitlements.write(to: plist)-- let theirs = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- let result = try VPhoneSignLdidHarness.run(ldid, ["-S\(plist.path)", theirs.path])- #expect(result.status == 0, "ldid -S<ent> \(name): \(result.error)")-- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: "ours-\(name)")- try VPhoneSigner.sign(fileAt: ours, options: .init(- identifier: name, entitlements: Self.sampleEntitlements- ))- let left = try Data(contentsOf: theirs), right = try Data(contentsOf: ours)- #expect(left == right, "\(name): \(VPhoneSignLdidHarness.difference(left, right))")+ let ours = try VPhoneSignFixtures.sign(+ source, in: directory, entitlements: Self.sampleEntitlements+ )+ try VPhoneSignFixtures.expect("\(name).entitlements", matches: Data(contentsOf: ours))}}- /// `-M` over a list written for the occasion, so that the merge itself is- /// pinned: a key replaced where it stood and a key appended after it,- /// which a system binary's own entitlements cannot be relied on to- /// contain. The unseeded case — a binary's own list, which is what the- /// installers actually merge over — is `mergedWithoutAFile` and- /// `mergedOverOwnEntitlements`.+ /// `-M` over a signature this signer did not write.+ ///+ /// The seeded fixtures arrive already signed by ldid, each carrying one+ /// real daemon's real entitlements, so the merge's starting point is+ /// nothing anybody here composed. The five `hello-*` files carry none,+ /// which is the other half of the claim: over them the merge has to be a+ /// no-op and land exactly where `ldid -S<ent>` lands.@Test("ldid -S<entitlements> -M over a seeded signature")func merged() throws {- let ldid = try ldid- for source in VPhoneSignLdidHarness.corpus {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let corpus = try VPhoneSignFixtures.fixtures+ #expect(corpus.count >= 12, "only \(corpus.count) fixtures: too few to say anything")+ var seeded = 0+ for source in corpus {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent+ if try VPhoneSigner.entitlements(ofFileAt: source).contains(where: { !$0.isEmpty }) {+ seeded += 1+ }- // give the file entitlements to merge over, with ldid, so the- // starting point is not this signer's own work- let seed = directory.appendingPathComponent("seed.plist")- try Self.seedEntitlements.write(to: seed)- let seeded = try VPhoneSignLdidHarness.copy(source, into: directory, as: "seeded-\(name)")- _ = try VPhoneSignLdidHarness.run(ldid, ["-S\(seed.path)", seeded.path])-- let plist = directory.appendingPathComponent("entitlements.plist")- try Self.sampleEntitlements.write(to: plist)-- let theirs = try VPhoneSignLdidHarness.copy(seeded, into: directory, as: name)- let result = try VPhoneSignLdidHarness.run(ldid, ["-S\(plist.path)", "-M", theirs.path])- #expect(result.status == 0, "ldid -S<ent> -M \(name): \(result.error)")-- let ours = try VPhoneSignLdidHarness.copy(seeded, into: directory, as: "ours-\(name)")- try VPhoneSigner.sign(fileAt: ours, options: .init(- identifier: name, entitlements: Self.sampleEntitlements, mergesExisting: true- ))-- let left = try Data(contentsOf: theirs), right = try Data(contentsOf: ours)- #expect(left == right, "\(name): \(VPhoneSignLdidHarness.difference(left, right))")+ let ours = try VPhoneSignFixtures.sign(+ source, in: directory, entitlements: Self.sampleEntitlements, mergesExisting: true+ )+ try VPhoneSignFixtures.expect("\(name).mergeSample", matches: Data(contentsOf: ours))}+ // a corpus of files with nothing to merge merges nothing and passes+ #expect(seeded >= 7, "only \(seeded) fixtures arrived carrying entitlements to merge over")}/// `ldid_sign` in `cfw_install*.sh` is `-S -M` with no entitlements file/// at all: whatever the binary already had is re-serialised and kept.///- /// The file is signed as it came off disk, with no fixture written over- /// it first. That is the whole point. Seeding a binary with an- /// author-written plist makes the merge input a list this signer is+ /// The merge input is entitlement XML nobody here wrote. That is the whole+ /// point, and it is why the seeded fixtures carry seven real daemons'+ /// lists rather than something composed for the occasion. Seeding a binary+ /// with an author-written plist makes the merge input a list this signer is/// already known to read, which is how twenty-eight green tests once sat/// beside a production path that aborted on `/usr/sbin/spindump` — its- /// `<integer>0</integer>` was a shape the fixtures never had. What the- /// firmware's own binaries carry is the only input this has to survive.+ /// `com.apple.trial.status.deployment-environment.allow` is+ /// `<array><integer>0</integer></array>`, and `<integer>0</integer>` was a+ /// shape the fixtures never had. `seeded-spindump` carries that array now,+ /// `seeded-promotedcontentd` a value above `Int32.max`,+ /// `seeded-runningboardd` two different ones and+ /// `seeded-sysdiagnose_helper` six.@Test("ldid -S -M over a binary's own entitlements, which is what cfw_install calls")func mergedWithoutAFile() throws {- let ldid = try ldid+ let corpus = try VPhoneSignFixtures.fixtures+ #expect(corpus.count >= 12, "only \(corpus.count) fixtures: too few to say anything")var merged = 0- for source in VPhoneSignLdidHarness.corpus {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ for source in corpus {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent-- let theirs = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- let result = try VPhoneSignLdidHarness.run(ldid, ["-S", "-M", theirs.path])- #expect(result.status == 0, "ldid -S -M \(name): \(result.error)")-- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: "ours-\(name)")- try VPhoneSigner.sign(fileAt: ours, options: .init(identifier: name, mergesExisting: true))-- let left = try Data(contentsOf: theirs), right = try Data(contentsOf: ours)- #expect(left == right, "\(name): \(VPhoneSignLdidHarness.difference(left, right))")- if try VPhoneSigner.entitlements(ofFileAt: source).isEmpty == false {- merged += 1+ let carries = try VPhoneSigner.entitlements(ofFileAt: source).contains { !$0.isEmpty }+ if carries { merged += 1 }++ let ours = try VPhoneSignFixtures.sign(source, in: directory, mergesExisting: true)+ try VPhoneSignFixtures.expect("\(name).mergeOwn", matches: Data(contentsOf: ours))++ // and where there was something to carry across, carrying it+ // across has to have changed the result — otherwise a merge that+ // dropped the existing list would match a frozen digest of nothing+ if carries {+ #expect(+ VPhoneSignFixtures.expected["\(name).mergeOwn"]+ != VPhoneSignFixtures.expected["\(name).adhoc"],+ "\(name): ldid's -S -M and its -S agree, so the merge carried nothing"+ )}}// a corpus of files with no entitlements merges nothing and passes- #expect(merged >= 8, "only \(merged) files carried entitlements to merge")+ #expect(merged >= 7, "only \(merged) files carried entitlements to merge")}/// The same, with an entitlements file on top: `ldid -S<ent> -M <file>`/// over what the binary already carried, which is what the installers/// run when they add a key rather than only re-sign.+ ///+ /// It runs over the seeded seven alone, where "the binary's own" means+ /// something. Its sibling `merged` covers the same verb over the whole+ /// corpus; what this adds is the guard that every one of the seven really+ /// did arrive with a list, and that merging over it is not the same as+ /// replacing it.@Test("ldid -S<entitlements> -M over a binary's own entitlements")func mergedOverOwnEntitlements() throws {- let ldid = try ldid- var merged = 0- for path in VPhoneSignLdidHarness.carryingEntitlements- where FileManager.default.fileExists(atPath: path)- {- merged += 1- let source = URL(fileURLWithPath: path)- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let seeded = try VPhoneSignFixtures.seeded+ // Without this the loop body can never run and the test passes having+ // compared nothing. Its sibling `mergedWithoutAFile` carries the same+ // guard.+ #expect(seeded.count >= 7, "only \(seeded.count) seeded fixtures")+ for source in seeded {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent- let plist = directory.appendingPathComponent("entitlements.plist")- try Self.sampleEntitlements.write(to: plist)-- let theirs = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- let result = try VPhoneSignLdidHarness.run(ldid, ["-S\(plist.path)", "-M", theirs.path])- #expect(result.status == 0, "ldid -S<ent> -M \(name): \(result.error)")-- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: "ours-\(name)")- try VPhoneSigner.sign(fileAt: ours, options: .init(- identifier: name, entitlements: Self.sampleEntitlements, mergesExisting: true- ))-- let left = try Data(contentsOf: theirs), right = try Data(contentsOf: ours)- #expect(left == right, "\(name): \(VPhoneSignLdidHarness.difference(left, right))")+ #expect(+ try VPhoneSigner.entitlements(ofFileAt: source).contains { !$0.isEmpty },+ "\(name) carries no entitlements, so there is nothing here to merge over"+ )++ let ours = try VPhoneSignFixtures.sign(+ source, in: directory, entitlements: Self.sampleEntitlements, mergesExisting: true+ )+ try VPhoneSignFixtures.expect("\(name).mergeSample", matches: Data(contentsOf: ours))++ // merging is not replacing: ldid's own two answers differ+ #expect(+ VPhoneSignFixtures.expected["\(name).mergeSample"]+ != VPhoneSignFixtures.expected["\(name).entitlements"],+ "\(name): ldid's -S<ent> -M and its -S<ent> agree, so the merge dropped the existing list"+ )}- // Without this the loop body can never run — every path missing on- // some future macOS — and the test passes having compared nothing.- // Its sibling `mergedWithoutAFile` carries the same guard.- #expect(merged >= 8, "only \(merged) of the entitlement-carrying binaries exist here")}/// `-I`, which a handful of call sites use to sign under an Apple@@ -189,21 +175,44 @@ struct VPhoneSignParityTests {/// name.@Test("ldid -I<identifier>")func explicitIdentifier() throws {- let ldid = try ldid- for source in VPhoneSignLdidHarness.corpus.prefix(4) {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let corpus = try VPhoneSignFixtures.fixtures+ #expect(corpus.count >= 12, "only \(corpus.count) fixtures: too few to say anything")+ for source in corpus {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent- let theirs = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- let result = try VPhoneSignLdidHarness.run(ldid, ["-S", "-Icom.apple.seputil", theirs.path])- #expect(result.status == 0, "ldid -I \(name): \(result.error)")+ let ours = try VPhoneSignFixtures.sign(source, in: directory, identifier: "com.apple.seputil")+ try VPhoneSignFixtures.expect("\(name).identifier", matches: Data(contentsOf: ours))+ }+ }- let ours = try VPhoneSignLdidHarness.copy(source, into: directory, as: "ours-\(name)")- try VPhoneSigner.sign(fileAt: ours, options: .init(identifier: "com.apple.seputil"))+ /// The default `-I`: with no identifier set, `VPhoneSigner.sign(fileAt:)`+ /// takes the file's own name, as ldid does.+ ///+ /// Every assertion in this file pins the identifier through+ /// `VPhoneSignFixtures.sign(_:in:…)`, precisely so that no frozen digest+ /// depends on what a temporary copy was called. That leaves one line of+ /// production logic — `options.identifier ?? url.lastPathComponent` —+ /// covered by nothing, so it is covered here, and structurally: the name+ /// is read back out of the CodeDirectory rather than compared to a digest.+ @Test("an unset identifier defaults to the file's name, as ldid does")+ func identifierDefaultsToTheFileName() throws {+ let directory = try VPhoneSignFixtures.temporaryDirectory()+ defer { try? FileManager.default.removeItem(at: directory) }+ // deliberately not the fixture's name: the claim is that the signer+ // reads the name off the file it was handed+ let name = "named-for-this-test"+ let file = try VPhoneSignFixtures.copy(+ try VPhoneSignFixtures.url("hello-arm64"), into: directory, as: name+ )+ try VPhoneSigner.sign(fileAt: file)- let left = try Data(contentsOf: theirs), right = try Data(contentsOf: ours)- #expect(left == right, "\(name): \(VPhoneSignLdidHarness.difference(left, right))")+ let slices = try VPhoneSignBlobs(fileAt: file).slices+ #expect(!slices.isEmpty, "nothing was signed")+ for (index, slice) in slices.enumerated() {+ let blob = try #require(slice[0], "slice \(index) has no CodeDirectory")+ #expect(VPhoneSignBlobs.identifier(ofCodeDirectory: blob) == name, "slice \(index)")}}@@ -211,14 +220,14 @@ struct VPhoneSignParityTests {/// would produce a different image every time.@Test("signing an already-signed file is idempotent")func idempotent() throws {- for source in VPhoneSignLdidHarness.corpus {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ for source in try VPhoneSignFixtures.fixtures {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent- let file = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)+ let file = try VPhoneSignFixtures.copy(source, into: directory, as: name)let once = try VPhoneSigner.sign(fileAt: file, options: .init(identifier: name))let twice = try VPhoneSigner.sign(fileAt: file, options: .init(identifier: name))- #expect(once == twice, "\(name): \(VPhoneSignLdidHarness.difference(once, twice))")+ #expect(once == twice, "\(name): \(VPhoneSignFixtures.difference(once, twice))")}}@@ -231,6 +240,10 @@ struct VPhoneSignParityTests {/// bytes in the DER and two different strings in the XML; `0` is one zero/// byte and not an empty INTEGER. A fixture whose only integer was `42`/// is what let the reader ship taking positive decimals only.+ ///+ /// These exact bytes are what ldid was given when the `.entitlements` and+ /// `.mergeSample` rows of the frozen table were taken. Changing a+ /// character here invalidates both columns.static let sampleEntitlements = Data("""<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">@@ -272,21 +285,4 @@ struct VPhoneSignParityTests {</plist>""".utf8)-- /// A different set, so a merge that silently dropped one side would show.- static let seedEntitlements = Data("""- <?xml version="1.0" encoding="UTF-8"?>- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">- <plist version="1.0">- <dict>- \t<key>com.apple.private.cs.debugger</key>- \t<true/>- \t<key>an-existing-key</key>- \t<string>kept</string>- \t<key>get-task-allow</key>- \t<false/>- </dict>- </plist>-- """.utf8)}diff --git a/tests/VPhoneSignTests/VPhoneSignStyleTests.swift b/tests/VPhoneSignTests/VPhoneSignStyleTests.swiftindex 577f469c..54bac78c 100644--- a/tests/VPhoneSignTests/VPhoneSignStyleTests.swift+++ b/tests/VPhoneSignTests/VPhoneSignStyleTests.swift@@ -13,14 +13,13 @@ struct VPhoneSignStyleTests {@Test("the Apple ad-hoc style passes codesign --verify")func appleAdHocVerifies() throws {let codesign = URL(fileURLWithPath: "/usr/bin/codesign")- for source in VPhoneSignLdidHarness.corpus {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ for source in try VPhoneSignFixtures.fixtures {+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let name = source.lastPathComponent- let file = try VPhoneSignLdidHarness.copy(source, into: directory, as: name)- try VPhoneSigner.sign(fileAt: file, options: .init(identifier: name, style: .appleAdHoc))+ let file = try VPhoneSignFixtures.sign(source, in: directory, style: .appleAdHoc)- let result = try VPhoneSignLdidHarness.run(codesign, ["--verify", "-vvv", file.path])+ let result = try VPhoneSignFixtures.run(codesign, ["--verify", "-vvv", file.path])#expect(result.status == 0, "\(name): \(result.error)")#expect(result.error.contains("valid on disk"), "\(name): \(result.error)")}@@ -28,11 +27,11 @@ struct VPhoneSignStyleTests {@Test("the Apple ad-hoc style sets the flag and writes the empty wrapper")func appleAdHocShape() throws {- let source = try #require(VPhoneSignLdidHarness.corpus.first)- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let file = try VPhoneSignLdidHarness.copy(source, into: directory, as: "binary")- try VPhoneSigner.sign(fileAt: file, options: .init(identifier: "binary", style: .appleAdHoc))+ let file = try VPhoneSignFixtures.sign(+ try VPhoneSignFixtures.url("hello-arm64"), in: directory, style: .appleAdHoc+ )for slice in try VPhoneSignBlobs(fileAt: file).slices {let directoryBlob = try #require(slice[0])@@ -51,7 +50,7 @@ struct VPhoneSignStyleTests {@Test("a file that is not a Mach-O is refused")func refusesSomethingElse() throws {- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let file = directory.appendingPathComponent("script.sh")try Data("#!/bin/sh\necho hello\n".utf8).write(to: file)@@ -64,8 +63,7 @@ struct VPhoneSignStyleTests {@Test("a truncated Mach-O is refused rather than signed over garbage")func refusesATruncatedMachO() throws {- let source = try #require(VPhoneSignLdidHarness.corpus.first { $0.path.hasPrefix("/bin") })- let whole = try Data(contentsOf: source)+ let whole = try Data(contentsOf: VPhoneSignFixtures.url("hello-arm64"))#expect(throws: VPhoneSignError.self) {_ = try VPhoneSigner.sign(whole.prefix(whole.count / 3), options: .init(identifier: "x"))}@@ -83,14 +81,32 @@ struct VPhoneSignStyleTests {}}+ /// `VPhoneMachOImage.armCPUTypes` is ARM only, deliberately: page size,+ /// the `__LINKEDIT` alignment and the deployment-target load commands all+ /// differ on x86, and nothing here exercises any of it. Signing such a+ /// slice on a guess is worse than saying so — and this is the rule that+ /// took the old corpus of fat system binaries out of this suite, so it is+ /// worth one test of its own.+ @Test("an x86_64 slice is refused rather than signed on a guess")+ func refusesAnX86Slice() throws {+ // MH_MAGIC_64, CPU_TYPE_X86_64, CPU_SUBTYPE_X86_64_ALL, MH_EXECUTE,+ // then ncmds/sizeofcmds/flags/reserved, all zero+ var header = Data()+ for word: UInt32 in [0xFEED_FACF, 0x0100_0007, 0x0000_0003, 0x0000_0002, 0, 0, 0, 0] {+ withUnsafeBytes(of: word.littleEndian) { header.append(contentsOf: $0) }+ }+ #expect(throws: VPhoneSignError.self) {+ _ = try VPhoneSigner.sign(header, options: .init(identifier: "x"))+ }+ }+/// `sign(_:options:)` takes any `Data`, and a slice of one keeps its/// parent's indices. Every offset in the signer counts from the start of/// the file, so a slice that starts anywhere else has to be handled/// before the first byte is read.@Test("a Data slice that does not start at zero signs the same as a copy")func signsANonZeroBasedSlice() throws {- let source = try #require(VPhoneSignLdidHarness.corpus.first)- let whole = try Data(contentsOf: source)+ let whole = try Data(contentsOf: VPhoneSignFixtures.url("hello-arm64"))let padded = Data(count: 7) + wholelet slice = padded[7...]#expect(slice.startIndex == 7, "the slice was rebased, so this proves nothing")@@ -104,10 +120,13 @@ struct VPhoneSignStyleTests {/// pipeline signs those in place.@Test("a read-only file is signed and keeps its mode")func signsAReadOnlyFile() throws {- let source = try #require(VPhoneSignLdidHarness.corpus.first)- let directory = try VPhoneSignLdidHarness.temporaryDirectory()+ let directory = try VPhoneSignFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let file = try VPhoneSignLdidHarness.copy(source, into: directory, as: "binary")+ // not through the shared helper: the mode has to be set between the+ // copy and the signature+ let file = try VPhoneSignFixtures.copy(+ try VPhoneSignFixtures.url("hello-arm64"), into: directory, as: "binary"+ )try FileManager.default.setAttributes([.posixPermissions: 0o444], ofItemAtPath: file.path)try VPhoneSigner.sign(fileAt: file, options: .init(identifier: "binary"))