diff --git a/Doxyfile b/Doxyfile index 55b844f..ae7c8ff 100644 --- a/Doxyfile +++ b/Doxyfile @@ -751,7 +751,7 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = +INPUT = include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/include/decaf.h b/include/decaf.h index 633be59..f13bd30 100644 --- a/include/decaf.h +++ b/include/decaf.h @@ -224,10 +224,12 @@ decaf_bool_t decaf_448_scalar_invert ( * @param [out] out Will become a copy of a. */ /* PERF: make this memcpy */ -void decaf_448_scalar_copy ( +static inline void NONNULL2 decaf_448_scalar_copy ( decaf_448_scalar_t out, const decaf_448_scalar_t a -) API_VIS NONNULL2; +) { + *out = *a; +} /** * @brief Set a scalar to an integer. @@ -276,10 +278,12 @@ decaf_bool_t decaf_448_point_decode ( * @param [out] a A copy of the point. * @param [in] b Any point. */ -void decaf_448_point_copy ( +static inline void NONNULL2 decaf_448_point_copy ( decaf_448_point_t a, const decaf_448_point_t b -) API_VIS NONNULL2; +) { + *a=*b; +} /** * @brief Test whether two points are equal. If yes, return diff --git a/include/decaf.hxx b/include/decaf.hxx index d3280f2..3765692 100644 --- a/include/decaf.hxx +++ b/include/decaf.hxx @@ -173,13 +173,13 @@ public: /** @brief Compare in constant time */ inline bool operator==(const Scalar &q) const NOEXCEPT { return !!decaf_448_scalar_eq(s,q.s); } - /** @brief Invert with Fermat's Little Theorem (slow!) */ + /** @brief Invert with Fermat's Little Theorem (slow!). If *this == 0, return 0. */ inline Scalar inverse() const NOEXCEPT { Scalar r; decaf_448_scalar_invert(r.s,s); return r; } - /** @brief Divide by inverting q. */ + /** @brief Divide by inverting q. If q == 0, return 0. */ inline Scalar operator/ (const Scalar &q) const NOEXCEPT { Scalar r; decaf_448_scalar_mul(r.s,s,q.inverse().s); return r; } - /** @brief Divide by inverting q. */ + /** @brief Divide by inverting q. If q == 0, return 0. */ inline Scalar operator/=(const Scalar &q) NOEXCEPT { decaf_448_scalar_mul(s,s,q.inverse().s); return *this; } /** @brief Scalarmul with scalar on left. */ diff --git a/src/decaf.c b/src/decaf.c index 2ebb94d..c701f1b 100644 --- a/src/decaf.c +++ b/src/decaf.c @@ -412,16 +412,6 @@ void decaf_448_scalar_add ( decaf_448_subx(out, out->limb, decaf_448_scalar_p, decaf_448_scalar_p, chain); } -void decaf_448_scalar_copy ( - decaf_448_scalar_t out, - const decaf_448_scalar_t a -) { - unsigned int i; - for (i=0; ilimb[i] = a->limb[i]; - } -} - void decaf_448_scalar_set ( decaf_448_scalar_t out, decaf_word_t w @@ -575,16 +565,6 @@ void decaf_448_point_double(decaf_448_point_t a, const decaf_448_point_t b) { decaf_448_point_add(a,b,b); } -void decaf_448_point_copy ( - decaf_448_point_t a, - const decaf_448_point_t b -) { - gf_cpy(a->x, b->x); - gf_cpy(a->y, b->y); - gf_cpy(a->z, b->z); - gf_cpy(a->t, b->t); -} - void decaf_448_point_negate ( decaf_448_point_t nega, const decaf_448_point_t a diff --git a/src/decaf_fast.c b/src/decaf_fast.c index 9ad27ae..37e917d 100644 --- a/src/decaf_fast.c +++ b/src/decaf_fast.c @@ -423,16 +423,6 @@ snv decaf_448_halve ( out->limb[i] = out->limb[i]>>1 | chain<<(WBITS-1); } -void decaf_448_scalar_copy ( - decaf_448_scalar_t out, - const decaf_448_scalar_t a -) { - unsigned int i; - for (i=0; ilimb[i] = a->limb[i]; - } -} - void decaf_448_scalar_set ( decaf_448_scalar_t out, decaf_word_t w @@ -623,16 +613,6 @@ void decaf_448_point_double(decaf_448_point_t p, const decaf_448_point_t q) { decaf_448_point_double_internal(p,q,0); } -void decaf_448_point_copy ( - decaf_448_point_t a, - const decaf_448_point_t b -) { - gf_cpy(a->x, b->x); - gf_cpy(a->y, b->y); - gf_cpy(a->z, b->z); - gf_cpy(a->t, b->t); -} - void decaf_448_point_negate ( decaf_448_point_t nega, const decaf_448_point_t a