x_val.c revision 59191
10SN/A/* crypto/asn1/x_val.c */ 20SN/A/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 30SN/A * All rights reserved. 40SN/A * 50SN/A * This package is an SSL implementation written 60SN/A * by Eric Young (eay@cryptsoft.com). 70SN/A * The implementation was written so as to conform with Netscapes SSL. 80SN/A * 90SN/A * This library is free for commercial and non-commercial use as long as 100SN/A * the following conditions are aheared to. The following conditions 110SN/A * apply to all code found in this distribution, be it the RC4, RSA, 120SN/A * lhash, DES, etc., code; not just the SSL code. The SSL documentation 130SN/A * included with this distribution is covered by the same copyright terms 140SN/A * except that the holder is Tim Hudson (tjh@cryptsoft.com). 150SN/A * 160SN/A * Copyright remains Eric Young's, and as such any Copyright notices in 170SN/A * the code are not to be removed. 180SN/A * If this package is used in a product, Eric Young should be given attribution 190SN/A * as the author of the parts of the library used. 200SN/A * This can be in the form of a textual message at program startup or 210SN/A * in documentation (online or textual) provided with the package. 220SN/A * 230SN/A * Redistribution and use in source and binary forms, with or without 240SN/A * modification, are permitted provided that the following conditions 250SN/A * are met: 260SN/A * 1. Redistributions of source code must retain the copyright 270SN/A * notice, this list of conditions and the following disclaimer. 280SN/A * 2. Redistributions in binary form must reproduce the above copyright 290SN/A * notice, this list of conditions and the following disclaimer in the 300SN/A * documentation and/or other materials provided with the distribution. 310SN/A * 3. All advertising materials mentioning features or use of this software 320SN/A * must display the following acknowledgement: 330SN/A * "This product includes cryptographic software written by 340SN/A * Eric Young (eay@cryptsoft.com)" 350SN/A * The word 'cryptographic' can be left out if the rouines from the library 360SN/A * being used are not cryptographic related :-). 370SN/A * 4. If you include any Windows specific code (or a derivative thereof) from 380SN/A * the apps directory (application code) you must include an acknowledgement: 390SN/A * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 400SN/A * 410SN/A * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 420SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 430SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 440SN/A * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 450SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 460SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 470SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 480SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 490SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 500SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 510SN/A * SUCH DAMAGE. 520SN/A * 530SN/A * The licence and distribution terms for any publically available version or 540SN/A * derivative of this code cannot be changed. i.e. this code cannot simply be 550SN/A * copied and put under another distribution licence 560SN/A * [including the GNU Public Licence.] 570SN/A */ 580SN/A 590SN/A#include <stdio.h> 600SN/A#include "cryptlib.h" 610SN/A#include <openssl/asn1_mac.h> 620SN/A#include <openssl/x509.h> 630SN/A 640SN/Aint i2d_X509_VAL(X509_VAL *a, unsigned char **pp) 659934SN/A { 669934SN/A M_ASN1_I2D_vars(a); 670SN/A 680SN/A M_ASN1_I2D_len(a->notBefore,i2d_ASN1_TIME); 690SN/A M_ASN1_I2D_len(a->notAfter,i2d_ASN1_TIME); 700SN/A 710SN/A M_ASN1_I2D_seq_total(); 720SN/A 730SN/A M_ASN1_I2D_put(a->notBefore,i2d_ASN1_TIME); 740SN/A M_ASN1_I2D_put(a->notAfter,i2d_ASN1_TIME); 750SN/A 760SN/A M_ASN1_I2D_finish(); 770SN/A } 7810200SN/A 7910200SN/AX509_VAL *d2i_X509_VAL(X509_VAL **a, unsigned char **pp, long length) 8010200SN/A { 8110200SN/A M_ASN1_D2I_vars(a,X509_VAL *,X509_VAL_new); 8210200SN/A 8310200SN/A M_ASN1_D2I_Init(); 8410200SN/A M_ASN1_D2I_start_sequence(); 859934SN/A M_ASN1_D2I_get(ret->notBefore,d2i_ASN1_TIME); 869934SN/A M_ASN1_D2I_get(ret->notAfter,d2i_ASN1_TIME); 879934SN/A M_ASN1_D2I_Finish(a,X509_VAL_free,ASN1_F_D2I_X509_VAL); 889934SN/A } 899934SN/A 909934SN/AX509_VAL *X509_VAL_new(void) 919934SN/A { 929934SN/A X509_VAL *ret=NULL; 939934SN/A ASN1_CTX c; 949934SN/A 959934SN/A M_ASN1_New_Malloc(ret,X509_VAL); 969934SN/A M_ASN1_New(ret->notBefore,M_ASN1_TIME_new); 979934SN/A M_ASN1_New(ret->notAfter,M_ASN1_TIME_new); 9810200SN/A return(ret); 9910200SN/A M_ASN1_New_Error(ASN1_F_X509_VAL_NEW); 10010200SN/A } 10110200SN/A 10210200SN/Avoid X509_VAL_free(X509_VAL *a) 10310200SN/A { 10410200SN/A if (a == NULL) return; 1059934SN/A M_ASN1_TIME_free(a->notBefore); 1069934SN/A M_ASN1_TIME_free(a->notAfter); 1079934SN/A Free(a); 1089934SN/A } 1090SN/A 1100SN/A