]> git.saurik.com Git - apple/security.git/blob - AppleX509CL/SnaccUtils.h
Security-30.1.tar.gz
[apple/security.git] / AppleX509CL / SnaccUtils.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 * SnaccUtils.h - snacc-related cert functions
21 *
22 * Created 9/1/2000 by Doug Mitchell.
23 * Copyright (c) 2000 by Apple Computer.
24 */
25
26 #ifndef _SNACC_UTILS_H_
27 #define _SNACC_UTILS_H_
28
29 #include <Security/cssmtype.h>
30 #include <Security/x509defs.h>
31 #include <Security/certextensions.h>
32 #include <Security/cssmdata.h>
33
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>
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51
52 void
53 CL_certDecodeComponents(
54 const CssmData &signedCert, // DER-encoded
55 CssmOwnedData &TBSCert, // still DER-encoded
56 CssmOwnedData &algId, // ditto
57 CssmOwnedData &sig); // ditto
58
59 void
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
65
66 void CL_snaccOidToCssm(
67 const AsnOid &inOid,
68 CssmOid &outOid,
69 CssmAllocator &alloc);
70
71 /* convert algorithm identifier between CSSM and snacc formats */
72 void CL_cssmAlgIdToSnacc (
73 const CSSM_X509_ALGORITHM_IDENTIFIER &cssmAlgId,
74 AlgorithmIdentifier &snaccAlgId);
75
76 void CL_snaccAlgIdToCssm (
77 const AlgorithmIdentifier &snaccAlgId,
78 CSSM_X509_ALGORITHM_IDENTIFIER &cssmAlgId,
79 CssmAllocator &alloc);
80
81 /* convert between uint32-style CSSM algorithm and snacc-style AsnOid */
82 CSSM_ALGORITHMS CL_snaccOidToCssmAlg(
83 const AsnOid &oid);
84
85 void CL_cssmAlgToSnaccOid(
86 CSSM_ALGORITHMS cssmAlg,
87 AsnOid &oid);
88
89 /* set up a encoded NULL for AlgorithmIdentifier.parameters */
90 void CL_nullAlgParams(
91 AlgorithmIdentifier &snaccAlgId);
92
93 /* AsnOcts --> CSSM_DATA */
94 void CL_AsnOctsToCssmData(
95 const AsnOcts &octs,
96 CSSM_DATA &cdata,
97 CssmAllocator &alloc);
98
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);
105
106 /* CE_GeneralNames --> snacc-style GeneralNames */
107 GeneralNames *CL_cdsaGeneralNamesToSnacc(
108 CE_GeneralNames &cdsaObj);
109
110 #define MAX_RDN_SIZE (4 * 1024)
111
112 void CL_normalizeString(
113 char *strPtr,
114 int &strLen);
115 void CL_normalizeX509Name(
116 Name &name,
117 CssmAllocator &alloc);
118
119 #ifdef __cplusplus
120 }
121 #endif
122
123 #endif /* _SNACC_UTILS_H_ */
124