]> git.saurik.com Git - apple/libsecurity_codesigning.git/blame - lib/SecCodeSigner.cpp
libsecurity_codesigning-32953.tar.gz
[apple/libsecurity_codesigning.git] / lib / SecCodeSigner.cpp
CommitLineData
7d31e928
A
1/*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24//
25// SecCode - API frame for SecCode objects.
26//
27// Note that some SecCode* functions take SecStaticCodeRef arguments in order to
28// accept either static or dynamic code references, operating on the respective
29// StaticCode. Those functions are in SecStaticCode.cpp, not here, despite their name.
30//
31#include "cs.h"
32#include "CodeSigner.h"
33#include "cskernel.h"
34
35using namespace CodeSigning;
36
37
38//
39// Parameter keys
40//
41const CFStringRef kSecCodeSignerApplicationData = CFSTR("application-specific");
42const CFStringRef kSecCodeSignerDetached = CFSTR("detached");
43const CFStringRef kSecCodeSignerDryRun = CFSTR("dryrun");
44const CFStringRef kSecCodeSignerFlags = CFSTR("flags");
45const CFStringRef kSecCodeSignerIdentifier = CFSTR("identifier");
46const CFStringRef kSecCodeSignerIdentifierPrefix = CFSTR("identifier-prefix");
47const CFStringRef kSecCodeSignerIdentity = CFSTR("signer");
48const CFStringRef kSecCodeSignerPageSize = CFSTR("pagesize");
49const CFStringRef kSecCodeSignerRequirements = CFSTR("requirements");
50const CFStringRef kSecCodeSignerResourceRules = CFSTR("resource-rules");
51const CFStringRef kSecCodeSignerSigningTime = CFSTR("signing-time");
52
53
54//
55// CF-standard type code functions
56//
57CFTypeID SecCodeSignerGetTypeID(void)
58{
59 BEGIN_CSAPI
60 return gCFObjects().CodeSigner.typeID;
61 END_CSAPI1(_kCFRuntimeNotATypeID)
62}
63
64
65//
66// Create a signer object
67//
68OSStatus SecCodeSignerCreate(CFDictionaryRef parameters, SecCSFlags flags,
69 SecCodeSignerRef *signerRef)
70{
71 BEGIN_CSAPI
72 SecPointer<SecCodeSigner> signer = new SecCodeSigner;
73 signer->parameters(parameters);
74 Required(signerRef) = signer->handle();
75 END_CSAPI
76}
77
78
79//
80// Generate a signature
81//
82OSStatus SecCodeSignerAddSignature(SecCodeSignerRef signerRef,
83 SecStaticCodeRef codeRef, SecCSFlags flags)
84{
85 return SecCodeSignerAddSignatureWithErrors(signerRef, codeRef, flags, NULL);
86}
87
88OSStatus SecCodeSignerAddSignatureWithErrors(SecCodeSignerRef signerRef,
89 SecStaticCodeRef codeRef, SecCSFlags flags, CFErrorRef *errors)
90{
91 BEGIN_CSAPI
92 SecCodeSigner::required(signerRef)->sign(SecStaticCode::required(codeRef), flags);
93 END_CSAPI_ERRORS
94}