]> git.saurik.com Git - apple/security.git/blob - AppleX509TP/certGroupUtils.h
Security-177.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 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /* quick & dirty port from OS9 to OS X... */
37 #define tpFree(alloc, ptr) (alloc).free(ptr)
38 #define tpMalloc(alloc, size) (alloc).malloc(size)
39 #define tpCalloc(alloc, num, size) (alloc).calloc(num, size)
40
41 void tpCopyCssmData(
42 CssmAllocator &alloc,
43 const CSSM_DATA *src,
44 CSSM_DATA_PTR dst);
45 CSSM_DATA_PTR tpMallocCopyCssmData(
46 CssmAllocator &alloc,
47 const CSSM_DATA *src);
48 void tpFreeCssmData(
49 CssmAllocator &alloc,
50 CSSM_DATA_PTR data,
51 CSSM_BOOL freeStruct);
52 CSSM_BOOL tpCompareCssmData(
53 const CSSM_DATA *data1,
54 const CSSM_DATA *data2);
55
56 /*
57 * This should break if/when CSSM_OID is not the same as
58 * CSSM_DATA, which is exactly what we want.
59 */
60 #define tpCompareOids(oid1, oid2) tpCompareCssmData(oid1, oid2)
61
62 void tpFreePluginMemory(
63 CSSM_HANDLE hand,
64 void *p);
65
66 CSSM_DATA_PTR tp_CertGetPublicKey(
67 TPCertInfo *cert,
68 CSSM_DATA_PTR *valueToFree); // used in tp_CertFreePublicKey
69 void tp_CertFreePublicKey(
70 CSSM_CL_HANDLE clHand,
71 CSSM_DATA_PTR value);
72
73 CSSM_X509_ALGORITHM_IDENTIFIER_PTR tp_CertGetAlgId(
74 TPCertInfo *cert,
75 CSSM_DATA_PTR *valueToFree); // used in tp_CertFreeAlgId
76 void tp_CertFreeAlgId(
77 CSSM_CL_HANDLE clHand,
78 CSSM_DATA_PTR value);
79
80 CSSM_BOOL tp_CompareCerts(
81 const CSSM_DATA *cert1,
82 const CSSM_DATA *cert2);
83
84 /*
85 * Given an OID, return the corresponding CSSM_ALGID.
86 */
87 CSSM_ALGORITHMS tpOidToAldId(
88 const CSSM_OID *oid,
89 CSSM_ALGORITHMS *keyAlg); // RETURNED
90
91 void tpToLower(
92 char *str,
93 unsigned strLen);
94
95 void tpNormalizeAddrSpec(
96 char *addr,
97 unsigned addrLen);
98
99 CSSM_BOOL tpCompareHostNames(
100 const char *hostName, // spec'd by app, tpToLower'd
101 uint32 hostNameLen,
102 char *certName, // from cert, we tpToLower
103 uint32 certNameLen);
104
105 CSSM_BOOL tpCompareEmailAddr(
106 const char *appEmail, // spec'd by app, tpToLower'd
107 uint32 appEmailLen,
108 char *certEmail, // from cert, we tpToLower
109 uint32 certEmailLen);
110
111 #ifdef __cplusplus
112 }
113 #endif
114
115 #endif /* _CERT_GROUP_UTILS_H */