Commit Graph

3664 Commits

Author SHA1 Message Date
David Garske
c0823c8a7e Refactor of AES wc_AesSetKeyLocal and wc_AesSetKey for software only use. Added missing aes argument check on wc_AesSetKeyDirect. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
453698ba27 add explanatory comments for do_div(), used when WOLFSSL_LINUXKM. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
7c2aefcfdd linuxkm: enable the rest of the _asm implementations for x86, wrapped in {SAVE,RESTORE}_VECTOR_REGISTERS(). 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
60a686f48c tidying suggested by Sean in review. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
a9cad51b65 sp_mod_word(): add unoptimized alternative if -U__GNUC__. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
fdbd6addd0 sp_int.c: add sp_mod_word() gated on WOLFSSL_SP_MOD_WORD_RP for runtimes lacking intrinsic support for int128 % int64; for linuxkm, use WOLFSSL_SP_DIV_WORD_HALF and the new WOLFSSL_SP_MOD_WORD_RP. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
43c12ede50 ge448_double_scalarmult_vartime(): streamline WOLFSSL_SMALL_STACK refactor. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
5801719ac3 wolfcrypt/src/asn.c:wc_GetKeyOID(): stack->heap refactor. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
4f5bbbdca8 rsa.c:wc_CheckProbablePrime(): WOLFSSL_SMALL_STACK refactor 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
76cba38971 wolfcrypt/src/ge_448.c: redo small stack refactor of ge448_double_scalarmult_vartime(), so that when -UWOLFSSL_SMALL_STACK, code is effectively unchanged. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
767f1972e3 aes.{c,h}: move SIMD includes from aes.h to aes.c, to avoid compiler errors on other .c's compiled -mno-sse for linuxkm. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
cd14cfb092 linuxkm: override-disable SIMD instructions for all .c.o's, with exceptions enumerated in Kbuild (currently only aes.c), and couple -msse with -fno-builtin-functions; export ENABLED_ASM for use as a pivot in Kbuild; use asm/i387.h, not asm/simd.h, for kernel_fpu_{begin,end}() protos. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
3626332334 wolfcrypt/src/aes.c for linuxkm: add missing vector register push/pops. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
360c749703 add {SAVE,RESTORE}_VECTOR_REGISTERS() macros for kernel_fpu_{begin,end} when WOLFSSL_LINUXKM, to allow safe use of AESNI and SIMD instructions in the kernel. 2020-09-23 18:32:16 -05:00
Daniel Pouzzner
3c91ce9342 wolfcrypt/src/sp_int.c: undo 8efb1142f1f2744ff128033df8a3a2d43e42fd93 to take dgarske's better wc_bigint_init()-based take on it (aa870861921a317cca9a978a75a7de127809e100). 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
c5d28c16b5 wolfcrypt/src/sp_int.c: clear whole struct in sp_init() and sp_init_multi(), to fix uninited pointer free()s in sp_free() when --enable-sp-math -DHAVE_WOLF_BIGINT. 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
ce8f2e65de wolfcrypt/src/sha256.c: undo c801de9d23c2f3348b84fdb8d893f81e6c3c2849 (dgarske has better&correct fix in 76e1760f915934bdc4911f3ae41abe6803ae094a). 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
e09487de1f sha256.c: add missing _SMALL_STACK_CACHE initialization in InitSha256(). 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
922b023aea wolfcrypt/src/random.c: rename the DRBG internal type __DRBG, because some customer is compiling libwolfssl with a "g++" override, which precludes typedefs and structs with different types but equal labels. 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
9ca94d6ca7 wolfcrypt/src/ge_448.c: refactor ge448_double_scalarmult_vartime() to use heap for workspace unless WOLFSSL_NO_MALLOC. 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
92df5692b1 wolfcrypt/src/ecc.c: revert to commit g0fa5af9, which has all the necessary fixes. 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
add78dfba9 wolfcrypt/src/sp_int.c: add _LINUXKM do_div codepaths for a couple more 64 bit divisions, in sp_div_word() and sp_mod_d(). 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
9ab1df690a wolfcrypt/src/ecc.c: fix uncompilable !WOLFSSL_SP_MATH && WOLFSSL_SMALL_STACK_CACHE implementations of ecc_key_tmp_init() and ecc_key_tmp_free() (the latter misnamed ecc_key_tmp_final()). 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
03d5a4eadd wolfcrypt/src/integer.c: mp_div_d(): refactor another 64 bit division to use do_div() when WOLFSSL_LINUXKM. 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
2591479866 linuxkm: add macros mapping malloc(), free(), and realloc() to the kernel equivalents, don't set WOLFSSL_NO_MALLOC, and reduce -Wframe-larger-than= from 256k to 64k; tweak fix for HAVE_INTEL_RDSEED conflict with WOLFSSL_LINUXKM; add clean rule to linuxkm/Makefile. 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
2bcdfce6df wolfcrypt/src/evp.c: tweak to silence gcc -Wmaybe-uninitialized. 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
0e480d1a14 Linux KM compilability cont'd: conform to C89isms (declarations before statements); iffdef WOLFSSL_LINUXKM use do_div() for long long division rather than C operator (avoids unresolvable compile-time callouts to libgcc function); misc gating and relocations for includes. 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
0f783077f8 fix stray whitespace 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
dd825d90c4 more LKM WIP: polish up the struct DRBG refactor ("struct DRBG_internal"), tweaks for buildability on 3.x kernels (now builds on 3.x, 4.x, and 5.x up to 5.8.1), move a slew of #[un]def[ines] from wc_port.h to settings.h where they belong, misc cleanup. 2020-09-23 18:32:15 -05:00
Daniel Pouzzner
3c2155f4a9 linuxkm WIP -- update for kernels 4.9.x (LTS representative) and 5.8.x (latest). 2020-09-23 18:32:15 -05:00
David Garske
6425ebb60e Linux Kernel Module support using "--enable-linuxkm". 2020-09-23 18:32:15 -05:00
toddouska
2bb8427ab2 Merge pull request #3320 from dgarske/stmcube
STM32 Cube Pack and AES GCM improvements
2020-09-23 14:39:53 -07:00
David Garske
c46301f111 Merge pull request #3328 from ejohnstown/fips-ready-fix
FIPS Ready Windows Fix
2020-09-23 12:18:23 -07:00
David Garske
ecd5a015eb Merge pull request #3317 from ejohnstown/evp-fix
EVP Fix
2020-09-23 11:10:07 -07:00
toddouska
b0998fb030 Merge pull request #3327 from SparkiDev/pkcs11_ecc
PKCS#11 fix: Generate ECC key for decrypt/sign or derive
2020-09-23 09:28:53 -07:00
toddouska
ad00cf0fc8 Merge pull request #3268 from dr-m/intel-intrinsics
Use Intel intrinsic functions for RDSEED and RDRAND
2020-09-23 09:24:47 -07:00
toddouska
2f74817e32 Merge pull request #3288 from embhorn/zd10901
Fix mp_radix_size off by 1 error
2020-09-23 09:19:02 -07:00
John Safranek
07e1baadc9 EVP Fix
Change a few missed strings to use the constant names.
2020-09-22 15:55:46 -07:00
Sean Parkinson
e539322a88 PKCS#11 fix: Generate ECC key for decrypt/sign or derive
Add debugging information to PKCS#11.
2020-09-23 08:30:22 +10:00
John Safranek
54c4258c4b FIPS Ready Windows Fix
1. Modify the WIN10 FIPS solution user_settings.h to check for a
   FIPS Ready flag and to override HAVE_FIPS_VERSION to 3 if set.
