159191Skris/* t_x509a.c */
2296465Sdelphij/*
3296465Sdelphij * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
4296465Sdelphij * 1999.
559191Skris */
659191Skris/* ====================================================================
759191Skris * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
859191Skris *
959191Skris * Redistribution and use in source and binary forms, with or without
1059191Skris * modification, are permitted provided that the following conditions
1159191Skris * are met:
1259191Skris *
1359191Skris * 1. Redistributions of source code must retain the above copyright
14296465Sdelphij *    notice, this list of conditions and the following disclaimer.
1559191Skris *
1659191Skris * 2. Redistributions in binary form must reproduce the above copyright
1759191Skris *    notice, this list of conditions and the following disclaimer in
1859191Skris *    the documentation and/or other materials provided with the
1959191Skris *    distribution.
2059191Skris *
2159191Skris * 3. All advertising materials mentioning features or use of this
2259191Skris *    software must display the following acknowledgment:
2359191Skris *    "This product includes software developed by the OpenSSL Project
2459191Skris *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
2559191Skris *
2659191Skris * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
2759191Skris *    endorse or promote products derived from this software without
2859191Skris *    prior written permission. For written permission, please contact
2959191Skris *    licensing@OpenSSL.org.
3059191Skris *
3159191Skris * 5. Products derived from this software may not be called "OpenSSL"
3259191Skris *    nor may "OpenSSL" appear in their names without prior written
3359191Skris *    permission of the OpenSSL Project.
3459191Skris *
3559191Skris * 6. Redistributions of any form whatsoever must retain the following
3659191Skris *    acknowledgment:
3759191Skris *    "This product includes software developed by the OpenSSL Project
3859191Skris *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
3959191Skris *
4059191Skris * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
4159191Skris * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4259191Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4359191Skris * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
4459191Skris * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4559191Skris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4659191Skris * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4759191Skris * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4859191Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4959191Skris * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5059191Skris * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
5159191Skris * OF THE POSSIBILITY OF SUCH DAMAGE.
5259191Skris * ====================================================================
5359191Skris *
5459191Skris * This product includes cryptographic software written by Eric Young
5559191Skris * (eay@cryptsoft.com).  This product includes software written by Tim
5659191Skris * Hudson (tjh@cryptsoft.com).
5759191Skris *
5859191Skris */
5959191Skris
6059191Skris#include <stdio.h>
6159191Skris#include "cryptlib.h"
6259191Skris#include <openssl/evp.h>
63109998Smarkm#include <openssl/asn1.h>
6459191Skris#include <openssl/x509.h>
6559191Skris
66296465Sdelphij/*
67296465Sdelphij * X509_CERT_AUX and string set routines
6859191Skris */
6959191Skris
7059191Skrisint X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
7159191Skris{
72296465Sdelphij    char oidstr[80], first;
73296465Sdelphij    int i;
74296465Sdelphij    if (!aux)
75296465Sdelphij        return 1;
76296465Sdelphij    if (aux->trust) {
77296465Sdelphij        first = 1;
78296465Sdelphij        BIO_printf(out, "%*sTrusted Uses:\n%*s", indent, "", indent + 2, "");
79296465Sdelphij        for (i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) {
80296465Sdelphij            if (!first)
81296465Sdelphij                BIO_puts(out, ", ");
82296465Sdelphij            else
83296465Sdelphij                first = 0;
84296465Sdelphij            OBJ_obj2txt(oidstr, sizeof oidstr,
85296465Sdelphij                        sk_ASN1_OBJECT_value(aux->trust, i), 0);
86296465Sdelphij            BIO_puts(out, oidstr);
87296465Sdelphij        }
88296465Sdelphij        BIO_puts(out, "\n");
89296465Sdelphij    } else
90296465Sdelphij        BIO_printf(out, "%*sNo Trusted Uses.\n", indent, "");
91296465Sdelphij    if (aux->reject) {
92296465Sdelphij        first = 1;
93296465Sdelphij        BIO_printf(out, "%*sRejected Uses:\n%*s", indent, "", indent + 2, "");
94296465Sdelphij        for (i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) {
95296465Sdelphij            if (!first)
96296465Sdelphij                BIO_puts(out, ", ");
97296465Sdelphij            else
98296465Sdelphij                first = 0;
99296465Sdelphij            OBJ_obj2txt(oidstr, sizeof oidstr,
100296465Sdelphij                        sk_ASN1_OBJECT_value(aux->reject, i), 0);
101296465Sdelphij            BIO_puts(out, oidstr);
102296465Sdelphij        }
103296465Sdelphij        BIO_puts(out, "\n");
104296465Sdelphij    } else
105296465Sdelphij        BIO_printf(out, "%*sNo Rejected Uses.\n", indent, "");
106296465Sdelphij    if (aux->alias)
107296465Sdelphij        BIO_printf(out, "%*sAlias: %s\n", indent, "", aux->alias->data);
108296465Sdelphij    if (aux->keyid) {
109296465Sdelphij        BIO_printf(out, "%*sKey Id: ", indent, "");
110296465Sdelphij        for (i = 0; i < aux->keyid->length; i++)
111296465Sdelphij            BIO_printf(out, "%s%02X", i ? ":" : "", aux->keyid->data[i]);
112296465Sdelphij        BIO_write(out, "\n", 1);
113296465Sdelphij    }
114296465Sdelphij    return 1;
11559191Skris}
116