Add features support to fips-prf plugin
authorMartin Willi <martin@revosec.ch>
Thu, 13 Oct 2011 11:01:56 +0000 (13:01 +0200)
committerMartin Willi <martin@revosec.ch>
Fri, 14 Oct 2011 08:05:48 +0000 (10:05 +0200)
src/libstrongswan/plugins/fips_prf/fips_prf_plugin.c

index 7038da1..68b6bac 100644 (file)
@@ -37,11 +37,21 @@ METHOD(plugin_t, get_name, char*,
        return "fips-prf";
 }
 
+METHOD(plugin_t, get_features, int,
+       private_fips_prf_plugin_t *this, plugin_feature_t *features[])
+{
+       static plugin_feature_t f[] = {
+               PLUGIN_REGISTER(PRF, fips_prf_create),
+                       PLUGIN_PROVIDE(PRF, PRF_FIPS_SHA1_160),
+                               PLUGIN_DEPENDS(PRF, PRF_KEYED_SHA1),
+       };
+       *features = f;
+       return countof(f);
+}
+
 METHOD(plugin_t, destroy, void,
        private_fips_prf_plugin_t *this)
 {
-       lib->crypto->remove_prf(lib->crypto,
-                                                       (prf_constructor_t)fips_prf_create);
        free(this);
 }
 
@@ -51,25 +61,16 @@ METHOD(plugin_t, destroy, void,
 plugin_t *fips_prf_plugin_create()
 {
        private_fips_prf_plugin_t *this;
-       prf_t *prf;
 
        INIT(this,
                .public = {
                        .plugin = {
                                .get_name = _get_name,
-                               .reload = (void*)return_false,
+                               .get_features = _get_features,
                                .destroy = _destroy,
                        },
                },
        );
 
-       prf = lib->crypto->create_prf(lib->crypto, PRF_KEYED_SHA1);
-       if (prf)
-       {
-               prf->destroy(prf);
-               lib->crypto->add_prf(lib->crypto, PRF_FIPS_SHA1_160, get_name(this),
-                                                        (prf_constructor_t)fips_prf_create);
-       }
-
        return &this->public.plugin;
 }