Skip to content

Commit 3863670

Browse files
author
Shingo Morimoto
committed
Modified Makefile and benchmark variables
-modified Makefile to execute clean target before building. -modified Makefile to add CFLAGS for sp_x86_64. -fixed BENCH_TIME_SEC possible to be defined by compiler flags.
1 parent f900379 commit 3863670

File tree

6 files changed

+30
-20
lines changed

6 files changed

+30
-20
lines changed

embedded/signature/ecc-sign-verify/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ OBJ_TFM := \
3939

4040
ifeq ($(math) $(arch),sp x64)
4141
ASFLAGS+= -DSP_X86_64_FLAG
42+
CFLAGS += -DSP_X86_64_FLAG
4243
OBJ += $(OBJ_SP_X86_64)
4344
else ifeq ($(math) $(arch),sp arm64)
4445
CFLAGS += -DSP_ARM64_FLAG
@@ -59,13 +60,13 @@ endif
5960

6061
all : ecc_sign_verify bench mem
6162

62-
ecc_sign_verify: $(OBJ)
63+
ecc_sign_verify: clean $(OBJ)
6364
$(CC) $(CFLAGS) -o ecc_sign_verify ecc_sign_verify.c $(OBJ)
6465

65-
bench: $(OBJ)
66+
bench: clean $(OBJ)
6667
$(CC) $(CFLAGS) -DBENCHMARK -o ecc_sign_verify_bench ecc_sign_verify.c $(OBJ)
6768

68-
mem: $(OBJ)
69+
mem: clean $(OBJ)
6970
$(CC) $(CFLAGS) -DDEBUG_MEMORY -o ecc_sign_verify_mem ecc_sign_verify.c $(OBJ)
7071
clean:
7172
rm -f ecc_sign_verify ecc_sign_verify_bench ecc_sign_verify_mem $(WOLFROOT)/wolfcrypt/src/*.o

embedded/signature/ecc-sign-verify/ecc_sign_verify.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
#define ECC_KEY_SIZE_512 512
4848
#define ECC_KEY_SIZE_521 521
4949
#define BYTE_SZ 8
50-
#define BENCH_TIME_SEC 1
5150
#define CHECK_RET(a, b, eLabel, msg) { \
5251
if (a != b) { \
5352
printf("failed %s\n", msg); \
@@ -62,10 +61,6 @@ int do_sig_ver_test(int eccKeySz);
6261
static void hexdump(const void *buffer, word32 len, byte cols);
6362
#endif
6463

65-
// int ret;
66-
double start_time, total_time;
67-
68-
6964
int ecc_sign_verify(void)
7065
{
7166
int ret = 0;
@@ -121,7 +116,13 @@ int do_sig_ver_test(int eccKeySz)
121116
byte* sig = NULL; // get rid of this magic number
122117
WC_RNG rng;
123118
int verified = 0;
124-
int count; // for the benchmark
119+
120+
/* Variables for Benchmark */
121+
double start_time, total_time;
122+
#ifndef BENCH_TIME_SEC
123+
#define BENCH_TIME_SEC 1
124+
#endif
125+
int count;
125126

126127

