encrypted_payload: Expose generate() to generate the plaintext
authorTobias Brunner <tobias@strongswan.org>
Thu, 12 Jun 2014 19:42:07 +0000 (21:42 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 10 Oct 2014 07:31:17 +0000 (09:31 +0200)
src/libcharon/encoding/payloads/encrypted_payload.c
src/libcharon/encoding/payloads/encrypted_payload.h

index bd309a9..431f7bb 100644 (file)
@@ -24,7 +24,6 @@
 #include <daemon.h>
 #include <encoding/payloads/encodings.h>
 #include <collections/linked_list.h>
-#include <encoding/generator.h>
 #include <encoding/parser.h>
 
 typedef struct private_encrypted_payload_t private_encrypted_payload_t;
@@ -298,6 +297,12 @@ static chunk_t generate(private_encrypted_payload_t *this,
        return chunk;
 }
 
+METHOD(encrypted_payload_t, generate_payloads, void,
+       private_encrypted_payload_t *this, generator_t *generator)
+{
+       generate(this, generator);
+}
+
 /**
  * Append the encrypted payload header to the associated data
  */
@@ -646,6 +651,7 @@ encrypted_payload_t *encrypted_payload_create(payload_type_t type)
                        .get_length = _get_length,
                        .add_payload = _add_payload,
                        .remove_payload = _remove_payload,
+                       .generate_payloads = _generate_payloads,
                        .set_transform = _set_transform,
                        .encrypt = _encrypt,
                        .decrypt = _decrypt,
index 57bcc21..663360f 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2014 Tobias Brunner
  * Copyright (C) 2005-2010 Martin Willi
  * Copyright (C) 2010 revosec AG
  * Copyright (C) 2005 Jan Hutter
@@ -28,6 +29,7 @@ typedef struct encrypted_payload_t encrypted_payload_t;
 #include <library.h>
 #include <crypto/aead.h>
 #include <encoding/payloads/payload.h>
+#include <encoding/generator.h>
 
 /**
  * The encrypted payload as described in RFC section 3.14.
@@ -62,6 +64,14 @@ struct encrypted_payload_t {
        payload_t* (*remove_payload)(encrypted_payload_t *this);
 
        /**
+        * Uses the given generator to generate the contained payloads.
+        *
+        * @param generator             generator used to generate the contained payloads
+        */
+       void (*generate_payloads)(encrypted_payload_t *this,
+                                                         generator_t *generator);
+
+       /**
         * Set the AEAD transform to use.
         *
         * @param aead          aead transform to use