]> git.saurik.com Git - apple/security.git/blob - AppleX509TP/certGroupUtils.h
Security-28.tar.gz
[apple/security.git] / AppleX509TP / certGroupUtils.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, 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 certGroupUtils.h
21
22 Created 10/9/2000 by Doug Mitchell.
23 */
24
25 #ifndef _CERT_GROUP_UTILS_H
26 #define _CERT_GROUP_UTILS_H
27
28 #include <Security/x509defs.h>
29 #include <Security/cssmalloc.h>
30 #include "TPCertInfo.h"
31 /*
32 * Cheetah version of TP doesn't work with DLs.
33 */
34 #define TP_DL_ENABLE 0
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /* quick & dirty port from OS9 to OS X... */
41 #define tpFree(alloc, ptr) (alloc).free(ptr)
42 #define tpMalloc(alloc, size) (alloc).malloc(size)
43 #define tpCalloc(alloc, num, size) (alloc).calloc(num, size)
44
45 void tpCopyCssmData(
46 CssmAllocator &alloc,
47 const CSSM_DATA *src,
48 CSSM_DATA_PTR dst);
49 CSSM_DATA_PTR tpMallocCopyCssmData(
50 CssmAllocator &alloc,
51 const CSSM_DATA *src);
52 void tpFreeCssmData(
53 CssmAllocator &alloc,
54 CSSM_DATA_PTR data,
55 CSSM_BOOL freeStruct);
56 CSSM_BOOL tpCompareCssmData(
57 const CSSM_DATA *data1,
58 const CSSM_DATA *data2);
59 CSSM_BOOL tpCompareOids(
60 const CSSM_OID *oid1,
61 const CSSM_OID *oid2);
62
63 CSSM_DATA_PTR tp_CertGetPublicKey(
64 TPCertInfo *cert,
65 CSSM_DATA_PTR *valueToFree); // used in tp_CertFreePublicKey
66 void tp_CertFreePublicKey(
67 CSSM_CL_HANDLE clHand,
68 CSSM_DATA_PTR value);
69
70 CSSM_X509_ALGORITHM_IDENTIFIER_PTR tp_CertGetAlgId(
71 TPCertInfo *cert,
72 CSSM_DATA_PTR *valueToFree); // used in tp_CertFreeAlgId
73 void tp_CertFreeAlgId(
74 CSSM_CL_HANDLE clHand,
75 CSSM_DATA_PTR value);
76
77 #if TP_DL_ENABLE
78 CSSM_DATA_PTR
79 tp_GetCertFromDBList( CSSM_TP_HANDLE hTP,
80 CSSM_CL_HANDLE hCL,
81 CSSM_SELECTION_PREDICATE_PTR pPredicate,
82 uint32 NumberOfPredicates,
83 const CSSM_DB_LIST_PTR pDBList );
84
85 CSSM_DATA_PTR
86 tp_GetCertFromDBListBySName( CSSM_TP_HANDLE hTP,
87 CSSM_CL_HANDLE hCL,
88 const CSSM_DATA_PTR pSubjectName,
89 const CSSM_DB_LIST_PTR pDBList );
90
91 #endif /* TP_DL_ENABLE*/
92
93 CSSM_BOOL tpIsSameName(
94 const CSSM_DATA *pName1,
95 const CSSM_DATA *pName2);
96
97 CSSM_RETURN tp_VerifyCert(
98 CSSM_CL_HANDLE clHand,
99 CSSM_CSP_HANDLE cspHand,
100 TPCertInfo *subjectCert,
101 TPCertInfo *issuerCert,
102 CSSM_BOOL checkIssuerCurrent,
103 CSSM_BOOL allowExpired);
104
105 CSSM_BOOL tp_CompareCerts(
106 const CSSM_DATA *cert1,
107 const CSSM_DATA *cert2);
108
109 #if TP_DL_ENABLE
110 /*
111 * Search a list of DBs for a cert which verifies specified subject cert.
112 * Just a boolean return - we found it, or not.
113 */
114 CSSM_DATA_PTR tpFindIssuer(
115 CSSM_TP_HANDLE tpHand,
116 CSSM_CL_HANDLE clHand,
117 CSSM_CSP_HANDLE cspHand,
118 const CSSM_DATA_PTR subjectCert,
119 const CSSM_DATA_PTR issuerName, // passed for convenience
120 const CSSM_DB_LIST_PTR dbList,
121 CSSM_BOOL *subjectExpired); // RETURNED
122 #endif
123
124 /*
125 * Given an OID, return the corresponding CSSM_ALGID.
126 */
127 CSSM_ALGORITHMS tpOidToAldId(
128 const CSSM_OID *oid,
129 CSSM_ALGORITHMS *keyAlg); // RETURNED
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /* _CERT_GROUP_UTILS_H */