ble_mesh: Format source and header files of tinycrypt

This commit is contained in:
lly 2020-06-08 18:16:43 +08:00 committed by bot
parent f1f3c7afd6
commit 3c0584f013
28 changed files with 2128 additions and 2123 deletions

View file

@ -609,8 +609,7 @@ void vli_mmod_fast_secp256r1(unsigned int *result, unsigned int*product)
if (carry < 0) {
do {
carry += uECC_vli_add(result, result, curve_secp256r1.p, NUM_ECC_WORDS);
}
while (carry < 0);
} while (carry < 0);
} else {
while (carry ||
uECC_vli_cmp_unsafe(curve_secp256r1.p, result, NUM_ECC_WORDS) != 1) {
@ -881,8 +880,9 @@ int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve)
curve->x_side(tmp2, point, curve); /* tmp2 = x^3 + ax + b */
/* Make sure that y^2 == x^3 + ax + b */
if (uECC_vli_equal(tmp1, tmp2, num_words) != 0)
if (uECC_vli_equal(tmp1, tmp2, num_words) != 0) {
return -3;
}
return 0;
}

View file

@ -127,8 +127,7 @@ int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash,
if (!g_rng_function) {
uECC_vli_clear(tmp, num_n_words);
tmp[0] = 1;
}
else if (!uECC_generate_random_int(tmp, curve->n, num_n_words)) {
} else if (!uECC_generate_random_int(tmp, curve->n, num_n_words)) {
return 0;
}

View file

@ -71,11 +71,13 @@
#define O_CLOEXEC 0
#endif
int default_CSPRNG(uint8_t *dest, unsigned int size) {
int default_CSPRNG(uint8_t *dest, unsigned int size)
{
/* input sanity check: */
if (dest == (uint8_t *) 0 || (size <= 0))
if (dest == (uint8_t *) 0 || (size <= 0)) {
return 0;
}
int fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
if (fd == -1) {

View file

@ -88,10 +88,12 @@ static void update(TCHmacPrng_t prng, const uint8_t *data, unsigned int datalen,
(void)tc_hmac_update(&prng->h, prng->v, sizeof(prng->v));
(void)tc_hmac_update(&prng->h, &separator0, sizeof(separator0));
if (data && datalen)
if (data && datalen) {
(void)tc_hmac_update(&prng->h, data, datalen);
if (additional_data && additional_datalen)
}
if (additional_data && additional_datalen) {
(void)tc_hmac_update(&prng->h, additional_data, additional_datalen);
}
(void)tc_hmac_final(prng->key, sizeof(prng->key), &prng->h);
@ -103,8 +105,9 @@ static void update(TCHmacPrng_t prng, const uint8_t *data, unsigned int datalen,
(void)tc_hmac_update(&prng->h, prng->v, sizeof(prng->v));
(void)tc_hmac_final(prng->v, sizeof(prng->v), &prng->h);
if (data == 0 || datalen == 0)
if (data == 0 || datalen == 0) {
return;
}
/* configure the new prng key into the prng's instance of hmac */
tc_hmac_set_key(&prng->h, prng->key, sizeof(prng->key));
@ -114,8 +117,9 @@ static void update(TCHmacPrng_t prng, const uint8_t *data, unsigned int datalen,
(void)tc_hmac_update(&prng->h, prng->v, sizeof(prng->v));
(void)tc_hmac_update(&prng->h, &separator1, sizeof(separator1));
(void)tc_hmac_update(&prng->h, data, datalen);
if (additional_data && additional_datalen)
if (additional_data && additional_datalen) {
(void)tc_hmac_update(&prng->h, additional_data, additional_datalen);
}
(void)tc_hmac_final(prng->key, sizeof(prng->key), &prng->h);
/* configure the new prng key into the prng's instance of hmac */