@@ -169,7 +169,7 @@ define define_curve | |||||
LIBCOMPONENTS += $$(BUILD_OBJ)/$(1)/decaf.o $$(BUILD_OBJ)/$(1)/crypto.o $$(BUILD_OBJ)/$(1)/decaf_tables.o | LIBCOMPONENTS += $$(BUILD_OBJ)/$(1)/decaf.o $$(BUILD_OBJ)/$(1)/crypto.o $$(BUILD_OBJ)/$(1)/decaf_tables.o | ||||
PER_OBJ_DIRS += $$(BUILD_OBJ)/$(1) | PER_OBJ_DIRS += $$(BUILD_OBJ)/$(1) | ||||
HEADERS_OF_$(1) = $$(HEADERS_OF_$(2)) $$(BUILD_H)/$(1)/curve_data.h | |||||
HEADERS_OF_$(1) = $$(HEADERS_OF_$(2)) | |||||
$$(BUILD_C)/$(1)/%.c: src/per_curve/%.tmpl.c src/gen_headers/* $$(HEADERS_OF_$(2)) | $$(BUILD_C)/$(1)/%.c: src/per_curve/%.tmpl.c src/gen_headers/* $$(HEADERS_OF_$(2)) | ||||
python -B src/gen_headers/template.py --per=curve --item=$(1) --guard=$(1)/`basename $$@` -o $$@ $$< | python -B src/gen_headers/template.py --per=curve --item=$(1) --guard=$(1)/`basename $$@` -o $$@ $$< | ||||
@@ -7,8 +7,9 @@ | |||||
#include <decaf/crypto.h> | #include <decaf/crypto.h> | ||||
#include <string.h> | #include <string.h> | ||||
#define DECAF_JUST_API | |||||
#include "curve_data.h" | |||||
#define API_NAME "$(c_ns)" | |||||
#define API_NS(_id) $(c_ns)_##_id | |||||
#define SCALAR_BITS $(C_NS)_SCALAR_BITS | |||||
#define SCALAR_BYTES ((SCALAR_BITS + 7)/8) | #define SCALAR_BYTES ((SCALAR_BITS + 7)/8) | ||||
/* TODO: canonicalize and freeze the STROBE constants in this file | /* TODO: canonicalize and freeze the STROBE constants in this file | ||||
@@ -1,34 +0,0 @@ | |||||
#define API_NAME "$(c_ns)" | |||||
#define API_NS(_id) $(c_ns)_##_id | |||||
#define SCALAR_BITS $(C_NS)_SCALAR_BITS | |||||
#ifndef DECAF_JUST_API | |||||
#define SCALAR_LIMBS $(C_NS)_SCALAR_LIMBS | |||||
#define scalar_t API_NS(scalar_t) | |||||
#define point_t API_NS(point_t) | |||||
#define precomputed_s API_NS(precomputed_s) | |||||
#define IMAGINE_TWIST $(imagine_twist) | |||||
#define COFACTOR $(cofactor) | |||||
static const int EDWARDS_D = $(d); | |||||
static const scalar_t sc_p = {{{ | |||||
$(scalar_p) | |||||
}}}; | |||||
#ifdef GEN_TABLES | |||||
/* Not exported, but used by pregen tool. */ | |||||
static const unsigned char base_point_ser_for_pregen[SER_BYTES] = { | |||||
$(decaf_base) | |||||
}; | |||||
#endif | |||||
#if COFACTOR==8 | |||||
static const gf SQRT_ONE_MINUS_D = {FIELD_LITERAL( | |||||
$(sqrt_one_minus_d) | |||||
)}; | |||||
#endif | |||||
#endif /* DECAF_JUST_API */ |
@@ -10,8 +10,24 @@ | |||||
#include <decaf.h> | #include <decaf.h> | ||||
/* Include the curve data here */ | |||||
#include "curve_data.h" | |||||
#define API_NS(_id) $(c_ns)_##_id | |||||
#define SCALAR_BITS $(C_NS)_SCALAR_BITS | |||||
#define SCALAR_LIMBS $(C_NS)_SCALAR_LIMBS | |||||
#define scalar_t API_NS(scalar_t) | |||||
#define point_t API_NS(point_t) | |||||
#define precomputed_s API_NS(precomputed_s) | |||||
#define IMAGINE_TWIST $(imagine_twist) | |||||
#define COFACTOR $(cofactor) | |||||
static const int EDWARDS_D = $(d); | |||||
static const scalar_t sc_p = {{{ $(scalar_p) }}}; | |||||
#if COFACTOR==8 | |||||
static const gf SQRT_ONE_MINUS_D = {FIELD_LITERAL( | |||||
$(sqrt_one_minus_d) | |||||
)}; | |||||
#endif | |||||
#if (COFACTOR == 8) && !IMAGINE_TWIST | #if (COFACTOR == 8) && !IMAGINE_TWIST | ||||
/* FUTURE: Curve41417 doesn't have these properties. */ | /* FUTURE: Curve41417 doesn't have these properties. */ | ||||