Commit e69e0026 authored by Michael Hamburg's avatar Michael Hamburg

rename publicly-visible macros to DECAF_ namespace

parent ec4ece08
......@@ -364,7 +364,7 @@ void API_NS(point_add) (
gf_mul ( p->t, b, c );
}
static NOINLINE void
static DECAF_NOINLINE void
point_double_internal (
point_t p,
const point_t q,
......@@ -403,7 +403,7 @@ void API_NS(point_negate) (
}
/* Operations on [p]niels */
static INLINE void
static DECAF_INLINE void
cond_neg_niels (
niels_t n,
mask_t neg
......@@ -412,7 +412,7 @@ cond_neg_niels (
gf_cond_neg(n->c, neg);
}
static NOINLINE void pt_to_pniels (
static DECAF_NOINLINE void pt_to_pniels (
pniels_t b,
const point_t a
) {
......@@ -422,7 +422,7 @@ static NOINLINE void pt_to_pniels (
gf_add ( b->z, a->z, a->z );
}
static NOINLINE void pniels_to_pt (
static DECAF_NOINLINE void pniels_to_pt (
point_t e,
const pniels_t d
) {
......@@ -435,7 +435,7 @@ static NOINLINE void pniels_to_pt (
gf_sqr ( e->z, d->z );
}
static NOINLINE void
static DECAF_NOINLINE void
niels_to_pt (
point_t e,
const niels_t n
......@@ -446,7 +446,7 @@ niels_to_pt (
gf_copy ( e->z, ONE );
}
static NOINLINE void
static DECAF_NOINLINE void
add_niels_to_pt (
point_t d,
const niels_t e,
......@@ -468,7 +468,7 @@ add_niels_to_pt (
if (!before_double) gf_mul ( d->t, b, c );
}
static NOINLINE void
static DECAF_NOINLINE void
sub_niels_from_pt (
point_t d,
const niels_t e,
......@@ -514,7 +514,7 @@ sub_pniels_from_pt (
sub_niels_from_pt( p, pn->n, before_double );
}
static NOINLINE void
static DECAF_NOINLINE void
prepare_fixed_window(
pniels_t *multiples,
const point_t b,
......@@ -973,7 +973,7 @@ void API_NS(precompute) (
decaf_bzero(doubles,sizeof(doubles));
}
static INLINE void
static DECAF_INLINE void
constant_time_lookup_niels (
niels_s *__restrict__ ni,
const niels_t *table,
......
......@@ -109,7 +109,7 @@ void API_NS(point_from_hash_uniform) (
#define MAX(A,B) (((A)>(B)) ? (A) : (B))
#define PKP_MASK ((1<<(MAX(8*SER_BYTES + 0 - 255,0)))-1)
#if PKP_MASK != 0
static UNUSED mask_t plus_k_p (
static DECAF_INLINE mask_t plus_k_p (
uint8_t x[SER_BYTES],
uint32_t factor_
) {
......
......@@ -37,7 +37,7 @@ const scalar_t API_NS(scalar_one) = {{{1}}}, API_NS(scalar_zero) = {{{0}}};
/** {extra,accum} - sub +? p
* Must have extra <= 1
*/
static NOINLINE void sc_subx(
static DECAF_NOINLINE void sc_subx(
scalar_t out,
const decaf_word_t accum[SCALAR_LIMBS],
const scalar_t sub,
......@@ -61,7 +61,7 @@ static NOINLINE void sc_subx(
}
}
static NOINLINE void sc_montmul (
static DECAF_NOINLINE void sc_montmul (
scalar_t out,
const scalar_t a,
const scalar_t b
......@@ -109,7 +109,7 @@ void API_NS(scalar_mul) (
}
/* PERF: could implement this */
static INLINE void sc_montsqr (scalar_t out, const scalar_t a) {
static DECAF_INLINE void sc_montsqr (scalar_t out, const scalar_t a) {
sc_montmul(out,a,a);
}
......@@ -222,7 +222,7 @@ API_NS(scalar_eq) (
return mask_to_bool(word_is_zero(diff));
}
static INLINE void scalar_decode_short (
static DECAF_INLINE void scalar_decode_short (
scalar_t s,
const unsigned char *ser,
unsigned int nbytes
......
......@@ -364,7 +364,7 @@ void API_NS(point_add) (
gf_mul ( p->t, b, c );
}
static NOINLINE void
static DECAF_NOINLINE void
point_double_internal (
point_t p,
const point_t q,
......@@ -403,7 +403,7 @@ void API_NS(point_negate) (
}
/* Operations on [p]niels */
static INLINE void
static DECAF_INLINE void
cond_neg_niels (
niels_t n,
mask_t neg
......@@ -412,7 +412,7 @@ cond_neg_niels (
gf_cond_neg(n->c, neg);
}
static NOINLINE void pt_to_pniels (
static DECAF_NOINLINE void pt_to_pniels (
pniels_t b,
const point_t a
) {
......@@ -422,7 +422,7 @@ static NOINLINE void pt_to_pniels (
gf_add ( b->z, a->z, a->z );
}
static NOINLINE void pniels_to_pt (
static DECAF_NOINLINE void pniels_to_pt (
point_t e,
const pniels_t d
) {
......@@ -435,7 +435,7 @@ static NOINLINE void pniels_to_pt (
gf_sqr ( e->z, d->z );
}
static NOINLINE void
static DECAF_NOINLINE void
niels_to_pt (
point_t e,
const niels_t n
......@@ -446,7 +446,7 @@ niels_to_pt (
gf_copy ( e->z, ONE );
}
static NOINLINE void
static DECAF_NOINLINE void
add_niels_to_pt (
point_t d,
const niels_t e,
......@@ -468,7 +468,7 @@ add_niels_to_pt (
if (!before_double) gf_mul ( d->t, b, c );
}
static NOINLINE void
static DECAF_NOINLINE void
sub_niels_from_pt (
point_t d,
const niels_t e,
......@@ -514,7 +514,7 @@ sub_pniels_from_pt (
sub_niels_from_pt( p, pn->n, before_double );
}
static NOINLINE void
static DECAF_NOINLINE void
prepare_fixed_window(
pniels_t *multiples,
const point_t b,
......@@ -973,7 +973,7 @@ void API_NS(precompute) (
decaf_bzero(doubles,sizeof(doubles));
}
static INLINE void
static DECAF_INLINE void
constant_time_lookup_niels (
niels_s *__restrict__ ni,
const niels_t *table,
......
......@@ -109,7 +109,7 @@ void API_NS(point_from_hash_uniform) (
#define MAX(A,B) (((A)>(B)) ? (A) : (B))
#define PKP_MASK ((1<<(MAX(8*SER_BYTES + 0 - 448,0)))-1)
#if PKP_MASK != 0
static UNUSED mask_t plus_k_p (
static DECAF_INLINE mask_t plus_k_p (
uint8_t x[SER_BYTES],
uint32_t factor_
) {
......
......@@ -37,7 +37,7 @@ const scalar_t API_NS(scalar_one) = {{{1}}}, API_NS(scalar_zero) = {{{0}}};
/** {extra,accum} - sub +? p
* Must have extra <= 1
*/
static NOINLINE void sc_subx(
static DECAF_NOINLINE void sc_subx(
scalar_t out,
const decaf_word_t accum[SCALAR_LIMBS],
const scalar_t sub,
......@@ -61,7 +61,7 @@ static NOINLINE void sc_subx(
}
}
static NOINLINE void sc_montmul (
static DECAF_NOINLINE void sc_montmul (
scalar_t out,
const scalar_t a,
const scalar_t b
......@@ -109,7 +109,7 @@ void API_NS(scalar_mul) (
}
/* PERF: could implement this */
static INLINE void sc_montsqr (scalar_t out, const scalar_t a) {
static DECAF_INLINE void sc_montsqr (scalar_t out, const scalar_t a) {
sc_montmul(out,a,a);
}
......@@ -222,7 +222,7 @@ API_NS(scalar_eq) (
return mask_to_bool(word_is_zero(diff));
}
static INLINE void scalar_decode_short (
static DECAF_INLINE void scalar_decode_short (
scalar_t s,
const unsigned char *ser,
unsigned int nbytes
......
......@@ -24,19 +24,18 @@ extern "C" {
#if defined(DOXYGEN) && !defined(__attribute__)
#define __attribute__((x))
#endif
#define API_VIS __attribute__((visibility("default")))
#define NOINLINE __attribute__((noinline))
#define WARN_UNUSED __attribute__((warn_unused_result))
#define NONNULL __attribute__((nonnull))
#define INLINE inline __attribute__((always_inline))
#define UNUSED __attribute__((unused))
#define DECAF_API_VIS __attribute__((visibility("default")))
#define DECAF_NOINLINE __attribute__((noinline))
#define DECAF_WARN_UNUSED __attribute__((warn_unused_result))
#define DECAF_NONNULL __attribute__((nonnull))
#define DECAF_INLINE inline __attribute__((always_inline,unused))
// Cribbed from libnotmuch
#if defined (__clang_major__) && __clang_major__ >= 3 \
|| defined (__GNUC__) && __GNUC__ >= 5 \
|| defined (__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 5
#define DEPRECATED(msg) __attribute__ ((deprecated(msg)))
#define DECAF_DEPRECATED(msg) __attribute__ ((deprecated(msg)))
#else
#define DEPRECATED(msg) __attribute__ ((deprecated))
#define DECAF_DEPRECATED(msg) __attribute__ ((deprecated))
#endif
/** @endcond */
......@@ -85,15 +84,13 @@ typedef enum {
/** Return success if x is true */
static UNUSED INLINE
decaf_error_t
static DECAF_INLINE decaf_error_t
decaf_succeed_if(decaf_bool_t x) {
return (decaf_error_t)x;
}
/** Return DECAF_TRUE iff x == DECAF_SUCCESS */
static UNUSED INLINE
decaf_bool_t
static DECAF_INLINE decaf_bool_t
decaf_successful(decaf_error_t e) {
decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS);
return (w-1)>>DECAF_WORD_BITS;
......@@ -103,14 +100,14 @@ decaf_successful(decaf_error_t e) {
void decaf_bzero (
void *data,
size_t size
) NONNULL API_VIS;
) DECAF_NONNULL DECAF_API_VIS;
/** Compare two buffers, returning DECAF_TRUE if they are equal. */
decaf_bool_t decaf_memeq (
const void *data1,
const void *data2,
size_t size
) NONNULL WARN_UNUSED API_VIS;
) DECAF_NONNULL DECAF_WARN_UNUSED DECAF_API_VIS;
#ifdef __cplusplus
} /* extern "C" */
......
......@@ -34,7 +34,7 @@ extern "C" {
/** Does EdDSA support non-contextual signatures? */
#define DECAF_EDDSA_25519_SUPPORTS_CONTEXTLESS_SIGS 1
extern const uint8_t * const DECAF_ED25519_NO_CONTEXT API_VIS;
extern const uint8_t * const DECAF_ED25519_NO_CONTEXT DECAF_API_VIS;
/** Prehash context renaming macros. */
#define decaf_ed25519_prehash_ctx_s decaf_sha512_ctx_s
......@@ -52,7 +52,7 @@ extern const uint8_t * const DECAF_ED25519_NO_CONTEXT API_VIS;
void decaf_ed25519_derive_public_key (
uint8_t pubkey[DECAF_EDDSA_25519_PUBLIC_BYTES],
const uint8_t privkey[DECAF_EDDSA_25519_PRIVATE_BYTES]
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
/**
* @brief EdDSA signing.
......@@ -80,7 +80,7 @@ void decaf_ed25519_sign (
uint8_t prehashed,
const uint8_t *context,
uint8_t context_len
) API_VIS __attribute__((nonnull(1,2,3))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1,2,3))) DECAF_NOINLINE;
/**
* @brief EdDSA signing with prehash.
......@@ -104,7 +104,7 @@ void decaf_ed25519_sign_prehash (
const decaf_ed25519_prehash_ctx_t hash,
const uint8_t *context,
uint8_t context_len
) API_VIS __attribute__((nonnull(1,2,3,4))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1,2,3,4))) DECAF_NOINLINE;
/**
* @brief Prehash initialization, with contexts if supported.
......@@ -113,7 +113,7 @@ void decaf_ed25519_sign_prehash (
*/
void decaf_ed25519_prehash_init (
decaf_ed25519_prehash_ctx_t hash
) API_VIS __attribute__((nonnull(1))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1))) DECAF_NOINLINE;
/**
* @brief EdDSA signature verification.
......@@ -141,7 +141,7 @@ decaf_error_t decaf_ed25519_verify (
uint8_t prehashed,
const uint8_t *context,
uint8_t context_len
) API_VIS __attribute__((nonnull(1,2))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1,2))) DECAF_NOINLINE;
/**
* @brief EdDSA signature verification.
......@@ -165,7 +165,7 @@ decaf_error_t decaf_ed25519_verify_prehash (
const decaf_ed25519_prehash_ctx_t hash,
const uint8_t *context,
uint8_t context_len
) API_VIS __attribute__((nonnull(1,2))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1,2))) DECAF_NOINLINE;
/**
* @brief EdDSA point encoding. Used internally, exposed externally.
......@@ -177,7 +177,7 @@ decaf_error_t decaf_ed25519_verify_prehash (
void decaf_255_point_mul_by_cofactor_and_encode_like_eddsa (
uint8_t enc[DECAF_EDDSA_25519_PUBLIC_BYTES],
const decaf_255_point_t p
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
/**
* @brief EdDSA point decoding. Remember that while points on the
......@@ -190,20 +190,23 @@ void decaf_255_point_mul_by_cofactor_and_encode_like_eddsa (
decaf_error_t decaf_255_point_decode_like_eddsa_and_ignore_cofactor (
decaf_255_point_t p,
const uint8_t enc[DECAF_EDDSA_25519_PUBLIC_BYTES]
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
/**
* @brief EdDSA to ECDH public key conversion
* Deserialize the point to get y on Edwards curve,
* Convert it to u coordinate on Montgomery curve.
*
* @warning This function does not check that the public key being converted
* is a valid EdDSA public key (FUTURE?)
*
* @param[out] x The ECDH public key as in RFC7748(point on Montgomery curve)
* @param[in] ed The EdDSA public key(point on Edwards curve)
*/
void decaf_ed25519_convert_public_key_to_x25519 (
uint8_t x[DECAF_X25519_PUBLIC_BYTES],
const uint8_t ed[DECAF_EDDSA_25519_PUBLIC_BYTES]
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
/**
* @brief EdDSA to ECDH private key conversion
......@@ -216,7 +219,7 @@ void decaf_ed25519_convert_public_key_to_x25519 (
void decaf_ed25519_convert_private_key_to_x25519 (
uint8_t x[DECAF_X25519_PRIVATE_BYTES],
const uint8_t ed[DECAF_EDDSA_25519_PRIVATE_BYTES]
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
#ifdef __cplusplus
} /* extern "C" */
......
......@@ -32,9 +32,9 @@
/** @cond internal */
#if __cplusplus >= 201103L
#define NOEXCEPT noexcept
#define DECAF_NOEXCEPT noexcept
#else
#define NOEXCEPT throw()
#define DECAF_NOEXCEPT throw()
#endif
/** @endcond */
......@@ -91,7 +91,7 @@ public:
}
/** Reset this hash */
void reset() NOEXCEPT { init(); }
void reset() DECAF_NOEXCEPT { init(); }
/** Output from this hash */
SecureBuffer final() throw(std::bad_alloc) {
......@@ -202,38 +202,38 @@ public:
/** Create but don't initialize */
inline explicit PrivateKeyBase(const NOINIT&) NOEXCEPT : priv_((NOINIT())), pub_((NOINIT())) { }
inline explicit PrivateKeyBase(const NOINIT&) DECAF_NOEXCEPT : priv_((NOINIT())), pub_((NOINIT())) { }
/** Read a private key from a string */
inline explicit PrivateKeyBase(const FixedBlock<SER_BYTES> &b) NOEXCEPT { *this = b; }
inline explicit PrivateKeyBase(const FixedBlock<SER_BYTES> &b) DECAF_NOEXCEPT { *this = b; }
/** Copy constructor */
inline PrivateKeyBase(const PrivateKey &k) NOEXCEPT { *this = k; }
inline PrivateKeyBase(const PrivateKey &k) DECAF_NOEXCEPT { *this = k; }
/** Create at random */
inline explicit PrivateKeyBase(Rng &r) NOEXCEPT : priv_(r) {
inline explicit PrivateKeyBase(Rng &r) DECAF_NOEXCEPT : priv_(r) {
decaf_ed25519_derive_public_key(pub_.data(), priv_.data());
}
/** Assignment from string */
inline PrivateKeyBase &operator=(const FixedBlock<SER_BYTES> &b) NOEXCEPT {
inline PrivateKeyBase &operator=(const FixedBlock<SER_BYTES> &b) DECAF_NOEXCEPT {
memcpy(priv_.data(),b.data(),b.size());
decaf_ed25519_derive_public_key(pub_.data(), priv_.data());
return *this;
}
/** Copy assignment */
inline PrivateKeyBase &operator=(const PrivateKey &k) NOEXCEPT {
inline PrivateKeyBase &operator=(const PrivateKey &k) DECAF_NOEXCEPT {
memcpy(priv_.data(),k.priv_.data(), priv_.size());
memcpy(pub_.data(),k.pub_.data(), pub_.size());
return *this;
}
/** Serialization size. */
inline size_t ser_size() const NOEXCEPT { return SER_BYTES; }
inline size_t ser_size() const DECAF_NOEXCEPT { return SER_BYTES; }
/** Serialize into a buffer. */
inline void serialize_into(unsigned char *x) const NOEXCEPT {
inline void serialize_into(unsigned char *x) const DECAF_NOEXCEPT {
memcpy(x,priv_.data(), priv_.size());
}
......@@ -245,7 +245,7 @@ public:
}
/** Return the corresponding public key */
inline MyPublicKey pub() const NOEXCEPT {
inline MyPublicKey pub() const DECAF_NOEXCEPT {
MyPublicKey pub(*this);
return pub;
}
......@@ -256,11 +256,11 @@ public:
template<class CRTP> class Verification<CRTP,PURE> {
public:
/** Verify a signature, returning DECAF_FAILURE if verification fails */
inline decaf_error_t WARN_UNUSED verify_noexcept (
inline decaf_error_t DECAF_WARN_UNUSED verify_noexcept (
const FixedBlock<DECAF_EDDSA_25519_SIGNATURE_BYTES> &sig,
const Block &message,
const Block &context = NO_CONTEXT()
) const /*NOEXCEPT*/ {
) const /*DECAF_NOEXCEPT*/ {
if (context.size() > 255) {
return DECAF_FAILURE;
}
......@@ -302,10 +302,10 @@ public:
template<class CRTP> class Verification<CRTP,PREHASHED> {
public:
/* Verify a prehash context. */
inline decaf_error_t WARN_UNUSED verify_prehashed_noexcept (
inline decaf_error_t DECAF_WARN_UNUSED verify_prehashed_noexcept (
const FixedBlock<DECAF_EDDSA_25519_SIGNATURE_BYTES> &sig,
const Prehash &ph
) const /*NOEXCEPT*/ {
) const /*DECAF_NOEXCEPT*/ {
return decaf_ed25519_verify_prehash (
sig.data(),
((const CRTP*)this)->pub_.data(),
......@@ -376,38 +376,38 @@ public:
/** Create but don't initialize */
inline explicit PublicKeyBase(const NOINIT&) NOEXCEPT : pub_((NOINIT())) { }
inline explicit PublicKeyBase(const NOINIT&) DECAF_NOEXCEPT : pub_((NOINIT())) { }
/** Read a private key from a string */
inline explicit PublicKeyBase(const FixedBlock<SER_BYTES> &b) NOEXCEPT { *this = b; }
inline explicit PublicKeyBase(const FixedBlock<SER_BYTES> &b) DECAF_NOEXCEPT { *this = b; }
/** Copy constructor */
inline PublicKeyBase(const PublicKeyBase &k) NOEXCEPT { *this = k; }
inline PublicKeyBase(const PublicKeyBase &k) DECAF_NOEXCEPT { *this = k; }
/** Copy constructor */
inline explicit PublicKeyBase(const MyPrivateKey &k) NOEXCEPT { *this = k; }
inline explicit PublicKeyBase(const MyPrivateKey &k) DECAF_NOEXCEPT { *this = k; }
/** Assignment from string */
inline PublicKey &operator=(const FixedBlock<SER_BYTES> &b) NOEXCEPT {
inline PublicKey &operator=(const FixedBlock<SER_BYTES> &b) DECAF_NOEXCEPT {
memcpy(pub_.data(),b.data(),b.size());
return *this;
}
/** Assignment from private key */
inline PublicKey &operator=(const PublicKey &p) NOEXCEPT {
inline PublicKey &operator=(const PublicKey &p) DECAF_NOEXCEPT {
return *this = p.pub_;
}
/** Assignment from private key */
inline PublicKey &operator=(const MyPrivateKey &p) NOEXCEPT {
inline PublicKey &operator=(const MyPrivateKey &p) DECAF_NOEXCEPT {
return *this = p.pub_;
}
/** Serialization size. */
inline size_t ser_size() const NOEXCEPT { return SER_BYTES; }
inline size_t ser_size() const DECAF_NOEXCEPT { return SER_BYTES; }
/** Serialize into a buffer. */
inline void serialize_into(unsigned char *x) const NOEXCEPT {
inline void serialize_into(unsigned char *x) const DECAF_NOEXCEPT {
memcpy(x,pub_.data(), pub_.size());
}
......@@ -421,7 +421,7 @@ public:
}; /* template<> struct EdDSA<IsoEd25519> */
#undef NOEXCEPT
#undef DECAF_NOEXCEPT
} /* namespace decaf */
#endif /* __DECAF_ED255_HXX__ */
......@@ -51,7 +51,7 @@ extern "C" {
void decaf_ed448_derive_public_key (
uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],
const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES]
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
/**
* @brief EdDSA signing.
......@@ -79,7 +79,7 @@ void decaf_ed448_sign (
uint8_t prehashed,
const uint8_t *context,
uint8_t context_len
) API_VIS __attribute__((nonnull(1,2,3))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1,2,3))) DECAF_NOINLINE;
/**
* @brief EdDSA signing with prehash.
......@@ -103,7 +103,7 @@ void decaf_ed448_sign_prehash (
const decaf_ed448_prehash_ctx_t hash,
const uint8_t *context,
uint8_t context_len
) API_VIS __attribute__((nonnull(1,2,3,4))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1,2,3,4))) DECAF_NOINLINE;
/**
* @brief Prehash initialization, with contexts if supported.
......@@ -112,7 +112,7 @@ void decaf_ed448_sign_prehash (
*/
void decaf_ed448_prehash_init (
decaf_ed448_prehash_ctx_t hash
) API_VIS __attribute__((nonnull(1))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1))) DECAF_NOINLINE;
/**
* @brief EdDSA signature verification.
......@@ -140,7 +140,7 @@ decaf_error_t decaf_ed448_verify (
uint8_t prehashed,
const uint8_t *context,
uint8_t context_len
) API_VIS __attribute__((nonnull(1,2))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1,2))) DECAF_NOINLINE;
/**
* @brief EdDSA signature verification.
......@@ -164,7 +164,7 @@ decaf_error_t decaf_ed448_verify_prehash (
const decaf_ed448_prehash_ctx_t hash,
const uint8_t *context,
uint8_t context_len
) API_VIS __attribute__((nonnull(1,2))) NOINLINE;
) DECAF_API_VIS __attribute__((nonnull(1,2))) DECAF_NOINLINE;
/**
* @brief EdDSA point encoding. Used internally, exposed externally.
......@@ -176,7 +176,7 @@ decaf_error_t decaf_ed448_verify_prehash (
void decaf_448_point_mul_by_cofactor_and_encode_like_eddsa (
uint8_t enc[DECAF_EDDSA_448_PUBLIC_BYTES],
const decaf_448_point_t p
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
/**
* @brief EdDSA point decoding. Remember that while points on the
......@@ -189,20 +189,23 @@ void decaf_448_point_mul_by_cofactor_and_encode_like_eddsa (
decaf_error_t decaf_448_point_decode_like_eddsa_and_ignore_cofactor (
decaf_448_point_t p,
const uint8_t enc[DECAF_EDDSA_448_PUBLIC_BYTES]
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
/**
* @brief EdDSA to ECDH public key conversion
* Deserialize the point to get y on Edwards curve,
* Convert it to u coordinate on Montgomery curve.
*
* @warning This function does not check that the public key being converted
* is a valid EdDSA public key (FUTURE?)
*
* @param[out] x The ECDH public key as in RFC7748(point on Montgomery curve)
* @param[in] ed The EdDSA public key(point on Edwards curve)
*/
void decaf_ed448_convert_public_key_to_x448 (
uint8_t x[DECAF_X448_PUBLIC_BYTES],
const uint8_t ed[DECAF_EDDSA_448_PUBLIC_BYTES]
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
/**
* @brief EdDSA to ECDH private key conversion
......@@ -215,7 +218,7 @@ void decaf_ed448_convert_public_key_to_x448 (
void decaf_ed448_convert_private_key_to_x448 (
uint8_t x[DECAF_X448_PRIVATE_BYTES],
const uint8_t ed[DECAF_EDDSA_448_PRIVATE_BYTES]
) API_VIS NONNULL NOINLINE;
) DECAF_API_VIS DECAF_NONNULL DECAF_NOINLINE;
#ifdef __cplusplus
} /* extern "C" */
......
......@@ -32,9 +32,9 @@
/** @cond internal */
#if __cplusplus >= 201103L
#define NOEXCEPT noexcept
#define DECAF_NOEXCEPT noexcept
#else
#define NOEXCEPT throw()
#define DECAF_NOEXCEPT throw()
#endif
/** @endcond */
......@@ -91,7 +91,7 @@ public:
}
/** Reset this hash */
void reset() NOEXCEPT { init(); }
void reset() DECAF_NOEXCEPT { init(); }
/** Output from this hash */
SecureBuffer final() throw(std::bad_alloc) {
......@@ -202,38 +202,38 @@ public:
/** Create but don't initialize */
inline explicit PrivateKeyBase(const NOINIT&) NOEXCEPT : priv_((NOINIT())), pub_((NOINIT())) { }
inline explicit PrivateKeyBase(const NOINIT&) DECAF_NOEXCEPT : priv_((NOINIT())), pub_((NOINIT())) { }
/** Read a private key from a string */
inline explicit PrivateKeyBase(const FixedBlock<SER_BYTES> &b) NOEXCEPT { *this = b; }
inline explicit PrivateKeyBase(const FixedBlock<SER_BYTES> &b) DECAF_NOEXCEPT { *this = b; }
/** Copy constructor */
inline PrivateKeyBase(const PrivateKey &k) NOEXCEPT { *this = k; }
inline PrivateKeyBase(const PrivateKey &k) DECAF_NOEXCEPT { *this = k; }
/** Create at random */
inline explicit PrivateKeyBase(Rng &r) NOEXCEPT : priv_(r) {
inline explicit PrivateKeyBase(Rng &r) DECAF_NOEXCEPT : priv_(r) {
decaf_ed448_derive_public_key(pub_.data(), priv_.data());
}
/** Assignment from string */
inline PrivateKeyBase &operator=(const FixedBlock<SER_BYTES> &b) NOEXCEPT {
inline PrivateKeyBase &operator=(const FixedBlock<SER_BYTES> &b) DECAF_NOEXCEPT {
memcpy(priv_.data(),b.data(),b.size());
decaf_ed448_derive_public_key(pub_.data(), priv_.data());
return *this;
}
/** Copy assignment */
inline PrivateKeyBase &operator=(const PrivateKey &k) NOEXCEPT {
inline PrivateKeyBase &operator=(const PrivateKey &k) DECAF_NOEXCEPT {
memcpy(priv_.data(),k.priv_.data(), priv_.size());
memcpy(pub_.data(),k.pub_.data(), pub_.size());
return *this;
}
/** Serialization size. */
inline size_t ser_size() const