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