}
};
-void resign(void *idata, size_t isize, std::streambuf &output, const std::string &name, const std::string &entitlements, const std::string &key) {
+typedef std::map<uint32_t, std::string> Slots;
+
+void resign(void *idata, size_t isize, std::streambuf &output, const std::string &name, const std::string &entitlements, const std::string &key, const Slots &slots) {
resign(idata, isize, output, fun([&](size_t size) -> size_t {
size_t alloc(sizeof(struct SuperBlob));
alloc += 0x3000;
}
+ _foreach (slot, slots)
+ special = std::max(special, slot.first);
+
uint32_t normal((size + PageSize_ - 1) / PageSize_);
alloc = Align(alloc + (special + normal) * SHA_DIGEST_LENGTH, 16);
return alloc;
uint32_t special(0);
_foreach (blob, blobs)
special = std::max(special, blob.first);
+ _foreach (slot, slots)
+ special = std::max(special, slot.first);
uint32_t normal((limit + PageSize_ - 1) / PageSize_);
CodeDirectory directory;
sha1((uint8_t *) (hashes - blob.first), local, Swap(local->length));
}
+ _foreach (slot, slots) {
+ _assert(sizeof(*hashes) == slot.second.size());
+ memcpy(hashes - slot.first, slot.second.data(), slot.second.size());
+ }
+
if (normal != 1)
for (size_t i = 0; i != normal - 1; ++i)
sha1(hashes[i], (PageSize_ * i < overlap.size() ? overlap.data() : top) + PageSize_ * i, PageSize_);
Map entitlements;
Map key;
+ Slots slots;
std::vector<std::string> files;
case 'e': flag_e = true; break;
+ case 'E': {
+ const char *slot = argv[argi] + 2;
+ const char *colon = strchr(slot, ':');
+ _assert(colon != NULL);
+ Map file(colon + 1, O_RDONLY, PROT_READ, MAP_PRIVATE);
+ char *arge;
+ unsigned number(strtoul(slot, &arge, 0));
+ _assert(arge == colon);
+ std::string &hash(slots[number]);
+ hash.resize(SHA_DIGEST_LENGTH);
+ sha1(reinterpret_cast<uint8_t *>(&hash[0]), file.data(), file.size());
+ } break;
+
case 'D': flag_D = true; break;
case 'a': flag_a = true; break;
if (flag_r)
resign(input.data(), input.size(), output);
- else {
- resign(input.data(), input.size(), output, name, entitlements, key);
- }
+ else
+ resign(input.data(), input.size(), output, name, entitlements, key, slots);
}
Map mapping(!temp.empty() ? temp.c_str() : path, flag_T || flag_s);