From c6ab48d9a5ef00cd330700be75914e2ff3ebd2b6 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Tue, 26 Feb 2019 11:15:12 -0700 Subject: [PATCH 1/2] Refactor PK examples out of crypto and mv non-sig specific to pk dir --- .gitignore | 11 +++++++---- {signature => pk}/ED25519/Makefile | 0 {signature => pk}/ED25519/README | 0 {signature => pk}/ED25519/ed_priv_test_key.der | 0 {signature => pk}/ED25519/ed_pub_test_key.der | 0 {signature => pk}/ED25519/gen_key_files.c | 0 {signature => pk}/ED25519/genkeybuffers.pl | 0 {signature => pk}/ED25519/sign_and_verify.c | 0 {signature => pk}/ED25519/test_keys.h | 0 {crypto/keys => pk/ecc}/Makefile | 0 {crypto/keys => pk/ecc}/README | 0 {crypto/keys => pk/ecc}/ecc_keys.c | 0 .../enc-through-sign-rsa}/README.md | 0 .../enc-through-sign-rsa}/build.sh | 0 .../enc-through-sign-rsa}/rsa-private-encrypt-app.c | 0 .../enc-through-sign-rsa}/rsa-public-decrypt-app.c | 0 {crypto => pk}/rsa-pss/Makefile | 0 {crypto => pk}/rsa-pss/README.md | 0 {crypto => pk}/rsa-pss/rsa-pss.c | 0 {crypto => pk}/rsa/Makefile | 0 {crypto => pk}/rsa/README.md | 0 {crypto => pk}/rsa/rsa-nb.c | 4 ++-- 22 files changed, 9 insertions(+), 6 deletions(-) rename {signature => pk}/ED25519/Makefile (100%) rename {signature => pk}/ED25519/README (100%) rename {signature => pk}/ED25519/ed_priv_test_key.der (100%) rename {signature => pk}/ED25519/ed_pub_test_key.der (100%) rename {signature => pk}/ED25519/gen_key_files.c (100%) rename {signature => pk}/ED25519/genkeybuffers.pl (100%) rename {signature => pk}/ED25519/sign_and_verify.c (100%) rename {signature => pk}/ED25519/test_keys.h (100%) rename {crypto/keys => pk/ecc}/Makefile (100%) rename {crypto/keys => pk/ecc}/README (100%) rename {crypto/keys => pk/ecc}/ecc_keys.c (100%) rename {signature/encryption-through-signing => pk/enc-through-sign-rsa}/README.md (100%) rename {signature/encryption-through-signing => pk/enc-through-sign-rsa}/build.sh (100%) rename {signature/encryption-through-signing => pk/enc-through-sign-rsa}/rsa-private-encrypt-app.c (100%) rename {signature/encryption-through-signing => pk/enc-through-sign-rsa}/rsa-public-decrypt-app.c (100%) rename {crypto => pk}/rsa-pss/Makefile (100%) rename {crypto => pk}/rsa-pss/README.md (100%) rename {crypto => pk}/rsa-pss/rsa-pss.c (100%) rename {crypto => pk}/rsa/Makefile (100%) rename {crypto => pk}/rsa/README.md (100%) rename {crypto => pk}/rsa/rsa-nb.c (98%) diff --git a/.gitignore b/.gitignore index 9605928e..3c5f06ea 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ *.i*86 *.x86_64 *.hex +*app # IDE Temp Files **/*.swp @@ -152,7 +153,9 @@ pkcs11/server-tls-pkcs11 pkcs11/softhsm2.conf pkcs11/softhsm2 -crypto/rsa-pss/rsa-pss -crypto/rsa-pss/rsa-public.der -crypto/rsa-pss/sign.txt -crypto/rsa/rsa-nb +pk/rsa-pss/rsa-pss +pk/rsa-pss/rsa-public.der +pk/rsa-pss/sign.txt +pk/rsa/rsa-nb + +wolfCLU/tests/somejunk/*somejunk*.txt diff --git a/signature/ED25519/Makefile b/pk/ED25519/Makefile similarity index 100% rename from signature/ED25519/Makefile rename to pk/ED25519/Makefile diff --git a/signature/ED25519/README b/pk/ED25519/README similarity index 100% rename from signature/ED25519/README rename to pk/ED25519/README diff --git a/signature/ED25519/ed_priv_test_key.der b/pk/ED25519/ed_priv_test_key.der similarity index 100% rename from signature/ED25519/ed_priv_test_key.der rename to pk/ED25519/ed_priv_test_key.der diff --git a/signature/ED25519/ed_pub_test_key.der b/pk/ED25519/ed_pub_test_key.der similarity index 100% rename from signature/ED25519/ed_pub_test_key.der rename to pk/ED25519/ed_pub_test_key.der diff --git a/signature/ED25519/gen_key_files.c b/pk/ED25519/gen_key_files.c similarity index 100% rename from signature/ED25519/gen_key_files.c rename to pk/ED25519/gen_key_files.c diff --git a/signature/ED25519/genkeybuffers.pl b/pk/ED25519/genkeybuffers.pl similarity index 100% rename from signature/ED25519/genkeybuffers.pl rename to pk/ED25519/genkeybuffers.pl diff --git a/signature/ED25519/sign_and_verify.c b/pk/ED25519/sign_and_verify.c similarity index 100% rename from signature/ED25519/sign_and_verify.c rename to pk/ED25519/sign_and_verify.c diff --git a/signature/ED25519/test_keys.h b/pk/ED25519/test_keys.h similarity index 100% rename from signature/ED25519/test_keys.h rename to pk/ED25519/test_keys.h diff --git a/crypto/keys/Makefile b/pk/ecc/Makefile similarity index 100% rename from crypto/keys/Makefile rename to pk/ecc/Makefile diff --git a/crypto/keys/README b/pk/ecc/README similarity index 100% rename from crypto/keys/README rename to pk/ecc/README diff --git a/crypto/keys/ecc_keys.c b/pk/ecc/ecc_keys.c similarity index 100% rename from crypto/keys/ecc_keys.c rename to pk/ecc/ecc_keys.c diff --git a/signature/encryption-through-signing/README.md b/pk/enc-through-sign-rsa/README.md similarity index 100% rename from signature/encryption-through-signing/README.md rename to pk/enc-through-sign-rsa/README.md diff --git a/signature/encryption-through-signing/build.sh b/pk/enc-through-sign-rsa/build.sh similarity index 100% rename from signature/encryption-through-signing/build.sh rename to pk/enc-through-sign-rsa/build.sh diff --git a/signature/encryption-through-signing/rsa-private-encrypt-app.c b/pk/enc-through-sign-rsa/rsa-private-encrypt-app.c similarity index 100% rename from signature/encryption-through-signing/rsa-private-encrypt-app.c rename to pk/enc-through-sign-rsa/rsa-private-encrypt-app.c diff --git a/signature/encryption-through-signing/rsa-public-decrypt-app.c b/pk/enc-through-sign-rsa/rsa-public-decrypt-app.c similarity index 100% rename from signature/encryption-through-signing/rsa-public-decrypt-app.c rename to pk/enc-through-sign-rsa/rsa-public-decrypt-app.c diff --git a/crypto/rsa-pss/Makefile b/pk/rsa-pss/Makefile similarity index 100% rename from crypto/rsa-pss/Makefile rename to pk/rsa-pss/Makefile diff --git a/crypto/rsa-pss/README.md b/pk/rsa-pss/README.md similarity index 100% rename from crypto/rsa-pss/README.md rename to pk/rsa-pss/README.md diff --git a/crypto/rsa-pss/rsa-pss.c b/pk/rsa-pss/rsa-pss.c similarity index 100% rename from crypto/rsa-pss/rsa-pss.c rename to pk/rsa-pss/rsa-pss.c diff --git a/crypto/rsa/Makefile b/pk/rsa/Makefile similarity index 100% rename from crypto/rsa/Makefile rename to pk/rsa/Makefile diff --git a/crypto/rsa/README.md b/pk/rsa/README.md similarity index 100% rename from crypto/rsa/README.md rename to pk/rsa/README.md diff --git a/crypto/rsa/rsa-nb.c b/pk/rsa/rsa-nb.c similarity index 98% rename from crypto/rsa/rsa-nb.c rename to pk/rsa/rsa-nb.c index 5e3f0e74..e5e27062 100644 --- a/crypto/rsa/rsa-nb.c +++ b/pk/rsa/rsa-nb.c @@ -60,7 +60,7 @@ static int load_file_to_buffer(const char* filename, byte** fileBuf, int* fileLe printf("File %s is %d bytes\n", filename, *fileLen); /* Allocate buffer for image */ - *fileBuf = malloc(*fileLen); + *fileBuf = malloc((unsigned long) *fileLen); if(!*fileBuf) { printf("File buffer malloc failed!\n"); ret = EXIT_FAILURE; @@ -68,7 +68,7 @@ static int load_file_to_buffer(const char* filename, byte** fileBuf, int* fileLe } /* Load file into buffer */ - ret = (int)fread(*fileBuf, 1, *fileLen, file); + ret = (int)fread(*fileBuf, 1, (size_t) *fileLen, file); if(ret != *fileLen) { printf("Error reading file! %d", ret); ret = EXIT_FAILURE; From 3eccfd69407dcd7bc03d8405a222494a343673ce Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Tue, 26 Feb 2019 11:20:33 -0700 Subject: [PATCH 2/2] Peer feedback on size_t vs UL and update gitignore further --- .gitignore | 12 ++++++------ pk/rsa/rsa-nb.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 3c5f06ea..775a83d9 100644 --- a/.gitignore +++ b/.gitignore @@ -80,18 +80,12 @@ android/wolfssljni-ndk-sample/proguard-project.txt crypto/3des/3des-file-encrypt crypto/aes/aes-file-encrypt crypto/camellia/camellia-encrypt -crypto/keys/ecc_keys */file-client/start-client */file-server/start-server -#Example der and x963 files -crypto/keys/*.der -crypto/keys/*.x963 signature/signature -signature/ED25519/gen_key_files -signature/ED25519/sign_and_verify #cergen certgen/test.o @@ -157,5 +151,11 @@ pk/rsa-pss/rsa-pss pk/rsa-pss/rsa-public.der pk/rsa-pss/sign.txt pk/rsa/rsa-nb +pk/ecc/ecc_keys +#Example der and x963 files +pk/ecc/*.der +pk/ecc/*.x963 +pk/ED25519/gen_key_files +pk/ED25519/sign_and_verify wolfCLU/tests/somejunk/*somejunk*.txt diff --git a/pk/rsa/rsa-nb.c b/pk/rsa/rsa-nb.c index e5e27062..9c5fa125 100644 --- a/pk/rsa/rsa-nb.c +++ b/pk/rsa/rsa-nb.c @@ -60,7 +60,7 @@ static int load_file_to_buffer(const char* filename, byte** fileBuf, int* fileLe printf("File %s is %d bytes\n", filename, *fileLen); /* Allocate buffer for image */ - *fileBuf = malloc((unsigned long) *fileLen); + *fileBuf = malloc((size_t) *fileLen); if(!*fileBuf) { printf("File buffer malloc failed!\n"); ret = EXIT_FAILURE;