Fix curve25519 code for MSVC.
MSVC doesn't like unary minus on unsigned types. Also, the speed test always failed because the inputs were all zeros and thus had small order. Change-Id: Ic2d3c2c9bd57dc66295d93891396871cebac1e0b
This commit is contained in:
parent
4fb0dc4b03
commit
3ac32b1eda
@ -231,7 +231,7 @@ static void fe_1(fe h) {
|
||||
*
|
||||
* Preconditions: b in {0,1}. */
|
||||
static void fe_cswap(fe f, fe g, unsigned int b) {
|
||||
b = -b;
|
||||
b = 0-b;
|
||||
unsigned i;
|
||||
for (i = 0; i < 10; i++) {
|
||||
int32_t x = f[i] ^ g[i];
|
||||
@ -807,7 +807,7 @@ static void fe_neg(fe h, const fe f) {
|
||||
*
|
||||
* Preconditions: b in {0,1}. */
|
||||
static void fe_cmov(fe f, const fe g, unsigned b) {
|
||||
b = -b;
|
||||
b = 0-b;
|
||||
unsigned i;
|
||||
for (i = 0; i < 10; i++) {
|
||||
int32_t x = f[i] ^ g[i];
|
||||
|
@ -456,6 +456,8 @@ static bool Speed25519(const std::string &selected) {
|
||||
uint8_t out[32], in1[32], in2[32];
|
||||
memset(in1, 0, sizeof(in1));
|
||||
memset(in2, 0, sizeof(in2));
|
||||
in1[0] = 1;
|
||||
in2[0] = 9;
|
||||
return X25519(out, in1, in2) == 1;
|
||||
})) {
|
||||
fprintf(stderr, "Curve25519 arbitrary point multiplication failed.\n");
|
||||
|
Loading…
Reference in New Issue
Block a user