2 * Copyright (c) 2004,2011-2012,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@
25 @header SecCmsSignerInfo.h
26 @Copyright (c) 2004,2011-2012,2014 Apple Inc. All Rights Reserved.
28 @availability 10.4 and later
29 @abstract Interfaces of the CMS implementation.
30 @discussion The functions here implement functions for encoding
31 and decoding Cryptographic Message Syntax (CMS) objects
32 as described in rfc3369.
35 #ifndef _SECURITY_SECCMSSIGNERINFO_H_
36 #define _SECURITY_SECCMSSIGNERINFO_H_ 1
38 #include <Security/SecCmsBase.h>
40 #include <Security/SecTrust.h>
41 #include <CoreFoundation/CFDate.h>
44 #if defined(__cplusplus)
51 extern SecCmsSignerInfoRef
52 SecCmsSignerInfoCreate(SecCmsMessageRef cmsg
, SecIdentityRef identity
, SECOidTag digestalgtag
);
57 extern SecCmsSignerInfoRef
58 SecCmsSignerInfoCreateWithSubjKeyID(SecCmsMessageRef cmsg
, CSSM_DATA_PTR subjKeyID
, SecPublicKeyRef pubKey
, SecPrivateKeyRef signingKey
, SECOidTag digestalgtag
);
62 @abstract Destroy a SignerInfo data structure.
65 SecCmsSignerInfoDestroy(SecCmsSignerInfoRef si
);
70 extern SecCmsVerificationStatus
71 SecCmsSignerInfoGetVerificationStatus(SecCmsSignerInfoRef signerinfo
);
77 SecCmsSignerInfoVerifyUnAuthAttrs(SecCmsSignerInfoRef signerinfo
);
83 SecCmsSignerInfoVerifyUnAuthAttrsWithPolicy(SecCmsSignerInfoRef signerinfo
,CFTypeRef timeStampPolicy
);
89 SecCmsSignerInfoGetEncDigest(SecCmsSignerInfoRef signerinfo
);
95 SecCmsSignerInfoGetDigestAlg(SecCmsSignerInfoRef signerinfo
);
101 SecCmsSignerInfoGetDigestAlgTag(SecCmsSignerInfoRef signerinfo
);
107 SecCmsSignerInfoGetCertList(SecCmsSignerInfoRef signerinfo
);
113 SecCmsSignerInfoGetTimestampCertList(SecCmsSignerInfoRef signerinfo
);
118 extern SecCertificateRef
119 SecCmsSignerInfoGetTimestampSigningCert(SecCmsSignerInfoRef signerinfo
);
123 @abstract Return the signing time, in UTCTime format, of a CMS signerInfo.
124 @param sinfo SignerInfo data for this signer.
125 @discussion Returns a pointer to XXXX (what?)
126 @result A return value of NULL is an error.
129 SecCmsSignerInfoGetSigningTime(SecCmsSignerInfoRef sinfo
, CFAbsoluteTime
*stime
);
133 @abstract Return the timestamp time, in UTCTime format, of a CMS signerInfo.
134 @param sinfo SignerInfo data for this signer.
135 @discussion Returns a pointer to XXXX (what?)
136 @result A return value of NULL is an error.
139 SecCmsSignerInfoGetTimestampTime(SecCmsSignerInfoRef sinfo
, CFAbsoluteTime
*stime
);
143 @abstract Return the timestamp time, in UTCTime format, of a CMS signerInfo.
144 @param sinfo SignerInfo data for this signer, timeStampPolicy the policy to verify the timestamp signer
145 @discussion Returns a pointer to XXXX (what?)
146 @result A return value of NULL is an error.
149 SecCmsSignerInfoGetTimestampTimeWithPolicy(SecCmsSignerInfoRef sinfo
, CFTypeRef timeStampPolicy
, CFAbsoluteTime
*stime
);
153 @abstract Return the data in the signed Codesigning Hash Agility attribute.
154 @param sinfo SignerInfo data for this signer, pointer to a CFDataRef for attribute value
155 @discussion Returns a CFDataRef containing the value of the attribute
156 @result A return value of SECFailure is an error.
159 SecCmsSignerInfoGetAppleCodesigningHashAgility(SecCmsSignerInfoRef sinfo
, CFDataRef
*sdata
);
163 @abstract Return the data in the signed Codesigning Hash Agility V2 attribute.
164 @param sinfo SignerInfo data for this signer, pointer to a CFDictionaryRef for attribute values
165 @discussion Returns a CFDictionaryRef containing the values of the attribute. V2 encodes the hash
166 agility values using DER.
167 @result A return value of SECFailure is an error.
170 SecCmsSignerInfoGetAppleCodesigningHashAgilityV2(SecCmsSignerInfoRef sinfo
, CFDictionaryRef
*sdict
);
174 @abstract Return the signing cert of a CMS signerInfo.
175 @discussion The certs in the enclosing SignedData must have been imported already.
177 extern SecCertificateRef
178 SecCmsSignerInfoGetSigningCertificate(SecCmsSignerInfoRef signerinfo
, SecKeychainRef keychainOrArray
);
182 @abstract Return the common name of the signer.
183 @param sinfo SignerInfo data for this signer.
184 @discussion Returns a CFStringRef containing the common name of the signer.
185 @result A return value of NULL is an error.
188 SecCmsSignerInfoGetSignerCommonName(SecCmsSignerInfoRef sinfo
);
192 @abstract Return the email address of the signer
193 @param sinfo SignerInfo data for this signer.
194 @discussion Returns a CFStringRef containing the name of the signer.
195 @result A return value of NULL is an error.
198 SecCmsSignerInfoGetSignerEmailAddress(SecCmsSignerInfoRef sinfo
);
202 @abstract Add the signing time to the authenticated (i.e. signed) attributes of "signerinfo".
203 @discussion This is expected to be included in outgoing signed
204 messages for email (S/MIME) but is likely useful in other situations.
206 This should only be added once; a second call will do nothing.
208 XXX This will probably just shove the current time into "signerinfo"
209 but it will not actually get signed until the entire item is
210 processed for encoding. Is this (expected to be small) delay okay?
213 SecCmsSignerInfoAddSigningTime(SecCmsSignerInfoRef signerinfo
, CFAbsoluteTime t
);
217 @abstract Add a SMIMECapabilities attribute to the authenticated (i.e. signed) attributes of "signerinfo".
218 @discussion This is expected to be included in outgoing signed messages for email (S/MIME).
221 SecCmsSignerInfoAddSMIMECaps(SecCmsSignerInfoRef signerinfo
);
225 @abstract Add a SMIMEEncryptionKeyPreferences attribute to the authenticated (i.e. signed) attributes of "signerinfo".
226 @discussion This is expected to be included in outgoing signed messages for email (S/MIME).
229 SecCmsSignerInfoAddSMIMEEncKeyPrefs(SecCmsSignerInfoRef signerinfo
, SecCertificateRef cert
, SecKeychainRef keychainOrArray
);
233 @abstract Add a SMIMEEncryptionKeyPreferences attribute to the authenticated (i.e. signed) attributes of "signerinfo", using the OID prefered by Microsoft.
234 @discussion This is expected to be included in outgoing signed messages for email (S/MIME), if compatibility with Microsoft mail clients is wanted.
237 SecCmsSignerInfoAddMSSMIMEEncKeyPrefs(SecCmsSignerInfoRef signerinfo
, SecCertificateRef cert
, SecKeychainRef keychainOrArray
);
241 @abstract Create a timestamp unsigned attribute with a TimeStampToken.
244 SecCmsSignerInfoAddTimeStamp(SecCmsSignerInfoRef signerinfo
, CSSM_DATA
*tstoken
);
248 @abstract Countersign a signerinfo.
251 SecCmsSignerInfoAddCounterSignature(SecCmsSignerInfoRef signerinfo
,
252 SECOidTag digestalg
, SecIdentityRef identity
);
256 @abstract Add the Apple Codesigning Hash Agility attribute to the authenticated (i.e. signed) attributes of "signerinfo".
257 @discussion This is expected to be included in outgoing Apple code signatures.
260 SecCmsSignerInfoAddAppleCodesigningHashAgility(SecCmsSignerInfoRef signerinfo
, CFDataRef attrValue
);
264 @abstract Add the Apple Codesigning Hash Agility V2 attribute to the authenticated (i.e. signed) attributes of "signerinfo".
265 @discussion This is expected to be included in outgoing Apple code signatures. V2 encodes the hash agility values using DER.
266 The dictionary should have CFNumberRef keys, corresponding to SECOidTags for digest algorithms, and CFDataRef values,
267 corresponding to the digest value for that digest algorithm.
270 SecCmsSignerInfoAddAppleCodesigningHashAgilityV2(SecCmsSignerInfoRef signerinfo
, CFDictionaryRef attrValues
);
274 @abstract The following needs to be done in the S/MIME layer code after signature of a signerinfo has been verified.
275 @param signerinfo The SecCmsSignerInfo object for which we verified the signature.
276 @result The preferred encryption certificate of the user who signed this message will be added to the users default Keychain and it will be marked as the preferred certificate to use when sending that person messages from now on.
279 SecCmsSignerInfoSaveSMIMEProfile(SecCmsSignerInfoRef signerinfo
);
283 @abstract Set cert chain inclusion mode for this signer.
286 SecCmsSignerInfoIncludeCerts(SecCmsSignerInfoRef signerinfo
, SecCmsCertChainMode cm
, SECCertUsage usage
);
288 /*! @functiongroup CMS misc utility functions */
291 Convert a SecCmsVerificationStatus to a human readable string.
294 SecCmsUtilVerificationStatusToString(SecCmsVerificationStatus vs
);
297 * Preference domain and key for the Microsoft ECDSA compatibility flag.
298 * Default if not present is TRUE, meaning we generate ECDSA-signed messages
299 * which are compatible with Microsoft Entourage. FALSE means we adhere to
300 * the spec (RFC 3278 section 2.1.1).
302 #define kMSCompatibilityDomain "com.apple.security.smime"
303 #define kMSCompatibilityMode CFSTR("MSCompatibilityMode")
306 @function SecCmsSignerInfoCopyCertFromEncryptionKeyPreference
307 @abstract Copy the certificate specified in the encryption key preference.
308 @param signerinfo The SecCmsSignerInfo object for which we verified the signature.
309 @result The preferred encryption certificate of the user who signed this message, if found.
310 @discussion This function should be called after the signer info has been verified.
312 SecCertificateRef
SecCmsSignerInfoCopyCertFromEncryptionKeyPreference(SecCmsSignerInfoRef signerinfo
);
314 #if defined(__cplusplus)
318 #endif /* _SECURITY_SECCMSSIGNERINFO_H_ */