Commit 26a7b2a9 authored by Johan Pascal's avatar Johan Pascal

include python code generation in cmake scripts

parent fd45d884
......@@ -10,10 +10,20 @@ project(DECAF VERSION 0.9.4 LANGUAGES C CXX)
set(DECAF_SO_VERSION "0")
find_package( PythonInterp 2.7 REQUIRED )
option(ENABLE_SHARED "Build shared library." ON)
option(ENABLE_STATIC "Build static library." ON)
option(ENABLE_STRICT "Build with strict compile options." YES)
option(ENABLE_TESTS "Enable compilation of tests." YES)
option(GENERATED_SOURCE_PATH "Where the generated source code is stored, default in the building tree" OFF)
if (GENERATED_SOURCE_PATH)
set(GSOURCE_PATH ${GENERATED_SOURCE_PATH})
else()
set(GSOURCE_PATH ${PROJECT_BINARY_DIR}/src/GENERATED)
endif()
message("Generated source code in ${GSOURCE_PATH}")
if(NOT CPACK_GENERATOR AND NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
......@@ -25,7 +35,7 @@ include(CheckSymbolExists)
include(CMakePushCheckState)
include_directories(
src/GENERATED/include/
${GSOURCE_PATH}/include/
src/include/
src/
${CMAKE_CURRENT_BINARY_DIR}
......
......@@ -58,20 +58,23 @@ include_directories(
set(DECAF_SOURCE_FILES_CXX
)
add_subdirectory(GENERATED/c/p25519)
add_subdirectory(GENERATED/c/p448)
add_subdirectory(GENERATED/c/curve25519)
add_subdirectory(GENERATED/c/ed448goldilocks)
add_subdirectory(curve25519)
add_subdirectory(ed448goldilocks)
add_subdirectory(p25519)
add_subdirectory(p448)
add_subdirectory(generator)
if(ENABLE_STATIC)
add_library(decaf-static STATIC ${DECAF_HEADER_FILES} ${DECAF_SOURCE_FILES_C} ${DECAF_SOURCE_FILES_CXX} $<TARGET_OBJECTS:p25519> $<TARGET_OBJECTS:p448> $<TARGET_OBJECTS:CURVE25519> $<TARGET_OBJECTS:CURVE448>)
add_dependencies(decaf-static generatedCode)
set_target_properties(decaf-static PROPERTIES OUTPUT_NAME decaf)
target_include_directories(decaf-static PUBLIC)
target_link_libraries(decaf-static INTERFACE)
endif()
if(ENABLE_SHARED)
add_library(decaf SHARED ${DECAF_HEADER_FILES} ${DECAF_SOURCE_FILES_C} ${DECAF_SOURCE_FILES_CXX} $<TARGET_OBJECTS:p25519> $<TARGET_OBJECTS:p448> $<TARGET_OBJECTS:CURVE25519> $<TARGET_OBJECTS:CURVE448>)
add_dependencies(decaf generatedCode)
if(APPLE)
set_target_properties(decaf PROPERTIES LINK_FLAGS "-stdlib=libc++")
endif()
......@@ -105,7 +108,7 @@ if(ENABLE_SHARED)
)
endif()
install(DIRECTORY GENERATED/include/
install(DIRECTORY ${GSOURCE_PATH}/include/
DESTINATION include/decaf
FILES_MATCHING PATTERN "*.h*"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
......
......@@ -7,20 +7,24 @@
include_directories(
${PROJECT_SOURCE_DIR}/src/p25519
${PROJECT_SOURCE_DIR}/src/GENERATED/c/p25519
)
include_directories(
${GSOURCE_PATH}/c/p25519
${PROJECT_SOURCE_DIR}/src/p25519/${TARGET_ARCH_DIR_P25519}
)
set(CURVE25519_SOURCE_FILES_C
decaf.c
elligator.c
scalar.c
eddsa.c
decaf_tables.c
${GSOURCE_PATH}/c/curve25519/decaf.c
${GSOURCE_PATH}/c/curve25519/elligator.c
${GSOURCE_PATH}/c/curve25519/scalar.c
${GSOURCE_PATH}/c/curve25519/eddsa.c
${GSOURCE_PATH}/c/curve25519/decaf_tables.c
)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/curve25519/decaf.c PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/curve25519/elligator.c PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/curve25519/scalar.c PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/curve25519/eddsa.c PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/curve25519/decaf_tables.c PROPERTIES GENERATED 1)
add_library(CURVE25519 OBJECT ${CURVE25519_SOURCE_FILES_C})
add_dependencies(CURVE25519 generatedCode)
set_target_properties(CURVE25519 PROPERTIES POSITION_INDEPENDENT_CODE True)
......@@ -7,20 +7,24 @@
include_directories(
${PROJECT_SOURCE_DIR}/src/p448
${PROJECT_SOURCE_DIR}/src/GENERATED/c/p448
)
include_directories(
${GSOURCE_PATH}/c/p448
${PROJECT_SOURCE_DIR}/src/p448/${TARGET_ARCH_DIR_P448}
)
set(CURVE448_SOURCE_FILES_C
decaf.c
elligator.c
scalar.c
eddsa.c
decaf_tables.c
${GSOURCE_PATH}/c/ed448goldilocks/decaf.c
${GSOURCE_PATH}/c/ed448goldilocks/elligator.c
${GSOURCE_PATH}/c/ed448goldilocks/scalar.c
${GSOURCE_PATH}/c/ed448goldilocks/eddsa.c
${GSOURCE_PATH}/c/ed448goldilocks/decaf_tables.c
)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/ed448goldilocks/decaf.c PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/ed448goldilocks/elligator.c PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/ed448goldilocks/scalar.c PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/ed448goldilocks/eddsa.c PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/ed448goldilocks/decaf_tables.c PROPERTIES GENERATED 1)
add_library(CURVE448 OBJECT ${CURVE448_SOURCE_FILES_C})
add_dependencies(CURVE448 generatedCode)
set_target_properties(CURVE448 PROPERTIES POSITION_INDEPENDENT_CODE True)
############################################################################
# CMakeLists.txt
#
# Released under the MIT License. See LICENSE.txt for license information.
#
############################################################################
# global include files
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=global --guard=decaf.h -o ${GSOURCE_PATH}/include/decaf.h ${PROJECT_SOURCE_DIR}/src/public_include/decaf.tmpl.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/public_include/decaf.tmpl.h
OUTPUT ${GSOURCE_PATH}/include/decaf.h
COMMENT "Generating code for include/decaf.h"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=global --guard=decaf/eddsa.hxx -o ${GSOURCE_PATH}/include/decaf/eddsa.hxx ${PROJECT_SOURCE_DIR}/src/public_include/decaf/eddsa.tmpl.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/public_include/decaf/eddsa.tmpl.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf/eddsa.hxx
COMMENT "Generating code for include/decaf/eddsa.hxx"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=global --guard=decaf.hxx -o ${GSOURCE_PATH}/include/decaf.hxx ${PROJECT_SOURCE_DIR}/src/public_include/decaf.tmpl.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/public_include/decaf.tmpl.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf.hxx
COMMENT "Generating code for include/decaf.hxx"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=global --guard=decaf/crypto.hxx -o ${GSOURCE_PATH}/c/decaf/crypto.hxx ${PROJECT_SOURCE_DIR}/src/include/decaf/crypto.tmpl.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/include/decaf/crypto.tmpl.hxx
OUTPUT ${GSOURCE_PATH}/c/decaf/crypto.hxx
COMMENT "Generating code for decaf/crypto.hxx"
)
# copying
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/public_include/decaf/common.h
${GSOURCE_PATH}/include/decaf/common.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/public_include/decaf/common.h
OUTPUT ${GSOURCE_PATH}/include/decaf/common.h
)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/public_include/decaf/sha512.hxx
${GSOURCE_PATH}/include/decaf/sha512.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/public_include/decaf/sha512.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf/sha512.hxx
)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/public_include/decaf/spongerng.h
${GSOURCE_PATH}/include/decaf/spongerng.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/public_include/decaf/spongerng.h
OUTPUT ${GSOURCE_PATH}/include/decaf/spongerng.h
)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/public_include/decaf/shake.hxx
${GSOURCE_PATH}/include/decaf/shake.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/public_include/decaf/shake.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf/shake.hxx
)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/public_include/decaf/shake.h
${GSOURCE_PATH}/include/decaf/shake.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/public_include/decaf/shake.h
OUTPUT ${GSOURCE_PATH}/include/decaf/shake.h
)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/public_include/decaf/spongerng.hxx
${GSOURCE_PATH}/include/decaf/spongerng.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/public_include/decaf/spongerng.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf/spongerng.hxx
)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/public_include/decaf/secure_buffer.hxx
${GSOURCE_PATH}/include/decaf/secure_buffer.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/public_include/decaf/secure_buffer.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf/secure_buffer.hxx
)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/public_include/decaf/sha512.h
${GSOURCE_PATH}/include/decaf/sha512.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/public_include/decaf/sha512.h
OUTPUT ${GSOURCE_PATH}/include/decaf/sha512.h
)
#these files shall be part of generatorCurve25519 and generatorEd448goldilocks targets but they are both included through decaf.h in a source file
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=curve25519 --guard=decaf/point_255.h -o ${GSOURCE_PATH}/include/decaf/point_255.h ${PROJECT_SOURCE_DIR}/src/per_curve/point.tmpl.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/point.tmpl.h
OUTPUT ${GSOURCE_PATH}/include/decaf/point_255.h
COMMENT "Generating code for decaf/point_255.h"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=curve25519 --guard=decaf/ed255.h -o ${GSOURCE_PATH}/include/decaf/ed255.h ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.h
OUTPUT ${GSOURCE_PATH}/include/decaf/ed255.h
COMMENT "Generating code for decaf/ed255.h"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=ed448goldilocks --guard=decaf/point_448.h -o ${GSOURCE_PATH}/include/decaf/point_448.h ${PROJECT_SOURCE_DIR}/src/per_curve/point.tmpl.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/point.tmpl.h
OUTPUT ${GSOURCE_PATH}/include/decaf/point_448.h
COMMENT "Generating code for decaf/point_448.h"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=ed448goldilocks --guard=decaf/ed448.h -o ${GSOURCE_PATH}/include/decaf/ed448.h ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.h
OUTPUT ${GSOURCE_PATH}/include/decaf/ed448.h
COMMENT "Generating code for decaf/ed448.h"
)
add_custom_target(generatorCommonCode DEPENDS
${GSOURCE_PATH}/include/decaf.h
${GSOURCE_PATH}/include/decaf/eddsa.hxx
${GSOURCE_PATH}/include/decaf.hxx
${GSOURCE_PATH}/c/decaf/crypto.hxx
${GSOURCE_PATH}/include/decaf/common.h
${GSOURCE_PATH}/include/decaf/sha512.hxx
${GSOURCE_PATH}/include/decaf/sha512.h
${GSOURCE_PATH}/include/decaf/shake.hxx
${GSOURCE_PATH}/include/decaf/shake.h
${GSOURCE_PATH}/include/decaf/spongerng.hxx
${GSOURCE_PATH}/include/decaf/spongerng.h
${GSOURCE_PATH}/include/decaf/secure_buffer.hxx
#these files shall be part of curve25519 and ed448goldilocks targets but they are included through decaf.h in common *.c
${GSOURCE_PATH}/include/decaf/point_255.h
${GSOURCE_PATH}/include/decaf/point_448.h
${GSOURCE_PATH}/include/decaf/ed255.h
${GSOURCE_PATH}/include/decaf/ed448.h
)
add_subdirectory(curve25519)
add_subdirectory(ed448goldilocks)
add_custom_target(generatedCode DEPENDS
generatorCommonCode
generatorEd448goldilocks
generatorCurve25519
)
############################################################################
# CMakeLists.txt
#
# Released under the MIT License. See LICENSE.txt for license information.
#
############################################################################
# p25519 field
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=field --guard=p25519/`basename ${GSOURCE_PATH}/c/p25519/f_field.h` --item=p25519 -o ${GSOURCE_PATH}/c/p25519/f_field.h ${PROJECT_SOURCE_DIR}/src/per_field/f_field.tmpl.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_field/f_field.tmpl.h
OUTPUT ${GSOURCE_PATH}/c/p25519/f_field.h
COMMENT "Generating code for p25519/f_field.h"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=field --guard=p25519/`basename ${GSOURCE_PATH}/c/p25519/f_generic.c` --item=p25519 -o ${GSOURCE_PATH}/c/p25519/f_generic.c ${PROJECT_SOURCE_DIR}/src/per_field/f_generic.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_field/f_generic.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/p25519/f_generic.c
COMMENT "Generating code for p25519/f_generic.c"
)
add_custom_target(generatorP25519 DEPENDS
generatorCommonCode
${GSOURCE_PATH}/c/p25519/f_field.h
${GSOURCE_PATH}/c/p25519/f_generic.c
)
# curve25519
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=curve25519 --guard=curve25519/`basename src/GENERATED/c/curve25519/scalar.c` -o ${GSOURCE_PATH}/c/curve25519/scalar.c ${PROJECT_SOURCE_DIR}/src/per_curve/scalar.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/scalar.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/curve25519/scalar.c
COMMENT "Generating code for curve25519/scalar.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=curve25519 --guard=curve25519/`basename src/GENERATED/c/curve25519/decaf.c` -o ${GSOURCE_PATH}/c/curve25519/decaf.c ${PROJECT_SOURCE_DIR}/src/per_curve/decaf.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/decaf.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/curve25519/decaf.c
COMMENT "Generating code for curve25519/decaf.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=curve25519 --guard=curve25519/`basename src/GENERATED/c/curve25519/elligator.c` -o ${GSOURCE_PATH}/c/curve25519/elligator.c ${PROJECT_SOURCE_DIR}/src/per_curve/elligator.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/elligator.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/curve25519/elligator.c
COMMENT "Generating code for curve25519/elligator.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=curve25519 --guard=curve25519/`basename src/GENERATED/c/curve25519/eddsa.c` -o ${GSOURCE_PATH}/c/curve25519/eddsa.c ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/curve25519/eddsa.c
COMMENT "Generating code for curve25519/eddsa.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=curve25519 --guard=curve25519/`basename src/GENERATED/c/curve25519/decaf_gen_tables.c` -o ${GSOURCE_PATH}/c/curve25519/decaf_gen_tables.c ${PROJECT_SOURCE_DIR}/src/per_curve/decaf_gen_tables.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/decaf_gen_tables.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/curve25519/decaf_gen_tables.c
COMMENT "Generating code for curve25519/decaf_gen_tables.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=curve25519 --guard=decaf/point_255.hxx -o ${GSOURCE_PATH}/include/decaf/point_255.hxx ${PROJECT_SOURCE_DIR}/src/per_curve/point.tmpl.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/point.tmpl.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf/point_255.hxx
COMMENT "Generating code for include/decaf/point_255.hxx"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=curve25519 --guard=decaf/ed255.hxx -o ${GSOURCE_PATH}/include/decaf/ed255.hxx ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf/ed255.hxx
COMMENT "Generating code for include/decaf/ed255.hxx"
)
#python -B src/generator/template.py --per=curve --item=curve25519 --guard=decaf/point_255.hxx -o src/GENERATED/include/decaf/point_255.hxx src/per_curve/point.tmpl.hxx
#python -B src/generator/template.py --per=curve --item=curve25519 --guard=decaf/ed255.hxx -o src/GENERATED/include/decaf/ed255.hxx src/per_curve/eddsa.tmpl.hxx
add_custom_target(generatorCurve25519 DEPENDS
${GSOURCE_PATH}/c/curve25519/scalar.c
${GSOURCE_PATH}/c/curve25519/decaf.c
${GSOURCE_PATH}/c/curve25519/elligator.c
${GSOURCE_PATH}/c/curve25519/eddsa.c
${GSOURCE_PATH}/c/curve25519/decaf_tables.c
${GSOURCE_PATH}/include/decaf/point_255.hxx
${GSOURCE_PATH}/include/decaf/ed255.hxx
)
include_directories(
${PROJECT_SOURCE_DIR}/src/p25519
${GSOURCE_PATH}/c/p25519
${PROJECT_SOURCE_DIR}/src/p25519/${TARGET_ARCH_DIR_P25519}
)
add_executable(decaf_gen_tables_curve25519 ${GSOURCE_PATH}/c/curve25519/decaf_gen_tables.c
${GSOURCE_PATH}/c/curve25519/decaf.c
${GSOURCE_PATH}/c/curve25519/scalar.c
${PROJECT_SOURCE_DIR}/src/utils.c
$<TARGET_OBJECTS:p25519>)
add_custom_command(
COMMAND decaf_gen_tables_curve25519 > ${GSOURCE_PATH}/c/curve25519/decaf_tables.c
DEPENDS decaf_gen_tables_curve25519
OUTPUT ${GSOURCE_PATH}/c/curve25519/decaf_tables.c
COMMENT "Generating code for curve25519/decaf_tables.c"
)
############################################################################
# CMakeLists.txt
#
# Released under the MIT License. See LICENSE.txt for license information.
#
############################################################################
# p448 field
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=field --guard=p448/`basename ${GSOURCE_PATH}/c/p448/f_field.h` --item=p448 -o ${GSOURCE_PATH}/c/p448/f_field.h ${PROJECT_SOURCE_DIR}/src/per_field/f_field.tmpl.h
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_field/f_field.tmpl.h
OUTPUT ${GSOURCE_PATH}/c/p448/f_field.h
COMMENT "Generating code for p448/f_field.h"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=field --guard=p448/`basename ${GSOURCE_PATH}/c/p448/f_generic.c` --item=p448 -o ${GSOURCE_PATH}/c/p448/f_generic.c ${PROJECT_SOURCE_DIR}/src/per_field/f_generic.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_field/f_generic.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/p448/f_generic.c
COMMENT "Generating code for p448/f_generic.c"
)
add_custom_target(generatorP448 DEPENDS
generatorCommonCode
${GSOURCE_PATH}/c/p448/f_field.h
${GSOURCE_PATH}/c/p448/f_generic.c
)
# ed448goldilocks
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=ed448goldilocks --guard=ed448goldilocks/`basename src/GENERATED/c/ed448goldilocks/scalar.c` -o ${GSOURCE_PATH}/c/ed448goldilocks/scalar.c ${PROJECT_SOURCE_DIR}/src/per_curve/scalar.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/scalar.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/ed448goldilocks/scalar.c
COMMENT "Generating code for ed448goldilocks/scalar.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=ed448goldilocks --guard=ed448goldilocks/`basename src/GENERATED/c/ed448goldilocks/decaf.c` -o ${GSOURCE_PATH}/c/ed448goldilocks/decaf.c ${PROJECT_SOURCE_DIR}/src/per_curve/decaf.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/decaf.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/ed448goldilocks/decaf.c
COMMENT "Generating code for ed448goldilocks/decaf.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=ed448goldilocks --guard=ed448goldilocks/`basename src/GENERATED/c/ed448goldilocks/elligator.c` -o ${GSOURCE_PATH}/c/ed448goldilocks/elligator.c ${PROJECT_SOURCE_DIR}/src/per_curve/elligator.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/elligator.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/ed448goldilocks/elligator.c
COMMENT "Generating code for ed448goldilocks/elligator.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=ed448goldilocks --guard=ed448goldilocks/`basename src/GENERATED/c/ed448goldilocks/eddsa.c` -o ${GSOURCE_PATH}/c/ed448goldilocks/eddsa.c ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/ed448goldilocks/eddsa.c
COMMENT "Generating code for ed448goldilocks/eddsa.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=ed448goldilocks --guard=ed448goldilocks/`basename src/GENERATED/c/ed448goldilocks/decaf_gen_tables.c` -o ${GSOURCE_PATH}/c/ed448goldilocks/decaf_gen_tables.c ${PROJECT_SOURCE_DIR}/src/per_curve/decaf_gen_tables.tmpl.c
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/decaf_gen_tables.tmpl.c
OUTPUT ${GSOURCE_PATH}/c/ed448goldilocks/decaf_gen_tables.c
COMMENT "Generating code for ed448goldilocks/decaf_gen_tables.c"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=ed448goldilocks --guard=decaf/point_448.hxx -o ${GSOURCE_PATH}/include/decaf/point_448.hxx ${PROJECT_SOURCE_DIR}/src/per_curve/point.tmpl.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/point.tmpl.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf/point_448.hxx
COMMENT "Generating code for include/decaf/point_448.hxx"
)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/src/generator/template.py --per=curve --item=ed448goldilocks --guard=decaf/ed448.hxx -o ${GSOURCE_PATH}/include/decaf/ed448.hxx ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.hxx
DEPENDS ${PROJECT_SOURCE_DIR}/src/generator/template.py ${PROJECT_SOURCE_DIR}/src/per_curve/eddsa.tmpl.hxx
OUTPUT ${GSOURCE_PATH}/include/decaf/ed448.hxx
COMMENT "Generating code for include/decaf/ed448.hxx"
)
add_custom_target(generatorEd448goldilocks DEPENDS
${GSOURCE_PATH}/c/ed448goldilocks/scalar.c
${GSOURCE_PATH}/c/ed448goldilocks/decaf.c
${GSOURCE_PATH}/c/ed448goldilocks/elligator.c
${GSOURCE_PATH}/c/ed448goldilocks/eddsa.c
${GSOURCE_PATH}/c/ed448goldilocks/decaf_tables.c
${GSOURCE_PATH}/include/decaf/point_448.hxx
${GSOURCE_PATH}/include/decaf/ed448.hxx
)
include_directories(
${PROJECT_SOURCE_DIR}/src/p448
${GSOURCE_PATH}/c/p448
${PROJECT_SOURCE_DIR}/src/p448/${TARGET_ARCH_DIR_P448}
)
add_executable(decaf_gen_tables_ed448goldilocks ${GSOURCE_PATH}/c/ed448goldilocks/decaf_gen_tables.c
${GSOURCE_PATH}/c/ed448goldilocks/decaf.c
${GSOURCE_PATH}/c/ed448goldilocks/scalar.c
${PROJECT_SOURCE_DIR}/src/utils.c
$<TARGET_OBJECTS:p448>)
add_custom_command(
COMMAND decaf_gen_tables_ed448goldilocks > ${GSOURCE_PATH}/c/ed448goldilocks/decaf_tables.c
DEPENDS decaf_gen_tables_ed448goldilocks
OUTPUT ${GSOURCE_PATH}/c/ed448goldilocks/decaf_tables.c
COMMENT "Generating code for ed448goldilocks/decaf_tables.c"
)
......@@ -4,25 +4,26 @@
# Released under the MIT License. See LICENSE.txt for license information.
#
############################################################################
include_directories(
${PROJECT_SOURCE_DIR}/src/p25519
${PROJECT_SOURCE_DIR}/src/GENERATED/c/p25519
)
include_directories(
${GSOURCE_PATH}/c/p25519
${PROJECT_SOURCE_DIR}/src/p25519/${TARGET_ARCH_DIR_P25519}
)
set(P25519_HEADER_FILES
f_field.h
${PROJECT_SOURCE_DIR}/src/p25519/${TARGET_ARCH_DIR_P25519}/f_impl.h
${GSOURCE_PATH}/c/p25519/f_field.h
${TARGET_ARCH_DIR_P25519}/f_impl.h
)
set(P25519_SOURCE_FILES_C
${PROJECT_SOURCE_DIR}/src/p25519/${TARGET_ARCH_DIR_P25519}/f_impl.c
${PROJECT_SOURCE_DIR}/src/p25519/f_arithmetic.c
f_generic.c
${TARGET_ARCH_DIR_P25519}/f_impl.c
f_arithmetic.c
${GSOURCE_PATH}/c/p25519/f_generic.c
)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/p25519/f_field.h PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/p25519/f_generic.c PROPERTIES GENERATED 1)
add_library(p25519 OBJECT ${P25519_HEADER_FILES} ${P25519_SOURCE_FILES_C})
add_dependencies(p25519 generatorP25519)
set_target_properties(p25519 PROPERTIES POSITION_INDEPENDENT_CODE True)
......@@ -4,26 +4,26 @@
# Released under the MIT License. See LICENSE.txt for license information.
#
############################################################################
include_directories(
${PROJECT_SOURCE_DIR}/src/p448
${PROJECT_SOURCE_DIR}/src/GENERATED/c/p448
)
include_directories(
${GSOURCE_PATH}/c/p448
${PROJECT_SOURCE_DIR}/src/p448/${TARGET_ARCH_DIR_P448}
)
set(P448_HEADER_FILES
f_field.h
${PROJECT_SOURCE_DIR}/src/p448/${TARGET_ARCH_DIR_P448}/f_impl.h
${GSOURCE_PATH}/c/p448/f_field.h
${TARGET_ARCH_DIR_P448}/f_impl.h
)
set(P448_SOURCE_FILES_C
${PROJECT_SOURCE_DIR}/src/p448/${TARGET_ARCH_DIR_P448}/f_impl.c
${PROJECT_SOURCE_DIR}/src/p448/f_arithmetic.c
f_generic.c
${TARGET_ARCH_DIR_P448}/f_impl.c
f_arithmetic.c
${GSOURCE_PATH}/c/p448/f_generic.c
)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/p448/f_field.h PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/p448/f_generic.c PROPERTIES GENERATED 1)
add_library(p448 OBJECT ${P448_HEADER_FILES} ${P448_SOURCE_FILES_C})
add_dependencies(p448 generatorP448)
set_target_properties(p448 PROPERTIES POSITION_INDEPENDENT_CODE True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment