t_x509a.c revision 68651
1132718Skan/* t_x509a.c */
2169689Skan/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3132718Skan * project 1999.
4132718Skan */
5132718Skan/* ====================================================================
6132718Skan * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
7132718Skan *
8132718Skan * Redistribution and use in source and binary forms, with or without
9132718Skan * modification, are permitted provided that the following conditions
10132718Skan * are met:
11132718Skan *
12132718Skan * 1. Redistributions of source code must retain the above copyright
13132718Skan *    notice, this list of conditions and the following disclaimer.
14132718Skan *
15132718Skan * 2. Redistributions in binary form must reproduce the above copyright
16132718Skan *    notice, this list of conditions and the following disclaimer in
17132718Skan *    the documentation and/or other materials provided with the
18169689Skan *    distribution.
19169689Skan *
20132718Skan * 3. All advertising materials mentioning features or use of this
21169689Skan *    software must display the following acknowledgment:
22169689Skan *    "This product includes software developed by the OpenSSL Project
23169689Skan *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24132718Skan *
25132718Skan * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26132718Skan *    endorse or promote products derived from this software without
27132718Skan *    prior written permission. For written permission, please contact
28132718Skan *    licensing@OpenSSL.org.
29132718Skan *
30132718Skan * 5. Products derived from this software may not be called "OpenSSL"
31132718Skan *    nor may "OpenSSL" appear in their names without prior written
32132718Skan *    permission of the OpenSSL Project.
33132718Skan *
34132718Skan * 6. Redistributions of any form whatsoever must retain the following
35132718Skan *    acknowledgment:
36132718Skan *    "This product includes software developed by the OpenSSL Project
37132718Skan *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38132718Skan *
39132718Skan * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40132718Skan * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41132718Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42132718Skan * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
43132718Skan * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44132718Skan * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45132718Skan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46132718Skan * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47132718Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48132718Skan * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49132718Skan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50132718Skan * OF THE POSSIBILITY OF SUCH DAMAGE.
51132718Skan * ====================================================================
52132718Skan *
53132718Skan * This product includes cryptographic software written by Eric Young
54132718Skan * (eay@cryptsoft.com).  This product includes software written by Tim
55132718Skan * Hudson (tjh@cryptsoft.com).
56132718Skan *
57132718Skan */
58132718Skan
59132718Skan#include <stdio.h>
60132718Skan#include "cryptlib.h"
61132718Skan#include <openssl/evp.h>
62132718Skan#include <openssl/asn1_mac.h>
63132718Skan#include <openssl/x509.h>
64132718Skan
65132718Skan/* X509_CERT_AUX and string set routines
66132718Skan */
67169689Skan
68169689Skanint X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
69169689Skan{
70169689Skan	char oidstr[80], first;
71169689Skan	int i;
72169689Skan	if(!aux) return 1;
73169689Skan	if(aux->trust) {
74169689Skan		first = 1;
75169689Skan		BIO_printf(out, "%*sTrusted Uses:\n%*s",
76169689Skan						indent, "", indent + 2, "");
77132718Skan		for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) {
78132718Skan			if(!first) BIO_puts(out, ", ");
79132718Skan			else first = 0;
80169689Skan			OBJ_obj2txt(oidstr, 80,
81132718Skan				sk_ASN1_OBJECT_value(aux->trust, i), 0);
82169689Skan			BIO_puts(out, oidstr);
83169689Skan		}
84169689Skan		BIO_puts(out, "\n");
85169689Skan	} else BIO_printf(out, "%*sNo Trusted Uses.\n", indent, "");
86169689Skan	if(aux->reject) {
87169689Skan		first = 1;
88169689Skan		BIO_printf(out, "%*sRejected Uses:\n%*s",
89169689Skan						indent, "", indent + 2, "");
90169689Skan		for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) {
91169689Skan			if(!first) BIO_puts(out, ", ");
92169689Skan			else first = 0;
93132718Skan			OBJ_obj2txt(oidstr, 80,
94132718Skan				sk_ASN1_OBJECT_value(aux->reject, i), 0);
95132718Skan			BIO_puts(out, oidstr);
96132718Skan		}
97132718Skan		BIO_puts(out, "\n");
98132718Skan	} else BIO_printf(out, "%*sNo Rejected Uses.\n", indent, "");
99132718Skan	if(aux->alias) BIO_printf(out, "%*sAlias: %s\n", indent, "",
100132718Skan							aux->alias->data);
101132718Skan	if(aux->keyid) {
102132718Skan		BIO_printf(out, "%*sKey Id: ", indent, "");
103132718Skan		for(i = 0; i < aux->keyid->length; i++)
104132718Skan			BIO_printf(out, "%s%02X",
105132718Skan				i ? ":" : "",
106132718Skan				aux->keyid->data[i]);
107132718Skan		BIO_write(out,"\n",1);
108132718Skan	}
109132718Skan	return 1;
110132718Skan}
111132718Skan