@@ -30,6 +30,14 @@ extern "C" { | |||||
#define NONNULL __attribute__((nonnull)) | #define NONNULL __attribute__((nonnull)) | ||||
#define INLINE inline __attribute__((always_inline)) | #define INLINE inline __attribute__((always_inline)) | ||||
#define UNUSED __attribute__((unused)) | #define UNUSED __attribute__((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))) | |||||
#else | |||||
#define DEPRECATED(msg) __attribute__ ((deprecated)) | |||||
#endif | |||||
/** @endcond */ | /** @endcond */ | ||||
/* Internal word types. | /* Internal word types. | ||||
@@ -77,14 +85,14 @@ typedef enum { | |||||
/** Return success if x is true */ | /** Return success if x is true */ | ||||
static __inline__ __attribute__((unused,always_inline)) | |||||
static UNUSED INLINE | |||||
decaf_error_t | decaf_error_t | ||||
decaf_succeed_if(decaf_bool_t x) { | decaf_succeed_if(decaf_bool_t x) { | ||||
return (decaf_error_t)x; | return (decaf_error_t)x; | ||||
} | } | ||||
/** Return DECAF_TRUE iff x == DECAF_SUCCESS */ | /** Return DECAF_TRUE iff x == DECAF_SUCCESS */ | ||||
static __inline__ __attribute__((unused,always_inline)) | |||||
static UNUSED INLINE | |||||
decaf_bool_t | decaf_bool_t | ||||
decaf_successful(decaf_error_t e) { | decaf_successful(decaf_error_t e) { | ||||
decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS); | decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS); | ||||
@@ -413,10 +413,7 @@ extern const uint8_t decaf_x25519_base_point[DECAF_X25519_PUBLIC_BYTES] API_VIS; | |||||
void decaf_x25519_generate_key ( | void decaf_x25519_generate_key ( | ||||
uint8_t out[DECAF_X25519_PUBLIC_BYTES], | uint8_t out[DECAF_X25519_PUBLIC_BYTES], | ||||
const uint8_t scalar[DECAF_X25519_PRIVATE_BYTES] | const uint8_t scalar[DECAF_X25519_PRIVATE_BYTES] | ||||
) API_VIS NONNULL NOINLINE | |||||
__attribute__((deprecated( | |||||
"Renamed to decaf_x25519_derive_public_key" | |||||
))); | |||||
) API_VIS NONNULL NOINLINE DEPRECATED("Renamed to decaf_x25519_derive_public_key"); | |||||
/** | /** | ||||
* @brief RFC 7748 Diffie-Hellman base point scalarmul. This function uses | * @brief RFC 7748 Diffie-Hellman base point scalarmul. This function uses | ||||
@@ -671,9 +671,8 @@ public: | |||||
* but possibly faster. | * but possibly faster. | ||||
* @deprecated Renamed to derive_public_key. | * @deprecated Renamed to derive_public_key. | ||||
*/ | */ | ||||
static inline SecureBuffer __attribute__((deprecated( | |||||
"Renamed to derive_public_key" | |||||
))) generate_key( | |||||
static inline SecureBuffer DEPRECATED("Renamed to derive_public_key") | |||||
generate_key( | |||||
const FixedBlock<PRIVATE_BYTES> &scalar | const FixedBlock<PRIVATE_BYTES> &scalar | ||||
) throw(std::bad_alloc) { | ) throw(std::bad_alloc) { | ||||
SecureBuffer out(PUBLIC_BYTES); | SecureBuffer out(PUBLIC_BYTES); | ||||
@@ -707,10 +706,7 @@ public: | |||||
* equivalent to shared_secret(base_point(),scalar) but possibly faster. | * equivalent to shared_secret(base_point(),scalar) but possibly faster. | ||||
* @deprecated Renamed to derive_public_key_noexcept. | * @deprecated Renamed to derive_public_key_noexcept. | ||||
*/ | */ | ||||
static inline void | |||||
__attribute__((deprecated( | |||||
"Renamed to derive_public_key_noexcept" | |||||
))) | |||||
static inline void DEPRECATED("Renamed to derive_public_key_noexcept") | |||||
generate_key_noexcept ( | generate_key_noexcept ( | ||||
FixedBuffer<PUBLIC_BYTES> &out, | FixedBuffer<PUBLIC_BYTES> &out, | ||||
const FixedBlock<PRIVATE_BYTES> &scalar | const FixedBlock<PRIVATE_BYTES> &scalar | ||||
@@ -413,10 +413,7 @@ extern const uint8_t decaf_x448_base_point[DECAF_X448_PUBLIC_BYTES] API_VIS; | |||||
void decaf_x448_generate_key ( | void decaf_x448_generate_key ( | ||||
uint8_t out[DECAF_X448_PUBLIC_BYTES], | uint8_t out[DECAF_X448_PUBLIC_BYTES], | ||||
const uint8_t scalar[DECAF_X448_PRIVATE_BYTES] | const uint8_t scalar[DECAF_X448_PRIVATE_BYTES] | ||||
) API_VIS NONNULL NOINLINE | |||||
__attribute__((deprecated( | |||||
"Renamed to decaf_x448_derive_public_key" | |||||
))); | |||||
) API_VIS NONNULL NOINLINE DEPRECATED("Renamed to decaf_x448_derive_public_key"); | |||||
/** | /** | ||||
* @brief RFC 7748 Diffie-Hellman base point scalarmul. This function uses | * @brief RFC 7748 Diffie-Hellman base point scalarmul. This function uses | ||||
@@ -671,9 +671,8 @@ public: | |||||
* but possibly faster. | * but possibly faster. | ||||
* @deprecated Renamed to derive_public_key. | * @deprecated Renamed to derive_public_key. | ||||
*/ | */ | ||||
static inline SecureBuffer __attribute__((deprecated( | |||||
"Renamed to derive_public_key" | |||||
))) generate_key( | |||||
static inline SecureBuffer DEPRECATED("Renamed to derive_public_key") | |||||
generate_key( | |||||
const FixedBlock<PRIVATE_BYTES> &scalar | const FixedBlock<PRIVATE_BYTES> &scalar | ||||
) throw(std::bad_alloc) { | ) throw(std::bad_alloc) { | ||||
SecureBuffer out(PUBLIC_BYTES); | SecureBuffer out(PUBLIC_BYTES); | ||||
@@ -707,10 +706,7 @@ public: | |||||
* equivalent to shared_secret(base_point(),scalar) but possibly faster. | * equivalent to shared_secret(base_point(),scalar) but possibly faster. | ||||
* @deprecated Renamed to derive_public_key_noexcept. | * @deprecated Renamed to derive_public_key_noexcept. | ||||
*/ | */ | ||||
static inline void | |||||
__attribute__((deprecated( | |||||
"Renamed to derive_public_key_noexcept" | |||||
))) | |||||
static inline void DEPRECATED("Renamed to derive_public_key_noexcept") | |||||
generate_key_noexcept ( | generate_key_noexcept ( | ||||
FixedBuffer<PUBLIC_BYTES> &out, | FixedBuffer<PUBLIC_BYTES> &out, | ||||
const FixedBlock<PRIVATE_BYTES> &scalar | const FixedBlock<PRIVATE_BYTES> &scalar | ||||
@@ -398,10 +398,7 @@ extern const uint8_t decaf_x$(gf_shortname)_base_point[DECAF_X$(gf_shortname)_PU | |||||
void decaf_x$(gf_shortname)_generate_key ( | void decaf_x$(gf_shortname)_generate_key ( | ||||
uint8_t out[DECAF_X$(gf_shortname)_PUBLIC_BYTES], | uint8_t out[DECAF_X$(gf_shortname)_PUBLIC_BYTES], | ||||
const uint8_t scalar[DECAF_X$(gf_shortname)_PRIVATE_BYTES] | const uint8_t scalar[DECAF_X$(gf_shortname)_PRIVATE_BYTES] | ||||
) API_VIS NONNULL NOINLINE | |||||
__attribute__((deprecated( | |||||
"Renamed to decaf_x$(gf_shortname)_derive_public_key" | |||||
))); | |||||
) API_VIS NONNULL NOINLINE DEPRECATED("Renamed to decaf_x$(gf_shortname)_derive_public_key"); | |||||
/** | /** | ||||
* @brief RFC 7748 Diffie-Hellman base point scalarmul. This function uses | * @brief RFC 7748 Diffie-Hellman base point scalarmul. This function uses | ||||
@@ -658,9 +658,8 @@ public: | |||||
* but possibly faster. | * but possibly faster. | ||||
* @deprecated Renamed to derive_public_key. | * @deprecated Renamed to derive_public_key. | ||||
*/ | */ | ||||
static inline SecureBuffer __attribute__((deprecated( | |||||
"Renamed to derive_public_key" | |||||
))) generate_key( | |||||
static inline SecureBuffer DEPRECATED("Renamed to derive_public_key") | |||||
generate_key( | |||||
const FixedBlock<PRIVATE_BYTES> &scalar | const FixedBlock<PRIVATE_BYTES> &scalar | ||||
) throw(std::bad_alloc) { | ) throw(std::bad_alloc) { | ||||
SecureBuffer out(PUBLIC_BYTES); | SecureBuffer out(PUBLIC_BYTES); | ||||
@@ -694,10 +693,7 @@ public: | |||||
* equivalent to shared_secret(base_point(),scalar) but possibly faster. | * equivalent to shared_secret(base_point(),scalar) but possibly faster. | ||||
* @deprecated Renamed to derive_public_key_noexcept. | * @deprecated Renamed to derive_public_key_noexcept. | ||||
*/ | */ | ||||
static inline void | |||||
__attribute__((deprecated( | |||||
"Renamed to derive_public_key_noexcept" | |||||
))) | |||||
static inline void DEPRECATED("Renamed to derive_public_key_noexcept") | |||||
generate_key_noexcept ( | generate_key_noexcept ( | ||||
FixedBuffer<PUBLIC_BYTES> &out, | FixedBuffer<PUBLIC_BYTES> &out, | ||||
const FixedBlock<PRIVATE_BYTES> &scalar | const FixedBlock<PRIVATE_BYTES> &scalar | ||||
@@ -30,6 +30,14 @@ extern "C" { | |||||
#define NONNULL __attribute__((nonnull)) | #define NONNULL __attribute__((nonnull)) | ||||
#define INLINE inline __attribute__((always_inline)) | #define INLINE inline __attribute__((always_inline)) | ||||
#define UNUSED __attribute__((unused)) | #define UNUSED __attribute__((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))) | |||||
#else | |||||
#define DEPRECATED(msg) __attribute__ ((deprecated)) | |||||
#endif | |||||
/** @endcond */ | /** @endcond */ | ||||
/* Internal word types. | /* Internal word types. | ||||
@@ -77,14 +85,14 @@ typedef enum { | |||||
/** Return success if x is true */ | /** Return success if x is true */ | ||||
static __inline__ __attribute__((unused,always_inline)) | |||||
static UNUSED INLINE | |||||
decaf_error_t | decaf_error_t | ||||
decaf_succeed_if(decaf_bool_t x) { | decaf_succeed_if(decaf_bool_t x) { | ||||
return (decaf_error_t)x; | return (decaf_error_t)x; | ||||
} | } | ||||
/** Return DECAF_TRUE iff x == DECAF_SUCCESS */ | /** Return DECAF_TRUE iff x == DECAF_SUCCESS */ | ||||
static __inline__ __attribute__((unused,always_inline)) | |||||
static UNUSED INLINE | |||||
decaf_bool_t | decaf_bool_t | ||||
decaf_successful(decaf_error_t e) { | decaf_successful(decaf_error_t e) { | ||||
decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS); | decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS); | ||||