* fix overallocation in WC_DECLARE_ARRAY() macro in the !WOLFSSL_SMALL_STACK path. * rename WC_INIT_ARRAY() to WC_ALLOC_ARRAY() for clarity (it doesn't initialize any memory). * rename WC_DECLARE_ARRAY_DYNAMIC_DEC(), WC_DECLARE_ARRAY_DYNAMIC_EXE(), and WC_FREE_ARRAY_DYNAMIC() to WC_DECLARE_HEAP_ARRAY(), WC_ALLOC_HEAP_ARRAY(), and WC_FREE_HEAP_ARRAY(), respectively, also for clarity, and refactor out the duplicate definitions. * add WC_ALLOC_VAR(), and move the XMALLOC() in smallstack WC_DECLARE_VAR() into it. smallstack WC_DECLARE_VAR() now initializes the pointer to NULL, like smallstack WC_DECLARE_ARRAY(), assuring all pointers are valid upon shortcircuit to cleanup for a failed allocation (see WC_ALLOC_DO_ON_FAILURE below). * add a new hook "WC_ALLOC_DO_ON_FAILURE" in WC_ALLOC_VAR(), WC_ALLOC_ARRAY(), and WC_DECLARE_ARRAY_DYNAMIC_EXE(), which is invoked when an allocation fails. by default the hook is defined to WC_DO_NOTHING. * add basic safety to WC_*_HEAP_ARRAY() by recording/detecting allocation state via idx##VAR_NAME. * add macros WC_ARRAY_OK() and WC_HEAP_ARRAY_OK() to test if allocation succeeded. * add macros WC_CALLOC_ARRAY() and WC_CALLOC_HEAP_ARRAY() which zero the objects. * add macro WC_CALLOC_VAR() which zeros the object. ED448: smallstack refactor of ge448_scalarmult_base(). src/tls.c tests/api.c wolfcrypt/test/test.c: update WC_DECLARE_VAR()s with now-required matching WC_ALLOC_VAR()s. wolfcrypt/benchmark/benchmark.c: * no functional changes in default error-free behavior. * add definition of WC_ALLOC_DO_ON_FAILURE() that prints error message, sets ret, and does goto exit. * add BENCH_NTIMES and BENCH_AGREETIMES overrideeable macros, to allow fast sanitizer runs and slow high-precision runs. * smallstack refactor of all declarations of stack arrays of the form foo[BENCH_MAX_PENDING], using WC_DECLARE_ARRAY() (35 in all). * additional smallstack refactors, using WC_DECLARE_VAR(), for bench_aesxts(), bench_ed448KeyGen(), bench_eccsi*(), and bench_sakke*(). * fixes for various unhandled error conditions around malloc failures. wolfcrypt/test/test.c: opportunistically constify several (42) static constants, moving them to the readonly data segment. linuxkm/Makefile: if ENABLED_LINUXKM_BENCHMARKS, add wolfcrypt/benchmark/benchmark.o to WOLFSSL_OBJ_FILES. linuxkm/Kbuild: enable FPU for benchmark.o, and remove enablement for module_hooks.o. linuxkm/module_hooks.c: remove inline include of benchmark.c.
wolfCrypt Test
Tool for performing cryptographic algorithm testing.
Example Output
Run on Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz.
./configure --enable-intelasm --enable-aesni --enable-sp --enable-sp-asm && make
./wolfcrypt/test/testwolfcrypt
------------------------------------------------------------------------------
wolfSSL version 4.0.0
------------------------------------------------------------------------------
error test passed!
MEMORY test passed!
base64 test passed!
asn test passed!
MD5 test passed!
SHA test passed!
SHA-224 test passed!
SHA-256 test passed!
SHA-384 test passed!
SHA-512 test passed!
SHA-3 test passed!
Hash test passed!
HMAC-MD5 test passed!
HMAC-SHA test passed!
HMAC-SHA224 test passed!
HMAC-SHA256 test passed!
HMAC-SHA384 test passed!
HMAC-SHA512 test passed!
HMAC-SHA3 test passed!
GMAC test passed!
Chacha test passed!
POLY1305 test passed!
ChaCha20-Poly1305 AEAD test passed!
AES test passed!
AES192 test passed!
AES256 test passed!
AES-GCM test passed!
RANDOM test passed!
RSA test passed!
DH test passed!
ECC test passed!
logging test passed!
mutex test passed!
memcb test passed!
Test complete
Windows Visual Studio
For building wolfCrypt test project in Visual Studio open the test.sln. For newer Visual Studio version it may prompt for a one-way upgrade. Then you may have to right-click on the solution and choose Retarget solution to update the project files for your Visual Studio version.
If you see an error about rc.exe then you'll need to update the "Target Platform Version". You can do this by right-clicking on the test project -> General -> "Target Platform Version" and changing to 8.1 (needs to match the wolfssl library project).
This solution includes the wolfSSL library project at <wolfssl-root>wolfssl.vcxproj and will compile the library, then the test project.