Skip to content

Commit

Permalink
add wc_encrypt.o as target
Browse files Browse the repository at this point in the history
add Makefile to make all
remove unnecessary files
remove trailing spaces
  • Loading branch information
miyazakh committed Oct 30, 2024
1 parent a322264 commit b6328e5
Show file tree
Hide file tree
Showing 31 changed files with 160 additions and 1,408 deletions.
20 changes: 20 additions & 0 deletions embedded/signature/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CC = gcc
#CC = clang
SRCROOT = .
ECCSRCDIRS := $(shell ls -d $(SRCROOT)/ecc_*)
RSASRCDIRS := $(shell ls -d $(SRCROOT)/rsa_*)

all: ecc rsa

ecc:
@for d in $(ECCSRCDIRS); do echo $$d ; $(MAKE) -C $$d CC=$(CC) ; done

rsa:
@for d in $(RSASRCDIRS); do echo $$d ; $(MAKE) -C $$d CC=$(CC) ; done

clean: FORCE
@for d in $(ECCSRCDIRS); do echo $$d ; $(MAKE) -C $$d clean; done
@for d in $(RSASRCDIRS); do echo $$d ; $(MAKE) -C $$d clean; done

FORCE:
.PHONY: FORCE
4 changes: 1 addition & 3 deletions embedded/signature/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ This directory includes the following examples under the sub-directories.Each ha
|Scheme|Directory|Description|
|---|---|---|
|RSA|rsa_sign_verify|sign/verify signature inline |
||rsa_buffer|sign/verify signature|
||rsa_vfy_only |verify signature|
||rsa_vfy_only_nonblock|verify signature with non-blocking|
|ECDSA|ecc_sign_verify/|sign msg and verify signature|
|ECDSA|ecc_sign_verify|sign msg and verify signature|
||ecc_vfy_only|verify Signature|
||ecc_vfy_only_nonblock|verify signature with non-blocking|

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


## Math library
|math|Description|
|---|---|
Expand Down
7 changes: 4 additions & 3 deletions embedded/signature/ecc_sign_verify/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ OBJ=\
$(WOLFROOT)/wolfcrypt/src/coding.o\
$(WOLFROOT)/wolfcrypt/src/memory.o\
$(WOLFROOT)/wolfcrypt/src/wolfmath.o\
$(WOLFROOT)/wolfcrypt/src/wc_encrypt.o\

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

.PHONY: all clean mem size bench

ifeq ($(math) $(arch),sp x64)
ifeq ($(math) $(arch),sp x64)
ASFLAGS+= -DSP_X86_64_FLAG
CFLAGS += -DSP_X86_64_FLAG
OBJ += $(OBJ_SP_X86_64)
Expand All @@ -54,15 +55,15 @@ OBJ += $(OBJ_SP_C32)
else ifeq ($(math), tfm)
CFLAGS += -DTFM_FLAG
OBJ += $(OBJ_TFM)
else
else
CFLAGS += -DSP_C64_FLAG
OBJ += $(OBJ_SP_C64)
endif

all : ecc_sign_verify bench mem

ecc_sign_verify: clean $(OBJ)
$(CC) $(CFLAGS) -o ecc_sign_verify ecc_sign_verify.c $(OBJ)
$(CC) $(CFLAGS) -o ecc_sign_verify ecc_sign_verify.c $(OBJ)

bench: clean $(OBJ)
$(CC) $(CFLAGS) -DBENCHMARK -o ecc_sign_verify_bench ecc_sign_verify.c $(OBJ) -lpthread
Expand Down
16 changes: 8 additions & 8 deletions embedded/signature/ecc_sign_verify/ecc_sign_verify.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ecc_sign_verify.c
*
* Copyright (C) 2006-2023 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
Expand Down Expand Up @@ -123,7 +123,7 @@ double start_time, total_time;
#ifndef BENCH_TIME_SEC
#define BENCH_TIME_SEC 1
#endif
int count;
int count;


