Add an enumerator for PKCS#7 contained certificates
authorMartin Willi <martin@revosec.ch>
Tue, 27 Nov 2012 16:35:30 +0000 (17:35 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 19 Dec 2012 09:32:08 +0000 (10:32 +0100)
src/libstrongswan/credentials/containers/pkcs7.h
src/libstrongswan/plugins/pkcs7/pkcs7_data.c
src/libstrongswan/plugins/pkcs7/pkcs7_enveloped_data.c
src/libstrongswan/plugins/pkcs7/pkcs7_signed_data.c

index 68125cd..d79650e 100644 (file)
@@ -48,6 +48,13 @@ struct pkcs7_t {
         */
        bool (*get_attribute)(pkcs7_t *this, int oid, enumerator_t *enumerator,
                                                  chunk_t *value);
+
+       /**
+        * Create an enumerator over attached certificates.
+        *
+        * @return                              enumerator over certificate_t
+        */
+       enumerator_t* (*create_cert_enumerator)(pkcs7_t *this);
 };
 
 #endif /** PKCS7_H_ @}*/
index d0e7e1c..0681609 100644 (file)
@@ -99,6 +99,7 @@ static private_pkcs7_data_t* create_empty()
                                .destroy = _destroy,
                        },
                        .get_attribute = (void*)return_false,
+                       .create_cert_enumerator = (void*)enumerator_create_empty,
                },
        );
 
index d9bff41..6c57ca7 100644 (file)
@@ -380,6 +380,7 @@ static private_pkcs7_enveloped_data_t* create_empty()
                                .get_encoding = _get_encoding,
                                .destroy = _destroy,
                        },
+                       .create_cert_enumerator = (void*)enumerator_create_empty,
                        .get_attribute = (void*)return_false,
                },
        );
index 5ec5684..1fffdc3 100644 (file)
@@ -330,6 +330,13 @@ METHOD(pkcs7_t, get_attribute, bool,
        return FALSE;
 }
 
+METHOD(pkcs7_t, create_cert_enumerator, enumerator_t*,
+       private_pkcs7_signed_data_t *this)
+{
+       return this->creds->set.create_cert_enumerator(&this->creds->set,
+                                                                                       CERT_ANY, KEY_ANY, NULL, FALSE);
+}
+
 METHOD(container_t, get_data, bool,
        private_pkcs7_signed_data_t *this, chunk_t *data)
 {
@@ -375,6 +382,7 @@ static private_pkcs7_signed_data_t* create_empty()
                                .destroy = _destroy,
                        },
                        .get_attribute = _get_attribute,
+                       .create_cert_enumerator = _create_cert_enumerator,
                },
                .creds = mem_cred_create(),
                .signerinfos = linked_list_create(),