127128
/*
@@ -164,7 +165,7 @@ int do_sig_ver_test(int eccKeySz)
164165
count = 0;
165166
start_time = current_time(1);
166167

167-
while( BENCH_TIME_SEC > (total_time = current_time(0) - start_time ) ){
168+
while( (double)BENCH_TIME_SEC > (total_time = current_time(0) - start_time ) ){
168169
#endif
169170
ret = wc_ecc_init(&key);
170171
CHECK_RET(ret, 0, sig_done, "wc_ecc_init()");

embedded/signature/rsa_buffer/Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
WOLFROOT = ../../../../wolfssl
2-
2+
# EX_CFLAGS
33
CFLAGS = $(EX_CFLAGS) -DWOLFSSL_USER_SETTINGS -I. -I$(WOLFROOT) -Os
44
ASFLAGS=-DWOLFSSL_USER_SETTINGS -I. -I$(WOLFROOT)
55

@@ -41,6 +41,7 @@ OBJ_TFM := \
4141

4242
ifeq ($(math) $(arch),sp x64)
4343
ASFLAGS+= -DSP_X86_64_FLAG
44+
CFLAGS += -DSP_X86_64_FLAG
4445
OBJ += $(OBJ_SP_X86_64)
4546
else ifeq ($(math) $(arch),sp arm64)
4647
CFLAGS += -DSP_ARM64_FLAG
@@ -61,13 +62,13 @@ endif
6162

6263
all: verify sign bench mem
6364

64-
verify: $(OBJ)
65+
verify: clean $(OBJ)
6566
$(CC) $(CFLAGS) -o verify verify.c $(OBJ)
66-
sign: $(OBJ)
67+
sign: clean $(OBJ)
6768
$(CC) $(CFLAGS) -o sign sign.c $(OBJ)
68-
bench: $(OBJ)
69+
bench: clean $(OBJ)
6970
$(CC) $(CFLAGS) -DBENCHMARK -o verify_bench verify.c $(OBJ)
70-
mem: $(OBJ)
71+
mem: clean $(OBJ)
7172
$(CC) $(CFLAGS) -DDEBUG_MEMORY -o verify_mem verify.c $(OBJ)
7273
clean:
7374
rm -f sign verify verify_bench verify_mem $(WOLFROOT)/wolfcrypt/src/*.o

embedded/signature/rsa_buffer/verify.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ int verify()
5656
unsigned char decSig[sizeof(rsa_sig_2048)];
5757
word32 decSigLen = 0;
5858

59+
/* Variables for benchmark */
5960
double start, total_time;
61+
#ifndef BENCH_TIME_SEC
6062
#define BENCH_TIME_SEC 3
63+
#endif
6164
int count;
6265

6366
#ifdef DEBUG_MEMORY
@@ -97,7 +100,7 @@ int verify()
97100
printf("Running benchmark...\n");
98101
printf("Please Wait %.2f seconds\n", (double)BENCH_TIME_SEC);
99102
start = current_time(0);// 1 0
100-
while( BENCH_TIME_SEC > (total_time = current_time(0) - start ) ){
103+
while( (double)BENCH_TIME_SEC > (total_time = current_time(0) - start ) ){
101104
#endif
102105
/* Verify the signature by decrypting the value. */
103106
if (ret == 0) {

embedded/signature/rsa_vfy_only/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ OBJ_TFM := \
4242

4343
ifeq ($(math) $(arch),sp x64)
4444
ASFLAGS+= -DSP_X86_64_FLAG
45+
CFLAGS += -DSP_X86_64_FLAG
4546
OBJ += $(OBJ_SP_X86_64)
4647
else ifeq ($(math) $(arch),sp arm64)
4748
CFLAGS += -DSP_ARM64_FLAG
@@ -62,11 +63,11 @@ endif
6263

6364
all: verify bench mem
6465

65-
verify: $(OBJ)
66+
verify: clean $(OBJ)
6667
$(CC) $(CFLAGS) -o verify verify.c $(OBJ)
67-
bench: $(OBJ)
68+
bench: clean $(OBJ)
6869
$(CC) $(CFLAGS) -DBENCHMARK -o verify_bench verify.c $(OBJ)
69-
mem: $(OBJ)
70+
mem: clean $(OBJ)
7071
$(CC) $(CFLAGS) -DDEBUG_MEMORY -o verify_mem verify.c $(OBJ)
7172
clean:
7273
rm -f verify verify_bench verify_mem $(WOLFROOT)/wolfcrypt/src/*.o

embedded/signature/rsa_vfy_only/verify.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,11 @@ int verify()
147147
0x00, 0x04, 0x20, 0x00,
148148
};
149149

150+
/* Variables for a benchmark*/
150151
double start, total_time;
152+
#ifndef BENCH_TIME_SEC
151153
#define BENCH_TIME_SEC 3
154+
#endif
152155
int count;
153156

154157
#ifdef DEBUG_MEMORY
@@ -181,7 +184,7 @@ int verify()
181184
printf("Running benchmark...\n");
182185
printf("Please Wait %.2f seconds\n", (double)BENCH_TIME_SEC);
183186
start = current_time(0);// 1 0
184-
while( BENCH_TIME_SEC > (total_time = current_time(0) - start ) ){
187+
while( (double)BENCH_TIME_SEC > (total_time = current_time(0) - start ) ){
185188
if (ret != 0 ) printf("Invalid signature in benchmark\n");
186189
#endif
187190
/* Verify the signature by decrypting the value. */

0 commit comments

Comments
 (0)