- if (dylib(name)) {
- Slots slots;
- Sign(data, hash, save, identifier, "", key, slots);
- } else {
- HashProxy proxy(hash, save);
- copy(data, proxy);
- }
+ union {
+ struct {
+ uint32_t magic;
+ uint32_t count;
+ };
+
+ uint8_t bytes[8];
+ } header;
+
+ auto size(most(data, &header.bytes, sizeof(header.bytes)));
+ if (size == sizeof(header.bytes))
+ switch (Swap(header.magic)) {
+ case FAT_MAGIC:
+ // Java class file format
+ if (Swap(header.count) >= 40)
+ break;
+ case FAT_CIGAM:
+ case MH_MAGIC: case MH_MAGIC_64:
+ case MH_CIGAM: case MH_CIGAM_64:
+ Slots slots;
+ Sign(header.bytes, size, data, hash, save, identifier, "", key, slots);
+ return;
+ }
+
+ HashProxy proxy(hash, save);
+ put(proxy, header.bytes, size);
+ copy(data, proxy);