Skip to content

Commit b6328e5

Browse files
committed
add wc_encrypt.o as target
add Makefile to make all remove unnecessary files remove trailing spaces
1 parent a322264 commit b6328e5

31 files changed

+160
-1408
lines changed

embedded/signature/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CC = gcc
2+
#CC = clang
3+
SRCROOT = .
4+
ECCSRCDIRS := $(shell ls -d $(SRCROOT)/ecc_*)
5+
RSASRCDIRS := $(shell ls -d $(SRCROOT)/rsa_*)
6+
7+
all: ecc rsa
8+
9+
ecc:
10+
@for d in $(ECCSRCDIRS); do echo $$d ; $(MAKE) -C $$d CC=$(CC) ; done
11+
12+
rsa:
13+
@for d in $(RSASRCDIRS); do echo $$d ; $(MAKE) -C $$d CC=$(CC) ; done
14+
15+
clean: FORCE
16+
@for d in $(ECCSRCDIRS); do echo $$d ; $(MAKE) -C $$d clean; done
17+
@for d in $(RSASRCDIRS); do echo $$d ; $(MAKE) -C $$d clean; done
18+
19+
FORCE:
20+
.PHONY: FORCE

embedded/signature/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ This directory includes the following examples under the sub-directories.Each ha
55
|Scheme|Directory|Description|
66
|---|---|---|
77
|RSA|rsa_sign_verify|sign/verify signature inline |
8-
||rsa_buffer|sign/verify signature|
98
||rsa_vfy_only |verify signature|
109
||rsa_vfy_only_nonblock|verify signature with non-blocking|
11-
|ECDSA|ecc_sign_verify/|sign msg and verify signature|
10+
|ECDSA|ecc_sign_verify|sign msg and verify signature|
1211
||ecc_vfy_only|verify Signature|
1312
||ecc_vfy_only_nonblock|verify signature with non-blocking|
1413

@@ -27,7 +26,6 @@ $ make <Function> math=<Mathlib> arch=<MCU>
2726
|mem|Memory Track on heap and stack usage|
2827
|bench|Performance benchmark|
2928

30-
3129
## Math library
3230
|math|Description|
3331
|---|---|

embedded/signature/ecc_sign_verify/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ OBJ=\
1414
$(WOLFROOT)/wolfcrypt/src/coding.o\
1515
$(WOLFROOT)/wolfcrypt/src/memory.o\
1616
$(WOLFROOT)/wolfcrypt/src/wolfmath.o\
17+
$(WOLFROOT)/wolfcrypt/src/wc_encrypt.o\
1718

1819
OBJ_SP_C32 := \
1920
$(WOLFROOT)/wolfcrypt/src/sp_int.o\
@@ -38,7 +39,7 @@ OBJ_TFM := \
3839

3940
.PHONY: all clean mem size bench
4041

41-
ifeq ($(math) $(arch),sp x64)
42+
ifeq ($(math) $(arch),sp x64)
4243
ASFLAGS+= -DSP_X86_64_FLAG
4344
CFLAGS += -DSP_X86_64_FLAG
4445
OBJ += $(OBJ_SP_X86_64)
@@ -54,15 +55,15 @@ OBJ += $(OBJ_SP_C32)
5455
else ifeq ($(math), tfm)
5556
CFLAGS += -DTFM_FLAG
5657
OBJ += $(OBJ_TFM)
57-
else
58+
else
5859
CFLAGS += -DSP_C64_FLAG
5960
OBJ += $(OBJ_SP_C64)
6061
endif
6162

6263
all : ecc_sign_verify bench mem
6364

6465
ecc_sign_verify: clean $(OBJ)
65-
$(CC) $(CFLAGS) -o ecc_sign_verify ecc_sign_verify.c $(OBJ)
66+
$(CC) $(CFLAGS) -o ecc_sign_verify ecc_sign_verify.c $(OBJ)
6667

