v3_ia5.c revision 68651
10Sduke/* v3_ia5.c */ 26412Sdrchase/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 30Sduke * project 1999. 40Sduke */ 50Sduke/* ==================================================================== 60Sduke * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 70Sduke * 80Sduke * Redistribution and use in source and binary forms, with or without 90Sduke * modification, are permitted provided that the following conditions 100Sduke * are met: 110Sduke * 120Sduke * 1. Redistributions of source code must retain the above copyright 130Sduke * notice, this list of conditions and the following disclaimer. 140Sduke * 150Sduke * 2. Redistributions in binary form must reproduce the above copyright 160Sduke * notice, this list of conditions and the following disclaimer in 170Sduke * the documentation and/or other materials provided with the 180Sduke * distribution. 191472Strims * 201472Strims * 3. All advertising materials mentioning features or use of this 211472Strims * software must display the following acknowledgment: 220Sduke * "This product includes software developed by the OpenSSL Project 230Sduke * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 240Sduke * 251879Sstefank * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 261879Sstefank * endorse or promote products derived from this software without 271879Sstefank * prior written permission. For written permission, please contact 281879Sstefank * licensing@OpenSSL.org. 291879Sstefank * 301879Sstefank * 5. Products derived from this software may not be called "OpenSSL" 311879Sstefank * nor may "OpenSSL" appear in their names without prior written 323059Snever * permission of the OpenSSL Project. 331879Sstefank * 341879Sstefank * 6. Redistributions of any form whatsoever must retain the following 351879Sstefank * acknowledgment: 360Sduke * "This product includes software developed by the OpenSSL Project 370Sduke * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 380Sduke * 390Sduke * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 400Sduke * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 410Sduke * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 420Sduke * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 430Sduke * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 440Sduke * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 450Sduke * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 460Sduke * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 470Sduke * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 480Sduke * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 490Sduke * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 500Sduke * OF THE POSSIBILITY OF SUCH DAMAGE. 510Sduke * ==================================================================== 520Sduke * 530Sduke * This product includes cryptographic software written by Eric Young 540Sduke * (eay@cryptsoft.com). This product includes software written by Tim 550Sduke * Hudson (tjh@cryptsoft.com). 560Sduke * 570Sduke */ 580Sduke 590Sduke 600Sduke#include <stdio.h> 610Sduke#include "cryptlib.h" 625862Sjwilhelm#include <openssl/asn1.h> 630Sduke#include <openssl/conf.h> 640Sduke#include <openssl/x509v3.h> 650Sduke 660Sdukestatic char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); 670Sdukestatic ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); 680SdukeX509V3_EXT_METHOD v3_ns_ia5_list[] = { 690SdukeEXT_IA5STRING(NID_netscape_base_url), 700SdukeEXT_IA5STRING(NID_netscape_revocation_url), 710SdukeEXT_IA5STRING(NID_netscape_ca_revocation_url), 720SdukeEXT_IA5STRING(NID_netscape_renewal_url), 730SdukeEXT_IA5STRING(NID_netscape_ca_policy_url), 740SdukeEXT_IA5STRING(NID_netscape_ssl_server_name), 750SdukeEXT_IA5STRING(NID_netscape_comment), 760SdukeEXT_END 770Sduke}; 780Sduke 791291Sxlu 800Sdukestatic char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, 810Sduke ASN1_IA5STRING *ia5) 820Sduke{ 830Sduke char *tmp; 840Sduke if(!ia5 || !ia5->length) return NULL; 850Sduke tmp = OPENSSL_malloc(ia5->length + 1); 860Sduke memcpy(tmp, ia5->data, ia5->length); 870Sduke tmp[ia5->length] = 0; 881291Sxlu return tmp; 890Sduke} 900Sduke 910Sdukestatic ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, 920Sduke X509V3_CTX *ctx, char *str) 930Sduke{ 945862Sjwilhelm ASN1_IA5STRING *ia5; 951291Sxlu if(!str) { 963059Snever X509V3err(X509V3_F_S2I_ASN1_IA5STRING,X509V3_R_INVALID_NULL_ARGUMENT); 970Sduke return NULL; 980Sduke } 990Sduke if(!(ia5 = M_ASN1_IA5STRING_new())) goto err; 1000Sduke if(!ASN1_STRING_set((ASN1_STRING *)ia5, (unsigned char*)str, 1010Sduke strlen(str))) { 1020Sduke M_ASN1_IA5STRING_free(ia5); 1030Sduke goto err; 1040Sduke } 1050Sduke#ifdef CHARSET_EBCDIC 1060Sduke ebcdic2ascii(ia5->data, ia5->data, ia5->length); 1071291Sxlu#endif /*CHARSET_EBCDIC*/ 1080Sduke return ia5; 1095862Sjwilhelm err: 1101291Sxlu X509V3err(X509V3_F_S2I_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE); 1111291Sxlu return NULL; 1121291Sxlu} 1131291Sxlu 1141291Sxlu