Unverified Commit ae68d25d authored by Sofia Celi's avatar Sofia Celi

Change decaf booleans to goldilocks name

parent 339c9194
......@@ -70,12 +70,12 @@ typedef int64_t decaf_dsword_t; /**< Signed double-word size for internal co
#else
#error "Only supporting DECAF_WORD_BITS = 32 or 64 for now"
#endif
/** DECAF_TRUE = -1 so that DECAF_TRUE & x = x */
static const decaf_bool_t DECAF_TRUE = -(decaf_bool_t)1;
/** DECAF_FALSE = 0 so that DECAF_FALSE & x = 0 */
static const decaf_bool_t DECAF_FALSE = 0;
/** GOLDILOCKS_TRUE = -1 so that GOLDILOCKS_TRUE & x = x */
static const decaf_bool_t GOLDILOCKS_TRUE = -(decaf_bool_t)1;
/** GOLDILOCKS_FALSE = 0 so that GOLDILOCKS_FALSE & x = 0 */
static const decaf_bool_t GOLDILOCKS_FALSE = 0;
/** Another boolean type used to indicate success or failure. */
typedef enum {
......@@ -90,28 +90,28 @@ decaf_succeed_if(decaf_bool_t x) {
return (decaf_error_t)x;
}
/** Return DECAF_TRUE iff x == DECAF_SUCCESS */
/** Return GOLDILOCKS_TRUE iff x == DECAF_SUCCESS */
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;
}
/** Overwrite data with zeros. Uses memset_s if available. */
void decaf_bzero (
void *data,
size_t size
) DECAF_NONNULL DECAF_API_VIS;
/** Compare two buffers, returning DECAF_TRUE if they are equal. */
/** Compare two buffers, returning GOLDILOCKS_TRUE if they are equal. */
decaf_bool_t decaf_memeq (
const void *data1,
const void *data2,
size_t size
) DECAF_NONNULL DECAF_WARN_UNUSED DECAF_API_VIS;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __DECAF_COMMON_H__ */
......@@ -158,8 +158,8 @@ void goldilocks_448_scalar_add (
* @brief Compare two scalars.
* @param [in] a One scalar.
* @param [in] b Another scalar.
* @retval DECAF_TRUE The scalars are equal.
* @retval DECAF_FALSE The scalars are not equal.
* @retval GOLDILOCKS_TRUE The scalars are equal.
* @retval GOLDILOCKS_FALSE The scalars are not equal.
*/
decaf_bool_t goldilocks_448_scalar_eq (
const goldilocks_448_scalar_t a,
......
......@@ -230,16 +230,16 @@ public:
*/
inline SecureBuffer direct_scalarmul (
const FixedBlock<SER_BYTES> &in,
decaf_bool_t allow_identity=DECAF_FALSE,
decaf_bool_t short_circuit=DECAF_TRUE
decaf_bool_t allow_identity=GOLDILOCKS_FALSE,
decaf_bool_t short_circuit=GOLDILOCKS_TRUE
) const /*throw(CryptoException)*/;
/** Direct scalar multiplication. */
inline decaf_error_t DECAF_WARN_UNUSED direct_scalarmul_noexcept(
FixedBuffer<SER_BYTES> &out,
const FixedBlock<SER_BYTES> &in,
decaf_bool_t allow_identity=DECAF_FALSE,
decaf_bool_t short_circuit=DECAF_TRUE
decaf_bool_t allow_identity=GOLDILOCKS_FALSE,
decaf_bool_t short_circuit=GOLDILOCKS_TRUE
) const DECAF_NOEXCEPT;
};
......
......@@ -143,8 +143,8 @@ void $(c_ns)_scalar_add (
* @brief Compare two scalars.
* @param [in] a One scalar.
* @param [in] b Another scalar.
* @retval DECAF_TRUE The scalars are equal.
* @retval DECAF_FALSE The scalars are not equal.
* @retval GOLDILOCKS_TRUE The scalars are equal.
* @retval GOLDILOCKS_FALSE The scalars are not equal.
*/
decaf_bool_t $(c_ns)_scalar_eq (
const $(c_ns)_scalar_t a,
......@@ -239,7 +239,7 @@ void $(c_ns)_point_encode (
*
* @param [out] pt The decoded point.
* @param [in] ser The serialized version of the point.
* @param [in] allow_identity DECAF_TRUE if the identity is a legal input.
* @param [in] allow_identity GOLDILOCKS_TRUE if the identity is a legal input.
* @retval DECAF_SUCCESS The decoding succeeded.
* @retval DECAF_FAILURE The decoding didn't succeed, because
* ser does not represent a point.
......@@ -266,12 +266,12 @@ static inline void DECAF_NONNULL $(c_ns)_point_copy (
/**
* @brief Test whether two points are equal. If yes, return
* DECAF_TRUE, else return DECAF_FALSE.
* GOLDILOCKS_TRUE, else return GOLDILOCKS_FALSE.
*
* @param [in] a A point.
* @param [in] b Another point.
* @retval DECAF_TRUE The points are equal.
* @retval DECAF_FALSE The points are not equal.
* @retval GOLDILOCKS_TRUE The points are equal.
* @retval GOLDILOCKS_FALSE The points are not equal.
*/
decaf_bool_t $(c_ns)_point_eq (
const $(c_ns)_point_t a,
......@@ -587,8 +587,8 @@ void $(c_ns)_scalar_cond_sel (
* @brief Test that a point is valid, for debugging purposes.
*
* @param [in] to_test The point to test.
* @retval DECAF_TRUE The point is valid.
* @retval DECAF_FALSE The point is invalid.
* @retval GOLDILOCKS_TRUE The point is valid.
* @retval GOLDILOCKS_FALSE The point is invalid.
*/
decaf_bool_t $(c_ns)_point_valid (
const $(c_ns)_point_t to_test
......
......@@ -217,16 +217,16 @@ public:
*/
inline SecureBuffer direct_scalarmul (
const FixedBlock<SER_BYTES> &in,
decaf_bool_t allow_identity=DECAF_FALSE,
decaf_bool_t short_circuit=DECAF_TRUE
decaf_bool_t allow_identity=GOLDILOCKS_FALSE,
decaf_bool_t short_circuit=GOLDILOCKS_TRUE
) const /*throw(CryptoException)*/;
/** Direct scalar multiplication. */
inline decaf_error_t DECAF_WARN_UNUSED direct_scalarmul_noexcept(
FixedBuffer<SER_BYTES> &out,
const FixedBlock<SER_BYTES> &in,
decaf_bool_t allow_identity=DECAF_FALSE,
decaf_bool_t short_circuit=DECAF_TRUE
decaf_bool_t allow_identity=GOLDILOCKS_FALSE,
decaf_bool_t short_circuit=GOLDILOCKS_TRUE
) const DECAF_NOEXCEPT;
};
......@@ -301,11 +301,11 @@ public:
* The all-zero string maps to the identity.
*
* @throw CryptoException the string was the wrong length, or wasn't the encoding of a point,
* or was the identity and allow_identity was DECAF_FALSE.
* or was the identity and allow_identity was GOLDILOCKS_FALSE.
*/
inline explicit Point(const FixedBlock<SER_BYTES> &buffer, bool allow_identity=true)
/*throw(CryptoException)*/ {
if (DECAF_SUCCESS != decode(buffer,allow_identity ? DECAF_TRUE : DECAF_FALSE)) {
if (DECAF_SUCCESS != decode(buffer,allow_identity ? GOLDILOCKS_TRUE : GOLDILOCKS_FALSE)) {
throw CryptoException();
}
}
......@@ -316,12 +316,12 @@ public:
*
* @retval DECAF_SUCCESS the string was successfully decoded.
* @return DECAF_FAILURE the string was the wrong length, or wasn't the encoding of a point,
* or was the identity and allow_identity was DECAF_FALSE. Contents of the buffer are undefined.
* or was the identity and allow_identity was GOLDILOCKS_FALSE. Contents of the buffer are undefined.
*/
inline decaf_error_t DECAF_WARN_UNUSED decode (
const FixedBlock<SER_BYTES> &buffer, bool allow_identity=true
) DECAF_NOEXCEPT {
return $(c_ns)_point_decode(p,buffer.data(),allow_identity ? DECAF_TRUE : DECAF_FALSE);
return $(c_ns)_point_decode(p,buffer.data(),allow_identity ? GOLDILOCKS_TRUE : GOLDILOCKS_FALSE);
}
/**
......
......@@ -70,12 +70,12 @@ typedef int64_t decaf_dsword_t; /**< Signed double-word size for internal co
#else
#error "Only supporting DECAF_WORD_BITS = 32 or 64 for now"
#endif
/** DECAF_TRUE = -1 so that DECAF_TRUE & x = x */
static const decaf_bool_t DECAF_TRUE = -(decaf_bool_t)1;
/** DECAF_FALSE = 0 so that DECAF_FALSE & x = 0 */
static const decaf_bool_t DECAF_FALSE = 0;
/** GOLDILOCKS_TRUE = -1 so that GOLDILOCKS_TRUE & x = x */
static const decaf_bool_t GOLDILOCKS_TRUE = -(decaf_bool_t)1;
/** GOLDILOCKS_FALSE = 0 so that GOLDILOCKS_FALSE & x = 0 */
static const decaf_bool_t GOLDILOCKS_FALSE = 0;
/** Another boolean type used to indicate success or failure. */
typedef enum {
......@@ -90,7 +90,7 @@ decaf_succeed_if(decaf_bool_t x) {
return (decaf_error_t)x;
}
/** Return DECAF_TRUE iff x == DECAF_SUCCESS */
/** Return GOLDILOCKS_TRUE iff x == DECAF_SUCCESS */
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);
......@@ -103,7 +103,7 @@ void decaf_bzero (
size_t size
) DECAF_NONNULL DECAF_API_VIS;
/** Compare two buffers, returning DECAF_TRUE if they are equal. */
/** Compare two buffers, returning GOLDILOCKS_TRUE if they are equal. */
decaf_bool_t decaf_memeq (
const void *data1,
const void *data2,
......
......@@ -107,7 +107,7 @@ static void test_cfrg() {
/* Specify the same value as you did when compiling decaf_crypto.c */
#ifndef DECAF_CRYPTO_SHARED_SECRET_SHORT_CIRUIT
#define DECAF_CRYPTO_SHARED_SECRET_SHORT_CIRUIT DECAF_FALSE
#define DECAF_CRYPTO_SHARED_SECRET_SHORT_CIRUIT GOLDILOCKS_FALSE
#endif
static void test_crypto() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment