]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_apple_x509_cl/lib/DecodedCert.h
2 * Copyright (c) 2000-2001,2011,2014 Apple 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 * Copyright (c) 2000,2011,2014 Apple Inc.
25 * See DecodedItem.h for details on the care and feeding of this
29 #ifndef _DECODED_CERT_H_
30 #define _DECODED_CERT_H_
32 #include <Security/cssmtype.h>
33 #include <security_cdsa_utilities/cssmdata.h>
35 #include "DecodedItem.h"
36 #include <Security/X509Templates.h>
37 #include <security_asn1/SecNssCoder.h>
39 class DecodedCert
: public DecodedItem
43 /* construct empty cert, no decoded extensions */
45 AppleX509CLSession
&session
);
47 /* one-shot constructor, decoding from DER-encoded data */
49 AppleX509CLSession
&session
,
50 const CssmData
&encodedCert
);
54 void encodeExtensions();
56 /* decode TBSCert and its extensions */
58 const CssmData
&encodedTbs
);
60 /* encode TBSCert and its extensions */
62 CssmOwnedData
&encodedTbs
);
65 *** field accessors (in CertFields.cpp)
69 * Obtain the index'th occurrence of field specified by fieldId.
70 * Format of the returned field depends on fieldId.
71 * Returns total number of fieldId fields in the cert if index is 0.
72 * Returns true if specified field was found, else returns false.
74 bool getCertFieldData(
75 const CssmOid
&fieldId
, // which field
76 unsigned index
, // which occurrence (0 = first)
77 uint32
&numFields
, // RETURNED
78 CssmOwnedData
&fieldValue
); // RETURNED
81 * Set the field specified by fieldId in TBS.
82 * Note no index - individual field routines either append (for extensions)
83 * or throw if field already set (for all others)
86 const CssmOid
&fieldId
, // which field
87 const CssmData
&fieldValue
);
90 * Free the fieldId-specific data referred to by fieldValue.get().data().
92 static void freeCertFieldData(
93 const CssmOid
&fieldId
,
94 CssmOwnedData
&fieldValue
);
96 void getAllParsedCertFields(
97 uint32
&NumberOfFields
, // RETURNED
98 CSSM_FIELD_PTR
&CertFields
); // RETURNED
100 static void describeFormat(
102 uint32
&NumberOfFields
,
103 CSSM_OID_PTR
&OidList
);
106 * Obtain a CSSM_KEY from a decoded cert, inferring as much as we can
107 * from required fields (subjectPublicKeyInfo) and extensions (for
110 CSSM_KEY_PTR
extractCSSMKey(
111 Allocator
&alloc
) const;
113 CSSM_KEYUSE
inferKeyUsage() const;
115 NSS_Certificate mCert
;
118 #endif /* _DECODED_CERT_H_ */