X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/5c19dc3ae3bd8e40a9c028b0deddd50ff337692c..bf028f67fd3bb2266df81b80fb6f25a77112e308:/OSX/libsecurity_codesigning/lib/sigblob.cpp diff --git a/OSX/libsecurity_codesigning/lib/sigblob.cpp b/OSX/libsecurity_codesigning/lib/sigblob.cpp index 619986a1..ecac7081 100644 --- a/OSX/libsecurity_codesigning/lib/sigblob.cpp +++ b/OSX/libsecurity_codesigning/lib/sigblob.cpp @@ -34,17 +34,24 @@ namespace CodeSigning { CFDataRef EmbeddedSignatureBlob::component(CodeDirectory::SpecialSlot slot) const { - if (const BlobCore *blob = this->find(slot)) { - if (CodeDirectory::slotAttributes(slot) & cdComponentIsBlob) { - return makeCFData(*blob); // is a native Blob - } else if (const BlobWrapper *wrap = BlobWrapper::specific(blob)) { - return makeCFData(*wrap); - } else { - MacOSError::throwMe(errSecCSSignatureInvalid); - } + const BlobCore *blob = this->find(slot); + + if (blob) { + return blobData(slot, blob); } return NULL; } + +CFDataRef EmbeddedSignatureBlob::blobData(CodeDirectory::SpecialSlot slot, BlobCore const *blob) +{ + if (CodeDirectory::slotAttributes(slot) & cdComponentIsBlob) { + return makeCFData(*blob); // is a native Blob + } else if (const BlobWrapper *wrap = BlobWrapper::specific(blob)) { + return makeCFData(*wrap); + } else { + MacOSError::throwMe(errSecCSSignatureInvalid); + } +} void EmbeddedSignatureBlob::Maker::component(CodeDirectory::SpecialSlot slot, CFDataRef data) @@ -62,6 +69,21 @@ CFDictionaryRef EntitlementBlob::entitlements() const this->length() - sizeof(EntitlementBlob)); } +EntitlementDERBlob *EntitlementDERBlob::alloc(size_t length) { + size_t blobLength = length + sizeof(BlobCore); + if (blobLength < length) { + // overflow + return NULL; + } + + EntitlementDERBlob *b = (EntitlementDERBlob *)malloc(blobLength); + + if (b != NULL) { + b->BlobCore::initialize(kSecCodeMagicEntitlementDER, blobLength); + } + + return b; +} } // end namespace CodeSigning } // end namespace Security