#include "detachedrep.h"
namespace Security {
namespace CodeSigning {
DetachedRep::DetachedRep(CFDataRef sig, DiskRep *orig, const std::string &source)
: FilterRep(orig), mSig(sig), mSource(source)
{
const BlobCore *sigBlob = reinterpret_cast<const BlobCore *>(CFDataGetBytePtr(sig));
if (sigBlob->is<EmbeddedSignatureBlob>()) { if ((mArch = EmbeddedSignatureBlob::specific(sigBlob))) {
mGlobal = NULL;
CODESIGN_DISKREP_CREATE_DETACHED(this, orig, (char*)source.c_str(), NULL);
return;
}
} else if (sigBlob->is<DetachedSignatureBlob>()) if (const DetachedSignatureBlob *dsblob = DetachedSignatureBlob::specific(sigBlob))
if (Universal *fat = orig->mainExecutableImage())
if (const BlobCore *blob = dsblob->find(fat->bestNativeArch().cpuType()))
if ((mArch = EmbeddedSignatureBlob::specific(blob)))
if ((mGlobal = EmbeddedSignatureBlob::specific(dsblob->find(0)))) {
CODESIGN_DISKREP_CREATE_DETACHED(this, orig, (char*)source.c_str(), (void*)mGlobal);
return;
}
MacOSError::throwMe(errSecCSSignatureInvalid);
}
DetachedRep::DetachedRep(CFDataRef sig, CFDataRef gsig, DiskRep *orig, const std::string &source)
: FilterRep(orig), mSig(sig), mGSig(gsig), mSource(source)
{
const BlobCore *sigBlob = reinterpret_cast<const BlobCore *>(CFDataGetBytePtr(sig));
mArch = EmbeddedSignatureBlob::specific(sigBlob);
if (!mArch)
MacOSError::throwMe(errSecCSSignatureInvalid);
if (gsig) {
const BlobCore *gsigBlob = reinterpret_cast<const BlobCore *>(CFDataGetBytePtr(gsig));
mGlobal = EmbeddedSignatureBlob::specific(gsigBlob);
if (!mGlobal)
MacOSError::throwMe(errSecCSSignatureInvalid);
} else
mGlobal = NULL;
CODESIGN_DISKREP_CREATE_DETACHED(this, orig, (char*)source.c_str(), (void*)mGlobal);
}
CFDataRef DetachedRep::component(CodeDirectory::SpecialSlot slot)
{
if (CFDataRef result = mArch->component(slot))
return result;
if (mGlobal)
if (CFDataRef result = mGlobal->component(slot))
return result;
return this->base()->component(slot);
}
} }