1 /*
2 * Copyright 1995-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/asn1.h>
11 #include <openssl/evp.h>
12 #include <openssl/obj.h>
13 #include <openssl/stack.h>
14 #include <openssl/x509.h>
15
16 #include "internal.h"
17
X509_CRL_get_ext_count(const X509_CRL * x)18 int X509_CRL_get_ext_count(const X509_CRL *x) {
19 return (X509v3_get_ext_count(x->crl->extensions));
20 }
21
X509_CRL_get_ext_by_NID(const X509_CRL * x,int nid,int lastpos)22 int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos) {
23 return (X509v3_get_ext_by_NID(x->crl->extensions, nid, lastpos));
24 }
25
X509_CRL_get_ext_by_OBJ(const X509_CRL * x,const ASN1_OBJECT * obj,int lastpos)26 int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj,
27 int lastpos) {
28 return (X509v3_get_ext_by_OBJ(x->crl->extensions, obj, lastpos));
29 }
30
X509_CRL_get_ext_by_critical(const X509_CRL * x,int crit,int lastpos)31 int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos) {
32 return (X509v3_get_ext_by_critical(x->crl->extensions, crit, lastpos));
33 }
34
X509_CRL_get_ext(const X509_CRL * x,int loc)35 X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc) {
36 return (X509v3_get_ext(x->crl->extensions, loc));
37 }
38
X509_CRL_delete_ext(X509_CRL * x,int loc)39 X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc) {
40 return (X509v3_delete_ext(x->crl->extensions, loc));
41 }
42
X509_CRL_get_ext_d2i(const X509_CRL * crl,int nid,int * out_critical,int * out_idx)43 void *X509_CRL_get_ext_d2i(const X509_CRL *crl, int nid, int *out_critical,
44 int *out_idx) {
45 return X509V3_get_d2i(crl->crl->extensions, nid, out_critical, out_idx);
46 }
47
X509_CRL_add1_ext_i2d(X509_CRL * x,int nid,void * value,int crit,unsigned long flags)48 int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
49 unsigned long flags) {
50 return X509V3_add1_i2d(&x->crl->extensions, nid, value, crit, flags);
51 }
52
X509_CRL_add_ext(X509_CRL * x,const X509_EXTENSION * ex,int loc)53 int X509_CRL_add_ext(X509_CRL *x, const X509_EXTENSION *ex, int loc) {
54 return (X509v3_add_ext(&(x->crl->extensions), ex, loc) != NULL);
55 }
56
X509_get_ext_count(const X509 * x)57 int X509_get_ext_count(const X509 *x) {
58 return (X509v3_get_ext_count(x->cert_info->extensions));
59 }
60
X509_get_ext_by_NID(const X509 * x,int nid,int lastpos)61 int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos) {
62 return (X509v3_get_ext_by_NID(x->cert_info->extensions, nid, lastpos));
63 }
64
X509_get_ext_by_OBJ(const X509 * x,const ASN1_OBJECT * obj,int lastpos)65 int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos) {
66 return (X509v3_get_ext_by_OBJ(x->cert_info->extensions, obj, lastpos));
67 }
68
X509_get_ext_by_critical(const X509 * x,int crit,int lastpos)69 int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos) {
70 return (X509v3_get_ext_by_critical(x->cert_info->extensions, crit, lastpos));
71 }
72
X509_get_ext(const X509 * x,int loc)73 X509_EXTENSION *X509_get_ext(const X509 *x, int loc) {
74 return (X509v3_get_ext(x->cert_info->extensions, loc));
75 }
76
X509_delete_ext(X509 * x,int loc)77 X509_EXTENSION *X509_delete_ext(X509 *x, int loc) {
78 return (X509v3_delete_ext(x->cert_info->extensions, loc));
79 }
80
X509_add_ext(X509 * x,const X509_EXTENSION * ex,int loc)81 int X509_add_ext(X509 *x, const X509_EXTENSION *ex, int loc) {
82 return (X509v3_add_ext(&(x->cert_info->extensions), ex, loc) != NULL);
83 }
84
X509_get_ext_d2i(const X509 * x509,int nid,int * out_critical,int * out_idx)85 void *X509_get_ext_d2i(const X509 *x509, int nid, int *out_critical,
86 int *out_idx) {
87 return X509V3_get_d2i(x509->cert_info->extensions, nid, out_critical,
88 out_idx);
89 }
90
X509_add1_ext_i2d(X509 * x,int nid,void * value,int crit,unsigned long flags)91 int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
92 unsigned long flags) {
93 return X509V3_add1_i2d(&x->cert_info->extensions, nid, value, crit, flags);
94 }
95
X509_REVOKED_get_ext_count(const X509_REVOKED * x)96 int X509_REVOKED_get_ext_count(const X509_REVOKED *x) {
97 return (X509v3_get_ext_count(x->extensions));
98 }
99
X509_REVOKED_get_ext_by_NID(const X509_REVOKED * x,int nid,int lastpos)100 int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos) {
101 return (X509v3_get_ext_by_NID(x->extensions, nid, lastpos));
102 }
103
X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED * x,const ASN1_OBJECT * obj,int lastpos)104 int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj,
105 int lastpos) {
106 return (X509v3_get_ext_by_OBJ(x->extensions, obj, lastpos));
107 }
108
X509_REVOKED_get_ext_by_critical(const X509_REVOKED * x,int crit,int lastpos)109 int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit,
110 int lastpos) {
111 return (X509v3_get_ext_by_critical(x->extensions, crit, lastpos));
112 }
113
X509_REVOKED_get_ext(const X509_REVOKED * x,int loc)114 X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc) {
115 return (X509v3_get_ext(x->extensions, loc));
116 }
117
X509_REVOKED_delete_ext(X509_REVOKED * x,int loc)118 X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc) {
119 return (X509v3_delete_ext(x->extensions, loc));
120 }
121
X509_REVOKED_add_ext(X509_REVOKED * x,const X509_EXTENSION * ex,int loc)122 int X509_REVOKED_add_ext(X509_REVOKED *x, const X509_EXTENSION *ex, int loc) {
123 return (X509v3_add_ext(&(x->extensions), ex, loc) != NULL);
124 }
125
X509_REVOKED_get_ext_d2i(const X509_REVOKED * revoked,int nid,int * out_critical,int * out_idx)126 void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *revoked, int nid,
127 int *out_critical, int *out_idx) {
128 return X509V3_get_d2i(revoked->extensions, nid, out_critical, out_idx);
129 }
130
X509_REVOKED_add1_ext_i2d(X509_REVOKED * x,int nid,void * value,int crit,unsigned long flags)131 int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
132 unsigned long flags) {
133 return X509V3_add1_i2d(&x->extensions, nid, value, crit, flags);
134 }
135