Commit a10260c
committed
refactor AESNI implementations and *VECTOR_REGISTERS* macros to allow dynamic as-needed fallback to pure C, via WC_AES_C_DYNAMIC_FALLBACK.
wolfssl/wolfcrypt/aes.h: add key_C_fallback[] to struct Aes, and remove comment that "AESNI needs key first, rounds 2nd, not sure why yet" now that AES_128_Key_Expansion_AESNI no longer writes rounds after the expanded key.
wolfcrypt/src/aes.c:
* add _AESNI or _aesni suffixes/infixes to AESNI implementations that were missing them: AES_CBC_encrypt(), AES_CBC_decrypt_by*(), AES_ECB_encrypt(), AES_*_Key_Expansion(), AES_set_encrypt_key(), AES_set_decrypt_key(), AES_GCM_encrypt(), AES_GCM_decrypt(), AES_XTS_encrypt(), and AES_XTS_decrypt().
* move key size check from to start of wc_AesSetKeyLocal().
* refactor pure-C AES setkey and cipher implementations to use aes->key_C_fallback when defined(WC_AES_C_DYNAMIC_FALLBACK).
* refactor wc_AesSetKeyLocal() to set up both AESNI and pure-C expanded keys when defined(WC_AES_C_DYNAMIC_FALLBACK).
* refactor all (haveAESNI && aes->use_aesni) conditions to just (aes->use_aesni).
* add macros VECTOR_REGISTERS_PUSH and VECTOR_REGISTERS_POP, which do nothing but push a brace level when !defined(WC_AES_C_DYNAMIC_FALLBACK), but when defined(WC_AES_C_DYNAMIC_FALLBACK), they call SAVE_VECTOR_REGISTERS2() and on failure, temporarily clear aes->use_aesni and restore at _POP().
* refactor all invocations of SAVE_VECTOR_REGISTERS() and RESTORE_VECTOR_REGISTERS() to VECTOR_REGISTERS_PUSH and VECTOR_REGISTERS_POP, except in wc_AesSetKeyLocal(), wc_AesXtsEncrypt(), and wc_AesXtsDecrypt(), which are refactored to use SAVE_VECTOR_REGISTERS2(), with graceful failure concealment if defined(WC_AES_C_DYNAMIC_FALLBACK).
* orthogonalize cleanup code in wc_AesCbcEncrypt(), wc_AesCcmEncrypt() and wc_AesCcmDecrypt().
* streamline fallthrough software definitions of wc_AesEncryptDirect() and wc_AesDecryptDirect(), and remove special-casing for defined(WOLFSSL_LINUXKM)&&defined(WOLFSSL_AESNI).
wolfcrypt/src/aes_asm.{S,asm}:
* remove errant "movl $10, 240(%rsi)" from AES_128_Key_Expansion_AESNI.
* add _AESNI suffixes/infixes to implementations that needed them.
wolfcrypt/src/{aes_gcm_asm.{S,asm},aes_xts_asm.S}: regenerate from revisions in scripts#357 -- adds _aesni suffixes to implementations that were missing them.
wolfssl/wolfcrypt/types.h: remove DEBUG_VECTOR_REGISTER_ACCESS macros, and add dummy fallthrough definitions for SAVE_VECTOR_REGISTERS2 and WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL.
wolfssl/wolfcrypt/memory.h: adopt DEBUG_VECTOR_REGISTER_ACCESS code from types.h, and add definitions for WC_DEBUG_VECTOR_REGISTERS_RETVAL_INITVAL and WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL.
linuxkm/linuxkm_wc_port.h: add arch-specific macro definitions for SAVE_VECTOR_REGISTERS2().
wolfcrypt/benchmark/benchmark.c: add missing gates around calls to RESTORE_VECTOR_REGISTERS().
configure.ac:
* cover various interdependencies in enable-all/enable-all-crypto, for better behavior in combination with --disable-aesgcm, --disable-ecc, --disable-ocsp, --disable-hmac, --disable-chacha, --disable-ed25519, and --disable-ed448.
* inhibit aesgcm_stream in enable-all/enable-all-crypto when ENABLED_LINUXKM_DEFAULTS, because it is currently incompatible with WC_AES_C_DYNAMIC_FALLBACK.
* add -DWC_AES_C_DYNAMIC_FALLBACK when ENABLED_LINUXKM_DEFAULTS.
* add 3 new interdependency checks: "ECCSI requires ECC.", "SAKKE requires ECC.", "WOLFSSH requires HMAC."
wolfcrypt/src/asn.c: tweak gating to accommodate defined(NO_RSA) && !defined(HAVE_ECC).
wolfcrypt/src/evp.c: tweak gating to accommodate defined(NO_HMAC).
wolfcrypt/src/logging.c: remove DEBUG_VECTOR_REGISTER_ACCESS code (moved to memory.c).
wolfcrypt/src/memory.c: change #include of settings.h to types.h; adopt DEBUG_VECTOR_REGISTER_ACCESS code from logging.c; add implementation of SAVE_VECTOR_REGISTERS2_fuzzer().
wolfcrypt/src/pwdbased.c: add explanatory #error scrypt requires HMAC.
wolfcrypt/test/test.c:
* add DEBUG_VECTOR_REGISTER_ACCESS clauses to aes_xts_128_test(), aesecb_test(), aesctr_test(), aes_test() CBC section, aes256_test() CBC section, and aesgcm_default_test_helper()
* remove duplicate wc_AesEcbDecrypt() in aesecb_test().
* add gating for pbkdf2_test().
* fix cleanup code in dsa_test().
* fix gating in pkcs7authenveloped_run_vectors() to accommodate !defined(HAVE_AESGCM).
* fix gating in cryptocb_test() to accommodate defined(NO_HMAC).
wolfssl/wolfcrypt/cryptocb.h: remove gates around "pk" sub-struct of struct wc_CryptoInfo -- wc_CryptoInfo.pk.type (an int) is used unconditionally when --enable-debug, and is used with DH.
wolfssl/wolfcrypt/error-crypt.h: fix whitespace.1 parent e395aad commit a10260c
20 files changed
Lines changed: 1907 additions & 1318 deletions
File tree
- linuxkm
- wolfcrypt
- benchmark
- src
- test
- wolfssl/wolfcrypt
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
724 | 723 | | |
725 | 724 | | |
726 | 725 | | |
| |||
741 | 740 | | |
742 | 741 | | |
743 | 742 | | |
744 | | - | |
745 | | - | |
| 743 | + | |
| 744 | + | |
746 | 745 | | |
747 | 746 | | |
748 | 747 | | |
749 | 748 | | |
750 | 749 | | |
751 | | - | |
752 | | - | |
| 750 | + | |
| 751 | + | |
753 | 752 | | |
754 | 753 | | |
755 | 754 | | |
756 | 755 | | |
757 | 756 | | |
758 | 757 | | |
759 | | - | |
| 758 | + | |
760 | 759 | | |
761 | 760 | | |
762 | 761 | | |
| |||
771 | 770 | | |
772 | 771 | | |
773 | 772 | | |
774 | | - | |
| 773 | + | |
775 | 774 | | |
776 | 775 | | |
777 | 776 | | |
| |||
797 | 796 | | |
798 | 797 | | |
799 | 798 | | |
| 799 | + | |
800 | 800 | | |
801 | 801 | | |
802 | 802 | | |
| |||
836 | 836 | | |
837 | 837 | | |
838 | 838 | | |
839 | | - | |
| 839 | + | |
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
843 | 843 | | |
844 | 844 | | |
845 | 845 | | |
846 | 846 | | |
847 | | - | |
| 847 | + | |
848 | 848 | | |
849 | | - | |
| 849 | + | |
850 | 850 | | |
851 | 851 | | |
852 | 852 | | |
| |||
856 | 856 | | |
857 | 857 | | |
858 | 858 | | |
859 | | - | |
860 | | - | |
| 859 | + | |
| 860 | + | |
861 | 861 | | |
862 | 862 | | |
863 | 863 | | |
| |||
908 | 908 | | |
909 | 909 | | |
910 | 910 | | |
911 | | - | |
912 | 911 | | |
913 | 912 | | |
914 | 913 | | |
| |||
929 | 928 | | |
930 | 929 | | |
931 | 930 | | |
932 | | - | |
933 | | - | |
| 931 | + | |
| 932 | + | |
934 | 933 | | |
935 | 934 | | |
936 | 935 | | |
937 | 936 | | |
938 | 937 | | |
939 | | - | |
940 | | - | |
| 938 | + | |
| 939 | + | |
941 | 940 | | |
942 | 941 | | |
943 | 942 | | |
944 | 943 | | |
945 | 944 | | |
946 | 945 | | |
947 | | - | |
| 946 | + | |
948 | 947 | | |
949 | 948 | | |
950 | 949 | | |
| |||
959 | 958 | | |
960 | 959 | | |
961 | 960 | | |
962 | | - | |
| 961 | + | |
963 | 962 | | |
964 | 963 | | |
965 | 964 | | |
| |||
969 | 968 | | |
970 | 969 | | |
971 | 970 | | |
| 971 | + | |
972 | 972 | | |
973 | 973 | | |
974 | 974 | | |
| |||
983 | 983 | | |
984 | 984 | | |
985 | 985 | | |
986 | | - | |
| 986 | + | |
987 | 987 | | |
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
991 | 991 | | |
992 | | - | |
| 992 | + | |
993 | 993 | | |
994 | | - | |
| 994 | + | |
995 | 995 | | |
996 | 996 | | |
997 | 997 | | |
998 | 998 | | |
999 | | - | |
1000 | | - | |
| 999 | + | |
| 1000 | + | |
1001 | 1001 | | |
1002 | 1002 | | |
1003 | 1003 | | |
| |||
2896 | 2896 | | |
2897 | 2897 | | |
2898 | 2898 | | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
2899 | 2903 | | |
2900 | 2904 | | |
2901 | 2905 | | |
| |||
3951 | 3955 | | |
3952 | 3956 | | |
3953 | 3957 | | |
| 3958 | + | |
| 3959 | + | |
| 3960 | + | |
| 3961 | + | |
3954 | 3962 | | |
3955 | 3963 | | |
3956 | 3964 | | |
| |||
3961 | 3969 | | |
3962 | 3970 | | |
3963 | 3971 | | |
| 3972 | + | |
| 3973 | + | |
| 3974 | + | |
| 3975 | + | |
| 3976 | + | |
3964 | 3977 | | |
3965 | 3978 | | |
3966 | 3979 | | |
| |||
8926 | 8939 | | |
8927 | 8940 | | |
8928 | 8941 | | |
| 8942 | + | |
| 8943 | + | |
| 8944 | + | |
| 8945 | + | |
| 8946 | + | |
8929 | 8947 | | |
8930 | 8948 | | |
8931 | 8949 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
| |||
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
| 197 | + | |
196 | 198 | | |
197 | 199 | | |
198 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2125 | 2125 | | |
2126 | 2126 | | |
2127 | 2127 | | |
| 2128 | + | |
2128 | 2129 | | |
| 2130 | + | |
2129 | 2131 | | |
2130 | 2132 | | |
2131 | 2133 | | |
| |||
2283 | 2285 | | |
2284 | 2286 | | |
2285 | 2287 | | |
| 2288 | + | |
2286 | 2289 | | |
| 2290 | + | |
2287 | 2291 | | |
2288 | 2292 | | |
2289 | 2293 | | |
| |||
0 commit comments