chromium/third_party/boringssl/src/ssl/ssl_x509.cc

/* Copyright (C) 1995-1998 Eric Young ([email protected])
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young ([email protected]).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson ([email protected]).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young ([email protected])"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson ([email protected])"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2007 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    [email protected].
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * ([email protected]).  This product includes software written by Tim
 * Hudson ([email protected]).
 *
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 * ECC cipher suite support in OpenSSL originally developed by
 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
 */
/* ====================================================================
 * Copyright 2005 Nokia. All rights reserved.
 *
 * The portions of the attached software ("Contribution") is developed by
 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
 * license.
 *
 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
 * support (see RFC 4279) to OpenSSL.
 *
 * No patent licenses or other rights except those expressly stated in
 * the OpenSSL open source license shall be deemed granted or received
 * expressly, by implication, estoppel, or otherwise.
 *
 * No assurances are provided by Nokia that the Contribution does not
 * infringe the patent or other intellectual property rights of any third
 * party or that the license provides you with all the necessary rights
 * to make use of the Contribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
 * OTHERWISE. */

#include <openssl/ssl.h>

#include <assert.h>

#include <openssl/asn1.h>
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/stack.h>
#include <openssl/x509.h>

#include "internal.h"
#include "../crypto/internal.h"


BSSL_NAMESPACE_BEGIN

// check_ssl_x509_method asserts that |ssl| has the X509-based method
// installed. Calling an X509-based method on an |ssl| with a different method
// will likely misbehave and possibly crash or leak memory.
static void check_ssl_x509_method(const SSL *ssl) {}

// check_ssl_ctx_x509_method acts like |check_ssl_x509_method|, but for an
// |SSL_CTX|.
static void check_ssl_ctx_x509_method(const SSL_CTX *ctx) {}

// x509_to_buffer returns a |CRYPTO_BUFFER| that contains the serialised
// contents of |x509|.
static UniquePtr<CRYPTO_BUFFER> x509_to_buffer(X509 *x509) {}

static void ssl_crypto_x509_cert_flush_cached_leaf(CERT *cert) {}

static void ssl_crypto_x509_cert_flush_cached_chain(CERT *cert) {}

// ssl_cert_set1_chain sets elements 1.. of |cert->chain| to the serialised
// forms of elements of |chain|. It returns one on success or zero on error, in
// which case no change to |cert->chain| is made. It preverses the existing
// leaf from |cert->chain|, if any.
static bool ssl_cert_set1_chain(CERT *cert, STACK_OF(X509) *chain) {}

static bool ssl_crypto_x509_check_client_CA_list(
    STACK_OF(CRYPTO_BUFFER) *names) {}

static void ssl_crypto_x509_cert_clear(CERT *cert) {}

static void ssl_crypto_x509_cert_free(CERT *cert) {}

static void ssl_crypto_x509_cert_dup(CERT *new_cert, const CERT *cert) {}

static bool ssl_crypto_x509_session_cache_objects(SSL_SESSION *sess) {}

static bool ssl_crypto_x509_session_dup(SSL_SESSION *new_session,
                                        const SSL_SESSION *session) {}

static void ssl_crypto_x509_session_clear(SSL_SESSION *session) {}

static bool ssl_crypto_x509_session_verify_cert_chain(SSL_SESSION *session,
                                                      SSL_HANDSHAKE *hs,
                                                      uint8_t *out_alert) {}

static void ssl_crypto_x509_hs_flush_cached_ca_names(SSL_HANDSHAKE *hs) {}

static bool ssl_crypto_x509_ssl_new(SSL_HANDSHAKE *hs) {}

static void ssl_crypto_x509_ssl_flush_cached_client_CA(SSL_CONFIG *cfg) {}

static void ssl_crypto_x509_ssl_config_free(SSL_CONFIG *cfg) {}

static bool ssl_crypto_x509_ssl_auto_chain_if_needed(SSL_HANDSHAKE *hs) {}

static void ssl_crypto_x509_ssl_ctx_flush_cached_client_CA(SSL_CTX *ctx) {}

static bool ssl_crypto_x509_ssl_ctx_new(SSL_CTX *ctx) {}

static void ssl_crypto_x509_ssl_ctx_free(SSL_CTX *ctx) {}

const SSL_X509_METHOD ssl_crypto_x509_method =;

BSSL_NAMESPACE_END

usingnamespacebssl;

X509 *SSL_get_peer_certificate(const SSL *ssl) {}

STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *ssl) {}

STACK_OF(X509) *SSL_get_peer_full_cert_chain(const SSL *ssl) {}

int SSL_CTX_set_purpose(SSL_CTX *ctx, int purpose) {}

int SSL_set_purpose(SSL *ssl, int purpose) {}

int SSL_CTX_set_trust(SSL_CTX *ctx, int trust) {}

int SSL_set_trust(SSL *ssl, int trust) {}

int SSL_CTX_set1_param(SSL_CTX *ctx, const X509_VERIFY_PARAM *param) {}

int SSL_set1_param(SSL *ssl, const X509_VERIFY_PARAM *param) {}

X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx) {}

X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl) {}

int SSL_get_verify_depth(const SSL *ssl) {}

int (*SSL_get_verify_callback(const SSL *ssl))(int, X509_STORE_CTX *) {}

int SSL_CTX_get_verify_mode(const SSL_CTX *ctx) {}

