]>
Commit | Line | Data |
---|---|---|
bac41a7b A |
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> | |
29654253 | 33 | #include "DecodedCert.h" |
bac41a7b A |
34 | |
35 | /* ghastly requirements of snacc-generated cert code */ | |
36 | #include <Security/asn-incl.h> | |
37 | #include <Security/sm_vdatypes.h> | |
38 | #include <Security/sm_x501if.h> | |
39 | #include <Security/sm_x520sa.h> | |
40 | #include <Security/sm_x411mtsas.h> | |
41 | #include <Security/sm_x509cmn.h> | |
42 | #include <Security/sm_x509af.h> | |
43 | #include <Security/pkcs9oids.h> | |
44 | #include <Security/sm_x509ce.h> | |
45 | #include <Security/sm_cms.h> | |
46 | #include <Security/sm_ess.h> | |
47 | ||
48 | #ifdef __cplusplus | |
49 | extern "C" { | |
50 | #endif | |
51 | ||
52 | ||
53 | void | |
54 | CL_certDecodeComponents( | |
55 | const CssmData &signedCert, // DER-encoded | |
56 | CssmOwnedData &TBSCert, // still DER-encoded | |
57 | CssmOwnedData &algId, // ditto | |
58 | CssmOwnedData &sig); // ditto | |
59 | ||
60 | void | |
61 | CL_certEncodeComponents( | |
62 | const CssmData &TBSCert, // DER-encoded | |
63 | const CssmData &algId, // ditto | |
64 | const CssmData &rawSig, // the raw bits, not encoded | |
65 | CssmOwnedData &signedCert); // DER-encoded | |
66 | ||
67 | void CL_snaccOidToCssm( | |
68 | const AsnOid &inOid, | |
69 | CssmOid &outOid, | |
70 | CssmAllocator &alloc); | |
71 | ||
72 | /* convert algorithm identifier between CSSM and snacc formats */ | |
73 | void CL_cssmAlgIdToSnacc ( | |
74 | const CSSM_X509_ALGORITHM_IDENTIFIER &cssmAlgId, | |
75 | AlgorithmIdentifier &snaccAlgId); | |
76 | ||
77 | void CL_snaccAlgIdToCssm ( | |
78 | const AlgorithmIdentifier &snaccAlgId, | |
79 | CSSM_X509_ALGORITHM_IDENTIFIER &cssmAlgId, | |
80 | CssmAllocator &alloc); | |
81 | ||
82 | /* convert between uint32-style CSSM algorithm and snacc-style AsnOid */ | |
83 | CSSM_ALGORITHMS CL_snaccOidToCssmAlg( | |
84 | const AsnOid &oid); | |
85 | ||
86 | void CL_cssmAlgToSnaccOid( | |
87 | CSSM_ALGORITHMS cssmAlg, | |
88 | AsnOid &oid); | |
89 | ||
90 | /* set up a encoded NULL for AlgorithmIdentifier.parameters */ | |
91 | void CL_nullAlgParams( | |
92 | AlgorithmIdentifier &snaccAlgId); | |
93 | ||
94 | /* AsnOcts --> CSSM_DATA */ | |
95 | void CL_AsnOctsToCssmData( | |
96 | const AsnOcts &octs, | |
97 | CSSM_DATA &cdata, | |
98 | CssmAllocator &alloc); | |
99 | ||
100 | /* snacc-style GeneralNames --> CE_GeneralNames */ | |
101 | /* GeneralNames from sm_x509cmn.h */ | |
102 | void CL_snaccGeneralNamesToCdsa( | |
103 | GeneralNames &snaccObj, | |
104 | CE_GeneralNames &cdsaObj, | |
105 | CssmAllocator &alloc); | |
106 | ||
107 | /* CE_GeneralNames --> snacc-style GeneralNames */ | |
108 | GeneralNames *CL_cdsaGeneralNamesToSnacc( | |
109 | CE_GeneralNames &cdsaObj); | |
110 | ||
111 | #define MAX_RDN_SIZE (4 * 1024) | |
112 | ||
113 | void CL_normalizeString( | |
114 | char *strPtr, | |
115 | int &strLen); | |
116 | void CL_normalizeX509Name( | |
117 | Name &name, | |
118 | CssmAllocator &alloc); | |
119 | ||
29654253 A |
120 | /* |
121 | * Obtain a CSSM_KEY from a SubjectPublicKeyInfo, inferring as much as we can | |
122 | * from required fields (subjectPublicKeyInfo) and extensions (for | |
123 | * KeyUse, obtained from the optional DecodedCert). | |
124 | */ | |
125 | CSSM_KEY_PTR CL_extractCSSMKey( | |
126 | SubjectPublicKeyInfo &snaccKeyInfo, | |
127 | CssmAllocator &alloc, | |
128 | const DecodedCert *decodedCert); // optional | |
129 | ||
130 | /* | |
131 | * Free key obtained in CL_extractCSSMKey(). | |
132 | */ | |
133 | void CL_freeCSSMKey( | |
134 | CSSM_KEY_PTR cssmKey, | |
135 | CssmAllocator &alloc, | |
136 | bool freeTop = true); // delete the actual key | |
137 | // as well as contents | |
138 | ||
bac41a7b A |
139 | #ifdef __cplusplus |
140 | } | |
141 | #endif | |
142 | ||
143 | #endif /* _SNACC_UTILS_H_ */ | |
144 |