* 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>
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);
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);
* 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_
};
/**
- * @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 inv\ 1lid.
+ * @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