/src/boringssl/crypto/x509/v3_ocsp.cc
Line | Count | Source |
1 | | // Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // https://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #include <openssl/x509.h> |
16 | | |
17 | | #include <openssl/asn1.h> |
18 | | #include <openssl/bio.h> |
19 | | #include <openssl/nid.h> |
20 | | |
21 | | #include "internal.h" |
22 | | |
23 | | |
24 | | using namespace bssl; |
25 | | |
26 | | // OCSP extensions and a couple of CRL entry extensions |
27 | | |
28 | | static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *nonce, |
29 | | BIO *out, int indent); |
30 | | |
31 | | static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck, |
32 | | BIO *out, int indent); |
33 | | static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, |
34 | | const X509V3_CTX *ctx, const char *str); |
35 | | |
36 | | const X509V3_EXT_METHOD bssl::v3_crl_invdate = { |
37 | | NID_invalidity_date, |
38 | | 0, |
39 | | ASN1_ITEM_ref(ASN1_GENERALIZEDTIME), |
40 | | nullptr, |
41 | | nullptr, |
42 | | nullptr, |
43 | | nullptr, |
44 | | nullptr, |
45 | | nullptr, |
46 | | nullptr, |
47 | | nullptr, |
48 | | i2r_ocsp_acutoff, |
49 | | nullptr, |
50 | | nullptr, |
51 | | }; |
52 | | |
53 | | const X509V3_EXT_METHOD bssl::v3_ocsp_nocheck = { |
54 | | NID_id_pkix_OCSP_noCheck, |
55 | | 0, |
56 | | ASN1_ITEM_ref(ASN1_NULL), |
57 | | nullptr, |
58 | | nullptr, |
59 | | nullptr, |
60 | | nullptr, |
61 | | nullptr, |
62 | | s2i_ocsp_nocheck, |
63 | | nullptr, |
64 | | nullptr, |
65 | | i2r_ocsp_nocheck, |
66 | | nullptr, |
67 | | nullptr, |
68 | | }; |
69 | | |
70 | | static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *cutoff, |
71 | 7 | BIO *bp, int ind) { |
72 | 7 | if (BIO_printf(bp, "%*s", ind, "") <= 0) { |
73 | 0 | return 0; |
74 | 0 | } |
75 | 7 | if (!ASN1_GENERALIZEDTIME_print( |
76 | 7 | bp, reinterpret_cast<ASN1_GENERALIZEDTIME *>(cutoff))) { |
77 | 0 | return 0; |
78 | 0 | } |
79 | 7 | return 1; |
80 | 7 | } |
81 | | |
82 | | // Nocheck is just a single NULL. Don't print anything and always set it |
83 | | |
84 | | static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck, |
85 | 3 | BIO *out, int indent) { |
86 | 3 | return 1; |
87 | 3 | } |
88 | | |
89 | | static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, |
90 | 33 | const X509V3_CTX *ctx, const char *str) { |
91 | 33 | return ASN1_NULL_new(); |
92 | 33 | } |