6768
bench: clean $(OBJ)
6869
$(CC) $(CFLAGS) -DBENCHMARK -o ecc_sign_verify_bench ecc_sign_verify.c $(OBJ) -lpthread

embedded/signature/ecc_sign_verify/ecc_sign_verify.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ecc_sign_verify.c
22
*
3-
* Copyright (C) 2006-2023 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL. (formerly known as CyaSSL)
66
*
@@ -123,7 +123,7 @@ double start_time, total_time;
123123
#ifndef BENCH_TIME_SEC
124124
#define BENCH_TIME_SEC 1
125125
#endif
126-
int count;
126+
int count;
127127

128128

129129
/*
@@ -154,7 +154,7 @@ double start_time, total_time;
154154
}
155155

156156

157-
157+
158158

159159
ret = wc_InitRng(&rng);
160160
CHECK_RET(ret, 0, key_done, "wc_InitRng()");
@@ -164,7 +164,7 @@ double start_time, total_time;
164164
start_time = current_time(1);
165165

166166
while( (double)BENCH_TIME_SEC > (total_time = current_time(0) - start_time ) ){
167-
#endif
167+
#endif
168168
ret = wc_ecc_init(&key);
169169
CHECK_RET(ret, 0, sig_done, "wc_ecc_init()");
170170

@@ -177,18 +177,18 @@ double start_time, total_time;
177177
hexdump(sig, maxSigSz, 16);
178178
#endif
179179

180-
ret = wc_ecc_verify_hash(sig, maxSigSz, hash, sizeof(hash),
180+
ret = wc_ecc_verify_hash(sig, maxSigSz, hash, sizeof(hash),
181181
&verified, &key);
182182

183183

184184
CHECK_RET(ret, 0, rng_done, "wc_ecc_verify_hash()");
185185
CHECK_RET(verified, 1, rng_done, "verification check");
186186
verified = 0;
187187
maxSigSz = ECC_MAX_SIG_SIZE;
188-
#ifdef BENCHMARK
188+
#ifdef BENCHMARK
189189
count++;
190190
}
191-
191+
192192
printf("ECC Key Size %d %9.2f Cycles/sec\n", eccKeySz, count/total_time);
193193

194194
#else
@@ -243,7 +243,7 @@ int main(){
243243

244244
#ifdef DEBUG_MEMORY
245245
return StackSizeCheck(NULL, (thread_func)ecc_sign_verify);
246-
#else
246+
#else
247247
return ecc_sign_verify();
248248
#endif
249249
}

embedded/signature/ecc_sign_verify/user_settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@
7878

7979
#ifdef BENCHMARK
8080
#undef DEBUG_MEMORY
81-
#endif
81+
#endif

embedded/signature/ecc_vfy_only/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ OBJ=\
1414
$(WOLFROOT)/wolfcrypt/src/coding.o\
1515
$(WOLFROOT)/wolfcrypt/src/memory.o\
1616
$(WOLFROOT)/wolfcrypt/src/wolfmath.o\
17+
$(WOLFROOT)/wolfcrypt/src/wc_encrypt.o\
1718

1819
OBJ_SP_C32 := \
1920
$(WOLFROOT)/wolfcrypt/src/sp_int.o\
@@ -38,7 +39,7 @@ OBJ_TFM := \
3839

3940
.PHONY: all clean mem size bench
4041

41-
ifeq ($(math) $(arch),sp x64)
42+
ifeq ($(math) $(arch),sp x64)
4243
ASFLAGS+= -DSP_X86_64_FLAG
4344
CFLAGS += -DSP_X86_64_FLAG
4445
OBJ += $(OBJ_SP_X86_64)
@@ -54,7 +55,7 @@ OBJ += $(OBJ_SP_C32)
5455
else ifeq ($(math), tfm)
5556
CFLAGS += -DTFM_FLAG
5657
OBJ += $(OBJ_TFM)
57-
else
58+
else
5859
CFLAGS += -DSP_C64_FLAG
5960
OBJ += $(OBJ_SP_C64)
6061
endif
@@ -66,7 +67,7 @@ ecc_verify: clean $(OBJ)
6667
$(CC) $(CFLAGS) -o ecc_verify ecc_verify.c $(OBJ)
6768

6869
bench: clean $(OBJ)
69-
$(CC) $(CFLAGS) -DBENCHMARK -o ecc_verify_bench ecc_verify.c $(OBJ)
70+
$(CC) $(CFLAGS) -DBENCHMARK -o ecc_verify_bench ecc_verify.c $(OBJ)
7071

7172
mem: clean $(OBJ)
7273
$(CC) $(CFLAGS) -DDEBUG_MEMORY -o ecc_verify_mem ecc_verify.c $(OBJ) -lpthread

embedded/signature/ecc_vfy_only/ecc_verify.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ecc_verify.c
22
*
3-
* Copyright (C) 2006-2023 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL. (formerly known as CyaSSL)
66
*
@@ -125,7 +125,7 @@ double start_time, total_time;
125125
#ifndef BENCH_TIME_SEC
126126
#define BENCH_TIME_SEC 1
127127
#endif
128-
int count;
128+
int count;
129129

130130

131131
/*
@@ -147,7 +147,7 @@ double start_time, total_time;
147147
#ifndef BENCHMARK
148148
printf("Key size is %d, byteField = %d\n", eccKeySz, byteField);
149149
#endif
150-
150+
151151

152152
ret = wc_InitRng(&rng);
153153
CHECK_RET(ret, 0, key_done, "wc_InitRng()");
@@ -157,7 +157,7 @@ double start_time, total_time;
157157
start_time = current_time(1);
158158

159159
while( (double)BENCH_TIME_SEC > (total_time = current_time(0) - start_time ) ){
160-
#endif
160+
#endif
161161
ret = wc_ecc_init(&key);
162162
CHECK_RET(ret, 0, sig_done, "wc_ecc_init()");
163163

@@ -171,19 +171,19 @@ double start_time, total_time;
171171

172172
ret = wc_ecc_import_x963(pKeybuff, key_size, &key);
173173
CHECK_RET(ret, 0, rng_done, "wc_ecc_import_x963()");
174-
175174

176-
ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
175+
176+
ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
177177
&verified, &key);
178178

179179
CHECK_RET(ret, 0, rng_done, "wc_ecc_verify_hash()");
180180
CHECK_RET(verified, 1, rng_done, "verification check");
181181
verified = 0;
182182
maxSigSz = ECC_MAX_SIG_SIZE;
183-
#ifdef BENCHMARK
183+
#ifdef BENCHMARK
184184
count++;
185185
}
186-
186+
187187
printf("ECC Key Size %d %9.2f Cycles/sec\n", eccKeySz, count/total_time);
188188

189189
#else
@@ -221,7 +221,7 @@ int main(){
221221

222222
#ifdef DEBUG_MEMORY
223223
return StackSizeCheck(NULL, (thread_func)ecc_verify);
224-
#else
224+
#else
225225
return ecc_verify();
226226
#endif
227227
}
@@ -252,7 +252,7 @@ int idx_key(int keysize){
252252
return 10;
253253
default:
254254
return -1;
255-
}
255+
}
256256

257-
}
257+
}
258258

embedded/signature/ecc_vfy_only_nonblock/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ OBJ=\
1414
$(WOLFROOT)/wolfcrypt/src/coding.o\
1515
$(WOLFROOT)/wolfcrypt/src/memory.o\
1616
$(WOLFROOT)/wolfcrypt/src/wolfmath.o\
17+
$(WOLFROOT)/wolfcrypt/src/wc_encrypt.o\
1718

1819
OBJ_SP_C32 := \
1920
$(WOLFROOT)/wolfcrypt/src/sp_int.o\
@@ -37,7 +38,7 @@ OBJ_TFM := \
3738
$(WOLFROOT)/wolfcrypt/src/tfm.o\
3839

3940

40-
ifeq ($(math) $(arch),sp x64)
41+
ifeq ($(math) $(arch),sp x64)
4142
ASFLAGS+= -DSP_X86_64_FLAG
4243
CFLAGS += -DSP_X86_64_FLAG
4344
OBJ += $(OBJ_SP_X86_64)
@@ -53,7 +54,7 @@ OBJ += $(OBJ_SP_C32)
5354
else ifeq ($(math), tfm)
5455
CFLAGS += -DTFM_FLAG
5556
OBJ += $(OBJ_TFM)
56-
else
57+
else
5758
CFLAGS += -DSP_C64_FLAG
5859
OBJ += $(OBJ_SP_C64)
5960
endif

embedded/signature/ecc_vfy_only_nonblock/ecc_verify_nonblock.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ecc_verify_nonblock.c
22
*
3-
* Copyright (C) 2006-2023 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL. (formerly known as CyaSSL)
66
*
@@ -121,16 +121,16 @@ int do_sig_ver_test(int eccKeySz)
121121

122122
#ifdef NONBLOCK
123123
ecc_nb_ctx_t nb_ctx;
124-
double total_blk_time;
124+
double total_blk_time;
125125
double pre_returned_t; /* previous recent returned time */
126-
double returned_t; /* most recent returned time */
127-
double max_t = -1.0; /* Maximum blocking time */
128-
double min_t = __DBL_MAX__; /* Minimum blocking time */
126+
double returned_t; /* most recent returned time */
127+
double max_t = -1.0; /* Maximum blocking time */
128+
double min_t = __DBL_MAX__; /* Minimum blocking time */
129129
double blocking_t; /* current blocking time */
130-
int blk_count;
131-
130+
int blk_count;
131+
132132
#endif
133-
133+
134134

