2 * Copyright (c) 2000-2004,2006 Apple Computer, 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 // cssmcert - CSSM layer certificate (CL) related objects.
31 #include <security_cdsa_utilities/cssmalloc.h>
32 #include <security_cdsa_utilities/cssmdata.h>
39 // A CSSM_FIELD, essentially an OID/Data pair.
41 class CssmField
: public PodWrapper
<CssmField
, CSSM_FIELD
> {
44 CssmField(const CSSM_OID
&oid
, const CSSM_DATA
&value
)
45 { FieldOid
= oid
; FieldValue
= value
; }
47 CssmField(const CSSM_OID
&oid
)
48 { FieldOid
= oid
; FieldValue
= CssmData(); }
51 CssmOid
&oid() { return CssmOid::overlay(FieldOid
); }
52 CssmOid
&value() { return CssmOid::overlay(FieldValue
); }
53 const CssmOid
&oid() const { return CssmOid::overlay(FieldOid
); }
54 const CssmOid
&value() const { return CssmOid::overlay(FieldValue
); }
56 bool isComplex() const
57 { return value().length() == CSSM_FIELDVALUE_COMPLEX_DATA_TYPE
; }
62 // An encoded certificate
64 class EncodedCertificate
: public PodWrapper
<EncodedCertificate
, CSSM_ENCODED_CERT
> {
66 EncodedCertificate(CSSM_CERT_TYPE type
= CSSM_CERT_UNKNOWN
,
67 CSSM_CERT_ENCODING enc
= CSSM_CERT_ENCODING_UNKNOWN
,
68 const CSSM_DATA
*data
= NULL
);
70 CSSM_CERT_TYPE
type() const { return CertType
; }
71 CSSM_CERT_ENCODING
encoding() const { return CertEncoding
; }
72 const CssmData
&blob() const { return CssmData::overlay(CertBlob
); }
74 // CssmDataoid features
75 void *data() const { return blob().data(); }
76 size_t length() const { return blob().length(); }
81 // CertGroups - groups of certificates in a bewildering variety of forms
83 class CertGroup
: public PodWrapper
<CertGroup
, CSSM_CERTGROUP
> {
86 CertGroup(CSSM_CERT_TYPE ctype
, CSSM_CERT_ENCODING encoding
, CSSM_CERTGROUP_TYPE type
);
89 CSSM_CERT_TYPE
certType() const { return CertType
; }
90 CSSM_CERT_ENCODING
encoding() const { return CertEncoding
; }
91 CSSM_CERTGROUP_TYPE
type() const { return CertGroupType
; }
92 uint32
count() const { return NumCerts
; }
93 uint32
&count() { return NumCerts
; }
96 // CSSM_CERTGROUP_DATA version
97 CssmData
* &blobCerts()
98 { assert(type() == CSSM_CERTGROUP_DATA
); return CssmData::overlayVar(GroupList
.CertList
); }
99 CssmData
*blobCerts() const
100 { assert(type() == CSSM_CERTGROUP_DATA
); return CssmData::overlay(GroupList
.CertList
); }
102 // CSSM_CERTGROUP_ENCODED_CERT version
103 EncodedCertificate
* &encodedCerts()
104 { return EncodedCertificate::overlayVar(GroupList
.EncodedCertList
); }
105 EncodedCertificate
*encodedCerts() const
106 { return EncodedCertificate::overlay(GroupList
.EncodedCertList
); }
109 // free all memory in this group with the given allocator
110 void destroy(Allocator
&allocator
);
117 namespace DataWalkers
{
122 } // end namespace DataWalkers
123 } // end namespace Security