faster comparison

parent 156d2ed4
Pipeline #1351 passed with stage
in 1 minute and 25 seconds
......@@ -23,13 +23,13 @@ case "$host" in
flags="$CFLAGS"
fastflags="-O3 -mfpu=neon $nomflags"
enable_fast=yes
CFLAGS=""
CFLAGS="-O3"
;;
i686-*linux*|i686-*cygwin*)
flags="$CFLAGS"
fastflags="-O3 -m32 -mssse3 $nomflags"
enable_fast=yes
CFLAGS=""
CFLAGS="-O3 -m32"
;;
i686-*)
# if you don't want sse, specify i586-linux-gnu
......
......@@ -8,7 +8,7 @@
Bo-Yin Yang
*/
#include <assert.h>
#include "ed25519-donna-portable.h"
#if defined(ED25519_SSE2)
......@@ -64,15 +64,18 @@ typedef unsigned char hash_512bits[64];
/*
Timing safe memory compare
*/
static int
ed25519_verify(const unsigned char *x, const unsigned char *y, size_t len) {
size_t differentbits = 0;
while (len--)
differentbits |= (*x++ ^ *y++);
return (int) (1 & ((differentbits - 1) >> 8));
static inline int ed25519_verify(long* a, long* b, size_t len) {
long diff=0;
assert(len == 32);
switch(sizeof(long)) {
case 4:
diff|=((a[4]^b[4])|(a[5]^b[5])|(a[6]^b[6])|(a[7]^b[7]));
case 8:
diff|=((a[0]^b[0])|(a[1]^b[1])|(a[2]^b[2])|(a[3]^b[3]));
}
return -(diff==0);
}
/*
* Arithmetic on the twisted Edwards curve -x^2 + y^2 = 1 + dx^2y^2
* with d = -(121665/121666) = 37095705934669439343138083508754565189542113879843219016388785533085940283555
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment