From 3439f4b9a8d53620600f47af705c871905b7249b Mon Sep 17 00:00:00 2001 From: "julian.speith" Date: Mon, 13 May 2024 14:07:51 +0200 Subject: [PATCH] initial HAWKEYE commit --- plugins/.gitignore | 10 +-- plugins/hawkeye/CMakeLists.txt | 18 +++++ plugins/hawkeye/documentation/hawkeye.rst | 2 + .../hawkeye/include/hawkeye/plugin_hawkeye.h | 72 +++++++++++++++++++ plugins/hawkeye/python/python_bindings.cpp | 71 ++++++++++++++++++ plugins/hawkeye/src/plugin_hawkeye.cpp | 35 +++++++++ 6 files changed, 204 insertions(+), 4 deletions(-) create mode 100644 plugins/hawkeye/CMakeLists.txt create mode 100644 plugins/hawkeye/documentation/hawkeye.rst create mode 100644 plugins/hawkeye/include/hawkeye/plugin_hawkeye.h create mode 100644 plugins/hawkeye/python/python_bindings.cpp create mode 100644 plugins/hawkeye/src/plugin_hawkeye.cpp diff --git a/plugins/.gitignore b/plugins/.gitignore index d4a380aef01..b88558e8765 100644 --- a/plugins/.gitignore +++ b/plugins/.gitignore @@ -15,14 +15,16 @@ !gui/**/* !gui_extension_demo* !gui_extension_demo/**/* -!liberty_parser* -!liberty_parser/**/* -!netlist_preprocessing* -!netlist_preprocessing/**/* +!hawkeye* +!hawkeye/**/* !hgl_parser* !hgl_parser/**/* !hgl_writer* !hgl_writer/**/* +!liberty_parser* +!liberty_parser/**/* +!netlist_preprocessing* +!netlist_preprocessing/**/* !python_shell* !python_shell/**/* !simulator diff --git a/plugins/hawkeye/CMakeLists.txt b/plugins/hawkeye/CMakeLists.txt new file mode 100644 index 00000000000..7d94e4b571f --- /dev/null +++ b/plugins/hawkeye/CMakeLists.txt @@ -0,0 +1,18 @@ +option(PL_HAWKEYE "PL_HAWKEYE" ON) + +if(PL_HAWKEYE OR BUILD_ALL_PLUGINS) + + file(GLOB_RECURSE HAWKEYE_INC ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h) + file(GLOB_RECURSE HAWKEYE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) + file(GLOB_RECURSE HAWKEYE_PYTHON_SRC ${CMAKE_CURRENT_SOURCE_DIR}/python/*.cpp) + + hal_add_plugin(hawkeye + SHARED + HEADER ${HAWKEYE_INC} + SOURCES ${HAWKEYE_SRC} ${HAWKEYE_PYTHON_SRC} + PYDOC SPHINX_DOC_INDEX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/documentation/hawkeye.rst + LINK_LIBRARIES graph_algorithm + COMPILE_OPTIONS "-march=native" + ) + +endif() diff --git a/plugins/hawkeye/documentation/hawkeye.rst b/plugins/hawkeye/documentation/hawkeye.rst new file mode 100644 index 00000000000..5dcfa3a7e76 --- /dev/null +++ b/plugins/hawkeye/documentation/hawkeye.rst @@ -0,0 +1,2 @@ +HAWKEYE +========================== \ No newline at end of file diff --git a/plugins/hawkeye/include/hawkeye/plugin_hawkeye.h b/plugins/hawkeye/include/hawkeye/plugin_hawkeye.h new file mode 100644 index 00000000000..d5908bd2a48 --- /dev/null +++ b/plugins/hawkeye/include/hawkeye/plugin_hawkeye.h @@ -0,0 +1,72 @@ +// MIT License +// +// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved. +// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved. +// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved. +// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include "hal_core/plugin_system/plugin_interface_base.h" + +namespace hal +{ + class Gate; + class Netlist; + + class PLUGIN_API HawkeyePlugin : public BasePluginInterface + { + public: + /* + * interface implementations + */ + + HawkeyePlugin(); + ~HawkeyePlugin() = default; + + /** + * Get the name of the plugin. + * + * @returns The name of the plugin. + */ + std::string get_name() const override; + + /** + * Get short description for plugin. + * + * @return The short description. + */ + std::string get_description() const override; + + /** + * Get the version of the plugin. + * + * @returns The version of the plugin. + */ + std::string get_version() const override; + + /** + * Get plugin dependencies. + * @return Set of plugins that this plugin depends on. + */ + std::set get_dependencies() const override; + }; +} // namespace hal diff --git a/plugins/hawkeye/python/python_bindings.cpp b/plugins/hawkeye/python/python_bindings.cpp new file mode 100644 index 00000000000..eacfe4f9097 --- /dev/null +++ b/plugins/hawkeye/python/python_bindings.cpp @@ -0,0 +1,71 @@ +#include "hal_core/python_bindings/python_bindings.h" + +#include "hawkeye/plugin_hawkeye.h" +#include "pybind11/operators.h" +#include "pybind11/pybind11.h" +#include "pybind11/stl.h" +#include "pybind11/stl_bind.h" + +namespace py = pybind11; + +namespace hal +{ + + // the name in PYBIND11_MODULE/PYBIND11_PLUGIN *MUST* match the filename of the output library (without extension), + // otherwise you will get "ImportError: dynamic module does not define module export function" when importing the module + +#ifdef PYBIND11_MODULE + PYBIND11_MODULE(hawkeye, m) + { + m.doc() = "hal HawkeyePlugin python bindings"; +#else + PYBIND11_PLUGIN(hawkeye) + { + py::module m("hawkeye", "hal HawkeyePlugin python bindings"); +#endif // ifdef PYBIND11_MODULE + + py::class_, BasePluginInterface> py_hawkeye_plugin(m, "HawkeyePlugin"); + py_hawkeye_plugin.def_property_readonly("name", &HawkeyePlugin::get_name, R"( + The name of the plugin. + + :type: str + )"); + + py_hawkeye_plugin.def("get_name", &HawkeyePlugin::get_name, R"( + Get the name of the plugin. + + :returns: Plugin name. + :rtype: str + )"); + + py_hawkeye_plugin.def_property_readonly("description", &HawkeyePlugin::get_description, R"( + The description of the plugin. + + :type: str + )"); + + py_hawkeye_plugin.def("get_description", &HawkeyePlugin::get_description, R"( + Get the description of the plugin. + + :returns: The description of the plugin. + :rtype: str + )"); + + py_hawkeye_plugin.def_property_readonly("version", &HawkeyePlugin::get_version, R"( + The version of the plugin. + + :type: str + )"); + + py_hawkeye_plugin.def("get_version", &HawkeyePlugin::get_version, R"( + Get the version of the plugin. + + :returns: Plugin version. + :rtype: str + )"); + +#ifndef PYBIND11_MODULE + return m.ptr(); +#endif // PYBIND11_MODULE + } +} // namespace hal diff --git a/plugins/hawkeye/src/plugin_hawkeye.cpp b/plugins/hawkeye/src/plugin_hawkeye.cpp new file mode 100644 index 00000000000..ce845d9c465 --- /dev/null +++ b/plugins/hawkeye/src/plugin_hawkeye.cpp @@ -0,0 +1,35 @@ +#include "hawkeye/plugin_hawkeye.h" + +namespace hal +{ + extern std::unique_ptr create_plugin_instance() + { + return std::make_unique(); + } + + std::string HawkeyePlugin::get_name() const + { + return std::string("hawkeye"); + } + + std::string HawkeyePlugin::get_description() const + { + return "Attempts to locate arbitrary symmetric cryptographic implementations."; + } + + std::string HawkeyePlugin::get_version() const + { + return std::string("0.1"); + } + + std::set HawkeyePlugin::get_dependencies() const + { + std::set retval; + retval.insert("graph_algorithm"); + return retval; + } + + HawkeyePlugin::HawkeyePlugin() + { + } +} // namespace hal