159191Skris/* t_x509a.c */ 2280297Sjkim/* 3280297Sjkim * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 4280297Sjkim * 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 14280297Sjkim * 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 66280297Sjkim/* 67280297Sjkim * X509_CERT_AUX and string set routines 6859191Skris */ 6959191Skris 7059191Skrisint X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent) 7159191Skris{ 72280297Sjkim char oidstr[80], first; 73280297Sjkim int i; 74280297Sjkim if (!aux) 75280297Sjkim return 1; 76280297Sjkim if (aux->trust) { 77280297Sjkim first = 1; 78280297Sjkim BIO_printf(out, "%*sTrusted Uses:\n%*s", indent, "", indent + 2, ""); 79280297Sjkim for (i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) { 80280297Sjkim if (!first) 81280297Sjkim BIO_puts(out, ", "); 82280297Sjkim else 83280297Sjkim first = 0; 84331638Sjkim OBJ_obj2txt(oidstr, sizeof(oidstr), 85280297Sjkim sk_ASN1_OBJECT_value(aux->trust, i), 0); 86280297Sjkim BIO_puts(out, oidstr); 87280297Sjkim } 88280297Sjkim BIO_puts(out, "\n"); 89280297Sjkim } else 90280297Sjkim BIO_printf(out, "%*sNo Trusted Uses.\n", indent, ""); 91280297Sjkim if (aux->reject) { 92280297Sjkim first = 1; 93280297Sjkim BIO_printf(out, "%*sRejected Uses:\n%*s", indent, "", indent + 2, ""); 94280297Sjkim for (i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) { 95280297Sjkim if (!first) 96280297Sjkim BIO_puts(out, ", "); 97280297Sjkim else 98280297Sjkim first = 0; 99331638Sjkim OBJ_obj2txt(oidstr, sizeof(oidstr), 100280297Sjkim sk_ASN1_OBJECT_value(aux->reject, i), 0); 101280297Sjkim BIO_puts(out, oidstr); 102280297Sjkim } 103280297Sjkim BIO_puts(out, "\n"); 104280297Sjkim } else 105280297Sjkim BIO_printf(out, "%*sNo Rejected Uses.\n", indent, ""); 106280297Sjkim if (aux->alias) 107370450Sgit2svn BIO_printf(out, "%*sAlias: %.*s\n", indent, "", aux->alias->length, 108370450Sgit2svn aux->alias->data); 109280297Sjkim if (aux->keyid) { 110280297Sjkim BIO_printf(out, "%*sKey Id: ", indent, ""); 111280297Sjkim for (i = 0; i < aux->keyid->length; i++) 112280297Sjkim BIO_printf(out, "%s%02X", i ? ":" : "", aux->keyid->data[i]); 113280297Sjkim BIO_write(out, "\n", 1); 114280297Sjkim } 115280297Sjkim return 1; 11659191Skris} 117