OLD | NEW |
1 /* v3_ocsp.c */ | 1 /* v3_ocsp.c */ |
2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 * project 1999. | 3 * project 1999. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include <stdio.h> | 61 #include <stdio.h> |
62 #include "cryptlib.h" | 62 #include "cryptlib.h" |
63 #include <openssl/conf.h> | 63 #include <openssl/conf.h> |
64 #include <openssl/asn1.h> | 64 #include <openssl/asn1.h> |
65 #include <openssl/ocsp.h> | 65 #include <openssl/ocsp.h> |
66 #include <openssl/x509v3.h> | 66 #include <openssl/x509v3.h> |
67 | 67 |
68 /* OCSP extensions and a couple of CRL entry extensions | 68 /* OCSP extensions and a couple of CRL entry extensions |
69 */ | 69 */ |
70 | 70 |
71 static int i2r_ocsp_crlid(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int
indent); | 71 static int i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *nonce, |
72 static int i2r_ocsp_acutoff(X509V3_EXT_METHOD *method, void *nonce, BIO *out, in
t indent); | 72 » » » BIO *out, int indent); |
73 static int i2r_object(X509V3_EXT_METHOD *method, void *obj, BIO *out, int indent
); | 73 static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *nonce, |
| 74 » » » BIO *out, int indent); |
| 75 static int i2r_object(const X509V3_EXT_METHOD *method, void *obj, BIO *out, |
| 76 » » int indent); |
74 | 77 |
75 static void *ocsp_nonce_new(void); | 78 static void *ocsp_nonce_new(void); |
76 static int i2d_ocsp_nonce(void *a, unsigned char **pp); | 79 static int i2d_ocsp_nonce(void *a, unsigned char **pp); |
77 static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length); | 80 static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length); |
78 static void ocsp_nonce_free(void *a); | 81 static void ocsp_nonce_free(void *a); |
79 static int i2r_ocsp_nonce(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int
indent); | 82 static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce, |
| 83 » » » BIO *out, int indent); |
80 | 84 |
81 static int i2r_ocsp_nocheck(X509V3_EXT_METHOD *method, void *nocheck, BIO *out,
int indent); | 85 static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, |
82 static void *s2i_ocsp_nocheck(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, const
char *str); | 86 » » » void *nocheck, BIO *out, int indent); |
83 static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int
ind); | 87 static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
| 88 » » » const char *str); |
| 89 static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in, |
| 90 » » » BIO *bp, int ind); |
84 | 91 |
85 const X509V3_EXT_METHOD v3_ocsp_crlid = { | 92 const X509V3_EXT_METHOD v3_ocsp_crlid = { |
86 NID_id_pkix_OCSP_CrlID, 0, ASN1_ITEM_ref(OCSP_CRLID), | 93 NID_id_pkix_OCSP_CrlID, 0, ASN1_ITEM_ref(OCSP_CRLID), |
87 0,0,0,0, | 94 0,0,0,0, |
88 0,0, | 95 0,0, |
89 0,0, | 96 0,0, |
90 i2r_ocsp_crlid,0, | 97 i2r_ocsp_crlid,0, |
91 NULL | 98 NULL |
92 }; | 99 }; |
93 | 100 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 148 |
142 const X509V3_EXT_METHOD v3_ocsp_serviceloc = { | 149 const X509V3_EXT_METHOD v3_ocsp_serviceloc = { |
143 NID_id_pkix_OCSP_serviceLocator, 0, ASN1_ITEM_ref(OCSP_SERVICELOC), | 150 NID_id_pkix_OCSP_serviceLocator, 0, ASN1_ITEM_ref(OCSP_SERVICELOC), |
144 0,0,0,0, | 151 0,0,0,0, |
145 0,0, | 152 0,0, |
146 0,0, | 153 0,0, |
147 i2r_ocsp_serviceloc,0, | 154 i2r_ocsp_serviceloc,0, |
148 NULL | 155 NULL |
149 }; | 156 }; |
150 | 157 |
151 static int i2r_ocsp_crlid(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) | 158 static int i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *in, BIO *bp, |
| 159 » » » int ind) |
152 { | 160 { |
153 OCSP_CRLID *a = in; | 161 OCSP_CRLID *a = in; |
154 if (a->crlUrl) | 162 if (a->crlUrl) |
155 { | 163 { |
156 if (BIO_printf(bp, "%*scrlUrl: ", ind, "") <= 0) goto err; | 164 if (BIO_printf(bp, "%*scrlUrl: ", ind, "") <= 0) goto err; |
157 if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl)) goto err; | 165 if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl)) goto err; |
158 if (BIO_write(bp, "\n", 1) <= 0) goto err; | 166 if (BIO_write(bp, "\n", 1) <= 0) goto err; |
159 } | 167 } |
160 if (a->crlNum) | 168 if (a->crlNum) |
161 { | 169 { |
162 if (BIO_printf(bp, "%*scrlNum: ", ind, "") <= 0) goto err; | 170 if (BIO_printf(bp, "%*scrlNum: ", ind, "") <= 0) goto err; |
163 if (i2a_ASN1_INTEGER(bp, a->crlNum) <= 0) goto err; | 171 if (i2a_ASN1_INTEGER(bp, a->crlNum) <= 0) goto err; |
164 if (BIO_write(bp, "\n", 1) <= 0) goto err; | 172 if (BIO_write(bp, "\n", 1) <= 0) goto err; |
165 } | 173 } |
166 if (a->crlTime) | 174 if (a->crlTime) |
167 { | 175 { |
168 if (BIO_printf(bp, "%*scrlTime: ", ind, "") <= 0) goto err; | 176 if (BIO_printf(bp, "%*scrlTime: ", ind, "") <= 0) goto err; |
169 if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime)) goto err; | 177 if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime)) goto err; |
170 if (BIO_write(bp, "\n", 1) <= 0) goto err; | 178 if (BIO_write(bp, "\n", 1) <= 0) goto err; |
171 } | 179 } |
172 return 1; | 180 return 1; |
173 err: | 181 err: |
174 return 0; | 182 return 0; |
175 } | 183 } |
176 | 184 |
177 static int i2r_ocsp_acutoff(X509V3_EXT_METHOD *method, void *cutoff, BIO *bp, in
t ind) | 185 static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *cutoff, |
| 186 » » » BIO *bp, int ind) |
178 { | 187 { |
179 if (BIO_printf(bp, "%*s", ind, "") <= 0) return 0; | 188 if (BIO_printf(bp, "%*s", ind, "") <= 0) return 0; |
180 if(!ASN1_GENERALIZEDTIME_print(bp, cutoff)) return 0; | 189 if(!ASN1_GENERALIZEDTIME_print(bp, cutoff)) return 0; |
181 return 1; | 190 return 1; |
182 } | 191 } |
183 | 192 |
184 | 193 |
185 static int i2r_object(X509V3_EXT_METHOD *method, void *oid, BIO *bp, int ind) | 194 static int i2r_object(const X509V3_EXT_METHOD *method, void *oid, BIO *bp, |
| 195 » » int ind) |
186 { | 196 { |
187 if (BIO_printf(bp, "%*s", ind, "") <= 0) return 0; | 197 if (BIO_printf(bp, "%*s", ind, "") <= 0) return 0; |
188 if(i2a_ASN1_OBJECT(bp, oid) <= 0) return 0; | 198 if(i2a_ASN1_OBJECT(bp, oid) <= 0) return 0; |
189 return 1; | 199 return 1; |
190 } | 200 } |
191 | 201 |
192 /* OCSP nonce. This is needs special treatment because it doesn't have | 202 /* OCSP nonce. This is needs special treatment because it doesn't have |
193 * an ASN1 encoding at all: it just contains arbitrary data. | 203 * an ASN1 encoding at all: it just contains arbitrary data. |
194 */ | 204 */ |
195 | 205 |
(...skipping 29 matching lines...) Expand all Loading... |
225 if(os && (!pos || (*pos != os))) M_ASN1_OCTET_STRING_free(os); | 235 if(os && (!pos || (*pos != os))) M_ASN1_OCTET_STRING_free(os); |
226 OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE); | 236 OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE); |
227 return NULL; | 237 return NULL; |
228 } | 238 } |
229 | 239 |
230 static void ocsp_nonce_free(void *a) | 240 static void ocsp_nonce_free(void *a) |
231 { | 241 { |
232 M_ASN1_OCTET_STRING_free(a); | 242 M_ASN1_OCTET_STRING_free(a); |
233 } | 243 } |
234 | 244 |
235 static int i2r_ocsp_nonce(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int
indent) | 245 static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce, |
| 246 » » » BIO *out, int indent) |
236 { | 247 { |
237 if(BIO_printf(out, "%*s", indent, "") <= 0) return 0; | 248 if(BIO_printf(out, "%*s", indent, "") <= 0) return 0; |
238 if(i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0) return 0; | 249 if(i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0) return 0; |
239 return 1; | 250 return 1; |
240 } | 251 } |
241 | 252 |
242 /* Nocheck is just a single NULL. Don't print anything and always set it */ | 253 /* Nocheck is just a single NULL. Don't print anything and always set it */ |
243 | 254 |
244 static int i2r_ocsp_nocheck(X509V3_EXT_METHOD *method, void *nocheck, BIO *out,
int indent) | 255 static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck, |
| 256 » » » BIO *out, int indent) |
245 { | 257 { |
246 return 1; | 258 return 1; |
247 } | 259 } |
248 | 260 |
249 static void *s2i_ocsp_nocheck(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, const
char *str) | 261 static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
| 262 » » » const char *str) |
250 { | 263 { |
251 return ASN1_NULL_new(); | 264 return ASN1_NULL_new(); |
252 } | 265 } |
253 | 266 |
254 static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int
ind) | 267 static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in, |
| 268 » » » BIO *bp, int ind) |
255 { | 269 { |
256 int i; | 270 int i; |
257 OCSP_SERVICELOC *a = in; | 271 OCSP_SERVICELOC *a = in; |
258 ACCESS_DESCRIPTION *ad; | 272 ACCESS_DESCRIPTION *ad; |
259 | 273 |
260 if (BIO_printf(bp, "%*sIssuer: ", ind, "") <= 0) goto err; | 274 if (BIO_printf(bp, "%*sIssuer: ", ind, "") <= 0) goto err; |
261 if (X509_NAME_print_ex(bp, a->issuer, 0, XN_FLAG_ONELINE) <= 0) goto err
; | 275 if (X509_NAME_print_ex(bp, a->issuer, 0, XN_FLAG_ONELINE) <= 0) goto err
; |
262 for (i = 0; i < sk_ACCESS_DESCRIPTION_num(a->locator); i++) | 276 for (i = 0; i < sk_ACCESS_DESCRIPTION_num(a->locator); i++) |
263 { | 277 { |
264 ad = sk_ACCESS_DESCRIPTION_value(a->locator,i); | 278 ad = sk_ACCESS_DESCRIPTION_value(a->locator,i); |
265 if (BIO_printf(bp, "\n%*s", (2*ind), "") <= 0) | 279 if (BIO_printf(bp, "\n%*s", (2*ind), "") <= 0) |
266 goto err; | 280 goto err; |
267 if(i2a_ASN1_OBJECT(bp, ad->method) <= 0) goto er
r; | 281 if(i2a_ASN1_OBJECT(bp, ad->method) <= 0) goto er
r; |
268 if(BIO_puts(bp, " - ") <= 0) goto err; | 282 if(BIO_puts(bp, " - ") <= 0) goto err; |
269 if(GENERAL_NAME_print(bp, ad->location) <= 0) go
to err; | 283 if(GENERAL_NAME_print(bp, ad->location) <= 0) go
to err; |
270 } | 284 } |
271 return 1; | 285 return 1; |
272 err: | 286 err: |
273 return 0; | 287 return 0; |
274 } | 288 } |
275 #endif | 289 #endif |
OLD | NEW |