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_utilities/alloc.h>
30#include "TPCertInfo.h"
31
32#ifdef	__cplusplus
33extern "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
41void tpCopyCssmData(
42	Allocator		&alloc,
43	const CSSM_DATA	*src,
44	CSSM_DATA_PTR	dst);
45CSSM_DATA_PTR tpMallocCopyCssmData(
46	Allocator		&alloc,
47	const CSSM_DATA	*src);
48void tpFreeCssmData(
49	Allocator		&alloc,
50	CSSM_DATA_PTR 	data,
51	CSSM_BOOL 		freeStruct);
52CSSM_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
62void tpFreePluginMemory(
63	CSSM_HANDLE	hand,
64	void 		*p);
65
66CSSM_DATA_PTR tp_CertGetPublicKey(
67	TPCertInfo 		*cert,
68	CSSM_DATA_PTR 	*valueToFree);			// used in tp_CertFreePublicKey
69void tp_CertFreePublicKey(
70	CSSM_CL_HANDLE	clHand,
71	CSSM_DATA_PTR	value);
72
73CSSM_X509_ALGORITHM_IDENTIFIER_PTR tp_CertGetAlgId(
74    TPCertInfo	 	*cert,
75	CSSM_DATA_PTR 	*valueToFree);	// used in tp_CertFreeAlgId
76void tp_CertFreeAlgId(
77	CSSM_CL_HANDLE	clHand,
78	CSSM_DATA_PTR	value);
79
80CSSM_BOOL tp_CompareCerts(
81	const CSSM_DATA			*cert1,
82	const CSSM_DATA			*cert2);
83
84void tpToLower(
85	char *str,
86	unsigned strLen);
87
88void tpNormalizeAddrSpec(
89	char		*addr,
90	unsigned	addrLen,
91	bool		normalizeAll);
92
93CSSM_BOOL tpCompareHostNames(
94	const char	 	*hostName,			// spec'd by app, tpToLower'd
95	uint32			hostNameLen,
96	char			*certName,			// from cert, we tpToLower
97	uint32			certNameLen);
98
99CSSM_BOOL tpCompareEmailAddr(
100	const char	 	*appEmail,		// spec'd by app, tpToLower'd
101	uint32			appEmailLen,
102	char			*certEmail,		// from cert, we tpToLower
103	uint32			certEmailLen,
104	bool			normalizeAll);	// true : lower-case all certEmail characters
105
106int decodeECDSA_SigAlgParams(
107	const CSSM_DATA *params,
108	CSSM_ALGORITHMS *cssmAlg);		/* RETURNED */
109
110#ifdef	__cplusplus
111}
112#endif
113
114#endif /* _CERT_GROUP_UTILS_H */
115