]>
git.saurik.com Git - apple/security.git/blob - libsecurity_apple_x509_cl/lib/DecodedCert.h
2 * Copyright (c) 2000-2001 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 obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
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 EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 * DecodedCert.h - object representing an NSS-decoded cert, with extensions
21 * parsed and decoded (still in NSS format).
23 * Created 9/1/2000 by Doug Mitchell.
24 * Copyright (c) 2000 by Apple Computer.
26 * See DecodedItem.h for details on the care and feeding of this
30 #ifndef _DECODED_CERT_H_
31 #define _DECODED_CERT_H_
33 #include <Security/cssmtype.h>
34 #include <security_cdsa_utilities/cssmdata.h>
36 #include "DecodedItem.h"
37 #include <Security/X509Templates.h>
38 #include <security_asn1/SecNssCoder.h>
40 class DecodedCert
: public DecodedItem
44 /* construct empty cert, no decoded extensions */
46 AppleX509CLSession
&session
);
48 /* one-shot constructor, decoding from DER-encoded data */
50 AppleX509CLSession
&session
,
51 const CssmData
&encodedCert
);
55 void encodeExtensions();
57 /* decode TBSCert and its extensions */
59 const CssmData
&encodedTbs
);
61 /* encode TBSCert and its extensions */
63 CssmOwnedData
&encodedTbs
);
66 *** field accessors (in CertFields.cpp)
70 * Obtain the index'th occurrence of field specified by fieldId.
71 * Format of the returned field depends on fieldId.
72 * Returns total number of fieldId fields in the cert if index is 0.
73 * Returns true if specified field was found, else returns false.
75 bool getCertFieldData(
76 const CssmOid
&fieldId
, // which field
77 unsigned index
, // which occurrence (0 = first)
78 uint32
&numFields
, // RETURNED
79 CssmOwnedData
&fieldValue
); // RETURNED
82 * Set the field specified by fieldId in TBS.
83 * Note no index - individual field routines either append (for extensions)
84 * or throw if field already set (for all others)
87 const CssmOid
&fieldId
, // which field
88 const CssmData
&fieldValue
);
91 * Free the fieldId-specific data referred to by fieldValue.get().data().
93 static void freeCertFieldData(
94 const CssmOid
&fieldId
,
95 CssmOwnedData
&fieldValue
);
97 void getAllParsedCertFields(
98 uint32
&NumberOfFields
, // RETURNED
99 CSSM_FIELD_PTR
&CertFields
); // RETURNED
101 static void describeFormat(
103 uint32
&NumberOfFields
,
104 CSSM_OID_PTR
&OidList
);
107 * Obtain a CSSM_KEY from a decoded cert, inferring as much as we can
108 * from required fields (subjectPublicKeyInfo) and extensions (for
111 CSSM_KEY_PTR
extractCSSMKey(
112 Allocator
&alloc
) const;
114 CSSM_KEYUSE
inferKeyUsage() const;
116 NSS_Certificate mCert
;
119 #endif /* _DECODED_CERT_H_ */