]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_ocspd/common/ocspdDbSchema.h
Security-59754.80.3.tar.gz
[apple/security.git] / OSX / libsecurity_ocspd / common / ocspdDbSchema.h
1 /*
2 * Copyright (c) 2004,2011,2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*
25 * ocspdDbSchema.h
26 *
27 * Definitions of structures which define the schema, including attributes
28 * and indexes, for the standard tables that are part of the OCSP server
29 * database.
30 */
31
32 #ifndef _OCSPD_DB_SCHEMA_H_
33 #define _OCSPD_DB_SCHEMA_H_
34
35 #include <Security/cssmtype.h>
36
37 /*
38 * Structure used to store information which is needed to create
39 * a relation with indexes. The info in one of these structs maps to one
40 * record type in a CSSM_DBINFO - both record attribute info and index info.
41 */
42 typedef struct {
43 CSSM_DB_RECORDTYPE recordType;
44 const char *relationName;
45 uint32 numberOfAttributes;
46 const CSSM_DB_ATTRIBUTE_INFO *attrInfo;
47 uint32 numIndexes;
48 const CSSM_DB_INDEX_INFO *indexInfo;
49 } OcspdDbRelationInfo;
50
51 // Macros used to simplify declarations of attributes and indexes.
52
53 // declare a CSSM_DB_ATTRIBUTE_INFO
54 #define DB_ATTRIBUTE(name, type) \
55 { CSSM_DB_ATTRIBUTE_NAME_AS_STRING, \
56 { (char*) name }, \
57 CSSM_DB_ATTRIBUTE_FORMAT_ ## type \
58 }
59
60 // declare a CSSM_DB_INDEX_INFO
61 #define UNIQUE_INDEX_ATTRIBUTE(name, type) \
62 { CSSM_DB_INDEX_NONUNIQUE, \
63 CSSM_DB_INDEX_ON_ATTRIBUTE, \
64 { CSSM_DB_ATTRIBUTE_NAME_AS_STRING, \
65 { name }, \
66 CSSM_DB_ATTRIBUTE_FORMAT_ ## type \
67 } \
68 }
69
70 // declare a OcspdDbRelationInfo
71 #define RELATION_INFO(relationId, name, attributes, indexes) \
72 { relationId, \
73 name, \
74 sizeof(attributes) / sizeof(CSSM_DB_ATTRIBUTE_INFO), \
75 attributes, \
76 sizeof(indexes) / sizeof(CSSM_DB_INDEX_INFO), \
77 indexes }
78
79 /*
80 * Currently there is only one relation in the OCSPD database; this is an array
81 * containing it.
82 */
83 extern const OcspdDbRelationInfo kOcspDbRelations[];
84 extern unsigned kNumOcspDbRelations;
85
86 /*
87 * CSSM_DB_RECORDTYPE for the ocspd DB schema.
88 */
89 #define OCSPD_DB_RECORDTYPE 0x11223344
90
91 /*
92 * Here are the attribute names and formats in kOcspDbRelation. All attributes
93 * have format CSSM_DB_ATTRIBUTE_NAME_AS_STRING.
94 */
95
96 /* DER encoded CertID - a record can have multiple values of this */
97 #define OCSPD_DBATTR_CERT_ID DB_ATTRIBUTE("CertID", BLOB)
98 /* URI */
99 #define OCSPD_DBATTR_URI DB_ATTRIBUTE("URI", STRING)
100 /* Expiration time, CSSM_TIMESTRING format */
101 #define OCSPD_DBATTR_EXPIRATION DB_ATTRIBUTE("Expiration", STRING)
102
103 #define OCSPD_NUM_DB_ATTRS 3
104
105 #endif /* _OCSPD_DB_SCHEMA_H_ */
106