1/* 2 * Copyright (c) 2004,2011,2014 Apple 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// dl_standard - standard-defined DL record types. 21// 22// These are the C++ record types corresponding to standard and Apple-defined 23// DL relations. Note that not all standard fields are included; only those 24// of particular interest to the implementation. Feel free to add field functions 25// as needed. 26// 27 28#ifndef _H_CDSA_CLIENT_DL_STANDARD 29#define _H_CDSA_CLIENT_DL_STANDARD 30 31#include <security_cdsa_client/dlclient.h> 32 33 34namespace Security { 35namespace CssmClient { 36 37 38// 39// All CDSA standard DL schemas contain these fields 40// 41class DLCommonFields : public Record { 42public: 43 DLCommonFields(const char * const * names); 44 45 string printName() const; 46 string alias() const; 47}; 48 49 50// 51// A record type for all records in a DL, with PrintName (only) 52// 53class AllDLRecords : public DLCommonFields { 54public: 55 AllDLRecords(); 56}; 57 58 59// 60// The CDSA-standard "generic record" table 61// 62class GenericRecord : public DLCommonFields { 63public: 64 GenericRecord(); 65 static const CSSM_DB_RECORDTYPE recordType = CSSM_DL_DB_RECORD_GENERIC; 66}; 67 68 69// 70// Generic password records (Apple specific) 71// 72class GenericPasswordRecord : public DLCommonFields { 73public: 74 GenericPasswordRecord(); 75 static const CSSM_DB_RECORDTYPE recordType = CSSM_DL_DB_RECORD_GENERIC_PASSWORD; 76}; 77 78 79// 80// Key records 81// 82class KeyRecord : public DLCommonFields { 83public: 84 KeyRecord(); 85 static const CSSM_DB_RECORDTYPE recordType = CSSM_DL_DB_RECORD_ALL_KEYS; 86 87 uint32 keyClass() const; 88 uint32 type() const; 89 uint32 size() const; 90 uint32 effectiveSize() const; 91 const CssmData &label() const; 92 const CssmData &applicationTag() const; 93 94 // boolean attributes for classification 95 bool isPermanent() const; 96 bool isPrivate() const; 97 bool isModifiable() const; 98 bool isSensitive() const; 99 bool wasAlwaysSensitive() const; 100 bool isExtractable() const; 101 bool wasNeverExtractable() const; 102 bool canEncrypt() const; 103 bool canDecrypt() const; 104 bool canDerive() const; 105 bool canSign() const; 106 bool canVerify() const; 107 bool canWrap() const; 108 bool canUnwrap() const; 109}; 110 111class PrivateKeyRecord : public KeyRecord { 112public: 113 static const CSSM_DB_RECORDTYPE recordType = CSSM_DL_DB_RECORD_PRIVATE_KEY; 114}; 115 116class PublicKeyRecord : public KeyRecord { 117public: 118 static const CSSM_DB_RECORDTYPE recordType = CSSM_DL_DB_RECORD_PUBLIC_KEY; 119}; 120 121class SymmetricKeyRecord : public KeyRecord { 122public: 123 static const CSSM_DB_RECORDTYPE recordType = CSSM_DL_DB_RECORD_SYMMETRIC_KEY; 124}; 125 126 127// 128// X509 Certificate records 129// 130class X509CertRecord : public DLCommonFields { 131public: 132 X509CertRecord(); 133 static const CSSM_DB_RECORDTYPE recordType = CSSM_DL_DB_RECORD_X509_CERTIFICATE; 134 135 CSSM_CERT_TYPE type() const; 136 CSSM_CERT_ENCODING encoding() const; 137 const CssmData &subject() const; 138 const CssmData &issuer() const; 139 const CssmData &serial() const; 140 const CssmData &subjectKeyIdentifier() const; 141 const CssmData &publicKeyHash() const; 142}; 143 144 145// 146// Unlock referral records 147// 148class UnlockReferralRecord : public DLCommonFields { 149public: 150 UnlockReferralRecord(); 151 static const CSSM_DB_RECORDTYPE recordType = CSSM_DL_DB_RECORD_UNLOCK_REFERRAL; 152 153 uint32 type() const; 154 string dbName() const; 155 const CssmData &dbNetname() const; 156 const Guid &dbGuid() const; 157 uint32 dbSSID() const; 158 uint32 dbSSType() const; 159 const CssmData &keyLabel() const; 160 const CssmData &keyApplicationTag() const; 161}; 162 163 164} // end namespace CssmClient 165} // end namespace Security 166 167#endif // _H_CDSA_CLIENT_DL_STANDARD 168