Change the default value of status variables to an error

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
Andrzej Kurek 2020-05-25 11:52:05 -04:00
parent 2d21e3e47b
commit fd56f409b3
No known key found for this signature in database
GPG key ID: 89A90840DC388527
10 changed files with 49 additions and 47 deletions

View file

@ -848,7 +848,7 @@ void vli_mmod_fast_secp256r1(unsigned int *result, unsigned int*product)
}
while (carry < 0);
} else {
while (carry ||
while (carry ||
uECC_vli_cmp_unsafe(curve_p, result) != 1) {
carry -= uECC_vli_sub(result, result, curve_p);
}
@ -1224,7 +1224,7 @@ int uECC_valid_public_key(const uint8_t *public_key)
int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key)
{
int ret;
int ret = UECC_FAULT_DETECTED;
uECC_word_t _private[NUM_ECC_WORDS];
uECC_word_t _public[NUM_ECC_WORDS * 2];
@ -1252,6 +1252,5 @@ int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key)
uECC_vli_nativeToBytes(
public_key +
NUM_ECC_BYTES, NUM_ECC_BYTES, _public + NUM_ECC_WORDS);
return UECC_SUCCESS;
return ret;
}

View file

@ -74,7 +74,7 @@
int uECC_make_key_with_d(uint8_t *public_key, uint8_t *private_key,
unsigned int *d)
{
int ret;
int ret = UECC_FAULT_DETECTED;
uECC_word_t _private[NUM_ECC_WORDS];
uECC_word_t _public[NUM_ECC_WORDS * 2];
@ -109,7 +109,7 @@ exit:
int uECC_make_key(uint8_t *public_key, uint8_t *private_key)
{
int ret;
int ret = UECC_FAULT_DETECTED;
uECC_word_t _random[NUM_ECC_WORDS * 2];
uECC_word_t _private[NUM_ECC_WORDS];
uECC_word_t _public[NUM_ECC_WORDS * 2];
@ -162,7 +162,7 @@ int uECC_shared_secret(const uint8_t *public_key, const uint8_t *private_key,
uECC_word_t _private[NUM_ECC_WORDS];
wordcount_t num_words = NUM_ECC_WORDS;
wordcount_t num_bytes = NUM_ECC_BYTES;
int r;
int r = UECC_FAULT_DETECTED;
/* Converting buffers to correct bit order: */
uECC_vli_bytesToNative(_private,

View file

@ -89,7 +89,7 @@ int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash,
uECC_word_t s[NUM_ECC_WORDS];
uECC_word_t p[NUM_ECC_WORDS * 2];
wordcount_t num_n_words = BITS_TO_WORDS(NUM_ECC_BITS);
int r;
int r = UECC_FAILURE;
/* Make sure 0 < k < curve_n */
@ -136,7 +136,7 @@ int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash,
}
uECC_vli_nativeToBytes(signature + NUM_ECC_BYTES, NUM_ECC_BYTES, s);
return UECC_SUCCESS;
return r;
}
int uECC_sign(const uint8_t *private_key, const uint8_t *message_hash,