1/*
2 * Copyright (c) 2003 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 * clNameUtils.h - support for Name, GeneralizedName, all sorts of names
20 */
21
22#ifndef	_CL_NAME_UTILS_H_
23#define _CL_NAME_UTILS_H_
24
25#include <Security/cssmtype.h>
26#include <security_utilities/alloc.h>
27#include <Security/x509defs.h>
28#include <Security/certextensions.h>
29#include <Security/X509Templates.h>
30#include <security_asn1/SecNssCoder.h>
31
32void CL_nssAtvToCssm(
33	const NSS_ATV				&nssObj,
34	CSSM_X509_TYPE_VALUE_PAIR	&cssmObj,
35	Allocator				&alloc
36	#if !NSS_TAGGED_ITEMS
37	, SecNssCoder					&coder
38	#endif
39	);
40void CL_nssRdnToCssm(
41	const NSS_RDN				&nssObj,
42	CSSM_X509_RDN				&cssmObj,
43	Allocator				&alloc,
44	SecNssCoder					&coder);
45void CL_nssNameToCssm(
46	const NSS_Name				&nssObj,
47	CSSM_X509_NAME				&cssmObj,
48	Allocator				&alloc);
49
50void CL_cssmAtvToNss(
51	const CSSM_X509_TYPE_VALUE_PAIR	&cssmObj,
52	NSS_ATV							&nssObj,
53	SecNssCoder						&coder);
54void CL_cssmRdnToNss(
55	const CSSM_X509_RDN			&cssmObj,
56	NSS_RDN						&nssObj,
57	SecNssCoder					&coder);
58void CL_cssmNameToNss(
59	const CSSM_X509_NAME		&cssmObj,
60	NSS_Name					&nssObj,
61	SecNssCoder					&coder);
62
63void CL_normalizeString(
64	char 						*strPtr,
65	int 						&strLen);		// IN/OUT
66void CL_normalizeX509NameNSS(
67	NSS_Name 					&nssName,
68	SecNssCoder 				&coder);
69
70void CL_nssGeneralNameToCssm(
71	NSS_GeneralName &nssObj,
72	CE_GeneralName &cdsaObj,
73	SecNssCoder &coder,				// for temp decoding
74	Allocator &alloc);			// destination
75
76void CL_nssGeneralNamesToCssm(
77	const NSS_GeneralNames &nssObj,
78	CE_GeneralNames &cdsaObj,
79	SecNssCoder &coder,				// for temp decoding
80	Allocator &alloc);			// destination
81void CL_cssmGeneralNameToNss(
82	CE_GeneralName &cdsaObj,
83	NSS_GeneralName &nssObj,		// actually an NSSTaggedItem
84	SecNssCoder &coder);			// for temp decoding
85void CL_cssmGeneralNamesToNss(
86	const CE_GeneralNames &cdsaObj,
87	NSS_GeneralNames &nssObj,
88	SecNssCoder &coder);
89
90void clCopyOtherName(
91	const CE_OtherName 			&src,
92	CE_OtherName 				&dst,
93	Allocator					&alloc);
94
95void CL_freeAuthorityKeyId(
96	CE_AuthorityKeyID			&cdsaObj,
97	Allocator					&alloc);
98void CL_freeCssmGeneralName(
99	CE_GeneralName				&genName,
100	Allocator					&alloc);
101void CL_freeCssmGeneralNames(
102	CE_GeneralNames				*cdsaObj,
103	Allocator					&alloc);
104void CL_freeCssmDistPointName(
105	CE_DistributionPointName	*cssmDpn,
106	Allocator					&alloc);
107void CL_freeCssmDistPoints(
108	CE_CRLDistPointsSyntax		*cssmDps,
109	Allocator					&alloc);
110void CL_freeX509Name(
111	CSSM_X509_NAME_PTR			x509Name,
112	Allocator					&alloc);
113void CL_freeX509Rdn(
114	CSSM_X509_RDN_PTR			rdn,
115	Allocator					&alloc);
116void CL_freeOtherName(
117	CE_OtherName				*cssmOther,
118	Allocator					&alloc);
119void CL_freeCssmIssuingDistPoint(
120	CE_IssuingDistributionPoint	*cssmIdp,
121	Allocator					&alloc);
122
123
124#endif	/* _CL_NAME_UTILS_H_ */
125