1 /*
2 * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10 #include <openssl/x509.h>
11
12 #include <openssl/asn1.h>
13 #include <openssl/bio.h>
14 #include <openssl/nid.h>
15
16 // OCSP extensions and a couple of CRL entry extensions
17
18 static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *nonce,
19 BIO *out, int indent);
20
21 static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck,
22 BIO *out, int indent);
23 static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method,
24 const X509V3_CTX *ctx, const char *str);
25
26 const X509V3_EXT_METHOD v3_crl_invdate = {
27 NID_invalidity_date,
28 0,
29 ASN1_ITEM_ref(ASN1_GENERALIZEDTIME),
30 0,
31 0,
32 0,
33 0,
34 0,
35 0,
36 0,
37 0,
38 i2r_ocsp_acutoff,
39 0,
40 NULL,
41 };
42
43 const X509V3_EXT_METHOD v3_ocsp_nocheck = {
44 NID_id_pkix_OCSP_noCheck,
45 0,
46 ASN1_ITEM_ref(ASN1_NULL),
47 0,
48 0,
49 0,
50 0,
51 0,
52 s2i_ocsp_nocheck,
53 0,
54 0,
55 i2r_ocsp_nocheck,
56 0,
57 NULL,
58 };
59
i2r_ocsp_acutoff(const X509V3_EXT_METHOD * method,void * cutoff,BIO * bp,int ind)60 static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *cutoff,
61 BIO *bp, int ind) {
62 if (BIO_printf(bp, "%*s", ind, "") <= 0) {
63 return 0;
64 }
65 if (!ASN1_GENERALIZEDTIME_print(bp, cutoff)) {
66 return 0;
67 }
68 return 1;
69 }
70
71 // Nocheck is just a single NULL. Don't print anything and always set it
72
i2r_ocsp_nocheck(const X509V3_EXT_METHOD * method,void * nocheck,BIO * out,int indent)73 static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck,
74 BIO *out, int indent) {
75 return 1;
76 }
77
s2i_ocsp_nocheck(const X509V3_EXT_METHOD * method,const X509V3_CTX * ctx,const char * str)78 static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method,
79 const X509V3_CTX *ctx, const char *str) {
80 return ASN1_NULL_new();
81 }
82