]> git.saurik.com Git - apple/security.git/blame - libsecurity_cdsa_client/lib/dl_standard.cpp
Security-55471.14.18.tar.gz
[apple/security.git] / libsecurity_cdsa_client / lib / dl_standard.cpp
CommitLineData
b1ab9ed8
A
1/*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19//
20// mds_standard - standard-defined MDS record types
21//
22#include <security_cdsa_client/dl_standard.h>
23#include <security_cdsa_client/dlquery.h>
24
25
26namespace Security {
27namespace CssmClient {
28
29
30//
31// CDSA Common relation (one record per module)
32//
33static const char * const commonAttributes[] = {
34 "PrintName",
35 "Alias",
36 NULL
37};
38DLCommonFields::DLCommonFields(const char * const * names)
39 : Record(commonAttributes)
40{
41 addAttributes(names);
42}
43
44string DLCommonFields::printName() const { return mAttributes[0]; }
45string DLCommonFields::alias() const
46 { return mAttributes[1].size() ? string(mAttributes[1]) : "(no value)"; }
47
48
49//
50// The all-record-types pseudo-record
51//
52AllDLRecords::AllDLRecords()
53 : DLCommonFields(NULL)
54{ }
55
56
57//
58// CDSA Generic record attributes
59//
60static const char * const genericAttributes[] = {
61 NULL
62};
63GenericRecord::GenericRecord()
64 : DLCommonFields(genericAttributes)
65{
66}
67
68
69//
70// Apple "Generic Password" records
71//
72static const char * const genericPasswordAttributes[] = {
73 // if you find yourself here, you should add the attributes and their functions
74 NULL
75};
76GenericPasswordRecord::GenericPasswordRecord()
77 : DLCommonFields(genericPasswordAttributes)
78{
79}
80
81
82//
83// Common key attributes
84//
85static const char * const keyAttributes[] = {
86 "KeyClass",
87 "KeyType",
88 "KeySizeInBits",
89 "EffectiveKeySize",
90 "Label",
91 "ApplicationTag",
92 "Permanent",
93 "Private",
94 "Modifiable",
95 "Sensitive",
96 "AlwaysSensitive",
97 "Extractable",
98 "NeverExtractable",
99 "Encrypt",
100 "Decrypt",
101 "Derive",
102 "Sign",
103 "Verify",
104 "Wrap",
105 "Unwrap",
106 NULL
107};
108
109KeyRecord::KeyRecord()
110 : DLCommonFields(keyAttributes)
111{
112}
113
114uint32 KeyRecord::keyClass() const { return mAttributes[2]; }
115uint32 KeyRecord::type() const { return mAttributes[3]; }
116uint32 KeyRecord::size() const { return mAttributes[4]; }
117uint32 KeyRecord::effectiveSize() const { return mAttributes[5]; }
118const CssmData &KeyRecord::label() const { return mAttributes[6]; }
119const CssmData &KeyRecord::applicationTag() const { return mAttributes[7]; }
120bool KeyRecord::isPermanent() const { return mAttributes[8]; }
121bool KeyRecord::isPrivate() const { return mAttributes[9]; }
122bool KeyRecord::isModifiable() const { return mAttributes[10]; }
123bool KeyRecord::isSensitive() const { return mAttributes[11]; }
124bool KeyRecord::wasAlwaysSensitive() const { return mAttributes[12]; }
125bool KeyRecord::isExtractable() const { return mAttributes[13]; }
126bool KeyRecord::wasNeverExtractable() const { return mAttributes[14]; }
127bool KeyRecord::canEncrypt() const { return mAttributes[15]; }
128bool KeyRecord::canDecrypt() const { return mAttributes[16]; }
129bool KeyRecord::canDerive() const { return mAttributes[17]; }
130bool KeyRecord::canSign() const { return mAttributes[18]; }
131bool KeyRecord::canVerify() const { return mAttributes[19]; }
132bool KeyRecord::canWrap() const { return mAttributes[20]; }
133bool KeyRecord::canUnwrap() const { return mAttributes[21]; }
134
135
136//
137// Certificate attributes
138//
139static const char * const certAttributes[] = {
140 "CertType",
141 "CertEncoding",
142 "Subject",
143 "Issuer",
144 "SerialNumber",
145 "SubjectKeyIdentifier",
146 "PublicKeyHash",
147 NULL
148};
149
150X509CertRecord::X509CertRecord()
151 : DLCommonFields(certAttributes)
152{
153}
154
155CSSM_CERT_TYPE X509CertRecord::type() const { return mAttributes[2]; }
156CSSM_CERT_ENCODING X509CertRecord::encoding() const { return mAttributes[3]; }
157const CssmData &X509CertRecord::subject() const { return mAttributes[4]; }
158const CssmData &X509CertRecord::issuer() const { return mAttributes[5]; }
159const CssmData &X509CertRecord::serial() const { return mAttributes[6]; }
160const CssmData &X509CertRecord::subjectKeyIdentifier() const { return mAttributes[7]; }
161const CssmData &X509CertRecord::publicKeyHash() const { return mAttributes[8]; }
162
163
164//
165// UnlockReferral attributes
166//
167static const char * const unlockReferralAttributes[] = {
168 "Type",
169 "DbName",
170 "DbNetname",
171 "DbGuid",
172 "DbSSID",
173 "DbSSType",
174 "KeyLabel",
175 "KeyAppTag",
176 NULL
177};
178
179UnlockReferralRecord::UnlockReferralRecord()
180 : DLCommonFields(unlockReferralAttributes)
181{
182}
183
184uint32 UnlockReferralRecord::type() const { return mAttributes[2]; }
185string UnlockReferralRecord::dbName() const { return mAttributes[3]; }
186const CssmData &UnlockReferralRecord::dbNetname() const { return mAttributes[4]; }
187const Guid &UnlockReferralRecord::dbGuid() const { return mAttributes[5]; }
188uint32 UnlockReferralRecord::dbSSID() const { return mAttributes[6]; }
189uint32 UnlockReferralRecord::dbSSType() const { return mAttributes[7]; }
190const CssmData &UnlockReferralRecord::keyLabel() const { return mAttributes[8]; }
191const CssmData &UnlockReferralRecord::keyApplicationTag() const { return mAttributes[9]; }
192
193
194} // end namespace CssmClient
195} // end namespace Security