Reduce nesting, improve readability

This commit is contained in:
Frank Denis 2017-11-06 21:55:20 +01:00
parent 1621448f6c
commit f8de352e6d

View File

@ -192,29 +192,30 @@ slide_vartime(signed char *r, const unsigned char *a)
r[i] = 1 & (a[i >> 3] >> (i & 7)); r[i] = 1 & (a[i >> 3] >> (i & 7));
} }
for (i = 0; i < 256; ++i) { for (i = 0; i < 256; ++i) {
if (r[i]) { if (! r[i]) {
for (b = 1; b <= 6 && i + b < 256; ++b) { continue;
if (r[i + b]) { }
ribs = r[i + b] << b; for (b = 1; b <= 6 && i + b < 256; ++b) {
cmp = r[i] + ribs; if (! r[i + b]) {
if (cmp <= 15) { continue;
r[i] = cmp; }
r[i + b] = 0; ribs = r[i + b] << b;
} else { cmp = r[i] + ribs;
cmp = r[i] - ribs; if (cmp <= 15) {
if (cmp >= -15) { r[i] = cmp;
r[i] = cmp; r[i + b] = 0;
for (k = i + b; k < 256; ++k) { } else {
if (!r[k]) { cmp = r[i] - ribs;
r[k] = 1; if (cmp < -15) {
break; break;
} }
r[k] = 0; r[i] = cmp;
} for (k = i + b; k < 256; ++k) {
} else { if (! r[k]) {
break; r[k] = 1;
} break;
} }
r[k] = 0;
} }
} }
} }