diff --git a/include/ox_aes.h b/include/ox_aes.h index 7a5545801..9fc144111 100644 --- a/include/ox_aes.h +++ b/include/ox_aes.h @@ -92,8 +92,8 @@ typedef struct cx_aes_key_s cx_aes_key_t; * - CX_OK on success * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_aes_set_key_hw(const cx_aes_key_t *key PLENGTH(sizeof(cx_aes_key_t)), - uint32_t mode); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_aes_set_key_hw(const cx_aes_key_t *key PLENGTH(sizeof(cx_aes_key_t)), uint32_t mode); /** * @brief Resets the AES context. @@ -111,7 +111,7 @@ SYSCALL void cx_aes_reset_hw(void); * - CX_OK on success * - INVALID_PARAMETER */ -SYSCALL cx_err_t cx_aes_block_hw(const unsigned char *inblock PLENGTH(16), - unsigned char *outblock PLENGTH(16)); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_aes_block_hw(const unsigned char *inblock PLENGTH(16), + unsigned char *outblock PLENGTH(16)); #endif diff --git a/include/ox_bls.h b/include/ox_bls.h index 6467cbf38..9d0a24105 100644 --- a/include/ox_bls.h +++ b/include/ox_bls.h @@ -61,16 +61,16 @@ * - CX_EC_INVALID_POINT * - CX_EC_INFINITE_POINT */ -SYSCALL cx_err_t cx_bls12381_key_gen(uint8_t mode, - const uint8_t *secret, - size_t secret_len, - const uint8_t *salt, - size_t salt_len, - uint8_t *key_info, - size_t key_info_len, - cx_ecfp_384_private_key_t *private_key, - uint8_t *public_key, - size_t public_key_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bls12381_key_gen(uint8_t mode, + const uint8_t *secret, + size_t secret_len, + const uint8_t *salt, + size_t salt_len, + uint8_t *key_info, + size_t key_info_len, + cx_ecfp_384_private_key_t *private_key, + uint8_t *public_key, + size_t public_key_len); /** * @brief Hash a message to be signed with BLS12-381 signature scheme. @@ -96,12 +96,12 @@ SYSCALL cx_err_t cx_bls12381_key_gen(uint8_t mode, * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_hash_to_field(const uint8_t *msg, - size_t msg_len, - const uint8_t *dst, - size_t dst_len, - uint8_t *hash, - size_t hash_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_hash_to_field(const uint8_t *msg, + size_t msg_len, + const uint8_t *dst, + size_t dst_len, + uint8_t *hash, + size_t hash_len); /** * @brief Sign the hash of a message. @@ -131,11 +131,11 @@ SYSCALL cx_err_t cx_hash_to_field(const uint8_t *msg, * - CX_INTERNAL_ERROR * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t ox_bls12381_sign(const cx_ecfp_384_private_key_t *key, - const uint8_t *message, - size_t message_len, - uint8_t *signature, - size_t signature_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t ox_bls12381_sign(const cx_ecfp_384_private_key_t *key, + const uint8_t *message, + size_t message_len, + uint8_t *signature, + size_t signature_len); /** * @brief Aggregate multiple signatures. @@ -159,11 +159,11 @@ SYSCALL cx_err_t ox_bls12381_sign(const cx_ecfp_384_private_key_t *key, * - CX_INTERNAL_ERROR * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bls12381_aggregate(const uint8_t *in, - size_t in_len, - bool first, - uint8_t *aggregated_signature, - size_t signature_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bls12381_aggregate(const uint8_t *in, + size_t in_len, + bool first, + uint8_t *aggregated_signature, + size_t signature_len); #endif // HAVE_BLS #endif // OX_BLS_H diff --git a/include/ox_bn.h b/include/ox_bn.h index 839720652..31f8f9c47 100644 --- a/include/ox_bn.h +++ b/include/ox_bn.h @@ -81,7 +81,7 @@ typedef struct { * - CX_OK on success * - CX_BN_LOCKED if already locked. */ -SYSCALL cx_err_t cx_bn_lock(size_t word_nbytes, uint32_t flags); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_lock(size_t word_nbytes, uint32_t flags); /** * @brief Releases the BN lock. @@ -114,7 +114,7 @@ SYSCALL bool cx_bn_is_locked(void); * - CX_OK on success * - CX_NOT_LOCKED */ -cx_err_t cx_bn_locked(void); +WARN_UNUSED_RESULT cx_err_t cx_bn_locked(void); /* ========================================================================= */ /* === ALLOCA === */ @@ -137,7 +137,7 @@ cx_err_t cx_bn_locked(void); * - CX_BN_MEMORY_FULL * - CX_BN_INVALID_PARAMETER_SIZE */ -SYSCALL cx_err_t cx_bn_alloc(cx_bn_t *x PLENGTH(sizeof(cx_bn_t)), size_t nbytes); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_alloc(cx_bn_t *x PLENGTH(sizeof(cx_bn_t)), size_t nbytes); /** * @brief Allocates memory for a new BN and @@ -160,10 +160,10 @@ SYSCALL cx_err_t cx_bn_alloc(cx_bn_t *x PLENGTH(sizeof(cx_bn_t)), size_t nbytes) * - CX_BN_MEMORY_FULL * - CX_BN_INVALID_PARAMETER_SIZE */ -SYSCALL cx_err_t cx_bn_alloc_init(cx_bn_t *x PLENGTH(sizeof(cx_bn_t)), - size_t nbytes, - const uint8_t *value PLENGTH(value_nbytes), - size_t value_nbytes); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_alloc_init(cx_bn_t *x PLENGTH(sizeof(cx_bn_t)), + size_t nbytes, + const uint8_t *value PLENGTH(value_nbytes), + size_t value_nbytes); /** * @brief Releases a BN and gives back its attached memory to the system. @@ -175,7 +175,7 @@ SYSCALL cx_err_t cx_bn_alloc_init(cx_bn_t *x PLENGTH(sizeof(cx_bn_t)), * - CX_BN_INVALID_PARAMETER_SIZE * - CX_BN_INVALID_PARAMETER_VALUE */ -SYSCALL cx_err_t cx_bn_destroy(cx_bn_t *x PLENGTH(sizeof(cx_bn_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_destroy(cx_bn_t *x PLENGTH(sizeof(cx_bn_t))); /** * @brief Gets the size in bytes of a BN. @@ -188,7 +188,7 @@ SYSCALL cx_err_t cx_bn_destroy(cx_bn_t *x PLENGTH(sizeof(cx_bn_t))); * - CX_OK on success * - CX_BN_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_nbytes(const cx_bn_t x, size_t *nbytes); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_nbytes(const cx_bn_t x, size_t *nbytes); /* ========================================================================= */ /* === R/W === */ @@ -207,9 +207,9 @@ SYSCALL cx_err_t cx_bn_nbytes(const cx_bn_t x, size_t *nbytes); * - CX_BN_INVALID_PARAMETER_SIZE * - CX_BN_INVALID_PARAMETER_VALUE */ -SYSCALL cx_err_t cx_bn_init(cx_bn_t x, - const uint8_t *value PLENGTH(value_nbytes), - size_t value_nbytes); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_init(cx_bn_t x, + const uint8_t *value PLENGTH(value_nbytes), + size_t value_nbytes); /** * @brief Generates a random number and @@ -221,7 +221,7 @@ SYSCALL cx_err_t cx_bn_init(cx_bn_t x, * - CX_OK on success * - CX_BN_INVALID_PARAMETER_VALUE */ -SYSCALL cx_err_t cx_bn_rand(cx_bn_t x); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_rand(cx_bn_t x); /** * @brief Copies the BN value. @@ -235,7 +235,7 @@ SYSCALL cx_err_t cx_bn_rand(cx_bn_t x); * - CX_BN_INVALID_PARAMETER_SIZE * - CX_BN_INVALID_PARAMETER_VALUE */ -SYSCALL cx_err_t cx_bn_copy(cx_bn_t a, const cx_bn_t b); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_copy(cx_bn_t a, const cx_bn_t b); /** * @brief Sets the value of a BN with a 32-bit unsigned value. @@ -249,7 +249,7 @@ SYSCALL cx_err_t cx_bn_copy(cx_bn_t a, const cx_bn_t b); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_set_u32(cx_bn_t x, uint32_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_set_u32(cx_bn_t x, uint32_t n); /** * @brief Gets the 32-bit value corresponding to a BN. @@ -263,7 +263,7 @@ SYSCALL cx_err_t cx_bn_set_u32(cx_bn_t x, uint32_t n); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_get_u32(const cx_bn_t x, uint32_t *n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_get_u32(const cx_bn_t x, uint32_t *n); /** * @brief Stores (serializes) a BN value as @@ -284,7 +284,9 @@ SYSCALL cx_err_t cx_bn_get_u32(const cx_bn_t x, uint32_t *n); * - CX_BN_INVALID_PARAMETER_SIZE * - CX_BN_INVALID_PARAMETER_VALUE */ -SYSCALL cx_err_t cx_bn_export(const cx_bn_t x, uint8_t *bytes PLENGTH(nbytes), size_t nbytes); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_export(const cx_bn_t x, + uint8_t *bytes PLENGTH(nbytes), + size_t nbytes); /* ========================================================================= */ /* === TEST === */ @@ -307,7 +309,7 @@ SYSCALL cx_err_t cx_bn_export(const cx_bn_t x, uint8_t *bytes PLENGTH(nbytes), s * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_cmp(const cx_bn_t a, const cx_bn_t b, int *diff); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_cmp(const cx_bn_t a, const cx_bn_t b, int *diff); /** * @brief Compares a BN value with an unsigned integer. @@ -326,7 +328,7 @@ SYSCALL cx_err_t cx_bn_cmp(const cx_bn_t a, const cx_bn_t b, int *diff); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_cmp_u32(const cx_bn_t a, uint32_t b, int *diff); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_cmp_u32(const cx_bn_t a, uint32_t b, int *diff); /** * @brief Tests whether a BN value is odd. @@ -342,7 +344,7 @@ SYSCALL cx_err_t cx_bn_cmp_u32(const cx_bn_t a, uint32_t b, int *diff); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_is_odd(const cx_bn_t n, bool *odd); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_is_odd(const cx_bn_t n, bool *odd); /* ========================================================================= */ /* === BIT MANIPULATION === */ @@ -364,7 +366,7 @@ SYSCALL cx_err_t cx_bn_is_odd(const cx_bn_t n, bool *odd); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_xor(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_xor(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); /** * @brief Performs the bitwise 'OR' of two BN values. @@ -382,7 +384,7 @@ SYSCALL cx_err_t cx_bn_xor(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_or(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_or(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); /** * @brief Performs the bitwise 'AND' of two BN values. @@ -400,7 +402,7 @@ SYSCALL cx_err_t cx_bn_or(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_and(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_and(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); /** * @brief Tests the bit value at the specified index. @@ -421,7 +423,7 @@ SYSCALL cx_err_t cx_bn_and(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_tst_bit(const cx_bn_t x, uint32_t pos, bool *set); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_tst_bit(const cx_bn_t x, uint32_t pos, bool *set); /** * @brief Sets the bit value at the specified index. @@ -438,7 +440,7 @@ SYSCALL cx_err_t cx_bn_tst_bit(const cx_bn_t x, uint32_t pos, bool *set); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_set_bit(cx_bn_t x, uint32_t pos); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_set_bit(cx_bn_t x, uint32_t pos); /** * @brief Clears the bit value at the specified index. @@ -455,7 +457,7 @@ SYSCALL cx_err_t cx_bn_set_bit(cx_bn_t x, uint32_t pos); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_clr_bit(cx_bn_t x, uint32_t pos); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_clr_bit(cx_bn_t x, uint32_t pos); /** * @brief Performs a right shift. @@ -469,7 +471,7 @@ SYSCALL cx_err_t cx_bn_clr_bit(cx_bn_t x, uint32_t pos); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_shr(cx_bn_t x, uint32_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_shr(cx_bn_t x, uint32_t n); /** * @brief Performs a left shift. @@ -483,7 +485,7 @@ SYSCALL cx_err_t cx_bn_shr(cx_bn_t x, uint32_t n); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_shl(cx_bn_t x, uint32_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_shl(cx_bn_t x, uint32_t n); /** * @brief Counts the number of bits set to 1 of the BN value. @@ -497,7 +499,7 @@ SYSCALL cx_err_t cx_bn_shl(cx_bn_t x, uint32_t n); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_cnt_bits(cx_bn_t n, uint32_t *nbits); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_cnt_bits(cx_bn_t n, uint32_t *nbits); /* ========================================================================= */ /* === NON MODULAR ARITHMETIC === */ @@ -519,7 +521,7 @@ SYSCALL cx_err_t cx_bn_cnt_bits(cx_bn_t n, uint32_t *nbits); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_add(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_add(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); /** * @brief Performs a subtraction **r = a - b**. @@ -537,7 +539,7 @@ SYSCALL cx_err_t cx_bn_add(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_sub(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_sub(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); /** * @brief Performs a multiplication **r = a * b**. @@ -557,7 +559,7 @@ SYSCALL cx_err_t cx_bn_sub(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_bn_mul(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mul(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); /* ========================================================================= */ /* === Z/pZ MODULAR ARITHMETIC === */ @@ -584,7 +586,10 @@ SYSCALL cx_err_t cx_bn_mul(cx_bn_t r, const cx_bn_t a, const cx_bn_t b); * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_mod_add(cx_bn_t r, const cx_bn_t a, const cx_bn_t b, const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mod_add(cx_bn_t r, + const cx_bn_t a, + const cx_bn_t b, + const cx_bn_t n); /** * @brief Performs a modular subtraction **r = a - b mod n**. @@ -607,7 +612,10 @@ SYSCALL cx_err_t cx_bn_mod_add(cx_bn_t r, const cx_bn_t a, const cx_bn_t b, cons * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_mod_sub(cx_bn_t r, const cx_bn_t a, const cx_bn_t b, const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mod_sub(cx_bn_t r, + const cx_bn_t a, + const cx_bn_t b, + const cx_bn_t n); /** * @brief Performs a modular multiplication **r = a * b mod n**. @@ -631,7 +639,10 @@ SYSCALL cx_err_t cx_bn_mod_sub(cx_bn_t r, const cx_bn_t a, const cx_bn_t b, cons * - CX_INVALID_PARAMETER_VALUE * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_mod_mul(cx_bn_t r, const cx_bn_t a, const cx_bn_t b, const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mod_mul(cx_bn_t r, + const cx_bn_t a, + const cx_bn_t b, + const cx_bn_t n); /** * @brief Performs a reduction **r = d mod n**. @@ -650,7 +661,7 @@ SYSCALL cx_err_t cx_bn_mod_mul(cx_bn_t r, const cx_bn_t a, const cx_bn_t b, cons * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_reduce(cx_bn_t r, const cx_bn_t d, const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_reduce(cx_bn_t r, const cx_bn_t d, const cx_bn_t n); /** * @brief Computes *r* such that **r² = a mod n** if *a* is a quadratic residue. @@ -673,7 +684,10 @@ SYSCALL cx_err_t cx_bn_reduce(cx_bn_t r, const cx_bn_t d, const cx_bn_t n); * - CX_MEMORY_FULL * - CX_NO_RESIDUE */ -SYSCALL cx_err_t cx_bn_mod_sqrt(cx_bn_t r, const cx_bn_t a, const cx_bn_t n, uint32_t sign); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mod_sqrt(cx_bn_t r, + const cx_bn_t a, + const cx_bn_t n, + uint32_t sign); /** * @brief Performs a modular exponentiation **r = a^e mod n**. @@ -695,7 +709,10 @@ SYSCALL cx_err_t cx_bn_mod_sqrt(cx_bn_t r, const cx_bn_t a, const cx_bn_t n, uin * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_mod_pow_bn(cx_bn_t r, const cx_bn_t a, const cx_bn_t e, const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mod_pow_bn(cx_bn_t r, + const cx_bn_t a, + const cx_bn_t e, + const cx_bn_t n); /** * @brief Performs a modular exponentiation **r = a^e mod n**. @@ -719,11 +736,11 @@ SYSCALL cx_err_t cx_bn_mod_pow_bn(cx_bn_t r, const cx_bn_t a, const cx_bn_t e, c * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_mod_pow(cx_bn_t r, - const cx_bn_t a, - const uint8_t *e PLENGTH(e_len), - uint32_t e_len, - const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mod_pow(cx_bn_t r, + const cx_bn_t a, + const uint8_t *e PLENGTH(e_len), + uint32_t e_len, + const cx_bn_t n); /** * @brief Performs a modular exponentiation **r = a^e mod n**. @@ -751,11 +768,11 @@ SYSCALL cx_err_t cx_bn_mod_pow(cx_bn_t r, * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_mod_pow2(cx_bn_t r, - const cx_bn_t a, - const uint8_t *e PLENGTH(e_len), - uint32_t e_len, - const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mod_pow2(cx_bn_t r, + const cx_bn_t a, + const uint8_t *e PLENGTH(e_len), + uint32_t e_len, + const cx_bn_t n); /** * @brief Computes the modular inverse **r = a^(-1) mod n**, @@ -775,7 +792,9 @@ SYSCALL cx_err_t cx_bn_mod_pow2(cx_bn_t r, * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_mod_invert_nprime(cx_bn_t r, const cx_bn_t a, const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mod_invert_nprime(cx_bn_t r, + const cx_bn_t a, + const cx_bn_t n); /** * @brief Computes the modular inverse **r = a^(-1) mod n**, @@ -799,7 +818,7 @@ SYSCALL cx_err_t cx_bn_mod_invert_nprime(cx_bn_t r, const cx_bn_t a, const cx_bn * - CX_INTERNAL_ERROR * - CX_NOT_INVERTIBLE */ -SYSCALL cx_err_t cx_bn_mod_u32_invert(cx_bn_t r, uint32_t a, cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_mod_u32_invert(cx_bn_t r, uint32_t a, cx_bn_t n); /* ========================================================================= */ /* === MONTGOMERY MODULAR ARITHMETIC === */ @@ -817,8 +836,8 @@ SYSCALL cx_err_t cx_bn_mod_u32_invert(cx_bn_t r, uint32_t a, cx_bn_t n); * - CX_NOT_LOCKED * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_mont_alloc(cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t)), - size_t length); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_mont_alloc(cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t)), size_t length); /** * @brief Initializes a Montgomery context with the modulus. @@ -835,8 +854,8 @@ SYSCALL cx_err_t cx_mont_alloc(cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_c * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_mont_init(cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t)), - const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_mont_init(cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t)), const cx_bn_t n); /** * @brief Initializes a Montgomery context with the modulus and @@ -858,9 +877,10 @@ SYSCALL cx_err_t cx_mont_init(cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ct * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_mont_init2(cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t)), - const cx_bn_t n, - const cx_bn_t h); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_mont_init2(cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t)), + const cx_bn_t n, + const cx_bn_t h); /** * @brief Computes the Montgomery representation of a BN value. @@ -880,7 +900,7 @@ SYSCALL cx_err_t cx_mont_init2(cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_c * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_mont_to_montgomery(cx_bn_t x, const cx_bn_t z, const cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t))); @@ -905,7 +925,7 @@ cx_mont_to_montgomery(cx_bn_t x, * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_mont_from_montgomery(cx_bn_t z, const cx_bn_t x, const cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t))); @@ -929,10 +949,11 @@ cx_mont_from_montgomery(cx_bn_t z, * - CX_NOT_LOCKED * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_mont_mul(cx_bn_t r, - const cx_bn_t a, - const cx_bn_t b, - const cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_mont_mul(cx_bn_t r, + const cx_bn_t a, + const cx_bn_t b, + const cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t))); /** * @brief Performs a modular exponentiation **r = a^e mod n**. @@ -959,11 +980,12 @@ SYSCALL cx_err_t cx_mont_mul(cx_bn_t r, * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_mont_pow(cx_bn_t r, - const cx_bn_t a, - const uint8_t *e PLENGTH(e_len), - uint32_t e_len, - const cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_mont_pow(cx_bn_t r, + const cx_bn_t a, + const uint8_t *e PLENGTH(e_len), + uint32_t e_len, + const cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t))); /** * @brief Performs a modular exponentiation **r = a^e mod n**. @@ -988,10 +1010,11 @@ SYSCALL cx_err_t cx_mont_pow(cx_bn_t r, * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_mont_pow_bn(cx_bn_t r, - const cx_bn_t a, - const cx_bn_t e, - const cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_mont_pow_bn(cx_bn_t r, + const cx_bn_t a, + const cx_bn_t e, + const cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t))); /** * @brief Computes the modular inverse **r = a^(-1) mod n** for @@ -1014,7 +1037,7 @@ SYSCALL cx_err_t cx_mont_pow_bn(cx_bn_t r, * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_mont_invert_nprime(cx_bn_t r, const cx_bn_t a, const cx_bn_mont_ctx_t *ctx PLENGTH(sizeof(cx_bn_mont_ctx_t))); @@ -1038,7 +1061,7 @@ cx_mont_invert_nprime(cx_bn_t r, * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_is_prime(const cx_bn_t n, bool *prime); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_is_prime(const cx_bn_t n, bool *prime); /** * @brief Gets the first prime number after a @@ -1053,7 +1076,7 @@ SYSCALL cx_err_t cx_bn_is_prime(const cx_bn_t n, bool *prime); * - CX_MEMORY_FULL * - CX_OVERFLOW */ -SYSCALL cx_err_t cx_bn_next_prime(cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_next_prime(cx_bn_t n); /** * @brief Generates a random number *r* in the range ]0,n[. @@ -1070,7 +1093,7 @@ SYSCALL cx_err_t cx_bn_next_prime(cx_bn_t n); * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_rng(cx_bn_t r, const cx_bn_t n); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_rng(cx_bn_t r, const cx_bn_t n); /** * @brief Performs a multiplication over GF(2^n). @@ -1093,10 +1116,10 @@ SYSCALL cx_err_t cx_bn_rng(cx_bn_t r, const cx_bn_t n); * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_bn_gf2_n_mul(cx_bn_t bn_r, - const cx_bn_t bn_a, - const cx_bn_t bn_b, - const cx_bn_t bn_n, - const cx_bn_t bn_h); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_bn_gf2_n_mul(cx_bn_t bn_r, + const cx_bn_t bn_a, + const cx_bn_t bn_b, + const cx_bn_t bn_n, + const cx_bn_t bn_h); #endif /* CX_BN_H */ diff --git a/include/ox_ec.h b/include/ox_ec.h index 2656478d8..3078dd803 100644 --- a/include/ox_ec.h +++ b/include/ox_ec.h @@ -400,7 +400,7 @@ typedef enum cx_curve_dom_param_s cx_curve_dom_param_t; * - CX_OK on success * - CX_EC_INVALID_CURVE */ -SYSCALL cx_err_t cx_ecdomain_size(cx_curve_t curve, size_t *length); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecdomain_size(cx_curve_t curve, size_t *length); /** * @brief Gets the byte length of each parameter of the curve. @@ -413,7 +413,7 @@ SYSCALL cx_err_t cx_ecdomain_size(cx_curve_t curve, size_t *length); * - CX_OK on success * - CX_EC_INVALID_CURVE */ -SYSCALL cx_err_t cx_ecdomain_parameters_length(cx_curve_t cv, size_t *length); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecdomain_parameters_length(cx_curve_t cv, size_t *length); /** * @brief Gets a specific parameter of the curve. @@ -431,10 +431,10 @@ SYSCALL cx_err_t cx_ecdomain_parameters_length(cx_curve_t cv, size_t *length); * - CX_EC_INVALID_CURVE * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_ecdomain_parameter(cx_curve_t cv, - cx_curve_dom_param_t id, - uint8_t *p PLENGTH(p_len), - uint32_t p_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecdomain_parameter(cx_curve_t cv, + cx_curve_dom_param_t id, + uint8_t *p PLENGTH(p_len), + uint32_t p_len); /** * @brief Stores a specific parameter of the curve as a BN. @@ -452,7 +452,9 @@ SYSCALL cx_err_t cx_ecdomain_parameter(cx_curve_t cv, * - CX_INVALID_PARAMETER * - CX_INVALID_PARAMETER_SIZE */ -SYSCALL cx_err_t cx_ecdomain_parameter_bn(cx_curve_t cv, cx_curve_dom_param_t id, cx_bn_t p); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecdomain_parameter_bn(cx_curve_t cv, + cx_curve_dom_param_t id, + cx_bn_t p); /** * @brief Gets the generator of the curve. @@ -470,10 +472,10 @@ SYSCALL cx_err_t cx_ecdomain_parameter_bn(cx_curve_t cv, cx_curve_dom_param_t id * - CX_EC_INVALID_CURVE * - CX_INVALID_PARAMETER */ -SYSCALL cx_err_t cx_ecdomain_generator(cx_curve_t cv, - uint8_t *Gx PLENGTH(len), - uint8_t *Gy PLENGTH(len), - size_t len); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecdomain_generator(cx_curve_t cv, + uint8_t *Gx PLENGTH(len), + uint8_t *Gy PLENGTH(len), + size_t len); /** * @brief Gets the generator of the curve and stores it in the point structure. @@ -490,8 +492,8 @@ SYSCALL cx_err_t cx_ecdomain_generator(cx_curve_t cv, * - CX_INVALID_PARAMETER_SIZE * - CX_EC_INVALID_POINT */ -SYSCALL cx_err_t cx_ecdomain_generator_bn(cx_curve_t cv, - cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecdomain_generator_bn(cx_curve_t cv, cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t))); /** * @brief Allocates memory for a point on the curve. @@ -507,7 +509,8 @@ SYSCALL cx_err_t cx_ecdomain_generator_bn(cx_curve_t cv, * - CX_INVALID_PARAMETER * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_alloc(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), cx_curve_t cv); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecpoint_alloc(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + cx_curve_t cv); /** * @brief Destroys a point on the curve. @@ -521,7 +524,8 @@ SYSCALL cx_err_t cx_ecpoint_alloc(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), * - CX_INVALID_PARAMETER * - CX_INTERNAL_ERROR */ -SYSCALL cx_err_t cx_ecpoint_destroy(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_destroy(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t))); /** * @brief Initializes a point on the curve. @@ -544,11 +548,11 @@ SYSCALL cx_err_t cx_ecpoint_destroy(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t) * - CX_INVALID_PARAMETER * - CX_EC_INVALID_CURVE */ -SYSCALL cx_err_t cx_ecpoint_init(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const uint8_t *x PLENGTH(x_len), - size_t x_len, - const uint8_t *y PLENGTH(y_len), - size_t y_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecpoint_init(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + const uint8_t *x PLENGTH(x_len), + size_t x_len, + const uint8_t *y PLENGTH(y_len), + size_t y_len); /** * @brief Initializes a point on the curve with the BN indexes of the coordinates. @@ -567,9 +571,8 @@ SYSCALL cx_err_t cx_ecpoint_init(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), * - CX_INVALID_PARAMETER * - CX_EC_INVALID_CURVE */ -SYSCALL cx_err_t cx_ecpoint_init_bn(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const cx_bn_t x, - const cx_bn_t y); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_init_bn(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), const cx_bn_t x, const cx_bn_t y); /** * @brief Exports a point. @@ -596,11 +599,12 @@ SYSCALL cx_err_t cx_ecpoint_init_bn(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t) * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_export(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - uint8_t *x PLENGTH(x_len), - size_t x_len, - uint8_t *y PLENGTH(y_len), - size_t y_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_export(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + uint8_t *x PLENGTH(x_len), + size_t x_len, + uint8_t *y PLENGTH(y_len), + size_t y_len); /** * @brief Exports a point using BN indexes of the coordinates. @@ -619,9 +623,10 @@ SYSCALL cx_err_t cx_ecpoint_export(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoi * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_export_bn(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - cx_bn_t *x PLENGTH(sizeof(cx_bn_t)), - cx_bn_t *y PLENGTH(sizeof(cx_bn_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_export_bn(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + cx_bn_t *x PLENGTH(sizeof(cx_bn_t)), + cx_bn_t *y PLENGTH(sizeof(cx_bn_t))); /** * @brief Computes the compressed form of a point. @@ -653,10 +658,11 @@ SYSCALL cx_err_t cx_ecpoint_export_bn(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ec * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_compress(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - uint8_t *xy_compressed PLENGTH(xy_compressed_len), - size_t xy_compressed_len, - uint32_t *sign); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_compress(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + uint8_t *xy_compressed PLENGTH(xy_compressed_len), + size_t xy_compressed_len, + uint32_t *sign); /** * @brief Computes the affine coordinates of a point given its compressed form. @@ -680,10 +686,11 @@ SYSCALL cx_err_t cx_ecpoint_compress(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ec * - CX_NO_RESIDUE * */ -SYSCALL cx_err_t cx_ecpoint_decompress(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const uint8_t *xy_compressed PLENGTH(xy_compressed_len), - size_t xy_compressed_len, - uint32_t sign); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_decompress(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + const uint8_t *xy_compressed PLENGTH(xy_compressed_len), + size_t xy_compressed_len, + uint32_t sign); /** * @brief Adds two points on a curve. @@ -709,9 +716,10 @@ SYSCALL cx_err_t cx_ecpoint_decompress(cx_ecpoint_t *P PLENGTH(size * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_add(cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), - const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const cx_ecpoint_t *Q PLENGTH(sizeof(cx_ecpoint_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_add(cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), + const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + const cx_ecpoint_t *Q PLENGTH(sizeof(cx_ecpoint_t))); /** * @brief Computes the opposite of a point. @@ -732,7 +740,7 @@ SYSCALL cx_err_t cx_ecpoint_add(cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_ * - CX_MEMORY_FULL * - CX_EC_INFINITE_POINT */ -SYSCALL cx_err_t cx_ecpoint_neg(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecpoint_neg(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t))); /** * @brief Performs a secure scalar multiplication. @@ -753,9 +761,10 @@ SYSCALL cx_err_t cx_ecpoint_neg(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t))); * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_rnd_scalarmul(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const uint8_t *k PLENGTH(k_len), - size_t k_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_rnd_scalarmul(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + const uint8_t *k PLENGTH(k_len), + size_t k_len); /** * @brief Performs a secure scalar multiplication given the BN index of the scalar. @@ -774,8 +783,9 @@ SYSCALL cx_err_t cx_ecpoint_rnd_scalarmul(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecp * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_rnd_scalarmul_bn(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const cx_bn_t bn_k PLENGTH(sizeof(cx_bn_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_rnd_scalarmul_bn(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + const cx_bn_t bn_k PLENGTH(sizeof(cx_bn_t))); /** * @brief Performs a secure scalar multiplication with a fixed scalar length. @@ -796,9 +806,10 @@ SYSCALL cx_err_t cx_ecpoint_rnd_scalarmul_bn(cx_ecpoint_t *P PLENGTH(sizeof(c * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_rnd_fixed_scalarmul(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const uint8_t *k PLENGTH(k_len), - size_t k_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_rnd_fixed_scalarmul(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + const uint8_t *k PLENGTH(k_len), + size_t k_len); /** * @brief Performs a scalar multiplication. @@ -823,9 +834,10 @@ SYSCALL cx_err_t cx_ecpoint_rnd_fixed_scalarmul(cx_ecpoint_t *P PLENGTH(sizeof( * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_scalarmul(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const uint8_t *k PLENGTH(k_len), - size_t k_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_scalarmul(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + const uint8_t *k PLENGTH(k_len), + size_t k_len); /** * @brief Performs a scalar multiplication given the BN index of the scalar. @@ -848,8 +860,9 @@ SYSCALL cx_err_t cx_ecpoint_scalarmul(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_scalarmul_bn(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const cx_bn_t bn_k PLENGTH(sizeof(cx_bn_t))); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_scalarmul_bn(cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + const cx_bn_t bn_k PLENGTH(sizeof(cx_bn_t))); /** * @brief Performs a double scalar multiplication. @@ -880,13 +893,14 @@ SYSCALL cx_err_t cx_ecpoint_scalarmul_bn(cx_ecpoint_t *P PLENGTH(sizeof(cx_ec * - CX_MEMORY_FULL * - CX_EC_INFINITE_POINT */ -SYSCALL cx_err_t cx_ecpoint_double_scalarmul(cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), - cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - cx_ecpoint_t *Q PLENGTH(sizeof(cx_ecpoint_t)), - const uint8_t *k PLENGTH(k_len), - size_t k_len, - const uint8_t *r PLENGTH(r_len), - size_t r_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_double_scalarmul(cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), + cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + cx_ecpoint_t *Q PLENGTH(sizeof(cx_ecpoint_t)), + const uint8_t *k PLENGTH(k_len), + size_t k_len, + const uint8_t *r PLENGTH(r_len), + size_t r_len); /** * @brief Performs a double scalar multiplication @@ -914,11 +928,12 @@ SYSCALL cx_err_t cx_ecpoint_double_scalarmul(cx_ecpoint_t *R PLENGTH(sizeof(cx_ * - CX_MEMORY_FULL * - CX_EC_INFINITE_POINT */ -SYSCALL cx_err_t cx_ecpoint_double_scalarmul_bn(cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), - cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - cx_ecpoint_t *Q PLENGTH(sizeof(cx_ecpoint_t)), - const cx_bn_t bn_k, - const cx_bn_t bn_r); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_double_scalarmul_bn(cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), + cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + cx_ecpoint_t *Q PLENGTH(sizeof(cx_ecpoint_t)), + const cx_bn_t bn_k, + const cx_bn_t bn_r); /** * @brief Compares two points on the same curve. @@ -939,9 +954,10 @@ SYSCALL cx_err_t cx_ecpoint_double_scalarmul_bn(cx_ecpoint_t *R PLENGTH(sizeof(c * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_cmp(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), - const cx_ecpoint_t *Q PLENGTH(sizeof(cx_ecpoint_t)), - bool *is_equal); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_cmp(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_t)), + const cx_ecpoint_t *Q PLENGTH(sizeof(cx_ecpoint_t)), + bool *is_equal); /** * @brief Checks whether a given point is on the curve. @@ -960,8 +976,8 @@ SYSCALL cx_err_t cx_ecpoint_cmp(const cx_ecpoint_t *P PLENGTH(sizeof(cx_ecpoint_ * - CX_EC_INFINITE_POINT * - CX_MEMORY_FULL */ -SYSCALL cx_err_t cx_ecpoint_is_on_curve(const cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), - bool *is_on_curve); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_is_on_curve(const cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), bool *is_on_curve); /** * @brief Checks whether a given point is the point at infinity. @@ -980,8 +996,9 @@ SYSCALL cx_err_t cx_ecpoint_is_on_curve(const cx_ecpoint_t *R PLENGTH(sizeof(cx_ * - CX_INVALID_PARAMETER * - CX_EC_INVALID_CURVE */ -SYSCALL cx_err_t cx_ecpoint_is_at_infinity(const cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), - bool *is_at_infinity); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_ecpoint_is_at_infinity(const cx_ecpoint_t *R PLENGTH(sizeof(cx_ecpoint_t)), + bool *is_at_infinity); #ifdef HAVE_X25519 /** @@ -1006,7 +1023,9 @@ SYSCALL cx_err_t cx_ecpoint_is_at_infinity(const cx_ecpoint_t *R PLENGTH(sizeof( * - CX_MEMORY_FULL * */ -SYSCALL cx_err_t cx_ecpoint_x25519(const cx_bn_t bn_u, const uint8_t *k, size_t k_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecpoint_x25519(const cx_bn_t bn_u, + const uint8_t *k, + size_t k_len); #endif // HAVE_X25519 #ifdef HAVE_X448 @@ -1032,7 +1051,9 @@ SYSCALL cx_err_t cx_ecpoint_x25519(const cx_bn_t bn_u, const uint8_t *k, size_t * - CX_MEMORY_FULL * */ -SYSCALL cx_err_t cx_ecpoint_x448(const cx_bn_t bn_u, const uint8_t *k, size_t k_len); +SYSCALL WARN_UNUSED_RESULT cx_err_t cx_ecpoint_x448(const cx_bn_t bn_u, + const uint8_t *k, + size_t k_len); #endif // HAVE_X448 #endif diff --git a/include/ox_vss.h b/include/ox_vss.h index cdaa34586..730e5af60 100644 --- a/include/ox_vss.h +++ b/include/ox_vss.h @@ -49,16 +49,17 @@ typedef struct { * @param[in] threshold Threshold of the secret sharing. * @return Error code */ -SYSCALL cx_err_t cx_vss_generate_shares(cx_vss_share_t *shares PLENGTH(shares_number), - cx_vss_commitment_t *commits PLENGTH(threshold), - const uint8_t *point, - size_t point_len, - const uint8_t *seed PLENGTH(seed_len), - size_t seed_len, - const uint8_t *secret PLENGTH(secret_len), - size_t secret_len, - uint8_t shares_number, - uint8_t threshold); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_vss_generate_shares(cx_vss_share_t *shares PLENGTH(shares_number), + cx_vss_commitment_t *commits PLENGTH(threshold), + const uint8_t *point, + size_t point_len, + const uint8_t *seed PLENGTH(seed_len), + size_t seed_len, + const uint8_t *secret PLENGTH(secret_len), + size_t secret_len, + uint8_t shares_number, + uint8_t threshold); /** * @brief This functions combines the given shares to get a secret. @@ -69,10 +70,11 @@ SYSCALL cx_err_t cx_vss_generate_shares(cx_vss_share_t *shares PLENGTH(sha * @param[in] threshold Threshold of the secret sharing. * @return Error code */ -SYSCALL cx_err_t cx_vss_combine_shares(uint8_t *secret PLENGTH(secret_len), - size_t secret_len, - cx_vss_share_t *shares PLENGTH(sizeof(cx_vss_share_t)), - uint8_t threshold); +SYSCALL WARN_UNUSED_RESULT cx_err_t +cx_vss_combine_shares(uint8_t *secret PLENGTH(secret_len), + size_t secret_len, + cx_vss_share_t *shares PLENGTH(sizeof(cx_vss_share_t)), + uint8_t threshold); #endif /* OX_VSS_H */ #endif // HAVE_VSS