OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 #include "plarena.h" | 5 #include "plarena.h" |
6 | 6 |
7 #include "seccomon.h" | 7 #include "seccomon.h" |
8 #include "secitem.h" | 8 #include "secitem.h" |
9 #include "secasn1.h" | 9 #include "secasn1.h" |
10 #include "secder.h" | 10 #include "secder.h" |
11 #include "cert.h" | 11 #include "cert.h" |
12 #include "secerr.h" | 12 #include "secerr.h" |
13 #include "secoid.h" | 13 #include "secoid.h" |
14 #include "sechash.h" | 14 #include "sechash.h" |
15 #include "keyhi.h" | 15 #include "keyhi.h" |
16 #include "cryptohi.h" | 16 #include "cryptohi.h" |
17 #include "ocsp.h" | 17 #include "ocsp.h" |
18 #include "ocspti.h" | 18 #include "ocspti.h" |
19 #include "ocspi.h" | 19 #include "ocspi.h" |
20 #include "pk11pub.h" | 20 #include "pk11pub.h" |
21 | 21 |
22 | |
23 extern const SEC_ASN1Template ocsp_ResponderIDByNameTemplate[]; | 22 extern const SEC_ASN1Template ocsp_ResponderIDByNameTemplate[]; |
24 extern const SEC_ASN1Template ocsp_ResponderIDByKeyTemplate[]; | 23 extern const SEC_ASN1Template ocsp_ResponderIDByKeyTemplate[]; |
25 extern const SEC_ASN1Template ocsp_OCSPResponseTemplate[]; | 24 extern const SEC_ASN1Template ocsp_OCSPResponseTemplate[]; |
26 | 25 |
27 ocspCertStatus* | 26 ocspCertStatus * |
28 ocsp_CreateCertStatus(PLArenaPool *arena, | 27 ocsp_CreateCertStatus(PLArenaPool *arena, |
29 ocspCertStatusType status, | 28 ocspCertStatusType status, |
30 PRTime revocationTime) | 29 PRTime revocationTime) |
31 { | 30 { |
32 ocspCertStatus *cs; | 31 ocspCertStatus *cs; |
33 | 32 |
34 if (!arena) { | 33 if (!arena) { |
35 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 34 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
36 return NULL; | 35 return NULL; |
37 } | 36 } |
38 | 37 |
39 switch (status) { | 38 switch (status) { |
40 case ocspCertStatus_good: | 39 case ocspCertStatus_good: |
41 case ocspCertStatus_unknown: | 40 case ocspCertStatus_unknown: |
42 case ocspCertStatus_revoked: | 41 case ocspCertStatus_revoked: |
43 break; | 42 break; |
44 default: | 43 default: |
45 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 44 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
46 return NULL; | 45 return NULL; |
47 } | 46 } |
48 | 47 |
49 cs = PORT_ArenaZNew(arena, ocspCertStatus); | 48 cs = PORT_ArenaZNew(arena, ocspCertStatus); |
50 if (!cs) | 49 if (!cs) |
51 return NULL; | 50 return NULL; |
52 cs->certStatusType = status; | 51 cs->certStatusType = status; |
53 switch (status) { | 52 switch (status) { |
54 case ocspCertStatus_good: | 53 case ocspCertStatus_good: |
55 cs->certStatusInfo.goodInfo = SECITEM_AllocItem(arena, NULL, 0); | 54 cs->certStatusInfo.goodInfo = SECITEM_AllocItem(arena, NULL, 0); |
56 if (!cs->certStatusInfo.goodInfo) | 55 if (!cs->certStatusInfo.goodInfo) |
57 return NULL; | 56 return NULL; |
58 break; | 57 break; |
59 case ocspCertStatus_unknown: | 58 case ocspCertStatus_unknown: |
60 cs->certStatusInfo.unknownInfo = SECITEM_AllocItem(arena, NULL, 0); | 59 cs->certStatusInfo.unknownInfo = SECITEM_AllocItem(arena, NULL, 0); |
61 if (!cs->certStatusInfo.unknownInfo) | 60 if (!cs->certStatusInfo.unknownInfo) |
62 return NULL; | 61 return NULL; |
63 break; | 62 break; |
64 case ocspCertStatus_revoked: | 63 case ocspCertStatus_revoked: |
65 cs->certStatusInfo.revokedInfo = | 64 cs->certStatusInfo.revokedInfo = |
66 PORT_ArenaZNew(arena, ocspRevokedInfo); | 65 PORT_ArenaZNew(arena, ocspRevokedInfo); |
67 if (!cs->certStatusInfo.revokedInfo) | 66 if (!cs->certStatusInfo.revokedInfo) |
68 return NULL; | 67 return NULL; |
69 cs->certStatusInfo.revokedInfo->revocationReason = | 68 cs->certStatusInfo.revokedInfo->revocationReason = |
70 SECITEM_AllocItem(arena, NULL, 0); | 69 SECITEM_AllocItem(arena, NULL, 0); |
71 if (!cs->certStatusInfo.revokedInfo->revocationReason) | 70 if (!cs->certStatusInfo.revokedInfo->revocationReason) |
72 return NULL; | 71 return NULL; |
73 if (DER_TimeToGeneralizedTimeArena(arena, | 72 if (DER_TimeToGeneralizedTimeArena(arena, |
74 &cs->certStatusInfo.revokedInfo->revocationTime, | 73 &cs->certStatusInfo.revokedInfo->
revocationTime, |
75 revocationTime) != SECSuccess) | 74 revocationTime) != |
| 75 SECSuccess) |
76 return NULL; | 76 return NULL; |
77 break; | 77 break; |
78 default: | 78 default: |
79 PORT_Assert(PR_FALSE); | 79 PORT_Assert(PR_FALSE); |
80 } | 80 } |
81 return cs; | 81 return cs; |
82 } | 82 } |
83 | 83 |
84 static const SEC_ASN1Template mySEC_EnumeratedTemplate[] = { | 84 static const SEC_ASN1Template mySEC_EnumeratedTemplate[] = { |
85 { SEC_ASN1_ENUMERATED, 0, NULL, sizeof(SECItem) } | 85 { SEC_ASN1_ENUMERATED, 0, NULL, sizeof(SECItem) } |
86 }; | 86 }; |
87 | 87 |
88 static const SEC_ASN1Template mySEC_PointerToEnumeratedTemplate[] = { | 88 static const SEC_ASN1Template mySEC_PointerToEnumeratedTemplate[] = { |
89 { SEC_ASN1_POINTER, 0, mySEC_EnumeratedTemplate } | 89 { SEC_ASN1_POINTER, 0, mySEC_EnumeratedTemplate } |
90 }; | 90 }; |
91 | 91 |
92 static const SEC_ASN1Template ocsp_EncodeRevokedInfoTemplate[] = { | 92 static const SEC_ASN1Template ocsp_EncodeRevokedInfoTemplate[] = { |
93 { SEC_ASN1_GENERALIZED_TIME, | 93 { SEC_ASN1_GENERALIZED_TIME, |
94 offsetof(ocspRevokedInfo, revocationTime) }, | 94 offsetof(ocspRevokedInfo, revocationTime) }, |
95 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | | 95 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | |
96 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC| 0, | 96 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, |
97 offsetof(ocspRevokedInfo, revocationReason), | 97 offsetof(ocspRevokedInfo, revocationReason), |
98 mySEC_PointerToEnumeratedTemplate }, | 98 mySEC_PointerToEnumeratedTemplate }, |
99 { 0 } | 99 { 0 } |
100 }; | 100 }; |
101 | 101 |
102 static const SEC_ASN1Template ocsp_PointerToEncodeRevokedInfoTemplate[] = { | 102 static const SEC_ASN1Template ocsp_PointerToEncodeRevokedInfoTemplate[] = { |
103 { SEC_ASN1_POINTER, 0, | 103 { SEC_ASN1_POINTER, 0, |
104 ocsp_EncodeRevokedInfoTemplate } | 104 ocsp_EncodeRevokedInfoTemplate } |
105 }; | 105 }; |
106 | 106 |
107 static const SEC_ASN1Template mySEC_NullTemplate[] = { | 107 static const SEC_ASN1Template mySEC_NullTemplate[] = { |
108 { SEC_ASN1_NULL, 0, NULL, sizeof(SECItem) } | 108 { SEC_ASN1_NULL, 0, NULL, sizeof(SECItem) } |
109 }; | 109 }; |
110 | 110 |
111 static const SEC_ASN1Template ocsp_CertStatusTemplate[] = { | 111 static const SEC_ASN1Template ocsp_CertStatusTemplate[] = { |
112 { SEC_ASN1_CHOICE, offsetof(ocspCertStatus, certStatusType), | 112 { SEC_ASN1_CHOICE, offsetof(ocspCertStatus, certStatusType), |
113 0, sizeof(ocspCertStatus) }, | 113 0, sizeof(ocspCertStatus) }, |
114 { SEC_ASN1_CONTEXT_SPECIFIC | 0, | 114 { SEC_ASN1_CONTEXT_SPECIFIC | 0, |
115 0, mySEC_NullTemplate, ocspCertStatus_good }, | 115 0, mySEC_NullTemplate, ocspCertStatus_good }, |
116 { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | | 116 { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | |
117 SEC_ASN1_CONTEXT_SPECIFIC | 1, | 117 SEC_ASN1_CONTEXT_SPECIFIC | 1, |
118 offsetof(ocspCertStatus, certStatusInfo.revokedInfo), | 118 offsetof(ocspCertStatus, certStatusInfo.revokedInfo), |
119 ocsp_PointerToEncodeRevokedInfoTemplate, ocspCertStatus_revoked }, | 119 ocsp_PointerToEncodeRevokedInfoTemplate, ocspCertStatus_revoked }, |
120 { SEC_ASN1_CONTEXT_SPECIFIC | 2, | 120 { SEC_ASN1_CONTEXT_SPECIFIC | 2, |
121 0, mySEC_NullTemplate, ocspCertStatus_unknown }, | 121 0, mySEC_NullTemplate, ocspCertStatus_unknown }, |
122 { 0 } | 122 { 0 } |
123 }; | 123 }; |
124 | 124 |
125 static const SEC_ASN1Template mySECOID_AlgorithmIDTemplate[] = { | 125 static const SEC_ASN1Template mySECOID_AlgorithmIDTemplate[] = { |
126 { SEC_ASN1_SEQUENCE, | 126 { SEC_ASN1_SEQUENCE, |
127 0, NULL, sizeof(SECAlgorithmID) }, | 127 0, NULL, sizeof(SECAlgorithmID) }, |
128 { SEC_ASN1_OBJECT_ID, | 128 { SEC_ASN1_OBJECT_ID, |
129 offsetof(SECAlgorithmID,algorithm), }, | 129 offsetof(SECAlgorithmID, algorithm) }, |
130 { SEC_ASN1_OPTIONAL | SEC_ASN1_ANY, | 130 { SEC_ASN1_OPTIONAL | SEC_ASN1_ANY, |
131 offsetof(SECAlgorithmID,parameters), }, | 131 offsetof(SECAlgorithmID, parameters) }, |
132 { 0, } | 132 { 0 } |
133 }; | 133 }; |
134 | 134 |
135 static const SEC_ASN1Template mySEC_AnyTemplate[] = { | 135 static const SEC_ASN1Template mySEC_AnyTemplate[] = { |
136 { SEC_ASN1_ANY | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) } | 136 { SEC_ASN1_ANY | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) } |
137 }; | 137 }; |
138 | 138 |
139 static const SEC_ASN1Template mySEC_SequenceOfAnyTemplate[] = { | 139 static const SEC_ASN1Template mySEC_SequenceOfAnyTemplate[] = { |
140 { SEC_ASN1_SEQUENCE_OF, 0, mySEC_AnyTemplate } | 140 { SEC_ASN1_SEQUENCE_OF, 0, mySEC_AnyTemplate } |
141 }; | 141 }; |
142 | 142 |
143 static const SEC_ASN1Template mySEC_PointerToSequenceOfAnyTemplate[] = { | 143 static const SEC_ASN1Template mySEC_PointerToSequenceOfAnyTemplate[] = { |
144 { SEC_ASN1_POINTER, 0, mySEC_SequenceOfAnyTemplate } | 144 { SEC_ASN1_POINTER, 0, mySEC_SequenceOfAnyTemplate } |
145 }; | 145 }; |
146 | 146 |
147 static const SEC_ASN1Template mySEC_IntegerTemplate[] = { | 147 static const SEC_ASN1Template mySEC_IntegerTemplate[] = { |
148 { SEC_ASN1_INTEGER, 0, NULL, sizeof(SECItem) } | 148 { SEC_ASN1_INTEGER, 0, NULL, sizeof(SECItem) } |
149 }; | 149 }; |
150 | 150 |
151 static const SEC_ASN1Template mySEC_PointerToIntegerTemplate[] = { | 151 static const SEC_ASN1Template mySEC_PointerToIntegerTemplate[] = { |
152 { SEC_ASN1_POINTER, 0, mySEC_IntegerTemplate } | 152 { SEC_ASN1_POINTER, 0, mySEC_IntegerTemplate } |
153 }; | 153 }; |
154 | 154 |
155 static const SEC_ASN1Template mySEC_GeneralizedTimeTemplate[] = { | 155 static const SEC_ASN1Template mySEC_GeneralizedTimeTemplate[] = { |
156 { SEC_ASN1_GENERALIZED_TIME | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem)} | 156 { SEC_ASN1_GENERALIZED_TIME | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem)
} |
157 }; | 157 }; |
158 | 158 |
159 static const SEC_ASN1Template mySEC_PointerToGeneralizedTimeTemplate[] = { | 159 static const SEC_ASN1Template mySEC_PointerToGeneralizedTimeTemplate[] = { |
160 { SEC_ASN1_POINTER, 0, mySEC_GeneralizedTimeTemplate } | 160 { SEC_ASN1_POINTER, 0, mySEC_GeneralizedTimeTemplate } |
161 }; | 161 }; |
162 | 162 |
163 static const SEC_ASN1Template ocsp_myCertIDTemplate[] = { | 163 static const SEC_ASN1Template ocsp_myCertIDTemplate[] = { |
164 { SEC_ASN1_SEQUENCE, | 164 { SEC_ASN1_SEQUENCE, |
165 0, NULL, sizeof(CERTOCSPCertID) }, | 165 0, NULL, sizeof(CERTOCSPCertID) }, |
166 { SEC_ASN1_INLINE, | 166 { SEC_ASN1_INLINE, |
167 offsetof(CERTOCSPCertID, hashAlgorithm), | 167 offsetof(CERTOCSPCertID, hashAlgorithm), |
168 mySECOID_AlgorithmIDTemplate }, | 168 mySECOID_AlgorithmIDTemplate }, |
169 { SEC_ASN1_OCTET_STRING, | 169 { SEC_ASN1_OCTET_STRING, |
170 offsetof(CERTOCSPCertID, issuerNameHash) }, | 170 offsetof(CERTOCSPCertID, issuerNameHash) }, |
171 { SEC_ASN1_OCTET_STRING, | 171 { SEC_ASN1_OCTET_STRING, |
172 offsetof(CERTOCSPCertID, issuerKeyHash) }, | 172 offsetof(CERTOCSPCertID, issuerKeyHash) }, |
173 { SEC_ASN1_INTEGER, | 173 { SEC_ASN1_INTEGER, |
174 offsetof(CERTOCSPCertID, serialNumber) }, | 174 offsetof(CERTOCSPCertID, serialNumber) }, |
175 { 0 } | 175 { 0 } |
176 }; | 176 }; |
177 | 177 |
178 static const SEC_ASN1Template myCERT_CertExtensionTemplate[] = { | 178 static const SEC_ASN1Template myCERT_CertExtensionTemplate[] = { |
179 { SEC_ASN1_SEQUENCE, | 179 { SEC_ASN1_SEQUENCE, |
180 0, NULL, sizeof(CERTCertExtension) }, | 180 0, NULL, sizeof(CERTCertExtension) }, |
181 { SEC_ASN1_OBJECT_ID, | 181 { SEC_ASN1_OBJECT_ID, |
182 offsetof(CERTCertExtension,id) }, | 182 offsetof(CERTCertExtension, id) }, |
183 { SEC_ASN1_OPTIONAL | SEC_ASN1_BOOLEAN, /* XXX DER_DEFAULT */ | 183 { SEC_ASN1_OPTIONAL | SEC_ASN1_BOOLEAN, /* XXX DER_DEFAULT */ |
184 offsetof(CERTCertExtension,critical) }, | 184 offsetof(CERTCertExtension, critical) }, |
185 { SEC_ASN1_OCTET_STRING, | 185 { SEC_ASN1_OCTET_STRING, |
186 offsetof(CERTCertExtension,value) }, | 186 offsetof(CERTCertExtension, value) }, |
187 { 0, } | 187 { 0 } |
188 }; | 188 }; |
189 | 189 |
190 static const SEC_ASN1Template myCERT_SequenceOfCertExtensionTemplate[] = { | 190 static const SEC_ASN1Template myCERT_SequenceOfCertExtensionTemplate[] = { |
191 { SEC_ASN1_SEQUENCE_OF, 0, myCERT_CertExtensionTemplate } | 191 { SEC_ASN1_SEQUENCE_OF, 0, myCERT_CertExtensionTemplate } |
192 }; | 192 }; |
193 | 193 |
194 static const SEC_ASN1Template myCERT_PointerToSequenceOfCertExtensionTemplate[]
= { | 194 static const SEC_ASN1Template myCERT_PointerToSequenceOfCertExtensionTemplate[]
= { |
195 { SEC_ASN1_POINTER, 0, myCERT_SequenceOfCertExtensionTemplate } | 195 { SEC_ASN1_POINTER, 0, myCERT_SequenceOfCertExtensionTemplate } |
196 }; | 196 }; |
197 | 197 |
198 static const SEC_ASN1Template ocsp_mySingleResponseTemplate[] = { | 198 static const SEC_ASN1Template ocsp_mySingleResponseTemplate[] = { |
199 { SEC_ASN1_SEQUENCE, | 199 { SEC_ASN1_SEQUENCE, |
200 0, NULL, sizeof(CERTOCSPSingleResponse) }, | 200 0, NULL, sizeof(CERTOCSPSingleResponse) }, |
201 { SEC_ASN1_POINTER, | 201 { SEC_ASN1_POINTER, |
202 offsetof(CERTOCSPSingleResponse, certID), | 202 offsetof(CERTOCSPSingleResponse, certID), |
203 ocsp_myCertIDTemplate }, | 203 ocsp_myCertIDTemplate }, |
204 { SEC_ASN1_ANY, | 204 { SEC_ASN1_ANY, |
205 offsetof(CERTOCSPSingleResponse, derCertStatus) }, | 205 offsetof(CERTOCSPSingleResponse, derCertStatus) }, |
206 { SEC_ASN1_GENERALIZED_TIME, | 206 { SEC_ASN1_GENERALIZED_TIME, |
207 offsetof(CERTOCSPSingleResponse, thisUpdate) }, | 207 offsetof(CERTOCSPSingleResponse, thisUpdate) }, |
208 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | | 208 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | |
209 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, | 209 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, |
210 offsetof(CERTOCSPSingleResponse, nextUpdate), | 210 offsetof(CERTOCSPSingleResponse, nextUpdate), |
211 mySEC_PointerToGeneralizedTimeTemplate }, | 211 mySEC_PointerToGeneralizedTimeTemplate }, |
212 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | | 212 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | |
213 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, | 213 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, |
214 offsetof(CERTOCSPSingleResponse, singleExtensions), | 214 offsetof(CERTOCSPSingleResponse, singleExtensions), |
215 myCERT_PointerToSequenceOfCertExtensionTemplate }, | 215 myCERT_PointerToSequenceOfCertExtensionTemplate }, |
216 { 0 } | 216 { 0 } |
217 }; | 217 }; |
218 | 218 |
219 static const SEC_ASN1Template ocsp_myResponseDataTemplate[] = { | 219 static const SEC_ASN1Template ocsp_myResponseDataTemplate[] = { |
220 { SEC_ASN1_SEQUENCE, | 220 { SEC_ASN1_SEQUENCE, |
221 0, NULL, sizeof(ocspResponseData) }, | 221 0, NULL, sizeof(ocspResponseData) }, |
222 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | /* XXX DER_DEFAULT */ | 222 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | /* XXX DER_DEFAULT */ |
223 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, | 223 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, |
224 offsetof(ocspResponseData, version), | 224 offsetof(ocspResponseData, version), |
225 mySEC_PointerToIntegerTemplate }, | 225 mySEC_PointerToIntegerTemplate }, |
226 { SEC_ASN1_ANY, | 226 { SEC_ASN1_ANY, |
227 offsetof(ocspResponseData, derResponderID) }, | 227 offsetof(ocspResponseData, derResponderID) }, |
228 { SEC_ASN1_GENERALIZED_TIME, | 228 { SEC_ASN1_GENERALIZED_TIME, |
229 offsetof(ocspResponseData, producedAt) }, | 229 offsetof(ocspResponseData, producedAt) }, |
230 { SEC_ASN1_SEQUENCE_OF, | 230 { SEC_ASN1_SEQUENCE_OF, |
231 offsetof(ocspResponseData, responses), | 231 offsetof(ocspResponseData, responses), |
232 ocsp_mySingleResponseTemplate }, | 232 ocsp_mySingleResponseTemplate }, |
233 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | | 233 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | |
234 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, | 234 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, |
235 offsetof(ocspResponseData, responseExtensions), | 235 offsetof(ocspResponseData, responseExtensions), |
236 myCERT_PointerToSequenceOfCertExtensionTemplate }, | 236 myCERT_PointerToSequenceOfCertExtensionTemplate }, |
237 { 0 } | 237 { 0 } |
238 }; | 238 }; |
239 | 239 |
240 | |
241 static const SEC_ASN1Template ocsp_EncodeBasicOCSPResponseTemplate[] = { | 240 static const SEC_ASN1Template ocsp_EncodeBasicOCSPResponseTemplate[] = { |
242 { SEC_ASN1_SEQUENCE, | 241 { SEC_ASN1_SEQUENCE, |
243 0, NULL, sizeof(ocspBasicOCSPResponse) }, | 242 0, NULL, sizeof(ocspBasicOCSPResponse) }, |
244 { SEC_ASN1_POINTER, | 243 { SEC_ASN1_POINTER, |
245 offsetof(ocspBasicOCSPResponse, tbsResponseData), | 244 offsetof(ocspBasicOCSPResponse, tbsResponseData), |
246 ocsp_myResponseDataTemplate }, | 245 ocsp_myResponseDataTemplate }, |
247 { SEC_ASN1_INLINE, | 246 { SEC_ASN1_INLINE, |
248 offsetof(ocspBasicOCSPResponse, responseSignature.signatureAlgorithm), | 247 offsetof(ocspBasicOCSPResponse, responseSignature.signatureAlgorithm), |
249 mySECOID_AlgorithmIDTemplate }, | 248 mySECOID_AlgorithmIDTemplate }, |
250 { SEC_ASN1_BIT_STRING, | 249 { SEC_ASN1_BIT_STRING, |
251 offsetof(ocspBasicOCSPResponse, responseSignature.signature) }, | 250 offsetof(ocspBasicOCSPResponse, responseSignature.signature) }, |
252 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | | 251 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | |
253 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, | 252 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, |
254 offsetof(ocspBasicOCSPResponse, responseSignature.derCerts), | 253 offsetof(ocspBasicOCSPResponse, responseSignature.derCerts), |
255 mySEC_PointerToSequenceOfAnyTemplate }, | 254 mySEC_PointerToSequenceOfAnyTemplate }, |
256 { 0 } | 255 { 0 } |
257 }; | 256 }; |
258 | 257 |
259 static CERTOCSPSingleResponse* | 258 static CERTOCSPSingleResponse * |
260 ocsp_CreateSingleResponse(PLArenaPool *arena, | 259 ocsp_CreateSingleResponse(PLArenaPool *arena, |
261 CERTOCSPCertID *id, ocspCertStatus *status, | 260 CERTOCSPCertID *id, ocspCertStatus *status, |
262 PRTime thisUpdate, const PRTime *nextUpdate) | 261 PRTime thisUpdate, const PRTime *nextUpdate) |
263 { | 262 { |
264 CERTOCSPSingleResponse *sr; | 263 CERTOCSPSingleResponse *sr; |
265 | 264 |
266 if (!arena || !id || !status) { | 265 if (!arena || !id || !status) { |
267 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 266 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
268 return NULL; | 267 return NULL; |
269 } | 268 } |
270 | 269 |
271 sr = PORT_ArenaZNew(arena, CERTOCSPSingleResponse); | 270 sr = PORT_ArenaZNew(arena, CERTOCSPSingleResponse); |
272 if (!sr) | 271 if (!sr) |
273 return NULL; | 272 return NULL; |
274 sr->arena = arena; | 273 sr->arena = arena; |
275 sr->certID = id; | 274 sr->certID = id; |
276 sr->certStatus = status; | 275 sr->certStatus = status; |
277 if (DER_TimeToGeneralizedTimeArena(arena, &sr->thisUpdate, thisUpdate) | 276 if (DER_TimeToGeneralizedTimeArena(arena, &sr->thisUpdate, thisUpdate) != |
278 != SECSuccess) | 277 SECSuccess) |
279 return NULL; | 278 return NULL; |
280 sr->nextUpdate = NULL; | 279 sr->nextUpdate = NULL; |
281 if (nextUpdate) { | 280 if (nextUpdate) { |
282 sr->nextUpdate = SECITEM_AllocItem(arena, NULL, 0); | 281 sr->nextUpdate = SECITEM_AllocItem(arena, NULL, 0); |
283 if (!sr->nextUpdate) | 282 if (!sr->nextUpdate) |
284 return NULL; | 283 return NULL; |
285 if (DER_TimeToGeneralizedTimeArena(arena, sr->nextUpdate, *nextUpdate) | 284 if (DER_TimeToGeneralizedTimeArena(arena, sr->nextUpdate, *nextUpdate) !
= |
286 != SECSuccess) | 285 SECSuccess) |
287 return NULL; | 286 return NULL; |
288 } | 287 } |
289 | 288 |
290 sr->singleExtensions = PORT_ArenaNewArray(arena, CERTCertExtension*, 1); | 289 sr->singleExtensions = PORT_ArenaNewArray(arena, CERTCertExtension *, 1); |
291 if (!sr->singleExtensions) | 290 if (!sr->singleExtensions) |
292 return NULL; | 291 return NULL; |
293 | 292 |
294 sr->singleExtensions[0] = NULL; | 293 sr->singleExtensions[0] = NULL; |
295 | 294 |
296 if (!SEC_ASN1EncodeItem(arena, &sr->derCertStatus, | 295 if (!SEC_ASN1EncodeItem(arena, &sr->derCertStatus, |
297 status, ocsp_CertStatusTemplate)) | 296 status, ocsp_CertStatusTemplate)) |
298 return NULL; | 297 return NULL; |
299 | 298 |
300 return sr; | 299 return sr; |
301 } | 300 } |
302 | 301 |
303 CERTOCSPSingleResponse* | 302 CERTOCSPSingleResponse * |
304 CERT_CreateOCSPSingleResponseGood(PLArenaPool *arena, | 303 CERT_CreateOCSPSingleResponseGood(PLArenaPool *arena, |
305 CERTOCSPCertID *id, | 304 CERTOCSPCertID *id, |
306 PRTime thisUpdate, | 305 PRTime thisUpdate, |
307 const PRTime *nextUpdate) | 306 const PRTime *nextUpdate) |
308 { | 307 { |
309 ocspCertStatus * cs; | 308 ocspCertStatus *cs; |
310 if (!arena) { | 309 if (!arena) { |
311 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 310 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
312 return NULL; | 311 return NULL; |
313 } | 312 } |
314 cs = ocsp_CreateCertStatus(arena, ocspCertStatus_good, 0); | 313 cs = ocsp_CreateCertStatus(arena, ocspCertStatus_good, 0); |
315 if (!cs) | 314 if (!cs) |
316 return NULL; | 315 return NULL; |
317 return ocsp_CreateSingleResponse(arena, id, cs, thisUpdate, nextUpdate); | 316 return ocsp_CreateSingleResponse(arena, id, cs, thisUpdate, nextUpdate); |
318 } | 317 } |
319 | 318 |
320 CERTOCSPSingleResponse* | 319 CERTOCSPSingleResponse * |
321 CERT_CreateOCSPSingleResponseUnknown(PLArenaPool *arena, | 320 CERT_CreateOCSPSingleResponseUnknown(PLArenaPool *arena, |
322 CERTOCSPCertID *id, | 321 CERTOCSPCertID *id, |
323 PRTime thisUpdate, | 322 PRTime thisUpdate, |
324 const PRTime *nextUpdate) | 323 const PRTime *nextUpdate) |
325 { | 324 { |
326 ocspCertStatus * cs; | 325 ocspCertStatus *cs; |
327 if (!arena) { | 326 if (!arena) { |
328 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 327 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
329 return NULL; | 328 return NULL; |
330 } | 329 } |
331 cs = ocsp_CreateCertStatus(arena, ocspCertStatus_unknown, 0); | 330 cs = ocsp_CreateCertStatus(arena, ocspCertStatus_unknown, 0); |
332 if (!cs) | 331 if (!cs) |
333 return NULL; | 332 return NULL; |
334 return ocsp_CreateSingleResponse(arena, id, cs, thisUpdate, nextUpdate); | 333 return ocsp_CreateSingleResponse(arena, id, cs, thisUpdate, nextUpdate); |
335 } | 334 } |
336 | 335 |
337 CERTOCSPSingleResponse* | 336 CERTOCSPSingleResponse * |
338 CERT_CreateOCSPSingleResponseRevoked( | 337 CERT_CreateOCSPSingleResponseRevoked( |
339 PLArenaPool *arena, | 338 PLArenaPool *arena, |
340 CERTOCSPCertID *id, | 339 CERTOCSPCertID *id, |
341 PRTime thisUpdate, | 340 PRTime thisUpdate, |
342 const PRTime *nextUpdate, | 341 const PRTime *nextUpdate, |
343 PRTime revocationTime, | 342 PRTime revocationTime, |
344 const CERTCRLEntryReasonCode* revocationReason) | 343 const CERTCRLEntryReasonCode *revocationReason) |
345 { | 344 { |
346 ocspCertStatus * cs; | 345 ocspCertStatus *cs; |
347 /* revocationReason is not yet supported, so it must be NULL. */ | 346 /* revocationReason is not yet supported, so it must be NULL. */ |
348 if (!arena || revocationReason) { | 347 if (!arena || revocationReason) { |
349 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 348 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
350 return NULL; | 349 return NULL; |
351 } | 350 } |
352 cs = ocsp_CreateCertStatus(arena, ocspCertStatus_revoked, revocationTime); | 351 cs = ocsp_CreateCertStatus(arena, ocspCertStatus_revoked, revocationTime); |
353 if (!cs) | 352 if (!cs) |
354 return NULL; | 353 return NULL; |
355 return ocsp_CreateSingleResponse(arena, id, cs, thisUpdate, nextUpdate); | 354 return ocsp_CreateSingleResponse(arena, id, cs, thisUpdate, nextUpdate); |
356 } | 355 } |
357 | 356 |
358 /* responderCert == 0 means: | 357 /* responderCert == 0 means: |
359 * create a response with an invalid signature (for testing purposes) */ | 358 * create a response with an invalid signature (for testing purposes) */ |
360 SECItem* | 359 SECItem * |
361 CERT_CreateEncodedOCSPSuccessResponse( | 360 CERT_CreateEncodedOCSPSuccessResponse( |
362 PLArenaPool *arena, | 361 PLArenaPool *arena, |
363 CERTCertificate *responderCert, | 362 CERTCertificate *responderCert, |
364 CERTOCSPResponderIDType responderIDType, | 363 CERTOCSPResponderIDType responderIDType, |
365 PRTime producedAt, | 364 PRTime producedAt, |
366 CERTOCSPSingleResponse **responses, | 365 CERTOCSPSingleResponse **responses, |
367 void *wincx) | 366 void *wincx) |
368 { | 367 { |
369 PLArenaPool *tmpArena; | 368 PLArenaPool *tmpArena; |
370 ocspResponseData *rd = NULL; | 369 ocspResponseData *rd = NULL; |
371 ocspResponderID *rid = NULL; | 370 ocspResponderID *rid = NULL; |
372 const SEC_ASN1Template *responderIDTemplate = NULL; | 371 const SEC_ASN1Template *responderIDTemplate = NULL; |
373 ocspBasicOCSPResponse *br = NULL; | 372 ocspBasicOCSPResponse *br = NULL; |
374 ocspResponseBytes *rb = NULL; | 373 ocspResponseBytes *rb = NULL; |
375 CERTOCSPResponse *response = NULL; | 374 CERTOCSPResponse *response = NULL; |
376 | 375 |
377 SECOidTag algID; | 376 SECOidTag algID; |
378 SECOidData *od = NULL; | 377 SECOidData *od = NULL; |
379 SECKEYPrivateKey *privKey = NULL; | 378 SECKEYPrivateKey *privKey = NULL; |
380 SECItem *result = NULL; | 379 SECItem *result = NULL; |
381 | 380 |
382 if (!arena || !responses) { | 381 if (!arena || !responses) { |
383 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 382 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
384 return NULL; | 383 return NULL; |
385 } | 384 } |
386 if (responderIDType != ocspResponderID_byName && | 385 if (responderIDType != ocspResponderID_byName && |
387 responderIDType != ocspResponderID_byKey) { | 386 responderIDType != ocspResponderID_byKey) { |
388 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 387 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
389 return NULL; | 388 return NULL; |
390 } | 389 } |
391 | 390 |
392 tmpArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 391 tmpArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
393 if (!tmpArena) | 392 if (!tmpArena) |
394 return NULL; | 393 return NULL; |
395 | 394 |
396 rd = PORT_ArenaZNew(tmpArena, ocspResponseData); | 395 rd = PORT_ArenaZNew(tmpArena, ocspResponseData); |
397 if (!rd) | 396 if (!rd) |
398 goto done; | 397 goto done; |
399 rid = PORT_ArenaZNew(tmpArena, ocspResponderID); | 398 rid = PORT_ArenaZNew(tmpArena, ocspResponderID); |
400 if (!rid) | 399 if (!rid) |
401 goto done; | 400 goto done; |
402 br = PORT_ArenaZNew(tmpArena, ocspBasicOCSPResponse); | 401 br = PORT_ArenaZNew(tmpArena, ocspBasicOCSPResponse); |
403 if (!br) | 402 if (!br) |
404 goto done; | 403 goto done; |
405 rb = PORT_ArenaZNew(tmpArena, ocspResponseBytes); | 404 rb = PORT_ArenaZNew(tmpArena, ocspResponseBytes); |
406 if (!rb) | 405 if (!rb) |
407 goto done; | 406 goto done; |
408 response = PORT_ArenaZNew(tmpArena, CERTOCSPResponse); | 407 response = PORT_ArenaZNew(tmpArena, CERTOCSPResponse); |
409 if (!response) | 408 if (!response) |
410 goto done; | 409 goto done; |
411 | 410 |
412 rd->version.data=NULL; | 411 rd->version.data = NULL; |
413 rd->version.len=0; | 412 rd->version.len = 0; |
414 rd->responseExtensions = NULL; | 413 rd->responseExtensions = NULL; |
415 rd->responses = responses; | 414 rd->responses = responses; |
416 if (DER_TimeToGeneralizedTimeArena(tmpArena, &rd->producedAt, producedAt) | 415 if (DER_TimeToGeneralizedTimeArena(tmpArena, &rd->producedAt, producedAt) != |
417 != SECSuccess) | 416 SECSuccess) |
418 goto done; | 417 goto done; |
419 | 418 |
420 if (!responderCert) { | 419 if (!responderCert) { |
421 » /* use invalid signature for testing purposes */ | 420 /* use invalid signature for testing purposes */ |
422 » unsigned char dummyChar = 'd'; | 421 unsigned char dummyChar = 'd'; |
423 » SECItem dummy; | 422 SECItem dummy; |
424 | 423 |
425 » dummy.len = 1; | 424 dummy.len = 1; |
426 » dummy.data = &dummyChar; | 425 dummy.data = &dummyChar; |
427 | 426 |
428 » /* it's easier to produdce a keyHash out of nowhere, | 427 /* it's easier to produdce a keyHash out of nowhere, |
429 » * than to produce an encoded subject, | 428 » * than to produce an encoded subject, |
430 » * so for our dummy response we always use byKey | 429 » * so for our dummy response we always use byKey |
431 » */ | 430 » */ |
432 » | |
433 » rid->responderIDType = ocspResponderID_byKey; | |
434 » if (!ocsp_DigestValue(tmpArena, SEC_OID_SHA1, &rid->responderIDValue.key
Hash, | |
435 » » » &dummy)) | |
436 » goto done; | |
437 | 431 |
438 » if (!SEC_ASN1EncodeItem(tmpArena, &rd->derResponderID, rid, | 432 rid->responderIDType = ocspResponderID_byKey; |
439 » » » » ocsp_ResponderIDByKeyTemplate)) | 433 if (!ocsp_DigestValue(tmpArena, SEC_OID_SHA1, &rid->responderIDValue.key
Hash, |
440 » goto done; | 434 &dummy)) |
| 435 goto done; |
441 | 436 |
442 » br->tbsResponseData = rd; | 437 if (!SEC_ASN1EncodeItem(tmpArena, &rd->derResponderID, rid, |
| 438 ocsp_ResponderIDByKeyTemplate)) |
| 439 goto done; |
443 | 440 |
444 » if (!SEC_ASN1EncodeItem(tmpArena, &br->tbsResponseDataDER, br->tbsRespon
seData, | 441 br->tbsResponseData = rd; |
445 » » » » ocsp_myResponseDataTemplate)) | |
446 » goto done; | |
447 | 442 |
448 » br->responseSignature.derCerts = PORT_ArenaNewArray(tmpArena, SECItem*,
1); | 443 if (!SEC_ASN1EncodeItem(tmpArena, &br->tbsResponseDataDER, br->tbsRespon
seData, |
449 » if (!br->responseSignature.derCerts) | 444 ocsp_myResponseDataTemplate)) |
450 » goto done; | 445 goto done; |
451 » br->responseSignature.derCerts[0] = NULL; | |
452 | 446 |
453 » algID = SEC_GetSignatureAlgorithmOidTag(rsaKey, SEC_OID_SHA1); | 447 br->responseSignature.derCerts = PORT_ArenaNewArray(tmpArena, SECItem *,
1); |
454 » if (algID == SEC_OID_UNKNOWN) | 448 if (!br->responseSignature.derCerts) |
455 » goto done; | 449 goto done; |
| 450 br->responseSignature.derCerts[0] = NULL; |
456 | 451 |
457 » /* match the regular signature code, which doesn't use the arena */ | 452 algID = SEC_GetSignatureAlgorithmOidTag(rsaKey, SEC_OID_SHA1); |
458 » if (!SECITEM_AllocItem(NULL, &br->responseSignature.signature, 1)) | 453 if (algID == SEC_OID_UNKNOWN) |
459 » goto done; | 454 goto done; |
460 » PORT_Memcpy(br->responseSignature.signature.data, &dummyChar, 1); | |
461 | 455 |
462 » /* convert len-in-bytes to len-in-bits */ | 456 /* match the regular signature code, which doesn't use the arena */ |
463 » br->responseSignature.signature.len = br->responseSignature.signature.le
n << 3; | 457 if (!SECITEM_AllocItem(NULL, &br->responseSignature.signature, 1)) |
464 } | 458 goto done; |
465 else { | 459 PORT_Memcpy(br->responseSignature.signature.data, &dummyChar, 1); |
466 » rid->responderIDType = responderIDType; | |
467 » if (responderIDType == ocspResponderID_byName) { | |
468 » responderIDTemplate = ocsp_ResponderIDByNameTemplate; | |
469 » if (CERT_CopyName(tmpArena, &rid->responderIDValue.name, | |
470 » » » &responderCert->subject) != SECSuccess) | |
471 » » goto done; | |
472 » } | |
473 » else { | |
474 » responderIDTemplate = ocsp_ResponderIDByKeyTemplate; | |
475 » if (!CERT_GetSubjectPublicKeyDigest(tmpArena, responderCert, | |
476 » » » » SEC_OID_SHA1, &rid->responderIDValue.keyHash)) | |
477 » » goto done; | |
478 » } | |
479 | 460 |
480 » if (!SEC_ASN1EncodeItem(tmpArena, &rd->derResponderID, rid, | 461 /* convert len-in-bytes to len-in-bits */ |
481 » » responderIDTemplate)) | 462 br->responseSignature.signature.len = br->responseSignature.signature.le
n << 3; |
482 » goto done; | 463 } else { |
| 464 rid->responderIDType = responderIDType; |
| 465 if (responderIDType == ocspResponderID_byName) { |
| 466 responderIDTemplate = ocsp_ResponderIDByNameTemplate; |
| 467 if (CERT_CopyName(tmpArena, &rid->responderIDValue.name, |
| 468 &responderCert->subject) != SECSuccess) |
| 469 goto done; |
| 470 } else { |
| 471 responderIDTemplate = ocsp_ResponderIDByKeyTemplate; |
| 472 if (!CERT_GetSubjectPublicKeyDigest(tmpArena, responderCert, |
| 473 SEC_OID_SHA1, &rid->responderIDV
alue.keyHash)) |
| 474 goto done; |
| 475 } |
483 | 476 |
484 » br->tbsResponseData = rd; | 477 if (!SEC_ASN1EncodeItem(tmpArena, &rd->derResponderID, rid, |
| 478 responderIDTemplate)) |
| 479 goto done; |
485 | 480 |
486 » if (!SEC_ASN1EncodeItem(tmpArena, &br->tbsResponseDataDER, br->tbsRespon
seData, | 481 br->tbsResponseData = rd; |
487 » » ocsp_myResponseDataTemplate)) | |
488 » goto done; | |
489 | 482 |
490 » br->responseSignature.derCerts = PORT_ArenaNewArray(tmpArena, SECItem*,
1); | 483 if (!SEC_ASN1EncodeItem(tmpArena, &br->tbsResponseDataDER, br->tbsRespon
seData, |
491 » if (!br->responseSignature.derCerts) | 484 ocsp_myResponseDataTemplate)) |
492 » goto done; | 485 goto done; |
493 » br->responseSignature.derCerts[0] = NULL; | |
494 | 486 |
495 » privKey = PK11_FindKeyByAnyCert(responderCert, wincx); | 487 br->responseSignature.derCerts = PORT_ArenaNewArray(tmpArena, SECItem *,
1); |
496 » if (!privKey) | 488 if (!br->responseSignature.derCerts) |
497 » goto done; | 489 goto done; |
| 490 br->responseSignature.derCerts[0] = NULL; |
498 | 491 |
499 » algID = SEC_GetSignatureAlgorithmOidTag(privKey->keyType, SEC_OID_SHA1); | 492 privKey = PK11_FindKeyByAnyCert(responderCert, wincx); |
500 » if (algID == SEC_OID_UNKNOWN) | 493 if (!privKey) |
501 » goto done; | 494 goto done; |
502 | 495 |
503 » if (SEC_SignData(&br->responseSignature.signature, | 496 algID = SEC_GetSignatureAlgorithmOidTag(privKey->keyType, SEC_OID_SHA1); |
504 » » » br->tbsResponseDataDER.data, br->tbsResponseDataDER.
len, | 497 if (algID == SEC_OID_UNKNOWN) |
505 » » » privKey, algID) | 498 goto done; |
506 » » != SECSuccess) | |
507 » goto done; | |
508 | 499 |
509 » /* convert len-in-bytes to len-in-bits */ | 500 if (SEC_SignData(&br->responseSignature.signature, |
510 » br->responseSignature.signature.len = br->responseSignature.signature.le
n << 3; | 501 br->tbsResponseDataDER.data, br->tbsResponseDataDER.len
, |
| 502 privKey, algID) != |
| 503 SECSuccess) |
| 504 goto done; |
511 | 505 |
512 » /* br->responseSignature.signature wasn't allocated from arena, | 506 /* convert len-in-bytes to len-in-bits */ |
513 » * we must free it when done. */ | 507 br->responseSignature.signature.len = br->responseSignature.signature.le
n << 3; |
| 508 |
| 509 /* br->responseSignature.signature wasn't allocated from arena, |
| 510 » * we must free it when done. */ |
514 } | 511 } |
515 | 512 |
516 if (SECOID_SetAlgorithmID(tmpArena, &br->responseSignature.signatureAlgorith
m, algID, 0) | 513 if (SECOID_SetAlgorithmID(tmpArena, &br->responseSignature.signatureAlgorith
m, algID, 0) != |
517 » != SECSuccess) | 514 SECSuccess) |
518 » goto done; | 515 goto done; |
519 | 516 |
520 if (!SEC_ASN1EncodeItem(tmpArena, &rb->response, br, | 517 if (!SEC_ASN1EncodeItem(tmpArena, &rb->response, br, |
521 ocsp_EncodeBasicOCSPResponseTemplate)) | 518 ocsp_EncodeBasicOCSPResponseTemplate)) |
522 goto done; | 519 goto done; |
523 | 520 |
524 rb->responseTypeTag = SEC_OID_PKIX_OCSP_BASIC_RESPONSE; | 521 rb->responseTypeTag = SEC_OID_PKIX_OCSP_BASIC_RESPONSE; |
525 | 522 |
526 od = SECOID_FindOIDByTag(rb->responseTypeTag); | 523 od = SECOID_FindOIDByTag(rb->responseTypeTag); |
527 if (!od) | 524 if (!od) |
528 goto done; | 525 goto done; |
(...skipping 16 matching lines...) Expand all Loading... |
545 SECKEY_DestroyPrivateKey(privKey); | 542 SECKEY_DestroyPrivateKey(privKey); |
546 if (br && br->responseSignature.signature.data) | 543 if (br && br->responseSignature.signature.data) |
547 SECITEM_FreeItem(&br->responseSignature.signature, PR_FALSE); | 544 SECITEM_FreeItem(&br->responseSignature.signature, PR_FALSE); |
548 PORT_FreeArena(tmpArena, PR_FALSE); | 545 PORT_FreeArena(tmpArena, PR_FALSE); |
549 | 546 |
550 return result; | 547 return result; |
551 } | 548 } |
552 | 549 |
553 static const SEC_ASN1Template ocsp_OCSPErrorResponseTemplate[] = { | 550 static const SEC_ASN1Template ocsp_OCSPErrorResponseTemplate[] = { |
554 { SEC_ASN1_SEQUENCE, | 551 { SEC_ASN1_SEQUENCE, |
555 0, NULL, sizeof(CERTOCSPResponse) }, | 552 0, NULL, sizeof(CERTOCSPResponse) }, |
556 { SEC_ASN1_ENUMERATED, | 553 { SEC_ASN1_ENUMERATED, |
557 offsetof(CERTOCSPResponse, responseStatus) }, | 554 offsetof(CERTOCSPResponse, responseStatus) }, |
558 { 0, 0, | 555 { 0, 0, |
559 mySEC_NullTemplate }, | 556 mySEC_NullTemplate }, |
560 { 0 } | 557 { 0 } |
561 }; | 558 }; |
562 | 559 |
563 SECItem* | 560 SECItem * |
564 CERT_CreateEncodedOCSPErrorResponse(PLArenaPool *arena, int error) | 561 CERT_CreateEncodedOCSPErrorResponse(PLArenaPool *arena, int error) |
565 { | 562 { |
566 CERTOCSPResponse response; | 563 CERTOCSPResponse response; |
567 SECItem *result = NULL; | 564 SECItem *result = NULL; |
568 | 565 |
569 switch (error) { | 566 switch (error) { |
570 case SEC_ERROR_OCSP_MALFORMED_REQUEST: | 567 case SEC_ERROR_OCSP_MALFORMED_REQUEST: |
571 response.statusValue = ocspResponse_malformedRequest; | 568 response.statusValue = ocspResponse_malformedRequest; |
572 break; | 569 break; |
573 case SEC_ERROR_OCSP_SERVER_ERROR: | 570 case SEC_ERROR_OCSP_SERVER_ERROR: |
(...skipping 17 matching lines...) Expand all Loading... |
591 response.statusValue)) | 588 response.statusValue)) |
592 return NULL; | 589 return NULL; |
593 | 590 |
594 result = SEC_ASN1EncodeItem(arena, NULL, &response, | 591 result = SEC_ASN1EncodeItem(arena, NULL, &response, |
595 ocsp_OCSPErrorResponseTemplate); | 592 ocsp_OCSPErrorResponseTemplate); |
596 | 593 |
597 SECITEM_FreeItem(&response.responseStatus, PR_FALSE); | 594 SECITEM_FreeItem(&response.responseStatus, PR_FALSE); |
598 | 595 |
599 return result; | 596 return result; |
600 } | 597 } |
OLD | NEW |