Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we're not using an uninitialized variable in secp256k1_wnaf_const(...) #533

Merged
merged 1 commit into from May 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/ecmult_const_impl.h
Expand Up @@ -61,6 +61,10 @@ static int secp256k1_wnaf_const(int *wnaf, secp256k1_scalar s, int w, int size)
int bit;
secp256k1_scalar neg_s;
int not_neg_one;

VERIFY_CHECK(w > 0);
VERIFY_CHECK(size > 0);

/* Note that we cannot handle even numbers by negating them to be odd, as is
* done in other implementations, since if our scalars were specified to have
* width < 256 for performance reasons, their negations would have width 256
Expand Down Expand Up @@ -93,7 +97,7 @@ static int secp256k1_wnaf_const(int *wnaf, secp256k1_scalar s, int w, int size)

/* 4 */
u_last = secp256k1_scalar_shr_int(&s, w);
while (word * w < size) {
do {
int sign;
int even;

Expand All @@ -109,7 +113,7 @@ static int secp256k1_wnaf_const(int *wnaf, secp256k1_scalar s, int w, int size)
wnaf[word++] = u_last * global_sign;

u_last = u;
}
} while (word * w < size);
wnaf[word] = u * global_sign;

VERIFY_CHECK(secp256k1_scalar_is_zero(&s));
Expand Down