summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt9
-rw-r--r--conanfile.py73
-rw-r--r--test.cpp2
-rw-r--r--test_package/CMakeLists.txt11
-rw-r--r--test_package/conanfile.py17
6 files changed, 113 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 1f1148f..8a9761d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/*.o
/test.elf
/test.map
+test_package/build
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..3c6081f
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(tinyaes C ASM)
+
+add_library(tiny-aes
+ aes.c
+ )
+
+target_include_directories(tiny-aes PRIVATE tiny-AES-c/)
diff --git a/conanfile.py b/conanfile.py
new file mode 100644
index 0000000..8a75744
--- /dev/null
+++ b/conanfile.py
@@ -0,0 +1,73 @@
+from conans import ConanFile, CMake
+from conans.errors import ConanException
+
+
+class TinyAesCConan(ConanFile):
+ name = "tiny-AES-c"
+ version = "1.0.0"
+ license = "The Unlicense"
+ url = "https://github.com/kokke/tiny-AES-c"
+ description = "Small portable AES128/192/256 in C"
+ topics = ("encryption", "crypto", "AES")
+ settings = "os", "compiler", "build_type", "arch"
+
+ generators = "cmake"
+ exports_sources = ["CMakeLists.txt", "*.c", '*.h', '*.hpp']
+ exports = ["unlicense.txt"]
+
+ _options_dict = {
+ # enable AES128
+ "AES128": [True, False],
+
+ # enable AES192
+ "AES192": [True, False],
+
+ # enable AES256
+ "AES256": [True, False],
+
+ # enable AES encryption in CBC-mode of operation
+ "CBC": [True, False],
+
+ # enable the basic ECB 16-byte block algorithm
+ "ECB": [True, False],
+
+ # enable encryption in counter-mode
+ "CTR": [True, False],
+ }
+
+ options = _options_dict
+
+ default_options = {
+ "AES128": True,
+ "AES192": False,
+ "AES256": False,
+ "CBC": True,
+ "ECB": True,
+ "CTR": True
+ }
+
+ def configure(self):
+ if not self.options.CBC and not self.options.ECB and not self.options.CTR:
+ raise ConanException("Need to at least specify one of CBC, ECB or CTR modes")
+
+ if not self.options.AES128 and not self.options.AES192 and not self.options.AES256:
+ raise ConanException("Need to at least specify one of AES{128, 192, 256} modes")
+
+ def build(self):
+ cmake = CMake(self)
+
+ for key in self._options_dict.keys():
+ if self.options[key]:
+ cmake.definitions["CMAKE_CFLAGS"].append(key)
+
+ cmake.configure()
+ cmake.build()
+
+ def package(self):
+ self.copy("*.h", dst="include")
+ self.copy("*.hpp", dst="include")
+ self.copy("*.a", dst="lib", keep_path=False)
+ self.copy("unlicense.txt")
+
+ def package_info(self):
+ self.cpp_info.libs = ["tiny-aes"]
diff --git a/test.cpp b/test.cpp
new file mode 100644
index 0000000..b7c8304
--- /dev/null
+++ b/test.cpp
@@ -0,0 +1,2 @@
+#include "aes.hpp"
+#include "test.c"
diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt
new file mode 100644
index 0000000..2e4b243
--- /dev/null
+++ b/test_package/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 2.8.12)
+project(TinyAesPackageTest C CXX)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+add_executable(example ../test.c)
+add_executable(example_cpp ../test.cpp)
+
+target_link_libraries(example ${CONAN_LIBS})
+target_link_libraries(example_cpp ${CONAN_LIBS}) \ No newline at end of file
diff --git a/test_package/conanfile.py b/test_package/conanfile.py
new file mode 100644
index 0000000..08f550f
--- /dev/null
+++ b/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class TinyAesCTestConan(ConanFile):
+ settings = "os", "compiler", "build_type", "arch"
+ generators = "cmake"
+
+ def build(self):
+ cmake = CMake(self)
+ cmake.configure()
+ cmake.build()
+
+ def test(self):
+ if not tools.cross_building(self.settings):
+ os.chdir("bin")
+ self.run(".%sexample" % os.sep)