2 * Copyright (c) 2000-2001 Apple Computer, 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 * SnaccUtils.h - snacc-related cert functions
22 * Created 9/1/2000 by Doug Mitchell.
23 * Copyright (c) 2000 by Apple Computer.
26 #ifndef _SNACC_UTILS_H_
27 #define _SNACC_UTILS_H_
29 #include <Security/cssmtype.h>
30 #include <Security/x509defs.h>
31 #include <Security/certextensions.h>
32 #include <Security/cssmdata.h>
34 /* ghastly requirements of snacc-generated cert code */
35 #include <Security/asn-incl.h>
36 #include <Security/sm_vdatypes.h>
37 #include <Security/sm_x501if.h>
38 #include <Security/sm_x520sa.h>
39 #include <Security/sm_x411mtsas.h>
40 #include <Security/sm_x509cmn.h>
41 #include <Security/sm_x509af.h>
42 #include <Security/pkcs9oids.h>
43 #include <Security/sm_x509ce.h>
44 #include <Security/sm_cms.h>
45 #include <Security/sm_ess.h>
53 CL_certDecodeComponents(
54 const CssmData
&signedCert
, // DER-encoded
55 CssmOwnedData
&TBSCert
, // still DER-encoded
56 CssmOwnedData
&algId
, // ditto
57 CssmOwnedData
&sig
); // ditto
60 CL_certEncodeComponents(
61 const CssmData
&TBSCert
, // DER-encoded
62 const CssmData
&algId
, // ditto
63 const CssmData
&rawSig
, // the raw bits, not encoded
64 CssmOwnedData
&signedCert
); // DER-encoded
66 void CL_snaccOidToCssm(
69 CssmAllocator
&alloc
);
71 /* convert algorithm identifier between CSSM and snacc formats */
72 void CL_cssmAlgIdToSnacc (
73 const CSSM_X509_ALGORITHM_IDENTIFIER
&cssmAlgId
,
74 AlgorithmIdentifier
&snaccAlgId
);
76 void CL_snaccAlgIdToCssm (
77 const AlgorithmIdentifier
&snaccAlgId
,
78 CSSM_X509_ALGORITHM_IDENTIFIER
&cssmAlgId
,
79 CssmAllocator
&alloc
);
81 /* convert between uint32-style CSSM algorithm and snacc-style AsnOid */
82 CSSM_ALGORITHMS
CL_snaccOidToCssmAlg(
85 void CL_cssmAlgToSnaccOid(
86 CSSM_ALGORITHMS cssmAlg
,
89 /* set up a encoded NULL for AlgorithmIdentifier.parameters */
90 void CL_nullAlgParams(
91 AlgorithmIdentifier
&snaccAlgId
);
93 /* AsnOcts --> CSSM_DATA */
94 void CL_AsnOctsToCssmData(
97 CssmAllocator
&alloc
);
99 /* snacc-style GeneralNames --> CE_GeneralNames */
100 /* GeneralNames from sm_x509cmn.h */
101 void CL_snaccGeneralNamesToCdsa(
102 GeneralNames
&snaccObj
,
103 CE_GeneralNames
&cdsaObj
,
104 CssmAllocator
&alloc
);
106 /* CE_GeneralNames --> snacc-style GeneralNames */
107 GeneralNames
*CL_cdsaGeneralNamesToSnacc(
108 CE_GeneralNames
&cdsaObj
);
110 #define MAX_RDN_SIZE (4 * 1024)
112 void CL_normalizeString(
115 void CL_normalizeX509Name(
117 CssmAllocator
&alloc
);
123 #endif /* _SNACC_UTILS_H_ */