@@ -170,7 +170,7 @@ LIBCOMPONENTS += $$(BUILD_OBJ)/$(1)/decaf.o $$(BUILD_OBJ)/$(1)/elligator.o $$(BU | |||
PER_OBJ_DIRS += $$(BUILD_OBJ)/$(1) | |||
GLOBAL_HEADERS_OF_$(1) = $(BUILD_INC)/decaf/decaf_$(3).h $(BUILD_INC)/decaf/decaf_$(3).hxx \ | |||
$(BUILD_INC)/decaf/crypto_$(3).h $(BUILD_INC)/decaf/crypto_$(3).hxx \ | |||
$(BUILD_INC)/decaf/eddsa_$(3).h $(BUILD_INC)/decaf/eddsa_$(3).hxx | |||
$(BUILD_INC)/decaf/ed$(3).h $(BUILD_INC)/decaf/ed$(3).hxx | |||
HEADERS_OF_$(1) = $$(HEADERS_OF_$(2)) $$(GLOBAL_HEADERS_OF_$(1)) | |||
HEADERS += $$(GLOBAL_HEADERS_OF_$(1)) | |||
@@ -183,7 +183,7 @@ $$(BUILD_H)/$(1)/%.h: src/per_curve/%.tmpl.h src/gen_headers/* $$(HEADERS_OF_$(2 | |||
$$(BUILD_INC)/decaf/decaf_$(3).%: src/per_curve/decaf.tmpl.% src/gen_headers/* $$(HEADERS_OF_$(2)) | |||
python -B src/gen_headers/template.py --per=curve --item=$(1) --guard=$$(@:$(BUILD_INC)/%=%) -o $$@ $$< | |||
$$(BUILD_INC)/decaf/eddsa_$(3).%: src/per_curve/eddsa.tmpl.% src/gen_headers/* $$(HEADERS_OF_$(2)) | |||
$$(BUILD_INC)/decaf/ed$(3).%: src/per_curve/eddsa.tmpl.% src/gen_headers/* $$(HEADERS_OF_$(2)) | |||
python -B src/gen_headers/template.py --per=curve --item=$(1) --guard=$$(@:$(BUILD_INC)/%=%) -o $$@ $$< | |||
$$(BUILD_INC)/decaf/elligator_$(3).%: src/per_curve/elligator.tmpl.% src/gen_headers/* $$(HEADERS_OF_$(2)) | |||
@@ -5,7 +5,7 @@ | |||
#include "field.h" | |||
#include <decaf.h> | |||
#include <decaf/eddsa_$(gf_bits).h> | |||
#include <decaf/ed$(gf_bits).h> | |||
/* Template stuff */ | |||
#define API_NS(_id) $(c_ns)_##_id | |||
@@ -1239,7 +1239,7 @@ decaf_error_t API_NS(point_decode_like_eddsa) ( | |||
return decaf_succeed_if(succ); | |||
} | |||
decaf_error_t decaf_x$(gf_shortname)_direct_scalarmul ( | |||
decaf_error_t decaf_x$(gf_shortname) ( | |||
uint8_t out[X_PUBLIC_BYTES], | |||
const uint8_t base[X_PUBLIC_BYTES], | |||
const uint8_t scalar[X_PRIVATE_BYTES] | |||
@@ -1310,7 +1310,7 @@ decaf_error_t decaf_x$(gf_shortname)_direct_scalarmul ( | |||
return decaf_succeed_if(mask_to_bool(nz)); | |||
} | |||
void decaf_x$(gf_shortname)_base_scalarmul ( | |||
void decaf_x$(gf_shortname)_generate_key ( | |||
uint8_t out[X_PUBLIC_BYTES], | |||
const uint8_t scalar[X_PRIVATE_BYTES] | |||
) { | |||
@@ -383,7 +383,7 @@ decaf_error_t $(c_ns)_direct_scalarmul ( | |||
* @retval DECAF_FAILURE The scalarmul didn't succeed, because the base | |||
* point is in a small subgroup. | |||
*/ | |||
decaf_error_t decaf_x$(gf_shortname)_direct_scalarmul ( | |||
decaf_error_t decaf_x$(gf_shortname) ( | |||
uint8_t out[DECAF_X$(gf_shortname)_PUBLIC_BYTES], | |||
const uint8_t base[DECAF_X$(gf_shortname)_PUBLIC_BYTES], | |||
const uint8_t scalar[DECAF_X$(gf_shortname)_PRIVATE_BYTES] | |||
@@ -399,7 +399,7 @@ extern const uint8_t decaf_x$(gf_shortname)_base_point[DECAF_X$(gf_shortname)_PU | |||
* @param [out] scaled The scaled point base*scalar | |||
* @param [in] scalar The scalar to multiply by. | |||
*/ | |||
void decaf_x$(gf_shortname)_base_scalarmul ( | |||
void decaf_x$(gf_shortname)_generate_key ( | |||
uint8_t out[DECAF_X$(gf_shortname)_PUBLIC_BYTES], | |||
const uint8_t scalar[DECAF_X$(gf_shortname)_PRIVATE_BYTES] | |||
) API_VIS NONNULL NOINLINE; | |||
@@ -21,7 +21,7 @@ | |||
#include <string.h> /* for memcpy */ | |||
#include <decaf/decaf_$(gf_bits).h> | |||
#include <decaf/eddsa_$(gf_bits).h> | |||
#include <decaf/ed$(gf_bits).h> | |||
#include <decaf/secure_buffer.hxx> | |||
#include <string> | |||
#include <sys/types.h> | |||
@@ -640,7 +640,7 @@ public: | |||
const FixedBlock<PRIVATE_BYTES> &scalar | |||
) throw(std::bad_alloc,CryptoException) { | |||
SecureBuffer out(PUBLIC_BYTES); | |||
if (DECAF_SUCCESS != decaf_x$(gf_shortname)_direct_scalarmul(out.data(), pk.data(), scalar.data())) { | |||
if (DECAF_SUCCESS != decaf_x$(gf_shortname)(out.data(), pk.data(), scalar.data())) { | |||
throw CryptoException(); | |||
} | |||
return out; | |||
@@ -653,7 +653,7 @@ public: | |||
const FixedBlock<PUBLIC_BYTES> &pk, | |||
const FixedBlock<PRIVATE_BYTES> &scalar | |||
) NOEXCEPT { | |||
return decaf_x$(gf_shortname)_direct_scalarmul(out.data(), pk.data(), scalar.data()); | |||
return decaf_x$(gf_shortname)(out.data(), pk.data(), scalar.data()); | |||
} | |||
/** Generate and return a public key; equivalent to shared_secret(base_point(),scalar) | |||
@@ -663,7 +663,7 @@ public: | |||
const FixedBlock<PRIVATE_BYTES> &scalar | |||
) throw(std::bad_alloc) { | |||
SecureBuffer out(PUBLIC_BYTES); | |||
decaf_x$(gf_shortname)_base_scalarmul(out.data(), scalar.data()); | |||
decaf_x$(gf_shortname)_generate_key(out.data(), scalar.data()); | |||
return out; | |||
} | |||
@@ -675,7 +675,7 @@ public: | |||
FixedBuffer<PUBLIC_BYTES> &out, | |||
const FixedBlock<PRIVATE_BYTES> &scalar | |||
) NOEXCEPT { | |||
decaf_x$(gf_shortname)_base_scalarmul(out.data(), scalar.data()); | |||
decaf_x$(gf_shortname)_generate_key(out.data(), scalar.data()); | |||
} | |||
}; | |||
@@ -4,7 +4,7 @@ | |||
*/ | |||
#include "word.h" | |||
#include <decaf/eddsa_$(gf_bits).h> | |||
#include <decaf/ed$(gf_bits).h> | |||
#include <decaf/shake.h> | |||
#include <decaf/sha512.h> | |||
#include <string.h> | |||
@@ -67,7 +67,7 @@ static void hash_init_with_dom( | |||
#endif | |||
} | |||
void decaf_eddsa_$(gf_shortname)_derive_public_key ( | |||
void decaf_ed$(gf_shortname)_derive_public_key ( | |||
uint8_t pubkey[DECAF_EDDSA_$(gf_shortname)_PUBLIC_BYTES], | |||
const uint8_t privkey[DECAF_EDDSA_$(gf_shortname)_PRIVATE_BYTES] | |||
) { | |||
@@ -101,7 +101,7 @@ void decaf_eddsa_$(gf_shortname)_derive_public_key ( | |||
decaf_bzero(secret_scalar_ser, sizeof(secret_scalar_ser)); | |||
} | |||
void decaf_eddsa_$(gf_shortname)_sign ( | |||
void decaf_ed$(gf_shortname)_sign ( | |||
uint8_t signature[DECAF_EDDSA_$(gf_shortname)_SIGNATURE_BYTES], | |||
const uint8_t privkey[DECAF_EDDSA_$(gf_shortname)_PRIVATE_BYTES], | |||
const uint8_t pubkey[DECAF_EDDSA_$(gf_shortname)_PUBLIC_BYTES], | |||
@@ -193,7 +193,7 @@ void decaf_eddsa_$(gf_shortname)_sign ( | |||
} | |||
decaf_error_t decaf_eddsa_$(gf_shortname)_verify ( | |||
decaf_error_t decaf_ed$(gf_shortname)_verify ( | |||
const uint8_t signature[DECAF_EDDSA_$(gf_shortname)_SIGNATURE_BYTES], | |||
const uint8_t pubkey[DECAF_EDDSA_$(gf_shortname)_PUBLIC_BYTES], | |||
const uint8_t *message, | |||
@@ -25,7 +25,7 @@ extern "C" { | |||
* @param [out] pubkey The public key. | |||
* @param [in] privkey The private key. | |||
*/ | |||
void decaf_eddsa_$(gf_shortname)_derive_public_key ( | |||
void decaf_ed$(gf_shortname)_derive_public_key ( | |||
uint8_t pubkey[DECAF_EDDSA_$(gf_shortname)_PUBLIC_BYTES], | |||
const uint8_t privkey[DECAF_EDDSA_$(gf_shortname)_PRIVATE_BYTES] | |||
) API_VIS NONNULL NOINLINE; | |||
@@ -42,7 +42,7 @@ void decaf_eddsa_$(gf_shortname)_derive_public_key ( | |||
* @param [in] message_len The length of the message. | |||
* @param [in] prehashed Nonzero if the message is actually the hash of something you want to sign. | |||
*/ | |||
void decaf_eddsa_$(gf_shortname)_sign ( | |||
void decaf_ed$(gf_shortname)_sign ( | |||
uint8_t signature[DECAF_EDDSA_$(gf_shortname)_SIGNATURE_BYTES], | |||
const uint8_t privkey[DECAF_EDDSA_$(gf_shortname)_PRIVATE_BYTES], | |||
const uint8_t pubkey[DECAF_EDDSA_$(gf_shortname)_PUBLIC_BYTES], | |||
@@ -68,7 +68,7 @@ void decaf_eddsa_$(gf_shortname)_sign ( | |||
* @param [in] message_len The length of the message. | |||
* @param [in] prehashed Nonzero if the message is actually the hash of something you want to verify. | |||
*/ | |||
decaf_error_t decaf_eddsa_$(gf_shortname)_verify ( | |||
decaf_error_t decaf_ed$(gf_shortname)_verify ( | |||
const uint8_t signature[DECAF_EDDSA_$(gf_shortname)_SIGNATURE_BYTES], | |||
const uint8_t pubkey[DECAF_EDDSA_$(gf_shortname)_PUBLIC_BYTES], | |||
const uint8_t *message, | |||
@@ -9,7 +9,7 @@ | |||
#include <decaf/eddsa.hxx> | |||
#include <decaf/decaf_$(gf_bits).hxx> | |||
#include <decaf/eddsa_$(gf_bits).h> | |||
#include <decaf/ed$(gf_bits).h> | |||
#include <decaf/shake.hxx> | |||
#include <decaf/sha512.hxx> | |||
@@ -113,7 +113,7 @@ public: | |||
SecureBuffer out(CRTP::SIG_BYTES); | |||
FixedArrayBuffer<Prehash::OUTPUT_BYTES> tmp; | |||
ph.final(tmp); | |||
decaf_eddsa_$(gf_shortname)_sign ( | |||
decaf_ed$(gf_shortname)_sign ( | |||
out.data(), | |||
((const CRTP*)this)->priv_.data(), | |||
((const CRTP*)this)->pub_.data(), | |||
@@ -162,7 +162,7 @@ public: | |||
} | |||
SecureBuffer out(CRTP::SIG_BYTES); | |||
decaf_eddsa_$(gf_shortname)_sign ( | |||
decaf_ed$(gf_shortname)_sign ( | |||
out.data(), | |||
((const CRTP*)this)->priv_.data(), | |||
((const CRTP*)this)->pub_.data(), | |||
@@ -235,13 +235,13 @@ public: | |||
/** Create at random */ | |||
inline explicit PrivateKeyBase(Rng &r) NOEXCEPT : priv_(r) { | |||
decaf_eddsa_$(gf_shortname)_derive_public_key(pub_.data(), priv_.data()); | |||
decaf_ed$(gf_shortname)_derive_public_key(pub_.data(), priv_.data()); | |||
} | |||
/** Assignment from string */ | |||
inline PrivateKeyBase &operator=(const FixedBlock<SER_BYTES> &b) NOEXCEPT { | |||
memcpy(priv_.data(),b.data(),b.size()); | |||
decaf_eddsa_$(gf_shortname)_derive_public_key(pub_.data(), priv_.data()); | |||
decaf_ed$(gf_shortname)_derive_public_key(pub_.data(), priv_.data()); | |||
return *this; | |||
} | |||
@@ -283,7 +283,7 @@ public: | |||
return DECAF_FAILURE; | |||
} | |||
return decaf_eddsa_$(gf_shortname)_verify ( | |||
return decaf_ed$(gf_shortname)_verify ( | |||
sig.data(), | |||
((const CRTP*)this)->pub_.data(), | |||
message.data(), | |||
@@ -331,7 +331,7 @@ public: | |||
) const /*NOEXCEPT*/ { | |||
FixedArrayBuffer<Prehash::OUTPUT_BYTES> m; | |||
ph.final(m); | |||
return decaf_eddsa_$(gf_shortname)_verify ( | |||
return decaf_ed$(gf_shortname)_verify ( | |||
sig.data(), | |||
((const CRTP*)this)->pub_.data(), | |||
m.data(), | |||
@@ -351,7 +351,7 @@ public: | |||
) const /*throw(CryptoException)*/ { | |||
FixedArrayBuffer<Prehash::OUTPUT_BYTES> m; | |||
ph.final(m); | |||
if (DECAF_SUCCESS != decaf_eddsa_$(gf_shortname)_verify ( | |||
if (DECAF_SUCCESS != decaf_ed$(gf_shortname)_verify ( | |||
sig.data(), | |||
((const CRTP*)this)->pub_.data(), | |||
m.data(), | |||
@@ -4,5 +4,5 @@ | |||
namespace decaf { enum Prehashed { PURE, PREHASHED }; } | |||
$("\n".join([ | |||
"#include <decaf/eddsa_%s.hxx>" % g for g in sorted([c["bits"] for _,c in curve.iteritems()]) | |||
"#include <decaf/ed%s.hxx>" % g for g in sorted([c["bits"] for _,c in curve.iteritems()]) | |||
])) |