1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci#include <stdio.h> 11e1051a39Sopenharmony_ci#include "internal/cryptlib.h" 12e1051a39Sopenharmony_ci#include <openssl/asn1.h> 13e1051a39Sopenharmony_ci#include <openssl/objects.h> 14e1051a39Sopenharmony_ci#include <openssl/evp.h> 15e1051a39Sopenharmony_ci#include <openssl/x509.h> 16e1051a39Sopenharmony_ci#include "crypto/x509.h" 17e1051a39Sopenharmony_ci#include <openssl/x509v3.h> 18e1051a39Sopenharmony_ci 19e1051a39Sopenharmony_ciint X509_CRL_get_ext_count(const X509_CRL *x) 20e1051a39Sopenharmony_ci{ 21e1051a39Sopenharmony_ci return X509v3_get_ext_count(x->crl.extensions); 22e1051a39Sopenharmony_ci} 23e1051a39Sopenharmony_ci 24e1051a39Sopenharmony_ciint X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos) 25e1051a39Sopenharmony_ci{ 26e1051a39Sopenharmony_ci return X509v3_get_ext_by_NID(x->crl.extensions, nid, lastpos); 27e1051a39Sopenharmony_ci} 28e1051a39Sopenharmony_ci 29e1051a39Sopenharmony_ciint X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj, 30e1051a39Sopenharmony_ci int lastpos) 31e1051a39Sopenharmony_ci{ 32e1051a39Sopenharmony_ci return X509v3_get_ext_by_OBJ(x->crl.extensions, obj, lastpos); 33e1051a39Sopenharmony_ci} 34e1051a39Sopenharmony_ci 35e1051a39Sopenharmony_ciint X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos) 36e1051a39Sopenharmony_ci{ 37e1051a39Sopenharmony_ci return X509v3_get_ext_by_critical(x->crl.extensions, crit, lastpos); 38e1051a39Sopenharmony_ci} 39e1051a39Sopenharmony_ci 40e1051a39Sopenharmony_ciX509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc) 41e1051a39Sopenharmony_ci{ 42e1051a39Sopenharmony_ci return X509v3_get_ext(x->crl.extensions, loc); 43e1051a39Sopenharmony_ci} 44e1051a39Sopenharmony_ci 45e1051a39Sopenharmony_ciX509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc) 46e1051a39Sopenharmony_ci{ 47e1051a39Sopenharmony_ci return X509v3_delete_ext(x->crl.extensions, loc); 48e1051a39Sopenharmony_ci} 49e1051a39Sopenharmony_ci 50e1051a39Sopenharmony_civoid *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx) 51e1051a39Sopenharmony_ci{ 52e1051a39Sopenharmony_ci return X509V3_get_d2i(x->crl.extensions, nid, crit, idx); 53e1051a39Sopenharmony_ci} 54e1051a39Sopenharmony_ci 55e1051a39Sopenharmony_ciint X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, 56e1051a39Sopenharmony_ci unsigned long flags) 57e1051a39Sopenharmony_ci{ 58e1051a39Sopenharmony_ci return X509V3_add1_i2d(&x->crl.extensions, nid, value, crit, flags); 59e1051a39Sopenharmony_ci} 60e1051a39Sopenharmony_ci 61e1051a39Sopenharmony_ciint X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc) 62e1051a39Sopenharmony_ci{ 63e1051a39Sopenharmony_ci return (X509v3_add_ext(&(x->crl.extensions), ex, loc) != NULL); 64e1051a39Sopenharmony_ci} 65e1051a39Sopenharmony_ci 66e1051a39Sopenharmony_ciint X509_get_ext_count(const X509 *x) 67e1051a39Sopenharmony_ci{ 68e1051a39Sopenharmony_ci return X509v3_get_ext_count(x->cert_info.extensions); 69e1051a39Sopenharmony_ci} 70e1051a39Sopenharmony_ci 71e1051a39Sopenharmony_ciint X509_get_ext_by_NID(const X509 *x, int nid, int lastpos) 72e1051a39Sopenharmony_ci{ 73e1051a39Sopenharmony_ci return X509v3_get_ext_by_NID(x->cert_info.extensions, nid, lastpos); 74e1051a39Sopenharmony_ci} 75e1051a39Sopenharmony_ci 76e1051a39Sopenharmony_ciint X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos) 77e1051a39Sopenharmony_ci{ 78e1051a39Sopenharmony_ci return X509v3_get_ext_by_OBJ(x->cert_info.extensions, obj, lastpos); 79e1051a39Sopenharmony_ci} 80e1051a39Sopenharmony_ci 81e1051a39Sopenharmony_ciint X509_get_ext_by_critical(const X509 *x, int crit, int lastpos) 82e1051a39Sopenharmony_ci{ 83e1051a39Sopenharmony_ci return (X509v3_get_ext_by_critical 84e1051a39Sopenharmony_ci (x->cert_info.extensions, crit, lastpos)); 85e1051a39Sopenharmony_ci} 86e1051a39Sopenharmony_ci 87e1051a39Sopenharmony_ciX509_EXTENSION *X509_get_ext(const X509 *x, int loc) 88e1051a39Sopenharmony_ci{ 89e1051a39Sopenharmony_ci return X509v3_get_ext(x->cert_info.extensions, loc); 90e1051a39Sopenharmony_ci} 91e1051a39Sopenharmony_ci 92e1051a39Sopenharmony_ciX509_EXTENSION *X509_delete_ext(X509 *x, int loc) 93e1051a39Sopenharmony_ci{ 94e1051a39Sopenharmony_ci return X509v3_delete_ext(x->cert_info.extensions, loc); 95e1051a39Sopenharmony_ci} 96e1051a39Sopenharmony_ci 97e1051a39Sopenharmony_ciint X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc) 98e1051a39Sopenharmony_ci{ 99e1051a39Sopenharmony_ci return (X509v3_add_ext(&(x->cert_info.extensions), ex, loc) != NULL); 100e1051a39Sopenharmony_ci} 101e1051a39Sopenharmony_ci 102e1051a39Sopenharmony_civoid *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx) 103e1051a39Sopenharmony_ci{ 104e1051a39Sopenharmony_ci return X509V3_get_d2i(x->cert_info.extensions, nid, crit, idx); 105e1051a39Sopenharmony_ci} 106e1051a39Sopenharmony_ci 107e1051a39Sopenharmony_ciint X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, 108e1051a39Sopenharmony_ci unsigned long flags) 109e1051a39Sopenharmony_ci{ 110e1051a39Sopenharmony_ci return X509V3_add1_i2d(&x->cert_info.extensions, nid, value, crit, 111e1051a39Sopenharmony_ci flags); 112e1051a39Sopenharmony_ci} 113e1051a39Sopenharmony_ci 114e1051a39Sopenharmony_ciint X509_REVOKED_get_ext_count(const X509_REVOKED *x) 115e1051a39Sopenharmony_ci{ 116e1051a39Sopenharmony_ci return X509v3_get_ext_count(x->extensions); 117e1051a39Sopenharmony_ci} 118e1051a39Sopenharmony_ci 119e1051a39Sopenharmony_ciint X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos) 120e1051a39Sopenharmony_ci{ 121e1051a39Sopenharmony_ci return X509v3_get_ext_by_NID(x->extensions, nid, lastpos); 122e1051a39Sopenharmony_ci} 123e1051a39Sopenharmony_ci 124e1051a39Sopenharmony_ciint X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, 125e1051a39Sopenharmony_ci int lastpos) 126e1051a39Sopenharmony_ci{ 127e1051a39Sopenharmony_ci return X509v3_get_ext_by_OBJ(x->extensions, obj, lastpos); 128e1051a39Sopenharmony_ci} 129e1051a39Sopenharmony_ci 130e1051a39Sopenharmony_ciint X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit, int lastpos) 131e1051a39Sopenharmony_ci{ 132e1051a39Sopenharmony_ci return X509v3_get_ext_by_critical(x->extensions, crit, lastpos); 133e1051a39Sopenharmony_ci} 134e1051a39Sopenharmony_ci 135e1051a39Sopenharmony_ciX509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc) 136e1051a39Sopenharmony_ci{ 137e1051a39Sopenharmony_ci return X509v3_get_ext(x->extensions, loc); 138e1051a39Sopenharmony_ci} 139e1051a39Sopenharmony_ci 140e1051a39Sopenharmony_ciX509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc) 141e1051a39Sopenharmony_ci{ 142e1051a39Sopenharmony_ci return X509v3_delete_ext(x->extensions, loc); 143e1051a39Sopenharmony_ci} 144e1051a39Sopenharmony_ci 145e1051a39Sopenharmony_ciint X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc) 146e1051a39Sopenharmony_ci{ 147e1051a39Sopenharmony_ci return (X509v3_add_ext(&(x->extensions), ex, loc) != NULL); 148e1051a39Sopenharmony_ci} 149e1051a39Sopenharmony_ci 150e1051a39Sopenharmony_civoid *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit, int *idx) 151e1051a39Sopenharmony_ci{ 152e1051a39Sopenharmony_ci return X509V3_get_d2i(x->extensions, nid, crit, idx); 153e1051a39Sopenharmony_ci} 154e1051a39Sopenharmony_ci 155e1051a39Sopenharmony_ciint X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, 156e1051a39Sopenharmony_ci unsigned long flags) 157e1051a39Sopenharmony_ci{ 158e1051a39Sopenharmony_ci return X509V3_add1_i2d(&x->extensions, nid, value, crit, flags); 159e1051a39Sopenharmony_ci} 160