summaryrefslogtreecommitdiff
path: root/src/charon/encoding/payloads/cert_payload.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/charon/encoding/payloads/cert_payload.c')
-rw-r--r--src/charon/encoding/payloads/cert_payload.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/charon/encoding/payloads/cert_payload.c b/src/charon/encoding/payloads/cert_payload.c
index 54a8c1392..6dd3141f0 100644
--- a/src/charon/encoding/payloads/cert_payload.c
+++ b/src/charon/encoding/payloads/cert_payload.c
@@ -43,14 +43,14 @@ typedef struct private_cert_payload_t private_cert_payload_t;
/**
* Private data of an cert_payload_t object.
- *
+ *
*/
struct private_cert_payload_t {
/**
* Public cert_payload_t interface.
*/
cert_payload_t public;
-
+
/**
* Next payload type.
*/
@@ -60,22 +60,22 @@ struct private_cert_payload_t {
* Critical flag.
*/
bool critical;
-
+
/**
* Length of this payload.
*/
u_int16_t payload_length;
-
+
/**
* Encoding of the CERT Data.
*/
u_int8_t encoding;
-
+
/**
* The contained cert data value.
*/
chunk_t data;
-
+
/**
* TRUE if the "Hash and URL" data is invalid
*/
@@ -84,17 +84,17 @@ struct private_cert_payload_t {
/**
* Encoding rules to parse or generate a CERT payload
- *
- * The defined offsets are the positions in a object of type
+ *
+ * The defined offsets are the positions in a object of type
* private_cert_payload_t.
- *
+ *
*/
encoding_rule_t cert_payload_encodings[] = {
- /* 1 Byte next payload type, stored in the field next_payload */
+ /* 1 Byte next payload type, stored in the field next_payload */
{ U_INT_8, offsetof(private_cert_payload_t, next_payload) },
/* the critical bit */
{ FLAG, offsetof(private_cert_payload_t, critical) },
- /* 7 Bit reserved bits, nowhere stored */
+ /* 7 Bit reserved bits, nowhere stored */
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
@@ -104,7 +104,7 @@ encoding_rule_t cert_payload_encodings[] = {
{ RESERVED_BIT, 0 },
/* Length of the whole payload*/
{ PAYLOAD_LENGTH, offsetof(private_cert_payload_t, payload_length)},
- /* 1 Byte CERT type*/
+ /* 1 Byte CERT type*/
{ U_INT_8, offsetof(private_cert_payload_t, encoding) },
/* some cert data bytes, length is defined in PAYLOAD_LENGTH */
{ CERT_DATA, offsetof(private_cert_payload_t, data) }
@@ -139,7 +139,7 @@ static status_t verify(private_cert_payload_t *this)
this->invalid_hash_and_url = TRUE;
return SUCCESS;
}
-
+
int i = 20; /* skipping the hash */
for (; i < this->data.len; ++i)
{
@@ -156,7 +156,7 @@ static status_t verify(private_cert_payload_t *this)
return SUCCESS;
}
}
-
+
/* URL is not null terminated, correct that */
chunk_t data = chunk_alloc(this->data.len + 1);
memcpy(data.ptr, this->data.ptr, this->data.len);
@@ -268,7 +268,7 @@ static char *get_url(private_cert_payload_t *this)
static void destroy(private_cert_payload_t *this)
{
chunk_free(&this->data);
- free(this);
+ free(this);
}
/*
@@ -285,13 +285,13 @@ cert_payload_t *cert_payload_create()
this->public.payload_interface.set_next_type = (void (*) (payload_t*,payload_type_t))set_next_type;
this->public.payload_interface.get_type = (payload_type_t (*) (payload_t*))get_payload_type;
this->public.payload_interface.destroy = (void (*) (payload_t*))destroy;
-
+
this->public.destroy = (void (*) (cert_payload_t*))destroy;
this->public.get_cert = (certificate_t* (*) (cert_payload_t*))get_cert;
this->public.get_cert_encoding = (cert_encoding_t (*) (cert_payload_t*))get_cert_encoding;
this->public.get_hash = (chunk_t (*) (cert_payload_t*))get_hash;
this->public.get_url = (char* (*) (cert_payload_t*))get_url;
-
+
this->critical = FALSE;
this->next_payload = NO_PAYLOAD;
this->payload_length = CERT_PAYLOAD_HEADER_LENGTH;
@@ -331,14 +331,9 @@ cert_payload_t *cert_payload_create_from_cert(certificate_t *cert)
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();
- chunk_t url_chunk;
-
+
this->encoding = ENC_X509_HASH_AND_URL;
-
- url_chunk.ptr = url;
- url_chunk.len = strlen(url) + 1;
-
- this->data = chunk_cat("cc", hash, url_chunk);
+ this->data = chunk_cat("cc", hash, chunk_create(url, strlen(url)));
this->payload_length = CERT_PAYLOAD_HEADER_LENGTH + this->data.len;
return &this->public;
}