+++ /dev/null
-/*
- * Copyright (c) 2007 Apple Inc. All Rights Reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- */
-
-//
-// cfmdiskrep - single-file CFM (PEF) executable disk representation
-//
-#ifndef _H_CFMDISKREP
-#define _H_CFMDISKREP
-
-#include "singlediskrep.h"
-#include "sigblob.h"
-#include "signerutils.h"
-#include <security_utilities/unix++.h>
-#include <security_utilities/cfutilities.h>
-
-namespace Security {
-namespace CodeSigning {
-
-
-//
-// A CFMDiskRep represents a single code file on disk containing a CFM (PEF)
-// binary. It is considered self-contained, and does not depend on any other
-// files in the system (even if it may be part of a larger bundle etc.)
-//
-// CFM is considered a legacy format that is not generated by Apple, but still
-// supported for backward compatibility. This DiskRep supports writing signing
-// data into the executable, using a simple back-of-file frame. It does not
-// support embedded Info.plists or any other fancy stuff.
-//
-// This DiskRep does not support resource sealing.
-//
-class CFMDiskRep : public SingleDiskRep {
-public:
- CFMDiskRep(const char *path);
- ~CFMDiskRep();
-
- CFDataRef component(CodeDirectory::SpecialSlot slot);
- size_t signingLimit();
- std::string format();
- void flush();
-
- const Requirements *defaultRequirements(const Architecture *arch, const SigningContext &ctx);
- size_t pageSize(const SigningContext &ctx);
-
- static bool candidate(UnixPlusPlus::FileDesc &fd); // could this reasonably be a CFM code?
-
-public:
- //
- // Signing sticks this structure at the very end of the file
- //
- struct Sentinel {
- Endian<uint32_t> magic; // EmbeddedSignatureBlob::magic()
- Endian<uint32_t> offset; // file absolute offset of EmbeddedSignatureBlob
- };
-
-public:
- DiskRep::Writer *writer();
- class Writer;
- friend class Writer;
-
-protected:
- void readSigningData(); // read and cache signing data
-
-private:
- bool mTriedRead; // tried to get signing data
- size_t mSigningOffset; // where we found the signing data
- EmbeddedSignatureBlob *mSigningData; // cached signing data
-};
-
-
-//
-// The write side of a FileDiskRep
-//
-class CFMDiskRep::Writer : public DiskRep::Writer, private EmbeddedSignatureBlob::Maker {
- friend class CFMDiskRep;
-public:
- Writer(CFMDiskRep *r) : rep(r), mSigningData(NULL) { }
- ~Writer();
-
- void component(CodeDirectory::SpecialSlot slot, CFDataRef data);
- virtual void flush();
-
-protected:
- RefPointer<CFMDiskRep> rep;
- EmbeddedSignatureBlob *mSigningData;
-};
-
-
-} // end namespace CodeSigning
-} // end namespace Security
-
-#endif // !_H_CFMDISKREP