2 * Copyright (c) 2000-2001,2011,2014 Apple Inc. All Rights Reserved.
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
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.
20 * CLCachedEntry.h - classes representing cached certs and CRLs.
22 * Copyright (c) 2000,2011,2014 Apple Inc.
25 #ifndef _APPLE_X509_CL_CACHED_ENTRY_H_
26 #define _APPLE_X509_CL_CACHED_ENTRY_H_
28 #include <Security/cssmtype.h>
29 #include <security_utilities/utilities.h>
30 #include <security_cdsa_utilities/cssmdata.h>
31 #include "DecodedCert.h"
32 #include "DecodedCrl.h"
35 * There is one of these per active cached object (cert or CRL).
36 * AppleX509CLSession keeps a map of these in cacheMap.
42 virtual ~CLCachedEntry() { }
43 CSSM_HANDLE
handle() { return mHandle
; }
48 class CLCachedCert
: public CLCachedEntry
52 DecodedCert
&c
) : mCert(c
) { }
54 DecodedCert
&cert() { return mCert
; }
56 /* decoded NSS format */
60 class CLCachedCRL
: public CLCachedEntry
64 DecodedCrl
&c
) : mCrl(c
) { }
66 DecodedCrl
&crl() { return mCrl
; }
68 /* decoded NSS format */
73 * An active query, always associated with a CLCachedEntry.
74 * AppleX509CLSession keeps a map of these in queryMap.
76 * In the case of a CLCachedEntry created by an explicit {Cert,CRL}Cache op,
77 * there can be multiple queries active for a given cached cert. In
78 * the *GetFirst*FieldValue case, there is a one-to-one relationship between
79 * the CLQUery and its associated cached object.
81 * Out of paranoia in the {Cert,CRL}Cache case, we store the handle of
82 * the associated cached object, not a ref to the object, in case the
83 * cached object has been deleted via *AbortCache. We could ref count,
84 * but that would require a lock in CLCachedEntry...looking up an object
85 * in the session's cache map should not be too expensive.
101 CSSM_HANDLE cachedObj
);
106 * Accessors - all member variables are invariant after creation, except
107 * for nextIndex which can only increment
109 CLQueryType
queryType() { return mQueryType
; }
110 const CssmOid
&fieldId() { return mFieldId
; }
111 unsigned nextIndex() { return mNextIndex
; }
112 void incrementIndex(){ mNextIndex
++; }
113 unsigned numFields() { return mNumFields
; }
114 bool fromCache() { return mFromCache
; }
115 CSSM_HANDLE
cachedObject() { return mCachedObject
; }
116 CSSM_HANDLE
handle() { return mHandle
;}
119 CLQueryType mQueryType
;
120 CssmAutoData mFieldId
; // thing we're searching for - may be empty
121 unsigned mNextIndex
; // index of next find op
122 unsigned mNumFields
; // total available
123 bool mFromCache
; // true : via CertGetFirstCachedFieldValue
124 // false : via CertGetFirstFieldValue
125 CSSM_HANDLE mCachedObject
; // of our associated cached cert/CRL
126 CSSM_HANDLE mHandle
; // ours
129 #endif /* _APPLE_X509_CL_CACHED_ENTRY_H_ */