Skip to content

Commit

Permalink
Add curve25519_perf
Browse files Browse the repository at this point in the history
  • Loading branch information
Legrandin committed Aug 24, 2024
1 parent f8b32c2 commit ee9a360
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CFLAGS=-Werror -Wall -O3 -g -Wno-unused-const-variable -Wconversion -Wsign-conve

CFLAGS += -fanalyzer

all:: modexp ec_ws_p256 ec_ws_p384 ec_ws_p521 ed25519_perf ed448_perf
all:: modexp ec_ws_p256 ec_ws_p384 ec_ws_p521 ed25519_perf ed448_perf curve25519_perf

ec_ws_p256: ec_ws_p256.c mont.c p256_table.c p384_table.c p521_table.c
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^ -DSYS_BITS=64 -DMAIN
Expand Down Expand Up @@ -36,8 +36,8 @@ p384_table.c: make_ecc_table.py
p521_table.c: make_ecc_table.py
python make_ecc_table.py p521 4 p521_table

x25519: x25519.c multiply_64.c
curve25519_perf: curve25519.c multiply_64.c
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^ -DSYS_BITS=64 -DPROFILE

clean::
rm -f ec_ws_p256 ec_ws_p384 ec_ws_p521 mont.o modexp x25519 ed25519_perf ed448_perf
rm -f ec_ws_p256 ec_ws_p384 ec_ws_p521 mont.o modexp x25519 ed25519_perf ed448_perf curve25519_perf
10 changes: 7 additions & 3 deletions src/curve25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ int main(void)
{
uint8_t pubkey[32];
uint8_t secret[32];
uint8_t out[32];
unsigned i;
int res;
Point *Pin;
Point Pout;

Expand All @@ -251,9 +251,13 @@ int main(void)
secret[i] = pubkey[i] = (uint8_t)((secret[i-1] << 1) | (secret[i-1] >> 7));
}

curve25519_new_point(&Pin, pubkey, 32);
res = curve25519_new_point(&Pin, pubkey, 32);
if (res) {
printf("Error: %d\n", res);
return res;
}

for (i=0; i<10000; i++) {
for (i=0; i<10000 && res == 0; i++) {
curve25519_scalar_internal(&Pout, secret, sizeof secret, Pin);
}

Expand Down

0 comments on commit ee9a360

Please sign in to comment.