From 6b96cc33e647d73a94fdf2363449bfc1fd7b84fd Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 20 Apr 2013 09:58:12 +0200 Subject: [PATCH] algo_suite: register all algorithms and enjoy them --- src/algo_suite.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/algo_suite.h | 26 ++++++++++++++++++++++++++ src/main.cpp | 10 ++++++++-- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/algo_suite.cpp create mode 100644 src/algo_suite.h diff --git a/src/algo_suite.cpp b/src/algo_suite.cpp new file mode 100644 index 0000000..a74e030 --- /dev/null +++ b/src/algo_suite.cpp @@ -0,0 +1,38 @@ + +/* + * This file is part of Codecrypt. + * + * Codecrypt is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Codecrypt is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Codecrypt. If not, see . + */ + +#include "algo_suite.h" + +#include "algos_enc.h" +#include "algos_sig.h" + +void fill_algorithm_suite (algorithm_suite&s) +{ + + static algo_mceqd128 mce1; + mce1.register_into_suite (s); + + static algo_mceqd256 mce2; + mce2.register_into_suite (s); + + static algo_fmtseq128 fmt1; + fmt1.register_into_suite (s); + + static algo_fmtseq256 fmt2; + fmt2.register_into_suite (s); +} diff --git a/src/algo_suite.h b/src/algo_suite.h new file mode 100644 index 0000000..7eb006b --- /dev/null +++ b/src/algo_suite.h @@ -0,0 +1,26 @@ + +/* + * This file is part of Codecrypt. + * + * Codecrypt is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Codecrypt is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Codecrypt. If not, see . + */ + +#ifndef _ccr_algo_suite_h_ +#define _ccr_algo_suite_h_ + +#include "algorithm.h" + +void fill_algorithm_suite (algorithm_suite&); + +#endif diff --git a/src/main.cpp b/src/main.cpp index 8a5acd9..6da2f41 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -97,7 +97,9 @@ void test() */ #include + #include "keyring.h" +#include "algo_suite.h" int main (int argc, char**argv) { @@ -207,13 +209,14 @@ int main (int argc, char**argv) } /* - * something is happening here, therefore init everything + * something will be happening, therefore init everything */ int exitflag = 0; - keyring KR; + algorithm_suite AS; + //keyring initialization if (!KR.open() ) { err ("could not open keyring!"); return 1; @@ -225,6 +228,9 @@ int main (int argc, char**argv) goto exit_ok; } + //register all available algorithms + fill_algorithm_suite (AS); + /* * check the option flags and do whatever was requested */