Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion mars/xlog/crypt/decode_log_file_c_impl/micro-ecc-master/uECC.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ static int uECC_sign_with_k(const uint8_t* private_key,
uECC_word_t tmp[uECC_MAX_WORDS];
uECC_word_t s[uECC_MAX_WORDS];
uECC_word_t* k2[2] = {tmp, s};
uECC_word_t *initial_Z = 0;
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
uECC_word_t* p = (uECC_word_t*)signature;
#else
Expand All @@ -1180,7 +1181,15 @@ static int uECC_sign_with_k(const uint8_t* private_key,
}

carry = regularize_k(k, tmp, s, curve);
EccPoint_mult(p, curve->G, k2[!carry], 0, num_n_bits + 1, curve);
/* If an RNG function was specified, try to get a random initial Z value to improve
protection against side-channel attacks. */
if (g_rng_function) {
if (!uECC_generate_random_int(k2[carry], curve->p, num_words)) {
return 0;
}
initial_Z = k2[carry];
}
EccPoint_mult(p, curve->G, k2[!carry], initial_Z, num_n_bits + 1, curve);
if (uECC_vli_isZero(p, num_words)) {
return 0;
}
Expand Down