2 * Copyright (c) 2004,2008,2010-2011 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 @Copyright (c) 2004,2008,2010-2011 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_SECCMSBASE_H_
36 #define _SECURITY_SECCMSBASE_H_ 1
38 #include <Security/SecBase.h>
39 #include <Security/SecKey.h>
40 #include <Security/SecAsn1Types.h>
42 #if !SEC_OS_OSX_INCLUDES
43 typedef CFTypeRef SecKeychainRef
;
44 #endif // ! SEC_OS_OSX_INCLUDES
46 #if defined(__cplusplus)
52 @discussion XXX We need to remove these from the API and move them back to secoidt.h.
54 typedef struct SECOidDataStr SECOidData
;
58 @discussion XXX We might want to get rid of this alltogether.
60 typedef SecAsn1AlgId SECAlgorithmID
;
64 @discussion XXX This should probably move to SecKey.h
66 typedef void * SecSymmetricKeyRef
;
70 @discussion XXX This should probably move to SecKey.h
72 typedef SecKeyRef SecPublicKeyRef
;
76 @discussion XXX This should probably move to SecKey.h
78 typedef SecKeyRef SecPrivateKeyRef
;
83 typedef void(*PK11PasswordFunc
)(void);
88 typedef struct SecCmsMessageStr
*SecCmsMessageRef
;
93 typedef struct SecCmsContentInfoStr
*SecCmsContentInfoRef
;
98 typedef struct SecCmsSignedDataStr
*SecCmsSignedDataRef
;
103 typedef struct SecCmsSignerInfoStr
*SecCmsSignerInfoRef
;
108 typedef struct SecCmsEnvelopedDataStr
*SecCmsEnvelopedDataRef
;
113 typedef struct SecCmsRecipientInfoStr
*SecCmsRecipientInfoRef
;
118 typedef struct SecCmsDigestedDataStr
*SecCmsDigestedDataRef
;
123 typedef struct SecCmsEncryptedDataStr
*SecCmsEncryptedDataRef
;
128 typedef struct SecCmsDecoderStr
*SecCmsDecoderRef
;
133 typedef struct SecCmsEncoderStr
*SecCmsEncoderRef
;
138 typedef struct SecCmsDigestContextStr
*SecCmsDigestContextRef
;
143 @discussion Type of function passed to SecCmsDecode or SecCmsDecoderStart.
144 If specified, this is where the content bytes (only) will be "sent" as they are recovered during the decoding.
146 Type of function passed to SecCmsEncode or SecCmsEncoderStart.
147 This is where the DER-encoded bytes will be "sent".
149 XXX Should just combine this with SecCmsEncoderContentCallback type and use a simpler, common name.
151 typedef void (*SecCmsContentCallback
)(void *arg
, const char *buf
, size_t len
);
155 @discussion Type of function passed to SecCmsDecode or SecCmsDecoderStart to retrieve the decryption key. This function is intended to be used for EncryptedData content info's which do not have a key available in a certificate, etc.
157 typedef SecSymmetricKeyRef(*SecCmsGetDecryptKeyCallback
)(void *arg
, SECAlgorithmID
*algid
);
160 @enum SecCmsVerificationStatus
163 SecCmsVSUnverified
= 0,
164 SecCmsVSGoodSignature
= 1,
165 SecCmsVSBadSignature
= 2,
166 SecCmsVSDigestMismatch
= 3,
167 SecCmsVSSigningCertNotFound
= 4,
168 SecCmsVSSigningCertNotTrusted
= 5,
169 SecCmsVSSignatureAlgorithmUnknown
= 6,
170 SecCmsVSSignatureAlgorithmUnsupported
= 7,
171 SecCmsVSMalformedSignature
= 8,
172 SecCmsVSProcessingError
= 9
173 } SecCmsVerificationStatus
;
176 @enum SecCmsCertChainMode
180 SecCmsCMCertOnly
= 1,
181 SecCmsCMCertChain
= 2,
182 SecCmsCMCertChainWithRoot
= 3
183 } SecCmsCertChainMode
;
187 @discussion XXX This should be replaced with SecPolicyRefs
189 typedef enum SECCertUsageEnum
{
190 certUsageSSLClient
= 0,
191 certUsageSSLServer
= 1,
192 certUsageSSLServerWithStepUp
= 2,
194 certUsageEmailSigner
= 4,
195 certUsageEmailRecipient
= 5,
196 certUsageObjectSigner
= 6,
197 certUsageUserCertImport
= 7,
198 certUsageVerifyCA
= 8,
199 certUsageProtectedObjectSigner
= 9,
200 certUsageStatusResponder
= 10,
207 @abstract Misc object IDs - these numbers are for convenient handling.
208 @discussion They are mapped into real object IDs
209 NOTE: the order of these entries must mach the array "oids" of SECOidData in util/secoid.c.
219 SEC_OID_DES_EDE3_CBC
= 7,
220 SEC_OID_RC5_CBC_PAD
= 8,
222 SEC_OID_DES_CBC
= 10,
223 SEC_OID_DES_OFB
= 11,
224 SEC_OID_DES_CFB
= 12,
225 SEC_OID_DES_MAC
= 13,
226 SEC_OID_DES_EDE
= 14,
227 SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE
= 15,
228 SEC_OID_PKCS1_RSA_ENCRYPTION
= 16,
229 SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION
= 17,
230 SEC_OID_PKCS1_MD4_WITH_RSA_ENCRYPTION
= 18,
231 SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION
= 19,
232 SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION
= 20,
233 SEC_OID_PKCS5_PBE_WITH_MD2_AND_DES_CBC
= 21,
234 SEC_OID_PKCS5_PBE_WITH_MD5_AND_DES_CBC
= 22,
235 SEC_OID_PKCS5_PBE_WITH_SHA1_AND_DES_CBC
= 23,
237 SEC_OID_PKCS7_DATA
= 25,
238 SEC_OID_PKCS7_SIGNED_DATA
= 26,
239 SEC_OID_PKCS7_ENVELOPED_DATA
= 27,
240 SEC_OID_PKCS7_SIGNED_ENVELOPED_DATA
= 28,
241 SEC_OID_PKCS7_DIGESTED_DATA
= 29,
242 SEC_OID_PKCS7_ENCRYPTED_DATA
= 30,
243 SEC_OID_PKCS9_EMAIL_ADDRESS
= 31,
244 SEC_OID_PKCS9_UNSTRUCTURED_NAME
= 32,
245 SEC_OID_PKCS9_CONTENT_TYPE
= 33,
246 SEC_OID_PKCS9_MESSAGE_DIGEST
= 34,
247 SEC_OID_PKCS9_SIGNING_TIME
= 35,
248 SEC_OID_PKCS9_COUNTER_SIGNATURE
= 36,
249 SEC_OID_PKCS9_CHALLENGE_PASSWORD
= 37,
250 SEC_OID_PKCS9_UNSTRUCTURED_ADDRESS
= 38,
251 SEC_OID_PKCS9_EXTENDED_CERTIFICATE_ATTRIBUTES
= 39,
252 SEC_OID_PKCS9_SMIME_CAPABILITIES
= 40,
253 SEC_OID_AVA_COMMON_NAME
= 41,
254 SEC_OID_AVA_COUNTRY_NAME
= 42,
255 SEC_OID_AVA_LOCALITY
= 43,
256 SEC_OID_AVA_STATE_OR_PROVINCE
= 44,
257 SEC_OID_AVA_ORGANIZATION_NAME
= 45,
258 SEC_OID_AVA_ORGANIZATIONAL_UNIT_NAME
= 46,
259 SEC_OID_AVA_DN_QUALIFIER
= 47,
262 SEC_OID_NS_TYPE_GIF
= 49,
263 SEC_OID_NS_TYPE_JPEG
= 50,
264 SEC_OID_NS_TYPE_URL
= 51,
265 SEC_OID_NS_TYPE_HTML
= 52,
266 SEC_OID_NS_TYPE_CERT_SEQUENCE
= 53,
267 SEC_OID_MISSI_KEA_DSS_OLD
= 54,
268 SEC_OID_MISSI_DSS_OLD
= 55,
269 SEC_OID_MISSI_KEA_DSS
= 56,
270 SEC_OID_MISSI_DSS
= 57,
271 SEC_OID_MISSI_KEA
= 58,
272 SEC_OID_MISSI_ALT_KEA
= 59,
274 /* Netscape private certificate extensions */
275 SEC_OID_NS_CERT_EXT_NETSCAPE_OK
= 60,
276 SEC_OID_NS_CERT_EXT_ISSUER_LOGO
= 61,
277 SEC_OID_NS_CERT_EXT_SUBJECT_LOGO
= 62,
278 SEC_OID_NS_CERT_EXT_CERT_TYPE
= 63,
279 SEC_OID_NS_CERT_EXT_BASE_URL
= 64,
280 SEC_OID_NS_CERT_EXT_REVOCATION_URL
= 65,
281 SEC_OID_NS_CERT_EXT_CA_REVOCATION_URL
= 66,
282 SEC_OID_NS_CERT_EXT_CA_CRL_URL
= 67,
283 SEC_OID_NS_CERT_EXT_CA_CERT_URL
= 68,
284 SEC_OID_NS_CERT_EXT_CERT_RENEWAL_URL
= 69,
285 SEC_OID_NS_CERT_EXT_CA_POLICY_URL
= 70,
286 SEC_OID_NS_CERT_EXT_HOMEPAGE_URL
= 71,
287 SEC_OID_NS_CERT_EXT_ENTITY_LOGO
= 72,
288 SEC_OID_NS_CERT_EXT_USER_PICTURE
= 73,
289 SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME
= 74,
290 SEC_OID_NS_CERT_EXT_COMMENT
= 75,
291 SEC_OID_NS_CERT_EXT_LOST_PASSWORD_URL
= 76,
292 SEC_OID_NS_CERT_EXT_CERT_RENEWAL_TIME
= 77,
293 SEC_OID_NS_KEY_USAGE_GOVT_APPROVED
= 78,
295 /* x.509 v3 Extensions */
296 SEC_OID_X509_SUBJECT_DIRECTORY_ATTR
= 79,
297 SEC_OID_X509_SUBJECT_KEY_ID
= 80,
298 SEC_OID_X509_KEY_USAGE
= 81,
299 SEC_OID_X509_PRIVATE_KEY_USAGE_PERIOD
= 82,
300 SEC_OID_X509_SUBJECT_ALT_NAME
= 83,
301 SEC_OID_X509_ISSUER_ALT_NAME
= 84,
302 SEC_OID_X509_BASIC_CONSTRAINTS
= 85,
303 SEC_OID_X509_NAME_CONSTRAINTS
= 86,
304 SEC_OID_X509_CRL_DIST_POINTS
= 87,
305 SEC_OID_X509_CERTIFICATE_POLICIES
= 88,
306 SEC_OID_X509_POLICY_MAPPINGS
= 89,
307 SEC_OID_X509_POLICY_CONSTRAINTS
= 90,
308 SEC_OID_X509_AUTH_KEY_ID
= 91,
309 SEC_OID_X509_EXT_KEY_USAGE
= 92,
310 SEC_OID_X509_AUTH_INFO_ACCESS
= 93,
312 SEC_OID_X509_CRL_NUMBER
= 94,
313 SEC_OID_X509_REASON_CODE
= 95,
314 SEC_OID_X509_INVALID_DATE
= 96,
315 /* End of x.509 v3 Extensions */
317 SEC_OID_X500_RSA_ENCRYPTION
= 97,
319 /* alg 1485 additions */
320 SEC_OID_RFC1274_UID
= 98,
321 SEC_OID_RFC1274_MAIL
= 99,
323 /* PKCS 12 additions */
324 SEC_OID_PKCS12
= 100,
325 SEC_OID_PKCS12_MODE_IDS
= 101,
326 SEC_OID_PKCS12_ESPVK_IDS
= 102,
327 SEC_OID_PKCS12_BAG_IDS
= 103,
328 SEC_OID_PKCS12_CERT_BAG_IDS
= 104,
329 SEC_OID_PKCS12_OIDS
= 105,
330 SEC_OID_PKCS12_PBE_IDS
= 106,
331 SEC_OID_PKCS12_SIGNATURE_IDS
= 107,
332 SEC_OID_PKCS12_ENVELOPING_IDS
= 108,
333 /* SEC_OID_PKCS12_OFFLINE_TRANSPORT_MODE,
334 SEC_OID_PKCS12_ONLINE_TRANSPORT_MODE, */
335 SEC_OID_PKCS12_PKCS8_KEY_SHROUDING
= 109,
336 SEC_OID_PKCS12_KEY_BAG_ID
= 110,
337 SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID
= 111,
338 SEC_OID_PKCS12_SECRET_BAG_ID
= 112,
339 SEC_OID_PKCS12_X509_CERT_CRL_BAG
= 113,
340 SEC_OID_PKCS12_SDSI_CERT_BAG
= 114,
341 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC4
= 115,
342 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC4
= 116,
343 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_TRIPLE_DES_CBC
= 117,
344 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC
= 118,
345 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC
= 119,
346 SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_128_BIT_RC4
= 120,
347 SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_40_BIT_RC4
= 121,
348 SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_TRIPLE_DES
= 122,
349 SEC_OID_PKCS12_RSA_SIGNATURE_WITH_SHA1_DIGEST
= 123,
350 /* end of PKCS 12 additions */
353 SEC_OID_ANSIX9_DSA_SIGNATURE
= 124,
354 SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST
= 125,
355 SEC_OID_BOGUS_DSA_SIGNATURE_WITH_SHA1_DIGEST
= 126,
358 SEC_OID_VERISIGN_USER_NOTICES
= 127,
361 SEC_OID_PKIX_CPS_POINTER_QUALIFIER
= 128,
362 SEC_OID_PKIX_USER_NOTICE_QUALIFIER
= 129,
363 SEC_OID_PKIX_OCSP
= 130,
364 SEC_OID_PKIX_OCSP_BASIC_RESPONSE
= 131,
365 SEC_OID_PKIX_OCSP_NONCE
= 132,
366 SEC_OID_PKIX_OCSP_CRL
= 133,
367 SEC_OID_PKIX_OCSP_RESPONSE
= 134,
368 SEC_OID_PKIX_OCSP_NO_CHECK
= 135,
369 SEC_OID_PKIX_OCSP_ARCHIVE_CUTOFF
= 136,
370 SEC_OID_PKIX_OCSP_SERVICE_LOCATOR
= 137,
371 SEC_OID_PKIX_REGCTRL_REGTOKEN
= 138,
372 SEC_OID_PKIX_REGCTRL_AUTHENTICATOR
= 139,
373 SEC_OID_PKIX_REGCTRL_PKIPUBINFO
= 140,
374 SEC_OID_PKIX_REGCTRL_PKI_ARCH_OPTIONS
= 141,
375 SEC_OID_PKIX_REGCTRL_OLD_CERT_ID
= 142,
376 SEC_OID_PKIX_REGCTRL_PROTOCOL_ENC_KEY
= 143,
377 SEC_OID_PKIX_REGINFO_UTF8_PAIRS
= 144,
378 SEC_OID_PKIX_REGINFO_CERT_REQUEST
= 145,
379 SEC_OID_EXT_KEY_USAGE_SERVER_AUTH
= 146,
380 SEC_OID_EXT_KEY_USAGE_CLIENT_AUTH
= 147,
381 SEC_OID_EXT_KEY_USAGE_CODE_SIGN
= 148,
382 SEC_OID_EXT_KEY_USAGE_EMAIL_PROTECT
= 149,
383 SEC_OID_EXT_KEY_USAGE_TIME_STAMP
= 150,
384 SEC_OID_OCSP_RESPONDER
= 151,
386 /* Netscape Algorithm OIDs */
387 SEC_OID_NETSCAPE_SMIME_KEA
= 152,
389 /* Skipjack OID -- ### mwelch temporary */
390 SEC_OID_FORTEZZA_SKIPJACK
= 153,
392 /* PKCS 12 V2 oids */
393 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC4
= 154,
394 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC4
= 155,
395 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_3KEY_TRIPLE_DES_CBC
= 156,
396 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_2KEY_TRIPLE_DES_CBC
= 157,
397 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC
= 158,
398 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC
= 159,
399 SEC_OID_PKCS12_SAFE_CONTENTS_ID
= 160,
400 SEC_OID_PKCS12_PKCS8_SHROUDED_KEY_BAG_ID
= 161,
402 SEC_OID_PKCS12_V1_KEY_BAG_ID
= 162,
403 SEC_OID_PKCS12_V1_PKCS8_SHROUDED_KEY_BAG_ID
= 163,
404 SEC_OID_PKCS12_V1_CERT_BAG_ID
= 164,
405 SEC_OID_PKCS12_V1_CRL_BAG_ID
= 165,
406 SEC_OID_PKCS12_V1_SECRET_BAG_ID
= 166,
407 SEC_OID_PKCS12_V1_SAFE_CONTENTS_BAG_ID
= 167,
408 SEC_OID_PKCS9_X509_CERT
= 168,
409 SEC_OID_PKCS9_SDSI_CERT
= 169,
410 SEC_OID_PKCS9_X509_CRL
= 170,
411 SEC_OID_PKCS9_FRIENDLY_NAME
= 171,
412 SEC_OID_PKCS9_LOCAL_KEY_ID
= 172,
413 SEC_OID_PKCS12_KEY_USAGE
= 173,
415 /*Diffe Helman OIDS */
416 SEC_OID_X942_DIFFIE_HELMAN_KEY
= 174,
418 /* Netscape other name types */
419 SEC_OID_NETSCAPE_NICKNAME
= 175,
421 /* Cert Server OIDS */
422 SEC_OID_NETSCAPE_RECOVERY_REQUEST
= 176,
424 /* New PSM certificate management OIDs */
425 SEC_OID_CERT_RENEWAL_LOCATOR
= 177,
426 SEC_OID_NS_CERT_EXT_SCOPE_OF_USE
= 178,
428 /* CMS (RFC2630) OIDs */
429 SEC_OID_CMS_EPHEMERAL_STATIC_DIFFIE_HELLMAN
= 179,
430 SEC_OID_CMS_3DES_KEY_WRAP
= 180,
431 SEC_OID_CMS_RC2_KEY_WRAP
= 181,
433 /* SMIME attributes */
434 SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE
= 182,
437 SEC_OID_AES_128_ECB
= 183,
438 SEC_OID_AES_128_CBC
= 184,
439 SEC_OID_AES_192_ECB
= 185,
440 SEC_OID_AES_192_CBC
= 186,
441 SEC_OID_AES_256_ECB
= 187,
442 SEC_OID_AES_256_CBC
= 188,
444 SEC_OID_SDN702_DSA_SIGNATURE
= 189,
446 SEC_OID_MS_SMIME_ENCRYPTION_KEY_PREFERENCE
= 190,
448 SEC_OID_SHA224
= 191,
449 SEC_OID_SHA256
= 192,
450 SEC_OID_SHA384
= 193,
451 SEC_OID_SHA512
= 194,
453 SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION
= 195,
454 SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION
= 196,
455 SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION
= 197,
457 SEC_OID_AES_128_KEY_WRAP
= 198,
458 SEC_OID_AES_192_KEY_WRAP
= 199,
459 SEC_OID_AES_256_KEY_WRAP
= 200,
461 /* eContentType set by client and not understood by this library; treated
462 * like SEC_OID_PKCS7_DATA, except the caller's OID is encoded. */
466 SEC_OID_EC_PUBLIC_KEY
= 202,
467 SEC_OID_ECDSA_WithSHA1
= 203,
468 SEC_OID_DH_SINGLE_STD_SHA1KDF
= 204,
469 SEC_OID_SECP_256_R1
= 205,
470 SEC_OID_SECP_384_R1
= 206,
471 SEC_OID_SECP_521_R1
= 207,
473 /* RFC 3161 Timestamping OIDs */
474 SEC_OID_PKCS9_ID_CT_TSTInfo
= 208,
475 SEC_OID_PKCS9_TIMESTAMP_TOKEN
= 209,
476 SEC_OID_PKCS9_SIGNING_CERTIFICATE
= 210,
478 /* ECDSA with SHA2 */
479 SEC_OID_ECDSA_WITH_SHA256
= 211,
480 SEC_OID_ECDSA_WITH_SHA384
= 212,
481 SEC_OID_ECDSA_WITH_SHA512
= 213,
483 /* Apple CMS Attribute */
484 SEC_OID_APPLE_HASH_AGILITY
= 214,
490 #if defined(__cplusplus)
494 #endif /* _SECURITY_SECCMSBASE_H_ */