From 83cfd6cae1a3e85c2060bcced5a40b8a7f058720 Mon Sep 17 00:00:00 2001 From: Michael Hamburg Date: Wed, 2 Mar 2016 11:38:11 -0800 Subject: [PATCH] change x### function names again, this time to decaf_x###, decaf_x###_generate_key --- Makefile | 4 ++-- src/per_curve/decaf.tmpl.c | 6 +++--- src/per_curve/decaf.tmpl.h | 4 ++-- src/per_curve/decaf.tmpl.hxx | 10 +++++----- src/per_curve/eddsa.tmpl.c | 8 ++++---- src/per_curve/eddsa.tmpl.h | 6 +++--- src/per_curve/eddsa.tmpl.hxx | 16 ++++++++-------- src/public_include/decaf/eddsa.tmpl.hxx | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 092d340..894274e 100644 --- a/Makefile +++ b/Makefile @@ -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)) diff --git a/src/per_curve/decaf.tmpl.c b/src/per_curve/decaf.tmpl.c index 9920122..955b339 100644 --- a/src/per_curve/decaf.tmpl.c +++ b/src/per_curve/decaf.tmpl.c @@ -5,7 +5,7 @@ #include "field.h" #include -#include +#include /* 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] ) { diff --git a/src/per_curve/decaf.tmpl.h b/src/per_curve/decaf.tmpl.h index 619baa7..cf2d5b4 100644 --- a/src/per_curve/decaf.tmpl.h +++ b/src/per_curve/decaf.tmpl.h @@ -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; diff --git a/src/per_curve/decaf.tmpl.hxx b/src/per_curve/decaf.tmpl.hxx index 87a4acf..bf929c6 100644 --- a/src/per_curve/decaf.tmpl.hxx +++ b/src/per_curve/decaf.tmpl.hxx @@ -21,7 +21,7 @@ #include /* for memcpy */ #include -#include +#include #include #include #include @@ -640,7 +640,7 @@ public: const FixedBlock &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 &pk, const FixedBlock &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 &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 &out, const FixedBlock &scalar ) NOEXCEPT { - decaf_x$(gf_shortname)_base_scalarmul(out.data(), scalar.data()); + decaf_x$(gf_shortname)_generate_key(out.data(), scalar.data()); } }; diff --git a/src/per_curve/eddsa.tmpl.c b/src/per_curve/eddsa.tmpl.c index 11cf52f..76240e7 100644 --- a/src/per_curve/eddsa.tmpl.c +++ b/src/per_curve/eddsa.tmpl.c @@ -4,7 +4,7 @@ */ #include "word.h" -#include +#include #include #include #include @@ -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, diff --git a/src/per_curve/eddsa.tmpl.h b/src/per_curve/eddsa.tmpl.h index 2d15182..7bc894f 100644 --- a/src/per_curve/eddsa.tmpl.h +++ b/src/per_curve/eddsa.tmpl.h @@ -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, diff --git a/src/per_curve/eddsa.tmpl.hxx b/src/per_curve/eddsa.tmpl.hxx index 4180e91..8e03d24 100644 --- a/src/per_curve/eddsa.tmpl.hxx +++ b/src/per_curve/eddsa.tmpl.hxx @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -113,7 +113,7 @@ public: SecureBuffer out(CRTP::SIG_BYTES); FixedArrayBuffer 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 &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 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 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(), diff --git a/src/public_include/decaf/eddsa.tmpl.hxx b/src/public_include/decaf/eddsa.tmpl.hxx index 8325f24..0566d98 100644 --- a/src/public_include/decaf/eddsa.tmpl.hxx +++ b/src/public_include/decaf/eddsa.tmpl.hxx @@ -4,5 +4,5 @@ namespace decaf { enum Prehashed { PURE, PREHASHED }; } $("\n".join([ - "#include " % g for g in sorted([c["bits"] for _,c in curve.iteritems()]) + "#include " % g for g in sorted([c["bits"] for _,c in curve.iteritems()]) ]))