added x509_create() synthesis function

This commit is contained in:
Andreas Steffen
2007-10-11 14:39:40 +00:00
parent a09bbc82ce
commit dba89b1bb7
2 changed files with 52 additions and 7 deletions
+29 -3
View File
@@ -23,6 +23,8 @@
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* RCSID $Id$
*/
#include <gmp.h>
@@ -1262,10 +1264,10 @@ static void destroy(private_x509_t *this)
free(this);
}
/*
* Described in header.
/**
* Internal generic constructor
*/
x509_t *x509_create_from_chunk(chunk_t chunk, u_int level)
static private_x509_t *x509_create_empty(void)
{
private_x509_t *this = malloc_thing(private_x509_t);
@@ -1315,6 +1317,30 @@ x509_t *x509_create_from_chunk(chunk_t chunk, u_int level)
this->public.list = (void(*)(x509_t*, FILE *out, bool utc))list;
this->public.destroy = (void (*) (x509_t*))destroy;
return this;
}
/*
* Described in header.
*/
x509_t *x509_create_(chunk_t serialNumber, identification_t *issuer, identification_t *subject)
{
private_x509_t *this = x509_create_empty();
this->serialNumber = serialNumber;
this->issuer = issuer->clone(issuer);
this->subject = subject->clone(subject);
return &this->public;
}
/*
* Described in header.
*/
x509_t *x509_create_from_chunk(chunk_t chunk, u_int level)
{
private_x509_t *this = x509_create_empty();
if (!parse_certificate(chunk, level, this))
{
destroy(this);
+23 -4
View File
@@ -23,6 +23,8 @@
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* RCSID $Id$
*/
#ifndef X509_H_
@@ -299,17 +301,34 @@ struct x509_t {
};
/**
* @brief Read a x509 certificate from a DER encoded blob.
*
* @brief Create a X.509 certificate from its components
*
* @param serialNumber chunk containing the serialNumber
* @param issuer issuer distinguished name
* @param notBefore start date of validity
* @param notAfter end date of validity
* @param subject subject distinguished name
*
* @return created x509_t certificate, or NULL if invalid.
*
* @ingroup crypto
*/
x509_t *x509_create(chunk_t serialNumber, identification_t *issuer,
time_t notBefore, time_t notAfter,
identification_t *subject);
/**
* @brief Read a X.509 certificate from a DER encoded blob.
*
* @param chunk chunk containing DER encoded data
* @return created x509_t certificate, or NULL if invlid.
* @return created x509_t certificate, or NULL if invalid.
*
* @ingroup crypto
*/
x509_t *x509_create_from_chunk(chunk_t chunk, u_int level);
/**
* @brief Read a x509 certificate from a DER encoded file.
* @brief Read a X.509 certificate from a DER encoded file.
*
* @param filename file containing DER encoded data
* @param label label describing kind of certificate