Change the default value of status variables to an error
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
diff --git a/tinycrypt/ecc.c b/tinycrypt/ecc.c
index c6c722a..8854c23 100644
--- a/tinycrypt/ecc.c
+++ b/tinycrypt/ecc.c
@@ -848,7 +848,7 @@
}
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_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 @@
uECC_vli_nativeToBytes(
public_key +
NUM_ECC_BYTES, NUM_ECC_BYTES, _public + NUM_ECC_WORDS);
- return UECC_SUCCESS;
+ return ret;
}
-
diff --git a/tinycrypt/ecc_dh.c b/tinycrypt/ecc_dh.c
index 1b1ff3f..ceabb00 100644
--- a/tinycrypt/ecc_dh.c
+++ b/tinycrypt/ecc_dh.c
@@ -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 @@
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 @@
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,
diff --git a/tinycrypt/ecc_dsa.c b/tinycrypt/ecc_dsa.c
index 660c5e9..41e1d71 100644
--- a/tinycrypt/ecc_dsa.c
+++ b/tinycrypt/ecc_dsa.c
@@ -89,7 +89,7 @@
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 @@
}
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,