4 * Copyright (c) 2000-2002 Apple Computer, Inc. All Rights Reserved.
6 * The contents of this file constitute Original Code as defined in and are
7 * subject to the Apple Public Source License Version 1.2 (the 'License').
8 * You may not use this file except in compliance with the License. Please obtain
9 * a copy of the License at http://www.apple.com/publicsource and read it before
12 * This Original Code and all software distributed under the License are
13 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
14 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
15 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
17 * specific language governing rights and limitations under the License.
21 `define(`arrayIndex', 0)dnl
22 define(`class', $1)dnl
24 // $1 password attributes
25 static const CSSM_DB_ATTRIBUTE_INFO $1Attributes[] =
28 // $1 password indices
29 static const CSSM_DB_INDEX_INFO $1Indices[] =
37 ` // Unique (primary) index'
39 ` // Secondary indices'
45 define(`attributeBody',
47 ifelse(index(`$1',`s'),-1,
48 ` CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER,
49 {(char *)((uint64_t)$3<<32|$3)},',
50 ` CSSM_DB_ATTRIBUTE_NAME_AS_STRING,
52 CSSM_DB_ATTRIBUTE_FORMAT_$7
55 define(`simpleAttribute',
56 `const CSSM_DB_ATTRIBUTE_INFO $2 =
61 `ifelse(index(`$1',`U'),-1,`',
65 CSSM_DB_INDEX_ON_ATTRIBUTE,
69 ifelse(index(`$1',`I'),-1,`',
72 CSSM_DB_INDEX_NONUNIQUE,
73 CSSM_DB_INDEX_ON_ATTRIBUTE,
78 dnl const CSSM_DB_ATTRIBUTE_INFO &`k'class()$2 = class()Attributes[arrayIndex()];
79 `#define k'class()$2 class()Attributes[arrayIndex()];
82 define(`arrayIndex', incr(arrayIndex))dnl
88 sizeof($2Attributes) / sizeof(CSSM_DB_ATTRIBUTE_INFO),
89 const_cast<CSSM_DB_ATTRIBUTE_INFO_PTR>($2Attributes)
95 sizeof($2Indices) / sizeof(CSSM_DB_INDEX_INFO),
96 const_cast<CSSM_DB_INDEX_INFO_PTR>($2Indices)
101 CSSM_DB_RECORDTYPE_APP_DEFINED_START,
110 define(`startNewClass',
111 `define(`indexIndex', 0)dnl
112 define(`class', $1)dnl
115 const CSSM_DB_SCHEMA_ATTRIBUTE_INFO $1SchemaAttributeList[] =
119 const CSSM_DB_SCHEMA_INDEX_INFO $1SchemaIndexList[] =
122 define(`endNewClass',
126 const uint32 class()SchemaAttributeCount = sizeof(class()SchemaAttributeList) / sizeof(CSSM_DB_SCHEMA_ATTRIBUTE_INFO);
129 ` // Unique (primary) index'
131 ` // Secondary indices'
135 const uint32 class()SchemaIndexCount = sizeof(class()SchemaIndexList) / sizeof(CSSM_DB_SCHEMA_INDEX_INFO);
142 define(`newAttributeBody',
144 ifelse(index(`$1',`s'),-1,
145 ` CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER,
146 {(char *)((uint64_t)$3<<32|$3)},',
147 ` CSSM_DB_ATTRIBUTE_NAME_AS_STRING,
149 CSSM_DB_ATTRIBUTE_FORMAT_$7
152 define(`simpleNewAttribute',
153 `const CSSM_DB_ATTRIBUTE_INFO `k'class()$2 =
154 newAttributeBody($*);
157 define(`newAttribute',
159 { $3, $4, { $5, $6 }, CSSM_DB_ATTRIBUTE_FORMAT_$7 },
161 ifelse(index(`$1',`S'),-1,`',
163 simpleNewAttribute($*)
166 ifelse(index(`$1',`U'),-1,`',
168 { $3, 0, CSSM_DB_INDEX_UNIQUE, CSSM_DB_INDEX_ON_ATTRIBUTE },
170 ifelse(index(`$1',`I'),-1,`',
171 `define(`indexIndex', incr(indexIndex))dnl
173 { $3, indexIndex(), CSSM_DB_INDEX_NONUNIQUE, CSSM_DB_INDEX_ON_ATTRIBUTE },
176 /* Start of actual output */
179 * Generated by m4 from Schema.m4 please do not edit this file.
182 `#include <security_cdsa_utilities/Schema.h>'
184 `#include <Security/SecCertificate.h>'
185 `#include <Security/SecTrustPriv.h>'
186 `#include <Security/SecKeychainItemPriv.h>'
187 `#include <Security/cssmapple.h>'
188 `#include <security_utilities/errors.h>'
192 namespace KeychainCore {
197 simpleAttribute(` s', RelationID, 0, (char*) "RelationID", 0, NULL, UINT32)
198 simpleAttribute(` s', RelationName, 1, (char*) "RelationName", 0, NULL, STRING)
199 simpleAttribute(` s', AttributeID, 1, (char*) "AttributeID", 0, NULL, UINT32)
200 simpleAttribute(` s', AttributeNameFormat, 2, (char*) "AttributeNameFormat", 0, NULL, UINT32)
201 simpleAttribute(` s', AttributeName, 3, (char*) "AttributeName", 0, NULL, STRING)
202 simpleAttribute(` s', AttributeNameID, 4, (char*) "AttributeNameID", 0, NULL, BLOB)
203 simpleAttribute(` s', AttributeFormat, 5, (char*) "AttributeFormat", 0, NULL, UINT32)
204 simpleAttribute(` s', IndexType, 3, (char*) "IndexType", 0, NULL, UINT32)
208 attribute(` i', CreationDate, kSecCreationDateItemAttr, (char*) "CreationDate", 0, NULL, TIME_DATE)
209 attribute(` i', ModDate, kSecModDateItemAttr, (char*) "ModDate", 0, NULL, TIME_DATE)
210 attribute(` i', Description, kSecDescriptionItemAttr, (char*) "Description", 0, NULL, BLOB)
211 attribute(` i', Comment, kSecCommentItemAttr, (char*) "Comment", 0, NULL, BLOB)
212 attribute(` i', Creator, kSecCreatorItemAttr, (char*) "Creator", 0, NULL, UINT32)
213 attribute(` i', Type, kSecTypeItemAttr, (char*) "Type", 0, NULL, UINT32)
214 attribute(` i', ScriptCode, kSecScriptCodeItemAttr, (char*) "ScriptCode", 0, NULL, SINT32)
215 attribute(` s', PrintName, kSecLabelItemAttr, (char*) "PrintName", 0, NULL, BLOB)
216 attribute(` s', Alias, kSecAlias, (char*) "Alias", 0, NULL, BLOB)
217 attribute(` i', Invisible, kSecInvisibleItemAttr, (char*) "Invisible", 0, NULL, SINT32)
218 attribute(` i', Negative, kSecNegativeItemAttr, (char*) "Negative", 0, NULL, SINT32)
219 attribute(` i', CustomIcon, kSecCustomIconItemAttr, (char*) "CustomIcon", 0, NULL, SINT32)
220 attribute(` i', Protected, kSecProtectedDataItemAttr, (char*) "Protected", 0, NULL, BLOB)
221 attribute(`UIi', Account, kSecAccountItemAttr, (char*) "Account", 0, NULL, BLOB)
222 attribute(`UIi', Service, kSecServiceItemAttr, (char*) "Service", 0, NULL, BLOB)
223 attribute(` i', Generic, kSecGenericItemAttr, (char*) "Generic", 0, NULL, BLOB)
226 startClass(Appleshare)
227 attribute(` i', CreationDate, kSecCreationDateItemAttr, (char*) "CreationDate", 0, NULL, TIME_DATE)
228 attribute(` i', ModDate, kSecModDateItemAttr, (char*) "ModDate", 0, NULL, TIME_DATE)
229 attribute(` i', Description, kSecDescriptionItemAttr, (char*) "Description", 0, NULL, BLOB)
230 attribute(` i', Comment, kSecCommentItemAttr, (char*) "Comment", 0, NULL, BLOB)
231 attribute(` i', Creator, kSecCreatorItemAttr, (char*) "Creator", 0, NULL, UINT32)
232 attribute(` i', Type, kSecTypeItemAttr, (char*) "Type", 0, NULL, UINT32)
233 attribute(` i', ScriptCode, kSecScriptCodeItemAttr, (char*) "ScriptCode", 0, NULL, SINT32)
234 attribute(` s', PrintName, kSecLabelItemAttr, (char*) "PrintName", 0, NULL, BLOB)
235 attribute(` s', Alias, kSecAlias, (char*) "Alias", 0, NULL, BLOB)
236 attribute(` i', Invisible, kSecInvisibleItemAttr, (char*) "Invisible", 0, NULL, SINT32)
237 attribute(` i', Negative, kSecNegativeItemAttr, (char*) "Negative", 0, NULL, SINT32)
238 attribute(` i', CustomIcon, kSecCustomIconItemAttr, (char*) "CustomIcon", 0, NULL, SINT32)
239 attribute(` i', Protected, kSecProtectedDataItemAttr, (char*) "Protected", 0, NULL, BLOB)
240 attribute(`UIi', Account, kSecAccountItemAttr, (char*) "Account", 0, NULL, BLOB)
241 attribute(`UIi', Volume, kSecVolumeItemAttr, (char*) "Volume", 0, NULL, BLOB)
242 attribute(` i', Server, kSecServerItemAttr, (char*) "Server", 0, NULL, BLOB)
243 attribute(` i', Protocol, kSecProtocolItemAttr, (char*) "Protocol", 0, NULL, UINT32)
244 attribute(`UIi', Address, kSecAddressItemAttr, (char*) "Address", 0, NULL, BLOB)
245 attribute(`UIi', Signature, kSecSignatureItemAttr, (char*) "Signature", 0, NULL, BLOB)
249 attribute(` i', CreationDate, kSecCreationDateItemAttr, (char*) "CreationDate", 0, NULL, TIME_DATE)
250 attribute(` i', ModDate, kSecModDateItemAttr, (char*) "ModDate", 0, NULL, TIME_DATE)
251 attribute(` i', Description, kSecDescriptionItemAttr, (char*) "Description", 0, NULL, BLOB)
252 attribute(` i', Comment, kSecCommentItemAttr, (char*) "Comment", 0, NULL, BLOB)
253 attribute(` i', Creator, kSecCreatorItemAttr, (char*) "Creator", 0, NULL, UINT32)
254 attribute(` i', Type, kSecTypeItemAttr, (char*) "Type", 0, NULL, UINT32)
255 attribute(` i', ScriptCode, kSecScriptCodeItemAttr, (char*) "ScriptCode", 0, NULL, SINT32)
256 attribute(` s', PrintName, kSecLabelItemAttr, (char*) "PrintName", 0, NULL, BLOB)
257 attribute(` s', Alias, kSecAlias, (char*) "Alias", 0, NULL, BLOB)
258 attribute(` i', Invisible, kSecInvisibleItemAttr, (char*) "Invisible", 0, NULL, SINT32)
259 attribute(` i', Negative, kSecNegativeItemAttr, (char*) "Negative", 0, NULL, SINT32)
260 attribute(` i', CustomIcon, kSecCustomIconItemAttr, (char*) "CustomIcon", 0, NULL, SINT32)
261 attribute(` i', Protected, kSecProtectedDataItemAttr, (char*) "Protected", 0, NULL, BLOB)
262 attribute(`UIi', Account, kSecAccountItemAttr, (char*) "Account", 0, NULL, BLOB)
263 attribute(`UIi', SecurityDomain, kSecSecurityDomainItemAttr, (char*) "SecurityDomain", 0, NULL, BLOB)
264 attribute(`UIi', Server, kSecServerItemAttr, (char*) "Server", 0, NULL, BLOB)
265 attribute(`UIi', Protocol, kSecProtocolItemAttr, (char*) "Protocol", 0, NULL, UINT32)
266 attribute(`UIi', AuthType, kSecAuthenticationTypeItemAttr, (char*) "AuthType", 0, NULL, BLOB)
267 attribute(`UIi', Port, kSecPortItemAttr, (char*) "Port", 0, NULL, UINT32)
268 attribute(`UIi', Path, kSecPathItemAttr, (char*) "Path", 0, NULL, BLOB)
271 startNewClass(X509Certificate)
272 newAttribute(`UISs', CertType, kSecCertTypeItemAttr, (char*) "CertType", 0, NULL, UINT32)
273 newAttribute(` Ss', CertEncoding, kSecCertEncodingItemAttr, (char*) "CertEncoding", 0, NULL, UINT32)
274 newAttribute(` Ss', PrintName, kSecLabelItemAttr, (char*) "PrintName", 0, NULL, BLOB)
275 newAttribute(` ISs', Alias, kSecAlias, (char*) "Alias", 0, NULL, BLOB)
276 newAttribute(` ISs', Subject, kSecSubjectItemAttr, (char*) "Subject", 0, NULL, BLOB)
277 newAttribute(`UISs', Issuer, kSecIssuerItemAttr, (char*) "Issuer", 0, NULL, BLOB)
278 newAttribute(`UISs', SerialNumber, kSecSerialNumberItemAttr, (char*) "SerialNumber", 0, NULL, BLOB)
279 newAttribute(` ISs', SubjectKeyIdentifier, kSecSubjectKeyIdentifierItemAttr, (char*) "SubjectKeyIdentifier", 0, NULL, BLOB)
280 newAttribute(` ISs', PublicKeyHash, kSecPublicKeyHashItemAttr, (char*) "PublicKeyHash", 0, NULL, BLOB)
283 startNewClass(X509Crl)
284 newAttribute(`UISs', CrlType, kSecCrlType, (char*) "CrlType", 0, NULL, UINT32)
285 newAttribute(` Ss', CrlEncoding, kSecCrlEncodingItemAttr, (char*) "CrlEncoding", 0, NULL, UINT32)
286 newAttribute(` Ss', PrintName, kSecLabelItemAttr, (char*) "PrintName", 0, NULL, BLOB)
287 newAttribute(` Ss', Alias, kSecAlias, (char*) "Alias", 0, NULL, BLOB)
288 newAttribute(`UISs', Issuer, kSecIssuerItemAttr, (char*) "Issuer", 0, NULL, BLOB)
289 newAttribute(`UISs', ThisUpdate, kSecThisUpdateItemAttr, (char*) "ThisUpdate", 0, NULL, BLOB)
290 newAttribute(`UISs', NextUpdate, kSecNextUpdateItemAttr, (char*) "NextUpdate", 0, NULL, BLOB)
291 newAttribute(` Ss', URI, kSecUriItemAttr, (char*) "URI", 0, NULL, BLOB)
292 newAttribute(` ISs', CrlNumber, kSecCrlNumberItemAttr, (char*) "CrlNumber", 0, NULL, UINT32)
293 newAttribute(` ISs', DeltaCrlNumber, kSecDeltaCrlNumberItemAttr, (char*) "DeltaCrlNumber", 0, NULL, UINT32)
296 startNewClass(UserTrust)
297 newAttribute(`UISs', TrustedCertificate, kSecTrustCertAttr, (char*) "TrustedCertificate", 0, NULL, BLOB)
298 newAttribute(`UISs', TrustedPolicy, kSecTrustPolicyAttr, (char*) "TrustedPolicy", 0, NULL, BLOB)
299 newAttribute(` Ss', PrintName, kSecLabelItemAttr, (char*) "PrintName", 0, NULL, BLOB)
302 startNewClass(UnlockReferral)
303 newAttribute(`UISs', Type, kSecReferralTypeAttr, (char*) "Type", 0, NULL, UINT32)
304 newAttribute(`UISs', DbName, kSecReferralDbNameAttr, (char*) "DbName", 0, NULL, STRING)
305 newAttribute(`UISs', DbNetname, kSecReferralDbNetnameAttr, (char*) "DbNetname", 0, NULL, BLOB)
306 newAttribute(`UISs', DbGuid, kSecReferralDbGuidAttr, (char*) "DbGuid", 0, NULL, BLOB)
307 newAttribute(`UISs', DbSSID, kSecReferralDbSSIDAttr, (char*) "DbSSID", 0, NULL, UINT32)
308 newAttribute(`UISs', DbSSType, kSecReferralDbSSTypeAttr, (char*) "DbSSType", 0, NULL, UINT32)
309 newAttribute(` ISs', KeyLabel, kSecReferralKeyLabelAttr, (char*) "KeyLabel", 0, NULL, BLOB)
310 newAttribute(` ISs', KeyAppTag, kSecReferralKeyAppTagAttr, (char*) "KeyAppTag", 0, NULL, BLOB)
311 newAttribute(` Ss', PrintName, kSecLabelItemAttr, (char*) "PrintName", 0, NULL, BLOB)
312 newAttribute(` Ss', Alias, kSecAlias, (char*) "Alias", 0, NULL, BLOB)
315 // Extended Attribute
316 startNewClass(ExtendedAttribute)
317 newAttribute(`UISs', RecordType, kExtendedAttrRecordTypeAttr, (char*) "RecordType", 0, NULL, UINT32)
318 newAttribute(`UISs', ItemID, kExtendedAttrItemIDAttr, (char*) "ItemID", 0, NULL, BLOB)
319 newAttribute(`UISs', AttributeName, kExtendedAttrAttributeNameAttr, (char*) "AttributeName", 0, NULL, BLOB)
320 newAttribute(` Ss', ModDate, kSecModDateItemAttr, (char*) "ModDate", 0, NULL, TIME_DATE)
321 newAttribute(` Ss', AttributeValue, kExtendedAttrAttributeValueAttr, (char*) "AttributeValue", 0, NULL, BLOB)
325 static const CSSM_DB_RECORD_ATTRIBUTE_INFO Attributes[] =
327 attrInfo(CSSM_DL_DB_RECORD_GENERIC_PASSWORD, Generic),
328 attrInfo(CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD, Appleshare),
329 attrInfo(CSSM_DL_DB_RECORD_INTERNET_PASSWORD, Internet)
332 static const CSSM_DB_RECORD_INDEX_INFO Indices[] =
334 indexInfo(CSSM_DL_DB_RECORD_GENERIC_PASSWORD, Generic),
335 indexInfo(CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD, Appleshare),
336 indexInfo(CSSM_DL_DB_RECORD_INTERNET_PASSWORD, Internet)
339 static const CSSM_DB_PARSING_MODULE_INFO ParseInfos[] =
349 const CSSM_DBINFO DBInfo =
351 sizeof(Attributes) / sizeof(CSSM_DB_RECORD_ATTRIBUTE_INFO),
352 const_cast<CSSM_DB_PARSING_MODULE_INFO_PTR>(ParseInfos),
353 const_cast<CSSM_DB_RECORD_ATTRIBUTE_INFO_PTR>(Attributes),
354 const_cast<CSSM_DB_RECORD_INDEX_INFO_PTR>(Indices),
364 recordTypeFor(SecItemClass itemClass)
368 case kSecGenericPasswordItemClass: return CSSM_DL_DB_RECORD_GENERIC_PASSWORD;
369 case kSecInternetPasswordItemClass: return CSSM_DL_DB_RECORD_INTERNET_PASSWORD;
370 case kSecAppleSharePasswordItemClass: return CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD;
371 default: return CSSM_DB_RECORDTYPE(itemClass);
376 itemClassFor(CSSM_DB_RECORDTYPE recordType)
380 case CSSM_DL_DB_RECORD_GENERIC_PASSWORD: return kSecGenericPasswordItemClass;
381 case CSSM_DL_DB_RECORD_INTERNET_PASSWORD: return kSecInternetPasswordItemClass;
382 case CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD: return kSecAppleSharePasswordItemClass;
383 default: return SecItemClass(recordType);
387 const CSSM_DB_ATTRIBUTE_INFO &
388 attributeInfo(SecKeychainAttrType attrType)
392 case kSecCreationDateItemAttr: return kGenericCreationDate;
393 case kSecModDateItemAttr: return kGenericModDate;
394 case kSecDescriptionItemAttr: return kGenericDescription;
395 case kSecCommentItemAttr: return kGenericComment;
396 case kSecCreatorItemAttr: return kGenericCreator;
397 case kSecTypeItemAttr: return kGenericType;
398 case kSecScriptCodeItemAttr: return kGenericScriptCode;
399 case kSecLabelItemAttr: return kGenericPrintName;
400 case kSecAlias: return kGenericAlias;
401 case kSecInvisibleItemAttr: return kGenericInvisible;
402 case kSecNegativeItemAttr: return kGenericNegative;
403 case kSecCustomIconItemAttr: return kGenericCustomIcon;
404 /* Unique Generic password attributes */
405 case kSecAccountItemAttr: return kGenericAccount;
406 case kSecServiceItemAttr: return kGenericService;
407 case kSecGenericItemAttr: return kGenericGeneric;
408 /* Unique Appleshare password attributes */
409 case kSecVolumeItemAttr: return kAppleshareVolume;
410 case kSecAddressItemAttr: return kAppleshareAddress;
411 case kSecSignatureItemAttr: return kAppleshareSignature;
412 /* Unique AppleShare and Internet attributes */
413 case kSecServerItemAttr: return kAppleshareServer;
414 case kSecProtocolItemAttr: return kAppleshareProtocol;
415 /* Unique Internet password attributes */
416 case kSecSecurityDomainItemAttr: return kInternetSecurityDomain;
417 case kSecAuthenticationTypeItemAttr: return kInternetAuthType;
418 case kSecPortItemAttr: return kInternetPort;
419 case kSecPathItemAttr: return kInternetPath;
420 /* Unique Certificate attributes */
421 case kSecCertTypeItemAttr: return kX509CertificateCertType;
422 case kSecCertEncodingItemAttr: return kX509CertificateCertEncoding;
423 case kSecSubjectItemAttr: return kX509CertificateSubject;
424 case kSecIssuerItemAttr: return kX509CertificateIssuer;
425 case kSecSerialNumberItemAttr: return kX509CertificateSerialNumber;
426 case kSecSubjectKeyIdentifierItemAttr: return kX509CertificateSubjectKeyIdentifier;
427 case kSecPublicKeyHashItemAttr: return kX509CertificatePublicKeyHash;
428 /* Unique UserTrust attributes */
429 case kSecTrustCertAttr: return kUserTrustTrustedCertificate;
430 case kSecTrustPolicyAttr: return kUserTrustTrustedPolicy;
431 /* Unique UnlockReferral attributes */
432 case kSecReferralTypeAttr: return kUnlockReferralType;
433 case kSecReferralDbNameAttr: return kUnlockReferralDbName;
434 case kSecReferralDbGuidAttr: return kUnlockReferralDbGuid;
435 case kSecReferralDbSSIDAttr: return kUnlockReferralDbSSID;
436 case kSecReferralDbSSTypeAttr: return kUnlockReferralDbSSType;
437 case kSecReferralDbNetnameAttr: return kUnlockReferralDbNetname;
438 case kSecReferralKeyLabelAttr: return kUnlockReferralKeyLabel;
439 case kSecReferralKeyAppTagAttr: return kUnlockReferralKeyAppTag;
440 /* Unique ExtendedAttribute attributes */
441 case kExtendedAttrRecordTypeAttr: return kExtendedAttributeRecordType;
442 case kExtendedAttrItemIDAttr: return kExtendedAttributeItemID;
443 case kExtendedAttrAttributeNameAttr: return kExtendedAttributeAttributeName;
444 case kExtendedAttrAttributeValueAttr: return kExtendedAttributeAttributeValue;
446 case kSecProtectedDataItemAttr: return kGenericProtected;
451 return kGenericPrintName;
453 else if (attrType == 8)
455 return kGenericAlias;
457 MacOSError::throwMe(errSecNoSuchAttr);
462 } // end namespace Schema
464 } // end namespace KeychainCore
466 } // end namespace Security