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/x509v3.h>
11 
12 #include <openssl/asn1.h>
13 #include <openssl/bio.h>
14 #include <openssl/nid.h>
15 
16 /*
17  * OCSP extensions and a couple of CRL entry extensions
18  */
19 
20 static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *nonce,
21                             BIO *out, int indent);
22 
23 static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method,
24                             void *nocheck, BIO *out, int indent);
25 static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method,
26                               X509V3_CTX *ctx, const char *str);
27 
28 const X509V3_EXT_METHOD v3_crl_invdate = {
29     NID_invalidity_date, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME),
30     0, 0, 0, 0,
31     0, 0,
32     0, 0,
33     i2r_ocsp_acutoff, 0,
34     NULL
35 };
36 
37 const X509V3_EXT_METHOD v3_ocsp_nocheck = {
38     NID_id_pkix_OCSP_noCheck, 0, ASN1_ITEM_ref(ASN1_NULL),
39     0, 0, 0, 0,
40     0, s2i_ocsp_nocheck,
41     0, 0,
42     i2r_ocsp_nocheck, 0,
43     NULL
44 };
45 
i2r_ocsp_acutoff(const X509V3_EXT_METHOD * method,void * cutoff,BIO * bp,int ind)46 static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *cutoff,
47                             BIO *bp, int ind)
48 {
49     if (BIO_printf(bp, "%*s", ind, "") <= 0)
50         return 0;
51     if (!ASN1_GENERALIZEDTIME_print(bp, cutoff))
52         return 0;
53     return 1;
54 }
55 
56 /* Nocheck is just a single NULL. Don't print anything and always set it */
57 
i2r_ocsp_nocheck(const X509V3_EXT_METHOD * method,void * nocheck,BIO * out,int indent)58 static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck,
59                             BIO *out, int indent)
60 {
61     return 1;
62 }
63 
s2i_ocsp_nocheck(const X509V3_EXT_METHOD * method,X509V3_CTX * ctx,const char * str)64 static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method,
65                               X509V3_CTX *ctx, const char *str)
66 {
67     return ASN1_NULL_new();
68 }
69