2  * Copyright (c) 2004,2011,2014 Apple 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@ 
  27  * Definitions of structures which define the schema, including attributes 
  28  * and indexes, for the standard tables that are part of the OCSP server 
  32 #ifndef _OCSPD_DB_SCHEMA_H_ 
  33 #define _OCSPD_DB_SCHEMA_H_ 
  35 #include <Security/cssmtype.h> 
  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. 
  43         CSSM_DB_RECORDTYPE                              recordType
; 
  44         const char                                              *relationName
; 
  45         uint32                                                  numberOfAttributes
; 
  46         const CSSM_DB_ATTRIBUTE_INFO    
*attrInfo
; 
  48         const CSSM_DB_INDEX_INFO                
*indexInfo
; 
  49 } OcspdDbRelationInfo
; 
  51 // Macros used to simplify declarations of attributes and indexes. 
  53 // declare a CSSM_DB_ATTRIBUTE_INFO 
  54 #define DB_ATTRIBUTE(name, type) \ 
  55         {  CSSM_DB_ATTRIBUTE_NAME_AS_STRING, \ 
  57            CSSM_DB_ATTRIBUTE_FORMAT_ ## type \ 
  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, \ 
  66                   CSSM_DB_ATTRIBUTE_FORMAT_ ## type \ 
  70 // declare a OcspdDbRelationInfo 
  71 #define RELATION_INFO(relationId, name, attributes, indexes) \ 
  74           sizeof(attributes) / sizeof(CSSM_DB_ATTRIBUTE_INFO), \ 
  76           sizeof(indexes) / sizeof(CSSM_DB_INDEX_INFO), \ 
  80  * Currently there is only one relation in the OCSPD database; this is an array 
  83 extern const OcspdDbRelationInfo kOcspDbRelations
[]; 
  84 extern unsigned kNumOcspDbRelations
; 
  87  * CSSM_DB_RECORDTYPE for the ocspd DB schema. 
  89 #define OCSPD_DB_RECORDTYPE             0x11223344 
  92  * Here are the attribute names and formats in kOcspDbRelation. All attributes 
  93  * have format CSSM_DB_ATTRIBUTE_NAME_AS_STRING.  
  96 /* DER encoded CertID - a record can have multiple values of this */ 
  97 #define OCSPD_DBATTR_CERT_ID                    DB_ATTRIBUTE("CertID", BLOB) 
  99 #define OCSPD_DBATTR_URI                                DB_ATTRIBUTE("URI", STRING) 
 100  /* Expiration time, CSSM_TIMESTRING format */ 
 101 #define OCSPD_DBATTR_EXPIRATION                 DB_ATTRIBUTE("Expiration", STRING) 
 103 #define OCSPD_NUM_DB_ATTRS              3 
 105 #endif /* _OCSPD_DB_SCHEMA_H_ */