/*
Expand Down Expand Up @@ -154,7 +154,7 @@ double start_time, total_time;
}




ret = wc_InitRng(&rng);
CHECK_RET(ret, 0, key_done, "wc_InitRng()");
Expand All @@ -164,7 +164,7 @@ double start_time, total_time;
start_time = current_time(1);

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

Expand All @@ -177,18 +177,18 @@ double start_time, total_time;
hexdump(sig, maxSigSz, 16);
#endif

ret = wc_ecc_verify_hash(sig, maxSigSz, hash, sizeof(hash),
ret = wc_ecc_verify_hash(sig, maxSigSz, hash, sizeof(hash),
&verified, &key);


CHECK_RET(ret, 0, rng_done, "wc_ecc_verify_hash()");
CHECK_RET(verified, 1, rng_done, "verification check");
verified = 0;
maxSigSz = ECC_MAX_SIG_SIZE;
#ifdef BENCHMARK
#ifdef BENCHMARK
count++;
}

printf("ECC Key Size %d %9.2f Cycles/sec\n", eccKeySz, count/total_time);

#else
Expand Down Expand Up @@ -243,7 +243,7 @@ int main(){

#ifdef DEBUG_MEMORY
return StackSizeCheck(NULL, (thread_func)ecc_sign_verify);
#else
#else
return ecc_sign_verify();
#endif
}
2 changes: 1 addition & 1 deletion embedded/signature/ecc_sign_verify/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@

#ifdef BENCHMARK
#undef DEBUG_MEMORY
#endif
#endif
7 changes: 4 additions & 3 deletions embedded/signature/ecc_vfy_only/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ OBJ=\
$(WOLFROOT)/wolfcrypt/src/coding.o\
$(WOLFROOT)/wolfcrypt/src/memory.o\
$(WOLFROOT)/wolfcrypt/src/wolfmath.o\
$(WOLFROOT)/wolfcrypt/src/wc_encrypt.o\

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

.PHONY: all clean mem size bench

ifeq ($(math) $(arch),sp x64)
ifeq ($(math) $(arch),sp x64)
ASFLAGS+= -DSP_X86_64_FLAG
CFLAGS += -DSP_X86_64_FLAG
OBJ += $(OBJ_SP_X86_64)
Expand All @@ -54,7 +55,7 @@ OBJ += $(OBJ_SP_C32)
else ifeq ($(math), tfm)
CFLAGS += -DTFM_FLAG
OBJ += $(OBJ_TFM)
else
else
CFLAGS += -DSP_C64_FLAG
OBJ += $(OBJ_SP_C64)
endif
Expand All @@ -66,7 +67,7 @@ ecc_verify: clean $(OBJ)
$(CC) $(CFLAGS) -o ecc_verify ecc_verify.c $(OBJ)

bench: clean $(OBJ)
$(CC) $(CFLAGS) -DBENCHMARK -o ecc_verify_bench ecc_verify.c $(OBJ)
$(CC) $(CFLAGS) -DBENCHMARK -o ecc_verify_bench ecc_verify.c $(OBJ)

mem: clean $(OBJ)
$(CC) $(CFLAGS) -DDEBUG_MEMORY -o ecc_verify_mem ecc_verify.c $(OBJ) -lpthread
Expand Down
22 changes: 11 additions & 11 deletions embedded/signature/ecc_vfy_only/ecc_verify.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ecc_verify.c
*
* Copyright (C) 2006-2023 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
Expand Down Expand Up @@ -125,7 +125,7 @@ double start_time, total_time;
#ifndef BENCH_TIME_SEC
#define BENCH_TIME_SEC 1
#endif
int count;
int count;


/*
Expand All @@ -147,7 +147,7 @@ double start_time, total_time;
#ifndef BENCHMARK
printf("Key size is %d, byteField = %d\n", eccKeySz, byteField);
#endif


ret = wc_InitRng(&rng);
CHECK_RET(ret, 0, key_done, "wc_InitRng()");
Expand All @@ -157,7 +157,7 @@ double start_time, total_time;
start_time = current_time(1);

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

Expand All @@ -171,19 +171,19 @@ double start_time, total_time;

ret = wc_ecc_import_x963(pKeybuff, key_size, &key);
CHECK_RET(ret, 0, rng_done, "wc_ecc_import_x963()");


ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),

ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
&verified, &key);

CHECK_RET(ret, 0, rng_done, "wc_ecc_verify_hash()");
CHECK_RET(verified, 1, rng_done, "verification check");
verified = 0;
maxSigSz = ECC_MAX_SIG_SIZE;
#ifdef BENCHMARK
#ifdef BENCHMARK
count++;
}

printf("ECC Key Size %d %9.2f Cycles/sec\n", eccKeySz, count/total_time);

#else
Expand Down Expand Up @@ -221,7 +221,7 @@ int main(){

#ifdef DEBUG_MEMORY
return StackSizeCheck(NULL, (thread_func)ecc_verify);
#else
#else
return ecc_verify();
#endif
}
Expand Down Expand Up @@ -252,7 +252,7 @@ int idx_key(int keysize){
return 10;
default:
return -1;
}
}

}
}

5 changes: 3 additions & 2 deletions embedded/signature/ecc_vfy_only_nonblock/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ OBJ=\
$(WOLFROOT)/wolfcrypt/src/coding.o\
$(WOLFROOT)/wolfcrypt/src/memory.o\
$(WOLFROOT)/wolfcrypt/src/wolfmath.o\
$(WOLFROOT)/wolfcrypt/src/wc_encrypt.o\

OBJ_SP_C32 := \
$(WOLFROOT)/wolfcrypt/src/sp_int.o\
Expand All @@ -37,7 +38,7 @@ OBJ_TFM := \
$(WOLFROOT)/wolfcrypt/src/tfm.o\


ifeq ($(math) $(arch),sp x64)
ifeq ($(math) $(arch),sp x64)
ASFLAGS+= -DSP_X86_64_FLAG
CFLAGS += -DSP_X86_64_FLAG
OBJ += $(OBJ_SP_X86_64)
Expand All @@ -53,7 +54,7 @@ OBJ += $(OBJ_SP_C32)
else ifeq ($(math), tfm)
CFLAGS += -DTFM_FLAG
OBJ += $(OBJ_TFM)
else
else
CFLAGS += -DSP_C64_FLAG
OBJ += $(OBJ_SP_C64)
endif
Expand Down
34 changes: 17 additions & 17 deletions embedded/signature/ecc_vfy_only_nonblock/ecc_verify_nonblock.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ecc_verify_nonblock.c
*
* Copyright (C) 2006-2023 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
Expand Down Expand Up @@ -121,16 +121,16 @@ int do_sig_ver_test(int eccKeySz)

#ifdef NONBLOCK
ecc_nb_ctx_t nb_ctx;
double total_blk_time;
double total_blk_time;
double pre_returned_t; /* previous recent returned time */
double returned_t; /* most recent returned time */
double max_t = -1.0; /* Maximum blocking time */
double min_t = __DBL_MAX__; /* Minimum blocking time */
double returned_t; /* most recent returned time */
double max_t = -1.0; /* Maximum blocking time */
double min_t = __DBL_MAX__; /* Minimum blocking time */
double blocking_t; /* current blocking time */
int blk_count;
int blk_count;

#endif



/*
Expand All @@ -152,7 +152,7 @@ int do_sig_ver_test(int eccKeySz)

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



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

ret = wc_ecc_import_x963(pKeybuff, key_size, &key);
CHECK_RET(ret, 0, rng_done, "wc_ecc_import_x963()");


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

do {
ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),

ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
&verified, &key);
returned_t = current_time(0);
blocking_t = returned_t - pre_returned_t;
Expand All @@ -198,8 +198,8 @@ int do_sig_ver_test(int eccKeySz)
blk_count++;
} while (ret == FP_WOULDBLOCK);

#else
ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
#else
ret = wc_ecc_verify_hash(sig, sig_size, hash, sizeof(hash),
&verified, &key);
#endif /* NONBLOCK */

Expand Down Expand Up @@ -237,7 +237,7 @@ int main(){

#ifdef DEBUG_MEMORY
return StackSizeCheck(NULL, (thread_func)ecc_verify);
#else
#else
return ecc_verify();
#endif
}
Expand Down Expand Up @@ -268,7 +268,7 @@ int idx_key(int keysize){
return 10;
default:
return -1;
}
}

}
}

File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b6328e5

Please sign in to comment.