2. Removed some redundant constants from the EVP file.
2020-09-22 15:23:36 -07:00
David Garske
99d96246bd Fix for STM32 issue with some Cube HAL versions (such as F777) which could modify non-block aligned bytes in the output buffer during decrypt. For TLS these bytes are the authentication tag. Workaround is to save off the incoming expected authentication tag. ZD 10961. 2020-09-22 15:04:30 -07:00
John Safranek
87d042e37d EVP Fix
Clean up a bad guard check for AES-CTR.
2020-09-22 09:46:27 -07:00
John Safranek
fc425b74fc EVP Fix
Add a few more guard flag checks to leave out things appropriately.
2020-09-22 09:06:30 -07:00
Marko Mäkelä
99a481b28e Use Intel intrinsic functions for RDSEED and RDRAND
Starting with GCC 9 or clang 9, we can actually use <immintrin.h>
without any problems. We only have to flag such
functions where such instructions are being used.

The benefit of using intrinsic functions over inline assembler
is that the compiler is given more flexibility. In particular,
clang -fsanitize=memory (MemorySanitizer, MSAN) will not raise
bogus alarms about memory being uninitialized.

Both intrinsic functions are available starting with GCC 5 and
clang 3.8. The RDRAND wrapper is available starting with clang 3.7
via <immintrin.h>. Before GCC 9 and clang 9, the RDSEED wrapper is
not available via <immintrin.h> but via <x86intrin.h>, and only after
jumping through some hoops to enable it.
2020-09-22 09:45:46 +03:00
Takashi Kojo
83cdd1c314 fix NO_DH guard 2020-09-22 07:30:21 +09:00
John Safranek
4f8dbf4f3e EVP Fix
There are some cases when the EVP wrapper code could call strncmp with
a null pointer. This was refactored to remove this possibility.
2020-09-21 14:31:42 -07:00
toddouska
47a720bdc6 Merge pull request #3315 from SparkiDev/evp_xts
EVP XTS key length: two keys used so double length
2020-09-21 13:56:35 -07:00
toddouska
1274a01dc7 Merge pull request #3289 from dgarske/wpas_small
Fixes for building `--enable-wpas=small` with WPA Supplicant v2.7
2020-09-21 13:37:58 -07:00
Sean Parkinson
d7525f0f86 EVP XTS key length: two keys used so double length 2020-09-21 11:02:07 +10:00
David Garske
0ae9adcfd9 Add Xilinx SDK printf support. 2020-09-18 09:16:31 -07:00