Cleanup CERT payload constructors
This commit is contained in:
@@ -304,10 +304,12 @@ cert_payload_t *cert_payload_create(payload_type_t type)
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
cert_payload_t *cert_payload_create_from_cert(certificate_t *cert, payload_type_t type)
|
||||
cert_payload_t *cert_payload_create_from_cert(payload_type_t type,
|
||||
certificate_t *cert)
|
||||
{
|
||||
private_cert_payload_t *this = (private_cert_payload_t*)cert_payload_create(type);
|
||||
private_cert_payload_t *this;
|
||||
|
||||
this = (private_cert_payload_t*)cert_payload_create(type);
|
||||
switch (cert->get_type(cert))
|
||||
{
|
||||
case CERT_X509:
|
||||
@@ -326,33 +328,38 @@ cert_payload_t *cert_payload_create_from_cert(certificate_t *cert, payload_type_
|
||||
return NULL;
|
||||
}
|
||||
this->payload_length = get_header_length(this) + this->data.len;
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
cert_payload_t *cert_payload_create_from_hash_and_url(chunk_t hash, char *url,
|
||||
payload_type_t type)
|
||||
cert_payload_t *cert_payload_create_from_hash_and_url(chunk_t hash, char *url)
|
||||
{
|
||||
private_cert_payload_t *this = (private_cert_payload_t*)cert_payload_create(type);
|
||||
private_cert_payload_t *this;
|
||||
|
||||
this = (private_cert_payload_t*)cert_payload_create(CERTIFICATE);
|
||||
this->encoding = ENC_X509_HASH_AND_URL;
|
||||
this->data = chunk_cat("cc", hash, chunk_create(url, strlen(url)));
|
||||
this->payload_length = get_header_length(this) + this->data.len;
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
cert_payload_t *cert_payload_create_custom(cert_encoding_t encoding,
|
||||
chunk_t data, payload_type_t type)
|
||||
cert_payload_t *cert_payload_create_custom(payload_type_t type,
|
||||
cert_encoding_t encoding, chunk_t data)
|
||||
{
|
||||
private_cert_payload_t *this = (private_cert_payload_t*)cert_payload_create(type);
|
||||
private_cert_payload_t *this;
|
||||
|
||||
this = (private_cert_payload_t*)cert_payload_create(type);
|
||||
this->encoding = encoding;
|
||||
this->data = data;
|
||||
this->payload_length = get_header_length(this) + this->data.len;
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,9 +55,7 @@ enum cert_encoding_t {
|
||||
extern enum_name_t *cert_encoding_names;
|
||||
|
||||
/**
|
||||
* Class representing an IKEv2 CERT payload.
|
||||
*
|
||||
* The CERT payload format is described in RFC section 3.6.
|
||||
* Class representing an IKEv1/IKEv2 CERT payload.
|
||||
*/
|
||||
struct cert_payload_t {
|
||||
|
||||
@@ -121,17 +119,16 @@ cert_payload_t *cert_payload_create(payload_type_t type);
|
||||
* @param cert certificate to embed
|
||||
* @return cert_payload_t object
|
||||
*/
|
||||
cert_payload_t *cert_payload_create_from_cert(certificate_t *cert, payload_type_t type);
|
||||
cert_payload_t *cert_payload_create_from_cert(payload_type_t type,
|
||||
certificate_t *cert);
|
||||
|
||||
/**
|
||||
* Creates a certificate payload with hash and URL encoding of a certificate.
|
||||
* Creates an IKEv2 certificate payload with hash and URL encoding.
|
||||
*
|
||||
* @param type payload type (for IKEv1 or IKEv2)
|
||||
* @param hash hash of the DER encoded certificate (get's cloned)
|
||||
* @param url the URL to locate the certificate (get's cloned)
|
||||
* @return cert_payload_t object
|
||||
*/
|
||||
cert_payload_t *cert_payload_create_from_hash_and_url(chunk_t hash, char *url, payload_type_t type);
|
||||
cert_payload_t *cert_payload_create_from_hash_and_url(chunk_t hash, char *url);
|
||||
|
||||
/**
|
||||
* Creates a custom certificate payload using type and associated data.
|
||||
@@ -141,6 +138,7 @@ cert_payload_t *cert_payload_create_from_hash_and_url(chunk_t hash, char *url, p
|
||||
* @param data associated data (gets owned)
|
||||
* @return cert_payload_t object
|
||||
*/
|
||||
cert_payload_t *cert_payload_create_custom(cert_encoding_t encoding, chunk_t data, payload_type_t type);
|
||||
cert_payload_t *cert_payload_create_custom(payload_type_t type,
|
||||
cert_encoding_t encoding, chunk_t data);
|
||||
|
||||
#endif /** CERT_PAYLOAD_H_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user