int SSL_CTX_get_verify_depth(const SSL_CTX *ctx) {}

int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(
    int ok, X509_STORE_CTX *store_ctx) {}

void SSL_set_verify(SSL *ssl, int mode,
                    int (*callback)(int ok, X509_STORE_CTX *store_ctx)) {}

void SSL_set_verify_depth(SSL *ssl, int depth) {}

void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx,
                                      int (*cb)(X509_STORE_CTX *store_ctx,
                                                void *arg),
                                      void *arg) {}

void SSL_CTX_set_verify(SSL_CTX *ctx, int mode,
                        int (*cb)(int, X509_STORE_CTX *)) {}

void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth) {}

int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) {}

int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *ca_file,
                                  const char *ca_dir) {}

long SSL_get_verify_result(const SSL *ssl) {}

X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx) {}

void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store) {}

static int ssl_use_certificate(CERT *cert, X509 *x) {}

int SSL_use_certificate(SSL *ssl, X509 *x) {}

int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x) {}

// ssl_cert_cache_leaf_cert sets |cert->x509_leaf|, if currently NULL, from the
// first element of |cert->chain|.
static int ssl_cert_cache_leaf_cert(CERT *cert) {}

static X509 *ssl_cert_get0_leaf(CERT *cert) {}

X509 *SSL_get_certificate(const SSL *ssl) {}

X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx) {}

static int ssl_cert_add1_chain_cert(CERT *cert, X509 *x509) {}

static int ssl_cert_add0_chain_cert(CERT *cert, X509 *x509) {}

int SSL_CTX_set0_chain(SSL_CTX *ctx, STACK_OF(X509) *chain) {}

int SSL_CTX_set1_chain(SSL_CTX *ctx, STACK_OF(X509) *chain) {}

int SSL_set0_chain(SSL *ssl, STACK_OF(X509) *chain) {}

int SSL_set1_chain(SSL *ssl, STACK_OF(X509) *chain) {}

int SSL_CTX_add0_chain_cert(SSL_CTX *ctx, X509 *x509) {}

int SSL_CTX_add1_chain_cert(SSL_CTX *ctx, X509 *x509) {}

int SSL_CTX_add_extra_chain_cert(SSL_CTX *ctx, X509 *x509) {}

int SSL_add0_chain_cert(SSL *ssl, X509 *x509) {}

int SSL_add1_chain_cert(SSL *ssl, X509 *x509) {}

int SSL_CTX_clear_chain_certs(SSL_CTX *ctx) {}

int SSL_CTX_clear_extra_chain_certs(SSL_CTX *ctx) {}

int SSL_clear_chain_certs(SSL *ssl) {}

// ssl_cert_cache_chain_certs fills in |cert->x509_chain| from elements 1.. of
// |cert->chain|.
static int ssl_cert_cache_chain_certs(CERT *cert) {}

int SSL_CTX_get0_chain_certs(const SSL_CTX *ctx, STACK_OF(X509) **out_chain) {}

int SSL_CTX_get_extra_chain_certs(const SSL_CTX *ctx,
                                  STACK_OF(X509) **out_chain) {}

int SSL_get0_chain_certs(const SSL *ssl, STACK_OF(X509) **out_chain) {}

SSL_SESSION *d2i_SSL_SESSION_bio(BIO *bio, SSL_SESSION **out) {}

int i2d_SSL_SESSION_bio(BIO *bio, const SSL_SESSION *session) {}

IMPLEMENT_PEM_rw()

SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const uint8_t **pp, long length) {}

STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *list) {}

static void set_client_CA_list(UniquePtr<STACK_OF(CRYPTO_BUFFER)> *ca_list,
                               const STACK_OF(X509_NAME) *name_list,
                               CRYPTO_BUFFER_POOL *pool) {}

void SSL_set_client_CA_list(SSL *ssl, STACK_OF(X509_NAME) *name_list) {}

void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list) {}

static STACK_OF(X509_NAME) *
    buffer_names_to_x509(const STACK_OF(CRYPTO_BUFFER) *names,
                         STACK_OF(X509_NAME) **cached) {}

STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *ssl) {}

STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *ctx) {}

static int add_client_CA(UniquePtr<STACK_OF(CRYPTO_BUFFER)> *names, X509 *x509,
                         CRYPTO_BUFFER_POOL *pool) {}

int SSL_add_client_CA(SSL *ssl, X509 *x509) {}

int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x509) {}

static int do_client_cert_cb(SSL *ssl, void *arg) {}

void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl,
                                                        X509 **out_x509,
                                                        EVP_PKEY **out_pkey)) {}

static int set_cert_store(X509_STORE **store_ptr, X509_STORE *new_store,
                          int take_ref) {}

int SSL_get_ex_data_X509_STORE_CTX_idx(void) {}

int SSL_CTX_set0_verify_cert_store(SSL_CTX *ctx, X509_STORE *store) {}

int SSL_CTX_set1_verify_cert_store(SSL_CTX *ctx, X509_STORE *store) {}

int SSL_set0_verify_cert_store(SSL *ssl, X509_STORE *store) {}

int SSL_set1_verify_cert_store(SSL *ssl, X509_STORE *store) {}

int SSL_set1_host(SSL *ssl, const char *hostname) {}

void SSL_set_hostflags(SSL *ssl, unsigned flags) {}

int SSL_alert_from_verify_result(long result) {}