| 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 "ext_dat.h" |
| 22 |
| 23 | // OCSP extensions and a couple of CRL entry extensions |
| 24 |
| 25 | static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *nonce, |
| 26 | BIO *out, int indent); |
| 27 |
| 28 | static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck, |
| 29 | BIO *out, int indent); |
| 30 | static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, |
| 31 | const X509V3_CTX *ctx, const char *str); |
| 32 |
| 33 | const X509V3_EXT_METHOD v3_crl_invdate = { |
| 34 | NID_invalidity_date, |
| 35 | 0, |
| 36 | ASN1_ITEM_ref(ASN1_GENERALIZEDTIME), |
| 37 | 0, |
| 38 | 0, |
| 39 | 0, |
| 40 | 0, |
| 41 | 0, |
| 42 | 0, |
| 43 | 0, |
| 44 | 0, |
| 45 | i2r_ocsp_acutoff, |
| 46 | 0, |
| 47 | NULL, |
| 48 | }; |
| 49 |
| 50 | const X509V3_EXT_METHOD v3_ocsp_nocheck = { |
| 51 | NID_id_pkix_OCSP_noCheck, |
| 52 | 0, |
| 53 | ASN1_ITEM_ref(ASN1_NULL), |
| 54 | 0, |
| 55 | 0, |
| 56 | 0, |
| 57 | 0, |
| 58 | 0, |
| 59 | s2i_ocsp_nocheck, |
| 60 | 0, |
| 61 | 0, |
| 62 | i2r_ocsp_nocheck, |
| 63 | 0, |
| 64 | NULL, |
| 65 | }; |
| 66 |
| 67 | static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *cutoff, |
| 68 | BIO *bp, int ind) { |
| 69 | if (BIO_printf(bp, "%*s", ind, "") <= 0) { |
| 70 | return 0; |
| 71 | } |
| 72 | if (!ASN1_GENERALIZEDTIME_print( |
| 73 | bp, reinterpret_cast<ASN1_GENERALIZEDTIME *>(cutoff))) { |
| 74 | return 0; |
| 75 | } |
| 76 | return 1; |
| 77 | } |
| 78 |
| 79 | // Nocheck is just a single NULL. Don't print anything and always set it |
| 80 |
| 81 | static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck, |
| 82 | BIO *out, int indent) { |
| 83 | return 1; |
| 84 | } |
| 85 |
| 86 | static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, |
| 87 | const X509V3_CTX *ctx, const char *str) { |
| 88 | return ASN1_NULL_new(); |
| 89 | } |
| 90 |