os/ossrv/ssl/libcrypto/src/crypto/x509/x509cset.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ssl/libcrypto/src/crypto/x509/x509cset.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,170 @@
     1.4 +/* crypto/x509/x509cset.c */
     1.5 +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
     1.6 + * project 2001.
     1.7 + */
     1.8 +/* ====================================================================
     1.9 + * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.
    1.10 + *
    1.11 + * Redistribution and use in source and binary forms, with or without
    1.12 + * modification, are permitted provided that the following conditions
    1.13 + * are met:
    1.14 + *
    1.15 + * 1. Redistributions of source code must retain the above copyright
    1.16 + *    notice, this list of conditions and the following disclaimer. 
    1.17 + *
    1.18 + * 2. Redistributions in binary form must reproduce the above copyright
    1.19 + *    notice, this list of conditions and the following disclaimer in
    1.20 + *    the documentation and/or other materials provided with the
    1.21 + *    distribution.
    1.22 + *
    1.23 + * 3. All advertising materials mentioning features or use of this
    1.24 + *    software must display the following acknowledgment:
    1.25 + *    "This product includes software developed by the OpenSSL Project
    1.26 + *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
    1.27 + *
    1.28 + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
    1.29 + *    endorse or promote products derived from this software without
    1.30 + *    prior written permission. For written permission, please contact
    1.31 + *    licensing@OpenSSL.org.
    1.32 + *
    1.33 + * 5. Products derived from this software may not be called "OpenSSL"
    1.34 + *    nor may "OpenSSL" appear in their names without prior written
    1.35 + *    permission of the OpenSSL Project.
    1.36 + *
    1.37 + * 6. Redistributions of any form whatsoever must retain the following
    1.38 + *    acknowledgment:
    1.39 + *    "This product includes software developed by the OpenSSL Project
    1.40 + *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
    1.41 + *
    1.42 + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
    1.43 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.44 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    1.45 + * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
    1.46 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.47 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    1.48 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    1.49 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.50 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    1.51 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.52 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    1.53 + * OF THE POSSIBILITY OF SUCH DAMAGE.
    1.54 + * ====================================================================
    1.55 + *
    1.56 + * This product includes cryptographic software written by Eric Young
    1.57 + * (eay@cryptsoft.com).  This product includes software written by Tim
    1.58 + * Hudson (tjh@cryptsoft.com).
    1.59 + *
    1.60 + */
    1.61 +
    1.62 +#include <stdio.h>
    1.63 +#include "cryptlib.h"
    1.64 +#include <openssl/asn1.h>
    1.65 +#include <openssl/objects.h>
    1.66 +#include <openssl/evp.h>
    1.67 +#include <openssl/x509.h>
    1.68 +
    1.69 +EXPORT_C int X509_CRL_set_version(X509_CRL *x, long version)
    1.70 +	{
    1.71 +	if (x == NULL) return(0);
    1.72 +	if (x->crl->version == NULL)
    1.73 +		{
    1.74 +		if ((x->crl->version=M_ASN1_INTEGER_new()) == NULL)
    1.75 +			return(0);
    1.76 +		}
    1.77 +	return(ASN1_INTEGER_set(x->crl->version,version));
    1.78 +	}
    1.79 +
    1.80 +EXPORT_C int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name)
    1.81 +	{
    1.82 +	if ((x == NULL) || (x->crl == NULL)) return(0);
    1.83 +	return(X509_NAME_set(&x->crl->issuer,name));
    1.84 +	}
    1.85 +
    1.86 +
    1.87 +EXPORT_C int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm)
    1.88 +	{
    1.89 +	ASN1_TIME *in;
    1.90 +
    1.91 +	if (x == NULL) return(0);
    1.92 +	in=x->crl->lastUpdate;
    1.93 +	if (in != tm)
    1.94 +		{
    1.95 +		in=M_ASN1_TIME_dup(tm);
    1.96 +		if (in != NULL)
    1.97 +			{
    1.98 +			M_ASN1_TIME_free(x->crl->lastUpdate);
    1.99 +			x->crl->lastUpdate=in;
   1.100 +			}
   1.101 +		}
   1.102 +	return(in != NULL);
   1.103 +	}
   1.104 +
   1.105 +EXPORT_C int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm)
   1.106 +	{
   1.107 +	ASN1_TIME *in;
   1.108 +
   1.109 +	if (x == NULL) return(0);
   1.110 +	in=x->crl->nextUpdate;
   1.111 +	if (in != tm)
   1.112 +		{
   1.113 +		in=M_ASN1_TIME_dup(tm);
   1.114 +		if (in != NULL)
   1.115 +			{
   1.116 +			M_ASN1_TIME_free(x->crl->nextUpdate);
   1.117 +			x->crl->nextUpdate=in;
   1.118 +			}
   1.119 +		}
   1.120 +	return(in != NULL);
   1.121 +	}
   1.122 +
   1.123 +EXPORT_C int X509_CRL_sort(X509_CRL *c)
   1.124 +	{
   1.125 +	int i;
   1.126 +	X509_REVOKED *r;
   1.127 +	/* sort the data so it will be written in serial
   1.128 +	 * number order */
   1.129 +	sk_X509_REVOKED_sort(c->crl->revoked);
   1.130 +	for (i=0; i<sk_X509_REVOKED_num(c->crl->revoked); i++)
   1.131 +		{
   1.132 +		r=sk_X509_REVOKED_value(c->crl->revoked,i);
   1.133 +		r->sequence=i;
   1.134 +		}
   1.135 +	c->crl->enc.modified = 1;
   1.136 +	return 1;
   1.137 +	}
   1.138 +
   1.139 +EXPORT_C int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm)
   1.140 +	{
   1.141 +	ASN1_TIME *in;
   1.142 +
   1.143 +	if (x == NULL) return(0);
   1.144 +	in=x->revocationDate;
   1.145 +	if (in != tm)
   1.146 +		{
   1.147 +		in=M_ASN1_TIME_dup(tm);
   1.148 +		if (in != NULL)
   1.149 +			{
   1.150 +			M_ASN1_TIME_free(x->revocationDate);
   1.151 +			x->revocationDate=in;
   1.152 +			}
   1.153 +		}
   1.154 +	return(in != NULL);
   1.155 +	}
   1.156 +
   1.157 +EXPORT_C int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial)
   1.158 +	{
   1.159 +	ASN1_INTEGER *in;
   1.160 +
   1.161 +	if (x == NULL) return(0);
   1.162 +	in=x->serialNumber;
   1.163 +	if (in != serial)
   1.164 +		{
   1.165 +		in=M_ASN1_INTEGER_dup(serial);
   1.166 +		if (in != NULL)
   1.167 +			{
   1.168 +			M_ASN1_INTEGER_free(x->serialNumber);
   1.169 +			x->serialNumber=in;
   1.170 +			}
   1.171 +		}
   1.172 +	return(in != NULL);
   1.173 +	}