2 * Copyright (c) 2003-2005 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please
7 * obtain a copy of the License at http://www.apple.com/publicsource and
8 * read it before using this file.
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
12 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
13 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
15 * Please see the License for the specific language governing rights and
16 * limitations under the License.
20 * CertParser.h - cert parser with autorelease of fetched fields
22 * Created 24 October 2003 by Doug Mitchell
25 #ifndef _CERT_PARSER_H_
26 #define _CERT_PARSER_H_
28 #include <Security/Security.h>
38 * We store an vector<> of these as an "autorelease" pool of fetched fields.
40 class CP_FetchedField
;
46 * Construct with or without data - you can add the data later with
47 * initWithData() to parse without exceptions
50 CertParser(); // must be used with initWithSecCert to get clHand
51 CertParser( // use with initWithData
52 CSSM_CL_HANDLE clHand
);
54 CSSM_CL_HANDLE clHand
,
55 const CSSM_DATA
&certData
);
57 SecCertificateRef secCert
);
59 /* frees all the fields we fetched */
63 * No cert- or CDSA-related exceptions thrown by remainder
65 CSSM_RETURN
initWithData(
66 const CSSM_DATA
&certData
);
67 OSStatus
initWithSecCert(
68 SecCertificateRef secCert
);
69 CSSM_RETURN
initWithCFData(
73 * Obtain atrbitrary field from cached cert. This class takes care of freeing
74 * the field in its destructor.
76 * Returns NULL if field not found (not exception).
78 * Caller optionally specifies field length to check - specifying zero means
79 * "don't care, don't check". Actual field length always returned in fieldLength.
81 const void *fieldForOid(
83 CSSM_SIZE
&fieldLength
); // IN/OUT
86 * Conveneince routine to fetch an extension we "know" the CL can parse.
87 * The return value gets cast to one of the CE_Data types.
89 const void *extensionForOid(
95 CSSM_CL_HANDLE mClHand
;
96 CSSM_HANDLE mCacheHand
; // the parsed & cached cert
97 vector
<CP_FetchedField
*> mFetchedFields
;
104 #endif /* _CERT_PARSER_H_ */