135135

136136
/*
@@ -152,7 +152,7 @@ int do_sig_ver_test(int eccKeySz)
152152

153153
printf("Key size is %d, byteField = %d\n", eccKeySz, byteField);
154154

155-
155+
156156

157157
ret = wc_InitRng(&rng);
158158
CHECK_RET(ret, 0, key_done, "wc_InitRng()");
@@ -170,7 +170,7 @@ int do_sig_ver_test(int eccKeySz)
170170

171171
ret = wc_ecc_import_x963(pKeybuff, key_size, &key);
172172
CHECK_RET(ret, 0, rng_done, "wc_ecc_import_x963()");
173-
173+
174174

175175
#ifdef NONBLOCK
176176
ret = wc_ecc_set_nonblock(&key, &nb_ctx);
@@ -180,8 +180,8 @@ int do_sig_ver_test(int eccKeySz)
180180
pre_returned_t = current_time(1);
181181

182182
do {
183-
184-
ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
183+
184+
ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
185185
&verified, &key);
186186
returned_t = current_time(0);
187187
blocking_t = returned_t - pre_returned_t;
@@ -198,8 +198,8 @@ int do_sig_ver_test(int eccKeySz)
198198
blk_count++;
199199
} while (ret == FP_WOULDBLOCK);
200200

201-
#else
202-
ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
201+
#else
202+
ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
203203
&verified, &key);
204204
#endif /* NONBLOCK */
205205

@@ -237,7 +237,7 @@ int main(){
237237

238238
#ifdef DEBUG_MEMORY
239239
return StackSizeCheck(NULL, (thread_func)ecc_verify);
240-
#else
240+
#else
241241
return ecc_verify();
242242
#endif
243243
}
@@ -268,7 +268,7 @@ int idx_key(int keysize){
268268
return 10;
269269
default:
270270
return -1;
271-
}
271+
}
272272

273-
}
273+
}
274274

0 commit comments

Comments
 (0)