2 * Copyright (c) 2000-2004,2006,2011,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 // acl_codesigning - ACL subject for signature of calling application
29 // Once upon a time, a code signature was a single binary blob, a "signature".
30 // Then we added an optional second blob, a "comment". The comment was only
31 // ancilliary (non-security) data first, but then we added more security data
32 // to it later. Now, the security-relevant data is kept in a (signature, comment)
33 // pair, all of which is relevant for the security of such subjects.
34 // Don't read any particular semantics into this separation. It is historical only
35 // (having to do with backward binary compatibility of ACL blobs).
37 #ifndef _H_ACL_CODESIGNING
38 #define _H_ACL_CODESIGNING
40 #include <security_cdsa_utilities/cssmdata.h>
41 #include <security_cdsa_utilities/cssmacl.h>
42 #include <security_cdsa_utilities/osxverifier.h>
48 // The CodeSignature subject type matches a code signature applied to the
49 // disk image that originated the client process.
51 class CodeSignatureAclSubject
: public AclSubject
, public OSXVerifier
{
53 class Maker
; friend class Maker
;
55 static const size_t commentBagAlignment
= 4;
57 CodeSignatureAclSubject(const SHA1::Byte
*hash
, const std::string
&path
)
58 : AclSubject(CSSM_ACL_SUBJECT_TYPE_CODE_SIGNATURE
), OSXVerifier(hash
, path
) { }
60 CodeSignatureAclSubject(const OSXVerifier
&verifier
)
61 : AclSubject(CSSM_ACL_SUBJECT_TYPE_CODE_SIGNATURE
), OSXVerifier(verifier
) { }
63 bool validates(const AclValidationContext
&baseCtx
) const;
64 CssmList
toList(Allocator
&alloc
) const;
66 void exportBlob(Writer::Counter
&pub
, Writer::Counter
&priv
);
67 void exportBlob(Writer
&pub
, Writer
&priv
);
69 IFDUMP(void debugDump() const);
72 class Environment
: public virtual AclValidationEnvironment
{
74 virtual bool verifyCodeSignature(const OSXVerifier
&verifier
,
75 const AclValidationContext
&context
) = 0;
79 class Maker
: public AclSubject::Maker
{
82 : AclSubject::Maker(CSSM_ACL_SUBJECT_TYPE_CODE_SIGNATURE
) { }
83 CodeSignatureAclSubject
*make(const TypedList
&list
) const;
84 CodeSignatureAclSubject
*make(Version version
, Reader
&pub
, Reader
&priv
) const;
87 CodeSignatureAclSubject
*make(const SHA1::Byte
*hash
, const CssmData
&commentBag
) const;
91 } // end namespace Security
95 #endif //_H_ACL_CODESIGNING